mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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.
This commit is contained in:
parent
24c3a2df1e
commit
fe8b23d14a
98 changed files with 208 additions and 232 deletions
|
@ -58,7 +58,7 @@ use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
|||
use style::attr::AttrValue;
|
||||
use style::context::QuirksMode;
|
||||
use style::invalidation::element::restyle_hints::RestyleHint;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::media_queries::Device;
|
||||
use style::selector_parser::Snapshot;
|
||||
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
|
||||
use style::str::{split_html_space_chars, str_join};
|
||||
|
@ -3476,20 +3476,14 @@ impl Document {
|
|||
have_changed
|
||||
}
|
||||
|
||||
/// Returns a `Device` suitable for media query evaluation.
|
||||
/// Runs the given closure using the Stylo `Device` suitable for media query evaluation.
|
||||
///
|
||||
/// FIXME(emilio): This really needs to be somehow more in sync with layout.
|
||||
/// Feels like a hack.
|
||||
pub fn device(&self) -> Device {
|
||||
let window_size = self.window().window_size();
|
||||
let viewport_size = window_size.initial_viewport;
|
||||
let device_pixel_ratio = window_size.device_pixel_ratio;
|
||||
Device::new(
|
||||
MediaType::screen(),
|
||||
self.quirks_mode(),
|
||||
viewport_size,
|
||||
device_pixel_ratio,
|
||||
)
|
||||
/// TODO: This can just become a getter when each Layout is more strongly associated with
|
||||
/// its given Document and Window.
|
||||
pub fn with_device<T>(&self, call: impl FnOnce(&Device) -> T) -> T {
|
||||
self.window
|
||||
.with_layout(move |layout| call(layout.device()))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn salvageable(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue