From 42abdb99c44727de33fb141486e47dcdf83301aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Nov 2020 22:30:28 +0000 Subject: [PATCH] style: Fix font loading invalidation to account for metrics coming from the parent style. We were only looking at the given frame's style, which is not sufficient for this case. Differential Revision: https://phabricator.services.mozilla.com/D96237 --- .../style/properties/computed_value_flags.rs | 19 ++++++++++++------- components/style/values/specified/length.rs | 12 ++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/style/properties/computed_value_flags.rs b/components/style/properties/computed_value_flags.rs index dc9597e087b..cc7d9c94fb9 100644 --- a/components/style/properties/computed_value_flags.rs +++ b/components/style/properties/computed_value_flags.rs @@ -57,19 +57,24 @@ bitflags! { /// Whether the child explicitly inherits any reset property. const INHERITS_RESET_STYLE = 1 << 8; - /// Whether any value on our style is font-metric-dependent. - const DEPENDS_ON_FONT_METRICS = 1 << 9; + /// Whether any value on our style is font-metric-dependent on our + /// primary font. + const DEPENDS_ON_SELF_FONT_METRICS = 1 << 9; + + /// Whether any value on our style is font-metric-dependent on the + /// primary font of our parent. + const DEPENDS_ON_INHERITED_FONT_METRICS = 1 << 10; /// Whether the style or any of the ancestors has a multicol style. /// /// Only used in Servo. - const CAN_BE_FRAGMENTED = 1 << 10; + const CAN_BE_FRAGMENTED = 1 << 11; /// Whether this style is the style of the document element. - const IS_ROOT_ELEMENT_STYLE = 1 << 11; + const IS_ROOT_ELEMENT_STYLE = 1 << 12; /// Whether this element is inside an `opacity: 0` subtree. - const IS_IN_OPACITY_ZERO_SUBTREE = 1 << 12; + const IS_IN_OPACITY_ZERO_SUBTREE = 1 << 13; /// Whether there are author-specified rules for border-* properties /// (except border-image-*), background-color, or background-image. @@ -77,13 +82,13 @@ bitflags! { /// TODO(emilio): Maybe do include border-image, see: /// /// https://github.com/w3c/csswg-drafts/issues/4777#issuecomment-604424845 - const HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND = 1 << 13; + const HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND = 1 << 14; /// Whether there are author-specified rules for padding-* properties. /// /// FIXME(emilio): Try to merge this with BORDER_BACKGROUND, see /// https://github.com/w3c/csswg-drafts/issues/4777 - const HAS_AUTHOR_SPECIFIED_PADDING = 1 << 14; + const HAS_AUTHOR_SPECIFIED_PADDING = 1 << 15; } } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 64a2e8cf5db..4fc841aea93 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -161,6 +161,10 @@ impl FontRelativeLength { } let reference_font_size = base_size.resolve(context); + let font_metrics_flag = match base_size { + FontBaseSize::CurrentStyle => ComputedValueFlags::DEPENDS_ON_SELF_FONT_METRICS, + FontBaseSize::InheritedStyle => ComputedValueFlags::DEPENDS_ON_INHERITED_FONT_METRICS, + }; match *self { FontRelativeLength::Em(length) => { if context.for_non_inherited_property.is_some() { @@ -178,9 +182,7 @@ impl FontRelativeLength { if context.for_non_inherited_property.is_some() { context.rule_cache_conditions.borrow_mut().set_uncacheable(); } - context - .builder - .add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS); + context.builder.add_flags(font_metrics_flag); // The x-height is an intrinsically horizontal metric. let metrics = query_font_metrics(context, base_size, FontMetricsOrientation::Horizontal); @@ -199,9 +201,7 @@ impl FontRelativeLength { if context.for_non_inherited_property.is_some() { context.rule_cache_conditions.borrow_mut().set_uncacheable(); } - context - .builder - .add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS); + context.builder.add_flags(font_metrics_flag); // https://drafts.csswg.org/css-values/#ch: // // Equal to the used advance measure of the “0” (ZERO,