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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp

Issue 2128543002: Make ViewportScrollCallback an interface and add child and root classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moveViewportCreationToDocumentAttachment
Patch Set: Rebase Created 4 years, 5 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 | « third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
diff --git a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
index f8cc13a7ff8d3c9b0a824568832561bc51bfe749..0c0e1d835db0954928d3ae657f22578fad853703 100644
--- a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
+++ b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
@@ -4,101 +4,28 @@
#include "core/page/scrolling/ViewportScrollCallback.h"
-#include "core/frame/FrameHost.h"
-#include "core/frame/FrameView.h"
-#include "core/frame/Settings.h"
-#include "core/frame/TopControls.h"
-#include "core/page/scrolling/OverscrollController.h"
#include "core/page/scrolling/ScrollState.h"
-#include "platform/geometry/FloatSize.h"
#include "platform/scroll/ScrollableArea.h"
namespace blink {
-ViewportScrollCallback::ViewportScrollCallback(
- TopControls* topControls, OverscrollController* overscrollController)
- : m_topControls(topControls)
- , m_overscrollController(overscrollController)
+ScrollResult ViewportScrollCallback::performNativeScroll(
+ ScrollState& state, ScrollableArea& scroller)
{
-}
-
-ViewportScrollCallback::~ViewportScrollCallback()
-{
-}
-
-DEFINE_TRACE(ViewportScrollCallback)
-{
- visitor->trace(m_topControls);
- visitor->trace(m_overscrollController);
- visitor->trace(m_scroller);
- ScrollStateCallback::trace(visitor);
-}
-
-bool ViewportScrollCallback::shouldScrollTopControls(const FloatSize& delta,
- ScrollGranularity granularity) const
-{
- if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel)
- return false;
-
- if (!m_scroller)
- return false;
-
- DoublePoint maxScroll = m_scroller->maximumScrollPositionDouble();
- DoublePoint scrollPosition = m_scroller->scrollPositionDouble();
-
- // Always give the delta to the top controls if the scroll is in
- // the direction to show the top controls. If it's in the
- // direction to hide the top controls, only give the delta to the
- // top controls when the frame can scroll.
- return delta.height() < 0 || scrollPosition.y() < maxScroll.y();
-}
-
-void ViewportScrollCallback::handleEvent(ScrollState* state)
-{
- FloatSize delta(state->deltaX(), state->deltaY());
+ 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())
- m_topControls->scrollBegin();
-
- if (shouldScrollTopControls(delta, granularity))
- remainingDelta = m_topControls->scrollBy(delta);
- }
-
- bool topControlsConsumedScroll = remainingDelta.height() != delta.height();
+ ScrollGranularity(static_cast<int>(state.deltaGranularity()));
- // Scroll the element's scrollable area.
- if (!m_scroller)
- return;
-
- ScrollResult result = m_scroller->userScroll(granularity, remainingDelta);
-
- // We consider top controls movement to be scrolling.
- result.didScrollY |= topControlsConsumedScroll;
-
- // Handle Overscroll.
- if (m_overscrollController) {
- FloatPoint position(state->positionX(), state->positionY());
- FloatSize velocity(state->velocityX(), state->velocityY());
- m_overscrollController->handleOverscroll(result, position, velocity);
- }
+ ScrollResult result = scroller.userScroll(granularity, delta);
// 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);
-}
+ // the main thread pull-to-refresh action. crbug.com/607210.
+ state.consumeDeltaNative(
+ delta.width() - result.unusedScrollDeltaX,
+ delta.height() - result.unusedScrollDeltaY);
-void ViewportScrollCallback::setScroller(ScrollableArea* scroller)
-{
- m_scroller = scroller;
+ return result;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698