From 42f5aea76a58b2885dfdf3a59067bc87bb7c784a Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 5 Apr 2017 18:30:46 -0700 Subject: [PATCH] Remove shareable boolean from ComputedValues and simplify code. This code is all vestigial at this point, presumably after a refactoring. MozReview-Commit-ID: CV0lKMStq13 --- components/style/matching.rs | 36 +++++-------------- components/style/properties/gecko.mako.rs | 5 --- .../style/properties/properties.mako.rs | 13 ++----- components/style/traversal.rs | 12 +++---- 4 files changed, 14 insertions(+), 52 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index 9a8a45fe2e0..ed77ae54557 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -15,7 +15,7 @@ use cascade_info::CascadeInfo; use context::{SequentialTask, SharedStyleContext, StyleContext}; use data::{ComputedStyle, ElementData, ElementStyles, RestyleData}; use dom::{AnimationRules, SendElement, TElement, TNode}; -use properties::{CascadeFlags, ComputedValues, SHAREABLE, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade}; +use properties::{CascadeFlags, ComputedValues, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade}; use properties::longhands::display::computed_value as display; use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_CSS_ANIMATIONS, RestyleHint}; use rule_tree::{CascadeLevel, RuleTree, StrongRuleNode}; @@ -430,15 +430,6 @@ pub enum StyleSharingResult { StyleWasShared(usize), } -/// Callers need to pass several boolean flags to cascade_primary_or_pseudo. -/// We encapsulate them in this struct to avoid mixing them up. -/// -/// FIXME(pcwalton): Unify with `CascadeFlags`, perhaps? -struct CascadeBooleans { - shareable: bool, - animate: bool, -} - trait PrivateMatchMethods: TElement { /// Returns the closest parent element that doesn't have a display: contents /// style (and thus generates a box). @@ -543,13 +534,9 @@ trait PrivateMatchMethods: TElement { fn cascade_internal(&self, context: &StyleContext, primary_style: &ComputedStyle, - pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>, - booleans: &CascadeBooleans) + pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>) -> Arc { let mut cascade_flags = CascadeFlags::empty(); - if booleans.shareable { - cascade_flags.insert(SHAREABLE) - } if self.skip_root_and_item_based_display_fixup() { cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) } @@ -566,7 +553,7 @@ trait PrivateMatchMethods: TElement { data: &mut ElementData, pseudo: Option<&PseudoElement>, possibly_expired_animations: &mut Vec, - booleans: CascadeBooleans) { + animate: bool) { // Collect some values. let (mut styles, restyle) = data.styles_and_restyle_mut(); let mut primary_style = &mut styles.primary; @@ -577,10 +564,10 @@ trait PrivateMatchMethods: TElement { // Compute the new values. let mut new_values = self.cascade_internal(context, primary_style, - &pseudo_style, &booleans); + &pseudo_style); // Handle animations. - if booleans.animate { + if animate { self.process_animations(context, &mut old_values, &mut new_values, @@ -1177,18 +1164,14 @@ pub trait MatchMethods : TElement { /// starting any new transitions or animations. fn cascade_element(&self, context: &mut StyleContext, - mut data: &mut AtomicRefMut, - primary_is_shareable: bool) + mut data: &mut AtomicRefMut) { let mut possibly_expired_animations = vec![]; // Cascade the primary style. self.cascade_primary_or_pseudo(context, data, None, &mut possibly_expired_animations, - CascadeBooleans { - shareable: primary_is_shareable, - animate: true, - }); + /* animate = */ true); // Check whether the primary style is display:none. let display_none = data.styles().primary.values().get_box().clone_display() == @@ -1214,10 +1197,7 @@ pub trait MatchMethods : TElement { let animate = pseudo.is_before_or_after(); self.cascade_primary_or_pseudo(context, data, Some(&pseudo), &mut possibly_expired_animations, - CascadeBooleans { - shareable: false, - animate: animate, - }); + animate); } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2d55fd3c475..2d8424ff2e2 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -77,7 +77,6 @@ pub struct ComputedValues { % endfor custom_properties: Option>, - shareable: bool, pub writing_mode: WritingMode, pub root_font_size: Au, pub font_size_keyword: Option, @@ -87,7 +86,6 @@ impl ComputedValues { pub fn inherit_from(parent: &Self, default: &Self) -> Arc { Arc::new(ComputedValues { custom_properties: parent.custom_properties.clone(), - shareable: parent.shareable, writing_mode: parent.writing_mode, root_font_size: parent.root_font_size, font_size_keyword: parent.font_size_keyword, @@ -102,7 +100,6 @@ impl ComputedValues { } pub fn new(custom_properties: Option>, - shareable: bool, writing_mode: WritingMode, root_font_size: Au, font_size_keyword: Option, @@ -112,7 +109,6 @@ impl ComputedValues { ) -> Self { ComputedValues { custom_properties: custom_properties, - shareable: shareable, writing_mode: writing_mode, root_font_size: root_font_size, font_size_keyword: font_size_keyword, @@ -125,7 +121,6 @@ impl ComputedValues { pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc { Arc::new(ComputedValues { custom_properties: None, - shareable: true, writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious? font_size_keyword: Some(Default::default()), diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index d00d4b38119..88121aa32f3 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1542,7 +1542,6 @@ pub struct ComputedValues { ${style_struct.ident}: Arc, % endfor custom_properties: Option>, - shareable: bool, /// The writing mode of this computed values struct. pub writing_mode: WritingMode, /// The root element's computed font size. @@ -1555,7 +1554,6 @@ pub struct ComputedValues { impl ComputedValues { /// Construct a `ComputedValues` instance. pub fn new(custom_properties: Option>, - shareable: bool, writing_mode: WritingMode, root_font_size: Au, font_size_keyword: Option, @@ -1565,7 +1563,6 @@ impl ComputedValues { ) -> Self { ComputedValues { custom_properties: custom_properties, - shareable: shareable, writing_mode: writing_mode, root_font_size: root_font_size, font_size_keyword: font_size_keyword, @@ -1889,7 +1886,6 @@ mod lazy_static_module { }), % endfor custom_properties: None, - shareable: true, writing_mode: WritingMode::empty(), root_font_size: longhands::font_size::get_initial_value(), font_size_keyword: Some(Default::default()), @@ -1918,15 +1914,12 @@ static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [ bitflags! { /// A set of flags to tweak the behavior of the `cascade` function. pub flags CascadeFlags: u8 { - /// Whether the `ComputedValues` structure to be constructed should be - /// considered shareable. - const SHAREABLE = 0x01, /// Whether to inherit all styles from the parent. If this flag is not /// present, non-inherited styles are reset to their initial values. - const INHERIT_ALL = 0x02, + const INHERIT_ALL = 0x01, /// Whether to skip any root element and flex/grid item display style /// fixup. - const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 0x04, + const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 0x02, } } @@ -2033,7 +2026,6 @@ pub fn apply_declarations<'a, F, I>(device: &Device, let starting_style = if !flags.contains(INHERIT_ALL) { ComputedValues::new(custom_properties, - flags.contains(SHAREABLE), WritingMode::empty(), inherited_style.root_font_size, inherited_style.font_size_keyword, @@ -2047,7 +2039,6 @@ pub fn apply_declarations<'a, F, I>(device: &Device, ) } else { ComputedValues::new(custom_properties, - flags.contains(SHAREABLE), WritingMode::empty(), inherited_style.root_font_size, inherited_style.font_size_keyword, diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 9712b3d84af..a26404792d5 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -395,9 +395,8 @@ fn resolve_style_internal(context: &mut StyleContext, } // Compute our style. - let match_results = element.match_element(context, &mut data); - element.cascade_element(context, &mut data, - match_results.primary_is_shareable()); + element.match_element(context, &mut data); + element.cascade_element(context, &mut data); // Conservatively mark us as having dirty descendants, since there might // be other unstyled siblings we miss when walking straight up the parent @@ -625,13 +624,10 @@ fn compute_style(_traversal: &D, }; // Cascade properties and compute values. - let shareable = match_results.primary_is_shareable(); - unsafe { - element.cascade_element(context, &mut data, shareable); - } + element.cascade_element(context, &mut data); // If the style is shareable, add it to the LRU cache. - if shareable { + if match_results.primary_is_shareable() { context.thread_local .style_sharing_candidate_cache .insert_if_possible(&element,