servo: Merge #17846 - Allow nonstandard font-weight values for system fonts (from Manishearth:font-weight); r=upsuper

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1379895

Source-Repo: https://github.com/servo/servo
Source-Revision: b8ac4a7a2efabe11af1366207f9649982250c0e2

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 536b943224fcf4bc326817ca0586b748a4cd78ba
This commit is contained in:
Manish Goregaokar 2017-07-24 17:26:31 -07:00
Родитель fba4d7c501
Коммит c5a2243880
2 изменённых файлов: 8 добавлений и 6 удалений

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

@ -2022,10 +2022,8 @@ fn static_assert() {
${impl_simple_copy('font_weight', 'mFont.weight')}
pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
debug_assert!(self.gecko.mFont.weight >= 100);
debug_assert!(self.gecko.mFont.weight <= 900);
debug_assert!(self.gecko.mFont.weight % 10 == 0);
unsafe { transmute(self.gecko.mFont.weight) }
debug_assert!(self.gecko.mFont.weight <= ::std::u16::MAX);
longhands::font_weight::computed_value::T(self.gecko.mFont.weight)
}
${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}

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

@ -457,6 +457,9 @@ ${helpers.single_keyword_system("font-variant-caps",
pub mod computed_value {
/// As of CSS Fonts Module Level 3, only the following values are
/// valid: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
///
/// However, system fonts may provide other values. Pango
/// may provide 350, 380, and 1000 (on top of the existing values), for example.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, ToCss)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub struct T(pub u16);
@ -483,8 +486,9 @@ ${helpers.single_keyword_system("font-variant-caps",
/// Convert from an Gecko weight
pub fn from_gecko_weight(weight: u16) -> Self {
Self::from_int(weight as i32)
.expect("from_gecko_weight: called with invalid weight")
// we allow a wider range of weights than is parseable
// because system fonts may provide custom values
T(weight)
}
/// Weither this weight is bold