servo: Merge #16394 - Support line number offsets for inline stylesheets (from mckaymatt:line_num_offset__issue_15693); r=SimonSapin
authormckaymatt <mckaymatt@gmail.com>
Thu, 13 Apr 2017 20:12:08 -0500
changeset 353088 28008f32e52549f572fdaabf2d6b93106988d405
parent 353087 d699ea9b283895171d07d606d69f16336086dc42
child 353089 66e18dd6ceff425459bc7f39656cab0afabc4c82
push id31656
push userihsiao@mozilla.com
push dateFri, 14 Apr 2017 09:10:41 +0000
treeherdermozilla-central@cda24082bff8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16394 - Support line number offsets for inline stylesheets (from mckaymatt:line_num_offset__issue_15693); r=SimonSapin <!-- Please describe your changes on the following line: --> This allows accurate line numbers when reporting stylesheet errors. @jdm This is going to require some effort to merge my changes with other recent changes to `ParserContext`. Because of that I would appreciate a quick sanity check before I put the time into performing the merge. For example, should I store the `offset` as a u64, or should it be an Option? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15693 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 94397ff0b4fed138241760770ff2d230985bed8a
servo/components/script/dom/htmlstyleelement.rs
servo/components/script_layout_interface/reporter.rs
servo/components/style/encoding_support.rs
servo/components/style/error_reporting.rs
servo/components/style/parser.rs
servo/components/style/stylesheets.rs
servo/ports/geckolib/glue.rs
servo/tests/unit/style/media_queries.rs
servo/tests/unit/style/rule_tree/bench.rs
servo/tests/unit/style/stylesheets.rs
servo/tests/unit/style/viewport.rs
--- a/servo/components/script/dom/htmlstyleelement.rs
+++ b/servo/components/script/dom/htmlstyleelement.rs
@@ -35,31 +35,33 @@ pub struct HTMLStyleElement {
     #[ignore_heap_size_of = "Arc"]
     stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
     cssom_stylesheet: MutNullableJS<CSSStyleSheet>,
     /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts
     parser_inserted: Cell<bool>,
     in_stack_of_open_elements: Cell<bool>,
     pending_loads: Cell<u32>,
     any_failed_load: Cell<bool>,
+    line_number: u64,
 }
 
 impl HTMLStyleElement {
     fn new_inherited(local_name: LocalName,
                      prefix: Option<DOMString>,
                      document: &Document,
                      creator: ElementCreator) -> HTMLStyleElement {
         HTMLStyleElement {
             htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
             stylesheet: DOMRefCell::new(None),
             cssom_stylesheet: MutNullableJS::new(None),
             parser_inserted: Cell::new(creator.is_parser_created()),
             in_stack_of_open_elements: Cell::new(creator.is_parser_created()),
             pending_loads: Cell::new(0),
             any_failed_load: Cell::new(false),
+            line_number: creator.return_line_number(),
         }
     }
 
     #[allow(unrooted_must_root)]
     pub fn new(local_name: LocalName,
                prefix: Option<DOMString>,
                document: &Document,
                creator: ElementCreator) -> Root<HTMLStyleElement> {
@@ -87,17 +89,18 @@ impl HTMLStyleElement {
                                                       win.css_error_reporter(),
                                                       Some(CssRuleType::Media));
         let shared_lock = node.owner_doc().style_shared_lock().clone();
         let mq = Arc::new(shared_lock.wrap(
                     parse_media_query_list(&context, &mut CssParser::new(&mq_str))));
         let loader = StylesheetLoader::for_element(self.upcast());
         let sheet = Stylesheet::from_str(&data, win.get_url(), Origin::Author, mq,
                                          shared_lock, Some(&loader),
-                                         win.css_error_reporter());
+                                         win.css_error_reporter(),
+                                         self.line_number);
 
         let sheet = Arc::new(sheet);
 
         // No subresource loads were triggered, just fire the load event now.
         if self.pending_loads.get() == 0 {
             self.upcast::<EventTarget>().fire_event(atom!("load"));
         }
 
--- a/servo/components/script_layout_interface/reporter.rs
+++ b/servo/components/script_layout_interface/reporter.rs
@@ -21,22 +21,24 @@ pub struct CSSErrorReporter {
     pub script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>,
 }
 
 impl ParseErrorReporter for CSSErrorReporter {
      fn report_error(&self,
                      input: &mut Parser,
                      position: SourcePosition,
                      message: &str,
-                     url: &ServoUrl) {
+                     url: &ServoUrl,
+                     line_number_offset: u64) {
         let location = input.source_location(position);
+        let line_offset = location.line + line_number_offset as usize;
         if log_enabled!(log::LogLevel::Info) {
              info!("Url:\t{}\n{}:{} {}",
                    url.as_str(),
-                   location.line,
+                   line_offset,
                    location.column,
                    message)
         }
 
          //TODO: report a real filename
          let _ = self.script_chan.lock().unwrap().send(
              ConstellationControlMsg::ReportCSSError(self.pipelineid,
                                                      "".to_owned(),
--- a/servo/components/style/encoding_support.rs
+++ b/servo/components/style/encoding_support.rs
@@ -61,17 +61,18 @@ impl Stylesheet {
         let (string, _) = decode_stylesheet_bytes(
             bytes, protocol_encoding_label, environment_encoding);
         Stylesheet::from_str(&string,
                              url_data,
                              origin,
                              Arc::new(shared_lock.wrap(media)),
                              shared_lock,
                              stylesheet_loader,
-                             error_reporter)
+                             error_reporter,
+                             0u64)
     }
 
     /// Updates an empty stylesheet with a set of bytes that reached over the
     /// network.
     pub fn update_from_bytes(existing: &Stylesheet,
                              bytes: &[u8],
                              protocol_encoding_label: Option<&str>,
                              environment_encoding: Option<EncodingRef>,
--- a/servo/components/style/error_reporting.rs
+++ b/servo/components/style/error_reporting.rs
@@ -7,35 +7,38 @@
 #![deny(missing_docs)]
 
 use cssparser::{Parser, SourcePosition};
 use log;
 use stylesheets::UrlExtraData;
 
 /// A generic trait for an error reporter.
 pub trait ParseErrorReporter : Sync + Send {
-    /// Called the style engine detects an error.
+    /// Called when the style engine detects an error.
     ///
     /// Returns the current input being parsed, the source position it was
     /// reported from, and a message.
     fn report_error(&self,
                     input: &mut Parser,
                     position: SourcePosition,
                     message: &str,
-                    url: &UrlExtraData);
+                    url: &UrlExtraData,
+                    line_number_offset: u64);
 }
 
 /// An error reporter that reports the errors to the `info` log channel.
 ///
 /// TODO(emilio): The name of this reporter is a lie, and should be renamed!
 pub struct StdoutErrorReporter;
 impl ParseErrorReporter for StdoutErrorReporter {
     fn report_error(&self,
                     input: &mut Parser,
                     position: SourcePosition,
                     message: &str,
-                    url: &UrlExtraData) {
+                    url: &UrlExtraData,
+                    line_number_offset: u64) {
         if log_enabled!(log::LogLevel::Info) {
             let location = input.source_location(position);
-            info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, message)
+            let line_offset = location.line + line_number_offset as usize;
+            info!("Url:\t{}\n{}:{} {}", url.as_str(), line_offset, location.column, message)
         }
     }
 }
--- a/servo/components/style/parser.rs
+++ b/servo/components/style/parser.rs
@@ -17,66 +17,90 @@ pub struct ParserContext<'a> {
     /// user-agent stylesheet.
     pub stylesheet_origin: Origin,
     /// The extra data we need for resolving url values.
     pub url_data: &'a UrlExtraData,
     /// An error reporter to report syntax errors.
     pub error_reporter: &'a ParseErrorReporter,
     /// The current rule type, if any.
     pub rule_type: Option<CssRuleType>,
+    ///  line number offsets for inline stylesheets
+    pub line_number_offset: u64,
 }
 
 impl<'a> ParserContext<'a> {
     /// Create a parser context.
     pub fn new(stylesheet_origin: Origin,
                url_data: &'a UrlExtraData,
                error_reporter: &'a ParseErrorReporter,
                rule_type: Option<CssRuleType>)
                -> ParserContext<'a> {
         ParserContext {
             stylesheet_origin: stylesheet_origin,
             url_data: url_data,
             error_reporter: error_reporter,
             rule_type: rule_type,
+            line_number_offset: 0u64,
         }
     }
 
     /// Create a parser context for on-the-fly parsing in CSSOM
     pub fn new_for_cssom(url_data: &'a UrlExtraData,
                          error_reporter: &'a ParseErrorReporter,
                          rule_type: Option<CssRuleType>)
                          -> ParserContext<'a> {
         Self::new(Origin::Author, url_data, error_reporter, rule_type)
     }
 
     /// Create a parser context based on a previous context, but with a modified rule type.
     pub fn new_with_rule_type(context: &'a ParserContext,
                               rule_type: Option<CssRuleType>)
                               -> ParserContext<'a> {
-        Self::new(context.stylesheet_origin,
-                  context.url_data,
-                  context.error_reporter,
-                  rule_type)
+        ParserContext {
+            stylesheet_origin: context.stylesheet_origin,
+            url_data: context.url_data,
+            error_reporter: context.error_reporter,
+            rule_type: rule_type,
+            line_number_offset: context.line_number_offset,
+        }
     }
 
     /// Get the rule type, which assumes that one is available.
     pub fn rule_type(&self) -> CssRuleType {
         self.rule_type.expect("Rule type expected, but none was found.")
     }
