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 upstyle: Make restyle hints handle child combinators better than restyling the entire subtree #16906
Conversation
highfive
commented
May 17, 2017
|
Heads up! This PR modifies the following files: |
highfive
commented
May 17, 2017
|
r? @emilio |
|
Looks great! mostly minor nits and naming shenanigans :) |
| /// restyle work, and thus any `insert()` calls will have no effect. | ||
| #[inline] | ||
| pub fn is_maximum(&self) -> bool { | ||
| self.match_self == 0xff && self.match_later_siblings && self.replacements.is_all() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
heycam
May 18, 2017
Author
Member
I decided to leave this as the numeric literal, as I think it's slightly clearer given we're using it as a bitfield.
| trace!(" > hint was already there"); | ||
| return true; | ||
| } | ||
|
|
||
| // We can ignore the selector flags, since they would have already | ||
| // We can ignore the selector replacements, since they would have already |
This comment has been minimized.
This comment has been minimized.
emilio
May 17, 2017
Member
This comment is talking about the slow selector flags, so I don't think it should be changed.
This comment has been minimized.
This comment has been minimized.
| /// children, the third its grandchildren, and so on. If the most significant | ||
| /// bit it set, it indicates that that selector matching must be re-run for | ||
| /// elements at that depth and all of their descendants. | ||
| match_self: u8, |
This comment has been minimized.
This comment has been minimized.
emilio
May 17, 2017
Member
Could we abstract this and make it a newtype (MatchingDepth(u8)?) that enforces this? I really don't want to think a lot about what 0x01 means if I could do something like: MatchingDepth::just_self() or MatchingDepth::at_depth(x).
Also, I don't think the name of match_self is representative anymore :)
This comment has been minimized.
This comment has been minimized.
heycam
May 17, 2017
Author
Member
Great idea about the newtype!
Regarding the name, WDYT about match_under_self? (I want a name that I can adjust to have a similar field to represent depth to restyle under later siblings, e.g. match_later_siblings or match_under_later_siblings.)
This comment has been minimized.
This comment has been minimized.
| @@ -651,6 +819,8 @@ impl DependencySet { | |||
| let mut combinator = None; | |||
| let mut iter = selector.inner.complex.iter(); | |||
| let mut index = 0; | |||
| let mut child_count = 0; | |||
| let mut descendants = false; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
heycam
May 18, 2017
Author
Member
Just used short names to avoid wrapping lines that used them. Will rename.
| if !descendants => RestyleHint::descendants_at_depth(child_count), | ||
| Some(Combinator::Child) => RestyleHint::descendants(), | ||
| Some(Combinator::Descendant) => RestyleHint::descendants(), | ||
| Some(Combinator::NextSibling) => RestyleHint::later_siblings(), |
This comment has been minimized.
This comment has been minimized.
| @@ -651,6 +819,8 @@ impl DependencySet { | |||
| let mut combinator = None; | |||
| let mut iter = selector.inner.complex.iter(); | |||
| let mut index = 0; | |||
| let mut child_count = 0; | |||
This comment has been minimized.
This comment has been minimized.
|
|
f37f1f4
to
99264ce
|
r=me, thanks! |
|
|
I'm including the https://bugzilla.mozilla.org/show_bug.cgi?id=1289868 changes in this PR, which have also been reviewed by @emilio over there. |
|
@bors-servo r=emilio |
|
|
|
@bors-servo r=emilio |
|
@bors-servo retry |
|
@bors-servo r- Actually I think that's a real test failure. :( |
|
I kind of suspect that Servo's damage calculation might be missing some properties, and that's making our decision to stop restyling invalid. For now I'm going to just always return |
|
@bors-servo r=emilio |
|
|
|
@bors-servo p=1 |
style: Make restyle hints handle child combinators better than restyling the entire subtree <!-- Please describe your changes on the following line: --> This PR reworks `RestyleHint` so that it can store the depth of the tree whose elements we need to re-run selector matching on, when selectors with `>` child combinators are involved. For example, with `div.x > span > em`, if we toggle the `x` attribute on a `div`, we'll re-run selector matching on grandchildren of the `div`, rather than (as we do currently) on every descendants of the `div`. --- <!-- 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: --> - [ ] 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16906) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
style: Make restyle hints handle child combinators better than restyling the entire subtree <!-- Please describe your changes on the following line: --> This PR reworks `RestyleHint` so that it can store the depth of the tree whose elements we need to re-run selector matching on, when selectors with `>` child combinators are involved. For example, with `div.x > span > em`, if we toggle the `x` attribute on a `div`, we'll re-run selector matching on grandchildren of the `div`, rather than (as we do currently) on every descendants of the `div`. --- <!-- 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: --> - [ ] 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16906) <!-- Reviewable:end -->
|
|
|
I posted the analysis of the failing test there, too, btw |
|
Landed #16967 :) |
|
Thanks so much, @emilio! |
heycam commentedMay 17, 2017
•
edited
This PR reworks
RestyleHintso that it can store the depth of the tree whose elements we need to re-run selector matching on, when selectors with>child combinators are involved. For example, withdiv.x > span > em, if we toggle thexattribute on adiv, we'll re-run selector matching on grandchildren of thediv, rather than (as we do currently) on every descendants of thediv../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is