Bug 1383001: Remove (mostly) unused has_current_styles. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 22 Jul 2017 14:53:57 +0200
changeset 613781 85ac7449a19477fc5a13e2a287ebae74e655a749
parent 613776 286907bac7aae14a13b308c5203cd581637045f9
child 613782 8d802b35960f6862abea72958683c7b322926634
push id69842
push userbmo:emilio+bugs@crisal.io
push dateSat, 22 Jul 2017 13:14:27 +0000
reviewersheycam
bugs1383001
milestone56.0a1
Bug 1383001: Remove (mostly) unused has_current_styles. r?heycam MozReview-Commit-ID: DV9HfvbUjBY
servo/components/style/dom.rs
servo/components/style/style_resolver.rs
servo/components/style/traversal.rs
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -465,25 +465,16 @@ pub trait TElement : Eq + PartialEq + De
     fn has_snapshot(&self) -> bool;
 
     /// Returns whether the current snapshot if present has been handled.
     fn handled_snapshot(&self) -> bool;
 
     /// Flags this element as having handled already its snapshot.
     unsafe fn set_handled_snapshot(&self);
 
-    /// Returns whether the element's styles are up-to-date.
-    fn has_current_styles(&self, data: &ElementData) -> bool {
-        if self.has_snapshot() && !self.handled_snapshot() {
-            return false;
-        }
-
-        data.has_styles() && !data.has_invalidations()
-    }
-
     /// Returns whether the element's styles are up-to-date for |traversal_flags|.
     fn has_current_styles_for_traversal(
         &self,
         data: &ElementData,
         traversal_flags: TraversalFlags,
     ) -> bool {
         if traversal_flags.for_animation_only() {
             // In animation-only restyle we never touch snapshots and don't
--- a/servo/components/style/style_resolver.rs
+++ b/servo/components/style/style_resolver.rs
@@ -46,27 +46,17 @@ pub struct PrimaryStyle {
 
 fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
 where
     E: TElement,
     F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R,
 {
     let parent_el = element.inheritance_parent();
     let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
-    let parent_style = parent_data.as_ref().map(|d| {
-        // Sometimes Gecko eagerly styles things without processing
-        // pending restyles first. In general we'd like to avoid this,
-        // but there can be good reasons (for example, needing to
-        // construct a frame for some small piece of newly-added
-        // content in order to do something specific with that frame,
-        // but not wanting to flush all of layout).
-        debug_assert!(cfg!(feature = "gecko") ||
-                      parent_el.unwrap().has_current_styles(d));
-        d.styles.primary()
-    });
+    let parent_style = parent_data.as_ref().map(|d| d.styles.primary());
 
     let mut layout_parent_el = parent_el.clone();
     let layout_parent_data;
     let mut layout_parent_style = parent_style;
     if parent_style.map_or(false, |s| s.is_display_contents()) {
         layout_parent_el = Some(layout_parent_el.unwrap().layout_parent());
         layout_parent_data = layout_parent_el.as_ref().unwrap().borrow_data().unwrap();
         layout_parent_style = Some(layout_parent_data.styles.primary());
--- a/servo/components/style/traversal.rs
+++ b/servo/components/style/traversal.rs
@@ -371,17 +371,17 @@ pub trait DomTraversal<E: TElement> : Sy
     fn should_cull_subtree(
         &self,
         context: &mut StyleContext<E>,
         parent: E,
         parent_data: &ElementData,
     ) -> bool {
         // See the comment on `cascade_node` for why we allow this on Gecko.
         debug_assert!(cfg!(feature = "gecko") ||
-                      parent.has_current_styles(parent_data));
+                      parent.has_current_styles_for_traversal(parent_data, context.shared.traversal_flags));
 
         // If the parent computed display:none, we don't style the subtree.
         if parent_data.styles.is_display_none() {
             debug!("Parent {:?} is display:none, culling traversal", parent);
             return true;
         }
 
         // Gecko-only XBL handling.