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:
Emilio Cobos Álvarez 2023-06-12 19:42:23 +00:00 committed by Martin Robinson
parent 1ad176f1bc
commit 9321265b38
5 changed files with 19 additions and 32 deletions

View file

@ -1018,7 +1018,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let new_size = match info.kw {
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)
},
};

View file

@ -431,13 +431,7 @@
declaration: &PropertyDeclaration,
context: &mut computed::Context,
) {
context.for_non_inherited_property =
% if property.style_struct.inherited:
None;
% else:
Some(LonghandId::${property.camel_case});
% endif
context.for_non_inherited_property = ${"false" if property.style_struct.inherited else "true"};
let specified_value = match *declaration {
PropertyDeclaration::${property.camel_case}(ref value) => value,
PropertyDeclaration::CSSWideKeyword(ref declaration) => {

View file

@ -270,11 +270,7 @@ impl AnimationValue {
let longhand_id = unsafe {
*(&decl_repr.tag as *const u16 as *const LonghandId)
};
% if inherit:
context.for_non_inherited_property = None;
% else:
context.for_non_inherited_property = Some(longhand_id);
% endif
context.for_non_inherited_property = ${"false" if inherit else "true"};
% if system:
if let Some(sf) = value.get_system() {
longhands::system_font::resolve_system_font(sf, context)

View file

@ -20,7 +20,7 @@ use crate::font_metrics::{FontMetrics, FontMetricsOrientation};
use crate::media_queries::Device;
#[cfg(feature = "gecko")]
use crate::properties;
use crate::properties::{ComputedValues, LonghandId, StyleBuilder};
use crate::properties::{ComputedValues, StyleBuilder};
use crate::rule_cache::RuleCacheConditions;
use crate::stylesheets::container_rule::{
ContainerInfo, ContainerSizeQuery, ContainerSizeQueryResult,
@ -185,11 +185,10 @@ pub struct Context<'a> {
/// Returns the container information to evaluate a given container query.
pub container_info: Option<ContainerInfo>,
/// 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>,
/// Whether we're computing a value for a non-inherited property.
/// False 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: bool,
/// The conditions to cache a rule node on the rule cache.
///
@ -223,7 +222,7 @@ impl<'a> Context<'a> {
quirks_mode,
for_smil_animation: false,
container_info: None,
for_non_inherited_property: None,
for_non_inherited_property: false,
rule_cache_conditions: RefCell::new(&mut conditions),
container_size_query: RefCell::new(ContainerSizeQuery::none()),
};
@ -258,7 +257,7 @@ impl<'a> Context<'a> {
quirks_mode,
for_smil_animation: false,
container_info,
for_non_inherited_property: None,
for_non_inherited_property: false,
rule_cache_conditions: RefCell::new(&mut conditions),
container_size_query: RefCell::new(container_size_query),
};
@ -281,7 +280,7 @@ impl<'a> Context<'a> {
quirks_mode,
container_info: None,
for_smil_animation: false,
for_non_inherited_property: None,
for_non_inherited_property: false,
rule_cache_conditions: RefCell::new(rule_cache_conditions),
container_size_query: RefCell::new(container_size_query),
}
@ -303,7 +302,7 @@ impl<'a> Context<'a> {
quirks_mode,
container_info: None,
for_smil_animation,
for_non_inherited_property: None,
for_non_inherited_property: false,
rule_cache_conditions: RefCell::new(rule_cache_conditions),
container_size_query: RefCell::new(container_size_query),
}
@ -321,7 +320,7 @@ impl<'a> Context<'a> {
orientation: FontMetricsOrientation,
retrieve_math_scales: bool,
) -> FontMetrics {
if self.for_non_inherited_property.is_some() {
if self.for_non_inherited_property {
self.rule_cache_conditions.borrow_mut().set_uncacheable();
}
self.builder.add_flags(match base_size {

View file

@ -180,13 +180,11 @@ impl FontRelativeLength {
let reference_font_size = base_size.resolve(context);
match *self {
Self::Em(length) => {
if context.for_non_inherited_property.is_some() {
if base_size == FontBaseSize::CurrentStyle {
context
.rule_cache_conditions
.borrow_mut()
.set_font_size_dependency(reference_font_size.computed_size);
}
if context.for_non_inherited_property && base_size == FontBaseSize::CurrentStyle {
context
.rule_cache_conditions
.borrow_mut()
.set_font_size_dependency(reference_font_size.computed_size);
}
(reference_font_size.computed_size(), length)
@ -786,7 +784,7 @@ impl ContainerRelativeLength {
/// Computes the given container-relative length.
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();
}
let size = context.get_container_size_query();