| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 enum CSSGradientType { | 40 enum CSSGradientType { |
| 41 CSSDeprecatedLinearGradient, | 41 CSSDeprecatedLinearGradient, |
| 42 CSSDeprecatedRadialGradient, | 42 CSSDeprecatedRadialGradient, |
| 43 CSSPrefixedLinearGradient, | 43 CSSPrefixedLinearGradient, |
| 44 CSSPrefixedRadialGradient, | 44 CSSPrefixedRadialGradient, |
| 45 CSSLinearGradient, | 45 CSSLinearGradient, |
| 46 CSSRadialGradient | 46 CSSRadialGradient |
| 47 }; | 47 }; |
| 48 enum CSSGradientRepeat { NonRepeating, Repeating }; | 48 enum CSSGradientRepeat { NonRepeating, Repeating }; |
| 49 | 49 |
| 50 // This struct is stack allocated and allocated as part of vectors. |
| 51 // When allocated on the stack its members are found by conservative |
| 52 // stack scanning. When allocated as part of Vectors in heap-allocated |
| 53 // objects its members are visited via the containing object's |
| 54 // (CSSGradientValue) traceAfterDispatch method. |
| 50 struct CSSGradientColorStop { | 55 struct CSSGradientColorStop { |
| 56 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 57 public: |
| 51 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { }; | 58 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { }; |
| 52 RefPtr<CSSPrimitiveValue> m_position; // percentage or length | 59 RefPtrWillBeMember<CSSPrimitiveValue> m_position; // percentage or length |
| 53 RefPtr<CSSPrimitiveValue> m_color; | 60 RefPtrWillBeMember<CSSPrimitiveValue> m_color; |
| 54 Color m_resolvedColor; | 61 Color m_resolvedColor; |
| 55 bool m_colorIsDerivedFromElement; | 62 bool m_colorIsDerivedFromElement; |
| 56 bool operator==(const CSSGradientColorStop& other) const | 63 bool operator==(const CSSGradientColorStop& other) const |
| 57 { | 64 { |
| 58 return compareCSSValuePtr(m_color, other.m_color) | 65 return compareCSSValuePtr(m_color, other.m_color) |
| 59 && compareCSSValuePtr(m_position, other.m_position); | 66 && compareCSSValuePtr(m_position, other.m_position); |
| 60 } | 67 } |
| 68 |
| 69 void trace(Visitor*); |
| 61 }; | 70 }; |
| 62 | 71 |
| 63 class CSSGradientValue : public CSSImageGeneratorValue { | 72 class CSSGradientValue : public CSSImageGeneratorValue { |
| 64 public: | 73 public: |
| 65 PassRefPtr<Image> image(RenderObject*, const IntSize&); | 74 PassRefPtr<Image> image(RenderObject*, const IntSize&); |
| 66 | 75 |
| 67 void setFirstX(PassRefPtr<CSSPrimitiveValue> val) { m_firstX = val; } | 76 void setFirstX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_firstX = v
al; } |
| 68 void setFirstY(PassRefPtr<CSSPrimitiveValue> val) { m_firstY = val; } | 77 void setFirstY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_firstY = v
al; } |
| 69 void setSecondX(PassRefPtr<CSSPrimitiveValue> val) { m_secondX = val; } | 78 void setSecondX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_secondX =
val; } |
| 70 void setSecondY(PassRefPtr<CSSPrimitiveValue> val) { m_secondY = val; } | 79 void setSecondY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_secondY =
val; } |
| 71 | 80 |
| 72 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); } | 81 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); } |
| 73 | 82 |
| 74 unsigned stopCount() const { return m_stops.size(); } | 83 unsigned stopCount() const { return m_stops.size(); } |
| 75 | 84 |
| 76 void sortStopsIfNeeded(); | 85 void sortStopsIfNeeded(); |
| 77 | 86 |
| 78 bool isRepeating() const { return m_repeating; } | 87 bool isRepeating() const { return m_repeating; } |
| 79 | 88 |
| 80 CSSGradientType gradientType() const { return m_gradientType; } | 89 CSSGradientType gradientType() const { return m_gradientType; } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 122 } |
| 114 | 123 |
| 115 void addStops(Gradient*, const CSSToLengthConversionData&, float maxLengthFo
rRepeat = 0); | 124 void addStops(Gradient*, const CSSToLengthConversionData&, float maxLengthFo
rRepeat = 0); |
| 116 | 125 |
| 117 // Resolve points/radii to front end values. | 126 // Resolve points/radii to front end values. |
| 118 FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const CSS
ToLengthConversionData&, const IntSize&); | 127 FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const CSS
ToLengthConversionData&, const IntSize&); |
| 119 | 128 |
| 120 bool isCacheable() const; | 129 bool isCacheable() const; |
| 121 | 130 |
| 122 // Points. Some of these may be null. | 131 // Points. Some of these may be null. |
| 123 RefPtr<CSSPrimitiveValue> m_firstX; | 132 RefPtrWillBeMember<CSSPrimitiveValue> m_firstX; |
| 124 RefPtr<CSSPrimitiveValue> m_firstY; | 133 RefPtrWillBeMember<CSSPrimitiveValue> m_firstY; |
| 125 | 134 |
| 126 RefPtr<CSSPrimitiveValue> m_secondX; | 135 RefPtrWillBeMember<CSSPrimitiveValue> m_secondX; |
| 127 RefPtr<CSSPrimitiveValue> m_secondY; | 136 RefPtrWillBeMember<CSSPrimitiveValue> m_secondY; |
| 128 | 137 |
| 129 // Stops | 138 // Stops |
| 130 Vector<CSSGradientColorStop, 2> m_stops; | 139 WillBeHeapVector<CSSGradientColorStop, 2> m_stops; |
| 131 bool m_stopsSorted; | 140 bool m_stopsSorted; |
| 132 CSSGradientType m_gradientType; | 141 CSSGradientType m_gradientType; |
| 133 bool m_repeating; | 142 bool m_repeating; |
| 134 }; | 143 }; |
| 135 | 144 |
| 136 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); | 145 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); |
| 137 | 146 |
| 138 class CSSLinearGradientValue : public CSSGradientValue { | 147 class CSSLinearGradientValue : public CSSGradientValue { |
| 139 public: | 148 public: |
| 140 | 149 |
| 141 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSLinearGradient) | 150 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSLinearGradient) |
| 142 { | 151 { |
| 143 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSLinearGrad
ientValue(repeat, gradientType)); | 152 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSLinearGrad
ientValue(repeat, gradientType)); |
| 144 } | 153 } |
| 145 | 154 |
| 146 void setAngle(PassRefPtr<CSSPrimitiveValue> val) { m_angle = val; } | 155 void setAngle(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_angle = val
; } |
| 147 | 156 |
| 148 String customCSSText() const; | 157 String customCSSText() const; |
| 149 | 158 |
| 150 // Create the gradient for a given size. | 159 // Create the gradient for a given size. |
| 151 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&); | 160 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&); |
| 152 | 161 |
| 153 PassRefPtrWillBeRawPtr<CSSLinearGradientValue> clone() const | 162 PassRefPtrWillBeRawPtr<CSSLinearGradientValue> clone() const |
| 154 { | 163 { |
| 155 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSLinearGrad
ientValue(*this)); | 164 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSLinearGrad
ientValue(*this)); |
| 156 } | 165 } |
| 157 | 166 |
| 158 bool equals(const CSSLinearGradientValue&) const; | 167 bool equals(const CSSLinearGradientValue&) const; |
| 159 | 168 |
| 160 void traceAfterDispatch(Visitor*); | 169 void traceAfterDispatch(Visitor*); |
| 161 | 170 |
| 162 private: | 171 private: |
| 163 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) | 172 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) |
| 164 : CSSGradientValue(LinearGradientClass, repeat, gradientType) | 173 : CSSGradientValue(LinearGradientClass, repeat, gradientType) |
| 165 { | 174 { |
| 166 } | 175 } |
| 167 | 176 |
| 168 explicit CSSLinearGradientValue(const CSSLinearGradientValue& other) | 177 explicit CSSLinearGradientValue(const CSSLinearGradientValue& other) |
| 169 : CSSGradientValue(other, LinearGradientClass, other.gradientType()) | 178 : CSSGradientValue(other, LinearGradientClass, other.gradientType()) |
| 170 , m_angle(other.m_angle) | 179 , m_angle(other.m_angle) |
| 171 { | 180 { |
| 172 } | 181 } |
| 173 | 182 |
| 174 RefPtr<CSSPrimitiveValue> m_angle; // may be null. | 183 RefPtrWillBeMember<CSSPrimitiveValue> m_angle; // may be null. |
| 175 }; | 184 }; |
| 176 | 185 |
| 177 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); | 186 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); |
| 178 | 187 |
| 179 class CSSRadialGradientValue : public CSSGradientValue { | 188 class CSSRadialGradientValue : public CSSGradientValue { |
| 180 public: | 189 public: |
| 181 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSRadialGradient) | 190 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSRadialGradient) |
| 182 { | 191 { |
| 183 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSRadialGrad
ientValue(repeat, gradientType)); | 192 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSRadialGrad
ientValue(repeat, gradientType)); |
| 184 } | 193 } |
| 185 | 194 |
| 186 PassRefPtrWillBeRawPtr<CSSRadialGradientValue> clone() const | 195 PassRefPtrWillBeRawPtr<CSSRadialGradientValue> clone() const |
| 187 { | 196 { |
| 188 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSRadialGrad
ientValue(*this)); | 197 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSRadialGrad
ientValue(*this)); |
| 189 } | 198 } |
| 190 | 199 |
| 191 String customCSSText() const; | 200 String customCSSText() const; |
| 192 | 201 |
| 193 void setFirstRadius(PassRefPtr<CSSPrimitiveValue> val) { m_firstRadius = val
; } | 202 void setFirstRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_first
Radius = val; } |
| 194 void setSecondRadius(PassRefPtr<CSSPrimitiveValue> val) { m_secondRadius = v
al; } | 203 void setSecondRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_seco
ndRadius = val; } |
| 195 | 204 |
| 196 void setShape(PassRefPtr<CSSPrimitiveValue> val) { m_shape = val; } | 205 void setShape(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_shape = val
; } |
| 197 void setSizingBehavior(PassRefPtr<CSSPrimitiveValue> val) { m_sizingBehavior
= val; } | 206 void setSizingBehavior(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_si
zingBehavior = val; } |
| 198 | 207 |
| 199 void setEndHorizontalSize(PassRefPtr<CSSPrimitiveValue> val) { m_endHorizont
alSize = val; } | 208 void setEndHorizontalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m
_endHorizontalSize = val; } |
| 200 void setEndVerticalSize(PassRefPtr<CSSPrimitiveValue> val) { m_endVerticalSi
ze = val; } | 209 void setEndVerticalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_e
ndVerticalSize = val; } |
| 201 | 210 |
| 202 // Create the gradient for a given size. | 211 // Create the gradient for a given size. |
| 203 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&); | 212 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&); |
| 204 | 213 |
| 205 bool equals(const CSSRadialGradientValue&) const; | 214 bool equals(const CSSRadialGradientValue&) const; |
| 206 | 215 |
| 207 void traceAfterDispatch(Visitor*); | 216 void traceAfterDispatch(Visitor*); |
| 208 | 217 |
| 209 private: | 218 private: |
| 210 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) | 219 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 221 , m_endHorizontalSize(other.m_endHorizontalSize) | 230 , m_endHorizontalSize(other.m_endHorizontalSize) |
| 222 , m_endVerticalSize(other.m_endVerticalSize) | 231 , m_endVerticalSize(other.m_endVerticalSize) |
| 223 { | 232 { |
| 224 } | 233 } |
| 225 | 234 |
| 226 | 235 |
| 227 // Resolve points/radii to front end values. | 236 // Resolve points/radii to front end values. |
| 228 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); | 237 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); |
| 229 | 238 |
| 230 // These may be null for non-deprecated gradients. | 239 // These may be null for non-deprecated gradients. |
| 231 RefPtr<CSSPrimitiveValue> m_firstRadius; | 240 RefPtrWillBeMember<CSSPrimitiveValue> m_firstRadius; |
| 232 RefPtr<CSSPrimitiveValue> m_secondRadius; | 241 RefPtrWillBeMember<CSSPrimitiveValue> m_secondRadius; |
| 233 | 242 |
| 234 // The below are only used for non-deprecated gradients. Any of them may be
null. | 243 // The below are only used for non-deprecated gradients. Any of them may be
null. |
| 235 RefPtr<CSSPrimitiveValue> m_shape; | 244 RefPtrWillBeMember<CSSPrimitiveValue> m_shape; |
| 236 RefPtr<CSSPrimitiveValue> m_sizingBehavior; | 245 RefPtrWillBeMember<CSSPrimitiveValue> m_sizingBehavior; |
| 237 | 246 |
| 238 RefPtr<CSSPrimitiveValue> m_endHorizontalSize; | 247 RefPtrWillBeMember<CSSPrimitiveValue> m_endHorizontalSize; |
| 239 RefPtr<CSSPrimitiveValue> m_endVerticalSize; | 248 RefPtrWillBeMember<CSSPrimitiveValue> m_endVerticalSize; |
| 240 }; | 249 }; |
| 241 | 250 |
| 242 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); | 251 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); |
| 243 | 252 |
| 244 } // namespace WebCore | 253 } // namespace WebCore |
| 245 | 254 |
| 246 #endif // CSSGradientValue_h | 255 #endif // CSSGradientValue_h |
| OLD | NEW |