Title: [98775] trunk
Revision
98775
Author
timothy_hor...@apple.com
Date
2011-10-28 16:08:51 -0700 (Fri, 28 Oct 2011)

Log Message

Implement CSS3 Images cross-fade() image function
https://bugs.webkit.org/show_bug.cgi?id=52162
<rdar://problem/10209254>

Reviewed by Simon Fraser.

Parse -webkit-cross-fade according to the CSS3 Images Values specification.

Also, adjust other CSS parsing functions to support nested functions, by using a specific CSS value list
instead of the global one. This allows - for example - cross-fade to pass each of its arguments back into
parseFillImage and to successfully parse image functions in this fashion.

Test: fast/css/getComputedStyle/computed-style-cross-fade.html

* WebCore.xcodeproj/project.pbxproj:
* css/CSSCrossfadeValue.cpp: Added.
(WebCore::CSSCrossfadeValue::~CSSCrossfadeValue):
(WebCore::CSSCrossfadeValue::cssText):
(WebCore::CSSCrossfadeValue::fixedSize):
(WebCore::CSSCrossfadeValue::image):
* css/CSSCrossfadeValue.h: Added.
(WebCore::CSSCrossfadeValue::create):
(WebCore::CSSCrossfadeValue::isFixedSize):
(WebCore::CSSCrossfadeValue::setFromImage):
(WebCore::CSSCrossfadeValue::setToImage):
(WebCore::CSSCrossfadeValue::setPercentage):
(WebCore::CSSCrossfadeValue::CSSCrossfadeValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseContent):
(WebCore::CSSParser::parseFillImage):
(WebCore::CSSParser::parseFillProperty):
(WebCore::CSSParser::parseBorderImage):
(WebCore::CSSParser::parseDeprecatedGradient):
(WebCore::CSSParser::parseLinearGradient):
(WebCore::CSSParser::parseRadialGradient):
(WebCore::CSSParser::isGeneratedImageValue):
(WebCore::CSSParser::parseGeneratedImage):
(WebCore::CSSParser::parseCrossfade):
(WebCore::CSSParser::parseCanvas):
* css/CSSParser.h:

Add tests to ensure that -webkit-cross-fade is parsed correctly.

* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt: Added.
* fast/css/getComputedStyle/computed-style-cross-fade.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98774 => 98775)


--- trunk/LayoutTests/ChangeLog	2011-10-28 23:06:00 UTC (rev 98774)
+++ trunk/LayoutTests/ChangeLog	2011-10-28 23:08:51 UTC (rev 98775)
@@ -1,3 +1,16 @@
+2011-10-28  Tim Horton  <timothy_hor...@apple.com>
+
+        Implement CSS3 Images cross-fade() image function
+        https://bugs.webkit.org/show_bug.cgi?id=52162
+        <rdar://problem/10209254>
+
+        Reviewed by Simon Fraser.
+
+        Add tests to ensure that -webkit-cross-fade is parsed correctly.
+
+        * fast/css/getComputedStyle/computed-style-cross-fade-expected.txt: Added.
+        * fast/css/getComputedStyle/computed-style-cross-fade.html: Added.
+
 2011-10-28  Chris Marrin  <cmar...@apple.com>
 
         CSS grammar doesn't support functions with no parameters

Added: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade-expected.txt (0 => 98775)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade-expected.txt	2011-10-28 23:08:51 UTC (rev 98775)
@@ -0,0 +1,22 @@
+-webkit-cross-fade
+
+
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png), 50%)", "background-image") is "-webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png), 50%)"
+PASS testCrossfade("background-image: -webkit-cross-fade(-webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), url(http://example.com/example.png), 50%)", "background-image") is "-webkit-cross-fade(-webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), url(http://example.com/example.png), 50%)"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/c.png), -webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), 50%)", "background-image") is "-webkit-cross-fade(url(http://example.com/c.png), -webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), 50%)"
+PASS testCrossfade("background-image: -webkit-cross-fade(-webkit-linear-gradient(black, white), url(http://example.com/example.png), 12%)", "background-image") is "-webkit-cross-fade(-webkit-linear-gradient(top, black, white), url(http://example.com/example.png), 12%)"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png),)", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(), url(http://example.com/example.png))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(10px 20% 5px #bbb)", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(-webkit-cross-fade(-webkit-cross-fade()))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(20%, url(http://example.com/a.png), url(http://example.com/b.png))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/a.png),)", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(,)", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(,url(http://example.com/a.png))", "background-image") is "none"
+PASS testCrossfade("background-image: -webkit-cross-fade(,,,,,)", "background-image") is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE

Added: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade.html (0 => 98775)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-cross-fade.html	2011-10-28 23:08:51 UTC (rev 98775)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script type="text/_javascript_">
+
+function testCrossfade(css, queryProp)
+{
+    var div = document.createElement('div');
+    div.setAttribute('style', css);
+    document.body.appendChild(div);
+
+    var result = getComputedStyle(div).getPropertyValue(queryProp);
+    document.body.removeChild(div);
+    return result;
+}
+
+debug('<p>-webkit-cross-fade</p>');
+
+// Valid
+
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png), 50%)", "background-image")', '"-webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png), 50%)"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(-webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), url(http://example.com/example.png), 50%)", "background-image")', '"-webkit-cross-fade(-webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), url(http://example.com/example.png), 50%)"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/c.png), -webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), 50%)", "background-image")', '"-webkit-cross-fade(url(http://example.com/c.png), -webkit-cross-fade(url(http://example.com/a.png), url(http://example.com/b.png), 25%), 50%)"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(-webkit-linear-gradient(black, white), url(http://example.com/example.png), 12%)", "background-image")', '"-webkit-cross-fade(-webkit-linear-gradient(top, black, white), url(http://example.com/example.png), 12%)"');
+
+// Invalid
+
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png), url(http://example.com/example.png),)", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/example.png))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(), url(http://example.com/example.png))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(10px 20% 5px #bbb)", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(-webkit-cross-fade(-webkit-cross-fade()))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(20%, url(http://example.com/a.png), url(http://example.com/b.png))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(url(http://example.com/a.png),)", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(,)", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(,url(http://example.com/a.png))", "background-image")', '"none"');
+shouldBe('testCrossfade("background-image: -webkit-cross-fade(,,,,,)", "background-image")', '"none"');
+
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (98774 => 98775)


--- trunk/Source/WebCore/ChangeLog	2011-10-28 23:06:00 UTC (rev 98774)
+++ trunk/Source/WebCore/ChangeLog	2011-10-28 23:08:51 UTC (rev 98775)
@@ -1,3 +1,47 @@
+2011-10-28  Tim Horton  <timothy_hor...@apple.com>
+
+        Implement CSS3 Images cross-fade() image function
+        https://bugs.webkit.org/show_bug.cgi?id=52162
+        <rdar://problem/10209254>
+
+        Reviewed by Simon Fraser.
+
+        Parse -webkit-cross-fade according to the CSS3 Images Values specification.
+
+        Also, adjust other CSS parsing functions to support nested functions, by using a specific CSS value list
+        instead of the global one. This allows - for example - cross-fade to pass each of its arguments back into
+        parseFillImage and to successfully parse image functions in this fashion.
+
+        Test: fast/css/getComputedStyle/computed-style-cross-fade.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSCrossfadeValue.cpp: Added.
+        (WebCore::CSSCrossfadeValue::~CSSCrossfadeValue):
+        (WebCore::CSSCrossfadeValue::cssText):
+        (WebCore::CSSCrossfadeValue::fixedSize):
+        (WebCore::CSSCrossfadeValue::image):
+        * css/CSSCrossfadeValue.h: Added.
+        (WebCore::CSSCrossfadeValue::create):
+        (WebCore::CSSCrossfadeValue::isFixedSize):
+        (WebCore::CSSCrossfadeValue::setFromImage):
+        (WebCore::CSSCrossfadeValue::setToImage):
+        (WebCore::CSSCrossfadeValue::setPercentage):
+        (WebCore::CSSCrossfadeValue::CSSCrossfadeValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseContent):
+        (WebCore::CSSParser::parseFillImage):
+        (WebCore::CSSParser::parseFillProperty):
+        (WebCore::CSSParser::parseBorderImage):
+        (WebCore::CSSParser::parseDeprecatedGradient):
+        (WebCore::CSSParser::parseLinearGradient):
+        (WebCore::CSSParser::parseRadialGradient):
+        (WebCore::CSSParser::isGeneratedImageValue):
+        (WebCore::CSSParser::parseGeneratedImage):
+        (WebCore::CSSParser::parseCrossfade):
+        (WebCore::CSSParser::parseCanvas):
+        * css/CSSParser.h:
+
 2011-10-28  Dan Bernstein  <m...@apple.com>
 
         Attempted build fix after r98765.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (98774 => 98775)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-28 23:06:00 UTC (rev 98774)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-28 23:08:51 UTC (rev 98775)
@@ -684,6 +684,8 @@
 		2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
 		2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
 		2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */; };
+		2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */; };
 		2D9066060BE141D400956998 /* LayoutState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D9066040BE141D400956998 /* LayoutState.cpp */; };
 		2D9066070BE141D400956998 /* LayoutState.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D9066050BE141D400956998 /* LayoutState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2E0888D41148848A00AF4265 /* JSDOMFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */; };
