Title: [138190] branches/chromium/1364
Revision
138190
Author
[email protected]
Date
2012-12-19 12:48:34 -0800 (Wed, 19 Dec 2012)

Log Message

Merge 138181
> Correct missing touch event handler de-registration for nested Documents and DOMWindows
> https://bugs.webkit.org/show_bug.cgi?id=105384
> 
> Reviewed by James Robinson.
> 
> Source/WebCore: 
> 
> Correcting case by which a nested DOMWindow wouldn't clean up its event handler references
> on its Document when removeAllEventListeners was called. Also, correctly propagating this
> from a nested Document to its owner Document.
> 
> Updating fast/events/touch/touch-handler-count.html to catch this bug.
> 
> * dom/Document.cpp:
> (WebCore::Document::didRemoveEventTargetNode):
> * page/DOMWindow.cpp:
> (WebCore::DOMWindow::removeAllEventListeners):
> 
> LayoutTests: 
> 
> * fast/events/touch/touch-handler-count-expected.txt:
> * fast/events/touch/touch-handler-count.html: Adding case of nested DOMWindows with event handlers.
> 

[email protected]
Review URL: https://codereview.chromium.org/11635026

Modified Paths

Diff

Modified: branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count-expected.txt (138189 => 138190)


--- branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count-expected.txt	2012-12-19 20:47:05 UTC (rev 138189)
+++ branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count-expected.txt	2012-12-19 20:48:34 UTC (rev 138190)
@@ -71,4 +71,8 @@
 PASS window.internals.touchEventHandlerCount(document) is 2
 PASS window.internals.touchEventHandlerCount(document) is 2
 PASS window.internals.touchEventHandlerCount(document) is 0
+Test that nested Documents' touch handlers are properly removed from their parent Document.
+PASS window.internals.touchEventHandlerCount(document) is 0
+PASS window.internals.touchEventHandlerCount(document) is 1
+PASS window.internals.touchEventHandlerCount(document) is 0
 

Modified: branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count.html (138189 => 138190)


--- branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count.html	2012-12-19 20:47:05 UTC (rev 138189)
+++ branches/chromium/1364/LayoutTests/fast/events/touch/touch-handler-count.html	2012-12-19 20:48:34 UTC (rev 138190)
@@ -204,5 +204,24 @@
     shouldBe('window.internals.touchEventHandlerCount(document)', '0');
 })();
 
+debug("Test that nested Documents' touch handlers are properly removed from their parent Document.");
+(function() {
+    var iframe = document.createElement('iframe');
+    var touchtarget = document.getElementById('touchtarget');
+
+    shouldBe('window.internals.touchEventHandlerCount(document)', '0');
+
+    touchtarget.appendChild(iframe);
+
+    var nestedDocument = iframe.contentWindow.document;
+    nestedDocument.open('text/html', 'replace');
+    nestedDocument.write("<!DOCTYPE html>\n<html><body _onload_=\"window._ontouchstart_ = function() { };\"></body>");
+    nestedDocument.close();
+
+    shouldBe('window.internals.touchEventHandlerCount(document)', '1');
+
+    touchtarget.removeChild(iframe);
+    shouldBe('window.internals.touchEventHandlerCount(document)', '0');
+})();
 </script>
 </body>

Modified: branches/chromium/1364/Source/WebCore/dom/Document.cpp (138189 => 138190)


--- branches/chromium/1364/Source/WebCore/dom/Document.cpp	2012-12-19 20:47:05 UTC (rev 138189)
+++ branches/chromium/1364/Source/WebCore/dom/Document.cpp	2012-12-19 20:48:34 UTC (rev 138190)
@@ -5659,6 +5659,9 @@
 {
     if (m_touchEventTargets.get())
         m_touchEventTargets->removeAll(handler);
+    if (handler == this)
+        if (Document* parentDocument = this->parentDocument())
+            parentDocument->didRemoveEventTargetNode(this);
 }
 #endif
 

Modified: branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp (138189 => 138190)


--- branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp	2012-12-19 20:47:05 UTC (rev 138189)
+++ branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp	2012-12-19 20:48:34 UTC (rev 138190)
@@ -1685,6 +1685,10 @@
     if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
         controller->removeAllDeviceEventListeners(this);
 #endif
+#if ENABLE(TOUCH_EVENTS)
+    if (Document* document = this->document())
+        document->didRemoveEventTargetNode(document);
+#endif
 
     removeAllUnloadEventListeners(this);
     removeAllBeforeUnloadEventListeners(this);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to