diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-12-03 14:24:37 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-12-03 14:24:37 +0530 |
commit | 765ce074a39f630de3357bc752177abb82833343 (patch) | |
tree | 9560f88c42f31de6842c0aa673d107901458d118 | |
parent | c2bdae1ec33f8e39bc25e3020813fc0e6ea497d7 (diff) | |
parent | afdc60fa575860d55abd36495928169f2684ecc1 (diff) | |
download | servo-765ce074a39f630de3357bc752177abb82833343.tar.gz servo-765ce074a39f630de3357bc752177abb82833343.zip |
Auto merge of #8784 - jdm:expose-css-errors-step2, r=jdm
Make log_css_error in parser.rs take a &ParserContext argument and ca…
…ll this method.
Rebase of #8472.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8784)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/font_face.rs | 2 | ||||
-rw-r--r-- | components/style/parser.rs | 8 | ||||
-rw-r--r-- | components/style/properties.mako.rs | 2 | ||||
-rw-r--r-- | components/style/stylesheets.rs | 7 | ||||
-rw-r--r-- | components/style/viewport.rs | 2 |
5 files changed, 9 insertions, 12 deletions
diff --git a/components/style/font_face.rs b/components/style/font_face.rs index 52abb82c3cf..394eed1ebdd 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -40,7 +40,7 @@ pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser) let pos = range.start; let message = format!("Unsupported @font-face descriptor declaration: '{}'", iter.input.slice(range)); - log_css_error(iter.input, pos, &*message); + log_css_error(iter.input, pos, &*message, context); } Ok(FontFaceDescriptorDeclaration::Family(value)) => { family = Some(value); diff --git a/components/style/parser.rs b/components/style/parser.rs index 8570bc777d1..40756638065 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -43,10 +43,6 @@ impl<'a> ParserContext<'a> { /// Defaults to a no-op. /// Set a `RUST_LOG=style::errors` environment variable /// to log CSS parse errors to stderr. -pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str) { - if log_enabled!(log::LogLevel::Info) { - let location = input.source_location(position); - // TODO eventually this will got into a "web console" or something. - info!("{}:{} {}", location.line, location.column, message) - } +pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str, parsercontext: &ParserContext) { + parsercontext.error_reporter.report_error(input, position, message); } diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index f1f4656f8e5..e6ec877904a 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -5739,7 +5739,7 @@ pub fn parse_property_declaration_list(context: &ParserContext, input: &mut Pars let pos = range.start; let message = format!("Unsupported property declaration: '{}'", iter.input.slice(range)); - log_css_error(iter.input, pos, &*message); + log_css_error(iter.input, pos, &*message, &context); } } } diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index e3af16929dc..cbf569f772e 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -108,7 +108,7 @@ impl Stylesheet { pub fn from_str(css: &str, base_url: Url, origin: Origin, error_reporter: Box<ParseErrorReporter + Send>) -> Stylesheet { let rule_parser = TopLevelRuleParser { - context: ParserContext::new(origin, &base_url, error_reporter), + context: ParserContext::new(origin, &base_url, error_reporter.clone()), state: Cell::new(State::Start), }; let mut input = Parser::new(css); @@ -131,7 +131,8 @@ impl Stylesheet { Err(range) => { let pos = range.start; let message = format!("Invalid rule: '{}'", iter.input.slice(range)); - log_css_error(iter.input, pos, &*message); + let context = ParserContext::new(origin, &base_url, error_reporter.clone()); + log_css_error(iter.input, pos, &*message, &context); } } } @@ -329,7 +330,7 @@ fn parse_nested_rules(context: &ParserContext, input: &mut Parser) -> Vec<CSSRul Err(range) => { let pos = range.start; let message = format!("Unsupported rule: '{}'", iter.input.slice(range)); - log_css_error(iter.input, pos, &*message); + log_css_error(iter.input, pos, &*message, &context); } } } diff --git a/components/style/viewport.rs b/components/style/viewport.rs index 698015686a1..ce67a24a561 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -271,7 +271,7 @@ impl ViewportRule { let pos = range.start; let message = format!("Unsupported @viewport descriptor declaration: '{}'", input.slice(range)); - log_css_error(input, pos, &*message); + log_css_error(input, pos, &*message, &context); } Ok(ViewportRule { declarations: valid_declarations.iter().cascade() }) |