| 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/graphics/paint/TransformPaintPropertyNode.h" | 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // | 25 // |
| 26 // Main thread scrolling reasons force scroll updates to go to the main thread | 26 // Main thread scrolling reasons force scroll updates to go to the main thread |
| 27 // and can have dependencies on other nodes. For example, all parents of a | 27 // and can have dependencies on other nodes. For example, all parents of a |
| 28 // scroll node with background attachment fixed set should also have it set. | 28 // scroll node with background attachment fixed set should also have it set. |
| 29 class PLATFORM_EXPORT ScrollPaintPropertyNode | 29 class PLATFORM_EXPORT ScrollPaintPropertyNode |
| 30 : public RefCounted<ScrollPaintPropertyNode> { | 30 : public RefCounted<ScrollPaintPropertyNode> { |
| 31 public: | 31 public: |
| 32 static ScrollPaintPropertyNode* root(); | 32 static ScrollPaintPropertyNode* root(); |
| 33 | 33 |
| 34 static PassRefPtr<ScrollPaintPropertyNode> create( | 34 static PassRefPtr<ScrollPaintPropertyNode> create( |
| 35 PassRefPtr<ScrollPaintPropertyNode> parent, | 35 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 36 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, | 36 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 37 const IntSize& clip, | 37 const IntSize& clip, |
| 38 const IntSize& bounds, | 38 const IntSize& bounds, |
| 39 bool userScrollableHorizontal, | 39 bool userScrollableHorizontal, |
| 40 bool userScrollableVertical) { | 40 bool userScrollableVertical, |
| 41 MainThreadScrollingReasons mainThreadScrollingReasons) { |
| 41 return adoptRef(new ScrollPaintPropertyNode( | 42 return adoptRef(new ScrollPaintPropertyNode( |
| 42 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds, | 43 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds, |
| 43 userScrollableHorizontal, userScrollableVertical)); | 44 userScrollableHorizontal, userScrollableVertical, |
| 45 mainThreadScrollingReasons)); |
| 44 } | 46 } |
| 45 | 47 |
| 46 void update( | 48 void update( |
| 47 PassRefPtr<ScrollPaintPropertyNode> parent, | 49 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 48 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, | 50 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 49 const IntSize& clip, | 51 const IntSize& clip, |
| 50 const IntSize& bounds, | 52 const IntSize& bounds, |
| 51 bool userScrollableHorizontal, | 53 bool userScrollableHorizontal, |
| 52 bool userScrollableVertical) { | 54 bool userScrollableVertical, |
| 55 MainThreadScrollingReasons mainThreadScrollingReasons) { |
| 53 DCHECK(!isRoot()); | 56 DCHECK(!isRoot()); |
| 54 DCHECK(parent != this); | 57 DCHECK(parent != this); |
| 55 m_parent = parent; | 58 m_parent = parent; |
| 56 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); | 59 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 57 m_scrollOffsetTranslation = scrollOffsetTranslation; | 60 m_scrollOffsetTranslation = scrollOffsetTranslation; |
| 58 m_clip = clip; | 61 m_clip = clip; |
| 59 m_bounds = bounds; | 62 m_bounds = bounds; |
| 60 m_userScrollableHorizontal = userScrollableHorizontal; | 63 m_userScrollableHorizontal = userScrollableHorizontal; |
| 61 m_userScrollableVertical = userScrollableVertical; | 64 m_userScrollableVertical = userScrollableVertical; |
| 62 m_mainThreadScrollingReasons = 0; | 65 m_mainThreadScrollingReasons = mainThreadScrollingReasons; |
| 63 } | 66 } |
| 64 | 67 |
| 65 ScrollPaintPropertyNode* parent() const { return m_parent.get(); } | 68 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } |
| 66 bool isRoot() const { return !m_parent; } | 69 bool isRoot() const { return !m_parent; } |
| 67 | 70 |
| 68 // Transform that the scroll is relative to. | 71 // Transform that the scroll is relative to. |
| 69 const TransformPaintPropertyNode* scrollOffsetTranslation() const { | 72 const TransformPaintPropertyNode* scrollOffsetTranslation() const { |
| 70 return m_scrollOffsetTranslation.get(); | 73 return m_scrollOffsetTranslation.get(); |
| 71 } | 74 } |
| 72 | 75 |
| 73 // The clipped area that contains the scrolled content. | 76 // The clipped area that contains the scrolled content. |
| 74 const IntSize& clip() const { return m_clip; } | 77 const IntSize& clip() const { return m_clip; } |
| 75 | 78 |
| 76 // The bounds of the content that is scrolled within |clip|. | 79 // The bounds of the content that is scrolled within |clip|. |
| 77 const IntSize& bounds() const { return m_bounds; } | 80 const IntSize& bounds() const { return m_bounds; } |
| 78 | 81 |
| 79 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } | 82 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } |
| 80 bool userScrollableVertical() const { return m_userScrollableVertical; } | 83 bool userScrollableVertical() const { return m_userScrollableVertical; } |
| 81 | 84 |
| 82 // Return reason bitfield with values from cc::MainThreadScrollingReason. | 85 // Return reason bitfield with values from cc::MainThreadScrollingReason. |
| 83 MainThreadScrollingReasons mainThreadScrollingReasons() const { | 86 MainThreadScrollingReasons mainThreadScrollingReasons() const { |
| 84 return m_mainThreadScrollingReasons; | 87 return m_mainThreadScrollingReasons; |
| 85 } | 88 } |
| 86 bool hasMainThreadScrollingReasons(MainThreadScrollingReasons reasons) const { | 89 |
| 87 return m_mainThreadScrollingReasons & reasons; | 90 // Main thread scrolling reason for the threaded scrolling disabled setting. |
| 91 bool threadedScrollingDisabled() const { |
| 92 return m_mainThreadScrollingReasons & |
| 93 MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 88 } | 94 } |
| 89 void addMainThreadScrollingReasons(MainThreadScrollingReasons reasons) { | 95 |
| 90 m_mainThreadScrollingReasons |= reasons; | 96 // Main thread scrolling reason for background attachment fixed descendants. |
| 97 bool hasBackgroundAttachmentFixedDescendants() const { |
| 98 return m_mainThreadScrollingReasons & |
| 99 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; |
| 91 } | 100 } |
| 92 void clearMainThreadScrollingReasons() { m_mainThreadScrollingReasons = 0; } | |
| 93 | 101 |
| 94 #if DCHECK_IS_ON() | 102 #if DCHECK_IS_ON() |
| 95 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 103 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
| 96 // a scroll node before it has been updated, to later detect changes. | 104 // a scroll node before it has been updated, to later detect changes. |
| 97 PassRefPtr<ScrollPaintPropertyNode> clone() const { | 105 PassRefPtr<ScrollPaintPropertyNode> clone() const { |
| 98 RefPtr<ScrollPaintPropertyNode> cloned = | 106 RefPtr<ScrollPaintPropertyNode> cloned = |
| 99 adoptRef(new ScrollPaintPropertyNode( | 107 adoptRef(new ScrollPaintPropertyNode( |
| 100 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds, | 108 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds, |
| 101 m_userScrollableHorizontal, m_userScrollableVertical)); | 109 m_userScrollableHorizontal, m_userScrollableVertical, |
| 102 cloned->addMainThreadScrollingReasons(m_mainThreadScrollingReasons); | 110 m_mainThreadScrollingReasons)); |
| 103 return cloned; | 111 return cloned; |
| 104 } | 112 } |
| 105 | 113 |
| 106 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 114 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
| 107 // if a scroll node has changed. | 115 // if a scroll node has changed. |
| 108 bool operator==(const ScrollPaintPropertyNode& o) const { | 116 bool operator==(const ScrollPaintPropertyNode& o) const { |
| 109 // TODO(pdr): Check main thread scrolling reason equality as well. We do | |
| 110 // not yet mark nodes as needing a paint property update on main thread | |
| 111 // scrolling reason changes. See: See: https://crbug.com/664672. | |
| 112 return m_parent == o.m_parent && | 117 return m_parent == o.m_parent && |
| 113 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation && | 118 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation && |
| 114 m_clip == o.m_clip && m_bounds == o.m_bounds && | 119 m_clip == o.m_clip && m_bounds == o.m_bounds && |
| 115 m_userScrollableHorizontal == o.m_userScrollableHorizontal && | 120 m_userScrollableHorizontal == o.m_userScrollableHorizontal && |
| 116 m_userScrollableVertical == o.m_userScrollableVertical; | 121 m_userScrollableVertical == o.m_userScrollableVertical && |
| 122 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons; |
| 117 } | 123 } |
| 118 #endif | 124 #endif |
| 119 | 125 |
| 120 private: | 126 private: |
| 121 ScrollPaintPropertyNode( | 127 ScrollPaintPropertyNode( |
| 122 PassRefPtr<ScrollPaintPropertyNode> parent, | 128 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 123 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, | 129 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 124 IntSize clip, | 130 IntSize clip, |
| 125 IntSize bounds, | 131 IntSize bounds, |
| 126 bool userScrollableHorizontal, | 132 bool userScrollableHorizontal, |
| 127 bool userScrollableVertical) | 133 bool userScrollableVertical, |
| 134 MainThreadScrollingReasons mainThreadScrollingReasons) |
| 128 : m_parent(parent), | 135 : m_parent(parent), |
| 129 m_scrollOffsetTranslation(scrollOffsetTranslation), | 136 m_scrollOffsetTranslation(scrollOffsetTranslation), |
| 130 m_clip(clip), | 137 m_clip(clip), |
| 131 m_bounds(bounds), | 138 m_bounds(bounds), |
| 132 m_userScrollableHorizontal(userScrollableHorizontal), | 139 m_userScrollableHorizontal(userScrollableHorizontal), |
| 133 m_userScrollableVertical(userScrollableVertical), | 140 m_userScrollableVertical(userScrollableVertical), |
| 134 m_mainThreadScrollingReasons(0) { | 141 m_mainThreadScrollingReasons(mainThreadScrollingReasons) { |
| 135 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); | 142 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 136 } | 143 } |
| 137 | 144 |
| 138 RefPtr<ScrollPaintPropertyNode> m_parent; | 145 RefPtr<const ScrollPaintPropertyNode> m_parent; |
| 139 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; | 146 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; |
| 140 IntSize m_clip; | 147 IntSize m_clip; |
| 141 IntSize m_bounds; | 148 IntSize m_bounds; |
| 142 bool m_userScrollableHorizontal; | 149 bool m_userScrollableHorizontal : 1; |
| 143 bool m_userScrollableVertical; | 150 bool m_userScrollableVertical : 1; |
| 144 MainThreadScrollingReasons m_mainThreadScrollingReasons; | 151 MainThreadScrollingReasons m_mainThreadScrollingReasons; |
| 145 // TODO(pdr): Add an offset for the clip and bounds to the transform. | |
| 146 // TODO(pdr): Add 2 bits for whether this is a viewport scroll node. | |
| 147 // TODO(pdr): Add a bit for whether this is affected by page scale. | |
| 148 }; | 152 }; |
| 149 | 153 |
| 150 // Redeclared here to avoid ODR issues. | 154 // Redeclared here to avoid ODR issues. |
| 151 // See platform/testing/PaintPrinters.h. | 155 // See platform/testing/PaintPrinters.h. |
| 152 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); | 156 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); |
| 153 | 157 |
| 154 } // namespace blink | 158 } // namespace blink |
| 155 | 159 |
| 156 #endif // ScrollPaintPropertyNode_h | 160 #endif // ScrollPaintPropertyNode_h |
| OLD | NEW |