Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky

BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.

Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.

I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.

Steps are:

$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#                      nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format

Then manual fixups.

Depends on D32948

Differential Revision: https://phabricator.services.mozilla.com/D32949
This commit is contained in:
Emilio Cobos Álvarez
2019-05-29 06:27:04 +02:00
parent d06bb40abc
commit a3b32df884
109 changed files with 512 additions and 552 deletions

View File

@@ -116,12 +116,10 @@ bool HTMLLinkElement::HasDeferredDNSPrefetchRequest() {
return HasFlag(HTML_LINK_DNS_PREFETCH_DEFERRED);
}
nsresult HTMLLinkElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLLinkElement::BindToTree(BindContext& aContext, nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (Document* doc = GetComposedDoc()) {
@@ -136,12 +134,15 @@ nsresult HTMLLinkElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLLinkElement::BindToTree", this, update));
if (aDocument && AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
nsGkAtoms::localization, eIgnoreCase)) {
aDocument->LocalizationLinkAdded(this);
// FIXME(emilio, bug 1555947): Why does this use the uncomposed doc but the
// attribute change code the composed doc?
if (IsInUncomposedDoc() &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
OwnerDoc()->LocalizationLinkAdded(this);
}
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded"));
LinkAdded();
return rv;
}