Closed Bug 1798218 Opened 2 years ago Closed 2 years ago

Non-print styles incorrectly applied when printing when transition is set

Categories

(Core :: Printing: Output, defect)

Firefox 108
defect

Tracking

()

VERIFIED FIXED
108 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox106 --- wontfix
firefox107 --- wontfix
firefox108 --- verified

People

(Reporter: theodorejb, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(4 files, 1 obsolete file)

Attached file print_style_bug.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0

Steps to reproduce:

Press Ctrl+P to open Print dialog on page with styles set to only apply when not printing (and a transition set on the element). Minimal reproduction attached.

The issue does not occur in Chrome or Microsoft Edge.

Actual results:

Padding, margin, color, and other styles are incorrectly applied to the printed page when the element has transition-duration set.

Expected results:

Styles should not be applied when printing when a media query excludes them, regardless of whether the element has a transition.

The Bugbug bot thinks this bug should belong to the 'Core::Printing: Output' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Printing: Output
Product: Firefox → Core
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Whiteboard: [qa-regression-triage]

Regression investigation results:

2022-11-02T16:07:03.613000: DEBUG : Found commit message:
Bug 774398 - Hack to make print and viewport media query listeners fire when printing. r=geckoview-reviewers,owlish,dholbert
This still doesn't fire on print settings changes, so it uses the
default page size. Which is probably better than nothing, but...

To make viewport-size media-query listeners work more generally for
printed documents, we would need to re-clone the top document
unconditionally for all print settings changes, which needs front-end
work at least, and is dubious if the page changes dynamically.

Differential Revision: https://phabricator.services.mozilla.com/D150499

In conclusion, this is a regression of bug 774398 starting in branch 105.

:emilio, since you are the author of the regressor, bug 774398, could you take a look?

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)

Hmm, so I'm not sure I agree with the expected result after looking more into this.

What happens after bug 774398 is that we trigger the style change due to @media print matching, which triggers transitions as expected. All those properties are transitioning, so at the time we print we see the "start" of the transition, which in this case are the initial values.

Here's a similar test-case that does this "manually", an where chromium also agrees on giving a red color.

I guess I could avoid starting transitions on print documents, which would fix this. One could argue that transitions when going into print are kinda silly because you'd always get the pre-transition value.

Flags: needinfo?(emilio)
Assignee: nobody → emilio
Attached file better test-case

Scratch the above, this shows the difference more clearly.

Attachment #9301633 - Attachment is obsolete: true

Two tweaks:

  • Use nsPresContext::Medium to decide whether to start transitions.
    This catches both the print emulation and the before/afterprint event
    dispatching code too, which is desirable.

  • Don't clone transition effects for print docs. This seems to match
    other browsers (click "trigger transition", then Ctrl+P in Chromium
    for example).

Move our existing css-animations tests to WPT. They were written for
compat with other browsers so we want to know if other browsers behave
differently.

Attachment #9301644 - Attachment description: Bug 1798218 - Ignore transitions for printing. r=hiro → Bug 1798218 - Ignore transitions for printing. r=hiro,boris,alaskanemily
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f83233d16398
Ignore transitions for printing. r=hiro
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/36811 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
Upstream PR merged by moz-wptsync-bot
Flags: qe-verify+

Reproduced the issue in Release 107 using Windows 10.
Verified - Fixed in Beta 108.0b4 and the latest Nightly 109.0a1 (2022-11-21) on Win10, macOS 12 and Ubuntu 20.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: