Skip to content

Conversation

nicoburns
Copy link
Collaborator

@nicoburns nicoburns commented Aug 5, 2025

Draft for design review: does the key idea here (pushing the top-level compute_style_difference up to the embedder) seem like a good idea?

(includes the changes from #222 which is a much more surface-level change)

Servo PR: servo/servo#38479


Objective

  • Give embedder full control over restyle damage computation (functionality built-in to Stylo (e.g. generated restyle_damage_* functions) is exposed as public library functions that the embedded can call into).
  • Remove the need for a separate LayoutDamage type.
  • Make interface/contract of the RestyleDamage type more explicit (by making it a trait)

Changes Made

  • Create TRestyleDamage trait to represent restyle damage
  • Add RestyleDamage associated type to TElement trait
  • Move the top-level compute_style_difference function from the (private) MatchMethods trait to the (public) TElement trait (so that the embedder can implement it).
  • Remove the TElement::compute_layout_damage method (embedders should now use compute_style_difference instead).
  • Make ElementData struct generic over TElement
  • Rename RestyleDamage::reconstruct to ::set_rebuild_pseudos
    (because that is the scenario in which it's called, and pseudos having changed doesn't necessarily imply that the entire box needs to be reconstructed (although Servo will presumably continue to do that for now))

Notes

There are a few places where Servo does different things to Gecko around RestyleDamage:

A key one is that in Gecko RestyleDamage::is_empty() will be false (triggering a StyleChange::Changed to be returned to Stylo) if any style property has changed. Whereas in Servo this only happens if one of the properties we check for damage has changed.

We should check what the correct semantics are here and whether Servo's implementation is correct/valid.

delan and others added 7 commits August 2, 2025 14:30
Any ancestors of this commit are from upstream mozilla-central, with
some filtering and renaming. Our patches and sync tooling start here.

The sync tooling has all been squashed into this commit, based on:
https://github.com/servo/stylo/commits/64731e10dc8ef87ef52aa2fb9f988c3b2530f3a7
This is a rebase of 22df130

Signed-off-by: Oriol Brufau <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
There is no point in setting this flag to true when it's no longer doing
anything, `transition-behavior` is now enabled unconditionally.

Signed-off-by: Oriol Brufau <[email protected]>
@nicoburns nicoburns force-pushed the associated-damage-type branch 3 times, most recently from 0b1623f to 4fe9a9a Compare August 5, 2025 15:20
…servo#222)

* Simplify restyle damage macros

Signed-off-by: Nico Burns <[email protected]>

* Don't diff custom properties if we've already set damage anyway

Signed-off-by: Nico Burns <[email protected]>

---------

Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants