Make RestyleDamage
an associated type and make embedder responsible for all damage computation
#224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
restyle_damage_*
functions) is exposed as public library functions that the embedded can call into).LayoutDamage
type.RestyleDamage
type more explicit (by making it a trait)Changes Made
TRestyleDamage
trait to represent restyle damageRestyleDamage
associated type toTElement
traitcompute_style_difference
function from the (private)MatchMethods
trait to the (public)TElement
trait (so that the embedder can implement it).TElement::compute_layout_damage
method (embedders should now usecompute_style_difference
instead).ElementData
struct generic overTElement
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 befalse
(triggering aStyleChange::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.