From 0ca3560a835267f5f913f68dc23297266a760408 Mon Sep 17 00:00:00 2001 From: "japhet@chromium.org" Date: Wed, 1 Feb 2012 18:45:17 +0000 Subject: [PATCH] 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 zacklloyd@google.com. 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106476 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 11 ++++++ .../resources/subframe-with-scrollable-div.html | 12 ++++++ ...v-with-prevent-default-in-subframe-expected.txt | 7 ++++ ...croll-div-with-prevent-default-in-subframe.html | 43 ++++++++++++++++++++++ Source/WebCore/ChangeLog | 14 +++++++ Source/WebCore/page/EventHandler.cpp | 2 +- 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/fast/events/resources/subframe-with-scrollable-div.html create mode 100644 LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt create mode 100644 LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 7adaaf0..8af76b4 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,14 @@ +2012-02-01 Nate Chapin + + Test for https://bugs.webkit.org/show_bug.cgi?id=73097. + Test adapted from repro case provided by zacklloyd@google.com. + + 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 [GTK] editing/inserting/4960120-2.html flaky crash diff --git a/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html b/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html new file mode 100644 index 0000000..ef0f287 --- /dev/null +++ b/LayoutTests/fast/events/resources/subframe-with-scrollable-div.html @@ -0,0 +1,12 @@ + +
+
+ Scrollable content. +
+
+ diff --git a/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt b/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt new file mode 100644 index 0000000..fa7a9f6 --- /dev/null +++ b/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe-expected.txt @@ -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. diff --git a/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html b/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html new file mode 100644 index 0000000..eda8c0e --- /dev/null +++ b/LayoutTests/fast/events/scroll-div-with-prevent-default-in-subframe.html @@ -0,0 +1,43 @@ + + +
+ +
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. + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index fc7fe28..0d00a4c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2012-02-01 Nate Chapin + + 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 [GTK] editing/inserting/4960120-2.html flaky crash diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 507a914..2fe8f04 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -1461,7 +1461,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) 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. -- 2.7.4