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

Side by Side Diff: third_party/WebKit/Source/core/paint/ObjectPaintProperties.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 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 "platform/geometry/LayoutPoint.h" 9 #include "platform/geometry/LayoutPoint.h"
10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // would be an effect node with opacity of 0.3 which was created by the div 121 // 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 122 // itself. Note that propertyTreeState.transform() would not be null but would
123 // instead point to the transform space setup by div's ancestors. 123 // instead point to the transform space setup by div's ancestors.
124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { 124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const {
125 return m_localBorderBoxProperties.get(); 125 return m_localBorderBoxProperties.get();
126 } 126 }
127 void setLocalBorderBoxProperties( 127 void setLocalBorderBoxProperties(
128 std::unique_ptr<PropertyTreeStateWithOffset> properties) { 128 std::unique_ptr<PropertyTreeStateWithOffset> properties) {
129 m_localBorderBoxProperties = std::move(properties); 129 m_localBorderBoxProperties = std::move(properties);
130 } 130 }
131 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; }
131 132
132 // This is the complete set of property nodes and paint offset that can be 133 // 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 134 // used to paint the contents of this object. It is similar to
134 // localBorderBoxProperties but includes properties (e.g., overflow clip, 135 // localBorderBoxProperties but includes properties (e.g., overflow clip,
135 // scroll translation) that apply to contents. This is suitable for paint 136 // scroll translation) that apply to contents. This is suitable for paint
136 // invalidation. 137 // invalidation.
137 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; 138 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const;
138 139
139 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } 140 // True if an existing property was deleted, false otherwise.
140 void clearTransform() { m_transform = nullptr; } 141 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); }
141 void clearEffect() { m_effect = nullptr; } 142 // True if an existing property was deleted, false otherwise.
142 void clearCssClip() { m_cssClip = nullptr; } 143 bool clearTransform() { return clear(m_transform); }
143 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } 144 // True if an existing property was deleted, false otherwise.
144 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } 145 bool clearEffect() { return clear(m_effect); }
145 void clearOverflowClip() { m_overflowClip = nullptr; } 146 // True if an existing property was deleted, false otherwise.
146 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } 147 bool clearCssClip() { return clear(m_cssClip); }
147 void clearPerspective() { m_perspective = nullptr; } 148 // True if an existing property was deleted, false otherwise.
148 void clearSvgLocalToBorderBoxTransform() { 149 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); }
149 m_svgLocalToBorderBoxTransform = nullptr; 150 // True if an existing property was deleted, false otherwise.
151 bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); }
152 // True if an existing property was deleted, false otherwise.
153 bool clearOverflowClip() { return clear(m_overflowClip); }
154 // True if an existing property was deleted, false otherwise.
155 bool clearPerspective() { return clear(m_perspective); }
156 // True if an existing property was deleted, false otherwise.
157 bool clearSvgLocalToBorderBoxTransform() {
158 return clear(m_svgLocalToBorderBoxTransform);
150 } 159 }
151 void clearScrollTranslation() { m_scrollTranslation = nullptr; } 160 // True if an existing property was deleted, false otherwise.
152 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } 161 bool clearScrollTranslation() { return clear(m_scrollTranslation); }
153 void clearScroll() { m_scroll = nullptr; } 162 // True if an existing property was deleted, false otherwise.
163 bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); }
164 // True if an existing property was deleted, false otherwise.
165 bool clearScroll() { return clear(m_scroll); }
154 166
167 // True if a new property was created, false if an existing one was updated.
155 template <typename... Args> 168 template <typename... Args>
156 void updatePaintOffsetTranslation(Args&&... args) { 169 bool updatePaintOffsetTranslation(Args&&... args) {
157 updateProperty(m_paintOffsetTranslation, std::forward<Args>(args)...); 170 return update(m_paintOffsetTranslation, std::forward<Args>(args)...);
158 } 171 }
172 // True if a new property was created, false if an existing one was updated.
159 template <typename... Args> 173 template <typename... Args>
160 void updateTransform(Args&&... args) { 174 bool updateTransform(Args&&... args) {
161 updateProperty(m_transform, std::forward<Args>(args)...); 175 return update(m_transform, std::forward<Args>(args)...);
162 } 176 }
177 // True if a new property was created, false if an existing one was updated.
163 template <typename... Args> 178 template <typename... Args>
164 void updatePerspective(Args&&... args) { 179 bool updatePerspective(Args&&... args) {
165 updateProperty(m_perspective, std::forward<Args>(args)...); 180 return update(m_perspective, std::forward<Args>(args)...);
166 } 181 }
182 // True if a new property was created, false if an existing one was updated.
167 template <typename... Args> 183 template <typename... Args>
168 void updateSvgLocalToBorderBoxTransform(Args&&... args) { 184 bool updateSvgLocalToBorderBoxTransform(Args&&... args) {
169 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " 185 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there "
170 "should never be both a scroll translation " 186 "should never be both a scroll translation "
171 "and an SVG local to border box transform."; 187 "and an SVG local to border box transform.";
172 updateProperty(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); 188 return update(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...);
173 } 189 }
190 // True if a new property was created, false if an existing one was updated.
174 template <typename... Args> 191 template <typename... Args>
175 void updateScrollTranslation(Args&&... args) { 192 bool updateScrollTranslation(Args&&... args) {
176 DCHECK(!svgLocalToBorderBoxTransform()) 193 DCHECK(!svgLocalToBorderBoxTransform())
177 << "SVG elements cannot scroll so there should never be both a scroll " 194 << "SVG elements cannot scroll so there should never be both a scroll "
178 "translation and an SVG local to border box transform."; 195 "translation and an SVG local to border box transform.";
179 updateProperty(m_scrollTranslation, std::forward<Args>(args)...); 196 return update(m_scrollTranslation, std::forward<Args>(args)...);
180 } 197 }
198 // True if a new property was created, false if an existing one was updated.
181 template <typename... Args> 199 template <typename... Args>
182 void updateScrollbarPaintOffset(Args&&... args) { 200 bool updateScrollbarPaintOffset(Args&&... args) {
183 updateProperty(m_scrollbarPaintOffset, std::forward<Args>(args)...); 201 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...);
184 } 202 }
203 // True if a new property was created, false if an existing one was updated.
185 template <typename... Args> 204 template <typename... Args>
186 void updateScroll(Args&&... args) { 205 bool updateScroll(Args&&... args) {
187 updateProperty(m_scroll, std::forward<Args>(args)...); 206 return update(m_scroll, std::forward<Args>(args)...);
188 } 207 }
208 // True if a new property was created, false if an existing one was updated.
189 template <typename... Args> 209 template <typename... Args>
190 void updateEffect(Args&&... args) { 210 bool updateEffect(Args&&... args) {
191 updateProperty(m_effect, std::forward<Args>(args)...); 211 return update(m_effect, std::forward<Args>(args)...);
192 } 212 }
213 // True if a new property was created, false if an existing one was updated.
193 template <typename... Args> 214 template <typename... Args>
194 void updateCssClip(Args&&... args) { 215 bool updateCssClip(Args&&... args) {
195 updateProperty(m_cssClip, std::forward<Args>(args)...); 216 return update(m_cssClip, std::forward<Args>(args)...);
196 } 217 }
218 // True if a new property was created, false if an existing one was updated.
197 template <typename... Args> 219 template <typename... Args>
198 void updateCssClipFixedPosition(Args&&... args) { 220 bool updateCssClipFixedPosition(Args&&... args) {
199 updateProperty(m_cssClipFixedPosition, std::forward<Args>(args)...); 221 return update(m_cssClipFixedPosition, std::forward<Args>(args)...);
200 } 222 }
223 // True if a new property was created, false if an existing one was updated.
201 template <typename... Args> 224 template <typename... Args>
202 void updateInnerBorderRadiusClip(Args&&... args) { 225 bool updateInnerBorderRadiusClip(Args&&... args) {
203 updateProperty(m_innerBorderRadiusClip, std::forward<Args>(args)...); 226 return update(m_innerBorderRadiusClip, std::forward<Args>(args)...);
204 } 227 }
228 // True if a new property was created, false if an existing one was updated.
205 template <typename... Args> 229 template <typename... Args>
206 void updateOverflowClip(Args&&... args) { 230 bool updateOverflowClip(Args&&... args) {
207 updateProperty(m_overflowClip, std::forward<Args>(args)...); 231 return update(m_overflowClip, std::forward<Args>(args)...);
208 } 232 }
209 233
210 #if DCHECK_IS_ON() 234 #if DCHECK_IS_ON()
211 // Used by FindPropertiesNeedingUpdate.h for recording the current properties. 235 // Used by FindPropertiesNeedingUpdate.h for recording the current properties.
212 std::unique_ptr<ObjectPaintProperties> clone() const { 236 std::unique_ptr<ObjectPaintProperties> clone() const {
213 std::unique_ptr<ObjectPaintProperties> cloned = create(); 237 std::unique_ptr<ObjectPaintProperties> cloned = create();
214 if (m_paintOffsetTranslation) 238 if (m_paintOffsetTranslation)
215 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); 239 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone();
216 if (m_transform) 240 if (m_transform)
217 cloned->m_transform = m_transform->clone(); 241 cloned->m_transform = m_transform->clone();
(...skipping 27 matching lines...) Expand all
245 PropertyTreeState(state.transform(), state.clip(), state.effect(), 269 PropertyTreeState(state.transform(), state.clip(), state.effect(),
246 state.scroll()))); 270 state.scroll())));
247 } 271 }
248 return cloned; 272 return cloned;
249 } 273 }
250 #endif 274 #endif
251 275
252 private: 276 private:
253 ObjectPaintProperties() {} 277 ObjectPaintProperties() {}
254 278
279 // True if an existing property was deleted, false otherwise.
280 template <typename PaintPropertyNode>
281 bool clear(RefPtr<PaintPropertyNode>& field) {
282 if (field) {
283 field = nullptr;
284 return true;
285 }
286 return false;
287 }
288
289 // True if a new property was created, false if an existing one was updated.
255 template <typename PaintPropertyNode, typename... Args> 290 template <typename PaintPropertyNode, typename... Args>
256 void updateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) { 291 bool update(RefPtr<PaintPropertyNode>& field, Args&&... args) {
257 if (field) 292 if (field) {
258 field->update(std::forward<Args>(args)...); 293 field->update(std::forward<Args>(args)...);
259 else 294 return false;
260 field = PaintPropertyNode::create(std::forward<Args>(args)...); 295 }
296 field = PaintPropertyNode::create(std::forward<Args>(args)...);
297 return true;
261 } 298 }
262 299
263 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; 300 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation;
264 RefPtr<TransformPaintPropertyNode> m_transform; 301 RefPtr<TransformPaintPropertyNode> m_transform;
265 RefPtr<EffectPaintPropertyNode> m_effect; 302 RefPtr<EffectPaintPropertyNode> m_effect;
266 RefPtr<ClipPaintPropertyNode> m_cssClip; 303 RefPtr<ClipPaintPropertyNode> m_cssClip;
267 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; 304 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition;
268 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; 305 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip;
269 RefPtr<ClipPaintPropertyNode> m_overflowClip; 306 RefPtr<ClipPaintPropertyNode> m_overflowClip;
270 RefPtr<TransformPaintPropertyNode> m_perspective; 307 RefPtr<TransformPaintPropertyNode> m_perspective;
271 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. 308 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there.
272 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; 309 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform;
273 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 310 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
274 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 311 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
275 RefPtr<ScrollPaintPropertyNode> m_scroll; 312 RefPtr<ScrollPaintPropertyNode> m_scroll;
276 313
277 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; 314 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties;
278 }; 315 };
279 316
280 } // namespace blink 317 } // namespace blink
281 318
282 #endif // ObjectPaintProperties_h 319 #endif // ObjectPaintProperties_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698