Incorrect handling of chained pending resources in SVGUseElement
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2012 12:26:03 +0000 (12:26 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2012 12:26:03 +0000 (12:26 +0000)
commit29a814d9ba945ab6f0fd0fd170840974caedecbe
treeea0755b5614f1fa8eda4b9c3b2fcaa2862ea778e
parentc8d72081a56bbdf6d840d2c1a5289af34573b68b
Incorrect handling of chained pending resources in SVGUseElement
https://bugs.webkit.org/show_bug.cgi?id=89686

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Currently SVGUseElement builds the shadow tree when the target first
becomes available. This is normally OK, but if the target itself (or
one of its children) is a <use> element with pending resources, then
the shadow expansion only captures the current state of the tree and
never gets updated when the pending resource becomes available.

In order to support arbitrary <use>-on-<use> constructs, this patch
tracks nested <use> dependencies and rebuilds the dependent trees
whenever the target gets updated.

Tests: svg/custom/use-nested-expected.svg
       svg/custom/use-nested.svg

* svg/SVGElement.cpp:
(WebCore::SVGElement::removedFrom): removedFrom needs to be called up the inheritance chain
before invoking removeAllElementReferencesForTarget. Otherwise we could end up finding the
element being removed as a valid target in SVGUseElement::buildInstanceTree because its
InDocument flag is not cleared yet.
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::~SVGUseElement):
(WebCore::SVGUseElement::clearResourceReferences):
(WebCore::SVGUseElement::buildPendingResource):
(WebCore::SVGUseElement::buildShadowAndInstanceTree):
(WebCore::SVGUseElement::buildInstanceTree):
* svg/SVGUseElement.h:
(SVGUseElement):
Track <use> -> <use> dependencies using SVGDocumentExtensions'
m_elementDependencies framework and ensure dependent trees are rebuilt
when the target itself gets rebuilt.

LayoutTests:

Added reftest to verify that nested/indirect <use> constructs are
handled correctly WRT pending resource tracking.

Also updated the svg/hixie/error/017-expected.txt to match the current
results. Per comments in SVGUseElement::buildShadowAndInstanceTree, the
new behavior is correct: <use> cycles are to be ignored.

* platform/chromium-win/svg/hixie/error/017-expected.txt:
* platform/efl/svg/hixie/error/017-expected.txt:
* platform/gtk/svg/hixie/error/017-expected.txt:
* platform/mac/svg/hixie/error/017-expected.txt:
* platform/qt/svg/hixie/error/017-expected.txt:
* svg/custom/use-nested-expected.svg: Added.
* svg/custom/use-nested.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-win/svg/hixie/error/017-expected.txt
LayoutTests/platform/efl/svg/hixie/error/017-expected.txt
LayoutTests/platform/gtk/svg/hixie/error/017-expected.txt
LayoutTests/platform/mac/svg/hixie/error/017-expected.txt
LayoutTests/platform/qt/svg/hixie/error/017-expected.txt
LayoutTests/svg/custom/use-nested-expected.svg [new file with mode: 0644]
LayoutTests/svg/custom/use-nested.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h