@@ -7752,6 +7754,8 @@
 		2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
 		2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
 		2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
+		2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCrossfadeValue.cpp; sourceTree = "<group>"; };
+		2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCrossfadeValue.h; sourceTree = "<group>"; };
 		2D9066040BE141D400956998 /* LayoutState.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; };
 		2D9066050BE141D400956998 /* LayoutState.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; };
 		2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -20459,6 +20463,8 @@
 				E1EBBBD30AAC9B87001FE8E2 /* CSSCharsetRule.cpp */,
 				A80E6CCF0A1989CA007FB8C5 /* CSSCharsetRule.h */,
 				85C56CAC0AA89F8E00D95755 /* CSSCharsetRule.idl */,
+				2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */,
+				2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */,
 				BCEA477C097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp */,
 				BCEA477D097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h */,
 				AA0978ED0ABAA6E100874480 /* CSSCursorImageValue.cpp */,
@@ -24544,6 +24550,7 @@
 				970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */,
 				9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
 				FD62F52E145898D80094B0ED /* AudioSourceProviderClient.h in Headers */,
+				2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -27391,6 +27398,7 @@
 				A0EE0DF5144F825500F80B0D /* WebGLDebugRendererInfo.cpp in Sources */,
 				A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */,
 				A3BB59F31457A40D00AC56FE /* DocumentEventQueue.cpp in Sources */,
+				2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Source/WebCore/css/CSSCrossfadeValue.cpp (0 => 98775)


