mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Use mozilla::Length rather than nscoord to store font sizes.
This avoids arbitrary precision loss when computing REM units and so on, which is particularly important if we ever change the base of our app units (but useful regardless). Differential Revision: https://phabricator.services.mozilla.com/D79928
This commit is contained in:
parent
45f5d84d1b
commit
46df06b3e2
12 changed files with 99 additions and 100 deletions
|
@ -787,13 +787,13 @@ impl ToComputedValue for FontSizeAdjust {
|
|||
const LARGER_FONT_SIZE_RATIO: f32 = 1.2;
|
||||
|
||||
/// The default font size.
|
||||
pub const FONT_MEDIUM_PX: i32 = 16;
|
||||
pub const FONT_MEDIUM_PX: f32 = 16.0;
|
||||
|
||||
impl FontSizeKeyword {
|
||||
#[inline]
|
||||
#[cfg(feature = "servo")]
|
||||
fn to_length(&self, _: &Context) -> NonNegativeLength {
|
||||
let medium = Length::new(FONT_MEDIUM_PX as f32);
|
||||
let medium = Length::new(FONT_MEDIUM_PX);
|
||||
// https://drafts.csswg.org/css-fonts-3/#font-size-prop
|
||||
NonNegative(match *self {
|
||||
FontSizeKeyword::XXSmall => medium * 3.0 / 5.0,
|
||||
|
|
|
@ -241,7 +241,7 @@ impl FontRelativeLength {
|
|||
let reference_size = if context.builder.is_root_element || context.in_media_query {
|
||||
reference_font_size
|
||||
} else {
|
||||
computed::Length::new(context.device().root_font_size().to_f32_px())
|
||||
context.device().root_font_size()
|
||||
};
|
||||
(reference_size, length)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue