From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- servo/components/style/properties/cascade.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'servo/components/style/properties/cascade.rs') diff --git a/servo/components/style/properties/cascade.rs b/servo/components/style/properties/cascade.rs index d4d48eaeb8..0f264a9249 100644 --- a/servo/components/style/properties/cascade.rs +++ b/servo/components/style/properties/cascade.rs @@ -297,7 +297,7 @@ where context.style().add_flags(cascade_input_flags); let using_cached_reset_properties; - let ignore_colors = !context.builder.device.use_document_colors(); + let ignore_colors = context.builder.device.forced_colors().is_active(); let mut cascade = Cascade::new(first_line_reparenting, ignore_colors); let mut declarations = Default::default(); let mut shorthand_cache = ShorthandsWithPropertyReferencesCache::default(); @@ -763,6 +763,11 @@ impl<'b> Cascade<'b> { if apply!(Zoom) { self.compute_zoom(context); + // NOTE(emilio): This is a bit of a hack, but matches the shipped WebKit and Blink + // behavior for now. Ideally, in the future, we have a pass over all + // implicitly-or-explicitly-inherited properties that can contain lengths and + // re-compute them properly, see https://github.com/w3c/csswg-drafts/issues/9397. + self.recompute_font_size_for_zoom_change(&mut context.builder); } // Compute font-family. @@ -1226,8 +1231,6 @@ impl<'b> Cascade<'b> { /// is not affected by text zoom, and it uses a preshint to disable it. We fix up /// the struct when this happens by unzooming its contained font values, which will have been /// zoomed in the parent. - /// - /// FIXME(emilio): Why doing this _before_ handling font-size? That sounds wrong. #[cfg(feature = "gecko")] fn unzoom_fonts_if_needed(&self, builder: &mut StyleBuilder) { debug_assert!(self.seen.contains(LonghandId::XTextScale)); @@ -1250,6 +1253,19 @@ impl<'b> Cascade<'b> { builder.mutate_font().unzoom_fonts(device); } + fn recompute_font_size_for_zoom_change(&self, builder: &mut StyleBuilder) { + debug_assert!(self.seen.contains(LonghandId::Zoom)); + // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited + // zooms are already applied. + let zoom = builder.get_box().clone_zoom(); + let old_size = builder.get_font().clone_font_size(); + let new_size = old_size.zoom(zoom); + if old_size == new_size { + return; + } + builder.mutate_font().set_font_size(new_size); + } + /// Special handling of font-size: math (used for MathML). /// https://w3c.github.io/mathml-core/#the-math-script-level-property /// TODO: Bug: 1548471: MathML Core also does not specify a script min size -- cgit v1.2.3