mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
style: Clean up Context::for_non_inherited_property
We don't ever check the particular property, so it can just be a boolean. Differential Revision: https://phabricator.services.mozilla.com/D180680
This commit is contained in:
parent
1ad176f1bc
commit
9321265b38
5 changed files with 19 additions and 32 deletions
|
@ -1018,7 +1018,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
|
||||||
let new_size = match info.kw {
|
let new_size = match info.kw {
|
||||||
specified::FontSizeKeyword::None => return,
|
specified::FontSizeKeyword::None => return,
|
||||||
_ => {
|
_ => {
|
||||||
self.context.for_non_inherited_property = None;
|
self.context.for_non_inherited_property = false;
|
||||||
specified::FontSize::Keyword(info).to_computed_value(self.context)
|
specified::FontSize::Keyword(info).to_computed_value(self.context)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -431,13 +431,7 @@
|
||||||
declaration: &PropertyDeclaration,
|
declaration: &PropertyDeclaration,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
) {
|
) {
|
||||||
context.for_non_inherited_property =
|
context.for_non_inherited_property = ${"false" if property.style_struct.inherited else "true"};
|
||||||
% if property.style_struct.inherited:
|
|
||||||
None;
|
|
||||||
% else:
|
|
||||||
Some(LonghandId::${property.camel_case});
|
|
||||||
% endif
|
|
||||||
|
|
||||||
let specified_value = match *declaration {
|
let specified_value = match *declaration {
|
||||||
PropertyDeclaration::${property.camel_case}(ref value) => value,
|
PropertyDeclaration::${property.camel_case}(ref value) => value,
|
||||||
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
||||||
|
|
|
@ -270,11 +270,7 @@ impl AnimationValue {
|
||||||
let longhand_id = unsafe {
|
let longhand_id = unsafe {
|
||||||
*(&decl_repr.tag as *const u16 as *const LonghandId)
|
*(&decl_repr.tag as *const u16 as *const LonghandId)
|
||||||
};
|
};
|
||||||
% if inherit:
|
context.for_non_inherited_property = ${"false" if inherit else "true"};
|
||||||
context.for_non_inherited_property = None;
|
|
||||||
% else:
|
|
||||||
context.for_non_inherited_property = Some(longhand_id);
|
|
||||||
% endif
|
|
||||||
% if system:
|
% if system:
|
||||||
if let Some(sf) = value.get_system() {
|
if let Some(sf) = value.get_system() {
|
||||||
longhands::system_font::resolve_system_font(sf, context)
|
longhands::system_font::resolve_system_font(sf, context)
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::font_metrics::{FontMetrics, FontMetricsOrientation};
|
||||||
use crate::media_queries::Device;
|
use crate::media_queries::Device;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use crate::properties;
|
use crate::properties;
|
||||||
use crate::properties::{ComputedValues, LonghandId, StyleBuilder};
|
use crate::properties::{ComputedValues, StyleBuilder};
|
||||||
use crate::rule_cache::RuleCacheConditions;
|
use crate::rule_cache::RuleCacheConditions;
|
||||||
use crate::stylesheets::container_rule::{
|
use crate::stylesheets::container_rule::{
|
||||||
ContainerInfo, ContainerSizeQuery, ContainerSizeQueryResult,
|
ContainerInfo, ContainerSizeQuery, ContainerSizeQueryResult,
|
||||||
|
@ -185,11 +185,10 @@ pub struct Context<'a> {
|
||||||
/// Returns the container information to evaluate a given container query.
|
/// Returns the container information to evaluate a given container query.
|
||||||
pub container_info: Option<ContainerInfo>,
|
pub container_info: Option<ContainerInfo>,
|
||||||
|
|
||||||
/// The property we are computing a value for, if it is a non-inherited
|
/// Whether we're computing a value for a non-inherited property.
|
||||||
/// property. None if we are computed a value for an inherited property
|
/// False if we are computed a value for an inherited property or not computing for a property
|
||||||
/// or not computing for a property at all (e.g. in a media query
|
/// at all (e.g. in a media query evaluation).
|
||||||
/// evaluation).
|
pub for_non_inherited_property: bool,
|
||||||
pub for_non_inherited_property: Option<LonghandId>,
|
|
||||||
|
|
||||||
/// The conditions to cache a rule node on the rule cache.
|
/// The conditions to cache a rule node on the rule cache.
|
||||||
///
|
///
|
||||||
|
@ -223,7 +222,7 @@ impl<'a> Context<'a> {
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
for_smil_animation: false,
|
for_smil_animation: false,
|
||||||
container_info: None,
|
container_info: None,
|
||||||
for_non_inherited_property: None,
|
for_non_inherited_property: false,
|
||||||
rule_cache_conditions: RefCell::new(&mut conditions),
|
rule_cache_conditions: RefCell::new(&mut conditions),
|
||||||
container_size_query: RefCell::new(ContainerSizeQuery::none()),
|
container_size_query: RefCell::new(ContainerSizeQuery::none()),
|
||||||
};
|
};
|
||||||
|
@ -258,7 +257,7 @@ impl<'a> Context<'a> {
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
for_smil_animation: false,
|
for_smil_animation: false,
|
||||||
container_info,
|
container_info,
|
||||||
for_non_inherited_property: None,
|
for_non_inherited_property: false,
|
||||||
rule_cache_conditions: RefCell::new(&mut conditions),
|
rule_cache_conditions: RefCell::new(&mut conditions),
|
||||||
container_size_query: RefCell::new(container_size_query),
|
container_size_query: RefCell::new(container_size_query),
|
||||||
};
|
};
|
||||||
|
@ -281,7 +280,7 @@ impl<'a> Context<'a> {
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
container_info: None,
|
container_info: None,
|
||||||
for_smil_animation: false,
|
for_smil_animation: false,
|
||||||
for_non_inherited_property: None,
|
for_non_inherited_property: false,
|
||||||
rule_cache_conditions: RefCell::new(rule_cache_conditions),
|
rule_cache_conditions: RefCell::new(rule_cache_conditions),
|
||||||
container_size_query: RefCell::new(container_size_query),
|
container_size_query: RefCell::new(container_size_query),
|
||||||
}
|
}
|
||||||
|
@ -303,7 +302,7 @@ impl<'a> Context<'a> {
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
container_info: None,
|
container_info: None,
|
||||||
for_smil_animation,
|
for_smil_animation,
|
||||||
for_non_inherited_property: None,
|
for_non_inherited_property: false,
|
||||||
rule_cache_conditions: RefCell::new(rule_cache_conditions),
|
rule_cache_conditions: RefCell::new(rule_cache_conditions),
|
||||||
container_size_query: RefCell::new(container_size_query),
|
container_size_query: RefCell::new(container_size_query),
|
||||||
}
|
}
|
||||||
|
@ -321,7 +320,7 @@ impl<'a> Context<'a> {
|
||||||
orientation: FontMetricsOrientation,
|
orientation: FontMetricsOrientation,
|
||||||
retrieve_math_scales: bool,
|
retrieve_math_scales: bool,
|
||||||
) -> FontMetrics {
|
) -> FontMetrics {
|
||||||
if self.for_non_inherited_property.is_some() {
|
if self.for_non_inherited_property {
|
||||||
self.rule_cache_conditions.borrow_mut().set_uncacheable();
|
self.rule_cache_conditions.borrow_mut().set_uncacheable();
|
||||||
}
|
}
|
||||||
self.builder.add_flags(match base_size {
|
self.builder.add_flags(match base_size {
|
||||||
|
|
|
@ -180,13 +180,11 @@ impl FontRelativeLength {
|
||||||
let reference_font_size = base_size.resolve(context);
|
let reference_font_size = base_size.resolve(context);
|
||||||
match *self {
|
match *self {
|
||||||
Self::Em(length) => {
|
Self::Em(length) => {
|
||||||
if context.for_non_inherited_property.is_some() {
|
if context.for_non_inherited_property && base_size == FontBaseSize::CurrentStyle {
|
||||||
if base_size == FontBaseSize::CurrentStyle {
|
context
|
||||||
context
|
.rule_cache_conditions
|
||||||
.rule_cache_conditions
|
.borrow_mut()
|
||||||
.borrow_mut()
|
.set_font_size_dependency(reference_font_size.computed_size);
|
||||||
.set_font_size_dependency(reference_font_size.computed_size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(reference_font_size.computed_size(), length)
|
(reference_font_size.computed_size(), length)
|
||||||
|
@ -786,7 +784,7 @@ impl ContainerRelativeLength {
|
||||||
|
|
||||||
/// Computes the given container-relative length.
|
/// Computes the given container-relative length.
|
||||||
pub fn to_computed_value(&self, context: &Context) -> CSSPixelLength {
|
pub fn to_computed_value(&self, context: &Context) -> CSSPixelLength {
|
||||||
if context.for_non_inherited_property.is_some() {
|
if context.for_non_inherited_property {
|
||||||
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
||||||
}
|
}
|
||||||
let size = context.get_container_size_query();
|
let size = context.get_container_size_query();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue