OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ScrollPaintPropertyNode_h |
| 6 #define ScrollPaintPropertyNode_h |
| 7 |
| 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatSize.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 11 #include "wtf/PassRefPtr.h" |
| 12 #include "wtf/RefCounted.h" |
| 13 #include "wtf/RefPtr.h" |
| 14 |
| 15 #include <iosfwd> |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 // A scroll node contains auxillary scrolling information about areas that |
| 20 // respond to user input and how far they can be scrolled. The actual scroll |
| 21 // offset is applied in an associated TransformPaintPropertyNode. |
| 22 class PLATFORM_EXPORT ScrollPaintPropertyNode : public RefCounted<ScrollPaintPro
pertyNode> { |
| 23 public: |
| 24 static PassRefPtr<ScrollPaintPropertyNode> create( |
| 25 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 26 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 27 const FloatSize& clip, |
| 28 const FloatSize& bounds, |
| 29 bool userScrollableHorizontal, |
| 30 bool userScrollableVertical) |
| 31 { |
| 32 return adoptRef(new ScrollPaintPropertyNode(parent, scrollOffsetTranslat
ion, clip, bounds, userScrollableHorizontal, userScrollableVertical)); |
| 33 } |
| 34 |
| 35 void update(PassRefPtr<const ScrollPaintPropertyNode> parent, PassRefPtr<con
st TransformPaintPropertyNode> scrollOffsetTranslation, const FloatSize& clip, c
onst FloatSize& bounds, bool userScrollableHorizontal, bool userScrollableVertic
al) |
| 36 { |
| 37 m_parent = parent; |
| 38 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 39 m_scrollOffsetTranslation = scrollOffsetTranslation; |
| 40 m_clip = clip; |
| 41 m_bounds = bounds; |
| 42 m_userScrollableHorizontal = userScrollableHorizontal; |
| 43 m_userScrollableVertical = userScrollableVertical; |
| 44 } |
| 45 |
| 46 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } |
| 47 |
| 48 // Transform that the scroll is relative to. |
| 49 const TransformPaintPropertyNode* scrollOffsetTranslation() const { return m
_scrollOffsetTranslation.get(); } |
| 50 |
| 51 // The clipped area that contains the scrolled content. In the common case |
| 52 // this is the area that could respond to user input. |
| 53 const FloatSize& clip() const { return m_clip; } |
| 54 |
| 55 // The bounds of the content that is scrolled. |
| 56 const FloatSize& bounds() const { return m_bounds; } |
| 57 |
| 58 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } |
| 59 bool userScrollableVertical() const { return m_userScrollableVertical; } |
| 60 |
| 61 private: |
| 62 ScrollPaintPropertyNode( |
| 63 PassRefPtr<const ScrollPaintPropertyNode> parent, |
| 64 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, |
| 65 FloatSize clip, |
| 66 FloatSize bounds, |
| 67 bool userScrollableHorizontal, |
| 68 bool userScrollableVertical) |
| 69 : m_parent(parent) |
| 70 , m_scrollOffsetTranslation(scrollOffsetTranslation) |
| 71 , m_clip(clip) |
| 72 , m_bounds(bounds) |
| 73 , m_userScrollableHorizontal(userScrollableHorizontal) |
| 74 , m_userScrollableVertical(userScrollableVertical) |
| 75 { |
| 76 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); |
| 77 } |
| 78 |
| 79 RefPtr<const ScrollPaintPropertyNode> m_parent; |
| 80 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; |
| 81 FloatSize m_clip; |
| 82 FloatSize m_bounds; |
| 83 bool m_userScrollableHorizontal; |
| 84 bool m_userScrollableVertical; |
| 85 // TODO(pdr): Add main thread scrolling reasons. |
| 86 // 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. |
| 88 // TODO(pdr): Add a bit for whether this is affected by page scale. |
| 89 }; |
| 90 |
| 91 // Redeclared here to avoid ODR issues. |
| 92 // See platform/testing/PaintPrinters.h. |
| 93 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); |
| 94 |
| 95 } // namespace blink |
| 96 |
| 97 #endif // ScrollPaintPropertyNode_h |
OLD | NEW |