| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/page/scrolling/ViewportScrollCallback.h" | 5 #include "core/page/scrolling/ViewportScrollCallback.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameHost.h" | 7 #include "core/frame/FrameHost.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/RootFrameViewport.h" | 9 #include "core/frame/RootFrameViewport.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 ViewportScrollCallback::~ViewportScrollCallback() {} | 27 ViewportScrollCallback::~ViewportScrollCallback() {} |
| 28 | 28 |
| 29 DEFINE_TRACE(ViewportScrollCallback) { | 29 DEFINE_TRACE(ViewportScrollCallback) { |
| 30 visitor->trace(m_topControls); | 30 visitor->trace(m_topControls); |
| 31 visitor->trace(m_overscrollController); | 31 visitor->trace(m_overscrollController); |
| 32 visitor->trace(m_rootFrameViewport); | 32 visitor->trace(m_rootFrameViewport); |
| 33 ScrollStateCallback::trace(visitor); | 33 ScrollStateCallback::trace(visitor); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool ViewportScrollCallback::shouldScrollTopControls( | 36 bool ViewportScrollCallback::shouldScrollTopControls( |
| 37 const FloatSize& delta, | 37 const ScrollOffset& delta, |
| 38 ScrollGranularity granularity) const { | 38 ScrollGranularity granularity) const { |
| 39 if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel) | 39 if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel) |
| 40 return false; | 40 return false; |
| 41 | 41 |
| 42 if (!m_rootFrameViewport) | 42 if (!m_rootFrameViewport) |
| 43 return false; | 43 return false; |
| 44 | 44 |
| 45 DoublePoint maxScroll = m_rootFrameViewport->maximumScrollPositionDouble(); | 45 ScrollOffset maxScroll = m_rootFrameViewport->maximumScrollOffset(); |
| 46 DoublePoint scrollPosition = m_rootFrameViewport->scrollPositionDouble(); | 46 ScrollOffset scrollOffset = m_rootFrameViewport->scrollOffset(); |
| 47 | 47 |
| 48 // Always give the delta to the top controls if the scroll is in | 48 // Always give the delta to the top controls if the scroll is in |
| 49 // the direction to show the top controls. If it's in the | 49 // the direction to show the top controls. If it's in the |
| 50 // direction to hide the top controls, only give the delta to the | 50 // direction to hide the top controls, only give the delta to the |
| 51 // top controls when the frame can scroll. | 51 // top controls when the frame can scroll. |
| 52 return delta.height() < 0 || scrollPosition.y() < maxScroll.y(); | 52 return delta.height() < 0 || scrollOffset.height() < maxScroll.height(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool ViewportScrollCallback::scrollTopControls(ScrollState& state) { | 55 bool ViewportScrollCallback::scrollTopControls(ScrollState& state) { |
| 56 // Scroll top controls. | 56 // Scroll top controls. |
| 57 if (m_topControls) { | 57 if (m_topControls) { |
| 58 if (state.isBeginning()) | 58 if (state.isBeginning()) |
| 59 m_topControls->scrollBegin(); | 59 m_topControls->scrollBegin(); |
| 60 | 60 |
| 61 FloatSize delta(state.deltaX(), state.deltaY()); | 61 FloatSize delta(state.deltaX(), state.deltaY()); |
| 62 ScrollGranularity granularity = | 62 ScrollGranularity granularity = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // The viewport consumes everything. | 109 // The viewport consumes everything. |
| 110 // TODO(bokan): This isn't actually consuming everything but doing so breaks | 110 // TODO(bokan): This isn't actually consuming everything but doing so breaks |
| 111 // the main thread pull-to-refresh action. crbug.com/607210. | 111 // the main thread pull-to-refresh action. crbug.com/607210. |
| 112 state.consumeDeltaNative(delta.width() - result.unusedScrollDeltaX, | 112 state.consumeDeltaNative(delta.width() - result.unusedScrollDeltaX, |
| 113 delta.height() - result.unusedScrollDeltaY); | 113 delta.height() - result.unusedScrollDeltaY); |
| 114 | 114 |
| 115 return result; | 115 return result; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |