Use the current parser location for CSS error

… rather than the start location of the current construct.
This likely places the error just *after* of the unexpected token
whereas before would be best, but that’s likely a much bigger change.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1378861
This commit is contained in:
Simon Sapin 2017-09-21 01:44:53 +02:00
parent bc0903c928
commit 056e599562
10 changed files with 34 additions and 31 deletions

View file

@ -273,7 +273,8 @@ macro_rules! font_feature_values_blocks {
while let Some(result) = iter.next() {
if let Err(err) = result {
let error = ContextualParseError::UnsupportedRule(err.slice, err.error);
context.log_css_error(error_context, err.location, error);
let location = iter.input.current_source_location();
context.log_css_error(error_context, location, error);
}
}
}
@ -427,7 +428,8 @@ macro_rules! font_feature_values_blocks {
if let Err(err) = declaration {
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(
err.slice, err.error);
self.context.log_css_error(self.error_context, err.location, error);
let location = iter.input.current_source_location();
self.context.log_css_error(self.error_context, location, error);
}
}
},

View file

@ -526,7 +526,7 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
},
Err(e) => {
let error = ContextualParseError::InvalidKeyframeRule(input.slice_from(start_position), e.clone());
self.context.log_css_error(self.error_context, start_location, error);
self.context.log_css_error(self.error_context, input.current_source_location(), error);
Err(e)
}
}
@ -555,7 +555,7 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
Err(err) => {
iter.parser.declarations.clear();
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(err.slice, err.error);
context.log_css_error(self.error_context, err.location, error);
context.log_css_error(self.error_context, iter.input.current_source_location(), error);
}
}
// `parse_important` is not called here, `!important` is not allowed in keyframe blocks.

View file

@ -333,7 +333,8 @@ impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
Ok(rule) => rules.push(rule),
Err(err) => {
let error = ContextualParseError::UnsupportedRule(err.slice, err.error);
self.context.log_css_error(self.error_context, err.location, error);
let location = iter.input.current_source_location();
self.context.log_css_error(self.error_context, location, error);
}
}
}

View file

@ -396,8 +396,9 @@ impl Stylesheet {
},
Err(err) => {
let error = ContextualParseError::InvalidRule(err.slice, err.error);
let location = iter.input.current_source_location();
iter.parser.context.log_css_error(&iter.parser.error_context,
err.location, error);
location, error);
}
}
}

View file

@ -370,7 +370,7 @@ impl ViewportRule {
}
Err(err) => {
let error = ContextualParseError::UnsupportedViewportDescriptorDeclaration(err.slice, err.error);
context.log_css_error(error_context, err.location, error);
context.log_css_error(error_context, parser.input.current_source_location(), error);
}
}
}