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.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include "core/css/CSSComputedStyleDeclaration.h"
27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/CSSPropertyNames.h"
29 #include "core/StylePropertyShorthand.h"
30 #include "core/animation/DocumentAnimations.h"
31 #include "core/css/BasicShapeFunctions.h"
32 #include "core/css/CSSAspectRatioValue.h"
33 #include "core/css/CSSBorderImage.h"
34 #include "core/css/CSSFilterValue.h"
35 #include "core/css/CSSFontFeatureValue.h"
36 #include "core/css/CSSFontValue.h"
37 #include "core/css/CSSFunctionValue.h"
38 #include "core/css/CSSGridLineNamesValue.h"
39 #include "core/css/CSSGridTemplateAreasValue.h"
40 #include "core/css/CSSLineBoxContainValue.h"
41 #include "core/css/parser/BisonCSSParser.h"
42 #include "core/css/CSSPrimitiveValue.h"
43 #include "core/css/CSSPrimitiveValueMappings.h"
44 #include "core/css/CSSReflectValue.h"
45 #include "core/css/CSSSelector.h"
46 #include "core/css/CSSShadowValue.h"
47 #include "core/css/CSSTimingFunctionValue.h"
48 #include "core/css/CSSTransformValue.h"
49 #include "core/css/CSSValueList.h"
50 #include "core/css/CSSValuePool.h"
51 #include "core/css/Pair.h"
52 #include "core/css/Rect.h"
53 #include "core/css/RuntimeCSSEnabled.h"
54 #include "core/css/StylePropertySet.h"
55 #include "core/css/resolver/StyleResolver.h"
56 #include "core/dom/Document.h"
57 #include "core/dom/ExceptionCode.h"
58 #include "core/dom/PseudoElement.h"
59 #include "core/rendering/RenderBox.h"
60 #include "core/rendering/RenderGrid.h"
61 #include "core/rendering/style/ContentData.h"
62 #include "core/rendering/style/CounterContent.h"
63 #include "core/rendering/style/RenderStyle.h"
64 #include "core/rendering/style/ShadowList.h"
65 #include "core/rendering/style/ShapeValue.h"
66 #include "platform/FontFamilyNames.h"
67 #include "platform/RuntimeEnabledFeatures.h"
68 #include "platform/fonts/FontFeatureSettings.h"
69 #include "wtf/text/StringBuilder.h"
73 // List of all properties we know how to compute, omitting shorthands.
74 // NOTE: Do not use this list, use computableProperties() instead
75 // to respect runtime enabling of CSS properties.
76 static const CSSPropertyID staticComputableProperties[] = {
77 CSSPropertyAnimationDelay,
78 CSSPropertyAnimationDirection,
79 CSSPropertyAnimationDuration,
80 CSSPropertyAnimationFillMode,
81 CSSPropertyAnimationIterationCount,
82 CSSPropertyAnimationName,
83 CSSPropertyAnimationPlayState,
84 CSSPropertyAnimationTimingFunction,
85 CSSPropertyBackgroundAttachment,
86 CSSPropertyBackgroundBlendMode,
87 CSSPropertyBackgroundClip,
88 CSSPropertyBackgroundColor,
89 CSSPropertyBackgroundImage,
90 CSSPropertyBackgroundOrigin,
91 CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
92 CSSPropertyBackgroundRepeat,
93 CSSPropertyBackgroundSize,
94 CSSPropertyBorderBottomColor,
95 CSSPropertyBorderBottomLeftRadius,
96 CSSPropertyBorderBottomRightRadius,
97 CSSPropertyBorderBottomStyle,
98 CSSPropertyBorderBottomWidth,
99 CSSPropertyBorderCollapse,
100 CSSPropertyBorderImageOutset,
101 CSSPropertyBorderImageRepeat,
102 CSSPropertyBorderImageSlice,
103 CSSPropertyBorderImageSource,
104 CSSPropertyBorderImageWidth,
105 CSSPropertyBorderLeftColor,
106 CSSPropertyBorderLeftStyle,
107 CSSPropertyBorderLeftWidth,
108 CSSPropertyBorderRightColor,
109 CSSPropertyBorderRightStyle,
110 CSSPropertyBorderRightWidth,
111 CSSPropertyBorderTopColor,
112 CSSPropertyBorderTopLeftRadius,
113 CSSPropertyBorderTopRightRadius,
114 CSSPropertyBorderTopStyle,
115 CSSPropertyBorderTopWidth,
117 CSSPropertyBoxShadow,
118 CSSPropertyBoxSizing,
119 CSSPropertyCaptionSide,
124 CSSPropertyDirection,
126 CSSPropertyEmptyCells,
128 CSSPropertyFontFamily,
129 CSSPropertyFontKerning,
131 CSSPropertyFontStretch,
132 CSSPropertyFontStyle,
133 CSSPropertyFontVariant,
134 CSSPropertyFontVariantLigatures,
135 CSSPropertyFontWeight,
137 CSSPropertyImageRendering,
138 CSSPropertyIsolation,
139 CSSPropertyJustifyItems,
140 CSSPropertyJustifySelf,
142 CSSPropertyLetterSpacing,
143 CSSPropertyLineHeight,
144 CSSPropertyListStyleImage,
145 CSSPropertyListStylePosition,
146 CSSPropertyListStyleType,
147 CSSPropertyMarginBottom,
148 CSSPropertyMarginLeft,
149 CSSPropertyMarginRight,
150 CSSPropertyMarginTop,
151 CSSPropertyMaxHeight,
153 CSSPropertyMinHeight,
155 CSSPropertyMixBlendMode,
156 CSSPropertyObjectFit,
157 CSSPropertyObjectPosition,
160 CSSPropertyOutlineColor,
161 CSSPropertyOutlineOffset,
162 CSSPropertyOutlineStyle,
163 CSSPropertyOutlineWidth,
164 CSSPropertyOverflowWrap,
165 CSSPropertyOverflowX,
166 CSSPropertyOverflowY,
167 CSSPropertyPaddingBottom,
168 CSSPropertyPaddingLeft,
169 CSSPropertyPaddingRight,
170 CSSPropertyPaddingTop,
171 CSSPropertyPageBreakAfter,
172 CSSPropertyPageBreakBefore,
173 CSSPropertyPageBreakInside,
174 CSSPropertyPointerEvents,
178 CSSPropertyScrollBehavior,
180 CSSPropertyTableLayout,
182 CSSPropertyTextAlign,
183 CSSPropertyTextAlignLast,
184 CSSPropertyTextDecoration,
185 CSSPropertyTextDecorationLine,
186 CSSPropertyTextDecorationStyle,
187 CSSPropertyTextDecorationColor,
188 CSSPropertyTextJustify,
189 CSSPropertyTextUnderlinePosition,
190 CSSPropertyTextIndent,
191 CSSPropertyTextRendering,
192 CSSPropertyTextShadow,
193 CSSPropertyTextOverflow,
194 CSSPropertyTextTransform,
196 CSSPropertyTouchAction,
197 CSSPropertyTouchActionDelay,
198 CSSPropertyTransitionDelay,
199 CSSPropertyTransitionDuration,
200 CSSPropertyTransitionProperty,
201 CSSPropertyTransitionTimingFunction,
202 CSSPropertyUnicodeBidi,
203 CSSPropertyVerticalAlign,
204 CSSPropertyVisibility,
205 CSSPropertyWhiteSpace,
208 CSSPropertyWillChange,
209 CSSPropertyWordBreak,
210 CSSPropertyWordSpacing,
215 CSSPropertyWebkitAnimationDelay,
216 CSSPropertyWebkitAnimationDirection,
217 CSSPropertyWebkitAnimationDuration,
218 CSSPropertyWebkitAnimationFillMode,
219 CSSPropertyWebkitAnimationIterationCount,
220 CSSPropertyWebkitAnimationName,
221 CSSPropertyWebkitAnimationPlayState,
222 CSSPropertyWebkitAnimationTimingFunction,
223 CSSPropertyWebkitAppearance,
224 CSSPropertyBackfaceVisibility,
225 CSSPropertyWebkitBackfaceVisibility,
226 CSSPropertyWebkitBackgroundClip,
227 CSSPropertyWebkitBackgroundComposite,
228 CSSPropertyWebkitBackgroundOrigin,
229 CSSPropertyWebkitBackgroundSize,
230 CSSPropertyWebkitBorderFit,
231 CSSPropertyWebkitBorderHorizontalSpacing,
232 CSSPropertyWebkitBorderImage,
233 CSSPropertyWebkitBorderVerticalSpacing,
234 CSSPropertyWebkitBoxAlign,
235 CSSPropertyWebkitBoxDecorationBreak,
236 CSSPropertyWebkitBoxDirection,
237 CSSPropertyWebkitBoxFlex,
238 CSSPropertyWebkitBoxFlexGroup,
239 CSSPropertyWebkitBoxLines,
240 CSSPropertyWebkitBoxOrdinalGroup,
241 CSSPropertyWebkitBoxOrient,
242 CSSPropertyWebkitBoxPack,
243 CSSPropertyWebkitBoxReflect,
244 CSSPropertyWebkitBoxShadow,
245 CSSPropertyWebkitClipPath,
246 CSSPropertyWebkitColumnBreakAfter,
247 CSSPropertyWebkitColumnBreakBefore,
248 CSSPropertyWebkitColumnBreakInside,
249 CSSPropertyWebkitColumnCount,
250 CSSPropertyWebkitColumnGap,
251 CSSPropertyWebkitColumnRuleColor,
252 CSSPropertyWebkitColumnRuleStyle,
253 CSSPropertyWebkitColumnRuleWidth,
254 CSSPropertyWebkitColumnSpan,
255 CSSPropertyWebkitColumnWidth,
256 CSSPropertyWebkitFilter,
257 CSSPropertyAlignContent,
258 CSSPropertyAlignItems,
259 CSSPropertyAlignSelf,
260 CSSPropertyFlexBasis,
262 CSSPropertyFlexShrink,
263 CSSPropertyFlexDirection,
265 CSSPropertyJustifyContent,
266 CSSPropertyWebkitFontSmoothing,
267 CSSPropertyGridAutoColumns,
268 CSSPropertyGridAutoFlow,
269 CSSPropertyGridAutoRows,
270 CSSPropertyGridColumnEnd,
271 CSSPropertyGridColumnStart,
272 CSSPropertyGridTemplateAreas,
273 CSSPropertyGridTemplateColumns,
274 CSSPropertyGridTemplateRows,
275 CSSPropertyGridRowEnd,
276 CSSPropertyGridRowStart,
277 CSSPropertyWebkitHighlight,
278 CSSPropertyWebkitHyphenateCharacter,
279 CSSPropertyWebkitLineBoxContain,
280 CSSPropertyWebkitLineBreak,
281 CSSPropertyWebkitLineClamp,
282 CSSPropertyWebkitLocale,
283 CSSPropertyWebkitMarginBeforeCollapse,
284 CSSPropertyWebkitMarginAfterCollapse,
285 CSSPropertyWebkitMaskBoxImage,
286 CSSPropertyWebkitMaskBoxImageOutset,
287 CSSPropertyWebkitMaskBoxImageRepeat,
288 CSSPropertyWebkitMaskBoxImageSlice,
289 CSSPropertyWebkitMaskBoxImageSource,
290 CSSPropertyWebkitMaskBoxImageWidth,
291 CSSPropertyWebkitMaskClip,
292 CSSPropertyWebkitMaskComposite,
293 CSSPropertyWebkitMaskImage,
294 CSSPropertyWebkitMaskOrigin,
295 CSSPropertyWebkitMaskPosition,
296 CSSPropertyWebkitMaskRepeat,
297 CSSPropertyWebkitMaskSize,
299 CSSPropertyPerspective,
300 CSSPropertyWebkitPerspective,
301 CSSPropertyPerspectiveOrigin,
302 CSSPropertyWebkitPerspectiveOrigin,
303 CSSPropertyWebkitPrintColorAdjust,
304 CSSPropertyWebkitRtlOrdering,
305 CSSPropertyShapeOutside,
306 CSSPropertyShapeImageThreshold,
307 CSSPropertyShapeMargin,
308 CSSPropertyWebkitTapHighlightColor,
309 CSSPropertyWebkitTextCombine,
310 CSSPropertyWebkitTextDecorationsInEffect,
311 CSSPropertyWebkitTextEmphasisColor,
312 CSSPropertyWebkitTextEmphasisPosition,
313 CSSPropertyWebkitTextEmphasisStyle,
314 CSSPropertyWebkitTextFillColor,
315 CSSPropertyWebkitTextOrientation,
316 CSSPropertyWebkitTextSecurity,
317 CSSPropertyWebkitTextStrokeColor,
318 CSSPropertyWebkitTextStrokeWidth,
319 CSSPropertyTransform,
320 CSSPropertyWebkitTransform,
321 CSSPropertyTransformOrigin,
322 CSSPropertyWebkitTransformOrigin,
323 CSSPropertyTransformStyle,
324 CSSPropertyWebkitTransformStyle,
325 CSSPropertyWebkitTransitionDelay,
326 CSSPropertyWebkitTransitionDuration,
327 CSSPropertyWebkitTransitionProperty,
328 CSSPropertyWebkitTransitionTimingFunction,
329 CSSPropertyWebkitUserDrag,
330 CSSPropertyWebkitUserModify,
331 CSSPropertyWebkitUserSelect,
332 CSSPropertyWebkitWritingMode,
333 CSSPropertyWebkitAppRegion,
334 CSSPropertyBufferedRendering,
339 CSSPropertyFloodColor,
340 CSSPropertyFloodOpacity,
341 CSSPropertyLightingColor,
342 CSSPropertyStopColor,
343 CSSPropertyStopOpacity,
344 CSSPropertyColorInterpolation,
345 CSSPropertyColorInterpolationFilters,
346 CSSPropertyColorRendering,
348 CSSPropertyFillOpacity,
350 CSSPropertyMarkerEnd,
351 CSSPropertyMarkerMid,
352 CSSPropertyMarkerStart,
354 CSSPropertyMaskSourceType,
355 CSSPropertyShapeRendering,
357 CSSPropertyStrokeDasharray,
358 CSSPropertyStrokeDashoffset,
359 CSSPropertyStrokeLinecap,
360 CSSPropertyStrokeLinejoin,
361 CSSPropertyStrokeMiterlimit,
362 CSSPropertyStrokeOpacity,
363 CSSPropertyStrokeWidth,
364 CSSPropertyAlignmentBaseline,
365 CSSPropertyBaselineShift,
366 CSSPropertyDominantBaseline,
367 CSSPropertyTextAnchor,
368 CSSPropertyWritingMode,
369 CSSPropertyGlyphOrientationHorizontal,
370 CSSPropertyGlyphOrientationVertical,
371 CSSPropertyVectorEffect,
372 CSSPropertyPaintOrder
375 static const Vector<CSSPropertyID>& computableProperties()
377 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
378 if (properties.isEmpty())
379 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticComputableProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties);
383 static CSSValueID valueForRepeatRule(int rule)
386 case RepeatImageRule:
387 return CSSValueRepeat;
389 return CSSValueRound;
391 return CSSValueSpace;
393 return CSSValueStretch;
397 static PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
399 // Create the slices.
400 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = nullptr;
401 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = nullptr;
402 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = nullptr;
403 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = nullptr;
405 if (image.imageSlices().top().isPercent())
406 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
408 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
410 if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
411 && image.imageSlices().left() == image.imageSlices().top()) {
416 if (image.imageSlices().right().isPercent())
417 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
419 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
421 if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
425 if (image.imageSlices().bottom().isPercent())
426 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
428 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
430 if (image.imageSlices().left() == image.imageSlices().right())
433 if (image.imageSlices().left().isPercent())
434 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
436 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
441 RefPtrWillBeRawPtr<Quad> quad = Quad::create();
443 quad->setRight(right);
444 quad->setBottom(bottom);
447 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
450 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const BorderImageLengthBox& box, const RenderStyle& style)
452 // Create the slices.
453 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = nullptr;
454 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = nullptr;
455 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = nullptr;
456 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = nullptr;
458 if (box.top().isNumber())
459 top = cssValuePool().createValue(box.top().number(), CSSPrimitiveValue::CSS_NUMBER);
461 top = cssValuePool().createValue(box.top().length(), style);
463 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
468 if (box.right().isNumber())
469 right = cssValuePool().createValue(box.right().number(), CSSPrimitiveValue::CSS_NUMBER);
471 right = cssValuePool().createValue(box.right().length(), style);
473 if (box.bottom() == box.top() && box.right() == box.left()) {
477 if (box.bottom().isNumber())
478 bottom = cssValuePool().createValue(box.bottom().number(), CSSPrimitiveValue::CSS_NUMBER);
480 bottom = cssValuePool().createValue(box.bottom().length(), style);
482 if (box.left() == box.right())
485 if (box.left().isNumber())
486 left = cssValuePool().createValue(box.left().number(), CSSPrimitiveValue::CSS_NUMBER);
488 left = cssValuePool().createValue(box.left().length(), style);
493 RefPtrWillBeRawPtr<Quad> quad = Quad::create();
495 quad->setRight(right);
496 quad->setBottom(bottom);
499 return cssValuePool().createValue(quad.release());
502 static PassRefPtrWillBeRawPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
504 RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalRepeat = nullptr;
505 RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalRepeat = nullptr;
507 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
508 if (image.horizontalRule() == image.verticalRule())
509 verticalRepeat = horizontalRepeat;
511 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
512 return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release(), Pair::DropIdenticalValues));
515 static PassRefPtrWillBeRawPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image, const RenderStyle& style)
517 if (!image.hasImage())
518 return cssValuePool().createIdentifierValue(CSSValueNone);
521 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr;
523 imageValue = image.image()->cssValue();
525 // Create the image slice.
526 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
528 // Create the border area slices.
529 RefPtrWillBeRawPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices(), style);
531 // Create the border outset.
532 RefPtrWillBeRawPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset(), style);
534 // Create the repeat rules.
535 RefPtrWillBeRawPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
537 return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
540 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle& style)
542 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
545 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle& style)
547 return cssValuePool().createValue(value / style.effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
550 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle& style)
552 if (length.isFixed())
553 return zoomAdjustedPixelValue(length.value(), style);
554 return cssValuePool().createValue(length, style);
557 static PassRefPtrWillBeRawPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle& style)
560 return cssValuePool().createIdentifierValue(CSSValueNone);
562 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr;
563 if (reflection->offset().isPercent())
564 offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
566 offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
568 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr;
569 switch (reflection->direction()) {
570 case ReflectionBelow:
571 direction = cssValuePool().createIdentifierValue(CSSValueBelow);
573 case ReflectionAbove:
574 direction = cssValuePool().createIdentifierValue(CSSValueAbove);
577 direction = cssValuePool().createIdentifierValue(CSSValueLeft);
579 case ReflectionRight:
580 direction = cssValuePool().createIdentifierValue(CSSValueRight);
584 return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask(), style));
587 static PassRefPtrWillBeRawPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const RenderStyle& style)
589 RefPtrWillBeRawPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
590 if (layer.isBackgroundXOriginSet()) {
591 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
592 positionList->append(cssValuePool().createValue(layer.backgroundXOrigin()));
594 positionList->append(zoomAdjustedPixelValueForLength(layer.xPosition(), style));
595 if (layer.isBackgroundYOriginSet()) {
596 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
597 positionList->append(cssValuePool().createValue(layer.backgroundYOrigin()));
599 positionList->append(zoomAdjustedPixelValueForLength(layer.yPosition(), style));
600 return positionList.release();
603 static PassRefPtrWillBeRawPtr<CSSValue> valueForPositionOffset(RenderStyle& style, CSSPropertyID propertyID, const RenderObject* renderer)
606 switch (propertyID) {
607 case CSSPropertyLeft:
610 case CSSPropertyRight:
616 case CSSPropertyBottom:
623 if (l.isPercent() && renderer && renderer->isBox()) {
624 LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight) ?
625 toRenderBox(renderer)->containingBlockLogicalWidthForContent() :
626 toRenderBox(renderer)->containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
627 return zoomAdjustedPixelValue(valueForLength(l, containingBlockSize), style);
630 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
631 // In other words if left is auto and right is not auto, then left's computed value is negative right().
632 // So we should get the opposite length unit and see if it is auto.
633 return cssValuePool().createIdentifierValue(CSSValueAuto);
636 return zoomAdjustedPixelValueForLength(l, style);
639 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(const RenderStyle& style, const StyleColor& color) const
641 // This function does NOT look at visited information, so that computed style doesn't expose that.
642 return cssValuePool().createColorValue(color.resolve(style.color()).rgb());
645 static PassRefPtrWillBeRawPtr<CSSValueList> valuesForBorderRadiusCorner(LengthSize radius, const RenderStyle& style)
647 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
648 if (radius.width().type() == Percent)
649 list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
651 list->append(zoomAdjustedPixelValueForLength(radius.width(), style));
652 if (radius.height().type() == Percent)
653 list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
655 list->append(zoomAdjustedPixelValueForLength(radius.height(), style));
656 return list.release();
659 static PassRefPtrWillBeRawPtr<CSSValue> valueForBorderRadiusCorner(LengthSize radius, const RenderStyle& style)
661 RefPtrWillBeRawPtr<CSSValueList> list = valuesForBorderRadiusCorner(radius, style);
662 if (list->item(0)->equals(*list->item(1)))
663 return list->item(0);
664 return list.release();
667 static PassRefPtrWillBeRawPtr<CSSValueList> valueForBorderRadiusShorthand(const RenderStyle& style)
669 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
671 bool showHorizontalBottomLeft = style.borderTopRightRadius().width() != style.borderBottomLeftRadius().width();
672 bool showHorizontalBottomRight = showHorizontalBottomLeft || (style.borderBottomRightRadius().width() != style.borderTopLeftRadius().width());
673 bool showHorizontalTopRight = showHorizontalBottomRight || (style.borderTopRightRadius().width() != style.borderTopLeftRadius().width());
675 bool showVerticalBottomLeft = style.borderTopRightRadius().height() != style.borderBottomLeftRadius().height();
676 bool showVerticalBottomRight = showVerticalBottomLeft || (style.borderBottomRightRadius().height() != style.borderTopLeftRadius().height());
677 bool showVerticalTopRight = showVerticalBottomRight || (style.borderTopRightRadius().height() != style.borderTopLeftRadius().height());
679 RefPtrWillBeRawPtr<CSSValueList> topLeftRadius = valuesForBorderRadiusCorner(style.borderTopLeftRadius(), style);
680 RefPtrWillBeRawPtr<CSSValueList> topRightRadius = valuesForBorderRadiusCorner(style.borderTopRightRadius(), style);
681 RefPtrWillBeRawPtr<CSSValueList> bottomRightRadius = valuesForBorderRadiusCorner(style.borderBottomRightRadius(), style);
682 RefPtrWillBeRawPtr<CSSValueList> bottomLeftRadius = valuesForBorderRadiusCorner(style.borderBottomLeftRadius(), style);
684 RefPtrWillBeRawPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
685 horizontalRadii->append(topLeftRadius->item(0));
686 if (showHorizontalTopRight)
687 horizontalRadii->append(topRightRadius->item(0));
688 if (showHorizontalBottomRight)
689 horizontalRadii->append(bottomRightRadius->item(0));
690 if (showHorizontalBottomLeft)
691 horizontalRadii->append(bottomLeftRadius->item(0));
693 list->append(horizontalRadii.release());
695 RefPtrWillBeRawPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
696 verticalRadii->append(topLeftRadius->item(1));
697 if (showVerticalTopRight)
698 verticalRadii->append(topRightRadius->item(1));
699 if (showVerticalBottomRight)
700 verticalRadii->append(bottomRightRadius->item(1));
701 if (showVerticalBottomLeft)
702 verticalRadii->append(bottomLeftRadius->item(1));
704 if (!verticalRadii->equals(*toCSSValueList(list->item(0))))
705 list->append(verticalRadii.release());
707 return list.release();
710 static LayoutRect sizingBox(RenderObject* renderer)
712 if (!renderer->isBox())
715 RenderBox* box = toRenderBox(renderer);
716 return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
719 static PassRefPtrWillBeRawPtr<CSSTransformValue> valueForMatrixTransform(const TransformationMatrix& transform, const RenderStyle& style)
721 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = nullptr;
722 if (transform.isAffine()) {
723 transformValue = CSSTransformValue::create(CSSTransformValue::MatrixTransformOperation);
725 transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
726 transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
727 transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
728 transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
729 transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
730 transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
732 transformValue = CSSTransformValue::create(CSSTransformValue::Matrix3DTransformOperation);
734 transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
735 transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
736 transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
737 transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
739 transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
740 transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
741 transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
742 transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
744 transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
745 transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
746 transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
747 transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
749 transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
750 transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
751 transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
752 transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
755 return transformValue.release();
758 static PassRefPtrWillBeRawPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle& style)
760 if (!renderer || !renderer->hasTransform() || !style.hasTransform())
761 return cssValuePool().createIdentifierValue(CSSValueNone);
764 if (renderer->isBox())
765 box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
767 TransformationMatrix transform;
768 style.applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
770 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
771 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
772 list->append(valueForMatrixTransform(transform, style));
774 return list.release();
777 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(const RenderObject* renderer, const RenderStyle& style) const
779 if (style.filter().operations().isEmpty())
780 return cssValuePool().createIdentifierValue(CSSValueNone);
782 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
784 RefPtrWillBeRawPtr<CSSFilterValue> filterValue = nullptr;
786 Vector<RefPtr<FilterOperation> >::const_iterator end = style.filter().operations().end();
787 for (Vector<RefPtr<FilterOperation> >::const_iterator it = style.filter().operations().begin(); it != end; ++it) {
788 FilterOperation* filterOperation = it->get();
789 switch (filterOperation->type()) {
790 case FilterOperation::REFERENCE:
791 filterValue = CSSFilterValue::create(CSSFilterValue::ReferenceFilterOperation);
792 filterValue->append(cssValuePool().createValue(toReferenceFilterOperation(filterOperation)->url(), CSSPrimitiveValue::CSS_STRING));
794 case FilterOperation::GRAYSCALE:
795 filterValue = CSSFilterValue::create(CSSFilterValue::GrayscaleFilterOperation);
796 filterValue->append(cssValuePool().createValue(toBasicColorMatrixFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
798 case FilterOperation::SEPIA:
799 filterValue = CSSFilterValue::create(CSSFilterValue::SepiaFilterOperation);
800 filterValue->append(cssValuePool().createValue(toBasicColorMatrixFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
802 case FilterOperation::SATURATE:
803 filterValue = CSSFilterValue::create(CSSFilterValue::SaturateFilterOperation);
804 filterValue->append(cssValuePool().createValue(toBasicColorMatrixFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
806 case FilterOperation::HUE_ROTATE:
807 filterValue = CSSFilterValue::create(CSSFilterValue::HueRotateFilterOperation);
808 filterValue->append(cssValuePool().createValue(toBasicColorMatrixFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_DEG));
810 case FilterOperation::INVERT:
811 filterValue = CSSFilterValue::create(CSSFilterValue::InvertFilterOperation);
812 filterValue->append(cssValuePool().createValue(toBasicComponentTransferFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
814 case FilterOperation::OPACITY:
815 filterValue = CSSFilterValue::create(CSSFilterValue::OpacityFilterOperation);
816 filterValue->append(cssValuePool().createValue(toBasicComponentTransferFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
818 case FilterOperation::BRIGHTNESS:
819 filterValue = CSSFilterValue::create(CSSFilterValue::BrightnessFilterOperation);
820 filterValue->append(cssValuePool().createValue(toBasicComponentTransferFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
822 case FilterOperation::CONTRAST:
823 filterValue = CSSFilterValue::create(CSSFilterValue::ContrastFilterOperation);
824 filterValue->append(cssValuePool().createValue(toBasicComponentTransferFilterOperation(filterOperation)->amount(), CSSPrimitiveValue::CSS_NUMBER));
826 case FilterOperation::BLUR:
827 filterValue = CSSFilterValue::create(CSSFilterValue::BlurFilterOperation);
828 filterValue->append(zoomAdjustedPixelValue(toBlurFilterOperation(filterOperation)->stdDeviation().value(), style));
830 case FilterOperation::DROP_SHADOW: {
831 DropShadowFilterOperation* dropShadowOperation = toDropShadowFilterOperation(filterOperation);
832 filterValue = CSSFilterValue::create(CSSFilterValue::DropShadowFilterOperation);
833 // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
834 ShadowData shadow(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, dropShadowOperation->color());
835 filterValue->append(valueForShadowData(shadow, style, false));
839 filterValue = CSSFilterValue::create(CSSFilterValue::UnknownFilterOperation);
842 list->append(filterValue.release());
845 return list.release();
848 static PassRefPtrWillBeRawPtr<CSSValue> specifiedValueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle& style)
850 if (!trackBreadth.isLength())
851 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue::CSS_FR);
853 const Length& trackBreadthLength = trackBreadth.length();
854 if (trackBreadthLength.isAuto())
855 return cssValuePool().createIdentifierValue(CSSValueAuto);
856 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
859 static PassRefPtrWillBeRawPtr<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle& style)
861 switch (trackSize.type()) {
862 case LengthTrackSizing:
863 return specifiedValueForGridTrackBreadth(trackSize.length(), style);
864 case MinMaxTrackSizing:
865 RefPtrWillBeRawPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
866 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.minTrackBreadth(), style));
867 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.maxTrackBreadth(), style));
868 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
870 ASSERT_NOT_REACHED();
874 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& orderedNamedGridLines, size_t i, CSSValueList& list)
876 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i);
877 if (namedGridLines.isEmpty())
880 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create();
881 for (size_t j = 0; j < namedGridLines.size(); ++j)
882 lineNames->append(cssValuePool().createValue(namedGridLines[j], CSSPrimitiveValue::CSS_STRING));
883 list.append(lineNames.release());
886 static PassRefPtrWillBeRawPtr<CSSValue> valueForGridTrackList(GridTrackSizingDirection direction, RenderObject* renderer, const RenderStyle& style)
888 const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style.gridTemplateColumns() : style.gridTemplateRows();
889 const OrderedNamedGridLines& orderedNamedGridLines = direction == ForColumns ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines();
891 // Handle the 'none' case here.
892 if (!trackSizes.size()) {
893 ASSERT(orderedNamedGridLines.isEmpty());
894 return cssValuePool().createIdentifierValue(CSSValueNone);
897 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
898 if (renderer && renderer->isRenderGrid()) {
899 const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toRenderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions();
900 // There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
901 // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
902 ASSERT(trackPositions.size() - 1 >= trackSizes.size());
904 for (size_t i = 0; i < trackSizes.size(); ++i) {
905 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
906 list->append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i], style));
909 for (size_t i = 0; i < trackSizes.size(); ++i) {
910 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
911 list->append(specifiedValueForGridTrackSize(trackSizes[i], style));
914 // Those are the trailing <string>* allowed in the syntax.
915 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list);
916 return list.release();
919 static PassRefPtrWillBeRawPtr<CSSValue> valueForGridPosition(const GridPosition& position)
921 if (position.isAuto())
922 return cssValuePool().createIdentifierValue(CSSValueAuto);
924 if (position.isNamedGridArea())
925 return cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING);
927 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
928 if (position.isSpan()) {
929 list->append(cssValuePool().createIdentifierValue(CSSValueSpan));
930 list->append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
932 list->append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
934 if (!position.namedGridLine().isNull())
935 list->append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
939 static PassRefPtrWillBeRawPtr<CSSValue> createTransitionPropertyValue(const CSSTransitionData::TransitionProperty& property)
941 if (property.propertyType == CSSTransitionData::TransitionNone)
942 return cssValuePool().createIdentifierValue(CSSValueNone);
943 if (property.propertyType == CSSTransitionData::TransitionAll)
944 return cssValuePool().createIdentifierValue(CSSValueAll);
945 if (property.propertyType == CSSTransitionData::TransitionUnknown)
946 return cssValuePool().createValue(property.propertyString, CSSPrimitiveValue::CSS_STRING);
947 ASSERT(property.propertyType == CSSTransitionData::TransitionSingleProperty);
948 return cssValuePool().createValue(getPropertyNameString(property.propertyId), CSSPrimitiveValue::CSS_STRING);
951 static PassRefPtrWillBeRawPtr<CSSValue> valueForTransitionProperty(const CSSTransitionData* transitionData)
953 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
954 if (transitionData) {
955 for (size_t i = 0; i < transitionData->propertyList().size(); ++i)
956 list->append(createTransitionPropertyValue(transitionData->propertyList()[i]));
958 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
960 return list.release();
963 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationDelay(const CSSTimingData* timingData)
965 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
967 for (size_t i = 0; i < timingData->delayList().size(); ++i)
968 list->append(cssValuePool().createValue(timingData->delayList()[i], CSSPrimitiveValue::CSS_S));
970 list->append(cssValuePool().createValue(CSSTimingData::initialDelay(), CSSPrimitiveValue::CSS_S));
972 return list.release();
975 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationDuration(const CSSTimingData* timingData)
977 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
979 for (size_t i = 0; i < timingData->durationList().size(); ++i)
980 list->append(cssValuePool().createValue(timingData->durationList()[i], CSSPrimitiveValue::CSS_S));
982 list->append(cssValuePool().createValue(CSSTimingData::initialDuration(), CSSPrimitiveValue::CSS_S));
984 return list.release();
987 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationIterationCount(double iterationCount)
989 if (iterationCount == std::numeric_limits<double>::infinity())
990 return cssValuePool().createIdentifierValue(CSSValueInfinite);
991 return cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER);
994 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationPlayState(EAnimPlayState playState)
996 if (playState == AnimPlayStatePlaying)
997 return cssValuePool().createIdentifierValue(CSSValueRunning);
998 ASSERT(playState == AnimPlayStatePaused);
999 return cssValuePool().createIdentifierValue(CSSValuePaused);
1002 static PassRefPtrWillBeRawPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1004 switch (timingFunction->type()) {
1005 case TimingFunction::CubicBezierFunction:
1007 const CubicBezierTimingFunction* bezierTimingFunction = toCubicBezierTimingFunction(timingFunction);
1008 if (bezierTimingFunction->subType() != CubicBezierTimingFunction::Custom) {
1009 CSSValueID valueId = CSSValueInvalid;
1010 switch (bezierTimingFunction->subType()) {
1011 case CubicBezierTimingFunction::Ease:
1012 valueId = CSSValueEase;
1014 case CubicBezierTimingFunction::EaseIn:
1015 valueId = CSSValueEaseIn;
1017 case CubicBezierTimingFunction::EaseOut:
1018 valueId = CSSValueEaseOut;
1020 case CubicBezierTimingFunction::EaseInOut:
1021 valueId = CSSValueEaseInOut;
1024 ASSERT_NOT_REACHED();
1027 return cssValuePool().createIdentifierValue(valueId);
1029 return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1032 case TimingFunction::StepsFunction:
1034 const StepsTimingFunction* stepsTimingFunction = toStepsTimingFunction(timingFunction);
1035 if (stepsTimingFunction->subType() == StepsTimingFunction::Custom)
1036 return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtPosition());
1039 switch (stepsTimingFunction->subType()) {
1040 case StepsTimingFunction::Start:
1041 valueId = CSSValueStepStart;
1043 case StepsTimingFunction::End:
1044 valueId = CSSValueStepEnd;
1047 ASSERT_NOT_REACHED();
1050 return cssValuePool().createIdentifierValue(valueId);
1054 return cssValuePool().createIdentifierValue(CSSValueLinear);
1058 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationTimingFunction(const CSSTimingData* timingData)
1060 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1062 for (size_t i = 0; i < timingData->timingFunctionList().size(); ++i)
1063 list->append(createTimingFunctionValue(timingData->timingFunctionList()[i].get()));
1065 list->append(createTimingFunctionValue(CSSTimingData::initialTimingFunction().get()));
1067 return list.release();
1070 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationFillMode(Timing::FillMode fillMode)
1073 case Timing::FillModeNone:
1074 return cssValuePool().createIdentifierValue(CSSValueNone);
1075 case Timing::FillModeForwards:
1076 return cssValuePool().createIdentifierValue(CSSValueForwards);
1077 case Timing::FillModeBackwards:
1078 return cssValuePool().createIdentifierValue(CSSValueBackwards);
1079 case Timing::FillModeBoth:
1080 return cssValuePool().createIdentifierValue(CSSValueBoth);
1082 ASSERT_NOT_REACHED();
1087 static PassRefPtrWillBeRawPtr<CSSValue> valueForAnimationDirection(Timing::PlaybackDirection direction)
1089 switch (direction) {
1090 case Timing::PlaybackDirectionNormal:
1091 return cssValuePool().createIdentifierValue(CSSValueNormal);
1092 case Timing::PlaybackDirectionAlternate:
1093 return cssValuePool().createIdentifierValue(CSSValueAlternate);
1094 case Timing::PlaybackDirectionReverse:
1095 return cssValuePool().createIdentifierValue(CSSValueReverse);
1096 case Timing::PlaybackDirectionAlternateReverse:
1097 return cssValuePool().createIdentifierValue(CSSValueAlternateReverse);
1099 ASSERT_NOT_REACHED();
1104 static PassRefPtrWillBeRawPtr<CSSValue> valueForWillChange(const Vector<CSSPropertyID>& willChangeProperties, bool willChangeContents, bool willChangeScrollPosition)
1106 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1107 if (willChangeContents)
1108 list->append(cssValuePool().createIdentifierValue(CSSValueContents));
1109 if (willChangeScrollPosition)
1110 list->append(cssValuePool().createIdentifierValue(CSSValueScrollPosition));
1111 for (size_t i = 0; i < willChangeProperties.size(); ++i)
1112 list->append(cssValuePool().createIdentifierValue(willChangeProperties[i]));
1113 if (!list->length())
1114 list->append(cssValuePool().createIdentifierValue(CSSValueAuto));
1115 return list.release();
1118 static PassRefPtrWillBeRawPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1120 if (!lineBoxContain)
1121 return cssValuePool().createIdentifierValue(CSSValueNone);
1122 return CSSLineBoxContainValue::create(lineBoxContain);
1125 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtrWillBeRawPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1127 , m_allowVisitedStyle(allowVisitedStyle)
1132 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1133 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1134 AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1137 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1142 void CSSComputedStyleDeclaration::ref()
1147 void CSSComputedStyleDeclaration::deref()
1155 String CSSComputedStyleDeclaration::cssText() const
1157 StringBuilder result;
1158 const Vector<CSSPropertyID>& properties = computableProperties();
1160 for (unsigned i = 0; i < properties.size(); i++) {
1163 result.append(getPropertyName(properties[i]));
1164 result.append(": ", 2);
1165 result.append(getPropertyValue(properties[i]));
1169 return result.toString();
1172 void CSSComputedStyleDeclaration::setCSSText(const String&, ExceptionState& exceptionState)
1174 exceptionState.throwDOMException(NoModificationAllowedError, "These styles are computed, and therefore read-only.");
1177 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
1179 ASSERT_ARG(keywordSize, keywordSize);
1180 ASSERT_ARG(keywordSize, keywordSize <= 8);
1181 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
1184 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
1189 m_node->document().updateLayoutIgnorePendingStylesheets();
1191 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1195 if (int keywordSize = style->fontDescription().keywordSize())
1196 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1199 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), *style);
1202 FixedPitchFontType CSSComputedStyleDeclaration::fixedPitchFontType() const
1205 return NonFixedPitchFont;
1207 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1209 return NonFixedPitchFont;
1211 return style->fontDescription().fixedPitchFontType();
1214 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadowData(const ShadowData& shadow, const RenderStyle& style, bool useSpread) const
1216 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(shadow.x(), style);
1217 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(shadow.y(), style);
1218 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(shadow.blur(), style);
1219 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = useSpread ? zoomAdjustedPixelValue(shadow.spread(), style) : PassRefPtrWillBeRawPtr<CSSPrimitiveValue>(nullptr);
1220 RefPtrWillBeRawPtr<CSSPrimitiveValue> shadowStyle = shadow.style() == Normal ? PassRefPtrWillBeRawPtr<CSSPrimitiveValue>(nullptr) : cssValuePool().createIdentifierValue(CSSValueInset);
1221 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = currentColorOrValidColor(style, shadow.color());
1222 return CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), shadowStyle.release(), color.release());
1225 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadowList(const ShadowList* shadowList, const RenderStyle& style, bool useSpread) const
1228 return cssValuePool().createIdentifierValue(CSSValueNone);
1230 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1231 size_t shadowCount = shadowList->shadows().size();
1232 for (size_t i = 0; i < shadowCount; ++i)
1233 list->append(valueForShadowData(shadowList->shadows()[i], style, useSpread));
1234 return list.release();
1237 static CSSValueID identifierForFamily(const AtomicString& family)
1239 if (family == FontFamilyNames::webkit_cursive)
1240 return CSSValueCursive;
1241 if (family == FontFamilyNames::webkit_fantasy)
1242 return CSSValueFantasy;
1243 if (family == FontFamilyNames::webkit_monospace)
1244 return CSSValueMonospace;
1245 if (family == FontFamilyNames::webkit_pictograph)
1246 return CSSValueWebkitPictograph;
1247 if (family == FontFamilyNames::webkit_sans_serif)
1248 return CSSValueSansSerif;
1249 if (family == FontFamilyNames::webkit_serif)
1250 return CSSValueSerif;
1251 return CSSValueInvalid;
1254 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1256 if (CSSValueID familyIdentifier = identifierForFamily(family))
1257 return cssValuePool().createIdentifierValue(familyIdentifier);
1258 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1261 static PassRefPtrWillBeRawPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1263 // Blink value is ignored.
1264 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1265 if (textDecoration & TextDecorationUnderline)
1266 list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1267 if (textDecoration & TextDecorationOverline)
1268 list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1269 if (textDecoration & TextDecorationLineThrough)
1270 list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1272 if (!list->length())
1273 return cssValuePool().createIdentifierValue(CSSValueNone);
1274 return list.release();
1277 static PassRefPtrWillBeRawPtr<CSSValue> valueForTextDecorationStyle(TextDecorationStyle textDecorationStyle)
1279 switch (textDecorationStyle) {
1280 case TextDecorationStyleSolid:
1281 return cssValuePool().createIdentifierValue(CSSValueSolid);
1282 case TextDecorationStyleDouble:
1283 return cssValuePool().createIdentifierValue(CSSValueDouble);
1284 case TextDecorationStyleDotted:
1285 return cssValuePool().createIdentifierValue(CSSValueDotted);
1286 case TextDecorationStyleDashed:
1287 return cssValuePool().createIdentifierValue(CSSValueDashed);
1288 case TextDecorationStyleWavy:
1289 return cssValuePool().createIdentifierValue(CSSValueWavy);
1292 ASSERT_NOT_REACHED();
1293 return cssValuePool().createExplicitInitialValue();
1296 static PassRefPtrWillBeRawPtr<CSSValue> valueForFillRepeat(EFillRepeat xRepeat, EFillRepeat yRepeat)
1298 // For backwards compatibility, if both values are equal, just return one of them. And
1299 // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1300 if (xRepeat == yRepeat)
1301 return cssValuePool().createValue(xRepeat);
1302 if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1303 return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1304 if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1305 return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1307 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1308 list->append(cssValuePool().createValue(xRepeat));
1309 list->append(cssValuePool().createValue(yRepeat));
1310 return list.release();
1313 static PassRefPtrWillBeRawPtr<CSSValue> valueForFillSourceType(EMaskSourceType type)
1317 return cssValuePool().createValue(CSSValueAlpha);
1319 return cssValuePool().createValue(CSSValueLuminance);
1322 ASSERT_NOT_REACHED();
1327 static PassRefPtrWillBeRawPtr<CSSValue> valueForFillSize(const FillSize& fillSize, const RenderStyle& style)
1329 if (fillSize.type == Contain)
1330 return cssValuePool().createIdentifierValue(CSSValueContain);
1332 if (fillSize.type == Cover)
1333 return cssValuePool().createIdentifierValue(CSSValueCover);
1335 if (fillSize.size.height().isAuto())
1336 return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1338 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1339 list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1340 list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1341 return list.release();
1344 static PassRefPtrWillBeRawPtr<CSSValue> valueForContentData(const RenderStyle& style)
1346 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1347 for (const ContentData* contentData = style.contentData(); contentData; contentData = contentData->next()) {
1348 if (contentData->isCounter()) {
1349 const CounterContent* counter = toCounterContentData(contentData)->counter();
1351 list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1352 } else if (contentData->isImage()) {
1353 const StyleImage* image = toImageContentData(contentData)->image();
1355 list->append(image->cssValue());
1356 } else if (contentData->isText()) {
1357 list->append(cssValuePool().createValue(toTextContentData(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1360 return list.release();
1363 static PassRefPtrWillBeRawPtr<CSSValue> valueForCounterDirectives(const RenderStyle& style, CSSPropertyID propertyID)
1365 const CounterDirectiveMap* map = style.counterDirectives();
1369 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1370 for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1371 list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1372 short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1373 list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1375 return list.release();
1378 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1380 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1381 if (!propertyIDSet.add(propertyID).isNewEntry)
1384 WTF_LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1387 static PassRefPtrWillBeRawPtr<CSSValueList> valueForFontFamily(RenderStyle& style)
1389 const FontFamily& firstFamily = style.fontDescription().family();
1390 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1391 for (const FontFamily* family = &firstFamily; family; family = family->next())
1392 list->append(valueForFamily(family->family()));
1393 return list.release();
1396 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForLineHeight(RenderStyle& style)
1398 Length length = style.lineHeight();
1399 if (length.isNegative())
1400 return cssValuePool().createIdentifierValue(CSSValueNormal);
1402 return zoomAdjustedPixelValue(floatValueForLength(length, style.fontDescription().specifiedSize()), style);
1405 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontSize(RenderStyle& style)
1407 return zoomAdjustedPixelValue(style.fontDescription().computedPixelSize(), style);
1410 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontStretch(RenderStyle& style)
1412 return cssValuePool().createValue(style.fontDescription().stretch());
1415 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontStyle(RenderStyle& style)
1417 return cssValuePool().createValue(style.fontDescription().style());
1420 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontVariant(RenderStyle& style)
1422 return cssValuePool().createValue(style.fontDescription().variant());
1425 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontWeight(RenderStyle& style)
1427 return cssValuePool().createValue(style.fontDescription().weight());
1430 static PassRefPtrWillBeRawPtr<CSSValue> valueForShape(const RenderStyle& style, ShapeValue* shapeValue)
1433 return cssValuePool().createIdentifierValue(CSSValueNone);
1434 if (shapeValue->type() == ShapeValue::Box)
1435 return cssValuePool().createValue(shapeValue->cssBox());
1436 if (shapeValue->type() == ShapeValue::Image) {
1437 if (shapeValue->image())
1438 return shapeValue->image()->cssValue();
1439 return cssValuePool().createIdentifierValue(CSSValueNone);
1442 ASSERT(shapeValue->type() == ShapeValue::Shape);
1444 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1445 list->append(valueForBasicShape(style, shapeValue->shape()));
1446 if (shapeValue->cssBox() != BoxMissing)
1447 list->append(cssValuePool().createValue(shapeValue->cssBox()));
1448 return list.release();
1451 static PassRefPtrWillBeRawPtr<CSSValue> touchActionFlagsToCSSValue(TouchAction touchAction)
1453 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1454 if (touchAction == TouchActionAuto)
1455 list->append(cssValuePool().createIdentifierValue(CSSValueAuto));
1456 if (touchAction & TouchActionNone) {
1457 ASSERT(touchAction == TouchActionNone);
1458 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1460 if (touchAction == (TouchActionPanX | TouchActionPanY | TouchActionPinchZoom)) {
1461 list->append(cssValuePool().createIdentifierValue(CSSValueManipulation));
1463 if (touchAction & TouchActionPanX)
1464 list->append(cssValuePool().createIdentifierValue(CSSValuePanX));
1465 if (touchAction & TouchActionPanY)
1466 list->append(cssValuePool().createIdentifierValue(CSSValuePanY));
1468 ASSERT(list->length());
1469 return list.release();
1472 static bool isLayoutDependent(CSSPropertyID propertyID, PassRefPtr<RenderStyle> style, RenderObject* renderer)
1474 // Some properties only depend on layout in certain conditions which
1475 // are specified in the main switch statement below. So we can avoid
1476 // forcing layout in those conditions. The conditions in this switch
1477 // statement must remain in sync with the conditions in the main switch.
1478 // FIXME: Some of these cases could be narrowed down or optimized better.
1479 switch (propertyID) {
1480 case CSSPropertyBottom:
1481 case CSSPropertyGridTemplateColumns:
1482 case CSSPropertyGridTemplateRows:
1483 case CSSPropertyHeight:
1484 case CSSPropertyLeft:
1485 case CSSPropertyRight:
1486 case CSSPropertyTop:
1487 case CSSPropertyPerspectiveOrigin:
1488 case CSSPropertyWebkitPerspectiveOrigin:
1489 case CSSPropertyTransform:
1490 case CSSPropertyWebkitTransform:
1491 case CSSPropertyTransformOrigin:
1492 case CSSPropertyWebkitTransformOrigin:
1493 case CSSPropertyWidth:
1494 case CSSPropertyWebkitFilter:
1496 case CSSPropertyMargin:
1497 return renderer && renderer->isBox() && (!style || !style->marginBottom().isFixed() || !style->marginTop().isFixed() || !style->marginLeft().isFixed() || !style->marginRight().isFixed());
1498 case CSSPropertyMarginLeft:
1499 return renderer && renderer->isBox() && (!style || !style->marginLeft().isFixed());
1500 case CSSPropertyMarginRight:
1501 return renderer && renderer->isBox() && (!style || !style->marginRight().isFixed());
1502 case CSSPropertyMarginTop:
1503 return renderer && renderer->isBox() && (!style || !style->marginTop().isFixed());
1504 case CSSPropertyMarginBottom:
1505 return renderer && renderer->isBox() && (!style || !style->marginBottom().isFixed());
1506 case CSSPropertyPadding:
1507 return renderer && renderer->isBox() && (!style || !style->paddingBottom().isFixed() || !style->paddingTop().isFixed() || !style->paddingLeft().isFixed() || !style->paddingRight().isFixed());
1508 case CSSPropertyPaddingBottom:
1509 return renderer && renderer->isBox() && (!style || !style->paddingBottom().isFixed());
1510 case CSSPropertyPaddingLeft:
1511 return renderer && renderer->isBox() && (!style || !style->paddingLeft().isFixed());
1512 case CSSPropertyPaddingRight:
1513 return renderer && renderer->isBox() && (!style || !style->paddingRight().isFixed());
1514 case CSSPropertyPaddingTop:
1515 return renderer && renderer->isBox() && (!style || !style->paddingTop().isFixed());
1521 PassRefPtr<RenderStyle> CSSComputedStyleDeclaration::computeRenderStyle(CSSPropertyID propertyID) const
1523 Node* styledNode = this->styledNode();
1525 return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
1528 Node* CSSComputedStyleDeclaration::styledNode() const
1532 if (m_node->isElementNode()) {
1533 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoElementSpecifier))
1536 return m_node.get();
1539 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element)
1541 if (position != ItemPositionAuto)
1544 bool isFlexOrGrid = element && element->computedStyle()
1545 && element->computedStyle()->isDisplayFlexibleOrGridBox();
1547 return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart;
1550 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType)
1552 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
1553 if (positionType == LegacyPosition)
1554 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
1555 result->append(CSSPrimitiveValue::create(itemPosition));
1556 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlignmentDefault)
1557 result->append(CSSPrimitiveValue::create(overflowAlignment));
1558 ASSERT(result->length() <= 2);
1559 return result.release();
1562 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1564 Node* styledNode = this->styledNode();
1567 RenderObject* renderer = styledNode->renderer();
1568 RefPtr<RenderStyle> style;
1571 Document& document = styledNode->document();
1573 // A timing update may be required if a compositor animation is running.
1574 DocumentAnimations::updateAnimationTimingForGetComputedStyle(*styledNode, propertyID);
1576 document.updateRenderTreeForNodeIfNeeded(styledNode);
1578 // The style recalc could have caused the styled node to be discarded or replaced
1579 // if it was a PseudoElement so we need to update it.
1580 styledNode = this->styledNode();
1581 renderer = styledNode->renderer();
1583 style = computeRenderStyle(propertyID);
1585 bool forceFullLayout = isLayoutDependent(propertyID, style, renderer)
1586 || styledNode->isInShadowTree()
1587 || (document.ownerElement() && document.ensureStyleResolver().hasViewportDependentMediaQueries());
1589 if (forceFullLayout) {
1590 document.updateLayoutIgnorePendingStylesheets();
1591 styledNode = this->styledNode();
1592 style = computeRenderStyle(propertyID);
1593 renderer = styledNode->renderer();
1596 style = computeRenderStyle(propertyID);
1602 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1604 switch (propertyID) {
1605 case CSSPropertyInvalid:
1608 case CSSPropertyBackgroundColor:
1609 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBackgroundColor).rgb()) : currentColorOrValidColor(*style, style->backgroundColor());
1610 case CSSPropertyBackgroundImage:
1611 case CSSPropertyWebkitMaskImage: {
1612 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1613 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskImage ? &style->maskLayers() : &style->backgroundLayers();
1614 for (; currLayer; currLayer = currLayer->next()) {
1615 if (currLayer->image())
1616 list->append(currLayer->image()->cssValue());
1618 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1620 return list.release();
1622 case CSSPropertyBackgroundSize:
1623 case CSSPropertyWebkitBackgroundSize:
1624 case CSSPropertyWebkitMaskSize: {
1625 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1626 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskSize ? &style->maskLayers() : &style->backgroundLayers();
1627 for (; currLayer; currLayer = currLayer->next())
1628 list->append(valueForFillSize(currLayer->size(), *style));
1629 return list.release();
1631 case CSSPropertyBackgroundRepeat:
1632 case CSSPropertyWebkitMaskRepeat: {
1633 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1634 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskRepeat ? &style->maskLayers() : &style->backgroundLayers();
1635 for (; currLayer; currLayer = currLayer->next())
1636 list->append(valueForFillRepeat(currLayer->repeatX(), currLayer->repeatY()));
1637 return list.release();
1639 case CSSPropertyMaskSourceType: {
1640 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1641 for (const FillLayer* currLayer = &style->maskLayers(); currLayer; currLayer = currLayer->next())
1642 list->append(valueForFillSourceType(currLayer->maskSourceType()));
1643 return list.release();
1645 case CSSPropertyWebkitBackgroundComposite:
1646 case CSSPropertyWebkitMaskComposite: {
1647 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1648 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskComposite ? &style->maskLayers() : &style->backgroundLayers();
1649 for (; currLayer; currLayer = currLayer->next())
1650 list->append(cssValuePool().createValue(currLayer->composite()));
1651 return list.release();
1653 case CSSPropertyBackgroundAttachment: {
1654 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1655 for (const FillLayer* currLayer = &style->backgroundLayers(); currLayer; currLayer = currLayer->next())
1656 list->append(cssValuePool().createValue(currLayer->attachment()));
1657 return list.release();
1659 case CSSPropertyBackgroundClip:
1660 case CSSPropertyBackgroundOrigin:
1661 case CSSPropertyWebkitBackgroundClip:
1662 case CSSPropertyWebkitBackgroundOrigin:
1663 case CSSPropertyWebkitMaskClip:
1664 case CSSPropertyWebkitMaskOrigin: {
1665 bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1666 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1667 const FillLayer* currLayer = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? &style->maskLayers() : &style->backgroundLayers();
1668 for (; currLayer; currLayer = currLayer->next()) {
1669 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1670 list->append(cssValuePool().createValue(box));
1672 return list.release();
1674 case CSSPropertyBackgroundPosition:
1675 case CSSPropertyWebkitMaskPosition: {
1676 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1677 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskPosition ? &style->maskLayers() : &style->backgroundLayers();
1678 for (; currLayer; currLayer = currLayer->next())
1679 list->append(createPositionListForLayer(propertyID, *currLayer, *style));
1680 return list.release();
1682 case CSSPropertyBackgroundPositionX:
1683 case CSSPropertyWebkitMaskPositionX: {
1684 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1685 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskPositionX ? &style->maskLayers() : &style->backgroundLayers();
1686 for (; currLayer; currLayer = currLayer->next())
1687 list->append(zoomAdjustedPixelValueForLength(currLayer->xPosition(), *style));
1688 return list.release();
1690 case CSSPropertyBackgroundPositionY:
1691 case CSSPropertyWebkitMaskPositionY: {
1692 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1693 const FillLayer* currLayer = propertyID == CSSPropertyWebkitMaskPositionY ? &style->maskLayers() : &style->backgroundLayers();
1694 for (; currLayer; currLayer = currLayer->next())
1695 list->append(zoomAdjustedPixelValueForLength(currLayer->yPosition(), *style));
1696 return list.release();
1698 case CSSPropertyBorderCollapse:
1699 if (style->borderCollapse())
1700 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1701 return cssValuePool().createIdentifierValue(CSSValueSeparate);
1702 case CSSPropertyBorderSpacing: {
1703 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1704 list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), *style));
1705 list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), *style));
1706 return list.release();
1708 case CSSPropertyWebkitBorderHorizontalSpacing:
1709 return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), *style);
1710 case CSSPropertyWebkitBorderVerticalSpacing:
1711 return zoomAdjustedPixelValue(style->verticalBorderSpacing(), *style);
1712 case CSSPropertyBorderImageSource:
1713 if (style->borderImageSource())
1714 return style->borderImageSource()->cssValue();
1715 return cssValuePool().createIdentifierValue(CSSValueNone);
1716 case CSSPropertyBorderTopColor:
1717 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(*style, style->borderTopColor());
1718 case CSSPropertyBorderRightColor:
1719 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(*style, style->borderRightColor());
1720 case CSSPropertyBorderBottomColor:
1721 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(*style, style->borderBottomColor());
1722 case CSSPropertyBorderLeftColor:
1723 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(*style, style->borderLeftColor());
1724 case CSSPropertyBorderTopStyle:
1725 return cssValuePool().createValue(style->borderTopStyle());
1726 case CSSPropertyBorderRightStyle:
1727 return cssValuePool().createValue(style->borderRightStyle());
1728 case CSSPropertyBorderBottomStyle:
1729 return cssValuePool().createValue(style->borderBottomStyle());
1730 case CSSPropertyBorderLeftStyle:
1731 return cssValuePool().createValue(style->borderLeftStyle());
1732 case CSSPropertyBorderTopWidth:
1733 return zoomAdjustedPixelValue(style->borderTopWidth(), *style);
1734 case CSSPropertyBorderRightWidth:
1735 return zoomAdjustedPixelValue(style->borderRightWidth(), *style);
1736 case CSSPropertyBorderBottomWidth:
1737 return zoomAdjustedPixelValue(style->borderBottomWidth(), *style);
1738 case CSSPropertyBorderLeftWidth:
1739 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style);
1740 case CSSPropertyBottom:
1741 return valueForPositionOffset(*style, CSSPropertyBottom, renderer);
1742 case CSSPropertyWebkitBoxAlign:
1743 return cssValuePool().createValue(style->boxAlign());
1744 case CSSPropertyWebkitBoxDecorationBreak:
1745 if (style->boxDecorationBreak() == DSLICE)
1746 return cssValuePool().createIdentifierValue(CSSValueSlice);
1747 return cssValuePool().createIdentifierValue(CSSValueClone);
1748 case CSSPropertyWebkitBoxDirection:
1749 return cssValuePool().createValue(style->boxDirection());
1750 case CSSPropertyWebkitBoxFlex:
1751 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1752 case CSSPropertyWebkitBoxFlexGroup:
1753 return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1754 case CSSPropertyWebkitBoxLines:
1755 return cssValuePool().createValue(style->boxLines());
1756 case CSSPropertyWebkitBoxOrdinalGroup:
1757 return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1758 case CSSPropertyWebkitBoxOrient:
1759 return cssValuePool().createValue(style->boxOrient());
1760 case CSSPropertyWebkitBoxPack:
1761 return cssValuePool().createValue(style->boxPack());
1762 case CSSPropertyWebkitBoxReflect:
1763 return valueForReflection(style->boxReflect(), *style);
1764 case CSSPropertyBoxShadow:
1765 case CSSPropertyWebkitBoxShadow:
1766 return valueForShadowList(style->boxShadow(), *style, true);
1767 case CSSPropertyCaptionSide:
1768 return cssValuePool().createValue(style->captionSide());
1769 case CSSPropertyClear:
1770 return cssValuePool().createValue(style->clear());
1771 case CSSPropertyColor:
1772 return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1773 case CSSPropertyWebkitPrintColorAdjust:
1774 return cssValuePool().createValue(style->printColorAdjust());
1775 case CSSPropertyWebkitColumnCount:
1776 if (style->hasAutoColumnCount())
1777 return cssValuePool().createIdentifierValue(CSSValueAuto);
1778 return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
1779 case CSSPropertyColumnFill:
1780 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled())
1781 return cssValuePool().createValue(style->columnFill());
1783 case CSSPropertyWebkitColumnGap:
1784 if (style->hasNormalColumnGap())
1785 return cssValuePool().createIdentifierValue(CSSValueNormal);
1786 return zoomAdjustedPixelValue(style->columnGap(), *style);
1787 case CSSPropertyWebkitColumnRuleColor:
1788 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(*style, style->columnRuleColor());
1789 case CSSPropertyWebkitColumnRuleStyle:
1790 return cssValuePool().createValue(style->columnRuleStyle());
1791 case CSSPropertyWebkitColumnRuleWidth:
1792 return zoomAdjustedPixelValue(style->columnRuleWidth(), *style);
1793 case CSSPropertyWebkitColumnSpan:
1794 return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
1795 case CSSPropertyWebkitColumnBreakAfter:
1796 return cssValuePool().createValue(style->columnBreakAfter());
1797 case CSSPropertyWebkitColumnBreakBefore:
1798 return cssValuePool().createValue(style->columnBreakBefore());
1799 case CSSPropertyWebkitColumnBreakInside:
1800 return cssValuePool().createValue(style->columnBreakInside());
1801 case CSSPropertyWebkitColumnWidth:
1802 if (style->hasAutoColumnWidth())
1803 return cssValuePool().createIdentifierValue(CSSValueAuto);
1804 return zoomAdjustedPixelValue(style->columnWidth(), *style);
1805 case CSSPropertyTabSize:
1806 return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
1807 case CSSPropertyCursor: {
1808 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
1809 CursorList* cursors = style->cursors();
1810 if (cursors && cursors->size() > 0) {
1811 list = CSSValueList::createCommaSeparated();
1812 for (unsigned i = 0; i < cursors->size(); ++i)
1813 if (StyleImage* image = cursors->at(i).image())
1814 list->append(image->cssValue());
1816 RefPtrWillBeRawPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
1818 list->append(value.release());
1819 return list.release();
1821 return value.release();
1823 case CSSPropertyDirection:
1824 return cssValuePool().createValue(style->direction());
1825 case CSSPropertyDisplay:
1826 return cssValuePool().createValue(style->display());
1827 case CSSPropertyEmptyCells:
1828 return cssValuePool().createValue(style->emptyCells());
1829 case CSSPropertyAlignContent:
1830 return cssValuePool().createValue(style->alignContent());
1831 case CSSPropertyAlignItems:
1832 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->alignItems(), styledNode), style->alignItemsOverflowAlignment(), NonLegacyPosition);
1833 case CSSPropertyAlignSelf:
1834 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->alignSelf(), styledNode->parentNode()), style->alignSelfOverflowAlignment(), NonLegacyPosition);
1835 case CSSPropertyFlex:
1836 return valuesForShorthandProperty(flexShorthand());
1837 case CSSPropertyFlexBasis:
1838 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style);
1839 case CSSPropertyFlexDirection:
1840 return cssValuePool().createValue(style->flexDirection());
1841 case CSSPropertyFlexFlow:
1842 return valuesForShorthandProperty(flexFlowShorthand());
1843 case CSSPropertyFlexGrow:
1844 return cssValuePool().createValue(style->flexGrow());
1845 case CSSPropertyFlexShrink:
1846 return cssValuePool().createValue(style->flexShrink());
1847 case CSSPropertyFlexWrap:
1848 return cssValuePool().createValue(style->flexWrap());
1849 case CSSPropertyJustifyContent:
1850 return cssValuePool().createValue(style->justifyContent());
1851 case CSSPropertyOrder:
1852 return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
1853 case CSSPropertyFloat:
1854 if (style->display() != NONE && style->hasOutOfFlowPosition())
1855 return cssValuePool().createIdentifierValue(CSSValueNone);
1856 return cssValuePool().createValue(style->floating());
1857 case CSSPropertyFont: {
1858 RefPtrWillBeRawPtr<CSSFontValue> computedFont = CSSFontValue::create();
1859 computedFont->style = valueForFontStyle(*style);
1860 computedFont->variant = valueForFontVariant(*style);
1861 computedFont->weight = valueForFontWeight(*style);
1862 computedFont->stretch = valueForFontStretch(*style);
1863 computedFont->size = valueForFontSize(*style);
1864 computedFont->lineHeight = valueForLineHeight(*style);
1865 computedFont->family = valueForFontFamily(*style);
1866 return computedFont.release();
1868 case CSSPropertyFontFamily: {
1869 RefPtrWillBeRawPtr<CSSValueList> fontFamilyList = valueForFontFamily(*style);
1870 // If there's only a single family, return that as a CSSPrimitiveValue.
1871 // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
1872 if (fontFamilyList->length() == 1)
1873 return fontFamilyList->item(0);
1874 return fontFamilyList.release();
1876 case CSSPropertyFontSize:
1877 return valueForFontSize(*style);
1878 case CSSPropertyFontStretch:
1879 return valueForFontStretch(*style);
1880 case CSSPropertyFontStyle:
1881 return valueForFontStyle(*style);
1882 case CSSPropertyFontVariant:
1883 return valueForFontVariant(*style);
1884 case CSSPropertyFontWeight:
1885 return valueForFontWeight(*style);
1886 case CSSPropertyWebkitFontFeatureSettings: {
1887 const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
1888 if (!featureSettings || !featureSettings->size())
1889 return cssValuePool().createIdentifierValue(CSSValueNormal);
1890 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1891 for (unsigned i = 0; i < featureSettings->size(); ++i) {
1892 const FontFeature& feature = featureSettings->at(i);
1893 RefPtrWillBeRawPtr<CSSFontFeatureValue> featureValue = CSSFontFeatureValue::create(feature.tag(), feature.value());
1894 list->append(featureValue.release());
1896 return list.release();
1898 case CSSPropertyGridAutoFlow: {
1899 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1900 switch (style->gridAutoFlow()) {
1902 case AutoFlowRowDense:
1903 list->append(cssValuePool().createIdentifierValue(CSSValueRow));
1905 case AutoFlowColumn:
1906 case AutoFlowColumnDense:
1907 list->append(cssValuePool().createIdentifierValue(CSSValueColumn));
1909 case AutoFlowStackRow:
1910 case AutoFlowStackColumn:
1911 list->append(cssValuePool().createIdentifierValue(CSSValueStack));
1914 ASSERT_NOT_REACHED();
1917 switch (style->gridAutoFlow()) {
1918 case AutoFlowRowDense:
1919 case AutoFlowColumnDense:
1920 list->append(cssValuePool().createIdentifierValue(CSSValueDense));
1922 case AutoFlowStackRow:
1923 list->append(cssValuePool().createIdentifierValue(CSSValueRow));
1925 case AutoFlowStackColumn:
1926 list->append(cssValuePool().createIdentifierValue(CSSValueColumn));
1933 return list.release();
1935 // Specs mention that getComputedStyle() should return the used value of the property instead of the computed
1936 // one for grid-definition-{rows|columns} but not for the grid-auto-{rows|columns} as things like
1937 // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as the '2fr' means very different things
1938 // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See
1939 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html
1940 case CSSPropertyGridAutoColumns:
1941 return specifiedValueForGridTrackSize(style->gridAutoColumns(), *style);
1942 case CSSPropertyGridAutoRows:
1943 return specifiedValueForGridTrackSize(style->gridAutoRows(), *style);
1945 case CSSPropertyGridTemplateColumns:
1946 return valueForGridTrackList(ForColumns, renderer, *style);
1947 case CSSPropertyGridTemplateRows:
1948 return valueForGridTrackList(ForRows, renderer, *style);
1950 case CSSPropertyGridColumnStart:
1951 return valueForGridPosition(style->gridColumnStart());
1952 case CSSPropertyGridColumnEnd:
1953 return valueForGridPosition(style->gridColumnEnd());
1954 case CSSPropertyGridRowStart:
1955 return valueForGridPosition(style->gridRowStart());
1956 case CSSPropertyGridRowEnd:
1957 return valueForGridPosition(style->gridRowEnd());
1958 case CSSPropertyGridColumn:
1959 return valuesForGridShorthand(gridColumnShorthand());
1960 case CSSPropertyGridRow:
1961 return valuesForGridShorthand(gridRowShorthand());
1962 case CSSPropertyGridArea:
1963 return valuesForGridShorthand(gridAreaShorthand());
1964 case CSSPropertyGridTemplate:
1965 return valuesForGridShorthand(gridTemplateShorthand());
1966 case CSSPropertyGrid:
1967 return valuesForGridShorthand(gridShorthand());
1968 case CSSPropertyGridTemplateAreas:
1969 if (!style->namedGridAreaRowCount()) {
1970 ASSERT(!style->namedGridAreaColumnCount());
1971 return cssValuePool().createIdentifierValue(CSSValueNone);
1974 return CSSGridTemplateAreasValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
1976 case CSSPropertyHeight:
1978 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
1979 // the "height" property does not apply for non-replaced inline elements.
1980 if (!renderer->isReplaced() && renderer->isInline())
1981 return cssValuePool().createIdentifierValue(CSSValueAuto);
1982 return zoomAdjustedPixelValue(sizingBox(renderer).height(), *style);
1984 return zoomAdjustedPixelValueForLength(style->height(), *style);
1985 case CSSPropertyWebkitHighlight:
1986 if (style->highlight() == nullAtom)
1987 return cssValuePool().createIdentifierValue(CSSValueNone);
1988 return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
1989 case CSSPropertyWebkitHyphenateCharacter:
1990 if (style->hyphenationString().isNull())
1991 return cssValuePool().createIdentifierValue(CSSValueAuto);
1992 return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
1993 case CSSPropertyWebkitBorderFit:
1994 if (style->borderFit() == BorderFitBorder)
1995 return cssValuePool().createIdentifierValue(CSSValueBorder);
1996 return cssValuePool().createIdentifierValue(CSSValueLines);
1997 case CSSPropertyImageRendering:
1998 return CSSPrimitiveValue::create(style->imageRendering());
1999 case CSSPropertyIsolation:
2000 return cssValuePool().createValue(style->isolation());
2001 case CSSPropertyJustifyItems:
2002 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->justifyItems(), styledNode), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType());
2003 case CSSPropertyJustifySelf:
2004 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->justifySelf(), styledNode->parentNode()), style->justifySelfOverflowAlignment(), NonLegacyPosition);
2005 case CSSPropertyLeft:
2006 return valueForPositionOffset(*style, CSSPropertyLeft, renderer);
2007 case CSSPropertyLetterSpacing:
2008 if (!style->letterSpacing())
2009 return cssValuePool().createIdentifierValue(CSSValueNormal);
2010 return zoomAdjustedPixelValue(style->letterSpacing(), *style);
2011 case CSSPropertyWebkitLineClamp:
2012 if (style->lineClamp().isNone())
2013 return cssValuePool().createIdentifierValue(CSSValueNone);
2014 return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2015 case CSSPropertyLineHeight:
2016 return valueForLineHeight(*style);
2017 case CSSPropertyListStyleImage:
2018 if (style->listStyleImage())
2019 return style->listStyleImage()->cssValue();
2020 return cssValuePool().createIdentifierValue(CSSValueNone);
2021 case CSSPropertyListStylePosition:
2022 return cssValuePool().createValue(style->listStylePosition());
2023 case CSSPropertyListStyleType:
2024 return cssValuePool().createValue(style->listStyleType());
2025 case CSSPropertyWebkitLocale:
2026 if (style->locale().isNull())
2027 return cssValuePool().createIdentifierValue(CSSValueAuto);
2028 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2029 case CSSPropertyMarginTop: {
2030 Length marginTop = style->marginTop();
2031 if (marginTop.isFixed() || !renderer || !renderer->isBox())
2032 return zoomAdjustedPixelValueForLength(marginTop, *style);
2033 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), *style);
2035 case CSSPropertyMarginRight: {
2036 Length marginRight = style->marginRight();
2037 if (marginRight.isFixed() || !renderer || !renderer->isBox())
2038 return zoomAdjustedPixelValueForLength(marginRight, *style);
2040 if (marginRight.isPercent()) {
2041 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2042 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2043 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2044 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent()).toFloat();
2046 value = toRenderBox(renderer)->marginRight().toFloat();
2048 return zoomAdjustedPixelValue(value, *style);
2050 case CSSPropertyMarginBottom: {
2051 Length marginBottom = style->marginBottom();
2052 if (marginBottom.isFixed() || !renderer || !renderer->isBox())
2053 return zoomAdjustedPixelValueForLength(marginBottom, *style);
2054 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), *style);
2056 case CSSPropertyMarginLeft: {
2057 Length marginLeft = style->marginLeft();
2058 if (marginLeft.isFixed() || !renderer || !renderer->isBox())
2059 return zoomAdjustedPixelValueForLength(marginLeft, *style);
2060 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), *style);
2062 case CSSPropertyWebkitUserModify:
2063 return cssValuePool().createValue(style->userModify());
2064 case CSSPropertyMaxHeight: {
2065 const Length& maxHeight = style->maxHeight();
2066 if (maxHeight.isUndefined())
2067 return cssValuePool().createIdentifierValue(CSSValueNone);
2068 return zoomAdjustedPixelValueForLength(maxHeight, *style);
2070 case CSSPropertyMaxWidth: {
2071 const Length& maxWidth = style->maxWidth();
2072 if (maxWidth.isUndefined())
2073 return cssValuePool().createIdentifierValue(CSSValueNone);
2074 return zoomAdjustedPixelValueForLength(maxWidth, *style);
2076 case CSSPropertyMinHeight:
2077 // FIXME: For flex-items, min-height:auto should compute to min-content.
2078 if (style->minHeight().isAuto())
2079 return zoomAdjustedPixelValue(0, *style);
2080 return zoomAdjustedPixelValueForLength(style->minHeight(), *style);
2081 case CSSPropertyMinWidth:
2082 // FIXME: For flex-items, min-width:auto should compute to min-content.
2083 if (style->minWidth().isAuto())
2084 return zoomAdjustedPixelValue(0, *style);
2085 return zoomAdjustedPixelValueForLength(style->minWidth(), *style);
2086 case CSSPropertyObjectFit:
2087 return cssValuePool().createValue(style->objectFit());
2088 case CSSPropertyObjectPosition:
2089 return cssValuePool().createValue(
2091 zoomAdjustedPixelValueForLength(style->objectPosition().x(), *style),
2092 zoomAdjustedPixelValueForLength(style->objectPosition().y(), *style),
2093 Pair::KeepIdenticalValues));
2094 case CSSPropertyOpacity:
2095 return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2096 case CSSPropertyOrphans:
2097 if (style->hasAutoOrphans())
2098 return cssValuePool().createIdentifierValue(CSSValueAuto);
2099 return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2100 case CSSPropertyOutlineColor:
2101 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(*style, style->outlineColor());
2102 case CSSPropertyOutlineOffset:
2103 return zoomAdjustedPixelValue(style->outlineOffset(), *style);
2104 case CSSPropertyOutlineStyle:
2105 if (style->outlineStyleIsAuto())
2106 return cssValuePool().createIdentifierValue(CSSValueAuto);
2107 return cssValuePool().createValue(style->outlineStyle());
2108 case CSSPropertyOutlineWidth:
2109 return zoomAdjustedPixelValue(style->outlineWidth(), *style);
2110 case CSSPropertyOverflow:
2111 return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
2112 case CSSPropertyOverflowWrap:
2113 return cssValuePool().createValue(style->overflowWrap());
2114 case CSSPropertyOverflowX:
2115 return cssValuePool().createValue(style->overflowX());
2116 case CSSPropertyOverflowY:
2117 return cssValuePool().createValue(style->overflowY());
2118 case CSSPropertyPaddingTop: {
2119 Length paddingTop = style->paddingTop();
2120 if (paddingTop.isFixed() || !renderer || !renderer->isBox())
2121 return zoomAdjustedPixelValueForLength(paddingTop, *style);
2122 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), *style);
2124 case CSSPropertyPaddingRight: {
2125 Length paddingRight = style->paddingRight();
2126 if (paddingRight.isFixed() || !renderer || !renderer->isBox())
2127 return zoomAdjustedPixelValueForLength(paddingRight, *style);
2128 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), *style);
2130 case CSSPropertyPaddingBottom: {
2131 Length paddingBottom = style->paddingBottom();
2132 if (paddingBottom.isFixed() || !renderer || !renderer->isBox())
2133 return zoomAdjustedPixelValueForLength(paddingBottom, *style);
2134 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), *style);
2136 case CSSPropertyPaddingLeft: {
2137 Length paddingLeft = style->paddingLeft();
2138 if (paddingLeft.isFixed() || !renderer || !renderer->isBox())
2139 return zoomAdjustedPixelValueForLength(paddingLeft, *style);
2140 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), *style);
2142 case CSSPropertyPageBreakAfter:
2143 return cssValuePool().createValue(style->pageBreakAfter());
2144 case CSSPropertyPageBreakBefore:
2145 return cssValuePool().createValue(style->pageBreakBefore());
2146 case CSSPropertyPageBreakInside: {
2147 EPageBreak pageBreak = style->pageBreakInside();
2148 ASSERT(pageBreak != PBALWAYS);
2149 if (pageBreak == PBALWAYS)
2151 return cssValuePool().createValue(style->pageBreakInside());
2153 case CSSPropertyPosition:
2154 return cssValuePool().createValue(style->position());
2155 case CSSPropertyRight:
2156 return valueForPositionOffset(*style, CSSPropertyRight, renderer);
2157 case CSSPropertyWebkitRubyPosition:
2158 return cssValuePool().createValue(style->rubyPosition());
2159 case CSSPropertyScrollBehavior:
2160 return cssValuePool().createValue(style->scrollBehavior());
2161 case CSSPropertyTableLayout:
2162 return cssValuePool().createValue(style->tableLayout());
2163 case CSSPropertyTextAlign:
2164 return cssValuePool().createValue(style->textAlign());
2165 case CSSPropertyTextAlignLast:
2166 return cssValuePool().createValue(style->textAlignLast());
2167 case CSSPropertyTextDecoration:
2168 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
2169 return valuesForShorthandProperty(textDecorationShorthand());
2171 case CSSPropertyTextDecorationLine:
2172 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2173 case CSSPropertyTextDecorationStyle:
2174 return valueForTextDecorationStyle(style->textDecorationStyle());
2175 case CSSPropertyTextDecorationColor:
2176 return currentColorOrValidColor(*style, style->textDecorationColor());
2177 case CSSPropertyTextJustify:
2178 return cssValuePool().createValue(style->textJustify());
2179 case CSSPropertyTextUnderlinePosition:
2180 return cssValuePool().createValue(style->textUnderlinePosition());
2181 case CSSPropertyWebkitTextDecorationsInEffect:
2182 return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2183 case CSSPropertyWebkitTextFillColor:
2184 return currentColorOrValidColor(*style, style->textFillColor());
2185 case CSSPropertyWebkitTextEmphasisColor:
2186 return currentColorOrValidColor(*style, style->textEmphasisColor());
2187 case CSSPropertyWebkitTextEmphasisPosition:
2188 return cssValuePool().createValue(style->textEmphasisPosition());
2189 case CSSPropertyWebkitTextEmphasisStyle:
2190 switch (style->textEmphasisMark()) {
2191 case TextEmphasisMarkNone:
2192 return cssValuePool().createIdentifierValue(CSSValueNone);
2193 case TextEmphasisMarkCustom:
2194 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2195 case TextEmphasisMarkAuto:
2196 ASSERT_NOT_REACHED();
2198 case TextEmphasisMarkDot:
2199 case TextEmphasisMarkCircle:
2200 case TextEmphasisMarkDoubleCircle:
2201 case TextEmphasisMarkTriangle:
2202 case TextEmphasisMarkSesame: {
2203 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2204 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2205 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2206 return list.release();
2209 case CSSPropertyTextIndent: {
2210 // If RuntimeEnabledFeatures::css3TextEnabled() returns false or text-indent has only one value(<length> | <percentage>),
2211 // getPropertyCSSValue() returns CSSValue.
2212 // If RuntimeEnabledFeatures::css3TextEnabled() returns true and text-indent has each-line or hanging,
2213 // getPropertyCSSValue() returns CSSValueList.
2214 RefPtrWillBeRawPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), *style);
2215 if (RuntimeEnabledFeatures::css3TextEnabled() && (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging)) {
2216 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2217 list->append(textIndent.release());
2218 if (style->textIndentLine() == TextIndentEachLine)
2219 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine));
2220 if (style->textIndentType() == TextIndentHanging)
2221 list->append(cssValuePool().createIdentifierValue(CSSValueHanging));
2222 return list.release();
2224 return textIndent.release();
2226 case CSSPropertyTextShadow:
2227 return valueForShadowList(style->textShadow(), *style, false);
2228 case CSSPropertyTextRendering:
2229 return cssValuePool().createValue(style->fontDescription().textRendering());
2230 case CSSPropertyTextOverflow:
2231 if (style->textOverflow())
2232 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2233 return cssValuePool().createIdentifierValue(CSSValueClip);
2234 case CSSPropertyWebkitTextSecurity:
2235 return cssValuePool().createValue(style->textSecurity());
2236 case CSSPropertyWebkitTextStrokeColor:
2237 return currentColorOrValidColor(*style, style->textStrokeColor());
2238 case CSSPropertyWebkitTextStrokeWidth:
2239 return zoomAdjustedPixelValue(style->textStrokeWidth(), *style);
2240 case CSSPropertyTextTransform:
2241 return cssValuePool().createValue(style->textTransform());
2242 case CSSPropertyTop:
2243 return valueForPositionOffset(*style, CSSPropertyTop, renderer);
2244 case CSSPropertyTouchAction:
2245 return touchActionFlagsToCSSValue(style->touchAction());
2246 case CSSPropertyTouchActionDelay:
2247 return cssValuePool().createValue(style->touchActionDelay());
2248 case CSSPropertyUnicodeBidi:
2249 return cssValuePool().createValue(style->unicodeBidi());
2250 case CSSPropertyVerticalAlign:
2251 switch (style->verticalAlign()) {
2253 return cssValuePool().createIdentifierValue(CSSValueBaseline);
2255 return cssValuePool().createIdentifierValue(CSSValueMiddle);
2257 return cssValuePool().createIdentifierValue(CSSValueSub);
2259 return cssValuePool().createIdentifierValue(CSSValueSuper);
2261 return cssValuePool().createIdentifierValue(CSSValueTextTop);
2263 return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2265 return cssValuePool().createIdentifierValue(CSSValueTop);
2267 return cssValuePool().createIdentifierValue(CSSValueBottom);
2268 case BASELINE_MIDDLE:
2269 return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2271 return zoomAdjustedPixelValueForLength(style->verticalAlignLength(), *style);
2273 ASSERT_NOT_REACHED();
2275 case CSSPropertyVisibility:
2276 return cssValuePool().createValue(style->visibility());
2277 case CSSPropertyWhiteSpace:
2278 return cssValuePool().createValue(style->whiteSpace());
2279 case CSSPropertyWidows:
2280 if (style->hasAutoWidows())
2281 return cssValuePool().createIdentifierValue(CSSValueAuto);
2282 return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2283 case CSSPropertyWidth:
2285 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2286 // the "width" property does not apply for non-replaced inline elements.
2287 if (!renderer->isReplaced() && renderer->isInline())
2288 return cssValuePool().createIdentifierValue(CSSValueAuto);
2289 return zoomAdjustedPixelValue(sizingBox(renderer).width(), *style);
2291 return zoomAdjustedPixelValueForLength(style->width(), *style);
2292 case CSSPropertyWillChange:
2293 return valueForWillChange(style->willChangeProperties(), style->willChangeContents(), style->willChangeScrollPosition());
2294 case CSSPropertyWordBreak:
2295 return cssValuePool().createValue(style->wordBreak());
2296 case CSSPropertyWordSpacing:
2297 return zoomAdjustedPixelValue(style->wordSpacing(), *style);
2298 case CSSPropertyWordWrap:
2299 return cssValuePool().createValue(style->overflowWrap());
2300 case CSSPropertyWebkitLineBreak:
2301 return cssValuePool().createValue(style->lineBreak());
2302 case CSSPropertyResize:
2303 return cssValuePool().createValue(style->resize());
2304 case CSSPropertyFontKerning:
2305 return cssValuePool().createValue(style->fontDescription().kerning());
2306 case CSSPropertyWebkitFontSmoothing:
2307 return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2308 case CSSPropertyFontVariantLigatures: {
2309 FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2310 FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2311 FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2312 FontDescription::LigaturesState contextualLigaturesState = style->fontDescription().contextualLigaturesState();
2313 if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2314 && historicalLigaturesState == FontDescription::NormalLigaturesState && contextualLigaturesState == FontDescription::NormalLigaturesState)
2315 return cssValuePool().createIdentifierValue(CSSValueNormal);
2317 RefPtrWillBeRawPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2318 if (commonLigaturesState != FontDescription::NormalLigaturesState)
2319 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2320 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2321 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2322 if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2323 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2324 if (contextualLigaturesState != FontDescription::NormalLigaturesState)
2325 valueList->append(cssValuePool().createIdentifierValue(contextualLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoContextual : CSSValueContextual));
2328 case CSSPropertyZIndex:
2329 if (style->hasAutoZIndex())
2330 return cssValuePool().createIdentifierValue(CSSValueAuto);
2331 return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2332 case CSSPropertyZoom:
2333 return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2334 case CSSPropertyBoxSizing:
2335 if (style->boxSizing() == CONTENT_BOX)
2336 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2337 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2338 case CSSPropertyWebkitAppRegion:
2339 return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2340 case CSSPropertyAnimationDelay:
2341 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2342 case CSSPropertyWebkitAnimationDelay:
2343 return valueForAnimationDelay(style->animations());
2344 case CSSPropertyAnimationDirection:
2345 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2346 case CSSPropertyWebkitAnimationDirection: {
2347 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2348 const CSSAnimationData* animationData = style->animations();
2349 if (animationData) {
2350 for (size_t i = 0; i < animationData->directionList().size(); ++i)
2351 list->append(valueForAnimationDirection(animationData->directionList()[i]));
2353 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2355 return list.release();
2357 case CSSPropertyAnimationDuration:
2358 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2359 case CSSPropertyWebkitAnimationDuration:
2360 return valueForAnimationDuration(style->animations());
2361 case CSSPropertyAnimationFillMode:
2362 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2363 case CSSPropertyWebkitAnimationFillMode: {
2364 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2365 const CSSAnimationData* animationData = style->animations();
2366 if (animationData) {
2367 for (size_t i = 0; i < animationData->fillModeList().size(); ++i)
2368 list->append(valueForAnimationFillMode(animationData->fillModeList()[i]));
2370 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2372 return list.release();
2374 case CSSPropertyAnimationIterationCount:
2375 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2376 case CSSPropertyWebkitAnimationIterationCount: {
2377 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2378 const CSSAnimationData* animationData = style->animations();
2379 if (animationData) {
2380 for (size_t i = 0; i < animationData->iterationCountList().size(); ++i)
2381 list->append(valueForAnimationIterationCount(animationData->iterationCountList()[i]));
2383 list->append(cssValuePool().createValue(CSSAnimationData::initialIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2385 return list.release();
2387 case CSSPropertyAnimationName:
2388 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2389 case CSSPropertyWebkitAnimationName: {
2390 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2391 const CSSAnimationData* animationData = style->animations();
2392 if (animationData) {
2393 for (size_t i = 0; i < animationData->nameList().size(); ++i)
2394 list->append(cssValuePool().createValue(animationData->nameList()[i], CSSPrimitiveValue::CSS_STRING));
2396 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2398 return list.release();
2400 case CSSPropertyAnimationPlayState:
2401 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2402 case CSSPropertyWebkitAnimationPlayState: {
2403 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2404 const CSSAnimationData* animationData = style->animations();
2405 if (animationData) {
2406 for (size_t i = 0; i < animationData->playStateList().size(); ++i)
2407 list->append(valueForAnimationPlayState(animationData->playStateList()[i]));
2409 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2411 return list.release();
2413 case CSSPropertyAnimationTimingFunction:
2414 ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
2415 case CSSPropertyWebkitAnimationTimingFunction:
2416 return valueForAnimationTimingFunction(style->animations());
2417 case CSSPropertyAnimation:
2418 case CSSPropertyWebkitAnimation: {
2419 const CSSAnimationData* animationData = style->animations();
2420 if (animationData) {
2421 RefPtrWillBeRawPtr<CSSValueList> animationsList = CSSValueList::createCommaSeparated();
2422 for (size_t i = 0; i < animationData->nameList().size(); ++i) {
2423 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2424 list->append(cssValuePool().createValue(animationData->nameList()[i], CSSPrimitiveValue::CSS_STRING));
2425 list->append(cssValuePool().createValue(CSSTimingData::getRepeated(animationData->durationList(), i), CSSPrimitiveValue::CSS_S));
2426 list->append(createTimingFunctionValue(CSSTimingData::getRepeated(animationData->timingFunctionList(), i).get()));
2427 list->append(cssValuePool().createValue(CSSTimingData::getRepeated(animationData->delayList(), i), CSSPrimitiveValue::CSS_S));
2428 list->append(valueForAnimationIterationCount(CSSTimingData::getRepeated(animationData->iterationCountList(), i)));
2429 list->append(valueForAnimationDirection(CSSTimingData::getRepeated(animationData->directionList(), i)));
2430 list->append(valueForAnimationFillMode(CSSTimingData::getRepeated(animationData->fillModeList(), i)));
2431 list->append(valueForAnimationPlayState(CSSTimingData::getRepeated(animationData->playStateList(), i)));
2432 animationsList->append(list);
2434 return animationsList.release();
2437 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2438 // animation-name default value.
2439 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2440 list->append(cssValuePool().createValue(CSSAnimationData::initialDuration(), CSSPrimitiveValue::CSS_S));
2441 list->append(createTimingFunctionValue(CSSAnimationData::initialTimingFunction().get()));
2442 list->append(cssValuePool().createValue(CSSAnimationData::initialDelay(), CSSPrimitiveValue::CSS_S));
2443 list->append(cssValuePool().createValue(CSSAnimationData::initialIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2444 list->append(valueForAnimationDirection(CSSAnimationData::initialDirection()));
2445 list->append(valueForAnimationFillMode(CSSAnimationData::initialFillMode()));
2446 // Initial animation-play-state.
2447 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2448 return list.release();
2450 case CSSPropertyWebkitAppearance:
2451 return cssValuePool().createValue(style->appearance());
2452 case CSSPropertyWebkitAspectRatio:
2453 if (!style->hasAspectRatio())
2454 return cssValuePool().createIdentifierValue(CSSValueNone);
2455 return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2456 case CSSPropertyBackfaceVisibility:
2457 case CSSPropertyWebkitBackfaceVisibility:
2458 return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2459 case CSSPropertyWebkitBorderImage:
2460 return valueForNinePieceImage(style->borderImage(), *style);
2461 case CSSPropertyBorderImageOutset:
2462 return valueForNinePieceImageQuad(style->borderImage().outset(), *style);
2463 case CSSPropertyBorderImageRepeat:
2464 return valueForNinePieceImageRepeat(style->borderImage());
2465 case CSSPropertyBorderImageSlice:
2466 return valueForNinePieceImageSlice(style->borderImage());
2467 case CSSPropertyBorderImageWidth:
2468 return valueForNinePieceImageQuad(style->borderImage().borderSlices(), *style);
2469 case CSSPropertyWebkitMaskBoxImage:
2470 return valueForNinePieceImage(style->maskBoxImage(), *style);
2471 case CSSPropertyWebkitMaskBoxImageOutset:
2472 return valueForNinePieceImageQuad(style->maskBoxImage().outset(), *style);
2473 case CSSPropertyWebkitMaskBoxImageRepeat:
2474 return valueForNinePieceImageRepeat(style->maskBoxImage());
2475 case CSSPropertyWebkitMaskBoxImageSlice:
2476 return valueForNinePieceImageSlice(style->maskBoxImage());
2477 case CSSPropertyWebkitMaskBoxImageWidth:
2478 return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices(), *style);
2479 case CSSPropertyWebkitMaskBoxImageSource:
2480 if (style->maskBoxImageSource())
2481 return style->maskBoxImageSource()->cssValue();
2482 return cssValuePool().createIdentifierValue(CSSValueNone);
2483 case CSSPropertyWebkitFontSizeDelta:
2484 // Not a real style property -- used by the editing engine -- so has no computed value.
2486 case CSSPropertyWebkitMarginBottomCollapse:
2487 case CSSPropertyWebkitMarginAfterCollapse:
2488 return cssValuePool().createValue(style->marginAfterCollapse());
2489 case CSSPropertyWebkitMarginTopCollapse:
2490 case CSSPropertyWebkitMarginBeforeCollapse:
2491 return cssValuePool().createValue(style->marginBeforeCollapse());
2492 case CSSPropertyPerspective:
2493 case CSSPropertyWebkitPerspective:
2494 if (!style->hasPerspective())
2495 return cssValuePool().createIdentifierValue(CSSValueNone);
2496 return zoomAdjustedPixelValue(style->perspective(), *style);
2497 case CSSPropertyPerspectiveOrigin:
2498 case CSSPropertyWebkitPerspectiveOrigin: {
2499 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2502 if (renderer->isBox())
2503 box = toRenderBox(renderer)->borderBoxRect();
2505 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width()), *style));
2506 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height()), *style));
2509 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), *style));
2510 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), *style));
2513 return list.release();
2515 case CSSPropertyWebkitRtlOrdering:
2516 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2517 case CSSPropertyWebkitTapHighlightColor:
2518 return currentColorOrValidColor(*style, style->tapHighlightColor());
2519 case CSSPropertyWebkitUserDrag:
2520 return cssValuePool().createValue(style->userDrag());
2521 case CSSPropertyWebkitUserSelect:
2522 return cssValuePool().createValue(style->userSelect());
2523 case CSSPropertyBorderBottomLeftRadius:
2524 return valueForBorderRadiusCorner(style->borderBottomLeftRadius(), *style);
2525 case CSSPropertyBorderBottomRightRadius:
2526 return valueForBorderRadiusCorner(style->borderBottomRightRadius(), *style);
2527 case CSSPropertyBorderTopLeftRadius:
2528 return valueForBorderRadiusCorner(style->borderTopLeftRadius(), *style);
2529 case CSSPropertyBorderTopRightRadius:
2530 return valueForBorderRadiusCorner(style->borderTopRightRadius(), *style);
2531 case CSSPropertyClip: {
2532 if (!style->hasClip())
2533 return cssValuePool().createIdentifierValue(CSSValueAuto);
2534 RefPtrWillBeRawPtr<Rect> rect = Rect::create();
2535 rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), *style));
2536 rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), *style));
2537 rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), *style));
2538 rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), *style));
2539 return cssValuePool().createValue(rect.release());
2541 case CSSPropertySpeak:
2542 return cssValuePool().createValue(style->speak());
2543 case CSSPropertyTransform:
2544 case CSSPropertyWebkitTransform:
2545 return computedTransform(renderer, *style);
2546 case CSSPropertyTransformOrigin:
2547 case CSSPropertyWebkitTransformOrigin: {
2548 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2551 if (renderer->isBox())
2552 box = toRenderBox(renderer)->borderBoxRect();
2554 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width()), *style));
2555 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height()), *style));
2556 if (style->transformOriginZ() != 0)
2557 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), *style));
2559 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), *style));
2560 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), *style));
2561 if (style->transformOriginZ() != 0)
2562 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), *style));
2564 return list.release();
2566 case CSSPropertyTransformStyle:
2567 case CSSPropertyWebkitTransformStyle:
2568 return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2569 case CSSPropertyTransitionDelay:
2570 case CSSPropertyWebkitTransitionDelay:
2571 return valueForAnimationDelay(style->transitions());
2572 case CSSPropertyTransitionDuration:
2573 case CSSPropertyWebkitTransitionDuration:
2574 return valueForAnimationDuration(style->transitions());
2575 case CSSPropertyTransitionProperty:
2576 case CSSPropertyWebkitTransitionProperty:
2577 return valueForTransitionProperty(style->transitions());
2578 case CSSPropertyTransitionTimingFunction:
2579 case CSSPropertyWebkitTransitionTimingFunction:
2580 return valueForAnimationTimingFunction(style->transitions());
2581 case CSSPropertyTransition:
2582 case CSSPropertyWebkitTransition: {
2583 const CSSTransitionData* transitionData = style->transitions();
2584 if (transitionData) {
2585 RefPtrWillBeRawPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2586 for (size_t i = 0; i < transitionData->propertyList().size(); ++i) {
2587 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2588 list->append(createTransitionPropertyValue(transitionData->propertyList()[i]));
2589 list->append(cssValuePool().createValue(CSSTimingData::getRepeated(transitionData->durationList(), i), CSSPrimitiveValue::CSS_S));
2590 list->append(createTimingFunctionValue(CSSTimingData::getRepeated(transitionData->timingFunctionList(), i).get()));
2591 list->append(cssValuePool().createValue(CSSTimingData::getRepeated(transitionData->delayList(), i), CSSPrimitiveValue::CSS_S));
2592 transitionsList->append(list);
2594 return transitionsList.release();
2597 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2598 // transition-property default value.
2599 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2600 list->append(cssValuePool().createValue(CSSTransitionData::initialDuration(), CSSPrimitiveValue::CSS_S));
2601 list->append(createTimingFunctionValue(CSSTransitionData::initialTimingFunction().get()));
2602 list->append(cssValuePool().createValue(CSSTransitionData::initialDelay(), CSSPrimitiveValue::CSS_S));
2603 return list.release();
2605 case CSSPropertyPointerEvents:
2606 return cssValuePool().createValue(style->pointerEvents());
2607 case CSSPropertyWebkitWritingMode:
2608 return cssValuePool().createValue(style->writingMode());
2609 case CSSPropertyWebkitTextCombine:
2610 return cssValuePool().createValue(style->textCombine());
2611 case CSSPropertyWebkitTextOrientation:
2612 return CSSPrimitiveValue::create(style->textOrientation());
2613 case CSSPropertyWebkitLineBoxContain:
2614 return createLineBoxContainValue(style->lineBoxContain());
2615 case CSSPropertyContent:
2616 return valueForContentData(*style);
2617 case CSSPropertyCounterIncrement:
2618 return valueForCounterDirectives(*style, propertyID);
2619 case CSSPropertyCounterReset:
2620 return valueForCounterDirectives(*style, propertyID);
2621 case CSSPropertyWebkitClipPath:
2622 if (ClipPathOperation* operation = style->clipPath()) {
2623 if (operation->type() == ClipPathOperation::SHAPE)
2624 return valueForBasicShape(*style, toShapeClipPathOperation(operation)->basicShape());
2625 if (operation->type() == ClipPathOperation::REFERENCE)
2626 return CSSPrimitiveValue::create(toReferenceClipPathOperation(operation)->url(), CSSPrimitiveValue::CSS_URI);
2628 return cssValuePool().createIdentifierValue(CSSValueNone);
2629 case CSSPropertyShapeMargin:
2630 return cssValuePool().createValue(style->shapeMargin(), *style);
2631 case CSSPropertyShapeImageThreshold:
2632 return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2633 case CSSPropertyShapeOutside:
2634 return valueForShape(*style, style->shapeOutside());
2635 case CSSPropertyWebkitFilter:
2636 return valueForFilter(renderer, *style);
2637 case CSSPropertyMixBlendMode:
2638 return cssValuePool().createValue(style->blendMode());
2640 case CSSPropertyBackgroundBlendMode: {
2641 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2642 for (const FillLayer* currLayer = &style->backgroundLayers(); currLayer; currLayer = currLayer->next())
2643 list->append(cssValuePool().createValue(currLayer->blendMode()));
2644 return list.release();
2646 case CSSPropertyBackground:
2647 return valuesForBackgroundShorthand();
2648 case CSSPropertyBorder: {
2649 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2650 const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2651 CSSPropertyBorderLeft };
2652 for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2653 if (!compareCSSValuePtr<CSSValue>(value, getPropertyCSSValue(properties[i], DoNotUpdateLayout)))
2656 return value.release();
2658 case CSSPropertyBorderBottom:
2659 return valuesForShorthandProperty(borderBottomShorthand());
2660 case CSSPropertyBorderColor:
2661 return valuesForSidesShorthand(borderColorShorthand());
2662 case CSSPropertyBorderLeft:
2663 return valuesForShorthandProperty(borderLeftShorthand());
2664 case CSSPropertyBorderImage:
2665 return valueForNinePieceImage(style->borderImage(), *style);
2666 case CSSPropertyBorderRadius:
2667 return valueForBorderRadiusShorthand(*style);
2668 case CSSPropertyBorderRight:
2669 return valuesForShorthandProperty(borderRightShorthand());
2670 case CSSPropertyBorderStyle:
2671 return valuesForSidesShorthand(borderStyleShorthand());
2672 case CSSPropertyBorderTop:
2673 return valuesForShorthandProperty(borderTopShorthand());
2674 case CSSPropertyBorderWidth:
2675 return valuesForSidesShorthand(borderWidthShorthand());
2676 case CSSPropertyWebkitColumnRule:
2677 return valuesForShorthandProperty(webkitColumnRuleShorthand());
2678 case CSSPropertyWebkitColumns:
2679 return valuesForShorthandProperty(webkitColumnsShorthand());
2680 case CSSPropertyListStyle:
2681 return valuesForShorthandProperty(listStyleShorthand());
2682 case CSSPropertyMargin:
2683 return valuesForSidesShorthand(marginShorthand());
2684 case CSSPropertyOutline:
2685 return valuesForShorthandProperty(outlineShorthand());
2686 case CSSPropertyPadding:
2687 return valuesForSidesShorthand(paddingShorthand());
2688 /* Individual properties not part of the spec */
2689 case CSSPropertyBackgroundRepeatX:
2690 case CSSPropertyBackgroundRepeatY:
2692 case CSSPropertyInternalCallback:
2693 // This property is hidden from the web.
2696 /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2697 case CSSPropertyWebkitTextEmphasis:
2700 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2701 case CSSPropertyWebkitBorderEnd:
2702 case CSSPropertyWebkitBorderEndColor:
2703 case CSSPropertyWebkitBorderEndStyle:
2704 case CSSPropertyWebkitBorderEndWidth:
2705 case CSSPropertyWebkitBorderStart:
2706 case CSSPropertyWebkitBorderStartColor:
2707 case CSSPropertyWebkitBorderStartStyle:
2708 case CSSPropertyWebkitBorderStartWidth:
2709 case CSSPropertyWebkitBorderAfter:
2710 case CSSPropertyWebkitBorderAfterColor:
2711 case CSSPropertyWebkitBorderAfterStyle:
2712 case CSSPropertyWebkitBorderAfterWidth:
2713 case CSSPropertyWebkitBorderBefore:
2714 case CSSPropertyWebkitBorderBeforeColor:
2715 case CSSPropertyWebkitBorderBeforeStyle:
2716 case CSSPropertyWebkitBorderBeforeWidth:
2717 case CSSPropertyWebkitMarginEnd:
2718 case CSSPropertyWebkitMarginStart:
2719 case CSSPropertyWebkitMarginAfter:
2720 case CSSPropertyWebkitMarginBefore:
2721 case CSSPropertyWebkitPaddingEnd:
2722 case CSSPropertyWebkitPaddingStart:
2723 case CSSPropertyWebkitPaddingAfter:
2724 case CSSPropertyWebkitPaddingBefore:
2725 case CSSPropertyWebkitLogicalWidth:
2726 case CSSPropertyWebkitLogicalHeight:
2727 case CSSPropertyWebkitMinLogicalWidth:
2728 case CSSPropertyWebkitMinLogicalHeight:
2729 case CSSPropertyWebkitMaxLogicalWidth:
2730 case CSSPropertyWebkitMaxLogicalHeight:
2731 ASSERT_NOT_REACHED();
2734 /* Unimplemented @font-face properties */
2735 case CSSPropertySrc:
2736 case CSSPropertyUnicodeRange:
2739 /* Other unimplemented properties */
2740 case CSSPropertyPage: // for @page
2741 case CSSPropertyQuotes: // FIXME: needs implementation
2742 case CSSPropertySize: // for @page
2745 /* Unimplemented -webkit- properties */
2746 case CSSPropertyWebkitBorderRadius:
2747 case CSSPropertyWebkitMarginCollapse:
2748 case CSSPropertyWebkitMask:
2749 case CSSPropertyWebkitMaskRepeatX:
2750 case CSSPropertyWebkitMaskRepeatY:
2751 case CSSPropertyWebkitPerspectiveOriginX:
2752 case CSSPropertyWebkitPerspectiveOriginY:
2753 case CSSPropertyWebkitTextStroke:
2754 case CSSPropertyWebkitTransformOriginX:
2755 case CSSPropertyWebkitTransformOriginY:
2756 case CSSPropertyWebkitTransformOriginZ:
2759 /* @viewport rule properties */
2760 case CSSPropertyMaxZoom:
2761 case CSSPropertyMinZoom:
2762 case CSSPropertyOrientation:
2763 case CSSPropertyUserZoom:
2766 // Internal properties that shouldn't be exposed throught getComputedStyle.
2767 case CSSPropertyInternalMarqueeDirection:
2768 case CSSPropertyInternalMarqueeIncrement:
2769 case CSSPropertyInternalMarqueeRepetition:
2770 case CSSPropertyInternalMarqueeSpeed:
2771 case CSSPropertyInternalMarqueeStyle:
2772 ASSERT_NOT_REACHED();
2775 case CSSPropertyBufferedRendering:
2776 case CSSPropertyClipPath:
2777 case CSSPropertyClipRule:
2778 case CSSPropertyMask:
2779 case CSSPropertyEnableBackground:
2780 case CSSPropertyFilter:
2781 case CSSPropertyFloodColor:
2782 case CSSPropertyFloodOpacity:
2783 case CSSPropertyLightingColor:
2784 case CSSPropertyStopColor:
2785 case CSSPropertyStopOpacity:
2786 case CSSPropertyColorInterpolation:
2787 case CSSPropertyColorInterpolationFilters:
2788 case CSSPropertyColorRendering:
2789 case CSSPropertyFill:
2790 case CSSPropertyFillOpacity:
2791 case CSSPropertyFillRule:
2792 case CSSPropertyMarker:
2793 case CSSPropertyMarkerEnd:
2794 case CSSPropertyMarkerMid:
2795 case CSSPropertyMarkerStart:
2796 case CSSPropertyMaskType:
2797 case CSSPropertyShapeRendering:
2798 case CSSPropertyStroke:
2799 case CSSPropertyStrokeDasharray:
2800 case CSSPropertyStrokeDashoffset:
2801 case CSSPropertyStrokeLinecap:
2802 case CSSPropertyStrokeLinejoin:
2803 case CSSPropertyStrokeMiterlimit:
2804 case CSSPropertyStrokeOpacity:
2805 case CSSPropertyStrokeWidth:
2806 case CSSPropertyAlignmentBaseline:
2807 case CSSPropertyBaselineShift:
2808 case CSSPropertyDominantBaseline:
2809 case CSSPropertyGlyphOrientationHorizontal:
2810 case CSSPropertyGlyphOrientationVertical:
2811 case CSSPropertyTextAnchor:
2812 case CSSPropertyVectorEffect:
2813 case CSSPropertyPaintOrder:
2814 case CSSPropertyWritingMode:
2815 return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
2817 case CSSPropertyAll:
2821 logUnimplementedPropertyID(propertyID);
2825 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
2827 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2829 return value->cssText();
2834 unsigned CSSComputedStyleDeclaration::length() const
2836 Node* node = m_node.get();
2840 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
2844 return computableProperties().size();
2847 String CSSComputedStyleDeclaration::item(unsigned i) const
2852 return getPropertyNameString(computableProperties()[i]);
2855 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
2857 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() && m_node) {
2858 m_node->document().updateLayoutIgnorePendingStylesheets();
2859 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
2860 if (style && style->fontDescription().keywordSize()) {
2861 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
2862 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(propertyValue);
2863 if (primitiveValue->isValueID() && primitiveValue->getValueID() == sizeValue)
2867 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2868 return value && propertyValue && value->equals(*propertyValue);
2871 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() const
2873 return copyPropertiesInSet(computableProperties());
2876 PassRefPtrWillBeRawPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForShorthandProperty(const StylePropertyShorthand& shorthand) const
2878 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2879 for (size_t i = 0; i < shorthand.length(); ++i) {
2880 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2881 list->append(value);
2883 return list.release();
2886 PassRefPtrWillBeRawPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
2888 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2889 // Assume the properties are in the usual order top, right, bottom, left.
2890 RefPtrWillBeRawPtr<CSSValue> topValue = getPropertyCSSValue(shorthand.properties()[0], DoNotUpdateLayout);
2891 RefPtrWillBeRawPtr<CSSValue> rightValue = getPropertyCSSValue(shorthand.properties()[1], DoNotUpdateLayout);
2892 RefPtrWillBeRawPtr<CSSValue> bottomValue = getPropertyCSSValue(shorthand.properties()[2], DoNotUpdateLayout);
2893 RefPtrWillBeRawPtr<CSSValue> leftValue = getPropertyCSSValue(shorthand.properties()[3], DoNotUpdateLayout);
2895 // All 4 properties must be specified.
2896 if (!topValue || !rightValue || !bottomValue || !leftValue)
2899 bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
2900 bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
2901 bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
2903 list->append(topValue.release());
2905 list->append(rightValue.release());
2907 list->append(bottomValue.release());
2909 list->append(leftValue.release());
2911 return list.release();
2914 PassRefPtrWillBeRawPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForGridShorthand(const StylePropertyShorthand& shorthand) const
2916 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
2917 for (size_t i = 0; i < shorthand.length(); ++i) {
2918 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2919 list->append(value.release());
2921 return list.release();
2924 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const Vector<CSSPropertyID>& properties) const
2926 WillBeHeapVector<CSSProperty, 256> list;
2927 list.reserveInitialCapacity(properties.size());
2928 for (unsigned i = 0; i < properties.size(); ++i) {
2929 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
2931 list.append(CSSProperty(properties[i], value.release(), false));
2933 return MutableStylePropertySet::create(list.data(), list.size());
2936 CSSRule* CSSComputedStyleDeclaration::parentRule() const
2941 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
2943 CSSPropertyID propertyID = cssPropertyID(propertyName);
2946 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2947 return value ? value->cloneForCSSOM() : nullptr;
2950 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
2952 CSSPropertyID propertyID = cssPropertyID(propertyName);
2953 if (!propertyID || !RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID))
2955 return getPropertyValue(propertyID);
2958 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
2960 // All computed styles have a priority of not "important".
2964 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
2969 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
2974 void CSSComputedStyleDeclaration::setProperty(const String& name, const String&, const String&, ExceptionState& exceptionState)
2976 exceptionState.throwDOMException(NoModificationAllowedError, "These styles are computed, and therefore the '" + name + "' property is read-only.");
2979 String CSSComputedStyleDeclaration::removeProperty(const String& name, ExceptionState& exceptionState)
2981 exceptionState.throwDOMException(NoModificationAllowedError, "These styles are computed, and therefore the '" + name + "' property is read-only.");
2985 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
2987 return getPropertyCSSValue(propertyID);
2990 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
2992 return getPropertyValue(propertyID);
2995 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const String&, bool, ExceptionState& exceptionState)
2997 exceptionState.throwDOMException(NoModificationAllowedError, "These styles are computed, and therefore the '" + getPropertyNameString(id) + "' property is read-only.");
3000 PassRefPtrWillBeRawPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForBackgroundShorthand() const
3002 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3003 CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
3004 CSSPropertyBackgroundPosition };
3005 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin,
3006 CSSPropertyBackgroundClip };
3008 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3009 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3010 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3011 return list.release();
3014 void CSSComputedStyleDeclaration::trace(Visitor* visitor)
3016 visitor->trace(m_node);
3017 CSSStyleDeclaration::trace(visitor);
3020 } // namespace blink