Backed out 2 changesets (bug 1865172) for causing wpt failures in page-name-unnamed-trailing-001-print.html.

Backed out changeset fc1f91bbfd85 (bug 1865172)
Backed out changeset 17019e03e97c (bug 1865172)
This commit is contained in:
Stanca Serban
2024-02-24 01:53:19 +02:00
parent e41893f2c5
commit f3138fcd27
8 changed files with 10 additions and 197 deletions

View File

@@ -8042,20 +8042,6 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
return newFrame;
}
void nsCSSFrameConstructor::MaybeSetNextPageContentFramePageName(
const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame, "Frame should not be null");
// No parent means the root frame, which isn't what this funciton is for.
MOZ_ASSERT(aFrame->GetParent(),
"Frame should be the first child placed on a new page, not the "
"root frame.");
if (mNextPageContentFramePageName) {
return;
}
const nsAtom* const autoValue = aFrame->GetParent()->GetAutoPageValue();
mNextPageContentFramePageName = aFrame->ComputePageValue(autoValue);
}
nsresult nsCSSFrameConstructor::ReplicateFixedFrames(
nsPageContentFrame* aParentFrame) {
// Now deal with fixed-pos things.... They should appear on all pages,

View File

@@ -297,39 +297,12 @@ class nsCSSFrameConstructor final : public nsFrameManager {
nsContainerFrame* aParentFrame,
bool aIsFluid = true);
/**
* Sets the page name when a page break is being generated due to a change
* in page name.
*
* Should only be used during paginated reflow, to signal what page value
* the next page content frame should have.
*
* It is an error to set this if a new page name has already been set, either
* through SetNextPageContentFramePageName or
* MaybeSetNextPageContentFramePageName.
*/
void SetNextPageContentFramePageName(const nsAtom* aPageName) {
MOZ_ASSERT(aPageName, "New page name should never be null");
void SetNextPageContentFramePageName(const nsAtom* aAtom) {
MOZ_ASSERT(!mNextPageContentFramePageName,
"PageContentFrame page name was already set");
mNextPageContentFramePageName = aPageName;
mNextPageContentFramePageName = aAtom;
}
/**
* If a new page name has not been set for the next page, sets the value
* using the given frame.
*
* |aFrame| should be a frame to be placed on the new page.
*
* This function handles the work of resolving an atom for the frame, and
* avoids doing this extra work when not necessary.
*
* This is used during block reflow when a page break has occurred but it was
* not caused by a change in page name. It should only be used during
* paginated reflow.
*/
void MaybeSetNextPageContentFramePageName(const nsIFrame* aFrame);
// Copy over fixed frames from aParentFrame's prev-in-flow
nsresult ReplicateFixedFrames(nsPageContentFrame* aParentFrame);

View File

@@ -3153,12 +3153,9 @@ bool nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
// Immediately fragment for page-name. It is possible we could break
// out of the loop right here, but this should make it more similar to
// what happens when reflow causes fragmentation.
// Set the page name, so that PushTruncatedLine does not need to
// recalculate the new page name.
PushTruncatedLine(aState, line, &keepGoing);
PresShell()->FrameConstructor()->SetNextPageContentFramePageName(
nextPageName ? nextPageName : GetAutoPageValue());
PushTruncatedLine(aState, line, &keepGoing,
ComputeNewPageNameIfNeeded::No);
} else {
// Reflow the dirty line. If it's an incremental reflow, then force
// it to invalidate the dirty area if necessary
@@ -4733,25 +4730,11 @@ void nsBlockFrame::SetBreakBeforeStatusBeforeLine(BlockReflowState& aState,
*aKeepReflowGoing = false;
}
void nsBlockFrame::PushTruncatedLine(
BlockReflowState& aState, LineIterator aLine, bool* aKeepReflowGoing,
ComputeNewPageNameIfNeeded aComputeNewPageName) {
void nsBlockFrame::PushTruncatedLine(BlockReflowState& aState,
LineIterator aLine,
bool* aKeepReflowGoing) {
PushLines(aState, aLine.prev());
*aKeepReflowGoing = false;
if (aComputeNewPageName == ComputeNewPageNameIfNeeded::Yes) {
// mCanHaveClassABreakpoints can only be true during paginated reflow, and
// we expect this function to only be called when the available bsize is
// constrained.
const WritingMode wm = GetWritingMode();
const bool canBreakForPageNames =
aState.mReflowInput.mFlags.mCanHaveClassABreakpoints &&
PresShell()->GetRootFrame()->GetWritingMode().IsOrthogonalTo(wm);
if (canBreakForPageNames) {
PresShell()->FrameConstructor()->MaybeSetNextPageContentFramePageName(
aLine->mFirstChild);
}
}
aState.mReflowStatus.SetIncomplete();
}

View File

@@ -848,24 +848,13 @@ class nsBlockFrame : public nsContainerFrame {
LineIterator aLine,
bool* aKeepReflowGoing);
/**
* Indicates if we need to compute a page name for the next page when pushing
* a truncated line.
*
* Using a value of No saves work when a new page name has already been set
* with nsCSSFrameConstructor::SetNextPageContentFramePageName.
*/
enum class ComputeNewPageNameIfNeeded : uint8_t { Yes, No };
/**
* Push aLine (and any after it), since it cannot be placed on this
* page/column. Set aKeepReflowGoing to false and set
* flag aState.mReflowStatus as incomplete.
*/
void PushTruncatedLine(BlockReflowState& aState, LineIterator aLine,
bool* aKeepReflowGoing,
ComputeNewPageNameIfNeeded aComputeNewPageName =
ComputeNewPageNameIfNeeded::Yes);
bool* aKeepReflowGoing);
void SplitLine(BlockReflowState& aState, nsLineLayout& aLineLayout,
LineIterator aLine, nsIFrame* aFrame,

View File

@@ -2117,8 +2117,8 @@ nsIFrame::CaretBlockAxisMetrics nsIFrame::GetCaretBlockAxisMetrics(
return CaretBlockAxisMetrics{.mOffset = baseline - ascent, .mExtent = height};
}
const nsAtom* nsIFrame::ComputePageValue(const nsAtom* aAutoValue) const {
const nsAtom* value = aAutoValue ? aAutoValue : nsGkAtoms::_empty;
const nsAtom* nsIFrame::ComputePageValue() const {
const nsAtom* value = nsGkAtoms::_empty;
const nsIFrame* frame = this;
// Find what CSS page name value this frame's subtree has, if any.
// Starting with this frame, check if a page name other than auto is present,

View File

@@ -1643,13 +1643,7 @@ class nsIFrame : public nsQueryFrame {
// This is intended to be used either on the root frame to find the first
// page's page-name, or on a newly created continuation to find what the new
// page's page-name will be.
//
// The auto page value can be set by the caller. This is useful when trying
// to compute a page value in the middle of a frame tree. In that case the
// auto value can be found from the AutoPageValue frame property of the
// parent frame. A null auto value is interpreted as the empty-string atom.
const nsAtom* ComputePageValue(const nsAtom* aAutoValue = nullptr) const
MOZ_NONNULL_RETURN;
const nsAtom* ComputePageValue() const MOZ_NONNULL_RETURN;
///////////////////////////////////////////////////////////////////////////////
// The public visibility API.

View File

@@ -1,55 +0,0 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
<title>Reference for styling a page with a non-empty name then a page with an empty name</title>
<link rel="author" title="Emily McDonough" href="mailto:emcdonough@mozilla.com"/>
<style>
@page{
size: 200px 300px;
}
@page a{
margin: 0;
}
@page b{
/* Add a margin so that even if page-orientation doesn't work in the tests
* the pages are different. */
margin: 20px;
page-orientation: rotate-left;
}
body{
margin: 0;
}
.page{
break-after: page;
overflow: hidden;
width: 160px;
height: 260px;
}
.marker{
width: 90px;
height: 90px;
background-color: cyan;
}
</style>
</head>
<body>
<div class="page" style="page: a">
<div>
<div class="marker">1</div>
<div style="position: absolute">x</div>
<canvas width="100" height="200"></canvas>
</div>
</div>
<div class="page" style="page: b">
<div class="marker">2</div>
<div style="position: absolute">y</div>
<canvas width="100" height="200"></canvas>
</div>
<div class="page" style="page: a">
<div>
<div class="marker">3</div>
<div style="position: absolute">z</div>
<canvas width="100" height="200"></canvas>
</div>
</div>
</body>

View File

@@ -1,57 +0,0 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
<title>Test that a page with a non-empty name then a page with an empty name are correctly styled</title>
<link rel="match" href="page-name-unnamed-trailing-001-print-ref.html"/>
<link rel="help" href="https://www.w3.org/TR/css-page-3/#using-named-pages"/>
<link rel="author" title="Emily McDonough" href="mailto:emcdonough@mozilla.com"/>
<style>
@page{
margin: 0;
size: 200px 300px;
}
@page landscape{
/* Add a margin so that even if page-orientation doesn't work in the tests
* the pages are different. */
margin: 20px;
page-orientation: rotate-left;
}
body{
margin: 0;
}
.page{
break-after: page;
overflow: hidden;
width: 160px;
height: 260px;
}
.marker{
width: 90px;
height: 90px;
background-color: cyan;
}
</style>
</head>
<body>
<div class="page">
<div>
<div class="marker">1</div>
<div style="position: absolute">x</div>
<canvas width="100" height="200"></canvas>
</div>
</div>
<div class="page">
<div style="page: landscape">
<div class="marker">2</div>
<div style="position: absolute">y</div>
<canvas style="page: landscape" width="100" height="200"></canvas>
</div>
</div>
<div class="page">
<div>
<div class="marker">3</div>
<div style="position: absolute">z</div>
<canvas width="100" height="200"></canvas>
</div>
</div>
</body>