Bug 1865172 Part 1 - Use computed page value on first reflow for all pages that don't have a pushed page name r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D196895
This commit is contained in:
@@ -2910,17 +2910,21 @@ nsContainerFrame* nsCSSFrameConstructor::ConstructPageFrame(
|
||||
// of the pages easier and faster.
|
||||
pageFrame->Init(nullptr, aParentFrame, aPrevPageFrame);
|
||||
|
||||
RefPtr<const nsAtom> pageName;
|
||||
if (mNextPageContentFramePageName) {
|
||||
pageName = mNextPageContentFramePageName.forget();
|
||||
} else if (aPrevPageFrame) {
|
||||
pageName = aPrevPageFrame->ComputePageValue();
|
||||
MOZ_ASSERT(pageName,
|
||||
"Page name from prev-in-flow should not have been null");
|
||||
}
|
||||
// If we were given a new page name for the next page, we can use it right
|
||||
// here and avoid computing the page name during reflow.
|
||||
// This should have the same resulting page name, but avoids traversing the
|
||||
// frame tree an extra time.
|
||||
// XXX alaskanemily: this isn't quite true, bug 1872292
|
||||
RefPtr<const nsAtom> pageName = mNextPageContentFramePageName.forget();
|
||||
|
||||
// Ensure the pseudoclass flags are set correctly. Currently, this won't end
|
||||
// up mattering because we only support none or :first, and
|
||||
// mNextPageContentFramePageName is always left as null for the first page.
|
||||
const StylePagePseudoClassFlags pseudoFlags =
|
||||
aPrevPageFrame ? StylePagePseudoClassFlags::NONE
|
||||
: StylePagePseudoClassFlags::FIRST;
|
||||
RefPtr<ComputedStyle> pageContentPseudoStyle =
|
||||
styleSet->ResolvePageContentStyle(pageName,
|
||||
StylePagePseudoClassFlags::NONE);
|
||||
styleSet->ResolvePageContentStyle(pageName, pseudoFlags);
|
||||
|
||||
nsContainerFrame* pageContentFrame = NS_NewPageContentFrame(
|
||||
aPresShell, pageContentPseudoStyle, pageName.forget());
|
||||
|
||||
@@ -404,20 +404,30 @@ void nsPageContentFrame::AppendDirectlyOwnedAnonBoxes(
|
||||
void nsPageContentFrame::EnsurePageName() {
|
||||
MOZ_ASSERT(HasAnyStateBits(NS_FRAME_FIRST_REFLOW),
|
||||
"Should only have been called on first reflow");
|
||||
|
||||
if (mPageName) {
|
||||
// The page name will be non-null only if
|
||||
// nsCSSFrameConstructor::mNextPageContentFramePageName was set when this
|
||||
// page was created. In that case, that value should be the same as what we
|
||||
// will find with nsPageContentFrame::ComputePageValue() to be correct.
|
||||
|
||||
// XXX alaskanemily: Bug 1872292 to enable this assert or understand why
|
||||
// it doesn't always hold. Sometimes ComputePageValue is wrong.
|
||||
// MOZ_ASSERT(
|
||||
// mPageName == ComputePageValue(),
|
||||
// "Computed page value should be the same as during page creation");
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(!GetPrevInFlow(),
|
||||
"Only the first page should initially have a null page name.");
|
||||
// This was the first page, we need to find our own page name and then set
|
||||
// our computed style based on that.
|
||||
|
||||
mPageName = ComputePageValue();
|
||||
|
||||
MOZ_ASSERT(mPageName, "Page name should never be null");
|
||||
// Resolve the computed style given this page-name and the :first pseudo.
|
||||
const StylePagePseudoClassFlags pseudoFlags =
|
||||
GetPrevInFlow() ? StylePagePseudoClassFlags::NONE
|
||||
: StylePagePseudoClassFlags::FIRST;
|
||||
RefPtr<ComputedStyle> pageContentPseudoStyle =
|
||||
PresShell()->StyleSet()->ResolvePageContentStyle(
|
||||
mPageName, StylePagePseudoClassFlags::FIRST);
|
||||
PresShell()->StyleSet()->ResolvePageContentStyle(mPageName, pseudoFlags);
|
||||
SetComputedStyleWithoutNotification(pageContentPseudoStyle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user