mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Bug 1331272: style: Unify restyle-damage display: none checks.
They were formerly different because we used the element check to cull the traversal. Now this is no longer true, so we can just unify them. Also, update a no-longer up-to-date comment on that. MozReview-Commit-ID: FH5GH7NfI8G Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
747e130295
commit
6f3957a549
1 changed files with 15 additions and 39 deletions
|
@ -769,22 +769,23 @@ pub trait MatchMethods : TElement {
|
||||||
//
|
//
|
||||||
// 2. This is an incremental restyle, but the old display value
|
// 2. This is an incremental restyle, but the old display value
|
||||||
// is none, so there's no effective way for Gecko to get the
|
// is none, so there's no effective way for Gecko to get the
|
||||||
// style source. In this case, we could return either
|
// style source (which is the style context).
|
||||||
|
//
|
||||||
|
// In this case, we could return either
|
||||||
// RestyleDamage::empty(), in the case both displays are
|
// RestyleDamage::empty(), in the case both displays are
|
||||||
// none, or rebuild_and_reflow, otherwise. The first case
|
// none, or rebuild_and_reflow, otherwise.
|
||||||
// should be already handled when calling this function, so
|
|
||||||
// we can assert that the new display value is not none.
|
|
||||||
//
|
//
|
||||||
// Also, this can be a text node (in which case we don't
|
if let Some(old_style) = old_style {
|
||||||
// care of watching the new display value).
|
// FIXME(emilio): This should assert the old style is
|
||||||
//
|
// display: none, but we still can't get an old style
|
||||||
// Unfortunately we can't strongly assert part of this, since
|
// context for other stuff that should give us a style
|
||||||
// we style some nodes that in Gecko never generate a frame,
|
// context source like display: contents, so we fall on the
|
||||||
// like children of replaced content. Arguably, we shouldn't be
|
// safe side here.
|
||||||
// styling those here, but until we implement that we'll have to
|
if new_style.get_box().clone_display() == display::T::none &&
|
||||||
// stick without the assertions.
|
old_style.get_box().clone_display() == display::T::none {
|
||||||
debug_assert!(pseudo.is_none() ||
|
return RestyleDamage::empty();
|
||||||
new_style.get_box().clone_display() != display::T::none);
|
}
|
||||||
|
}
|
||||||
RestyleDamage::rebuild_and_reflow()
|
RestyleDamage::rebuild_and_reflow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -881,31 +882,6 @@ pub trait MatchMethods : TElement {
|
||||||
possibly_expired_animations: &mut Vec<PropertyAnimation>)
|
possibly_expired_animations: &mut Vec<PropertyAnimation>)
|
||||||
-> RestyleDamage
|
-> RestyleDamage
|
||||||
{
|
{
|
||||||
// Here we optimise the case of the style changing but both the
|
|
||||||
// previous and the new styles having display: none. In this
|
|
||||||
// case, we can always optimize the traversal, regardless of the
|
|
||||||
// restyle hint.
|
|
||||||
let this_display = new_primary.get_box().clone_display();
|
|
||||||
if this_display == display::T::none {
|
|
||||||
let old_display = old_primary.map(|old| {
|
|
||||||
old.get_box().clone_display()
|
|
||||||
});
|
|
||||||
|
|
||||||
// If display passed from none to something, then we need to reflow,
|
|
||||||
// otherwise, we don't do anything.
|
|
||||||
let damage = match old_display {
|
|
||||||
Some(display) if display == this_display => {
|
|
||||||
RestyleDamage::empty()
|
|
||||||
}
|
|
||||||
_ => RestyleDamage::rebuild_and_reflow()
|
|
||||||
};
|
|
||||||
|
|
||||||
debug!("Short-circuiting traversal: {:?} {:?} {:?}",
|
|
||||||
this_display, old_display, damage);
|
|
||||||
|
|
||||||
return damage
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the damage and sum up the damage related to pseudo-elements.
|
// Compute the damage and sum up the damage related to pseudo-elements.
|
||||||
let mut damage =
|
let mut damage =
|
||||||
self.compute_restyle_damage(old_primary, new_primary, None);
|
self.compute_restyle_damage(old_primary, new_primary, None);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue