Bug 1367635 - Part 3: Record the property we are computing on computed::Context, if it's a non-inherited one. r=emilio draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 13 Sep 2017 16:03:24 +0800
changeset 664566 3477fc2fabda85e946e6f639524b7df01bcca3c3
parent 664565 5eff987eca861f2d4275a1daebd6d8e8cc3e4cf5
child 664567 c1fc4d0bf4671601b9f120fbcdadd6adbe95e4c9
push id79725
push userbmo:cam@mcc.id.au
push dateThu, 14 Sep 2017 03:06:57 +0000
reviewersemilio
bugs1367635
milestone57.0a1
Bug 1367635 - Part 3: Record the property we are computing on computed::Context, if it's a non-inherited one. r=emilio MozReview-Commit-ID: 4OfTccwtnK8
servo/components/style/gecko/media_queries.rs
servo/components/style/properties/helpers.mako.rs
servo/components/style/properties/properties.mako.rs
servo/components/style/stylesheets/viewport_rule.rs
servo/components/style/values/computed/mod.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -701,16 +701,17 @@ impl Expression {
             is_root_element: false,
             builder: StyleBuilder::for_derived_style(device, default_values, None, None),
             font_metrics_provider: &provider,
             cached_system_font: None,
             in_media_query: true,
             // TODO: pass the correct value here.
             quirks_mode: quirks_mode,
             for_smil_animation: false,
+            for_non_inherited_property: None,
             rule_cache_conditions: RefCell::new(&mut conditions),
         };
 
         let required_value = match self.value {
             Some(ref v) => v,
             None => {
                 // If there's no value, always match unless it's a zero length
                 // or a zero integer or boolean.
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -309,16 +309,23 @@
                     DeclaredValue::CSSWideKeyword(value)
                 },
                 PropertyDeclaration::WithVariables(..) => {
                     panic!("variables should already have been substituted")
                 }
                 _ => panic!("entered the wrong cascade_property() implementation"),
             };
 
+            context.for_non_inherited_property =
+                % if property.style_struct.inherited:
+                    None;
+                % else:
+                    Some(LonghandId::${property.camel_case});
+                % endif
+
             % if not property.derived_from:
                 match value {
                     DeclaredValue::Value(specified_value) => {
                         % if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
                             if let Some(sf) = specified_value.get_system() {
                                 longhands::system_font::resolve_system_font(sf, context);
                             }
                         % endif
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -3182,16 +3182,17 @@ where
             WritingMode::empty(),
             inherited_style.font_computation_data,
             ComputedValueFlags::empty(),
             visited_style,
         ),
         cached_system_font: None,
         in_media_query: false,
         for_smil_animation: false,
+        for_non_inherited_property: None,
         font_metrics_provider,
         quirks_mode,
         rule_cache_conditions: RefCell::new(rule_cache_conditions),
     };
 
     let ignore_colors = !device.use_document_colors();
     let default_background_color_decl = if ignore_colors {
         let color = device.default_background_color();
--- a/servo/components/style/stylesheets/viewport_rule.rs
+++ b/servo/components/style/stylesheets/viewport_rule.rs
@@ -713,16 +713,17 @@ impl MaybeNew for ViewportConstraints {
         let context = Context {
             is_root_element: false,
             builder: StyleBuilder::for_derived_style(device, default_values, None, None),
             font_metrics_provider: &provider,
             cached_system_font: None,
             in_media_query: false,
             quirks_mode: quirks_mode,
             for_smil_animation: false,
+            for_non_inherited_property: None,
             rule_cache_conditions: RefCell::new(&mut conditions),
         };
 
         // DEVICE-ADAPT ยง 9.3 Resolving 'extend-to-zoom'
         let extend_width;
         let extend_height;
         if let Some(extend_zoom) = max!(initial_zoom, max_zoom) {
             let scale_factor = 1. / extend_zoom;
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -6,17 +6,17 @@
 
 use {Atom, Namespace};
 use context::QuirksMode;
 use euclid::Size2D;
 use font_metrics::FontMetricsProvider;
 use media_queries::Device;
 #[cfg(feature = "gecko")]
 use properties;
-use properties::{ComputedValues, StyleBuilder};
+use properties::{ComputedValues, LonghandId, StyleBuilder};
 use rule_cache::RuleCacheConditions;
 #[cfg(feature = "servo")]
 use servo_url::ServoUrl;
 use std::{f32, fmt};
 use std::cell::RefCell;
 #[cfg(feature = "servo")]
 use std::sync::Arc;
 use style_traits::ToCss;
@@ -114,16 +114,22 @@ pub struct Context<'a> {
     pub quirks_mode: QuirksMode,
 
     /// Whether this computation is being done for a SMIL animation.
     ///
     /// This is used to allow certain properties to generate out-of-range
     /// values, which SMIL allows.
     pub for_smil_animation: bool,
 
+    /// The property we are computing a value for, if it is a non-inherited
+    /// property.  None if we are computed a value for an inherited property
+    /// or not computing for a property at all (e.g. in a media query
+    /// evaluation).
+    pub for_non_inherited_property: Option<LonghandId>,
+
     /// The conditions to cache a rule node on the rule cache.
     ///
     /// FIXME(emilio): Drop the refcell.
     pub rule_cache_conditions: RefCell<&'a mut RuleCacheConditions>,
 }
 
 impl<'a> Context<'a> {
     /// Whether the current element is the root element.
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -3196,16 +3196,17 @@ fn create_context<'a>(
             parent_style,
             pseudo,
         ),
         font_metrics_provider: font_metrics_provider,
         cached_system_font: None,
         in_media_query: false,
         quirks_mode: per_doc_data.stylist.quirks_mode(),
         for_smil_animation,
+        for_non_inherited_property: None,
         rule_cache_conditions: RefCell::new(rule_cache_conditions),
     }
 }
 
 struct PropertyAndIndex {
     property: PropertyId,
     index: usize,
 }