| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // When allocated on the stack its members are found by conservative | 51 // When allocated on the stack its members are found by conservative |
| 52 // stack scanning. When allocated as part of Vectors in heap-allocated | 52 // stack scanning. When allocated as part of Vectors in heap-allocated |
| 53 // objects its members are visited via the containing object's | 53 // objects its members are visited via the containing object's |
| 54 // (CSSGradientValue) traceAfterDispatch method. | 54 // (CSSGradientValue) traceAfterDispatch method. |
| 55 // | 55 // |
| 56 // http://www.w3.org/TR/css3-images/#color-stop-syntax | 56 // http://www.w3.org/TR/css3-images/#color-stop-syntax |
| 57 struct CSSGradientColorStop { | 57 struct CSSGradientColorStop { |
| 58 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 58 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 59 public: | 59 public: |
| 60 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { } | 60 CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { } |
| 61 RefPtrWillBeMember<CSSPrimitiveValue> m_position; // percentage or length | 61 Member<CSSPrimitiveValue> m_position; // percentage or length |
| 62 RefPtrWillBeMember<CSSValue> m_color; | 62 Member<CSSValue> m_color; |
| 63 bool m_colorIsDerivedFromElement; | 63 bool m_colorIsDerivedFromElement; |
| 64 bool operator==(const CSSGradientColorStop& other) const | 64 bool operator==(const CSSGradientColorStop& other) const |
| 65 { | 65 { |
| 66 return compareCSSValuePtr(m_color, other.m_color) | 66 return compareCSSValuePtr(m_color, other.m_color) |
| 67 && compareCSSValuePtr(m_position, other.m_position); | 67 && compareCSSValuePtr(m_position, other.m_position); |
| 68 } | 68 } |
| 69 bool isHint() const | 69 bool isHint() const |
| 70 { | 70 { |
| 71 ASSERT(m_color || m_position); | 71 ASSERT(m_color || m_position); |
| 72 return !m_color; | 72 return !m_color; |
| 73 } | 73 } |
| 74 | 74 |
| 75 DECLARE_TRACE(); | 75 DECLARE_TRACE(); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 } // namespace blink | 78 } // namespace blink |
| 79 | 79 |
| 80 | 80 |
| 81 // We have to declare the VectorTraits specialization before CSSGradientValue | 81 // We have to declare the VectorTraits specialization before CSSGradientValue |
| 82 // declares its inline capacity vector below. | 82 // declares its inline capacity vector below. |
| 83 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop); | 83 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop); |
| 84 | 84 |
| 85 namespace blink { | 85 namespace blink { |
| 86 | 86 |
| 87 class CSSGradientValue : public CSSImageGeneratorValue { | 87 class CSSGradientValue : public CSSImageGeneratorValue { |
| 88 public: | 88 public: |
| 89 PassRefPtr<Image> image(const LayoutObject*, const IntSize&); | 89 PassRefPtr<Image> image(const LayoutObject*, const IntSize&); |
| 90 | 90 |
| 91 void setFirstX(PassRefPtrWillBeRawPtr<CSSValue> val) { m_firstX = val; } | 91 void setFirstX(RawPtr<CSSValue> val) { m_firstX = val; } |
| 92 void setFirstY(PassRefPtrWillBeRawPtr<CSSValue> val) { m_firstY = val; } | 92 void setFirstY(RawPtr<CSSValue> val) { m_firstY = val; } |
| 93 void setSecondX(PassRefPtrWillBeRawPtr<CSSValue> val) { m_secondX = val; } | 93 void setSecondX(RawPtr<CSSValue> val) { m_secondX = val; } |
| 94 void setSecondY(PassRefPtrWillBeRawPtr<CSSValue> val) { m_secondY = val; } | 94 void setSecondY(RawPtr<CSSValue> val) { m_secondY = val; } |
| 95 | 95 |
| 96 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); } | 96 void addStop(const CSSGradientColorStop& stop) { m_stops.append(stop); } |
| 97 | 97 |
| 98 unsigned stopCount() const { return m_stops.size(); } | 98 unsigned stopCount() const { return m_stops.size(); } |
| 99 | 99 |
| 100 void appendCSSTextForDeprecatedColorStops(StringBuilder&) const; | 100 void appendCSSTextForDeprecatedColorStops(StringBuilder&) const; |
| 101 | 101 |
| 102 bool isRepeating() const { return m_repeating; } | 102 bool isRepeating() const { return m_repeating; } |
| 103 | 103 |
| 104 CSSGradientType gradientType() const { return m_gradientType; } | 104 CSSGradientType gradientType() const { return m_gradientType; } |
| 105 | 105 |
| 106 bool isFixedSize() const { return false; } | 106 bool isFixedSize() const { return false; } |
| 107 IntSize fixedSize(const LayoutObject*) const { return IntSize(); } | 107 IntSize fixedSize(const LayoutObject*) const { return IntSize(); } |
| 108 | 108 |
| 109 bool isPending() const { return false; } | 109 bool isPending() const { return false; } |
| 110 bool knownToBeOpaque(const LayoutObject*) const; | 110 bool knownToBeOpaque(const LayoutObject*) const; |
| 111 | 111 |
| 112 void loadSubimages(Document*) { } | 112 void loadSubimages(Document*) { } |
| 113 | 113 |
| 114 void getStopColors(WillBeHeapVector<Color>& stopColors, const LayoutObject*)
const; | 114 void getStopColors(HeapVector<Color>& stopColors, const LayoutObject*) const
; |
| 115 | 115 |
| 116 DECLARE_TRACE_AFTER_DISPATCH(); | 116 DECLARE_TRACE_AFTER_DISPATCH(); |
| 117 | 117 |
| 118 protected: | 118 protected: |
| 119 CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientT
ype gradientType) | 119 CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientT
ype gradientType) |
| 120 : CSSImageGeneratorValue(classType) | 120 : CSSImageGeneratorValue(classType) |
| 121 , m_stopsSorted(false) | 121 , m_stopsSorted(false) |
| 122 , m_gradientType(gradientType) | 122 , m_gradientType(gradientType) |
| 123 , m_repeating(repeat == Repeating) | 123 , m_repeating(repeat == Repeating) |
| 124 { | 124 { |
| 125 } | 125 } |
| 126 | 126 |
| 127 void addStops(Gradient*, const CSSToLengthConversionData&, const LayoutObjec
t&); | 127 void addStops(Gradient*, const CSSToLengthConversionData&, const LayoutObjec
t&); |
| 128 void addDeprecatedStops(Gradient*, const LayoutObject&); | 128 void addDeprecatedStops(Gradient*, const LayoutObject&); |
| 129 | 129 |
| 130 // Resolve points/radii to front end values. | 130 // Resolve points/radii to front end values. |
| 131 FloatPoint computeEndPoint(CSSValue*, CSSValue*, const CSSToLengthConversion
Data&, const IntSize&); | 131 FloatPoint computeEndPoint(CSSValue*, CSSValue*, const CSSToLengthConversion
Data&, const IntSize&); |
| 132 | 132 |
| 133 bool isCacheable() const; | 133 bool isCacheable() const; |
| 134 | 134 |
| 135 // Points. Some of these may be null. | 135 // Points. Some of these may be null. |
| 136 RefPtrWillBeMember<CSSValue> m_firstX; | 136 Member<CSSValue> m_firstX; |
| 137 RefPtrWillBeMember<CSSValue> m_firstY; | 137 Member<CSSValue> m_firstY; |
| 138 | 138 |
| 139 RefPtrWillBeMember<CSSValue> m_secondX; | 139 Member<CSSValue> m_secondX; |
| 140 RefPtrWillBeMember<CSSValue> m_secondY; | 140 Member<CSSValue> m_secondY; |
| 141 | 141 |
| 142 // Stops | 142 // Stops |
| 143 WillBeHeapVector<CSSGradientColorStop, 2> m_stops; | 143 HeapVector<CSSGradientColorStop, 2> m_stops; |
| 144 bool m_stopsSorted; | 144 bool m_stopsSorted; |
| 145 CSSGradientType m_gradientType; | 145 CSSGradientType m_gradientType; |
| 146 bool m_repeating; | 146 bool m_repeating; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); | 149 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); |
| 150 | 150 |
| 151 class CSSLinearGradientValue final : public CSSGradientValue { | 151 class CSSLinearGradientValue final : public CSSGradientValue { |
| 152 public: | 152 public: |
| 153 | 153 |
| 154 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSLinearGradient) | 154 static RawPtr<CSSLinearGradientValue> create(CSSGradientRepeat repeat, CSSGr
adientType gradientType = CSSLinearGradient) |
| 155 { | 155 { |
| 156 return adoptRefWillBeNoop(new CSSLinearGradientValue(repeat, gradientTyp
e)); | 156 return (new CSSLinearGradientValue(repeat, gradientType)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void setAngle(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_angle = val
; } | 159 void setAngle(RawPtr<CSSPrimitiveValue> val) { m_angle = val; } |
| 160 | 160 |
| 161 String customCSSText() const; | 161 String customCSSText() const; |
| 162 | 162 |
| 163 // Create the gradient for a given size. | 163 // Create the gradient for a given size. |
| 164 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); | 164 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); |
| 165 | 165 |
| 166 bool equals(const CSSLinearGradientValue&) const; | 166 bool equals(const CSSLinearGradientValue&) const; |
| 167 | 167 |
| 168 DECLARE_TRACE_AFTER_DISPATCH(); | 168 DECLARE_TRACE_AFTER_DISPATCH(); |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) | 171 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) |
| 172 : CSSGradientValue(LinearGradientClass, repeat, gradientType) | 172 : CSSGradientValue(LinearGradientClass, repeat, gradientType) |
| 173 { | 173 { |
| 174 } | 174 } |
| 175 | 175 |
| 176 RefPtrWillBeMember<CSSPrimitiveValue> m_angle; // may be null. | 176 Member<CSSPrimitiveValue> m_angle; // may be null. |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); | 179 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); |
| 180 | 180 |
| 181 class CSSRadialGradientValue final : public CSSGradientValue { | 181 class CSSRadialGradientValue final : public CSSGradientValue { |
| 182 public: | 182 public: |
| 183 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSRadialGradient) | 183 static RawPtr<CSSRadialGradientValue> create(CSSGradientRepeat repeat, CSSGr
adientType gradientType = CSSRadialGradient) |
| 184 { | 184 { |
| 185 return adoptRefWillBeNoop(new CSSRadialGradientValue(repeat, gradientTyp
e)); | 185 return (new CSSRadialGradientValue(repeat, gradientType)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 String customCSSText() const; | 188 String customCSSText() const; |
| 189 | 189 |
| 190 void setFirstRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_first
Radius = val; } | 190 void setFirstRadius(RawPtr<CSSPrimitiveValue> val) { m_firstRadius = val; } |
| 191 void setSecondRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_seco
ndRadius = val; } | 191 void setSecondRadius(RawPtr<CSSPrimitiveValue> val) { m_secondRadius = val;
} |
| 192 | 192 |
| 193 void setShape(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_shape = val
; } | 193 void setShape(RawPtr<CSSPrimitiveValue> val) { m_shape = val; } |
| 194 void setSizingBehavior(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_si
zingBehavior = val; } | 194 void setSizingBehavior(RawPtr<CSSPrimitiveValue> val) { m_sizingBehavior = v
al; } |
| 195 | 195 |
| 196 void setEndHorizontalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m
_endHorizontalSize = val; } | 196 void setEndHorizontalSize(RawPtr<CSSPrimitiveValue> val) { m_endHorizontalSi
ze = val; } |
| 197 void setEndVerticalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_e
ndVerticalSize = val; } | 197 void setEndVerticalSize(RawPtr<CSSPrimitiveValue> val) { m_endVerticalSize =
val; } |
| 198 | 198 |
| 199 // Create the gradient for a given size. | 199 // Create the gradient for a given size. |
| 200 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); | 200 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); |
| 201 | 201 |
| 202 bool equals(const CSSRadialGradientValue&) const; | 202 bool equals(const CSSRadialGradientValue&) const; |
| 203 | 203 |
| 204 DECLARE_TRACE_AFTER_DISPATCH(); | 204 DECLARE_TRACE_AFTER_DISPATCH(); |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) | 207 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) |
| 208 : CSSGradientValue(RadialGradientClass, repeat, gradientType) | 208 : CSSGradientValue(RadialGradientClass, repeat, gradientType) |
| 209 { | 209 { |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Resolve points/radii to front end values. | 212 // Resolve points/radii to front end values. |
| 213 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); | 213 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); |
| 214 | 214 |
| 215 // These may be null for non-deprecated gradients. | 215 // These may be null for non-deprecated gradients. |
| 216 RefPtrWillBeMember<CSSPrimitiveValue> m_firstRadius; | 216 Member<CSSPrimitiveValue> m_firstRadius; |
| 217 RefPtrWillBeMember<CSSPrimitiveValue> m_secondRadius; | 217 Member<CSSPrimitiveValue> m_secondRadius; |
| 218 | 218 |
| 219 // The below are only used for non-deprecated gradients. Any of them may be
null. | 219 // The below are only used for non-deprecated gradients. Any of them may be
null. |
| 220 RefPtrWillBeMember<CSSPrimitiveValue> m_shape; | 220 Member<CSSPrimitiveValue> m_shape; |
| 221 RefPtrWillBeMember<CSSPrimitiveValue> m_sizingBehavior; | 221 Member<CSSPrimitiveValue> m_sizingBehavior; |
| 222 | 222 |
| 223 RefPtrWillBeMember<CSSPrimitiveValue> m_endHorizontalSize; | 223 Member<CSSPrimitiveValue> m_endHorizontalSize; |
| 224 RefPtrWillBeMember<CSSPrimitiveValue> m_endVerticalSize; | 224 Member<CSSPrimitiveValue> m_endVerticalSize; |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); | 227 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); |
| 228 | 228 |
| 229 } // namespace blink | 229 } // namespace blink |
| 230 | 230 |
| 231 #endif // CSSGradientValue_h | 231 #endif // CSSGradientValue_h |
| OLD | NEW |