web-platform-tests / web-platform-tests/rfcs

Consider allowing Print Reftests finer control over the application of CSS page size

Open
#175 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
110
Forks
90
PR merge metrics
No merged PRs in 30d

Description

For pagination/printing we need to consider both virtual pages and sheets of paper (multiple pages may be printed on a single sheet of paper).

This section of CSS Paged Media 3 talks about how to position pages on a sheet:

https://drafts.csswg.org/css-page-3/#positioning-page-box

What browsers actually do when it comes to sizing pages and sizing sheets for @page size is quite complicated. A simplified description would be that CSS page size is always applied to the pages. But what happens to the sheets depends on whether the output target is a PDF file or a printer. If it is a PDF file, and if the user is printing one page per sheet, then the CSS page size is also applied to the "sheets" written into the PDF (the size of the page and sheet then match exactly). If the target is something else (perhaps a physical or virtual printer), then the page is scaled to fit whatever size of sheet is in use (perhaps what an output printer supports, or a size specified by the user) as described in the section of the spec that I linked above.

Prior to pull 173, sheets would all be the same size in WPT Print Reftests, which meant that only the scaling behavior was tested, and testing of the application of CSS page size rules to sheets could not be tested. That pull request changes the requirements on the test harness to apply CSS page size to the PDF sheets that are output. But that means that the scaling behavior described in section of the spec linked above now can't be tested.

I've encountered this issue while looking to test a bug that Firefox has where, if a page is much smaller than a sheet, Firefox will scale it up to fit the sheet rather than centering it or positioning it in the upper-left corner. This is pretty undesirable behavior from a user's point of view, and I plan to fix Firefox to match Chrome's centering behavior. But I would like to be able to add tests for that.

I think it is sensible for WPT Print Reftests to default to applying CSS page size to the sheets too, but given that browser's have the two different behaviors (size-the-sheet vs. scale-the-page), it would be useful if WPT Print Reftests had the flexibility to test the scale-the-page behavior.

Could we have some sort of mechanism for Print Reftests to specify that they would like to have the scale-the-page behavior when encountering CSS page size? Perhaps a meta tag, something like:

<meta name=page-size-fitting content=[match-sheet-to-page|scale-page-to-sheet]>

or just:

<meta name=size-sheets content=[yes|no]>

@jgraham @mstensho

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Print Reftests requirements changed by pull request 173 and the CSS Paged Media positioning-page-box section. Identify how the harness currently applies CSS page size to PDF sheets, then add a way for a test to request scale-page-to-sheet behavior. Done means a Print Reftest can exercise scaling or positioning without changing the default sheet-sizing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.