Changeset 196632 in webkit
- Timestamp:
- Feb 16, 2016 1:50:26 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r196631 r196632 1 2016-02-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] clicking on the scrollbar trough steps rather than jumps to the clicked position 4 https://bugs.webkit.org/show_bug.cgi?id=115363 5 6 Reviewed by Michael Catanzaro. 7 8 Allow ScrollbarTheme to decide the behavior of a button press event, 9 instead of only deciding whether to center on thumb or not. This 10 way we can match the current GTK+ behavior in WebKit, without 11 affecting other ports. 12 13 * platform/ScrollTypes.h: Add ScrollbarButtonPressAction enum. 14 * platform/Scrollbar.cpp: 15 (WebCore::Scrollbar::mouseDown): Ask ScrollbarTheme to handle the 16 event for the pressed part and do the requested action. 17 * platform/ScrollbarTheme.cpp: 18 (WebCore::ScrollbarTheme::handleMousePressEvent): Add default 19 implementation. It's equivalent to the previous default implementation. 20 * platform/ScrollbarTheme.h: 21 * platform/gtk/ScrollbarThemeGtk.cpp: 22 (WebCore::ScrollbarThemeGtk::handleMousePressEvent): Match current 23 GTK+ behavior: left click centers on thumb and right click 24 scrolls. Dragging the thumb works for left and middle buttons. 25 * platform/gtk/ScrollbarThemeGtk.h: 26 * platform/ios/ScrollbarThemeIOS.h: Remove shouldCenterOnThumb, 27 and don't override handleMousePressEvent since iOS wants the 28 default behavior. 29 * platform/ios/ScrollbarThemeIOS.mm: 30 * platform/mac/ScrollbarThemeMac.h: Override handleMousePressEvent 31 and remove shouldCenterOnThumb. 32 * platform/mac/ScrollbarThemeMac.mm: 33 (WebCore::shouldCenterOnThumb): Same implementation just made it 34 static to be used as helper. 35 (WebCore::ScrollbarThemeMac::handleMousePressEvent): Return the 36 desired action keeping the same behavior. 37 * platform/win/ScrollbarThemeWin.cpp: 38 (WebCore::ScrollbarThemeWin::handleMousePressEvent): Ditto. 39 * platform/win/ScrollbarThemeWin.h: 40 * rendering/RenderScrollbarTheme.h: 41 1 42 2016-02-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 43 -
trunk/Source/WebCore/platform/ScrollTypes.h
r196248 r196632 181 181 }; 182 182 183 enum class ScrollbarButtonPressAction { 184 None, 185 CenterOnThumb, 186 StartDrag, 187 Scroll 188 }; 189 183 190 } 184 191 -
trunk/Source/WebCore/platform/Scrollbar.cpp
r194515 r196632 392 392 bool Scrollbar::mouseDown(const PlatformMouseEvent& evt) 393 393 { 394 // Early exit for right click 395 if (evt.button() == RightButton) 396 return true; // FIXME: Handled as context menu by Qt right now. Should just avoid even calling this method on a right click though. 394 ScrollbarPart pressedPart = theme().hitTest(*this, evt.position()); 395 auto action = theme().handleMousePressEvent(*this, evt, pressedPart); 396 if (action == ScrollbarButtonPressAction::None) 397 return true; 397 398 398 399 m_scrollableArea.mouseIsDownInScrollbar(this, true); 399 setPressedPart( theme().hitTest(*this, evt.position()));400 int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y()); 401 402 if ( (m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme().shouldCenterOnThumb(*this, evt)) {400 setPressedPart(pressedPart); 401 402 int pressedPosition = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y()); 403 if (action == ScrollbarButtonPressAction::CenterOnThumb) { 403 404 setHoveredPart(ThumbPart); 404 405 setPressedPart(ThumbPart); 405 406 m_dragOrigin = m_currentPos; 406 int thumbLen = theme().thumbLength(*this);407 int desiredPos = pressedPos;408 407 // Set the pressed position to the middle of the thumb so that when we do the move, the delta 409 408 // will be from the current pixel position of the thumb to the new desired position for the thumb. 410 m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + th umbLen/ 2;411 moveThumb( desiredPos);409 m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + theme().thumbLength(*this) / 2; 410 moveThumb(pressedPosition); 412 411 return true; 413 } else if (m_pressedPart == ThumbPart) 412 } 413 414 m_pressedPos = pressedPosition; 415 416 if (action == ScrollbarButtonPressAction::StartDrag) 414 417 m_dragOrigin = m_currentPos; 415 416 m_pressedPos = pressedPos;417 418 autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); 418 419 if (action == ScrollbarButtonPressAction::Scroll) 420 autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); 421 419 422 return true; 420 423 } -
trunk/Source/WebCore/platform/ScrollbarTheme.cpp
r194819 r196632 27 27 #include "ScrollbarTheme.h" 28 28 29 #include "PlatformMouseEvent.h" 29 30 #include "ScrollbarThemeMock.h" 30 31 #include "Settings.h" … … 42 43 } 43 44 45 ScrollbarButtonPressAction ScrollbarTheme::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart) 46 { 47 if (event.button() == RightButton) 48 return ScrollbarButtonPressAction::None; 49 if (pressedPart == ThumbPart) 50 return ScrollbarButtonPressAction::StartDrag; 51 return ScrollbarButtonPressAction::Scroll; 44 52 } 53 54 } -
trunk/Source/WebCore/platform/ScrollbarTheme.h
r192140 r196632 96 96 #endif 97 97 98 virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) { return false; }98 virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart); 99 99 virtual bool shouldSnapBackToDragOrigin(Scrollbar&, const PlatformMouseEvent&) { return false; } 100 100 virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) { return false; } -
trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
r196172 r196632 494 494 } 495 495 496 bool ScrollbarThemeGtk::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent& event) 497 { 498 return (event.shiftKey() && event.button() == LeftButton) || (event.button() == MiddleButton); 496 ScrollbarButtonPressAction ScrollbarThemeGtk::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart) 497 { 498 switch (pressedPart) { 499 case BackTrackPart: 500 case ForwardTrackPart: 501 if (event.button() == LeftButton) 502 return ScrollbarButtonPressAction::CenterOnThumb; 503 if (event.button() == RightButton) 504 return ScrollbarButtonPressAction::Scroll; 505 break; 506 case ThumbPart: 507 if (event.button() != RightButton) 508 return ScrollbarButtonPressAction::StartDrag; 509 break; 510 default: 511 break; 512 } 513 514 return ScrollbarButtonPressAction::None; 499 515 } 500 516 -
trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h
r195810 r196632 54 54 virtual void paintThumb(GraphicsContext&, Scrollbar&, const IntRect&) override; 55 55 virtual void paintButton(GraphicsContext&, Scrollbar&, const IntRect&, ScrollbarPart) override; 56 virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;56 virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override; 57 57 virtual int scrollbarThickness(ScrollbarControlSize) override; 58 58 virtual int minimumThumbLength(Scrollbar&) override; -
trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.h
r185964 r196632 59 59 60 60 virtual int minimumThumbLength(Scrollbar&) override; 61 62 virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override; 63 61 64 62 public: 65 63 void preferencesChanged(); -
trunk/Source/WebCore/platform/ios/ScrollbarThemeIOS.mm
r189270 r196632 112 112 } 113 113 114 bool ScrollbarThemeIOS::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&)115 {116 return false;117 }118 119 114 bool ScrollbarThemeIOS::paint(Scrollbar&, GraphicsContext&, const IntRect& /*damageRect*/) 120 115 { -
trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h
r185964 r196632 85 85 virtual int minimumThumbLength(Scrollbar&) override; 86 86 87 virtual bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;87 virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override; 88 88 virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) override; 89 89 int scrollbarPartToHIPressedState(ScrollbarPart); -
trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm
r196247 r196632 425 425 } 426 426 427 bool ScrollbarThemeMac::shouldCenterOnThumb(Scrollbar&,const PlatformMouseEvent& evt)427 static bool shouldCenterOnThumb(const PlatformMouseEvent& evt) 428 428 { 429 429 if (evt.button() != LeftButton) … … 432 432 return !evt.altKey(); 433 433 return evt.altKey(); 434 } 435 436 ScrollbarButtonPressAction ScrollbarThemeMac::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart) 437 { 438 if (event.button() == RightButton) 439 return ScrollbarButtonPressAction::None; 440 441 switch (pressedPart) { 442 case BackTrackPart: 443 case ForwardTrackPart: 444 if (shouldCenterOnThumb(event)) 445 return ScrollbarButtonPressAction::CenterOnThumb; 446 break; 447 case ThumbPart: 448 return ScrollbarButtonPressAction::StartDrag; 449 default: 450 break; 451 } 452 453 return ScrollbarButtonPressAction::Scroll; 434 454 } 435 455 -
trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
r189270 r196632 194 194 } 195 195 196 bool ScrollbarThemeWin::shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent& evt) 197 { 198 return evt.shiftKey() && evt.button() == LeftButton; 196 ScrollbarButtonPressAction ScrollbarThemeWin::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart) 197 { 198 if (event.button() == RightButton) 199 return ScrollbarButtonPressAction::None; 200 201 switch (pressedPart) { 202 case BackTrackPart: 203 case ForwardTrackPart: 204 if (event.shiftKey() && event.button() == LeftButton) 205 return ScrollbarButtonPressAction::CenterOnThumb; 206 break; 207 case ThumbPart: 208 return ScrollbarButtonPressAction::StartDrag; 209 default: 210 break; 211 } 212 213 return ScrollbarButtonPressAction::Scroll; 199 214 } 200 215 -
trunk/Source/WebCore/platform/win/ScrollbarThemeWin.h
r185964 r196632 50 50 bool hasThumb(Scrollbar&) override; 51 51 52 bool shouldCenterOnThumb(Scrollbar&, const PlatformMouseEvent&) override;52 virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override; 53 53 bool shouldSnapBackToDragOrigin(Scrollbar&, const PlatformMouseEvent&) override; 54 54 -
trunk/Source/WebCore/rendering/RenderScrollbarTheme.h
r189270 r196632 47 47 virtual void paintScrollCorner(ScrollView*, GraphicsContext&, const IntRect& cornerRect) override; 48 48 49 virtual bool shouldCenterOnThumb(Scrollbar& scrollbar, const PlatformMouseEvent& event) override { return ScrollbarTheme::theme().shouldCenterOnThumb(scrollbar, event); }50 49 virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar& scrollbar, const PlatformMouseEvent& event, ScrollbarPart pressedPart) override { return ScrollbarTheme::theme().handleMousePressEvent(scrollbar, event, pressedPart); } 50 51 51 virtual double initialAutoscrollTimerDelay() override { return ScrollbarTheme::theme().initialAutoscrollTimerDelay(); } 52 52 virtual double autoscrollTimerDelay() override { return ScrollbarTheme::theme().autoscrollTimerDelay(); }
Note: See TracChangeset
for help on using the changeset viewer.