Chromium Code Reviews| 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" |
| 11 #include "platform/scroll/MainThreadScrollingReason.h" | |
| 11 #include "wtf/PassRefPtr.h" | 12 #include "wtf/PassRefPtr.h" |
| 12 #include "wtf/RefCounted.h" | 13 #include "wtf/RefCounted.h" |
| 13 #include "wtf/RefPtr.h" | 14 #include "wtf/RefPtr.h" |
| 14 | 15 |
| 15 #include <iosfwd> | 16 #include <iosfwd> |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 // A scroll node contains auxiliary scrolling information for compositor-thread | 20 using MainThreadScrollingReasons = uint32_t; |
| 20 // scrolling and includes how far an area can be scrolled, which | 21 |
| 21 // |TransformPaintPropertyNode| contains the scroll offset, etc. | 22 // A scroll node contains auxiliary scrolling information for threaded scrolling |
| 23 // which includes how far an area can be scrolled, which transform node contains | |
| 24 // the scroll offset, etc. | |
| 25 // | |
| 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 | |
| 28 // scroll node with background attachment fixed set should also have it set. | |
| 22 class PLATFORM_EXPORT ScrollPaintPropertyNode : public RefCounted<ScrollPaintPro pertyNode> { | 29 class PLATFORM_EXPORT ScrollPaintPropertyNode : public RefCounted<ScrollPaintPro pertyNode> { |
| 23 public: | 30 public: |
| 24 static PassRefPtr<ScrollPaintPropertyNode> create( | 31 static PassRefPtr<ScrollPaintPropertyNode> create( |
| 25 PassRefPtr<const ScrollPaintPropertyNode> parent, | 32 PassRefPtr<ScrollPaintPropertyNode> parent, |
| 26 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, | 33 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 27 const IntSize& clip, | 34 const IntSize& clip, |
| 28 const IntSize& bounds, | 35 const IntSize& bounds, |
| 29 bool userScrollableHorizontal, | 36 bool userScrollableHorizontal, |
| 30 bool userScrollableVertical) | 37 bool userScrollableVertical) |
| 31 { | 38 { |
| 32 return adoptRef(new ScrollPaintPropertyNode(std::move(parent), std::move (scrollOffsetTranslation), clip, bounds, userScrollableHorizontal, userScrollabl eVertical)); | 39 return adoptRef(new ScrollPaintPropertyNode(std::move(parent), std::move (scrollOffsetTranslation), clip, bounds, userScrollableHorizontal, userScrollabl eVertical)); |
| 33 } | 40 } |
| 34 | 41 |
| 35 void update(PassRefPtr<const ScrollPaintPropertyNode> parent, PassRefPtr<con st TransformPaintPropertyNode> scrollOffsetTranslation, const IntSize& clip, con st IntSize& bounds, bool userScrollableHorizontal, bool userScrollableVertical) | 42 void update(PassRefPtr<ScrollPaintPropertyNode> parent, PassRefPtr<const Tra nsformPaintPropertyNode> scrollOffsetTranslation, const IntSize& clip, const Int Size& bounds, bool userScrollableHorizontal, bool userScrollableVertical) |
| 36 { | 43 { |
| 37 DCHECK(parent != this); | 44 DCHECK(parent != this); |
| 38 m_parent = parent; | 45 m_parent = parent; |
| 39 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); | 46 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 40 m_scrollOffsetTranslation = scrollOffsetTranslation; | 47 m_scrollOffsetTranslation = scrollOffsetTranslation; |
| 41 m_clip = clip; | 48 m_clip = clip; |
| 42 m_bounds = bounds; | 49 m_bounds = bounds; |
| 43 m_userScrollableHorizontal = userScrollableHorizontal; | 50 m_userScrollableHorizontal = userScrollableHorizontal; |
| 44 m_userScrollableVertical = userScrollableVertical; | 51 m_userScrollableVertical = userScrollableVertical; |
| 52 m_mainThreadScrollingReasons = 0; | |
| 45 } | 53 } |
| 46 | 54 |
| 47 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } | 55 ScrollPaintPropertyNode* parent() const { return m_parent.get(); } |
| 48 | 56 |
| 49 // Transform that the scroll is relative to. | 57 // Transform that the scroll is relative to. |
| 50 const TransformPaintPropertyNode* scrollOffsetTranslation() const { return m _scrollOffsetTranslation.get(); } | 58 const TransformPaintPropertyNode* scrollOffsetTranslation() const { return m _scrollOffsetTranslation.get(); } |
| 51 | 59 |
| 52 // The clipped area that contains the scrolled content. | 60 // The clipped area that contains the scrolled content. |
| 53 const IntSize& clip() const { return m_clip; } | 61 const IntSize& clip() const { return m_clip; } |
| 54 | 62 |
| 55 // The bounds of the content that is scrolled within |clip|. | 63 // The bounds of the content that is scrolled within |clip|. |
| 56 const IntSize& bounds() const { return m_bounds; } | 64 const IntSize& bounds() const { return m_bounds; } |
| 57 | 65 |
| 58 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } | 66 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } |
| 59 bool userScrollableVertical() const { return m_userScrollableVertical; } | 67 bool userScrollableVertical() const { return m_userScrollableVertical; } |
| 60 | 68 |
| 69 // Return reason bitfield with values from cc::MainThreadScrollingReason. | |
| 70 MainThreadScrollingReasons mainThreadScrollingReasons() const | |
| 71 { | |
| 72 return m_mainThreadScrollingReasons; | |
| 73 } | |
| 74 bool hasBackgroundAttachmentFixedMainThreadScrollingReason() const | |
| 75 { | |
| 76 return m_mainThreadScrollingReasons & MainThreadScrollingReason::kHasBac kgroundAttachmentFixedObjects; | |
| 77 } | |
| 78 void setBackgroundAttachmentFixedMainThreadScrollingReason() | |
|
chrishtr
2016/09/19 17:00:12
How about:
void addMainThreadScrollingReason(Main
pdr.
2016/09/19 20:25:50
+1, was going in this direction in the followup pa
| |
| 79 { | |
| 80 m_mainThreadScrollingReasons |= MainThreadScrollingReason::kHasBackgroun dAttachmentFixedObjects; | |
| 81 } | |
| 82 | |
| 61 private: | 83 private: |
| 62 ScrollPaintPropertyNode( | 84 ScrollPaintPropertyNode( |
| 63 PassRefPtr<const ScrollPaintPropertyNode> parent, | 85 PassRefPtr<ScrollPaintPropertyNode> parent, |
| 64 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, | 86 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 65 IntSize clip, | 87 IntSize clip, |
| 66 IntSize bounds, | 88 IntSize bounds, |
| 67 bool userScrollableHorizontal, | 89 bool userScrollableHorizontal, |
| 68 bool userScrollableVertical) | 90 bool userScrollableVertical) |
| 69 : m_parent(parent) | 91 : m_parent(parent) |
| 70 , m_scrollOffsetTranslation(scrollOffsetTranslation) | 92 , m_scrollOffsetTranslation(scrollOffsetTranslation) |
| 71 , m_clip(clip) | 93 , m_clip(clip) |
| 72 , m_bounds(bounds) | 94 , m_bounds(bounds) |
| 73 , m_userScrollableHorizontal(userScrollableHorizontal) | 95 , m_userScrollableHorizontal(userScrollableHorizontal) |
| 74 , m_userScrollableVertical(userScrollableVertical) | 96 , m_userScrollableVertical(userScrollableVertical) |
| 97 , m_mainThreadScrollingReasons(0) | |
| 75 { | 98 { |
| 76 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); | 99 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 77 } | 100 } |
| 78 | 101 |
| 79 RefPtr<const ScrollPaintPropertyNode> m_parent; | 102 RefPtr<ScrollPaintPropertyNode> m_parent; |
| 80 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; | 103 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; |
| 81 IntSize m_clip; | 104 IntSize m_clip; |
| 82 IntSize m_bounds; | 105 IntSize m_bounds; |
| 83 bool m_userScrollableHorizontal; | 106 bool m_userScrollableHorizontal; |
| 84 bool m_userScrollableVertical; | 107 bool m_userScrollableVertical; |
| 85 // TODO(pdr): Add main thread scrolling reasons. | 108 MainThreadScrollingReasons m_mainThreadScrollingReasons; |
| 86 // TODO(pdr): Add an offset for the clip and bounds to the transform. | 109 // TODO(pdr): Add an offset for the clip and bounds to the transform. |
| 87 // TODO(pdr): Add 2 bits for whether this is a viewport scroll node. | 110 // TODO(pdr): Add 2 bits for whether this is a viewport scroll node. |
| 88 // TODO(pdr): Add a bit for whether this is affected by page scale. | 111 // TODO(pdr): Add a bit for whether this is affected by page scale. |
| 89 }; | 112 }; |
| 90 | 113 |
| 91 // Redeclared here to avoid ODR issues. | 114 // Redeclared here to avoid ODR issues. |
| 92 // See platform/testing/PaintPrinters.h. | 115 // See platform/testing/PaintPrinters.h. |
| 93 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); | 116 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); |
| 94 | 117 |
| 95 } // namespace blink | 118 } // namespace blink |
| 96 | 119 |
| 97 #endif // ScrollPaintPropertyNode_h | 120 #endif // ScrollPaintPropertyNode_h |
| OLD | NEW |