Source/WebCore: Implement filter url() function.
authorsenorblanco@chromium.org <senorblanco@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 02:50:27 +0000 (02:50 +0000)
committersenorblanco@chromium.org <senorblanco@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 02:50:27 +0000 (02:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72443

url() references can be internal, in which case the DOM nodes are
retrieved directly from the current document, or external, in which
case a CachedSVGDocument request is made, and the filter node build is
deferred until the document is loaded.  WebKitSVGDocumentValue
holds the CachedSVGDocument (if any) and the URL as a CSSValue,
and is stored in the CSSValue chain as the argument to the reference
filter.

One notable difference between internal and external references is
that internal references will automatically update on an SVG filter node
attribute change, while external references will not, since they live
in a separate document.  This is consistent with the Mozilla
implementation.  In order to make this work, the RenderLayer is made a
client of the RenderSVGResourceContainer, and calls
filterNeedsRepaint() when the SVG nodes are invalidated.

Some plumbing:  The CSS StyleResolver was refactored to load all
all external resources (images, shaders and (now) SVG filters) in a
single function, loadPendingResources().  The PlatformLayer typedef
was moved out into its own file, in order to break a cyclic
dependency.  SVGFilterBuilder was modified to accept the SourceGraphic
and SourceAlpha FilterEffects in its constructor and factory function,
rather than extracting them from the parent Filter.  (This is necessary
so that the url() filter can correctly hook up its inputs from
previous CSS filters.)

Reviewed by Dean Jackson.

Tests: css3/filters/effect-reference-external.html
       css3/filters/effect-reference-hw.html
       css3/filters/effect-reference-ordering.html
       css3/filters/effect-reference.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Add WebKitCSSSVGDocumentValue to the various build files.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::valueForFilter):
Use the reference filter's url when getting the computed style for
a reference filter.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseFilter):
Create the referenceFilterValue's argument as a
WebKitCSSSVGDocumentValue instead of a CSS string.
* css/CSSValue.cpp:
(WebCore::CSSValue::cssText):
Add support for WebKitCSSSVGDocumentValue.
(WebCore::CSSValue::destroy):
Add support for WebKitCSSSVGDocumentValue.
* css/CSSValue.h:
(WebCore::CSSValue::isWebKitCSSSVGDocumentValue):
Add support for WebKitCSSSVGDocumentValue.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList):
Keep track of pending SVG document references, and load them when
necessary.
* css/StyleResolver.h:
* css/WebKitCSSSVGDocumentValue.cpp: Added.
New CSSValue subclass for holding SVG document references.
(WebCore::WebKitCSSSVGDocumentValue::WebKitCSSSVGDocumentValue):
(WebCore::WebKitCSSSVGDocumentValue::~WebKitCSSSVGDocumentValue):
(WebCore::WebKitCSSSVGDocumentValue::load):
(WebCore::WebKitCSSSVGDocumentValue::customCssText):
* css/WebKitCSSSVGDocumentValue.h: Added.
(WebCore::WebKitCSSSVGDocumentValue::create):
(WebCore::WebKitCSSSVGDocumentValue::cachedSVGDocument):
(WebCore::WebKitCSSSVGDocumentValue::url):
(WebCore::WebKitCSSSVGDocumentValue::loadRequested):
* platform/graphics/GraphicsLayer.h:
Refactor PlatformLayer out into its own file, to avoid circular
includes.
* platform/graphics/ImageBuffer.h:
Include PlatformLayer.h instead of GraphicsLayer.h.
* platform/graphics/PlatformLayer.h: Added.
Refactor PlatformLayer out into its own file, to avoid circular
includes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::ReferenceFilterOperation::create):
(WebCore::ReferenceFilterOperation::clone):
(WebCore::ReferenceFilterOperation::url):
(WebCore::ReferenceFilterOperation::fragment):
(ReferenceFilterOperation):
(WebCore::ReferenceFilterOperation::data):
(WebCore::ReferenceFilterOperation::setData):
(WebCore::ReferenceFilterOperation::operator==):
(WebCore::ReferenceFilterOperation::ReferenceFilterOperation):
Augment ReferenceFilterOperation to maintain a data pointer,
in order to preserve context while loading external SVG documents.
Replace "reference" with "url" and "fragment" members, in order to
ease retrieval of the appropriate DOM objects.
* platform/graphics/filters/FilterOperations.cpp:
(WebCore::FilterOperations::hasReferenceFilter):
Convenience function for finding reference filters.
* platform/graphics/filters/FilterOperations.h:
(FilterOperations):
* platform/mac/ScrollbarThemeMac.mm:
Include GraphicsLayer.h explicitly, since ImageBuffer.h no longer
includes it (and only includes PlatformLayer.h).
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
Utility function to build a FilterEffect node graph for a
ReferenceFilterOperation.
(WebCore::FilterEffectRenderer::build):
Call the above builder function for ReferenceFilterOperations.
* rendering/FilterEffectRenderer.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateOrRemoveFilterEffect):
If we have reference filters, update them along with other filters.
(WebCore::RenderLayer::filterNeedsRepaint):
* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayerFilterInfo::~RenderLayerFilterInfo):
(WebCore::RenderLayerFilterInfo::notifyFinished):
Implement callback function when external SVGDocuments are loaded.
(WebCore::RenderLayerFilterInfo::updateReferenceFilterClients):
Add the FilterInfo as a client to be called when SVGDocuments are
loaded.
(WebCore::RenderLayerFilterInfo::removeReferenceFilterClients):
Remove this from the list of notified clients.
* rendering/RenderLayerFilterInfo.h:
Add new member vars for tracking internal and external SVG
references, so we can remove ourselves as a client when done.
* rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::markAllClientsForInvalidation):
When marking client DOM nodes for repaint, also mark any RenderLayers
referring to this DOM tree via filters as needing repaint.
(WebCore::RenderSVGResourceContainer::addClientRenderLayer):
(WebCore::RenderSVGResourceContainer::removeClientRenderLayer):
* rendering/svg/RenderSVGResourceContainer.h:
Maintain a list of RenderLayer clients on each SVG resource container,
and turn SVG DOM repaint notifications into filter repaint (CSS)
notifications.
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::buildPrimitives):
Construct a SourceGraphic and SourceAlpha node explicitly for the
SVG builder case.
* svg/graphics/filters/SVGFilterBuilder.cpp:
(WebCore::SVGFilterBuilder::SVGFilterBuilder):
* svg/graphics/filters/SVGFilterBuilder.h:
(WebCore::SVGFilterBuilder::create):
Add the SourceGraphic and SourceAlpha as parameters to the constructor
and create() methods, so they can be supplied by the caller.

LayoutTests: Add tests for the url() filter function.
https://bugs.webkit.org/show_bug.cgi?id=72443

Reviewed by Dean Jackson.

* css3/filters/effect-reference-external.html: Added.
* css3/filters/effect-reference-hw.html: Added.
* css3/filters/effect-reference-ordering.html: Added.
* css3/filters/effect-reference.html: Added.
* css3/filters/resources/hueRotate.svg: Added.
* platform/chromium-linux/css3/filters/effect-reference-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-expected.txt: Added.
* platform/chromium-linux/css3/filters/effect-reference-external-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-external-expected.txt: Added.
* platform/chromium-linux/css3/filters/effect-reference-hw-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-hw-expected.txt: Added.
* platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-ordering-expected.txt: Added.
* platform/chromium/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121513 268f45cc-cd09-0410-ab3c-d52691b4dbfc

