mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Update font-weight property and descriptor to css-fonts-4.
Bug: 1454596 Reviewed-by: xidorn MozReview-Commit-ID: 27aS2UrgXjs
This commit is contained in:
parent
76a14d6a64
commit
bc1126ee8c
10 changed files with 199 additions and 141 deletions
|
@ -5,7 +5,7 @@
|
|||
//! Bindings for CSS Rule objects
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use computed_values::{font_stretch, font_style, font_weight};
|
||||
use computed_values::{font_stretch, font_style};
|
||||
use counter_style::{self, CounterBound};
|
||||
use cssparser::UnicodeRange;
|
||||
use font_face::{FontDisplay, FontWeight, Source};
|
||||
|
@ -15,6 +15,7 @@ use properties::longhands::font_language_override;
|
|||
use std::str;
|
||||
use values::computed::font::FamilyName;
|
||||
use values::generics::font::FontTag;
|
||||
use values::specified::font::AbsoluteFontWeight;
|
||||
use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings};
|
||||
|
||||
impl<'a> ToNsCssValue for &'a FamilyName {
|
||||
|
@ -23,19 +24,9 @@ impl<'a> ToNsCssValue for &'a FamilyName {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for font_weight::T {
|
||||
impl<'a> ToNsCssValue for &'a AbsoluteFontWeight {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
nscssvalue.set_font_weight(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToNsCssValue for &'a FontWeight {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match *self {
|
||||
FontWeight::Normal => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_NORMAL as i32),
|
||||
FontWeight::Bold => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_BOLD as i32),
|
||||
FontWeight::Weight(weight) => nscssvalue.set_font_weight(weight.0),
|
||||
}
|
||||
nscssvalue.set_font_weight(self.compute().0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +68,28 @@ impl<'a> ToNsCssValue for &'a SpecifiedFontVariationSettings {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ToNsCssValue for &'a FontWeight {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
let FontWeight(ref first, ref second) = *self;
|
||||
|
||||
let second = match *second {
|
||||
None => {
|
||||
nscssvalue.set_from(first);
|
||||
return;
|
||||
}
|
||||
Some(ref second) => second,
|
||||
};
|
||||
|
||||
let mut a = nsCSSValue::null();
|
||||
let mut b = nsCSSValue::null();
|
||||
|
||||
a.set_from(first);
|
||||
b.set_from(second);
|
||||
|
||||
nscssvalue.set_pair(&a, &b);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToNsCssValue for &'a font_language_override::SpecifiedValue {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue