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

@ -19,8 +19,12 @@ use style_traits::ToCss;
pub struct CSSErrorReporterTest;
impl ParseErrorReporter for CSSErrorReporterTest {
fn report_error(&self, _input: &mut Parser, _position: SourcePosition, _message: &str,
_url: &ServoUrl) {
fn report_error(&self,
_input: &mut Parser,
_position: SourcePosition,
_message: &str,
_url: &ServoUrl,
_line_number_offset: u64) {
}
}
@ -33,7 +37,7 @@ fn test_media_rule<F>(css: &str, callback: F)
let media_list = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(
css, url, Origin::Author, media_list, lock,
None, &CSSErrorReporterTest);
None, &CSSErrorReporterTest, 0u64);
let mut rule_count = 0;
let guard = stylesheet.shared_lock.read();
media_queries(&guard, &stylesheet.rules.read_with(&guard).0, &mut |mq| {
@ -62,7 +66,7 @@ fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
let media_list = Arc::new(lock.wrap(MediaList::empty()));
let ss = Stylesheet::from_str(
css, url, Origin::Author, media_list, lock,
None, &CSSErrorReporterTest);
None, &CSSErrorReporterTest, 0u64);
let mut rule_count = 0;
ss.effective_style_rules(device, &ss.shared_lock.read(), |_| rule_count += 1);
assert!(rule_count == expected_rule_count, css.to_owned());