diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 92c15a10067..adc542bd3a4 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -10,6 +10,7 @@ use dom::bindings::str::DOMString; use dom::window::Window; use dom_struct::dom_struct; use style::parser::ParserContext; +use style::stylesheets::CssRuleType; use style::supports::{Declaration, parse_condition_or_declaration}; #[dom_struct] @@ -29,7 +30,7 @@ impl CSS { pub fn Supports(win: &Window, property: DOMString, value: DOMString) -> bool { let decl = Declaration { prop: property.into(), val: value.into() }; let url = win.Document().url(); - let context = ParserContext::new_for_cssom(&url, win.css_error_reporter()); + let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports)); decl.eval(&context) } @@ -39,7 +40,7 @@ impl CSS { let cond = parse_condition_or_declaration(&mut input); if let Ok(cond) = cond { let url = win.Document().url(); - let context = ParserContext::new_for_cssom(&url, win.css_error_reporter()); + let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports)); cond.eval(&context) } else { false diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 2a07471679e..c6bb86bc287 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -17,7 +17,7 @@ use dom_struct::dom_struct; use std::sync::Arc; use style::media_queries::parse_media_query_list; use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::MediaRule; +use style::stylesheets::{CssRuleType, MediaRule}; use style_traits::ToCss; #[dom_struct] @@ -68,6 +68,9 @@ impl CSSMediaRule { /// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface pub fn set_condition_text(&self, text: DOMString) { let mut input = Parser::new(&text); + let win = self.global().as_window(); + let url = win.Document().url(); + let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media)); let new_medialist = parse_media_query_list(&mut input); let mut guard = self.cssconditionrule.shared_lock().write(); diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 7ba3a24d038..bad93e621b5 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -16,7 +16,7 @@ use dom_struct::dom_struct; use std::sync::Arc; use style::parser::ParserContext; use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::SupportsRule; +use style::stylesheets::{CssRuleType, SupportsRule}; use style::supports::SupportsCondition; use style_traits::ToCss; @@ -61,7 +61,7 @@ impl CSSSupportsRule { let global = self.global(); let win = global.as_window(); let url = win.Document().url(); - let context = ParserContext::new_for_cssom(&url, win.css_error_reporter()); + let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports)); let enabled = cond.eval(&context); let mut guard = self.cssconditionrule.shared_lock().write(); let rule = self.supportsrule.write_with(&mut guard); diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 7d01a40fdf3..c12856dd108 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -128,7 +128,8 @@ impl Keyframe { let error_reporter = MemoryHoleReporter; let context = ParserContext::new(parent_stylesheet.origin, &parent_stylesheet.url_data, - &error_reporter); + &error_reporter, + Some(CssRuleType::Keyframe)); let mut input = Parser::new(css); let mut rule_parser = KeyframeListParser { @@ -364,8 +365,9 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> { fn parse_block(&mut self, prelude: Self::Prelude, input: &mut Parser) -> Result { + let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Keyframe)); let parser = KeyframeDeclarationParser { - context: self.context, + context: &context, }; let mut iter = DeclarationListParser::new(input, parser); let mut block = PropertyDeclarationBlock::new(); @@ -376,7 +378,7 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> { let pos = range.start; let message = format!("Unsupported keyframe property declaration: '{}'", iter.input.slice(range)); - log_css_error(iter.input, pos, &*message, self.context); + log_css_error(iter.input, pos, &*message, &context); } } // `parse_important` is not called here, `!important` is not allowed in keyframe blocks. @@ -403,7 +405,7 @@ impl<'a, 'b> DeclarationParser for KeyframeDeclarationParser<'a, 'b> { fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result { let id = try!(PropertyId::parse(name.into())); - match ParsedDeclaration::parse(id, self.context, input, true, CssRuleType::Keyframe) { + match ParsedDeclaration::parse(id, self.context, input, true) { Ok(parsed) => { // In case there is still unparsed text in the declaration, we should roll back. if !input.is_exhausted() { diff --git a/components/style/parser.rs b/components/style/parser.rs index 024d71de936..2f8c3bbffa7 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -9,7 +9,7 @@ use cssparser::{Parser, SourcePosition, UnicodeRange}; use error_reporting::ParseErrorReporter; use style_traits::OneOrMoreCommaSeparated; -use stylesheets::{Origin, UrlExtraData}; +use stylesheets::{CssRuleType, Origin, UrlExtraData}; /// The data that the parser needs from outside in order to parse a stylesheet. pub struct ParserContext<'a> { @@ -20,26 +20,46 @@ pub struct ParserContext<'a> { 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, } impl<'a> ParserContext<'a> { /// Create a parser context. pub fn new(stylesheet_origin: Origin, url_data: &'a UrlExtraData, - error_reporter: &'a ParseErrorReporter) + error_reporter: &'a ParseErrorReporter, + rule_type: Option) -> ParserContext<'a> { ParserContext { stylesheet_origin: stylesheet_origin, url_data: url_data, error_reporter: error_reporter, + rule_type: rule_type, } } /// Create a parser context for on-the-fly parsing in CSSOM pub fn new_for_cssom(url_data: &'a UrlExtraData, - error_reporter: &'a ParseErrorReporter) + error_reporter: &'a ParseErrorReporter, + rule_type: Option) -> ParserContext<'a> { - Self::new(Origin::Author, url_data, error_reporter) + 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) + -> ParserContext<'a> { + Self::new(context.stylesheet_origin, + context.url_data, + context.error_reporter, + rule_type) + } + + /// 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.") } } diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index c9c0e3d9ad3..bd23f73748f 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -612,8 +612,8 @@ pub fn parse_style_attribute(input: &str, url_data: &UrlExtraData, error_reporter: &ParseErrorReporter) -> PropertyDeclarationBlock { - let context = ParserContext::new(Origin::Author, url_data, error_reporter); - parse_property_declaration_list(&context, &mut Parser::new(input), CssRuleType::Style) + let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style)); + parse_property_declaration_list(&context, &mut Parser::new(input)) } /// Parse a given property declaration. Can result in multiple @@ -626,9 +626,9 @@ pub fn parse_one_declaration(id: PropertyId, url_data: &UrlExtraData, error_reporter: &ParseErrorReporter) -> Result { - let context = ParserContext::new(Origin::Author, url_data, error_reporter); + let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style)); Parser::new(input).parse_entirely(|parser| { - ParsedDeclaration::parse(id, &context, parser, false, CssRuleType::Style) + ParsedDeclaration::parse(id, &context, parser, false) .map_err(|_| ()) }) } @@ -636,7 +636,6 @@ pub fn parse_one_declaration(id: PropertyId, /// A struct to parse property declarations. struct PropertyDeclarationParser<'a, 'b: 'a> { context: &'a ParserContext<'b>, - rule_type: CssRuleType, } @@ -654,7 +653,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> { -> Result<(ParsedDeclaration, Importance), ()> { let id = try!(PropertyId::parse(name.into())); let parsed = input.parse_until_before(Delimiter::Bang, |input| { - ParsedDeclaration::parse(id, self.context, input, false, self.rule_type) + ParsedDeclaration::parse(id, self.context, input, false) .map_err(|_| ()) })?; let importance = match input.try(parse_important) { @@ -673,13 +672,11 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> { /// Parse a list of property declarations and return a property declaration /// block. pub fn parse_property_declaration_list(context: &ParserContext, - input: &mut Parser, - rule_type: CssRuleType) + input: &mut Parser) -> PropertyDeclarationBlock { let mut block = PropertyDeclarationBlock::new(); let parser = PropertyDeclarationParser { context: context, - rule_type: rule_type, }; let mut iter = DeclarationListParser::new(input, parser); while let Some(declaration) = iter.next() { diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 28bfc925cb7..db9eaa9651f 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -330,7 +330,7 @@ impl PropertyDeclarationIdSet { // // FIXME(pcwalton): Cloning the error reporter is slow! But so are custom // properties, so whatever... - let context = ParserContext::new(Origin::Author, url_data, error_reporter); + let context = ParserContext::new(Origin::Author, url_data, error_reporter, None); Parser::new(&css).parse_entirely(|input| { match from_shorthand { None => { @@ -977,8 +977,9 @@ impl ParsedDeclaration { /// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser, /// we only set them here so that we don't have to reallocate pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser, - in_keyframe_block: bool, rule_type: CssRuleType) + in_keyframe_block: bool) -> Result { + let rule_type = context.rule_type(); debug_assert!(rule_type == CssRuleType::Keyframe || rule_type == CssRuleType::Page || rule_type == CssRuleType::Style, diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index a85a8a6a307..694806c8ef1 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -387,7 +387,8 @@ impl CssRule { let mut namespaces = parent_stylesheet.namespaces.write(); let context = ParserContext::new(parent_stylesheet.origin, &parent_stylesheet.url_data, - &error_reporter); + &error_reporter, + None); let mut input = Parser::new(css); // nested rules are in the body state @@ -658,7 +659,7 @@ impl Stylesheet { namespaces: namespaces, shared_lock: shared_lock, loader: stylesheet_loader, - context: ParserContext::new(origin, url_data, error_reporter), + context: ParserContext::new(origin, url_data, error_reporter, None), state: Cell::new(State::Start), }; @@ -1115,7 +1116,8 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> { })))) } AtRulePrelude::Page => { - let declarations = parse_property_declaration_list(self.context, input, CssRuleType::Page); + let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Page)); + let declarations = parse_property_declaration_list(&context, input); Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule( Arc::new(self.shared_lock.wrap(declarations)) ))))) @@ -1138,7 +1140,8 @@ impl<'a, 'b> QualifiedRuleParser for NestedRuleParser<'a, 'b> { fn parse_block(&mut self, prelude: SelectorList, input: &mut Parser) -> Result { - let declarations = parse_property_declaration_list(self.context, input, CssRuleType::Style); + let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Style)); + let declarations = parse_property_declaration_list(&context, input); Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule { selectors: prelude, block: Arc::new(self.shared_lock.wrap(declarations)) diff --git a/components/style/supports.rs b/components/style/supports.rs index aae9d989916..37926c2fc9e 100644 --- a/components/style/supports.rs +++ b/components/style/supports.rs @@ -212,7 +212,8 @@ impl Declaration { return false }; let mut input = Parser::new(&self.val); - let res = ParsedDeclaration::parse(id, cx, &mut input, /* in_keyframe */ false, CssRuleType::Style); + let context = ParserContext::new_with_rule_type(cx, Some(CssRuleType::Style)); + let res = ParsedDeclaration::parse(id, &context, &mut input, /* in_keyframe */ false); let _ = input.try(parse_important); res.is_ok() && input.is_exhausted() } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 9999dbff74d..438bd79369d 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -950,9 +950,9 @@ pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const let url_data = unsafe { RefPtr::from_ptr_ref(&data) }; let reporter = StdoutErrorReporter; - let context = ParserContext::new(Origin::Author, url_data, &reporter); + let context = ParserContext::new(Origin::Author, url_data, &reporter, Some(CssRuleType::Style)); - match ParsedDeclaration::parse(id, &context, &mut Parser::new(value), false, CssRuleType::Style) { + match ParsedDeclaration::parse(id, &context, &mut Parser::new(value), false) { Ok(parsed) => { let global_style_data = &*GLOBAL_STYLE_DATA; let mut block = PropertyDeclarationBlock::new(); @@ -972,7 +972,7 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString, let url_data = unsafe { RefPtr::from_ptr_ref(&data) }; let reporter = StdoutErrorReporter; - let context = ParserContext::new(Origin::Author, url_data, &reporter); + let context = ParserContext::new(Origin::Author, url_data, &reporter, Some(CssRuleType::Style)); let easing = unsafe { (*easing).to_string() }; match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) { Ok(parsed_easing) => { @@ -1511,7 +1511,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool { if let Ok(cond) = cond { let url_data = unsafe { dummy_url_data() }; let reporter = StdoutErrorReporter; - let context = ParserContext::new_for_cssom(url_data, &reporter); + let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style)); cond.eval(&context) } else { false diff --git a/tests/unit/style/parsing/animation.rs b/tests/unit/style/parsing/animation.rs index bf9f3b3e2ee..0cb0bc62a03 100644 --- a/tests/unit/style/parsing/animation.rs +++ b/tests/unit/style/parsing/animation.rs @@ -9,7 +9,7 @@ use servo_atoms::Atom; use style::parser::{Parse, ParserContext}; use style::properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount; use style::properties::longhands::animation_name; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] diff --git a/tests/unit/style/parsing/background.rs b/tests/unit/style/parsing/background.rs index 084c2e10201..d2fea3944c7 100644 --- a/tests/unit/style/parsing/background.rs +++ b/tests/unit/style/parsing/background.rs @@ -10,13 +10,13 @@ use style::properties::longhands::{background_attachment, background_clip, backg use style::properties::longhands::{background_origin, background_position_x, background_position_y, background_repeat}; use style::properties::longhands::background_size; use style::properties::shorthands::background; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn background_shorthand_should_parse_all_available_properties_when_specified() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("url(\"http://servo/test.png\") top center / 200px 200px repeat-x fixed padding-box \ content-box red"); let result = background::parse_value(&context, &mut parser).unwrap(); @@ -36,7 +36,7 @@ fn background_shorthand_should_parse_all_available_properties_when_specified() { fn background_shorthand_should_parse_when_some_fields_set() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("14px 40px repeat-y"); let result = background::parse_value(&context, &mut parser).unwrap(); @@ -67,7 +67,7 @@ fn background_shorthand_should_parse_when_some_fields_set() { fn background_shorthand_should_parse_comma_separated_declarations() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("url(\"http://servo/test.png\") top left no-repeat, url(\"http://servo/test.png\") \ center / 100% 100% no-repeat, white"); let result = background::parse_value(&context, &mut parser).unwrap(); @@ -89,7 +89,7 @@ fn background_shorthand_should_parse_comma_separated_declarations() { fn background_shorthand_should_parse_position_and_size_correctly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("7px 4px"); let result = background::parse_value(&context, &mut parser).unwrap(); @@ -114,7 +114,7 @@ fn background_shorthand_should_parse_position_and_size_correctly() { fn background_shorthand_should_parse_origin_and_clip_correctly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("padding-box content-box"); let result = background::parse_value(&context, &mut parser).unwrap(); diff --git a/tests/unit/style/parsing/basic_shape.rs b/tests/unit/style/parsing/basic_shape.rs index dcb269c9397..0923499aed9 100644 --- a/tests/unit/style/parsing/basic_shape.rs +++ b/tests/unit/style/parsing/basic_shape.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::{Parse, ParserContext}; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style::values::specified::basic_shape::*; use style_traits::ToCss; diff --git a/tests/unit/style/parsing/border.rs b/tests/unit/style/parsing/border.rs index 94a4d8f6ff3..e89d33b2b0f 100644 --- a/tests/unit/style/parsing/border.rs +++ b/tests/unit/style/parsing/border.rs @@ -9,14 +9,14 @@ use style::parser::{ParserContext, Parse}; use style::properties::longhands::{border_image_outset, border_image_repeat, border_image_slice}; use style::properties::longhands::{border_image_source, border_image_width}; use style::properties::shorthands::border_image; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] fn border_image_shorthand_should_parse_when_all_properties_specified() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px / 10px \ round stretch"); let result = border_image::parse_value(&context, &mut parser).unwrap(); @@ -33,7 +33,7 @@ fn border_image_shorthand_should_parse_when_all_properties_specified() { fn border_image_shorthand_should_parse_without_width() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / / 10px round stretch"); let result = border_image::parse_value(&context, &mut parser).unwrap(); @@ -49,7 +49,7 @@ fn border_image_shorthand_should_parse_without_width() { fn border_image_shorthand_should_parse_without_outset() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px round"); let result = border_image::parse_value(&context, &mut parser).unwrap(); @@ -65,7 +65,7 @@ fn border_image_shorthand_should_parse_without_outset() { fn border_image_shorthand_should_parse_without_width_or_outset() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round"); let result = border_image::parse_value(&context, &mut parser).unwrap(); @@ -81,7 +81,7 @@ fn border_image_shorthand_should_parse_without_width_or_outset() { fn border_image_shorthand_should_parse_with_just_source() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("linear-gradient(red, blue)"); let result = border_image::parse_value(&context, &mut parser).unwrap(); @@ -97,7 +97,7 @@ fn border_image_shorthand_should_parse_with_just_source() { fn border_image_outset_should_error_on_negative_length() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("-1em"); let result = border_image_outset::parse(&context, &mut parser); assert_eq!(result, Err(())); @@ -107,7 +107,7 @@ fn border_image_outset_should_error_on_negative_length() { fn border_image_outset_should_error_on_negative_number() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("-15"); let result = border_image_outset::parse(&context, &mut parser); assert_eq!(result, Err(())); @@ -117,7 +117,7 @@ fn border_image_outset_should_error_on_negative_number() { fn border_image_outset_should_return_number_on_plain_zero() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("0"); let result = border_image_outset::parse(&context, &mut parser); assert_eq!(result.unwrap(), parse_longhand!(border_image_outset, "0")); @@ -127,7 +127,7 @@ fn border_image_outset_should_return_number_on_plain_zero() { fn border_image_outset_should_return_length_on_length_zero() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("0em"); let result = border_image_outset::parse(&context, &mut parser); assert_eq!(result.unwrap(), parse_longhand!(border_image_outset, "0em")); diff --git a/tests/unit/style/parsing/box_.rs b/tests/unit/style/parsing/box_.rs index e6b73a3b246..0f7925391a7 100644 --- a/tests/unit/style/parsing/box_.rs +++ b/tests/unit/style/parsing/box_.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] diff --git a/tests/unit/style/parsing/column.rs b/tests/unit/style/parsing/column.rs index f8aff1e04b7..cc8c8532db7 100644 --- a/tests/unit/style/parsing/column.rs +++ b/tests/unit/style/parsing/column.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] @@ -20,7 +20,7 @@ fn test_column_width() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut negative = Parser::new("-6px"); assert!(column_width::parse(&context, &mut negative).is_err()); @@ -37,7 +37,7 @@ fn test_column_gap() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut negative = Parser::new("-6px"); assert!(column_gap::parse(&context, &mut negative).is_err()); diff --git a/tests/unit/style/parsing/containment.rs b/tests/unit/style/parsing/containment.rs index de697cb8441..d5a7bea9723 100644 --- a/tests/unit/style/parsing/containment.rs +++ b/tests/unit/style/parsing/containment.rs @@ -5,7 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn contain_longhand_should_parse_correctly() { diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs index 2b8ef18c2e5..aa53c3c209e 100644 --- a/tests/unit/style/parsing/effects.rs +++ b/tests/unit/style/parsing/effects.rs @@ -8,7 +8,7 @@ use parsing::parse; use servo_url::ServoUrl; use style::parser::ParserContext; use style::properties::longhands::{self, perspective_origin, transform_origin}; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] @@ -39,7 +39,7 @@ fn test_clip() { fn test_longhands_parse_origin() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("1px some-rubbish"); let parsed = longhands::parse_origin(&context, &mut parser); diff --git a/tests/unit/style/parsing/font.rs b/tests/unit/style/parsing/font.rs index 6d44e1f532f..19aa0f12172 100644 --- a/tests/unit/style/parsing/font.rs +++ b/tests/unit/style/parsing/font.rs @@ -9,7 +9,7 @@ use style::parser::ParserContext; use style::properties::longhands::{font_feature_settings, font_weight}; use style::properties::longhands::font_feature_settings::computed_value; use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] @@ -54,7 +54,7 @@ fn font_feature_settings_should_parse_properly() { fn font_feature_settings_should_throw_on_bad_input() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut empty = Parser::new(""); assert!(font_feature_settings::parse(&context, &mut empty).is_err()); @@ -105,7 +105,7 @@ fn font_weight_keyword_should_preserve_keyword() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("normal"); let result = font_weight::parse(&context, &mut parser); assert_eq!(result.unwrap(), SpecifiedValue::Normal); diff --git a/tests/unit/style/parsing/image.rs b/tests/unit/style/parsing/image.rs index 68ccec16a5f..4859abf41df 100644 --- a/tests/unit/style/parsing/image.rs +++ b/tests/unit/style/parsing/image.rs @@ -10,7 +10,7 @@ use style::font_metrics::ServoMetricsProvider; use style::media_queries::{Device, MediaType}; use style::parser::ParserContext; use style::properties::ComputedValues; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style::values::computed; use style::values::computed::{Angle, Context, ToComputedValue}; use style::values::specified; diff --git a/tests/unit/style/parsing/inherited_box.rs b/tests/unit/style/parsing/inherited_box.rs index 749641c79cf..8eb0cd8d48d 100644 --- a/tests/unit/style/parsing/inherited_box.rs +++ b/tests/unit/style/parsing/inherited_box.rs @@ -5,7 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn image_orientation_longhand_should_parse_properly() { diff --git a/tests/unit/style/parsing/inherited_text.rs b/tests/unit/style/parsing/inherited_text.rs index b0d474b6024..ce25252b25d 100644 --- a/tests/unit/style/parsing/inherited_text.rs +++ b/tests/unit/style/parsing/inherited_text.rs @@ -5,7 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn negative_letter_spacing_should_parse_properly() { @@ -112,7 +112,7 @@ fn webkit_text_stroke_shorthand_should_parse_properly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("thin red"); let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap(); @@ -134,7 +134,7 @@ fn line_height_should_return_number_on_plain_zero() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("0"); let result = line_height::parse(&context, &mut parser); assert_eq!(result.unwrap(), parse_longhand!(line_height, "0")); @@ -148,7 +148,7 @@ fn line_height_should_return_length_on_length_zero() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("0px"); let result = line_height::parse(&context, &mut parser); assert_eq!(result.unwrap(), parse_longhand!(line_height, "0px")); diff --git a/tests/unit/style/parsing/length.rs b/tests/unit/style/parsing/length.rs index 39407441aaf..bc94ab5ba91 100644 --- a/tests/unit/style/parsing/length.rs +++ b/tests/unit/style/parsing/length.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::{Parse, ParserContext}; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style::values::specified::length::Length; use style_traits::ToCss; diff --git a/tests/unit/style/parsing/mask.rs b/tests/unit/style/parsing/mask.rs index 15f498c4c73..b3f3912d7c9 100644 --- a/tests/unit/style/parsing/mask.rs +++ b/tests/unit/style/parsing/mask.rs @@ -9,13 +9,13 @@ use style::parser::ParserContext; use style::properties::longhands::{mask_clip, mask_composite, mask_image, mask_mode}; use style::properties::longhands::{mask_origin, mask_position_x, mask_position_y, mask_repeat, mask_size}; use style::properties::shorthands::mask; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn mask_shorthand_should_parse_all_available_properties_when_specified() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("url(\"http://servo/test.png\") luminance 7px 4px / 70px 50px \ repeat-x padding-box border-box subtract"); let result = mask::parse_value(&context, &mut parser).unwrap(); @@ -35,7 +35,7 @@ fn mask_shorthand_should_parse_all_available_properties_when_specified() { fn mask_shorthand_should_parse_when_some_fields_set() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("14px 40px repeat-y"); let result = mask::parse_value(&context, &mut parser).unwrap(); @@ -65,7 +65,7 @@ fn mask_shorthand_should_parse_when_some_fields_set() { fn mask_shorthand_should_parse_position_and_size_correctly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("7px 4px"); let result = mask::parse_value(&context, &mut parser).unwrap(); @@ -90,7 +90,7 @@ fn mask_shorthand_should_parse_position_and_size_correctly() { fn mask_shorthand_should_parse_origin_and_clip_correctly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("padding-box content-box"); let result = mask::parse_value(&context, &mut parser).unwrap(); @@ -114,7 +114,7 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() { fn mask_shorthand_should_parse_mode_everywhere() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new("luminance 7px 4px repeat-x padding-box"); assert!(mask::parse_value(&context, &mut parser).is_ok()); @@ -155,7 +155,7 @@ fn mask_repeat_should_parse_longhand_correctly() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); // repeat-x is not available in longhand form. let mut parser = Parser::new("repeat-x no-repeat"); diff --git a/tests/unit/style/parsing/mod.rs b/tests/unit/style/parsing/mod.rs index cb5181fc6cc..b6da9a138d6 100644 --- a/tests/unit/style/parsing/mod.rs +++ b/tests/unit/style/parsing/mod.rs @@ -7,12 +7,12 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; fn parse Result>(f: F, s: &str) -> Result { let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new(s); f(&context, &mut parser) } @@ -26,7 +26,7 @@ macro_rules! assert_roundtrip_with_context { ($fun:expr,$input:expr, $output:expr) => { let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new($input); let parsed = $fun(&context, &mut parser) .expect(&format!("Failed to parse {}", $input)); @@ -64,7 +64,7 @@ macro_rules! assert_parser_exhausted { ($name:ident, $string:expr, $should_exhausted:expr) => {{ let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new($string); let parsed = $name::parse(&context, &mut parser); assert_eq!(parsed.is_ok(), true); @@ -76,7 +76,7 @@ macro_rules! parse_longhand { ($name:ident, $s:expr) => {{ let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); $name::parse(&context, &mut Parser::new($s)).unwrap() }}; } diff --git a/tests/unit/style/parsing/outline.rs b/tests/unit/style/parsing/outline.rs index 3603ccda1db..787d4172055 100644 --- a/tests/unit/style/parsing/outline.rs +++ b/tests/unit/style/parsing/outline.rs @@ -5,7 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] @@ -29,7 +29,7 @@ fn test_outline_style() { let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new(r#"hidden"#); let parsed = outline_style::parse(&context, &mut parser); assert!(parsed.is_err()); diff --git a/tests/unit/style/parsing/position.rs b/tests/unit/style/parsing/position.rs index 8c56b323e67..04da426ded8 100644 --- a/tests/unit/style/parsing/position.rs +++ b/tests/unit/style/parsing/position.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::{Parse, ParserContext}; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style::values::specified::position::*; use style_traits::ToCss; diff --git a/tests/unit/style/parsing/selectors.rs b/tests/unit/style/parsing/selectors.rs index 3654360b07c..24ccc11d546 100644 --- a/tests/unit/style/parsing/selectors.rs +++ b/tests/unit/style/parsing/selectors.rs @@ -7,7 +7,7 @@ use media_queries::CSSErrorReporterTest; use selectors::parser::SelectorList; use style::parser::ParserContext; use style::selector_parser::{SelectorImpl, SelectorParser}; -use style::stylesheets::{Origin, Namespaces}; +use style::stylesheets::{CssRuleType, Origin, Namespaces}; fn parse(_context: &ParserContext, input: &mut Parser) -> Result, ()> { let mut ns = Namespaces::default(); diff --git a/tests/unit/style/parsing/text.rs b/tests/unit/style/parsing/text.rs index d1646c0b887..298d8255e7f 100644 --- a/tests/unit/style/parsing/text.rs +++ b/tests/unit/style/parsing/text.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] diff --git a/tests/unit/style/parsing/text_overflow.rs b/tests/unit/style/parsing/text_overflow.rs index fd2b6b91cab..0e57e733477 100644 --- a/tests/unit/style/parsing/text_overflow.rs +++ b/tests/unit/style/parsing/text_overflow.rs @@ -5,7 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] diff --git a/tests/unit/style/parsing/transition_timing_function.rs b/tests/unit/style/parsing/transition_timing_function.rs index fe24b2453c3..5b27ab75188 100644 --- a/tests/unit/style/parsing/transition_timing_function.rs +++ b/tests/unit/style/parsing/transition_timing_function.rs @@ -7,7 +7,7 @@ use media_queries::CSSErrorReporterTest; use parsing::parse; use style::parser::ParserContext; use style::properties::longhands::transition_timing_function; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style_traits::ToCss; #[test] diff --git a/tests/unit/style/parsing/ui.rs b/tests/unit/style/parsing/ui.rs index 10342947ea5..07a1b0a5d4b 100644 --- a/tests/unit/style/parsing/ui.rs +++ b/tests/unit/style/parsing/ui.rs @@ -6,7 +6,7 @@ use cssparser::{Color, Parser, RGBA}; use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::parser::ParserContext; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; use style::values::{Auto, Either}; use style::values::specified::CSSColor; use style_traits::ToCss; @@ -28,7 +28,7 @@ fn test_moz_user_select() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut negative = Parser::new("potato"); assert!(_moz_user_select::parse(&context, &mut negative).is_err()); diff --git a/tests/unit/style/properties/background.rs b/tests/unit/style/properties/background.rs index 4640845ae85..c83286c10c8 100644 --- a/tests/unit/style/properties/background.rs +++ b/tests/unit/style/properties/background.rs @@ -6,13 +6,13 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; use style::properties::longhands::background_size; -use style::stylesheets::Origin; +use style::stylesheets::{CssRuleType, Origin}; #[test] fn background_size_should_reject_negative_values() { let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let parse_result = background_size::parse(&context, &mut Parser::new("-40% -40%")); diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 1dc93fc7656..04dffa1aa5a 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -21,9 +21,9 @@ use stylesheets::block_from; fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let mut parser = Parser::new(css_properties); - parse_property_declaration_list(&context, &mut parser, CssRuleType::Style) + parse_property_declaration_list(&context, &mut parser) } #[test] @@ -976,7 +976,7 @@ mod shorthand_serialization { let mut s = String::new(); let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let parsed = transform::parse(&context, &mut Parser::new("none")).unwrap(); let try_serialize = parsed.to_css(&mut s); @@ -1040,7 +1040,7 @@ mod shorthand_serialization { let mut s = String::new(); let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style)); let parsed = quotes::parse(&context, &mut Parser::new("none")).unwrap(); let try_serialize = parsed.to_css(&mut s); diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs index dc15436af5e..252aa266478 100644 --- a/tests/unit/style/viewport.rs +++ b/tests/unit/style/viewport.rs @@ -10,7 +10,7 @@ use servo_url::ServoUrl; use style::media_queries::{Device, MediaType}; use style::parser::{Parse, ParserContext}; use style::shared_lock::SharedRwLock; -use style::stylesheets::{Stylesheet, Origin}; +use style::stylesheets::{CssRuleType, Stylesheet, Origin}; use style::values::specified::LengthOrPercentageOrAuto::{self, Auto}; use style::values::specified::NoCalcLength::{self, ViewportPercentage}; use style::values::specified::ViewportPercentageLength::Vw; @@ -290,7 +290,7 @@ fn multiple_stylesheets_cascading() { fn constrain_viewport() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; - let context = ParserContext::new(Origin::Author, &url, &reporter); + let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Viewport)); macro_rules! from_css { ($css:expr) => {