SVG length parsing mode

SVG allows non-zero lengths to be accepted and assumes they are in px.  This
adds this length parsing mode to Servo.

MozReview-Commit-ID: Kxd3x64r9Ye
This commit is contained in:
J. Ryan Stinnett 2017-04-12 17:40:48 +08:00
parent 0936dd24d0
commit 6069e44f02
18 changed files with 130 additions and 53 deletions

View file

@ -6,13 +6,14 @@
use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use style::parser::ParserContext;
use style::parser::{LengthParsingMode, ParserContext};
use style::stylesheets::{CssRuleType, Origin};
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 reporter = CSSErrorReporterTest;
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style));
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style),
LengthParsingMode::Default);
let mut parser = Parser::new(s);
f(&context, &mut parser)
}