Bug 1596199 - Devirtualize GetBindingParent. r=bzbarsky

The amount of XUL elements with non-null binding-parent pointer should be
equivalent to HTML now that XBL is gone.

Shadow DOM already has the extended slots for both the binding parent and
containing shadow root.

Differential Revision: https://phabricator.services.mozilla.com/D52901

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-11-13 20:35:15 +00:00
Родитель e2c243ba4f
Коммит 32fdd189d1
4 изменённых файлов: 7 добавлений и 50 удалений

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

@ -1477,16 +1477,9 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
aParent.AsContent()->GetBindingParent(),
"We should be passed the right binding parent");
#ifdef MOZ_XUL
// First set the binding parent
if (nsXULElement* xulElem = nsXULElement::FromNode(this)) {
xulElem->SetXULBindingParent(aContext.GetBindingParent());
} else
#endif
{
if (Element* bindingParent = aContext.GetBindingParent()) {
ExtendedDOMSlots()->mBindingParent = bindingParent;
}
if (Element* bindingParent = aContext.GetBindingParent()) {
ExtendedDOMSlots()->mBindingParent = bindingParent;
}
const bool hadParent = !!GetParentNode();
@ -1771,19 +1764,8 @@ void Element::UnbindFromTree(bool aNullParent) {
SetSubtreeRootPointer(aNullParent ? this : mParent->SubtreeRoot());
}
bool clearBindingParent = true;
#ifdef MOZ_XUL
if (nsXULElement* xulElem = nsXULElement::FromNode(this)) {
xulElem->SetXULBindingParent(nullptr);
clearBindingParent = false;
}
#endif
if (nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots()) {
if (clearBindingParent) {
slots->mBindingParent = nullptr;
}
slots->mBindingParent = nullptr;
if (aNullParent || !mParent->IsInShadowTree()) {
slots->mContainingShadow = nullptr;
}

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

@ -382,14 +382,14 @@ class nsIContent : public nsINode {
/**
* Gets content node with the binding (or native code, possibly on the
* frame) responsible for our construction (and existence). Used by
* anonymous content (both XBL-generated and native-anonymous).
* native-anonymous content and shadow DOM.
*
* null for all explicit content (i.e., content reachable from the top
* of its GetParent() chain via child lists).
*
* @return the binding parent
*/
virtual mozilla::dom::Element* GetBindingParent() const {
mozilla::dom::Element* GetBindingParent() const {
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
return slots ? slots->mBindingParent.get() : nullptr;
}

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

@ -103,7 +103,7 @@ uint32_t nsXULPrototypeAttribute::gNumCacheFills;
//
nsXULElement::nsXULElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: nsStyledElement(std::move(aNodeInfo)), mBindingParent(nullptr) {
: nsStyledElement(std::move(aNodeInfo)) {
XUL_PROTOTYPE_ATTRIBUTE_METER(gNumElements);
}
@ -271,17 +271,7 @@ void NS_TrustedNewXULElement(
//----------------------------------------------------------------------
// nsISupports interface
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULElement, nsStyledElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBindingParent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULElement, nsStyledElement)
// Why aren't we unlinking the prototype?
tmp->ClearHasID();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBindingParent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsXULElement, nsStyledElement)
NS_IMPL_ADDREF_INHERITED(nsXULElement, nsStyledElement)
NS_IMPL_RELEASE_INHERITED(nsXULElement, nsStyledElement)

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

@ -349,8 +349,6 @@ class nsXULElement : public nsStyledElement {
bool aIsTrustedEvent) override;
void ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent);
Element* GetBindingParent() const final { return mBindingParent; }
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual bool IsFocusableInternal(int32_t* aTabIndex,
bool aWithMouse) override;
@ -364,13 +362,6 @@ class nsXULElement : public nsStyledElement {
virtual void RecompileScriptEventListeners() override;
// This function should ONLY be used by BindToTree implementations.
// The function exists solely because XUL elements store the binding
// parent as a member instead of in the slots, as Element does.
void SetXULBindingParent(Element* aBindingParent) {
mBindingParent = aBindingParent;
}
virtual bool IsEventAttributeNameInternal(nsAtom* aName) override;
typedef mozilla::dom::DOMString DOMString;
@ -532,12 +523,6 @@ class nsXULElement : public nsStyledElement {
nsresult AddPopupListener(nsAtom* aName);
/**
* The nearest enclosing content node with a binding
* that created us.
*/
RefPtr<Element> mBindingParent;
/**
* Abandon our prototype linkage, and copy all attributes locally
*/