[SVG] fragment-only url 'url(#fragment)' should be resolved against the current docum...
authorHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Sep 2019 01:55:27 +0000 (01:55 +0000)
committerHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Sep 2019 01:55:27 +0000 (01:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189499
<rdar://problem/44466206>

Reviewed by Said Abou-Hallawa.

Source/WebCore:

Fragment-only URL 'url(#fragment)' should be resolved against the
current document even if HTML <base> element is specified.
Spec: <https://drafts.csswg.org/css-values/#local-urls>

Tests: css3/filters/effect-reference-local-url-with-base.html
       css3/masking/clip-path-reference-local-url-with-base.html
       http/tests/svg/local-url-with-valid-base-and-resource.html
       svg/animations/local-url-target-reference.html
       svg/custom/local-url-reference-clip-path.html
       svg/custom/local-url-reference-fill.html
       svg/custom/local-url-reference-filter.html
       svg/custom/local-url-reference-marker.html
       svg/custom/local-url-reference-mask.html
       svg/custom/local-url-reference-pattern.html
       svg/custom/local-url-reference-radial-gradient.html
       svg/custom/local-url-reference-srcdoc.html
       svg/custom/local-url-reference-stroke.html
       svg/custom/local-url-reference-use.html
       svg/text/textpath-local-url-reference.html

* svg/SVGURIReference.cpp:
(WebCore::SVGURIReference::fragmentIdentifierFromIRIString): Return the fragment if the URL starts with '#'.

LayoutTests:

These test cases are imported from Blink's commit, and modified for WebKit.
<https://chromium.googlesource.com/chromium/src/+/e7d7225c33aa7fc42ee390125b01df9167fad106%5E%21/>

* TestExpectations:
* css3/filters/effect-reference-local-url-with-base-expected.html: Added.
* css3/filters/effect-reference-local-url-with-base.html: Added.
* css3/filters/effect-reference.html:
* css3/masking/clip-path-reference-local-url-with-base-expected.html: Added.
* css3/masking/clip-path-reference-local-url-with-base.html: Added.
* http/tests/svg/local-url-with-valid-base-and-resource-expected.html: Added.
* http/tests/svg/local-url-with-valid-base-and-resource.html: Added.
* http/tests/svg/resources/red100x100.svg: Added.
* platform/gtk/TestExpectations: Marked svg/custom/local-url-reference-marker.html as ImageOnlyFailure for Bug 113849.
* platform/wpe/TestExpectations: Ditto.
* svg/animations/local-url-target-reference-expected.html: Added.
* svg/animations/local-url-target-reference.html: Added.
* svg/custom/linking-base-external-reference-expected.txt: Removed. This was a test for old spec.
* svg/custom/linking-base-external-reference.xhtml: Ditto.
* svg/custom/local-url-reference-clip-path-expected.html: Added.
* svg/custom/local-url-reference-clip-path.html: Added.
* svg/custom/local-url-reference-fill-expected.html: Added.
* svg/custom/local-url-reference-fill.html: Added.
* svg/custom/local-url-reference-filter-expected.html: Added.
* svg/custom/local-url-reference-filter.html: Added.
* svg/custom/local-url-reference-marker-expected.html: Added.
* svg/custom/local-url-reference-marker.html: Added.
* svg/custom/local-url-reference-mask-expected.html: Added.
* svg/custom/local-url-reference-mask.html: Added.
* svg/custom/local-url-reference-pattern-expected.html: Added.
* svg/custom/local-url-reference-pattern.html: Added.
* svg/custom/local-url-reference-radial-gradient-expected.html: Added.
* svg/custom/local-url-reference-radial-gradient.html: Added.
* svg/custom/local-url-reference-srcdoc-expected.html: Added.
* svg/custom/local-url-reference-srcdoc.html: Added.
* svg/custom/local-url-reference-stroke-expected.html: Added.
* svg/custom/local-url-reference-stroke.html: Added.
* svg/custom/local-url-reference-use-expected.html: Added.
* svg/custom/local-url-reference-use.html: Added.
* svg/text/textpath-local-url-reference-expected.html: Added.
* svg/text/textpath-local-url-reference.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/effect-reference-local-url-with-base-expected.html [new file with mode: 0644]
LayoutTests/css3/filters/effect-reference-local-url-with-base.html [new file with mode: 0644]
LayoutTests/css3/masking/clip-path-reference-local-url-with-base-expected.html [new file with mode: 0644]
LayoutTests/css3/masking/clip-path-reference-local-url-with-base.html [new file with mode: 0644]
LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource-expected.html [new file with mode: 0644]
LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource.html [new file with mode: 0644]
LayoutTests/http/tests/svg/resources/red100x100.svg [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/wpe/TestExpectations
LayoutTests/svg/animations/local-url-target-reference-expected.html [new file with mode: 0644]
LayoutTests/svg/animations/local-url-target-reference.html [new file with mode: 0644]
LayoutTests/svg/custom/linking-base-external-reference-expected.txt [deleted file]
LayoutTests/svg/custom/linking-base-external-reference.xhtml [deleted file]
LayoutTests/svg/custom/local-url-reference-clip-path-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-clip-path.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-fill-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-fill.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-filter-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-filter.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-marker-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-marker.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-mask-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-mask.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-pattern-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-pattern.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-radial-gradient-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-radial-gradient.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-srcdoc-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-srcdoc.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-stroke-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-stroke.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-use-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/local-url-reference-use.html [new file with mode: 0644]
LayoutTests/svg/text/textpath-local-url-reference-expected.html [new file with mode: 0644]
LayoutTests/svg/text/textpath-local-url-reference.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGURIReference.cpp

index 76e49fe..dd4226b 100644 (file)
@@ -1,3 +1,52 @@
+2019-09-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [SVG] fragment-only url 'url(#fragment)' should be resolved against the current document with regardless to HTML <base> element
+        https://bugs.webkit.org/show_bug.cgi?id=189499
+        <rdar://problem/44466206>
+
+        Reviewed by Said Abou-Hallawa.
+
+        These test cases are imported from Blink's commit, and modified for WebKit.
+        <https://chromium.googlesource.com/chromium/src/+/e7d7225c33aa7fc42ee390125b01df9167fad106%5E%21/>
+
+        * TestExpectations:
+        * css3/filters/effect-reference-local-url-with-base-expected.html: Added.
+        * css3/filters/effect-reference-local-url-with-base.html: Added.
+        * css3/filters/effect-reference.html:
+        * css3/masking/clip-path-reference-local-url-with-base-expected.html: Added.
+        * css3/masking/clip-path-reference-local-url-with-base.html: Added.
+        * http/tests/svg/local-url-with-valid-base-and-resource-expected.html: Added.
+        * http/tests/svg/local-url-with-valid-base-and-resource.html: Added.
+        * http/tests/svg/resources/red100x100.svg: Added.
+        * platform/gtk/TestExpectations: Marked svg/custom/local-url-reference-marker.html as ImageOnlyFailure for Bug 113849.
+        * platform/wpe/TestExpectations: Ditto.
+        * svg/animations/local-url-target-reference-expected.html: Added.
+        * svg/animations/local-url-target-reference.html: Added.
+        * svg/custom/linking-base-external-reference-expected.txt: Removed. This was a test for old spec.
+        * svg/custom/linking-base-external-reference.xhtml: Ditto.
+        * svg/custom/local-url-reference-clip-path-expected.html: Added.
+        * svg/custom/local-url-reference-clip-path.html: Added.
+        * svg/custom/local-url-reference-fill-expected.html: Added.
+        * svg/custom/local-url-reference-fill.html: Added.
+        * svg/custom/local-url-reference-filter-expected.html: Added.
+        * svg/custom/local-url-reference-filter.html: Added.
+        * svg/custom/local-url-reference-marker-expected.html: Added.
+        * svg/custom/local-url-reference-marker.html: Added.
+        * svg/custom/local-url-reference-mask-expected.html: Added.
+        * svg/custom/local-url-reference-mask.html: Added.
+        * svg/custom/local-url-reference-pattern-expected.html: Added.
+        * svg/custom/local-url-reference-pattern.html: Added.
+        * svg/custom/local-url-reference-radial-gradient-expected.html: Added.
+        * svg/custom/local-url-reference-radial-gradient.html: Added.
+        * svg/custom/local-url-reference-srcdoc-expected.html: Added.
+        * svg/custom/local-url-reference-srcdoc.html: Added.
+        * svg/custom/local-url-reference-stroke-expected.html: Added.
+        * svg/custom/local-url-reference-stroke.html: Added.
+        * svg/custom/local-url-reference-use-expected.html: Added.
+        * svg/custom/local-url-reference-use.html: Added.
+        * svg/text/textpath-local-url-reference-expected.html: Added.
+        * svg/text/textpath-local-url-reference.html: Added.
+
 2019-09-01  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [WHLSL] Resources don't work when only a subset of a bind group is referenced by a shader
diff --git a/LayoutTests/css3/filters/effect-reference-local-url-with-base-expected.html b/LayoutTests/css3/filters/effect-reference-local-url-with-base-expected.html
new file mode 100644 (file)
index 0000000..8b271b4
--- /dev/null
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<svg></svg>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/css3/filters/effect-reference-local-url-with-base.html b/LayoutTests/css3/filters/effect-reference-local-url-with-base.html
new file mode 100644 (file)
index 0000000..96378df
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  background-color: red;
+  filter: url(#filter);
+}
+</style>
+<svg>
+  <filter id="filter" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
+    <feFlood flood-color="green"/>
+  </filter>
+</svg>
+<div id="target"></div>
diff --git a/LayoutTests/css3/masking/clip-path-reference-local-url-with-base-expected.html b/LayoutTests/css3/masking/clip-path-reference-local-url-with-base-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/css3/masking/clip-path-reference-local-url-with-base.html b/LayoutTests/css3/masking/clip-path-reference-local-url-with-base.html
new file mode 100644 (file)
index 0000000..3403359
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  border-right: 100px solid red;
+  background-color: green;
+  -webkit-clip-path: url(#clip);
+  clip-path: url(#clip);
+}
+</style>
+<div id="target"></div>
+<svg>
+  <clipPath id="clip">
+    <rect width="100" height="100"/>
+  </filter>
+</svg>
diff --git a/LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource-expected.html b/LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource-expected.html
new file mode 100644 (file)
index 0000000..5fc78bb
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource.html b/LayoutTests/http/tests/svg/local-url-with-valid-base-and-resource.html
new file mode 100644 (file)
index 0000000..bd782a3
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<base href="http://127.0.0.1:8000/svg/resources/red100x100.svg">
+<svg>
+  <rect id="rect" width="100" height="100" fill="green"/>
+  <use href="#rect" x="100"/>
+</svg>
diff --git a/LayoutTests/http/tests/svg/resources/red100x100.svg b/LayoutTests/http/tests/svg/resources/red100x100.svg
new file mode 100644 (file)
index 0000000..263b3af
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+  <rect id="rect" width="100" height="100" fill="red"/>
+</svg>
index 457857d..918baa4 100644 (file)
@@ -3020,6 +3020,8 @@ webkit.org/b/107825 media/audio-delete-while-step-button-clicked.html [ Failure
 webkit.org/b/107825 media/nodesFromRect-shadowContent.html [ Failure Crash ]
 webkit.org/b/107825 media/video-controls-fullscreen-volume.html [ Failure ]
 
+webkit.org/b/113849 svg/custom/local-url-reference-marker.html [ ImageOnlyFailure ]
+
 # Test marked in TestExpectations as failing on non-retina displays, passing on GTK port
 webkit.org/b/129113 fast/multicol/newmulticol/clipping.html [ Pass ]
 
index 8cfabdc..ae5b684 100644 (file)
@@ -1376,6 +1376,7 @@ webkit.org/b/135529 svg/css/parse-length.html [ Failure ]
 webkit.org/b/163831 svg/custom/acid3-test-77.html [ Failure ]
 webkit.org/b/134758 svg/custom/composited-svg-with-opacity.html [ ImageOnlyFailure Pass ]
 webkit.org/b/131347 svg/custom/hidpi-masking-clipping.svg [ Failure ImageOnlyFailure Timeout ]
+webkit.org/b/113849 svg/custom/local-url-reference-marker.html [ ImageOnlyFailure ]
 webkit.org/b/160137 svg/custom/non-scaling-stroke.svg [ Failure Pass ]
 webkit.org/b/160137 svg/custom/non-scaling-stroke-update.svg [ ImageOnlyFailure Pass ]
 webkit.org/b/112228 svg/custom/resources-css-scaled.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/svg/animations/local-url-target-reference-expected.html b/LayoutTests/svg/animations/local-url-target-reference-expected.html
new file mode 100644 (file)
index 0000000..5fc78bb
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/animations/local-url-target-reference.html b/LayoutTests/svg/animations/local-url-target-reference.html
new file mode 100644 (file)
index 0000000..1c50105
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <script>
+    var svgRoot = document.querySelector('svg');
+    svgRoot.pauseAnimations();
+    svgRoot.setCurrentTime(1);
+  </script>
+  <defs>
+    <path id="path" d="M100,0z"/>
+  </defs>
+  <rect width="100" height="100" fill="green">
+    <animateMotion dur="0.01" fill="freeze">
+      <mpath href="#path"/>
+    </animateMotion>
+  </rect>
+  <rect id="rect" width="100" height="100" fill="red"/>
+  <set attributeName="fill" href="#rect" to="green" dur="indefinite"/>
+</svg>
diff --git a/LayoutTests/svg/custom/linking-base-external-reference-expected.txt b/LayoutTests/svg/custom/linking-base-external-reference-expected.txt
deleted file mode 100644 (file)
index fb10326..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x154
-  RenderBlock {html} at (0,0) size 800x154
-    RenderInline {base} at (0,0) size 0x0
-    RenderText {#text} at (0,0) size 0x0
-    RenderText {#text} at (0,0) size 0x0
-    RenderSVGRoot {svg} at (0,0) size 100x100
-      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-        RenderSVGResourceLinearGradient {linearGradient} [id="orange_red"] [gradientUnits=objectBoundingBox] [start=(0,0)] [end=(1,0)]
-          RenderSVGGradientStop {stop} [offset=0.00] [color=#FF0000]
-          RenderSVGGradientStop {stop} [offset=1.00] [color=#FF0000]
-      RenderSVGRect {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
-    RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/svg/custom/linking-base-external-reference.xhtml b/LayoutTests/svg/custom/linking-base-external-reference.xhtml
deleted file mode 100644 (file)
index e7b3140..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <base href="http://www.example.com"/>
-  <!-- There should be no red -->
-  <svg width="100%" height="100%" version="1.1"
-       xmlns="http://www.w3.org/2000/svg" style="height: 100%">
-
-    <defs>
-      <linearGradient id="orange_red" x1="0%" y1="0%" x2="100%" y2="0%">
-        <stop offset="0%" style="stop-color:red;"/>
-        <stop offset="100%" style="stop-color:red;"/>
-      </linearGradient>
-
-    </defs>
-
-    <rect x="0" y="0" width="100" height="100" style="fill: url(#orange_red)"/>
-  </svg>
-</html>
diff --git a/LayoutTests/svg/custom/local-url-reference-clip-path-expected.html b/LayoutTests/svg/custom/local-url-reference-clip-path-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-clip-path.html b/LayoutTests/svg/custom/local-url-reference-clip-path.html
new file mode 100644 (file)
index 0000000..803a02d
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <clipPath id="clip">
+    <rect y="50" width="100" height="50"/>
+  </clipPath>
+  <rect width="100" height="50" fill="green"/>
+  <g clip-path="url(#clip)">
+    <rect width="100" height="50" fill="red"/>
+    <rect y="50" width="100" height="50" fill="green"/>
+  </g>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-fill-expected.html b/LayoutTests/svg/custom/local-url-reference-fill-expected.html
new file mode 100644 (file)
index 0000000..5fc78bb
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-fill.html b/LayoutTests/svg/custom/local-url-reference-fill.html
new file mode 100644 (file)
index 0000000..a3374c8
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+    <linearGradient id="paint">
+        <stop stop-color="green"/>
+    </linearGradient>
+    <linearGradient id="inheritedPaint" href="#paint"/>
+    <rect width="100" height="100" fill="url(#paint) red"/>
+    <rect x="100" width="100" height="100" fill="url(#inheritedPaint) red"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-filter-expected.html b/LayoutTests/svg/custom/local-url-reference-filter-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-filter.html b/LayoutTests/svg/custom/local-url-reference-filter.html
new file mode 100644 (file)
index 0000000..cb2d044
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+    <filter id="filter" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
+        <feFlood flood-color="green"/>
+    </filter>
+    <rect width="100" height="100" fill="red" filter="url(#filter)"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-marker-expected.html b/LayoutTests/svg/custom/local-url-reference-marker-expected.html
new file mode 100644 (file)
index 0000000..70e4940
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 300px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-marker.html b/LayoutTests/svg/custom/local-url-reference-marker.html
new file mode 100644 (file)
index 0000000..954a60b
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <marker id="marker" refY="0.5">
+    <rect width="1" height="1" fill="green"/>
+  </marker>
+  <polyline points="0,50 100,50 200,50" stroke="red" stroke-width="100"
+            marker-start="url(#marker)" marker-mid="url(#marker)" marker-end="url(#marker)"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-mask-expected.html b/LayoutTests/svg/custom/local-url-reference-mask-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-mask.html b/LayoutTests/svg/custom/local-url-reference-mask.html
new file mode 100644 (file)
index 0000000..e00e494
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <mask id="mask">
+    <rect y="50" width="100" height="50" fill="white"/>
+  </mask>
+  <rect width="100" height="50" fill="green"/>
+  <g mask="url(#mask)">
+    <rect width="100" height="50" fill="red"/>
+    <rect y="50" width="100" height="50" fill="green"/>
+  </g>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-pattern-expected.html b/LayoutTests/svg/custom/local-url-reference-pattern-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-pattern.html b/LayoutTests/svg/custom/local-url-reference-pattern.html
new file mode 100644 (file)
index 0000000..8316f8b
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <pattern id="pattern" width="100" height="100" patternUnits="userSpaceOnUse">
+    <rect width="100" height="100" fill="green"/>
+  </pattern>
+  <pattern id="inheritedPattern" href="#pattern"/>
+  <rect width="100" height="100" fill="url(#inheritedPattern) red"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-radial-gradient-expected.html b/LayoutTests/svg/custom/local-url-reference-radial-gradient-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-radial-gradient.html b/LayoutTests/svg/custom/local-url-reference-radial-gradient.html
new file mode 100644 (file)
index 0000000..690165d
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+  <radialGradient id="radial">
+    <stop stop-color="green"/>
+  </radialGradient>
+  <radialGradient id="inheritedRadial" href="#radial"/>
+  <rect width="100" height="100" fill="url(#inheritedRadial) red"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-srcdoc-expected.html b/LayoutTests/svg/custom/local-url-reference-srcdoc-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-srcdoc.html b/LayoutTests/svg/custom/local-url-reference-srcdoc.html
new file mode 100644 (file)
index 0000000..201ba10
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<iframe srcdoc="
+  <!DOCTYPE html>
+  <style>body { margin: 0; }</style>
+  <svg xmlns='http://www.w3.org/2000/svg'>
+    <linearGradient id='gradient'>
+      <stop stop-color='green'/>
+    </linearGradient>
+    <rect width='100' height='100' fill='url(#gradient) red'/>
+  </svg>"
+  style="margin: 0; border: none" scrolling="no">
+</iframe>
diff --git a/LayoutTests/svg/custom/local-url-reference-stroke-expected.html b/LayoutTests/svg/custom/local-url-reference-stroke-expected.html
new file mode 100644 (file)
index 0000000..5fc78bb
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-stroke.html b/LayoutTests/svg/custom/local-url-reference-stroke.html
new file mode 100644 (file)
index 0000000..6d99395
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+    <linearGradient id="paint">
+        <stop stop-color="green"/>
+    </linearGradient>
+    <linearGradient id="inheritedPaint" href="#paint"/>
+    <rect x="25" y="25" width="50" height="50" stroke="url(#paint) red" stroke-width="50"/>
+    <rect x="125" y="25" width="50" height="50" stroke="url(#inheritedPaint) red" stroke-width="50"/>
+</svg>
diff --git a/LayoutTests/svg/custom/local-url-reference-use-expected.html b/LayoutTests/svg/custom/local-url-reference-use-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/custom/local-url-reference-use.html b/LayoutTests/svg/custom/local-url-reference-use.html
new file mode 100644 (file)
index 0000000..38403ec
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<svg>
+    <defs>
+        <rect id="rect" width="100" height="100" fill="green"/>
+    </defs>
+    <use href="#rect"/>
+</svg>
diff --git a/LayoutTests/svg/text/textpath-local-url-reference-expected.html b/LayoutTests/svg/text/textpath-local-url-reference-expected.html
new file mode 100644 (file)
index 0000000..f718ea6
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/LayoutTests/svg/text/textpath-local-url-reference.html b/LayoutTests/svg/text/textpath-local-url-reference.html
new file mode 100644 (file)
index 0000000..d563d92
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<base href="http://www.example.com/">
+<script src="../../resources/ahem.js"></script>
+<svg>
+  <path id="path" d="M0,80h100"/>
+  <text font-size="100" font-family="Ahem" fill="green"><textPath href="#path">X</textPath></textPath>
+</svg>
index 5fb5645..d0fb5b3 100644 (file)
@@ -1,5 +1,36 @@
 2019-09-02  Fujii Hironori  <Hironori.Fujii@sony.com>
 
+        [SVG] fragment-only url 'url(#fragment)' should be resolved against the current document with regardless to HTML <base> element
+        https://bugs.webkit.org/show_bug.cgi?id=189499
+        <rdar://problem/44466206>
+
+        Reviewed by Said Abou-Hallawa.
+
+        Fragment-only URL 'url(#fragment)' should be resolved against the
+        current document even if HTML <base> element is specified.
+        Spec: <https://drafts.csswg.org/css-values/#local-urls>
+
+        Tests: css3/filters/effect-reference-local-url-with-base.html
+               css3/masking/clip-path-reference-local-url-with-base.html
+               http/tests/svg/local-url-with-valid-base-and-resource.html
+               svg/animations/local-url-target-reference.html
+               svg/custom/local-url-reference-clip-path.html
+               svg/custom/local-url-reference-fill.html
+               svg/custom/local-url-reference-filter.html
+               svg/custom/local-url-reference-marker.html
+               svg/custom/local-url-reference-mask.html
+               svg/custom/local-url-reference-pattern.html
+               svg/custom/local-url-reference-radial-gradient.html
+               svg/custom/local-url-reference-srcdoc.html
+               svg/custom/local-url-reference-stroke.html
+               svg/custom/local-url-reference-use.html
+               svg/text/textpath-local-url-reference.html
+
+        * svg/SVGURIReference.cpp:
+        (WebCore::SVGURIReference::fragmentIdentifierFromIRIString): Return the fragment if the URL starts with '#'.
+
+2019-09-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
         [Win] Remove a unused PlatformWheelEvent constructor
         https://bugs.webkit.org/show_bug.cgi?id=201398
 
index 53da59c..86af4a2 100644 (file)
@@ -57,7 +57,10 @@ String SVGURIReference::fragmentIdentifierFromIRIString(const String& url, const
     if (start == notFound)
         return emptyString();
 
-    URL base = start ? URL(document.baseURL(), url.substring(0, start)) : document.baseURL();
+    if (!start)
+        return url.substring(1);
+
+    URL base = URL(document.baseURL(), url.substring(0, start));
     String fragmentIdentifier = url.substring(start);
     URL kurl(base, fragmentIdentifier);
     if (equalIgnoringFragmentIdentifier(kurl, document.url()))