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

Side by Side Diff: Source/core/css/CSSGradientValue.h

Issue 1249553002: CSSValue Immediates: Add move operators to CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_3_tagged_ptrs_with_copy_ops_mv_operators_ref_primvalue
Patch Set: Rebase Created 5 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
« no previous file with comments | « Source/core/css/CSSCrossfadeValue.cpp ('k') | Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // This struct is stack allocated and allocated as part of vectors. 49 // This struct is stack allocated and allocated as part of vectors.
50 // When allocated on the stack its members are found by conservative 50 // When allocated on the stack its members are found by conservative
51 // stack scanning. When allocated as part of Vectors in heap-allocated 51 // stack scanning. When allocated as part of Vectors in heap-allocated
52 // objects its members are visited via the containing object's 52 // objects its members are visited via the containing object's
53 // (CSSGradientValue) traceAfterDispatch method. 53 // (CSSGradientValue) traceAfterDispatch method.
54 struct CSSGradientColorStop { 54 struct CSSGradientColorStop {
55 ALLOW_ONLY_INLINE_ALLOCATION(); 55 ALLOW_ONLY_INLINE_ALLOCATION();
56 public: 56 public:
57 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { } 57 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { }
58 RefPtrWillBeMember<CSSPrimitiveValue> m_position; // percentage or length 58 NullableCSSValue m_position; // percentage or length
59 RefPtrWillBeMember<CSSPrimitiveValue> m_color; 59 NullableCSSValue m_color;
60 bool m_colorIsDerivedFromElement; 60 bool m_colorIsDerivedFromElement;
61 bool operator==(const CSSGradientColorStop& other) const 61 bool operator==(const CSSGradientColorStop& other) const
62 { 62 {
63 return compareCSSValuePtr(m_color, other.m_color) 63 return m_color == other.m_color
64 && compareCSSValuePtr(m_position, other.m_position); 64 && m_position == other.m_position;
65 } 65 }
66 bool isHint() const 66 bool isHint() const
67 { 67 {
68 ASSERT(m_color || m_position); 68 ASSERT(m_color || m_position);
69 return !m_color; 69 return !m_color;
70 } 70 }
71 71
72 DECLARE_TRACE(); 72 DECLARE_TRACE();
73 }; 73 };
74 74
75 } // namespace blink 75 } // namespace blink
76 76
77 77
78 // We have to declare the VectorTraits specialization before CSSGradientValue 78 // We have to declare the VectorTraits specialization before CSSGradientValue
79 // declares its inline capacity vector below. 79 // declares its inline capacity vector below.
80 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop); 80 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop);
81 81
82 namespace blink { 82 namespace blink {
83 83
84 class CSSGradientValue : public CSSImageGeneratorValue { 84 class CSSGradientValue : public CSSImageGeneratorValue {
85 public: 85 public:
86 PassRefPtr<Image> image(LayoutObject*, const IntSize&); 86 PassRefPtr<Image> image(LayoutObject*, const IntSize&);
87 87
88 void setFirstX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_firstX = v al; } 88 void setFirstX(NullableCSSValue val) { m_firstX = val; }
89 void setFirstY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_firstY = v al; } 89 void setFirstY(NullableCSSValue val) { m_firstY = val; }
90 void setSecondX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_secondX = val; } 90 void setSecondX(NullableCSSValue val) { m_secondX = val; }
91 void setSecondY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_secondY = val; } 91 void setSecondY(NullableCSSValue val) { m_secondY = val; }
92 92
93 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); } 93 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); }
94 94
95 unsigned stopCount() const { return m_stops.size(); } 95 unsigned stopCount() const { return m_stops.size(); }
96 96
97 void appendCSSTextForDeprecatedColorStops(StringBuilder&) const; 97 void appendCSSTextForDeprecatedColorStops(StringBuilder&) const;
98 98
99 bool isRepeating() const { return m_repeating; } 99 bool isRepeating() const { return m_repeating; }
100 100
101 CSSGradientType gradientType() const { return m_gradientType; } 101 CSSGradientType gradientType() const { return m_gradientType; }
(...skipping 27 matching lines...) Expand all
129 , m_stopsSorted(other.m_stopsSorted) 129 , m_stopsSorted(other.m_stopsSorted)
130 , m_gradientType(gradientType) 130 , m_gradientType(gradientType)
131 , m_repeating(other.isRepeating() ? Repeating : NonRepeating) 131 , m_repeating(other.isRepeating() ? Repeating : NonRepeating)
132 { 132 {
133 } 133 }
134 134
135 void addStops(Gradient*, const CSSToLengthConversionData&, const LayoutObjec t&); 135 void addStops(Gradient*, const CSSToLengthConversionData&, const LayoutObjec t&);
136 void addDeprecatedStops(Gradient*, const LayoutObject&); 136 void addDeprecatedStops(Gradient*, const LayoutObject&);
137 137
138 // Resolve points/radii to front end values. 138 // Resolve points/radii to front end values.
139 FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const CSS ToLengthConversionData&, const IntSize&); 139 FloatPoint computeEndPoint(NullableCSSValue, NullableCSSValue, const CSSToLe ngthConversionData&, const IntSize&);
140 140
141 bool isCacheable() const; 141 bool isCacheable() const;
142 142
143 // Points. Some of these may be null. 143 // Points. Some of these may be null.
144 RefPtrWillBeMember<CSSPrimitiveValue> m_firstX; 144 NullableCSSValue m_firstX;
145 RefPtrWillBeMember<CSSPrimitiveValue> m_firstY; 145 NullableCSSValue m_firstY;
146 146
147 RefPtrWillBeMember<CSSPrimitiveValue> m_secondX; 147 NullableCSSValue m_secondX;
148 RefPtrWillBeMember<CSSPrimitiveValue> m_secondY; 148 NullableCSSValue m_secondY;
149 149
150 // Stops 150 // Stops
151 WillBeHeapVector<CSSGradientColorStop, 2> m_stops; 151 WillBeHeapVector<CSSGradientColorStop, 2> m_stops;
152 bool m_stopsSorted; 152 bool m_stopsSorted;
153 CSSGradientType m_gradientType; 153 CSSGradientType m_gradientType;
154 bool m_repeating; 154 bool m_repeating;
155 }; 155 };
156 156
157 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); 157 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue());
158 158
159 class CSSLinearGradientValue final : public CSSGradientValue { 159 class CSSLinearGradientValue final : public CSSGradientValue {
160 public: 160 public:
161 161
162 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe at repeat, CSSGradientType gradientType = CSSLinearGradient) 162 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe at repeat, CSSGradientType gradientType = CSSLinearGradient)
163 { 163 {
164 return adoptRefWillBeNoop(new CSSLinearGradientValue(repeat, gradientTyp e)); 164 return adoptRefWillBeNoop(new CSSLinearGradientValue(repeat, gradientTyp e));
165 } 165 }
166 166
167 void setAngle(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_angle = val ; } 167 void setAngle(CSSPrimitiveValue val) { m_angle = val; }
168 168
169 String customCSSText() const; 169 String customCSSText() const;
170 170
171 // Create the gradient for a given size. 171 // Create the gradient for a given size.
172 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const IntSize&, const LayoutObject&); 172 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const IntSize&, const LayoutObject&);
173 173
174 PassRefPtrWillBeRawPtr<CSSLinearGradientValue> clone() const 174 PassRefPtrWillBeRawPtr<CSSLinearGradientValue> clone() const
175 { 175 {
176 return adoptRefWillBeNoop(new CSSLinearGradientValue(*this)); 176 return adoptRefWillBeNoop(new CSSLinearGradientValue(*this));
177 } 177 }
178 178
179 bool equals(const CSSLinearGradientValue&) const; 179 bool equals(const CSSLinearGradientValue&) const;
180 180
181 DECLARE_TRACE_AFTER_DISPATCH(); 181 DECLARE_TRACE_AFTER_DISPATCH();
182 182
183 private: 183 private:
184 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp e = CSSLinearGradient) 184 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp e = CSSLinearGradient)
185 : CSSGradientValue(LinearGradientClass, repeat, gradientType) 185 : CSSGradientValue(LinearGradientClass, repeat, gradientType)
186 { 186 {
187 } 187 }
188 188
189 explicit CSSLinearGradientValue(const CSSLinearGradientValue& other) 189 explicit CSSLinearGradientValue(const CSSLinearGradientValue& other)
190 : CSSGradientValue(other, LinearGradientClass, other.gradientType()) 190 : CSSGradientValue(other, LinearGradientClass, other.gradientType())
191 , m_angle(other.m_angle) 191 , m_angle(other.m_angle)
192 { 192 {
193 } 193 }
194 194
195 RefPtrWillBeMember<CSSPrimitiveValue> m_angle; // may be null. 195 NullableCSSValue m_angle; // may be null.
196 }; 196 };
197 197
198 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); 198 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue());
199 199
200 class CSSRadialGradientValue final : public CSSGradientValue { 200 class CSSRadialGradientValue final : public CSSGradientValue {
201 public: 201 public:
202 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe at repeat, CSSGradientType gradientType = CSSRadialGradient) 202 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe at repeat, CSSGradientType gradientType = CSSRadialGradient)
203 { 203 {
204 return adoptRefWillBeNoop(new CSSRadialGradientValue(repeat, gradientTyp e)); 204 return adoptRefWillBeNoop(new CSSRadialGradientValue(repeat, gradientTyp e));
205 } 205 }
206 206
207 PassRefPtrWillBeRawPtr<CSSRadialGradientValue> clone() const 207 PassRefPtrWillBeRawPtr<CSSRadialGradientValue> clone() const
208 { 208 {
209 return adoptRefWillBeNoop(new CSSRadialGradientValue(*this)); 209 return adoptRefWillBeNoop(new CSSRadialGradientValue(*this));
210 } 210 }
211 211
212 String customCSSText() const; 212 String customCSSText() const;
213 213
214 void setFirstRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_first Radius = val; } 214 void setFirstRadius(CSSPrimitiveValue val) { m_firstRadius = val; }
215 void setSecondRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_seco ndRadius = val; } 215 void setSecondRadius(CSSPrimitiveValue val) { m_secondRadius = val; }
216 216
217 void setShape(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_shape = val ; } 217 void setShape(NullableCSSValue val) { m_shape = val; }
218 void setSizingBehavior(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_si zingBehavior = val; } 218 void setSizingBehavior(NullableCSSValue val) { m_sizingBehavior = val; }
219 219
220 void setEndHorizontalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m _endHorizontalSize = val; } 220 void setEndHorizontalSize(NullableCSSValue val) { m_endHorizontalSize = val; }
221 void setEndVerticalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_e ndVerticalSize = val; } 221 void setEndVerticalSize(NullableCSSValue val) { m_endVerticalSize = val; }
222 222
223 // Create the gradient for a given size. 223 // Create the gradient for a given size.
224 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const IntSize&, const LayoutObject&); 224 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const IntSize&, const LayoutObject&);
225 225
226 bool equals(const CSSRadialGradientValue&) const; 226 bool equals(const CSSRadialGradientValue&) const;
227 227
228 DECLARE_TRACE_AFTER_DISPATCH(); 228 DECLARE_TRACE_AFTER_DISPATCH();
229 229
230 private: 230 private:
231 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp e = CSSRadialGradient) 231 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp e = CSSRadialGradient)
232 : CSSGradientValue(RadialGradientClass, repeat, gradientType) 232 : CSSGradientValue(RadialGradientClass, repeat, gradientType)
233 { 233 {
234 } 234 }
235 235
236 explicit CSSRadialGradientValue(const CSSRadialGradientValue& other) 236 explicit CSSRadialGradientValue(const CSSRadialGradientValue& other)
237 : CSSGradientValue(other, RadialGradientClass, other.gradientType()) 237 : CSSGradientValue(other, RadialGradientClass, other.gradientType())
238 , m_firstRadius(other.m_firstRadius) 238 , m_firstRadius(other.m_firstRadius)
239 , m_secondRadius(other.m_secondRadius) 239 , m_secondRadius(other.m_secondRadius)
240 , m_shape(other.m_shape) 240 , m_shape(other.m_shape)
241 , m_sizingBehavior(other.m_sizingBehavior) 241 , m_sizingBehavior(other.m_sizingBehavior)
242 , m_endHorizontalSize(other.m_endHorizontalSize) 242 , m_endHorizontalSize(other.m_endHorizontalSize)
243 , m_endVerticalSize(other.m_endVerticalSize) 243 , m_endVerticalSize(other.m_endVerticalSize)
244 { 244 {
245 } 245 }
246 246
247 247
248 // Resolve points/radii to front end values. 248 // Resolve points/radii to front end values.
249 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl oat* widthOrHeight = 0); 249 float resolveRadius(CSSPrimitiveValue, const CSSToLengthConversionData&, flo at* widthOrHeight = 0);
250 250
251 // These may be null for non-deprecated gradients. 251 // These may be null for non-deprecated gradients.
252 RefPtrWillBeMember<CSSPrimitiveValue> m_firstRadius; 252 NullableCSSValue m_firstRadius;
253 RefPtrWillBeMember<CSSPrimitiveValue> m_secondRadius; 253 NullableCSSValue m_secondRadius;
254 254
255 // The below are only used for non-deprecated gradients. Any of them may be null. 255 // The below are only used for non-deprecated gradients. Any of them may be null.
256 RefPtrWillBeMember<CSSPrimitiveValue> m_shape; 256 NullableCSSValue m_shape;
257 RefPtrWillBeMember<CSSPrimitiveValue> m_sizingBehavior; 257 NullableCSSValue m_sizingBehavior;
258 258
259 RefPtrWillBeMember<CSSPrimitiveValue> m_endHorizontalSize; 259 NullableCSSValue m_endHorizontalSize;
260 RefPtrWillBeMember<CSSPrimitiveValue> m_endVerticalSize; 260 NullableCSSValue m_endVerticalSize;
261 }; 261 };
262 262
263 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); 263 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue());
264 264
265 } // namespace blink 265 } // namespace blink
266 266
267 #endif // CSSGradientValue_h 267 #endif // CSSGradientValue_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSCrossfadeValue.cpp ('k') | Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698