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
Родитель 75dec50c7b
Коммит 6917a38081
109 изменённых файлов: 512 добавлений и 552 удалений

72
dom/base/BindContext.h Normal file
Просмотреть файл

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* State that is passed down to BindToTree. */
#ifndef mozilla_dom_BindContext_h__
#define mozilla_dom_BindContext_h__
#include "mozilla/Attributes.h"
#include "nsXBLBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ShadowRoot.h"
namespace mozilla {
namespace dom {
struct MOZ_STACK_CLASS BindContext final {
// Whether our subtree root is changing as a result of this operation.
bool SubtreeRootChanges() const { return mSubtreeRootChanges; }
// Returns the binding parent of the subtree to be inserted.
//
// This can be null.
Element* GetBindingParent() const { return mBindingParent; }
// This constructor should be used for regular appends to content.
//
// FIXME(emilio, bug 1555944): nsIContent::GetBindingParent() should return an
// Element*.
explicit BindContext(nsINode& aParentNode)
: mSubtreeRootChanges(true),
mBindingParent(aParentNode.IsContent()
? static_cast<Element*>(
aParentNode.AsContent()->GetBindingParent())
: nullptr) {}
// When re-binding a shadow host into a tree, we re-bind all the shadow tree
// from the root. In that case, the shadow tree contents remain within the
// same subtree root. So children should avoid doing silly things like adding
// themselves to the ShadowRoot's id table twice or what not.
//
// This constructor is only meant to be used in that situation.
explicit BindContext(ShadowRoot& aShadowRoot)
: mSubtreeRootChanges(false),
mBindingParent(aShadowRoot.Host()) {}
// This constructor is meant to be used when inserting native-anonymous
// children into a subtree.
enum ForNativeAnonymous { ForNativeAnonymous };
BindContext(Element& aParentElement, enum ForNativeAnonymous)
: mSubtreeRootChanges(true),
mBindingParent(&aParentElement) {}
// This is meant to be used to bind XBL anonymous content.
BindContext(nsXBLBinding& aBinding, Element& aParentElement)
: mSubtreeRootChanges(true),
mBindingParent(aBinding.GetBoundElement()) {}
private:
// Whether the bind operation will change the subtree root of the content
// we're binding.
const bool mSubtreeRootChanges;
Element* const mBindingParent;
};
} // namespace dom
} // namespace mozilla
#endif

Просмотреть файл

