Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(983)

Unified Diff: Source/platform/scroll/ScrollbarThemeGtkOrAura.cpp

Issue 151483008: Re-add snap-back behavior (Blink side) (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeGtkOrAura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeGtkOrAura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698