Skip to content

Make RestyleDamage an associated type and make embedder responsible for all damage computation#224

Draft
nicoburns wants to merge 26 commits intoservo:mainfrom
nicoburns:associated-damage-type
Draft

Make RestyleDamage an associated type and make embedder responsible for all damage computation#224
nicoburns wants to merge 26 commits intoservo:mainfrom
nicoburns:associated-damage-type

Conversation

@nicoburns
Copy link
Copy Markdown
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 11 commits March 5, 2026 04:42
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 ab75cec

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
- Bump stylo_* to 0.13.0
- Bump selectors to 0.36.0

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
TimvdLippe and others added 6 commits March 8, 2026 16:16
Required for firing events for contenteditable

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This way it can be shared among Gecko and Servo.

Stylo PR: servo/servo#43085
Upstream: https://bugzilla.mozilla.org/show_bug.cgi?id=2021743

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
…holder` and `::marker` (servo#322)

The `::placeholder` pseudo element should be a public pseudo element.
And, both `::placeholder` and `::marker` should have a property
restriction as defined in the spec. In stylo, the property restriction
has been computed in `PropertyFlags`.

Servo PR: servo/servo#43053

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This enables `jump-start`, `jump-end`, `jump-none`, `jump-both`.

The feature is left here 7 years ago. As tested with examples, all
`step-easing-function`s work as expected.

Servo PR: servo/servo#43061

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>>
This change does two things:
1. Restores Servo's original theme colors from before support for system
color was added.
2. Eliminates the selection of default system color based on the color
scheme of the system. This code was dead code since
`is_dark_color_scheme` always returns `false`.

Servo PR: servo/servo#43107

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Adds a new file `style/device/mod.rs` with the `Device` logic that is
common for Gecko and Servo.

The Gecko-specific logic for `Device` is moved into
`style/device/gecko.rs`, and the previous `style/gecko/media_queries.rs`
is removed.

The Servo-specific logic for `Device` is moved into
`style/device/servo.rs`. The previous `servo/media_queries.rs` also had
logic for media features, which is now moved into
`style/servo/media_features.rs` for consistency with Gecko.

Servo PR: servo/servo#43146

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Loirooriol and others added 9 commits March 11, 2026 13:05
This makes Servo use the same `ListStyleType`  as Gecko. In particular:
- `counter()` and `counters()` will no longer accept a `none` style.
- `list-style-type` will now accept a string.
- Both `list-style-type` and counters will now accept arbitrary
keywords. However, Servo's flavor of Stylo will still reject
`@counter-style` rules. So non-predefined keywords will just default to
`decimal`.
- Both `list-style-type` and counters will now accept `symbols()`.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This PR enables parsing `first-letter` pseudo element for servo. An
accompanying servo PR (servo/servo#43027) is
open

---------

Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
This isn't really used. Nowadays we always test incremental layout as
it's considered an essential feature of the functioning of Servo.

After servo/servo#43207, Servo will no longer use this feature.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
The independently versioned crates in this workspace haven't had any
changes since the last release according to git.
servo#330 moved the module into
`style/device` but forgot to remove the old declaration. That's why
`cargo fmt` currently fails on `main`:
```
Error writing files: failed to resolve mod `media_queries`: /home/alaska/stylo/style/gecko/media_queries.rs does not exist
```

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Signed-off-by: Nico Burns <nico@nicoburns.com>
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.