mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Parse perspective property as non negative and add tests
This commit is contained in:
parent
c5c4354f84
commit
20c07332a1
4 changed files with 50 additions and 0 deletions
|
@ -1711,6 +1711,7 @@ ${helpers.single_keyword("resize",
|
|||
${helpers.predefined_type("perspective",
|
||||
"LengthOrNone",
|
||||
"Either::Second(None_)",
|
||||
"parse_non_negative_length",
|
||||
gecko_ffi_name="mChildPerspective",
|
||||
spec="https://drafts.csswg.org/css-transforms/#perspective",
|
||||
extra_prefixes="moz webkit",
|
||||
|
|
|
@ -458,6 +458,17 @@ impl Parse for Length {
|
|||
}
|
||||
}
|
||||
|
||||
impl Either<Length, None_> {
|
||||
/// Parse a non-negative length or none
|
||||
#[inline]
|
||||
pub fn parse_non_negative_length(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
if input.try(|input| None_::parse(context, input)).is_ok() {
|
||||
return Ok(Either::Second(None_));
|
||||
}
|
||||
Length::parse_non_negative(input).map(Either::First)
|
||||
}
|
||||
}
|
||||
|
||||
impl Either<Length, Normal> {
|
||||
#[inline]
|
||||
#[allow(missing_docs)]
|
||||
|
|
|
@ -11100,6 +11100,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/perspective.html": [
|
||||
[
|
||||
"/_mozilla/css/perspective.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/stylesheet_media_queries.html": [
|
||||
[
|
||||
"/_mozilla/css/stylesheet_media_queries.html",
|
||||
|
@ -22741,6 +22747,10 @@
|
|||
"001acfd664f89e45ab321bf549803ca24d44e098",
|
||||
"support"
|
||||
],
|
||||
"css/perspective.html": [
|
||||
"6d455ef4b9c815d89917f496999268d7410cfa62",
|
||||
"testharness"
|
||||
],
|
||||
"css/perspective_zero.html": [
|
||||
"bcb877f51808e896d8024877f945ce289dbc6b36",
|
||||
"reftest"
|
||||
|
|
28
tests/wpt/mozilla/tests/css/perspective.html
Normal file
28
tests/wpt/mozilla/tests/css/perspective.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!doctype html>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Test: parsing perspective property</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="test"></div>
|
||||
|
||||
<script>
|
||||
test(function () {
|
||||
var test = document.getElementById('test');
|
||||
var tests = [
|
||||
["none", "none"],
|
||||
["0px", "0px"],
|
||||
["100px", "100px"],
|
||||
["-200px", ""],
|
||||
["300PX", "300px"],
|
||||
];
|
||||
for (var i = 0; i < tests.length; ++i) {
|
||||
var specified = tests[i][0];
|
||||
var expected = tests[i][1];
|
||||
test.style.perspective = specified;
|
||||
assert_equals(test.style.perspective, expected);
|
||||
test.style.perspective = '';
|
||||
}
|
||||
}, "Parsing of the perspective property");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue