servo: Merge #16824 - Recalculate font-size when generic changes (from Manishearth:font-size-generic-changed); r=heycam

With the MathML refactorings this feature got lost. It would still get
recalculated when explicitly specified as a keyword, but not otherwise.

To avoid hitting the font metrics provider too often, we only do this
when the generic changes. Otherwise we trust the existing calculated
font.

I swear, once Stylo lands I'm going to campaign to remove font-size from CSS entirely. 😩

Source-Repo: https://github.com/servo/servo
Source-Revision: 29f5b226ac6029cfa3806a36e58974b94c12d655

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : feaf14b66482d4ceeb79c4d44c91e38ed3d31d72
This commit is contained in:
Manish Goregaokar 2017-05-12 23:59:25 -05:00
Родитель 396f88abfc
Коммит 4a5e1e7e86
1 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -891,9 +891,10 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
} }
#[allow(unused_mut)]
pub fn cascade_specified_font_size(context: &mut Context, pub fn cascade_specified_font_size(context: &mut Context,
specified_value: &SpecifiedValue, specified_value: &SpecifiedValue,
computed: Au, mut computed: Au,
parent: &Font) { parent: &Font) {
if let SpecifiedValue::Keyword(kw, fraction) if let SpecifiedValue::Keyword(kw, fraction)
= *specified_value { = *specified_value {
@ -914,6 +915,22 @@ ${helpers.single_keyword_system("font-variant-caps",
context.mutate_style().font_size_keyword = None; context.mutate_style().font_size_keyword = None;
} }
// we could use clone_language and clone_font_family() here but that's
// expensive. Do it only in gecko mode for now.
% if product == "gecko":
use gecko_bindings::structs::nsIAtom;
// if the language or generic changed, we need to recalculate
// the font size from the stored font-size origin information.
if context.style().get_font().gecko().mLanguage.raw::<nsIAtom>() !=
context.inherited_style().get_font().gecko().mLanguage.raw::<nsIAtom>() ||
context.style().get_font().gecko().mGenericID !=
context.inherited_style().get_font().gecko().mGenericID {
if let Some((kw, ratio)) = context.style().font_size_keyword {
computed = kw.to_computed_value(context).scale_by(ratio);
}
}
% endif
let parent_unconstrained = context.mutate_style() let parent_unconstrained = context.mutate_style()
.mutate_font() .mutate_font()
.apply_font_size(computed, .apply_font_size(computed,