Title: [251290] trunk
Revision
251290
Author
[email protected]
Date
2019-10-18 11:29:11 -0700 (Fri, 18 Oct 2019)

Log Message

Load event must be fired only for the SVG structurally external elements and the outermost SVG element
https://bugs.webkit.org/show_bug.cgi?id=203044

Patch by Said Abou-Hallawa <[email protected]> on 2019-10-18
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto-expected.txt:
The timeout issues are now fixed. webkit.org/b/202013 will fix the other
failures.

* web-platform-tests/svg/images/20x20.png: Added.
Add an image which is referenced by these tests:
    web-platform-tests/svg/import/styling-pres-02-f-manual.svg
    web-platform-tests/svg/import/struct-use-01-t-manual.svg
    web-platform-tests/svg/import/interact-events-02-b-manual.svg

* web-platform-tests/svg/linking/scripted/href-script-element-expected.txt:

Source/WebCore:

The SVG1.1 spec for SVGLoad event is:
    https://www.w3.org/TR/SVG11/interact.html

The SVG2 spec for the load event is:
    https://www.w3.org/TR/SVG/changes.html#interact
    https://www.w3.org/TR/SVG/interact.html

SVG2 removes the SVGExternalResourcesRequired interface. It also simplifies
the rules for firing the load event and made them consistent with the HTML
specs. The plan is to remove SVGExternalResourcesRequired in a following
patch. This patch makes SVGExternalResourcesRequired have no effect on the
load event firing rules. It moves all the functionalities to SVGURIReference
as a step towards removing the SVGExternalResourcesRequired interface.

Test: svg/custom/image-load-event.html

* dom/Document.cpp:
(WebCore::Document::implicitClose):
Do not use the SVGLoad term. It has been removed from the specs.

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::ScriptElement):
* dom/ScriptElement.h:
(WebCore::ScriptElement::errorOccurred const):
(WebCore::ScriptElement::setErrorOccurred):
Add a method to track the occurrence  of loading error. errorOccurred()
|| haveFiredLoadEvent() means no pending loading activity.

* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::dispatchLoadEventToOutermostSVGElements):
(WebCore::SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements): Deleted.
* svg/SVGDocumentExtensions.h:
Do not use the SVGLoad term.

* svg/SVGElement.cpp:
(WebCore::SVGElement::sendLoadEventIfPossible):
(WebCore::SVGElement::loadEventTimerFired):
(WebCore::SVGElement::loadEventTimer):
(WebCore::SVGElement::finishParsingChildren):
(WebCore::SVGElement::sendSVGLoadEventIfPossible): Deleted.
(WebCore::SVGElement::sendSVGLoadEventIfPossibleAsynchronously): Deleted.
(WebCore::SVGElement::svgLoadEventTimerFired): Deleted.
(WebCore::SVGElement::svgLoadEventTimer): Deleted.
* svg/SVGElement.h:
finishParsingChildren() won't fire 'load' event anymore. The 'load' event
will be fired explicitly for the outermost SVG element from Document::implicitClose().

* svg/SVGExternalResourcesRequired.cpp:
(WebCore::SVGExternalResourcesRequired::svgAttributeChanged):
(WebCore::SVGExternalResourcesRequired::dispatchLoadEvent): Deleted.
(WebCore::SVGExternalResourcesRequired::insertedIntoDocument): Deleted.
(WebCore::SVGExternalResourcesRequired::finishParsingChildren): Deleted.
(WebCore::SVGExternalResourcesRequired::haveLoadedRequiredResources const): Deleted.
* svg/SVGExternalResourcesRequired.h:
(WebCore::SVGExternalResourcesRequired::setHaveFiredLoadEvent): Deleted.
(WebCore::SVGExternalResourcesRequired::isParserInserted const): Deleted.
(WebCore::SVGExternalResourcesRequired::haveFiredLoadEvent const): Deleted.
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::haveLoadedRequiredResources):
* svg/SVGImageLoader.cpp:
(WebCore::SVGImageLoader::dispatchLoadEvent):
The value of externalResourcesRequired() no longer controls firing the
'load' event.

* svg/SVGScriptElement.cpp:
(WebCore::SVGScriptElement::SVGScriptElement):
(WebCore::SVGScriptElement::insertedIntoAncestor):
(WebCore::SVGScriptElement::dispatchErrorEvent):
(WebCore::SVGScriptElement::finishParsingChildren): Deleted.
* svg/SVGScriptElement.h:
dispatchErrorEvent() is now a virtual function. Let SVGScriptElement
overrides it so it can track when the loader finishes its activity.

* svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::SVGStyleElement):
* svg/SVGStyleElement.h:

* svg/SVGURIReference.cpp:
(WebCore::SVGURIReference::contextElement const):
(WebCore::SVGURIReference::parseAttribute):
(WebCore::SVGURIReference::haveLoadedRequiredResources const):
(WebCore::SVGURIReference::dispatchLoadEvent):
* svg/SVGURIReference.h:
(WebCore::SVGURIReference::haveFiredLoadEvent const):
(WebCore::SVGURIReference::setHaveFiredLoadEvent):
(WebCore::SVGURIReference::errorOccurred const):
(WebCore::SVGURIReference::setErrorOccurred):
SVGURIReference will decide whether the 'load' event can be fired or not.

* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::SVGUseElement):
(WebCore::SVGUseElement::insertedIntoAncestor):
(WebCore::SVGUseElement::notifyFinished):
(WebCore::SVGUseElement::finishParsingChildren): Deleted.
(WebCore::SVGUseElement::isValid const): Deleted.
(WebCore::SVGUseElement::haveLoadedRequiredResources): Deleted.
(WebCore::SVGUseElement::setHaveFiredLoadEvent): Deleted.
(WebCore::SVGUseElement::haveFiredLoadEvent const): Deleted.
(WebCore::SVGUseElement::svgLoadEventTimer): Deleted.
* svg/SVGUseElement.h:
SVGUseElement needs to track firing the load event or error occurrence
the same way SVGImageElement and SVGScriptElement do.

LayoutTests:

* fast/dom/crash-moving-subtree-between-documents.html:
* fast/dom/focus-style-resolution.html:
* fast/html/marquee-reparent-check.html:
The SVGElement element should not fire "load" event. Set the HTML <body>
element's "onload" event handler to be the function which was set to the
SVGElement's "onload" event handler.

* svg/custom/image-load-event-expected.html: Added.
* svg/custom/image-load-event.html: Added.
Images with external resources or data URIs must fire load events once
the data is loaded or decoded.

* svg/custom/loadevents-async-expected.txt: Removed.
* svg/custom/loadevents-async.html: Removed.
* svg/custom/loadevents-capturing-expected.txt: Removed.
* svg/custom/loadevents-capturing.svg: Removed.
* svg/custom/loadevents-externalresourcesrequired-displaynone-expected.txt: Removed.
* svg/custom/loadevents-externalresourcesrequired-displaynone.svg: Removed.
* svg/custom/loadevents-externalresourcesrequired-expected.txt: Removed.
* svg/custom/loadevents-externalresourcesrequired.svg: Removed.
* svg/custom/loadevents-normal-displaynone-expected.txt: Removed.
* svg/custom/loadevents-normal-displaynone.svg: Removed.
* svg/custom/loadevents-normal-expected.txt: Removed.
* svg/custom/loadevents-normal.svg: Removed.
These tests were implementing the SVG1.1 SVGLoad event interactivity:
https://www.w3.org/TR/SVG11/interact.html where every SVG element had to
fire the SVGLoad event once it parsed its closing tag. SVG structurally
external elements were firing load events when the corresponding external
resources had finished loading but only if externalResourcesRequired = true.

* svg/dom/SVGScriptElement/script-load-and-error-events.svg:
This test had two wrong assumptions:
1) The SVG structurally external element fires a load event when parsing
the children finishes. Then they may fire another load or error event if
externalResourcesRequired = true.
2) The outermost SVG element will not fire its load event unless all the
children fires their load events correctly.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (251289 => 251290)


--- trunk/LayoutTests/ChangeLog	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/ChangeLog	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,3 +1,48 @@
+2019-10-18  Said Abou-Hallawa  <[email protected]>
+
+        Load event must be fired only for the SVG structurally external elements and the outermost SVG element
+        https://bugs.webkit.org/show_bug.cgi?id=203044
+
+        Reviewed by Simon Fraser.
+
+        * fast/dom/crash-moving-subtree-between-documents.html:
+        * fast/dom/focus-style-resolution.html:
+        * fast/html/marquee-reparent-check.html:
+        The SVGElement element should not fire "load" event. Set the HTML <body>
+        element's "onload" event handler to be the function which was set to the
+        SVGElement's "onload" event handler.
+
+        * svg/custom/image-load-event-expected.html: Added.
+        * svg/custom/image-load-event.html: Added.
+        Images with external resources or data URIs must fire load events once
+        the data is loaded or decoded.
+
+        * svg/custom/loadevents-async-expected.txt: Removed.
+        * svg/custom/loadevents-async.html: Removed.
+        * svg/custom/loadevents-capturing-expected.txt: Removed.
+        * svg/custom/loadevents-capturing.svg: Removed.
+        * svg/custom/loadevents-externalresourcesrequired-displaynone-expected.txt: Removed.
+        * svg/custom/loadevents-externalresourcesrequired-displaynone.svg: Removed.
+        * svg/custom/loadevents-externalresourcesrequired-expected.txt: Removed.
+        * svg/custom/loadevents-externalresourcesrequired.svg: Removed.
+        * svg/custom/loadevents-normal-displaynone-expected.txt: Removed.
+        * svg/custom/loadevents-normal-displaynone.svg: Removed.
+        * svg/custom/loadevents-normal-expected.txt: Removed.
+        * svg/custom/loadevents-normal.svg: Removed.
+        These tests were implementing the SVG1.1 SVGLoad event interactivity:
+        https://www.w3.org/TR/SVG11/interact.html where every SVG element had to
+        fire the SVGLoad event once it parsed its closing tag. SVG structurally
+        external elements were firing load events when the corresponding external
+        resources had finished loading but only if externalResourcesRequired = true.
+
+        * svg/dom/SVGScriptElement/script-load-and-error-events.svg:
+        This test had two wrong assumptions:
+        1) The SVG structurally external element fires a load event when parsing
+        the children finishes. Then they may fire another load or error event if
+        externalResourcesRequired = true.        
+        2) The outermost SVG element will not fire its load event unless all the
+        children fires their load events correctly.
+
 2019-10-18  Russell Epstein  <[email protected]>
 
         REGRESSION (r251262): Layout Test scrollingcoordinator/ios/non-stable-viewport-scroll.html is a Flaky Failure

Modified: trunk/LayoutTests/fast/dom/crash-moving-subtree-between-documents.html (251289 => 251290)


--- trunk/LayoutTests/fast/dom/crash-moving-subtree-between-documents.html	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/fast/dom/crash-moving-subtree-between-documents.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,8 +1,10 @@
 <!DOCTYPE html>
 <html>
 <script>
-if (window.testRunner)
+if (window.testRunner) {
     testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
 function go()
 {
     var v = document.getElementById("v");
@@ -14,19 +16,23 @@
     var d = document.implementation.createHTMLDocument("doc");
     var s = d.createElement("script");
     s.prepend(v);
+    testRunner.notifyDone();
 }
 function eventhandler1()
 {
     v.appendChild(o);
     o.addEventListener("DOMNodeRemoved", eventhandler2);
+    setTimeout(() => {
+        go();
+    }, 0);
 }
 </script>
-<body _onload_=go()>
+<body _onload_=eventhandler1()>
 This test passes if it does not assert or crash.
 <a id="a"></a>
 <output id="o">foo</output>
 <video id="v"></video>
 <svg>
-<text _onload_="eventhandler1()" />
+<text/>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/dom/focus-style-resolution.html (251289 => 251290)


--- trunk/LayoutTests/fast/dom/focus-style-resolution.html	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/fast/dom/focus-style-resolution.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -17,6 +17,7 @@
 }
 
 </script>
+<body _onload_="eventhandler3()">
 This test passes if it doesn't assert or crash.
 <table id="table"></table>
 <form>
@@ -24,7 +25,7 @@
 </form>
 <svg>
 <animate id="anim" attributeName="text-anchor" from="middle" to="inherit" _onbegin_="eventhandler1()" />
-<text id="txt" _onload_="eventhandler3()">
+<text id="txt">
 <font color="white"></font>
 <select _onfocus_="eventhandler2()" autofocus="autofocus">
 <textarea>a</textarea>

Modified: trunk/LayoutTests/fast/html/marquee-reparent-check.html (251289 => 251290)


--- trunk/LayoutTests/fast/html/marquee-reparent-check.html	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/fast/html/marquee-reparent-check.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -2,32 +2,6 @@
 <html>
 <head>
 <script src=""
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-description("The test passes if it does not ASSERT in debug builds.");
-
-var innerMarquee;
-var outerMarquee;
-
-function runTest() {
-    innerMarquee = document.getElementById("innerMarquee");
-    outerMarquee = document.getElementById("outerMarquee");
-
-    document.execCommand("createLink", false, "#foo");
-    document.getElementById("htmlTableHeader").innerHTML = "TEST";
-}
-
-function blurHandler() {
-    document.getElementById("htmlTextArea").setSelectionRange(0, 0, "foo");
-}
-
-function focusHandler() {
-    document.getElementById("htmlTextArea").click();
-    innerMarquee.appendChild(outerMarquee);
-}
-</script>
 </head>
 <body>
     <div id="divElement">
@@ -46,8 +20,7 @@
                 <th id="htmlTableHeader">
                     <marquee id="innerMarquee">
                         <svg>
-                            <mesh _onload_="runTest()">
-                            </mesh>
+                            <mesh/>
                         </svg>
                     </marquee>
                 </th>
@@ -56,6 +29,27 @@
     </table>
     <keygen autofocus="autofocus">
     <iframe>Test Frame</iframe>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        description("The test passes if it does not ASSERT in debug builds.");
+
+        var innerMarquee = document.getElementById("innerMarquee");
+        var outerMarquee = document.getElementById("outerMarquee");
+
+        document.execCommand("createLink", false, "#foo");
+        document.getElementById("htmlTableHeader").innerHTML = "TEST";
+
+        function blurHandler() {
+            document.getElementById("htmlTextArea").setSelectionRange(0, 0, "foo");
+        }
+
+        function focusHandler() {
+            document.getElementById("htmlTextArea").click();
+            innerMarquee.appendChild(outerMarquee);
+        }
+    </script>
     <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (251289 => 251290)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,3 +1,22 @@
+2019-10-18  Said Abou-Hallawa  <[email protected]>
+
+        Load event must be fired only for the SVG structurally external elements and the outermost SVG element
+        https://bugs.webkit.org/show_bug.cgi?id=203044
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto-expected.txt:
+        The timeout issues are now fixed. webkit.org/b/202013 will fix the other
+        failures.
+
+        * web-platform-tests/svg/images/20x20.png: Added.
+        Add an image which is referenced by these tests:
+            web-platform-tests/svg/import/styling-pres-02-f-manual.svg
+            web-platform-tests/svg/import/struct-use-01-t-manual.svg
+            web-platform-tests/svg/import/interact-events-02-b-manual.svg
+
+        * web-platform-tests/svg/linking/scripted/href-script-element-expected.txt:
+
 2019-10-18  Antti Koivisto  <[email protected]>
 
         [CSS Shadow Parts] :part rules should be able to override style attribute

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto-expected.txt (251289 => 251290)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,34 +1,32 @@
 
