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