mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Add PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES to force to parse negative values.
As per SVG spec [1], we should also parse negative color components values for SMIL, but currently Gecko does not support it either. [1] https://www.w3.org/TR/SVG/implnote.html#RangeClamping
This commit is contained in:
parent
b6b3187efa
commit
59dd93f849
3 changed files with 43 additions and 6 deletions
|
@ -3,8 +3,13 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use app_units::Au;
|
||||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::HasViewportPercentage;
|
||||
use style::values::specified::{AbsoluteLength, NoCalcLength, ViewportPercentageLength};
|
||||
use style::values::specified::{AbsoluteLength, NoCalcLength, Number, ViewportPercentageLength};
|
||||
|
||||
#[test]
|
||||
fn length_has_viewport_percentage() {
|
||||
|
@ -13,3 +18,18 @@ fn length_has_viewport_percentage() {
|
|||
let l = NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px()));
|
||||
assert!(!l.has_viewport_percentage());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parsing_allo_all_numeric_values() {
|
||||
// In SVG length mode, non-zero lengths are assumed to be px.
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter,
|
||||
Some(CssRuleType::Style), PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new("-1");
|
||||
let result = Number::parse_non_negative(&context, &mut parser);
|
||||
assert!(result.is_ok());
|
||||
assert_eq!(result.unwrap(), Number::new(-1.));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue