servo: Merge #17877 - Cleanup @font-face rule constructor (from canaltinova:font-face-refactoring); r=jdm
authorNazım Can Altınova <canaltinova@gmail.com>
Wed, 26 Jul 2017 14:13:02 -0500
changeset 419845 62ccb664f57db3d7992a564af17e6b6cc3e70e6c
parent 419844 02874c4ecef40f64645fee4eb62f2fa0a1323df9
child 419846 dd104d6d9adf98ce733028dbb698b8f658a69cc8
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs17877
milestone56.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 #17877 - Cleanup @font-face rule constructor (from canaltinova:font-face-refactoring); r=jdm Passing SourceLocation into constructor instead of assigning immediately after construction cleans up the code and helps to prevent leaving an invalid SourceLocation in the future. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because it's just a cleanup. Source-Repo: https://github.com/servo/servo Source-Revision: a15d13a6ec7b1f1ffeef86484ee483ec253ed0ba
servo/components/style/font_face.rs
--- a/servo/components/style/font_face.rs
+++ b/servo/components/style/font_face.rs
@@ -105,18 +105,17 @@ impl Parse for FontWeight {
     }
 }
 
 /// Parse the block inside a `@font-face` rule.
 ///
 /// Note that the prelude parsing code lives in the `stylesheets` module.
 pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser, location: SourceLocation)
     -> FontFaceRuleData {
-    let mut rule = FontFaceRuleData::empty();
-    rule.source_location = location;
+    let mut rule = FontFaceRuleData::empty(location);
     {
         let parser = FontFaceRuleParser {
             context: context,
             rule: &mut rule,
         };
         let mut iter = DeclarationListParser::new(input, parser);
         while let Some(declaration) = iter.next() {
             if let Err(err) = declaration {
@@ -224,25 +223,22 @@ macro_rules! font_face_descriptors_commo
                 #[$doc]
                 pub $ident: Option<$ty>,
             )*
             /// Line and column of the @font-face rule source code.
             pub source_location: SourceLocation,
         }
 
         impl FontFaceRuleData {
-            fn empty() -> Self {
+            fn empty(location: SourceLocation) -> Self {
                 FontFaceRuleData {
                     $(
                         $ident: None,
                     )*
-                    source_location: SourceLocation {
-                        line: 0,
-                        column: 0,
-                    },
+                    source_location: location,
                 }
             }
 
             /// Convert to Gecko types
             #[cfg(feature = "gecko")]
             pub fn set_descriptors(self, descriptors: &mut CSSFontFaceDescriptors) {
                 $(
                     if let Some(value) = self.$ident {