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

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

Issue 2515113002: WIP: Prune the prepaint tree walk (Closed)
Patch Set: Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 ObjectPaintProperties_h 5 #ifndef ObjectPaintProperties_h
6 #define ObjectPaintProperties_h 6 #define ObjectPaintProperties_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/paint/PaintPropertyTreeBuilder.h"
9 #include "platform/geometry/LayoutPoint.h" 10 #include "platform/geometry/LayoutPoint.h"
10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 11 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
11 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 12 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
12 #include "platform/graphics/paint/PaintChunkProperties.h" 13 #include "platform/graphics/paint/PaintChunkProperties.h"
13 #include "platform/graphics/paint/PropertyTreeState.h" 14 #include "platform/graphics/paint/PropertyTreeState.h"
14 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 15 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
15 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 16 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
16 #include "wtf/PassRefPtr.h" 17 #include "wtf/PassRefPtr.h"
17 #include "wtf/PtrUtil.h" 18 #include "wtf/PtrUtil.h"
18 #include "wtf/RefPtr.h" 19 #include "wtf/RefPtr.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // because some properties inherit from the containing block chain instead of 118 // because some properties inherit from the containing block chain instead of
118 // the painting parent and cannot be derived in O(1) during the paint walk. 119 // the painting parent and cannot be derived in O(1) during the paint walk.
119 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> 120 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/>
120 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() 121 // would have a paint offset of (11px, 11px) and propertyTreeState.effect()
121 // would be an effect node with opacity of 0.3 which was created by the div 122 // would be an effect node with opacity of 0.3 which was created by the div
122 // itself. Note that propertyTreeState.transform() would not be null but would 123 // itself. Note that propertyTreeState.transform() would not be null but would
123 // instead point to the transform space setup by div's ancestors. 124 // instead point to the transform space setup by div's ancestors.
124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { 125 const PropertyTreeStateWithOffset* localBorderBoxProperties() const {
125 return m_localBorderBoxProperties.get(); 126 return m_localBorderBoxProperties.get();
126 } 127 }
127 void setLocalBorderBoxProperties( 128 TreeStructureChange setLocalBorderBoxProperties(
128 std::unique_ptr<PropertyTreeStateWithOffset> properties) { 129 std::unique_ptr<PropertyTreeStateWithOffset> properties) {
130 DCHECK(properties);
131 bool existingNode = !!m_localBorderBoxProperties;
129 m_localBorderBoxProperties = std::move(properties); 132 m_localBorderBoxProperties = std::move(properties);
133 return existingNode ? StructureNotChanged : StructureChanged;
134 }
135 TreeStructureChange clearLocalBorderBoxProperties() {
136 if (m_localBorderBoxProperties) {
137 m_localBorderBoxProperties = nullptr;
138 return StructureChanged;
139 }
140 return StructureNotChanged;
130 } 141 }
131 142
132 // This is the complete set of property nodes and paint offset that can be 143 // This is the complete set of property nodes and paint offset that can be
133 // used to paint the contents of this object. It is similar to 144 // used to paint the contents of this object. It is similar to
134 // localBorderBoxProperties but includes properties (e.g., overflow clip, 145 // localBorderBoxProperties but includes properties (e.g., overflow clip,
135 // scroll translation) that apply to contents. This is suitable for paint 146 // scroll translation) that apply to contents. This is suitable for paint
136 // invalidation. 147 // invalidation.
137 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; 148 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const;
138 149
139 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } 150 TreeStructureChange clearPaintOffsetTranslation() {
140 void clearTransform() { m_transform = nullptr; } 151 return clear(m_paintOffsetTranslation);
141 void clearEffect() { m_effect = nullptr; }
142 void clearCssClip() { m_cssClip = nullptr; }
143 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; }
144 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; }
145 void clearOverflowClip() { m_overflowClip = nullptr; }
146 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; }
147 void clearPerspective() { m_perspective = nullptr; }
148 void clearSvgLocalToBorderBoxTransform() {
149 m_svgLocalToBorderBoxTransform = nullptr;
150 } 152 }
151 void clearScrollTranslation() { m_scrollTranslation = nullptr; } 153 TreeStructureChange clearTransform() { return clear(m_transform); }
152 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } 154 TreeStructureChange clearEffect() { return clear(m_effect); }
153 void clearScroll() { m_scroll = nullptr; } 155 TreeStructureChange clearCssClip() { return clear(m_cssClip); }
156 TreeStructureChange clearCssClipFixedPosition() {
157 return clear(m_cssClipFixedPosition);
158 }
159 TreeStructureChange clearInnerBorderRadiusClip() {
160 return clear(m_innerBorderRadiusClip);
161 }
162 TreeStructureChange clearOverflowClip() { return clear(m_overflowClip); }
163 TreeStructureChange clearPerspective() { return clear(m_perspective); }
164 TreeStructureChange clearSvgLocalToBorderBoxTransform() {
165 return clear(m_svgLocalToBorderBoxTransform);
166 }
167 TreeStructureChange clearScrollTranslation() {
168 return clear(m_scrollTranslation);
169 }
170 TreeStructureChange clearScrollbarPaintOffset() {
171 return clear(m_scrollbarPaintOffset);
172 }
173 TreeStructureChange clearScroll() { return clear(m_scroll); }
154 174
155 template <typename... Args> 175 template <typename... Args>
156 void updatePaintOffsetTranslation(Args&&... args) { 176 TreeStructureChange updatePaintOffsetTranslation(Args&&... args) {
157 updateProperty(m_paintOffsetTranslation, std::forward<Args>(args)...); 177 return update(m_paintOffsetTranslation, std::forward<Args>(args)...);
158 } 178 }
159 template <typename... Args> 179 template <typename... Args>
160 void updateTransform(Args&&... args) { 180 TreeStructureChange updateTransform(Args&&... args) {
161 updateProperty(m_transform, std::forward<Args>(args)...); 181 return update(m_transform, std::forward<Args>(args)...);
162 } 182 }
163 template <typename... Args> 183 template <typename... Args>
164 void updatePerspective(Args&&... args) { 184 TreeStructureChange updatePerspective(Args&&... args) {
165 updateProperty(m_perspective, std::forward<Args>(args)...); 185 return update(m_perspective, std::forward<Args>(args)...);
166 } 186 }
167 template <typename... Args> 187 template <typename... Args>
168 void updateSvgLocalToBorderBoxTransform(Args&&... args) { 188 TreeStructureChange updateSvgLocalToBorderBoxTransform(Args&&... args) {
169 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " 189 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there "
170 "should never be both a scroll translation " 190 "should never be both a scroll translation "
171 "and an SVG local to border box transform."; 191 "and an SVG local to border box transform.";
172 updateProperty(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); 192 return update(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...);
173 } 193 }
174 template <typename... Args> 194 template <typename... Args>
175 void updateScrollTranslation(Args&&... args) { 195 TreeStructureChange updateScrollTranslation(Args&&... args) {
176 DCHECK(!svgLocalToBorderBoxTransform()) 196 DCHECK(!svgLocalToBorderBoxTransform())
177 << "SVG elements cannot scroll so there should never be both a scroll " 197 << "SVG elements cannot scroll so there should never be both a scroll "
178 "translation and an SVG local to border box transform."; 198 "translation and an SVG local to border box transform.";
179 updateProperty(m_scrollTranslation, std::forward<Args>(args)...); 199 return update(m_scrollTranslation, std::forward<Args>(args)...);
180 } 200 }
181 template <typename... Args> 201 template <typename... Args>
182 void updateScrollbarPaintOffset(Args&&... args) { 202 TreeStructureChange updateScrollbarPaintOffset(Args&&... args) {
183 updateProperty(m_scrollbarPaintOffset, std::forward<Args>(args)...); 203 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...);
184 } 204 }
185 template <typename... Args> 205 template <typename... Args>
186 void updateScroll(Args&&... args) { 206 TreeStructureChange updateScroll(Args&&... args) {
187 updateProperty(m_scroll, std::forward<Args>(args)...); 207 return update(m_scroll, std::forward<Args>(args)...);
188 } 208 }
189 template <typename... Args> 209 template <typename... Args>
190 void updateEffect(Args&&... args) { 210 TreeStructureChange updateEffect(Args&&... args) {
191 updateProperty(m_effect, std::forward<Args>(args)...); 211 return update(m_effect, std::forward<Args>(args)...);
192 } 212 }
193 template <typename... Args> 213 template <typename... Args>
194 void updateCssClip(Args&&... args) { 214 TreeStructureChange updateCssClip(Args&&... args) {
195 updateProperty(m_cssClip, std::forward<Args>(args)...); 215 return update(m_cssClip, std::forward<Args>(args)...);
196 } 216 }
197 template <typename... Args> 217 template <typename... Args>
198 void updateCssClipFixedPosition(Args&&... args) { 218 TreeStructureChange updateCssClipFixedPosition(Args&&... args) {
199 updateProperty(m_cssClipFixedPosition, std::forward<Args>(args)...); 219 return update(m_cssClipFixedPosition, std::forward<Args>(args)...);
200 } 220 }
201 template <typename... Args> 221 template <typename... Args>
202 void updateInnerBorderRadiusClip(Args&&... args) { 222 TreeStructureChange updateInnerBorderRadiusClip(Args&&... args) {
203 updateProperty(m_innerBorderRadiusClip, std::forward<Args>(args)...); 223 return update(m_innerBorderRadiusClip, std::forward<Args>(args)...);
204 } 224 }
205 template <typename... Args> 225 template <typename... Args>
206 void updateOverflowClip(Args&&... args) { 226 TreeStructureChange updateOverflowClip(Args&&... args) {
207 updateProperty(m_overflowClip, std::forward<Args>(args)...); 227 return update(m_overflowClip, std::forward<Args>(args)...);
208 } 228 }
209 229
210 #if DCHECK_IS_ON() 230 #if DCHECK_IS_ON()
211 // Used by FindPropertiesNeedingUpdate.h for recording the current properties. 231 // Used by FindPropertiesNeedingUpdate.h for recording the current properties.
212 std::unique_ptr<ObjectPaintProperties> clone() const { 232 std::unique_ptr<ObjectPaintProperties> clone() const {
213 std::unique_ptr<ObjectPaintProperties> cloned = create(); 233 std::unique_ptr<ObjectPaintProperties> cloned = create();
214 if (m_paintOffsetTranslation) 234 if (m_paintOffsetTranslation)
215 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); 235 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone();
216 if (m_transform) 236 if (m_transform)
217 cloned->m_transform = m_transform->clone(); 237 cloned->m_transform = m_transform->clone();
(...skipping 28 matching lines...) Expand all
246 state.scroll()))); 266 state.scroll())));
247 } 267 }
248 return cloned; 268 return cloned;
249 } 269 }
250 #endif 270 #endif
251 271
252 private: 272 private:
253 ObjectPaintProperties() {} 273 ObjectPaintProperties() {}
254 274
255 template <typename PaintPropertyNode, typename... Args> 275 template <typename PaintPropertyNode, typename... Args>
256 void updateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) { 276 TreeStructureChange update(RefPtr<PaintPropertyNode>& field, Args&&... args) {
257 if (field) 277 if (field) {
258 field->update(std::forward<Args>(args)...); 278 field->update(std::forward<Args>(args)...);
259 else 279 return StructureNotChanged;
260 field = PaintPropertyNode::create(std::forward<Args>(args)...); 280 }
281 field = PaintPropertyNode::create(std::forward<Args>(args)...);
282 return StructureChanged;
283 }
284
285 template <typename PaintPropertyNode>
286 TreeStructureChange clear(RefPtr<PaintPropertyNode>& field) {
287 if (field) {
288 field = nullptr;
289 return StructureChanged;
290 }
291 return StructureNotChanged;
261 } 292 }
262 293
263 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; 294 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation;
264 RefPtr<TransformPaintPropertyNode> m_transform; 295 RefPtr<TransformPaintPropertyNode> m_transform;
265 RefPtr<EffectPaintPropertyNode> m_effect; 296 RefPtr<EffectPaintPropertyNode> m_effect;
266 RefPtr<ClipPaintPropertyNode> m_cssClip; 297 RefPtr<ClipPaintPropertyNode> m_cssClip;
267 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; 298 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition;
268 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; 299 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip;
269 RefPtr<ClipPaintPropertyNode> m_overflowClip; 300 RefPtr<ClipPaintPropertyNode> m_overflowClip;
270 RefPtr<TransformPaintPropertyNode> m_perspective; 301 RefPtr<TransformPaintPropertyNode> m_perspective;
271 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. 302 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there.
272 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; 303 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform;
273 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 304 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
274 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 305 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
275 RefPtr<ScrollPaintPropertyNode> m_scroll; 306 RefPtr<ScrollPaintPropertyNode> m_scroll;
276 307
277 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; 308 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties;
278 }; 309 };
279 310
280 } // namespace blink 311 } // namespace blink
281 312
282 #endif // ObjectPaintProperties_h 313 #endif // ObjectPaintProperties_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698