feImage doesn't invalidate when its target SVG element is animated
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 12:12:31 +0000 (12:12 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 12:12:31 +0000 (12:12 +0000)
commit65f0a9211036019fb70b5b7f1ac77c481dbfe2f4
tree4646695dd14e149170a588e808550edc6ad8cb29
parent511af948af5805ee6bc9bd7d34665033d0072240
feImage doesn't invalidate when its target SVG element is animated
https://bugs.webkit.org/show_bug.cgi?id=73860

Reviewed by Dirk Schulze.

Source/WebCore:

Consider following testcase:
<defs>
    <rect id="rect" fill="red" width="50" height="50"/>
    <filter id="filter">
        <feImage xlink:href="#rect"/>
    </filter>
</defs>
<rect width="50" height="50" filter="url(#filter)"/>

If the <rect id="rect"> gets changed dynamically (attribute/property/style change) the <feImage>
doesn't notice this, as there's no link between the <rect> and the <feImage>, as the <rect> is not
a child of the <feImage/>. To get invalidations working for these situations, we have to track
the referencingElement & referencedElement in SVGDocumentExtensions.

Fixes parts the SVG-Wow twirl testcase and David Daileys SVG waves example.

Tests: svg/filters/feImage-animated-transform-on-target-rect.svg
       svg/filters/feImage-late-indirect-update.svg
       svg/filters/feImage-mutliple-targets-id-change.svg
       svg/filters/feImage-target-attribute-change-with-use-indirection-2.svg
       svg/filters/feImage-target-attribute-change-with-use-indirection.svg
       svg/filters/feImage-target-attribute-change.svg
       svg/filters/feImage-target-inline-style-change.svg
       svg/filters/feImage-target-property-change.svg
       svg/filters/feImage-target-style-change.svg

* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromFilterCacheAndInvalidateDependencies): Renamed from removeFromFilterCache, as it has another purpose now.
(WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation): s/removeFromFilterCache/removeFromFilterCacheAndInvalidateDependencies/.
* rendering/svg/RenderSVGResource.h: Removed removeFromFilterCache, it got inlined.
* svg/SVGDocumentExtensions.cpp: Add a new HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > > used for dependency tracking.
(WebCore::SVGDocumentExtensions::setOfElementsReferencingTarget): Returns all elements the passed in element depends on.
(WebCore::SVGDocumentExtensions::addElementReferencingTarget): Register element 'a' referencing target 'b'.
(WebCore::SVGDocumentExtensions::removeAllTargetReferencesForElement): Called by element 'a' on destruction or any target change.
(WebCore::SVGDocumentExtensions::removeAllElementReferencesForTarget): Called by element 'b' on destruction.
* svg/SVGDocumentExtensions.h: Expose new methods.
* svg/SVGElement.cpp:
(WebCore::SVGElement::~SVGElement): Call remove removeAllElementReferencesForTarget on destruction.
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::clearResourceReferences):
(WebCore::SVGFEImageElement::buildPendingResource):

LayoutTests:

Add lots of new testcases covering <feImage> invalidation, when the referenced target changes.
Thanks to the repaint harness, it uncovered a bug with feImage-late-indirect-update.svg - there no gray
overlay rects are visible, as the whole screen gets repainted, which is a bug!

