From 2291ce4767a554636255da79d9a7c34dce1ead49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 28 Aug 2017 11:36:27 +0200 Subject: [PATCH] style: Remove CascadeInfo. --- components/style/animation.rs | 1 - components/style/cascade_info.rs | 95 ------------------- components/style/lib.rs | 1 - components/style/properties/helpers.mako.rs | 6 -- .../style/properties/properties.mako.rs | 27 ++---- components/style/style_resolver.rs | 5 - components/style/stylist.rs | 4 - 7 files changed, 8 insertions(+), 131 deletions(-) delete mode 100644 components/style/cascade_info.rs diff --git a/components/style/animation.rs b/components/style/animation.rs index a4272b98e7d..c2e3f33b794 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -502,7 +502,6 @@ fn compute_style_for_animation_step(context: &SharedStyleContext, Some(previous_style), Some(previous_style), Some(previous_style), - /* cascade_info = */ None, /* visited_style = */ None, font_metrics_provider, CascadeFlags::empty(), diff --git a/components/style/cascade_info.rs b/components/style/cascade_info.rs deleted file mode 100644 index 2fdd047dadf..00000000000 --- a/components/style/cascade_info.rs +++ /dev/null @@ -1,95 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! A structure to collect information about the cascade. - -#![deny(missing_docs)] - -use dom::TNode; -use properties::{DeclaredValue, PropertyDeclaration}; -use style_traits::HasViewportPercentage; - -/// A structure to collect information about the cascade. -/// -/// This is useful to gather information about what an element is affected by, -/// and can be used in the future to track optimisations like when a -/// non-inherited property is explicitly inherited, in order to cut-off the -/// traversal. -pub struct CascadeInfo { - /// Whether we've seen viewport units so far. - pub saw_viewport_units: bool, - /// Whether the cascade has been marked as finished. This is a debug-only - /// flag to ensure `finish` is called, given it's optional to not pass a - /// `CascadeInfo`. - #[cfg(debug_assertions)] - finished: bool, -} - -impl CascadeInfo { - /// Construct a new `CascadeInfo`. - #[cfg(debug_assertions)] - pub fn new() -> Self { - CascadeInfo { - saw_viewport_units: false, - finished: false, - } - } - - /// Construct a new `CascadeInfo`. - #[cfg(not(debug_assertions))] - pub fn new() -> Self { - CascadeInfo { - saw_viewport_units: false, - } - } - - /// Called when a property is cascaded. - /// - /// NOTE: We can add a vast amount of information here. - #[inline] - pub fn on_cascade_property(&mut self, - _property_declaration: &PropertyDeclaration, - value: &DeclaredValue) - where T: HasViewportPercentage, - { - // TODO: we can be smarter and keep a property bitfield to keep track of - // the last applying rule. - if value.has_viewport_percentage() { - self.saw_viewport_units = true; - } - } - - #[cfg(debug_assertions)] - fn mark_as_finished_if_appropriate(&mut self) { - self.finished = true; - } - - #[cfg(not(debug_assertions))] - fn mark_as_finished_if_appropriate(&mut self) {} - - /// Called when the cascade is finished, in order to use the information - /// we've collected. - /// - /// Currently used for styling to mark a node as needing restyling when the - /// viewport size changes. - #[allow(unsafe_code)] - pub fn finish(mut self, node: &N) { - self.mark_as_finished_if_appropriate(); - - if self.saw_viewport_units { - unsafe { - node.set_dirty_on_viewport_size_changed(); - } - } - } -} - -#[cfg(debug_assertions)] -impl Drop for CascadeInfo { - fn drop(&mut self) { - debug_assert!(self.finished, - "Didn't use the result of CascadeInfo, if you don't need \ - it, consider passing None"); - } -} diff --git a/components/style/lib.rs b/components/style/lib.rs index 929a1fde4ac..0f8a21651d2 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -99,7 +99,6 @@ pub mod applicable_declarations; pub mod bezier; pub mod bloom; pub mod cache; -pub mod cascade_info; pub mod context; pub mod counter_style; pub mod custom_properties; diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index ca1756098ed..ec22cabd352 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -275,8 +275,6 @@ #[allow(unused_imports)] use values::{Auto, Either, None_, Normal}; #[allow(unused_imports)] - use cascade_info::CascadeInfo; - #[allow(unused_imports)] use error_reporting::ParseErrorReporter; #[allow(unused_imports)] use properties::longhands; @@ -303,7 +301,6 @@ pub fn cascade_property( declaration: &PropertyDeclaration, context: &mut computed::Context, - cascade_info: &mut Option<<&mut CascadeInfo>, ) { let value = match *declaration { PropertyDeclaration::${property.camel_case}(ref value) => { @@ -320,9 +317,6 @@ }; % if not property.derived_from: - if let Some(ref mut cascade_info) = *cascade_info { - cascade_info.on_cascade_property(&declaration, &value); - } match value { DeclaredValue::Value(ref specified_value) => { % if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko": diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 391778b8b68..44811df97c8 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -43,7 +43,6 @@ use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraDat use values::generics::text::LineHeight; use values::computed; use values::computed::NonNegativeAu; -use cascade_info::CascadeInfo; use rule_tree::{CascadeLevel, StrongRuleNode}; use self::computed_value_flags::ComputedValueFlags; use style_adjuster::StyleAdjuster; @@ -2953,9 +2952,10 @@ mod lazy_static_module { /// A per-longhand function that performs the CSS cascade for that longhand. pub type CascadePropertyFn = - extern "Rust" fn(declaration: &PropertyDeclaration, - context: &mut computed::Context, - cascade_info: &mut Option<<&mut CascadeInfo>); + extern "Rust" fn( + declaration: &PropertyDeclaration, + context: &mut computed::Context, + ); /// A per-longhand array of functions to perform the CSS cascade on each of /// them, effectively doing virtual dispatch. @@ -3030,7 +3030,6 @@ pub fn cascade( parent_style_ignoring_first_line: Option<<&ComputedValues>, layout_parent_style: Option<<&ComputedValues>, visited_style: Option>, - cascade_info: Option<<&mut CascadeInfo>, font_metrics_provider: &FontMetricsProvider, flags: CascadeFlags, quirks_mode: QuirksMode @@ -3089,7 +3088,6 @@ pub fn cascade( parent_style_ignoring_first_line, layout_parent_style, visited_style, - cascade_info, font_metrics_provider, flags, quirks_mode, @@ -3108,7 +3106,6 @@ pub fn apply_declarations<'a, F, I>( parent_style_ignoring_first_line: Option<<&ComputedValues>, layout_parent_style: Option<<&ComputedValues>, visited_style: Option>, - mut cascade_info: Option<<&mut CascadeInfo>, font_metrics_provider: &FontMetricsProvider, flags: CascadeFlags, quirks_mode: QuirksMode, @@ -3280,9 +3277,7 @@ where % endif let discriminant = longhand_id as usize; - (CASCADE_PROPERTY[discriminant])(&*declaration, - &mut context, - &mut cascade_info); + (CASCADE_PROPERTY[discriminant])(&*declaration, &mut context); } % if category_to_cascade_now == "early": let writing_mode = get_writing_mode(context.builder.get_inheritedbox()); @@ -3363,9 +3358,7 @@ where if let Some(ref declaration) = font_family { let discriminant = LonghandId::FontFamily as usize; - (CASCADE_PROPERTY[discriminant])(declaration, - &mut context, - &mut cascade_info); + (CASCADE_PROPERTY[discriminant])(declaration, &mut context); % if product == "gecko": let device = context.builder.device; if let PropertyDeclaration::FontFamily(ref val) = **declaration { @@ -3383,9 +3376,7 @@ where if let Some(ref declaration) = font_size { let discriminant = LonghandId::FontSize as usize; - (CASCADE_PROPERTY[discriminant])(declaration, - &mut context, - &mut cascade_info); + (CASCADE_PROPERTY[discriminant])(declaration, &mut context); % if product == "gecko": // Font size must be explicitly inherited to handle lang changes and // scriptlevel changes. @@ -3397,9 +3388,7 @@ where let size = PropertyDeclaration::CSSWideKeyword( LonghandId::FontSize, CSSWideKeyword::Inherit); - (CASCADE_PROPERTY[discriminant])(&size, - &mut context, - &mut cascade_info); + (CASCADE_PROPERTY[discriminant])(&size, &mut context); % endif } % endif diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index 53add177b2c..bc3f6c56e10 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -5,7 +5,6 @@ //! Style resolution for a given element or pseudo-element. use applicable_declarations::ApplicableDeclarationList; -use cascade_info::CascadeInfo; use context::{CascadeInputs, ElementCascadeInputs, StyleContext}; use data::{ElementStyles, EagerPseudoStyles}; use dom::TElement; @@ -481,7 +480,6 @@ where cascade_visited: CascadeVisitedMode, pseudo: Option<&PseudoElement>, ) -> Arc { - let mut cascade_info = CascadeInfo::new(); let mut cascade_flags = CascadeFlags::empty(); if self.element.skip_root_and_item_based_display_fixup() || @@ -525,14 +523,11 @@ where parent_style, layout_parent_style, style_if_visited, - Some(&mut cascade_info), &self.context.thread_local.font_metrics_provider, cascade_flags, self.context.shared.quirks_mode(), ); - cascade_info.finish(&self.element.as_node()); - values } } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 14150c58a29..dffca94eaf1 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -721,7 +721,6 @@ impl Stylist { parent, parent, None, - None, font_metrics, cascade_flags, self.quirks_mode, @@ -901,7 +900,6 @@ impl Stylist { Some(inherited_style_ignoring_first_line), Some(layout_parent_style_for_visited), None, - None, font_metrics, cascade_flags, self.quirks_mode, @@ -927,7 +925,6 @@ impl Stylist { Some(parent_style_ignoring_first_line), Some(layout_parent_style), visited_values, - None, font_metrics, cascade_flags, self.quirks_mode, @@ -1543,7 +1540,6 @@ impl Stylist { Some(parent_style), Some(parent_style), None, - None, &metrics, CascadeFlags::empty(), self.quirks_mode,