aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-12 23:59:25 -0500
committerGitHub <noreply@github.com>2017-05-12 23:59:25 -0500
commit29f5b226ac6029cfa3806a36e58974b94c12d655 (patch)
tree0303a1078ee39f9e1843010f7565b2e7eb7007f0
parentb6f5d65bbddc9e8d35016c8669256a8a539b7516 (diff)
parentb1482437b1d590bb6d0a337527bcc64137581b10 (diff)
downloadservo-29f5b226ac6029cfa3806a36e58974b94c12d655.tar.gz
servo-29f5b226ac6029cfa3806a36e58974b94c12d655.zip
Auto merge of #16824 - Manishearth:font-size-generic-changed, r=heycam
Recalculate font-size when generic changes 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. :weary: <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16824) <!-- Reviewable:end -->
-rw-r--r--components/style/properties/longhand/font.mako.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs
index 723d657abe2..11e4aeb1ef0 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhand/font.mako.rs
@@ -891,9 +891,10 @@ ${helpers.single_keyword_system("font-variant-caps",
}
}
+ #[allow(unused_mut)]
pub fn cascade_specified_font_size(context: &mut Context,
specified_value: &SpecifiedValue,
- computed: Au,
+ mut computed: Au,
parent: &Font) {
if let SpecifiedValue::Keyword(kw, fraction)
= *specified_value {
@@ -914,6 +915,22 @@ ${helpers.single_keyword_system("font-variant-caps",
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()
.mutate_font()
.apply_font_size(computed,