mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +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*
|
/* static */ nsStyleContext*
|
||||||
nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap,
|
nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap,
|
||||||
const nsIContent* aContent)
|
const nsIContent* aContent)
|
||||||
|
|
@ -138,8 +149,8 @@ nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap,
|
||||||
if (!aContent) {
|
if (!aContent) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
nsIContent* parent = aContent->GetParentElementCrossingShadowRoot();
|
|
||||||
MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements");
|
nsIContent* parent = ParentForUndisplayedMap(aContent);
|
||||||
for (UndisplayedNode* node = aMap->GetFirstNode(parent);
|
for (UndisplayedNode* node = aMap->GetFirstNode(parent);
|
||||||
node; node = node->getNext()) {
|
node; node = node->getNext()) {
|
||||||
if (node->mContent == aContent)
|
if (node->mContent == aContent)
|
||||||
|
|
@ -178,8 +189,7 @@ nsFrameManager::SetStyleContextInMap(UndisplayedMap* aMap,
|
||||||
MOZ_ASSERT(!GetStyleContextInMap(aMap, aContent),
|
MOZ_ASSERT(!GetStyleContextInMap(aMap, aContent),
|
||||||
"Already have an entry for aContent");
|
"Already have an entry for aContent");
|
||||||
|
|
||||||
nsIContent* parent = aContent->GetParentElementCrossingShadowRoot();
|
nsIContent* parent = ParentForUndisplayedMap(aContent);
|
||||||
MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements");
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsIPresShell* shell = aStyleContext->PresContext()->PresShell();
|
nsIPresShell* shell = aStyleContext->PresContext()->PresShell();
|
||||||
NS_ASSERTION(parent || (shell && shell->GetDocument() &&
|
NS_ASSERTION(parent || (shell && shell->GetDocument() &&
|
||||||
|
|
@ -223,8 +233,7 @@ nsFrameManager::ChangeStyleContextInMap(UndisplayedMap* aMap,
|
||||||
printf("ChangeStyleContextInMap(%d): p=%p \n", i++, (void *)aContent);
|
printf("ChangeStyleContextInMap(%d): p=%p \n", i++, (void *)aContent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsIContent* parent = aContent->GetParentElementCrossingShadowRoot();
|
nsIContent* parent = ParentForUndisplayedMap(aContent);
|
||||||
MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements");
|
|
||||||
|
|
||||||
for (UndisplayedNode* node = aMap->GetFirstNode(parent);
|
for (UndisplayedNode* node = aMap->GetFirstNode(parent);
|
||||||
node; node = node->getNext()) {
|
node; node = node->getNext()) {
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,8 @@ public:
|
||||||
void RestoreFrameStateFor(nsIFrame* aFrame,
|
void RestoreFrameStateFor(nsIFrame* aFrame,
|
||||||
nsILayoutHistoryState* aState);
|
nsILayoutHistoryState* aState);
|
||||||
protected:
|
protected:
|
||||||
|
static nsIContent* ParentForUndisplayedMap(const nsIContent* aContent);
|
||||||
|
|
||||||
void ClearAllMapsFor(nsIContent* aParentContent);
|
void ClearAllMapsFor(nsIContent* aParentContent);
|
||||||
|
|
||||||
static nsStyleContext* GetStyleContextInMap(UndisplayedMap* aMap,
|
static nsStyleContext* GetStyleContextInMap(UndisplayedMap* aMap,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue