servo: Merge #17516 - style: Fix rem computation on the root element (from emilio:rem-root-size); r=heycam

Bug: 1375930
Reviewed-By: heycam
MozReview-Commit-ID: DK98SS1w5nO
Source-Repo: https://github.com/servo/servo
Source-Revision: c39de45d81eb54c3a8dc78b41883b07dbd7d3896

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 4b37a44e8001e93736d0d576dce860c26c6dda3d
This commit is contained in:
Emilio Cobos Álvarez 2017-06-24 17:47:46 -07:00
Родитель b7a3d1be4c
Коммит c5d41dbbc6
1 изменённых файлов: 13 добавлений и 2 удалений

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

@ -112,7 +112,6 @@ impl FontRelativeLength {
let reference_font_size = base_size.resolve(context);
let root_font_size = context.device.root_font_size();
match *self {
FontRelativeLength::Em(length) => reference_font_size.scale_by(length),
FontRelativeLength::Ex(length) => {
@ -149,7 +148,19 @@ impl FontRelativeLength {
}
}
}
FontRelativeLength::Rem(length) => root_font_size.scale_by(length)
FontRelativeLength::Rem(length) => {
// https://drafts.csswg.org/css-values/#rem:
//
// When specified on the font-size property of the root
// element, the rem units refer to the propertys initial
// value.
//
if context.is_root_element {
reference_font_size.scale_by(length)
} else {
context.device.root_font_size().scale_by(length)
}
}
}
}
}