Support line number offsets for inline stylesheets

This commit is contained in:
mckaymatt 2017-04-12 19:33:03 -04:00
parent ea20bd6f63
commit 5d8cbd8e6a
11 changed files with 87 additions and 37 deletions

View file

@ -16,9 +16,15 @@ use test::{self, Bencher};
struct ErrorringErrorReporter;
impl ParseErrorReporter for ErrorringErrorReporter {
fn report_error(&self, _input: &mut Parser, position: SourcePosition, message: &str,
url: &ServoUrl) {
panic!("CSS error: {}\t\n{:?} {}", url.as_str(), position, message);
fn report_error(&self,
input: &mut Parser,
position: SourcePosition,
message: &str,
url: &ServoUrl,
line_number_offset: u64) {
let location = input.source_location(position);
let line_offset = location.line + line_number_offset as usize;
panic!("CSS error: {}\t\n{}:{} {}", url.as_str(), line_offset, location.column, message);
}
}
@ -51,7 +57,8 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
media,
lock,
None,
&ErrorringErrorReporter);
&ErrorringErrorReporter,
0u64);
let guard = s.shared_lock.read();
let rules = s.rules.read_with(&guard);
rules.0.iter().filter_map(|rule| {