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