47 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/effect-reference-external.html [new file with mode: 0644]
LayoutTests/css3/filters/effect-reference-hw.html [new file with mode: 0644]
LayoutTests/css3/filters/effect-reference-ordering.html [new file with mode: 0644]
LayoutTests/css3/filters/effect-reference.html [new file with mode: 0644]
LayoutTests/css3/filters/resources/hueRotate.svg [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp [new file with mode: 0644]
Source/WebCore/css/WebKitCSSSVGDocumentValue.h [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/PlatformLayer.h [new file with mode: 0644]
Source/WebCore/platform/graphics/filters/FilterOperation.h
Source/WebCore/platform/graphics/filters/FilterOperations.cpp
Source/WebCore/platform/graphics/filters/FilterOperations.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/FilterEffectRenderer.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerFilterInfo.cpp
Source/WebCore/rendering/RenderLayerFilterInfo.h
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp
Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h

index 5a607fd..3063932 100644 (file)
@@ -1,3 +1,25 @@
+2012-06-28  Stephen White  <senorblanco@chromium.org>
+
+        Add tests for the url() filter function.
+        https://bugs.webkit.org/show_bug.cgi?id=72443
+
+        Reviewed by Dean Jackson.
+
+        * css3/filters/effect-reference-external.html: Added.
+        * css3/filters/effect-reference-hw.html: Added.
+        * css3/filters/effect-reference-ordering.html: Added.
+        * css3/filters/effect-reference.html: Added.
+        * css3/filters/resources/hueRotate.svg: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-expected.txt: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-external-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-external-expected.txt: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-hw-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-hw-expected.txt: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-ordering-expected.txt: Added.
+        * platform/chromium/TestExpectations:
+
 2012-06-28  Mike Lawther  <mikelawther@chromium.org>
 
         Unreviewed gardening.
diff --git a/LayoutTests/css3/filters/effect-reference-external.html b/LayoutTests/css3/filters/effect-reference-external.html
new file mode 100644 (file)
index 0000000..5353de1
--- /dev/null
@@ -0,0 +1,6 @@
+<style>
+img {
+    margin: 10px;
+}
+</style>
+<img style="-webkit-filter: url(resources/hueRotate.svg#MyFilter); filter: url(resources/hueRotate.svg#MyFilter);" src="resources/reference.png">
diff --git a/LayoutTests/css3/filters/effect-reference-hw.html b/LayoutTests/css3/filters/effect-reference-hw.html
new file mode 100644 (file)
index 0000000..27994d7
--- /dev/null
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" version="1.1">
+  <defs>
+    <filter id="MyFilter">
+      <feColorMatrix type="hueRotate" values="180"/>
+    </filter>
+  </defs>
+</svg>
+<style>
+img {
+    margin: 10px;
+    -webkit-transform: translateZ(0);
+}
+</style>
+<img style="-webkit-filter: url(#MyFilter); filter: url(#MyFilter);" src="resources/reference.png">
diff --git a/LayoutTests/css3/filters/effect-reference-ordering.html b/LayoutTests/css3/filters/effect-reference-ordering.html
new file mode 100644 (file)
index 0000000..ffe16cc
--- /dev/null
@@ -0,0 +1,19 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" version="1.1">
+  <defs>
+    <filter id="blurX">
+      <feGaussianBlur stdDeviation="5 0"/>
+    </filter>
+    <filter id="blurY">
+      <feGaussianBlur stdDeviation="0 5"/>
+    </filter>
+  </defs>
+</svg>
+<style>
+img {
+    margin: 10px;
+}
+</style>
+<img style="-webkit-filter: url(#blurY);" src="resources/reference.png">
+<img style="-webkit-filter: contrast(500%) url(#blurY);" src="resources/reference.png">
+<img style="-webkit-filter: url(#blurY) contrast(500%);" src="resources/reference.png">
+<img style="-webkit-filter: url(#blurX) contrast(500%); url(#blurY);" src="resources/reference.png">
diff --git a/LayoutTests/css3/filters/effect-reference.html b/LayoutTests/css3/filters/effect-reference.html
new file mode 100644 (file)
index 0000000..40d353d
--- /dev/null
@@ -0,0 +1,13 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" version="1.1">
+  <defs>
+    <filter id="MyFilter">
+      <feColorMatrix type="hueRotate" values="180"/>
+    </filter>
+  </defs>
+</svg>
+<style>
+img {
+    margin: 10px;
+}
+</style>
+<img style="-webkit-filter: url(#MyFilter); filter: url(#MyFilter);" src="resources/reference.png">
diff --git a/LayoutTests/css3/filters/resources/hueRotate.svg b/LayoutTests/css3/filters/resources/hueRotate.svg
new file mode 100644 (file)
index 0000000..753ca5b
--- /dev/null
@@ -0,0 +1,7 @@
+<svg width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
+  <defs>
+    <filter id="MyFilter">
+      <feColorMatrix type="hueRotate" values="180"/>
+    </filter>
+  </defs>
+</svg>
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.png b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.png
new file mode 100644 (file)
index 0000000..d2b081b
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.txt b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-expected.txt
new file mode 100644 (file)
index 0000000..ae40719
--- /dev/null
@@ -0,0 +1,16 @@
+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
+      RenderSVGRoot {svg} at (8,118) size 0x0
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGResourceFilter {filter} [id="MyFilter"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feColorMatrix type="HUEROTATE" values="180.00"]
+              [SourceGraphic]
+      RenderText {#text} at (0,95) size 4x19
+        text run at (0,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+layer at (22,18) size 160x90
+  RenderImage {IMG} at (14,10) size 160x90
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.png b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.png
new file mode 100644 (file)
index 0000000..ef8d477
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.txt b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-external-expected.txt
new file mode 100644 (file)
index 0000000..2fa9cf0
--- /dev/null
@@ -0,0 +1,8 @@
+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
+      RenderText {#text} at (0,0) size 0x0
+layer at (18,18) size 160x90
+  RenderImage {IMG} at (10,10) size 160x90
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.png b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.png
new file mode 100644 (file)
index 0000000..d2b081b
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.txt b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-hw-expected.txt
new file mode 100644 (file)
index 0000000..ae40719
--- /dev/null
@@ -0,0 +1,16 @@
+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
+      RenderSVGRoot {svg} at (8,118) size 0x0
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGResourceFilter {filter} [id="MyFilter"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feColorMatrix type="HUEROTATE" values="180.00"]
+              [SourceGraphic]
+      RenderText {#text} at (0,95) size 4x19
+        text run at (0,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+layer at (22,18) size 160x90
+  RenderImage {IMG} at (14,10) size 160x90
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png
new file mode 100644 (file)
index 0000000..5b257c6
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.txt b/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-ordering-expected.txt
new file mode 100644 (file)
index 0000000..ac84fc1
--- /dev/null
@@ -0,0 +1,31 @@
+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
+      RenderSVGRoot {svg} at (8,118) size 0x0
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGResourceFilter {filter} [id="blurX"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feGaussianBlur stdDeviation="5.00, 0.00"]
+              [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="blurY"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feGaussianBlur stdDeviation="0.00, 5.00"]
+              [SourceGraphic]
+      RenderText {#text} at (0,95) size 4x19
+        text run at (0,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (184,95) size 4x19
+        text run at (184,95) width 4: " "
+      RenderText {#text} at (368,95) size 4x19
+        text run at (368,95) width 4: " "
+      RenderText {#text} at (552,95) size 4x19
+        text run at (552,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+layer at (22,18) size 160x90
+  RenderImage {IMG} at (14,10) size 160x90
+layer at (206,18) size 160x90
+  RenderImage {IMG} at (198,10) size 160x90
+layer at (390,18) size 160x90
+  RenderImage {IMG} at (382,10) size 160x90
+layer at (574,18) size 160x90
+  RenderImage {IMG} at (566,10) size 160x90
index ac8b603..ed0171c 100644 (file)
@@ -1289,6 +1289,13 @@ BUGWK83183 MAC : svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size.html
 // Appears to be failing on Skia platforms
 BUGWK83199 : svg/filters/big-sized-filter.svg = IMAGE PASS
 
+// This will need to be rebaselined after
+// https://bugs.webkit.org/show_bug.cgi?id=72443 lands.
+BUG_SENORBLANCO WIN MAC : css3/filters/effect-reference.html = IMAGE IMAGE+TEXT TEXT
+BUG_SENORBLANCO WIN MAC : css3/filters/effect-reference-hw.html = IMAGE IMAGE+TEXT TEXT
+BUG_SENORBLANCO WIN MAC : css3/filters/effect-reference-external.html = IMAGE IMAGE+TEXT TEXT
+BUG_SENORBLANCO WIN MAC : css3/filters/effect-reference-ordering.html = IMAGE IMAGE+TEXT TEXT
+
 // Many WIN and Linux SVG tests containing text are flaky. It seems different fonts are used at different times.
 BUGWK83303 WIN LINUX : svg/zoom/text/zoom-hixie-mixed-009.xml = PASS IMAGE
 BUGWK83303 WIN LINUX : svg/zoom/page/zoom-hixie-mixed-009.xml = PASS IMAGE
index 6d3da7f..0348fa3 100644 (file)
@@ -539,6 +539,7 @@ SET(WebCore_SOURCES
     css/WebKitCSSKeyframesRule.cpp
     css/WebKitCSSMatrix.cpp
     css/WebKitCSSRegionRule.cpp
+    css/WebKitCSSSVGDocumentValue.cpp
     css/WebKitCSSTransformValue.cpp
 
     dom/ActiveDOMObject.cpp
index b3f6890..6dd1636 100644 (file)
@@ -1,3 +1,154 @@
+2012-06-28  Stephen White  <senorblanco@chromium.org>
+
+        Implement filter url() function.
+        https://bugs.webkit.org/show_bug.cgi?id=72443
+
+        url() references can be internal, in which case the DOM nodes are
+        retrieved directly from the current document, or external, in which
+        case a CachedSVGDocument request is made, and the filter node build is
+        deferred until the document is loaded.  WebKitSVGDocumentValue
+        holds the CachedSVGDocument (if any) and the URL as a CSSValue,
+        and is stored in the CSSValue chain as the argument to the reference
+        filter.
+
+        One notable difference between internal and external references is
+        that internal references will automatically update on an SVG filter node
+        attribute change, while external references will not, since they live
+        in a separate document.  This is consistent with the Mozilla
+        implementation.  In order to make this work, the RenderLayer is made a
+        client of the RenderSVGResourceContainer, and calls
+        filterNeedsRepaint() when the SVG nodes are invalidated.
+
+        Some plumbing:  The CSS StyleResolver was refactored to load all
+        all external resources (images, shaders and (now) SVG filters) in a
+        single function, loadPendingResources().  The PlatformLayer typedef
+        was moved out into its own file, in order to break a cyclic
+        dependency.  SVGFilterBuilder was modified to accept the SourceGraphic
+        and SourceAlpha FilterEffects in its constructor and factory function,
+        rather than extracting them from the parent Filter.  (This is necessary
+        so that the url() filter can correctly hook up its inputs from
+        previous CSS filters.)
+
+        Reviewed by Dean Jackson.
+
+        Tests: css3/filters/effect-reference-external.html
+               css3/filters/effect-reference-hw.html
+               css3/filters/effect-reference-ordering.html
+               css3/filters/effect-reference.html
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        Add WebKitCSSSVGDocumentValue to the various build files.
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::valueForFilter):
+        Use the reference filter's url when getting the computed style for
+        a reference filter.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseFilter):
+        Create the referenceFilterValue's argument as a
+        WebKitCSSSVGDocumentValue instead of a CSS string.
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::cssText):
+        Add support for WebKitCSSSVGDocumentValue.
+        (WebCore::CSSValue::destroy):
+        Add support for WebKitCSSSVGDocumentValue.
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isWebKitCSSSVGDocumentValue):
+        Add support for WebKitCSSSVGDocumentValue.
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+        Keep track of pending SVG document references, and load them when
+        necessary.
+        * css/StyleResolver.h:
+        * css/WebKitCSSSVGDocumentValue.cpp: Added.
+        New CSSValue subclass for holding SVG document references.
+        (WebCore::WebKitCSSSVGDocumentValue::WebKitCSSSVGDocumentValue):
+        (WebCore::WebKitCSSSVGDocumentValue::~WebKitCSSSVGDocumentValue):
+        (WebCore::WebKitCSSSVGDocumentValue::load):
+        (WebCore::WebKitCSSSVGDocumentValue::customCssText):
+        * css/WebKitCSSSVGDocumentValue.h: Added.
+        (WebCore::WebKitCSSSVGDocumentValue::create):
+        (WebCore::WebKitCSSSVGDocumentValue::cachedSVGDocument):
+        (WebCore::WebKitCSSSVGDocumentValue::url):
+        (WebCore::WebKitCSSSVGDocumentValue::loadRequested):
+        * platform/graphics/GraphicsLayer.h:
+        Refactor PlatformLayer out into its own file, to avoid circular
+        includes.
+        * platform/graphics/ImageBuffer.h:
+        Include PlatformLayer.h instead of GraphicsLayer.h.
+        * platform/graphics/PlatformLayer.h: Added.
+        Refactor PlatformLayer out into its own file, to avoid circular
+        includes.
+        * platform/graphics/filters/FilterOperation.h:
+        (WebCore::ReferenceFilterOperation::create):
+        (WebCore::ReferenceFilterOperation::clone):
+        (WebCore::ReferenceFilterOperation::url):
+        (WebCore::ReferenceFilterOperation::fragment):
+        (ReferenceFilterOperation):
+        (WebCore::ReferenceFilterOperation::data):
+        (WebCore::ReferenceFilterOperation::setData):
+        (WebCore::ReferenceFilterOperation::operator==):
+        (WebCore::ReferenceFilterOperation::ReferenceFilterOperation):
+        Augment ReferenceFilterOperation to maintain a data pointer,
+        in order to preserve context while loading external SVG documents.
+        Replace "reference" with "url" and "fragment" members, in order to
+        ease retrieval of the appropriate DOM objects.
+        * platform/graphics/filters/FilterOperations.cpp:
+        (WebCore::FilterOperations::hasReferenceFilter):
+        Convenience function for finding reference filters.
+        * platform/graphics/filters/FilterOperations.h:
+        (FilterOperations):
+        * platform/mac/ScrollbarThemeMac.mm:
+        Include GraphicsLayer.h explicitly, since ImageBuffer.h no longer
+        includes it (and only includes PlatformLayer.h).
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::buildReferenceFilter):
+        Utility function to build a FilterEffect node graph for a
+        ReferenceFilterOperation.
+        (WebCore::FilterEffectRenderer::build):
+        Call the above builder function for ReferenceFilterOperations.
+        * rendering/FilterEffectRenderer.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateOrRemoveFilterEffect):
+        If we have reference filters, update them along with other filters.
+        (WebCore::RenderLayer::filterNeedsRepaint):
+        * rendering/RenderLayerFilterInfo.cpp:
+        (WebCore::RenderLayerFilterInfo::~RenderLayerFilterInfo):
+        (WebCore::RenderLayerFilterInfo::notifyFinished):
+        Implement callback function when external SVGDocuments are loaded.
+        (WebCore::RenderLayerFilterInfo::updateReferenceFilterClients):
+        Add the FilterInfo as a client to be called when SVGDocuments are
+        loaded.
+        (WebCore::RenderLayerFilterInfo::removeReferenceFilterClients):
+        Remove this from the list of notified clients.
+        * rendering/RenderLayerFilterInfo.h:
+        Add new member vars for tracking internal and external SVG
+        references, so we can remove ourselves as a client when done.
+        * rendering/svg/RenderSVGResourceContainer.cpp:
+        (WebCore::RenderSVGResourceContainer::markAllClientsForInvalidation):
+        When marking client DOM nodes for repaint, also mark any RenderLayers
+        referring to this DOM tree via filters as needing repaint.
+        (WebCore::RenderSVGResourceContainer::addClientRenderLayer):
+        (WebCore::RenderSVGResourceContainer::removeClientRenderLayer):
+        * rendering/svg/RenderSVGResourceContainer.h:
+        Maintain a list of RenderLayer clients on each SVG resource container,
+        and turn SVG DOM repaint notifications into filter repaint (CSS)
+        notifications.
+        * rendering/svg/RenderSVGResourceFilter.cpp:
+        (WebCore::RenderSVGResourceFilter::buildPrimitives):
+        Construct a SourceGraphic and SourceAlpha node explicitly for the
+        SVG builder case.
+        * svg/graphics/filters/SVGFilterBuilder.cpp:
+        (WebCore::SVGFilterBuilder::SVGFilterBuilder):
+        * svg/graphics/filters/SVGFilterBuilder.h:
+        (WebCore::SVGFilterBuilder::create):
+        Add the SourceGraphic and SourceAlpha as parameters to the constructor
+        and create() methods, so they can be supplied by the caller.
+
 2012-06-28  Kenichi Ishibashi  <bashi@chromium.org>
 
         [Chromium] CTFontCopyTable of MacOSX10.5 SDK doesn't work for layout tables
index 35ec2ec..066b94c 100644 (file)
@@ -1772,6 +1772,8 @@ webcore_sources += \
        Source/WebCore/css/WebKitCSSMatrix.h \
        Source/WebCore/css/WebKitCSSRegionRule.cpp \
        Source/WebCore/css/WebKitCSSRegionRule.h \
+       Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp \
+       Source/WebCore/css/WebKitCSSSVGDocumentValue.h \
        Source/WebCore/css/WebKitCSSShaderValue.cpp \
        Source/WebCore/css/WebKitCSSShaderValue.h \
        Source/WebCore/css/WebKitCSSTransformValue.cpp \
@@ -3368,6 +3370,7 @@ webcore_sources += \
        Source/WebCore/platform/graphics/PathTraversalState.h \
        Source/WebCore/platform/graphics/Pattern.cpp \
        Source/WebCore/platform/graphics/Pattern.h \
+       Source/WebCore/platform/graphics/PlatformLayer.h \
        Source/WebCore/platform/graphics/Region.cpp \
        Source/WebCore/platform/graphics/Region.h \
        Source/WebCore/platform/graphics/RoundedRect.cpp \
index 7b96b76..31bd7b2 100644 (file)
@@ -502,6 +502,7 @@ SOURCES += \
     css/WebKitCSSKeyframesRule.cpp \
     css/WebKitCSSMatrix.cpp \
     css/WebKitCSSRegionRule.cpp \
+    css/WebKitCSSSVGDocumentValue.cpp \
     css/WebKitCSSShaderValue.cpp \
     css/WebKitCSSTransformValue.cpp \
     dom/ActiveDOMObject.cpp \
@@ -1686,6 +1687,7 @@ HEADERS += \
     css/WebKitCSSKeyframesRule.h \
     css/WebKitCSSMatrix.h \
     css/WebKitCSSRegionRule.h \
+    css/WebKitCSSSVGDocumentValue.h \
     css/WebKitCSSShaderValue.h \
     css/WebKitCSSTransformValue.h \
     dom/ActiveDOMObject.h \
@@ -2300,6 +2302,7 @@ HEADERS += \
     platform/graphics/Path.h \
     platform/graphics/PathTraversalState.h \
     platform/graphics/Pattern.h \
+    platform/graphics/PlatformLayer.h \
     platform/graphics/Region.h \
     platform/graphics/RoundedRect.h \
     platform/graphics/qt/FontCustomPlatformData.h \
index 7f6e22d..3ff9fd4 100644 (file)
             'platform/graphics/MediaPlayer.h',
             'platform/graphics/Path.h',
             'platform/graphics/Pattern.h',
+            'platform/graphics/PlatformLayer.h',
             'platform/graphics/Region.h',
             'platform/graphics/RoundedRect.h',
             'platform/graphics/SimpleFontData.h',
             'css/WebKitCSSRegionRule.h',
             'css/WebKitCSSShaderValue.cpp',
             'css/WebKitCSSShaderValue.h',
+            'css/WebKitCSSSVGDocumentValue.cpp',
+            'css/WebKitCSSSVGDocumentValue.h',
             'css/WebKitCSSTransformValue.cpp',
             'editing/AlternativeTextController.cpp',
             'editing/AlternativeTextController.h',
index d12db56..fee6bc9 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\graphics\PlatformLayer.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\graphics\Region.cpp"
                                        >
                                </File>
                                >
                        </File>
                        <File
-                               RelativePath="..\css\WebKitCSSShaderValue.cpp"
+                               RelativePath="..\css\WebKitCSSSVGDocumentValue.cpp"
                                >
                        </File>
                        <File
-                               RelativePath="..\css\WebKitCSSShaderValue.h"
+                               RelativePath="..\css\WebKitCSSSVGDocumentValue.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\css\WebKitCSSShaderValue.cpp"
                                >
                        </File>
                        <File
index 2dd358c..6ea00e3 100644 (file)
@@ -78,6 +78,9 @@
                033A6A83147E08A600509B36 /* JSHTMLPropertiesCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 033A6A82147E08A600509B36 /* JSHTMLPropertiesCollection.h */; };
                052BFCE9128ABF1500FD338D /* GeolocationClientMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 052BFCE8128ABF1500FD338D /* GeolocationClientMock.cpp */; };
                052BFCEB128ABF2100FD338D /* GeolocationClientMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 052BFCEA128ABF2100FD338D /* GeolocationClientMock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0562F9461573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0562F9441573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.cpp */; };
+               0562F9471573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0562F9451573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h */; };
+               0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0562F9601573F88F0031CA16 /* PlatformLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                05FD69E012845D4300B2BEB3 /* DOMTimeStamp.h in Headers */ = {isa = PBXBuildFile; fileRef = 05FD69DF12845D4300B2BEB3 /* DOMTimeStamp.h */; settings = {ATTRIBUTES = (Private, ); }; };
                06027CAD0B1CBFC000884B2D /* ContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */; };
                A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */; };
                A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF4144F825500F80B0D /* WebGLDebugShaders.h */; };
                A104F24314C71F7A009E2C23 /* CachedSVGDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A104F24114C71F7A009E2C23 /* CachedSVGDocument.cpp */; };
-               A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; };
+               A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* RenderSVGRect.h */; };
                A10BB58B1484E3B300B2E87A /* RenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* RenderSVGShape.h */; };
                A10DC76A14747BAB005E2471 /* StyleGridData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10DC76814747BAB005E2471 /* StyleGridData.cpp */; };
                B22279B00D00BF220071B782 /* SVGDescElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B222781A0D00BF1F0071B782 /* SVGDescElement.cpp */; };
                B22279B10D00BF220071B782 /* SVGDescElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B222781B0D00BF1F0071B782 /* SVGDescElement.h */; };
                B22279B30D00BF220071B782 /* SVGDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B222781D0D00BF1F0071B782 /* SVGDocument.cpp */; };
-               B22279B40D00BF220071B782 /* SVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = B222781E0D00BF1F0071B782 /* SVGDocument.h */; };
+               B22279B40D00BF220071B782 /* SVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = B222781E0D00BF1F0071B782 /* SVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
                B22279B60D00BF220071B782 /* SVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278200D00BF1F0071B782 /* SVGElement.cpp */; };
                B22279B70D00BF220071B782 /* SVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278210D00BF1F0071B782 /* SVGElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                B22279B90D00BF220071B782 /* SVGElementInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278230D00BF1F0071B782 /* SVGElementInstance.cpp */; };
                033A6A82147E08A600509B36 /* JSHTMLPropertiesCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLPropertiesCollection.h; sourceTree = "<group>"; };
                052BFCE8128ABF1500FD338D /* GeolocationClientMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GeolocationClientMock.cpp; path = mock/GeolocationClientMock.cpp; sourceTree = "<group>"; };
                052BFCEA128ABF2100FD338D /* GeolocationClientMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeolocationClientMock.h; path = mock/GeolocationClientMock.h; sourceTree = "<group>"; };
+               0562F9441573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSSVGDocumentValue.cpp; sourceTree = "<group>"; };
+               0562F9451573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSSVGDocumentValue.h; sourceTree = "<group>"; };
+               0562F9601573F88F0031CA16 /* PlatformLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformLayer.h; sourceTree = "<group>"; };
                05FD69DF12845D4300B2BEB3 /* DOMTimeStamp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMTimeStamp.h; sourceTree = "<group>"; };
                06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenuItem.h; sourceTree = "<group>"; };
                06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuItemMac.mm; sourceTree = "<group>"; };
                B2A015910AF6CD53006BCE0E /* graphics */ = {
                        isa = PBXGroup;
                        children = (
+                               0562F9601573F88F0031CA16 /* PlatformLayer.h */,
                                076F0D0812B8192700C26AA4 /* avfoundation */,
                                499B3EC0128CCC1800E726C2 /* ca */,
                                B27535290B053814002CE64F /* cg */,
                                8AA61CFD144D595B00F37350 /* WebKitCSSRegionRule.cpp */,
                                8AA61CFE144D595B00F37350 /* WebKitCSSRegionRule.h */,
                                8AD0A55614C87425000D83C5 /* WebKitCSSRegionRule.idl */,
+                               0562F9441573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.cpp */,
+                               0562F9451573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h */,
                                5038BC0614711CDB0095E0D1 /* WebKitCSSShaderValue.cpp */,
                                50B42157146976960087E604 /* WebKitCSSShaderValue.h */,
                                BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */,
                                A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */,
                                BC9585E112F0989500755821 /* PlatformGestureEvent.h in Headers */,
                                935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
+                               0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
                                932871C00B20DEB70049035A /* PlatformMenuDescription.h in Headers */,
                                41BF70100FE86F61005E8DEC /* PlatformMessagePortChannel.h in Headers */,
                                935C476909AC4D4300A6AAB4 /* PlatformMouseEvent.h in Headers */,
                                31288E750E3005D6003619AE /* WebKitCSSKeyframesRule.h in Headers */,
                                498391590F1E776900C23782 /* WebKitCSSMatrix.h in Headers */,
                                8AA61D00144D595B00F37350 /* WebKitCSSRegionRule.h in Headers */,
+                               0562F9471573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h in Headers */,
                                29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */,
                                BC9ADD230CC4032600098C4C /* WebKitCSSTransformValue.h in Headers */,
                                89878566122CA064003AABDA /* WebKitFlags.h in Headers */,
                                498391580F1E776900C23782 /* WebKitCSSMatrix.cpp in Sources */,
                                8AA61CFF144D595B00F37350 /* WebKitCSSRegionRule.cpp in Sources */,
                                5038BC0714711CDB0095E0D1 /* WebKitCSSShaderValue.cpp in Sources */,
+        0562F9461573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.cpp in Sources */,
                                BC9ADD800CC4092200098C4C /* WebKitCSSTransformValue.cpp in Sources */,
                                1A1414B513A0F0500019996C /* WebKitFontFamilyNames.cpp in Sources */,
                                C6F0900E14327B6100685849 /* WebKitMutationObserver.cpp in Sources */,
index d19e554..cb85beb 100644 (file)
@@ -785,7 +785,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* st
         case FilterOperation::REFERENCE: {
             ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
-            filterValue->append(cssValuePool().createValue(referenceOperation->reference(), CSSPrimitiveValue::CSS_STRING));
+            filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
             break;
         }
         case FilterOperation::GRAYSCALE: {
index c386891..5b56ba2 100644 (file)
@@ -94,6 +94,9 @@
 
 #if ENABLE(CSS_FILTERS)
 #include "WebKitCSSFilterValue.h"
+#if ENABLE(SVG)
+#include "WebKitCSSSVGDocumentValue.h"
+#endif
 #endif
 
 #if ENABLE(CSS_SHADERS)
@@ -7558,9 +7561,11 @@ PassRefPtr<CSSValueList> CSSParser::parseFilter()
 
         // See if the specified primitive is one we understand.
         if (value->unit == CSSPrimitiveValue::CSS_URI) {
+#if ENABLE(SVG)
             RefPtr<WebKitCSSFilterValue> referenceFilterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
             list->append(referenceFilterValue);
-            referenceFilterValue->append(cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRING));
+            referenceFilterValue->append(WebKitCSSSVGDocumentValue::create(value->string));
+#endif
         } else {
             const CSSParserString name = value->function->name;
             unsigned maximumArgumentCount = 1;
index 40a1bc0..cda43b9 100644 (file)
 #include "WebKitCSSShaderValue.h"
 #include "WebKitCSSTransformValue.h"
 
+#if ENABLE(SVG)
+#include "WebKitCSSSVGDocumentValue.h"
+#endif
+
 namespace WebCore {
 
 struct SameSizeAsCSSValue : public RefCounted<SameSizeAsCSSValue> {
@@ -197,6 +201,8 @@ String CSSValue::cssText() const
         return static_cast<const SVGColor*>(this)->customCssText();
     case SVGPaintClass:
         return static_cast<const SVGPaint*>(this)->customCssText();
+    case WebKitCSSSVGDocumentClass:
+        return static_cast<const WebKitCSSSVGDocumentValue*>(this)->customCssText();
 #endif
     }
     ASSERT_NOT_REACHED();
@@ -331,6 +337,9 @@ void CSSValue::destroy()
     case SVGPaintClass:
         delete static_cast<SVGPaint*>(this);
         return;
+    case WebKitCSSSVGDocumentClass:
+        delete static_cast<WebKitCSSSVGDocumentValue*>(this);
+        return;
 #endif
     }
     ASSERT_NOT_REACHED();
index b4e8a89..3850961 100644 (file)
@@ -99,6 +99,7 @@ public:
 #if ENABLE(SVG)
     bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; }
     bool isSVGPaint() const { return m_classType == SVGPaintClass; }
+    bool isWebKitCSSSVGDocumentValue() const { return m_classType == WebKitCSSSVGDocumentClass; }
 #endif
     
     bool isCSSOMSafe() const { return m_isCSSOMSafe; }
@@ -161,6 +162,7 @@ protected:
 #if ENABLE(SVG)
         SVGColorClass,
         SVGPaintClass,
+        WebKitCSSSVGDocumentClass,
 #endif
 
         // List class types must appear after ValueListClass.
index df4a7c0..56313fe 100644 (file)
 #endif
 
 #if ENABLE(SVG)
+#include "CachedSVGDocument.h"
+#include "SVGDocument.h"
 #include "SVGElement.h"
 #include "SVGNames.h"
+#include "SVGURIReference.h"
+#include "WebKitCSSSVGDocumentValue.h"
 #endif
 
 #if ENABLE(CSS_SHADERS)
@@ -1793,14 +1797,9 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* eleme
     // go ahead and update it a second time.
     updateFont();
 
-    // Start loading images referenced by this style.
-    loadPendingImages();
+    // Start loading resources referenced by this style.
+    loadPendingResources();
     
-#if ENABLE(CSS_SHADERS)
-    // Start loading the shaders referenced by this style.
-    loadPendingShaders();
-#endif
-
     // Add all the animating properties to the keyframe.
     if (StylePropertySet* styleDeclaration = keyframe->properties()) {
         unsigned propertyCount = styleDeclaration->propertyCount();
@@ -1914,13 +1913,8 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, El
     // Clean up our style object's display and text decorations (among other fixups).
     adjustRenderStyle(style(), parentStyle, 0);
 
-    // Start loading images referenced by this style.
-    loadPendingImages();
-
-#if ENABLE(CSS_SHADERS)
-    // Start loading the shaders referenced by this style.
-    loadPendingShaders();
-#endif
+    // Start loading resources referenced by this style.
+    loadPendingResources();
 
     // Now return the style.
     return m_style.release();
@@ -1958,13 +1952,8 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
 
     applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
 
-    // Start loading images referenced by this style.
-    loadPendingImages();
-
-#if ENABLE(CSS_SHADERS)
-    // Start loading the shaders referenced by this style.
-    loadPendingShaders();
-#endif
+    // Start loading resources referenced by this style.
+    loadPendingResources();
 
     // Now return the style.
     return m_style.release();
@@ -3009,12 +2998,9 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const
     applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
     applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
     applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
-    
-    loadPendingImages();
-    
-#if ENABLE(CSS_SHADERS)
-    loadPendingShaders();
-#endif
+   
+    // Start loading resources referenced by this style.
+    loadPendingResources();
     
     ASSERT(!m_fontDirty);
     
@@ -5092,6 +5078,34 @@ static FilterOperation::OperationType filterOperationForType(WebKitCSSFilterValu
     return FilterOperation::NONE;
 }
 
+#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
+void StyleResolver::loadPendingSVGDocuments()
+{
+    if (!m_style->hasFilter() || m_pendingSVGDocuments.isEmpty())
+        return;
+
+    CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
+    Vector<RefPtr<FilterOperation> >& filterOperations = m_style->filter().operations();
+    for (unsigned i = 0; i < filterOperations.size(); ++i) {
+        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
+        if (filterOperation->getOperationType() == FilterOperation::REFERENCE) {
+            ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get());
+
+            WebKitCSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilter);
+            if (!value)
+                continue;
+            CachedSVGDocument* cachedDocument = value->load(cachedResourceLoader);
+            if (!cachedDocument)
+                continue;
+
+            // Stash the CachedSVGDocument on the reference filter.
+            referenceFilter->setData(cachedDocument);
+        }
+    }
+    m_pendingSVGDocuments.clear();
+}
+#endif
+
 #if ENABLE(CSS_SHADERS)
 StyleShader* StyleResolver::styleShader(CSSValue* value)
 {
@@ -5337,6 +5351,29 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style
             continue;
         }
 #endif
+        if (operationType == FilterOperation::REFERENCE) {
+#if ENABLE(SVG)
+            if (filterValue->length() != 1)
+                continue;
+            CSSValue* argument = filterValue->itemWithoutBoundsCheck(0);
+
+            if (!argument->isWebKitCSSSVGDocumentValue())
+                continue;
+
+            WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument);
+            KURL url = m_element->document()->completeURL(svgDocumentValue->url());
+
+            RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType);
+            if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_element->document())) {
+                if (!svgDocumentValue->loadRequested())
+                    m_pendingSVGDocuments.set(operation.get(), svgDocumentValue);
+                else
+                    operation->setData(svgDocumentValue->cachedSVGDocument());
+            }
+            operations.operations().append(operation);
+#endif
+            continue;
+        }
 
         // Check that all parameters are primitive values, with the
         // exception of drop shadow which has a ShadowValue parameter.
