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 RootScrollerController_h | 5 #ifndef RootScrollerController_h |
6 #define RootScrollerController_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 GraphicsLayer; | 15 class GraphicsLayer; |
| 16 class ScrollStateCallback; |
16 class ViewportScrollCallback; | 17 class ViewportScrollCallback; |
17 | 18 |
18 // Manages the root scroller associated with a given document. The root scroller | 19 // Manages the root scroller associated with a given document. The root scroller |
19 // causes top controls movement, overscroll effects and prevents chaining | 20 // causes top controls movement, overscroll effects and prevents chaining |
20 // scrolls up further in the DOM. It can be set from script using | 21 // scrolls up further in the DOM. It can be set from script using |
21 // document.setRootScroller. | 22 // document.setRootScroller. |
22 // | 23 // |
23 // There are two notions of a root scroller in this class: m_rootScroller and | 24 // There are two notions of a root scroller in this class: m_rootScroller and |
24 // m_effectiveRootScroller. The former is the Element that was set as the root | 25 // m_effectiveRootScroller. The former is the Element that was set as the root |
25 // scroller using document.setRootScroller. If the page didn't set a root | 26 // scroller using document.setRootScroller. If the page didn't set a root |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 // This class needs to be informed of changes in layout so that it can | 70 // This class needs to be informed of changes in layout so that it can |
70 // determine if the current root scroller is still valid or if it must be | 71 // determine if the current root scroller is still valid or if it must be |
71 // replaced by the defualt root scroller. | 72 // replaced by the defualt root scroller. |
72 void didUpdateLayout(); | 73 void didUpdateLayout(); |
73 | 74 |
74 // This class needs to be informed of changes to compositing so that it can | 75 // This class needs to be informed of changes to compositing so that it can |
75 // update the compositor when the effective root scroller changes. | 76 // update the compositor when the effective root scroller changes. |
76 void didUpdateCompositing(); | 77 void didUpdateCompositing(); |
77 | 78 |
| 79 // This class needs to be informed when the document has been attached to a |
| 80 // FrameView so that we can initialize the viewport scroll callback. |
| 81 void didAttachDocument(); |
| 82 |
78 GraphicsLayer* rootScrollerLayer(); | 83 GraphicsLayer* rootScrollerLayer(); |
79 | 84 |
80 // TODO(bokan): Temporarily exposed to allow ScrollCustomization to | 85 // TODO(bokan): Temporarily needed to allow ScrollCustomization to |
81 // differentiate between real custom callback and the built-in viewport | 86 // differentiate between real custom callback and the built-in viewport |
82 // apply scroll. | 87 // apply scroll. |
83 const ViewportScrollCallback* viewportScrollCallback() | 88 bool isViewportScrollCallback(const ScrollStateCallback*) const; |
84 { | |
85 return m_viewportApplyScroll; | |
86 } | |
87 | |
88 void setViewportScrollCallback(ViewportScrollCallback*); | |
89 | 89 |
90 private: | 90 private: |
91 RootScrollerController(Document&); | 91 RootScrollerController(Document&); |
92 | 92 |
93 Element* defaultEffectiveRootScroller(); | 93 Element* defaultEffectiveRootScroller(); |
94 | 94 |
95 // Ensures the effective root scroller is currently valid and replaces it | 95 // Ensures the effective root scroller is currently valid and replaces it |
96 // with the default if not. | 96 // with the default if not. |
97 void updateEffectiveRootScroller(); | 97 void updateEffectiveRootScroller(); |
98 | 98 |
99 // Returns true if the move was successful. | 99 // Called only from the top Document's RootScrollerController. Ensures that |
100 bool moveViewportApplyScroll(Element* target); | 100 // the element that should be used as the root scroller on the page has the |
| 101 // m_viewportApplyScroll callback set on it. |
| 102 void setViewportApplyScrollOnRootScroller(); |
101 | 103 |
102 WeakMember<Document> m_document; | 104 WeakMember<Document> m_document; |
103 Member<ViewportScrollCallback> m_viewportApplyScroll; | 105 Member<ViewportScrollCallback> m_viewportApplyScroll; |
104 | 106 |
105 WeakMember<Element> m_rootScroller; | 107 WeakMember<Element> m_rootScroller; |
106 | 108 |
107 // The element currently being used as the root scroller. If | 109 // The element currently being used as the root scroller. If |
108 // m_viewportApplyScroll has been set, this element is guaranteed to have it | 110 // m_viewportApplyScroll has been set, this element is guaranteed to have it |
109 // set as its applyScroll callback. This can be nullptr during | 111 // set as its applyScroll callback. This can be nullptr during |
110 // initialization and will not be set until m_viewportApplyScroll is | 112 // initialization and will not be set until m_viewportApplyScroll is |
111 // provided. | 113 // provided. |
112 WeakMember<Element> m_effectiveRootScroller; | 114 WeakMember<Element> m_effectiveRootScroller; |
| 115 |
| 116 // Tracks which element currently has the m_viewportApplyScroll set to it. |
| 117 // This will only ever be set on the top Document's RootScrollerController. |
| 118 WeakMember<Element> m_currentViewportApplyScrollHost; |
113 }; | 119 }; |
114 | 120 |
115 } // namespace blink | 121 } // namespace blink |
116 | 122 |
117 #endif // RootScrollerController_h | 123 #endif // RootScrollerController_h |
OLD | NEW |