-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix perspective interpolation test to allow 0 as value #28036
Fix perspective interpolation test to allow 0 as value #28036
Conversation
…orms spec](https://drafts.csswg.org/css-transforms-2/#perspective-property): > As very small <length> values can produce bizarre rendering results and stress the numerical accuracy of transform calculations, values less than 1px must be treated as 1px for rendering purposes. (This clamping does not affect the underlying value, so perspective: 0; in a stylesheet will still serialize back as 0.)
Firefox has the correct behavior I believe, while Chrome has the incorrect behavior where |
https://bugs.webkit.org/show_bug.cgi?id=223111 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Add an extra 59 PASS results, although we also have 18 new FAIL results. Of those new failures, 16 are due to what I believe to be an issue in the WPT test and I filed web-platform-tests/wpt#28036 to address this. With this change in the test, we pass all perspective interpolation tests. * web-platform-tests/css/css-transforms/animation/perspective-composition-expected.txt: * web-platform-tests/css/css-transforms/animation/perspective-interpolation-expected.txt: Source/WebCore: In order to correctly interplate the "perspective" CSS property, we must not interpolate between "none" values and lengths. To do this, we add a new wrapper for this property with a canInterpolate() implementation that uses RenderStyle::hasPerspective() to determine whether we're dealing with a "none" value. We also had to make a change to the way the "none" value is represented internally, since it used to be 0 although the spec (https://drafts.csswg.org/css-transforms-2/#perspective-property) says "perspective: 0 in a stylesheet will still serialize back as 0". So we now change the initial value to be -1, which is fine since negative values are otherwise not allowed. To correctly support this, we must also change consumePerspective() to no longer disallow the 0 value at parse time. * animation/CSSPropertyAnimation.cpp: (WebCore::PerspectiveWrapper::PerspectiveWrapper): (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap): * css/parser/CSSPropertyParser.cpp: (WebCore::consumePerspective): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::hasPerspective const): (WebCore::RenderStyle::initialPerspective): * style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertPerspective): Canonical link: https://commits.webkit.org/235217@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=223111 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Add an extra 59 PASS results, although we also have 18 new FAIL results. Of those new failures, 16 are due to what I believe to be an issue in the WPT test and I filed web-platform-tests/wpt#28036 to address this. With this change in the test, we pass all perspective interpolation tests. * web-platform-tests/css/css-transforms/animation/perspective-composition-expected.txt: * web-platform-tests/css/css-transforms/animation/perspective-interpolation-expected.txt: Source/WebCore: In order to correctly interplate the "perspective" CSS property, we must not interpolate between "none" values and lengths. To do this, we add a new wrapper for this property with a canInterpolate() implementation that uses RenderStyle::hasPerspective() to determine whether we're dealing with a "none" value. We also had to make a change to the way the "none" value is represented internally, since it used to be 0 although the spec (https://drafts.csswg.org/css-transforms-2/#perspective-property) says "perspective: 0 in a stylesheet will still serialize back as 0". So we now change the initial value to be -1, which is fine since negative values are otherwise not allowed. To correctly support this, we must also change consumePerspective() to no longer disallow the 0 value at parse time. * animation/CSSPropertyAnimation.cpp: (WebCore::PerspectiveWrapper::PerspectiveWrapper): (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap): * css/parser/CSSPropertyParser.cpp: (WebCore::consumePerspective): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::hasPerspective const): (WebCore::RenderStyle::initialPerspective): * style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertPerspective): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@274329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
So having -1 be a (still valid) 0px looks good, but -20 would be -190px, right? Is there defined behavior for clamping to the valid range when an extended transition exceeds the normal bounds? |
The existing tests expects the value to be clipped to 0, but the spec doesn't mention anything like other specs do about the value being non-negative. |
Okay, after combing thru several specs, as far as I can tell it is not defined what happens if an interpolation results in a value that is outside the valid range. I've opened w3c/csswg-drafts#6097 to address this. That said, I think there's an obvious correct answer (clamp to the valid range, like math functions do), and this test conforms to that, so I'm gonna go ahead and approve this ahead of the WG discussion. |
…hat resulted from web-platform-tests/wpt#28036 and update the expectations now that we pass this test entirely with 16 new PASS results. * web-platform-tests/css/css-transforms/animation/perspective-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/perspective-interpolation.html: Canonical link: https://commits.webkit.org/235251@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274384 268f45cc-cd09-0410-ab3c-d52691b4dbfc
…hat resulted from web-platform-tests/wpt#28036 and update the expectations now that we pass this test entirely with 16 new PASS results. * web-platform-tests/css/css-transforms/animation/perspective-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/perspective-interpolation.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@274384 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Following up: I confirmed in w3c/csswg-drafts#6097 that clamping is indeed the desired effect, and it was present in the spec previously before getting accidentally removed by unrelated edits. It's fixed now. |
The
perspective
property allows0
as a value, per the CSS Transforms spec: