style: Record the property we are computing on computed::Context, if it's a non-inherited one.

This commit is contained in:
Cameron McCormack 2017-09-13 16:03:24 +08:00
parent 9230030daa
commit 1cde26eacb
7 changed files with 19 additions and 1 deletions

View file

@ -706,6 +706,7 @@ impl Expression {
// 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),
};

View file

@ -314,6 +314,13 @@
_ => 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) => {

View file

@ -3199,6 +3199,7 @@ where
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),

View file

@ -260,6 +260,7 @@ impl Range<specified::Length> {
cached_system_font: None,
quirks_mode: quirks_mode,
for_smil_animation: false,
for_non_inherited_property: None,
rule_cache_conditions: RefCell::new(&mut conditions),
};

View file

@ -718,6 +718,7 @@ impl MaybeNew for ViewportConstraints {
in_media_query: false,
quirks_mode: quirks_mode,
for_smil_animation: false,
for_non_inherited_property: None,
rule_cache_conditions: RefCell::new(&mut conditions),
};

View file

@ -11,7 +11,7 @@ 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;
@ -119,6 +119,12 @@ pub struct Context<'a> {
/// 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.

View file

@ -3203,6 +3203,7 @@ fn create_context<'a>(
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),
}
}