mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1377993 - Make node slots less memory hungry in common cases. r=peterv
MozReview-Commit-ID: Lhr1UsCrRTs
This commit is contained in:
parent
e05d0241f7
commit
0738714332
@ -1549,7 +1549,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
#endif
|
||||
{
|
||||
if (aBindingParent) {
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
|
||||
slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
|
||||
}
|
||||
@ -1575,7 +1575,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
}
|
||||
ShadowRoot* parentContainingShadow = aParent->GetContainingShadow();
|
||||
if (parentContainingShadow) {
|
||||
DOMSlots()->mContainingShadow = parentContainingShadow;
|
||||
ExtendedDOMSlots()->mContainingShadow = parentContainingShadow;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1965,7 +1965,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
}
|
||||
#endif
|
||||
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
if (clearBindingParent) {
|
||||
slots->mBindingParent = nullptr;
|
||||
@ -2013,7 +2013,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
nsICSSDeclaration*
|
||||
Element::GetSMILOverrideStyle()
|
||||
{
|
||||
Element::nsDOMSlots *slots = DOMSlots();
|
||||
Element::nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
|
||||
if (!slots->mSMILOverrideStyle) {
|
||||
slots->mSMILOverrideStyle = new nsDOMCSSAttributeDeclaration(this, true);
|
||||
@ -2025,7 +2025,7 @@ Element::GetSMILOverrideStyle()
|
||||
DeclarationBlock*
|
||||
Element::GetSMILOverrideStyleDeclaration()
|
||||
{
|
||||
Element::nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
Element::nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
return slots ? slots->mSMILOverrideStyleDeclaration.get() : nullptr;
|
||||
}
|
||||
|
||||
@ -2033,7 +2033,7 @@ nsresult
|
||||
Element::SetSMILOverrideStyleDeclaration(DeclarationBlock* aDeclaration,
|
||||
bool aNotify)
|
||||
{
|
||||
Element::nsDOMSlots *slots = DOMSlots();
|
||||
Element::nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
|
||||
slots->mSMILOverrideStyleDeclaration = aDeclaration;
|
||||
|
||||
@ -4087,7 +4087,7 @@ Element::ClearDataset()
|
||||
nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>*
|
||||
Element::RegisteredIntersectionObservers()
|
||||
{
|
||||
nsDOMSlots* slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
return &slots->mRegisteredIntersectionObservers;
|
||||
}
|
||||
|
||||
@ -4138,7 +4138,7 @@ Element::ClearServoData() {
|
||||
void
|
||||
Element::SetCustomElementData(CustomElementData* aData)
|
||||
{
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots *slots = ExtendedDOMSlots();
|
||||
MOZ_ASSERT(!slots->mCustomElementData, "Custom element data may not be changed once set.");
|
||||
slots->mCustomElementData = aData;
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ public:
|
||||
*/
|
||||
inline CustomElementData* GetCustomElementData() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mCustomElementData;
|
||||
}
|
||||
@ -1026,7 +1026,7 @@ public:
|
||||
|
||||
ShadowRoot *FastGetShadowRoot() const
|
||||
{
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
return slots ? slots->mShadowRoot.get() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -660,8 +660,7 @@ nsNodeSupportsWeakRefTearoff::GetWeakReference(nsIWeakReference** aInstancePtr)
|
||||
//----------------------------------------------------------------------
|
||||
FragmentOrElement::nsDOMSlots::nsDOMSlots()
|
||||
: nsINode::nsSlots(),
|
||||
mDataset(nullptr),
|
||||
mBindingParent(nullptr)
|
||||
mDataset(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -673,84 +672,104 @@ FragmentOrElement::nsDOMSlots::~nsDOMSlots()
|
||||
}
|
||||
|
||||
void
|
||||
FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb, bool aIsXUL)
|
||||
FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mStyle");
|
||||
cb.NoteXPCOMChild(mStyle.get());
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mSMILOverrideStyle");
|
||||
cb.NoteXPCOMChild(mSMILOverrideStyle.get());
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mAttributeMap");
|
||||
cb.NoteXPCOMChild(mAttributeMap.get());
|
||||
|
||||
if (aIsXUL) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mControllers");
|
||||
cb.NoteXPCOMChild(mControllers);
|
||||
}
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mXBLBinding");
|
||||
cb.NoteNativeChild(mXBLBinding, NS_CYCLE_COLLECTION_PARTICIPANT(nsXBLBinding));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mXBLInsertionParent");
|
||||
cb.NoteXPCOMChild(mXBLInsertionParent.get());
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mShadowRoot");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mShadowRoot));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mContainingShadow");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mContainingShadow));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mChildrenList");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMNodeList*, mChildrenList));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mLabelsList");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMNodeList*, mLabelsList));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mClassList");
|
||||
cb.NoteXPCOMChild(mClassList.get());
|
||||
|
||||
if (mCustomElementData) {
|
||||
for (uint32_t i = 0; i < mCustomElementData->mCallbackQueue.Length(); i++) {
|
||||
mCustomElementData->mCallbackQueue[i]->Traverse(cb);
|
||||
if (!mExtendedSlots) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mSMILOverrideStyle");
|
||||
cb.NoteXPCOMChild(mExtendedSlots->mSMILOverrideStyle.get());
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mControllers");
|
||||
cb.NoteXPCOMChild(mExtendedSlots->mControllers);
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mLabelsList");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMNodeList*,mExtendedSlots-> mLabelsList));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mShadowRoot");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mExtendedSlots->mShadowRoot));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mContainingShadow");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mExtendedSlots->mContainingShadow));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mXBLBinding");
|
||||
cb.NoteNativeChild(mExtendedSlots->mXBLBinding,
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT(nsXBLBinding));
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mXBLInsertionParent");
|
||||
cb.NoteXPCOMChild(mExtendedSlots->mXBLInsertionParent.get());
|
||||
|
||||
if (mExtendedSlots->mCustomElementData) {
|
||||
for (uint32_t i = 0;
|
||||
i < mExtendedSlots->mCustomElementData->mCallbackQueue.Length(); i++) {
|
||||
mExtendedSlots->mCustomElementData->mCallbackQueue[i]->Traverse(cb);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto iter = mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = mExtendedSlots->mRegisteredIntersectionObservers.Iter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Key();
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mRegisteredIntersectionObservers[i]");
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
|
||||
"mExtendedSlots->mRegisteredIntersectionObservers[i]");
|
||||
cb.NoteXPCOMChild(observer);
|
||||
}
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mFrameLoaderOrOpener");
|
||||
cb.NoteXPCOMChild(mExtendedSlots->mFrameLoaderOrOpener);
|
||||
}
|
||||
|
||||
void
|
||||
FragmentOrElement::nsDOMSlots::Unlink(bool aIsXUL)
|
||||
FragmentOrElement::nsDOMSlots::Unlink()
|
||||
{
|
||||
mStyle = nullptr;
|
||||
mSMILOverrideStyle = nullptr;
|
||||
if (mAttributeMap) {
|
||||
mAttributeMap->DropReference();
|
||||
mAttributeMap = nullptr;
|
||||
}
|
||||
if (aIsXUL)
|
||||
NS_IF_RELEASE(mControllers);
|
||||
|
||||
MOZ_ASSERT(!mXBLBinding);
|
||||
|
||||
mXBLInsertionParent = nullptr;
|
||||
mShadowRoot = nullptr;
|
||||
mContainingShadow = nullptr;
|
||||
mChildrenList = nullptr;
|
||||
mLabelsList = nullptr;
|
||||
mCustomElementData = nullptr;
|
||||
mClassList = nullptr;
|
||||
mRegisteredIntersectionObservers.Clear();
|
||||
|
||||
if (!mExtendedSlots) {
|
||||
return;
|
||||
}
|
||||
|
||||
mExtendedSlots->mSMILOverrideStyle = nullptr;
|
||||
mExtendedSlots->mControllers = nullptr;
|
||||
mExtendedSlots->mLabelsList = nullptr;
|
||||
mExtendedSlots->mShadowRoot = nullptr;
|
||||
mExtendedSlots->mContainingShadow = nullptr;
|
||||
MOZ_ASSERT(!(mExtendedSlots->mXBLBinding));
|
||||
mExtendedSlots->mXBLInsertionParent = nullptr;
|
||||
mExtendedSlots->mCustomElementData = nullptr;
|
||||
mExtendedSlots->mRegisteredIntersectionObservers.Clear();
|
||||
nsCOMPtr<nsIFrameLoader> frameLoader =
|
||||
do_QueryInterface(mExtendedSlots->mFrameLoaderOrOpener);
|
||||
if (frameLoader) {
|
||||
static_cast<nsFrameLoader*>(frameLoader.get())->Destroy();
|
||||
}
|
||||
mExtendedSlots->mFrameLoaderOrOpener = nullptr;
|
||||
}
|
||||
|
||||
size_t
|
||||
FragmentOrElement::nsDOMSlots::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
if (mExtendedSlots) {
|
||||
n += aMallocSizeOf(mExtendedSlots.get());
|
||||
}
|
||||
|
||||
if (mAttributeMap) {
|
||||
n += mAttributeMap->SizeOfIncludingThis(aMallocSizeOf);
|
||||
@ -771,6 +790,19 @@ FragmentOrElement::nsDOMSlots::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) c
|
||||
return n;
|
||||
}
|
||||
|
||||
FragmentOrElement::nsExtendedDOMSlots::nsExtendedDOMSlots()
|
||||
: mBindingParent(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
FragmentOrElement::nsExtendedDOMSlots::~nsExtendedDOMSlots()
|
||||
{
|
||||
nsCOMPtr<nsIFrameLoader> frameLoader = do_QueryInterface(mFrameLoaderOrOpener);
|
||||
if (frameLoader) {
|
||||
static_cast<nsFrameLoader*>(frameLoader.get())->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
FragmentOrElement::FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: nsIContent(aNodeInfo)
|
||||
{
|
||||
@ -1092,7 +1124,7 @@ FragmentOrElement::IsLink(nsIURI** aURI) const
|
||||
nsIContent*
|
||||
FragmentOrElement::GetBindingParent() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
|
||||
if (slots) {
|
||||
return slots->mBindingParent;
|
||||
@ -1104,7 +1136,7 @@ nsXBLBinding*
|
||||
FragmentOrElement::GetXBLBinding() const
|
||||
{
|
||||
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mXBLBinding;
|
||||
}
|
||||
@ -1139,11 +1171,11 @@ FragmentOrElement::SetXBLBinding(nsXBLBinding* aBinding,
|
||||
|
||||
if (aBinding) {
|
||||
SetFlags(NODE_MAY_BE_IN_BINDING_MNGR);
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
slots->mXBLBinding = aBinding;
|
||||
bindingManager->AddBoundContent(this);
|
||||
} else {
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
slots->mXBLBinding = nullptr;
|
||||
}
|
||||
@ -1158,7 +1190,7 @@ nsIContent*
|
||||
FragmentOrElement::GetXBLInsertionParent() const
|
||||
{
|
||||
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mXBLInsertionParent;
|
||||
}
|
||||
@ -1170,7 +1202,7 @@ FragmentOrElement::GetXBLInsertionParent() const
|
||||
ShadowRoot*
|
||||
FragmentOrElement::GetContainingShadow() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mContainingShadow;
|
||||
}
|
||||
@ -1180,21 +1212,21 @@ FragmentOrElement::GetContainingShadow() const
|
||||
void
|
||||
FragmentOrElement::SetShadowRoot(ShadowRoot* aShadowRoot)
|
||||
{
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
slots->mShadowRoot = aShadowRoot;
|
||||
}
|
||||
|
||||
nsTArray<nsIContent*>&
|
||||
FragmentOrElement::DestInsertionPoints()
|
||||
{
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
return slots->mDestInsertionPoints;
|
||||
}
|
||||
|
||||
nsTArray<nsIContent*>*
|
||||
FragmentOrElement::GetExistingDestInsertionPoints() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
return &slots->mDestInsertionPoints;
|
||||
}
|
||||
@ -1205,11 +1237,11 @@ void
|
||||
FragmentOrElement::SetXBLInsertionParent(nsIContent* aContent)
|
||||
{
|
||||
if (aContent) {
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
SetFlags(NODE_MAY_BE_IN_BINDING_MNGR);
|
||||
slots->mXBLInsertionParent = aContent;
|
||||
} else {
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
slots->mXBLInsertionParent = nullptr;
|
||||
}
|
||||
@ -1496,14 +1528,15 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FragmentOrElement)
|
||||
{
|
||||
nsDOMSlots *slots = tmp->GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
if (tmp->IsElement()) {
|
||||
if (slots->mExtendedSlots && tmp->IsElement()) {
|
||||
Element* elem = tmp->AsElement();
|
||||
for (auto iter = slots->mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = slots->mExtendedSlots->mRegisteredIntersectionObservers.Iter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Key();
|
||||
observer->UnlinkTarget(*elem);
|
||||
}
|
||||
}
|
||||
slots->Unlink(tmp->IsXULElement());
|
||||
slots->Unlink();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2068,7 +2101,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
|
||||
{
|
||||
nsDOMSlots *slots = tmp->GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
slots->Traverse(cb, tmp->IsXULElement());
|
||||
slots->Traverse(cb);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsAttrAndChildArray.h" // member
|
||||
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_*
|
||||
#include "nsIContent.h" // base class
|
||||
@ -242,8 +243,6 @@ protected:
|
||||
nsresult CopyInnerTo(FragmentOrElement* aDest, bool aPreallocateChildren);
|
||||
|
||||
public:
|
||||
// Because of a bug in MS C++ compiler nsDOMSlots must be declared public,
|
||||
// otherwise nsXULElement::nsXULSlots doesn't compile.
|
||||
/**
|
||||
* There are a set of DOM- and scripting-specific instance variables
|
||||
* that may only be instantiated when a content object is accessed
|
||||
@ -252,29 +251,13 @@ public:
|
||||
* in a side structure that's only allocated when the content is
|
||||
* accessed through the DOM.
|
||||
*/
|
||||
class nsDOMSlots : public nsINode::nsSlots
|
||||
|
||||
class nsExtendedDOMSlots
|
||||
{
|
||||
public:
|
||||
nsDOMSlots();
|
||||
virtual ~nsDOMSlots();
|
||||
nsExtendedDOMSlots();
|
||||
|
||||
void Traverse(nsCycleCollectionTraversalCallback &cb, bool aIsXUL);
|
||||
void Unlink(bool aIsXUL);
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
/**
|
||||
* The .style attribute (an interface that forwards to the actual
|
||||
* style rules)
|
||||
* @see nsGenericHTMLElement::GetStyle
|
||||
*/
|
||||
nsCOMPtr<nsICSSDeclaration> mStyle;
|
||||
|
||||
/**
|
||||
* The .dataset attribute.
|
||||
* @see nsGenericHTMLElement::GetDataset
|
||||
*/
|
||||
nsDOMStringMap* mDataset; // [Weak]
|
||||
~nsExtendedDOMSlots();
|
||||
|
||||
/**
|
||||
* SMIL Overridde style rules (for SMIL animation of CSS properties)
|
||||
@ -288,35 +271,17 @@ public:
|
||||
RefPtr<mozilla::DeclarationBlock> mSMILOverrideStyleDeclaration;
|
||||
|
||||
/**
|
||||
* An object implementing nsIDOMMozNamedAttrMap for this content (attributes)
|
||||
* @see FragmentOrElement::GetAttributes
|
||||
*/
|
||||
RefPtr<nsDOMAttributeMap> mAttributeMap;
|
||||
|
||||
union {
|
||||
/**
|
||||
* The nearest enclosing content node with a binding that created us.
|
||||
* @see FragmentOrElement::GetBindingParent
|
||||
*/
|
||||
nsIContent* mBindingParent; // [Weak]
|
||||
|
||||
/**
|
||||
* The controllers of the XUL Element.
|
||||
*/
|
||||
nsIControllers* mControllers; // [OWNER]
|
||||
};
|
||||
* The nearest enclosing content node with a binding that created us.
|
||||
* @see FragmentOrElement::GetBindingParent
|
||||
*/
|
||||
nsIContent* mBindingParent; // [Weak]
|
||||
|
||||
/**
|
||||
* An object implementing the .children property for this element.
|
||||
*/
|
||||
RefPtr<nsContentList> mChildrenList;
|
||||
* The controllers of the XUL Element.
|
||||
*/
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
|
||||
/**
|
||||
* An object implementing the .classList property for this element.
|
||||
*/
|
||||
RefPtr<nsDOMTokenList> mClassList;
|
||||
|
||||
/*
|
||||
* An object implementing the .labels property for this element.
|
||||
*/
|
||||
RefPtr<nsLabelsNodeList> mLabelsList;
|
||||
@ -357,6 +322,55 @@ public:
|
||||
*/
|
||||
nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>
|
||||
mRegisteredIntersectionObservers;
|
||||
|
||||
/**
|
||||
* For XUL to hold either frameloader or opener.
|
||||
*/
|
||||
nsCOMPtr<nsISupports> mFrameLoaderOrOpener;
|
||||
|
||||
};
|
||||
|
||||
class nsDOMSlots : public nsINode::nsSlots
|
||||
{
|
||||
public:
|
||||
nsDOMSlots();
|
||||
virtual ~nsDOMSlots();
|
||||
|
||||
void Traverse(nsCycleCollectionTraversalCallback &cb);
|
||||
void Unlink();
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
/**
|
||||
* The .style attribute (an interface that forwards to the actual
|
||||
* style rules)
|
||||
* @see nsGenericHTMLElement::GetStyle
|
||||
*/
|
||||
nsCOMPtr<nsICSSDeclaration> mStyle;
|
||||
|
||||
/**
|
||||
* The .dataset attribute.
|
||||
* @see nsGenericHTMLElement::GetDataset
|
||||
*/
|
||||
nsDOMStringMap* mDataset; // [Weak]
|
||||
|
||||
/**
|
||||
* An object implementing nsIDOMMozNamedAttrMap for this content (attributes)
|
||||
* @see FragmentOrElement::GetAttributes
|
||||
*/
|
||||
RefPtr<nsDOMAttributeMap> mAttributeMap;
|
||||
|
||||
/**
|
||||
* An object implementing the .children property for this element.
|
||||
*/
|
||||
RefPtr<nsContentList> mChildrenList;
|
||||
|
||||
/**
|
||||
* An object implementing the .classList property for this element.
|
||||
*/
|
||||
RefPtr<nsDOMTokenList> mClassList;
|
||||
|
||||
mozilla::UniquePtr<nsExtendedDOMSlots> mExtendedSlots;
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -376,6 +390,26 @@ protected:
|
||||
return static_cast<nsDOMSlots*>(GetExistingSlots());
|
||||
}
|
||||
|
||||
nsExtendedDOMSlots* ExtendedDOMSlots()
|
||||
{
|
||||
nsDOMSlots* slots = DOMSlots();
|
||||
if (!slots->mExtendedSlots) {
|
||||
slots->mExtendedSlots = MakeUnique<nsExtendedDOMSlots>();
|
||||
}
|
||||
|
||||
return slots->mExtendedSlots.get();
|
||||
}
|
||||
|
||||
nsExtendedDOMSlots* GetExistingExtendedDOMSlots() const
|
||||
{
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mExtendedSlots.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls SetIsElementInStyleScopeFlagOnSubtree for each shadow tree attached
|
||||
* to this node, which is assumed to be an Element.
|
||||
|
@ -75,8 +75,8 @@ ShadowRoot::ShadowRoot(nsIContent* aContent,
|
||||
|
||||
SetFlags(NODE_IS_IN_SHADOW_TREE);
|
||||
|
||||
DOMSlots()->mBindingParent = aContent;
|
||||
DOMSlots()->mContainingShadow = this;
|
||||
ExtendedDOMSlots()->mBindingParent = aContent;
|
||||
ExtendedDOMSlots()->mContainingShadow = this;
|
||||
|
||||
// Add the ShadowRoot as a mutation observer on the host to watch
|
||||
// for mutations because the insertion points in this ShadowRoot
|
||||
|
@ -301,9 +301,12 @@ nsNodeUtils::LastRelease(nsINode* aNode)
|
||||
Element* elem = aNode->AsElement();
|
||||
FragmentOrElement::nsDOMSlots* domSlots =
|
||||
static_cast<FragmentOrElement::nsDOMSlots*>(slots);
|
||||
for (auto iter = domSlots->mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Key();
|
||||
observer->UnlinkTarget(*elem);
|
||||
if (domSlots->mExtendedSlots) {
|
||||
for (auto iter = domSlots->mExtendedSlots->mRegisteredIntersectionObservers.Iter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Key();
|
||||
observer->UnlinkTarget(*elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
// We need to consider a labels element is moved to another subtree
|
||||
// with different root, it needs to update labels list and its root
|
||||
// as well.
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots && slots->mLabelsList) {
|
||||
slots->mLabelsList->MaybeResetRoot(SubtreeRoot());
|
||||
}
|
||||
@ -530,7 +530,7 @@ nsGenericHTMLElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
|
||||
// We need to consider a labels element is removed from tree,
|
||||
// it needs to update labels list and its root as well.
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots && slots->mLabelsList) {
|
||||
slots->mLabelsList->MaybeResetRoot(SubtreeRoot());
|
||||
}
|
||||
@ -1702,7 +1702,7 @@ nsGenericHTMLElement::Labels()
|
||||
{
|
||||
MOZ_ASSERT(IsLabelable(),
|
||||
"Labels() only allow labelable elements to use it.");
|
||||
nsDOMSlots* slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
|
||||
if (!slots->mLabelsList) {
|
||||
slots->mLabelsList = new nsLabelsNodeList(SubtreeRoot(), MatchLabelsElement,
|
||||
|
@ -176,33 +176,6 @@ nsXULElement::~nsXULElement()
|
||||
{
|
||||
}
|
||||
|
||||
nsXULElement::nsXULSlots::nsXULSlots()
|
||||
: nsXULElement::nsDOMSlots()
|
||||
{
|
||||
}
|
||||
|
||||
nsXULElement::nsXULSlots::~nsXULSlots()
|
||||
{
|
||||
NS_IF_RELEASE(mControllers); // Forces release
|
||||
nsCOMPtr<nsIFrameLoader> frameLoader = do_QueryInterface(mFrameLoaderOrOpener);
|
||||
if (frameLoader) {
|
||||
static_cast<nsFrameLoader*>(frameLoader.get())->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::nsXULSlots::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mFrameLoaderOrOpener");
|
||||
cb.NoteXPCOMChild(mFrameLoaderOrOpener);
|
||||
}
|
||||
|
||||
nsINode::nsSlots*
|
||||
nsXULElement::CreateSlots()
|
||||
{
|
||||
return new nsXULSlots();
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::MaybeUpdatePrivateLifetime()
|
||||
{
|
||||
@ -328,12 +301,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULElement)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULElement,
|
||||
nsStyledElement)
|
||||
{
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(tmp->GetExistingSlots());
|
||||
if (slots) {
|
||||
slots->Traverse(cb);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULElement,
|
||||
@ -887,9 +854,9 @@ nsXULElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
// mDocument in nsGlobalWindow::SetDocShell, but I'm not
|
||||
// sure whether that would fix all possible cycles through
|
||||
// mControllers.)
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots());
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
NS_IF_RELEASE(slots->mControllers);
|
||||
slots->mControllers = nullptr;
|
||||
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader) {
|
||||
frameLoader->Destroy();
|
||||
@ -1235,9 +1202,9 @@ nsXULElement::RemoveBroadcaster(const nsAString & broadcasterId)
|
||||
void
|
||||
nsXULElement::DestroyContent()
|
||||
{
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots());
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (slots) {
|
||||
NS_IF_RELEASE(slots->mControllers);
|
||||
slots->mControllers = nullptr;
|
||||
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader) {
|
||||
frameLoader->Destroy();
|
||||
@ -1462,7 +1429,7 @@ nsIControllers*
|
||||
nsXULElement::GetControllers(ErrorResult& rv)
|
||||
{
|
||||
if (! Controllers()) {
|
||||
nsDOMSlots* slots = DOMSlots();
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
|
||||
rv = NS_NewXULControllers(nullptr, NS_GET_IID(nsIControllers),
|
||||
reinterpret_cast<void**>(&slots->mControllers));
|
||||
@ -1501,7 +1468,7 @@ nsXULElement::LoadSrc()
|
||||
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (!frameLoader) {
|
||||
// Check if we have an opener we need to be setting
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(Slots());
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
nsCOMPtr<nsPIDOMWindowOuter> opener = do_QueryInterface(slots->mFrameLoaderOrOpener);
|
||||
if (!opener) {
|
||||
// If we are a primary xul-browser, we want to take the opener property!
|
||||
@ -1547,7 +1514,7 @@ nsXULElement::GetFrameLoaderXPCOM(nsIFrameLoader **aFrameLoader)
|
||||
already_AddRefed<nsFrameLoader>
|
||||
nsXULElement::GetFrameLoader()
|
||||
{
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingSlots());
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
if (!slots)
|
||||
return nullptr;
|
||||
|
||||
@ -1558,7 +1525,7 @@ nsXULElement::GetFrameLoader()
|
||||
void
|
||||
nsXULElement::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, ErrorResult& aRv)
|
||||
{
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(Slots());
|
||||
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
|
||||
MOZ_ASSERT(!slots->mFrameLoaderOrOpener, "A frameLoader or opener is present when calling PresetOpenerWindow");
|
||||
|
||||
slots->mFrameLoaderOrOpener = aWindow;
|
||||
@ -1574,7 +1541,7 @@ nsXULElement::SetIsPrerendered()
|
||||
void
|
||||
nsXULElement::InternalSetFrameLoader(nsIFrameLoader* aNewFrameLoader)
|
||||
{
|
||||
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots());
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
MOZ_ASSERT(slots);
|
||||
|
||||
slots->mFrameLoaderOrOpener = aNewFrameLoader;
|
||||
|
@ -725,19 +725,6 @@ protected:
|
||||
|
||||
nsresult AddPopupListener(nsIAtom* aName);
|
||||
|
||||
class nsXULSlots : public mozilla::dom::Element::nsDOMSlots
|
||||
{
|
||||
public:
|
||||
nsXULSlots();
|
||||
virtual ~nsXULSlots();
|
||||
|
||||
void Traverse(nsCycleCollectionTraversalCallback &cb);
|
||||
|
||||
nsCOMPtr<nsISupports> mFrameLoaderOrOpener;
|
||||
};
|
||||
|
||||
virtual nsINode::nsSlots* CreateSlots() override;
|
||||
|
||||
nsresult LoadSrc();
|
||||
|
||||
/**
|
||||
@ -795,8 +782,8 @@ protected:
|
||||
// Internal accessor. This shadows the 'Slots', and returns
|
||||
// appropriate value.
|
||||
nsIControllers *Controllers() {
|
||||
nsDOMSlots* slots = GetExistingDOMSlots();
|
||||
return slots ? slots->mControllers : nullptr;
|
||||
nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
|
||||
return slots ? slots->mControllers.get() : nullptr;
|
||||
}
|
||||
|
||||
void UnregisterAccessKey(const nsAString& aOldValue);
|
||||
|
Loading…
x
Reference in New Issue
Block a user