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 17 matching lines...) Expand all Loading... |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/css/resolver/CSSToStyleMap.h" | 29 #include "core/css/resolver/CSSToStyleMap.h" |
30 | 30 |
31 #include "core/CSSValueKeywords.h" | 31 #include "core/CSSValueKeywords.h" |
32 #include "core/animation/css/CSSAnimationData.h" | 32 #include "core/animation/css/CSSAnimationData.h" |
33 #include "core/css/CSSBorderImageSliceValue.h" | 33 #include "core/css/CSSBorderImageSliceValue.h" |
34 #include "core/css/CSSPrimitiveValue.h" | 34 #include "core/css/CSSPrimitiveValue.h" |
35 #include "core/css/CSSPrimitiveValueMappings.h" | 35 #include "core/css/CSSPrimitiveValueMappings.h" |
36 #include "core/css/CSSQuadValue.h" | 36 #include "core/css/CSSQuadValue.h" |
37 #include "core/css/CSSTimingFunctionValue.h" | 37 #include "core/css/CSSTimingFunctionValue.h" |
38 #include "core/css/Pair.h" | 38 #include "core/css/CSSValuePair.h" |
39 #include "core/css/resolver/StyleBuilderConverter.h" | 39 #include "core/css/resolver/StyleBuilderConverter.h" |
40 #include "core/css/resolver/StyleResolverState.h" | 40 #include "core/css/resolver/StyleResolverState.h" |
41 #include "core/style/BorderImageLengthBox.h" | 41 #include "core/style/BorderImageLengthBox.h" |
42 #include "core/style/FillLayer.h" | 42 #include "core/style/FillLayer.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, CSS
Value* value) | 46 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, CSS
Value* value) |
47 { | 47 { |
48 if (value->isInitialValue()) { | 48 if (value->isInitialValue()) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, CSS
Value* value) | 168 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, CSS
Value* value) |
169 { | 169 { |
170 if (value->isInitialValue()) { | 170 if (value->isInitialValue()) { |
171 layer->setSizeType(FillLayer::initialFillSizeType(layer->type())); | 171 layer->setSizeType(FillLayer::initialFillSizeType(layer->type())); |
172 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type())); | 172 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type())); |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 if (!value->isPrimitiveValue()) | 176 if (!value->isPrimitiveValue() && !value->isValuePair()) |
177 return; | 177 return; |
178 | 178 |
179 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 179 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() ==
CSSValueContain) |
180 if (primitiveValue->getValueID() == CSSValueContain) | |
181 layer->setSizeType(Contain); | 180 layer->setSizeType(Contain); |
182 else if (primitiveValue->getValueID() == CSSValueCover) | 181 else if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID
() == CSSValueCover) |
183 layer->setSizeType(Cover); | 182 layer->setSizeType(Cover); |
184 else | 183 else |
185 layer->setSizeType(SizeLength); | 184 layer->setSizeType(SizeLength); |
186 | 185 |
187 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); | 186 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); |
188 | 187 |
189 if (primitiveValue->getValueID() == CSSValueContain || primitiveValue->getVa
lueID() == CSSValueCover) { | 188 if (value->isPrimitiveValue() && (toCSSPrimitiveValue(value)->getValueID() =
= CSSValueContain || toCSSPrimitiveValue(value)->getValueID() == CSSValueCover))
{ |
190 layer->setSizeLength(b); | 189 layer->setSizeLength(b); |
191 return; | 190 return; |
192 } | 191 } |
193 | 192 |
194 Length firstLength; | 193 Length firstLength; |
195 Length secondLength; | 194 Length secondLength; |
196 | 195 |
197 if (Pair* pair = primitiveValue->getPairValue()) { | 196 if (value->isValuePair()) { |
| 197 const CSSValuePair* pair = toCSSValuePair(value); |
198 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, pair->fi
rst()); | 198 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, pair->fi
rst()); |
199 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, pair->s
econd()); | 199 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, pair->s
econd()); |
200 } else { | 200 } else { |
201 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, primitiv
eValue); | 201 ASSERT(value->isPrimitiveValue()); |
| 202 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, value); |
202 secondLength = Length(); | 203 secondLength = Length(); |
203 } | 204 } |
204 | 205 |
205 b.setWidth(firstLength); | 206 b.setWidth(firstLength); |
206 b.setHeight(secondLength); | 207 b.setHeight(secondLength); |
207 layer->setSizeLength(b); | 208 layer->setSizeLength(b); |
208 } | 209 } |
209 | 210 |
210 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) | 211 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) |
211 { | 212 { |
212 if (value->isInitialValue()) { | 213 if (value->isInitialValue()) { |
213 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); | 214 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); |
214 return; | 215 return; |
215 } | 216 } |
216 | 217 |
217 if (!value->isPrimitiveValue()) | 218 if (!value->isPrimitiveValue() && !value->isValuePair()) |
218 return; | 219 return; |
219 | 220 |
220 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 221 CSSPrimitiveValue* primitiveValue; |
221 Pair* pair = primitiveValue->getPairValue(); | 222 if (value->isValuePair()) |
222 if (pair) | 223 primitiveValue = toCSSPrimitiveValue(toCSSValuePair(value)->second()); |
223 primitiveValue = pair->second(); | 224 else |
| 225 primitiveValue = toCSSPrimitiveValue(value); |
224 | 226 |
225 Length length = primitiveValue->convertToLength(state.cssToLengthConversionD
ata()); | 227 Length length = primitiveValue->convertToLength(state.cssToLengthConversionD
ata()); |
226 | 228 |
227 layer->setXPosition(length); | 229 layer->setXPosition(length); |
228 if (pair) | 230 if (value->isValuePair()) |
229 layer->setBackgroundXOrigin(*(pair->first())); | 231 layer->setBackgroundXOrigin(*toCSSPrimitiveValue(toCSSValuePair(value)->
first())); |
230 } | 232 } |
231 | 233 |
232 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) | 234 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer
, CSSValue* value) |
233 { | 235 { |
234 if (value->isInitialValue()) { | 236 if (value->isInitialValue()) { |
235 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); | 237 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); |
236 return; | 238 return; |
237 } | 239 } |
238 | 240 |
239 if (!value->isPrimitiveValue()) | 241 if (!value->isPrimitiveValue() && !value->isValuePair()) |
240 return; | 242 return; |
241 | 243 |
242 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 244 CSSPrimitiveValue* primitiveValue; |
243 Pair* pair = primitiveValue->getPairValue(); | 245 if (value->isValuePair()) |
244 if (pair) | 246 primitiveValue = toCSSPrimitiveValue(toCSSValuePair(value)->second()); |
245 primitiveValue = pair->second(); | 247 else |
| 248 primitiveValue = toCSSPrimitiveValue(value); |
246 | 249 |
247 Length length = primitiveValue->convertToLength(state.cssToLengthConversionD
ata()); | 250 Length length = primitiveValue->convertToLength(state.cssToLengthConversionD
ata()); |
248 | 251 |
249 layer->setYPosition(length); | 252 layer->setYPosition(length); |
250 if (pair) | 253 if (value->isValuePair()) |
251 layer->setBackgroundYOrigin(*(pair->first())); | 254 layer->setBackgroundYOrigin(*toCSSPrimitiveValue(toCSSValuePair(value)->
first())); |
252 } | 255 } |
253 | 256 |
254 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer,
CSSValue* value) | 257 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer,
CSSValue* value) |
255 { | 258 { |
256 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); | 259 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); |
257 if (value->isInitialValue()) { | 260 if (value->isInitialValue()) { |
258 layer->setMaskSourceType(type); | 261 layer->setMaskSourceType(type); |
259 return; | 262 return; |
260 } | 263 } |
261 | 264 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 if (length && slashList->item(0)->isBorderImageSliceValue()) | 457 if (length && slashList->item(0)->isBorderImageSliceValue()) |
455 mapNinePieceImageSlice(state, slashList->item(0), image); | 458 mapNinePieceImageSlice(state, slashList->item(0), image); |
456 | 459 |
457 // Map in the border slices. | 460 // Map in the border slices. |
458 if (length > 1) | 461 if (length > 1) |
459 image.setBorderSlices(mapNinePieceImageQuad(state, slashList->it
em(1))); | 462 image.setBorderSlices(mapNinePieceImageQuad(state, slashList->it
em(1))); |
460 | 463 |
461 // Map in the outset. | 464 // Map in the outset. |
462 if (length > 2) | 465 if (length > 2) |
463 image.setOutset(mapNinePieceImageQuad(state, slashList->item(2))
); | 466 image.setOutset(mapNinePieceImageQuad(state, slashList->item(2))
); |
464 } else if (current->isPrimitiveValue()) { | 467 } else if (current->isPrimitiveValue() || current->isValuePair()) { |
465 // Set the appropriate rules for stretch/round/repeat of the slices. | 468 // Set the appropriate rules for stretch/round/repeat of the slices. |
466 mapNinePieceImageRepeat(state, current, image); | 469 mapNinePieceImageRepeat(state, current, image); |
467 } | 470 } |
468 } | 471 } |
469 | 472 |
470 if (property == CSSPropertyWebkitBorderImage) { | 473 if (property == CSSPropertyWebkitBorderImage) { |
471 // We have to preserve the legacy behavior of -webkit-border-image and m
ake the border slices | 474 // We have to preserve the legacy behavior of -webkit-border-image and m
ake the border slices |
472 // also set the border widths. We don't need to worry about percentages,
since we don't even support | 475 // also set the border widths. We don't need to worry about percentages,
since we don't even support |
473 // those on real borders yet. | 476 // those on real borders yet. |
474 if (image.borderSlices().top().isLength() && image.borderSlices().top().
length().isFixed()) | 477 if (image.borderSlices().top().isLength() && image.borderSlices().top().
length().isFixed()) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // Set up a border image length box to represent our image slices. | 539 // Set up a border image length box to represent our image slices. |
537 return BorderImageLengthBox( | 540 return BorderImageLengthBox( |
538 toBorderImageLength(*slices->top(), state.cssToLengthConversionData()), | 541 toBorderImageLength(*slices->top(), state.cssToLengthConversionData()), |
539 toBorderImageLength(*slices->right(), state.cssToLengthConversionData())
, | 542 toBorderImageLength(*slices->right(), state.cssToLengthConversionData())
, |
540 toBorderImageLength(*slices->bottom(), state.cssToLengthConversionData()
), | 543 toBorderImageLength(*slices->bottom(), state.cssToLengthConversionData()
), |
541 toBorderImageLength(*slices->left(), state.cssToLengthConversionData()))
; | 544 toBorderImageLength(*slices->left(), state.cssToLengthConversionData()))
; |
542 } | 545 } |
543 | 546 |
544 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, CSSValue* value
, NinePieceImage& image) | 547 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, CSSValue* value
, NinePieceImage& image) |
545 { | 548 { |
546 if (!value || !value->isPrimitiveValue()) | 549 if (!value || !value->isValuePair()) |
547 return; | 550 return; |
548 | 551 |
549 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 552 const CSSValuePair* pair = toCSSValuePair(value); |
550 Pair* pair = primitiveValue->getPairValue(); | |
551 if (!pair || !pair->first() || !pair->second()) | 553 if (!pair || !pair->first() || !pair->second()) |
552 return; | 554 return; |
553 | 555 |
554 CSSValueID firstIdentifier = pair->first()->getValueID(); | 556 CSSValueID firstIdentifier = toCSSPrimitiveValue(pair->first())->getValueID(
); |
555 CSSValueID secondIdentifier = pair->second()->getValueID(); | 557 CSSValueID secondIdentifier = toCSSPrimitiveValue(pair->second())->getValueI
D(); |
556 | 558 |
557 ENinePieceImageRule horizontalRule; | 559 ENinePieceImageRule horizontalRule; |
558 switch (firstIdentifier) { | 560 switch (firstIdentifier) { |
559 case CSSValueStretch: | 561 case CSSValueStretch: |
560 horizontalRule = StretchImageRule; | 562 horizontalRule = StretchImageRule; |
561 break; | 563 break; |
562 case CSSValueRound: | 564 case CSSValueRound: |
563 horizontalRule = RoundImageRule; | 565 horizontalRule = RoundImageRule; |
564 break; | 566 break; |
565 case CSSValueSpace: | 567 case CSSValueSpace: |
(...skipping 17 matching lines...) Expand all Loading... |
583 verticalRule = SpaceImageRule; | 585 verticalRule = SpaceImageRule; |
584 break; | 586 break; |
585 default: // CSSValueRepeat | 587 default: // CSSValueRepeat |
586 verticalRule = RepeatImageRule; | 588 verticalRule = RepeatImageRule; |
587 break; | 589 break; |
588 } | 590 } |
589 image.setVerticalRule(verticalRule); | 591 image.setVerticalRule(verticalRule); |
590 } | 592 } |
591 | 593 |
592 }; | 594 }; |
OLD | NEW |