mirror of
https://github.com/servo/servo.git
synced 2025-08-17 19:35:33 +01:00
style: Update font-style to css-fonts-4.
Bug: 1455358 Reviewed-by: xidorn MozReview-Commit-ID: 1Nq5DyCjaZe
This commit is contained in:
parent
f7636e6662
commit
32d4da8a99
11 changed files with 361 additions and 63 deletions
|
@ -5,10 +5,9 @@
|
|||
//! Bindings for CSS Rule objects
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use computed_values::font_style::T as ComputedFontStyle;
|
||||
use counter_style::{self, CounterBound};
|
||||
use cssparser::UnicodeRange;
|
||||
use font_face::{FontDisplay, FontWeight, FontStretch, Source};
|
||||
use font_face::{FontDisplay, FontWeight, FontStretch, FontStyle, Source};
|
||||
use gecko_bindings::structs::{self, nsCSSValue};
|
||||
use gecko_bindings::sugar::ns_css_value::ToNsCssValue;
|
||||
use properties::longhands::font_language_override;
|
||||
|
@ -17,6 +16,7 @@ use values::computed::font::FamilyName;
|
|||
use values::generics::font::FontTag;
|
||||
use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings};
|
||||
use values::specified::font::{AbsoluteFontWeight, FontStretch as SpecifiedFontStretch};
|
||||
use values::specified::font::FontStyle as SpecifiedFontStyle;
|
||||
|
||||
impl<'a> ToNsCssValue for &'a FamilyName {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
|
@ -114,6 +114,24 @@ macro_rules! descriptor_range_conversion {
|
|||
descriptor_range_conversion!(FontWeight);
|
||||
descriptor_range_conversion!(FontStretch);
|
||||
|
||||
impl<'a> ToNsCssValue for &'a FontStyle {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match *self {
|
||||
FontStyle::Normal => nscssvalue.set_normal(),
|
||||
FontStyle::Italic => nscssvalue.set_enum(structs::NS_FONT_STYLE_ITALIC as i32),
|
||||
FontStyle::Oblique(ref first, ref second) => {
|
||||
let mut a = nsCSSValue::null();
|
||||
let mut b = nsCSSValue::null();
|
||||
|
||||
a.set_angle(SpecifiedFontStyle::compute_angle(first));
|
||||
b.set_angle(SpecifiedFontStyle::compute_angle(second));
|
||||
|
||||
nscssvalue.set_pair(&a, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToNsCssValue for &'a font_language_override::SpecifiedValue {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match *self {
|
||||
|
@ -127,34 +145,6 @@ impl<'a> ToNsCssValue for &'a font_language_override::SpecifiedValue {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! map_enum {
|
||||
(
|
||||
$(
|
||||
$ty:ident {
|
||||
$($servo:ident => $gecko:ident,)+
|
||||
}
|
||||
)+
|
||||
) => {
|
||||
$(
|
||||
impl<'a> ToNsCssValue for &'a $ty {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
nscssvalue.set_enum(match *self {
|
||||
$( $ty::$servo => structs::$gecko as i32, )+
|
||||
})
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
map_enum! {
|
||||
ComputedFontStyle {
|
||||
Normal => NS_FONT_STYLE_NORMAL,
|
||||
Italic => NS_FONT_STYLE_ITALIC,
|
||||
Oblique => NS_FONT_STYLE_OBLIQUE,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToNsCssValue for &'a Vec<Source> {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
let src_len = self.iter().fold(0, |acc, src| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue