[CSS Color 4] Add support for new srgb-linear, xyz-d50 and xyz-d65 colorspaces
https://bugs.webkit.org/show_bug.cgi?id=233475

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Update existing color(xyz ...) tests for new d65 whitepoint and add new tests
for color(srgb-linear ...), color(xyz-d50 ...) and color(xyz-d65 ...).

* web-platform-tests/css/css-color/predefined-016.html:
* web-platform-tests/css/css-color/srgb-linear-001-expected.html: Added.
* web-platform-tests/css/css-color/srgb-linear-001.html: Added.
* web-platform-tests/css/css-color/srgb-linear-002-expected.html: Added.
* web-platform-tests/css/css-color/srgb-linear-002.html: Added.
* web-platform-tests/css/css-color/srgb-linear-003-expected.html: Added.
* web-platform-tests/css/css-color/srgb-linear-003.html: Added.
* web-platform-tests/css/css-color/srgb-linear-004-expected.html: Added.
* web-platform-tests/css/css-color/srgb-linear-004.html: Added.
* web-platform-tests/css/css-color/xyz-001.html:
* web-platform-tests/css/css-color/xyz-003-expected.html:
* web-platform-tests/css/css-color/xyz-003.html:
* web-platform-tests/css/css-color/xyz-004-expected.html:
* web-platform-tests/css/css-color/xyz-004.html:
* web-platform-tests/css/css-color/xyz-005.html:
* web-platform-tests/css/css-color/xyz-d50-001-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d50-001.html: Added.
* web-platform-tests/css/css-color/xyz-d50-002-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d50-002.html: Added.
* web-platform-tests/css/css-color/xyz-d50-003-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d50-003.html: Added.
* web-platform-tests/css/css-color/xyz-d50-004-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d50-004.html: Added.
* web-platform-tests/css/css-color/xyz-d50-005-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d50-005.html: Added.
* web-platform-tests/css/css-color/xyz-d65-001-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d65-001.html: Added.
* web-platform-tests/css/css-color/xyz-d65-002-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d65-002.html: Added.
* web-platform-tests/css/css-color/xyz-d65-003-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d65-003.html: Added.
* web-platform-tests/css/css-color/xyz-d65-004-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d65-004.html: Added.
* web-platform-tests/css/css-color/xyz-d65-005-expected.html: Added.
* web-platform-tests/css/css-color/xyz-d65-005.html: Added.

Source/WebCore:

Updates existing tests to add cases for the new colorspaces.

- Adds support for color(srgb-linear ...), color(xyz-d50 ...) and color(xyz-d65 ...)
- Updates color(xyz ...) to be an alias of color(xyz-d65 ...), which is a breaking change
  both because previously it used the d50 white point and because we now serialize it
  as color(xyz-d65 ...). We think this is acceptable as we just shipped the feature and
  no other browsers yet support it.
- Adds support for color-mix(in xyz-d50, ...) and color-mix(in xyz-d65, ...).
- Updates color-mix(in xyz, ...) to use the d65 white point (like above). We have not shipped
  color-mix enabled, so this should even less controvertial.

* css/CSSValueKeywords.in:
Add new keywords.

* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionForRGBTypes):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForRGBTypes):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForXYZTypes):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionForXYZTypes):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeColorFunctionParameters):
(WebCore::CSSPropertyParserHelpers::consumeColorMixColorSpaceAndComma):
(WebCore::CSSPropertyParserHelpers::mixColorComponents):
Add/update parsing support for new/updated colorspaces. parseColorFunctionForXYZTypes
is now templatized like parseColorFunctionForRGBTypes to allow reusing it for each
of the XYZ types.

* platform/graphics/ColorSpace.h:
(WebCore::callWithColorType):
* platform/graphics/ColorSpace.cpp:
(WebCore::operator<<):
* platform/graphics/ColorConversion.cpp:
(WebCore::converColorComponents):
Add new "named" colorspace, XYZ_D65, so that color(xyz-d65 ...) can be piped through
and serialized correctly. We already had a name for srgb-linear (though it was not
possible to create it from css previously) so no new name was needed for it.

* platform/graphics/ColorSerialization.cpp:
(WebCore::serialization):
(WebCore::serializationForCSS):
(WebCore::serializationForHTML):
(WebCore::serializationForRenderTreeAsText):
Add serialization specialization for xyz-d50/xyz-d65 and update name of LinearSRGBA
to "srgb-linear" to match the now defined name in css.

