OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> | 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. | 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. |
7 * Copyright (C) 2015 Google Inc. All rights reserved. | 7 * Copyright (C) 2015 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "platform/LengthFunctions.h" | 55 #include "platform/LengthFunctions.h" |
56 | 56 |
57 namespace blink { | 57 namespace blink { |
58 | 58 |
59 inline static bool isFlexOrGrid(Node* element) | 59 inline static bool isFlexOrGrid(Node* element) |
60 { | 60 { |
61 return element && element->ensureComputedStyle() | 61 return element && element->ensureComputedStyle() |
62 && element->ensureComputedStyle()->isDisplayFlexibleOrGridBox(); | 62 && element->ensureComputedStyle()->isDisplayFlexibleOrGridBox(); |
63 } | 63 } |
64 | 64 |
65 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(d
ouble value, const ComputedStyle& style) | 65 inline static CSSPrimitiveValue zoomAdjustedPixelValue(double value, const Compu
tedStyle& style) |
66 { | 66 { |
67 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::CSS_PX); | 67 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::CSS_PX); |
68 } | 68 } |
69 | 69 |
70 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(
double value, const ComputedStyle& style) | 70 inline static CSSPrimitiveValue zoomAdjustedNumberValue(double value, const Comp
utedStyle& style) |
71 { | 71 { |
72 return cssValuePool().createValue(value / style.effectiveZoom(), CSSPrimitiv
eValue::CSS_NUMBER); | 72 return cssValuePool().createValue(value / style.effectiveZoom(), CSSPrimitiv
eValue::CSS_NUMBER); |
73 } | 73 } |
74 | 74 |
75 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValueForLength
(const Length& length, const ComputedStyle& style) | 75 static CSSPrimitiveValue zoomAdjustedPixelValueForLength(const Length& length, c
onst ComputedStyle& style) |
76 { | 76 { |
77 if (length.isFixed()) | 77 if (length.isFixed()) |
78 return zoomAdjustedPixelValue(length.value(), style); | 78 return zoomAdjustedPixelValue(length.value(), style); |
79 return cssValuePool().createValue(length, style); | 79 return cssValuePool().createValue(length, style); |
80 } | 80 } |
81 | 81 |
82 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> pixelValueForUnzoomedLength(con
st UnzoomedLength& unzoomedLength, const ComputedStyle& style) | 82 static CSSPrimitiveValue pixelValueForUnzoomedLength(const UnzoomedLength& unzoo
medLength, const ComputedStyle& style) |
83 { | 83 { |
84 const Length& length = unzoomedLength.length(); | 84 const Length& length = unzoomedLength.length(); |
85 if (length.isFixed()) | 85 if (length.isFixed()) |
86 return cssValuePool().createValue(length.value(), CSSPrimitiveValue::CSS
_PX); | 86 return cssValuePool().createValue(length.value(), CSSPrimitiveValue::CSS
_PX); |
87 return cssValuePool().createValue(length, style); | 87 return cssValuePool().createValue(length, style); |
88 } | 88 } |
89 | 89 |
90 static PassRefPtrWillBeRawPtr<CSSValueList> createPositionListForLayer(CSSProper
tyID propertyID, const FillLayer& layer, const ComputedStyle& style) | 90 static PassRefPtrWillBeRawPtr<CSSValueList> createPositionListForLayer(CSSProper
tyID propertyID, const FillLayer& layer, const ComputedStyle& style) |
91 { | 91 { |
92 RefPtrWillBeRawPtr<CSSValueList> positionList = CSSValueList::createSpaceSep
arated(); | 92 RefPtrWillBeRawPtr<CSSValueList> positionList = CSSValueList::createSpaceSep
arated(); |
93 if (layer.isBackgroundXOriginSet()) { | 93 if (layer.isBackgroundXOriginSet()) { |
94 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition ||
propertyID == CSSPropertyWebkitMaskPosition); | 94 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition ||
propertyID == CSSPropertyWebkitMaskPosition); |
95 positionList->append(cssValuePool().createValue(layer.backgroundXOrigin(
))); | 95 positionList->append(cssValuePool().createValue(layer.backgroundXOrigin(
))); |
96 } | 96 } |
97 positionList->append(zoomAdjustedPixelValueForLength(layer.xPosition(), styl
e)); | 97 positionList->append(zoomAdjustedPixelValueForLength(layer.xPosition(), styl
e)); |
98 if (layer.isBackgroundYOriginSet()) { | 98 if (layer.isBackgroundYOriginSet()) { |
99 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSP
ropertyWebkitMaskPosition); | 99 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSP
ropertyWebkitMaskPosition); |
100 positionList->append(cssValuePool().createValue(layer.backgroundYOrigin(
))); | 100 positionList->append(cssValuePool().createValue(layer.backgroundYOrigin(
))); |
101 } | 101 } |
102 positionList->append(zoomAdjustedPixelValueForLength(layer.yPosition(), styl
e)); | 102 positionList->append(zoomAdjustedPixelValueForLength(layer.yPosition(), styl
e)); |
103 return positionList.release(); | 103 return positionList.release(); |
104 } | 104 } |
105 | 105 |
106 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> ComputedStyleCSSValueMapping::currentC
olorOrValidColor(const ComputedStyle& style, const StyleColor& color) | 106 CSSPrimitiveValue ComputedStyleCSSValueMapping::currentColorOrValidColor(const C
omputedStyle& style, const StyleColor& color) |
107 { | 107 { |
108 // This function does NOT look at visited information, so that computed styl
e doesn't expose that. | 108 // This function does NOT look at visited information, so that computed styl
e doesn't expose that. |
109 return cssValuePool().createColorValue(color.resolve(style.color()).rgb()); | 109 return cssValuePool().createColorValue(color.resolve(style.color()).rgb()); |
110 } | 110 } |
111 | 111 |
112 static CSSValue valueForFillSize(const FillSize& fillSize, const ComputedStyle&
style) | 112 static CSSValue valueForFillSize(const FillSize& fillSize, const ComputedStyle&
style) |
113 { | 113 { |
114 if (fillSize.type == Contain) | 114 if (fillSize.type == Contain) |
115 return cssValuePool().createIdentifierValue(CSSValueContain); | 115 return cssValuePool().createIdentifierValue(CSSValueContain); |
116 | 116 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // So we should get the opposite length unit and see if it is auto. | 188 // So we should get the opposite length unit and see if it is auto. |
189 return cssValuePool().createIdentifierValue(CSSValueAuto); | 189 return cssValuePool().createIdentifierValue(CSSValueAuto); |
190 } | 190 } |
191 | 191 |
192 return zoomAdjustedPixelValueForLength(offset, style); | 192 return zoomAdjustedPixelValueForLength(offset, style); |
193 } | 193 } |
194 | 194 |
195 static PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> valueForNinePieceImageSl
ice(const NinePieceImage& image) | 195 static PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> valueForNinePieceImageSl
ice(const NinePieceImage& image) |
196 { | 196 { |
197 // Create the slices. | 197 // Create the slices. |
198 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = nullptr; | 198 NullableCSSValue top; |
199 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = nullptr; | 199 NullableCSSValue right; |
200 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = nullptr; | 200 NullableCSSValue bottom; |
201 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = nullptr; | 201 NullableCSSValue left; |
202 | 202 |
203 // TODO(alancutter): Make this code aware of calc lengths. | 203 // TODO(alancutter): Make this code aware of calc lengths. |
204 if (image.imageSlices().top().hasPercent()) | 204 if (image.imageSlices().top().hasPercent()) |
205 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSP
rimitiveValue::CSS_PERCENTAGE); | 205 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSP
rimitiveValue::CSS_PERCENTAGE); |
206 else | 206 else |
207 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSP
rimitiveValue::CSS_NUMBER); | 207 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSP
rimitiveValue::CSS_NUMBER); |
208 | 208 |
209 if (image.imageSlices().right() == image.imageSlices().top() && image.imageS
lices().bottom() == image.imageSlices().top() | 209 if (image.imageSlices().right() == image.imageSlices().top() && image.imageS
lices().bottom() == image.imageSlices().top() |
210 && image.imageSlices().left() == image.imageSlices().top()) { | 210 && image.imageSlices().left() == image.imageSlices().top()) { |
211 right = top; | 211 right = top; |
(...skipping 19 matching lines...) Expand all Loading... |
231 } else { | 231 } else { |
232 if (image.imageSlices().left().hasPercent()) | 232 if (image.imageSlices().left().hasPercent()) |
233 left = cssValuePool().createValue(image.imageSlices().left()
.value(), CSSPrimitiveValue::CSS_PERCENTAGE); | 233 left = cssValuePool().createValue(image.imageSlices().left()
.value(), CSSPrimitiveValue::CSS_PERCENTAGE); |
234 else | 234 else |
235 left = cssValuePool().createValue(image.imageSlices().left()
.value(), CSSPrimitiveValue::CSS_NUMBER); | 235 left = cssValuePool().createValue(image.imageSlices().left()
.value(), CSSPrimitiveValue::CSS_NUMBER); |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); | 240 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); |
241 quad->setTop(top); | 241 quad->setTop(toCSSPrimitiveValue(*top)); |
242 quad->setRight(right); | 242 quad->setRight(toCSSPrimitiveValue(*right)); |
243 quad->setBottom(bottom); | 243 quad->setBottom(toCSSPrimitiveValue(*bottom)); |
244 quad->setLeft(left); | 244 quad->setLeft(toCSSPrimitiveValue(*left)); |
245 | 245 |
246 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.rele
ase()), image.fill()); | 246 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.rele
ase()), image.fill()); |
247 } | 247 } |
248 | 248 |
249 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(cons
t BorderImageLengthBox& box, const ComputedStyle& style) | 249 static CSSPrimitiveValue valueForNinePieceImageQuad(const BorderImageLengthBox&
box, const ComputedStyle& style) |
250 { | 250 { |
251 // Create the slices. | 251 // Create the slices. |
252 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = nullptr; | 252 NullableCSSValue top; |
253 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = nullptr; | 253 NullableCSSValue right; |
254 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = nullptr; | 254 NullableCSSValue bottom; |
255 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = nullptr; | 255 NullableCSSValue left; |
256 | 256 |
257 if (box.top().isNumber()) | 257 if (box.top().isNumber()) |
258 top = cssValuePool().createValue(box.top().number(), CSSPrimitiveValue::
CSS_NUMBER); | 258 top = cssValuePool().createValue(box.top().number(), CSSPrimitiveValue::
CSS_NUMBER); |
259 else | 259 else |
260 top = cssValuePool().createValue(box.top().length(), style); | 260 top = cssValuePool().createValue(box.top().length(), style); |
261 | 261 |
262 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == b
ox.top()) { | 262 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == b
ox.top()) { |
263 right = top; | 263 right = top; |
264 bottom = top; | 264 bottom = top; |
265 left = top; | 265 left = top; |
(...skipping 17 matching lines...) Expand all Loading... |
283 } else { | 283 } else { |
284 if (box.left().isNumber()) | 284 if (box.left().isNumber()) |
285 left = cssValuePool().createValue(box.left().number(), CSSPr
imitiveValue::CSS_NUMBER); | 285 left = cssValuePool().createValue(box.left().number(), CSSPr
imitiveValue::CSS_NUMBER); |
286 else | 286 else |
287 left = cssValuePool().createValue(box.left().length(), style
); | 287 left = cssValuePool().createValue(box.left().length(), style
); |
288 } | 288 } |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); | 292 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); |
293 quad->setTop(top); | 293 quad->setTop(toCSSPrimitiveValue(*top)); |
294 quad->setRight(right); | 294 quad->setRight(toCSSPrimitiveValue(*right)); |
295 quad->setBottom(bottom); | 295 quad->setBottom(toCSSPrimitiveValue(*bottom)); |
296 quad->setLeft(left); | 296 quad->setLeft(toCSSPrimitiveValue(*left)); |
297 | 297 |
298 return cssValuePool().createValue(quad.release()); | 298 return cssValuePool().createValue(quad.release()); |
299 } | 299 } |
300 | 300 |
301 static CSSValueID valueForRepeatRule(int rule) | 301 static CSSValueID valueForRepeatRule(int rule) |
302 { | 302 { |
303 switch (rule) { | 303 switch (rule) { |
304 case RepeatImageRule: | 304 case RepeatImageRule: |
305 return CSSValueRepeat; | 305 return CSSValueRepeat; |
306 case RoundImageRule: | 306 case RoundImageRule: |
307 return CSSValueRound; | 307 return CSSValueRound; |
308 case SpaceImageRule: | 308 case SpaceImageRule: |
309 return CSSValueSpace; | 309 return CSSValueSpace; |
310 default: | 310 default: |
311 return CSSValueStretch; | 311 return CSSValueStretch; |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 static CSSValue valueForNinePieceImageRepeat(const NinePieceImage& image) | 315 static CSSValue valueForNinePieceImageRepeat(const NinePieceImage& image) |
316 { | 316 { |
317 RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalRepeat = nullptr; | 317 NullableCSSValue horizontalRepeat; |
318 RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalRepeat = nullptr; | 318 NullableCSSValue verticalRepeat; |
319 | 319 |
320 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(i
mage.horizontalRule())); | 320 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(i
mage.horizontalRule())); |
321 if (image.horizontalRule() == image.verticalRule()) | 321 if (image.horizontalRule() == image.verticalRule()) |
322 verticalRepeat = horizontalRepeat; | 322 verticalRepeat = horizontalRepeat; |
323 else | 323 else |
324 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule
(image.verticalRule())); | 324 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule
(image.verticalRule())); |
325 return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), v
erticalRepeat.release(), Pair::DropIdenticalValues)); | 325 return cssValuePool().createValue(Pair::create(toCSSPrimitiveValue(*horizont
alRepeat), toCSSPrimitiveValue(*verticalRepeat), Pair::DropIdenticalValues)); |
326 } | 326 } |
327 | 327 |
328 static CSSValue valueForNinePieceImage(const NinePieceImage& image, const Comput
edStyle& style) | 328 static CSSValue valueForNinePieceImage(const NinePieceImage& image, const Comput
edStyle& style) |
329 { | 329 { |
330 if (!image.hasImage()) | 330 if (!image.hasImage()) |
331 return cssValuePool().createIdentifierValue(CSSValueNone); | 331 return cssValuePool().createIdentifierValue(CSSValueNone); |
332 | 332 |
333 // Image first. | 333 // Image first. |
334 NullableCSSValue imageValue; | 334 NullableCSSValue imageValue; |
335 if (image.image()) | 335 if (image.image()) |
(...skipping 12 matching lines...) Expand all Loading... |
348 CSSValue repeat = valueForNinePieceImageRepeat(image); | 348 CSSValue repeat = valueForNinePieceImageRepeat(image); |
349 | 349 |
350 return createBorderImageValue(imageValue, imageSlices, borderSlices, outset,
repeat); | 350 return createBorderImageValue(imageValue, imageSlices, borderSlices, outset,
repeat); |
351 } | 351 } |
352 | 352 |
353 static CSSValue valueForReflection(const StyleReflection* reflection, const Comp
utedStyle& style) | 353 static CSSValue valueForReflection(const StyleReflection* reflection, const Comp
utedStyle& style) |
354 { | 354 { |
355 if (!reflection) | 355 if (!reflection) |
356 return cssValuePool().createIdentifierValue(CSSValueNone); | 356 return cssValuePool().createIdentifierValue(CSSValueNone); |
357 | 357 |
358 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; | 358 NullableCSSValue offset; |
359 // TODO(alancutter): Make this work correctly for calc lengths. | 359 // TODO(alancutter): Make this work correctly for calc lengths. |
360 if (reflection->offset().hasPercent()) | 360 if (reflection->offset().hasPercent()) |
361 offset = cssValuePool().createValue(reflection->offset().percent(), CSSP
rimitiveValue::CSS_PERCENTAGE); | 361 offset = cssValuePool().createValue(reflection->offset().percent(), CSSP
rimitiveValue::CSS_PERCENTAGE); |
362 else | 362 else |
363 offset = zoomAdjustedPixelValue(reflection->offset().value(), style); | 363 offset = zoomAdjustedPixelValue(reflection->offset().value(), style); |
364 | 364 |
365 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; | 365 NullableCSSValue direction; |
366 switch (reflection->direction()) { | 366 switch (reflection->direction()) { |
367 case ReflectionBelow: | 367 case ReflectionBelow: |
368 direction = cssValuePool().createIdentifierValue(CSSValueBelow); | 368 direction = cssValuePool().createIdentifierValue(CSSValueBelow); |
369 break; | 369 break; |
370 case ReflectionAbove: | 370 case ReflectionAbove: |
371 direction = cssValuePool().createIdentifierValue(CSSValueAbove); | 371 direction = cssValuePool().createIdentifierValue(CSSValueAbove); |
372 break; | 372 break; |
373 case ReflectionLeft: | 373 case ReflectionLeft: |
374 direction = cssValuePool().createIdentifierValue(CSSValueLeft); | 374 direction = cssValuePool().createIdentifierValue(CSSValueLeft); |
375 break; | 375 break; |
376 case ReflectionRight: | 376 case ReflectionRight: |
377 direction = cssValuePool().createIdentifierValue(CSSValueRight); | 377 direction = cssValuePool().createIdentifierValue(CSSValueRight); |
378 break; | 378 break; |
379 } | 379 } |
380 | 380 |
381 return CSSReflectValue::create(direction.release(), offset.release(), valueF
orNinePieceImage(reflection->mask(), style)); | 381 return CSSReflectValue::create(toCSSPrimitiveValue(*direction), toCSSPrimiti
veValue(*offset), valueForNinePieceImage(reflection->mask(), style)); |
382 } | 382 } |
383 | 383 |
384 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) | 384 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) |
385 { | 385 { |
386 if (position != ItemPositionAuto) | 386 if (position != ItemPositionAuto) |
387 return position; | 387 return position; |
388 | 388 |
389 return isFlexOrGrid(element) ? ItemPositionStretch : ItemPositionStart; | 389 return isFlexOrGrid(element) ? ItemPositionStretch : ItemPositionStart; |
390 } | 390 } |
391 | 391 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 { | 425 { |
426 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); | 426 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); |
427 const FillLayer* currLayer = &style.backgroundLayers(); | 427 const FillLayer* currLayer = &style.backgroundLayers(); |
428 for (; currLayer; currLayer = currLayer->next()) { | 428 for (; currLayer; currLayer = currLayer->next()) { |
429 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparat
ed(); | 429 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparat
ed(); |
430 RefPtrWillBeRawPtr<CSSValueList> beforeSlash = CSSValueList::createSpace
Separated(); | 430 RefPtrWillBeRawPtr<CSSValueList> beforeSlash = CSSValueList::createSpace
Separated(); |
431 if (!currLayer->next()) { // color only for final layer | 431 if (!currLayer->next()) { // color only for final layer |
432 NullableCSSValue value = ComputedStyleCSSValueMapping::get(CSSProper
tyBackgroundColor, style, layoutObject, styledNode, allowVisitedStyle); | 432 NullableCSSValue value = ComputedStyleCSSValueMapping::get(CSSProper
tyBackgroundColor, style, layoutObject, styledNode, allowVisitedStyle); |
433 beforeSlash->append(*value); | 433 beforeSlash->append(*value); |
434 } | 434 } |
435 beforeSlash->append(currLayer->image() ? *currLayer->image()->cssValue()
: cssValuePool().createIdentifierValue(CSSValueNone)); | 435 beforeSlash->append(currLayer->image() ? *currLayer->image()->cssValue()
: CSSValue(cssValuePool().createIdentifierValue(CSSValueNone))); |
436 beforeSlash->append(valueForFillRepeat(currLayer->repeatX(), currLayer->
repeatY())); | 436 beforeSlash->append(valueForFillRepeat(currLayer->repeatX(), currLayer->
repeatY())); |
437 beforeSlash->append(cssValuePool().createValue(currLayer->attachment()))
; | 437 beforeSlash->append(cssValuePool().createValue(currLayer->attachment()))
; |
438 beforeSlash->append(createPositionListForLayer(CSSPropertyBackgroundPosi
tion, *currLayer, style)); | 438 beforeSlash->append(createPositionListForLayer(CSSPropertyBackgroundPosi
tion, *currLayer, style)); |
439 list->append(beforeSlash); | 439 list->append(beforeSlash); |
440 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS
eparated(); | 440 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS
eparated(); |
441 afterSlash->append(valueForFillSize(currLayer->size(), style)); | 441 afterSlash->append(valueForFillSize(currLayer->size(), style)); |
442 afterSlash->append(cssValuePool().createValue(currLayer->origin())); | 442 afterSlash->append(cssValuePool().createValue(currLayer->origin())); |
443 afterSlash->append(cssValuePool().createValue(currLayer->clip())); | 443 afterSlash->append(cssValuePool().createValue(currLayer->clip())); |
444 list->append(afterSlash); | 444 list->append(afterSlash); |
445 ret->append(list); | 445 ret->append(list); |
(...skipping 19 matching lines...) Expand all Loading... |
465 result->append(CSSPrimitiveValue::create(distribution)); | 465 result->append(CSSPrimitiveValue::create(distribution)); |
466 if (distribution == ContentDistributionDefault || position != ContentPositio
nAuto) | 466 if (distribution == ContentDistributionDefault || position != ContentPositio
nAuto) |
467 result->append(CSSPrimitiveValue::create(position)); | 467 result->append(CSSPrimitiveValue::create(position)); |
468 if ((position >= ContentPositionCenter || distribution != ContentDistributio
nDefault) && overflowAlignment != OverflowAlignmentDefault) | 468 if ((position >= ContentPositionCenter || distribution != ContentDistributio
nDefault) && overflowAlignment != OverflowAlignmentDefault) |
469 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 469 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
470 ASSERT(result->length() > 0); | 470 ASSERT(result->length() > 0); |
471 ASSERT(result->length() <= 3); | 471 ASSERT(result->length() <= 3); |
472 return result.release(); | 472 return result.release(); |
473 } | 473 } |
474 | 474 |
475 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForLineHeight(const Comput
edStyle& style) | 475 static CSSPrimitiveValue valueForLineHeight(const ComputedStyle& style) |
476 { | 476 { |
477 Length length = style.lineHeight(); | 477 Length length = style.lineHeight(); |
478 if (length.isNegative()) | 478 if (length.isNegative()) |
479 return cssValuePool().createIdentifierValue(CSSValueNormal); | 479 return cssValuePool().createIdentifierValue(CSSValueNormal); |
480 | 480 |
481 return zoomAdjustedPixelValue(floatValueForLength(length, style.fontDescript
ion().specifiedSize()), style); | 481 return zoomAdjustedPixelValue(floatValueForLength(length, style.fontDescript
ion().specifiedSize()), style); |
482 } | 482 } |
483 | 483 |
484 static CSSValueID identifierForFamily(const AtomicString& family) | 484 static CSSValueID identifierForFamily(const AtomicString& family) |
485 { | 485 { |
486 if (family == FontFamilyNames::webkit_cursive) | 486 if (family == FontFamilyNames::webkit_cursive) |
487 return CSSValueCursive; | 487 return CSSValueCursive; |
488 if (family == FontFamilyNames::webkit_fantasy) | 488 if (family == FontFamilyNames::webkit_fantasy) |
489 return CSSValueFantasy; | 489 return CSSValueFantasy; |
490 if (family == FontFamilyNames::webkit_monospace) | 490 if (family == FontFamilyNames::webkit_monospace) |
491 return CSSValueMonospace; | 491 return CSSValueMonospace; |
492 if (family == FontFamilyNames::webkit_pictograph) | 492 if (family == FontFamilyNames::webkit_pictograph) |
493 return CSSValueWebkitPictograph; | 493 return CSSValueWebkitPictograph; |
494 if (family == FontFamilyNames::webkit_sans_serif) | 494 if (family == FontFamilyNames::webkit_sans_serif) |
495 return CSSValueSansSerif; | 495 return CSSValueSansSerif; |
496 if (family == FontFamilyNames::webkit_serif) | 496 if (family == FontFamilyNames::webkit_serif) |
497 return CSSValueSerif; | 497 return CSSValueSerif; |
498 return CSSValueInvalid; | 498 return CSSValueInvalid; |
499 } | 499 } |
500 | 500 |
501 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFamily(const AtomicStri
ng& family) | 501 static CSSPrimitiveValue valueForFamily(const AtomicString& family) |
502 { | 502 { |
503 if (CSSValueID familyIdentifier = identifierForFamily(family)) | 503 if (CSSValueID familyIdentifier = identifierForFamily(family)) |
504 return cssValuePool().createIdentifierValue(familyIdentifier); | 504 return cssValuePool().createIdentifierValue(familyIdentifier); |
505 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_CU
STOM_IDENT); | 505 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_CU
STOM_IDENT); |
506 } | 506 } |
507 | 507 |
508 static PassRefPtrWillBeRawPtr<CSSValueList> valueForFontFamily(const ComputedSty
le& style) | 508 static PassRefPtrWillBeRawPtr<CSSValueList> valueForFontFamily(const ComputedSty
le& style) |
509 { | 509 { |
510 const FontFamily& firstFamily = style.fontDescription().family(); | 510 const FontFamily& firstFamily = style.fontDescription().family(); |
511 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 511 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
512 for (const FontFamily* family = &firstFamily; family; family = family->next(
)) | 512 for (const FontFamily* family = &firstFamily; family; family = family->next(
)) |
513 list->append(valueForFamily(family->family())); | 513 list->append(valueForFamily(family->family())); |
514 return list.release(); | 514 return list.release(); |
515 } | 515 } |
516 | 516 |
517 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontSize(const Computed
Style& style) | 517 static CSSPrimitiveValue valueForFontSize(const ComputedStyle& style) |
518 { | 518 { |
519 return zoomAdjustedPixelValue(style.fontDescription().computedSize(), style)
; | 519 return zoomAdjustedPixelValue(style.fontDescription().computedSize(), style)
; |
520 } | 520 } |
521 | 521 |
522 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontStretch(const Compu
tedStyle& style) | 522 static CSSPrimitiveValue valueForFontStretch(const ComputedStyle& style) |
523 { | 523 { |
524 return cssValuePool().createValue(style.fontDescription().stretch()); | 524 return cssValuePool().createValue(style.fontDescription().stretch()); |
525 } | 525 } |
526 | 526 |
527 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontStyle(const Compute
dStyle& style) | 527 static CSSPrimitiveValue valueForFontStyle(const ComputedStyle& style) |
528 { | 528 { |
529 return cssValuePool().createValue(style.fontDescription().style()); | 529 return cssValuePool().createValue(style.fontDescription().style()); |
530 } | 530 } |
531 | 531 |
532 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontVariant(const Compu
tedStyle& style) | 532 static CSSPrimitiveValue valueForFontVariant(const ComputedStyle& style) |
533 { | 533 { |
534 return cssValuePool().createValue(style.fontDescription().variant()); | 534 return cssValuePool().createValue(style.fontDescription().variant()); |
535 } | 535 } |
536 | 536 |
537 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontWeight(const Comput
edStyle& style) | 537 static CSSPrimitiveValue valueForFontWeight(const ComputedStyle& style) |
538 { | 538 { |
539 return cssValuePool().createValue(style.fontDescription().weight()); | 539 return cssValuePool().createValue(style.fontDescription().weight()); |
540 } | 540 } |
541 | 541 |
542 static CSSValue specifiedValueForGridTrackBreadth(const GridLength& trackBreadth
, const ComputedStyle& style) | 542 static CSSValue specifiedValueForGridTrackBreadth(const GridLength& trackBreadth
, const ComputedStyle& style) |
543 { | 543 { |
544 if (!trackBreadth.isLength()) | 544 if (!trackBreadth.isLength()) |
545 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue
::CSS_FR); | 545 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue
::CSS_FR); |
546 | 546 |
547 const Length& trackBreadthLength = trackBreadth.length(); | 547 const Length& trackBreadthLength = trackBreadth.length(); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 return CSSValueInvalid; | 1008 return CSSValueInvalid; |
1009 } | 1009 } |
1010 | 1010 |
1011 static CSSValue valueForContentData(const ComputedStyle& style) | 1011 static CSSValue valueForContentData(const ComputedStyle& style) |
1012 { | 1012 { |
1013 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 1013 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
1014 for (const ContentData* contentData = style.contentData(); contentData; cont
entData = contentData->next()) { | 1014 for (const ContentData* contentData = style.contentData(); contentData; cont
entData = contentData->next()) { |
1015 if (contentData->isCounter()) { | 1015 if (contentData->isCounter()) { |
1016 const CounterContent* counter = toCounterContentData(contentData)->c
ounter(); | 1016 const CounterContent* counter = toCounterContentData(contentData)->c
ounter(); |
1017 ASSERT(counter); | 1017 ASSERT(counter); |
1018 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = cssValuePool().cr
eateValue(counter->identifier(), CSSPrimitiveValue::CSS_CUSTOM_IDENT); | 1018 CSSPrimitiveValue identifier = cssValuePool().createValue(counter->i
dentifier(), CSSPrimitiveValue::CSS_CUSTOM_IDENT); |
1019 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = cssValuePool().cre
ateValue(counter->separator(), CSSPrimitiveValue::CSS_CUSTOM_IDENT); | 1019 CSSPrimitiveValue separator = cssValuePool().createValue(counter->se
parator(), CSSPrimitiveValue::CSS_CUSTOM_IDENT); |
1020 CSSValueID listStyleIdent = CSSValueNone; | 1020 CSSValueID listStyleIdent = CSSValueNone; |
1021 if (counter->listStyle() != NoneListStyle) | 1021 if (counter->listStyle() != NoneListStyle) |
1022 listStyleIdent = static_cast<CSSValueID>(CSSValueDisc + counter-
>listStyle()); | 1022 listStyleIdent = static_cast<CSSValueID>(CSSValueDisc + counter-
>listStyle()); |
1023 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle = cssValuePool().cre
ateIdentifierValue(listStyleIdent); | 1023 CSSPrimitiveValue listStyle = cssValuePool().createIdentifierValue(l
istStyleIdent); |
1024 list->append(cssValuePool().createValue(Counter::create(identifier.r
elease(), listStyle.release(), separator.release()))); | 1024 list->append(cssValuePool().createValue(Counter::create(identifier,
listStyle, separator))); |
1025 } else if (contentData->isImage()) { | 1025 } else if (contentData->isImage()) { |
1026 const StyleImage* image = toImageContentData(contentData)->image(); | 1026 const StyleImage* image = toImageContentData(contentData)->image(); |
1027 ASSERT(image); | 1027 ASSERT(image); |
1028 list->append(*image->cssValue()); | 1028 list->append(*image->cssValue()); |
1029 } else if (contentData->isText()) { | 1029 } else if (contentData->isText()) { |
1030 list->append(cssValuePool().createValue(toTextContentData(contentDat
a)->text(), CSSPrimitiveValue::CSS_STRING)); | 1030 list->append(cssValuePool().createValue(toTextContentData(contentDat
a)->text(), CSSPrimitiveValue::CSS_STRING)); |
1031 } else if (contentData->isQuote()) { | 1031 } else if (contentData->isQuote()) { |
1032 const QuoteType quoteType = toQuoteContentData(contentData)->quote()
; | 1032 const QuoteType quoteType = toQuoteContentData(contentData)->quote()
; |
1033 list->append(cssValuePool().createIdentifierValue(valueForQuoteType(
quoteType))); | 1033 list->append(cssValuePool().createIdentifierValue(valueForQuoteType(
quoteType))); |
1034 } else { | 1034 } else { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 verticalRadii->append(bottomRightRadius->item(1)); | 1146 verticalRadii->append(bottomRightRadius->item(1)); |
1147 if (showVerticalBottomLeft) | 1147 if (showVerticalBottomLeft) |
1148 verticalRadii->append(bottomLeftRadius->item(1)); | 1148 verticalRadii->append(bottomLeftRadius->item(1)); |
1149 | 1149 |
1150 if (!verticalRadii->equals(toCSSValueList(list->item(0)))) | 1150 if (!verticalRadii->equals(toCSSValueList(list->item(0)))) |
1151 list->append(verticalRadii.release()); | 1151 list->append(verticalRadii.release()); |
1152 | 1152 |
1153 return list.release(); | 1153 return list.release(); |
1154 } | 1154 } |
1155 | 1155 |
1156 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveV
alue(EGlyphOrientation orientation) | 1156 static NullableCSSValue glyphOrientationToCSSPrimitiveValue(EGlyphOrientation or
ientation) |
1157 { | 1157 { |
1158 switch (orientation) { | 1158 switch (orientation) { |
1159 case GO_0DEG: | 1159 case GO_0DEG: |
1160 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); | 1160 return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG); |
1161 case GO_90DEG: | 1161 case GO_90DEG: |
1162 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); | 1162 return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG); |
1163 case GO_180DEG: | 1163 case GO_180DEG: |
1164 return CSSPrimitiveValue::create(180.0f, CSSPrimitiveValue::CSS_DEG); | 1164 return CSSPrimitiveValue::create(180.0f, CSSPrimitiveValue::CSS_DEG); |
1165 case GO_270DEG: | 1165 case GO_270DEG: |
1166 return CSSPrimitiveValue::create(270.0f, CSSPrimitiveValue::CSS_DEG); | 1166 return CSSPrimitiveValue::create(270.0f, CSSPrimitiveValue::CSS_DEG); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 return CSSPrimitiveValue::createColor(color.rgb()); | 1223 return CSSPrimitiveValue::createColor(color.rgb()); |
1224 } | 1224 } |
1225 | 1225 |
1226 static inline String serializeAsFragmentIdentifier(const AtomicString& resource) | 1226 static inline String serializeAsFragmentIdentifier(const AtomicString& resource) |
1227 { | 1227 { |
1228 return "#" + resource; | 1228 return "#" + resource; |
1229 } | 1229 } |
1230 | 1230 |
1231 CSSValue ComputedStyleCSSValueMapping::valueForShadowData(const ShadowData& shad
ow, const ComputedStyle& style, bool useSpread) | 1231 CSSValue ComputedStyleCSSValueMapping::valueForShadowData(const ShadowData& shad
ow, const ComputedStyle& style, bool useSpread) |
1232 { | 1232 { |
1233 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(shadow.x(),
style); | 1233 CSSPrimitiveValue x = zoomAdjustedPixelValue(shadow.x(), style); |
1234 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(shadow.y(),
style); | 1234 CSSPrimitiveValue y = zoomAdjustedPixelValue(shadow.y(), style); |
1235 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(shadow.b
lur(), style); | 1235 CSSPrimitiveValue blur = zoomAdjustedPixelValue(shadow.blur(), style); |
1236 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = useSpread ? zoomAdjustedPixel
Value(shadow.spread(), style) : PassRefPtrWillBeRawPtr<CSSPrimitiveValue>(nullpt
r); | 1236 NullableCSSValue spread = useSpread ? NullableCSSValue(zoomAdjustedPixelValu
e(shadow.spread(), style)) : nullptr; |
1237 RefPtrWillBeRawPtr<CSSPrimitiveValue> shadowStyle = shadow.style() == Normal
? PassRefPtrWillBeRawPtr<CSSPrimitiveValue>(nullptr) : cssValuePool().createIde
ntifierValue(CSSValueInset); | 1237 NullableCSSValue shadowStyle = shadow.style() == Normal ? nullptr : Nullable
CSSValue(cssValuePool().createIdentifierValue(CSSValueInset)); |
1238 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = currentColorOrValidColor(style
, shadow.color()); | 1238 CSSPrimitiveValue color = currentColorOrValidColor(style, shadow.color()); |
1239 return CSSShadowValue::create(x.release(), y.release(), blur.release(), spre
ad.release(), shadowStyle.release(), color.release()); | 1239 return CSSShadowValue::create(x, y, blur, spread, shadowStyle, color); |
1240 } | 1240 } |
1241 | 1241 |
1242 CSSValue ComputedStyleCSSValueMapping::valueForShadowList(const ShadowList* shad
owList, const ComputedStyle& style, bool useSpread) | 1242 CSSValue ComputedStyleCSSValueMapping::valueForShadowList(const ShadowList* shad
owList, const ComputedStyle& style, bool useSpread) |
1243 { | 1243 { |
1244 if (!shadowList) | 1244 if (!shadowList) |
1245 return cssValuePool().createIdentifierValue(CSSValueNone); | 1245 return cssValuePool().createIdentifierValue(CSSValueNone); |
1246 | 1246 |
1247 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 1247 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
1248 size_t shadowCount = shadowList->shadows().size(); | 1248 size_t shadowCount = shadowList->shadows().size(); |
1249 for (size_t i = 0; i < shadowCount; ++i) | 1249 for (size_t i = 0; i < shadowCount; ++i) |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 return zoomAdjustedPixelValueForLength(svgStyle.baselineShiftValue()
, style); | 2601 return zoomAdjustedPixelValueForLength(svgStyle.baselineShiftValue()
, style); |
2602 } | 2602 } |
2603 ASSERT_NOT_REACHED(); | 2603 ASSERT_NOT_REACHED(); |
2604 return nullptr; | 2604 return nullptr; |
2605 } | 2605 } |
2606 case CSSPropertyBufferedRendering: | 2606 case CSSPropertyBufferedRendering: |
2607 return CSSPrimitiveValue::create(svgStyle.bufferedRendering()); | 2607 return CSSPrimitiveValue::create(svgStyle.bufferedRendering()); |
2608 case CSSPropertyGlyphOrientationHorizontal: | 2608 case CSSPropertyGlyphOrientationHorizontal: |
2609 return glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationHori
zontal()); | 2609 return glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationHori
zontal()); |
2610 case CSSPropertyGlyphOrientationVertical: { | 2610 case CSSPropertyGlyphOrientationVertical: { |
2611 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> value = glyphOrientationToCSSP
rimitiveValue(svgStyle.glyphOrientationVertical())) | 2611 if (NullableCSSValue value = glyphOrientationToCSSPrimitiveValue(svgStyl
e.glyphOrientationVertical())) |
2612 return value.release(); | 2612 return value; |
2613 if (svgStyle.glyphOrientationVertical() == GO_AUTO) | 2613 if (svgStyle.glyphOrientationVertical() == GO_AUTO) |
2614 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); | 2614 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
2615 return nullptr; | 2615 return nullptr; |
2616 } | 2616 } |
2617 case CSSPropertyPaintOrder: | 2617 case CSSPropertyPaintOrder: |
2618 return paintOrderToCSSValueList(svgStyle.paintOrder()); | 2618 return paintOrderToCSSValueList(svgStyle.paintOrder()); |
2619 case CSSPropertyVectorEffect: | 2619 case CSSPropertyVectorEffect: |
2620 return CSSPrimitiveValue::create(svgStyle.vectorEffect()); | 2620 return CSSPrimitiveValue::create(svgStyle.vectorEffect()); |
2621 case CSSPropertyMaskType: | 2621 case CSSPropertyMaskType: |
2622 return CSSPrimitiveValue::create(svgStyle.maskType()); | 2622 return CSSPrimitiveValue::create(svgStyle.maskType()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 case CSSPropertyAll: | 2701 case CSSPropertyAll: |
2702 return nullptr; | 2702 return nullptr; |
2703 default: | 2703 default: |
2704 break; | 2704 break; |
2705 } | 2705 } |
2706 ASSERT_NOT_REACHED(); | 2706 ASSERT_NOT_REACHED(); |
2707 return nullptr; | 2707 return nullptr; |
2708 } | 2708 } |
2709 | 2709 |
2710 } | 2710 } |
OLD | NEW |