Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: third_party/WebKit/Source/core/paint/FindPropertiesNeedingUpdate.h

Issue 2539693002: Early-out from the prepaint tree walk (Closed)
Patch Set: Switch away from typed enums which Windows clang does not like Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #define DCHECK_PTR_VAL_EQ(ptrA, ptrB) \ 11 #define DCHECK_PTR_VAL_EQ(ptrA, ptrB) \
12 DCHECK((!!ptrA == !!ptrB) && ((!ptrA && !ptrB) || (*ptrA == *ptrB))); 12 DCHECK((!!ptrA == !!ptrB) && ((!ptrA && !ptrB) || (*ptrA == *ptrB)));
13 13
14 // This file contains two scope classes for catching cases where paint 14 // This file contains two scope classes for catching cases where paint
15 // properties need an update but where not marked as such. If paint properties 15 // properties need an update but where not marked as such. If paint properties
16 // will change, the object must be marked as needing a paint property update 16 // will change, the object must be marked as needing a paint property update
17 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate(). 17 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate().
18 // 18 //
19 // Both scope classes work by recording the paint property state of an object 19 // Both scope classes work by recording the paint property state of an object
20 // before rebuilding properties, forcing the properties to get updated, then 20 // before rebuilding properties, forcing the properties to get updated, then
21 // checking that the updated properties match the original properties. 21 // checking that the updated properties match the original properties.
22 22
23 class FindFrameViewPropertiesNeedingUpdateScope { 23 class FindFrameViewPropertiesNeedingUpdateScope {
24 public: 24 public:
25 FindFrameViewPropertiesNeedingUpdateScope(FrameView* frameView) 25 FindFrameViewPropertiesNeedingUpdateScope(
26 FrameView* frameView,
27 PaintPropertyTreeBuilderContext& context)
26 : m_frameView(frameView), 28 : m_frameView(frameView),
27 m_neededPaintPropertyUpdate(frameView->needsPaintPropertyUpdate()) { 29 m_neededPaintPropertyUpdate(frameView->needsPaintPropertyUpdate()),
30 m_context(context),
31 m_hadForceSubtreeUpdate(context.forceSubtreeUpdate) {
chrishtr 2016/12/01 02:36:35 Can you also use this field to check that forceSub
pdr. 2016/12/01 09:35:35 This class catches underinvalidation by checking t
28 // No need to check when already marked as needing an update. 32 // No need to check when already marked as needing an update.
29 if (m_neededPaintPropertyUpdate) 33 if (m_neededPaintPropertyUpdate)
30 return; 34 return;
31 35
32 // Mark the properties as needing an update to ensure they are rebuilt. 36 // Mark the properties as needing an update to ensure they are rebuilt.
33 m_frameView->setNeedsPaintPropertyUpdate(); 37 m_frameView->setNeedsPaintPropertyUpdate();
34 if (auto* preTranslation = m_frameView->preTranslation()) 38 if (auto* preTranslation = m_frameView->preTranslation())
35 m_preTranslation = preTranslation->clone(); 39 m_preTranslation = preTranslation->clone();
36 if (auto* contentClip = m_frameView->contentClip()) 40 if (auto* contentClip = m_frameView->contentClip())
37 m_contentClip = contentClip->clone(); 41 m_contentClip = contentClip->clone();
38 if (auto* scrollTranslation = m_frameView->scrollTranslation()) 42 if (auto* scrollTranslation = m_frameView->scrollTranslation())
39 m_scrollTranslation = scrollTranslation->clone(); 43 m_scrollTranslation = scrollTranslation->clone();
40 if (auto* scroll = m_frameView->scroll()) 44 if (auto* scroll = m_frameView->scroll())
41 m_scroll = scroll->clone(); 45 m_scroll = scroll->clone();
42 } 46 }
43 47
44 ~FindFrameViewPropertiesNeedingUpdateScope() { 48 ~FindFrameViewPropertiesNeedingUpdateScope() {
45 // No need to check when already marked as needing an update. 49 // No need to check when already marked as needing an update.
46 if (m_neededPaintPropertyUpdate) 50 if (m_neededPaintPropertyUpdate)
47 return; 51 return;
48 52
49 // If paint properties are not marked as needing an update but still change, 53 // If paint properties are not marked as needing an update but still change,
50 // we are missing a call to FrameView::setNeedsPaintPropertyUpdate(). 54 // we are missing a call to FrameView::setNeedsPaintPropertyUpdate().
51 DCHECK_PTR_VAL_EQ(m_preTranslation, m_frameView->preTranslation()); 55 DCHECK_PTR_VAL_EQ(m_preTranslation, m_frameView->preTranslation());
52 DCHECK_PTR_VAL_EQ(m_contentClip, m_frameView->contentClip()); 56 DCHECK_PTR_VAL_EQ(m_contentClip, m_frameView->contentClip());
53 DCHECK_PTR_VAL_EQ(m_scrollTranslation, m_frameView->scrollTranslation()); 57 DCHECK_PTR_VAL_EQ(m_scrollTranslation, m_frameView->scrollTranslation());
54 DCHECK_PTR_VAL_EQ(m_scroll, m_frameView->scroll()); 58 DCHECK_PTR_VAL_EQ(m_scroll, m_frameView->scroll());
55 // Restore original clean bit. 59 // Restore original clean bits.
56 m_frameView->clearNeedsPaintPropertyUpdate(); 60 m_frameView->clearNeedsPaintPropertyUpdate();
61 m_context.forceSubtreeUpdate = m_hadForceSubtreeUpdate;
57 } 62 }
58 63
59 private: 64 private:
60 Persistent<FrameView> m_frameView; 65 Persistent<FrameView> m_frameView;
61 bool m_neededPaintPropertyUpdate; 66 bool m_neededPaintPropertyUpdate;
67 PaintPropertyTreeBuilderContext& m_context;
68 bool m_hadForceSubtreeUpdate;
62 RefPtr<TransformPaintPropertyNode> m_preTranslation; 69 RefPtr<TransformPaintPropertyNode> m_preTranslation;
63 RefPtr<ClipPaintPropertyNode> m_contentClip; 70 RefPtr<ClipPaintPropertyNode> m_contentClip;
64 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 71 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
65 RefPtr<ScrollPaintPropertyNode> m_scroll; 72 RefPtr<ScrollPaintPropertyNode> m_scroll;
66 }; 73 };
67 74
68 class FindObjectPropertiesNeedingUpdateScope { 75 class FindObjectPropertiesNeedingUpdateScope {
69 public: 76 public:
70 FindObjectPropertiesNeedingUpdateScope(const LayoutObject& object) 77 FindObjectPropertiesNeedingUpdateScope(
78 const LayoutObject& object,
79 PaintPropertyTreeBuilderContext& context)
71 : m_object(object), 80 : m_object(object),
72 m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()) { 81 m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()),
82 m_context(context),
83 m_hadForceSubtreeUpdate(context.forceSubtreeUpdate) {
73 // No need to check when already marked as needing an update. 84 // No need to check when already marked as needing an update.
74 if (m_neededPaintPropertyUpdate) 85 if (m_neededPaintPropertyUpdate)
75 return; 86 return;
76 87
77 // Mark the properties as needing an update to ensure they are rebuilt. 88 // Mark the properties as needing an update to ensure they are rebuilt.
78 const_cast<LayoutObject&>(m_object).setNeedsPaintPropertyUpdate(); 89 const_cast<LayoutObject&>(m_object).setNeedsPaintPropertyUpdate();
79 if (const auto* properties = m_object.paintProperties()) 90 if (const auto* properties = m_object.paintProperties())
80 m_properties = properties->clone(); 91 m_properties = properties->clone();
81 } 92 }
82 93
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 DCHECK_EQ(borderBox->propertyTreeState.effect(), 132 DCHECK_EQ(borderBox->propertyTreeState.effect(),
122 objectBorderBox->propertyTreeState.effect()); 133 objectBorderBox->propertyTreeState.effect());
123 DCHECK_EQ(borderBox->propertyTreeState.scroll(), 134 DCHECK_EQ(borderBox->propertyTreeState.scroll(),
124 objectBorderBox->propertyTreeState.scroll()); 135 objectBorderBox->propertyTreeState.scroll());
125 } else { 136 } else {
126 DCHECK_EQ(!!borderBox, !!objectBorderBox); 137 DCHECK_EQ(!!borderBox, !!objectBorderBox);
127 } 138 }
128 } else { 139 } else {
129 DCHECK_EQ(!!m_properties, !!objectProperties); 140 DCHECK_EQ(!!m_properties, !!objectProperties);
130 } 141 }
131 // Restore original clean bit. 142 // Restore original clean bits.
132 const_cast<LayoutObject&>(m_object).clearNeedsPaintPropertyUpdate(); 143 const_cast<LayoutObject&>(m_object).clearNeedsPaintPropertyUpdate();
144 m_context.forceSubtreeUpdate = m_hadForceSubtreeUpdate;
133 } 145 }
134 146
135 private: 147 private:
136 const LayoutObject& m_object; 148 const LayoutObject& m_object;
137 bool m_neededPaintPropertyUpdate; 149 bool m_neededPaintPropertyUpdate;
150 PaintPropertyTreeBuilderContext& m_context;
151 bool m_hadForceSubtreeUpdate;
138 std::unique_ptr<const ObjectPaintProperties> m_properties; 152 std::unique_ptr<const ObjectPaintProperties> m_properties;
139 }; 153 };
140 154
141 } // namespace blink 155 } // namespace blink
142 #endif // DCHECK_IS_ON() 156 #endif // DCHECK_IS_ON()
143 157
144 #endif // FindPropertiesNeedingUpdate_h 158 #endif // FindPropertiesNeedingUpdate_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698