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

Side by Side Diff: content/renderer/webscrollbarbehavior_impl_aura.cc

Issue 2489083002: Revert of Disable scrollbar snapback on desktop Linux (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/webscrollbarbehavior_impl_aura.h"
6
7 #include "build/build_config.h"
8 #include "third_party/WebKit/public/platform/WebPoint.h"
9 #include "third_party/WebKit/public/platform/WebRect.h"
10
11 namespace content {
12
13 bool WebScrollbarBehaviorImpl::shouldCenterOnThumb(
14 blink::WebPointerProperties::Button mouseButton,
15 bool shiftKeyPressed,
16 bool altKeyPressed) {
17 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS))
18 if (mouseButton == blink::WebPointerProperties::Button::Middle)
19 return true;
20 #endif
21 return (mouseButton == blink::WebPointerProperties::Button::Left) &&
22 shiftKeyPressed;
23 }
24
25 bool WebScrollbarBehaviorImpl::shouldSnapBackToDragOrigin(
26 const blink::WebPoint& eventPoint,
27 const blink::WebRect& scrollbarRect,
28 bool isHorizontal) {
29 // Disable snapback on desktop Linux to better integrate with the desktop
30 // behavior. Typically, Linux apps do not implement scrollbar snapback (this is
31 // true for at least GTK and QT apps).
32 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS))
33 return false;
34 #endif
35
36 // Constants used to figure the drag rect outside which we should snap the
37 // scrollbar thumb back to its origin. These calculations are based on
38 // observing the behavior of the MSVC8 main window scrollbar + some
39 // guessing/extrapolation.
40 static const int kOffEndMultiplier = 3;
41 static const int kOffSideMultiplier = 8;
42 static const int kDefaultWinScrollbarThickness = 17;
43
44 // Find the rect within which we shouldn't snap, by expanding the track rect
45 // in both dimensions.
46 gfx::Rect noSnapRect(scrollbarRect);
47 int thickness = isHorizontal ? noSnapRect.height() : noSnapRect.width();
48 // Even if the platform's scrollbar is narrower than the default Windows one,
49 // we still want to provide at least as much slop area, since a slightly
50 // narrower scrollbar doesn't necessarily imply that users will drag
51 // straighter.
52 thickness = std::max(thickness, kDefaultWinScrollbarThickness);
53 noSnapRect.Inset(
54 (isHorizontal ? kOffEndMultiplier : kOffSideMultiplier) * -thickness,
55 (isHorizontal ? kOffSideMultiplier : kOffEndMultiplier) * -thickness);
56
57 return !noSnapRect.Contains(eventPoint);
58 }
59
60 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webscrollbarbehavior_impl_aura.h ('k') | content/renderer/webscrollbarbehavior_impl_gtkoraura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698