@ -15,6 +15,7 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLSlotElement.h"
#include "mozilla/dom/ShadowRoot.h"
@ -386,79 +387,77 @@ void CharacterData::ToCString(nsAString& aBuf, int32_t aOffset,
}
#endif
nsresult CharacterData::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
MOZ_ASSERT(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() || aParent.IsDocument(),
"Must have content or document parent!");
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
"Must have the same owner document");
MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
"aDocument must be current doc of aParent");
MOZ_ASSERT(!GetUncomposedDoc() && !IsInUncomposedDoc(),
"Already have a document. Unbind first!");
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParent() || aParent == GetParent(),
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_ASSERT(!GetBindingParent() || aBindingParent == GetBindingParent() ||
(!aBindingParent && aParent &&
aParent->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aBindingParent != this,
"Content must not be its own binding parent");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || aBindingParent == aParent,
MOZ_ASSERT(
!GetBindingParent() ||
aContext.GetBindingParent() == GetBindingParent() ||
(!aContext.GetBindingParent() && aParent.IsContent() &&
aParent.AsContent()->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
aContext.GetBindingParent() == &aParent,
"Native anonymous content must have its parent as its "
"own binding parent");
if (!aBindingParent && aParent) {
aBindingParent = aParent->GetBindingParent();
Element* bindingParent = aContext.GetBindingParent();
if (!bindingParent && aParent.IsContent()) {
bindingParent =
static_cast<Element*>(aParent.AsContent()->GetBindingParent());
}
// First set the binding parent
if (aBindingParent) {
if (bindingParent) {
NS_ASSERTION(IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) ||
(aParent && aParent->IsInNativeAnonymousSubtree()),
aParent.IsInNativeAnonymousSubtree(),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
ExtendedContentSlots()->mBindingParent =
aBindingParent; // Weak, so no addref happens.
if (aParent->IsInNativeAnonymousSubtree()) {
ExtendedContentSlots()->mBindingParent = bindingParent;
if (aParent.IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent->HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
if (aParent.HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent->SetMayHaveAnonymousChildren();
aParent.SetMayHaveAnonymousChildren();
}
}
if (aParent && aParent->IsInShadowTree()) {
if (aParent.IsInShadowTree()) {
ClearSubtreeRootPointer();
SetFlags(NODE_IS_IN_SHADOW_TREE);
SetIsConnected(aParent->IsInComposedDoc());
MOZ_ASSERT(aParent->GetContainingShadow());
ExtendedContentSlots()->mContainingShadow = aParent->GetContainingShadow();
SetIsConnected(aParent.IsInComposedDoc());
MOZ_ASSERT(aParent.IsContent() &&
aParent.AsContent()->GetContainingShadow());
ExtendedContentSlots()->mContainingShadow =
aParent.AsContent()->GetContainingShadow();
}
bool hadParent = !!GetParentNode();
const bool hadParent = !!GetParentNode();
// Set parent
if (aParent) {
if (!GetParent()) {
NS_ADDREF(aParent);
}
mParent = aParent;
} else {
mParent = aDocument;
mParent = &aParent;
if (!hadParent && aParent.IsContent()) {
SetParentIsContent(true);
NS_ADDREF(mParent);
}
SetParentIsContent(aParent);
MOZ_ASSERT(!!GetParent() == aParent.IsContent());
// XXXbz sXBL/XBL2 issue!
// Set document
if (aDocument) {
if (aParent.IsInUncomposedDoc()) {
// We no longer need to track the subtree pointer (and in fact we'll assert
// if we do this any later).
ClearSubtreeRootPointer();
@ -466,15 +465,17 @@ nsresult CharacterData::BindToTree(Document* aDocument, nsIContent* aParent,
// XXX See the comment in Element::BindToTree
SetIsInDocument();
SetIsConnected(true);
// FIXME(emilio): This should probably be dependent on composed doc, not
// uncomposed.
if (mText.IsBidi()) {
aDocument->SetBidiEnabled();
OwnerDoc()->SetBidiEnabled();
}
// Clear the lazy frame construction bits.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
} else if (!IsInShadowTree()) {
// If we're not in the doc and not in a shadow tree,
// update our subtree pointer.
SetSubtreeRootPointer(aParent->SubtreeRoot());
SetSubtreeRootPointer(aParent.SubtreeRoot());
}
nsNodeUtils::ParentChainChanged(this);
@ -484,11 +485,14 @@ nsresult CharacterData::BindToTree(Document* aDocument, nsIContent* aParent,
UpdateEditableState(false);
MOZ_ASSERT(aDocument == GetUncomposedDoc(), "Bound to wrong document");
MOZ_ASSERT(aParent == GetParent(), "Bound to wrong parent");
MOZ_ASSERT(aBindingParent == GetBindingParent(),
MOZ_ASSERT(OwnerDoc() == aParent.OwnerDoc(), "Bound to wrong document");
MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node");
MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(),
"Bound to wrong binding parent");
MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc());
MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc());
MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree());
MOZ_ASSERT(aParent.SubtreeRoot() == SubtreeRoot());
return NS_OK;
}

Просмотреть файл

@ -107,8 +107,7 @@ class CharacterData : public nsIContent {
}
// Implementation for nsIContent
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;

Просмотреть файл

@ -59,8 +59,7 @@ class DocumentFragment : public FragmentOrElement {
virtual bool IsNodeOfType(uint32_t aFlags) const override;
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override {
nsresult BindToTree(BindContext&, nsINode& aParent) override {
NS_ASSERTION(false, "Trying to bind a fragment to a tree");
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/Flex.h"
#include "mozilla/dom/Grid.h"
#include "mozilla/dom/ScriptLoader.h"
@ -1575,92 +1576,86 @@ void Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements) {
}
}
nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
MOZ_ASSERT((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() || aParent.IsDocument(),
"Must have content or document parent!");
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
"Must have the same owner document");
MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
"aDocument must be current doc of aParent");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParent() || aParent == GetParent(),
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_ASSERT(!GetBindingParent() || aBindingParent == GetBindingParent() ||
(!aBindingParent && aParent &&
aParent->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aBindingParent != this,
MOZ_ASSERT(
!GetBindingParent() ||
aContext.GetBindingParent() == GetBindingParent() ||
(!aContext.GetBindingParent() && aParent.IsContent() &&
aParent.AsContent()->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aContext.GetBindingParent() != this,
"Content must not be its own binding parent");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || aBindingParent == aParent,
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
aContext.GetBindingParent() == &aParent,
"Native anonymous content must have its parent as its "
"own binding parent");
MOZ_ASSERT(aBindingParent || !aParent ||
aBindingParent == aParent->GetBindingParent(),
MOZ_ASSERT(aContext.GetBindingParent() || !aParent.IsContent() ||
aContext.GetBindingParent() ==
aParent.AsContent()->GetBindingParent(),
"We should be passed the right binding parent");
#ifdef MOZ_XUL
// First set the binding parent
nsXULElement* xulElem = nsXULElement::FromNode(this);
if (xulElem) {
xulElem->SetXULBindingParent(aBindingParent);
if (nsXULElement* xulElem = nsXULElement::FromNode(this)) {
xulElem->SetXULBindingParent(aContext.GetBindingParent());
} else
#endif
{
if (aBindingParent) {
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
if (Element* bindingParent = aContext.GetBindingParent()) {
ExtendedDOMSlots()->mBindingParent = bindingParent;
}
}
const bool hadParent = !!GetParentNode();
const bool wasInShadowTree = IsInShadowTree();
NS_ASSERTION(!aBindingParent || IsRootOfNativeAnonymousSubtree() ||
NS_ASSERTION(!aContext.GetBindingParent() ||
IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) ||
(aParent && aParent->IsInNativeAnonymousSubtree()),
aParent.IsInNativeAnonymousSubtree(),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
if (aParent) {
if (aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent->HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent->SetMayHaveAnonymousChildren();
}
if (aParent->IsInShadowTree()) {
ClearSubtreeRootPointer();
SetFlags(NODE_IS_IN_SHADOW_TREE);
MOZ_ASSERT(aParent->GetContainingShadow());
ExtendedDOMSlots()->mContainingShadow = aParent->GetContainingShadow();
}
if (aParent.IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent.HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent.SetMayHaveAnonymousChildren();
}
if (aParent.IsInShadowTree()) {
ClearSubtreeRootPointer();
SetFlags(NODE_IS_IN_SHADOW_TREE);
MOZ_ASSERT(aParent.IsContent() &&
aParent.AsContent()->GetContainingShadow());
ExtendedDOMSlots()->mContainingShadow =
aParent.AsContent()->GetContainingShadow();
}
MOZ_ASSERT_IF(wasInShadowTree, IsInShadowTree());
// Now set the parent.
if (aParent) {
if (!GetParent()) {
NS_ADDREF(aParent);
}
mParent = aParent;
} else {
mParent = aDocument;
mParent = &aParent;
if (!hadParent && aParent.IsContent()) {
SetParentIsContent(true);
NS_ADDREF(mParent);
}
SetParentIsContent(aParent);
MOZ_ASSERT(!!GetParent() == aParent.IsContent());
// XXXbz sXBL/XBL2 issue!
MOZ_ASSERT(!HasAnyOfFlags(Element::kAllServoDescendantBits));
// Finally, set the document
if (aDocument) {
if (aParent.IsInUncomposedDoc()) {
// Notify XBL- & nsIAnonymousContentCreator-generated
// anonymous content that the document is changing.
// XXXbz ordering issues here? Probably not, since ChangeDocumentFor is
@ -1681,7 +1676,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// Clear the lazy frame construction bits.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
} else if (IsInShadowTree()) {
SetIsConnected(aParent->IsInComposedDoc());
SetIsConnected(aParent.IsInComposedDoc());
// We're not in a document, but we did get inserted into a shadow tree.
// Since we won't have any restyle data in the document's restyle trackers,
// don't let us get inserted with restyle bits set incorrectly.
@ -1694,7 +1689,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
} else {
// If we're not in the doc and not in a shadow tree,
// update our subtree pointer.
SetSubtreeRootPointer(aParent->SubtreeRoot());
SetSubtreeRootPointer(aParent.SubtreeRoot());
}
if (IsInComposedDoc()) {
@ -1714,7 +1709,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// because it has to happen after updating the parent pointer, but before
// recursively binding the kids.
if (IsHTMLElement()) {
SetDirOnBind(this, aParent);
SetDirOnBind(this, nsIContent::FromNode(aParent));
}
UpdateEditableState(false);
@ -1734,7 +1729,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
nsresult rv;
for (nsIContent* child = GetFirstChild(); child;
child = child->GetNextSibling()) {
rv = child->BindToTree(aDocument, this, aBindingParent);
rv = child->BindToTree(aContext, *this);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1745,7 +1740,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// Ensure we only add to the table once, in the case we move the ShadowRoot
// around.
if (HasID() && !wasInShadowTree) {
if (HasID() && aContext.SubtreeRootChanges()) {
AddToIdTable(DoGetID());
}
@ -1767,14 +1762,14 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
//
// Also, if this _is_ needed, then it's wrong and should use GetComposedDoc()
// to account for Shadow DOM.
if (aDocument && MayHaveAnimations()) {
if (aParent.IsInUncomposedDoc() && MayHaveAnimations()) {
PseudoStyleType pseudoType = GetPseudoElementType();
if ((pseudoType == PseudoStyleType::NotPseudo ||
pseudoType == PseudoStyleType::before ||
pseudoType == PseudoStyleType::after ||
pseudoType == PseudoStyleType::marker) &&
EffectSet::GetEffectSet(this, pseudoType)) {
if (nsPresContext* presContext = aDocument->GetPresContext()) {
if (nsPresContext* presContext = OwnerDoc()->GetPresContext()) {
presContext->EffectCompositor()->RequestRestyle(
this, pseudoType, EffectCompositor::RestyleType::Standard,
EffectCompositor::CascadeLevel::Animations);
@ -1785,11 +1780,14 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// XXXbz script execution during binding can trigger some of these
// postcondition asserts.... But we do want that, since things will
// generally be quite broken when that happens.
MOZ_ASSERT(aDocument == GetUncomposedDoc(), "Bound to wrong document");
MOZ_ASSERT(aParent == GetParent(), "Bound to wrong parent");
MOZ_ASSERT(aBindingParent == GetBindingParent(),
MOZ_ASSERT(OwnerDoc() == aParent.OwnerDoc(), "Bound to wrong document");
MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node");
MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(),
"Bound to wrong binding parent");
MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc());
MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc());
MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree());
MOZ_ASSERT(aParent.SubtreeRoot() == SubtreeRoot());
return NS_OK;
}

Просмотреть файл

@ -653,8 +653,7 @@ class Element : public FragmentOrElement {
void UpdateEditableState(bool aNotify) override;
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/DocumentFragment.h"
#include "ChildIterator.h"
@ -131,9 +132,10 @@ nsresult ShadowRoot::Bind() {
OwnerDoc()->AddComposedDocShadowRoot(*this);
}
BindContext context(*this);
for (nsIContent* child = GetFirstChild(); child;
child = child->GetNextSibling()) {
nsresult rv = child->BindToTree(nullptr, this, Host());
nsresult rv = child->BindToTree(context, *this);
NS_ENSURE_SUCCESS(rv, rv);
}

Просмотреть файл

@ -141,6 +141,7 @@ EXPORTS.mozilla.dom += [
'AnonymousContent.h',
'Attr.h',
'BarProps.h',
'BindContext.h',
'BodyUtil.h',
'BorrowedAttrInfo.h',
'CharacterData.h',

Просмотреть файл

@ -28,6 +28,7 @@ namespace mozilla {
class EventChainPreVisitor;
struct URLExtraData;
namespace dom {
struct BindContext;
class ShadowRoot;
class HTMLSlotElement;
} // namespace dom
@ -57,7 +58,9 @@ enum nsLinkState {
*/
class nsIContent : public nsINode {
public:
typedef mozilla::widget::IMEState IMEState;
using IMEState = mozilla::widget::IMEState;
using BindContext = mozilla::dom::BindContext;
void ConstructUbiNode(void* storage) override;
@ -85,19 +88,9 @@ class nsIContent : public nsINode {
* appended to a parent, this will be called after the node has been added to
* the parent's child list and before nsIDocumentObserver notifications for
* the addition are dispatched.
* @param aDocument The new document for the content node. May not be null
* if aParent is null. Must match the current document of
* aParent, if aParent is not null (note that
* aParent->GetUncomposedDoc() can be null, in which case
* this must also be null).
* @param aParent The new parent for the content node. May be null if the
* node is being bound as a direct child of the document.
* @param aBindingParent The new binding parent for the content node.
* This is must either be non-null if a particular
* binding parent is desired or match aParent's binding
* parent.
* @note either aDocument or aParent must be non-null. If both are null,
* this method _will_ crash.
* BindContext propagates various information down the subtree; see its
* documentation to know how to set it up.
* @param aParent The new parent node for the content node. May be a document.
* @note This method must not be called by consumers of nsIContent on a node
* that is already bound to a tree. Call UnbindFromTree first.
* @note This method will handle rebinding descendants appropriately (eg
@ -108,8 +101,7 @@ class nsIContent : public nsINode {
* TODO(emilio): Should we move to nsIContent::BindToTree most of the
* FragmentOrElement / CharacterData duplicated code?
*/
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) = 0;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) = 0;
/**
* Unbind this content node from a tree. This will set its current document

Просмотреть файл

@ -28,6 +28,7 @@
#include "mozilla/Telemetry.h"
#include "mozilla/TextEditor.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/CharacterData.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h"
@ -1223,7 +1224,6 @@ nsresult nsINode::InsertChildBefore(nsIContent* aKid,
nsMutationGuard::DidMutate();
// Do this before checking the child-count since this could cause mutations
Document* doc = GetUncomposedDoc();
mozAutoDocUpdate updateBatch(GetComposedDoc(), aNotify);
if (OwnerDoc() != aKid->OwnerDoc()) {
@ -1249,8 +1249,8 @@ nsresult nsINode::InsertChildBefore(nsIContent* aKid,
// XXXbz Do we even need this code anymore?
bool wasInNACScope = ShouldUseNACScope(aKid);
nsresult rv = aKid->BindToTree(doc, parent,
parent ? parent->GetBindingParent() : nullptr);
BindContext context(*this);
nsresult rv = aKid->BindToTree(context, *this);
if (NS_SUCCEEDED(rv) && !wasInNACScope && ShouldUseNACScope(aKid)) {
MOZ_ASSERT(ShouldUseNACScope(this),
"Why does the kid need to use an the anonymous content scope?");

Просмотреть файл

@ -1610,8 +1610,8 @@ void nsImageLoadingContent::NotifyOwnerDocumentActivityChanged() {
}
}
void nsImageLoadingContent::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
void nsImageLoadingContent::BindToTree(BindContext& aContext,
nsINode& aParent) {
// We may be getting connected, if so our image should be tracked,
if (GetOurCurrentDoc()) {
TrackImage(mCurrentRequest);

Просмотреть файл

@ -35,6 +35,7 @@ class imgRequestProxy;
namespace mozilla {
class AsyncEventDispatcher;
namespace dom {
struct BindContext;
class Document;
class Element;
} // namespace dom
@ -216,8 +217,7 @@ class nsImageLoadingContent : public nsIImageLoadingContent {
virtual mozilla::net::ReferrerPolicy GetImageReferrerPolicy();
// Subclasses are *required* to call BindToTree/UnbindFromTree.
void BindToTree(mozilla::dom::Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent);
void BindToTree(mozilla::dom::BindContext&, nsINode& aParent);
void UnbindFromTree(bool aNullParent);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);

Просмотреть файл

@ -563,15 +563,14 @@ already_AddRefed<nsIDocShell> nsObjectLoadingContent::SetupDocShell(
return docShell.forget();
}
nsresult nsObjectLoadingContent::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
if (aDocument) {
aDocument->AddPlugin(this);
nsresult nsObjectLoadingContent::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsImageLoadingContent::BindToTree(aContext, aParent);
// NOTE(emilio): Using aParent to avoid silly QI.
// FIXME(emilio): Should probably use composed doc?
if (Document* doc = aParent.GetUncomposedDoc()) {
doc->AddPlugin(this);
}
return NS_OK;
}

Просмотреть файл

@ -35,6 +35,7 @@ class nsPluginInstanceOwner;
namespace mozilla {
namespace dom {
struct BindContext;
template <typename T>
class Sequence;
struct MozPluginParameter;
@ -316,8 +317,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent,
void DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner);
nsresult BindToTree(mozilla::dom::Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent);
nsresult BindToTree(mozilla::dom::BindContext&, nsINode& aParent);
void UnbindFromTree(bool aNullParent = true);
/**

Просмотреть файл

@ -42,8 +42,7 @@ class nsAttributeTextNode final : public nsTextNode,
NS_ASSERTION(mAttrName, "Must have attr name");
}
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
@ -113,9 +112,8 @@ nsresult nsTextNode::AppendTextForNormalize(const char16_t* aBuffer,
&details);
}
nsresult nsTextNode::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = CharacterData::BindToTree(aDocument, aParent, aBindingParent);
nsresult nsTextNode::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = CharacterData::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
SetDirectionFromNewTextNode(this);
@ -194,18 +192,17 @@ nsresult NS_NewAttributeContent(nsNodeInfoManager* aNodeInfoManager,
NS_IMPL_ISUPPORTS_INHERITED(nsAttributeTextNode, nsTextNode,
nsIMutationObserver)
nsresult nsAttributeTextNode::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(
aParent && aParent->GetParent(),
"This node can't be a child of the document or of the document root");
nsresult nsAttributeTextNode::BindToTree(BindContext& aContext,
nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() && aParent.GetParent(),
"This node can't be a child of the document or of "
"the document root");
nsresult rv = nsTextNode::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsTextNode::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(!mGrandparent, "We were already bound!");
mGrandparent = aParent->GetParent()->AsElement();
mGrandparent = aParent.GetParent()->AsElement();
mGrandparent->AddMutationObserver(this);
// Note that there is no need to notify here, since we have no

Просмотреть файл

@ -46,8 +46,7 @@ class nsTextNode : public mozilla::dom::Text {
virtual already_AddRefed<CharacterData> CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength,

Просмотреть файл

@ -93,12 +93,11 @@ bool HTMLAnchorElement::HasDeferredDNSPrefetchRequest() {
return HasFlag(HTML_ANCHOR_DNS_PREFETCH_DEFERRED);
}
nsresult HTMLAnchorElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLAnchorElement::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);
// Prefetch links

Просмотреть файл

@ -43,8 +43,7 @@ class HTMLAnchorElement final : public nsGenericHTMLElement, public Link {
// DOM memory reporter participant
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;

Просмотреть файл

@ -66,11 +66,9 @@ nsDOMTokenList* HTMLAreaElement::RelList() {
return mRelList;
}
nsresult HTMLAreaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLAreaElement::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);
Document* doc = GetComposedDoc();

Просмотреть файл

@ -43,8 +43,7 @@ class HTMLAreaElement final : public nsGenericHTMLElement, public Link {
virtual void GetLinkTarget(nsAString& aTarget) override;
virtual already_AddRefed<nsIURI> GetHrefURI() const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

Просмотреть файл

@ -283,10 +283,8 @@ bool HTMLBodyElement::IsEventAttributeNameInternal(nsAtom* aName) {
aName, EventNameType_HTML | EventNameType_HTMLBodyOrFramesetOnly);
}
nsresult HTMLBodyElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLBodyElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
return mAttrs.ForceMapped(this, OwnerDoc());
}

Просмотреть файл

@ -100,8 +100,7 @@ class HTMLBodyElement final : public nsGenericHTMLElement {
virtual bool IsEventAttributeNameInternal(nsAtom* aName) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
/**
* Called when an attribute has just been changed
*/

Просмотреть файл

@ -287,10 +287,10 @@ nsresult HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
return rv;
}
nsresult HTMLButtonElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLButtonElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Update our state; we may now be the default submit element

Просмотреть файл

@ -60,8 +60,7 @@ class HTMLButtonElement final : public nsGenericHTMLFormElementWithState,
JS::Handle<JSObject*> aGivenProto) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual void DoneCreatingElement() override;

Просмотреть файл

@ -73,20 +73,20 @@ void HTMLEmbedElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) {
nsImageLoadingContent::AsyncEventRunning(aEvent);
}
nsresult HTMLEmbedElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLEmbedElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
rv = nsObjectLoadingContent::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Don't kick off load from being bound to a plugin document - the plugin
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
// initial load.
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
//
// FIXME(emilio): Seems a bit wasteful to add the runnable unconditionally
// otherwise?
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(GetUncomposedDoc());
if (!pluginDoc) {
void (HTMLEmbedElement::*start)() = &HTMLEmbedElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(

Просмотреть файл

@ -36,8 +36,7 @@ class HTMLEmbedElement final : public nsGenericHTMLElement,
// EventTarget
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,

Просмотреть файл

@ -251,13 +251,11 @@ bool HTMLFormElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
aMaybeScriptedPrincipal, aResult);
}
nsresult HTMLFormElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLFormElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(GetUncomposedDoc()));
if (htmlDoc) {
htmlDoc->AddedForm();
}

Просмотреть файл

@ -94,8 +94,7 @@ class HTMLFormElement final : public nsGenericHTMLElement,
void WillHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

Просмотреть файл

@ -65,10 +65,9 @@ HTMLIFrameElement::~HTMLIFrameElement() {}
NS_IMPL_ELEMENT_CLONE(HTMLIFrameElement)
nsresult HTMLIFrameElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFrameElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLIFrameElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFrameElement::BindToTree(aContext, aParent);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -34,8 +34,7 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
}
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,

Просмотреть файл

@ -491,17 +491,13 @@ bool HTMLImageElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
return false;
}
nsresult HTMLImageElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (aParent) {
UpdateFormOwner();
}
UpdateFormOwner();
if (HaveSrcsetOrInPicture()) {
Document* doc = GetComposedDoc();

Просмотреть файл

@ -73,8 +73,7 @@ class HTMLImageElement final : public nsGenericHTMLElement,
bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual EventStates IntrinsicState() const override;

Просмотреть файл

@ -4265,13 +4265,12 @@ void HTMLInputElement::MaybeLoadImage() {
}
}
nsresult HTMLInputElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLInputElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (mType == NS_FORM_INPUT_IMAGE) {
// Our base URI may have changed; claim that our URI changed, and the

Просмотреть файл

@ -200,8 +200,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
MOZ_CAN_RUN_SCRIPT
void SetValueOfRangeForUserEvent(Decimal aValue);
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY

Просмотреть файл

@ -57,9 +57,9 @@ nsChangeHint HTMLLegendElement::GetAttributeChangeHint(const nsAtom* aAttribute,
return retval;
}
nsresult HTMLLegendElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
return nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLLegendElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
return nsGenericHTMLElement::BindToTree(aContext, aParent);
}
void HTMLLegendElement::UnbindFromTree(bool aNullParent) {

Просмотреть файл

@ -30,8 +30,7 @@ class HTMLLegendElement final : public nsGenericHTMLElement {
bool aIsTrustedEvent) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -48,8 +48,7 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
JS::Handle<JSObject*> aGivenProto) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

Просмотреть файл

@ -46,11 +46,9 @@ JSObject* HTMLMarqueeElement::WrapNode(JSContext* aCx,
return dom::HTMLMarqueeElement_Binding::Wrap(aCx, this, aGivenProto);
}
nsresult HTMLMarqueeElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMarqueeElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (IsInComposedDoc()) {

Просмотреть файл

@ -17,8 +17,7 @@ class HTMLMarqueeElement final : public nsGenericHTMLElement {
explicit HTMLMarqueeElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
: nsGenericHTMLElement(std::move(aNodeInfo)) {}
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;
static const int kDefaultLoop = -1;

Просмотреть файл

@ -4066,10 +4066,8 @@ void HTMLMediaElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
}
}
nsresult HTMLMediaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMediaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
if (IsInComposedDoc()) {
// Construct Shadow Root so web content can be hidden in the DOM.
@ -4077,9 +4075,11 @@ nsresult HTMLMediaElement::BindToTree(Document* aDocument, nsIContent* aParent,
NotifyUAWidgetSetupOrChange();
}
// FIXME(emilio, bug 1555946): mUnboundFromTree doesn't make any sense, should
// just use IsInComposedDoc() in the relevant places or something.
mUnboundFromTree = false;
if (aDocument) {
if (IsInUncomposedDoc()) {
// The preload action depends on the value of the autoplay attribute.
// It's value may have changed, so update it.
UpdatePreloadAction();
@ -5679,8 +5679,7 @@ bool HTMLMediaElement::IsActive() const {
}
bool HTMLMediaElement::IsHidden() const {
Document* ownerDoc;
return mUnboundFromTree || !(ownerDoc = OwnerDoc()) || ownerDoc->Hidden();
return mUnboundFromTree || OwnerDoc()->Hidden();
}
VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer() {

Просмотреть файл

@ -34,7 +34,6 @@
# undef CurrentTime
#endif
// Define to output information on decoding and painting framerate
/* #define DEBUG_FRAME_RATE 1 */
@ -148,8 +147,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual void DoneCreatingElement() override;

Просмотреть файл

@ -269,13 +269,12 @@ nsresult HTMLMenuItemElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
return NS_OK;
}
nsresult HTMLMenuItemElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMenuItemElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_SUCCEEDED(rv) && aDocument && mType == CMD_TYPE_RADIO) {
if (IsInUncomposedDoc() && mType == CMD_TYPE_RADIO) {
AddedToRadioGroup();
}

Просмотреть файл

@ -34,8 +34,7 @@ class HTMLMenuItemElement final : public nsGenericHTMLElement {
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLMetaElement.h"
#include "mozilla/dom/HTMLMetaElementBinding.h"
#include "mozilla/dom/nsCSPService.h"
@ -70,25 +71,26 @@ nsresult HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
aNameSpaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
}
nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMetaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument && AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
Document* document = GetUncomposedDoc();
if (!document) {
return rv;
}
if (AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport,
eIgnoreCase)) {
nsAutoString content;
GetContent(content);
nsContentUtils::ProcessViewportInfo(aDocument, content);
nsContentUtils::ProcessViewportInfo(document, content);
}
if (StaticPrefs::security_csp_enable() && aDocument &&
!aDocument->IsLoadedAsData() &&
if (StaticPrefs::security_csp_enable() && !document->IsLoadedAsData() &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::httpEquiv, nsGkAtoms::headerCSP,
eIgnoreCase)) {
// only accept <meta http-equiv="Content-Security-Policy" content=""> if it
// appears in the <head> element.
Element* headElt = aDocument->GetHeadElement();
Element* headElt = document->GetHeadElement();
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
nsAutoString content;
GetContent(content);
@ -96,11 +98,10 @@ nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
content);
nsCOMPtr<nsIContentSecurityPolicy> csp = aDocument->GetCsp();
if (csp) {
if (nsCOMPtr<nsIContentSecurityPolicy> csp = document->GetCsp()) {
if (LOG_ENABLED()) {
nsAutoCString documentURIspec;
nsIURI* documentURI = aDocument->GetDocumentURI();
nsIURI* documentURI = document->GetDocumentURI();
if (documentURI) {
documentURI->GetAsciiSpec(documentURIspec);
}
@ -108,7 +109,7 @@ nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
LOG(
("HTMLMetaElement %p sets CSP '%s' on document=%p, "
"document-uri=%s",
this, NS_ConvertUTF16toUTF8(content).get(), aDocument,
this, NS_ConvertUTF16toUTF8(content).get(), document,
documentURIspec.get()));
}
@ -120,19 +121,18 @@ nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
false, // csp via meta tag can not be report only
true); // delivered through the meta tag
NS_ENSURE_SUCCESS(rv, rv);
nsPIDOMWindowInner* inner = aDocument->GetInnerWindow();
if (inner) {
if (nsPIDOMWindowInner* inner = document->GetInnerWindow()) {
inner->SetCsp(csp);
}
aDocument->ApplySettingsFromCSP(false);
document->ApplySettingsFromCSP(false);
}
}
}
// Referrer Policy spec requires a <meta name="referrer" tag to be in the
// <head> element.
SetMetaReferrer(aDocument);
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMMetaAdded"));
SetMetaReferrer(document);
CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaAdded"));
return rv;
}

Просмотреть файл

@ -21,8 +21,7 @@ class HTMLMetaElement final : public nsGenericHTMLElement {
// nsISupports
NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMetaElement, nsGenericHTMLElement)
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EventStates.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLFormSubmission.h"
#include "mozilla/dom/HTMLObjectElement.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
@ -196,20 +197,21 @@ HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
#endif // #ifdef XP_MACOSX
nsresult HTMLObjectElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFormElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLObjectElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFormElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
rv = nsObjectLoadingContent::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Don't kick off load from being bound to a plugin document - the plugin
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
// initial load.
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
//
// FIXME(emilio): Seems wasteful to queue the runnable unconditionally
// otherwise.
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(GetUncomposedDoc());
// If we already have all the children, start the load.
if (mIsDoneAddingChildren && !pluginDoc) {
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;

Просмотреть файл

@ -52,8 +52,7 @@ class HTMLObjectElement final : public nsGenericHTMLFormElement,
// EventTarget
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,

Просмотреть файл

@ -243,10 +243,9 @@ void HTMLOptionElement::SetText(const nsAString& aText, ErrorResult& aRv) {
aRv = nsContentUtils::SetNodeTextContent(this, aText, true);
}
nsresult HTMLOptionElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLOptionElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Our new parent might change :disabled/:enabled state.

Просмотреть файл

@ -65,8 +65,7 @@ class HTMLOptionElement final : public nsGenericHTMLElement {
*/
void UpdateDisabledState(bool aNotify);
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
// nsIContent

Просмотреть файл

@ -100,10 +100,9 @@ EventStates HTMLOutputElement::IntrinsicState() const {
return states;
}
nsresult HTMLOutputElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFormElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLOutputElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFormElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Unfortunately, we can actually end up having to change our state

Просмотреть файл

@ -45,8 +45,7 @@ class HTMLOutputElement final : public nsGenericHTMLFormElement,
EventStates IntrinsicState() const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
// This function is called when a callback function from nsIMutationObserver
// has to be used to update the defaultValue attribute.

Просмотреть файл

@ -47,10 +47,9 @@ NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement,
nsIScriptLoaderObserver, nsIScriptElement,
nsIMutationObserver)
nsresult HTMLScriptElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (GetComposedDoc()) {

Просмотреть файл

@ -39,8 +39,7 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
virtual mozilla::net::ReferrerPolicy GetReferrerPolicy() override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,

Просмотреть файл

@ -1003,10 +1003,10 @@ bool HTMLSelectElement::SelectSomething(bool aNotify) {
return false;
}
nsresult HTMLSelectElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLSelectElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// If there is a disabled fieldset in the parent chain, the element is now

Просмотреть файл

@ -268,8 +268,7 @@ class HTMLSelectElement final : public nsGenericHTMLFormElementWithState,
/**
* Called when an attribute is about to be changed
*/
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

Просмотреть файл

@ -224,20 +224,19 @@ nsresult HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
}
nsresult HTMLSharedElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLSharedElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// The document stores a pointer to its base URI and base target, which we may
// need to update here.
if (mNodeInfo->Equals(nsGkAtoms::base) && aDocument) {
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
SetBaseURIUsingFirstBaseWithHref(aDocument, this);
SetBaseURIUsingFirstBaseWithHref(OwnerDoc(), this);
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
SetBaseTargetUsingFirstBaseWithTarget(aDocument, this);
SetBaseTargetUsingFirstBaseWithTarget(OwnerDoc(), this);
}
}

Просмотреть файл

@ -36,8 +36,7 @@ class HTMLSharedElement final : public nsGenericHTMLElement {
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;

Просмотреть файл

@ -39,12 +39,10 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLSlotElement)
nsresult HTMLSlotElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLSlotElement::BindToTree(BindContext& aContext, nsINode& aParent) {
RefPtr<ShadowRoot> oldContainingShadow = GetContainingShadow();
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
ShadowRoot* containingShadow = GetContainingShadow();

Просмотреть файл

@ -27,8 +27,7 @@ class HTMLSlotElement final : public nsGenericHTMLElement {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,

Просмотреть файл

@ -124,13 +124,12 @@ nsresult HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
aNameSpaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
}
nsresult HTMLSourceElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLSourceElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (auto* media = HTMLMediaElement::FromNodeOrNull(aParent)) {
if (auto* media = HTMLMediaElement::FromNode(aParent)) {
media->NotifyAddedSource();
}

Просмотреть файл

@ -34,8 +34,7 @@ class HTMLSourceElement final : public nsGenericHTMLElement {
// Override BindToTree() so that we can trigger a load when we add a
// child source element.
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
// If this element's media attr matches for its owner document. Returns true
// if no media attr was set.

Просмотреть файл

@ -81,10 +81,8 @@ void HTMLStyleElement::ContentChanged(nsIContent* aContent) {
}
}
nsresult HTMLStyleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLStyleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
void (HTMLStyleElement::*update)() =

Просмотреть файл

@ -38,8 +38,7 @@ class HTMLStyleElement final : public nsGenericHTMLElement,
nsIPrincipal* aSubjectPrincipal,
mozilla::ErrorResult& aError) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,

Просмотреть файл

@ -1023,11 +1023,9 @@ void HTMLTableElement::ReleaseInheritedAttributes() {
NS_IF_RELEASE(mTableInheritedAttributes);
}
nsresult HTMLTableElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLTableElement::BindToTree(BindContext& aContext, nsINode& aParent) {
ReleaseInheritedAttributes();
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
BuildInheritedAttributes();
return NS_OK;

Просмотреть файл

@ -157,8 +157,7 @@ class HTMLTableElement final : public nsGenericHTMLElement {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
/**
* Called when an attribute is about to be changed

Просмотреть файл

@ -781,11 +781,10 @@ EventStates HTMLTextAreaElement::IntrinsicState() const {
return state;
}
nsresult HTMLTextAreaElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLTextAreaElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// If there is a disabled fieldset in the parent chain, the element is now

Просмотреть файл

@ -106,8 +106,7 @@ class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
NS_IMETHOD_(bool) HasCachedSelection() override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

Просмотреть файл

@ -63,11 +63,9 @@ void HTMLTitleElement::ContentRemoved(nsIContent* aChild,
SendTitleChangeEvent(false);
}
nsresult HTMLTitleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLTitleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
// Let this fall through.
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
SendTitleChangeEvent(true);

Просмотреть файл

@ -39,8 +39,7 @@ class HTMLTitleElement final : public nsGenericHTMLElement,
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;

Просмотреть файл

@ -378,14 +378,12 @@ void HTMLTrackElement::LoadResource(RefPtr<WebVTTListener>&& aWebVTTListener) {
doc->Dispatch(TaskCategory::Other, runnable.forget());
}
nsresult HTMLTrackElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLTrackElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
LOG("Track Element bound to tree.");
auto* parent = HTMLMediaElement::FromNodeOrNull(aParent);
auto* parent = HTMLMediaElement::FromNode(aParent);
if (!parent) {
return NS_OK;
}

Просмотреть файл

@ -83,8 +83,7 @@ class HTMLTrackElement final : public nsGenericHTMLElement {
// Override BindToTree() so that we can trigger a load when we become
// the child of a media element.
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,

Просмотреть файл

@ -417,25 +417,20 @@ EventStates nsGenericHTMLElement::IntrinsicState() const {
return state;
}
nsresult nsGenericHTMLElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult nsGenericHTMLElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
if (Document* doc = GetUncomposedDoc()) {
RegAccessKey();
if (HasName() && CanHaveName(NodeInfo()->NameAtom())) {
aDocument->AddToNameTable(this,
GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
doc->AddToNameTable(this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
}
}
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue &&
IsInComposedDoc()) {
Document* doc = GetComposedDoc();
if (doc) {
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue) {
if (Document* doc = GetComposedDoc()) {
doc->ChangeContentEditableCount(this, +1);
}
}
@ -1593,11 +1588,9 @@ nsIContent::IMEState nsGenericHTMLFormElement::GetDesiredIMEState() {
return state;
}
nsresult nsGenericHTMLFormElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult nsGenericHTMLFormElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// An autofocus event has to be launched if the autofocus attribute is
@ -1605,8 +1598,8 @@ nsresult nsGenericHTMLFormElement::BindToTree(Document* aDocument,
// the document should not be already loaded and the "browser.autofocus"
// preference should be 'true'.
if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) &&
StaticPrefs::browser_autofocus() && aDocument) {
aDocument->SetAutoFocusElement(this);
StaticPrefs::browser_autofocus() && IsInUncomposedDoc()) {
OwnerDoc()->SetAutoFocusElement(this);
}
// If @form is set, the element *has* to be in a composed document, otherwise
@ -1616,7 +1609,7 @@ nsresult nsGenericHTMLFormElement::BindToTree(Document* aDocument,
// We should not call UpdateFormOwner if none of these conditions are
// fulfilled.
if (HasAttr(kNameSpaceID_None, nsGkAtoms::form) ? IsInComposedDoc()
: !!aParent) {
: aParent.IsContent()) {
UpdateFormOwner(true, nullptr);
}

Просмотреть файл

@ -240,8 +240,7 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
public:
// Implementation for nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsFocusableInternal(int32_t* aTabIndex,
@ -932,8 +931,7 @@ class nsGenericHTMLFormElement : public nsGenericHTMLElement,
virtual bool AllowDrop() override { return true; }
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual IMEState GetDesiredIMEState() override;
virtual mozilla::EventStates IntrinsicState() const override;

Просмотреть файл

@ -213,11 +213,9 @@ void nsGenericHTMLFrameElement::LoadSrc() {
mFrameLoader->LoadFrame(origSrc);
}
nsresult nsGenericHTMLFrameElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult nsGenericHTMLFrameElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (IsInComposedDoc()) {

Просмотреть файл

@ -63,8 +63,7 @@ class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
// nsIContent
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual void DestroyContent() override;

Просмотреть файл

@ -73,16 +73,16 @@ nsMathMLElement::nsMathMLElement(
ALLOW_THIS_IN_INITIALIZER_LIST(Link(this)),
mIncrementScriptLevel(false) {}
nsresult nsMathMLElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult nsMathMLElement::BindToTree(BindContext& aContext, nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv =
nsMathMLElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsMathMLElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
aDocument->RegisterPendingLinkUpdate(this);
// FIXME(emilio): Probably should be composed, this uses all the other link
// infrastructure.
if (Document* doc = GetUncomposedDoc()) {
doc->RegisterPendingLinkUpdate(this);
}
// Set the bit in the document for telemetry.

Просмотреть файл

@ -35,8 +35,7 @@ class nsMathMLElement final : public nsMathMLElementBase,
// Implementation of nsISupports is inherited from nsMathMLElementBase
NS_DECL_ISUPPORTS_INHERITED
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,

Просмотреть файл

@ -154,11 +154,10 @@ void SVGAElement::SetText(const nsAString& aText, mozilla::ErrorResult& rv) {
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGAElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult SVGAElement::BindToTree(BindContext& aContext, nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv = SVGAElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = SVGAElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
Document* doc = GetComposedDoc();

Просмотреть файл

@ -47,8 +47,7 @@ class SVGAElement final : public SVGAElementBase, public Link {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
virtual int32_t TabIndexDefault() override;

Просмотреть файл

@ -131,19 +131,16 @@ float SVGAnimationElement::GetSimpleDuration(ErrorResult& rv) {
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGAnimationElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult SVGAnimationElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
MOZ_ASSERT(!mHrefTarget.get(),
"Shouldn't have href-target yet (or it should've been cleared)");
nsresult rv =
SVGAnimationElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = SVGAnimationElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Add myself to the animation controller's master set of animation elements.
if (Document* doc = GetComposedDoc()) {
SMILAnimationController* controller = doc->GetAnimationController();
if (controller) {
if (SMILAnimationController* controller = doc->GetAnimationController()) {
controller->RegisterAnimationElement(this);
}
const nsAttrValue* href =

Просмотреть файл

@ -35,8 +35,7 @@ class SVGAnimationElement : public SVGAnimationElementBase, public SVGTests {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
// nsIContent specializations
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual bool IsNodeOfType(uint32_t aFlags) const override;

Просмотреть файл

@ -227,9 +227,8 @@ nsresult SVGElement::Init() {
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = SVGElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = SVGElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (!MayHaveStyle()) {

Просмотреть файл

@ -83,8 +83,7 @@ class SVGElement : public SVGElementBase // nsIContent
// nsIContent interface methods
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
int32_t aModType) const override;

Просмотреть файл

@ -132,13 +132,12 @@ void SVGFEImageElement::MaybeLoadSVGImage() {
}
}
nsresult SVGFEImageElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
SVGFEImageElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGFEImageElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = SVGFEImageElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (mStringAttributes[HREF].IsExplicitlySet() ||
mStringAttributes[XLINK_HREF].IsExplicitlySet()) {

Просмотреть файл

@ -65,8 +65,7 @@ class SVGFEImageElement final : public SVGFEImageElementBase,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual EventStates IntrinsicState() const override;

Просмотреть файл

@ -203,13 +203,11 @@ void SVGImageElement::MaybeLoadSVGImage() {
}
}
nsresult SVGImageElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
SVGImageElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = SVGImageElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (mStringAttributes[HREF].IsExplicitlySet() ||
mStringAttributes[XLINK_HREF].IsExplicitlySet()) {

Просмотреть файл

@ -56,8 +56,7 @@ class SVGImageElement : public SVGImageElementBase,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual EventStates IntrinsicState() const override;

Просмотреть файл

@ -69,12 +69,10 @@ already_AddRefed<DOMSVGAnimatedString> SVGMPathElement::Href() {
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGMPathElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult SVGMPathElement::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(!mPathTracker.get(),
"Shouldn't have href-target yet (or it should've been cleared)");
nsresult rv =
SVGMPathElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = SVGMPathElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (IsInComposedDoc()) {
@ -83,7 +81,8 @@ nsresult SVGMPathElement::BindToTree(Document* aDocument, nsIContent* aParent,
? mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_None)
: mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
if (hrefAttrValue) {
UpdateHrefTarget(aParent, hrefAttrValue->GetStringValue());
UpdateHrefTarget(nsIContent::FromNode(aParent),
hrefAttrValue->GetStringValue());
}
}

Просмотреть файл

@ -44,8 +44,7 @@ class SVGMPathElement final : public SVGMPathElementBase,
// nsIContent interface
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
// Element specializations

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/dom/SVGSVGElement.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/SVGSVGElementBinding.h"
#include "mozilla/dom/SVGMatrix.h"
#include "mozilla/dom/SVGRect.h"
@ -366,15 +367,15 @@ SMILTimeContainer* SVGSVGElement::GetTimedDocumentRoot() {
}
//----------------------------------------------------------------------
// SVGElement
nsresult SVGSVGElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult SVGSVGElement::BindToTree(BindContext& aContext, nsINode& aParent) {
SMILAnimationController* smilController = nullptr;
if (aDocument) {
smilController = aDocument->GetAnimationController();
if (smilController) {
// NOTE(emilio): Using aParent because we still haven't called our base class.
// FIXME(emilio, bug 1555948): Should probably use IsInComposedDoc()?
if (aParent.IsInUncomposedDoc()) {
if ((smilController = OwnerDoc()->GetAnimationController())) {
// SMIL is enabled in this document
if (WillBeOutermostSVG(aParent, aBindingParent)) {
if (WillBeOutermostSVG(aParent, aContext.GetBindingParent())) {
// We'll be the outermost <svg> element. We'll need a time container.
if (!mTimedDocumentRoot) {
mTimedDocumentRoot = new SMILTimeContainer();
@ -389,8 +390,7 @@ nsresult SVGSVGElement::BindToTree(Document* aDocument, nsIContent* aParent,
}
}
nsresult rv =
SVGGraphicsElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = SVGGraphicsElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (mTimedDocumentRoot && smilController) {
@ -485,9 +485,9 @@ void SVGSVGElement::FlushImageTransformInvalidation() {
//----------------------------------------------------------------------
// implementation helpers
bool SVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
nsIContent* aBindingParent) const {
nsIContent* parent = aBindingParent ? aBindingParent : aParent;
bool SVGSVGElement::WillBeOutermostSVG(nsINode& aParent,
Element* aBindingParent) const {
nsINode* parent = aBindingParent ? aBindingParent : &aParent;
while (parent && parent->IsSVGElement()) {
if (parent->IsSVGElement(nsGkAtoms::foreignObject)) {

Просмотреть файл

@ -147,8 +147,7 @@ class SVGSVGElement final : public SVGSVGElementBase {
// SVGElement overrides
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual SVGAnimatedTransformList* GetAnimatedTransformList(
uint32_t aFlags = 0) override;
@ -197,8 +196,7 @@ class SVGSVGElement final : public SVGSVGElementBase {
* basically a simplified version of GetOwnerSVGElement that uses the parent
* parameters passed in instead.
*/
bool WillBeOutermostSVG(nsIContent* aParent,
nsIContent* aBindingParent) const;
bool WillBeOutermostSVG(nsINode& aParent, Element* aBindingParent) const;
// invalidate viewbox -> viewport xform & inform frames
void InvalidateTransformNotifyFrame();

Просмотреть файл

@ -180,13 +180,12 @@ SVGElement::StringAttributesInfo SVGScriptElement::GetStringInfo() {
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGScriptElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
SVGScriptElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGScriptElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = SVGScriptElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
// FIXME(emilio, bug 1555949): Should be IsInComposedDoc().
if (IsInUncomposedDoc()) {
MaybeProcessScript();
}

Просмотреть файл

@ -50,8 +50,7 @@ class SVGScriptElement final : public SVGScriptElementBase,
virtual bool HasScriptContent() override;
// nsIContent specializations:
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,

Просмотреть файл

@ -58,10 +58,8 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement)
//----------------------------------------------------------------------
// nsIContent methods
nsresult SVGStyleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
SVGStyleElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGStyleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = SVGStyleElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
void (SVGStyleElement::*update)() =

Просмотреть файл

@ -40,8 +40,7 @@ class SVGStyleElement final : public SVGStyleElementBase,
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement, SVGStyleElementBase)
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,

Просмотреть файл

@ -50,11 +50,9 @@ void SVGTitleElement::ContentRemoved(nsIContent* aChild,
SendTitleChangeEvent(false);
}
nsresult SVGTitleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult SVGTitleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
// Let this fall through.
nsresult rv =
SVGTitleElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = SVGTitleElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
SendTitleChangeEvent(true);

Просмотреть файл

@ -44,8 +44,7 @@ class SVGTitleElement final : public SVGTitleElementBase,
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;

Просмотреть файл

@ -149,10 +149,8 @@ nsresult SVGUseElement::Clone(dom::NodeInfo* aNodeInfo,
return NS_FAILED(rv1) ? rv1 : rv2;
}
nsresult SVGUseElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
SVGUseElementBase::BindToTree(aDocument, aParent, aBindingParent);
nsresult SVGUseElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = SVGUseElementBase::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
TriggerReclone();

Просмотреть файл

@ -49,8 +49,7 @@ class SVGUseElement final : public SVGUseElementBase,
public:
NS_IMPL_FROMNODE_WITH_TAG(SVGUseElement, kNameSpaceID_SVG, use)
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;
// interfaces:

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше