From 8a63d9e059ae5ad3bde9dcb167fdd1567d52eb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 20 Sep 2022 19:30:45 +0000 Subject: [PATCH] style: Simplify our setup for font metric queries from style While looking at moving the flag around I realized that the only reason we have FontMetricsProvider and co is because we didn't have access to the per-document font-prefs cache. That's trivial to fix tho, so do that and simplify the setup for font queries even more. Differential Revision: https://phabricator.services.mozilla.com/D157589 --- components/style/properties/cascade.rs | 11 +++++------ components/style/values/computed/mod.rs | 2 -- components/style/values/specified/font.rs | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index b1a823f96be..73dee7ede07 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -1128,13 +1128,12 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> { SCALE_FACTOR_WHEN_INCREMENTING_MATH_DEPTH_BY_ONE { (parent_font.mScriptSizeMultiplier as f32).powi(delta as i32) } else { - builder.add_flags(ComputedValueFlags::DEPENDS_ON_SELF_FONT_METRICS); // Script scale factors are independent of orientation. - let font_metrics = self.context - .font_metrics_provider - .query(self.context, FontBaseSize::InheritedStyle, - FontMetricsOrientation::Horizontal, - true /* retrieve_math_scales */); + let font_metrics = self.context.query_font_metrics( + FontBaseSize::InheritedStyle, + FontMetricsOrientation::Horizontal, + /* retrieve_math_scales = */ true, + ); scale_factor_for_math_depth_change( parent_font.mMathDepth as i32, font.mMathDepth as i32, diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index e185d297f84..9e8a8e1bfdc 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -195,7 +195,6 @@ impl<'a> Context<'a> { F: FnOnce(&Context) -> R, { let mut conditions = RuleCacheConditions::default(); - let context = Context { builder: StyleBuilder::for_inheritance(device, None, None), cached_system_font: None, @@ -206,7 +205,6 @@ impl<'a> Context<'a> { for_non_inherited_property: None, rule_cache_conditions: RefCell::new(&mut conditions), }; - f(&context) } diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 1ae42ac772d..14947c79500 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -10,7 +10,7 @@ use crate::parser::{Parse, ParserContext}; use crate::values::computed::font::{FamilyName, FontFamilyList, SingleFontFamily}; use crate::values::computed::FontSizeAdjust as ComputedFontSizeAdjust; use crate::values::computed::{font as computed, Length, NonNegativeLength}; -use crate::values::computed::{Percentage as ComputedPercentage}; +use crate::values::computed::Percentage as ComputedPercentage; use crate::values::computed::{CSSPixelLength, Context, ToComputedValue}; use crate::values::generics::font::VariationValue; use crate::values::generics::font::{