From c9e5cf0a28a99d821274f7b214c26dfbef3d9b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Wed, 26 Jul 2017 11:48:33 -0700 Subject: [PATCH] Cleanup @font-face rule constructor 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. --- components/style/font_face.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/components/style/font_face.rs b/components/style/font_face.rs index 3dca241828b..23f1496b157 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -110,8 +110,7 @@ impl Parse for FontWeight { /// 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, @@ -229,15 +228,12 @@ macro_rules! font_face_descriptors_common { } impl FontFaceRuleData { - fn empty() -> Self { + fn empty(location: SourceLocation) -> Self { FontFaceRuleData { $( $ident: None, )* - source_location: SourceLocation { - line: 0, - column: 0, - }, + source_location: location, } }