-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Centralize event states in rust-selectors #8162
Conversation
r? @Manishearth |
b3a6f8a
to
eabcb38
Compare
Added rust-selectors rev bump. |
} | ||
// NB: We can't [derive(..)] this because it's defined in rust-selectors, which | ||
// doesn't know about JS<T>. | ||
impl JSTraceable for EventState { fn trace(&self, _trc: *mut JSTracer) {} } |
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.
no_jsmanaged_fields!
is what we should use here (grep the source for it)
Reviewed 15 of 15 files at r2. components/script/dom/htmlinputelement.rs, line 245 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. components/script/dom/htmlinputelement.rs, line 245 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. components/script/dom/htmlinputelement.rs, line 245 [r2] (raw file): Comments from the review on Reviewable.io |
eabcb38
to
a162226
Compare
r- This change is unjustified, seems unnecessary to me (is there a benefit I don’t see?), and the corresponding rust-selectors change (servo/rust-selectors#55) forces users to either keep all state in a single Please explain motivation for this change and the rust-selectors one. |
@SimonSapin: |
Can we discuss in public, where people other than me can find it later? |
@SimonSapin I need to run, and there's not an easy way to convert an email thread to a github issue thread. But feel free to post/summarize, and I can respond in a few hours when I get back. |
A bit more context here now that I have a few minutes (sorry for the delay): My high-level goal here is to fix #6942 by implementing restyle hints in Servo. This logic needs to live at the intersection of layout, style, and rust-selectors, and therefore will understandably involve changes to rust-selectors. Restyle hints work by batching up a series of EventState changes for a given Element and then asking the style system for an upper-bound of the categories of elements (self, subtree, siblings, etc) that may need restyling. In order to ask this question, rust-selectors and layout need a common bitfield type by which to represent a set of event states. Given the dependency tree, this type needs to live in rust-selectors, hence this change. Once we have this common representation, it seems like an obvious simplification to remove the per-state methods from the trait definition and pass this information with a single method. This removes a lot of boilerplate code (duplicated across tree.rs, element.rs, and wrapper.rs), and makes it possible to access the entire set of state values with a single virtual call. More importantly, it eliminates the chicken-and-egg dependency problem that causes Servo to break when rust-selectors adds support for a new EventState. This bit me today with #8142 , and I wanted to prevent it from biting other people. The one downside is the one mentioned in [1], whereby other theoretical consumers without a centralized EventState representation will pay a performance cost when aggregating their state. However, optimizing performance for multiple consumer designs is pretty hard. Any consumer that wants maximal performance is going to want to centralize EventState to take advantage of restyle hints (and subsequent optimizations beyond it), so I'm not convinced that this should block what we do here. [1] #8162 (comment) |
@Ms2ger explained to me that our use of generics allows us to bypass virtual calls on the trait impls (which is super neat!). I think the rest of the points are still valid though. |
https://github.com/SimonSapin/kuchiki is not theoretical. It doesn’t have many users yet (as far as I know?), but there was demand for it repetitively. I’m not buying the preformance thing. As you mentioned @Ms2ger explained, the compiler generates separate code for generic functions/methods for each concrete type arguments. Moving the Repetitive code probably wouldn’t be hard to generate with Please explain motivation in pull request messages. Restyle hints does make servo/rust-selectors#55 seem less gratuitous than it first did in isolation. Still, it’s not clear to me: why does rust-selectors need to know about this bitfield? |
Sorry. The motivation is explained in commit messages and comments of other dependent commits, but I was trying to get this piece landed separately, since it requires me to update Servo's rust-selectors dependency, and I wanted to isolate any issues that might be caused by that step. The larger context here is that @pcwalton and I are investigating what it would take to plug Servo's style system into Gecko. In order to familiarize myself with Servo's style system (and Rust in general), I'm implementing restyle hints.
When testing restyle hints, we need to match against selectors while ignoring the subset of pseudo-selectors corresponding to the EventStates that changed. Suppose a selector However, Another side-benefit is that it consolidates the two existing enumerates of states (EventState and SimpleSelector) into the same library, making it easier to change both of them together (see my complaint about :target). Landing coordinated mutually-dependent changes to multiple libraries is a barrier to contribution that I'd like to remove.
Potentially yes, but we still need to enumerate those states in all of the places I mentioned, making us susceptible to cross-library breakage. All that being said, coalescing the API was an attempt to simplify the API and improve the cross-library ergonomic footguns that I was encountering. We could revert that change if you like without scuttling restyle hints, though I do think that doing so would make our lives harder on the whole. |
Please see my proposed changes in servo/rust-selectors#56 and discuss them there. Let’s block this in the mean time. |
a162226
to
1e16a66
Compare
🔒 Merge conflict |
☔ The latest upstream changes (presumably #8114) made this pull request unmergeable. Please resolve the merge conflicts. |
Probably should start using p=1 for PRs which have a tendency to bitrot often. ( |
This is necessary for those selectors to take advantage of restyle hints.
37fb636
to
79ac365
Compare
@Manishearth r? |
@bors-servo p=1 |
@bors-servo r=pcwalton p=1 |
📌 Commit 79ac365 has been approved by |
Centralize event states in rust-selectors This still needs a rev bump on rust-selectors once servo/rust-selectors#55 gets merged. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8162) <!-- Reviewable:end -->
💔 Test failed - linux-rel |
@bors-servo retry |
⚡ Previous build results for android, gonk, linux-dev, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-rel... |
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt |
This still needs a rev bump on rust-selectors once servo/rust-selectors#55 gets merged.