Bug 1964380 - Upstream Stylo changes from Servo (2025-05-01). r=emilio

Fixup for D241392: restrict `selectors::parser::PseudoElement` import
to Gecko, avoiding a compiler warning for Servo.

Fixup for D246780: move `QueryFontMetricsFlags` definition out of
Gecko-specific code, since its used in common APIs.

Differential Revision: https://phabricator.services.mozilla.com/D247757
This commit is contained in:
Oriol Brufau
2025-05-05 13:51:18 +00:00
committed by oriol-bugzilla@hotmail.com
parent 6864b6b07f
commit 0d6ac874e6
9 changed files with 33 additions and 32 deletions

View File

@@ -18,7 +18,9 @@ use crate::string_cache::Atom;
use crate::values::computed::font::GenericFontFamily;
use crate::values::computed::{ColorScheme, Length, NonNegativeLength};
use crate::values::specified::color::{ColorSchemeFlags, ForcedColors, SystemColor};
use crate::values::specified::font::{FONT_MEDIUM_LINE_HEIGHT_PX, FONT_MEDIUM_PX};
use crate::values::specified::font::{
FONT_MEDIUM_LINE_HEIGHT_PX, FONT_MEDIUM_PX, QueryFontMetricsFlags,
};
use crate::values::specified::ViewportVariant;
use crate::values::{CustomIdent, KeyframesName};
use app_units::{Au, AU_PER_PX};
@@ -29,23 +31,6 @@ use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
use std::{cmp, fmt};
use style_traits::{CSSPixel, DevicePixel};
/// Flags for the query_font_metrics() function.
#[repr(C)]
pub struct QueryFontMetricsFlags(u8);
bitflags! {
impl QueryFontMetricsFlags: u8 {
/// Should we use the user font set?
const USE_USER_FONT_SET = 1 << 0;
/// Does the caller need the `ch` unit (width of the ZERO glyph)?
const NEEDS_CH = 1 << 1;
/// Does the caller need the `ic` unit (width of the WATER ideograph)?
const NEEDS_IC = 1 << 2;
/// Does the caller need math scales to be retrieved?
const NEEDS_MATH_SCALES = 1 << 3;
}
}
/// The `Device` in Gecko wraps a pres context, has a default values computed,
/// and contains all the viewport rule state.
pub struct Device {

View File

@@ -1355,7 +1355,7 @@ impl<'b> Cascade<'b> {
}
let (new_size, new_unconstrained_size) = {
use crate::gecko::media_queries::QueryFontMetricsFlags;
use crate::values::specified::font::QueryFontMetricsFlags;
let builder = &context.builder;
let font = builder.get_font();

View File

@@ -17,7 +17,9 @@ use crate::properties::ComputedValues;
use crate::values::computed::{CSSPixelLength, Context, Length, LineHeight, NonNegativeLength, Resolution};
use crate::values::computed::font::GenericFontFamily;
use crate::values::specified::color::{ColorSchemeFlags, ForcedColors};
use crate::values::specified::font::{FONT_MEDIUM_LINE_HEIGHT_PX, FONT_MEDIUM_PX};
use crate::values::specified::font::{
FONT_MEDIUM_LINE_HEIGHT_PX, FONT_MEDIUM_PX, QueryFontMetricsFlags,
};
use crate::values::specified::ViewportVariant;
use crate::values::KeyframesName;
use app_units::{Au, AU_PER_PX};
@@ -38,8 +40,7 @@ pub trait FontMetricsProvider: Debug + Sync {
vertical: bool,
font: &Font,
base_size: CSSPixelLength,
in_media_query: bool,
retrieve_math_scales: bool,
flags: QueryFontMetricsFlags,
) -> FontMetrics;
/// Gets the base size given a generic font family.
fn base_size_for_generic(&self, generic: GenericFontFamily) -> Length;
@@ -268,16 +269,14 @@ impl Device {
vertical: bool,
font: &Font,
base_size: CSSPixelLength,
in_media_query: bool,
retrieve_math_scales: bool,
flags: QueryFontMetricsFlags,
) -> FontMetrics {
self.used_font_metrics.store(true, Ordering::Relaxed);
self.font_metrics_provider.query_font_metrics(
vertical,
font,
base_size,
in_media_query,
retrieve_math_scales,
flags,
)
}

View File

@@ -19,6 +19,7 @@ use crate::properties::longhands::float::computed_value::T as Float;
use crate::properties::longhands::position::computed_value::T as Position;
use crate::properties::{self, ComputedValues, StyleBuilder};
#[cfg(feature = "gecko")]
use selectors::parser::PseudoElement;
/// A struct that implements all the adjustment methods.

View File

@@ -4,7 +4,6 @@
//! Computed values for font properties
use crate::gecko::media_queries::QueryFontMetricsFlags;
use crate::parser::{Parse, ParserContext};
use crate::values::animated::ToAnimatedValue;
use crate::values::computed::{
@@ -32,8 +31,8 @@ pub use crate::values::computed::Length as MozScriptMinSize;
pub use crate::values::specified::font::MozScriptSizeMultiplier;
pub use crate::values::specified::font::{FontPalette, FontSynthesis, FontSynthesisStyle};
pub use crate::values::specified::font::{
FontVariantAlternates, FontVariantEastAsian, FontVariantLigatures, FontVariantNumeric, XLang,
XTextScale,
FontVariantAlternates, FontVariantEastAsian, FontVariantLigatures, FontVariantNumeric,
QueryFontMetricsFlags, XLang, XTextScale,
};
pub use crate::values::specified::Integer as SpecifiedInteger;
pub use crate::values::specified::Number as SpecifiedNumber;

View File

@@ -18,7 +18,6 @@ use crate::computed_value_flags::ComputedValueFlags;
use crate::context::QuirksMode;
use crate::custom_properties::ComputedCustomProperties;
use crate::font_metrics::{FontMetrics, FontMetricsOrientation};
use crate::gecko::media_queries::QueryFontMetricsFlags;
use crate::media_queries::Device;
#[cfg(feature = "gecko")]
use crate::properties;
@@ -28,6 +27,7 @@ use crate::stylesheets::container_rule::{
ContainerInfo, ContainerSizeQuery, ContainerSizeQueryResult,
};
use crate::stylist::Stylist;
use crate::values::specified::font::QueryFontMetricsFlags;
use crate::values::specified::length::FontBaseSize;
use crate::{ArcSlice, Atom, One};
use euclid::{default, Point2D, Rect, Size2D};

View File

@@ -1950,3 +1950,20 @@ impl ToComputedValue for LineHeight {
}
}
}
/// Flags for the query_font_metrics() function.
#[repr(C)]
pub struct QueryFontMetricsFlags(u8);
bitflags! {
impl QueryFontMetricsFlags: u8 {
/// Should we use the user font set?
const USE_USER_FONT_SET = 1 << 0;
/// Does the caller need the `ch` unit (width of the ZERO glyph)?
const NEEDS_CH = 1 << 1;
/// Does the caller need the `ic` unit (width of the WATER ideograph)?
const NEEDS_IC = 1 << 2;
/// Does the caller need math scales to be retrieved?
const NEEDS_MATH_SCALES = 1 << 3;
}
}

View File

@@ -9,7 +9,6 @@
use super::{AllowQuirks, Number, Percentage, ToComputedValue};
use crate::computed_value_flags::ComputedValueFlags;
use crate::font_metrics::{FontMetrics, FontMetricsOrientation};
use crate::gecko::media_queries::QueryFontMetricsFlags;
#[cfg(feature = "gecko")]
use crate::gecko_bindings::structs::GeckoFontMetrics;
use crate::parser::{Parse, ParserContext};
@@ -21,6 +20,7 @@ use crate::values::generics::length::{
};
use crate::values::generics::NonNegative;
use crate::values::specified::calc::{self, AllowAnchorPositioningFunctions, CalcNode};
use crate::values::specified::font::QueryFontMetricsFlags;
use crate::values::specified::NonNegativeNumber;
use crate::values::CSSFloat;
use crate::{Zero, ZeroNoPercent};