Closed Bug 1859830 Opened 8 months ago Closed 8 months ago

@page :first doesn't work if the first page uses the auto page name (e.g. if `page` is never specified)

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

VERIFIED FIXED
121 Branch
Tracking Status
firefox121 --- verified
firefox122 --- verified

People

(Reporter: dholbert, Assigned: alaskanemily)

References

Details

Attachments

(8 files)

Attached file testcase 1

STR:

  1. Print-preview the attached testcase (or any testcase with :first and with no declared page: value for content on the first page)

EXPECTED RESULTS:
The testcase's huge margins should show up in the print preview.

ACTUAL RESULTS:
No huge margins are used.

If I add page:a to the div, then suddenly the margin does get picked up, as shown in the soon-to-be-attached reference case.

I think this is the reason behind the test-failure in bug 1859823, on my local Linux machine at least.

Flags: needinfo?(emcdonough)
Attached file reference case 1

Here's the testcase vs. reference case in Nightly 120.0a1 (2023-10-17)

Summary: @page :first doesn't work if the first page uses the auto page name → @page :first doesn't work if the first page uses the auto page name (e.g. if `page` is never specified)

More specifically, it looks like we honor the size from the :first page style, when determining the paper size. But we don't honor the margin or page-orientation. And we don't honor the size when determining the page size; we just use whatever we get from the paper (which happens to be correct if we're using the save-to-pdf print target).

Updated testcase coming to demonstrate that.

Attached file testcase 2
Attached file reference case 2

If you print-preview testcase 2 with the "Save to PDF" print target, then it looks like we get the page size correct (10x9, disregarding the requested page-orientation). But in fact we only get things correct because we use the specified size to determine the PDF "paper-size" in that case, and then we default to matching the paper size when we go to lay out our page.

If you use a physical print target instead, you can see more-clearly that we do in fact disregard the size (when comparing against how we render the reference case with a physical print target, where you can see the edge of the headers/footers as an indication of the scaled-down-to-fit-the-paper-whose-ratio-doesn't-quite-match page-size)

Note: there are two unrelated cosmetic issues shown in the header/footer in the right half of comment 7's screenshot.

  • I filed bug 1859926 on the fact that the header/footer are clipped (at the bottom edge of the screenshot -- e.g. timestamp 4:15 P, missing M)
  • There appears to be a overlapping-header issue (on the right edge of the screenshot, with the two copies of the URL stomping on top of each other), but I think that's just a version of bug 1112298; that overlap only shows up in Print Preview and only as a side-effect of that bug. There's no overlap in the actual physical printout, which just shows Nightly in place of the first URL. Nor does any overlap happen in print-preview or print output if I use an actual extremely-long-<title> -- we ellipsize the title to avoid overlapping the URL.)

https://searchfox.org/mozilla-central/rev/e4afef5d3ff67781dc1377912344694f3cf3a226/layout/generic/nsPageContentFrame.cpp#417-420

Well that's clearly not correct now that we care about page-rule pseudo classes. I'll make a patch to fix that.

Flags: needinfo?(emcdonough)
Assignee: nobody → emcdonough
Status: NEW → ASSIGNED
Attachment #9360064 - Attachment description: Bug 1859830 Part 1 - Apply resolved page style for the first page, even if it has the auto page name → Bug 1859830 Part 1 - Apply resolved page style for :first @page, even if it has no specified page name
Attachment #9360065 - Attachment description: Bug 1859830 Part 2 - Add tests for a page-rule with :first when the first page has an auto page name → Bug 1859830 Part 2 - Add a test for a :first @page rules when the first page doesn't have a page name set.
Pushed by emcdonough@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/618a42246cb8
Part 1 - Apply resolved page style for :first @page, even if it has no specified page name r=dholbert
https://hg.mozilla.org/integration/autoland/rev/fe6bbd79621a
Part 2 - Add a test for a :first @page rules when the first page doesn't have a page name set. r=dholbert
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/42852 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR was closed without merging
QA Whiteboard: [qa-121b-p2]

Reproducible on a 2023-10-18 Nightly build on Windows 10.
Verified as fixed on Firefox 121.0b8 and Nightly 122.0a1 on Windows 10, macOS 12, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-121b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: