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.
This commit is contained in:
Nazım Can Altınova 2017-07-26 11:48:33 -07:00
parent 002ea74a71
commit c9e5cf0a28

View file

@ -110,8 +110,7 @@ impl Parse for FontWeight {
/// Note that the prelude parsing code lives in the `stylesheets` module. /// Note that the prelude parsing code lives in the `stylesheets` module.
pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser, location: SourceLocation) pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser, location: SourceLocation)
-> FontFaceRuleData { -> FontFaceRuleData {
let mut rule = FontFaceRuleData::empty(); let mut rule = FontFaceRuleData::empty(location);
rule.source_location = location;
{ {
let parser = FontFaceRuleParser { let parser = FontFaceRuleParser {
context: context, context: context,
@ -229,15 +228,12 @@ macro_rules! font_face_descriptors_common {
} }
impl FontFaceRuleData { impl FontFaceRuleData {
fn empty() -> Self { fn empty(location: SourceLocation) -> Self {
FontFaceRuleData { FontFaceRuleData {
$( $(
$ident: None, $ident: None,
)* )*
source_location: SourceLocation { source_location: location,
line: 0,
column: 0,
},
} }
} }