diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-02 22:33:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-02 22:33:15 -0500 |
commit | fb6015a75b68b2f894ee0b057a2f17a3ea78494e (patch) | |
tree | a92adb67ae374b283ebfe70bbaeebca3b863cc31 | |
parent | 7b1006936a27232fb77fef5893cc141e66bb12b7 (diff) | |
parent | b298a2bb8e667befdd93eb5ace2f5178e043fec3 (diff) | |
download | servo-fb6015a75b68b2f894ee0b057a2f17a3ea78494e.tar.gz servo-fb6015a75b68b2f894ee0b057a2f17a3ea78494e.zip |
Auto merge of #16695 - Manishearth:kw-inherit, r=heycam
Do not inherit kw font size if it was not used due to MathML
See https://bugzilla.mozilla.org/show_bug.cgi?id=1361126#c9
<!-- 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/16695)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/properties/gecko.mako.rs | 7 | ||||
-rw-r--r-- | components/style/properties/longhand/font.mako.rs | 10 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 3 |
3 files changed, 15 insertions, 5 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b428ec3e198..e6aab102506 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1490,8 +1490,10 @@ fn static_assert() { /// This function will also handle scriptminsize and scriptlevel /// so should not be called when you just want the font sizes to be copied. /// Hence the different name. + /// + /// Returns true if the inherited keyword size was actually used pub fn inherit_font_size_from(&mut self, parent: &Self, - kw_inherited_size: Option<Au>) { + kw_inherited_size: Option<Au>) -> bool { let (adjusted_size, adjusted_unconstrained_size) = self.calculate_script_level_size(parent); if adjusted_size.0 != parent.gecko.mSize || @@ -1513,18 +1515,21 @@ fn static_assert() { self.gecko.mFont.size = adjusted_size.0; self.gecko.mSize = adjusted_size.0; self.gecko.mScriptUnconstrainedSize = adjusted_unconstrained_size.0; + false } else if let Some(size) = kw_inherited_size { // Parent element was a keyword-derived size. self.gecko.mFont.size = size.0; self.gecko.mSize = size.0; // MathML constraints didn't apply here, so we can ignore this. self.gecko.mScriptUnconstrainedSize = size.0; + true } else { // MathML isn't affecting us, and our parent element does not // have a keyword-derived size. Set things normally. self.gecko.mFont.size = parent.gecko.mFont.size; self.gecko.mSize = parent.gecko.mSize; self.gecko.mScriptUnconstrainedSize = parent.gecko.mScriptUnconstrainedSize; + false } } diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index e99b15dd9cf..842b3279d90 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -927,10 +927,14 @@ ${helpers.single_keyword_system("font-variant-caps", let kw_inherited_size = context.style().font_size_keyword.map(|(kw, ratio)| { SpecifiedValue::Keyword(kw, ratio).to_computed_value(context) }); - context.mutate_style().mutate_font() + let used_kw = context.mutate_style().mutate_font() .inherit_font_size_from(parent, kw_inherited_size); - context.mutate_style().font_size_keyword = - context.inherited_style.font_size_keyword; + if used_kw { + context.mutate_style().font_size_keyword = + context.inherited_style.font_size_keyword; + } else { + context.mutate_style().font_size_keyword = None; + } } pub fn cascade_initial_font_size(context: &mut Context) { diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index ff2361fb792..b2a122adcbe 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1569,8 +1569,9 @@ pub mod style_structs { /// (Servo does not handle MathML, so this just calls copy_font_size_from) pub fn inherit_font_size_from(&mut self, parent: &Self, - _: Option<Au>) { + _: Option<Au>) -> bool { self.copy_font_size_from(parent); + false } /// (Servo does not handle MathML, so this just calls set_font_size) pub fn apply_font_size(&mut self, |