Title: [106476] trunk
Revision
106476
Author
[email protected]
Date
2012-02-01 10:45:17 -0800 (Wed, 01 Feb 2012)

Log Message

Source/WebCore: preventDefault() in a mousedown in a subframe should not
prevent the scrollbar from handling mouse movements if the
cursor leaves the subframe.
https://bugs.webkit.org/show_bug.cgi?id=73097

Reviewed by Darin Adler.

Test: fast/events/scroll-div-with-prevent-default-in-subframe.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):

LayoutTests: Test for https://bugs.webkit.org/show_bug.cgi?id=73097.
Test adapted from repro case provided by [email protected].

Reviewed by Darin Adler.

* fast/events/resources/subframe-with-scrollable-div.html: Added.
* fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt: Added.
* fast/events/scroll-div-with-prevent-default-in-subframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106475 => 106476)


--- trunk/LayoutTests/ChangeLog	2012-02-01 18:29:20 UTC (rev 106475)
+++ trunk/LayoutTests/ChangeLog	2012-02-01 18:45:17 UTC (rev 106476)
@@ -1,3 +1,14 @@
+2012-02-01  Nate Chapin  <[email protected]>
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=73097.
+        Test adapted from repro case provided by [email protected].
+
+        Reviewed by Darin Adler.
+
+        * fast/events/resources/subframe-with-scrollable-div.html: Added.
+        * fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt: Added.
+        * fast/events/scroll-div-with-prevent-default-in-subframe.html: Added.
+
 2012-02-01  Mario Sanchez Prada  <[email protected]>
 
         [GTK] editing/inserting/4960120-2.html flaky crash

Added: trunk/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html (0 => 106476)


--- trunk/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html	2012-02-01 18:45:17 UTC (rev 106476)
@@ -0,0 +1,12 @@
+<html><body>
+<div id="scrollable" style="overflow-y:scroll;height:500px">
+  <div style="height:1000px;width:500px;">
+    Scrollable content.
+  </div>
+</div>
+<script type="text/_javascript_">
+document.getElementById('scrollable').addEventListener('mousedown', 
+    function(evt) { 
+        evt.preventDefault(); 
+    });
+</script></body></html>

Added: trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt (0 => 106476)


--- trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt	2012-02-01 18:45:17 UTC (rev 106476)
@@ -0,0 +1,7 @@
+PASS
+ 
+This test does the following via EventSender:
+1. Click and drag the div scrollbar to a middle point.
+2. Click and drag again, this time down and to right, with the mouseup occurring in a parent frame.
+3. Move the mouse back into the div with the scrollbar.
+Per https://bugs.webkit.org/show_bug.cgi?id=73097, because the div with the scrollbar had a mousedown event that called preventDefault(), the mouse moves would not properly be handled by the scrollbar. We pass if the div's scrollTop property is the same after all 3 steps.

Added: trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html (0 => 106476)


--- trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html	2012-02-01 18:45:17 UTC (rev 106476)
@@ -0,0 +1,43 @@
+<html><body _onload_="scroll()">
+<script>
+function scroll() {
+    if (window.eventSender) {
+        var scrollbar = document.getElementById("subframe").contentDocument.getElementById('scrollable');
+
+        var startX = scrollbar.offsetLeft + scrollbar.offsetWidth - 5;
+        var startY = scrollbar.offsetTop + 200;
+
+        eventSender.mouseMoveTo(startX, startY - 100);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(startX, startY);
+        eventSender.mouseUp();
+
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(startX, startY + 200);
+        eventSender.mouseMoveTo(startX + 200, startY + 200);
+        eventSender.mouseUp();
+        var scrollAfterMoveToMainFrame = scrollbar.scrollTop;
+
+        eventSender.mouseMoveTo(startX - 100, startY - 100);
+        var scrollAfterReturnToSubframe = scrollbar.scrollTop;
+        var result = scrollAfterMoveToMainFrame == scrollAfterReturnToSubframe ? "PASS" 
+            : "FAIL: scrollAfterMoveToMainFrame = " + scrollAfterMoveToMainFrame + ", scrollAfterReturnToSubframe = " + scrollAfterReturnToSubframe;
+        document.getElementById("console").appendChild(document.createTextNode(result));
+        layoutTestController.notifyDone();
+    }
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+</script>
+<div id="console"></div>
+<iframe id="subframe" width="500px" height="350" scrolling="no" marginwidth="0" marginheight="0" src=""
+<br>This test does the following via EventSender:<br>
+1. Click and drag the div scrollbar to a middle point.<br>
+2. Click and drag again, this time down and to right, with the mouseup occurring in a parent frame.<br>
+3. Move the mouse back into the div with the scrollbar.<br>
+Per https://bugs.webkit.org/show_bug.cgi?id=73097, because the div with the scrollbar had a mousedown event that called preventDefault(),
+the mouse moves would not properly be handled by the scrollbar. We pass if the div's scrollTop property is the same after all 3 steps.
+</body></html>

Modified: trunk/Source/WebCore/ChangeLog (106475 => 106476)


--- trunk/Source/WebCore/ChangeLog	2012-02-01 18:29:20 UTC (rev 106475)
+++ trunk/Source/WebCore/ChangeLog	2012-02-01 18:45:17 UTC (rev 106476)
@@ -1,3 +1,17 @@
+2012-02-01  Nate Chapin  <[email protected]>
+
+        preventDefault() in a mousedown in a subframe should not
+        prevent the scrollbar from handling mouse movements if the
+        cursor leaves the subframe.
+        https://bugs.webkit.org/show_bug.cgi?id=73097
+
+        Reviewed by Darin Adler.
+
+        Test: fast/events/scroll-div-with-prevent-default-in-subframe.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+
 2012-02-01  Mario Sanchez Prada  <[email protected]>
 
         [GTK] editing/inserting/4960120-2.html flaky crash

Modified: trunk/Source/WebCore/page/EventHandler.cpp (106475 => 106476)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-02-01 18:29:20 UTC (rev 106475)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-02-01 18:45:17 UTC (rev 106476)
@@ -1461,7 +1461,7 @@
     m_frame->selection()->setCaretBlinkingSuspended(true);
 
     bool swallowEvent = dispatchMouseEvent(eventNames().mousedownEvent, targetNode(mev), true, m_clickCount, mouseEvent, true);
-    m_capturesDragging = !swallowEvent;
+    m_capturesDragging = !swallowEvent || mev.scrollbar();
 
     // If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults
     // in case the scrollbar widget was destroyed when the mouse event was handled.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to