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
style: Split the invalidation processing from the invalidator step. #18847
Conversation
Heads up! This PR modifies the following files:
|
r? @heycam or @SimonSapin This is just moving code around, no behavior change (apart from introducing the |
9378669
to
0023ceb
Compare
I ended up working more on top of this, so please review each commit individually. Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -49,10 +49,11 @@ where | |||
} | |||
|
|||
/// A collector for state and attribute invalidations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this comment now that these things are called processors rather than collectors?
@@ -33,12 +33,61 @@ pub trait InvalidationCollector { | |||
) -> bool | |||
where | |||
E: TElement; | |||
|
|||
/// Returns whether a given element should process its descendants. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I guess it's the process that processes the descendants, not the element. So maybe "Returns whether the invalidation process should process the descendants of the given element."
Also, document what data
is, here and on the other functions?
/// any). | ||
fn recursion_limit_exceeded<E>( | ||
&self, | ||
_element: E, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: odd to use "_" in a trait function declaration.
let invalidated_descendants = child_invalidator.invalidate_descendants( | ||
&invalidations_for_descendants | ||
); | ||
|
||
// The child may not be a flattened tree child of the current element, | ||
// but may be arbitrarily deep. | ||
// | ||
// Since we keep the traversal flags in terms of the flattened tree, | ||
// we need to propagate it as appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems to be describing what we do inside the invalidated_descendants
implementation, which could be anything on some abritrary InvalidationProcessor. This comment is already duplicated in the (one) invalidated_descendants
implementation so I think we should just drop this comment here.
@@ -22,6 +22,11 @@ pub trait InvalidationProcessor<E> | |||
where | |||
E: TElement, | |||
{ | |||
/// Whether an invalidation that only leaves an eager pseudo-element like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not sure what you mean by "leaves".)
This is the first step in reusing the invalidation machinery for other stuff, potentially including QuerySelector / QuerySelectorAll.
…an InvalidationProcessor trait. Ditto, no change in behavior.
I think invalidated_descendants was buggy, and this fixes it.
This would allow querySelector / querySelectorAll to mutate the list of matched nodes as it sees fit.
832b864
to
e447f81
Compare
@bors-servo r=heycam p=1 |
📌 Commit e447f81 has been approved by |
style: Split the invalidation processing from the invalidator step. This is the first step in reusing the invalidation machinery for other stuff, potentially including QuerySelector / QuerySelectorAll. <!-- 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/18847) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
This is the first step in reusing the invalidation machinery for other stuff,
potentially including QuerySelector / QuerySelectorAll.
This change is