Skip to content

[css-transforms-2] 3-D painting order should treat establishing element's background/border like its content #6238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dbaron opened this issue Apr 22, 2021 · 4 comments

Comments

@dbaron
Copy link
Member

dbaron commented Apr 22, 2021

§ 4.1.2. 3D Rendering Contexts currently defines the painting order for a 3-D Rendering Context as follows:

The rendering of elements in a 3D rendering context is as follows (numbers refer to items in CSS 2.1, Appendix E, Section E.2 Painting Order):

A. The background, borders and other box decorations of the establishing element are rendered (steps 1 and 2)
B. The content and descendant elements without 3D transforms, ordered according to steps 3—7, are rendered into a plane at z=0 relative to the establishing element.
C. 3D-transformed elements are each rendered into their own plane, transformed by the accumulated 3D transformation matrix.
D. Intersection is performed between the set of planes generated by steps B and C, according to Newell’s algorithm.
E. The resulting set of planes is rendered on top of the backgrounds and box decorations rendered in this step A. Coplanar 3D transformed elements are rendered in painting order.

it then goes on to note:

ISSUE 6: requiring intersection with non-transformed content and descendants requires UAs to allocate additional textures (possibly doubling memory use). Would be more efficient to simply render content and untransformed descendants along with background and borders.

I wrote a simple test for this which I would expect from the spec to match this reference. However, the behavior I get in Chrome, Firefox, and Safari, assuming I'm interpreting this correctly, is as though A and B were done together into a plane at z=0 (i.e., step A is eliminated by merging it into step B). It's not clear to me if that issue was suggesting merging in the opposite direction. However, given that this behavior appears to be interoperable, I think we're probably better off switching the spec to match all of the implementations unless there's a very good reason to want the implementations to all change (given that I suspect it would break some existing web content).

cc @smfr @mattwoodrow

@mattwoodrow
Copy link
Contributor

Agreed, I'm not aware of any complaints with the current behaviour (apart from that inline comment about memory usage), so it seems like a good idea to fix the spec to match.

@smfr
Copy link
Contributor

smfr commented Jun 23, 2021

In WebKit, transform-style: preserve-3d does not establish a 3D rendering context, it just extend it, so in WebKit the body is establishing in your testcase.

It's worth looking at some more test cases to make sure your transformed elements don't also intersect with things behind the establishing element.

The behavior was specified like this because it's akin to how negative z-index works, but I'm OK with saying that backgrounds/borders/box-shadow are all rendered in the same plane an intersected with atomically.

@dbaron
Copy link
Member Author

dbaron commented Oct 19, 2021

Related to #926.

dbaron added a commit to dbaron/web-platform-tests that referenced this issue Oct 25, 2021
Add some tests of 3D rendering behavior intended to understand the
behavior related to w3c/csswg-drafts#6238 .

Test 004 tests the behavior change proposed in that issue.  However, in
implementations that fail the earlier tests, test 005 is more relevant
than test 004 to understanding whether the implementation follows the
proposal.
@dbaron
Copy link
Member Author

dbaron commented Oct 26, 2021

Given that @smfr said he's OK with it, and given:

  1. the note in the spec about improved performance/memory use,
  2. that it's what Gecko and Chromium currently do, and
  3. that, given that the 3D context behavior in the spec also matches the Gecko/Chromium behavior and not the WebKit behavior, it seems like it's likely the more Web-compatible behavior.

I'm going to change the editor's draft to specify it this way.

In particular, to expand on (3) a little bit: Given that, in the presence of preserve-3d (or even without it!) WebKit will perform 3D intersection one element in the tree higher (closer to the root) than the spec says to (and what Chromium and Gecko do), it seems that specifying the WebKit behavior along with the spec's current 3D intersection model has a chance of breaking content, since it would move backgrounds (such as those in test 004.tentative in web-platform-tests/wpt#31375) from being 3D intersected with in all engines to being behind the 3D scene. And given point (1) it seems like there's an advantage to doing things this way, so I think it's probably best to do so.

@dbaron dbaron closed this as completed in ac72c9b Oct 26, 2021
dbaron added a commit to dbaron/web-platform-tests that referenced this issue Oct 26, 2021
Add some tests of 3D rendering behavior intended to understand the
behavior related to w3c/csswg-drafts#6238 .

Test 004 tests the behavior change proposed in that issue.  However, in
implementations that fail the earlier tests, test 005 is more relevant
than test 004 to understanding whether the implementation follows the
proposal.

Tests 006 and 007 test that Appendix E is followed within a 3D plane, as
noted in the edit for w3c/csswg-drafts#926 .
dbaron added a commit to dbaron/web-platform-tests that referenced this issue Oct 26, 2021
Add some tests of 3D rendering behavior intended to understand the
behavior related to w3c/csswg-drafts#6238 .

Test 004 tests the behavior change proposed in that issue.  However, in
implementations that fail the earlier tests, test 005 is more relevant
than test 004 to understanding whether the implementation follows the
proposal.

Tests 006 and 007 test that Appendix E is followed within a 3D plane, as
noted in the edit for w3c/csswg-drafts#926 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants