| 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 PaintLayer; |
| 16 class ScrollableArea; | 17 class ScrollableArea; |
| 17 class ScrollStateCallback; | 18 class ScrollStateCallback; |
| 18 | 19 |
| 19 // Manages the root scroller associated with a given document. The root | 20 // Manages the root scroller associated with a given document. The root |
| 20 // scroller causes top controls movement, overscroll effects and prevents | 21 // scroller causes top controls movement, overscroll effects and prevents |
| 21 // chaining scrolls up further in the DOM. It can be set from script using | 22 // chaining scrolls up further in the DOM. It can be set from script using |
| 22 // document.setRootScroller. | 23 // document.setRootScroller. |
| 23 // | 24 // |
| 24 // There are two notions of a root scroller in this class: m_rootScroller and | 25 // There are two notions of a root scroller in this class: m_rootScroller and |
| 25 // m_effectiveRootScroller. The former is the Element that was set as the root | 26 // m_effectiveRootScroller. The former is the Element that was set as the root |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // element. | 83 // element. |
| 83 virtual GraphicsLayer* rootScrollerLayer(); | 84 virtual GraphicsLayer* rootScrollerLayer(); |
| 84 | 85 |
| 85 // Returns true if the given ScrollStateCallback is the | 86 // Returns true if the given ScrollStateCallback is the |
| 86 // ViewportScrollCallback managed by this class. | 87 // ViewportScrollCallback managed by this class. |
| 87 // TODO(bokan): Temporarily needed to allow ScrollCustomization to | 88 // TODO(bokan): Temporarily needed to allow ScrollCustomization to |
| 88 // differentiate between real custom callback and the built-in viewport | 89 // differentiate between real custom callback and the built-in viewport |
| 89 // apply scroll. crbug.com/623079. | 90 // apply scroll. crbug.com/623079. |
| 90 virtual bool isViewportScrollCallback(const ScrollStateCallback*) const; | 91 virtual bool isViewportScrollCallback(const ScrollStateCallback*) const; |
| 91 | 92 |
| 93 PaintLayer* rootScrollerPaintLayer() const; |
| 94 |
| 92 protected: | 95 protected: |
| 93 RootScrollerController(Document&); | 96 RootScrollerController(Document&); |
| 94 | 97 |
| 95 // Called when the root scroller of any descendant frames changes. This | 98 // Called when the root scroller of any descendant frames changes. This |
| 96 // will only ever be called on the top document's RootScrollerController. | 99 // will only ever be called on the top document's RootScrollerController. |
| 97 virtual void globalRootScrollerMayHaveChanged(); | 100 virtual void globalRootScrollerMayHaveChanged(); |
| 98 | 101 |
| 99 // Returns the ScrollableArea to use to scroll the given Element. | 102 // Returns the ScrollableArea to use to scroll the given Element. |
| 100 ScrollableArea* scrollableAreaFor(const Element&) const; | 103 ScrollableArea* scrollableAreaFor(const Element&) const; |
| 101 | 104 |
| 102 // The owning Document whose root scroller this object manages. | 105 // The owning Document whose root scroller this object manages. |
| 103 WeakMember<Document> m_document; | 106 WeakMember<Document> m_document; |
| 104 | 107 |
| 105 private: | 108 private: |
| 106 | |
| 107 // Ensures the effective root scroller is currently valid and replaces it | 109 // Ensures the effective root scroller is currently valid and replaces it |
| 108 // with the default if not. | 110 // with the default if not. |
| 109 void recomputeEffectiveRootScroller(); | 111 void recomputeEffectiveRootScroller(); |
| 110 | 112 |
| 111 // Determines whether the given element meets the criteria to become the | 113 // Determines whether the given element meets the criteria to become the |
| 112 // effective root scroller. | 114 // effective root scroller. |
| 113 bool isValidRootScroller(const Element&) const; | 115 bool isValidRootScroller(const Element&) const; |
| 114 | 116 |
| 115 // Returns the Element that should be used if the currently set | 117 // Returns the Element that should be used if the currently set |
| 116 // m_rootScroller isn't valid to be a root scroller. | 118 // m_rootScroller isn't valid to be a root scroller. |
| 117 Element* defaultEffectiveRootScroller(); | 119 Element* defaultEffectiveRootScroller(); |
| 118 | 120 |
| 119 // The Element that was set from script as rootScroller for this Document. | 121 // The Element that was set from script as rootScroller for this Document. |
| 120 // Depending on its validity to be the root scroller (e.g. a display: none | 122 // Depending on its validity to be the root scroller (e.g. a display: none |
| 121 // element isn't a valid root scroller), this may not actually be the | 123 // element isn't a valid root scroller), this may not actually be the |
| 122 // Element being used as the root scroller. | 124 // Element being used as the root scroller. |
| 123 WeakMember<Element> m_rootScroller; | 125 WeakMember<Element> m_rootScroller; |
| 124 | 126 |
| 125 // The element currently being used as the root scroller in this Document. | 127 // The element currently being used as the root scroller in this Document. |
| 126 // If the m_rootScroller is valid this will point to it. Otherwise, it'll | 128 // If the m_rootScroller is valid this will point to it. Otherwise, it'll |
| 127 // use a default Element. | 129 // use a default Element. |
| 128 WeakMember<Element> m_effectiveRootScroller; | 130 WeakMember<Element> m_effectiveRootScroller; |
| 129 }; | 131 }; |
| 130 | 132 |
| 131 } // namespace blink | 133 } // namespace blink |
| 132 | 134 |
| 133 #endif // RootScrollerController_h | 135 #endif // RootScrollerController_h |
| OLD | NEW |