servo: Merge #16742 - Properly use big endianness to parse font feature tags (from nox:font-feature-settings); r=emilio
authorAnthony Ramine <n.oxyde@gmail.com>
Fri, 05 May 2017 15:45:53 -0500
changeset 356855 20b0f18b27452611e3204eecd29efa7166404104
parent 356854 3633cb2d5260126d77c82fb61bc9e8548032ee38
child 356856 24b55221df23c82bd45cccbb0b3c7596bd9e5323
push id31775
push userihsiao@mozilla.com
push dateMon, 08 May 2017 03:10:38 +0000
treeherdermozilla-central@22aaf8bad4df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16742 - Properly use big endianness to parse font feature tags (from nox:font-feature-settings); r=emilio Source-Repo: https://github.com/servo/servo Source-Revision: ce874d72ecaa531f1da7f619b2bced72100612d3
servo/components/style/properties/longhand/font.mako.rs
servo/tests/unit/style/parsing/font.rs
--- a/servo/components/style/properties/longhand/font.mako.rs
+++ b/servo/components/style/properties/longhand/font.mako.rs
@@ -1810,20 +1810,20 @@ macro_rules! exclusive_value {
                     }
                 }
             }
         }
 
         impl ToCss for FeatureTagValue {
             fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                 use std::str;
-                use byteorder::{WriteBytesExt, NativeEndian};
+                use byteorder::{WriteBytesExt, BigEndian};
 
                 let mut raw: Vec<u8> = vec!();
-                raw.write_u32::<NativeEndian>(self.tag).unwrap();
+                raw.write_u32::<BigEndian>(self.tag).unwrap();
                 let str_print = str::from_utf8(&raw).unwrap_or_default();
 
                 match self.value {
                     1 => write!(dest, "\"{}\"", str_print),
                     0 => write!(dest, "\"{}\" off",str_print),
                     x => write!(dest, "\"{}\" {}", str_print, x)
                 }
             }
@@ -1831,29 +1831,29 @@ macro_rules! exclusive_value {
 
         impl Parse for FeatureTagValue {
             /// https://www.w3.org/TR/css-fonts-3/#propdef-font-feature-settings
             /// <string> [ on | off | <integer> ]
             fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
                 use std::io::Cursor;
                 use std::str;
                 use std::ops::Deref;
-                use byteorder::{ReadBytesExt, NativeEndian};
+                use byteorder::{ReadBytesExt, BigEndian};
 
                 let tag = try!(input.expect_string());
 
                 // allowed strings of length 4 containing chars: <U+20, U+7E>
                 if tag.len() != 4 ||
                    tag.chars().any(|c| c < ' ' || c > '~')
                 {
                     return Err(())
                 }
 
                 let mut raw = Cursor::new(tag.as_bytes());
-                let u_tag = raw.read_u32::<NativeEndian>().unwrap();
+                let u_tag = raw.read_u32::<BigEndian>().unwrap();
 
                 if let Ok(value) = input.try(|input| input.expect_integer()) {
                     // handle integer, throw if it is negative
                     if value >= 0 {
                         Ok(FeatureTagValue { tag: u_tag, value: value as u32 })
                     } else {
                         Err(())
                     }
--- a/servo/tests/unit/style/parsing/font.rs
+++ b/servo/tests/unit/style/parsing/font.rs
@@ -5,28 +5,28 @@
 use parsing::parse;
 use style::properties::longhands::{font_feature_settings, font_weight};
 use style::properties::longhands::font_feature_settings::computed_value;
 use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
 use style_traits::ToCss;
 
 #[test]
 fn font_feature_settings_should_parse_properly() {
-    use byteorder::{ReadBytesExt, NativeEndian};
+    use byteorder::{ReadBytesExt, BigEndian};
     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 abcd = a_d_bytes.read_u32::<BigEndian>().unwrap();
+    let efgh = e_h_bytes.read_u32::<BigEndian>().unwrap();
 
     let on = parse_longhand!(font_feature_settings, "\"abcd\" on");
     let on_computed = computed_value::T::Tag(vec![
         FeatureTagValue { tag: abcd, value: 1 }
     ]);
     assert_eq!(on, on_computed);
 
     let off = parse_longhand!(font_feature_settings, "\"abcd\" off");