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 #ifndef RootScroller_h | 5 #ifndef RootScrollerController_h |
6 #define RootScroller_h | 6 #define RootScrollerController_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class Document; | 13 class Document; |
14 class Element; | 14 class Element; |
15 class OverscrollController; | 15 class OverscrollController; |
16 class TopControls; | 16 class TopControls; |
(...skipping 11 matching lines...) Expand all Loading... |
28 // element we're using internally to apply viewport scroll actions. i.e It's the | 28 // element we're using internally to apply viewport scroll actions. i.e It's the |
29 // element with the ViewportScrollCallback set as its apply-scroll callback. | 29 // element with the ViewportScrollCallback set as its apply-scroll callback. |
30 // The effective root scroller will only be null during document initialization. | 30 // The effective root scroller will only be null during document initialization. |
31 // | 31 // |
32 // If the root scroller element is a valid element to become the root scroller, | 32 // If the root scroller element is a valid element to become the root scroller, |
33 // it will be promoted to the effective root scroller. If it is not valid, the | 33 // it will be promoted to the effective root scroller. If it is not valid, the |
34 // effective root scroller will fall back to a default Element (see | 34 // effective root scroller will fall back to a default Element (see |
35 // defaultEffectiveRootScroller()). The rules for what makes an element a valid | 35 // defaultEffectiveRootScroller()). The rules for what makes an element a valid |
36 // root scroller are set in isValidRootScroller(). The validity of the current | 36 // root scroller are set in isValidRootScroller(). The validity of the current |
37 // root scroller is re-checked after each layout. | 37 // root scroller is re-checked after each layout. |
38 class CORE_EXPORT RootScroller : public GarbageCollected<RootScroller> { | 38 class CORE_EXPORT RootScrollerController |
| 39 : public GarbageCollected<RootScrollerController> { |
39 public: | 40 public: |
40 // Creates a RootScroller for the given document. An optional | 41 // Creates a RootScrollerController for the given document. An optional |
41 // ViewportScrollCallback can be provided. If it is, RootScroller will | 42 // ViewportScrollCallback can be provided. If it is, RootScrollerController |
42 // ensure that the effectiveRootScroller element always has this set as the | 43 // will ensure that the effectiveRootScroller element always has this set as |
43 // apply scroll callback. | 44 // the apply scroll callback. |
44 static RootScroller* create( | 45 static RootScrollerController* create( |
45 Document& document, | 46 Document& document, |
46 ViewportScrollCallback* applyScrollCallback) | 47 ViewportScrollCallback* applyScrollCallback) |
47 { | 48 { |
48 return new RootScroller(document, applyScrollCallback); | 49 return new RootScrollerController(document, applyScrollCallback); |
49 } | 50 } |
50 | 51 |
51 // Creates an apply scroll callback that handles viewport actions like | 52 // Creates an apply scroll callback that handles viewport actions like |
52 // TopControls movement and Overscroll. | 53 // TopControls movement and Overscroll. |
53 static ViewportScrollCallback* createViewportApplyScroll( | 54 static ViewportScrollCallback* createViewportApplyScroll( |
54 TopControls&, OverscrollController&); | 55 TopControls&, OverscrollController&); |
55 | 56 |
56 DECLARE_TRACE(); | 57 DECLARE_TRACE(); |
57 | 58 |
58 // Sets the element that will be used as the root scroller. This can be | 59 // Sets the element that will be used as the root scroller. This can be |
(...skipping 13 matching lines...) Expand all Loading... |
72 // actions right now. This is different from get() if a root scroller hasn't | 73 // actions right now. This is different from get() if a root scroller hasn't |
73 // been set, or if the set root scroller isn't currently a valid scroller. | 74 // been set, or if the set root scroller isn't currently a valid scroller. |
74 Element* effectiveRootScroller() const; | 75 Element* effectiveRootScroller() const; |
75 | 76 |
76 // This class needs to be informed of changes in layout so that it can | 77 // This class needs to be informed of changes in layout so that it can |
77 // determine if the current root scroller is still valid or if it must be | 78 // determine if the current root scroller is still valid or if it must be |
78 // replaced by the defualt root scroller. | 79 // replaced by the defualt root scroller. |
79 void didUpdateLayout(); | 80 void didUpdateLayout(); |
80 | 81 |
81 private: | 82 private: |
82 RootScroller(Document&, ViewportScrollCallback*); | 83 RootScrollerController(Document&, ViewportScrollCallback*); |
83 | 84 |
84 Element* defaultEffectiveRootScroller(); | 85 Element* defaultEffectiveRootScroller(); |
85 | 86 |
86 // Ensures the effective root scroller is currently valid and replaces it | 87 // Ensures the effective root scroller is currently valid and replaces it |
87 // with the default if not. | 88 // with the default if not. |
88 void updateEffectiveRootScroller(); | 89 void updateEffectiveRootScroller(); |
89 void moveViewportApplyScroll(Element* target); | 90 void moveViewportApplyScroll(Element* target); |
90 | 91 |
91 WeakMember<Document> m_document; | 92 WeakMember<Document> m_document; |
92 Member<ViewportScrollCallback> m_viewportApplyScroll; | 93 Member<ViewportScrollCallback> m_viewportApplyScroll; |
93 | 94 |
94 WeakMember<Element> m_rootScroller; | 95 WeakMember<Element> m_rootScroller; |
95 WeakMember<Element> m_effectiveRootScroller; | 96 WeakMember<Element> m_effectiveRootScroller; |
96 }; | 97 }; |
97 | 98 |
98 } // namespace blink | 99 } // namespace blink |
99 | 100 |
100 #endif // RootScroller_h | 101 #endif // RootScrollerController_h |
OLD | NEW |