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)
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

index 497238a..80b6b83 100644 (file)
@@ -1,3 +1,19 @@
+2015-06-18  Dean Jackson  <dino@apple.com>
+
+        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.
+
+        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.
+
 2015-06-18  KyungTae Kim  <ktf.kim@samsung.com> and Myles C. Maxfield  <mmaxfield@apple.com>
 
         [CSS3] Add support for the word-break:keep-all CSS property
diff --git a/LayoutTests/fast/css/named-images-expected.png b/LayoutTests/fast/css/named-images-expected.png
new file mode 100644 (file)
index 0000000..833113b
Binary files /dev/null and b/LayoutTests/fast/css/named-images-expected.png differ
diff --git a/LayoutTests/fast/css/named-images.html b/LayoutTests/fast/css/named-images.html
new file mode 100644 (file)
index 0000000..2e7f399
--- /dev/null
@@ -0,0 +1,27 @@
+<style>
+div {
+    width: 100px;
+    height: 100px;
+    margin: 5px;
+    display: inline-block;
+    border: 1px solid black;
+    box-sizing: border-box;
+}
+.normal {
+    background-image: -webkit-named-image(wireless-playback);
+    background-size: 100% 100%;
+    background-repeat: no-repeat;
+}
+.mask {
+    -webkit-mask-image: -webkit-named-image(wireless-playback);
+    -webkit-mask-size: 100% 100%;
+    background-color: blue;
+}
+</style>
+<div class="normal" ></div>
+<div class="normal" style="background-size: 50px 50px"></div>
+<div class="normal" style="background-size: 50px 50px; background-position: 50% 50%"></div>
+<div class="normal" style="width: 150px"></div>
+<div class="normal" style="height: 150px"></div>
+<div class="normal" style="width: 200px; height: 200px; background-repeat: repeat; background-size: 50px 50px"></div>
+<div class="mask"></div>
diff --git a/LayoutTests/platform/mac/fast/css/named-images-expected.png b/LayoutTests/platform/mac/fast/css/named-images-expected.png
new file mode 100644 (file)
index 0000000..2d02e4f
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/named-images-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/named-images-expected.txt b/LayoutTests/platform/mac/fast/css/named-images-expected.txt
new file mode 100644 (file)
index 0000000..7c31bab
--- /dev/null
@@ -0,0 +1,26 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (5,55) size 100x100 [border: (1px solid #000000)]
+      RenderText {#text} at (110,146) size 4x18
+        text run at (110,146) width 4: " "
+      RenderBlock {DIV} at (119,55) size 100x100 [border: (1px solid #000000)]
+      RenderText {#text} at (224,146) size 4x18
+        text run at (224,146) width 4: " "
+      RenderBlock {DIV} at (233,55) size 100x100 [border: (1px solid #000000)]
+      RenderText {#text} at (338,146) size 4x18
+        text run at (338,146) width 4: " "
+      RenderBlock {DIV} at (347,55) size 150x100 [border: (1px solid #000000)]
+      RenderText {#text} at (502,146) size 4x18
+        text run at (502,146) width 4: " "
+      RenderBlock {DIV} at (511,5) size 100x150 [border: (1px solid #000000)]
+      RenderText {#text} at (616,146) size 4x18
+        text run at (616,146) width 4: " "
+      RenderBlock {DIV} at (5,169) size 200x200 [border: (1px solid #000000)]
+      RenderText {#text} at (210,360) size 4x18
+        text run at (210,360) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+layer at (227,277) size 100x100
+  RenderBlock {DIV} at (219,269) size 100x100 [bgcolor=#0000FF] [border: (1px solid #000000)]
index ea6983b..d67fead 100644 (file)
@@ -1289,6 +1289,7 @@ set(WebCore_SOURCES
     css/CSSKeyframesRule.cpp
     css/CSSLineBoxContainValue.cpp
     css/CSSMediaRule.cpp
+    css/CSSNamedImageValue.cpp
     css/CSSOMUtils.cpp
     css/CSSPageRule.cpp
     css/CSSParser.cpp
@@ -2163,6 +2164,7 @@ set(WebCore_SOURCES
     platform/graphics/LayoutRect.cpp
     platform/graphics/MaskImageOperation.cpp
     platform/graphics/MediaPlayer.cpp
+    platform/graphics/NamedImageGeneratedImage.cpp
     platform/graphics/Path.cpp
     platform/graphics/PathTraversalState.cpp
     platform/graphics/Pattern.cpp
index 31856ad..abfcb48 100644 (file)
@@ -1,3 +1,74 @@
+2015-06-18  Dean Jackson  <dino@apple.com>
+
+        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.
+
+        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.
+
 2015-06-18  KyungTae Kim  <ktf.kim@samsung.com> and Myles C. Maxfield  <mmaxfield@apple.com>
 
         [CSS3] Add support for the word-break:keep-all CSS property
index b1fd6d8..a19299a 100644 (file)
     <ClCompile Include="..\platform\graphics\IntSize.cpp" />
     <ClCompile Include="..\platform\graphics\LayoutRect.cpp" />
     <ClCompile Include="..\platform\graphics\MediaPlayer.cpp" />
+    <ClCompile Include="..\platform\graphics\NamedImageGeneratedImage.cpp" />
     <ClCompile Include="..\platform\graphics\Path.cpp" />
     <ClCompile Include="..\platform\graphics\PathTraversalState.cpp" />
     <ClCompile Include="..\platform\graphics\Pattern.cpp" />
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\css\CSSNamedImageValue.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\css\CSSOMUtils.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
     <ClInclude Include="..\platform\graphics\LayoutRect.h" />
     <ClInclude Include="..\platform\graphics\LayoutSize.h" />
     <ClInclude Include="..\platform\graphics\MediaPlayer.h" />
+    <ClInclude Include="..\platform\graphics\NamedImageGeneratedImage.h" />
     <ClInclude Include="..\platform\graphics\NativeImagePtr.h" />
     <ClInclude Include="..\platform\graphics\Path.h" />
     <ClInclude Include="..\platform\graphics\PathTraversalState.h" />
     <ClInclude Include="..\css\CSSInitialValue.h" />
     <ClInclude Include="..\css\CSSLineBoxContainValue.h" />
     <ClInclude Include="..\css\CSSMediaRule.h" />
+    <ClInclude Include="..\css\CSSNamedImageValue.h" />
     <ClInclude Include="..\css\CSSOMUtils.h" />
     <ClInclude Include="..\css\CSSPageRule.h" />
     <ClInclude Include="..\css\CSSParser.h" />
index 4149dba..d90f8b1 100644 (file)
     <ClCompile Include="..\platform\graphics\MediaPlayer.cpp">
       <Filter>platform\graphics</Filter>
     </ClCompile>
+    <ClCompile Include="..\platform\graphics\NamedImageGeneratedImage.cpp">
+      <Filter>platform\graphics</Filter>
+    </ClCompile>
     <ClCompile Include="..\platform\graphics\Path.cpp">
       <Filter>platform\graphics</Filter>
     </ClCompile>
     <ClCompile Include="..\css\CSSMediaRule.cpp">
       <Filter>css</Filter>
     </ClCompile>
+    <ClCompile Include="..\css\CSSNamedImageValue.cpp">
+      <Filter>css</Filter>
+    </ClCompile>
     <ClCompile Include="..\css\CSSOMUtils.cpp">
       <Filter>css</Filter>
     </ClCompile>
     <ClInclude Include="..\platform\graphics\MediaPlayer.h">
       <Filter>platform\graphics</Filter>
     </ClInclude>
+    <ClInclude Include="..\platform\graphics\NamedImageGeneratedImage.h">
+      <Filter>platform\graphics</Filter>
+    </ClInclude>
     <ClInclude Include="..\platform\graphics\NativeImagePtr.h">
       <Filter>platform\graphics</Filter>
     </ClInclude>
     <ClInclude Include="..\css\CSSMediaRule.h">
       <Filter>css</Filter>
     </ClInclude>
+    <ClInclude Include="..\css\CSSNamedImageValue.h">
+      <Filter>css</Filter>
+    </ClInclude>
     <ClInclude Include="..\css\CSSOMUtils.h">
       <Filter>css</Filter>
     </ClInclude>
index e872b75..19b45fc 100644 (file)
                31078CC81880AABB008099DC /* OESTextureHalfFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 31078CC31880A6A6008099DC /* OESTextureHalfFloatLinear.h */; };
                31078CC91880AAC9008099DC /* JSOESTextureHalfFloatLinear.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31078CC51880AAAA008099DC /* JSOESTextureHalfFloatLinear.cpp */; };
                31078CCA1880AACE008099DC /* JSOESTextureHalfFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 31078CC61880AAAA008099DC /* JSOESTextureHalfFloatLinear.h */; };
+               310D71951B335C9D009C7B73 /* ThemeCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 310D71931B335C9D009C7B73 /* ThemeCocoa.cpp */; };
+               310D71961B335C9E009C7B73 /* ThemeCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 310D71941B335C9D009C7B73 /* ThemeCocoa.h */; };
                311C08BD18EB7CAF00B65615 /* mediaControlsApple.css in Resources */ = {isa = PBXBuildFile; fileRef = CDC1DD4117CC2C48008CB55D /* mediaControlsApple.css */; };
                311C08BE18EB7CAF00B65615 /* mediaControlsApple.js in Resources */ = {isa = PBXBuildFile; fileRef = CDE6560E17CA6E7600526BA7 /* mediaControlsApple.js */; };
                311C08BF18EB7CAF00B65615 /* mediaControlsiOS.css in Resources */ = {isa = PBXBuildFile; fileRef = CDAAF45D1869094E003C1717 /* mediaControlsiOS.css */; };
                3146FE6F184420AA001A937C /* OESTextureFloatLinear.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3146FE6518442087001A937C /* OESTextureFloatLinear.cpp */; };
                3146FE7418442370001A937C /* JSOESTextureFloatLinear.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3146FE7018442367001A937C /* JSOESTextureFloatLinear.cpp */; };
                3146FE7518442370001A937C /* JSOESTextureFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 3146FE7118442367001A937C /* JSOESTextureFloatLinear.h */; };
+               314BE3A11B30F6B700141982 /* CSSNamedImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 314BE3A01B30F6B700141982 /* CSSNamedImageValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               314BE3A31B30F6D100141982 /* CSSNamedImageValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 314BE3A21B30F6D100141982 /* CSSNamedImageValue.cpp */; };
+               314BE3A61B3103FB00141982 /* NamedImageGeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */; };
+               314BE3A71B3103FB00141982 /* NamedImageGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */; };
                316023F01532C40C00D50FF4 /* Dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316023EF1532C40C00D50FF4 /* Dictionary.h */; settings = {ATTRIBUTES = (Private, ); }; };
                31611E5A0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31611E580E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp */; };
                31611E5B0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 31611E590E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h */; };
                31078CC41880A6A6008099DC /* OESTextureHalfFloatLinear.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESTextureHalfFloatLinear.idl; sourceTree = "<group>"; };
                31078CC51880AAAA008099DC /* JSOESTextureHalfFloatLinear.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESTextureHalfFloatLinear.cpp; sourceTree = "<group>"; };
                31078CC61880AAAA008099DC /* JSOESTextureHalfFloatLinear.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureHalfFloatLinear.h; sourceTree = "<group>"; };
+               310D71931B335C9D009C7B73 /* ThemeCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThemeCocoa.cpp; sourceTree = "<group>"; };
+               310D71941B335C9D009C7B73 /* ThemeCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeCocoa.h; sourceTree = "<group>"; };
                311C08BC18E35D6800B65615 /* ControlStates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControlStates.h; sourceTree = "<group>"; };
                31288E6E0E3005D6003619AE /* CSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSKeyframeRule.cpp; sourceTree = "<group>"; };
                31288E6F0E3005D6003619AE /* CSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSKeyframeRule.h; sourceTree = "<group>"; };
                3146FE6718442087001A937C /* OESTextureFloatLinear.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESTextureFloatLinear.idl; sourceTree = "<group>"; };
                3146FE7018442367001A937C /* JSOESTextureFloatLinear.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESTextureFloatLinear.cpp; sourceTree = "<group>"; };
                3146FE7118442367001A937C /* JSOESTextureFloatLinear.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureFloatLinear.h; sourceTree = "<group>"; };
+               314BE3A01B30F6B700141982 /* CSSNamedImageValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CSSNamedImageValue.h; sourceTree = "<group>"; };
+               314BE3A21B30F6D100141982 /* CSSNamedImageValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CSSNamedImageValue.cpp; sourceTree = "<group>"; };
+               314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NamedImageGeneratedImage.cpp; sourceTree = "<group>"; };
+               314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamedImageGeneratedImage.h; sourceTree = "<group>"; };
                316023EF1532C40C00D50FF4 /* Dictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dictionary.h; sourceTree = "<group>"; };
                31611E540E1C4D4A00F6A579 /* WebKitCSSTransformValue.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitCSSTransformValue.idl; sourceTree = "<group>"; };
                31611E580E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSTransformValue.cpp; sourceTree = "<group>"; };
                                5D5975B119635F1100D00878 /* SystemVersion.h */,
                                5D5975B219635F1100D00878 /* SystemVersion.mm */,
                                7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */,
+                               310D71931B335C9D009C7B73 /* ThemeCocoa.cpp */,
+                               310D71941B335C9D009C7B73 /* ThemeCocoa.h */,
                                46DB7D561B20FE3C005651B2 /* VNodeTrackerCocoa.cpp */,
                        );
                        path = cocoa;
                                079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */,
                                CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */,
                                CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */,
+                               314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */,
+                               314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
                                6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */,
                                B27535520B053814002CE64F /* Path.cpp */,
                                B27535530B053814002CE64F /* Path.h */,
                                A80E6CD20A1989CA007FB8C5 /* CSSMediaRule.cpp */,
                                A80E6CD90A1989CA007FB8C5 /* CSSMediaRule.h */,
                                85C56CA20AA89C1000D95755 /* CSSMediaRule.idl */,
+                               314BE3A01B30F6B700141982 /* CSSNamedImageValue.h */,
+                               314BE3A21B30F6D100141982 /* CSSNamedImageValue.cpp */,
                                F98FFF4211A2676200F548E8 /* CSSOMUtils.cpp */,
                                F98FFF4311A2676200F548E8 /* CSSOMUtils.h */,
                                A80E6CCB0A1989CA007FB8C5 /* CSSPageRule.cpp */,
                                E1BD331C182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h in Headers */,
                                E125F82C1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h in Headers */,
                                E19AC3EF1824DC7900349426 /* CryptoAlgorithmSHA224.h in Headers */,
+                               314BE3A11B30F6B700141982 /* CSSNamedImageValue.h in Headers */,
                                E19AC3F11824DC7900349426 /* CryptoAlgorithmSHA256.h in Headers */,
                                E19AC3F31824DC7900349426 /* CryptoAlgorithmSHA384.h in Headers */,
                                E19AC3F51824DC7900349426 /* CryptoAlgorithmSHA512.h in Headers */,
                                E446143A0CD689C800FADA75 /* JSHTMLMediaElement.h in Headers */,
                                1AE2AE5C0A1D26F200B42B25 /* JSHTMLMenuElement.h in Headers */,
                                A80E7A180A19C3D6007FB8C5 /* JSHTMLMetaElement.h in Headers */,
+                               314BE3A71B3103FB00141982 /* NamedImageGeneratedImage.h in Headers */,
                                A7BBE26711AFB3F20005EA03 /* JSHTMLMeterElement.h in Headers */,
                                1AE2AB2A0A1CE63B00B42B25 /* JSHTMLModElement.h in Headers */,
                                BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */,
                                B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */,
                                08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */,
                                B2227A2D0D00BF220071B782 /* SVGImageElement.h in Headers */,
+                               310D71961B335C9E009C7B73 /* ThemeCocoa.h in Headers */,
                                08F859D51463F9CD0067D934 /* SVGImageForContainer.h in Headers */,
                                B28C6A2A0D00C44800334AA4 /* SVGImageLoader.h in Headers */,
                                0854B01F1255E4E600B9CDD0 /* SVGInlineFlowBox.h in Headers */,
                                A81369CD097374F600D74463 /* HTMLInputElement.cpp in Sources */,
                                93309DE5099E64920056E581 /* HTMLInterchange.cpp in Sources */,
                                A81369E5097374F600D74463 /* HTMLKeygenElement.cpp in Sources */,
+                               314BE3A61B3103FB00141982 /* NamedImageGeneratedImage.cpp in Sources */,
                                A81369E3097374F600D74463 /* HTMLLabelElement.cpp in Sources */,
                                A81369E1097374F600D74463 /* HTMLLegendElement.cpp in Sources */,
                                A8EA79FC0A1916DF00A8EF5F /* HTMLLIElement.cpp in Sources */,
                                978AD67414130A8D00C7CAE3 /* HTMLSpanElement.cpp in Sources */,
                                536D5A21193E18EE00CE4CAB /* HTMLSrcsetParser.cpp in Sources */,
                                A871DC260A15205700B12A68 /* HTMLStyleElement.cpp in Sources */,
+                               310D71951B335C9D009C7B73 /* ThemeCocoa.cpp in Sources */,
                                D3D4E972130C7CFE007BA540 /* HTMLSummaryElement.cpp in Sources */,
                                A871DB320A150BD600B12A68 /* HTMLTableCaptionElement.cpp in Sources */,
                                A871DB2E0A150BD600B12A68 /* HTMLTableCellElement.cpp in Sources */,
                                BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
                                A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
                                41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
+                               314BE3A31B30F6D100141982 /* CSSNamedImageValue.cpp in Sources */,
                                93B70D6F09EB0C7C009D8468 /* ScriptController.cpp in Sources */,
                                A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */,
                                4998AED113FB224D0090B1AA /* ScriptedAnimationController.cpp in Sources */,
index 3f5ddbd..516b682 100644 (file)
@@ -57,6 +57,7 @@
 #include "CSSInitialValue.cpp"
 #include "CSSLineBoxContainValue.cpp"
 #include "CSSMediaRule.cpp"
+#include "CSSNamedImageValue.cpp"
 #include "CSSOMUtils.cpp"
 #include "CSSPageRule.cpp"
 #include "CSSParser.cpp"
index 17d3eeb..eb4889e 100644 (file)
@@ -32,6 +32,7 @@
 #include "CSSFilterImageValue.h"
 #include "CSSGradientValue.h"
 #include "CSSImageValue.h"
+#include "CSSNamedImageValue.h"
 #include "GeneratedImage.h"
 #include "RenderElement.h"
 #include "StyleCachedImage.h"
@@ -110,6 +111,8 @@ PassRefPtr<Image> CSSImageGeneratorValue::image(RenderElement* renderer, const F
     switch (classType()) {
     case CanvasClass:
         return downcast<CSSCanvasValue>(*this).image(renderer, size);
+    case NamedImageClass:
+        return downcast<CSSNamedImageValue>(*this).image(renderer, size);
     case CrossfadeClass:
         return downcast<CSSCrossfadeValue>(*this).image(renderer, size);
     case FilterImageClass:
@@ -129,6 +132,8 @@ bool CSSImageGeneratorValue::isFixedSize() const
     switch (classType()) {
     case CanvasClass:
         return downcast<CSSCanvasValue>(*this).isFixedSize();
+    case NamedImageClass:
+        return downcast<CSSNamedImageValue>(*this).isFixedSize();
     case CrossfadeClass:
         return downcast<CSSCrossfadeValue>(*this).isFixedSize();
     case FilterImageClass:
@@ -169,6 +174,8 @@ bool CSSImageGeneratorValue::isPending() const
         return downcast<CSSCrossfadeValue>(*this).isPending();
     case CanvasClass:
         return downcast<CSSCanvasValue>(*this).isPending();
+    case NamedImageClass:
+        return downcast<CSSNamedImageValue>(*this).isPending();
     case FilterImageClass:
         return downcast<CSSFilterImageValue>(*this).isPending();
     case LinearGradientClass:
@@ -188,6 +195,8 @@ bool CSSImageGeneratorValue::knownToBeOpaque(const RenderElement* renderer) cons
         return downcast<CSSCrossfadeValue>(*this).knownToBeOpaque(renderer);
     case CanvasClass:
         return false;
+    case NamedImageClass:
+        return false;
     case FilterImageClass:
         return downcast<CSSFilterImageValue>(*this).knownToBeOpaque(renderer);
     case LinearGradientClass:
diff --git a/Source/WebCore/css/CSSNamedImageValue.cpp b/Source/WebCore/css/CSSNamedImageValue.cpp
new file mode 100644 (file)
index 0000000..1add546
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSNamedImageValue.h"
+
+#include "ImageBuffer.h"
+#include "NamedImageGeneratedImage.h"
+
+namespace WebCore {
+
+String CSSNamedImageValue::customCSSText() const
+{
+    return makeString("-webkit-named-image(", m_name, ')');
+}
+
+PassRefPtr<Image> CSSNamedImageValue::image(RenderElement*, const FloatSize& size)
+{
+    if (size.isEmpty())
+        return nullptr;
+
+    m_generatedImage = NamedImageGeneratedImage::create(m_name, size);
+
+    return m_generatedImage.release();
+}
+
+bool CSSNamedImageValue::equals(const CSSNamedImageValue& other) const
+{
+    return m_name == other.m_name;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/css/CSSNamedImageValue.h b/Source/WebCore/css/CSSNamedImageValue.h
new file mode 100644 (file)
index 0000000..f1cdaa6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSNamedImageValue_h
+#define CSSNamedImageValue_h
+
+#include "CSSImageGeneratorValue.h"
+
+#include "Image.h"
+
+namespace WebCore {
+
+class Document;
+
+class CSSNamedImageValue : public CSSImageGeneratorValue {
+public:
+    static Ref<CSSNamedImageValue> create(const String& name)
+    {
+        return adoptRef(*new CSSNamedImageValue(name));
+    }
+
+    String customCSSText() const;
+
+    bool isFixedSize() const { return false; }
+    bool isPending() const { return false; }
+
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
+
+    bool equals(const CSSNamedImageValue&) const;
+
+private:
+    explicit CSSNamedImageValue(const String& name)
+        : CSSImageGeneratorValue(NamedImageClass)
+        , m_name(name)
+    {
+    }
+
+    String m_name;
+    RefPtr<Image> m_generatedImage;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSNamedImageValue, isNamedImageValue())
+
+#endif // CSSNamedImageValue_h
index 8ecf66d..4b69c31 100644 (file)
@@ -50,6 +50,7 @@
 #include "CSSKeyframesRule.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSMediaRule.h"
+#include "CSSNamedImageValue.h"
 #include "CSSPageRule.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSPrimitiveValueMappings.h"
@@ -9152,7 +9153,8 @@ bool CSSParser::isGeneratedImageValue(CSSParserValue& value) const
         || equalIgnoringCase(value.function->name, "repeating-radial-gradient(")
         || equalIgnoringCase(value.function->name, "-webkit-canvas(")
         || equalIgnoringCase(value.function->name, "-webkit-cross-fade(")
-        || equalIgnoringCase(value.function->name, "-webkit-filter(");
+        || equalIgnoringCase(value.function->name, "-webkit-filter(")
+        || equalIgnoringCase(value.function->name, "-webkit-named-image(");
 }
 
 bool CSSParser::parseGeneratedImage(CSSParserValueList& valueList, RefPtr<CSSValue>& value)
@@ -9198,6 +9200,9 @@ bool CSSParser::parseGeneratedImage(CSSParserValueList& valueList, RefPtr<CSSVal
     if (equalIgnoringCase(parserValue.function->name, "-webkit-filter("))
         return parseFilterImage(valueList, value);
 
+    if (equalIgnoringCase(parserValue.function->name, "-webkit-named-image("))
+        return parseNamedImage(valueList, value);
+
     return false;
 }
 
@@ -9310,6 +9315,21 @@ bool CSSParser::parseCanvas(CSSParserValueList& valueList, RefPtr<CSSValue>& can
     return true;
 }
 
+bool CSSParser::parseNamedImage(CSSParserValueList& valueList, RefPtr<CSSValue>& namedImage)
+{
+    CSSParserValueList* args = valueList.current()->function->args.get();
+    if (!args || args->size() != 1)
+        return false;
+
+    // The only argument is the image name.
+    CSSParserValue* value = args->current();
+    if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT)
+        return false;
+
+    namedImage = CSSNamedImageValue::create(value->string);
+    return true;
+}
+
 #if ENABLE(CSS_IMAGE_RESOLUTION)
 PassRefPtr<CSSValue> CSSParser::parseImageResolution()
 {
index 5299dbb..398c2f4 100644 (file)
@@ -290,6 +290,7 @@ public:
 
     // Image generators
     bool parseCanvas(CSSParserValueList&, RefPtr<CSSValue>&);
+    bool parseNamedImage(CSSParserValueList&, RefPtr<CSSValue>&);
 
     bool parseDeprecatedGradient(CSSParserValueList&, RefPtr<CSSValue>&);
     bool parseDeprecatedLinearGradient(CSSParserValueList&, RefPtr<CSSValue>&, CSSGradientRepeat repeating);
index 431dd45..9eb19ab 100644 (file)
@@ -47,6 +47,7 @@
 #include "CSSInheritedValue.h"
 #include "CSSInitialValue.h"
 #include "CSSLineBoxContainValue.h"
+#include "CSSNamedImageValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSReflectValue.h"
 #include "CSSShadowValue.h"
@@ -168,6 +169,8 @@ bool CSSValue::equals(const CSSValue& other) const
             return compareCSSValues<CSSBorderImageSliceValue>(*this, other);
         case CanvasClass:
             return compareCSSValues<CSSCanvasValue>(*this, other);
+        case NamedImageClass:
+            return compareCSSValues<CSSNamedImageValue>(*this, other);
         case CursorImageClass:
             return compareCSSValues<CSSCursorImageValue>(*this, other);
         case FilterImageClass:
@@ -260,6 +263,8 @@ String CSSValue::cssText() const
         return downcast<CSSBorderImageSliceValue>(*this).customCSSText();
     case CanvasClass:
         return downcast<CSSCanvasValue>(*this).customCSSText();
+    case NamedImageClass:
+        return downcast<CSSNamedImageValue>(*this).customCSSText();
     case CursorImageClass:
         return downcast<CSSCursorImageValue>(*this).customCSSText();
     case FilterImageClass:
@@ -352,6 +357,9 @@ void CSSValue::destroy()
     case CanvasClass:
         delete downcast<CSSCanvasValue>(this);
         return;
+    case NamedImageClass:
+        delete downcast<CSSNamedImageValue>(this);
+        return;
     case CursorImageClass:
         delete downcast<CSSCursorImageValue>(this);
         return;
index 9a40686..59ea1c9 100644 (file)
@@ -79,6 +79,7 @@ public:
     bool isFontValue() const { return m_classType == FontClass; }
     bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_classType <= RadialGradientClass; }
     bool isGradientValue() const { return m_classType >= LinearGradientClass && m_classType <= RadialGradientClass; }
+    bool isNamedImageValue() const { return m_classType == NamedImageClass; }
 #if ENABLE(CSS_IMAGE_SET)
     bool isImageSetValue() const { return m_classType == ImageSetClass; }
 #endif
@@ -139,6 +140,7 @@ protected:
 
         // Image generator classes.
         CanvasClass,
+        NamedImageClass,
         CrossfadeClass,
         FilterImageClass,
         LinearGradientClass,
index 96547a7..eac7352 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "Theme.h"
 
+#include "GraphicsContext.h"
+
 namespace WebCore {
 
 LengthBox Theme::controlBorder(ControlPart part, const FontCascade&, const LengthBox& zoomedBox, float) const
@@ -55,4 +57,60 @@ LengthBox Theme::controlPadding(ControlPart part, const FontCascade&, const Leng
     }
 }
 
+void Theme::drawNamedImage(const String& name, GraphicsContext* context, const FloatRect& rect) const
+{
+    // We only handle one icon at the moment.
+    if (name != "wireless-playback")
+        return;
+
+    GraphicsContextStateSaver stateSaver(*context);
+    context->setFillColor(Color::black, ColorSpaceDeviceRGB);
+
+    // Draw a generic Wireless Playback icon.
+
+    context->scale(FloatSize(rect.size().width() / 100, rect.size().height() / 100));
+    context->translate(8, 1);
+
+    Path outline;
+    outline.moveTo(FloatPoint(59, 58.7));
+    outline.addBezierCurveTo(FloatPoint(58.1, 58.7), FloatPoint(57.2, 58.4), FloatPoint(56.4, 57.7));
+    outline.addLineTo(FloatPoint(42, 45.5));
+    outline.addLineTo(FloatPoint(27.6, 57.8));
+    outline.addBezierCurveTo(FloatPoint(25.9, 59.2), FloatPoint(23.4, 59), FloatPoint(22, 57.3));
+    outline.addBezierCurveTo(FloatPoint(20.6, 55.6), FloatPoint(20.8, 53.1), FloatPoint(22.5, 51.7));
+    outline.addLineTo(FloatPoint(39.5, 37.3));
+    outline.addBezierCurveTo(FloatPoint(41, 36), FloatPoint(43.2, 36), FloatPoint(44.7, 37.3));
+    outline.addLineTo(FloatPoint(61.7, 51.7));
+    outline.addBezierCurveTo(FloatPoint(63.4, 53.1), FloatPoint(63.6, 55.7), FloatPoint(62.2, 57.3));
+    outline.addBezierCurveTo(FloatPoint(61.3, 58.2), FloatPoint(60.1, 58.7), FloatPoint(59, 58.7));
+    outline.addLineTo(FloatPoint(59, 58.7));
+    outline.closeSubpath();
+
+    outline.moveTo(FloatPoint(42, 98));
+    outline.addBezierCurveTo(FloatPoint(39.8, 98), FloatPoint(38, 96.3), FloatPoint(38, 94.2));
+    outline.addLineTo(FloatPoint(38, 43.6));
+    outline.addBezierCurveTo(FloatPoint(38, 41.5), FloatPoint(39.8, 39.8), FloatPoint(42, 39.8));
+    outline.addBezierCurveTo(FloatPoint(44.2, 39.8), FloatPoint(46, 41.5), FloatPoint(46, 43.6));
+    outline.addLineTo(FloatPoint(46, 94.2));
+    outline.addBezierCurveTo(FloatPoint(46, 96.3), FloatPoint(44.2, 98), FloatPoint(42, 98));
+    outline.addLineTo(FloatPoint(42, 98));
+    outline.closeSubpath();
+
+    outline.moveTo(FloatPoint(83.6, 41.6));
+    outline.addBezierCurveTo(FloatPoint(83.6, 18.6), FloatPoint(65, 0), FloatPoint(42, 0));
+    outline.addBezierCurveTo(FloatPoint(19, 0), FloatPoint(0.4, 18.6), FloatPoint(0.4, 41.6));
+    outline.addBezierCurveTo(FloatPoint(0.4, 62.2), FloatPoint(15, 79.2), FloatPoint(35, 82.6));
+    outline.addLineTo(FloatPoint(35, 74.5));
+    outline.addBezierCurveTo(FloatPoint(20, 71.2), FloatPoint(8.4, 57.7), FloatPoint(8.4, 41.6));
+    outline.addBezierCurveTo(FloatPoint(8.4, 23.1), FloatPoint(23.5, 8), FloatPoint(42, 8));
+    outline.addBezierCurveTo(FloatPoint(60.5, 8), FloatPoint(75.5, 23.1), FloatPoint(75.5, 41.6));
+    outline.addBezierCurveTo(FloatPoint(75.6, 57.7), FloatPoint(64, 71.2), FloatPoint(49, 74.5));
+    outline.addLineTo(FloatPoint(49, 82.6));
+    outline.addBezierCurveTo(FloatPoint(69, 79.3), FloatPoint(83.6, 62.2), FloatPoint(83.6, 41.6));
+    outline.addLineTo(FloatPoint(83.6, 41.6));
+    outline.closeSubpath();
+
+    context->fillPath(outline);
+}
+
 }
index ece84cf..10e0c77 100644 (file)
@@ -29,6 +29,7 @@
 #include "Color.h"
 #include "ControlStates.h"
 #include "FontCascade.h"
+#include "GraphicsTypes.h"
 #include "IntRect.h"
 #include "LengthBox.h"
 #include "LengthSize.h"
@@ -106,7 +107,9 @@ public:
     // The rect passed in is in zoomed coordinates, so the inflation should take that into account and make sure the inflation
     // amount is also scaled by the zoomFactor.
     virtual void inflateControlPaintRect(ControlPart, const ControlStates*, FloatRect& /*zoomedRect*/, float /*zoomFactor*/) const { }
-    
+
+    virtual void drawNamedImage(const String&, GraphicsContext*, const FloatRect&) const;
+
     // This method is called once, from RenderTheme::adjustDefaultStyleSheet(), to let each platform adjust
     // the default CSS rules in html.css.
     static String defaultStyleSheet();
diff --git a/Source/WebCore/platform/cocoa/ThemeCocoa.cpp b/Source/WebCore/platform/cocoa/ThemeCocoa.cpp
new file mode 100644 (file)
index 0000000..da87928
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ThemeCocoa.h"
+
+#import "GraphicsContext.h"
+
+namespace WebCore {
+
+static void fitContextToBox(GraphicsContext* context, const FloatSize& srcImageSize, const FloatSize& dstSize)
+{
+    float srcRatio = srcImageSize.aspectRatio();
+    float dstRatio = dstSize.aspectRatio();
+
+    float scale;
+    float translationX = 0;
+    float translationY = 0;
+    if (srcRatio > dstRatio) {
+        scale = dstSize.width() / srcImageSize.width();
+        translationY = (dstSize.height() - scale * srcImageSize.height()) / 2;
+    } else {
+        scale = dstSize.height() / srcImageSize.height();
+        translationX = (dstSize.width() - scale * srcImageSize.width()) / 2;
+    }
+    context->translate(translationX, translationY);
+    context->scale(FloatSize(scale, scale));
+}
+
+void ThemeCocoa::drawNamedImage(const String& name, GraphicsContext* context, const FloatRect& rect) const
+{
+    // We only handle one icon at the moment.
+    if (name != "wireless-playback") {
+        Theme::drawNamedImage(name, context, rect);
+        return;
+    }
+
+    GraphicsContextStateSaver stateSaver(*context);
+    context->setFillColor(Color::black, ColorSpaceDeviceRGB);
+
+    FloatSize wirelessPlaybackSrcSize(32, 24.016);
+    fitContextToBox(context, wirelessPlaybackSrcSize, rect.size());
+
+    Path outline;
+    outline.moveTo(FloatPoint(24.066, 18));
+    outline.addLineTo(FloatPoint(22.111, 16));
+    outline.addLineTo(FloatPoint(30, 16));
+    outline.addLineTo(FloatPoint(30, 2));
+    outline.addLineTo(FloatPoint(2, 2));
+    outline.addLineTo(FloatPoint(2, 16));
+    outline.addLineTo(FloatPoint(9.908, 16));
+    outline.addLineTo(FloatPoint(7.953, 18));
+    outline.addLineTo(FloatPoint(0, 18));
+    outline.addLineTo(FloatPoint(0, 0));
+    outline.addLineTo(FloatPoint(32, 0));
+    outline.addLineTo(FloatPoint(32, 18));
+    outline.addLineTo(FloatPoint(24.066, 18));
+    outline.closeSubpath();
+    outline.moveTo(FloatPoint(26.917, 24.016));
+    outline.addLineTo(FloatPoint(5.040, 24.016));
+    outline.addLineTo(FloatPoint(15.978, 12.828));
+    outline.addLineTo(FloatPoint(26.917, 24.016));
+    outline.closeSubpath();
+    
+    context->fillPath(outline);
+}
+
+}
diff --git a/Source/WebCore/platform/cocoa/ThemeCocoa.h b/Source/WebCore/platform/cocoa/ThemeCocoa.h
new file mode 100644 (file)
index 0000000..1d6b693
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ThemeCocoa_h
+#define ThemeCocoa_h
+
+#include "Theme.h"
+
+namespace WebCore {
+
+class ThemeCocoa : public Theme {
+public:
+    ThemeCocoa() { }
+    virtual ~ThemeCocoa() { }
+
+    virtual void drawNamedImage(const String&, GraphicsContext*, const FloatRect&) const override;
+};
+
+} // namespace WebCore
+
+#endif // ThemeCocoa_h
index a9d58c5..56a9875 100644 (file)
@@ -34,8 +34,6 @@
 
 namespace WebCore {
 
-class CSSCrossfadeValue;
-
 class CrossfadeGeneratedImage final : public GeneratedImage {
 public:
     static Ref<CrossfadeGeneratedImage> create(Image* fromImage, Image* toImage, float percentage, const FloatSize& crossfadeSize, const FloatSize& size)
index f2ee506..66c1d8f 100644 (file)
@@ -149,6 +149,7 @@ private:
     friend class GraphicsContext;
     friend class GeneratedImage;
     friend class CrossfadeGeneratedImage;
+    friend class NamedImageGeneratedImage;
     friend class GradientImage;
 
 private:
diff --git a/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp b/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp
new file mode 100644 (file)
index 0000000..9ba9bf0
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NamedImageGeneratedImage.h"
+
+#include "FloatRect.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "Theme.h"
+
+namespace WebCore {
+
+NamedImageGeneratedImage::NamedImageGeneratedImage(String name, const FloatSize& size)
+    : m_name(name)
+{
+    setContainerSize(size);
+}
+
+void NamedImageGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription)
+{
+#if USE(NEW_THEME)
+    GraphicsContextStateSaver stateSaver(*context);
+    context->setCompositeOperation(compositeOp, blendMode);
+    context->clip(dstRect);
+    context->translate(dstRect.x(), dstRect.y());
+    if (dstRect.size() != srcRect.size())
+        context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
+    context->translate(-srcRect.x(), -srcRect.y());
+
+    platformTheme()->drawNamedImage(m_name, context, dstRect);
+#else
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(dstRect);
+    UNUSED_PARAM(srcRect);
+    UNUSED_PARAM(compositeOp);
+    UNUSED_PARAM(blendMode);
+#endif
+}
+
+void NamedImageGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
+{
+#if USE(NEW_THEME)
+//    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
+    std::unique_ptr<ImageBuffer> imageBuffer = context->createCompatibleBuffer(size(), true);
+    if (!imageBuffer)
+        return;
+
+    GraphicsContext* graphicsContext = imageBuffer->context();
+    platformTheme()->drawNamedImage(m_name, graphicsContext, FloatRect(0, 0, size().width(), size().height()));
+
+    // Tile the image buffer into the context.
+    imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, dstRect, blendMode);
+#else
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(srcRect);
+    UNUSED_PARAM(patternTransform);
+    UNUSED_PARAM(phase);
+    UNUSED_PARAM(styleColorSpace);
+    UNUSED_PARAM(dstRect);
+    UNUSED_PARAM(compositeOp);
+    UNUSED_PARAM(blendMode);
+#endif
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/NamedImageGeneratedImage.h b/Source/WebCore/platform/graphics/NamedImageGeneratedImage.h
new file mode 100644 (file)
index 0000000..01778eb
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NamedImageGeneratedImage_h
+#define NamedImageGeneratedImage_h
+
+#include "FloatSize.h"
+#include "GeneratedImage.h"
+#include "Image.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class NamedImageGeneratedImage final : public GeneratedImage {
+public:
+    static Ref<NamedImageGeneratedImage> create(String name, const FloatSize& size)
+    {
+        return adoptRef(*new NamedImageGeneratedImage(name, size));
+    }
+
+protected:
+    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, ImageOrientationDescription) override;
+    virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect, BlendMode) override;
+
+    NamedImageGeneratedImage(String name, const FloatSize&);
+
+private:
+    String m_name;
+};
+
+}
+
+#endif
index f3cc9ba..8d809f2 100644 (file)
 #ifndef ThemeIOS_h
 #define ThemeIOS_h
 
-#include "Theme.h"
+#include "ThemeCocoa.h"
 
 namespace WebCore {
 
-class ThemeIOS : public Theme {
+class ThemeIOS : public ThemeCocoa {
 public:
     ThemeIOS() { }
     virtual ~ThemeIOS() { }
index 9ae1ed1..83db8a8 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef ThemeMac_h
 #define ThemeMac_h
 
-#include "Theme.h"
+#include "ThemeCocoa.h"
 
 @interface NSFont(WebCoreTheme)
 - (NSString*)webCoreFamilyName;
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-class ThemeMac : public Theme {
+class ThemeMac : public ThemeCocoa {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     ThemeMac() { }