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
--- 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,
}