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 FindPropertiesNeedingUpdate_h | 5 #ifndef FindPropertiesNeedingUpdate_h |
6 #define FindPropertiesNeedingUpdate_h | 6 #define FindPropertiesNeedingUpdate_h |
7 | 7 |
8 #if DCHECK_IS_ON() | 8 #if DCHECK_IS_ON() |
| 9 |
| 10 #include "core/frame/FrameView.h" |
| 11 #include "core/layout/LayoutObject.h" |
| 12 #include "core/paint/ObjectPaintProperties.h" |
| 13 #include "core/paint/PaintPropertyTreeBuilder.h" |
| 14 |
9 namespace blink { | 15 namespace blink { |
10 | 16 |
11 // This file contains two scope classes for catching cases where paint | 17 // This file contains two scope classes for catching cases where paint |
12 // properties needed an update but were not marked as such. If paint properties | 18 // properties needed an update but were not marked as such. If paint properties |
13 // will change, the object must be marked as needing a paint property update | 19 // will change, the object must be marked as needing a paint property update |
14 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing | 20 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing |
15 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate). | 21 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate). |
16 // | 22 // |
17 // Both scope classes work by recording the paint property state of an object | 23 // Both scope classes work by recording the paint property state of an object |
18 // before rebuilding properties, forcing the properties to get updated, then | 24 // before rebuilding properties, forcing the properties to get updated, then |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 m_frameView->scrollTranslation()); | 89 m_frameView->scrollTranslation()); |
84 | 90 |
85 // Restore original clean bit. | 91 // Restore original clean bit. |
86 m_frameView->clearNeedsPaintPropertyUpdate(); | 92 m_frameView->clearNeedsPaintPropertyUpdate(); |
87 } | 93 } |
88 | 94 |
89 private: | 95 private: |
90 Persistent<FrameView> m_frameView; | 96 Persistent<FrameView> m_frameView; |
91 bool m_neededPaintPropertyUpdate; | 97 bool m_neededPaintPropertyUpdate; |
92 bool m_neededForcedSubtreeUpdate; | 98 bool m_neededForcedSubtreeUpdate; |
93 RefPtr<TransformPaintPropertyNode> m_originalPreTranslation; | 99 RefPtr<const TransformPaintPropertyNode> m_originalPreTranslation; |
94 RefPtr<ClipPaintPropertyNode> m_originalContentClip; | 100 RefPtr<const ClipPaintPropertyNode> m_originalContentClip; |
95 RefPtr<TransformPaintPropertyNode> m_originalScrollTranslation; | 101 RefPtr<const TransformPaintPropertyNode> m_originalScrollTranslation; |
96 }; | 102 }; |
97 | 103 |
98 #define DCHECK_OBJECT_PROPERTY_EQ(object, original, updated) \ | 104 #define DCHECK_OBJECT_PROPERTY_EQ(object, original, updated) \ |
99 CHECK_PROPERTY_EQ("the layout object (" << object.debugName() << ")", \ | 105 CHECK_PROPERTY_EQ("the layout object (" << object.debugName() << ")", \ |
100 original, updated) | 106 original, updated) |
101 | 107 |
102 class FindObjectPropertiesNeedingUpdateScope { | 108 class FindObjectPropertiesNeedingUpdateScope { |
103 public: | 109 public: |
104 FindObjectPropertiesNeedingUpdateScope( | 110 FindObjectPropertiesNeedingUpdateScope( |
105 const LayoutObject& object, | 111 const LayoutObject& object, |
106 PaintPropertyTreeBuilderContext& context) | 112 PaintPropertyTreeBuilderContext& context) |
107 : m_object(object), | 113 : m_object(object), |
108 m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()), | 114 m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()), |
109 m_neededForcedSubtreeUpdate(context.forceSubtreeUpdate), | 115 m_neededForcedSubtreeUpdate(context.forceSubtreeUpdate), |
110 m_originalPaintOffset(object.paintOffset()) { | 116 m_originalPaintOffset(object.paintOffset()) { |
111 // No need to check if an update was already needed. | 117 // No need to check if an update was already needed. |
112 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 118 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) |
113 return; | 119 return; |
114 | 120 |
115 // Mark the properties as needing an update to ensure they are rebuilt. | 121 // Mark the properties as needing an update to ensure they are rebuilt. |
116 m_object.getMutableForPainting() | 122 m_object.getMutableForPainting() |
117 .setOnlyThisNeedsPaintPropertyUpdateForTesting(); | 123 .setOnlyThisNeedsPaintPropertyUpdateForTesting(); |
118 | 124 |
119 if (const auto* properties = m_object.paintProperties()) | 125 if (const auto* properties = m_object.paintProperties()) |
120 m_originalProperties = properties->clone(); | 126 m_originalProperties = properties->clone(); |
121 } | 127 } |
122 | 128 |
123 ~FindObjectPropertiesNeedingUpdateScope() { | 129 ~FindObjectPropertiesNeedingUpdateScope() { |
| 130 // Paint offset and paintOffsetTranslation should not change under |
| 131 // FindObjectPropertiesNeedingUpdateScope no matter if we needed paint |
| 132 // property update. |
| 133 DCHECK_OBJECT_PROPERTY_EQ(m_object, &m_originalPaintOffset, |
| 134 &m_object.paintOffset()); |
| 135 const auto* objectProperties = m_object.paintProperties(); |
| 136 if (m_originalProperties && objectProperties) { |
| 137 DCHECK_OBJECT_PROPERTY_EQ(m_object, |
| 138 m_originalProperties->paintOffsetTranslation(), |
| 139 objectProperties->paintOffsetTranslation()); |
| 140 } |
| 141 |
124 // No need to check if an update was already needed. | 142 // No need to check if an update was already needed. |
125 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 143 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) |
126 return; | 144 return; |
127 | 145 |
128 // If these checks fail, the paint properties changed unexpectedly. This is | 146 // If these checks fail, the paint properties changed unexpectedly. This is |
129 // due to missing one of these paint property invalidations: | 147 // due to missing one of these paint property invalidations: |
130 // 1) The LayoutObject should have been marked as needing an update with | 148 // 1) The LayoutObject should have been marked as needing an update with |
131 // LayoutObject::setNeedsPaintPropertyUpdate(). | 149 // LayoutObject::setNeedsPaintPropertyUpdate(). |
132 // 2) The PrePaintTreeWalk should have had a forced subtree update (see: | 150 // 2) The PrePaintTreeWalk should have had a forced subtree update (see: |
133 // PaintPropertyTreeBuilderContext::forceSubtreeUpdate). | 151 // PaintPropertyTreeBuilderContext::forceSubtreeUpdate). |
134 DCHECK_OBJECT_PROPERTY_EQ(m_object, &m_originalPaintOffset, | |
135 &m_object.paintOffset()); | |
136 const auto* objectProperties = m_object.paintProperties(); | |
137 if (m_originalProperties && objectProperties) { | 152 if (m_originalProperties && objectProperties) { |
138 DCHECK_OBJECT_PROPERTY_EQ(m_object, | |
139 m_originalProperties->paintOffsetTranslation(), | |
140 objectProperties->paintOffsetTranslation()); | |
141 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->transform(), | 153 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->transform(), |
142 objectProperties->transform()); | 154 objectProperties->transform()); |
143 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->effect(), | 155 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->effect(), |
144 objectProperties->effect()); | 156 objectProperties->effect()); |
145 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->filter(), | 157 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->filter(), |
146 objectProperties->filter()); | 158 objectProperties->filter()); |
147 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->mask(), | 159 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->mask(), |
148 objectProperties->mask()); | 160 objectProperties->mask()); |
149 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->maskClip(), | 161 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->maskClip(), |
150 objectProperties->maskClip()); | 162 objectProperties->maskClip()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 bool m_neededPaintPropertyUpdate; | 209 bool m_neededPaintPropertyUpdate; |
198 bool m_neededForcedSubtreeUpdate; | 210 bool m_neededForcedSubtreeUpdate; |
199 LayoutPoint m_originalPaintOffset; | 211 LayoutPoint m_originalPaintOffset; |
200 std::unique_ptr<const ObjectPaintProperties> m_originalProperties; | 212 std::unique_ptr<const ObjectPaintProperties> m_originalProperties; |
201 }; | 213 }; |
202 | 214 |
203 } // namespace blink | 215 } // namespace blink |
204 #endif // DCHECK_IS_ON() | 216 #endif // DCHECK_IS_ON() |
205 | 217 |
206 #endif // FindPropertiesNeedingUpdate_h | 218 #endif // FindPropertiesNeedingUpdate_h |
OLD | NEW |