[webkit-changes] [WebKit/WebKit] f9b1ad: [Image Set]: Refactor CSSImageSetValue to accept o...
Ryan Reno
noreply at github.com
Thu Feb 23 12:23:17 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f9b1ad4c0847a6799049abdb764a5ca7367b4800
https://github.com/WebKit/WebKit/commit/f9b1ad4c0847a6799049abdb764a5ca7367b4800
Author: Ryan Reno <rreno at apple.com>
Date: 2023-02-23 (Thu, 23 Feb 2023)
Changed paths:
M LayoutTests/TestExpectations
M LayoutTests/fast/css/image-set-parsing-expected.txt
R LayoutTests/fast/css/image-set-parsing-generated-expected.txt
R LayoutTests/fast/css/image-set-parsing-generated.html
M LayoutTests/fast/css/image-set-parsing.html
M LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-parsing-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-parsing.html
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
A Source/WebCore/css/CSSImageSetOptionValue.cpp
A Source/WebCore/css/CSSImageSetOptionValue.h
M Source/WebCore/css/CSSImageSetValue.cpp
M Source/WebCore/css/CSSValue.cpp
M Source/WebCore/css/CSSValue.h
M Source/WebCore/css/CSSValuePair.cpp
M Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp
M Source/WebCore/css/parser/CSSPropertyParser.cpp
M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
M Source/WebCore/rendering/style/StyleImageSet.cpp
Log Message:
-----------
[Image Set]: Refactor CSSImageSetValue to accept optional resolution and MIME type parameters
https://bugs.webkit.org/show_bug.cgi?id=252137
rdar://105367742
Reviewed by Antti Koivisto.
The standardized image-set differs from -webkit-image-set in that each option has three arguments instead of two -
an image, an optional resolution, and an optional type() function declaring the MIME type of the image.
This refactors the CSSImageSetValue to hold an CSSImageSetOptionValue object instead of placing the image and
resolution values in a vector and using a stride of 2 to represent each option. The actual parsing of
resolution and type() will be in a follow-on patch.
* LayoutTests/TestExpectations:
Unskip newly passing WPT ref tests.
* LayoutTests/fast/css/image-set-parsing-expected.txt:
* LayoutTests/fast/css/image-set-parsing-generated-expected.txt: Removed.
* LayoutTests/fast/css/image-set-parsing-generated.html: Removed.
* LayoutTests/fast/css/image-set-parsing.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:
Refactor the internal parsing tests in the following ways:
1) Move and dedup all tests of standard properties (e.g. background-image) to WPT.
2) Move generated image tests (gradients, for example) to the main image-set-parsing test.
3) Test that -webkit-image-set is an alias to image-set
4) Test that the serialization is as expected (per WPT).
* Source/WebCore/css/CSSImageSetOptionValue.cpp: Added.
(WebCore::CSSImageSetOptionValue::Type::Type):
(WebCore::CSSImageSetOptionValue::Type::cssText const):
(WebCore::CSSImageSetOptionValue::CSSImageSetOptionValue):
(WebCore::CSSImageSetOptionValue::create):
(WebCore::CSSImageSetOptionValue::equals const):
(WebCore::CSSImageSetOptionValue::customCSSText const):
(WebCore::CSSImageSetOptionValue::image const):
(WebCore::CSSImageSetOptionValue::resolution const):
(WebCore::CSSImageSetOptionValue::setResolution):
(WebCore::CSSImageSetOptionValue::type const):
(WebCore::CSSImageSetOptionValue::setType):
* Source/WebCore/css/CSSImageSetOptionValue.h: Copied from Source/WebCore/css/CSSImageSetValue.h.
Create a new CSSImageSetOptionValue class to represent the arguments to the image-set function.
This object holds a Ref to either a CSSImageValue or a generated image (e.g. a linear-gradient),
and optionally holds a resolution (scale factor) and a MIME type string.
* Source/WebCore/css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::create):
(WebCore::CSSImageSetValue::CSSImageSetValue):
(WebCore::CSSImageSetValue::customCSSText const):
(WebCore::CSSImageSetValue::createStyleImage const):
* Source/WebCore/css/CSSImageSetValue.h:
With -webkit-image-set, the image and resolution were the only two arguments and they were both
required. The standardized image-set makes resolution and type optional. Instead of holding all
the arguments as individual elements in the underlying CSSListValue storage we hold the new
CSSImageSetOptionValues in the internal vector instead. We also now filter the image set on provided
MIME type if it's supported or not when creating the StyleImage.
* Source/WebCore/css/CSSValue.cpp:
(WebCore::CSSValue::visitDerived):
* Source/WebCore/css/CSSValue.h:
(WebCore::CSSValue::isImageSetOptionValue const):
Updates for support for the new CSSImageSetOptionValue.
* Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
* Source/WebCore/css/CSSValuePair.cpp:
Adding a new file caused build errors due to missing includes/incomplete types from forward decls.
I added the needed includes.
(WebCore::CSSPropertyParserHelpers::consumeImageSetOptionalArguments):
(WebCore::CSSPropertyParserHelpers::consumeImageSet):
Use the new CSSImageSetOptionValue/CSSImageSetValue API when constructing those objects. Also created
a stub function which will eventually dispatch to parsing the resolution and type() optional parameters
in a forthcoming patch.
* Source/WebCore/rendering/style/StyleImageSet.cpp:
(WebCore::StyleImageSet::computedStyleValue const):
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
Canonical link: https://commits.webkit.org/260760@main
More information about the webkit-changes
mailing list