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)
commite00f3facc0733da51d49531deccb6d55dce6e2f3
tree1fd448564a034732e8f7ae58da54b17a559fda50
parentf191959f08084db423dfb2908213175835fa414e
Source/WebCore: 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.

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: https://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