Use cssparser's new_with_line_number_offset

cssparser provides a way to set the initial line number on a
ParserInput.  This patch changes servo to use this facility, rather than
reimplement the same functionality itself.
This commit is contained in:
Tom Tromey 2017-08-24 07:37:02 -06:00
parent a266e96d28
commit 546ecaeee9
11 changed files with 26 additions and 60 deletions

View file

@ -37,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, QuirksMode::NoQuirks, 0u64);
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
let dummy = Device::new(MediaType::screen(), TypedSize2D::new(200.0, 100.0), ScaleFactor::new(1.0));
let mut rule_count = 0;
let guard = stylesheet.shared_lock.read();
@ -56,7 +56,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, QuirksMode::NoQuirks, 0u64);
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
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());

View file

@ -57,7 +57,7 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
None,
&ErrorringErrorReporter,
QuirksMode::NoQuirks,
0u64);
0);
let guard = s.shared_lock.read();
let rules = s.contents.rules.read_with(&guard);
rules.0.iter().filter_map(|rule| {

View file

@ -70,7 +70,7 @@ fn test_parse_stylesheet() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64);
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
let mut namespaces = Namespaces::default();
namespaces.default = Some((ns!(html), ()));
let expected = Stylesheet {
@ -304,7 +304,7 @@ fn test_report_error_stylesheet() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
None, &error_reporter, QuirksMode::NoQuirks, 5u64);
None, &error_reporter, QuirksMode::NoQuirks, 5);
let mut errors = errors.lock().unwrap();
@ -341,7 +341,7 @@ fn test_no_report_unrecognized_vendor_properties() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(css, url, Origin::UserAgent, media, lock,
None, &error_reporter, QuirksMode::NoQuirks, 0u64);
None, &error_reporter, QuirksMode::NoQuirks, 0);
let mut errors = errors.lock().unwrap();
let error = errors.pop().unwrap();
@ -364,7 +364,7 @@ fn test_source_map_url() {
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(test.0, url.clone(), Origin::UserAgent, media, lock,
None, &CSSErrorReporterTest, QuirksMode::NoQuirks,
0u64);
0);
let url_opt = stylesheet.contents.source_map_url.read();
assert_eq!(*url_opt, test.1);
}

View file

@ -35,7 +35,7 @@ macro_rules! stylesheet {
None,
&$error_reporter,
QuirksMode::NoQuirks,
0u64
0
))
}
}