* platform/graphics/cg/ColorCG.cpp:
(WebCore::Color::createAndLosslesslyConvertToSupportedColorSpace):
* platform/graphics/cg/ColorSpaceCG.cpp:
(WebCore::xyzD50ColorSpaceRef):
(WebCore::colorSpaceForCGColorSpace):
(WebCore::xyzColorSpaceRef): Deleted.
* platform/graphics/cg/ColorSpaceCG.h:
(WebCore::cachedNullableCGColorSpace):
Updates xyzColorSpaceRef() function to be named xyzD50ColorSpaceRef() to more accurately
state what it is. It is not yet clear how or if an xyz-d65 colorspace can be created in
CoreGraphics, so we return nullptr when requested. This does not change any rendered values
as we can convert to extended-srgb in that case (as we do with lab and lch) without any loss.

LayoutTests:

Update tests for new srgb-linear, xyz-d50 and xyz-d65 colorspaces

* fast/css/parsing-color-function-expected.txt:
* fast/css/parsing-color-function.html:
* fast/css/parsing-color-mix-expected.txt:
* fast/css/parsing-color-mix.html:
* fast/css/parsing-relative-color-syntax-expected.txt:
* fast/css/parsing-relative-color-syntax.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@286168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
53 files changed
tree: 0d2fd1e8030c448ad015ae90a7e9ac1c721d6dfe
  1. .ccls
  2. .clang-format
  3. .dir-locals.el
  4. .editorconfig
  5. .gitattributes
  6. .gitignore
  7. CMakeLists.txt
  8. ChangeLog
  9. ChangeLog-2012-05-22
  10. ChangeLog-2018-01-01
  11. Introduction.md
  12. JSTests/
  13. LayoutTests/
  14. Makefile
  15. Makefile.shared
  16. ManualTests/
  17. PerformanceTests/
  18. ReadMe.md
  19. Source/
  20. Tools/
  21. WebDriverTests/
  22. WebKit.xcworkspace/
  23. WebKitLibraries/
  24. Websites/
  25. metadata/
  26. resources/
ReadMe.md

WebKit

WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.

Feature Status

Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.

Trying the Latest

On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.

Reporting Bugs

  1. Search WebKit Bugzilla to see if there is an existing report for the bug you've encountered.
  2. Create a Bugzilla account to to report bugs (and to comment on them) if you haven't done so already.
  3. File a bug in accordance with our guidelines.

Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.

Getting the Code

On Windows, follow the instructions on our website.

Cloning the Git SVN Repository

Run the following command to clone WebKit's Git SVN repository:

git clone git@github.com:WebKit/WebKit.git WebKit

or

git clone https://github.com/WebKit/WebKit.git WebKit

If you want to be able to track Subversion revision from your git checkout, you can run the following command to do so:

Tools/Scripts/git-webkit setup-git-svn

For information about this, and other aspects of using Git with WebKit, read the wiki page.

Checking out the Subversion Repository

If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:

svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit

Building WebKit

Building macOS Port

Install Xcode and its command line tools if you haven't done so already:

  1. Install Xcode Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
  2. Install the Xcode Command Line Tools In Terminal, run the command: xcode-select --install

Run the following command to build a debug build with debugging symbols and assertions:

Tools/Scripts/build-webkit --debug

For performance testing, and other purposes, use --release instead.

Using Xcode

You can open WebKit.xcworkspace to build and debug WebKit within Xcode.

If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild for both Products and Intermediates.

Embedded Builds

iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:

sudo Tools/Scripts/configure-xcode-for-embedded-development

Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.” when building target JSCLLIntOffsetsExtractor of project JavaScriptCore.

Run the following command to build a debug build with debugging symbols and assertions for embededded simulators:

Tools/Scripts/build-webkit --debug --<platform>-simulator

or embedded devices:

Tools/Scripts/build-webkit --debug --<platform>-device

where platform is ios, tvos or watchos.

Building the GTK+ Port

For production builds:

cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/gtk/install-dependencies
Tools/Scripts/update-webkitgtk-libs
Tools/Scripts/build-webkit --gtk --debug

For more information on building WebKitGTK+, see the wiki page.

Building the WPE Port

For production builds:

cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/wpe/install-dependencies
Tools/Scripts/update-webkitwpe-libs
Tools/Scripts/build-webkit --wpe --debug

Building Windows Port

For building WebKit on Windows, see the wiki page.

Running WebKit

With Safari and Other macOS Applications

Run the following command to launch Safari with your local build of WebKit:

Tools/Scripts/run-safari --debug

The run-safari script sets the DYLD_FRAMEWORK_PATH environment variable to point to your build products, and then launches /Applications/Safari.app. DYLD_FRAMEWORK_PATH tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks.

To run other applications with your local build of WebKit, run the following command:

Tools/Scripts/run-webkit-app <application-path>

iOS Simulator

Run the following command to launch iOS simulator with your local build of WebKit:

run-safari --debug --ios-simulator

In both cases, if you have built release builds instead, use --release instead of --debug.

Linux Ports

If you have a development build, you can use the run-minibrowser script, e.g.:

run-minibrowser --debug --wpe

Pass one of --gtk, --jsc-only, or --wpe to indicate the port to use.

Contribute

Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.