mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Pull rule_type into ParserContext
Absorb `rule_type` into the `ParserContext` so that it's easier to pass down to deeper levels of the parser. MozReview-Commit-ID: DjBNytLxGKX
This commit is contained in:
parent
a093b0a087
commit
4574cd8ea6
35 changed files with 125 additions and 97 deletions
|
@ -10,6 +10,7 @@ use dom::bindings::str::DOMString;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
|
use style::stylesheets::CssRuleType;
|
||||||
use style::supports::{Declaration, parse_condition_or_declaration};
|
use style::supports::{Declaration, parse_condition_or_declaration};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -29,7 +30,7 @@ impl CSS {
|
||||||
pub fn Supports(win: &Window, property: DOMString, value: DOMString) -> bool {
|
pub fn Supports(win: &Window, property: DOMString, value: DOMString) -> bool {
|
||||||
let decl = Declaration { prop: property.into(), val: value.into() };
|
let decl = Declaration { prop: property.into(), val: value.into() };
|
||||||
let url = win.Document().url();
|
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)
|
decl.eval(&context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ impl CSS {
|
||||||
let cond = parse_condition_or_declaration(&mut input);
|
let cond = parse_condition_or_declaration(&mut input);
|
||||||
if let Ok(cond) = cond {
|
if let Ok(cond) = cond {
|
||||||
let url = win.Document().url();
|
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)
|
cond.eval(&context)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -17,7 +17,7 @@ use dom_struct::dom_struct;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::media_queries::parse_media_query_list;
|
use style::media_queries::parse_media_query_list;
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||||
use style::stylesheets::MediaRule;
|
use style::stylesheets::{CssRuleType, MediaRule};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -68,6 +68,9 @@ impl CSSMediaRule {
|
||||||
/// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface
|
/// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface
|
||||||
pub fn set_condition_text(&self, text: DOMString) {
|
pub fn set_condition_text(&self, text: DOMString) {
|
||||||
let mut input = Parser::new(&text);
|
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 new_medialist = parse_media_query_list(&mut input);
|
||||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use dom_struct::dom_struct;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||||
use style::stylesheets::SupportsRule;
|
use style::stylesheets::{CssRuleType, SupportsRule};
|
||||||
use style::supports::SupportsCondition;
|
use style::supports::SupportsCondition;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ impl CSSSupportsRule {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let win = global.as_window();
|
let win = global.as_window();
|
||||||
let url = win.Document().url();
|
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 enabled = cond.eval(&context);
|
||||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||||
let rule = self.supportsrule.write_with(&mut guard);
|
let rule = self.supportsrule.write_with(&mut guard);
|
||||||
|
|
|
@ -128,7 +128,8 @@ impl Keyframe {
|
||||||
let error_reporter = MemoryHoleReporter;
|
let error_reporter = MemoryHoleReporter;
|
||||||
let context = ParserContext::new(parent_stylesheet.origin,
|
let context = ParserContext::new(parent_stylesheet.origin,
|
||||||
&parent_stylesheet.url_data,
|
&parent_stylesheet.url_data,
|
||||||
&error_reporter);
|
&error_reporter,
|
||||||
|
Some(CssRuleType::Keyframe));
|
||||||
let mut input = Parser::new(css);
|
let mut input = Parser::new(css);
|
||||||
|
|
||||||
let mut rule_parser = KeyframeListParser {
|
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)
|
fn parse_block(&mut self, prelude: Self::Prelude, input: &mut Parser)
|
||||||
-> Result<Self::QualifiedRule, ()> {
|
-> Result<Self::QualifiedRule, ()> {
|
||||||
|
let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Keyframe));
|
||||||
let parser = KeyframeDeclarationParser {
|
let parser = KeyframeDeclarationParser {
|
||||||
context: self.context,
|
context: &context,
|
||||||
};
|
};
|
||||||
let mut iter = DeclarationListParser::new(input, parser);
|
let mut iter = DeclarationListParser::new(input, parser);
|
||||||
let mut block = PropertyDeclarationBlock::new();
|
let mut block = PropertyDeclarationBlock::new();
|
||||||
|
@ -376,7 +378,7 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> {
|
||||||
let pos = range.start;
|
let pos = range.start;
|
||||||
let message = format!("Unsupported keyframe property declaration: '{}'",
|
let message = format!("Unsupported keyframe property declaration: '{}'",
|
||||||
iter.input.slice(range));
|
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.
|
// `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<ParsedDeclaration, ()> {
|
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<ParsedDeclaration, ()> {
|
||||||
let id = try!(PropertyId::parse(name.into()));
|
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) => {
|
Ok(parsed) => {
|
||||||
// In case there is still unparsed text in the declaration, we should roll back.
|
// In case there is still unparsed text in the declaration, we should roll back.
|
||||||
if !input.is_exhausted() {
|
if !input.is_exhausted() {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
use cssparser::{Parser, SourcePosition, UnicodeRange};
|
use cssparser::{Parser, SourcePosition, UnicodeRange};
|
||||||
use error_reporting::ParseErrorReporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
use style_traits::OneOrMoreCommaSeparated;
|
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.
|
/// The data that the parser needs from outside in order to parse a stylesheet.
|
||||||
pub struct ParserContext<'a> {
|
pub struct ParserContext<'a> {
|
||||||
|
@ -20,26 +20,46 @@ pub struct ParserContext<'a> {
|
||||||
pub url_data: &'a UrlExtraData,
|
pub url_data: &'a UrlExtraData,
|
||||||
/// An error reporter to report syntax errors.
|
/// An error reporter to report syntax errors.
|
||||||
pub error_reporter: &'a ParseErrorReporter,
|
pub error_reporter: &'a ParseErrorReporter,
|
||||||
|
/// The current rule type, if any.
|
||||||
|
pub rule_type: Option<CssRuleType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ParserContext<'a> {
|
impl<'a> ParserContext<'a> {
|
||||||
/// Create a parser context.
|
/// Create a parser context.
|
||||||
pub fn new(stylesheet_origin: Origin,
|
pub fn new(stylesheet_origin: Origin,
|
||||||
url_data: &'a UrlExtraData,
|
url_data: &'a UrlExtraData,
|
||||||
error_reporter: &'a ParseErrorReporter)
|
error_reporter: &'a ParseErrorReporter,
|
||||||
|
rule_type: Option<CssRuleType>)
|
||||||
-> ParserContext<'a> {
|
-> ParserContext<'a> {
|
||||||
ParserContext {
|
ParserContext {
|
||||||
stylesheet_origin: stylesheet_origin,
|
stylesheet_origin: stylesheet_origin,
|
||||||
url_data: url_data,
|
url_data: url_data,
|
||||||
error_reporter: error_reporter,
|
error_reporter: error_reporter,
|
||||||
|
rule_type: rule_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a parser context for on-the-fly parsing in CSSOM
|
/// Create a parser context for on-the-fly parsing in CSSOM
|
||||||
pub fn new_for_cssom(url_data: &'a UrlExtraData,
|
pub fn new_for_cssom(url_data: &'a UrlExtraData,
|
||||||
error_reporter: &'a ParseErrorReporter)
|
error_reporter: &'a ParseErrorReporter,
|
||||||
|
rule_type: Option<CssRuleType>)
|
||||||
-> ParserContext<'a> {
|
-> 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<CssRuleType>)
|
||||||
|
-> 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.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -612,8 +612,8 @@ pub fn parse_style_attribute(input: &str,
|
||||||
url_data: &UrlExtraData,
|
url_data: &UrlExtraData,
|
||||||
error_reporter: &ParseErrorReporter)
|
error_reporter: &ParseErrorReporter)
|
||||||
-> PropertyDeclarationBlock {
|
-> PropertyDeclarationBlock {
|
||||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||||
parse_property_declaration_list(&context, &mut Parser::new(input), CssRuleType::Style)
|
parse_property_declaration_list(&context, &mut Parser::new(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a given property declaration. Can result in multiple
|
/// Parse a given property declaration. Can result in multiple
|
||||||
|
@ -626,9 +626,9 @@ pub fn parse_one_declaration(id: PropertyId,
|
||||||
url_data: &UrlExtraData,
|
url_data: &UrlExtraData,
|
||||||
error_reporter: &ParseErrorReporter)
|
error_reporter: &ParseErrorReporter)
|
||||||
-> Result<ParsedDeclaration, ()> {
|
-> Result<ParsedDeclaration, ()> {
|
||||||
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| {
|
Parser::new(input).parse_entirely(|parser| {
|
||||||
ParsedDeclaration::parse(id, &context, parser, false, CssRuleType::Style)
|
ParsedDeclaration::parse(id, &context, parser, false)
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,6 @@ pub fn parse_one_declaration(id: PropertyId,
|
||||||
/// A struct to parse property declarations.
|
/// A struct to parse property declarations.
|
||||||
struct PropertyDeclarationParser<'a, 'b: 'a> {
|
struct PropertyDeclarationParser<'a, 'b: 'a> {
|
||||||
context: &'a ParserContext<'b>,
|
context: &'a ParserContext<'b>,
|
||||||
rule_type: CssRuleType,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,7 +653,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
||||||
-> Result<(ParsedDeclaration, Importance), ()> {
|
-> Result<(ParsedDeclaration, Importance), ()> {
|
||||||
let id = try!(PropertyId::parse(name.into()));
|
let id = try!(PropertyId::parse(name.into()));
|
||||||
let parsed = input.parse_until_before(Delimiter::Bang, |input| {
|
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(|_| ())
|
.map_err(|_| ())
|
||||||
})?;
|
})?;
|
||||||
let importance = match input.try(parse_important) {
|
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
|
/// Parse a list of property declarations and return a property declaration
|
||||||
/// block.
|
/// block.
|
||||||
pub fn parse_property_declaration_list(context: &ParserContext,
|
pub fn parse_property_declaration_list(context: &ParserContext,
|
||||||
input: &mut Parser,
|
input: &mut Parser)
|
||||||
rule_type: CssRuleType)
|
|
||||||
-> PropertyDeclarationBlock {
|
-> PropertyDeclarationBlock {
|
||||||
let mut block = PropertyDeclarationBlock::new();
|
let mut block = PropertyDeclarationBlock::new();
|
||||||
let parser = PropertyDeclarationParser {
|
let parser = PropertyDeclarationParser {
|
||||||
context: context,
|
context: context,
|
||||||
rule_type: rule_type,
|
|
||||||
};
|
};
|
||||||
let mut iter = DeclarationListParser::new(input, parser);
|
let mut iter = DeclarationListParser::new(input, parser);
|
||||||
while let Some(declaration) = iter.next() {
|
while let Some(declaration) = iter.next() {
|
||||||
|
|
|
@ -330,7 +330,7 @@ impl PropertyDeclarationIdSet {
|
||||||
//
|
//
|
||||||
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
|
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
|
||||||
// properties, so whatever...
|
// 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| {
|
Parser::new(&css).parse_entirely(|input| {
|
||||||
match from_shorthand {
|
match from_shorthand {
|
||||||
None => {
|
None => {
|
||||||
|
@ -977,8 +977,9 @@ impl ParsedDeclaration {
|
||||||
/// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
|
/// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
|
||||||
/// we only set them here so that we don't have to reallocate
|
/// we only set them here so that we don't have to reallocate
|
||||||
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
|
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
|
||||||
in_keyframe_block: bool, rule_type: CssRuleType)
|
in_keyframe_block: bool)
|
||||||
-> Result<ParsedDeclaration, PropertyDeclarationParseError> {
|
-> Result<ParsedDeclaration, PropertyDeclarationParseError> {
|
||||||
|
let rule_type = context.rule_type();
|
||||||
debug_assert!(rule_type == CssRuleType::Keyframe ||
|
debug_assert!(rule_type == CssRuleType::Keyframe ||
|
||||||
rule_type == CssRuleType::Page ||
|
rule_type == CssRuleType::Page ||
|
||||||
rule_type == CssRuleType::Style,
|
rule_type == CssRuleType::Style,
|
||||||
|
|
|
@ -387,7 +387,8 @@ impl CssRule {
|
||||||
let mut namespaces = parent_stylesheet.namespaces.write();
|
let mut namespaces = parent_stylesheet.namespaces.write();
|
||||||
let context = ParserContext::new(parent_stylesheet.origin,
|
let context = ParserContext::new(parent_stylesheet.origin,
|
||||||
&parent_stylesheet.url_data,
|
&parent_stylesheet.url_data,
|
||||||
&error_reporter);
|
&error_reporter,
|
||||||
|
None);
|
||||||
let mut input = Parser::new(css);
|
let mut input = Parser::new(css);
|
||||||
|
|
||||||
// nested rules are in the body state
|
// nested rules are in the body state
|
||||||
|
@ -658,7 +659,7 @@ impl Stylesheet {
|
||||||
namespaces: namespaces,
|
namespaces: namespaces,
|
||||||
shared_lock: shared_lock,
|
shared_lock: shared_lock,
|
||||||
loader: stylesheet_loader,
|
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),
|
state: Cell::new(State::Start),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1115,7 +1116,8 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
|
||||||
}))))
|
}))))
|
||||||
}
|
}
|
||||||
AtRulePrelude::Page => {
|
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(
|
Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule(
|
||||||
Arc::new(self.shared_lock.wrap(declarations))
|
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<SelectorImpl>, input: &mut Parser)
|
fn parse_block(&mut self, prelude: SelectorList<SelectorImpl>, input: &mut Parser)
|
||||||
-> Result<CssRule, ()> {
|
-> Result<CssRule, ()> {
|
||||||
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 {
|
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
|
||||||
selectors: prelude,
|
selectors: prelude,
|
||||||
block: Arc::new(self.shared_lock.wrap(declarations))
|
block: Arc::new(self.shared_lock.wrap(declarations))
|
||||||
|
|
|
@ -212,7 +212,8 @@ impl Declaration {
|
||||||
return false
|
return false
|
||||||
};
|
};
|
||||||
let mut input = Parser::new(&self.val);
|
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);
|
let _ = input.try(parse_important);
|
||||||
res.is_ok() && input.is_exhausted()
|
res.is_ok() && input.is_exhausted()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||||
let reporter = StdoutErrorReporter;
|
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) => {
|
Ok(parsed) => {
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let mut block = PropertyDeclarationBlock::new();
|
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 url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||||
let reporter = StdoutErrorReporter;
|
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() };
|
let easing = unsafe { (*easing).to_string() };
|
||||||
match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) {
|
match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) {
|
||||||
Ok(parsed_easing) => {
|
Ok(parsed_easing) => {
|
||||||
|
@ -1511,7 +1511,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
|
||||||
if let Ok(cond) = cond {
|
if let Ok(cond) = cond {
|
||||||
let url_data = unsafe { dummy_url_data() };
|
let url_data = unsafe { dummy_url_data() };
|
||||||
let reporter = StdoutErrorReporter;
|
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)
|
cond.eval(&context)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -9,7 +9,7 @@ use servo_atoms::Atom;
|
||||||
use style::parser::{Parse, ParserContext};
|
use style::parser::{Parse, ParserContext};
|
||||||
use style::properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
|
use style::properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
|
||||||
use style::properties::longhands::animation_name;
|
use style::properties::longhands::animation_name;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -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_origin, background_position_x, background_position_y, background_repeat};
|
||||||
use style::properties::longhands::background_size;
|
use style::properties::longhands::background_size;
|
||||||
use style::properties::shorthands::background;
|
use style::properties::shorthands::background;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn background_shorthand_should_parse_all_available_properties_when_specified() {
|
fn background_shorthand_should_parse_all_available_properties_when_specified() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 \
|
let mut parser = Parser::new("url(\"http://servo/test.png\") top center / 200px 200px repeat-x fixed padding-box \
|
||||||
content-box red");
|
content-box red");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn background_shorthand_should_parse_when_some_fields_set() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("14px 40px repeat-y");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn background_shorthand_should_parse_comma_separated_declarations() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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\") \
|
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");
|
center / 100% 100% no-repeat, white");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn background_shorthand_should_parse_position_and_size_correctly() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("7px 4px");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn background_shorthand_should_parse_origin_and_clip_correctly() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("padding-box content-box");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::{Parse, ParserContext};
|
use style::parser::{Parse, ParserContext};
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::specified::basic_shape::*;
|
use style::values::specified::basic_shape::*;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
|
|
@ -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_outset, border_image_repeat, border_image_slice};
|
||||||
use style::properties::longhands::{border_image_source, border_image_width};
|
use style::properties::longhands::{border_image_source, border_image_width};
|
||||||
use style::properties::shorthands::border_image;
|
use style::properties::shorthands::border_image;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn border_image_shorthand_should_parse_when_all_properties_specified() {
|
fn border_image_shorthand_should_parse_when_all_properties_specified() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 \
|
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px / 10px \
|
||||||
round stretch");
|
round stretch");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn border_image_shorthand_should_parse_without_width() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 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();
|
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() {
|
fn border_image_shorthand_should_parse_without_outset() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 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();
|
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() {
|
fn border_image_shorthand_should_parse_without_width_or_outset() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn border_image_shorthand_should_parse_with_just_source() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("linear-gradient(red, blue)");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn border_image_outset_should_error_on_negative_length() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("-1em");
|
||||||
let result = border_image_outset::parse(&context, &mut parser);
|
let result = border_image_outset::parse(&context, &mut parser);
|
||||||
assert_eq!(result, Err(()));
|
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() {
|
fn border_image_outset_should_error_on_negative_number() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("-15");
|
||||||
let result = border_image_outset::parse(&context, &mut parser);
|
let result = border_image_outset::parse(&context, &mut parser);
|
||||||
assert_eq!(result, Err(()));
|
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() {
|
fn border_image_outset_should_return_number_on_plain_zero() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("0");
|
||||||
let result = border_image_outset::parse(&context, &mut parser);
|
let result = border_image_outset::parse(&context, &mut parser);
|
||||||
assert_eq!(result.unwrap(), parse_longhand!(border_image_outset, "0"));
|
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() {
|
fn border_image_outset_should_return_length_on_length_zero() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("0em");
|
||||||
let result = border_image_outset::parse(&context, &mut parser);
|
let result = border_image_outset::parse(&context, &mut parser);
|
||||||
assert_eq!(result.unwrap(), parse_longhand!(border_image_outset, "0em"));
|
assert_eq!(result.unwrap(), parse_longhand!(border_image_outset, "0em"));
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -20,7 +20,7 @@ fn test_column_width() {
|
||||||
|
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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");
|
let mut negative = Parser::new("-6px");
|
||||||
assert!(column_width::parse(&context, &mut negative).is_err());
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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");
|
let mut negative = Parser::new("-6px");
|
||||||
assert!(column_gap::parse(&context, &mut negative).is_err());
|
assert!(column_gap::parse(&context, &mut negative).is_err());
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn contain_longhand_should_parse_correctly() {
|
fn contain_longhand_should_parse_correctly() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use parsing::parse;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::longhands::{self, perspective_origin, transform_origin};
|
use style::properties::longhands::{self, perspective_origin, transform_origin};
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -39,7 +39,7 @@ fn test_clip() {
|
||||||
fn test_longhands_parse_origin() {
|
fn test_longhands_parse_origin() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("1px some-rubbish");
|
||||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||||
|
|
|
@ -9,7 +9,7 @@ use style::parser::ParserContext;
|
||||||
use style::properties::longhands::{font_feature_settings, font_weight};
|
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;
|
||||||
use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
|
use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -54,7 +54,7 @@ fn font_feature_settings_should_parse_properly() {
|
||||||
fn font_feature_settings_should_throw_on_bad_input() {
|
fn font_feature_settings_should_throw_on_bad_input() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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("");
|
let mut empty = Parser::new("");
|
||||||
assert!(font_feature_settings::parse(&context, &mut empty).is_err());
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("normal");
|
||||||
let result = font_weight::parse(&context, &mut parser);
|
let result = font_weight::parse(&context, &mut parser);
|
||||||
assert_eq!(result.unwrap(), SpecifiedValue::Normal);
|
assert_eq!(result.unwrap(), SpecifiedValue::Normal);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use style::font_metrics::ServoMetricsProvider;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::computed;
|
use style::values::computed;
|
||||||
use style::values::computed::{Angle, Context, ToComputedValue};
|
use style::values::computed::{Angle, Context, ToComputedValue};
|
||||||
use style::values::specified;
|
use style::values::specified;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn image_orientation_longhand_should_parse_properly() {
|
fn image_orientation_longhand_should_parse_properly() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn negative_letter_spacing_should_parse_properly() {
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("thin red");
|
||||||
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("0");
|
||||||
let result = line_height::parse(&context, &mut parser);
|
let result = line_height::parse(&context, &mut parser);
|
||||||
assert_eq!(result.unwrap(), parse_longhand!(line_height, "0"));
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("0px");
|
||||||
let result = line_height::parse(&context, &mut parser);
|
let result = line_height::parse(&context, &mut parser);
|
||||||
assert_eq!(result.unwrap(), parse_longhand!(line_height, "0px"));
|
assert_eq!(result.unwrap(), parse_longhand!(line_height, "0px"));
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::{Parse, ParserContext};
|
use style::parser::{Parse, ParserContext};
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::specified::length::Length;
|
use style::values::specified::length::Length;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
|
|
@ -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_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::longhands::{mask_origin, mask_position_x, mask_position_y, mask_repeat, mask_size};
|
||||||
use style::properties::shorthands::mask;
|
use style::properties::shorthands::mask;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mask_shorthand_should_parse_all_available_properties_when_specified() {
|
fn mask_shorthand_should_parse_all_available_properties_when_specified() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 \
|
let mut parser = Parser::new("url(\"http://servo/test.png\") luminance 7px 4px / 70px 50px \
|
||||||
repeat-x padding-box border-box subtract");
|
repeat-x padding-box border-box subtract");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn mask_shorthand_should_parse_when_some_fields_set() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("14px 40px repeat-y");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn mask_shorthand_should_parse_position_and_size_correctly() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("7px 4px");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn mask_shorthand_should_parse_origin_and_clip_correctly() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new("padding-box content-box");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
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() {
|
fn mask_shorthand_should_parse_mode_everywhere() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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");
|
let mut parser = Parser::new("luminance 7px 4px repeat-x padding-box");
|
||||||
assert!(mask::parse_value(&context, &mut parser).is_ok());
|
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 url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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.
|
// repeat-x is not available in longhand form.
|
||||||
let mut parser = Parser::new("repeat-x no-repeat");
|
let mut parser = Parser::new("repeat-x no-repeat");
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str) -> Result<T, ()> {
|
fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str) -> Result<T, ()> {
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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);
|
let mut parser = Parser::new(s);
|
||||||
f(&context, &mut parser)
|
f(&context, &mut parser)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ macro_rules! assert_roundtrip_with_context {
|
||||||
($fun:expr,$input:expr, $output:expr) => {
|
($fun:expr,$input:expr, $output:expr) => {
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new($input);
|
||||||
let parsed = $fun(&context, &mut parser)
|
let parsed = $fun(&context, &mut parser)
|
||||||
.expect(&format!("Failed to parse {}", $input));
|
.expect(&format!("Failed to parse {}", $input));
|
||||||
|
@ -64,7 +64,7 @@ macro_rules! assert_parser_exhausted {
|
||||||
($name:ident, $string:expr, $should_exhausted:expr) => {{
|
($name:ident, $string:expr, $should_exhausted:expr) => {{
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new($string);
|
||||||
let parsed = $name::parse(&context, &mut parser);
|
let parsed = $name::parse(&context, &mut parser);
|
||||||
assert_eq!(parsed.is_ok(), true);
|
assert_eq!(parsed.is_ok(), true);
|
||||||
|
@ -76,7 +76,7 @@ macro_rules! parse_longhand {
|
||||||
($name:ident, $s:expr) => {{
|
($name:ident, $s:expr) => {{
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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()
|
$name::parse(&context, &mut Parser::new($s)).unwrap()
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -29,7 +29,7 @@ fn test_outline_style() {
|
||||||
|
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 mut parser = Parser::new(r#"hidden"#);
|
||||||
let parsed = outline_style::parse(&context, &mut parser);
|
let parsed = outline_style::parse(&context, &mut parser);
|
||||||
assert!(parsed.is_err());
|
assert!(parsed.is_err());
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::{Parse, ParserContext};
|
use style::parser::{Parse, ParserContext};
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::specified::position::*;
|
use style::values::specified::position::*;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use media_queries::CSSErrorReporterTest;
|
||||||
use selectors::parser::SelectorList;
|
use selectors::parser::SelectorList;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::selector_parser::{SelectorImpl, SelectorParser};
|
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<SelectorList<SelectorImpl>, ()> {
|
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SelectorList<SelectorImpl>, ()> {
|
||||||
let mut ns = Namespaces::default();
|
let mut ns = Namespaces::default();
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -7,7 +7,7 @@ use media_queries::CSSErrorReporterTest;
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::longhands::transition_timing_function;
|
use style::properties::longhands::transition_timing_function;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::{Color, Parser, RGBA};
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::{Auto, Either};
|
use style::values::{Auto, Either};
|
||||||
use style::values::specified::CSSColor;
|
use style::values::specified::CSSColor;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
@ -28,7 +28,7 @@ fn test_moz_user_select() {
|
||||||
|
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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");
|
let mut negative = Parser::new("potato");
|
||||||
assert!(_moz_user_select::parse(&context, &mut negative).is_err());
|
assert!(_moz_user_select::parse(&context, &mut negative).is_err());
|
||||||
|
|
|
@ -6,13 +6,13 @@ use cssparser::Parser;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::longhands::background_size;
|
use style::properties::longhands::background_size;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn background_size_should_reject_negative_values() {
|
fn background_size_should_reject_negative_values() {
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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%"));
|
let parse_result = background_size::parse(&context, &mut Parser::new("-40% -40%"));
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ use stylesheets::block_from;
|
||||||
fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock {
|
fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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);
|
let mut parser = Parser::new(css_properties);
|
||||||
parse_property_declaration_list(&context, &mut parser, CssRuleType::Style)
|
parse_property_declaration_list(&context, &mut parser)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -976,7 +976,7 @@ mod shorthand_serialization {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 parsed = transform::parse(&context, &mut Parser::new("none")).unwrap();
|
||||||
let try_serialize = parsed.to_css(&mut s);
|
let try_serialize = parsed.to_css(&mut s);
|
||||||
|
@ -1040,7 +1040,7 @@ mod shorthand_serialization {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 parsed = quotes::parse(&context, &mut Parser::new("none")).unwrap();
|
||||||
let try_serialize = parsed.to_css(&mut s);
|
let try_serialize = parsed.to_css(&mut s);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use servo_url::ServoUrl;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::parser::{Parse, ParserContext};
|
use style::parser::{Parse, ParserContext};
|
||||||
use style::shared_lock::SharedRwLock;
|
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::LengthOrPercentageOrAuto::{self, Auto};
|
||||||
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
||||||
use style::values::specified::ViewportPercentageLength::Vw;
|
use style::values::specified::ViewportPercentageLength::Vw;
|
||||||
|
@ -290,7 +290,7 @@ fn multiple_stylesheets_cascading() {
|
||||||
fn constrain_viewport() {
|
fn constrain_viewport() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let reporter = CSSErrorReporterTest;
|
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 {
|
macro_rules! from_css {
|
||||||
($css:expr) => {
|
($css:expr) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue