mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add rejection of out-of-range values for single-timing-functions
This commit is contained in:
parent
d44bf6182f
commit
8f4282ef76
4 changed files with 46 additions and 8 deletions
|
@ -594,6 +594,10 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
||||||
p2y = try!(specified::parse_number(input));
|
p2y = try!(specified::parse_number(input));
|
||||||
Ok(())
|
Ok(())
|
||||||
}));
|
}));
|
||||||
|
if p1x < 0.0 || p1x > 1.0 || p2x < 0.0 || p2x > 1.0 {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
|
||||||
let (p1, p2) = (Point2D::new(p1x, p1y), Point2D::new(p2x, p2y));
|
let (p1, p2) = (Point2D::new(p1x, p1y), Point2D::new(p2x, p2y));
|
||||||
Ok(SpecifiedValue::CubicBezier(p1, p2))
|
Ok(SpecifiedValue::CubicBezier(p1, p2))
|
||||||
},
|
},
|
||||||
|
@ -601,6 +605,10 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
||||||
let (mut step_count, mut start_end) = (0, StartEnd::End);
|
let (mut step_count, mut start_end) = (0, StartEnd::End);
|
||||||
try!(input.parse_nested_block(|input| {
|
try!(input.parse_nested_block(|input| {
|
||||||
step_count = try!(specified::parse_integer(input));
|
step_count = try!(specified::parse_integer(input));
|
||||||
|
if step_count < 1 {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
|
||||||
if input.try(|input| input.expect_comma()).is_ok() {
|
if input.try(|input| input.expect_comma()).is_ok() {
|
||||||
start_end = try!(match_ignore_ascii_case! {
|
start_end = try!(match_ignore_ascii_case! {
|
||||||
try!(input.expect_ident()),
|
try!(input.expect_ident()),
|
||||||
|
|
|
@ -80,3 +80,4 @@ mod position;
|
||||||
mod selectors;
|
mod selectors;
|
||||||
mod supports;
|
mod supports;
|
||||||
mod text_overflow;
|
mod text_overflow;
|
||||||
|
mod transition_timing_function;
|
||||||
|
|
37
tests/unit/style/parsing/transition_timing_function.rs
Normal file
37
tests/unit/style/parsing/transition_timing_function.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use cssparser::Parser;
|
||||||
|
use media_queries::CSSErrorReporterTest;
|
||||||
|
use parsing::parse;
|
||||||
|
use style::parser::ParserContext;
|
||||||
|
use style::properties::longhands::transition_timing_function;
|
||||||
|
use style::stylesheets::Origin;
|
||||||
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cubic_bezier() {
|
||||||
|
assert_roundtrip_with_context!(transition_timing_function::parse, "cubic-bezier(0, 0, 0, 0)");
|
||||||
|
assert_roundtrip_with_context!(transition_timing_function::parse, "cubic-bezier(0.25, 0, 0.5, 0)");
|
||||||
|
assert_roundtrip_with_context!(transition_timing_function::parse, "cubic-bezier(1, 1, 1, 1)");
|
||||||
|
|
||||||
|
// p1x and p2x values must be in range [0, 1]
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(-1, 0, 0, 0").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(0, 0, -1, 0").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(-1, 0, -1, 0").is_err());
|
||||||
|
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(2, 0, 0, 0").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(0, 0, 2, 0").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "cubic-bezier(2, 0, 2, 0").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_steps() {
|
||||||
|
assert_roundtrip_with_context!(transition_timing_function::parse, "steps(1)");
|
||||||
|
|
||||||
|
// Step interval value must be an integer greater than 0
|
||||||
|
assert!(parse(transition_timing_function::parse, "steps(0)").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "steps(0.5)").is_err());
|
||||||
|
assert!(parse(transition_timing_function::parse, "steps(-1)").is_err());
|
||||||
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
[transition-timing-function-001.htm]
|
|
||||||
type: testharness
|
|
||||||
[parse 'cubic-bezier(-0.1, -0.2, -0.3, -0.4)']
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[parse 'cubic-bezier(1.1, 1.2, 1.3, 1.4)']
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue