diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 108f5cd665a8be63da671ef4e017abe7c02c0f75..c686511ea124aecd5d15bcaedae2078ab33d5efa 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2009-07-22 Viet-Trung Luu + + Reviewed by David Hyatt. + + https://bugs.webkit.org/show_bug.cgi?id=27289 + Tests that mouse clicks/releases are handled properly on scrollbars + even when there is no mouse move onto the scrollbar (two cases: enabled + and disabled controls). + + * scrollbars/scrollbar-miss-mousemove-disabled-expected.txt: Added. + * scrollbars/scrollbar-miss-mousemove-disabled.html: Added. + * scrollbars/scrollbar-miss-mousemove-expected.txt: Added. + * scrollbars/scrollbar-miss-mousemove.html: Added. + 2009-07-23 Simon Hausmann Reviewed by Tor Arne Vestbø. diff --git a/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled-expected.txt b/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..dc0c7ec4304b8df41ee681182d54fd272e57602c --- /dev/null +++ b/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled-expected.txt @@ -0,0 +1,4 @@ + +Test for bug 27289: This tests that mouse clicks/releases on scrollbars are handled properly even is there was no mouse move onto the scrollbar; this is the disabled control case. On success, the text should begin with "zx". + +Text is "zx y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y " diff --git a/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled.html b/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled.html new file mode 100644 index 0000000000000000000000000000000000000000..2e5a61a8a5d262496b5acd39a2311376f5d28df7 --- /dev/null +++ b/LayoutTests/scrollbars/scrollbar-miss-mousemove-disabled.html @@ -0,0 +1,146 @@ + + + +
+ +
+

Test for bug +27289: This tests that mouse clicks/releases on scrollbars are handled +properly even is there was no mouse move onto the scrollbar; this is the +disabled control case. On success, the text should begin with "zx".

+

+ + + diff --git a/LayoutTests/scrollbars/scrollbar-miss-mousemove-expected.txt b/LayoutTests/scrollbars/scrollbar-miss-mousemove-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..58876ca4d9e56c9b93965be7eb4979b2c2b47f3e --- /dev/null +++ b/LayoutTests/scrollbars/scrollbar-miss-mousemove-expected.txt @@ -0,0 +1,3 @@ +Test for bug 27289: This tests that mouse clicks/releases on scrollbars are handled properly even is there was no mouse move onto the scrollbar; this is the enabled control case. On success, the offset should be 0. + +Scroll offset is 0 diff --git a/LayoutTests/scrollbars/scrollbar-miss-mousemove.html b/LayoutTests/scrollbars/scrollbar-miss-mousemove.html new file mode 100644 index 0000000000000000000000000000000000000000..b13eea8ff832ff9b5153741bf317124103568ce0 --- /dev/null +++ b/LayoutTests/scrollbars/scrollbar-miss-mousemove.html @@ -0,0 +1,37 @@ + + + +
+
+
+
+

Test for bug +27289: This tests that mouse clicks/releases on scrollbars are handled +properly even is there was no mouse move onto the scrollbar; this is the +enabled control case. On success, the offset should be 0.

+

+ + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index b1137c604231089ffcd14d75106fa1aea8eb07d8..c2005a4b9cd43182ccf091c9181a08fc128a7aca 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2009-07-22 Viet-Trung Luu + + Reviewed by David Hyatt. + + https://bugs.webkit.org/show_bug.cgi?id=27289 + When a mouse click occurs on a scrollbar without a preceding mouse move + onto it, the release isn't handled correctly (since + EventHandler::m_lastScrollbarUnderMouse isn't set on mouse down, but + only on mouse move). (Side comment: That scrollbar-handling code + in EventHandler is ugly. It should be fixed properly.) + + Tests: scrollbars/scrollbar-miss-mousemove.html + scrollbars/scrollbar-miss-mousemove-disabled.html + + * page/EventHandler.cpp: + (WebCore::EventHandler::handleMousePressEvent): + (WebCore::EventHandler::handleMouseMoveEvent): + (WebCore::EventHandler::updateLastScrollbarUnderMouse): + * page/EventHandler.h: + 2009-07-23 Mike Fenton Reviewed by David Levin. diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 3f0296ec14b7cb9db0e7ca5ddaedca542eb2e13a..9b3ee7832f0e10d31fd3a7e7abd4db27c5ae3ad3 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -1195,8 +1195,12 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) if (swallowEvent) { // scrollbars should get events anyway, even disabled controls might be scrollable - if (mev.scrollbar()) - passMousePressEventToScrollbar(mev, mev.scrollbar()); + Scrollbar* scrollbar = mev.scrollbar(); + + updateLastScrollbarUnderMouse(scrollbar, true); + + if (scrollbar) + passMousePressEventToScrollbar(mev, scrollbar); } else { // Refetch the event target node if it currently is the shadow node inside an element. // If a mouse event handler changes the input element type to one that has a widget associated, @@ -1211,6 +1215,9 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) Scrollbar* scrollbar = view ? view->scrollbarAtPoint(mouseEvent.pos()) : 0; if (!scrollbar) scrollbar = mev.scrollbar(); + + updateLastScrollbarUnderMouse(scrollbar, true); + if (scrollbar && passMousePressEventToScrollbar(mev, scrollbar)) swallowEvent = true; else @@ -1327,12 +1334,7 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent, Hi if (!scrollbar) scrollbar = mev.scrollbar(); - if (m_lastScrollbarUnderMouse != scrollbar) { - // Send mouse exited to the old scrollbar. - if (m_lastScrollbarUnderMouse) - m_lastScrollbarUnderMouse->mouseExited(); - m_lastScrollbarUnderMouse = m_mousePressed ? 0 : scrollbar; - } + updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); } bool swallowEvent = false; @@ -2422,4 +2424,16 @@ bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& return scrollbar->mouseDown(mev.event()); } +// If scrollbar (under mouse) is different from last, send a mouse exited. Set +// last to scrollbar if setLast is true; else set last to 0. +void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setLast) +{ + if (m_lastScrollbarUnderMouse != scrollbar) { + // Send mouse exited to the old scrollbar. + if (m_lastScrollbarUnderMouse) + m_lastScrollbarUnderMouse->mouseExited(); + m_lastScrollbarUnderMouse = setLast ? scrollbar : 0; + } +} + } diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index 42f24fe85fa300830baf839822d5a1828dab1b8a..20d288811270142a121c95e37c54a07025b0a077 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -271,6 +271,8 @@ private: void updateSelectionForMouseDrag(Node* targetNode, const IntPoint& localPoint); + void updateLastScrollbarUnderMouse(Scrollbar*, bool); + bool capturesDragging() const { return m_capturesDragging; } #if PLATFORM(MAC) && defined(__OBJC__)