--- trunk/Source/WebCore/css/CSSCrossfadeValue.cpp	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSCrossfadeValue.cpp	2011-10-28 23:08:51 UTC (rev 98775)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 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 COMPUTER, 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 COMPUTER, 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 "CSSCrossfadeValue.h"
+
+namespace WebCore {
+
+CSSCrossfadeValue::~CSSCrossfadeValue()
+{
+
+}
+
+String CSSCrossfadeValue::cssText() const
+{
+    String result = "-webkit-cross-fade(";
+    result += m_fromImage->cssText() + ", ";
+    result += m_toImage->cssText() + ", ";
+    result += m_percentage->cssText();
+    result += ")";
+    return result;
+}
+
+IntSize CSSCrossfadeValue::fixedSize(const RenderObject* renderer)
+{
+    UNUSED_PARAM(renderer);
+
+    return IntSize();
+}
+
+PassRefPtr<Image> CSSCrossfadeValue::image(RenderObject* renderer, const IntSize& size)
+{
+    UNUSED_PARAM(renderer);
+    UNUSED_PARAM(size);
+
+    return 0;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/css/CSSCrossfadeValue.h (0 => 98775)


--- trunk/Source/WebCore/css/CSSCrossfadeValue.h	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSCrossfadeValue.h	2011-10-28 23:08:51 UTC (rev 98775)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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 COMPUTER, 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 COMPUTER, 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 CSSCrossfadeValue_h
+#define CSSCrossfadeValue_h
+
+#include "CSSImageGeneratorValue.h"
+#include "CSSImageValue.h"
+#include "Image.h"
+#include "ImageObserver.h"
+
+namespace WebCore {
+
+class RenderObject;
+
+class CSSCrossfadeValue : public CSSImageGeneratorValue {
+public:
+    static PassRefPtr<CSSCrossfadeValue> create(PassRefPtr<CSSImageValue> fromImage, PassRefPtr<CSSImageValue> toImage) { return adoptRef(new CSSCrossfadeValue(fromImage, toImage)); }
+    virtual ~CSSCrossfadeValue();
+
+    virtual String cssText() const OVERRIDE;
+
+    virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) OVERRIDE;
+    virtual bool isFixedSize() const OVERRIDE { return false; }
+    virtual IntSize fixedSize(const RenderObject*) OVERRIDE;
+
+    void setPercentage(PassRefPtr<CSSPrimitiveValue> percentage) { m_percentage = percentage; }
+
+private:
+    CSSCrossfadeValue(PassRefPtr<CSSImageValue> fromImage, PassRefPtr<CSSImageValue> toImage)
+    : m_fromImage(fromImage)
+    , m_toImage(toImage)
+    {
+    }
+
+    RefPtr<CSSImageValue> m_fromImage;
+    RefPtr<CSSImageValue> m_toImage;
+    RefPtr<CSSPrimitiveValue> m_percentage;
+};
+
+} // namespace WebCore
+
+#endif // CSSCrossfadeValue_h

Modified: trunk/Source/WebCore/css/CSSParser.cpp (98774 => 98775)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-10-28 23:06:00 UTC (rev 98774)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-10-28 23:08:51 UTC (rev 98775)
@@ -28,6 +28,7 @@
 #include "CSSBorderImageValue.h"
 #include "CSSCanvasValue.h"
 #include "CSSCharsetRule.h"
+#include "CSSCrossfadeValue.h"
 #include "CSSCursorImageValue.h"
 #include "CSSFlexValue.h"
 #include "CSSFontFaceRule.h"
@@ -1213,7 +1214,7 @@
                 m_valueList->next();
             }
         } else if (isGeneratedImageValue(value)) {
-            if (parseGeneratedImage(parsedValue))
+            if (parseGeneratedImage(m_valueList, parsedValue))
                 m_valueList->next();
             else
                 return false;
@@ -2729,7 +2730,7 @@
                 if (!parsedValue)
                     return false;
             } else if (isGeneratedImageValue(val)) {
-                if (!parseGeneratedImage(parsedValue))
+                if (!parseGeneratedImage(m_valueList, parsedValue))
                     return false;
             } else
                 return false;
@@ -2801,22 +2802,22 @@
     return parseColor();
 }
 
-bool CSSParser::parseFillImage(RefPtr<CSSValue>& value)
+bool CSSParser::parseFillImage(CSSParserValueList* valueList, RefPtr<CSSValue>& value)
 {
-    if (m_valueList->current()->id == CSSValueNone) {
+    if (valueList->current()->id == CSSValueNone) {
         value = CSSImageValue::create();
         return true;
     }
-    if (m_valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
+    if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
         // FIXME: The completeURL call should be done when using the CSSImageValue,
         // not when creating it.
         if (m_styleSheet)
-            value = CSSImageValue::create(m_styleSheet->completeURL(m_valueList->current()->string));
+            value = CSSImageValue::create(m_styleSheet->completeURL(valueList->current()->string));
         return true;
     }
 
-    if (isGeneratedImageValue(m_valueList->current()))
-        return parseGeneratedImage(value);
+    if (isGeneratedImageValue(valueList->current()))
+        return parseGeneratedImage(valueList, value);
 
     return false;
 }
@@ -3078,7 +3079,7 @@
                     break;
                 case CSSPropertyBackgroundImage:
                 case CSSPropertyWebkitMaskImage:
-                    if (parseFillImage(currValue))
+                    if (parseFillImage(m_valueList, currValue))
                         m_valueList->next();
                     break;
                 case CSSPropertyWebkitBackgroundClip:
@@ -5266,7 +5267,7 @@
                 context.commitImage(CSSImageValue::create(m_styleSheet->completeURL(val->string)));
             } else if (isGeneratedImageValue(val)) {
                 RefPtr<CSSValue> value;
-                if (parseGeneratedImage(value))
+                if (parseGeneratedImage(m_valueList, value))
                     context.commitImage(value);
                 else
                     return false;
@@ -5772,10 +5773,10 @@
     return true;
 }
 
