| 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 18 matching lines...) Expand all Loading... |
| 29 // | 29 // |
| 30 // If the root scroller element is a valid element to become the root scroller, | 30 // If the root scroller element is a valid element to become the root scroller, |
| 31 // it will be promoted to the effective root scroller. If it is not valid, the | 31 // it will be promoted to the effective root scroller. If it is not valid, the |
| 32 // effective root scroller will fall back to a default Element (see | 32 // effective root scroller will fall back to a default Element (see |
| 33 // defaultEffectiveRootScroller()). The rules for what makes an element a valid | 33 // defaultEffectiveRootScroller()). The rules for what makes an element a valid |
| 34 // root scroller are set in isValidRootScroller(). The validity of the current | 34 // root scroller are set in isValidRootScroller(). The validity of the current |
| 35 // root scroller is re-checked after each layout. | 35 // root scroller is re-checked after each layout. |
| 36 class CORE_EXPORT RootScrollerController | 36 class CORE_EXPORT RootScrollerController |
| 37 : public GarbageCollected<RootScrollerController> { | 37 : public GarbageCollected<RootScrollerController> { |
| 38 public: | 38 public: |
| 39 // Creates a RootScrollerController for the given document. An optional | 39 // Creates a RootScrollerController for the given document. You should use |
| 40 // ViewportScrollCallback can be provided. If it is, RootScrollerController | 40 // setViewportScrollCallback to provide this class with a scroll callback |
| 41 // will ensure that the effectiveRootScroller element always has this set as | 41 // that RootScrollerController will keep applied to the current RootScroller |
| 42 // the apply scroll callback. | 42 // so that special actions can occur on scrolling. |
| 43 static RootScrollerController* create( | 43 static RootScrollerController* create(Document& document) |
| 44 Document& document, | |
| 45 ViewportScrollCallback* applyScrollCallback) | |
| 46 { | 44 { |
| 47 return new RootScrollerController(document, applyScrollCallback); | 45 return new RootScrollerController(document); |
| 48 } | 46 } |
| 49 | 47 |
| 50 DECLARE_TRACE(); | 48 DECLARE_TRACE(); |
| 51 | 49 |
| 52 // Sets the element that will be used as the root scroller. This can be | 50 // Sets the element that will be used as the root scroller. This can be |
| 53 // nullptr, in which case we'll use the default element (documentElement) as | 51 // nullptr, in which case we'll use the default element (documentElement) as |
| 54 // the effective root scroller. | 52 // the effective root scroller. |
| 55 void set(Element*); | 53 void set(Element*); |
| 56 | 54 |
| 57 // Returns the element currently set as the root scroller from script. This | 55 // Returns the element currently set as the root scroller from script. This |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 void didUpdateLayout(); | 71 void didUpdateLayout(); |
| 74 | 72 |
| 75 // TODO(bokan): Temporarily exposed to allow ScrollCustomization to | 73 // TODO(bokan): Temporarily exposed to allow ScrollCustomization to |
| 76 // differentiate between real custom callback and the built-in viewport | 74 // differentiate between real custom callback and the built-in viewport |
| 77 // apply scroll. | 75 // apply scroll. |
| 78 const ViewportScrollCallback* viewportScrollCallback() | 76 const ViewportScrollCallback* viewportScrollCallback() |
| 79 { | 77 { |
| 80 return m_viewportApplyScroll; | 78 return m_viewportApplyScroll; |
| 81 } | 79 } |
| 82 | 80 |
| 81 void setViewportScrollCallback(ViewportScrollCallback*); |
| 82 |
| 83 private: | 83 private: |
| 84 RootScrollerController(Document&, ViewportScrollCallback*); | 84 RootScrollerController(Document&); |
| 85 | 85 |
| 86 Element* defaultEffectiveRootScroller(); | 86 Element* defaultEffectiveRootScroller(); |
| 87 | 87 |
| 88 // Ensures the effective root scroller is currently valid and replaces it | 88 // Ensures the effective root scroller is currently valid and replaces it |
| 89 // with the default if not. | 89 // with the default if not. |
| 90 void updateEffectiveRootScroller(); | 90 void updateEffectiveRootScroller(); |
| 91 void moveViewportApplyScroll(Element* target); | 91 |
| 92 // Returns true if the move was successful. |
| 93 bool moveViewportApplyScroll(Element* target); |
| 92 | 94 |
| 93 WeakMember<Document> m_document; | 95 WeakMember<Document> m_document; |
| 94 Member<ViewportScrollCallback> m_viewportApplyScroll; | 96 Member<ViewportScrollCallback> m_viewportApplyScroll; |
| 95 | 97 |
| 96 WeakMember<Element> m_rootScroller; | 98 WeakMember<Element> m_rootScroller; |
| 99 |
| 100 // The element currently being used as the root scroller. If |
| 101 // m_viewportApplyScroll has been set, this element is guaranteed to have it |
| 102 // set as its applyScroll callback. This can be nullptr during |
| 103 // initialization and will not be set until m_viewportApplyScroll is |
| 104 // provided. |
| 97 WeakMember<Element> m_effectiveRootScroller; | 105 WeakMember<Element> m_effectiveRootScroller; |
| 98 }; | 106 }; |
| 99 | 107 |
| 100 } // namespace blink | 108 } // namespace blink |
| 101 | 109 |
| 102 #endif // RootScrollerController_h | 110 #endif // RootScrollerController_h |
| OLD | NEW |