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
This commit is contained in:
Emilio Cobos Álvarez 2022-09-20 19:30:45 +00:00 committed by Martin Robinson
parent 99d588a90e
commit 8a63d9e059
3 changed files with 6 additions and 9 deletions

View file

@ -1128,13 +1128,12 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
SCALE_FACTOR_WHEN_INCREMENTING_MATH_DEPTH_BY_ONE { SCALE_FACTOR_WHEN_INCREMENTING_MATH_DEPTH_BY_ONE {
(parent_font.mScriptSizeMultiplier as f32).powi(delta as i32) (parent_font.mScriptSizeMultiplier as f32).powi(delta as i32)
} else { } else {
builder.add_flags(ComputedValueFlags::DEPENDS_ON_SELF_FONT_METRICS);
// Script scale factors are independent of orientation. // Script scale factors are independent of orientation.
let font_metrics = self.context let font_metrics = self.context.query_font_metrics(
.font_metrics_provider FontBaseSize::InheritedStyle,
.query(self.context, FontBaseSize::InheritedStyle, FontMetricsOrientation::Horizontal,
FontMetricsOrientation::Horizontal, /* retrieve_math_scales = */ true,
true /* retrieve_math_scales */); );
scale_factor_for_math_depth_change( scale_factor_for_math_depth_change(
parent_font.mMathDepth as i32, parent_font.mMathDepth as i32,
font.mMathDepth as i32, font.mMathDepth as i32,

View file

@ -195,7 +195,6 @@ impl<'a> Context<'a> {
F: FnOnce(&Context) -> R, F: FnOnce(&Context) -> R,
{ {
let mut conditions = RuleCacheConditions::default(); let mut conditions = RuleCacheConditions::default();
let context = Context { let context = Context {
builder: StyleBuilder::for_inheritance(device, None, None), builder: StyleBuilder::for_inheritance(device, None, None),
cached_system_font: None, cached_system_font: None,
@ -206,7 +205,6 @@ impl<'a> Context<'a> {
for_non_inherited_property: None, for_non_inherited_property: None,
rule_cache_conditions: RefCell::new(&mut conditions), rule_cache_conditions: RefCell::new(&mut conditions),
}; };
f(&context) f(&context)
} }

View file

@ -10,7 +10,7 @@ use crate::parser::{Parse, ParserContext};
use crate::values::computed::font::{FamilyName, FontFamilyList, SingleFontFamily}; use crate::values::computed::font::{FamilyName, FontFamilyList, SingleFontFamily};
use crate::values::computed::FontSizeAdjust as ComputedFontSizeAdjust; use crate::values::computed::FontSizeAdjust as ComputedFontSizeAdjust;
use crate::values::computed::{font as computed, Length, NonNegativeLength}; 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::computed::{CSSPixelLength, Context, ToComputedValue};
use crate::values::generics::font::VariationValue; use crate::values::generics::font::VariationValue;
use crate::values::generics::font::{ use crate::values::generics::font::{