-bool CSSParser::parseDeprecatedGradient(RefPtr<CSSValue>& gradient)
+bool CSSParser::parseDeprecatedGradient(CSSParserValueList* valueList, RefPtr<CSSValue>& gradient)
 {
     // Walk the arguments.
-    CSSParserValueList* args = m_valueList->current()->function->args.get();
+    CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || args->size() == 0)
         return false;
 
@@ -5931,12 +5932,12 @@
     return p->parseColor(value);
 }
 
-bool CSSParser::parseLinearGradient(RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating)
+bool CSSParser::parseLinearGradient(CSSParserValueList* valueList, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating)
 {
     RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repeating);
 
     // Walk the arguments.
-    CSSParserValueList* args = m_valueList->current()->function->args.get();
+    CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || !args->size())
         return false;
 
@@ -6001,12 +6002,12 @@
     return true;
 }
 
-bool CSSParser::parseRadialGradient(RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating)
+bool CSSParser::parseRadialGradient(CSSParserValueList* valueList, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating)
 {
     RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repeating);
 
     // Walk the arguments.
-    CSSParserValueList* args = m_valueList->current()->function->args.get();
+    CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || !args->size())
         return false;
 
@@ -6168,43 +6169,91 @@
         || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient(")
         || equalIgnoringCase(val->function->name, "-webkit-radial-gradient(")
         || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-canvas(");
+        || equalIgnoringCase(val->function->name, "-webkit-canvas(")
+        || equalIgnoringCase(val->function->name, "-webkit-cross-fade(");
 }
 
-bool CSSParser::parseGeneratedImage(RefPtr<CSSValue>& value)
+bool CSSParser::parseGeneratedImage(CSSParserValueList* valueList, RefPtr<CSSValue>& value)
 {
-    CSSParserValue* val = m_valueList->current();
+    CSSParserValue* val = valueList->current();
 
     if (val->unit != CSSParserValue::Function)
         return false;
 
     if (equalIgnoringCase(val->function->name, "-webkit-gradient("))
-        return parseDeprecatedGradient(value);
+        return parseDeprecatedGradient(valueList, value);
 
     if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient("))
-        return parseLinearGradient(value, NonRepeating);
+        return parseLinearGradient(valueList, value, NonRepeating);
 
     if (equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient("))
-        return parseLinearGradient(value, Repeating);
+        return parseLinearGradient(valueList, value, Repeating);
 
     if (equalIgnoringCase(val->function->name, "-webkit-radial-gradient("))
-        return parseRadialGradient(value, NonRepeating);
+        return parseRadialGradient(valueList, value, NonRepeating);
 
     if (equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient("))
-        return parseRadialGradient(value, Repeating);
+        return parseRadialGradient(valueList, value, Repeating);
 
     if (equalIgnoringCase(val->function->name, "-webkit-canvas("))
-        return parseCanvas(value);
+        return parseCanvas(valueList, value);
 
+    if (equalIgnoringCase(val->function->name, "-webkit-cross-fade("))
+        return parseCrossfade(valueList, value);
+
     return false;
 }
 
-bool CSSParser::parseCanvas(RefPtr<CSSValue>& canvas)
+bool CSSParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSValue>& crossfade)
 {
+    RefPtr<CSSCrossfadeValue> result;
+
+    // Walk the arguments.
+    CSSParserValueList* args = valueList->current()->function->args.get();
+    if (!args || args->size() != 5)
+        return false;
+    CSSParserValue* a = args->current();
+    RefPtr<CSSValue> fromImageValue;
+    RefPtr<CSSValue> toImageValue;
+
+    // The first argument is the "from" image. It is a fill image.
+    if (!a || !parseFillImage(args, fromImageValue))
+        return false;
+    a = args->next();
+
+    // Skip a comma
+    if (a->unit != CSSParserValue::Operator || a->iValue != ',')
+        return false;
+    a = args->next();
+
+    // The second argument is the "to" image. It is a fill image.
+    if (!a || !parseFillImage(args, toImageValue))
+        return false;
+    a = args->next();
+
+    // Skip a comma
+    if (a->unit != CSSParserValue::Operator || a->iValue != ',')
+        return false;
+    a = args->next();
+
+    // The third argument is the crossfade value. It is a percentage.
+    if (!a || a->unit != CSSPrimitiveValue::CSS_PERCENTAGE)
+        return false;
+
+    result = CSSCrossfadeValue::create(static_cast<CSSImageValue*>(fromImageValue.get()), static_cast<CSSImageValue*>(toImageValue.get()));
+    result->setPercentage(createPrimitiveNumericValue(a));
+
+    crossfade = result;
+
+    return true;
+}
+
+bool CSSParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSValue>& canvas)
+{
     RefPtr<CSSCanvasValue> result = CSSCanvasValue::create();
 
     // Walk the arguments.
-    CSSParserValueList* args = m_valueList->current()->function->args.get();
+    CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || args->size() != 1)
         return false;
 

Modified: trunk/Source/WebCore/css/CSSParser.h (98774 => 98775)


--- trunk/Source/WebCore/css/CSSParser.h	2011-10-28 23:06:00 UTC (rev 98774)
+++ trunk/Source/WebCore/css/CSSParser.h	2011-10-28 23:08:51 UTC (rev 98775)
@@ -91,7 +91,7 @@
 
     PassRefPtr<CSSValue> parseBackgroundColor();
 
-    bool parseFillImage(RefPtr<CSSValue>&);
+    bool parseFillImage(CSSParserValueList*, RefPtr<CSSValue>&);
 
     enum FillPositionFlag { InvalidFillPosition = 0, AmbiguousFillPosition = 1, XFillPosition = 2, YFillPosition = 4 };
     PassRefPtr<CSSValue> parseFillPositionComponent(CSSParserValueList*, unsigned& cumulativeFlags, FillPositionFlag& individualFlag);
@@ -176,13 +176,15 @@
     bool parseFlex(int propId, bool important);
 
     // Image generators
-    bool parseCanvas(RefPtr<CSSValue>&);
+    bool parseCanvas(CSSParserValueList*, RefPtr<CSSValue>&);
 
-    bool parseDeprecatedGradient(RefPtr<CSSValue>&);
-    bool parseLinearGradient(RefPtr<CSSValue>&, CSSGradientRepeat repeating);
-    bool parseRadialGradient(RefPtr<CSSValue>&, CSSGradientRepeat repeating);
+    bool parseDeprecatedGradient(CSSParserValueList*, RefPtr<CSSValue>&);
+    bool parseLinearGradient(CSSParserValueList*, RefPtr<CSSValue>&, CSSGradientRepeat repeating);
+    bool parseRadialGradient(CSSParserValueList*, RefPtr<CSSValue>&, CSSGradientRepeat repeating);
     bool parseGradientColorStops(CSSParserValueList*, CSSGradientValue*, bool expectComma);
 
+    bool parseCrossfade(CSSParserValueList*, RefPtr<CSSValue>&);
+
 #if ENABLE(CSS_FILTERS)
     bool isValidFilterArgument(CSSParserValue* argument, WebKitCSSFilterValue::FilterOperationType&, unsigned argumentCount);
     PassRefPtr<CSSValueList> parseFilter();
@@ -317,7 +319,7 @@
     void deleteFontFaceOnlyValues();
 
     bool isGeneratedImageValue(CSSParserValue*) const;
-    bool parseGeneratedImage(RefPtr<CSSValue>&);
+    bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
 
     bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to