Create a named CSS property for system colors
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 03:15:23 +0000 (03:15 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 03:15:23 +0000 (03:15 +0000)
commit616caaa4c73ec01408f1449c1a8bd595005fc79e
treef6908564042ea7d73a03ca2ae8acfe4477b4d1bc
parentb7cceb87efa51d471b84514cb87b5b21cb64701b
Create a named CSS property for system colors
https://bugs.webkit.org/show_bug.cgi?id=144423
<rdar://problem/20491011>

Reviewed by Tim Horton.

Source/WebCore:

Test: fast/css/apple-system-colors.html

Expose the following values to CSS color properties:
    -apple-system-blue
    -apple-system-brown
    -apple-system-gray
    -apple-system-green
    -apple-system-orange
    -apple-system-pink
    -apple-system-purple
    -apple-system-red
    -apple-system-yellow

On platforms other than OS X Yosemite and iOS, the
actual color values are undefined and become transparent
black. (In fact, not all are defined on iOS either.)

* WebCore.xcodeproj/project.pbxproj: Two new SPI header files.

* css/CSSParser.cpp:
(WebCore::CSSParser::validSystemColorValue): New helper function that
checks if a CSSValueID is between the two system color values. This
was being tested everywhere, which meant adding a new system color was
at risk of being ignored. It's a static method so it can be used
from the SVG CSS parser too.
(WebCore::validPrimitiveValueColor): Use the new helper.
(WebCore::CSSParser::parseValue): Ditto.
(WebCore::CSSParser::parseBackgroundColor): Ditto.
(WebCore::CSSParser::parseShadow): Ditto.
(WebCore::parseDeprecatedGradientColorStop): Ditto.
(WebCore::parseGradientColorOrKeyword): Ditto.
* css/CSSParser.h: New static helper function.

* css/CSSValueKeywords.in: Add the new CSS value keywords.

* css/SVGCSSParser.cpp:
(WebCore::validSystemControlColorValue): SVG has a restricted
set of system colors, so use the helper from CSSParser but with
an extra condition.
(WebCore::CSSParser::parseSVGValue): Use the helper.

* platform/spi/ios/UIColorSPI.h: Added.
* platform/spi/cocoa/NSColorSPI.h: Added.

* rendering/RenderThemeIOS.h: New systemColor override. Also add a cache for system colors.
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::systemColor): Ask UIColor to provide the color values for the new CSS values.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::systemColor): Ditto.

LayoutTests:

Expose the following values to CSS color properties:
    -apple-system-blue
    -apple-system-brown
    -apple-system-gray
    -apple-system-green
    -apple-system-orange
    -apple-system-pink
    -apple-system-purple
    -apple-system-red
    -apple-system-yellow

The new test shows the computed value for each of these colors. It
includes generic results (no special value) and platform results for
Mac (other than Mavericks) and iOS.

* fast/css/apple-system-colors-expected.txt: Generic results.
* fast/css/apple-system-colors.html: Added - the new test.
* platform/mac/fast/css/apple-system-colors-expected.txt: Added OS X results.
* platform/ios-simulator/fast/css/apple-system-colors-expected.txt: Added iOS results.
* platform/mac-mavericks/fast/css/apple-system-colors-expected.txt: Generic results for Mavericks.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/apple-system-colors-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/apple-system-colors.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/css/apple-system-colors-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/fast/css/apple-system-colors-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/apple-system-colors-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/SVGCSSParser.cpp
Source/WebCore/platform/spi/cocoa/NSColorSPI.h [new file with mode: 0644]
Source/WebCore/platform/spi/ios/UIColorSPI.h [new file with mode: 0644]
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm