mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16157 - n0max:perspective_parse_non_negative, r=emilio
Parse perspective property as non negative and add tests <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #15449 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16157) <!-- Reviewable:end -->
This commit is contained in:
commit
b783cacc54
4 changed files with 50 additions and 0 deletions
|
@ -1778,6 +1778,7 @@ ${helpers.single_keyword("resize",
|
||||||
${helpers.predefined_type("perspective",
|
${helpers.predefined_type("perspective",
|
||||||
"LengthOrNone",
|
"LengthOrNone",
|
||||||
"Either::Second(None_)",
|
"Either::Second(None_)",
|
||||||
|
"parse_non_negative_length",
|
||||||
gecko_ffi_name="mChildPerspective",
|
gecko_ffi_name="mChildPerspective",
|
||||||
spec="https://drafts.csswg.org/css-transforms/#perspective",
|
spec="https://drafts.csswg.org/css-transforms/#perspective",
|
||||||
extra_prefixes="moz webkit",
|
extra_prefixes="moz webkit",
|
||||||
|
|
|
@ -466,6 +466,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> {
|
impl Either<Length, Normal> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
|
|
@ -11123,6 +11123,12 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"css/perspective.html": [
|
||||||
|
[
|
||||||
|
"/_mozilla/css/perspective.html",
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"css/stylesheet_media_queries.html": [
|
"css/stylesheet_media_queries.html": [
|
||||||
[
|
[
|
||||||
"/_mozilla/css/stylesheet_media_queries.html",
|
"/_mozilla/css/stylesheet_media_queries.html",
|
||||||
|
@ -22782,6 +22788,10 @@
|
||||||
"001acfd664f89e45ab321bf549803ca24d44e098",
|
"001acfd664f89e45ab321bf549803ca24d44e098",
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
|
"css/perspective.html": [
|
||||||
|
"6d455ef4b9c815d89917f496999268d7410cfa62",
|
||||||
|
"testharness"
|
||||||
|
],
|
||||||
"css/perspective_zero.html": [
|
"css/perspective_zero.html": [
|
||||||
"bcb877f51808e896d8024877f945ce289dbc6b36",
|
"bcb877f51808e896d8024877f945ce289dbc6b36",
|
||||||
"reftest"
|
"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