+
+    /// Create a parser context for inline CSS which accepts additional line offset argument.
+    pub fn new_with_line_number_offset(stylesheet_origin: Origin,
+                                       url_data: &'a UrlExtraData,
+                                       error_reporter: &'a ParseErrorReporter,
+                                       line_number_offset: u64)
+                                       -> ParserContext<'a> {
+        ParserContext {
+            stylesheet_origin: stylesheet_origin,
+            url_data: url_data,
+            error_reporter: error_reporter,
+            rule_type: None,
+            line_number_offset: line_number_offset,
+        }
+    }
 }
 
 /// 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,
                      parsercontext: &ParserContext) {
     let url_data = parsercontext.url_data;
-    parsercontext.error_reporter.report_error(input, position, message, url_data);
+    let line_number_offset = parsercontext.line_number_offset;
+    parsercontext.error_reporter.report_error(input, position,
+                                              message, url_data,
+                                              line_number_offset);
 }
 
 // XXXManishearth Replace all specified value parse impls with impls of this
 // trait. This will make it easy to write more generic values in the future.
 /// A trait to abstract parsing of a specified value given a `ParserContext` and
 /// CSS input.
 pub trait Parse : Sized {
     /// Parse a value of this type.
--- a/servo/components/style/stylesheets.rs
+++ b/servo/components/style/stylesheets.rs
@@ -323,17 +323,18 @@ pub enum CssRuleType {
 /// Error reporter which silently forgets errors
 pub struct MemoryHoleReporter;
 
 impl ParseErrorReporter for MemoryHoleReporter {
     fn report_error(&self,
             _: &mut Parser,
             _: SourcePosition,
             _: &str,
-            _: &UrlExtraData) {
+            _: &UrlExtraData,
+            _: u64) {
         // do nothing
     }
 }
 
 #[allow(missing_docs)]
 pub enum SingleRuleParseError {
     Syntax,
     Hierarchy,
@@ -661,43 +662,45 @@ impl Stylesheet {
                            stylesheet_loader: Option<&StylesheetLoader>,
                            error_reporter: &ParseErrorReporter) {
         let mut namespaces = Namespaces::default();
         // FIXME: we really should update existing.url_data with the given url_data,
         // otherwise newly inserted rule may not have the right base url.
         let (rules, dirty_on_viewport_size_change) = Stylesheet::parse_rules(
             css, url_data, existing.origin, &mut namespaces,
             &existing.shared_lock, stylesheet_loader, error_reporter,
-        );
+            0u64);
 
         *existing.namespaces.write() = namespaces;
         existing.dirty_on_viewport_size_change
             .store(dirty_on_viewport_size_change, Ordering::Release);
 
         // Acquire the lock *after* parsing, to minimize the exclusive section.
         let mut guard = existing.shared_lock.write();
         *existing.rules.write_with(&mut guard) = CssRules(rules);
     }
 
     fn parse_rules(css: &str,
                    url_data: &UrlExtraData,
                    origin: Origin,
                    namespaces: &mut Namespaces,
                    shared_lock: &SharedRwLock,
                    stylesheet_loader: Option<&StylesheetLoader>,
-                   error_reporter: &ParseErrorReporter)
+                   error_reporter: &ParseErrorReporter,
+                   line_number_offset: u64)
                    -> (Vec<CssRule>, bool) {
         let mut rules = Vec::new();
         let mut input = Parser::new(css);
         let rule_parser = TopLevelRuleParser {
             stylesheet_origin: origin,
             namespaces: namespaces,
             shared_lock: shared_lock,
             loader: stylesheet_loader,
-            context: ParserContext::new(origin, url_data, error_reporter, None),
+            context: ParserContext::new_with_line_number_offset(origin, url_data, error_reporter,
+                                                                line_number_offset),
             state: Cell::new(State::Start),
         };
 
         input.look_for_viewport_percentages();
 
         {
             let mut iter = RuleListParser::new_for_stylesheet(&mut input, rule_parser);
             while let Some(result) = iter.next() {
@@ -721,21 +724,22 @@ impl Stylesheet {
     /// Effectively creates a new stylesheet and forwards the hard work to
     /// `Stylesheet::update_from_str`.
     pub fn from_str(css: &str,
                     url_data: UrlExtraData,
                     origin: Origin,
                     media: Arc<Locked<MediaList>>,
                     shared_lock: SharedRwLock,
                     stylesheet_loader: Option<&StylesheetLoader>,
-                    error_reporter: &ParseErrorReporter) -> Stylesheet {
+                    error_reporter: &ParseErrorReporter,
+                    line_number_offset: u64) -> Stylesheet {
         let mut namespaces = Namespaces::default();
         let (rules, dirty_on_viewport_size_change) = Stylesheet::parse_rules(
             css, &url_data, origin, &mut namespaces,
-            &shared_lock, stylesheet_loader, error_reporter,
+            &shared_lock, stylesheet_loader, error_reporter, line_number_offset
         );
         Stylesheet {
             origin: origin,
             url_data: url_data,
             namespaces: RwLock::new(namespaces),
             rules: CssRules::new(rules, &shared_lock),
             media: media,
             shared_lock: shared_lock,
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -491,17 +491,17 @@ pub extern "C" fn Servo_StyleSheet_Empty
         SheetParsingMode::eAuthorSheetFeatures => Origin::Author,
         SheetParsingMode::eUserSheetFeatures => Origin::User,
         SheetParsingMode::eAgentSheetFeatures => Origin::UserAgent,
     };
     let shared_lock = global_style_data.shared_lock.clone();
     Arc::new(Stylesheet::from_str(
         "", unsafe { dummy_url_data() }.clone(), origin,
         Arc::new(shared_lock.wrap(MediaList::empty())),
-        shared_lock, None, &StdoutErrorReporter)
+        shared_lock, None, &StdoutErrorReporter, 0u64)
     ).into_strong()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
                                                  stylesheet: *mut ServoStyleSheet,
                                                  data: *const nsACString,
                                                  mode: SheetParsingMode,
@@ -534,17 +534,17 @@ pub extern "C" fn Servo_StyleSheet_FromU
     let media = if media_list.is_null() {
         Arc::new(shared_lock.wrap(MediaList::empty()))
     } else {
         Locked::<MediaList>::as_arc(unsafe { &&*media_list }).clone()
     };
 
     Arc::new(Stylesheet::from_str(
         input, url_data.clone(), origin, media,
-        shared_lock, loader, &StdoutErrorReporter)
+        shared_lock, loader, &StdoutErrorReporter, 0u64)
     ).into_strong()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheetBorrowed,
                                                   loader: *mut Loader,
                                                   gecko_stylesheet: *mut ServoStyleSheet,
                                                   data: *const nsACString,
--- a/servo/tests/unit/style/media_queries.rs
+++ b/servo/tests/unit/style/media_queries.rs
@@ -14,31 +14,35 @@ use style::servo::media_queries::*;
 use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard};
 use style::stylesheets::{Stylesheet, Origin, CssRule};
 use style::values::specified;
 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) {
     }
 }
 
 fn test_media_rule<F>(css: &str, callback: F)
     where F: Fn(&MediaList, &str),
 {
     let url = ServoUrl::parse("http://localhost").unwrap();
     let css_str = css.to_owned();
     let lock = SharedRwLock::new();
     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| {
         rule_count += 1;
         callback(mq, css);
     });
     assert!(rule_count > 0, css_str);
 }