-Harness Error (TIMEOUT), message = null
+PASS <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='64' 
+FAIL <svg:image> 'auto' sizing with 256x256 png image, attributes width='128' height='64' and CSS 'width:auto' assert_equals: expected 64 but got 128
+FAIL <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='128' and CSS 'height:auto' assert_equals: expected 64 but got 128
+FAIL <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='64' and CSS 'width:auto; height:auto' assert_equals: expected 256 but got 128
+PASS <svg:image> 'auto' sizing with default sized svg image, attributes width='50' height='50' 
+FAIL <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto; height:auto' assert_equals: expected 200 but got 50
+FAIL <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto' assert_equals: expected 100 but got 50
+FAIL <svg:image> 'auto' sizing with 200x100 svg image, without attributes width and height and CSS 'width:auto' assert_equals: expected 200 but got 0
+FAIL <svg:image> 'auto' sizing with 200x100 svg image, attributes height='50' and 'width:auto' assert_equals: expected 100 but got 0
+FAIL <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' and CSS height:auto assert_equals: expected 25 but got 0
+FAIL <svg:image> 'auto' sizing with default sized svg image, attributes width='200' height='200' and CSS 'width:auto; height:auto' assert_equals: expected 300 but got 200
+FAIL <svg:image> 'auto' sizing with default sized svg image, attributes height='200' and CSS 'width:auto; height:auto' assert_equals: expected 300 but got 0
+FAIL <svg:image> 'auto' sizing with default sized svg image, attributes width='200' and CSS 'width:auto; height:auto' assert_equals: expected 300 but got 200
+FAIL <svg:image> 'auto' sizing with default sized svg image, without attributes width and height, no css width/height specified assert_equals: expected 300 but got 0
+PASS <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified 
+FAIL <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' assert_equals: expected 240 but got 60
+FAIL <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' assert_equals: expected 15 but got 60
+FAIL <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' assert_equals: expected 300 but got 60
+PASS <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified 
+FAIL <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' assert_equals: expected 240 but got 60
+FAIL <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' assert_equals: expected 15 but got 60
+FAIL <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' assert_equals: expected 200 but got 60
+PASS <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified 
+FAIL <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' assert_equals: expected 240 but got 60
+FAIL <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' assert_equals: expected 15 but got 60
+FAIL <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' assert_equals: expected 400 but got 60
+PASS <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified 
+FAIL <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' assert_equals: expected 120 but got 60
+FAIL <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' assert_equals: expected 30 but got 60
+FAIL <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' assert_equals: expected 200 but got 60
 
-TIMEOUT <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='64' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 256x256 png image, attributes width='128' height='64' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='128' and CSS 'height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 256x256 png image, attributes width='64' height='64' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image, attributes width='50' height='50' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image, without attributes width and height and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image, attributes height='50' and 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image, attributes width='50' and CSS height:auto Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image, attributes width='200' height='200' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image, attributes height='200' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image, attributes width='200' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image, without attributes width and height, no css width/height specified Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' Test timed out
-TIMEOUT <svg:image> 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' Test timed out
-

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/images/20x20.png


(Binary files differ)
Index: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/images/20x20.png =================================================================== --- trunk/LayoutTests/imported/w3c/web-platform-tests/svg/images/20x20.png 2019-10-18 18:08:43 UTC (rev 251289) +++ trunk/LayoutTests/imported/w3c/web-platform-tests/svg/images/20x20.png 2019-10-18 18:29:11 UTC (rev 251290) Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/images/20x20.png ___________________________________________________________________

Added: svn:mime-type

+image/png \ No newline at end of property

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/linking/scripted/href-script-element-expected.txt (251289 => 251290)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/svg/linking/scripted/href-script-element-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/svg/linking/scripted/href-script-element-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,5 +1,5 @@
 
-FAIL Test for loading external script from href when setting href and then xlink:href promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: loadedScript"
-FAIL Test for loading external script from xlnk:href by adding xlink:href and then href promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: loadedScript"
-FAIL Test for loading external script from href by adding href and then xlink:href, and then removing href promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: loadedScript"
+PASS Test for loading external script from href when setting href and then xlink:href 
+PASS Test for loading external script from xlnk:href by adding xlink:href and then href 
+PASS Test for loading external script from href by adding href and then xlink:href, and then removing href 
 

Added: trunk/LayoutTests/svg/custom/image-load-event-expected.html (0 => 251290)


--- trunk/LayoutTests/svg/custom/image-load-event-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/image-load-event-expected.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -0,0 +1,5 @@
+<body>
+    <svg width="100" height="100">
+        <rect width="100%" height="100%" fill="green"/>
+    </svg>
+</body>

Added: trunk/LayoutTests/svg/custom/image-load-event.html (0 => 251290)


--- trunk/LayoutTests/svg/custom/image-load-event.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/image-load-event.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -0,0 +1,27 @@
+<body>
+    <svg width="100" height="100">
+        <image width="100%" height="100%"/>
+    </svg>
+    <div id="log"></div>
+    <script>
+        function loadImage(href) {
+            return new Promise((resolve) => {
+                let image = document.querySelector('image');
+                image._onload_ = (() => {
+                    resolve();
+                });
+                image.setAttribute("href", href);
+            });
+        }
+
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        loadImage("resources/green-checker.png").then(() => {
+            loadImage("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' fill='green'/></svg>").then(() => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        });
+    </script>
+</body>

Deleted: trunk/LayoutTests/svg/custom/loadevents-async-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-async-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-async-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,11 +0,0 @@
-This test ensures that tree mutation on the load doesn't break consistency.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS invoked is false
-PASS invoked is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/svg/custom/loadevents-async.html (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-async.html	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-async.html	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,31 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<script>
-description("This test ensures that tree mutation on the load doesn't break consistency.");
-var invoked = false;
-var spanElement = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
-var divElement = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
-var useElement = document.createElementNS("http://www.w3.org/2000/svg", "use");
-var emptyDocument = document.implementation.createDocument("", "", null);
-
-document.body.appendChild(spanElement);
-divElement.appendChild(useElement);
-useElement.addEventListener("load", function () { emptyDocument.adoptNode(useElement); invoked = true; }, false);
-spanElement.appendChild(divElement);
-document.body.appendChild(useElement);
-shouldBeFalse("invoked");
-
-jsTestIsAsync = true;
-setTimeout(function() {
-    shouldBeTrue("invoked");
-    finishJSTest();
-}, 1);
-
-</script>
-<script src=""
-<body>
-</html>

Deleted: trunk/LayoutTests/svg/custom/loadevents-capturing-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-capturing-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-capturing-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,3 +0,0 @@
-This tests that load dispatching works when there are no
-direct listeners, but there are capturing event listeners on an ancestor. Bug 16447
-Passed

Deleted: trunk/LayoutTests/svg/custom/loadevents-capturing.svg (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-capturing.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-capturing.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,35 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-  <script>
-    <![CDATA[
-      if (window.testRunner)
-        testRunner.dumpAsText();
-
-      var results = [ ];
-      function handler(event)
-      {
-        results.push(event.target.localName);
-      }
-      document.documentElement.addEventListener('load', handler, true);
-
-      function reportResults()
-      {
-        var console = document.getElementById("console");
-        var expected = [ "image", "text", "text", "text", "g", "svg" ];
-        for (var i = 0; i < expected.length; ++i) {
-            if (results[i] != expected[i]) {
-              console.appendChild(document.createTextNode("FAIL: " + i + " should be " + expected[i] + " but instead is " + results[i] + ".\n"));
-              return;
-            }
-        }
-        console.appendChild(document.createTextNode("Passed"));
-      }
-      document.documentElement.addEventListener('load', reportResults);
-    ]]>
-  </script>
-  <g>
-    <image externalResourcesRequired="false" id="image" width="100" height="100" xlink:href="" />
-    <text y="130" x="20">This tests that load dispatching works when there are no</text>
-    <text y="150" x="20">direct listeners, but there are capturing event listeners on an ancestor. Bug 16447</text>
-    <text y="170" x="20" id="console" />
-  </g>
-</svg>

Deleted: trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,2 +0,0 @@
-This tests load dispatching order with externalResourcesRequired and an image that does not render(display=none). Bug 16447
-Passed

Deleted: trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone.svg (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-displaynone.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,30 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" _onload_="reportLoadEvent(this);runTest();">
-  <script>
-    <![CDATA[
-      if (window.testRunner)
-        testRunner.dumpAsText();
-
-      var results = new Array();
-
-      function reportLoadEvent(el) {
-        results.push(el.localName);
-      }
-      function runTest()
-      {
-        var test = document.getElementById("console");
-        if ( results.length != 4 || results[0] != "text" ||
-             results[1] != "image" || results[2] != "g" ||
-             results[3] != "svg") {
-          test.appendChild(document.createTextNode("Failed"));
-        } else {
-          test.appendChild(document.createTextNode("Passed"));
-        }
-      }
-    ]]>
-  </script>
-  <g _onload_="reportLoadEvent(this)">
-    <image display="none" externalResourcesRequired="true" id="image" _onload_="reportLoadEvent(this)" width="100" height="100" xlink:href="" />
-    <text y="130" x="20">This tests load dispatching order with externalResourcesRequired and an image that does not render(display=none). Bug 16447</text>
-    <text y="150" x="20" id="console" _onload_="reportLoadEvent(this)"/>
-  </g>
-</svg>

Deleted: trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,2 +0,0 @@
-This tests load dispatching order with externalResourcesRequired. Bug 16447
-Passed

Deleted: trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired.svg (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,30 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" _onload_="reportLoadEvent(this);runTest();">
-  <script>
-    <![CDATA[
-      if (window.testRunner)
-        testRunner.dumpAsText();
-
-      var results = new Array();
-
-      function reportLoadEvent(el) {
-		results.push(el.localName);
-      }
-      function runTest()
-      {
-        var test = document.getElementById("console");
-        if ( results.length != 4 || results[0] != "text" ||
-             results[1] != "image" || results[2] != "g" ||
-             results[3] != "svg") {
-          test.appendChild(document.createTextNode("Failed"));
-        } else {
-          test.appendChild(document.createTextNode("Passed"));
-        }
-      }
-    ]]>
-  </script>
-  <g _onload_="reportLoadEvent(this)">
-    <image externalResourcesRequired="true" id="image" _onload_="reportLoadEvent(this)" width="100" height="100" xlink:href="" />
-    <text y="130" x="20">This tests load dispatching order with externalResourcesRequired. Bug 16447</text>
-    <text y="150" x="20" id="console" _onload_="reportLoadEvent(this)"/>
-  </g>
-</svg>

Deleted: trunk/LayoutTests/svg/custom/loadevents-normal-displaynone-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-normal-displaynone-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-normal-displaynone-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,2 +0,0 @@
-This tests normal load dispatching order and an image that does not render(display=none). Bug 16447
-Passed

Deleted: trunk/LayoutTests/svg/custom/loadevents-normal-displaynone.svg (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-normal-displaynone.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-normal-displaynone.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,30 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" _onload_="reportLoadEvent(this);runTest();">
-  <script>
-    <![CDATA[
-      if (window.testRunner)
-        testRunner.dumpAsText();
-
-      var results = new Array();
-
-      function reportLoadEvent(el) {
-        results.push(el.localName);
-      }
-      function runTest()
-      {
-        var test = document.getElementById("console");
-        if ( results.length != 4 || results[0] != "image" ||
-             results[1] != "text" || results[2] != "g" ||
-             results[3] != "svg") {
-          test.appendChild(document.createTextNode("Failed"));
-        } else {
-          test.appendChild(document.createTextNode("Passed"));
-        }
-      }
-    ]]>
-  </script>
-  <g _onload_="reportLoadEvent(this)">
-    <image display="none" externalResourcesRequired="false" id="image" _onload_="reportLoadEvent(this)" width="100" height="100" xlink:href="" />
-    <text y="130" x="20">This tests normal load dispatching order and an image that does not render(display=none). Bug 16447</text>
-    <text y="150" x="20" id="console" _onload_="reportLoadEvent(this)"/>
-  </g>
-</svg>

Deleted: trunk/LayoutTests/svg/custom/loadevents-normal-expected.txt (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-normal-expected.txt	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-normal-expected.txt	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,2 +0,0 @@
-This tests normal load dispatching order. Bug 16447
-Passed

Deleted: trunk/LayoutTests/svg/custom/loadevents-normal.svg (251289 => 251290)


--- trunk/LayoutTests/svg/custom/loadevents-normal.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/custom/loadevents-normal.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,30 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" _onload_="reportLoadEvent(this);runTest();">
-  <script>
-    <![CDATA[
-      if (window.testRunner)
-        testRunner.dumpAsText();
-
-      var results = new Array();
-
-      function reportLoadEvent(el) {
-        results.push(el.localName);
-      }
-      function runTest()
-      {
-        var test = document.getElementById("console");
-        if ( results.length != 4 || results[0] != "image" ||
-             results[1] != "text" || results[2] != "g" ||
-             results[3] != "svg") {
-          test.appendChild(document.createTextNode("Failed"));
-        } else {
-          test.appendChild(document.createTextNode("Passed"));
-        }
-      }
-    ]]>
-  </script>
-  <g _onload_="reportLoadEvent(this)">
-    <image externalResourcesRequired="false" id="image" _onload_="reportLoadEvent(this)" width="100" height="100" xlink:href="" />
-    <text y="130" x="20">This tests normal load dispatching order. Bug 16447</text>
-    <text y="150" x="20" id="console" _onload_="reportLoadEvent(this)"/>
-  </g>
-</svg>

Modified: trunk/LayoutTests/svg/dom/SVGScriptElement/script-load-and-error-events.svg (251289 => 251290)


--- trunk/LayoutTests/svg/dom/SVGScriptElement/script-load-and-error-events.svg	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/LayoutTests/svg/dom/SVGScriptElement/script-load-and-error-events.svg	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" _onerror_="testGlobalErrorHandlerNotFired(evt)" _onload_="testLoadEventNotFired()">
+<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" _onerror_="testGlobalErrorHandlerNotFired(evt)">
 <defs>
 <title>&lt;SCRIPT&gt; load and error events</title>
 <script type="text/_javascript_">
@@ -20,10 +20,6 @@
     status_[evt.target.id] += "G";
 }
 
-function testLoadEventNotFired() {
-    shouldContinue = 0;
-}
-
 function loadEventHandler(evt) {
     status_[evt.target.id] += "L";
 }
@@ -38,7 +34,7 @@
 function endTest() {
     var failures = "";
 
-    if (status_[0] != "LE")
+    if (status_[0] != "E")
         failures += "0 (actual result: " + status_[0] + ") ";
     if (status_[1] != "E")
         failures += "1 (actual result: " + status_[1] + ") ";
@@ -48,7 +44,7 @@
         failures += "3 (actual result: " + status_[3] + ") ";
     if (status_[4] != "L")
         failures += "4 (actual result: " + status_[4] + ") ";
-    if (status_[5] != "LE")
+    if (status_[5] != "E")
         failures += "5 (actual result: " + status_[5] + ") ";
     if (status_[6] != "E")
         failures += "6 (actual result: " + status_[6] + ")";

Modified: trunk/Source/WebCore/ChangeLog (251289 => 251290)


--- trunk/Source/WebCore/ChangeLog	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/ChangeLog	2019-10-18 18:29:11 UTC (rev 251290)
@@ -1,3 +1,113 @@
+2019-10-18  Said Abou-Hallawa  <[email protected]>
+
+        Load event must be fired only for the SVG structurally external elements and the outermost SVG element
+        https://bugs.webkit.org/show_bug.cgi?id=203044
+
+        Reviewed by Simon Fraser.
+
+        The SVG1.1 spec for SVGLoad event is:
+            https://www.w3.org/TR/SVG11/interact.html
+
+        The SVG2 spec for the load event is:
+            https://www.w3.org/TR/SVG/changes.html#interact
+            https://www.w3.org/TR/SVG/interact.html
+
+        SVG2 removes the SVGExternalResourcesRequired interface. It also simplifies
+        the rules for firing the load event and made them consistent with the HTML
+        specs. The plan is to remove SVGExternalResourcesRequired in a following
+        patch. This patch makes SVGExternalResourcesRequired have no effect on the
+        load event firing rules. It moves all the functionalities to SVGURIReference
+        as a step towards removing the SVGExternalResourcesRequired interface.
+
+        Test: svg/custom/image-load-event.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::implicitClose):
+        Do not use the SVGLoad term. It has been removed from the specs.
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::ScriptElement):
+        * dom/ScriptElement.h:
+        (WebCore::ScriptElement::errorOccurred const):
+        (WebCore::ScriptElement::setErrorOccurred):
+        Add a method to track the occurrence  of loading error. errorOccurred()
+        || haveFiredLoadEvent() means no pending loading activity.
+
+        * svg/SVGDocumentExtensions.cpp:
+        (WebCore::SVGDocumentExtensions::dispatchLoadEventToOutermostSVGElements):
+        (WebCore::SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements): Deleted.
+        * svg/SVGDocumentExtensions.h:
+        Do not use the SVGLoad term. 
+
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::sendLoadEventIfPossible):
+        (WebCore::SVGElement::loadEventTimerFired):
+        (WebCore::SVGElement::loadEventTimer):
+        (WebCore::SVGElement::finishParsingChildren):
+        (WebCore::SVGElement::sendSVGLoadEventIfPossible): Deleted.
+        (WebCore::SVGElement::sendSVGLoadEventIfPossibleAsynchronously): Deleted.
+        (WebCore::SVGElement::svgLoadEventTimerFired): Deleted.
+        (WebCore::SVGElement::svgLoadEventTimer): Deleted.
+        * svg/SVGElement.h:
+        finishParsingChildren() won't fire 'load' event anymore. The 'load' event 
+        will be fired explicitly for the outermost SVG element from Document::implicitClose().
+
+        * svg/SVGExternalResourcesRequired.cpp:
+        (WebCore::SVGExternalResourcesRequired::svgAttributeChanged):
+        (WebCore::SVGExternalResourcesRequired::dispatchLoadEvent): Deleted.
+        (WebCore::SVGExternalResourcesRequired::insertedIntoDocument): Deleted.
+        (WebCore::SVGExternalResourcesRequired::finishParsingChildren): Deleted.
+        (WebCore::SVGExternalResourcesRequired::haveLoadedRequiredResources const): Deleted.
+        * svg/SVGExternalResourcesRequired.h:
+        (WebCore::SVGExternalResourcesRequired::setHaveFiredLoadEvent): Deleted.
+        (WebCore::SVGExternalResourcesRequired::isParserInserted const): Deleted.
+        (WebCore::SVGExternalResourcesRequired::haveFiredLoadEvent const): Deleted.
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::haveLoadedRequiredResources):
+        * svg/SVGImageLoader.cpp:
+        (WebCore::SVGImageLoader::dispatchLoadEvent):
+        The value of externalResourcesRequired() no longer controls firing the
+        'load' event.
+
+        * svg/SVGScriptElement.cpp:
+        (WebCore::SVGScriptElement::SVGScriptElement):
+        (WebCore::SVGScriptElement::insertedIntoAncestor):
+        (WebCore::SVGScriptElement::dispatchErrorEvent):
+        (WebCore::SVGScriptElement::finishParsingChildren): Deleted.
+        * svg/SVGScriptElement.h:
+        dispatchErrorEvent() is now a virtual function. Let SVGScriptElement
+        overrides it so it can track when the loader finishes its activity.
+
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::SVGStyleElement):
+        * svg/SVGStyleElement.h:
+
+        * svg/SVGURIReference.cpp:
+        (WebCore::SVGURIReference::contextElement const):
+        (WebCore::SVGURIReference::parseAttribute):
+        (WebCore::SVGURIReference::haveLoadedRequiredResources const):
+        (WebCore::SVGURIReference::dispatchLoadEvent):
+        * svg/SVGURIReference.h:
+        (WebCore::SVGURIReference::haveFiredLoadEvent const):
+        (WebCore::SVGURIReference::setHaveFiredLoadEvent):
+        (WebCore::SVGURIReference::errorOccurred const):
+        (WebCore::SVGURIReference::setErrorOccurred):
+        SVGURIReference will decide whether the 'load' event can be fired or not.
+
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::SVGUseElement):
+        (WebCore::SVGUseElement::insertedIntoAncestor):
+        (WebCore::SVGUseElement::notifyFinished):
+        (WebCore::SVGUseElement::finishParsingChildren): Deleted.
+        (WebCore::SVGUseElement::isValid const): Deleted.
+        (WebCore::SVGUseElement::haveLoadedRequiredResources): Deleted.
+        (WebCore::SVGUseElement::setHaveFiredLoadEvent): Deleted.
+        (WebCore::SVGUseElement::haveFiredLoadEvent const): Deleted.
+        (WebCore::SVGUseElement::svgLoadEventTimer): Deleted.
+        * svg/SVGUseElement.h:
+        SVGUseElement needs to track firing the load event or error occurrence 
+        the same way SVGImageElement and SVGScriptElement do.
+
 2019-10-18  Antti Koivisto  <[email protected]>
 
         ElementRuleCollector function signature cleanups

Modified: trunk/Source/WebCore/dom/Document.cpp (251289 => 251290)


--- trunk/Source/WebCore/dom/Document.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -2971,11 +2971,8 @@
         HTMLLinkElement::dispatchPendingLoadEvents();
         HTMLStyleElement::dispatchPendingLoadEvents();
 
-        // To align the HTML load event and the SVGLoad event for the outermost <svg> element, fire it from
-        // here, instead of doing it from SVGElement::finishedParsingChildren (if externalResourcesRequired="false",
-        // which is the default, for ='' its fired at a later time, once all external resources finished loading).
         if (svgExtensions())
-            accessSVGExtensions().dispatchSVGLoadEventToOutermostSVGElements();
+            accessSVGExtensions().dispatchLoadEventToOutermostSVGElements();
     }
 
     dispatchWindowLoadEvent();

Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/dom/ScriptElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -66,6 +66,7 @@
     , m_isExternalScript(false)
     , m_alreadyStarted(alreadyStarted)
     , m_haveFiredLoad(false)
