| Index: content/renderer/webscrollbarbehavior_impl_gtkoraura.cc
|
| diff --git a/content/renderer/webscrollbarbehavior_impl_gtkoraura.cc b/content/renderer/webscrollbarbehavior_impl_gtkoraura.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a07e1d47fd727d6ee9492fde8e625acd39fc1154
|
| --- /dev/null
|
| +++ b/content/renderer/webscrollbarbehavior_impl_gtkoraura.cc
|
| @@ -0,0 +1,62 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/renderer/webscrollbarbehavior_impl_gtkoraura.h"
|
| +
|
| +#include "build/build_config.h"
|
| +#include "third_party/WebKit/public/platform/WebPoint.h"
|
| +#include "third_party/WebKit/public/platform/WebRect.h"
|
| +
|
| +namespace content {
|
| +
|
| +bool WebScrollbarBehaviorImpl::shouldCenterOnThumb(
|
| + blink::WebPointerProperties::Button mouseButton,
|
| + bool shiftKeyPressed,
|
| + bool altKeyPressed) {
|
| +#if (defined(OS_LINUX) && !defined(OS_CHROMEOS))
|
| + if (mouseButton == blink::WebPointerProperties::Button::Middle)
|
| + return true;
|
| +#endif
|
| + return (mouseButton == blink::WebPointerProperties::Button::Left) &&
|
| + shiftKeyPressed;
|
| +}
|
| +
|
| +bool WebScrollbarBehaviorImpl::shouldSnapBackToDragOrigin(
|
| + const blink::WebPoint& eventPoint,
|
| + const blink::WebRect& scrollbarRect,
|
| + bool isHorizontal) {
|
| + // 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;
|
| + static const int kDefaultWinScrollbarThickness = 17;
|
| +
|
| + // Find the rect within which we shouldn't snap, by expanding the track rect
|
| + // in both dimensions.
|
| + gfx::Rect noSnapRect(scrollbarRect);
|
| + int thickness = isHorizontal ? noSnapRect.height() : noSnapRect.width();
|
| + // Even if the platform's scrollbar is narrower than the default Windows one,
|
| + // we still want to provide at least as much slop area, since a slightly
|
| + // narrower scrollbar doesn't necessarily imply that users will drag
|
| + // straighter.
|
| + thickness = std::max(thickness, kDefaultWinScrollbarThickness);
|
| + noSnapRect.Inset(
|
| + (isHorizontal ? kOffEndMultiplier : kOffSideMultiplier) * -thickness,
|
| + (isHorizontal ? kOffSideMultiplier : kOffEndMultiplier) * -thickness);
|
| +
|
| + // On most platforms, we should snap iff the event is outside our calculated
|
| + // rect. On Linux, however, we should not snap for events off the ends, but
|
| + // not the sides, of the rect.
|
| +#if (defined(OS_LINUX) && !defined(OS_CHROMEOS))
|
| + return isHorizontal ?
|
| + (eventPoint.y < noSnapRect.y() || eventPoint.y >= noSnapRect.bottom()) :
|
| + (eventPoint.x < noSnapRect.x() || eventPoint.x >= noSnapRect.right());
|
| +#else
|
| + return !noSnapRect.Contains(eventPoint);
|
| +#endif
|
| +}
|
| +
|
| +} // namespace content
|
|
|