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 namespace blink { | 9 namespace blink { |
10 | 10 |
11 // This file contains two scope classes for catching cases where paint | 11 // 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 | 12 // 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 | 13 // will change, the object must be marked as needing a paint property update |
14 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing | 14 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing |
15 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate). | 15 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate). |
16 // | 16 // |
17 // 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 |
18 // before rebuilding properties, forcing the properties to get updated, then | 18 // before rebuilding properties, forcing the properties to get updated, then |
19 // checking that the updated properties match the original properties. | 19 // checking that the updated properties match the original properties. |
20 | 20 |
21 #define DUMP_PROPERTIES(original, updated) \ | 21 #define DUMP_PROPERTIES(original, updated) \ |
22 "\nOriginal:\n" \ | 22 "\nOriginal:\n" \ |
23 << (original ? (original)->toString().ascii().data() : "null") \ | 23 << (original ? (original)->toString().ascii().data() : "null") \ |
24 << "\nUpdated:\n" \ | 24 << "\nUpdated:\n" \ |
25 << (updated ? (updated)->toString().ascii().data() : "null") | 25 << (updated ? (updated)->toString().ascii().data() : "null") |
26 | 26 |
27 #define CHECK_PROPERTY_EQ(thing, original, updated) \ | 27 #define CHECK_PROPERTY_EQ(thing, original, updated) \ |
28 do { \ | 28 do { \ |
29 DCHECK(!!original == !!updated) << "Property was created or deleted " \ | 29 DCHECK(!!original == !!updated) \ |
30 << "without " << thing \ | 30 << "Property was created or deleted " \ |
31 << " needing a paint property update." \ | 31 << "without " << thing << " needing a paint property update." \ |
32 << DUMP_PROPERTIES(original, updated); \ | 32 << DUMP_PROPERTIES(original, updated); \ |
33 if (!!original && !!updated) { \ | 33 if (!!original && !!updated) { \ |
34 DCHECK(*original == *updated) << "Property was updated without " \ | 34 DCHECK(*original == *updated) \ |
35 << thing \ | 35 << "Property was updated without " << thing \ |
36 << " needing a paint property update." \ | 36 << " needing a paint property update." \ |
37 << DUMP_PROPERTIES(original, updated); \ | 37 << DUMP_PROPERTIES(original, updated); \ |
38 } \ | 38 } \ |
39 } while (0) | 39 } while (0) |
40 | 40 |
41 #define DCHECK_FRAMEVIEW_PROPERTY_EQ(original, updated) \ | 41 #define DCHECK_FRAMEVIEW_PROPERTY_EQ(original, updated) \ |
42 CHECK_PROPERTY_EQ("the FrameView", original, updated) | 42 CHECK_PROPERTY_EQ("the FrameView", original, updated) |
43 | 43 |
44 class FindFrameViewPropertiesNeedingUpdateScope { | 44 class FindFrameViewPropertiesNeedingUpdateScope { |
45 public: | 45 public: |
46 FindFrameViewPropertiesNeedingUpdateScope( | 46 FindFrameViewPropertiesNeedingUpdateScope( |
47 FrameView* frameView, | 47 FrameView* frameView, |
48 PaintPropertyTreeBuilderContext& context) | 48 PaintPropertyTreeBuilderContext& context) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 bool m_neededPaintPropertyUpdate; | 191 bool m_neededPaintPropertyUpdate; |
192 bool m_neededForcedSubtreeUpdate; | 192 bool m_neededForcedSubtreeUpdate; |
193 LayoutPoint m_originalPaintOffset; | 193 LayoutPoint m_originalPaintOffset; |
194 std::unique_ptr<const ObjectPaintProperties> m_originalProperties; | 194 std::unique_ptr<const ObjectPaintProperties> m_originalProperties; |
195 }; | 195 }; |
196 | 196 |
197 } // namespace blink | 197 } // namespace blink |
198 #endif // DCHECK_IS_ON() | 198 #endif // DCHECK_IS_ON() |
199 | 199 |
200 #endif // FindPropertiesNeedingUpdate_h | 200 #endif // FindPropertiesNeedingUpdate_h |
OLD | NEW |