style: Remove damage_handled, and use a reconstructed_ancestor bit instead.

Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 8KK0YfhiS2
This commit is contained in:
Emilio Cobos Álvarez 2017-06-13 14:13:24 +02:00
parent f9c268922d
commit dc521b2799
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 30 additions and 58 deletions

View file

@ -111,9 +111,9 @@ use std::thread;
use style::animation::Animation; use style::animation::Animation;
use style::context::{QuirksMode, ReflowGoal, SharedStyleContext}; use style::context::{QuirksMode, ReflowGoal, SharedStyleContext};
use style::context::{StyleSystemOptions, ThreadLocalStyleContextCreationInfo}; use style::context::{StyleSystemOptions, ThreadLocalStyleContextCreationInfo};
use style::data::StoredRestyleHint;
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode}; use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
use style::error_reporting::{NullReporter, RustLogReporter}; use style::error_reporting::{NullReporter, RustLogReporter};
use style::invalidation::element::restyle_hints::RestyleHint;
use style::logical_geometry::LogicalPoint; use style::logical_geometry::LogicalPoint;
use style::media_queries::{Device, MediaList, MediaType}; use style::media_queries::{Device, MediaList, MediaType};
use style::selector_parser::SnapshotMap; use style::selector_parser::SnapshotMap;
@ -1119,7 +1119,7 @@ impl LayoutThread {
let el = node.as_element().unwrap(); let el = node.as_element().unwrap();
if let Some(mut d) = element.mutate_data() { if let Some(mut d) = element.mutate_data() {
if d.has_styles() { if d.has_styles() {
d.ensure_restyle().hint.insert(StoredRestyleHint::subtree()); d.ensure_restyle().hint.insert(RestyleHint::restyle_subtree());
} }
} }
if let Some(p) = el.parent_element() { if let Some(p) = el.parent_element() {
@ -1155,7 +1155,7 @@ impl LayoutThread {
if needs_dirtying { if needs_dirtying {
if let Some(mut d) = element.mutate_data() { if let Some(mut d) = element.mutate_data() {
if d.has_styles() { if d.has_styles() {
d.ensure_restyle().hint.insert(StoredRestyleHint::subtree()); d.ensure_restyle().hint.insert(RestyleHint::restyle_subtree());
} }
} }
} }

View file

@ -357,19 +357,12 @@ pub struct RestyleData {
/// for this element, its children, and its descendants. /// for this element, its children, and its descendants.
pub hint: RestyleHint, pub hint: RestyleHint,
/// Whether we reframed/reconstructed any ancestor or self.
pub reconstructed_ancestor: bool,
/// The restyle damage, indicating what kind of layout changes are required /// The restyle damage, indicating what kind of layout changes are required
/// afte restyling. /// afte restyling.
pub damage: RestyleDamage, pub damage: RestyleDamage,
/// The restyle damage that has already been handled by our ancestors, and does
/// not need to be applied again at this element. Only non-empty during the
/// traversal, once ancestor damage has been calculated.
///
/// Note that this optimization mostly makes sense in terms of Gecko's top-down
/// frame constructor and change list processing model. We don't bother with it
/// for Servo for now.
#[cfg(feature = "gecko")]
pub damage_handled: RestyleDamage,
} }
impl RestyleData { impl RestyleData {
@ -377,28 +370,6 @@ impl RestyleData {
pub fn has_invalidations(&self) -> bool { pub fn has_invalidations(&self) -> bool {
self.hint.has_self_invalidations() self.hint.has_self_invalidations()
} }
/// Returns damage handled.
#[cfg(feature = "gecko")]
pub fn damage_handled(&self) -> RestyleDamage {
self.damage_handled
}
/// Returns damage handled (always empty for servo).
#[cfg(feature = "servo")]
pub fn damage_handled(&self) -> RestyleDamage {
RestyleDamage::empty()
}
/// Sets damage handled.
#[cfg(feature = "gecko")]
pub fn set_damage_handled(&mut self, d: RestyleDamage) {
self.damage_handled = d;
}
/// Sets damage handled. No-op for Servo.
#[cfg(feature = "servo")]
pub fn set_damage_handled(&mut self, _: RestyleDamage) {}
} }
/// Style system data associated with an Element. /// Style system data associated with an Element.

View file

@ -697,8 +697,8 @@ trait PrivateMatchMethods: TElement {
// for followup work to make the optimization here more optimal by considering // for followup work to make the optimization here more optimal by considering
// each bit individually. // each bit individually.
let skip_applying_damage = let skip_applying_damage =
restyle.damage_handled.contains(RestyleDamage::reconstruct()) || restyle.damage.contains(RestyleDamage::reconstruct()) ||
restyle.damage.contains(RestyleDamage::reconstruct()); restyle.reconstructed_ancestor;
let difference = self.compute_style_difference(&old_values, let difference = self.compute_style_difference(&old_values,
&new_values, &new_values,

View file

@ -297,8 +297,8 @@ pub trait DomTraversal<E: TElement> : Sync {
if let Some(parent) = el.traversal_parent() { if let Some(parent) = el.traversal_parent() {
let parent_data = parent.borrow_data().unwrap(); let parent_data = parent.borrow_data().unwrap();
let going_to_reframe = parent_data.get_restyle().map_or(false, |r| { let going_to_reframe = parent_data.get_restyle().map_or(false, |r| {
(r.damage | r.damage_handled()) r.reconstructed_ancestor ||
.contains(RestyleDamage::reconstruct()) r.damage.contains(RestyleDamage::reconstruct())
}); });
let mut is_before_or_after_pseudo = false; let mut is_before_or_after_pseudo = false;
@ -730,14 +730,16 @@ pub fn recalc_style_at<E, D>(traversal: &D,
DontLog) && DontLog) &&
(has_dirty_descendants_for_this_restyle || (has_dirty_descendants_for_this_restyle ||
!propagated_hint.is_empty()) { !propagated_hint.is_empty()) {
let damage_handled = data.get_restyle().map_or(RestyleDamage::empty(), |r| { let reconstructed_ancestor = data.get_restyle().map_or(false, |r| {
r.damage_handled() | r.damage.handled_for_descendants() r.reconstructed_ancestor ||
r.damage.contains(RestyleDamage::reconstruct())
}); });
preprocess_children::<E, D>(
preprocess_children::<E, D>(context, context,
element, element,
propagated_hint, propagated_hint,
damage_handled); reconstructed_ancestor,
)
} }
// If we are in a restyle for reconstruction, drop the existing restyle // If we are in a restyle for reconstruction, drop the existing restyle
@ -840,12 +842,15 @@ fn compute_style<E, D>(_traversal: &D,
} }
} }
fn preprocess_children<E, D>(context: &mut StyleContext<E>, fn preprocess_children<E, D>(
element: E, context: &mut StyleContext<E>,
propagated_hint: RestyleHint, element: E,
damage_handled: RestyleDamage) propagated_hint: RestyleHint,
where E: TElement, reconstructed_ancestor: bool,
D: DomTraversal<E>, )
where
E: TElement,
D: DomTraversal<E>,
{ {
trace!("preprocess_children: {:?}", element); trace!("preprocess_children: {:?}", element);
@ -880,9 +885,7 @@ fn preprocess_children<E, D>(context: &mut StyleContext<E>,
// If the child doesn't have pre-existing RestyleData and we don't have // If the child doesn't have pre-existing RestyleData and we don't have
// any reason to create one, avoid the useless allocation and move on to // any reason to create one, avoid the useless allocation and move on to
// the next child. // the next child.
if propagated_hint.is_empty() && if !reconstructed_ancestor && propagated_hint.is_empty() && !child_data.has_restyle() {
damage_handled.is_empty() &&
!child_data.has_restyle() {
continue; continue;
} }
@ -890,10 +893,8 @@ fn preprocess_children<E, D>(context: &mut StyleContext<E>,
// Propagate the parent restyle hint, that may make us restyle the whole // Propagate the parent restyle hint, that may make us restyle the whole
// subtree. // subtree.
restyle_data.reconstructed_ancestor = reconstructed_ancestor;
restyle_data.hint.insert(propagated_hint); restyle_data.hint.insert(propagated_hint);
// Store the damage already handled by ancestors.
restyle_data.set_damage_handled(damage_handled);
} }
} }