| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef RootFrameViewport_h | 5 #ifndef RootFrameViewport_h |
| 6 #define RootFrameViewport_h | 6 #define RootFrameViewport_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/scroll/ScrollableArea.h" | 9 #include "platform/scroll/ScrollableArea.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class LayoutRect; | 13 class LayoutRect; |
| 14 | 14 |
| 15 // ScrollableArea for the root frame's viewport. This class ties together the | 15 // ScrollableArea for the root frame's viewport. This class ties together the |
| 16 // concepts of layout and visual viewports, used in pinch-to-zoom. This class | 16 // concepts of layout and visual viewports, used in pinch-to-zoom. This class |
| 17 // takes two ScrollableAreas, one for the visual viewport and one for the | 17 // takes two ScrollableAreas, one for the visual viewport and one for the |
| 18 // layout viewport, and delegates and composes the ScrollableArea API as needed | 18 // layout viewport, and delegates and composes the ScrollableArea API as needed |
| 19 // between them. For most scrolling APIs, this class will split the scroll up | 19 // between them. For most scrolling APIs, this class will split the scroll up |
| 20 // between the two viewports in accord with the pinch-zoom semantics. For other | 20 // between the two viewports in accord with the pinch-zoom semantics. For other |
| 21 // APIs that don't make sense on the combined viewport, the call is delegated to | 21 // APIs that don't make sense on the combined viewport, the call is delegated to |
| 22 // the layout viewport. Thus, we could say this class is a decorator on the | 22 // the layout viewport. Thus, we could say this class is a decorator on the |
| 23 // FrameView scrollable area that adds pinch-zoom semantics to scrolling. | 23 // FrameView scrollable area that adds pinch-zoom semantics to scrolling. |
| 24 class CORE_EXPORT RootFrameViewport final : public NoBaseWillBeGarbageCollectedF
inalized<RootFrameViewport>, public ScrollableArea { | 24 class CORE_EXPORT RootFrameViewport final : public NoBaseWillBeGarbageCollectedF
inalized<RootFrameViewport>, public ScrollableArea { |
| 25 USING_FAST_MALLOC_WILL_BE_REMOVED(RootFrameViewport); | 25 USING_FAST_MALLOC_WILL_BE_REMOVED(RootFrameViewport); |
| 26 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RootFrameViewport); | 26 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RootFrameViewport); |
| 27 public: | 27 public: |
| 28 static PassOwnPtrWillBeRawPtr<RootFrameViewport> create(ScrollableArea& visu
alViewport, ScrollableArea& layoutViewport) | 28 static PassOwnPtrWillBeRawPtr<RootFrameViewport> create(ScrollableArea& visu
alViewport, ScrollableArea& layoutViewport, bool invertScrollOrder = false) |
| 29 { | 29 { |
| 30 return adoptPtrWillBeNoop(new RootFrameViewport(visualViewport, layoutVi
ewport)); | 30 return adoptPtrWillBeNoop(new RootFrameViewport(visualViewport, layoutVi
ewport, invertScrollOrder)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DECLARE_VIRTUAL_TRACE(); | 33 DECLARE_VIRTUAL_TRACE(); |
| 34 | 34 |
| 35 // ScrollableArea Implementation | 35 // ScrollableArea Implementation |
| 36 void setScrollPosition(const DoublePoint&, ScrollType, ScrollBehavior = Scro
llBehaviorInstant) override; | 36 void setScrollPosition(const DoublePoint&, ScrollType, ScrollBehavior = Scro
llBehaviorInstant) override; |
| 37 LayoutRect scrollIntoView( | 37 LayoutRect scrollIntoView( |
| 38 const LayoutRect& rectInContent, | 38 const LayoutRect& rectInContent, |
| 39 const ScrollAlignment& alignX, | 39 const ScrollAlignment& alignX, |
| 40 const ScrollAlignment& alignY, | 40 const ScrollAlignment& alignY, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 64 GraphicsLayer* layerForHorizontalScrollbar() const override; | 64 GraphicsLayer* layerForHorizontalScrollbar() const override; |
| 65 GraphicsLayer* layerForVerticalScrollbar() const override; | 65 GraphicsLayer* layerForVerticalScrollbar() const override; |
| 66 ScrollResultOneDimensional userScroll(ScrollDirectionPhysical, ScrollGranula
rity, float delta = 1) override; | 66 ScrollResultOneDimensional userScroll(ScrollDirectionPhysical, ScrollGranula
rity, float delta = 1) override; |
| 67 bool scrollAnimatorEnabled() const override; | 67 bool scrollAnimatorEnabled() const override; |
| 68 HostWindow* hostWindow() const override; | 68 HostWindow* hostWindow() const override; |
| 69 void serviceScrollAnimations(double) override; | 69 void serviceScrollAnimations(double) override; |
| 70 void updateCompositorScrollAnimations() override; | 70 void updateCompositorScrollAnimations() override; |
| 71 ScrollBehavior scrollBehaviorStyle() const override; | 71 ScrollBehavior scrollBehaviorStyle() const override; |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 RootFrameViewport(ScrollableArea& visualViewport, ScrollableArea& layoutView
port); | 74 RootFrameViewport(ScrollableArea& visualViewport, ScrollableArea& layoutView
port, bool invertScrollOrder); |
| 75 | 75 |
| 76 DoublePoint scrollOffsetFromScrollAnimators() const; | 76 DoublePoint scrollOffsetFromScrollAnimators() const; |
| 77 | 77 |
| 78 void distributeScrollBetweenViewports(const DoublePoint&, ScrollType, Scroll
Behavior); | 78 void distributeScrollBetweenViewports(const DoublePoint&, ScrollType, Scroll
Behavior); |
| 79 | 79 |
| 80 // If either of the layout or visual viewports are scrolled explicitly (i.e.
not | 80 // If either of the layout or visual viewports are scrolled explicitly (i.e.
not |
| 81 // through this class), their updated offset will not be reflected in this c
lass' | 81 // through this class), their updated offset will not be reflected in this c
lass' |
| 82 // animator so use this method to pull updated values when necessary. | 82 // animator so use this method to pull updated values when necessary. |
| 83 void updateScrollAnimator(); | 83 void updateScrollAnimator(); |
| 84 | 84 |
| 85 ScrollableArea& visualViewport() const { ASSERT(m_visualViewport); return *m
_visualViewport; } | 85 ScrollableArea& visualViewport() const { ASSERT(m_visualViewport); return *m
_visualViewport; } |
| 86 ScrollableArea& layoutViewport() const { ASSERT(m_layoutViewport); return *m
_layoutViewport; } | 86 ScrollableArea& layoutViewport() const { ASSERT(m_layoutViewport); return *m
_layoutViewport; } |
| 87 | 87 |
| 88 RawPtrWillBeMember<ScrollableArea> m_visualViewport; | 88 RawPtrWillBeMember<ScrollableArea> m_visualViewport; |
| 89 RawPtrWillBeMember<ScrollableArea> m_layoutViewport; | 89 RawPtrWillBeMember<ScrollableArea> m_layoutViewport; |
| 90 |
| 91 // Experimental flag. If the experiment is enabled, scroll the visual viewpo
rt first, |
| 92 // the bubble scrolls to the layout viewport. |
| 93 bool m_invertScrollOrder; |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 } // namespace blink | 96 } // namespace blink |
| 93 | 97 |
| 94 #endif // RootFrameViewport_h | 98 #endif // RootFrameViewport_h |
| OLD | NEW |