mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Bug 1325734 - Simplify ElementData and eliminate the concept of consuming styles. r=emilio
This commit is contained in:
parent
4558efbca5
commit
3fcfc9c5fc
12 changed files with 202 additions and 360 deletions
|
@ -660,16 +660,22 @@ pub trait MatchMethods : TElement {
|
|||
// better, factor it out/make it a bit more generic so Gecko
|
||||
// can decide more easily if it knows that it's a child of
|
||||
// replaced content, or similar stuff!
|
||||
let damage = {
|
||||
debug_assert!(!data.has_current_styles());
|
||||
let previous_values = data.get_styles().map(|x| &x.primary.values);
|
||||
match self.existing_style_for_restyle_damage(previous_values, None) {
|
||||
Some(ref source) => RestyleDamage::compute(source, &shared_style.values),
|
||||
None => RestyleDamage::rebuild_and_reflow(),
|
||||
}
|
||||
let maybe_damage = {
|
||||
let previous = data.get_styles().map(|x| &x.primary.values);
|
||||
let existing = self.existing_style_for_restyle_damage(previous, None);
|
||||
existing.map(|e| RestyleDamage::compute(e, &shared_style.values))
|
||||
};
|
||||
if let Some(d) = maybe_damage {
|
||||
data.restyle_mut().damage |= d;
|
||||
}
|
||||
|
||||
// We never put elements with pseudo style into the style sharing cache,
|
||||
// so we can just mint an ElementStyles directly here.
|
||||
//
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1329361
|
||||
let styles = ElementStyles::new(shared_style);
|
||||
data.set_styles(styles);
|
||||
|
||||
data.finish_styling(ElementStyles::new(shared_style), damage);
|
||||
return StyleSharingResult::StyleWasShared(i)
|
||||
}
|
||||
Err(miss) => {
|
||||
|
@ -857,7 +863,10 @@ pub trait MatchMethods : TElement {
|
|||
damage
|
||||
};
|
||||
|
||||
data.finish_styling(new_styles, damage);
|
||||
if data.has_styles() {
|
||||
data.restyle_mut().damage |= damage;
|
||||
}
|
||||
data.set_styles(new_styles);
|
||||
}
|
||||
|
||||
/// Given the old and new styling results, compute the final restyle damage.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue