-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[image-set] Handle zero resolution and clamping negative resolutions in calc expressions #13479
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
[image-set] Handle zero resolution and clamping negative resolutions in calc expressions #13479
Conversation
EWS run on previous version of this PR (hash 8417bd9) |
need to rename the bug this doesn't handle clamping in math functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 things:
- Can you retitle the issue to be only about zero resolution?
- Can we add a WPT for rendering zero resolution image set? (similar to the negative resolution one we had before)
Ah right we have zero resolution parsing tests but no zero resolution rendering tests. Yep I'll add a test. |
8417bd9
to
ee56df9
Compare
EWS run on previous version of this PR (hash ee56df9) |
ee56df9
to
f4c999c
Compare
EWS run on previous version of this PR (hash f4c999c) |
I got clamping to work in calc. We're failing the two new parsing tests because we don't serialize calc() the way WPT expects but we do clamp as we should. @nt1m can you take another look at this since I've made some changes since the last time you looked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
@@ -96,7 +96,7 @@ ImageWithScale StyleImageSet::bestImageForScaleFactor() | |||
result = image; | |||
} | |||
|
|||
if (!result.image) | |||
if (!result.image || !result.scaleFactor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we assert that result.scaleFactor
is never negative given calc() should have clamped it earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll add a debug assert here for that. Should catch any mistakes in the parser.
f4c999c
to
aca75bd
Compare
EWS run on current version of this PR (hash aca75bd)
|
EWS run on current version of this PR (hash aca75bd)
|
…in calc expressions https://bugs.webkit.org/show_bug.cgi?id=254388 rdar://107167273 Reviewed by Tim Nguyen. In a CSSWG resolution it was decided that zero resolutions should be accepted by image-set but that they should produce an invalid image. This change accepts zero but will reject negative resolutions. In a follow-up we should clamp the result of calc expressions to zero. This change also resyncs the image-set WPT as of upstream commit c56aec6 w3c/csswg-drafts#8532 (comment) * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering-2.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering-3-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering-3.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering.html. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering-expected.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-negative-resolution-rendering.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-parsing-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-parsing.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-zero-resolution-rendering-2-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-zero-resolution-rendering-2.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-zero-resolution-rendering-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-zero-resolution-rendering.html: Added. * Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSetOption): * Source/WebCore/rendering/style/StyleImageSet.cpp: (WebCore::StyleImageSet::bestImageForScaleFactor): Canonical link: https://commits.webkit.org/264298@main
aca75bd
to
f9cc497
Compare
Committed 264298@main (f9cc497): https://commits.webkit.org/264298@main Reviewed commits have been landed. Closing PR #13479 and removing active labels. |
f9cc497
aca75bd
🧪 wpe-wk2🧪 ios-wk2-wpt🧪 gtk-wk2🧪 api-ios🧪 api-gtk🧪 mac-AS-debug-wk2