@@ -57,17 +61,17 @@ fn media_queries<F>(guard: &SharedRwLock
 }
 
 fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
     let url = ServoUrl::parse("http://localhost").unwrap();
     let lock = SharedRwLock::new();
     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());
 }
 
 #[test]
 fn test_mq_empty() {
     test_media_rule("@media { }", |list, css| {
--- a/servo/tests/unit/style/rule_tree/bench.rs
+++ b/servo/tests/unit/style/rule_tree/bench.rs
@@ -11,19 +11,25 @@ use style::media_queries::MediaList;
 use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
 use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
 use style::shared_lock::SharedRwLock;
 use style::stylesheets::{Origin, Stylesheet, CssRule};
 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);
     }
 }
 
 struct AutoGCRuleTree<'a>(&'a RuleTree);
 
 impl<'a> AutoGCRuleTree<'a> {
     fn new(r: &'a RuleTree) -> Self {
         AutoGCRuleTree(r)
@@ -46,17 +52,18 @@ fn parse_rules(css: &str) -> Vec<(StyleS
     let media = Arc::new(lock.wrap(MediaList::empty()));
 
     let s = Stylesheet::from_str(css,
                                  ServoUrl::parse("http://localhost").unwrap(),
                                  Origin::Author,
                                  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| {
         match *rule {
             CssRule::Style(ref style_rule) => Some(style_rule),
             _ => None,
         }
     }).cloned().map(StyleSource::Style).map(|s| {
--- a/servo/tests/unit/style/stylesheets.rs
+++ b/servo/tests/unit/style/stylesheets.rs
@@ -60,17 +60,17 @@ fn test_parse_stylesheet() {
                 animation-name: 'foo'; /* animation properties not allowed here */
                 animation-play-state: running; /* … except animation-play-state */
             }
         }";
     let url = ServoUrl::parse("about::test").unwrap();
     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);
+                                          None, &CSSErrorReporterTest, 0u64);
     let mut namespaces = Namespaces::default();
     namespaces.default = Some(ns!(html));
     let expected = Stylesheet {
         origin: Origin::UserAgent,
         media: Arc::new(stylesheet.shared_lock.wrap(MediaList::empty())),
         shared_lock: stylesheet.shared_lock.clone(),
         namespaces: RwLock::new(namespaces),
         url_data: url,
@@ -288,26 +288,27 @@ impl CSSInvalidErrorReporterTest {
     }
 }
 
 impl ParseErrorReporter for CSSInvalidErrorReporterTest {
     fn report_error(&self,
                     input: &mut CssParser,
                     position: SourcePosition,
                     message: &str,
-                    url: &ServoUrl) {
+                    url: &ServoUrl,
+                    line_number_offset: u64) {
 
         let location = input.source_location(position);
+        let line_offset = location.line + line_number_offset as usize;
 
         let mut errors = self.errors.lock().unwrap();
-
         errors.push(
             CSSError{
                 url: url.clone(),
-                line: location.line,
+                line: line_offset,
                 column: location.column,
                 message: message.to_owned()
             }
         );
     }
 }
 
 
@@ -323,25 +324,25 @@ fn test_report_error_stylesheet() {
     let url = ServoUrl::parse("about::test").unwrap();
     let error_reporter = CSSInvalidErrorReporterTest::new();
 
     let errors = error_reporter.errors.clone();
 
     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);
+                         None, &error_reporter, 5u64);
 
     let mut errors = errors.lock().unwrap();
 
     let error = errors.pop().unwrap();
     assert_eq!("Unsupported property declaration: 'invalid: true;'", error.message);
-    assert_eq!(5, error.line);
+    assert_eq!(10, error.line);
     assert_eq!(9, error.column);
 
     let error = errors.pop().unwrap();
     assert_eq!("Unsupported property declaration: 'display: invalid;'", error.message);
-    assert_eq!(4, error.line);
+    assert_eq!(9, error.line);
     assert_eq!(9, error.column);
 
     // testing for the url
     assert_eq!(url, error.url);
 }
--- a/servo/tests/unit/style/viewport.rs
+++ b/servo/tests/unit/style/viewport.rs
@@ -26,17 +26,18 @@ macro_rules! stylesheet {
     ($css:expr, $origin:ident, $error_reporter:expr, $shared_lock:expr) => {
         Box::new(Stylesheet::from_str(
             $css,
             ServoUrl::parse("http://localhost").unwrap(),
             Origin::$origin,
             Arc::new($shared_lock.wrap(MediaList::empty())),
             $shared_lock,
             None,
-            &$error_reporter
+            &$error_reporter,
+            0u64
         ))
     }
 }
 
 fn test_viewport_rule<F>(css: &str,
                          device: &Device,
                          callback: F)
     where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str)