OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "core/css/CSSPrimitiveValueMappings.h" | 35 #include "core/css/CSSPrimitiveValueMappings.h" |
36 #include "core/css/CSSTimingFunctionValue.h" | 36 #include "core/css/CSSTimingFunctionValue.h" |
37 #include "core/css/Pair.h" | 37 #include "core/css/Pair.h" |
38 #include "core/css/Rect.h" | 38 #include "core/css/Rect.h" |
39 #include "core/css/resolver/StyleResolverState.h" | 39 #include "core/css/resolver/StyleResolverState.h" |
40 #include "core/rendering/style/BorderImageLengthBox.h" | 40 #include "core/rendering/style/BorderImageLengthBox.h" |
41 #include "core/rendering/style/FillLayer.h" | 41 #include "core/rendering/style/FillLayer.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 const CSSToLengthConversionData& CSSToStyleMap::cssToLengthConversionData() cons
t | 45 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, CSS
Value* value) |
46 { | |
47 return m_state.cssToLengthConversionData(); | |
48 } | |
49 | |
50 PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSVa
lue* value) | |
51 { | |
52 return m_elementStyleResources.styleImage(m_state.document(), m_state.docume
nt().textLinkColors(), m_state.style()->color(), propertyId, value); | |
53 } | |
54 | |
55 void CSSToStyleMap::mapFillAttachment(FillLayer* layer, CSSValue* value) const | |
56 { | 46 { |
57 if (value->isInitialValue()) { | 47 if (value->isInitialValue()) { |
58 layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); | 48 layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); |
59 return; | 49 return; |
60 } | 50 } |
61 | 51 |
62 if (!value->isPrimitiveValue()) | 52 if (!value->isPrimitiveValue()) |
63 return; | 53 return; |
64 | 54 |
65 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 55 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
66 switch (primitiveValue->getValueID()) { | 56 switch (primitiveValue->getValueID()) { |
67 case CSSValueFixed: | 57 case CSSValueFixed: |
68 layer->setAttachment(FixedBackgroundAttachment); | 58 layer->setAttachment(FixedBackgroundAttachment); |
69 break; | 59 break; |
70 case CSSValueScroll: | 60 case CSSValueScroll: |
71 layer->setAttachment(ScrollBackgroundAttachment); | 61 layer->setAttachment(ScrollBackgroundAttachment); |
72 break; | 62 break; |
73 case CSSValueLocal: | 63 case CSSValueLocal: |
74 layer->setAttachment(LocalBackgroundAttachment); | 64 layer->setAttachment(LocalBackgroundAttachment); |
75 break; | 65 break; |
76 default: | 66 default: |
77 return; | 67 return; |
78 } | 68 } |
79 } | 69 } |
80 | 70 |
81 void CSSToStyleMap::mapFillClip(FillLayer* layer, CSSValue* value) const | 71 void CSSToStyleMap::mapFillClip(StyleResolverState&, FillLayer* layer, CSSValue*
value) |
82 { | 72 { |
83 if (value->isInitialValue()) { | 73 if (value->isInitialValue()) { |
84 layer->setClip(FillLayer::initialFillClip(layer->type())); | 74 layer->setClip(FillLayer::initialFillClip(layer->type())); |
85 return; | 75 return; |
86 } | 76 } |
87 | 77 |
88 if (!value->isPrimitiveValue()) | 78 if (!value->isPrimitiveValue()) |
89 return; | 79 return; |
90 | 80 |
91 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 81 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
92 layer->setClip(*primitiveValue); | 82 layer->setClip(*primitiveValue); |
93 } | 83 } |
94 | 84 |
95 void CSSToStyleMap::mapFillComposite(FillLayer* layer, CSSValue* value) const | 85 void CSSToStyleMap::mapFillComposite(StyleResolverState&, FillLayer* layer, CSSV
alue* value) |
96 { | 86 { |
97 if (value->isInitialValue()) { | 87 if (value->isInitialValue()) { |
98 layer->setComposite(FillLayer::initialFillComposite(layer->type())); | 88 layer->setComposite(FillLayer::initialFillComposite(layer->type())); |
99 return; | 89 return; |
100 } | 90 } |
101 | 91 |
102 if (!value->isPrimitiveValue()) | 92 if (!value->isPrimitiveValue()) |
103 return; | 93 return; |
104 | 94 |
105 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 95 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
106 layer->setComposite(*primitiveValue); | 96 layer->setComposite(*primitiveValue); |
107 } | 97 } |
108 | 98 |
109 void CSSToStyleMap::mapFillBlendMode(FillLayer* layer, CSSValue* value) const | 99 void CSSToStyleMap::mapFillBlendMode(StyleResolverState&, FillLayer* layer, CSSV
alue* value) |
110 { | 100 { |
111 if (value->isInitialValue()) { | 101 if (value->isInitialValue()) { |
112 layer->setBlendMode(FillLayer::initialFillBlendMode(layer->type())); | 102 layer->setBlendMode(FillLayer::initialFillBlendMode(layer->type())); |
113 return; | 103 return; |
114 } | 104 } |
115 | 105 |
116 if (!value->isPrimitiveValue()) | 106 if (!value->isPrimitiveValue()) |
117 return; | 107 return; |
118 | 108 |
119 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 109 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
120 layer->setBlendMode(*primitiveValue); | 110 layer->setBlendMode(*primitiveValue); |
121 } | 111 } |
122 | 112 |
123 void CSSToStyleMap::mapFillOrigin(FillLayer* layer, CSSValue* value) const | 113 void CSSToStyleMap::mapFillOrigin(StyleResolverState&, FillLayer* layer, CSSValu
e* value) |
124 { | 114 { |
125 if (value->isInitialValue()) { | 115 if (value->isInitialValue()) { |
126 layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); | 116 layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); |
127 return; | 117 return; |
128 } | 118 } |
129 | 119 |
130 if (!value->isPrimitiveValue()) | 120 if (!value->isPrimitiveValue()) |
131 return; | 121 return; |
132 | 122 |
133 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 123 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
134 layer->setOrigin(*primitiveValue); | 124 layer->setOrigin(*primitiveValue); |
135 } | 125 } |
136 | 126 |
137 | 127 |
138 void CSSToStyleMap::mapFillImage(FillLayer* layer, CSSValue* value) | 128 void CSSToStyleMap::mapFillImage(StyleResolverState& state, FillLayer* layer, CS
SValue* value) |
139 { | 129 { |
140 if (value->isInitialValue()) { | 130 if (value->isInitialValue()) { |
141 layer->setImage(FillLayer::initialFillImage(layer->type())); | 131 layer->setImage(FillLayer::initialFillImage(layer->type())); |
142 return; | 132 return; |
143 } | 133 } |
144 | 134 |
145 CSSPropertyID property = layer->type() == BackgroundFillLayer ? CSSPropertyB
ackgroundImage : CSSPropertyWebkitMaskImage; | 135 CSSPropertyID property = layer->type() == BackgroundFillLayer ? CSSPropertyB
ackgroundImage : CSSPropertyWebkitMaskImage; |
146 layer->setImage(styleImage(property, value)); | 136 layer->setImage(state.styleImage(property, value)); |
147 } | 137 } |
148 | 138 |
149 void CSSToStyleMap::mapFillRepeatX(FillLayer* layer, CSSValue* value) const | 139 void CSSToStyleMap::mapFillRepeatX(StyleResolverState&, FillLayer* layer, CSSVal
ue* value) |
150 { | 140 { |
151 if (value->isInitialValue()) { | 141 if (value->isInitialValue()) { |
152 layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); | 142 layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); |
153 return; | 143 return; |
154 } | 144 } |
155 | 145 |
156 if (!value->isPrimitiveValue()) | 146 if (!value->isPrimitiveValue()) |
157 return; | 147 return; |
158 | 148 |
159 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 149 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
160 layer->setRepeatX(*primitiveValue); | 150 layer->setRepeatX(*primitiveValue); |
161 } | 151 } |
162 | 152 |
163 void CSSToStyleMap::mapFillRepeatY(FillLayer* layer, CSSValue* value) const | 153 void CSSToStyleMap::mapFillRepeatY(StyleResolverState&, FillLayer* layer, CSSVal
ue* value) |
164 { | 154 { |
165 if (value->isInitialValue()) { | 155 if (value->isInitialValue()) { |
166 layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); | 156 layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); |
167 return; | 157 return; |
168 } | 158 } |
169 | 159 |
170 if (!value->isPrimitiveValue()) | 160 if (!value->isPrimitiveValue()) |
171 return; | 161 return; |
172 | 162 |
173 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 163 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
174 layer->setRepeatY(*primitiveValue); | 164 layer->setRepeatY(*primitiveValue); |
175 } | 165 } |
176 | 166 |
177 void CSSToStyleMap::mapFillSize(FillLayer* layer, CSSValue* value) const | 167 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, CSS
Value* value) |
178 { | 168 { |
179 if (value->isInitialValue()) { | 169 if (value->isInitialValue()) { |
180 layer->setSizeType(FillLayer::initialFillSizeType(layer->type())); | 170 layer->setSizeType(FillLayer::initialFillSizeType(layer->type())); |
181 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type())); | 171 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type())); |
182 return; | 172 return; |
183 } | 173 } |
184 | 174 |
185 if (!value->isPrimitiveValue()) | 175 if (!value->isPrimitiveValue()) |
186 return; | 176 return; |
187 | 177 |
188 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 178 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
189 if (primitiveValue->getValueID() == CSSValueContain) | 179 if (primitiveValue->getValueID() == CSSValueContain) |
190 layer->setSizeType(Contain); | 180 layer->setSizeType(Contain); |
191 else if (primitiveValue->getValueID() == CSSValueCover) | 181 else if (primitiveValue->getValueID() == CSSValueCover) |
192 layer->setSizeType(Cover); | 182 layer->setSizeType(Cover); |
193 else | 183 else |
194 layer->setSizeType(SizeLength); | 184 layer->setSizeType(SizeLength); |
195 | 185 |
196 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); | 186 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); |
197 | 187 |
198 if (primitiveValue->getValueID() == CSSValueContain || primitiveValue->getVa
lueID() == CSSValueCover) { | 188 if (primitiveValue->getValueID() == CSSValueContain || primitiveValue->getVa
lueID() == CSSValueCover) { |
199 layer->setSizeLength(b); | 189 layer->setSizeLength(b); |
200 return; | 190 return; |
201 } | 191 } |
202 | 192 |
203 Length firstLength; | 193 Length firstLength; |
204 Length secondLength; | 194 Length secondLength; |
205 | 195 |
206 if (Pair* pair = primitiveValue->getPairValue()) { | 196 if (Pair* pair = primitiveValue->getPairValue()) { |
207 firstLength = pair->first()->convertToLength<AnyConversion>(cssToLengthC
onversionData()); | 197 firstLength = pair->first()->convertToLength<AnyConversion>(state.cssToL
engthConversionData()); |
208 secondLength = pair->second()->convertToLength<AnyConversion>(cssToLengt
hConversionData()); | 198 secondLength = pair->second()->convertToLength<AnyConversion>(state.cssT
oLengthConversionData()); |
209 } else { | 199 } else { |
210 firstLength = primitiveValue->convertToLength<AnyConversion>(cssToLength
ConversionData()); | 200 firstLength = primitiveValue->convertToLength<AnyConversion>(state.cssTo
LengthConversionData()); |
211 secondLength = Length(); | 201 secondLength = Length(); |
212 } | 202 } |
213 | 203 |
214 b.setWidth(firstLength); | 204 b.setWidth(firstLength); |
215 b.setHeight(secondLength); | 205 b.setHeight(secondLength); |
216 layer->setSizeLength(b); | 206 layer->setSizeLength(b); |
217 } | 207 } |
218 | 208 |
219 void CSSToStyleMap::mapFillXPosition(FillLayer* layer, CSSValue* value) const | 209 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) |
220 { | 210 { |
221 if (value->isInitialValue()) { | 211 if (value->isInitialValue()) { |
222 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); | 212 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); |
223 return; | 213 return; |
224 } | 214 } |
225 | 215 |
226 if (!value->isPrimitiveValue()) | 216 if (!value->isPrimitiveValue()) |
227 return; | 217 return; |
228 | 218 |
229 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 219 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
230 Pair* pair = primitiveValue->getPairValue(); | 220 Pair* pair = primitiveValue->getPairValue(); |
231 if (pair) | 221 if (pair) |
232 primitiveValue = pair->second(); | 222 primitiveValue = pair->second(); |
233 | 223 |
234 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon
version>(cssToLengthConversionData()); | 224 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon
version>(state.cssToLengthConversionData()); |
235 | 225 |
236 layer->setXPosition(length); | 226 layer->setXPosition(length); |
237 if (pair) | 227 if (pair) |
238 layer->setBackgroundXOrigin(*(pair->first())); | 228 layer->setBackgroundXOrigin(*(pair->first())); |
239 } | 229 } |
240 | 230 |
241 void CSSToStyleMap::mapFillYPosition(FillLayer* layer, CSSValue* value) const | 231 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) |
242 { | 232 { |
243 if (value->isInitialValue()) { | 233 if (value->isInitialValue()) { |
244 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); | 234 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); |
245 return; | 235 return; |
246 } | 236 } |
247 | 237 |
248 if (!value->isPrimitiveValue()) | 238 if (!value->isPrimitiveValue()) |
249 return; | 239 return; |
250 | 240 |
251 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 241 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
252 Pair* pair = primitiveValue->getPairValue(); | 242 Pair* pair = primitiveValue->getPairValue(); |
253 if (pair) | 243 if (pair) |
254 primitiveValue = pair->second(); | 244 primitiveValue = pair->second(); |
255 | 245 |
256 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon
version>(cssToLengthConversionData()); | 246 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon
version>(state.cssToLengthConversionData()); |
257 | 247 |
258 layer->setYPosition(length); | 248 layer->setYPosition(length); |
259 if (pair) | 249 if (pair) |
260 layer->setBackgroundYOrigin(*(pair->first())); | 250 layer->setBackgroundYOrigin(*(pair->first())); |
261 } | 251 } |
262 | 252 |
263 void CSSToStyleMap::mapFillMaskSourceType(FillLayer* layer, CSSValue* value) con
st | 253 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer,
CSSValue* value) |
264 { | 254 { |
265 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); | 255 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); |
266 if (value->isInitialValue()) { | 256 if (value->isInitialValue()) { |
267 layer->setMaskSourceType(type); | 257 layer->setMaskSourceType(type); |
268 return; | 258 return; |
269 } | 259 } |
270 | 260 |
271 if (!value->isPrimitiveValue()) | 261 if (!value->isPrimitiveValue()) |
272 return; | 262 return; |
273 | 263 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 416 |
427 if (value->isInitialValue()) | 417 if (value->isInitialValue()) |
428 return CSSTimingData::initialTimingFunction(); | 418 return CSSTimingData::initialTimingFunction(); |
429 | 419 |
430 CSSStepsTimingFunctionValue* stepsTimingFunction = toCSSStepsTimingFunctionV
alue(value); | 420 CSSStepsTimingFunctionValue* stepsTimingFunction = toCSSStepsTimingFunctionV
alue(value); |
431 if (stepsTimingFunction->stepAtPosition() == StepsTimingFunction::Middle &&
!allowStepMiddle) | 421 if (stepsTimingFunction->stepAtPosition() == StepsTimingFunction::Middle &&
!allowStepMiddle) |
432 return CSSTimingData::initialTimingFunction(); | 422 return CSSTimingData::initialTimingFunction(); |
433 return StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), ste
psTimingFunction->stepAtPosition()); | 423 return StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), ste
psTimingFunction->stepAtPosition()); |
434 } | 424 } |
435 | 425 |
436 void CSSToStyleMap::mapNinePieceImage(RenderStyle* mutableStyle, CSSPropertyID p
roperty, CSSValue* value, NinePieceImage& image) | 426 void CSSToStyleMap::mapNinePieceImage(StyleResolverState& state, CSSPropertyID p
roperty, CSSValue* value, NinePieceImage& image) |
437 { | 427 { |
438 // If we're not a value list, then we are "none" and don't need to alter the
empty image at all. | 428 // If we're not a value list, then we are "none" and don't need to alter the
empty image at all. |
439 if (!value || !value->isValueList()) | 429 if (!value || !value->isValueList()) |
440 return; | 430 return; |
441 | 431 |
442 // Retrieve the border image value. | 432 // Retrieve the border image value. |
443 CSSValueList* borderImage = toCSSValueList(value); | 433 CSSValueList* borderImage = toCSSValueList(value); |
444 | 434 |
445 // Set the image (this kicks off the load). | 435 // Set the image (this kicks off the load). |
446 CSSPropertyID imageProperty; | 436 CSSPropertyID imageProperty; |
447 if (property == CSSPropertyWebkitBorderImage) | 437 if (property == CSSPropertyWebkitBorderImage) |
448 imageProperty = CSSPropertyBorderImageSource; | 438 imageProperty = CSSPropertyBorderImageSource; |
449 else if (property == CSSPropertyWebkitMaskBoxImage) | 439 else if (property == CSSPropertyWebkitMaskBoxImage) |
450 imageProperty = CSSPropertyWebkitMaskBoxImageSource; | 440 imageProperty = CSSPropertyWebkitMaskBoxImageSource; |
451 else | 441 else |
452 imageProperty = property; | 442 imageProperty = property; |
453 | 443 |
454 for (unsigned i = 0 ; i < borderImage->length() ; ++i) { | 444 for (unsigned i = 0 ; i < borderImage->length() ; ++i) { |
455 CSSValue* current = borderImage->item(i); | 445 CSSValue* current = borderImage->item(i); |
456 | 446 |
457 if (current->isImageValue() || current->isImageGeneratorValue() || curre
nt->isImageSetValue()) | 447 if (current->isImageValue() || current->isImageGeneratorValue() || curre
nt->isImageSetValue()) |
458 image.setImage(styleImage(imageProperty, current)); | 448 image.setImage(state.styleImage(imageProperty, current)); |
459 else if (current->isBorderImageSliceValue()) | 449 else if (current->isBorderImageSliceValue()) |
460 mapNinePieceImageSlice(current, image); | 450 mapNinePieceImageSlice(state, current, image); |
461 else if (current->isValueList()) { | 451 else if (current->isValueList()) { |
462 CSSValueList* slashList = toCSSValueList(current); | 452 CSSValueList* slashList = toCSSValueList(current); |
463 size_t length = slashList->length(); | 453 size_t length = slashList->length(); |
464 // Map in the image slices. | 454 // Map in the image slices. |
465 if (length && slashList->item(0)->isBorderImageSliceValue()) | 455 if (length && slashList->item(0)->isBorderImageSliceValue()) |
466 mapNinePieceImageSlice(slashList->item(0), image); | 456 mapNinePieceImageSlice(state, slashList->item(0), image); |
467 | 457 |
468 // Map in the border slices. | 458 // Map in the border slices. |
469 if (length > 1) | 459 if (length > 1) |
470 image.setBorderSlices(mapNinePieceImageQuad(slashList->item(1)))
; | 460 image.setBorderSlices(mapNinePieceImageQuad(state, slashList->it
em(1))); |
471 | 461 |
472 // Map in the outset. | 462 // Map in the outset. |
473 if (length > 2) | 463 if (length > 2) |
474 image.setOutset(mapNinePieceImageQuad(slashList->item(2))); | 464 image.setOutset(mapNinePieceImageQuad(state, slashList->item(2))
); |
475 } else if (current->isPrimitiveValue()) { | 465 } else if (current->isPrimitiveValue()) { |
476 // Set the appropriate rules for stretch/round/repeat of the slices. | 466 // Set the appropriate rules for stretch/round/repeat of the slices. |
477 mapNinePieceImageRepeat(current, image); | 467 mapNinePieceImageRepeat(state, current, image); |
478 } | 468 } |
479 } | 469 } |
480 | 470 |
481 if (property == CSSPropertyWebkitBorderImage) { | 471 if (property == CSSPropertyWebkitBorderImage) { |
482 // We have to preserve the legacy behavior of -webkit-border-image and m
ake the border slices | 472 // We have to preserve the legacy behavior of -webkit-border-image and m
ake the border slices |
483 // also set the border widths. We don't need to worry about percentages,
since we don't even support | 473 // also set the border widths. We don't need to worry about percentages,
since we don't even support |
484 // those on real borders yet. | 474 // those on real borders yet. |
485 if (image.borderSlices().top().isLength() && image.borderSlices().top().
length().isFixed()) | 475 if (image.borderSlices().top().isLength() && image.borderSlices().top().
length().isFixed()) |
486 mutableStyle->setBorderTopWidth(image.borderSlices().top().length().
value()); | 476 state.style()->setBorderTopWidth(image.borderSlices().top().length()
.value()); |
487 if (image.borderSlices().right().isLength() && image.borderSlices().righ
t().length().isFixed()) | 477 if (image.borderSlices().right().isLength() && image.borderSlices().righ
t().length().isFixed()) |
488 mutableStyle->setBorderRightWidth(image.borderSlices().right().lengt
h().value()); | 478 state.style()->setBorderRightWidth(image.borderSlices().right().leng
th().value()); |
489 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot
tom().length().isFixed()) | 479 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot
tom().length().isFixed()) |
490 mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().len
gth().value()); | 480 state.style()->setBorderBottomWidth(image.borderSlices().bottom().le
ngth().value()); |
491 if (image.borderSlices().left().isLength() && image.borderSlices().left(
).length().isFixed()) | 481 if (image.borderSlices().left().isLength() && image.borderSlices().left(
).length().isFixed()) |
492 mutableStyle->setBorderLeftWidth(image.borderSlices().left().length(
).value()); | 482 state.style()->setBorderLeftWidth(image.borderSlices().left().length
().value()); |
493 } | 483 } |
494 } | 484 } |
495 | 485 |
496 void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag
e) const | 486 void CSSToStyleMap::mapNinePieceImageSlice(StyleResolverState&, CSSValue* value,
NinePieceImage& image) |
497 { | 487 { |
498 if (!value || !value->isBorderImageSliceValue()) | 488 if (!value || !value->isBorderImageSliceValue()) |
499 return; | 489 return; |
500 | 490 |
501 // Retrieve the border image value. | 491 // Retrieve the border image value. |
502 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu
e); | 492 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu
e); |
503 | 493 |
504 // Set up a length box to represent our image slices. | 494 // Set up a length box to represent our image slices. |
505 LengthBox box; | 495 LengthBox box; |
506 Quad* slices = borderImageSlice->slices(); | 496 Quad* slices = borderImageSlice->slices(); |
(...skipping 23 matching lines...) Expand all Loading... |
530 { | 520 { |
531 if (value.isNumber()) | 521 if (value.isNumber()) |
532 return value.getDoubleValue(); | 522 return value.getDoubleValue(); |
533 if (value.isPercentage()) | 523 if (value.isPercentage()) |
534 return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), P
ercent); | 524 return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), P
ercent); |
535 if (value.getValueID() != CSSValueAuto) | 525 if (value.getValueID() != CSSValueAuto) |
536 return value.computeLength<Length>(conversionData); | 526 return value.computeLength<Length>(conversionData); |
537 return Length(Auto); | 527 return Length(Auto); |
538 } | 528 } |
539 | 529 |
540 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const | 530 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& st
ate, CSSValue* value) |
541 { | 531 { |
542 if (!value || !value->isPrimitiveValue()) | 532 if (!value || !value->isPrimitiveValue()) |
543 return BorderImageLengthBox(Length(Auto)); | 533 return BorderImageLengthBox(Length(Auto)); |
544 | 534 |
545 Quad* slices = toCSSPrimitiveValue(value)->getQuadValue(); | 535 Quad* slices = toCSSPrimitiveValue(value)->getQuadValue(); |
546 | 536 |
547 // Set up a border image length box to represent our image slices. | 537 // Set up a border image length box to represent our image slices. |
548 return BorderImageLengthBox( | 538 return BorderImageLengthBox( |
549 toBorderImageLength(*slices->top(), cssToLengthConversionData()), | 539 toBorderImageLength(*slices->top(), state.cssToLengthConversionData()), |
550 toBorderImageLength(*slices->right(), cssToLengthConversionData()), | 540 toBorderImageLength(*slices->right(), state.cssToLengthConversionData())
, |
551 toBorderImageLength(*slices->bottom(), cssToLengthConversionData()), | 541 toBorderImageLength(*slices->bottom(), state.cssToLengthConversionData()
), |
552 toBorderImageLength(*slices->left(), cssToLengthConversionData())); | 542 toBorderImageLength(*slices->left(), state.cssToLengthConversionData()))
; |
553 } | 543 } |
554 | 544 |
555 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima
ge) const | 545 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, CSSValue* value
, NinePieceImage& image) |
556 { | 546 { |
557 if (!value || !value->isPrimitiveValue()) | 547 if (!value || !value->isPrimitiveValue()) |
558 return; | 548 return; |
559 | 549 |
560 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 550 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
561 Pair* pair = primitiveValue->getPairValue(); | 551 Pair* pair = primitiveValue->getPairValue(); |
562 if (!pair || !pair->first() || !pair->second()) | 552 if (!pair || !pair->first() || !pair->second()) |
563 return; | 553 return; |
564 | 554 |
565 CSSValueID firstIdentifier = pair->first()->getValueID(); | 555 CSSValueID firstIdentifier = pair->first()->getValueID(); |
(...skipping 28 matching lines...) Expand all Loading... |
594 verticalRule = SpaceImageRule; | 584 verticalRule = SpaceImageRule; |
595 break; | 585 break; |
596 default: // CSSValueRepeat | 586 default: // CSSValueRepeat |
597 verticalRule = RepeatImageRule; | 587 verticalRule = RepeatImageRule; |
598 break; | 588 break; |
599 } | 589 } |
600 image.setVerticalRule(verticalRule); | 590 image.setVerticalRule(verticalRule); |
601 } | 591 } |
602 | 592 |
603 }; | 593 }; |
OLD | NEW |