Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd initial support for stacking contexts to layout_2020 #25763
Conversation
highfive
commented
Feb 14, 2020
4906a75
to
a1f3cea
| pub(crate) enum StackingContextType { | ||
| Real, | ||
| PseudoPositioned, | ||
| PseudoFloat, |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Feb 14, 2020
Member
The spec uses the phrase “treat the element as if it created a new stacking context” a third time: for “inline-block and inline-table elements”. I think this should generalize to non-replaced atomic inline-level elements/boxes.
This comment has been minimized.
This comment has been minimized.
mrobinson
Feb 17, 2020
Author
Member
Nice catch! I plan to add support for this kind of pseudo stacking context in a followup change, if that's okay with you. Adding it allows more tests to pass once support is added for sorting the fragments inside a stacking context.
| return a.z_index.cmp(&b.z_index); | ||
| } | ||
|
|
||
| match (a.context_type, b.context_type) { |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Feb 14, 2020
Member
Instead of this enum being part of the sort, what do you think of having separate Vecs for each categories? (I’m not saying we should do that, I haven’t thought through the advantages or downsides of each approach.)
This comment has been minimized.
This comment has been minimized.
mrobinson
Feb 17, 2020
Author
Member
So it's essentially a tradeoff between sorting one slightly larger Vec of stacking contexts versus sorting three or four smaller ones. I'm not sure which is better, but I've tried to more-or-less copy the design of the old layout system which went through a process of iteration and optimization.
| if !self.style.get_box().transform.0.is_empty() { | ||
| return self.style.get_position().z_index.integer_or(0); | ||
| } |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Feb 14, 2020
Member
My reading of https://drafts.csswg.org/css-transforms/#transform-rendering is that this should be removed:
For elements whose layout is governed by the CSS box model, any value other than
nonefor thetransformproperty results in the creation of a stacking context. Implementations must paint the layer it creates, within its parent stacking context, at the same stacking order that would be used if it were a positioned element withz-index: 0. If an element with a transform is positioned, thez-indexproperty applies as described in [CSS2], except thatautois treated as 0 since a new stacking context is always created.
This comment has been minimized.
This comment has been minimized.
mrobinson
Feb 17, 2020
Author
Member
This is quite odd, because Gecko has a strange behavior here that Servo has been replicating. Observe how this particular file is rendered in Gecko:
<div style="position: absolute; top: 2px; z-index: 2; background: green; width: 100px; height: 100px;"></div>
<div style="background: blue; transform: rotate(45deg); z-index: 3; width: 100px; height: 100px;"></div>
In Gecko, the z-index of the transformed div is taken into account, while in Chromium and WebKit it is not.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Feb 17, 2020
Member
This is arguably a Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1256980
Another bit of relevant spec is https://drafts.csswg.org/css2/visuren.html#z-index with “Applies to: positioned elements”
This comment has been minimized.
This comment has been minimized.
mrobinson
Feb 17, 2020
Author
Member
Oh, thanks for finding that bug. I've pushed a new version of the branch which removes this, bringing layout_2020 in line with WebKit and Blink.
This adds very rudimentary support for paint order in stacking context. In particular z-index is now handled properly, apart from issues with hoisted fragments.
a1f3cea
to
4a2787b
|
Looks good, thanks! @bors-servo r+ |
|
|
Add initial support for stacking contexts to layout_2020 These changes add initial support for stacking contexts, enabling some parts of z-index to work properly. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
Not sure what could be causing this failure on the non-Layout 2020 test run. |
This is a symptom of #24726 @bors-servo retry |
Add initial support for stacking contexts to layout_2020 These changes add initial support for stacking contexts, enabling some parts of z-index to work properly. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
mrobinson commentedFeb 14, 2020
These changes add initial support for stacking contexts, enabling some parts of z-index to work properly.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors