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

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

Issue 2614093002: Combine LayoutObject::previousPaintOffset and paintOffset in paint properties (Closed)
Patch Set: Resolve conflict Created 3 years, 11 months 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 10 matching lines...) Expand all
21 namespace blink { 21 namespace blink {
22 22
23 // This class stores the paint property nodes associated with a LayoutObject. 23 // This class stores the paint property nodes associated with a LayoutObject.
24 // The object owns each of the property nodes directly set here (e.g, m_cssClip, 24 // The object owns each of the property nodes directly set here (e.g, m_cssClip,
25 // m_paintOffsetTranslation, etc.) and RefPtrs are only used to harden against 25 // m_paintOffsetTranslation, etc.) and RefPtrs are only used to harden against
26 // use-after-free bugs. These paint properties are built/updated by 26 // use-after-free bugs. These paint properties are built/updated by
27 // PaintPropertyTreeBuilder during the PrePaint lifecycle step. 27 // PaintPropertyTreeBuilder during the PrePaint lifecycle step.
28 // 28 //
29 // There are two groups of information stored on ObjectPaintProperties: 29 // There are two groups of information stored on ObjectPaintProperties:
30 // 1. The set of property nodes created locally and owned by this LayoutObject. 30 // 1. The set of property nodes created locally and owned by this LayoutObject.
31 // 2. The set of property nodes (inherited, or created locally) and paint offset 31 // 2. The set of property nodes (inherited, or created locally) that can be used
32 // that can be used to paint the border box of this LayoutObject (see: 32 // along with LayoutObject::paintOffset to paint the border box of this
33 // localBorderBoxProperties). 33 // LayoutObject (see: localBorderBoxProperties).
34 // 34 //
35 // [update & clear implementation note] This class has update[property](...) and 35 // [update & clear implementation note] This class has update[property](...) and
36 // clear[property]() helper functions for efficiently creating and updating 36 // clear[property]() helper functions for efficiently creating and updating
37 // properties. These functions return true if the property tree structure 37 // properties. These functions return true if the property tree structure
38 // changes (e.g., a node is added or removed), and false otherwise. Property 38 // changes (e.g., a node is added or removed), and false otherwise. Property
39 // nodes store parent pointers but not child pointers and these return values 39 // nodes store parent pointers but not child pointers and these return values
40 // are important for catching property tree structure changes which require 40 // are important for catching property tree structure changes which require
41 // updating descendant's parent pointers. The update functions use a 41 // updating descendant's parent pointers. The update functions use a
42 // create-or-update pattern of re-using existing properties for efficiency: 42 // create-or-update pattern of re-using existing properties for efficiency:
43 // 1. It avoids extra allocations. 43 // 1. It avoids extra allocations.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const ClipPaintPropertyNode* cssClipFixedPosition() const { 109 const ClipPaintPropertyNode* cssClipFixedPosition() const {
110 return m_cssClipFixedPosition.get(); 110 return m_cssClipFixedPosition.get();
111 } 111 }
112 const ClipPaintPropertyNode* innerBorderRadiusClip() const { 112 const ClipPaintPropertyNode* innerBorderRadiusClip() const {
113 return m_innerBorderRadiusClip.get(); 113 return m_innerBorderRadiusClip.get();
114 } 114 }
115 const ClipPaintPropertyNode* overflowClip() const { 115 const ClipPaintPropertyNode* overflowClip() const {
116 return m_overflowClip.get(); 116 return m_overflowClip.get();
117 } 117 }
118 118
119 // The complete set of property tree nodes (inherited, or created locally) and
120 // paint offset that can be used to paint. |paintOffset| is relative to the
121 // propertyTreeState's transform space.
122 // See: localBorderBoxProperties and contentsProperties.
123 struct PropertyTreeStateWithOffset {
124 PropertyTreeStateWithOffset(LayoutPoint offset, PropertyTreeState treeState)
125 : paintOffset(offset), propertyTreeState(treeState) {}
126 LayoutPoint paintOffset;
127 PropertyTreeState propertyTreeState;
128 };
129
130 // This is a complete set of property nodes and paint offset that should be 119 // This is a complete set of property nodes and paint offset that should be
131 // used as a starting point to paint this layout object. This is cached 120 // used as a starting point to paint this layout object. This is cached
132 // because some properties inherit from the containing block chain instead of 121 // because some properties inherit from the containing block chain instead of
133 // the painting parent and cannot be derived in O(1) during the paint walk. 122 // the painting parent and cannot be derived in O(1) during the paint walk.
134 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> 123 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/>
135 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() 124 // would have a paint offset of (11px, 11px) and propertyTreeState.effect()
136 // would be an effect node with opacity of 0.3 which was created by the div 125 // would be an effect node with opacity of 0.3 which was created by the div
137 // itself. Note that propertyTreeState.transform() would not be null but would 126 // itself. Note that propertyTreeState.transform() would not be null but would
138 // instead point to the transform space setup by div's ancestors. 127 // instead point to the transform space setup by div's ancestors.
139 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { 128 const PropertyTreeState* localBorderBoxProperties() const {
140 return m_localBorderBoxProperties.get(); 129 return m_localBorderBoxProperties.get();
141 } 130 }
142 131
143 // This is the complete set of property nodes and paint offset that can be 132 // This is the complete set of property nodes and paint offset that can be
144 // used to paint the contents of this object. It is similar to 133 // used to paint the contents of this object. It is similar to
145 // localBorderBoxProperties but includes properties (e.g., overflow clip, 134 // localBorderBoxProperties but includes properties (e.g., overflow clip,
146 // scroll translation) that apply to contents. This is suitable for paint 135 // scroll translation) that apply to contents. This is suitable for paint
147 // invalidation. 136 // invalidation.
148 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; 137 PropertyTreeState contentsProperties() const;
149 138
150 void updateLocalBorderBoxProperties( 139 void updateLocalBorderBoxProperties(
151 LayoutPoint& paintOffset,
152 const TransformPaintPropertyNode* transform, 140 const TransformPaintPropertyNode* transform,
153 const ClipPaintPropertyNode* clip, 141 const ClipPaintPropertyNode* clip,
154 const EffectPaintPropertyNode* effect, 142 const EffectPaintPropertyNode* effect,
155 const ScrollPaintPropertyNode* scroll) { 143 const ScrollPaintPropertyNode* scroll) {
156 if (m_localBorderBoxProperties) { 144 if (m_localBorderBoxProperties) {
157 m_localBorderBoxProperties->paintOffset = paintOffset; 145 m_localBorderBoxProperties->setTransform(transform);
158 m_localBorderBoxProperties->propertyTreeState.setTransform(transform); 146 m_localBorderBoxProperties->setClip(clip);
159 m_localBorderBoxProperties->propertyTreeState.setClip(clip); 147 m_localBorderBoxProperties->setEffect(effect);
160 m_localBorderBoxProperties->propertyTreeState.setEffect(effect); 148 m_localBorderBoxProperties->setScroll(scroll);
161 m_localBorderBoxProperties->propertyTreeState.setScroll(scroll);
162 } else { 149 } else {
163 m_localBorderBoxProperties = WTF::wrapUnique( 150 m_localBorderBoxProperties = WTF::wrapUnique(new PropertyTreeState(
164 new ObjectPaintProperties::PropertyTreeStateWithOffset( 151 PropertyTreeState(transform, clip, effect, scroll)));
165 paintOffset, PropertyTreeState(transform, clip, effect, scroll)));
166 } 152 }
167 } 153 }
168 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } 154 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; }
169 155
170 // The following clear* functions return true if the property tree structure 156 // The following clear* functions return true if the property tree structure
171 // changes (an existing node was deleted), and false otherwise. See the 157 // changes (an existing node was deleted), and false otherwise. See the
172 // class-level comment ("update & clear implementation note") for details 158 // class-level comment ("update & clear implementation note") for details
173 // about why this is needed for efficient updates. 159 // about why this is needed for efficient updates.
174 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } 160 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); }
175 bool clearTransform() { return clear(m_transform); } 161 bool clearTransform() { return clear(m_transform); }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 cloned->m_svgLocalToBorderBoxTransform = 255 cloned->m_svgLocalToBorderBoxTransform =
270 m_svgLocalToBorderBoxTransform->clone(); 256 m_svgLocalToBorderBoxTransform->clone();
271 } 257 }
272 if (m_scrollTranslation) 258 if (m_scrollTranslation)
273 cloned->m_scrollTranslation = m_scrollTranslation->clone(); 259 cloned->m_scrollTranslation = m_scrollTranslation->clone();
274 if (m_scrollbarPaintOffset) 260 if (m_scrollbarPaintOffset)
275 cloned->m_scrollbarPaintOffset = m_scrollbarPaintOffset->clone(); 261 cloned->m_scrollbarPaintOffset = m_scrollbarPaintOffset->clone();
276 if (m_scroll) 262 if (m_scroll)
277 cloned->m_scroll = m_scroll->clone(); 263 cloned->m_scroll = m_scroll->clone();
278 if (m_localBorderBoxProperties) { 264 if (m_localBorderBoxProperties) {
279 auto& state = m_localBorderBoxProperties->propertyTreeState;
280 cloned->m_localBorderBoxProperties = 265 cloned->m_localBorderBoxProperties =
281 WTF::wrapUnique(new PropertyTreeStateWithOffset( 266 WTF::wrapUnique(new PropertyTreeState(*m_localBorderBoxProperties));
282 m_localBorderBoxProperties->paintOffset,
283 PropertyTreeState(state.transform(), state.clip(), state.effect(),
284 state.scroll())));
285 } 267 }
286 return cloned; 268 return cloned;
287 } 269 }
288 #endif 270 #endif
289 271
290 private: 272 private:
291 ObjectPaintProperties() {} 273 ObjectPaintProperties() {}
292 274
293 // Return true if the property tree structure changes (an existing node was 275 // Return true if the property tree structure changes (an existing node was
294 // deleted), and false otherwise. See the class-level comment ("update & clear 276 // deleted), and false otherwise. See the class-level comment ("update & clear
(...skipping 27 matching lines...) Expand all
322 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; 304 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition;
323 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; 305 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip;
324 RefPtr<ClipPaintPropertyNode> m_overflowClip; 306 RefPtr<ClipPaintPropertyNode> m_overflowClip;
325 RefPtr<TransformPaintPropertyNode> m_perspective; 307 RefPtr<TransformPaintPropertyNode> m_perspective;
326 // 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.
327 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; 309 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform;
328 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 310 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
329 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 311 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
330 RefPtr<ScrollPaintPropertyNode> m_scroll; 312 RefPtr<ScrollPaintPropertyNode> m_scroll;
331 313
332 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; 314 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties;
333 }; 315 };
334 316
335 } // namespace blink 317 } // namespace blink
336 318
337 #endif // ObjectPaintProperties_h 319 #endif // ObjectPaintProperties_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698