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

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

Issue 2378883003: Refactor PropertyTreeState to use RefPtrs (Closed)
Patch Set: Created 4 years, 2 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"
11 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 11 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
12 #include "platform/graphics/paint/GeometryPropertyTreeState.h" 12 #include "platform/graphics/paint/GeometryPropertyTreeState.h"
13 #include "platform/graphics/paint/PaintChunkProperties.h" 13 #include "platform/graphics/paint/PaintChunkProperties.h"
14 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 14 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
15 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 15 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
16 #include "wtf/PassRefPtr.h" 16 #include "wtf/PassRefPtr.h"
17 #include "wtf/PtrUtil.h" 17 #include "wtf/PtrUtil.h"
18 #include "wtf/RefPtr.h" 18 #include "wtf/RefPtr.h"
19 #include <memory> 19 #include <memory>
20 20
21 namespace blink { 21 namespace blink {
22 22
23 // A complete set of paint properties including those that are inherited from ot her objects. 23 // A complete set of paint properties including those that are inherited from ot her objects.
24 struct PropertyTreeState { 24 // RefPtrs are used to guard against use-after-free bugs and DCHECKs ensure Prop ertyTreeState never
25 PropertyTreeState(const TransformPaintPropertyNode* transformState, 25 // retains the last reference to a property tree node.
26 const ClipPaintPropertyNode* clipState, const EffectPaintPropertyNode* e ffectState, 26 class PropertyTreeState {
27 const ScrollPaintPropertyNode* scrollState) 27 public:
28 : transform(transformState), clip(clipState), effect(effectState), scrol l(scrollState) 28 PropertyTreeState(const TransformPaintPropertyNode* transform,
29 const ClipPaintPropertyNode* clip,
30 const EffectPaintPropertyNode* effect,
31 const ScrollPaintPropertyNode* scroll)
32 : m_transform(transform), m_clip(clip), m_effect(effect), m_scroll(scrol l)
29 { 33 {
30 DCHECK(transform && clip && effect && scroll); 34 DCHECK(!m_transform->hasOneRef() && !m_clip->hasOneRef() && !m_effect->h asOneRef() && !m_scroll->hasOneRef());
31 } 35 }
32 const TransformPaintPropertyNode* transform; 36
33 const ClipPaintPropertyNode* clip; 37 const TransformPaintPropertyNode* transform() const { DCHECK(!m_transform->h asOneRef()); return m_transform.get(); }
34 const EffectPaintPropertyNode* effect; 38 const ClipPaintPropertyNode* clip() const { DCHECK(!m_clip->hasOneRef()); re turn m_clip.get(); }
35 const ScrollPaintPropertyNode* scroll; 39 const EffectPaintPropertyNode* effect() const { DCHECK(!m_effect->hasOneRef( )); return m_effect.get(); }
40 const ScrollPaintPropertyNode* scroll() const { DCHECK(!m_scroll->hasOneRef( )); return m_scroll.get(); }
41
42 private:
43 RefPtr<const TransformPaintPropertyNode> m_transform;
44 RefPtr<const ClipPaintPropertyNode> m_clip;
45 RefPtr<const EffectPaintPropertyNode> m_effect;
46 RefPtr<const ScrollPaintPropertyNode> m_scroll;
36 }; 47 };
37 48
38 // This class stores property tree related information associated with a LayoutO bject. 49 // This class stores property tree related information associated with a LayoutO bject.
39 // Currently there are two groups of information: 50 // Currently there are two groups of information:
40 // 1. The set of property nodes created locally by this LayoutObject. 51 // 1. The set of property nodes created locally by this LayoutObject.
41 // 2. [Optional] A suite of property nodes (PaintChunkProperties) and paint offs et 52 // 2. [Optional] A suite of property nodes (PaintChunkProperties) and paint offs et
42 // that can be used to paint the border box of this LayoutObject. 53 // that can be used to paint the border box of this LayoutObject.
43 class CORE_EXPORT ObjectPaintProperties { 54 class CORE_EXPORT ObjectPaintProperties {
44 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); 55 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties);
45 USING_FAST_MALLOC(ObjectPaintProperties); 56 USING_FAST_MALLOC(ObjectPaintProperties);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 176 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
166 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 177 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
167 RefPtr<ScrollPaintPropertyNode> m_scroll; 178 RefPtr<ScrollPaintPropertyNode> m_scroll;
168 179
169 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; 180 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties;
170 }; 181 };
171 182
172 } // namespace blink 183 } // namespace blink
173 184
174 #endif // ObjectPaintProperties_h 185 #endif // ObjectPaintProperties_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698