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 "platform/scroll/ScrollableArea.h" | 8 #include "platform/scroll/ScrollableArea.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class LayoutRect; | 12 class LayoutRect; |
13 | 13 |
14 // ScrollableArea for the root frame's viewport. This class ties together the | 14 // ScrollableArea for the root frame's viewport. This class ties together the |
15 // concepts of layout and visual viewports, used in pinch-to-zoom. This class | 15 // concepts of layout and visual viewports, used in pinch-to-zoom. This class |
16 // takes two ScrollableAreas, one for the visual viewport and one for the | 16 // takes two ScrollableAreas, one for the visual viewport and one for the |
17 // layout viewport, and delegates and composes the ScrollableArea API as needed | 17 // layout viewport, and delegates and composes the ScrollableArea API as needed |
18 // between them. For most scrolling APIs, this class will split the scroll up | 18 // between them. For most scrolling APIs, this class will split the scroll up |
19 // between the two viewports in accord with the pinch-zoom semantics. For other | 19 // between the two viewports in accord with the pinch-zoom semantics. For other |
20 // APIs that don't make sense on the combined viewport, the call is delegated to | 20 // APIs that don't make sense on the combined viewport, the call is delegated to |
21 // the layout viewport. Thus, we could say this class is a decorator on the | 21 // the layout viewport. Thus, we could say this class is a decorator on the |
22 // FrameView scrollable area that adds pinch-zoom semantics to scrolling. | 22 // FrameView scrollable area that adds pinch-zoom semantics to scrolling. |
23 class RootFrameViewport final : public NoBaseWillBeGarbageCollectedFinalized<Roo
tFrameViewport>, public ScrollableArea { | 23 class RootFrameViewport final : public ScrollableArea { |
24 public: | 24 public: |
25 DECLARE_VIRTUAL_TRACE(); | 25 static PassOwnPtr<RootFrameViewport> create(ScrollableArea& visualViewport,
ScrollableArea& layoutViewport) |
26 static PassOwnPtrWillBeRawPtr<RootFrameViewport> create(ScrollableArea& visu
alViewport, ScrollableArea& layoutViewport) | |
27 { | 26 { |
28 return adoptPtrWillBeNoop(new RootFrameViewport(visualViewport, layoutVi
ewport)); | 27 return adoptPtr(new RootFrameViewport(visualViewport, layoutViewport)); |
29 } | 28 } |
30 | 29 |
31 // ScrollableArea Implementation | 30 // ScrollableArea Implementation |
32 void setScrollPosition(const DoublePoint&, ScrollBehavior = ScrollBehaviorIn
stant) override; | 31 void setScrollPosition(const DoublePoint&, ScrollBehavior = ScrollBehaviorIn
stant) override; |
33 LayoutRect scrollIntoView( | 32 LayoutRect scrollIntoView( |
34 const LayoutRect& rectInContent, | 33 const LayoutRect& rectInContent, |
35 const ScrollAlignment& alignX, | 34 const ScrollAlignment& alignX, |
36 const ScrollAlignment& alignY) override; | 35 const ScrollAlignment& alignY) override; |
37 DoubleRect visibleContentRectDouble(IncludeScrollbarsInRect = ExcludeScrollb
ars) const override; | 36 DoubleRect visibleContentRectDouble(IncludeScrollbarsInRect = ExcludeScrollb
ars) const override; |
38 IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) cons
t override; | 37 IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) cons
t override; |
(...skipping 19 matching lines...) Expand all Loading... |
58 GraphicsLayer* layerForContainer() const override; | 57 GraphicsLayer* layerForContainer() const override; |
59 GraphicsLayer* layerForScrolling() const override; | 58 GraphicsLayer* layerForScrolling() const override; |
60 GraphicsLayer* layerForHorizontalScrollbar() const override; | 59 GraphicsLayer* layerForHorizontalScrollbar() const override; |
61 GraphicsLayer* layerForVerticalScrollbar() const override; | 60 GraphicsLayer* layerForVerticalScrollbar() const override; |
62 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1) override; | 61 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1) override; |
63 // TODO(bokan): This method should be removed. It should be replaced by | 62 // TODO(bokan): This method should be removed. It should be replaced by |
64 // making EventHandler::handleWheelEvent unpack the WheelEvent and make a | 63 // making EventHandler::handleWheelEvent unpack the WheelEvent and make a |
65 // call to this class' scroll method. | 64 // call to this class' scroll method. |
66 ScrollResult handleWheel(const PlatformWheelEvent&) override; | 65 ScrollResult handleWheel(const PlatformWheelEvent&) override; |
67 | 66 |
68 | |
69 private: | 67 private: |
70 RootFrameViewport(ScrollableArea& visualViewport, ScrollableArea& layoutView
port); | 68 RootFrameViewport(ScrollableArea& visualViewport, ScrollableArea& layoutView
port); |
71 | 69 |
72 DoublePoint scrollOffsetFromScrollAnimators() const; | 70 DoublePoint scrollOffsetFromScrollAnimators() const; |
73 | 71 |
74 // If either of the layout or visual viewports are scrolled explicitly (i.e.
not | 72 // If either of the layout or visual viewports are scrolled explicitly (i.e.
not |
75 // through this class), their updated offset will not be reflected in this c
lass' | 73 // through this class), their updated offset will not be reflected in this c
lass' |
76 // animator so use this method to pull updated values when necessary. | 74 // animator so use this method to pull updated values when necessary. |
77 void updateScrollAnimator(); | 75 void updateScrollAnimator(); |
78 | 76 |
79 ScrollableArea& visualViewport() const { return *m_visualViewport; } | 77 ScrollableArea& visualViewport() const { return m_visualViewport; } |
80 ScrollableArea& layoutViewport() const { return *m_layoutViewport; } | 78 ScrollableArea& layoutViewport() const { return m_layoutViewport; } |
81 | 79 |
82 RawPtrWillBeMember<ScrollableArea> m_visualViewport; | 80 ScrollableArea& m_visualViewport; |
83 RawPtrWillBeMember<ScrollableArea> m_layoutViewport; | 81 ScrollableArea& m_layoutViewport; |
84 }; | 82 }; |
85 | 83 |
86 } // namespace blink | 84 } // namespace blink |
87 | 85 |
88 #endif // RootFrameViewport_h | 86 #endif // RootFrameViewport_h |
OLD | NEW |