Skip to content

Commit

Permalink
Do not inherit kw font size if it was not used due to MathML
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 3, 2017
1 parent 52920ed commit b298a2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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
}
}

Expand Down
10 changes: 7 additions & 3 deletions components/style/properties/longhand/font.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion components/style/properties/properties.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,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,
Expand Down

0 comments on commit b298a2b

Please sign in to comment.