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

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

Issue 2173363002: Improve code readibility of PaintPropertyTreeBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra "const" (might be a typo) Created 4 years, 4 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 30 matching lines...) Expand all
41 // +---[ transform ] The space created by CSS transform. 41 // +---[ transform ] The space created by CSS transform.
42 // | This is the local border box space, see: LocalBorderBoxProperties below. 42 // | This is the local border box space, see: LocalBorderBoxProperties below.
43 // +---[ perspective ] The space created by CSS perspective . 43 // +---[ perspective ] The space created by CSS perspective .
44 // | +---[ svgLocalToBorderBoxTransform ] Additional transform for chi ldren of the outermost root SVG. 44 // | +---[ svgLocalToBorderBoxTransform ] Additional transform for chi ldren of the outermost root SVG.
45 // | OR (SVG does not support scrolling.) 45 // | OR (SVG does not support scrolling.)
46 // | +---[ scrollTranslation ] The space created by overflow clip. 46 // | +---[ scrollTranslation ] The space created by overflow clip.
47 // +---[ scrollbarPaintOffset ] TODO(trchen): Remove this once we ba ke the paint offset into frameRect. 47 // +---[ scrollbarPaintOffset ] TODO(trchen): Remove this once we ba ke the paint offset into frameRect.
48 // This is equivalent to the local bord er box space above, 48 // This is equivalent to the local bord er box space above,
49 // with pixel snapped paint offset bake d in. It is really redundant, 49 // with pixel snapped paint offset bake d in. It is really redundant,
50 // but it is a pain to teach scrollbars to paint with an offset. 50 // but it is a pain to teach scrollbars to paint with an offset.
51 TransformPaintPropertyNode* paintOffsetTranslation() const { return m_paintO ffsetTranslation.get(); } 51 const TransformPaintPropertyNode* paintOffsetTranslation() const { return m_ paintOffsetTranslation.get(); }
52 TransformPaintPropertyNode* transform() const { return m_transform.get(); } 52 const TransformPaintPropertyNode* transform() const { return m_transform.get (); }
53 TransformPaintPropertyNode* perspective() const { return m_perspective.get() ; } 53 const TransformPaintPropertyNode* perspective() const { return m_perspective .get(); }
54 TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { return m_ svgLocalToBorderBoxTransform.get(); } 54 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { ret urn m_svgLocalToBorderBoxTransform.get(); }
55 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans lation.get(); } 55 const TransformPaintPropertyNode* scrollTranslation() const { return m_scrol lTranslation.get(); }
56 TransformPaintPropertyNode* scrollbarPaintOffset() const { return m_scrollba rPaintOffset.get(); } 56 const TransformPaintPropertyNode* scrollbarPaintOffset() const { return m_sc rollbarPaintOffset.get(); }
57 57
58 EffectPaintPropertyNode* effect() const { return m_effect.get(); } 58 const EffectPaintPropertyNode* effect() const { return m_effect.get(); }
59 59
60 // The hierarchy of the clip subtree created by a LayoutObject is as follows : 60 // The hierarchy of the clip subtree created by a LayoutObject is as follows :
61 // [ css clip ] 61 // [ css clip ]
62 // | 62 // |
63 // +--- [ overflow clip ] 63 // +--- [ overflow clip ]
64 ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } 64 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); }
65 ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClipFixedP osition.get(); } 65 const ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClip FixedPosition.get(); }
66 ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.get(); } 66 const ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.ge t(); }
67 67
68 // This is a complete set of property nodes that should be used as a startin g point to paint 68 // This is a complete set of property nodes that should be used as a startin g point to paint
69 // this layout object. It is needed becauase some property inherits from the containing block, 69 // this layout object. It is needed becauase some property inherits from the containing block,
70 // not painting parent, thus can't be derived in O(1) during paint walk. 70 // not painting parent, thus can't be derived in O(1) during paint walk.
71 // Note: If this layout object has transform or stacking-context effects, th ose are already 71 // Note: If this layout object has transform or stacking-context effects, th ose are already
72 // baked into in the context here. However for properties that affects only children, 72 // baked into in the context here. However for properties that affects only children,
73 // for example, perspective and overflow clip, those should be applied by th e painter 73 // for example, perspective and overflow clip, those should be applied by th e painter
74 // at the right painting step. 74 // at the right painting step.
75 struct LocalBorderBoxProperties { 75 struct LocalBorderBoxProperties {
76 LayoutPoint paintOffset; 76 LayoutPoint paintOffset;
77 PropertyTreeState propertyTreeState; 77 PropertyTreeState propertyTreeState;
78 }; 78 };
79 LocalBorderBoxProperties* localBorderBoxProperties() const { return m_localB orderBoxProperties.get(); } 79 const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_ localBorderBoxProperties.get(); }
80
81 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; }
82 void clearTransform() { m_transform = nullptr; }
83 void clearEffect() { m_effect = nullptr; }
84 void clearCssClip() { m_cssClip = nullptr; }
85 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; }
86 void clearOverflowClip() { m_overflowClip = nullptr; }
87 void clearPerspective() { m_perspective = nullptr; }
88 void clearSvgLocalToBorderBoxTransform() { m_svgLocalToBorderBoxTransform = nullptr; }
89 void clearScrollTranslation() { m_scrollTranslation = nullptr; }
90 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; }
91
92 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePaintO ffsetTranslation(Args&&... args) { return createOrUpdateProperty(m_paintOffsetTr anslation, std::forward<Args>(args)...); }
93 template <typename... Args> TransformPaintPropertyNode* createOrUpdateTransf orm(Args&&... args) { return createOrUpdateProperty(m_transform, std::forward<Ar gs>(args)...); }
94 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePerspe ctive(Args&&... args) { return createOrUpdateProperty(m_perspective, std::forwar d<Args>(args)...); }
95 template <typename... Args> TransformPaintPropertyNode* createOrUpdateSvgLoc alToBorderBoxTransform(Args&&... args)
96 {
97 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there sho uld never be both a scroll translation and an SVG local to border box transform. ";
98 return createOrUpdateProperty(m_svgLocalToBorderBoxTransform, std::forwa rd<Args>(args)...);
99 }
100 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll Translation(Args&&... args)
101 {
102 DCHECK(!svgLocalToBorderBoxTransform()) << "SVG elements cannot scroll s o there should never be both a scroll translation and an SVG local to border box transform.";
103 return createOrUpdateProperty(m_scrollTranslation, std::forward<Args>(ar gs)...);
104 }
105 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll barPaintOffset(Args&&... args) { return createOrUpdateProperty(m_scrollbarPaintO ffset, std::forward<Args>(args)...); }
106 template <typename... Args> EffectPaintPropertyNode* createOrUpdateEffect(Ar gs&&... args) { return createOrUpdateProperty(m_effect, std::forward<Args>(args) ...); }
107 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClip(Arg s&&... args) { return createOrUpdateProperty(m_cssClip, std::forward<Args>(args) ...); }
108 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClipFixe dPosition(Args&&... args) { return createOrUpdateProperty(m_cssClipFixedPosition , std::forward<Args>(args)...); }
109 template <typename... Args> ClipPaintPropertyNode* createOrUpdateOverflowCli p(Args&&... args) { return createOrUpdateProperty(m_overflowClip, std::forward<A rgs>(args)...); }
110
111 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p roperties) { m_localBorderBoxProperties = std::move(properties); }
80 112
81 private: 113 private:
82 ObjectPaintProperties() { } 114 ObjectPaintProperties() { }
83 115
84 friend class PaintPropertyTreeBuilder; 116 template <typename PaintPropertyNode, typename... Args>
85 // These setters should only be used by PaintPropertyTreeBuilder. 117 PaintPropertyNode* createOrUpdateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args)
86 void setPaintOffsetTranslation(PassRefPtr<TransformPaintPropertyNode> paintO ffset) { m_paintOffsetTranslation = paintOffset; }
87 void setTransform(PassRefPtr<TransformPaintPropertyNode> transform) { m_tran sform = transform; }
88 void setEffect(PassRefPtr<EffectPaintPropertyNode> effect) { m_effect = effe ct; }
89 void setCssClip(PassRefPtr<ClipPaintPropertyNode> clip) { m_cssClip = clip; }
90 void setCssClipFixedPosition(PassRefPtr<ClipPaintPropertyNode> clip) { m_css ClipFixedPosition = clip; }
91 void setOverflowClip(PassRefPtr<ClipPaintPropertyNode> clip) { m_overflowCli p = clip; }
92 void setPerspective(PassRefPtr<TransformPaintPropertyNode> perspective) { m_ perspective = perspective; }
93 void setSvgLocalToBorderBoxTransform(PassRefPtr<TransformPaintPropertyNode> transform)
94 { 118 {
95 DCHECK(!scrollTranslation() || !transform) << "SVG elements cannot scrol l so there should never be both a scroll translation and an SVG local to border box transform."; 119 if (field)
96 m_svgLocalToBorderBoxTransform = transform; 120 field->update(std::forward<Args>(args)...);
121 else
122 field = PaintPropertyNode::create(std::forward<Args>(args)...);
123 return field.get();
97 } 124 }
98 void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> translation )
99 {
100 DCHECK(!svgLocalToBorderBoxTransform() || !translation) << "SVG elements cannot scroll so there should never be both a scroll translation and an SVG loc al to border box transform.";
101 m_scrollTranslation = translation;
102 }
103 void setScrollbarPaintOffset(PassRefPtr<TransformPaintPropertyNode> paintOff set) { m_scrollbarPaintOffset = paintOffset; }
104 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p roperties) { m_localBorderBoxProperties = std::move(properties); }
105 125
106 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; 126 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation;
107 RefPtr<TransformPaintPropertyNode> m_transform; 127 RefPtr<TransformPaintPropertyNode> m_transform;
108 RefPtr<EffectPaintPropertyNode> m_effect; 128 RefPtr<EffectPaintPropertyNode> m_effect;
109 RefPtr<ClipPaintPropertyNode> m_cssClip; 129 RefPtr<ClipPaintPropertyNode> m_cssClip;
110 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; 130 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition;
111 RefPtr<ClipPaintPropertyNode> m_overflowClip; 131 RefPtr<ClipPaintPropertyNode> m_overflowClip;
112 RefPtr<TransformPaintPropertyNode> m_perspective; 132 RefPtr<TransformPaintPropertyNode> m_perspective;
113 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. 133 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there.
114 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; 134 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform;
115 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 135 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
116 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 136 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
117 137
118 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; 138 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties;
119 }; 139 };
120 140
121 } // namespace blink 141 } // namespace blink
122 142
123 #endif // ObjectPaintProperties_h 143 #endif // ObjectPaintProperties_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LayoutItem.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698