| 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 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // will ensure that the effectiveRootScroller element always has this set as | 43 // will ensure that the effectiveRootScroller element always has this set as |
| 44 // the apply scroll callback. | 44 // the apply scroll callback. |
| 45 static RootScrollerController* create( | 45 static RootScrollerController* create( |
| 46 Document& document, | 46 Document& document, |
| 47 ViewportScrollCallback* applyScrollCallback) | 47 ViewportScrollCallback* applyScrollCallback) |
| 48 { | 48 { |
| 49 return new RootScrollerController(document, applyScrollCallback); | 49 return new RootScrollerController(document, applyScrollCallback); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Creates an apply scroll callback that handles viewport actions like | 52 // Creates an apply scroll callback that handles viewport actions like |
| 53 // TopControls movement and Overscroll. | 53 // TopControls movement and Overscroll. The TopControls and |
| 54 // OverscrollController are given to the ViewportScrollCallback but are not |
| 55 // owned or kept alive by it. |
| 54 static ViewportScrollCallback* createViewportApplyScroll( | 56 static ViewportScrollCallback* createViewportApplyScroll( |
| 55 TopControls&, OverscrollController&); | 57 TopControls*, OverscrollController*); |
| 56 | 58 |
| 57 DECLARE_TRACE(); | 59 DECLARE_TRACE(); |
| 58 | 60 |
| 59 // Sets the element that will be used as the root scroller. This can be | 61 // Sets the element that will be used as the root scroller. This can be |
| 60 // nullptr, in which case we'll use the default element (documentElement) as | 62 // nullptr, in which case we'll use the default element (documentElement) as |
| 61 // the effective root scroller. | 63 // the effective root scroller. |
| 62 void set(Element*); | 64 void set(Element*); |
| 63 | 65 |
| 64 // Returns the element currently set as the root scroller from script. This | 66 // Returns the element currently set as the root scroller from script. This |
| 65 // differs from the effective root scroller since the set Element may not | 67 // differs from the effective root scroller since the set Element may not |
| 66 // currently be a valid root scroller. e.g. If the page sets an Element | 68 // currently be a valid root scroller. e.g. If the page sets an Element |
| 67 // with `display: none`, get() will return that element, even though the | 69 // with `display: none`, get() will return that element, even though the |
| 68 // effective root scroller will remain the element returned by | 70 // effective root scroller will remain the element returned by |
| 69 // defaultEffectiveRootScroller(). | 71 // defaultEffectiveRootScroller(). |
| 70 Element* get() const; | 72 Element* get() const; |
| 71 | 73 |
| 72 // This returns the Element that's actually being used to control viewport | 74 // This returns the Element that's actually being used to control viewport |
| 73 // actions right now. This is different from get() if a root scroller hasn't | 75 // actions right now. This is different from get() if a root scroller hasn't |
| 74 // been set, or if the set root scroller isn't currently a valid scroller. | 76 // been set, or if the set root scroller isn't currently a valid scroller. |
| 75 Element* effectiveRootScroller() const; | 77 Element* effectiveRootScroller() const; |
| 76 | 78 |
| 77 // This class needs to be informed of changes in layout so that it can | 79 // This class needs to be informed of changes in layout so that it can |
| 78 // determine if the current root scroller is still valid or if it must be | 80 // determine if the current root scroller is still valid or if it must be |
| 79 // replaced by the defualt root scroller. | 81 // replaced by the defualt root scroller. |
| 80 void didUpdateLayout(); | 82 void didUpdateLayout(); |
| 81 | 83 |
| 84 // TODO(bokan): Temporarily exposed to allow ScrollCustomization to |
| 85 // differentiate between real custom callback and the built-in viewport |
| 86 // apply scroll. |
| 87 const ViewportScrollCallback* viewportScrollCallback() |
| 88 { |
| 89 return m_viewportApplyScroll; |
| 90 } |
| 91 |
| 82 private: | 92 private: |
| 83 RootScrollerController(Document&, ViewportScrollCallback*); | 93 RootScrollerController(Document&, ViewportScrollCallback*); |
| 84 | 94 |
| 85 Element* defaultEffectiveRootScroller(); | 95 Element* defaultEffectiveRootScroller(); |
| 86 | 96 |
| 87 // Ensures the effective root scroller is currently valid and replaces it | 97 // Ensures the effective root scroller is currently valid and replaces it |
| 88 // with the default if not. | 98 // with the default if not. |
| 89 void updateEffectiveRootScroller(); | 99 void updateEffectiveRootScroller(); |
| 90 void moveViewportApplyScroll(Element* target); | 100 void moveViewportApplyScroll(Element* target); |
| 91 | 101 |
| 92 WeakMember<Document> m_document; | 102 WeakMember<Document> m_document; |
| 93 Member<ViewportScrollCallback> m_viewportApplyScroll; | 103 Member<ViewportScrollCallback> m_viewportApplyScroll; |
| 94 | 104 |
| 95 WeakMember<Element> m_rootScroller; | 105 WeakMember<Element> m_rootScroller; |
| 96 WeakMember<Element> m_effectiveRootScroller; | 106 WeakMember<Element> m_effectiveRootScroller; |
| 97 }; | 107 }; |
| 98 | 108 |
| 99 } // namespace blink | 109 } // namespace blink |
| 100 | 110 |
| 101 #endif // RootScrollerController_h | 111 #endif // RootScrollerController_h |
| OLD | NEW |