@@ -5354,11 +5391,6 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style
 
         CSSPrimitiveValue* firstValue = filterValue->length() ? static_cast<CSSPrimitiveValue*>(filterValue->itemWithoutBoundsCheck(0)) : 0;
         switch (filterValue->operationType()) {
-        case WebKitCSSFilterValue::ReferenceFilterOperation: {
-            if (firstValue)
-                operations.operations().append(ReferenceFilterOperation::create(firstValue->getStringValue(), operationType));
-            break;
-        }
         case WebKitCSSFilterValue::GrayscaleFilterOperation:
         case WebKitCSSFilterValue::SepiaFilterOperation:
         case WebKitCSSFilterValue::SaturateFilterOperation: {
@@ -5543,4 +5575,20 @@ void StyleResolver::loadPendingImages()
     m_pendingImageProperties.clear();
 }
 
+void StyleResolver::loadPendingResources()
+{
+    // Start loading images referenced by this style.
+    loadPendingImages();
+
+#if ENABLE(CSS_SHADERS)
+    // Start loading the shaders referenced by this style.
+    loadPendingShaders();
+#endif
+    
+#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
+    // Start loading the SVG Documents referenced by this style.
+    loadPendingSVGDocuments();
+#endif
+}
+
 } // namespace WebCore
index 4843eb5..b653e84 100644 (file)
@@ -87,6 +87,7 @@ class StyleSheetList;
 class StyledElement;
 class WebKitCSSFilterValue;
 class WebKitCSSShaderValue;
