mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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:
parent
77a75596bb
commit
aa5ea337da
8 changed files with 290 additions and 498 deletions
|
@ -82,17 +82,12 @@ pub enum FontBaseSize {
|
|||
///
|
||||
/// FIXME(emilio): This is very complex, and should go away.
|
||||
InheritedStyleButStripEmUnits,
|
||||
/// Use a custom base size.
|
||||
///
|
||||
/// FIXME(emilio): This is very dubious, and only used for MathML.
|
||||
Custom(Au),
|
||||
}
|
||||
|
||||
impl FontBaseSize {
|
||||
/// Calculate the actual size for a given context
|
||||
pub fn resolve(&self, context: &Context) -> Au {
|
||||
match *self {
|
||||
FontBaseSize::Custom(size) => size,
|
||||
FontBaseSize::CurrentStyle => context.style().get_font().clone_font_size().size(),
|
||||
FontBaseSize::InheritedStyleButStripEmUnits | FontBaseSize::InheritedStyle => {
|
||||
context.style().get_parent_font().clone_font_size().size()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue