Provide a way for web developers to draw a Theme-specific Wireless Playback icon
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jun 2015 01:13:37 +0000 (01:13 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jun 2015 01:13:37 +0000 (01:13 +0000)
commit4ad14388952ad55b1ae3c446bd389fd239515823
tree52651945b080ee7c09e744c7e8d0f7c1b39c94b7
parentfde66b744e509925d1f76caf0412946dd0472ff4
Provide a way for web developers to draw a Theme-specific Wireless Playback icon
https://bugs.webkit.org/show_bug.cgi?id=146123
<rdar://problem/21119287>

Reviewed by Simon Fraser.

Source/WebCore:

Implement a -webkit-named-image() CSS <image> generator that allows a site to
request artwork by name and get the platform variant. At the moment
we only support "wireless-playback" which returns a generic image everywhere
but Cocoa platforms, where we render the AirPlay icon.

In order to do this I added a ThemeCocoa to share any Theme code between
Mac and iOS.

Test: fast/css/named-icons.html

* WebCore.xcodeproj/project.pbxproj: Add new files CSSNamedImageValue, NamedImageGeneratedImage and ThemeCocoa.

* css/CSSImageGeneratorValue.cpp: Handle the new NamedImageClass in the switch statements for downcasting.
(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::isFixedSize):
(WebCore::CSSImageGeneratorValue::isPending):
(WebCore::CSSImageGeneratorValue::knownToBeOpaque):

* css/CSSNamedImageValue.cpp: New class. Just holds a name String.
(WebCore::CSSNamedImageValue::customCSSText):
(WebCore::CSSNamedImageValue::image):
(WebCore::CSSNamedImageValue::equals):
* css/CSSNamedImageValue.h:
(WebCore::CSSNamedImageValue::create):
(WebCore::CSSNamedImageValue::isFixedSize):
(WebCore::CSSNamedImageValue::isPending):
(WebCore::CSSNamedImageValue::CSSNamedImageValue):

* css/CSSParser.cpp:
(WebCore::CSSParser::isGeneratedImageValue): Allow "-webkit-named-image(".
(WebCore::CSSParser::parseGeneratedImage): Call parseNamedImage if we hit named-icon.
(WebCore::CSSParser::parseNamedImage): Parse the function looking for a CSS ident.
* css/CSSParser.h:

* css/CSSValue.cpp: Handle NamedImageClass in the various switch statements.
(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isNamedImageValue): Helper to detect the correct CSSValue subclass.

* platform/Theme.cpp:
(WebCore::Theme::drawNamedImage): Draw a generic wireless playback icon.
* platform/Theme.h: Add drawNamedImage.

* platform/cocoa/ThemeCocoa.cpp: New shared base class for ThemeMac and ThemeIOS.
(WebCore::fitContextToBox):
(WebCore::ThemeCocoa::drawNamedImage): Draw an AirPlay icon for wireless playback.
* platform/cocoa/ThemeCocoa.h:

* platform/graphics/CrossfadeGeneratedImage.h: Drive-by removal of unnecessary forward class definition.

* platform/graphics/ImageBuffer.h: Add NamedImageGeneratedImage as a friend class.

* platform/graphics/NamedImageGeneratedImage.cpp: New class. Calls into the Theme to render the artwork.
(WebCore::NamedImageGeneratedImage::NamedImageGeneratedImage):
(WebCore::NamedImageGeneratedImage::draw):
(WebCore::NamedImageGeneratedImage::drawPattern):
* platform/graphics/NamedImageGeneratedImage.h:

* platform/ios/ThemeIOS.h: Inherit from ThemeCocoa.
* platform/mac/ThemeMac.h: Ditto.

LayoutTests:

Test the new -webkit-named-image CSS generator. Only "wireless-playback"
is supported for now, and has platform-specific results for Cocoa.

* fast/css/named-images-expected.png: Added.
* fast/css/named-images.html: Added.
* platform/mac/fast/css/named-images-expected.png: Added.
* platform/mac/fast/css/named-images-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185731 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/named-images-expected.png [new file with mode: 0644]
LayoutTests/fast/css/named-images.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/named-images-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/named-images-expected.txt [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSAllInOne.cpp
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSNamedImageValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSNamedImageValue.h [new file with mode: 0644]
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/platform/Theme.cpp
Source/WebCore/platform/Theme.h
Source/WebCore/platform/cocoa/ThemeCocoa.cpp [new file with mode: 0644]
Source/WebCore/platform/cocoa/ThemeCocoa.h [new file with mode: 0644]
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/NamedImageGeneratedImage.h [new file with mode: 0644]
Source/WebCore/platform/ios/ThemeIOS.h
Source/WebCore/platform/mac/ThemeMac.h