mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 22:38:41 +09:00
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
This commit is contained in:
parent
5422762839
commit
c5f6e6155b
2 changed files with 17 additions and 6 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue