mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
font-feature-settings gecko glue code
FeatureTagValue value property changed to use u32. ToCss for FeatureTagValue changed to allow conversion from u32 to string. Parse for the same struct updated to convert from string to u32. Added two functions to transfer settings to gecko and copy settings.
This commit is contained in:
parent
3905b5af18
commit
a3dbf1d275
6 changed files with 79 additions and 17 deletions
|
@ -13,6 +13,7 @@ doctest = false
|
|||
testing = ["style/testing"]
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.0"
|
||||
app_units = "0.4"
|
||||
cssparser = "0.13"
|
||||
euclid = "0.11"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#![feature(plugin, test)]
|
||||
|
||||
extern crate app_units;
|
||||
extern crate byteorder;
|
||||
extern crate cssparser;
|
||||
extern crate euclid;
|
||||
#[macro_use] extern crate html5ever;
|
||||
|
|
|
@ -10,38 +10,47 @@ use style_traits::ToCss;
|
|||
|
||||
#[test]
|
||||
fn font_feature_settings_should_parse_properly() {
|
||||
use byteorder::{ReadBytesExt, NativeEndian};
|
||||
use std::io::Cursor;
|
||||
|
||||
let normal = parse_longhand!(font_feature_settings, "normal");
|
||||
let normal_computed = computed_value::T::Normal;
|
||||
assert_eq!(normal, normal_computed);
|
||||
|
||||
let mut a_d_bytes = Cursor::new(b"abcd");
|
||||
let mut e_h_bytes = Cursor::new(b"efgh");
|
||||
|
||||
let abcd = a_d_bytes.read_u32::<NativeEndian>().unwrap();
|
||||
let efgh = e_h_bytes.read_u32::<NativeEndian>().unwrap();
|
||||
|
||||
let on = parse_longhand!(font_feature_settings, "\"abcd\" on");
|
||||
let on_computed = computed_value::T::Tag(vec![
|
||||
FeatureTagValue { tag: String::from("abcd"), value: 1 }
|
||||
FeatureTagValue { tag: abcd, value: 1 }
|
||||
]);
|
||||
assert_eq!(on, on_computed);
|
||||
|
||||
let off = parse_longhand!(font_feature_settings, "\"abcd\" off");
|
||||
let off_computed = computed_value::T::Tag(vec![
|
||||
FeatureTagValue { tag: String::from("abcd"), value: 0 }
|
||||
FeatureTagValue { tag: abcd, value: 0 }
|
||||
]);
|
||||
assert_eq!(off, off_computed);
|
||||
|
||||
let no_value = parse_longhand!(font_feature_settings, "\"abcd\"");
|
||||
let no_value_computed = computed_value::T::Tag(vec![
|
||||
FeatureTagValue { tag: String::from("abcd"), value: 1 }
|
||||
FeatureTagValue { tag: abcd, value: 1 }
|
||||
]);
|
||||
assert_eq!(no_value, no_value_computed);
|
||||
|
||||
let pos_integer = parse_longhand!(font_feature_settings, "\"abcd\" 100");
|
||||
let pos_integer_computed = computed_value::T::Tag(vec![
|
||||
FeatureTagValue { tag: String::from("abcd"), value: 100 }
|
||||
FeatureTagValue { tag: abcd, value: 100 }
|
||||
]);
|
||||
assert_eq!(pos_integer, pos_integer_computed);
|
||||
|
||||
let multiple = parse_longhand!(font_feature_settings, "\"abcd\" off, \"efgh\"");
|
||||
let multiple_computed = computed_value::T::Tag(vec![
|
||||
FeatureTagValue { tag: String::from("abcd"), value: 0 },
|
||||
FeatureTagValue { tag: String::from("efgh"), value: 1 }
|
||||
FeatureTagValue { tag: abcd, value: 0 },
|
||||
FeatureTagValue { tag: efgh, value: 1 }
|
||||
]);
|
||||
assert_eq!(multiple, multiple_computed);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue