style: Avoid double-applying text-zoom for keywords.

Bug: 1412743
Reviewed-by: Manishearth
This commit is contained in:
Emilio Cobos Álvarez 2017-10-31 20:20:55 +01:00
parent 1f6c16ad04
commit ed9cf6b4eb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 13 additions and 8 deletions

View file

@ -38,6 +38,13 @@ pub struct KeywordInfo {
}
impl KeywordInfo {
/// Computes the final size for this font-size keyword, accounting for
/// text-zoom.
pub fn to_computed_value(&self, context: &Context) -> NonNegativeLength {
let base = context.maybe_zoom_text(self.kw.to_computed_value(context));
base.scale_by(self.factor) + context.maybe_zoom_text(self.offset)
}
/// Given a parent keyword info (self), apply an additional factor/offset to it
pub fn compose(self, factor: f32, offset: NonNegativeLength) -> Self {
KeywordInfo {

View file

@ -316,7 +316,7 @@ impl FontSize {
FontSize::Keyword(i) => {
// As a specified keyword, this is keyword derived
info = Some(i);
context.maybe_zoom_text(i.kw.to_computed_value(context).scale_by(i.factor) + i.offset)
i.to_computed_value(context)
}
FontSize::Smaller => {
info = compose_keyword(1. / LARGER_FONT_SIZE_RATIO);