diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2022-04-18 23:11:06 +0800 |
---|---|---|
committer | FranklinDM <mrmineshafter17@gmail.com> | 2022-04-18 23:21:22 +0800 |
commit | 8d8da66f9400e8929e7bd6051d785bbdd02c6340 (patch) | |
tree | 8e8e941aabf6f953dc9deb70b8fd076d29594384 /layout | |
parent | 145947d86b7d8072b4b12a955e642e21873dd212 (diff) | |
download | uxp-8d8da66f9400e8929e7bd6051d785bbdd02c6340.tar.gz |
Issue #1873 - Part 1: Introduce ParentForUndisplayedMap helper method
This introduces the `ParentForUndisplayedMap` helper method to reduce duplication in terms of getting the parent and asserting parent existence.
Partially based on parts of https://bugzilla.mozilla.org/show_bug.cgi?id=1341083
Diffstat (limited to 'layout')
-rw-r--r-- | layout/base/nsFrameManager.cpp | 21 | ||||
-rw-r--r-- | layout/base/nsFrameManager.h | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index d6a6cb46b5..df91e65fae 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -131,6 +131,17 @@ nsFrameManager::Destroy() //---------------------------------------------------------------------- +/* static */ nsIContent* +nsFrameManager::ParentForUndisplayedMap(const nsIContent* aContent) +{ + MOZ_ASSERT(aContent); + + nsIContent* parent = aContent->GetParentElementCrossingShadowRoot(); + MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements"); + + return parent; +} + /* static */ nsStyleContext* nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap, const nsIContent* aContent) @@ -138,8 +149,8 @@ nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap, if (!aContent) { return nullptr; } - nsIContent* parent = aContent->GetParentElementCrossingShadowRoot(); - MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements"); + + nsIContent* parent = ParentForUndisplayedMap(aContent); for (UndisplayedNode* node = aMap->GetFirstNode(parent); node; node = node->getNext()) { if (node->mContent == aContent) @@ -178,8 +189,7 @@ nsFrameManager::SetStyleContextInMap(UndisplayedMap* aMap, MOZ_ASSERT(!GetStyleContextInMap(aMap, aContent), "Already have an entry for aContent"); - nsIContent* parent = aContent->GetParentElementCrossingShadowRoot(); - MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements"); + nsIContent* parent = ParentForUndisplayedMap(aContent); #ifdef DEBUG nsIPresShell* shell = aStyleContext->PresContext()->PresShell(); NS_ASSERTION(parent || (shell && shell->GetDocument() && @@ -223,8 +233,7 @@ nsFrameManager::ChangeStyleContextInMap(UndisplayedMap* aMap, printf("ChangeStyleContextInMap(%d): p=%p \n", i++, (void *)aContent); #endif - nsIContent* parent = aContent->GetParentElementCrossingShadowRoot(); - MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements"); + nsIContent* parent = ParentForUndisplayedMap(aContent); for (UndisplayedNode* node = aMap->GetFirstNode(parent); node; node = node->getNext()) { diff --git a/layout/base/nsFrameManager.h b/layout/base/nsFrameManager.h index 7537888605..77484fe3f0 100644 --- a/layout/base/nsFrameManager.h +++ b/layout/base/nsFrameManager.h @@ -182,6 +182,8 @@ public: void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState); protected: + static nsIContent* ParentForUndisplayedMap(const nsIContent* aContent); + void ClearAllMapsFor(nsIContent* aParentContent); static nsStyleContext* GetStyleContextInMap(UndisplayedMap* aMap, |