| 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 ScrollPaintPropertyNode_h | 5 #ifndef ScrollPaintPropertyNode_h |
| 6 #define ScrollPaintPropertyNode_h | 6 #define ScrollPaintPropertyNode_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatSize.h" | 9 #include "platform/geometry/FloatSize.h" |
| 10 #include "platform/scroll/MainThreadScrollingReason.h" | 10 #include "platform/scroll/MainThreadScrollingReason.h" |
| 11 #include "wtf/PassRefPtr.h" | 11 #include "wtf/PassRefPtr.h" |
| 12 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" |
| 13 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 14 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
| 15 | 15 |
| 16 #include <iosfwd> | 16 #include <iosfwd> |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 using MainThreadScrollingReasons = uint32_t; | 20 using MainThreadScrollingReasons = uint32_t; |
| 21 class WebLayerScrollClient; |
| 21 | 22 |
| 22 // A scroll node contains auxiliary scrolling information which includes how far | 23 // A scroll node contains auxiliary scrolling information which includes how far |
| 23 // an area can be scrolled, main thread scrolling reasons, etc. Scroll nodes | 24 // an area can be scrolled, main thread scrolling reasons, etc. Scroll nodes |
| 24 // are owned by TransformPaintPropertyNodes that are used for the scroll offset | 25 // are owned by TransformPaintPropertyNodes that are used for the scroll offset |
| 25 // translation. | 26 // translation. |
| 26 // | 27 // |
| 27 // Main thread scrolling reasons force scroll updates to go to the main thread | 28 // Main thread scrolling reasons force scroll updates to go to the main thread |
| 28 // and can have dependencies on other nodes. For example, all parents of a | 29 // and can have dependencies on other nodes. For example, all parents of a |
| 29 // scroll node with background attachment fixed set should also have it set. | 30 // scroll node with background attachment fixed set should also have it set. |
| 30 // | 31 // |
| 31 // The scroll tree differs from the other trees because it does not affect | 32 // The scroll tree differs from the other trees because it does not affect |
| 32 // geometry directly. We may want to rename this class to reflect that it is | 33 // geometry directly. We may want to rename this class to reflect that it is |
| 33 // more like rare scroll data for TransformPaintPropertyNode. | 34 // more like rare scroll data for TransformPaintPropertyNode. |
| 34 class PLATFORM_EXPORT ScrollPaintPropertyNode | 35 class PLATFORM_EXPORT ScrollPaintPropertyNode |
| 35 : public RefCounted<ScrollPaintPropertyNode> { | 36 : public RefCounted<ScrollPaintPropertyNode> { |
| 36 public: | 37 public: |
| 37 // This node is really a sentinel, and does not represent a real scroll. | 38 // This node is really a sentinel, and does not represent a real scroll. |
| 38 static ScrollPaintPropertyNode* root(); | 39 static ScrollPaintPropertyNode* root(); |
| 39 | 40 |
| 40 static PassRefPtr<ScrollPaintPropertyNode> create( | 41 static PassRefPtr<ScrollPaintPropertyNode> create( |
| 41 PassRefPtr<const ScrollPaintPropertyNode> parent, | 42 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 42 const IntSize& clip, | 43 const IntSize& clip, |
| 43 const IntSize& bounds, | 44 const IntSize& bounds, |
| 44 bool userScrollableHorizontal, | 45 bool userScrollableHorizontal, |
| 45 bool userScrollableVertical, | 46 bool userScrollableVertical, |
| 46 MainThreadScrollingReasons mainThreadScrollingReasons) { | 47 MainThreadScrollingReasons mainThreadScrollingReasons, |
| 48 WebLayerScrollClient* scrollClient) { |
| 47 return adoptRef(new ScrollPaintPropertyNode( | 49 return adoptRef(new ScrollPaintPropertyNode( |
| 48 std::move(parent), clip, bounds, userScrollableHorizontal, | 50 std::move(parent), clip, bounds, userScrollableHorizontal, |
| 49 userScrollableVertical, mainThreadScrollingReasons)); | 51 userScrollableVertical, mainThreadScrollingReasons, scrollClient)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void update(PassRefPtr<const ScrollPaintPropertyNode> parent, | 54 void update(PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 53 const IntSize& clip, | 55 const IntSize& clip, |
| 54 const IntSize& bounds, | 56 const IntSize& bounds, |
| 55 bool userScrollableHorizontal, | 57 bool userScrollableHorizontal, |
| 56 bool userScrollableVertical, | 58 bool userScrollableVertical, |
| 57 MainThreadScrollingReasons mainThreadScrollingReasons) { | 59 MainThreadScrollingReasons mainThreadScrollingReasons, |
| 60 WebLayerScrollClient* scrollClient) { |
| 58 DCHECK(!isRoot()); | 61 DCHECK(!isRoot()); |
| 59 DCHECK(parent != this); | 62 DCHECK(parent != this); |
| 60 m_parent = parent; | 63 m_parent = parent; |
| 61 m_clip = clip; | 64 m_clip = clip; |
| 62 m_bounds = bounds; | 65 m_bounds = bounds; |
| 63 m_userScrollableHorizontal = userScrollableHorizontal; | 66 m_userScrollableHorizontal = userScrollableHorizontal; |
| 64 m_userScrollableVertical = userScrollableVertical; | 67 m_userScrollableVertical = userScrollableVertical; |
| 65 m_mainThreadScrollingReasons = mainThreadScrollingReasons; | 68 m_mainThreadScrollingReasons = mainThreadScrollingReasons; |
| 69 m_scrollClient = scrollClient; |
| 66 } | 70 } |
| 67 | 71 |
| 68 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } | 72 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } |
| 69 bool isRoot() const { return !m_parent; } | 73 bool isRoot() const { return !m_parent; } |
| 70 | 74 |
| 71 // The clipped area that contains the scrolled content. | 75 // The clipped area that contains the scrolled content. |
| 72 const IntSize& clip() const { return m_clip; } | 76 const IntSize& clip() const { return m_clip; } |
| 73 | 77 |
| 74 // The bounds of the content that is scrolled within |clip|. | 78 // The bounds of the content that is scrolled within |clip|. |
| 75 const IntSize& bounds() const { return m_bounds; } | 79 const IntSize& bounds() const { return m_bounds; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 return m_mainThreadScrollingReasons & | 91 return m_mainThreadScrollingReasons & |
| 88 MainThreadScrollingReason::kThreadedScrollingDisabled; | 92 MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 89 } | 93 } |
| 90 | 94 |
| 91 // Main thread scrolling reason for background attachment fixed descendants. | 95 // Main thread scrolling reason for background attachment fixed descendants. |
| 92 bool hasBackgroundAttachmentFixedDescendants() const { | 96 bool hasBackgroundAttachmentFixedDescendants() const { |
| 93 return m_mainThreadScrollingReasons & | 97 return m_mainThreadScrollingReasons & |
| 94 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; | 98 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; |
| 95 } | 99 } |
| 96 | 100 |
| 101 WebLayerScrollClient* scrollClient() const { return m_scrollClient; } |
| 102 |
| 97 #if DCHECK_IS_ON() | 103 #if DCHECK_IS_ON() |
| 98 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 104 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
| 99 // a scroll node before it has been updated, to later detect changes. | 105 // a scroll node before it has been updated, to later detect changes. |
| 100 PassRefPtr<ScrollPaintPropertyNode> clone() const { | 106 PassRefPtr<ScrollPaintPropertyNode> clone() const { |
| 101 RefPtr<ScrollPaintPropertyNode> cloned = | 107 RefPtr<ScrollPaintPropertyNode> cloned = |
| 102 adoptRef(new ScrollPaintPropertyNode( | 108 adoptRef(new ScrollPaintPropertyNode( |
| 103 m_parent, m_clip, m_bounds, m_userScrollableHorizontal, | 109 m_parent, m_clip, m_bounds, m_userScrollableHorizontal, |
| 104 m_userScrollableVertical, m_mainThreadScrollingReasons)); | 110 m_userScrollableVertical, m_mainThreadScrollingReasons, |
| 111 m_scrollClient)); |
| 105 return cloned; | 112 return cloned; |
| 106 } | 113 } |
| 107 | 114 |
| 108 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 115 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
| 109 // if a scroll node has changed. | 116 // if a scroll node has changed. |
| 110 bool operator==(const ScrollPaintPropertyNode& o) const { | 117 bool operator==(const ScrollPaintPropertyNode& o) const { |
| 111 return m_parent == o.m_parent && m_clip == o.m_clip && | 118 return m_parent == o.m_parent && m_clip == o.m_clip && |
| 112 m_bounds == o.m_bounds && | 119 m_bounds == o.m_bounds && |
| 113 m_userScrollableHorizontal == o.m_userScrollableHorizontal && | 120 m_userScrollableHorizontal == o.m_userScrollableHorizontal && |
| 114 m_userScrollableVertical == o.m_userScrollableVertical && | 121 m_userScrollableVertical == o.m_userScrollableVertical && |
| 115 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons; | 122 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons && |
| 123 m_scrollClient == o.m_scrollClient; |
| 116 } | 124 } |
| 117 | 125 |
| 118 String toTreeString() const; | 126 String toTreeString() const; |
| 119 #endif | 127 #endif |
| 120 | 128 |
| 121 String toString() const; | 129 String toString() const; |
| 122 | 130 |
| 123 private: | 131 private: |
| 124 ScrollPaintPropertyNode(PassRefPtr<const ScrollPaintPropertyNode> parent, | 132 ScrollPaintPropertyNode(PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 125 IntSize clip, | 133 IntSize clip, |
| 126 IntSize bounds, | 134 IntSize bounds, |
| 127 bool userScrollableHorizontal, | 135 bool userScrollableHorizontal, |
| 128 bool userScrollableVertical, | 136 bool userScrollableVertical, |
| 129 MainThreadScrollingReasons mainThreadScrollingReasons) | 137 MainThreadScrollingReasons mainThreadScrollingReasons, |
| 138 WebLayerScrollClient* scrollClient) |
| 130 : m_parent(parent), | 139 : m_parent(parent), |
| 131 m_clip(clip), | 140 m_clip(clip), |
| 132 m_bounds(bounds), | 141 m_bounds(bounds), |
| 133 m_userScrollableHorizontal(userScrollableHorizontal), | 142 m_userScrollableHorizontal(userScrollableHorizontal), |
| 134 m_userScrollableVertical(userScrollableVertical), | 143 m_userScrollableVertical(userScrollableVertical), |
| 135 m_mainThreadScrollingReasons(mainThreadScrollingReasons) {} | 144 m_mainThreadScrollingReasons(mainThreadScrollingReasons), |
| 145 m_scrollClient(scrollClient) {} |
| 136 | 146 |
| 137 RefPtr<const ScrollPaintPropertyNode> m_parent; | 147 RefPtr<const ScrollPaintPropertyNode> m_parent; |
| 138 IntSize m_clip; | 148 IntSize m_clip; |
| 139 IntSize m_bounds; | 149 IntSize m_bounds; |
| 140 bool m_userScrollableHorizontal : 1; | 150 bool m_userScrollableHorizontal : 1; |
| 141 bool m_userScrollableVertical : 1; | 151 bool m_userScrollableVertical : 1; |
| 142 MainThreadScrollingReasons m_mainThreadScrollingReasons; | 152 MainThreadScrollingReasons m_mainThreadScrollingReasons; |
| 153 WebLayerScrollClient* m_scrollClient; |
| 143 }; | 154 }; |
| 144 | 155 |
| 145 // Redeclared here to avoid ODR issues. | 156 // Redeclared here to avoid ODR issues. |
| 146 // See platform/testing/PaintPrinters.h. | 157 // See platform/testing/PaintPrinters.h. |
| 147 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); | 158 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); |
| 148 | 159 |
| 149 } // namespace blink | 160 } // namespace blink |
| 150 | 161 |
| 151 #endif // ScrollPaintPropertyNode_h | 162 #endif // ScrollPaintPropertyNode_h |
| OLD | NEW |