+    , m_errorOccurred(false)
     , m_willBeParserExecuted(false)
     , m_readyToBeParserExecuted(false)
     , m_willExecuteWhenDocumentFinishedParsing(false)

Modified: trunk/Source/WebCore/dom/ScriptElement.h (251289 => 251290)


--- trunk/Source/WebCore/dom/ScriptElement.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/dom/ScriptElement.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -56,9 +56,10 @@
 
     // XML parser calls these
     virtual void dispatchLoadEvent() = 0;
-    void dispatchErrorEvent();
+    virtual void dispatchErrorEvent();
 
     bool haveFiredLoadEvent() const { return m_haveFiredLoad; }
+    bool errorOccurred() const { return m_errorOccurred; }
     bool willBeParserExecuted() const { return m_willBeParserExecuted; }
     bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; }
     bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWhenDocumentFinishedParsing; }
@@ -76,6 +77,7 @@
     ScriptElement(Element&, bool createdByParser, bool isEvaluated);
 
     void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFiredLoad; }
+    void setErrorOccurred(bool errorOccurred) { m_errorOccurred = errorOccurred; }
     bool isParserInserted() const { return m_parserInserted; }
     bool alreadyStarted() const { return m_alreadyStarted; }
     bool forceAsync() const { return m_forceAsync; }
@@ -122,6 +124,7 @@
     bool m_isExternalScript : 1;
     bool m_alreadyStarted : 1;
     bool m_haveFiredLoad : 1;
+    bool m_errorOccurred : 1;
     bool m_willBeParserExecuted : 1; // Same as "The parser will handle executing the script."
     bool m_readyToBeParserExecuted : 1;
     bool m_willExecuteWhenDocumentFinishedParsing : 1;

Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -111,7 +111,7 @@
     m_areAnimationsPaused = false;
 }
 
-void SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements()
+void SVGDocumentExtensions::dispatchLoadEventToOutermostSVGElements()
 {
     Vector<RefPtr<SVGSVGElement>> timeContainers;
     timeContainers.appendRange(m_timeContainers.begin(), m_timeContainers.end());
@@ -119,7 +119,7 @@
     for (auto& container : timeContainers) {
         if (!container->isOutermostSVGSVGElement())
             continue;
-        container->sendSVGLoadEventIfPossible();
+        container->sendLoadEventIfPossible();
     }
 }
 

Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGDocumentExtensions.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -53,7 +53,7 @@
     void startAnimations();
     void pauseAnimations();
     void unpauseAnimations();
-    void dispatchSVGLoadEventToOutermostSVGElements();
+    void dispatchLoadEventToOutermostSVGElements();
     bool areAnimationsPaused() const { return m_areAnimationsPaused; }
 
     void reportWarning(const String&);

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -440,48 +440,24 @@
     return false;
 }
 
-void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents)
+void SVGElement::sendLoadEventIfPossible()
 {
     if (!isConnected() || !document().frame())
         return;
 
-    RefPtr<SVGElement> currentTarget = this;
-    while (currentTarget && currentTarget->haveLoadedRequiredResources()) {
-        RefPtr<Element> parent;
-        if (sendParentLoadEvents)
-            parent = currentTarget->parentOrShadowHostElement(); // save the next parent to dispatch too incase dispatching the event changes the tree
-        if (hasLoadListener(currentTarget.get()))
-            currentTarget->dispatchEvent(Event::create(eventNames().loadEvent, Event::CanBubble::No, Event::IsCancelable::No));
-        currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : RefPtr<SVGElement>();
-        SVGElement* element = currentTarget.get();
-        if (!element || !element->isOutermostSVGSVGElement())
-            continue;
+    if (!haveLoadedRequiredResources() || !hasLoadListener(this))
+        return;
 
-        // Consider <svg _onload_="foo()"><image xlink:href="" externalResourcesRequired="true"/></svg>.
-        // If foo.png is not yet loaded, the first SVGLoad event will go to the <svg> element, sent through
-        // Document::implicitClose(). Then the SVGLoad event will fire for <image>, once its loaded.
-        ASSERT(sendParentLoadEvents);
-
-        // If the load event was not sent yet by Document::implicitClose(), but the <image> from the example
-        // above, just appeared, don't send the SVGLoad event to the outermost <svg>, but wait for the document
-        // to be "ready to render", first.
-        if (!document().loadEventFinished())
-            break;
-    }
+    dispatchEvent(Event::create(eventNames().loadEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
-void SVGElement::sendSVGLoadEventIfPossibleAsynchronously()
+void SVGElement::loadEventTimerFired()
 {
-    svgLoadEventTimer()->startOneShot(0_s);
+    sendLoadEventIfPossible();
 }
 
-void SVGElement::svgLoadEventTimerFired()
+Timer* SVGElement::loadEventTimer()
 {
-    sendSVGLoadEventIfPossible();
-}
-
-Timer* SVGElement::svgLoadEventTimer()
-{
     ASSERT_NOT_REACHED();
     return nullptr;
 }
@@ -490,14 +466,9 @@
 {
     StyledElement::finishParsingChildren();
 
-    // The outermost SVGSVGElement SVGLoad event is fired through Document::dispatchWindowLoadEvent.
     if (isOutermostSVGSVGElement())
         return;
 
-    // finishParsingChildren() is called when the close tag is reached for an element (e.g. </svg>)
-    // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish
-    sendSVGLoadEventIfPossible();
-
     // Notify all the elements which have references to this element to rebuild their shadow and render
     // trees, e.g. a <use> element references a target element before this target element is defined.
     invalidateInstances();

Modified: trunk/Source/WebCore/svg/SVGElement.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGElement.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGElement.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -76,10 +76,9 @@
 
     virtual void svgAttributeChanged(const QualifiedName&);
 
-    void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
-    void sendSVGLoadEventIfPossibleAsynchronously();
-    void svgLoadEventTimerFired();
-    virtual Timer* svgLoadEventTimer();
+    void sendLoadEventIfPossible();
+    void loadEventTimerFired();
+    virtual Timer* loadEventTimer();
 
     virtual AffineTransform* supplementalTransform() { return nullptr; }
 

Modified: trunk/Source/WebCore/svg/SVGExternalResourcesRequired.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGExternalResourcesRequired.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGExternalResourcesRequired.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -52,16 +52,6 @@
     if (!m_contextElement.isConnected())
         return;
 
-    // Handle dynamic updates of the 'externalResourcesRequired' attribute. Only possible case: changing from 'true' to 'false'
-    // causes an immediate dispatch of the SVGLoad event. If the attribute value was 'false' before inserting the script element
-    // in the document, the SVGLoad event has already been dispatched.
-    if (!externalResourcesRequiredAnimated().isAnimating() && !externalResourcesRequired() && !haveFiredLoadEvent() && !isParserInserted()) {
-        setHaveFiredLoadEvent(true);
-
-        ASSERT(m_contextElement.haveLoadedRequiredResources());
-        m_contextElement.sendSVGLoadEventIfPossible();
-    }
-
     auto* renderer = m_contextElement.renderer();
     if (renderer && is<RenderSVGShape>(renderer)) {
         SVGElement::InstanceInvalidationGuard guard(m_contextElement);
@@ -74,51 +64,4 @@
     supportedAttributes.add(SVGNames::externalResourcesRequiredAttr);
 }
 
-void SVGExternalResourcesRequired::dispatchLoadEvent()
-{
-    if (isParserInserted())
-        ASSERT(externalResourcesRequired() != haveFiredLoadEvent());
-    else if (haveFiredLoadEvent())
-        return;
-
-    // HTML and SVG differ completely in the 'onload' event handling of <script> elements.
-    // HTML fires the 'load' event after it sucessfully loaded a remote resource, otherwise an error event.
-    // SVG fires the SVGLoad event immediately after parsing the <script> element, if externalResourcesRequired
-    // is set to 'false', otherwise it dispatches the 'SVGLoad' event just after loading the remote resource.
-    if (!externalResourcesRequired())
-        return;
-
-    ASSERT(!haveFiredLoadEvent());
-
-    // Dispatch SVGLoad event
-    setHaveFiredLoadEvent(true);
-    ASSERT(m_contextElement.haveLoadedRequiredResources());
-
-    m_contextElement.sendSVGLoadEventIfPossible();
 }
-
-void SVGExternalResourcesRequired::insertedIntoDocument()
-{
-    if (isParserInserted())
-        return;
-
-    // Eventually send SVGLoad event now for the dynamically inserted script element.
-    if (externalResourcesRequired())
-        return;
-    setHaveFiredLoadEvent(true);
-    m_contextElement.sendSVGLoadEventIfPossibleAsynchronously();
-}
-
-void SVGExternalResourcesRequired::finishParsingChildren()
-{
-    // A SVGLoad event has been fired by SVGElement::finishParsingChildren.
-    if (!externalResourcesRequired())
-        setHaveFiredLoadEvent(true);
-}
-
-bool SVGExternalResourcesRequired::haveLoadedRequiredResources() const
-{
-    return !externalResourcesRequired() || haveFiredLoadEvent();
-}
-
-}

Modified: trunk/Source/WebCore/svg/SVGExternalResourcesRequired.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGExternalResourcesRequired.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGExternalResourcesRequired.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -51,18 +51,8 @@
 
 protected:
     SVGExternalResourcesRequired(SVGElement* contextElement);
-
     static bool isKnownAttribute(const QualifiedName& attributeName) { return PropertyRegistry::isKnownAttribute(attributeName); }
 
-    virtual void setHaveFiredLoadEvent(bool) { }
-    virtual bool isParserInserted() const { return false; }
-    virtual bool haveFiredLoadEvent() const { return false; }
-
-    void dispatchLoadEvent();
-    void insertedIntoDocument();
-    void finishParsingChildren();
-    bool haveLoadedRequiredResources() const;
-
 private:
     SVGElement& m_contextElement;
     Ref<SVGAnimatedBoolean> m_externalResourcesRequired;

Modified: trunk/Source/WebCore/svg/SVGImageElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGImageElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGImageElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -136,7 +136,7 @@
 
 bool SVGImageElement::haveLoadedRequiredResources()
 {
-    return !externalResourcesRequired() || !m_imageLoader.hasPendingActivity();
+    return !m_imageLoader.hasPendingActivity();
 }
 
 void SVGImageElement::didAttachRenderers()

Modified: trunk/Source/WebCore/svg/SVGImageLoader.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGImageLoader.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGImageLoader.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -40,10 +40,8 @@
 {
     if (image()->errorOccurred())
         element().dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
-    else {
-        if (downcast<SVGImageElement>(element()).externalResourcesRequired())
-            downcast<SVGImageElement>(ImageLoader::element()).sendSVGLoadEventIfPossible(true);
-    }
+    else
+        downcast<SVGImageElement>(ImageLoader::element()).sendLoadEventIfPossible();
 }
 
 String SVGImageLoader::sourceURI(const AtomString& attribute) const

Modified: trunk/Source/WebCore/svg/SVGScriptElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGScriptElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGScriptElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -35,7 +35,7 @@
     , SVGExternalResourcesRequired(this)
     , SVGURIReference(this)
     , ScriptElement(*this, wasInsertedByParser, alreadyStarted)
-    , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired)
+    , m_loadEventTimer(*this, &SVGElement::loadEventTimerFired)
 {
     ASSERT(hasTagName(SVGNames::scriptTag));
 }
@@ -68,8 +68,6 @@
 Node::InsertedIntoAncestorResult SVGScriptElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     SVGElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
-    if (insertionType.connectedToDocument)
-        SVGExternalResourcesRequired::insertedIntoDocument();
     return ScriptElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
 }
 
@@ -84,12 +82,6 @@
     ScriptElement::childrenChanged(change);
 }
 
-void SVGScriptElement::finishParsingChildren()
-{
-    SVGElement::finishParsingChildren();
-    SVGExternalResourcesRequired::finishParsingChildren();
-}
-
 void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
 {
     SVGElement::addSubresourceAttributeURLs(urls);
@@ -101,4 +93,10 @@
     return adoptRef(*new SVGScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
 }
 
+void SVGScriptElement::dispatchErrorEvent()
+{
+    setErrorOccurred(true);
+    ScriptElement::dispatchErrorEvent();
 }
+
+}

Modified: trunk/Source/WebCore/svg/SVGScriptElement.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGScriptElement.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGScriptElement.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -51,11 +51,12 @@
     void childrenChanged(const ChildChange&) final;
 
     bool isURLAttribute(const Attribute& attribute) const final { return attribute.name() == sourceAttributeValue(); }
-    void finishParsingChildren() final;
     void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
 
-    bool haveLoadedRequiredResources() final { return SVGExternalResourcesRequired::haveLoadedRequiredResources(); }
+    Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) final;
+    bool rendererIsNeeded(const RenderStyle&) final { return false; }
 
+    // ScriptElement
     String sourceAttributeValue() const final { return href(); }
     String charsetAttributeValue() const final { return String(); }
     String typeAttributeValue() const final { return getAttribute(SVGNames::typeAttr).string(); }
@@ -67,17 +68,18 @@
     bool hasNoModuleAttribute() const final { return false; }
     ReferrerPolicy referrerPolicy() const final { return ReferrerPolicy::EmptyString; }
     bool hasSourceAttribute() const final { return hasAttribute(SVGNames::hrefAttr) || hasAttribute(XLinkNames::hrefAttr); }
+    void dispatchLoadEvent() final { SVGURIReference::dispatchLoadEvent(); }
+    void dispatchErrorEvent() final;
 
-    void dispatchLoadEvent() final { SVGExternalResourcesRequired::dispatchLoadEvent(); }
+    // SVGElement
+    bool haveLoadedRequiredResources() final { return SVGURIReference::haveLoadedRequiredResources(); }
+    Timer* loadEventTimer() final { return &m_loadEventTimer; }
 
-    Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) final;
-    bool rendererIsNeeded(const RenderStyle&) final { return false; }
-
-    // SVGExternalResourcesRequired
+    // SVGURIReference
+    bool haveFiredLoadEvent() const final { return ScriptElement::haveFiredLoadEvent(); }
     void setHaveFiredLoadEvent(bool haveFiredLoadEvent) final { ScriptElement::setHaveFiredLoadEvent(haveFiredLoadEvent); }
-    bool isParserInserted() const final { return ScriptElement::isParserInserted(); }
-    bool haveFiredLoadEvent() const final { return ScriptElement::haveFiredLoadEvent(); }
-    Timer* svgLoadEventTimer() final { return &m_svgLoadEventTimer; }
+    bool errorOccurred() const final { return ScriptElement::errorOccurred(); }
+    void setErrorOccurred(bool errorOccurred) final { ScriptElement::setErrorOccurred(errorOccurred); }
 
 #ifndef NDEBUG
     bool filterOutAnimatableAttribute(const QualifiedName& name) const final { return name == SVGNames::typeAttr; }
@@ -84,7 +86,7 @@
 #endif
 
     PropertyRegistry m_propertyRegistry { *this };
-    Timer m_svgLoadEventTimer;
+    Timer m_loadEventTimer;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/svg/SVGStyleElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGStyleElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGStyleElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -36,7 +36,7 @@
 inline SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : SVGElement(tagName, document)
     , m_styleSheetOwner(document, createdByParser)
-    , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired)
+    , m_loadEventTimer(*this, &SVGElement::loadEventTimerFired)
 {
     ASSERT(hasTagName(SVGNames::styleTag));
 }

Modified: trunk/Source/WebCore/svg/SVGStyleElement.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGStyleElement.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGStyleElement.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -58,12 +58,12 @@
     virtual bool isLoading() const { return m_styleSheetOwner.isLoading(); }
     bool sheetLoaded() final { return m_styleSheetOwner.sheetLoaded(*this); }
     void startLoadingDynamicSheet() final { m_styleSheetOwner.startLoadingDynamicSheet(*this); }
-    Timer* svgLoadEventTimer() final { return &m_svgLoadEventTimer; }
+    Timer* loadEventTimer() final { return &m_loadEventTimer; }
 
     String title() const final;
 
     InlineStyleSheetOwner m_styleSheetOwner;
-    Timer m_svgLoadEventTimer;
+    Timer m_loadEventTimer;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/svg/SVGURIReference.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGURIReference.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGURIReference.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -45,12 +45,16 @@
     return PropertyRegistry::isKnownAttribute(attributeName);
 }
 
+SVGElement& SVGURIReference::contextElement() const
+{
+    return *m_href->contextElement();
+}
+
 void SVGURIReference::parseAttribute(const QualifiedName& name, const AtomString& value)
 {
-    auto* contextElement = m_href->contextElement();
     if (name.matches(SVGNames::hrefAttr))
-        m_href->setBaseValInternal(value.isNull() ? contextElement->getAttribute(XLinkNames::hrefAttr) : value);
-    else if (name.matches(XLinkNames::hrefAttr) && !contextElement->hasAttribute(SVGNames::hrefAttr))
+        m_href->setBaseValInternal(value.isNull() ? contextElement().getAttribute(XLinkNames::hrefAttr) : value);
+    else if (name.matches(XLinkNames::hrefAttr) && !contextElement().hasAttribute(SVGNames::hrefAttr))
         m_href->setBaseValInternal(value);
 }
 
@@ -100,4 +104,23 @@
     return { treeScope.getElementById(id), WTFMove(id) };
 }
 
+bool SVGURIReference::haveLoadedRequiredResources() const
+{
+    if (href().isEmpty() || !isExternalURIReference(href(), contextElement().document()))
+        return true;
+    return errorOccurred() || haveFiredLoadEvent();
 }
+
+void SVGURIReference::dispatchLoadEvent()
+{
+    if (haveFiredLoadEvent())
+        return;
+
+    // Dispatch the load event
+    setHaveFiredLoadEvent(true);
+    ASSERT(contextElement().haveLoadedRequiredResources());
+
+    contextElement().sendLoadEventIfPossible();
+}
+
+}

Modified: trunk/Source/WebCore/svg/SVGURIReference.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGURIReference.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGURIReference.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -66,7 +66,17 @@
 
     static bool isKnownAttribute(const QualifiedName& attributeName);
 
+    virtual bool haveFiredLoadEvent() const { return false; }
+    virtual void setHaveFiredLoadEvent(bool) { }
+    virtual bool errorOccurred() const { return false; }
+    virtual void setErrorOccurred(bool) { }
+
+    bool haveLoadedRequiredResources() const;
+    void dispatchLoadEvent();
+
 private:
+    SVGElement& contextElement() const;
+
     Ref<SVGAnimatedString> m_href;
 };
 

Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGUseElement.cpp	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp	2019-10-18 18:29:11 UTC (rev 251290)
@@ -50,7 +50,7 @@
     : SVGGraphicsElement(tagName, document)
     , SVGExternalResourcesRequired(this)
     , SVGURIReference(this)
-    , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired)
+    , m_loadEventTimer(*this, &SVGElement::loadEventTimerFired)
 {
     ASSERT(hasCustomStyleResolveCallbacks());
     ASSERT(hasTagName(SVGNames::useTag));
@@ -101,7 +101,6 @@
     if (insertionType.connectedToDocument) {
         if (m_shadowTreeNeedsUpdate)
             document().addSVGUseElement(*this);
-        SVGExternalResourcesRequired::insertedIntoDocument();
         invalidateShadowTree();
         // FIXME: Move back the call to updateExternalDocument() here once notifyFinished is made always async.
         return InsertedIntoAncestorResult::NeedsPostInsertionCallback;
@@ -554,18 +553,13 @@
 {
     ASSERT(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     invalidateShadowTree();
-    if (resource.errorOccurred())
+    if (resource.errorOccurred()) {
+        setErrorOccurred(true);
         dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
-    else if (!resource.wasCanceled())
-        SVGExternalResourcesRequired::dispatchLoadEvent();
+    } else if (!resource.wasCanceled())
+        SVGURIReference::dispatchLoadEvent();
 }
 
-void SVGUseElement::finishParsingChildren()
-{
-    SVGGraphicsElement::finishParsingChildren();
-    SVGExternalResourcesRequired::finishParsingChildren();
-}
-
 void SVGUseElement::updateExternalDocument()
 {
     URL externalDocumentURL;
@@ -597,29 +591,4 @@
     invalidateShadowTree();
 }
 
-bool SVGUseElement::isValid() const
-{
-    return SVGTests::isValid();
 }
-
-bool SVGUseElement::haveLoadedRequiredResources()
-{
-    return SVGExternalResourcesRequired::haveLoadedRequiredResources();
-}
-
-void SVGUseElement::setHaveFiredLoadEvent(bool haveFiredLoadEvent)
-{
-    m_haveFiredLoadEvent = haveFiredLoadEvent;
-}
-
-bool SVGUseElement::haveFiredLoadEvent() const
-{
-    return m_haveFiredLoadEvent;
-}
-
-Timer* SVGUseElement::svgLoadEventTimer()
-{
-    return &m_svgLoadEventTimer;
-}
-
-}

Modified: trunk/Source/WebCore/svg/SVGUseElement.h (251289 => 251290)


--- trunk/Source/WebCore/svg/SVGUseElement.h	2019-10-18 18:08:43 UTC (rev 251289)
+++ trunk/Source/WebCore/svg/SVGUseElement.h	2019-10-18 18:29:11 UTC (rev 251290)
@@ -57,7 +57,6 @@
 private:
     SVGUseElement(const QualifiedName&, Document&);
 
-    bool isValid() const override;
     InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override;
     void didFinishInsertingNode() final;
     void removedFromAncestor(RemovalType, ContainerNode&) override;
@@ -71,12 +70,7 @@
 
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
     Path toClipPath() override;
-    bool haveLoadedRequiredResources() override;
-    void finishParsingChildren() override;
     bool selfHasRelativeLengths() const override;
-    void setHaveFiredLoadEvent(bool) override;
-    bool haveFiredLoadEvent() const override;
-    Timer* svgLoadEventTimer() override;
     void notifyFinished(CachedResource&) final;
 
     Document* externalDocument() const;
@@ -95,6 +89,15 @@
     void clearShadowTree();
     void invalidateDependentShadowTrees();
 
+    bool haveLoadedRequiredResources() override { return SVGURIReference::haveLoadedRequiredResources(); }
+    void setHaveFiredLoadEvent(bool haveFiredLoadEvent) override { m_haveFiredLoadEvent = haveFiredLoadEvent; }
+    bool haveFiredLoadEvent() const override { return m_haveFiredLoadEvent; }
+    void setErrorOccurred(bool errorOccurred) override { m_errorOccurred = errorOccurred; }
+    bool errorOccurred() const override { return m_errorOccurred; }
+    Timer* loadEventTimer() override { return &m_loadEventTimer; }
+
+    bool isValid() const override { return SVGTests::isValid(); }
+
     PropertyRegistry m_propertyRegistry { *this };
     Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
     Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
@@ -102,9 +105,10 @@
     Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 
     bool m_haveFiredLoadEvent { false };
+    bool m_errorOccurred { false };
     bool m_shadowTreeNeedsUpdate { true };
     CachedResourceHandle<CachedSVGDocument> m_externalDocument;
-    Timer m_svgLoadEventTimer;
+    Timer m_loadEventTimer;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to