Title: [125727] trunk
Revision
125727
Author
[email protected]
Date
2012-08-15 17:43:01 -0700 (Wed, 15 Aug 2012)

Log Message

A 'load' event should be fired on the shadow host directly, not on an inner image element of shadow dom subtree.
https://bugs.webkit.org/show_bug.cgi?id=93920

Reviewed by Dimitri Glazkov.

Source/WebCore:

A 'load' event is a must-stoppable event at shadow boundary. So we
should fire a 'load' event on a shadow host directly, not on an
inner image element.

Test: fast/dom/shadow/shadowdom-for-image-event.html

* html/HTMLImageLoader.cpp:
(WebCore::HTMLImageLoader::dispatchLoadEvent):
* loader/ImageLoaderClient.h:
(WebCore::ImageLoaderClient::eventTarget):

LayoutTests:

* fast/dom/shadow/shadowdom-for-image-event-expected.txt: Added.
* fast/dom/shadow/shadowdom-for-image-event.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125726 => 125727)


--- trunk/LayoutTests/ChangeLog	2012-08-16 00:38:07 UTC (rev 125726)
+++ trunk/LayoutTests/ChangeLog	2012-08-16 00:43:01 UTC (rev 125727)
@@ -1,3 +1,13 @@
+2012-08-15  Hayato Ito  <[email protected]>
+
+        A 'load' event should be fired on the shadow host directly, not on an inner image element of shadow dom subtree.
+        https://bugs.webkit.org/show_bug.cgi?id=93920
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadowdom-for-image-event-expected.txt: Added.
+        * fast/dom/shadow/shadowdom-for-image-event.html: Added.
+
 2012-08-15  Lauro Neto  <[email protected]>
 
         [Qt] new test fast/forms/radio/radio-group.html introduced in r104668 fails

Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event-expected.txt (0 => 125727)


--- trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event-expected.txt	2012-08-16 00:43:01 UTC (rev 125727)
@@ -0,0 +1,7 @@
+Tests to ensure that an img element receives a load event, but an inner image element in shadow DOM subtree does not receive.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.currentTarget.id is "host"
+

Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event.html (0 => 125727)


--- trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-for-image-event.html	2012-08-16 00:43:01 UTC (rev 125727)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<div id="container">
+    <img id="host">
+</div>
+<script>
+description("Tests to ensure that an img element receives a load event, but an inner image element in shadow DOM subtree does not receive.");
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function listener(event) {
+    shouldBeEqualToString("event.currentTarget.id", "host");
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function addShadowDOM(host) {
+    var shadowRoot = new WebKitShadowRoot(host);
+    var div = document.createElement('div');
+    shadowRoot.appendChild(div);
+    div.id = 'inner-div';
+    div.addEventListener('load', listener, true);
+    div.appendChild(document.createElement('shadow'));
+}
+
+var host = document.getElementById('host');
+host.addEventListener('load', listener, true);
+addShadowDOM(host);
+host.src = ""
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (125726 => 125727)


--- trunk/Source/WebCore/ChangeLog	2012-08-16 00:38:07 UTC (rev 125726)
+++ trunk/Source/WebCore/ChangeLog	2012-08-16 00:43:01 UTC (rev 125727)
@@ -1,3 +1,21 @@
+2012-08-15  Hayato Ito  <[email protected]>
+
+        A 'load' event should be fired on the shadow host directly, not on an inner image element of shadow dom subtree.
+        https://bugs.webkit.org/show_bug.cgi?id=93920
+
+        Reviewed by Dimitri Glazkov.
+
+        A 'load' event is a must-stoppable event at shadow boundary. So we
+        should fire a 'load' event on a shadow host directly, not on an
+        inner image element.
+
+        Test: fast/dom/shadow/shadowdom-for-image-event.html
+
+        * html/HTMLImageLoader.cpp:
+        (WebCore::HTMLImageLoader::dispatchLoadEvent):
+        * loader/ImageLoaderClient.h:
+        (WebCore::ImageLoaderClient::eventTarget):
+
 2012-08-15  Otto Derek Cheung  <[email protected]>
 
         [BlackBerry] Show custom error page when 407 is received

Modified: trunk/Source/WebCore/html/HTMLImageLoader.cpp (125726 => 125727)


--- trunk/Source/WebCore/html/HTMLImageLoader.cpp	2012-08-16 00:38:07 UTC (rev 125726)
+++ trunk/Source/WebCore/html/HTMLImageLoader.cpp	2012-08-16 00:43:01 UTC (rev 125727)
@@ -56,7 +56,7 @@
     bool errorOccurred = image()->errorOccurred();
     if (!errorOccurred && image()->response().httpStatusCode() >= 400)
         errorOccurred = client()->sourceElement()->hasTagName(HTMLNames::objectTag); // An <object> considers a 404 to be an error and should fire onerror.
-    client()->imageElement()->dispatchEvent(Event::create(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false));
+    client()->eventTarget()->dispatchEvent(Event::create(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false));
 }
 
 String HTMLImageLoader::sourceURI(const AtomicString& attr) const

Modified: trunk/Source/WebCore/loader/ImageLoaderClient.h (125726 => 125727)


--- trunk/Source/WebCore/loader/ImageLoaderClient.h	2012-08-16 00:38:07 UTC (rev 125726)
+++ trunk/Source/WebCore/loader/ImageLoaderClient.h	2012-08-16 00:43:01 UTC (rev 125727)
@@ -42,6 +42,7 @@
 
     virtual Element* sourceElement() = 0;
     virtual Element* imageElement() = 0;
+    Element* eventTarget() { return sourceElement(); }
 
     virtual void refSourceElement() = 0;
     virtual void derefSourceElement() = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to