Bug 1853455 - Fix nsIFrame::ComputePageValue to check for page style values, rather than checking the start page value. r=dholbert

Because we use NULL to indicate the auto value, once a page contributes a
non-auto page value then that will be all that is seen by ComputePageValue
when a later page doesn't have a page-name at all.

Actually checking for the page-name value will fix page-name values when
an empty/auto page-name follows pages with a non-auto value. It is also
slightly more efficient, as it avoids a frame property lookup and instead
just looks at the computed style.

While we are here, remove an assert that is clearly not possible to occur
anymore, and add a short explanation of the code in ComputePageValue.

Differential Revision: https://phabricator.services.mozilla.com/D188544
This commit is contained in:
Emily McDonough
2023-09-27 19:06:17 +00:00
parent d2def41543
commit c650091e27
4 changed files with 35 additions and 19 deletions

View File

@@ -1350,16 +1350,6 @@ static void MoveChildrenTo(nsIFrame* aOldParent, nsContainerFrame* aNewParent,
}
}
static bool MaybeApplyPageName(nsFrameConstructorState& aState,
const StylePageName& aPageName) {
if (aPageName.IsPageName()) {
aState.mAutoPageNameValue = aPageName.AsPageName().AsAtom();
return true;
}
MOZ_ASSERT(aPageName.IsAuto(), "Impossible page name");
return false;
}
static void EnsureAutoPageName(nsFrameConstructorState& aState,
const nsContainerFrame* const aFrame) {
// Check if we need to figure out our used page name.
@@ -1372,8 +1362,8 @@ static void EnsureAutoPageName(nsFrameConstructorState& aState,
for (const nsContainerFrame* frame = aFrame; frame;
frame = frame->GetParent()) {
const StylePageName& pageName = frame->StylePage()->mPage;
if (MaybeApplyPageName(aState, pageName)) {
if (const nsAtom* maybePageName = frame->GetStylePageName()) {
aState.mAutoPageNameValue = maybePageName;
return;
}
}
@@ -1402,7 +1392,9 @@ nsCSSFrameConstructor::AutoFrameConstructionPageName::
MOZ_ASSERT(mNameToRestore,
"Page name should have been found by EnsureAutoPageName");
MaybeApplyPageName(aState, aFrame->StylePage()->mPage);
if (const nsAtom* maybePageName = aFrame->GetStylePageName()) {
aState.mAutoPageNameValue = maybePageName;
}
aFrame->SetAutoPageValue(aState.mAutoPageNameValue);
}