mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Refactor font-feature-settings and font-variation-settings.
This fixes all known issues with serialization and parsing of these two properties, and in particular calc handling and such: https://bugzilla.mozilla.org/show_bug.cgi?id=1434692 https://bugzilla.mozilla.org/show_bug.cgi?id=1434724 Also does a fair amount of cleanup and all that, which was needed.
This commit is contained in:
parent
09398d42af
commit
3b34d734e6
11 changed files with 270 additions and 261 deletions
|
@ -5,7 +5,7 @@
|
|||
//! Bindings for CSS Rule objects
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use computed_values::{font_feature_settings, font_stretch, font_style, font_weight};
|
||||
use computed_values::{font_stretch, font_style, font_weight};
|
||||
use counter_style;
|
||||
use cssparser::UnicodeRange;
|
||||
use font_face::{FontFaceRuleData, Source, FontDisplay, FontWeight};
|
||||
|
@ -21,7 +21,7 @@ use std::fmt::{self, Write};
|
|||
use std::str;
|
||||
use str::CssStringWriter;
|
||||
use values::computed::font::FamilyName;
|
||||
use values::generics::font::FontSettings;
|
||||
use values::specified::font::SpecifiedFontFeatureSettings;
|
||||
|
||||
/// A @font-face rule
|
||||
pub type FontFaceRule = RefPtr<nsCSSFontFaceRule>;
|
||||
|
@ -50,24 +50,24 @@ impl ToNsCssValue for FontWeight {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for font_feature_settings::T {
|
||||
impl ToNsCssValue for SpecifiedFontFeatureSettings {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match self {
|
||||
FontSettings::Normal => nscssvalue.set_normal(),
|
||||
FontSettings::Tag(tags) => {
|
||||
nscssvalue.set_pair_list(tags.into_iter().map(|entry| {
|
||||
let mut feature = nsCSSValue::null();
|
||||
let mut raw = [0u8; 4];
|
||||
(&mut raw[..]).write_u32::<BigEndian>(entry.tag.0).unwrap();
|
||||
feature.set_string(str::from_utf8(&raw).unwrap());
|
||||
|
||||
let mut index = nsCSSValue::null();
|
||||
index.set_integer(entry.value.0 as i32);
|
||||
|
||||
(feature, index)
|
||||
}))
|
||||
}
|
||||
if self.0.is_empty() {
|
||||
nscssvalue.set_normal();
|
||||
return;
|
||||
}
|
||||
|
||||
nscssvalue.set_pair_list(self.0.into_iter().map(|entry| {
|
||||
let mut feature = nsCSSValue::null();
|
||||
let mut raw = [0u8; 4];
|
||||
(&mut raw[..]).write_u32::<BigEndian>(entry.tag.0).unwrap();
|
||||
feature.set_string(str::from_utf8(&raw).unwrap());
|
||||
|
||||
let mut index = nsCSSValue::null();
|
||||
index.set_integer(entry.value.value());
|
||||
|
||||
(feature, index)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue