| 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 |
| 61 RefPtrWillBeMember<CSSPrimitiveValue> m_position; // percentage or length | 62 RefPtrWillBeMember<CSSPrimitiveValue> m_position; // percentage or length |
| 62 RefPtrWillBeMember<CSSValue> m_color; | 63 RefPtrWillBeMember<CSSValue> m_color; |
| 63 bool m_colorIsDerivedFromElement; | 64 bool m_colorIsDerivedFromElement; |
| 64 bool operator==(const CSSGradientColorStop& other) const | 65 bool operator==(const CSSGradientColorStop& other) const |
| 65 { | 66 { |
| 66 return compareCSSValuePtr(m_color, other.m_color) | 67 return compareCSSValuePtr(m_color, other.m_color) |
| 67 && compareCSSValuePtr(m_position, other.m_position); | 68 && compareCSSValuePtr(m_position, other.m_position); |
| 68 } | 69 } |
| 69 bool isHint() const | 70 bool isHint() const |
| 70 { | 71 { |
| 71 ASSERT(m_color || m_position); | 72 ASSERT(m_color || m_position); |
| 72 return !m_color; | 73 return !m_color; |
| 73 } | 74 } |
| 74 | 75 |
| 76 void serialize(CSSSerializeStream*) const; |
| 77 void deserialize(CSSDeserializeStream*); |
| 75 DECLARE_TRACE(); | 78 DECLARE_TRACE(); |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 } // namespace blink | 81 } // namespace blink |
| 79 | 82 |
| 80 | 83 |
| 81 // We have to declare the VectorTraits specialization before CSSGradientValue | 84 // We have to declare the VectorTraits specialization before CSSGradientValue |
| 82 // declares its inline capacity vector below. | 85 // declares its inline capacity vector below. |
| 83 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop); | 86 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSGradientColorStop); |
| 84 | 87 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 106 bool isFixedSize() const { return false; } | 109 bool isFixedSize() const { return false; } |
| 107 IntSize fixedSize(const LayoutObject*) const { return IntSize(); } | 110 IntSize fixedSize(const LayoutObject*) const { return IntSize(); } |
| 108 | 111 |
| 109 bool isPending() const { return false; } | 112 bool isPending() const { return false; } |
| 110 bool knownToBeOpaque(const LayoutObject*) const; | 113 bool knownToBeOpaque(const LayoutObject*) const; |
| 111 | 114 |
| 112 void loadSubimages(Document*) { } | 115 void loadSubimages(Document*) { } |
| 113 | 116 |
| 114 void getStopColors(WillBeHeapVector<Color>& stopColors, const LayoutObject*)
const; | 117 void getStopColors(WillBeHeapVector<Color>& stopColors, const LayoutObject*)
const; |
| 115 | 118 |
| 119 void deserializeAfterDispatch(CSSDeserializeStream*); |
| 120 void serializeAfterDispatch(CSSSerializeStream*) const; |
| 121 |
| 116 DECLARE_TRACE_AFTER_DISPATCH(); | 122 DECLARE_TRACE_AFTER_DISPATCH(); |
| 117 | 123 |
| 118 protected: | 124 protected: |
| 119 CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientT
ype gradientType) | 125 CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientT
ype gradientType) |
| 120 : CSSImageGeneratorValue(classType) | 126 : CSSImageGeneratorValue(classType) |
| 121 , m_stopsSorted(false) | 127 , m_stopsSorted(false) |
| 122 , m_gradientType(gradientType) | 128 , m_gradientType(gradientType) |
| 123 , m_repeating(repeat == Repeating) | 129 , m_repeating(repeat == Repeating) |
| 124 { | 130 { |
| 125 } | 131 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 143 WillBeHeapVector<CSSGradientColorStop, 2> m_stops; | 149 WillBeHeapVector<CSSGradientColorStop, 2> m_stops; |
| 144 bool m_stopsSorted; | 150 bool m_stopsSorted; |
| 145 CSSGradientType m_gradientType; | 151 CSSGradientType m_gradientType; |
| 146 bool m_repeating; | 152 bool m_repeating; |
| 147 }; | 153 }; |
| 148 | 154 |
| 149 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); | 155 DEFINE_CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue()); |
| 150 | 156 |
| 151 class CSSLinearGradientValue final : public CSSGradientValue { | 157 class CSSLinearGradientValue final : public CSSGradientValue { |
| 152 public: | 158 public: |
| 153 | |
| 154 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSLinearGradient) | 159 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSLinearGradient) |
| 155 { | 160 { |
| 156 return adoptRefWillBeNoop(new CSSLinearGradientValue(repeat, gradientTyp
e)); | 161 return adoptRefWillBeNoop(new CSSLinearGradientValue(repeat, gradientTyp
e)); |
| 157 } | 162 } |
| 163 static PassRefPtrWillBeRawPtr<CSSLinearGradientValue> deserializeAfterDispat
ch(CSSDeserializeStream*); |
| 158 | 164 |
| 159 void setAngle(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_angle = val
; } | 165 void setAngle(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_angle = val
; } |
| 160 | 166 |
| 161 String customCSSText() const; | 167 String customCSSText() const; |
| 162 | 168 |
| 163 // Create the gradient for a given size. | 169 // Create the gradient for a given size. |
| 164 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); | 170 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); |
| 165 | 171 |
| 166 bool equals(const CSSLinearGradientValue&) const; | 172 bool equals(const CSSLinearGradientValue&) const; |
| 167 | 173 |
| 174 void serializeAfterDispatch(CSSSerializeStream*) const; |
| 175 |
| 168 DECLARE_TRACE_AFTER_DISPATCH(); | 176 DECLARE_TRACE_AFTER_DISPATCH(); |
| 169 | 177 |
| 170 private: | 178 private: |
| 171 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) | 179 CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSLinearGradient) |
| 172 : CSSGradientValue(LinearGradientClass, repeat, gradientType) | 180 : CSSGradientValue(LinearGradientClass, repeat, gradientType) |
| 173 { | 181 { |
| 174 } | 182 } |
| 175 | 183 |
| 176 RefPtrWillBeMember<CSSPrimitiveValue> m_angle; // may be null. | 184 RefPtrWillBeMember<CSSPrimitiveValue> m_angle; // may be null. |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); | 187 DEFINE_CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue()); |
| 180 | 188 |
| 181 class CSSRadialGradientValue final : public CSSGradientValue { | 189 class CSSRadialGradientValue final : public CSSGradientValue { |
| 182 public: | 190 public: |
| 183 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSRadialGradient) | 191 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> create(CSSGradientRepe
at repeat, CSSGradientType gradientType = CSSRadialGradient) |
| 184 { | 192 { |
| 185 return adoptRefWillBeNoop(new CSSRadialGradientValue(repeat, gradientTyp
e)); | 193 return adoptRefWillBeNoop(new CSSRadialGradientValue(repeat, gradientTyp
e)); |
| 186 } | 194 } |
| 195 static PassRefPtrWillBeRawPtr<CSSRadialGradientValue> deserializeAfterDispat
ch(CSSDeserializeStream*); |
| 187 | 196 |
| 188 String customCSSText() const; | 197 String customCSSText() const; |
| 189 | 198 |
| 190 void setFirstRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_first
Radius = val; } | 199 void setFirstRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_first
Radius = val; } |
| 191 void setSecondRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_seco
ndRadius = val; } | 200 void setSecondRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_seco
ndRadius = val; } |
| 192 | 201 |
| 193 void setShape(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_shape = val
; } | 202 void setShape(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_shape = val
; } |
| 194 void setSizingBehavior(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_si
zingBehavior = val; } | 203 void setSizingBehavior(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_si
zingBehavior = val; } |
| 195 | 204 |
| 196 void setEndHorizontalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m
_endHorizontalSize = val; } | 205 void setEndHorizontalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m
_endHorizontalSize = val; } |
| 197 void setEndVerticalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_e
ndVerticalSize = val; } | 206 void setEndVerticalSize(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_e
ndVerticalSize = val; } |
| 198 | 207 |
| 199 // Create the gradient for a given size. | 208 // Create the gradient for a given size. |
| 200 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); | 209 PassRefPtr<Gradient> createGradient(const CSSToLengthConversionData&, const
IntSize&, const LayoutObject&); |
| 201 | 210 |
| 202 bool equals(const CSSRadialGradientValue&) const; | 211 bool equals(const CSSRadialGradientValue&) const; |
| 203 | 212 |
| 213 void serializeAfterDispatch(CSSSerializeStream*) const; |
| 214 |
| 204 DECLARE_TRACE_AFTER_DISPATCH(); | 215 DECLARE_TRACE_AFTER_DISPATCH(); |
| 205 | 216 |
| 206 private: | 217 private: |
| 207 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) | 218 CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientTyp
e = CSSRadialGradient) |
| 208 : CSSGradientValue(RadialGradientClass, repeat, gradientType) | 219 : CSSGradientValue(RadialGradientClass, repeat, gradientType) |
| 209 { | 220 { |
| 210 } | 221 } |
| 211 | 222 |
| 212 // Resolve points/radii to front end values. | 223 // Resolve points/radii to front end values. |
| 213 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); | 224 float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, fl
oat* widthOrHeight = 0); |
| 214 | 225 |
| 215 // These may be null for non-deprecated gradients. | 226 // These may be null for non-deprecated gradients. |
| 216 RefPtrWillBeMember<CSSPrimitiveValue> m_firstRadius; | 227 RefPtrWillBeMember<CSSPrimitiveValue> m_firstRadius; |
| 217 RefPtrWillBeMember<CSSPrimitiveValue> m_secondRadius; | 228 RefPtrWillBeMember<CSSPrimitiveValue> m_secondRadius; |
| 218 | 229 |
| 219 // The below are only used for non-deprecated gradients. Any of them may be
null. | 230 // The below are only used for non-deprecated gradients. Any of them may be
null. |
| 220 RefPtrWillBeMember<CSSPrimitiveValue> m_shape; | 231 RefPtrWillBeMember<CSSPrimitiveValue> m_shape; |
| 221 RefPtrWillBeMember<CSSPrimitiveValue> m_sizingBehavior; | 232 RefPtrWillBeMember<CSSPrimitiveValue> m_sizingBehavior; |
| 222 | 233 |
| 223 RefPtrWillBeMember<CSSPrimitiveValue> m_endHorizontalSize; | 234 RefPtrWillBeMember<CSSPrimitiveValue> m_endHorizontalSize; |
| 224 RefPtrWillBeMember<CSSPrimitiveValue> m_endVerticalSize; | 235 RefPtrWillBeMember<CSSPrimitiveValue> m_endVerticalSize; |
| 225 }; | 236 }; |
| 226 | 237 |
| 227 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); | 238 DEFINE_CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue()); |
| 228 | 239 |
| 229 } // namespace blink | 240 } // namespace blink |
| 230 | 241 |
| 231 #endif // CSSGradientValue_h | 242 #endif // CSSGradientValue_h |
| OLD | NEW |