+class WebKitCSSSVGDocumentValue;
 
 #if ENABLE(CSS_SHADERS)
 typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterList;
@@ -262,8 +263,13 @@ public:
     PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*);
     void loadPendingShaders();
 #endif
+#if ENABLE(SVG)
+    void loadPendingSVGDocuments();
+#endif
 #endif // ENABLE(CSS_FILTERS)
 
+    void loadPendingResources();
+
     struct RuleFeature {
         RuleFeature(StyleRule* rule, CSSSelector* selector, bool hasDocumentSecurityOrigin)
             : rule(rule)
@@ -495,6 +501,10 @@ private:
     bool m_hasPendingShaders;
 #endif
 
+#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
+    HashMap<FilterOperation*, WebKitCSSSVGDocumentValue*> m_pendingSVGDocuments;
+#endif
+
 #if ENABLE(STYLE_SCOPED)
     const ContainerNode* determineScope(const CSSStyleSheet*);
 
diff --git a/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp b/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
new file mode 100644 (file)
index 0000000..4902504
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 Google 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,
+ * 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"
+
+#if ENABLE(SVG)
+#include "WebKitCSSSVGDocumentValue.h"
+
+#include "CSSParser.h"
+#include "CachedResourceLoader.h"
+#include "Document.h"
+
+namespace WebCore {
+
+WebKitCSSSVGDocumentValue::WebKitCSSSVGDocumentValue(const String& url)
+    : CSSValue(WebKitCSSSVGDocumentClass)
+    , m_url(url)
+    , m_loadRequested(false)
+{
+}
+
+WebKitCSSSVGDocumentValue::~WebKitCSSSVGDocumentValue()
+{
+}
+
+CachedSVGDocument* WebKitCSSSVGDocumentValue::load(CachedResourceLoader* loader)
+{
+    ASSERT(loader);
+
+    if (!m_loadRequested) {
+        m_loadRequested = true;
+
+        ResourceRequest request(loader->document()->completeURL(m_url));
+        m_document = loader->requestSVGDocument(request);
+    }
+
+    return m_document.get();
+}
+
+String WebKitCSSSVGDocumentValue::customCssText() const
+{
+    return quoteCSSStringIfNeeded(m_url);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/Source/WebCore/css/WebKitCSSSVGDocumentValue.h b/Source/WebCore/css/WebKitCSSSVGDocumentValue.h
new file mode 100644 (file)
index 0000000..cb03f56
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Google 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,
+ * 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 WebKitCSSSVGDocumentValue_h
+#define WebKitCSSSVGDocumentValue_h
+
+#include "CSSValue.h"
+#include "CachedResourceHandle.h"
+#include "CachedSVGDocument.h"
+
+namespace WebCore {
+
+class CachedResourceLoader;
+
+class WebKitCSSSVGDocumentValue : public CSSValue {
+public:
+    static PassRefPtr<WebKitCSSSVGDocumentValue> create(const String& url) { return adoptRef(new WebKitCSSSVGDocumentValue(url)); }
+    ~WebKitCSSSVGDocumentValue();
+
+    CachedSVGDocument* cachedSVGDocument() const { return m_document.get(); }
+    CachedSVGDocument* load(CachedResourceLoader*);
+
+    String customCssText() const;
+    const String& url() const { return m_url; }
+    bool loadRequested() const { return m_loadRequested; }
+
+private:
+    WebKitCSSSVGDocumentValue(const String& url);
+
+    String m_url;
+    CachedResourceHandle<CachedSVGDocument> m_document;
+    bool m_loadRequested;
+};
+
+} // namespace WebCore
+
+#endif // WebKitCSSSVGDocumentValue_h
index e00c795..7939717 100644 (file)
 #include "FloatSize.h"
 #include "GraphicsLayerClient.h"
 #include "IntRect.h"
+#include "PlatformLayer.h"
 #include "TransformationMatrix.h"
 #include "TransformOperations.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
-#if PLATFORM(MAC)
-OBJC_CLASS CALayer;
-typedef CALayer PlatformLayer;
-#elif PLATFORM(WIN)
-typedef struct _CACFLayer PlatformLayer;
-#elif PLATFORM(QT)
-#if USE(TEXTURE_MAPPER)
-namespace WebCore {
-class TextureMapperPlatformLayer;
-typedef TextureMapperPlatformLayer PlatformLayer;
-};
-#else
-QT_BEGIN_NAMESPACE
-class QGraphicsObject;
-QT_END_NAMESPACE
-namespace WebCore {
-typedef QGraphicsObject PlatformLayer;
-}
-#endif
-#elif PLATFORM(CHROMIUM)
-namespace WebCore {
-class LayerChromium;
-typedef LayerChromium PlatformLayer;
-}
-#elif PLATFORM(GTK)
-#if USE(TEXTURE_MAPPER_CAIRO) || USE(TEXTURE_MAPPER_GL)
-namespace WebCore {
-class TextureMapperPlatformLayer;
-typedef TextureMapperPlatformLayer PlatformLayer;
-};
-#elif USE(CLUTTER)
-typedef struct _ClutterActor ClutterActor;
-namespace WebCore {
-typedef ClutterActor PlatformLayer;
-};
-#endif
-#else
-typedef void* PlatformLayer;
-#endif
-
 enum LayerTreeAsTextBehaviorFlags {
     LayerTreeAsTextBehaviorNormal = 0,
     LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
index 24831ed..06ac567 100644 (file)
@@ -33,7 +33,7 @@
 #include "FloatRect.h"
 #include "GraphicsContext.h"
 #if USE(ACCELERATED_COMPOSITING)
-#include "GraphicsLayer.h"
+#include "PlatformLayer.h"
 #endif
 #include "GraphicsTypes.h"
 #include "GraphicsTypes3D.h"
diff --git a/Source/WebCore/platform/graphics/PlatformLayer.h b/Source/WebCore/platform/graphics/PlatformLayer.h
new file mode 100644 (file)
index 0000000..dbf325d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Google 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 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 PlatformLayer_h
+#define PlatformLayer_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#if PLATFORM(MAC)
+OBJC_CLASS CALayer;
+typedef CALayer PlatformLayer;
+#elif PLATFORM(WIN)
+typedef struct _CACFLayer PlatformLayer;
+#elif PLATFORM(QT)
+#if USE(TEXTURE_MAPPER)
+namespace WebCore {
+class TextureMapperPlatformLayer;
+typedef TextureMapperPlatformLayer PlatformLayer;
+};
+#else
+QT_BEGIN_NAMESPACE
+class QGraphicsObject;
+QT_END_NAMESPACE
+namespace WebCore {
+typedef QGraphicsObject PlatformLayer;
+}
+#endif
+#elif PLATFORM(CHROMIUM)
+namespace WebCore {
+class LayerChromium;
+typedef LayerChromium PlatformLayer;
+}
+#elif PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER_CAIRO) || USE(TEXTURE_MAPPER_GL)
+namespace WebCore {
+class TextureMapperPlatformLayer;
+typedef TextureMapperPlatformLayer PlatformLayer;
+};
+#elif USE(CLUTTER)
+typedef struct _ClutterActor ClutterActor;
+namespace WebCore {
+typedef ClutterActor PlatformLayer;
+};
+#endif
+#else
+typedef void* PlatformLayer;
+#endif
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // PlatformLayer_h
index 255f640..b8796e8 100644 (file)
@@ -33,7 +33,7 @@
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefCounted.h>
-#include <wtf/text/AtomicString.h>
+#include <wtf/text/WTFString.h>
 
 // Annoyingly, wingdi.h #defines this.
 #ifdef PASSTHROUGH
@@ -147,21 +147,25 @@ private:
 
 class ReferenceFilterOperation : public FilterOperation {
 public:
-    static PassRefPtr<ReferenceFilterOperation> create(const AtomicString& reference, OperationType type)
+    static PassRefPtr<ReferenceFilterOperation> create(const String& url, const String& fragment, OperationType type)
     {
-        return adoptRef(new ReferenceFilterOperation(reference, type));
+        return adoptRef(new ReferenceFilterOperation(url, fragment, type));
     }
 
     virtual PassRefPtr<FilterOperation> clone() const
     {
-        // AtomicString is thread-hostile, so we can't be cloned.
+        // Unimplemented
         return 0;
     }
 
     virtual bool affectsOpacity() const { return true; }
     virtual bool movesPixels() const { return true; }
 
-    const AtomicString& reference() const { return m_reference; }
+    const String& url() const { return m_url; }
+    const String& fragment() const { return m_fragment; }
+
+    void* data() const { return m_data; }
+    void setData(void* data) { m_data = data; }
 
 private:
 
@@ -170,16 +174,20 @@ private:
         if (!isSameType(o))
             return false;
         const ReferenceFilterOperation* other = static_cast<const ReferenceFilterOperation*>(&o);
-        return m_reference == other->m_reference;
+        return m_url == other->m_url;
     }
 
-    ReferenceFilterOperation(const AtomicString& reference, OperationType type)
+    ReferenceFilterOperation(const String& url, const String& fragment, OperationType type)
         : FilterOperation(type)
-        , m_reference(reference)
+        , m_url(url)
+        , m_fragment(fragment)
+        , m_data(0)
     {
     }
 
-    AtomicString m_reference;
+    String m_url;
+    String m_fragment;
+    void* m_data;
 };
 
 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color matrix effect.
index 821bc6e..c4b8765 100644 (file)
@@ -98,6 +98,15 @@ bool FilterOperations::hasCustomFilter() const
 }
 #endif
 
+bool FilterOperations::hasReferenceFilter() const
+{
+    for (size_t i = 0; i < m_operations.size(); ++i) {
+        if (m_operations.at(i)->getOperationType() == FilterOperation::REFERENCE)
+            return true;
+    }
+    return false;
+}
+
 bool FilterOperations::hasOutsets() const
 {
     for (size_t i = 0; i < m_operations.size(); ++i) {
index be1b0a6..beb649b 100644 (file)
@@ -72,6 +72,7 @@ public:
 #if ENABLE(CSS_SHADERS)
     bool hasCustomFilter() const;
 #endif
+    bool hasReferenceFilter() const;
 private:
     Vector<RefPtr<FilterOperation> > m_operations;
 };
index 2fe336f..323719b 100644 (file)
@@ -27,6 +27,7 @@
 #include "ScrollbarThemeMac.h"
 
 #include "ImageBuffer.h"
+#include "GraphicsLayer.h"
 #include "LocalCurrentGraphicsContext.h"
 #include "NSScrollerImpDetails.h"
 #include "PlatformMouseEvent.h"
index ebf6b7e..11cf5f5 100644 (file)
 #include "Settings.h"
 #endif
 
+#if ENABLE(SVG)
+#include "CachedSVGDocument.h"
+#include "SVGElement.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SourceAlpha.h"
+#endif
+
 namespace WebCore {
 
 static inline void endMatrixRow(Vector<float>& parameters)
@@ -108,6 +115,56 @@ GraphicsContext* FilterEffectRenderer::inputContext()
     return sourceImage() ? sourceImage()->context() : 0;
 }
 
+PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(Document* document, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* op)
+{
+#if ENABLE(SVG)
+    CachedSVGDocument* cachedSVGDocument = static_cast<CachedSVGDocument*>(op->data());
+
+    // If we have an SVG document, this is an external reference. Otherwise
+    // we look up the referenced node in the current document.
+    if (cachedSVGDocument)
+        document = cachedSVGDocument->document();
+
+    if (!document)
+        return 0;
+
+    Element* filter = document->getElementById(op->fragment());
+    if (!filter)
+        return 0;
+
+    RefPtr<FilterEffect> effect;
+
+    // FIXME: Figure out what to do with SourceAlpha. Right now, we're
+    // using the alpha of the original input layer, which is obviously
+    // wrong. We should probably be extracting the alpha from the 
+    // previousEffect, but this requires some more processing.  
+    // This may need a spec clarification.
+    RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(this));
+
+    for (Node* node = filter->firstChild(); node; node = node->nextSibling()) {
+        if (!node->isSVGElement())
+            continue;
+
+        SVGElement* element = static_cast<SVGElement*>(node);
+        if (!element->isFilterEffect())
+            continue;
+
+        SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
+
+        effect = effectElement->build(builder.get(), this);
+        if (!effect)
+            continue;
+
+        effectElement->setStandardAttributes(effect.get());
+        builder->add(effectElement->result(), effect);
+        m_effects.append(effect);
+    }
+    return effect;
+#else
+    return 0;
+#endif
+}
+
 bool FilterEffectRenderer::build(Document* document, const FilterOperations& operations)
 {
 #if !ENABLE(CSS_SHADERS) || !ENABLE(WEBGL)
@@ -122,14 +179,13 @@ bool FilterEffectRenderer::build(Document* document, const FilterOperations& ope
         operations.getOutsets(m_topOutset, m_rightOutset, m_bottomOutset, m_leftOutset);
     m_effects.clear();
 
-    RefPtr<FilterEffect> previousEffect;
+    RefPtr<FilterEffect> previousEffect = m_sourceGraphic;
     for (size_t i = 0; i < operations.operations().size(); ++i) {
         RefPtr<FilterEffect> effect;
         FilterOperation* filterOperation = operations.operations().at(i).get();
         switch (filterOperation->getOperationType()) {
         case FilterOperation::REFERENCE: {
-            // FIXME: Not yet implemented.
-            // https://bugs.webkit.org/show_bug.cgi?id=72443
+            effect = buildReferenceFilter(document, previousEffect, static_cast<ReferenceFilterOperation*>(filterOperation));
             break;
         }
         case FilterOperation::GRAYSCALE: {
@@ -291,18 +347,18 @@ bool FilterEffectRenderer::build(Document* document, const FilterOperations& ope
             // Unlike SVG, filters applied here should not clip to their primitive subregions.
             effect->setClipsToBounds(false);
             
-            if (previousEffect)
+            if (filterOperation->getOperationType() != FilterOperation::REFERENCE) {
                 effect->inputEffects().append(previousEffect);
-            m_effects.append(effect);
+                m_effects.append(effect);
+            }
             previousEffect = effect.release();
         }
     }
 
     // If we didn't make any effects, tell our caller we are not valid
-    if (!previousEffect)
+    if (!m_effects.size())
         return false;
 
-    m_effects.first()->inputEffects().append(m_sourceGraphic);
     setMaxEffectRects(m_sourceDrawingRegion);
     
     return true;
index c6266f6..0db987b 100644 (file)
@@ -100,6 +100,7 @@ public:
     ImageBuffer* output() const { return lastEffect()->asImageBuffer(); }
 
     bool build(Document*, const FilterOperations&);
+    PassRefPtr<FilterEffect> buildReferenceFilter(Document*, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation*);
     bool updateBackingStoreRect(const FloatRect& filterRect);
     void allocateBackingStoreIfNeeded();
     void clearIntermediateResults();
index 12c3b92..038f661 100644 (file)
@@ -4994,7 +4994,14 @@ void RenderLayer::updateOrRemoveFilterEffect()
     else if (hasFilterInfo())
         filterInfo()->removeCustomFilterClients();
 #endif
-    
+
+#if ENABLE(SVG)
+    if (renderer()->style()->filter().hasReferenceFilter())
+        ensureFilterInfo()->updateReferenceFilterClients(renderer()->style()->filter());
+    else if (hasFilterInfo())
+        filterInfo()->removeReferenceFilterClients();
+#endif
+
     if (!paintsWithFilters()) {
         // Don't delete the whole filter info here, because we might use it
         // for loading CSS shader files.
@@ -5020,7 +5027,8 @@ void RenderLayer::updateOrRemoveFilterEffect()
 void RenderLayer::filterNeedsRepaint()
 {
     renderer()->node()->setNeedsStyleRecalc(SyntheticStyleChange);
-    renderer()->repaint();
+    if (renderer()->view())
+        renderer()->repaint();
 }
 #endif
 
index 703df63..acbf07d 100644 (file)
 #include "FilterEffectRenderer.h"
 #include "RenderLayer.h"
 
+#if ENABLE(SVG)
+#include "CachedSVGDocument.h"
+#include "SVGElement.h"
+#include "SVGFilter.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#endif
+
 #if ENABLE(CSS_SHADERS)
 #include "CustomFilterOperation.h"
 #include "CustomFilterProgram.h"
@@ -96,6 +103,9 @@ RenderLayerFilterInfo::~RenderLayerFilterInfo()
 #if ENABLE(CSS_SHADERS)
     removeCustomFilterClients();
 #endif
+#if ENABLE(SVG)
+    removeReferenceFilterClients();
+#endif
 }
 
 void RenderLayerFilterInfo::setRenderer(PassRefPtr<FilterEffectRenderer> renderer)
@@ -103,6 +113,56 @@ void RenderLayerFilterInfo::setRenderer(PassRefPtr<FilterEffectRenderer> rendere
     m_renderer = renderer; 
 }
 
+#if ENABLE(SVG)
+void RenderLayerFilterInfo::notifyFinished(CachedResource*)
+{
+    RenderObject* renderer = m_layer->renderer();
+    renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
+    renderer->repaint();
+}
+
+void RenderLayerFilterInfo::updateReferenceFilterClients(const FilterOperations& operations)
+{
+    removeReferenceFilterClients();
+    for (size_t i = 0; i < operations.size(); ++i) {
+        RefPtr<FilterOperation> filterOperation = operations.operations().at(i);
+        if (filterOperation->getOperationType() != FilterOperation::REFERENCE)
+            continue;
+        ReferenceFilterOperation* referenceFilterOperation = static_cast<ReferenceFilterOperation*>(filterOperation.get());
+        CachedSVGDocument* cachedSVGDocument = static_cast<CachedSVGDocument*>(referenceFilterOperation->data());
+
+        if (cachedSVGDocument) {
+            // Reference is external; wait for notifyFinished().
+            cachedSVGDocument->addClient(this);
+            m_externalSVGReferences.append(cachedSVGDocument);
+        } else {
+            // Reference is internal; add layer as a client so we can trigger
+            // filter repaint on SVG attribute change.
+            Element* filter = m_layer->renderer()->node()->document()->getElementById(referenceFilterOperation->fragment());
+            if (!filter || !filter->renderer())
+                continue;
+            ASSERT(filter->renderer()->isSVGResourceContainer());
+            filter->renderer()->toRenderSVGResourceContainer()->addClientRenderLayer(m_layer);
+            m_internalSVGReferences.append(filter);
+        }
+    }
+}
+
+void RenderLayerFilterInfo::removeReferenceFilterClients()
+{
+    for (size_t i = 0; i < m_externalSVGReferences.size(); ++i)
+        m_externalSVGReferences.at(i)->removeClient(this);
+    m_externalSVGReferences.clear();
+    for (size_t i = 0; i < m_internalSVGReferences.size(); ++i) {
+        Element* filter = m_internalSVGReferences.at(i).get();
+        if (!filter->renderer())
+            continue;
+        filter->renderer()->toRenderSVGResourceContainer()->removeClientRenderLayer(m_layer);
+    }
+    m_internalSVGReferences.clear();
+}
+#endif
+
 #if ENABLE(CSS_SHADERS)
 void RenderLayerFilterInfo::notifyCustomFilterProgramLoaded(CustomFilterProgram*)
 {
index 86a9c13..ab45a9f 100644 (file)
 
 #if ENABLE(CSS_FILTERS)
 
+#if ENABLE(SVG)
+#include "CachedSVGDocument.h"
+#endif
+#include "FilterOperation.h"
 #include "LayoutTypes.h"
 #include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h>
@@ -53,6 +57,11 @@ typedef HashMap<const RenderLayer*, RenderLayerFilterInfo*> RenderLayerFilterInf
 class RenderLayerFilterInfo
 #if ENABLE(CSS_SHADERS)
     : public CustomFilterProgramClient
+#if ENABLE(SVG)
+    , public CachedSVGDocumentClient
+#endif
+#elif ENABLE(SVG)
+    : public CachedSVGDocumentClient
 #endif
 {
 public:
@@ -75,7 +84,12 @@ public:
     void removeCustomFilterClients();
 #endif
 
-    
+#if ENABLE(SVG)
+    void updateReferenceFilterClients(const FilterOperations&);
+    virtual void notifyFinished(CachedResource*);
+    void removeReferenceFilterClients();
+#endif
+
 private:
     RenderLayerFilterInfo(RenderLayer*);
     ~RenderLayerFilterInfo();
@@ -91,6 +105,10 @@ private:
 #endif
     
     static RenderLayerFilterInfoMap* s_filterMap;
+#if ENABLE(SVG)
+    Vector<RefPtr<Element> > m_internalSVGReferences;
+    Vector<CachedResourceHandle<CachedSVGDocument> > m_externalSVGReferences;
+#endif
 };
 
 } // namespace WebCore
index 3e223ed..51858e5 100644 (file)
@@ -22,6 +22,7 @@
 #if ENABLE(SVG)
 #include "RenderSVGResourceContainer.h"
 
+#include "RenderLayer.h"
 #include "RenderSVGRoot.h"
 #include "RenderView.h"
 #include "SVGRenderingContext.h"
@@ -91,7 +92,7 @@ void RenderSVGResourceContainer::idChanged()
 
 void RenderSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode mode)
 {
-    if (m_clients.isEmpty() || m_isInvalidating)
+    if ((m_clients.isEmpty() && m_clientLayers.isEmpty()) || m_isInvalidating)
         return;
 
     m_isInvalidating = true;
@@ -111,6 +112,13 @@ void RenderSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode
 
         RenderSVGResource::markForLayoutAndParentResourceInvalidation(client, needsLayout);
     }
+
+#if ENABLE(CSS_FILTERS)
+    HashSet<RenderLayer*>::iterator layerEnd = m_clientLayers.end();
+    for (HashSet<RenderLayer*>::iterator it = m_clientLayers.begin(); it != layerEnd; ++it)
+        (*it)->filterNeedsRepaint();
+#endif
+
     m_isInvalidating = false;
 }
 
@@ -145,6 +153,18 @@ void RenderSVGResourceContainer::removeClient(RenderObject* client)
     m_clients.remove(client);
 }
 
+void RenderSVGResourceContainer::addClientRenderLayer(RenderLayer* client)
+{
+    ASSERT(client);
+    m_clientLayers.add(client);
+}
+
+void RenderSVGResourceContainer::removeClientRenderLayer(RenderLayer* client)
+{
+    ASSERT(client);
+    m_clientLayers.remove(client);
+}
+
 void RenderSVGResourceContainer::registerResource()
 {
     SVGDocumentExtensions* extensions = svgExtensionsFromNode(node());
index 1e8e62d..0f07486 100644 (file)
@@ -26,6 +26,8 @@
 
 namespace WebCore {
 
+class RenderLayer;
+
 class RenderSVGResourceContainer : public RenderSVGHiddenContainer,
                                    public RenderSVGResource {
 public:
@@ -42,6 +44,8 @@ public:
     static AffineTransform transformOnNonScalingStroke(RenderObject*, const AffineTransform& resourceTransform);
 
     void idChanged();
+    void addClientRenderLayer(RenderLayer*);
+    void removeClientRenderLayer(RenderLayer*);
 
 protected:
     enum InvalidationMode {
@@ -68,6 +72,7 @@ private:
     bool m_registered : 1;
     bool m_isInvalidating : 1;
     HashSet<RenderObject*> m_clients;
+    HashSet<RenderLayer*> m_clientLayers;
 };
 
 inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(Document* document, const AtomicString& id)
index d5d792d..e6f755c 100644 (file)
@@ -38,7 +38,6 @@
 #include "Page.h"
 #include "RenderSVGResource.h"
 #include "RenderSVGResourceFilterPrimitive.h"
-#include "Settings.h"
 #include "SVGElement.h"
 #include "SVGFilter.h"
 #include "SVGFilterElement.h"
@@ -47,6 +46,9 @@
 #include "SVGRenderingContext.h"
 #include "SVGStyledElement.h"
 #include "SVGUnitTypes.h"
+#include "Settings.h"
+#include "SourceAlpha.h"
+#include "SourceGraphic.h"
 
 #include <wtf/UnusedParam.h>
 #include <wtf/Vector.h>
@@ -101,7 +103,7 @@ PassRefPtr<SVGFilterBuilder> RenderSVGResourceFilter::buildPrimitives(SVGFilter*
     FloatRect targetBoundingBox = filter->targetBoundingBox();
 
     // Add effects to the builder
-    RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(filter);
+    RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(SourceGraphic::create(filter), SourceAlpha::create(filter));
     for (Node* node = filterElement->firstChild(); node; node = node->nextSibling()) {
         if (!node->isSVGElement())
             continue;
index 605cc74..8ad1ec7 100644 (file)
 
 namespace WebCore {
 
-SVGFilterBuilder::SVGFilterBuilder(Filter* filter)
+SVGFilterBuilder::SVGFilterBuilder(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha)
 {
-    m_builtinEffects.add(SourceGraphic::effectName(), SourceGraphic::create(filter));
-    m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create(filter));
+    m_builtinEffects.add(SourceGraphic::effectName(), sourceGraphic);
+    m_builtinEffects.add(SourceAlpha::effectName(), sourceAlpha);
     addBuiltinEffects();
 }
 
index 713241c..44d3227 100644 (file)
@@ -37,7 +37,7 @@ class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> {
 public:
     typedef HashSet<FilterEffect*> FilterEffectSet;
 
-    static PassRefPtr<SVGFilterBuilder> create(Filter* filter) { return adoptRef(new SVGFilterBuilder(filter)); }
+    static PassRefPtr<SVGFilterBuilder> create(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha) { return adoptRef(new SVGFilterBuilder(sourceGraphic, sourceAlpha)); }
 
     void add(const AtomicString& id, PassRefPtr<FilterEffect>);
 
@@ -60,7 +60,7 @@ public:
     void clearResultsRecursive(FilterEffect*);
 
 private:
-    SVGFilterBuilder(Filter*);
+    SVGFilterBuilder(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha);
 
     inline void addBuiltinEffects()
     {