Index: Source/platform/scroll/ScrollbarThemeGtkOrAura.cpp |
=================================================================== |
--- Source/platform/scroll/ScrollbarThemeGtkOrAura.cpp (revision 166567) |
+++ Source/platform/scroll/ScrollbarThemeGtkOrAura.cpp (working copy) |
@@ -145,9 +145,42 @@ |
bool ScrollbarThemeGtkOrAura::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt) |
{ |
- return (evt.shiftKey() && evt.button() == LeftButton) || (evt.button() == MiddleButton); |
+#if defined(TOOLKIT_GTK) |
Elliot Glaysher
2014/02/11 18:36:56
You probably want defined(TOOLKIT_GTK) || (defined
Peter Kasting
2014/02/12 03:17:58
Done.
|
+ if (evt.button() == MiddleButton) |
+ return true; |
+#endif |
+ return (evt.shiftKey() && evt.button() == LeftButton); |
} |
+bool ScrollbarThemeGtkOrAura::shouldSnapBackToDragOrigin(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt) |
+{ |
+#if defined(TOOLKIT_GTK) |
sky
2014/02/10 15:14:30
Don't you want !win here? Otherwise won't chromeos
Peter Kasting
2014/02/10 23:09:16
To re-quote my initial comment on this CL:
"(I ch
|
+ return false; |
+#endif |
+ |
+ // Constants used to figure the drag rect outside which we should snap the |
+ // scrollbar thumb back to its origin. These calculations are based on |
+ // observing the behavior of the MSVC8 main window scrollbar + some |
+ // guessing/extrapolation. |
+ static const int kOffEndMultiplier = 3; |
+ static const int kOffSideMultiplier = 8; |
+ |
+ // Find the rect within which we shouldn't snap, by expanding the track rect |
+ // in both dimensions. |
+ IntRect rect = trackRect(scrollbar); |
+ const bool horz = scrollbar->orientation() == HorizontalScrollbar; |
+ const int thickness = scrollbarThickness(scrollbar->controlSize()); |
+ rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness); |
+ rect.inflateY((horz ? kOffSideMultiplier : kOffEndMultiplier) * thickness); |
+ |
+ // Convert the event to local coordinates. |
+ IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.position()); |
+ mousePosition.move(scrollbar->x(), scrollbar->y()); |
+ |
+ // We should snap iff the event is outside our calculated rect. |
+ return !rect.contains(mousePosition); |
+} |
+ |
IntSize ScrollbarThemeGtkOrAura::buttonSize(ScrollbarThemeClient* scrollbar) |
{ |
if (scrollbar->orientation() == VerticalScrollbar) { |