w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.43k stars 656 forks source link

[css-view-transitions-1] Simplify definition of hit testing during "rendering suppression for view transitions" #10045

Open nt1m opened 6 months ago

nt1m commented 6 months ago

rendering suppression for view transitions a boolean. Initially false.

While a Document’s rendering suppression for view transitions is true, all pointer hit testing must target its document element, ignoring all other elements.

Would it be possible to define this in terms of pre-existing primitives? Something like "the document acts as if pointer-events: none was set on the document element". This way this can just be implemented using a simple style adjustment.

cc @khushalsagar @vmpstr

khushalsagar commented 6 months ago

@nt1m updated the title since this is just about how hit testing works in this mode.

Something like "the document acts as if pointer-events: none was set on the document element".

It's more like the opposite, its as-if all elements other than the document element have pointer-events: none so the only element which can consume the event is the document element. I'm not sure how to set it up in UA CSS such that it's not overridden by author CSS.

nt1m commented 6 months ago

@nt1m updated the title since this is just about how hit testing works in this mode.

Is there a place where the rest of this mode is defined? So far I only saw the hit testing definition.

Something like "the document acts as if pointer-events: none was set on the document element".

It's more like the opposite, its as-if all elements other than the document element have pointer-events: none so the only element which can consume the event is the document element. I'm not sure how to set it up in UA CSS such that it's not overridden by author CSS.

I guess you could have *:not(:root) { pointer-events: none !important } where !important prevents the rule from getting overridden?

khushalsagar commented 6 months ago

Is there a place where the rest of this mode is defined? So far I only saw the hit testing definition.

yes, in the html spec here. The browser should not render any frames after caching the old state and before the update callback is done or there is a timeout.

I guess you could have *:not(:root) { pointer-events: none !important } where !important prevents the rule from getting overridden?

That CSS should work! So we could consider it if we wanted a UA CSS way to do this.

I still worry that it might surprise authors to see the computed style being different that way. We've generally tried to avoid changing the computed style of author DOM. Another similar hit testing override during the animation phase except for the tagged elements is also defined : When a Document's active view transition's phase is "animating", the boxes generated by any element in that Document with captured in a view transition and its element contents, except transition root pseudo-element's inclusive descendants, are not painted (as if they had visibility: hidden) and do not respond to hit-testing (as if they had pointer-events: none).

The above one is harder to do via CSS because UA CSS doesn't have a way to say "set this style for elements participating in a transition". So I feel like for consistency it might be better to do this without overriding styles.