style: Try to bring some more sanity into our font code.

It's not very easy to understand on its current state, and it causes subtle bugs
like bug 1533654.

It could be simpler if we centralized where the interactions between properties
are handled. This patch does this.

This patch also changes how MathML script sizes are tracked when scriptlevel
changes and they have relative fonts in between.

With this patch, any explicitly specified font-size is treated the same (being a
scriptlevel boundary), regardless of whether it's either an absolute size, a
relative size, or a wide keyword.

Relative lengths always resolve relative to the constrained size, which allows
us to avoid the double font-size computation, and not give up on sanity with
keyword font-sizes.

I think given no other browser supports scriptlevel it seems like the right
trade-off.

Differential Revision: https://phabricator.services.mozilla.com/D23070
This commit is contained in:
Emilio Cobos Álvarez 2019-03-18 15:37:03 +00:00
parent 77a75596bb
commit aa5ea337da
8 changed files with 290 additions and 498 deletions

View file

@ -379,7 +379,7 @@ ${helpers.predefined_type(
use crate::gecko_bindings::structs::{LookAndFeel_FontID, nsFont};
use std::mem;
use crate::values::computed::Percentage;
use crate::values::computed::font::{FontSize, FontStretch, FontStyle, FontFamilyList};
use crate::values::computed::font::{FontFamily, FontSize, FontStretch, FontStyle, FontFamilyList};
use crate::values::generics::NonNegative;
let id = match *self {
@ -405,11 +405,12 @@ ${helpers.predefined_type(
})));
let font_style = FontStyle::from_gecko(system.style);
let ret = ComputedSystemFont {
font_family: longhands::font_family::computed_value::T(
FontFamilyList(
unsafe { system.fontlist.mFontlist.mBasePtr.to_safe() }
)
),
font_family: FontFamily {
families: FontFamilyList(unsafe {
system.fontlist.mFontlist.mBasePtr.to_safe()
}),
is_system_font: true,
},
font_size: FontSize {
size: Au(system.size).into(),
keyword_info: None