| Index: third_party/WebKit/Source/core/page/scrolling/RootViewportScrollCallback.cpp
|
| diff --git a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp b/third_party/WebKit/Source/core/page/scrolling/RootViewportScrollCallback.cpp
|
| similarity index 58%
|
| copy from third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
|
| copy to third_party/WebKit/Source/core/page/scrolling/RootViewportScrollCallback.cpp
|
| index f8cc13a7ff8d3c9b0a824568832561bc51bfe749..a75ebc3a0c280ad08012e8461212c700d4233ec3 100644
|
| --- a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
|
| +++ b/third_party/WebKit/Source/core/page/scrolling/RootViewportScrollCallback.cpp
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "core/page/scrolling/ViewportScrollCallback.h"
|
| +#include "core/page/scrolling/RootViewportScrollCallback.h"
|
|
|
| #include "core/frame/FrameHost.h"
|
| #include "core/frame/FrameView.h"
|
| @@ -15,26 +15,26 @@
|
|
|
| namespace blink {
|
|
|
| -ViewportScrollCallback::ViewportScrollCallback(
|
| +RootViewportScrollCallback::RootViewportScrollCallback(
|
| TopControls* topControls, OverscrollController* overscrollController)
|
| : m_topControls(topControls)
|
| , m_overscrollController(overscrollController)
|
| {
|
| }
|
|
|
| -ViewportScrollCallback::~ViewportScrollCallback()
|
| +RootViewportScrollCallback::~RootViewportScrollCallback()
|
| {
|
| }
|
|
|
| -DEFINE_TRACE(ViewportScrollCallback)
|
| +DEFINE_TRACE(RootViewportScrollCallback)
|
| {
|
| visitor->trace(m_topControls);
|
| visitor->trace(m_overscrollController);
|
| visitor->trace(m_scroller);
|
| - ScrollStateCallback::trace(visitor);
|
| + ViewportScrollCallback::trace(visitor);
|
| }
|
|
|
| -bool ViewportScrollCallback::shouldScrollTopControls(const FloatSize& delta,
|
| +bool RootViewportScrollCallback::shouldScrollTopControls(const FloatSize& delta,
|
| ScrollGranularity granularity) const
|
| {
|
| if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel)
|
| @@ -53,32 +53,39 @@ bool ViewportScrollCallback::shouldScrollTopControls(const FloatSize& delta,
|
| return delta.height() < 0 || scrollPosition.y() < maxScroll.y();
|
| }
|
|
|
| -void ViewportScrollCallback::handleEvent(ScrollState* state)
|
| +bool RootViewportScrollCallback::scrollTopControls(ScrollState& state)
|
| {
|
| - FloatSize delta(state->deltaX(), state->deltaY());
|
| - ScrollGranularity granularity =
|
| - ScrollGranularity(static_cast<int>(state->deltaGranularity()));
|
| - FloatSize remainingDelta = delta;
|
| -
|
| // Scroll top controls.
|
| if (m_topControls) {
|
| - if (state->isBeginning())
|
| + if (state.isBeginning())
|
| m_topControls->scrollBegin();
|
|
|
| - if (shouldScrollTopControls(delta, granularity))
|
| - remainingDelta = m_topControls->scrollBy(delta);
|
| + FloatSize delta(state.deltaX(), state.deltaY());
|
| + ScrollGranularity granularity =
|
| + ScrollGranularity(static_cast<int>(state.deltaGranularity()));
|
| + if (shouldScrollTopControls(delta, granularity)) {
|
| + FloatSize remainingDelta = m_topControls->scrollBy(delta);
|
| + FloatSize consumed = delta - remainingDelta;
|
| + state.consumeDeltaNative(consumed.width(), consumed.height());
|
| + return !consumed.isZero();
|
| + }
|
| }
|
|
|
| - bool topControlsConsumedScroll = remainingDelta.height() != delta.height();
|
| + return false;
|
| +}
|
|
|
| - // Scroll the element's scrollable area.
|
| +void RootViewportScrollCallback::handleEvent(ScrollState* state)
|
| +{
|
| + DCHECK(state);
|
| if (!m_scroller)
|
| return;
|
|
|
| - ScrollResult result = m_scroller->userScroll(granularity, remainingDelta);
|
| + bool topControlsDidScroll = scrollTopControls(*state);
|
| +
|
| + ScrollResult result = performNativeScroll(*state, *m_scroller);
|
|
|
| // We consider top controls movement to be scrolling.
|
| - result.didScrollY |= topControlsConsumedScroll;
|
| + result.didScrollY |= topControlsDidScroll;
|
|
|
| // Handle Overscroll.
|
| if (m_overscrollController) {
|
| @@ -86,17 +93,9 @@ void ViewportScrollCallback::handleEvent(ScrollState* state)
|
| FloatSize velocity(state->velocityX(), state->velocityY());
|
| m_overscrollController->handleOverscroll(result, position, velocity);
|
| }
|
| -
|
| - // The viewport consumes everything.
|
| - // TODO(bokan): This isn't actually consuming everything but doing so breaks
|
| - // the main thread pull-to-refresh action. I need to figure out where that
|
| - // gets activated. crbug.com/607210.
|
| - state->consumeDeltaNative(
|
| - state->deltaX() - result.unusedScrollDeltaX,
|
| - state->deltaY() - result.unusedScrollDeltaY);
|
| }
|
|
|
| -void ViewportScrollCallback::setScroller(ScrollableArea* scroller)
|
| +void RootViewportScrollCallback::setScroller(ScrollableArea* scroller)
|
| {
|
| m_scroller = scroller;
|
| }
|
|
|