summaryrefslogtreecommitdiffstats
path: root/dom/xul/nsXULElement.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-04 19:48:30 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:18 -0500
commitcc533eaee5b800a534b93484598779debcdf5591 (patch)
treef4613faeda690275556065ad825c1c249e155afe /dom/xul/nsXULElement.cpp
parent59c26110c1124844b5c6820573a8cb4807f1151a (diff)
downloadUXP-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/nsXULElement.cpp')
-rw-r--r--dom/xul/nsXULElement.cpp52
1 files changed, 10 insertions, 42 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;