css-houdini-drafts icon indicating copy to clipboard operation
css-houdini-drafts copied to clipboard

Print behaviour & test requirements

Open gsnedders opened this issue 5 years ago • 4 comments

Does anywhere normatively say what should happen when you print the document? I guess it's technically implementation defined, and just assumed that the page is laid out for the new medium (and print medium styles are applied)?

Given historically, JS is not run when redoing style & layout for print, what do we expect the behaviour with the Layout API to be? Do we expect the registered JS to be called? What happens if it doesn't halt (do you fallback to breaking the existing screen rendering, or do we just give a script hang prompt, etc.)?

How do we expect to test such behaviour? Are we just envisioning print reftests for this, or would there be in any way the worklets would be tested with testharness.js?

gsnedders avatar Jan 29 '20 18:01 gsnedders

The CSS Working Group just discussed ????, and agreed to the following:

  • RESOLVED: Any Houdini JS that needs to run for style / layout calc needs to run for print
The full IRC log of that discussion <fantasai> Topic: ????
<fantasai> s/????/Print Behavior and Test Requirements/
<Rossen___> github: https://github.com/w3c/css-houdini-drafts/issues/978
<fantasai> github: https://github.com/w3c/css-houdini-drafts/issues/978
<fantasai> TabAtkins: gsnedders brought up really good point that historically we don't run JS for print
<fantasai> TabAtkins: but how should that interact with layout API and paint API?
<AmeliaBR> q+
<fantasai> TabAtkins: print style can change sizes of things
<fantasai> TabAtkins: have to run custom paint and custom layout
<astearns> ack florian
<fantasai> TabAtkins: are we doing something with that?
<florian> q-
<fantasai> TabAtkins: if we're not, do we plan to?
<fantasai> TabAtkins: we should document this either way, to make sure it's clear how printing and houdini APIs work together
<fantasai> Rossen___: When are we evaluating print?
<fantasai> TabAtkins: when you print a web page
<fantasai> TabAtkins: switch over to print styles and fragment for printing
<sushanth> +q
<fantasai> TabAtkins: but aren't running JS
<fantasai> iank_: These particular things, we should be running any layout API JS
<Rossen___> ack AmeliaBR
<fantasai> AmeliaBR: Definitely as part of a style recalc
<fantasai> AmeliaBR: Dunno if works correctly, but that should be the expectation
<fantasai> sushanth: for printing, I work on canvas so I know how it works for Chavas
<fantasai> sushanth: There's a "about to print" event, and you do stuff, and that gets replayed
<Rossen___> ack sushanth
<fantasai> sushanth: when you print, those recordings are played back
<AmeliaBR> s/"about to print"/onBeforePrint/
<emilio> q+
<fantasai> Rossen___: So takeaway is yes, should be running all of the JS hooks and execute scripts that will do custom paint / layout etc. in all of these cases
<fantasai> emilio: One question, for print approach, what happens when user changes stuff?
<fantasai> emilio: does print run multiple times?
<fantasai> emilio: in Gecko that's not the case
<fantasai> emilio: You issue print command, right?
<fantasai> emilio: there's a print preview that let's you adjust page size / margins / etc.
<fantasai> emilio: we don't dispatch JS events every time that happens
<fantasai> emilio: in Gecko, we do a complete separate document just for printing
<fantasai> emilio: we fire beforeprint event before doing this
<fantasai> emilio: when you change layout, we don't do it over again
<fantasai> AmeliaBR: It would be after regular JS event
<Rossen___> q?
<Rossen___> ack emilio
<fantasai> AmeliaBR: Houdini isn't part of event loop, it's triggered by style recalc directly
<gsnedders> q+
<fantasai> gsnedders: Want to point of last bit of my issue, which was about how we plan on testing the layout API
<fantasai> gsnedders: whether we expect there to be different testing for paged media vs scrolling media
<fantasai> iank_: There's currently work that is at least planned but maybe not in progress to support better printing in WPT?
<fantasai> gsnedders: We have paged reftests, but only currently implemented in Gecko
<fantasai> iank_: so on Chromium project to add support reftests of that form
<Rossen___> ack gsnedders
<fantasai> iank_: Testing strategy should be no different from other printing tests
<fantasai> gsnedders: ...
<fantasai> gsnedders: JS tests for worklets specifically, do we want them to differ from paged media?
<fantasai> iank_: Changing behavior between paged vs non-paged?
<fantasai> iank_: Definitely will be a difference
<fantasai> iank_: sizes change
<fantasai> iank_: definitley change in layout maybe paint
<fantasai> iank_: One that's missing is fragmentation support
<fantasai> iank_: that's one thing that will definitely be triggered by paged media context
<fantasai> emilio: We ported a lot of the Gecko paged reftests to be in WPT
<fantasai> iank_: We're undergoing adding more and more capabilities to our new fragmentation engine
<fantasai> iank_: adding a lot of those tests as ? tests
<fantasai> iank_: first half of next year will be focusing solely on printing, effectively
<fantasai> iank_: will add a lot more reftests
<AmeliaBR> s/?/ref/
<fantasai> iank_: will work on supporting print reftests in chromium at the same time
<fantasai> gsnedders: I think that answers my questions
<fantasai> Rossen___: smfr pointed out that we should probably specify when Houdini JS is specified in all of these cases for printing
<fantasai> AmeliaBR: Are worklets allowed to do anything asyc?
<fantasai> TabAtkins: nope. Very intentionally
<TabAtkins> ScribeNick: TabAtkins
<TabAtkins> fantasai: Layout API hasnt' been published since 2018, and I'm guessing edits ahve happened since then
<fantasai> fantasai: Just want to point out that Layout API haven't been published since 2018
<TabAtkins> Rossen___: Yes Ian and I botha ttempted to publish this and both failed
<TabAtkins> fantasai: If you have mechanics issues, can youg et a staff contact to help?
<TabAtkins> Rossen___: Yes.
<fantasai> fantasai: If you're getting stuck, ask the staff contacts for help
<fantasai> scribeNick: TabAtkins
<fantasai> TabAtkins: let's record a resolution
<fantasai> TabAtkins: Any houdini JS that needs to rerun for style / layout recalc needs to run
<fantasai> RESOLVED: Any Houdini JS that needs to run for style / layout calc needs to run for print

css-meeting-bot avatar Jul 31 '20 15:07 css-meeting-bot

Hmm, I wonder what spec this would go in. I suppose it isn't a general Worklets thing; Audio worklets won't run on print. I suppose it's some boilerplate I'd just need to spam into each of the relevant specs.

I think it needs to go in the Introduction, like the Module Interactions that some specs have.

tabatkins avatar Aug 03 '20 15:08 tabatkins

We certainly have some normative requirements here, no? Do we not need to call out explicitly that the layout worklet should be run when going from scrolling media to paged media, for example when printing from an on-screen browser?

gsnedders avatar Aug 03 '20 16:08 gsnedders

Yes, I'm putting an indicator on it that it's a normative section.

tabatkins avatar Aug 03 '20 16:08 tabatkins