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
Bug 1332969: stylo: Synchronously do a style update when the device changes #15157
Conversation
…hanges. Ideally this would be lazy, but eventually we're going to need to restyle in RebuildAllStyleData anyway, which would require us to have the style up to date, so no need to complicate our lives. MozReview-Commit-ID: AlmUGRCNm2z Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
Heads up! This PR modifies the following files:
|
} | ||
self.stylesheets_changed = true; |
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.
Why do we need to mark the stylesheets as having changed if the device changes? It seems like we need to recascade the DOM and reevaluate media queries, but stylesheets_changed does more work, no?
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.
We need to reconstruct the style data because different rules may match.
We can definitely be more granular in the future, but that mechanism isn't there right now.
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.
s/may match/may apply/
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.
We need to reconstruct the style data because different rules may match.
Oh ok. So We should put a RESTYLE_SELF | RESTYLE_DESCENDANTS hint on the root then.
We can definitely be more granular in the future, but that mechanism isn't there right now.
My understanding is that the servo architecture already differentiates between "stylesheets changed" and "device changed". What machinery is missing?
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.
I didn't want to do the restyle stuff after I've finished all the medialist work, because gecko has its own control about which media queries have matched and not, and can provide us with an adequate restyle hint if we do the right thing.
Servo does indeed have the concept of "setting a new device", but there are fundamental differences between a servo device and a Gecko device that don't allow us to do that for gecko.
Concretely, in gecko right now the device is represented by the pres context and effectively unique. There's no easy way to compare against a previous state of the pres context (and I think its not bad, but we can't just reuse that piece of code so easily)
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.
Ok - Just add a comment indicating that Gecko doesn't use that machinery?
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.
Oh, and just so that I understand - if Gecko does provide us with such a restyle hint, will it avoid invoke RebuildAllStyleData? Because otherwise we're still going to dirty everything.
I guess I'm probably enough context here that it makes sense for heycam to review it, since he reviewed the media query stuff.
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.
Nope, RebuildAllStyleData
receives a hint and a change hint.
Here is how it works in Gecko. To respond to window resizes, we call In It's quite important for performance that we can quickly evaluate whether the current set of matched |
Oh, and when |
@heycam asked me to comment on this PR. So the thing is that right now we try to reconstruct the style and device data lazily. This changes that so it's sychronous. The background of this is that right now we might fail to flush the device on time. There are two ways to solve it.
The reason why I want to go with (2), is because the RebuildAllStyleData call may/uses to require a restyle, so we need to have the style up-to-date anyway. |
I think we should redo this infrastructure per [1]. However, if you think this PR makes things more correct in the interim, I'm ok with landing it. @bors-servo delegate+ |
✌️ @emilio can now approve this pull request |
Yes, I believe this is the right thing to do in the meantime. @bors-servo r=bholley |
📌 Commit d29fade has been approved by |
Bug 1332969: stylo: Synchronously do a style update when the device changes Ideally this would be lazy, but eventually we're going to need to restyle in RebuildAllStyleData anyway, which would require us to have the style up to date, so no need to complicate our lives. r? @heycam or @upsuper or @bholley <!-- 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/15157) <!-- Reviewable:end -->
💔 Test failed - windows-gnu-dev |
@bors-servo retry |
Bug 1332969: stylo: Synchronously do a style update when the device changes Ideally this would be lazy, but eventually we're going to need to restyle in RebuildAllStyleData anyway, which would require us to have the style up to date, so no need to complicate our lives. r? @heycam or @upsuper or @bholley <!-- 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/15157) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
Ideally this would be lazy, but eventually we're going to need to restyle in
RebuildAllStyleData anyway, which would require us to have the style up to date,
so no need to complicate our lives.
r? @heycam or @upsuper or @bholley
This change is