Make SVGUseElement respect & support externalResourcesRequired
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 16:59:16 +0000 (16:59 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 16:59:16 +0000 (16:59 +0000)
commit2dce2cc4cf87fcf6a597fe89d374ad01007bc5a8
tree6ab3049c3f58a48ce05733b5abe9a909d37f7691
parent7866cbf9a8ae790760348f2b01bb67c6230085bd
Make SVGUseElement respect & support externalResourcesRequired
https://bugs.webkit.org/show_bug.cgi?id=81109

Reviewed by Rob Buis.

Source/WebCore:

Generalize the existing externalResourcesRequired support from SVGScriptElement
into SVGExternalResourcesRequired, so it can be shared with SVGUseElement, which
was lacking proper externalResourcesRequired support.

<use xlink:href="external.svg" onload="alert('hi')" externalResourcesRequired="true"/>
The onload handler now fires _after_ the external resources loaded, making it possible
to write reliable tests that switch from internal to external resources or the other
way around. Converted the new tests in svg/dynamic-updates/SVGUseElement* to listen
to SVGLoad events, to make them reliable.

We may be able to generalize this to cover SVGImageElement as well (the only other class which
is currently supporting externalResourcesRequired - but that's more involved, so I left it TODO).

Covered by existing tests and the changes to the new SVGUseElement tests.

* svg/SVGElement.h:
(SVGElement): Make haveLoadedRequiredResources() public so SVGExternalResourcesRequired can call it.
* svg/SVGExternalResourcesRequired.cpp: Refactored code from SVGScriptElement, 1:1 copies w/o changes.
(WebCore::SVGExternalResourcesRequired::handleAttributeChange):
(WebCore::SVGExternalResourcesRequired::dispatchLoadEvent):
(WebCore::SVGExternalResourcesRequired::insertedIntoDocument):
(WebCore::SVGExternalResourcesRequired::finishParsingChildren):
(WebCore::SVGExternalResourcesRequired::haveLoadedRequiredResources):
* svg/SVGExternalResourcesRequired.h: Add new virtual functions, that must be available in classes that inherit from SVGExternalResourcesRequired.
(WebCore::SVGExternalResourcesRequired::setHaveFiredLoadEvent):
(WebCore::SVGExternalResourcesRequired::isParserInserted):
(WebCore::SVGExternalResourcesRequired::haveFiredLoadEvent):
* svg/SVGScriptElement.cpp: Refactored externalResourcesRequired handling into SVGExternalResourcesRequired.
(WebCore::SVGScriptElement::svgAttributeChanged):
(WebCore::SVGScriptElement::insertedIntoDocument):
(WebCore::SVGScriptElement::finishParsingChildren):
* svg/SVGScriptElement.h: Ditto.
(WebCore::SVGScriptElement::haveLoadedRequiredResources):
(WebCore::SVGScriptElement::dispatchLoadEvent):
(WebCore::SVGScriptElement::setHaveFiredLoadEvent):
(WebCore::SVGScriptElement::isParserInserted):
(WebCore::SVGScriptElement::haveFiredLoadEvent):
* svg/SVGTests.cpp: Fix obvious typo, that leads to an assertion. Always return true if we know the attributeName.
(WebCore::SVGTests::handleAttributeChange):
* svg/SVGTests.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::insertedIntoDocument): Remove ambigous call warning.
* svg/SVGUseElement.cpp: Support externalResourcesRequired="true/false" + dynamic changes of it. Covered by existing tests.
(WebCore::SVGUseElement::SVGUseElement):
(WebCore::SVGUseElement::create):
(WebCore::SVGUseElement::insertedIntoDocument):
(WebCore::SVGUseElement::svgAttributeChanged):
(WebCore::SVGUseElement::notifyFinished):
(WebCore::SVGUseElement::finishParsingChildren):
(WebCore):
* svg/SVGUseElement.h: Ditto.
(WebCore::SVGUseElement::haveLoadedRequiredResources):
(WebCore::SVGUseElement::setHaveFiredLoadEvent):
(WebCore::SVGUseElement::isParserInserted):
(WebCore::SVGUseElement::haveFiredLoadEvent):
* svg/svgtags.in: Pass "bool wasInsertedByParser" to SVGUseElement constructor.

LayoutTests:

Fix flakiness of new external <use> tests introduced in r110676.

* platform/mac/svg/batik/masking/maskRegions-expected.png:
* platform/mac/svg/dynamic-updates/SVGUseElement-dom-href2-attr-expected.png:
* platform/mac/svg/dynamic-updates/SVGUseElement-svgdom-href2-prop-expected.png:
* svg/dynamic-updates/SVGUseElement-dom-href2-attr-expected.txt:
* svg/dynamic-updates/SVGUseElement-svgdom-href2-prop-expected.txt:
* svg/dynamic-updates/script-tests/SVGUseElement-dom-href1-attr.js:
(repaintTest):
* svg/dynamic-updates/script-tests/SVGUseElement-dom-href2-attr.js:
(repaintTest):
(externalLoadDone):
* svg/dynamic-updates/script-tests/SVGUseElement-svgdom-href1-prop.js:
(repaintTest):
* svg/dynamic-updates/script-tests/SVGUseElement-svgdom-href2-prop.js:
(repaintTest):
(externalLoadDone):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/batik/masking/maskRegions-expected.png
LayoutTests/platform/mac/svg/dynamic-updates/SVGUseElement-dom-href2-attr-expected.png
LayoutTests/platform/mac/svg/dynamic-updates/SVGUseElement-svgdom-href2-prop-expected.png
LayoutTests/svg/dynamic-updates/SVGUseElement-dom-href2-attr-expected.txt
LayoutTests/svg/dynamic-updates/SVGUseElement-svgdom-href2-prop-expected.txt
LayoutTests/svg/dynamic-updates/script-tests/SVGUseElement-dom-href1-attr.js
LayoutTests/svg/dynamic-updates/script-tests/SVGUseElement-dom-href2-attr.js
LayoutTests/svg/dynamic-updates/script-tests/SVGUseElement-svgdom-href1-prop.js
LayoutTests/svg/dynamic-updates/script-tests/SVGUseElement-svgdom-href2-prop.js
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGExternalResourcesRequired.cpp
Source/WebCore/svg/SVGExternalResourcesRequired.h
Source/WebCore/svg/SVGScriptElement.cpp
Source/WebCore/svg/SVGScriptElement.h
Source/WebCore/svg/SVGTests.cpp
Source/WebCore/svg/SVGTests.h
Source/WebCore/svg/SVGTextPathElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h
Source/WebCore/svg/svgtags.in