diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-04 19:48:30 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:18 -0500 |
commit | cc533eaee5b800a534b93484598779debcdf5591 (patch) | |
tree | f4613faeda690275556065ad825c1c249e155afe /dom/xul | |
parent | 59c26110c1124844b5c6820573a8cb4807f1151a (diff) | |
download | UXP-cc533eaee5b800a534b93484598779debcdf5591.tar UXP-cc533eaee5b800a534b93484598779debcdf5591.tar.gz UXP-cc533eaee5b800a534b93484598779debcdf5591.tar.lz UXP-cc533eaee5b800a534b93484598779debcdf5591.tar.xz UXP-cc533eaee5b800a534b93484598779debcdf5591.zip |
Bug 1377993 - Make node slots less memory hungry in common cases.
Tag UXP Issue #1344
Diffstat (limited to 'dom/xul')
-rw-r--r-- | dom/xul/nsXULElement.cpp | 52 | ||||
-rw-r--r-- | dom/xul/nsXULElement.h | 17 |
2 files changed, 12 insertions, 57 deletions
diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index e351a46eb..a854f53ec 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -174,33 +174,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() { @@ -326,12 +299,7 @@ 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, @@ -895,9 +863,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(); @@ -1241,9 +1209,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(); @@ -1473,7 +1441,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)); @@ -1578,7 +1546,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 content-primary xul-browser, we want to take the opener property! @@ -1624,7 +1592,7 @@ nsXULElement::GetFrameLoaderXPCOM(nsIFrameLoader **aFrameLoader) already_AddRefed<nsFrameLoader> nsXULElement::GetFrameLoader() { - nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingSlots()); + nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots(); if (!slots) return nullptr; @@ -1646,7 +1614,7 @@ nsXULElement::GetParentApplication(mozIApplication** aApplication) 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; @@ -1662,7 +1630,7 @@ nsXULElement::SetIsPrerendered() void nsXULElement::InternalSetFrameLoader(nsIFrameLoader* aNewFrameLoader) { - nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots()); + nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots(); MOZ_ASSERT(slots); slots->mFrameLoaderOrOpener = aNewFrameLoader; diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h index 164afacd3..80424412f 100644 --- a/dom/xul/nsXULElement.h +++ b/dom/xul/nsXULElement.h @@ -609,19 +609,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(); /** @@ -677,8 +664,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); |