* platform/mac/svg/filters/feImage-animated-transform-on-target-rect-expected.png: Added.
* platform/mac/svg/filters/feImage-change-target-id-expected.png: Added.
* platform/mac/svg/filters/feImage-change-target-id-expected.txt: Added.
* platform/mac/svg/filters/feImage-late-indirect-update-expected.png: Added.
* platform/mac/svg/filters/feImage-late-indirect-update-expected.txt: Added.
* platform/mac/svg/filters/feImage-multiple-targets-id-change-expected.png: Added.
* platform/mac/svg/filters/feImage-multiple-targets-id-change-expected.txt: Added.
* platform/mac/svg/filters/feImage-remove-target-expected.png: Added.
* platform/mac/svg/filters/feImage-remove-target-expected.txt: Added.
* platform/mac/svg/filters/feImage-target-add-to-document-expected.png: Renamed from LayoutTests/svg/filters/feImage-target-add-to-document-expected.png.
* platform/mac/svg/filters/feImage-target-add-to-document-expected.txt: Copied from LayoutTests/svg/filters/feImage-target-add-to-document-expected.txt.
* platform/mac/svg/filters/feImage-target-attribute-change-expected.png: Added.
* platform/mac/svg/filters/feImage-target-attribute-change-expected.txt: Copied from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt.
* platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-2-expected.png: Added.
* platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-2-expected.txt: Added.
* platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-expected.png: Added.
* platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-expected.txt: Added.
* platform/mac/svg/filters/feImage-target-changes-id-expected.png: Renamed from LayoutTests/svg/filters/feImage-target-changes-id-expected.png.
* platform/mac/svg/filters/feImage-target-changes-id-expected.txt: Copied from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt.
* platform/mac/svg/filters/feImage-target-id-change-expected.png: Renamed from LayoutTests/svg/filters/feImage-target-id-change-expected.png.
* platform/mac/svg/filters/feImage-target-id-change-expected.txt: Renamed from LayoutTests/svg/filters/feImage-target-id-change-expected.txt.
* platform/mac/svg/filters/feImage-target-inline-style-change-expected.png: Added.
* platform/mac/svg/filters/feImage-target-inline-style-change-expected.txt: Copied from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt.
* platform/mac/svg/filters/feImage-target-property-change-expected.png: Added.
* platform/mac/svg/filters/feImage-target-property-change-expected.txt: Copied from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt.
* platform/mac/svg/filters/feImage-target-reappend-to-document-expected.png: Renamed from LayoutTests/svg/filters/feImage-target-reappend-to-document-expected.png.
* platform/mac/svg/filters/feImage-target-reappend-to-document-expected.txt: Renamed from LayoutTests/svg/filters/feImage-target-reappend-to-document-expected.txt.
* platform/mac/svg/filters/feImage-target-remove-from-document-expected.png: Renamed from LayoutTests/svg/filters/feImage-target-remove-from-document-expected.png.
* platform/mac/svg/filters/feImage-target-remove-from-document-expected.txt: Renamed from LayoutTests/svg/filters/feImage-target-remove-from-document-expected.txt.
* platform/mac/svg/filters/feImage-target-style-change-expected.png: Added.
* platform/mac/svg/filters/feImage-target-style-change-expected.txt: Renamed from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt.
* svg/filters/feImage-animated-transform-on-target-rect-expected.txt: Added.
* svg/filters/feImage-animated-transform-on-target-rect.svg: Added.
* svg/filters/feImage-change-target-id.svg: Added.
* svg/filters/feImage-late-indirect-update.svg: Added.
* svg/filters/feImage-multiple-targets-id-change.svg: Added.
* svg/filters/feImage-remove-target.svg: Added.
* svg/filters/feImage-target-attribute-change-with-use-indirection-2.svg: Added.
* svg/filters/feImage-target-attribute-change-with-use-indirection.svg: Added.
* svg/filters/feImage-target-attribute-change.svg: Added.
* svg/filters/feImage-target-inline-style-change.svg: Added.
* svg/filters/feImage-target-property-change.svg: Added.
* svg/filters/feImage-target-style-change.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
52 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/filters/feImage-animated-transform-on-target-rect-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-change-target-id-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-change-target-id-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-late-indirect-update-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-late-indirect-update-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-multiple-targets-id-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-multiple-targets-id-change-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-remove-target-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-remove-target-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-add-to-document-expected.png [moved from LayoutTests/svg/filters/feImage-target-add-to-document-expected.png with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-add-to-document-expected.txt [moved from LayoutTests/svg/filters/feImage-target-add-to-document-expected.txt with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-expected.png [moved from LayoutTests/svg/filters/feImage-target-changes-id-expected.png with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-expected.txt [moved from LayoutTests/svg/filters/feImage-target-changes-id-expected.txt with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-2-expected.png [moved from LayoutTests/svg/filters/feImage-target-id-change-expected.png with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-expected.png [moved from LayoutTests/svg/filters/feImage-target-reappend-to-document-expected.png with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-attribute-change-with-use-indirection-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-changes-id-expected.png [moved from LayoutTests/svg/filters/feImage-target-remove-from-document-expected.png with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-changes-id-expected.txt [moved from LayoutTests/svg/filters/feImage-target-id-change-expected.txt with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-id-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-id-change-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-inline-style-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-inline-style-change-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-property-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-property-change-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-reappend-to-document-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-reappend-to-document-expected.txt [moved from LayoutTests/svg/filters/feImage-target-reappend-to-document-expected.txt with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-remove-from-document-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-remove-from-document-expected.txt [moved from LayoutTests/svg/filters/feImage-target-remove-from-document-expected.txt with 100% similarity]
LayoutTests/platform/mac/svg/filters/feImage-target-style-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/filters/feImage-target-style-change-expected.txt [new file with mode: 0644]
LayoutTests/svg/filters/feImage-animated-transform-on-target-rect-expected.txt [new file with mode: 0644]
LayoutTests/svg/filters/feImage-animated-transform-on-target-rect.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-change-target-id.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-late-indirect-update.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-multiple-targets-id-change.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-remove-target.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-attribute-change-with-use-indirection-2.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-attribute-change-with-use-indirection.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-attribute-change.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-inline-style-change.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-property-change.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-target-style-change.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResource.cpp
Source/WebCore/rendering/svg/RenderSVGResource.h
Source/WebCore/svg/SVGDocumentExtensions.cpp
Source/WebCore/svg/SVGDocumentExtensions.h
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGFEImageElement.cpp