SVG use element inside a shadow tree cannot reference an element in the same tree
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2018 22:48:08 +0000 (22:48 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2018 22:48:08 +0000 (22:48 +0000)
commit8295d67e23d64482ef254bc586d2bc59ee088556
tree40128199aa0a5cdb3fefd97bd6321b2ff8a18ceb
parent6a324d9d68775d9ce9510f17b166542cb1f2acd8
SVG use element inside a shadow tree cannot reference an element in the same tree
https://bugs.webkit.org/show_bug.cgi?id=174977
<rdar://problem/33665636>

Reviewed by Zalan Bujtas.

Source/WebCore:

Make fragment URL references used by SVGelements within a shadow tree to refer to other elements
in the same shadow tree. To do this, this patch makes targetElementFromIRIString take a TreeScope
instead of a Document, and updates its call sites.

This patch updates the most uses of targetElementFromIRIString except CSS cursor image, altGraph,
and glyphRef since the cursor image isn't really a SVG feature, and there aren't really real world
use cases in which altGraph and glyphRef are used within shadow trees.

Tests: fast/shadow-dom/svg-animate-href-change-in-shadow-tree.html
       fast/shadow-dom/svg-animate-href-in-shadow-tree.html
       fast/shadow-dom/svg-feimage-href-in-shadow-tree.html
       fast/shadow-dom/svg-linear-gradient-href-in-shadow-tree.html
       fast/shadow-dom/svg-mpath-href-change-in-shadow-tree.html
       fast/shadow-dom/svg-mpath-href-in-shadow-tree.html
       fast/shadow-dom/svg-radial-gradient-href-in-shadow-tree.html
       fast/shadow-dom/svg-text-path-href-change-in-shadow-tree.html
       fast/shadow-dom/svg-text-path-href-in-shadow-tree.html
       fast/shadow-dom/svg-thref-href-change-in-shadow-tree.html
       fast/shadow-dom/svg-thref-href-in-shadow-tree.html
       fast/shadow-dom/svg-use-href-change-in-shadow-tree.html
       fast/shadow-dom/svg-use-href-in-shadow-tree.html

* accessibility/AccessibilitySVGElement.cpp:
(WebCore::AccessibilitySVGElement::targetForUseElement const):
* css/CSSCursorImageValue.cpp:
* rendering/svg/RenderSVGTextPath.cpp:
(WebCore::RenderSVGTextPath::layoutPath const):
* svg/SVGAltGlyphElement.cpp:
(WebCore::SVGAltGlyphElement::hasValidGlyphElements const):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::buildPendingResource):
(WebCore::SVGFEImageElement::build):
* svg/SVGGlyphRefElement.cpp:
(WebCore::SVGGlyphRefElement::hasValidGlyphElement const):
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::collectGradientAttributes):
* svg/SVGMPathElement.cpp:
(WebCore::SVGMPathElement::buildPendingResource):
(WebCore::SVGMPathElement::pathElement):
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::collectGradientAttributes):
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::buildPendingResource):
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::buildPendingResource):
* svg/SVGURIReference.cpp:
(WebCore::SVGURIReference::targetElementFromIRIString):
* svg/SVGURIReference.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::updateShadowTree):
(WebCore::SVGUseElement::findTarget const):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::buildPendingResource):
(WebCore::SVGSMILElement::insertedIntoAncestor):
* svg/graphics/filters/SVGFEImage.cpp:
(WebCore::FEImage::FEImage):
(WebCore::FEImage::createWithIRIReference):
(WebCore::FEImage::referencedRenderer const):
* svg/graphics/filters/SVGFEImage.h:

LayoutTests:

Added tests for specifying a fragment URL to refer to other elements within shadow trees.

This patch doesn't add a test for updating a fragment URL of linearGradient and radialGradient
since it doesn't work at all even outside shadow trees. See webkit.org/b/191934.

* fast/shadow-dom/svg-animate-href-change-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-animate-href-change-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-animate-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-animate-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-feimage-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-feimage-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-linear-gradient-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-linear-gradient-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-mpath-href-change-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-mpath-href-change-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-mpath-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-mpath-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-radial-gradient-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-radial-gradient-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-text-path-href-change-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-text-path-href-change-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-text-path-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-text-path-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-thref-href-change-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-thref-href-change-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-thref-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-thref-href-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-use-href-change-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-use-href-change-in-shadow-tree.html: Added.
* fast/shadow-dom/svg-use-href-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/svg-use-href-in-shadow-tree.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238524 268f45cc-cd09-0410-ab3c-d52691b4dbfc
45 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/svg-animate-href-change-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-animate-href-change-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-animate-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-animate-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-feimage-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-feimage-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-linear-gradient-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-linear-gradient-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-mpath-href-change-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-mpath-href-change-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-mpath-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-mpath-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-radial-gradient-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-radial-gradient-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-text-path-href-change-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-text-path-href-change-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-text-path-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-text-path-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-thref-href-change-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-thref-href-change-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-thref-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-thref-href-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-use-href-change-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-use-href-change-in-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-use-href-in-shadow-tree-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/svg-use-href-in-shadow-tree.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilitySVGElement.cpp
Source/WebCore/css/CSSCursorImageValue.cpp
Source/WebCore/rendering/svg/RenderSVGTextPath.cpp
Source/WebCore/svg/SVGAltGlyphElement.cpp
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGGlyphRefElement.cpp
Source/WebCore/svg/SVGLinearGradientElement.cpp
Source/WebCore/svg/SVGMPathElement.cpp
Source/WebCore/svg/SVGRadialGradientElement.cpp
Source/WebCore/svg/SVGTRefElement.cpp
Source/WebCore/svg/SVGTextPathElement.cpp
Source/WebCore/svg/SVGURIReference.cpp
Source/WebCore/svg/SVGURIReference.h
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/svg/graphics/filters/SVGFEImage.cpp
Source/WebCore/svg/graphics/filters/SVGFEImage.h