diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-04-04 14:35:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 12:35:15 +0000 |
commit | fe8b23d14a006de5569f967d6d6a78a46d48f367 (patch) | |
tree | c32b893761cf941c1187cdb610704f6e120b37d9 /components/shared/script_layout/lib.rs | |
parent | 24c3a2df1eb63a75274eb219128f305aabc236c2 (diff) | |
download | servo-fe8b23d14a006de5569f967d6d6a78a46d48f367.tar.gz servo-fe8b23d14a006de5569f967d6d6a78a46d48f367.zip |
layout: Add a `FontMetricsProvider` for resolving font-relative units (#31966)
The only font relative unit that Servo knows how to resolve currently is
`rem` (relative to the root font size). This is because Stylo cannot do
any font queries. This adds a mechanism to allow this, exposing the
ability to properly render `ex` units in Servo.
This change only allows resolving some font size relative units thoug,
as Servo doesn't collect all the FontMetrics it needs to resolve them
all. This capability will be added in followup changes.
Some new tests fail:
- ex-unit-001.html: This test fails because Servo does not yet have
support for setting the weight using @font-face rules on web fonts.
- ex-unit-004.html: This test fails because Servo does not yet have
support for setting the Unicode range of a web font using @font-face
rules.
- first-available-font-001.html: This test fails because the above
two feature are missing.
Diffstat (limited to 'components/shared/script_layout/lib.rs')
-rw-r--r-- | components/shared/script_layout/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index a09e0fcf1aa..3279f993820 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -40,6 +40,7 @@ use servo_url::{ImmutableOrigin, ServoUrl}; use style::animation::DocumentAnimationSet; use style::data::ElementData; use style::dom::OpaqueNode; +use style::media_queries::Device; use style::properties::style_structs::Font; use style::properties::PropertyId; use style::selector_parser::PseudoElement; @@ -179,6 +180,10 @@ pub trait Layout { /// Handle a a single mesasge from the FontCacheThread. fn handle_font_cache_msg(&mut self); + /// Get a reference to this Layout's Stylo `Device` used to handle media queries and + /// resolve font metrics. + fn device<'a>(&'a self) -> &'a Device; + /// Whether or not this layout is waiting for fonts from loaded stylesheets to finish loading. fn waiting_for_web_fonts_to_load(&self) -> bool; |