Skip to content
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

Add initial support for stacking contexts to layout_2020 #25763

Merged
merged 3 commits into from Feb 17, 2020

Conversation

@mrobinson
Copy link
Member

mrobinson commented Feb 14, 2020

These changes add initial support for stacking contexts, enabling some parts of z-index to work properly.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___
@highfive
Copy link

highfive commented Feb 14, 2020

Heads up! This PR modifies the following files:

  • @jgraham: tests/wpt/include-layout-2020.ini
  • @emilio: components/style/properties/longhands/position.mako.rs
@mrobinson mrobinson changed the title Add initial support for stacking contexts Add initial support for stacking contexts to layout_2020 Feb 14, 2020
@mrobinson mrobinson requested a review from SimonSapin Feb 14, 2020
mrobinson added 2 commits Feb 13, 2020
This adds an intermediary data structure that allows the display list
builder to move through the fragment tree in stacking context painting
order. Spatial nodes are built during this phase and all display list
items are added to the end of the display list.
@mrobinson mrobinson force-pushed the mrobinson:stacking-contexts-v1 branch 2 times, most recently from 4906a75 to a1f3cea Feb 14, 2020
pub(crate) enum StackingContextType {
Real,
PseudoPositioned,
PseudoFloat,

This comment has been minimized.

Copy link
@SimonSapin

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.

Copy link
@mrobinson

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.

Copy link
@SimonSapin

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.

Copy link
@mrobinson

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);
}
Comment on lines 211 to 213

This comment has been minimized.

Copy link
@SimonSapin

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 none for the transform property 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 with z-index: 0. If an element with a transform is positioned, the z-index property applies as described in [CSS2], except that auto is treated as 0 since a new stacking context is always created.

This comment has been minimized.

Copy link
@mrobinson

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.

Copy link
@SimonSapin

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.

Copy link
@mrobinson

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.

@SimonSapin SimonSapin added this to In progress in Layout 2020 via automation Feb 14, 2020
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.
@mrobinson mrobinson force-pushed the mrobinson:stacking-contexts-v1 branch from a1f3cea to 4a2787b Feb 17, 2020
@SimonSapin
Copy link
Member

SimonSapin commented Feb 17, 2020

Looks good, thanks!

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

📌 Commit 4a2787b has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

Testing commit 4a2787b with merge 3198864...

bors-servo added a commit that referenced this pull request Feb 17, 2020
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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

💔 Test failed - status-taskcluster

@mrobinson
Copy link
Member Author

mrobinson commented Feb 17, 2020

+ ./mach filter-intermittents wpt-jsonsummary.log --log-intermittents intermittents.log --log-filteredsummary filtered-wpt-errorsummary.log --tracker-api default --reporter-api default
1 unexpected results that are NOT known-intermittents:
  ▶ FAIL [expected PASS] /css/CSS2/margin-padding-clear/margin-bottom-042.xht
  │   → /css/CSS2/margin-padding-clear/margin-bottom-042.xht 54a9df64f1476dd12020019d7cf22ac34d727bc0
  │   → /css/CSS2/reference/ref-no-vert-space-between.xht 361532ece0d2a0454900e9de0bb71598ea4a4295
  └   → Screenshot is solid color 0xFFFFFF for /css/CSS2/margin-padding-clear/margin-bottom-042.xht

Not sure what could be causing this failure on the non-Layout 2020 test run.

@SimonSapin
Copy link
Member

SimonSapin commented Feb 17, 2020

Screenshot is solid color 0xFFFFFF

This is a symptom of #24726

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

Testing commit 4a2787b with merge 13ff7ce...

bors-servo added a commit that referenced this pull request Feb 17, 2020
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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

☀️ Test successful - status-taskcluster
Approved by: SimonSapin
Pushing 13ff7ce to master...

@bors-servo bors-servo merged commit 4a2787b into servo:master Feb 17, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
Layout 2020 automation moved this from In progress to Merged / resolved Feb 17, 2020
@mrobinson mrobinson deleted the mrobinson:stacking-contexts-v1 branch Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Layout 2020
  
Merged / resolved
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.