Closed Bug 1364824 Opened 4 years ago Closed 4 years ago

stylo: Implement PostRebuildAllStyleDataEvent


(Core :: CSS Parsing and Computation, enhancement)

53 Branch
Not set



Tracking Status
firefox55 --- fixed


(Reporter: xidorn, Assigned: emilio)




(1 file, 1 obsolete file)

@counter-style needs a mechanism to invalidate all style data (recompute all data in style structs) after rule changes. It currently uses PostRebuildAllStyleDataEvent in Gecko to do so asynchronously from nsPresContext::FlushCounterStyles. We probably need something similar in Stylo.
emilio, could you provide some suggestion on how should we do this?

It seems to me RebuildAllStyleData in ServoRestyleManager is actually async somehow. I wonder whether we can just duplicate some of its code to Post*Event one...
Flags: needinfo?(emilio+bugs)
Duplicate of this bug: 1360805
You mean async in the sense that the restyle is posted asynchronously? If so, yes.

If you want it synchronously you should be able to do:


Would that work for you?
Flags: needinfo?(emilio+bugs)
Comment on attachment 8867617 [details]
Bug 1364824: Implement ServoRestyleManager::PostRebuildAllStyleDataEvent.

::: commit-message-72dbf:4
(Diff revision 1)
> +Bug 1364824: Implement ServoRestyleManager::PostRebuildAllStyleDataEvent. r?heycam
> +
> +MozReview-Commit-ID: I9HmM9ZMB2c
> +Signed-off-by: Emilio Cobos Álvarez <>

Probably don't need this line.
Attachment #8867617 - Flags: review?(cam) → review+
Comment on attachment 8867624 [details]
Bug 1364824: Make RebuildAllStyleData's flush async too.

OK, let's try.
Attachment #8867624 - Flags: review?(cam) → review+
Comment on attachment 8867624 [details]
Bug 1364824: Make RebuildAllStyleData's flush async too.

::: servo/components/style/gecko/
(Diff revision 1)
>  impl PerDocumentStyleDataImpl {
>      /// Reset the device state because it may have changed.
>      ///
>      /// Implies also a stylesheet flush.
>      pub fn reset_device(&mut self, guard: &SharedRwLockReadGuard) {

> error: unused variable: `guard`
It seems somehow the patch doesn't quite work :/

The first patch doesn't fix the issue of bug 1328319, and the second patch has startup crash.
The second patch doesn't work because I forgot to force_dirty the stylesheets, and because we definitely rely on it being sync (some font-face tests assert without it).

I'll land the first patch because it fixes some font-face tests:

Then file a bug to make the flush async, which requires a few more changes.
Attachment #8867624 - Attachment is obsolete: true
Pushed by
Implement ServoRestyleManager::PostRebuildAllStyleDataEvent. r=heycam
Blocks: 1364862
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Assignee: nobody → emilio
You need to log in before you can comment on or make changes to this bug.