mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use the location in the error value when reporting a CSS error
This commit is contained in:
parent
c0f8f15f39
commit
c64374bc58
10 changed files with 34 additions and 27 deletions
|
@ -68,8 +68,9 @@ pub fn parse_counter_style_body<'i, 't, R>(name: CustomIdent,
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err((error, slice)) = declaration {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(slice, error);
|
||||
context.log_css_error(error_context, iter.input.current_source_location(), error)
|
||||
context.log_css_error(error_context, location, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,8 +124,9 @@ pub fn parse_font_face_block<R>(context: &ParserContext,
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err((error, slice)) = declaration {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedFontFaceDescriptor(slice, error);
|
||||
context.log_css_error(error_context, iter.input.current_source_location(), error)
|
||||
context.log_css_error(error_context, location, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,10 +263,11 @@ where
|
|||
},
|
||||
Err(err) => {
|
||||
media_queries.push(MediaQuery::never_matching());
|
||||
let location = err.location;
|
||||
let error = ContextualParseError::InvalidMediaRule(
|
||||
input.slice_from(start_position), err);
|
||||
let error_context = ParserErrorContext { error_reporter };
|
||||
context.log_css_error(&error_context, input.current_source_location(), error);
|
||||
context.log_css_error(&error_context, location, error);
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1040,10 +1040,11 @@ pub fn parse_one_declaration_into<R>(declarations: &mut SourcePropertyDeclaratio
|
|||
PropertyDeclaration::parse_into(declarations, id, name, &context, parser)
|
||||
.map_err(|e| e.into())
|
||||
}).map_err(|err| {
|
||||
let location = err.location;
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
parser.slice_from(start_position), err);
|
||||
let error_context = ParserErrorContext { error_reporter: error_reporter };
|
||||
context.log_css_error(&error_context, parser.current_source_location(), error);
|
||||
context.log_css_error(&error_context, location, error);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1131,8 +1132,8 @@ pub fn parse_property_declaration_list<R>(context: &ParserContext,
|
|||
continue;
|
||||
}
|
||||
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(slice, error);
|
||||
let location = iter.input.current_source_location();
|
||||
context.log_css_error(error_context, location, error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@ macro_rules! font_feature_values_blocks {
|
|||
});
|
||||
while let Some(result) = iter.next() {
|
||||
if let Err((error, slice)) = result {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedRule(slice, error);
|
||||
let location = iter.input.current_source_location();
|
||||
context.log_css_error(error_context, location, error);
|
||||
}
|
||||
}
|
||||
|
@ -430,10 +430,10 @@ macro_rules! font_feature_values_blocks {
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err((error, slice)) = declaration {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(
|
||||
slice, error
|
||||
);
|
||||
let location = iter.input.current_source_location();
|
||||
self.context.log_css_error(self.error_context, location, error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -525,8 +525,9 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
|
|||
})
|
||||
},
|
||||
Err(e) => {
|
||||
let location = e.location;
|
||||
let error = ContextualParseError::InvalidKeyframeRule(input.slice_from(start_position), e.clone());
|
||||
self.context.log_css_error(self.error_context, input.current_source_location(), error);
|
||||
self.context.log_css_error(self.error_context, location, error);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
|
@ -554,8 +555,9 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
|
|||
}
|
||||
Err((error, slice)) => {
|
||||
iter.parser.declarations.clear();
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(slice, error);
|
||||
context.log_css_error(self.error_context, iter.input.current_source_location(), error);
|
||||
context.log_css_error(self.error_context, location, error);
|
||||
}
|
||||
}
|
||||
// `parse_important` is not called here, `!important` is not allowed in keyframe blocks.
|
||||
|
|
|
@ -333,8 +333,8 @@ impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
|
|||
match result {
|
||||
Ok(rule) => rules.push(rule),
|
||||
Err((error, slice)) => {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedRule(slice, error);
|
||||
let location = iter.input.current_source_location();
|
||||
self.context.log_css_error(self.error_context, location, error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,8 +395,8 @@ impl Stylesheet {
|
|||
}
|
||||
},
|
||||
Err((error, slice)) => {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::InvalidRule(slice, error);
|
||||
let location = iter.input.current_source_location();
|
||||
iter.parser.context.log_css_error(&iter.parser.error_context,
|
||||
location, error);
|
||||
}
|
||||
|
|
|
@ -369,8 +369,9 @@ impl ViewportRule {
|
|||
}
|
||||
}
|
||||
Err((error, slice)) => {
|
||||
let location = error.location;
|
||||
let error = ContextualParseError::UnsupportedViewportDescriptorDeclaration(slice, error);
|
||||
context.log_css_error(error_context, parser.input.current_source_location(), error);
|
||||
context.log_css_error(error_context, location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue