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 "CSSComputedStyleDeclaration.h"
27 #include "AnimationController.h"
28 #include "BasicShapeFunctions.h"
29 #include "BasicShapes.h"
30 #include "CSSAspectRatioValue.h"
31 #include "CSSBasicShapes.h"
32 #include "CSSBorderImage.h"
33 #include "CSSFunctionValue.h"
34 #include "CSSLineBoxContainValue.h"
35 #include "CSSParser.h"
36 #include "CSSPrimitiveValue.h"
37 #include "CSSPrimitiveValueMappings.h"
38 #include "CSSPropertyNames.h"
39 #include "CSSReflectValue.h"
40 #include "CSSSelector.h"
41 #include "CSSTimingFunctionValue.h"
42 #include "CSSValueList.h"
43 #include "CSSValuePool.h"
44 #include "ContentData.h"
45 #include "CounterContent.h"
46 #include "CursorList.h"
48 #include "ExceptionCode.h"
49 #include "FontFeatureSettings.h"
50 #include "FontFeatureValue.h"
51 #include "FontValue.h"
52 #include "HTMLFrameOwnerElement.h"
54 #include "PseudoElement.h"
56 #include "RenderBox.h"
57 #include "RenderStyle.h"
58 #include "RenderView.h"
59 #include "ShadowValue.h"
60 #include "StyleInheritedData.h"
61 #include "StylePropertySet.h"
62 #include "StylePropertyShorthand.h"
63 #include "StyleResolver.h"
64 #include "WebCoreMemoryInstrumentation.h"
65 #include "WebKitCSSTransformValue.h"
66 #include "WebKitFontFamilyNames.h"
67 #include <wtf/text/StringBuilder.h>
69 #if ENABLE(CSS_EXCLUSIONS)
70 #include "ExclusionShapeValue.h"
73 #if ENABLE(CSS_SHADERS)
74 #include "CustomFilterArrayParameter.h"
75 #include "CustomFilterNumberParameter.h"
76 #include "CustomFilterOperation.h"
77 #include "CustomFilterParameter.h"
78 #include "CustomFilterTransformParameter.h"
79 #include "WebKitCSSArrayFunctionValue.h"
80 #include "WebKitCSSMixFunctionValue.h"
83 #if ENABLE(CSS_FILTERS)
84 #include "StyleCustomFilterProgram.h"
85 #include "WebKitCSSFilterValue.h"
88 #if ENABLE(DASHBOARD_SUPPORT)
89 #include "DashboardRegion.h"
94 // List of all properties we know how to compute, omitting shorthands.
95 static const CSSPropertyID computedProperties[] = {
96 CSSPropertyBackgroundAttachment,
97 CSSPropertyBackgroundClip,
98 CSSPropertyBackgroundColor,
99 CSSPropertyBackgroundImage,
100 CSSPropertyBackgroundOrigin,
101 CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
102 CSSPropertyBackgroundRepeat,
103 CSSPropertyBackgroundSize,
104 CSSPropertyBorderBottomColor,
105 CSSPropertyBorderBottomLeftRadius,
106 CSSPropertyBorderBottomRightRadius,
107 CSSPropertyBorderBottomStyle,
108 CSSPropertyBorderBottomWidth,
109 CSSPropertyBorderCollapse,
110 CSSPropertyBorderImageOutset,
111 CSSPropertyBorderImageRepeat,
112 CSSPropertyBorderImageSlice,
113 CSSPropertyBorderImageSource,
114 CSSPropertyBorderImageWidth,
115 CSSPropertyBorderLeftColor,
116 CSSPropertyBorderLeftStyle,
117 CSSPropertyBorderLeftWidth,
118 CSSPropertyBorderRightColor,
119 CSSPropertyBorderRightStyle,
120 CSSPropertyBorderRightWidth,
121 CSSPropertyBorderTopColor,
122 CSSPropertyBorderTopLeftRadius,
123 CSSPropertyBorderTopRightRadius,
124 CSSPropertyBorderTopStyle,
125 CSSPropertyBorderTopWidth,
127 CSSPropertyBoxShadow,
128 CSSPropertyBoxSizing,
129 CSSPropertyCaptionSide,
134 CSSPropertyDirection,
136 CSSPropertyEmptyCells,
138 CSSPropertyFontFamily,
140 CSSPropertyFontStyle,
141 CSSPropertyFontVariant,
142 CSSPropertyFontWeight,
144 #if ENABLE(CSS_IMAGE_ORIENTATION)
145 CSSPropertyImageOrientation,
147 CSSPropertyImageRendering,
148 #if ENABLE(CSS_IMAGE_RESOLUTION)
149 CSSPropertyImageResolution,
152 CSSPropertyLetterSpacing,
153 CSSPropertyLineHeight,
154 CSSPropertyListStyleImage,
155 CSSPropertyListStylePosition,
156 CSSPropertyListStyleType,
157 CSSPropertyMarginBottom,
158 CSSPropertyMarginLeft,
159 CSSPropertyMarginRight,
160 CSSPropertyMarginTop,
161 CSSPropertyMaxHeight,
163 CSSPropertyMinHeight,
167 CSSPropertyOutlineColor,
168 CSSPropertyOutlineOffset,
169 CSSPropertyOutlineStyle,
170 CSSPropertyOutlineWidth,
171 CSSPropertyOverflowWrap,
172 CSSPropertyOverflowX,
173 CSSPropertyOverflowY,
174 CSSPropertyPaddingBottom,
175 CSSPropertyPaddingLeft,
176 CSSPropertyPaddingRight,
177 CSSPropertyPaddingTop,
178 CSSPropertyPageBreakAfter,
179 CSSPropertyPageBreakBefore,
180 CSSPropertyPageBreakInside,
181 CSSPropertyPointerEvents,
186 CSSPropertyTableLayout,
188 CSSPropertyTextAlign,
189 CSSPropertyTextDecoration,
190 #if ENABLE(CSS3_TEXT)
191 CSSPropertyWebkitTextDecorationLine,
192 CSSPropertyWebkitTextDecorationStyle,
193 CSSPropertyWebkitTextAlignLast,
195 CSSPropertyTextIndent,
196 CSSPropertyTextRendering,
197 CSSPropertyTextShadow,
198 CSSPropertyTextOverflow,
199 CSSPropertyTextTransform,
201 CSSPropertyTransitionDelay,
202 CSSPropertyTransitionDuration,
203 CSSPropertyTransitionProperty,
204 CSSPropertyTransitionTimingFunction,
205 CSSPropertyUnicodeBidi,
206 CSSPropertyVerticalAlign,
207 CSSPropertyVisibility,
208 CSSPropertyWhiteSpace,
211 CSSPropertyWordBreak,
212 CSSPropertyWordSpacing,
217 CSSPropertyWebkitAnimationDelay,
218 CSSPropertyWebkitAnimationDirection,
219 CSSPropertyWebkitAnimationDuration,
220 CSSPropertyWebkitAnimationFillMode,
221 CSSPropertyWebkitAnimationIterationCount,
222 CSSPropertyWebkitAnimationName,
223 CSSPropertyWebkitAnimationPlayState,
224 CSSPropertyWebkitAnimationTimingFunction,
225 CSSPropertyWebkitAppearance,
226 CSSPropertyWebkitBackfaceVisibility,
227 CSSPropertyWebkitBackgroundClip,
228 CSSPropertyWebkitBackgroundComposite,
229 CSSPropertyWebkitBackgroundOrigin,
230 CSSPropertyWebkitBackgroundSize,
231 #if ENABLE(CSS_COMPOSITING)
232 CSSPropertyWebkitBlendMode,
233 CSSPropertyWebkitBackgroundBlendMode,
235 CSSPropertyWebkitBorderFit,
236 CSSPropertyWebkitBorderHorizontalSpacing,
237 CSSPropertyWebkitBorderImage,
238 CSSPropertyWebkitBorderVerticalSpacing,
239 CSSPropertyWebkitBoxAlign,
240 #if ENABLE(CSS_BOX_DECORATION_BREAK)
241 CSSPropertyWebkitBoxDecorationBreak,
243 CSSPropertyWebkitBoxDirection,
244 CSSPropertyWebkitBoxFlex,
245 CSSPropertyWebkitBoxFlexGroup,
246 CSSPropertyWebkitBoxLines,
247 CSSPropertyWebkitBoxOrdinalGroup,
248 CSSPropertyWebkitBoxOrient,
249 CSSPropertyWebkitBoxPack,
250 CSSPropertyWebkitBoxReflect,
251 CSSPropertyWebkitBoxShadow,
252 CSSPropertyWebkitClipPath,
253 CSSPropertyWebkitColorCorrection,
254 CSSPropertyWebkitColumnBreakAfter,
255 CSSPropertyWebkitColumnBreakBefore,
256 CSSPropertyWebkitColumnBreakInside,
257 CSSPropertyWebkitColumnAxis,
258 CSSPropertyWebkitColumnCount,
259 CSSPropertyWebkitColumnGap,
260 CSSPropertyWebkitColumnProgression,
261 CSSPropertyWebkitColumnRuleColor,
262 CSSPropertyWebkitColumnRuleStyle,
263 CSSPropertyWebkitColumnRuleWidth,
264 CSSPropertyWebkitColumnSpan,
265 CSSPropertyWebkitColumnWidth,
266 #if ENABLE(DASHBOARD_SUPPORT)
267 CSSPropertyWebkitDashboardRegion,
269 #if ENABLE(CSS_FILTERS)
270 CSSPropertyWebkitFilter,
272 CSSPropertyWebkitAlignContent,
273 CSSPropertyWebkitAlignItems,
274 CSSPropertyWebkitAlignSelf,
275 CSSPropertyWebkitFlexBasis,
276 CSSPropertyWebkitFlexGrow,
277 CSSPropertyWebkitFlexShrink,
278 CSSPropertyWebkitFlexDirection,
279 CSSPropertyWebkitFlexWrap,
280 CSSPropertyWebkitJustifyContent,
281 CSSPropertyWebkitFontKerning,
282 CSSPropertyWebkitFontSmoothing,
283 CSSPropertyWebkitFontVariantLigatures,
284 CSSPropertyWebkitGridAutoFlow,
285 CSSPropertyWebkitGridColumns,
286 CSSPropertyWebkitGridRows,
287 CSSPropertyWebkitGridColumn,
288 CSSPropertyWebkitGridRow,
289 CSSPropertyWebkitHighlight,
290 CSSPropertyWebkitHyphenateCharacter,
291 CSSPropertyWebkitHyphenateLimitAfter,
292 CSSPropertyWebkitHyphenateLimitBefore,
293 CSSPropertyWebkitHyphenateLimitLines,
294 CSSPropertyWebkitHyphens,
295 CSSPropertyWebkitLineAlign,
296 CSSPropertyWebkitLineBoxContain,
297 CSSPropertyWebkitLineBreak,
298 CSSPropertyWebkitLineClamp,
299 CSSPropertyWebkitLineGrid,
300 CSSPropertyWebkitLineSnap,
301 CSSPropertyWebkitLocale,
302 CSSPropertyWebkitMarginBeforeCollapse,
303 CSSPropertyWebkitMarginAfterCollapse,
304 CSSPropertyWebkitMarqueeDirection,
305 CSSPropertyWebkitMarqueeIncrement,
306 CSSPropertyWebkitMarqueeRepetition,
307 CSSPropertyWebkitMarqueeStyle,
308 CSSPropertyWebkitMaskBoxImage,
309 CSSPropertyWebkitMaskBoxImageOutset,
310 CSSPropertyWebkitMaskBoxImageRepeat,
311 CSSPropertyWebkitMaskBoxImageSlice,
312 CSSPropertyWebkitMaskBoxImageSource,
313 CSSPropertyWebkitMaskBoxImageWidth,
314 CSSPropertyWebkitMaskClip,
315 CSSPropertyWebkitMaskComposite,
316 CSSPropertyWebkitMaskImage,
317 CSSPropertyWebkitMaskOrigin,
318 CSSPropertyWebkitMaskPosition,
319 CSSPropertyWebkitMaskRepeat,
320 CSSPropertyWebkitMaskSize,
321 CSSPropertyWebkitNbspMode,
322 CSSPropertyWebkitOrder,
323 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
324 CSSPropertyWebkitOverflowScrolling,
326 CSSPropertyWebkitPerspective,
327 CSSPropertyWebkitPerspectiveOrigin,
328 CSSPropertyWebkitPrintColorAdjust,
329 CSSPropertyWebkitRtlOrdering,
330 #if ENABLE(CSS_EXCLUSIONS)
331 CSSPropertyWebkitShapeInside,
332 CSSPropertyWebkitShapeOutside,
334 #if ENABLE(TOUCH_EVENTS)
335 CSSPropertyWebkitTapHighlightColor,
337 CSSPropertyWebkitTextCombine,
338 CSSPropertyWebkitTextDecorationsInEffect,
339 CSSPropertyWebkitTextEmphasisColor,
340 CSSPropertyWebkitTextEmphasisPosition,
341 CSSPropertyWebkitTextEmphasisStyle,
342 CSSPropertyWebkitTextFillColor,
343 CSSPropertyWebkitTextOrientation,
344 CSSPropertyWebkitTextSecurity,
345 CSSPropertyWebkitTextStrokeColor,
346 CSSPropertyWebkitTextStrokeWidth,
347 CSSPropertyWebkitTransform,
348 CSSPropertyWebkitTransformOrigin,
349 CSSPropertyWebkitTransformStyle,
350 CSSPropertyWebkitTransitionDelay,
351 CSSPropertyWebkitTransitionDuration,
352 CSSPropertyWebkitTransitionProperty,
353 CSSPropertyWebkitTransitionTimingFunction,
354 CSSPropertyWebkitUserDrag,
355 CSSPropertyWebkitUserModify,
356 CSSPropertyWebkitUserSelect,
357 CSSPropertyWebkitWritingMode,
358 #if ENABLE(CSS_REGIONS)
359 CSSPropertyWebkitFlowInto,
360 CSSPropertyWebkitFlowFrom,
361 CSSPropertyWebkitRegionOverflow,
362 CSSPropertyWebkitRegionBreakAfter,
363 CSSPropertyWebkitRegionBreakBefore,
364 CSSPropertyWebkitRegionBreakInside,
366 #if ENABLE(DRAGGABLE_REGION)
367 CSSPropertyWebkitAppRegion,
369 #if ENABLE(CSS_EXCLUSIONS)
370 CSSPropertyWebkitWrapFlow,
371 CSSPropertyWebkitShapeMargin,
372 CSSPropertyWebkitShapePadding,
373 CSSPropertyWebkitWrapThrough,
380 CSSPropertyFloodColor,
381 CSSPropertyFloodOpacity,
382 CSSPropertyLightingColor,
383 CSSPropertyStopColor,
384 CSSPropertyStopOpacity,
385 CSSPropertyColorInterpolation,
386 CSSPropertyColorInterpolationFilters,
387 CSSPropertyColorRendering,
389 CSSPropertyFillOpacity,
391 CSSPropertyMarkerEnd,
392 CSSPropertyMarkerMid,
393 CSSPropertyMarkerStart,
395 CSSPropertyShapeRendering,
397 CSSPropertyStrokeDasharray,
398 CSSPropertyStrokeDashoffset,
399 CSSPropertyStrokeLinecap,
400 CSSPropertyStrokeLinejoin,
401 CSSPropertyStrokeMiterlimit,
402 CSSPropertyStrokeOpacity,
403 CSSPropertyStrokeWidth,
404 CSSPropertyAlignmentBaseline,
405 CSSPropertyBaselineShift,
406 CSSPropertyDominantBaseline,
408 CSSPropertyTextAnchor,
409 CSSPropertyWritingMode,
410 CSSPropertyGlyphOrientationHorizontal,
411 CSSPropertyGlyphOrientationVertical,
412 CSSPropertyWebkitSvgShadow,
413 CSSPropertyVectorEffect
417 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
419 static int valueForRepeatRule(int rule)
422 case RepeatImageRule:
423 return CSSValueRepeat;
425 return CSSValueRound;
427 return CSSValueSpace;
429 return CSSValueStretch;
433 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
435 // Create the slices.
436 RefPtr<CSSPrimitiveValue> top;
437 RefPtr<CSSPrimitiveValue> right;
438 RefPtr<CSSPrimitiveValue> bottom;
439 RefPtr<CSSPrimitiveValue> left;
441 if (image.imageSlices().top().isPercent())
442 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
444 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
446 if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
447 && image.imageSlices().left() == image.imageSlices().top()) {
452 if (image.imageSlices().right().isPercent())
453 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
455 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
457 if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
461 if (image.imageSlices().bottom().isPercent())
462 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
464 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
466 if (image.imageSlices().left() == image.imageSlices().right())
469 if (image.imageSlices().left().isPercent())
470 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
472 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
477 RefPtr<Quad> quad = Quad::create();
479 quad->setRight(right);
480 quad->setBottom(bottom);
483 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
486 static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
488 // Create the slices.
489 RefPtr<CSSPrimitiveValue> top;
490 RefPtr<CSSPrimitiveValue> right;
491 RefPtr<CSSPrimitiveValue> bottom;
492 RefPtr<CSSPrimitiveValue> left;
494 if (box.top().isRelative())
495 top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
497 top = cssValuePool().createValue(box.top());
499 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
504 if (box.right().isRelative())
505 right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
507 right = cssValuePool().createValue(box.right());
509 if (box.bottom() == box.top() && box.right() == box.left()) {
513 if (box.bottom().isRelative())
514 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
516 bottom = cssValuePool().createValue(box.bottom());
518 if (box.left() == box.right())
521 if (box.left().isRelative())
522 left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
524 left = cssValuePool().createValue(box.left());
529 RefPtr<Quad> quad = Quad::create();
531 quad->setRight(right);
532 quad->setBottom(bottom);
535 return cssValuePool().createValue(quad.release());
538 static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
540 RefPtr<CSSPrimitiveValue> horizontalRepeat;
541 RefPtr<CSSPrimitiveValue> verticalRepeat;
543 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
544 if (image.horizontalRule() == image.verticalRule())
545 verticalRepeat = horizontalRepeat;
547 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
548 return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
551 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
553 if (!image.hasImage())
554 return cssValuePool().createIdentifierValue(CSSValueNone);
557 RefPtr<CSSValue> imageValue;
559 imageValue = image.image()->cssValue();
561 // Create the image slice.
562 RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
564 // Create the border area slices.
565 RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
567 // Create the border outset.
568 RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
570 // Create the repeat rules.
571 RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
573 return createBorderImageValue(imageValue, imageSlices, borderSlices, outset, repeat);
576 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
578 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
581 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
583 return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
586 static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
588 if (length.isFixed())
589 return zoomAdjustedPixelValue(length.value(), style);
590 return cssValuePool().createValue(length);
593 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
596 return cssValuePool().createIdentifierValue(CSSValueNone);
598 RefPtr<CSSPrimitiveValue> offset;
599 if (reflection->offset().isPercent())
600 offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
602 offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
604 RefPtr<CSSPrimitiveValue> direction;
605 switch (reflection->direction()) {
606 case ReflectionBelow:
607 direction = cssValuePool().createIdentifierValue(CSSValueBelow);
609 case ReflectionAbove:
610 direction = cssValuePool().createIdentifierValue(CSSValueAbove);
613 direction = cssValuePool().createIdentifierValue(CSSValueLeft);
615 case ReflectionRight:
616 direction = cssValuePool().createIdentifierValue(CSSValueRight);
620 return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
623 static PassRefPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
625 RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
626 if (layer->isBackgroundOriginSet()) {
627 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
628 positionList->append(cssValuePool().createValue(layer->backgroundXOrigin()));
630 positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
631 if (layer->isBackgroundOriginSet()) {
632 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
633 positionList->append(cssValuePool().createValue(layer->backgroundYOrigin()));
635 positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
636 return positionList.release();
639 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
645 switch (propertyID) {
646 case CSSPropertyLeft:
649 case CSSPropertyRight:
655 case CSSPropertyBottom:
662 if (style->hasOutOfFlowPosition()) {
663 if (l.type() == WebCore::Fixed)
664 return zoomAdjustedPixelValue(l.value(), style);
665 else if (l.isViewportPercentage())
666 return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
667 return cssValuePool().createValue(l);
670 if (style->hasInFlowPosition()) {
671 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
672 // In other words if left is auto and right is not auto, then left's computed value is negative right().
673 // So we should get the opposite length unit and see if it is auto.
674 return cssValuePool().createValue(l);
677 return cssValuePool().createIdentifierValue(CSSValueAuto);
680 PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const Color& color) const
682 // This function does NOT look at visited information, so that computed style doesn't expose that.
683 if (!color.isValid())
684 return cssValuePool().createColorValue(style->color().rgb());
685 return cssValuePool().createColorValue(color.rgb());
688 static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, RenderView* renderView)
690 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
691 if (radius.width().type() == Percent)
692 list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
694 list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
695 if (radius.height().type() == Percent)
696 list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
698 list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
699 return list.release();
702 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, RenderView* renderView)
704 if (radius.width() == radius.height()) {
705 if (radius.width().type() == Percent)
706 return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
707 return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
709 return getBorderRadiusCornerValues(radius, style, renderView);
712 static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
714 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
715 bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
716 bool showHorizontalBottomRight = style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width();
717 bool showHorizontalTopRight = style->borderTopRightRadius().width() != style->borderTopLeftRadius().width();
719 bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
720 bool showVerticalBottomRight = (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomLeft;
721 bool showVerticalTopRight = (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomRight;
722 bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
724 RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
725 RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
726 RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
727 RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
729 RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
730 horizontalRadii->append(topLeftRadius->item(0));
731 if (showHorizontalTopRight)
732 horizontalRadii->append(topRightRadius->item(0));
733 if (showHorizontalBottomRight)
734 horizontalRadii->append(bottomRightRadius->item(0));
735 if (showHorizontalBottomLeft)
736 horizontalRadii->append(bottomLeftRadius->item(0));
738 list->append(horizontalRadii);
740 if (showVerticalTopLeft) {
741 RefPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
742 verticalRadii->append(topLeftRadius->item(1));
743 if (showVerticalTopRight)
744 verticalRadii->append(topRightRadius->item(1));
745 if (showVerticalBottomRight)
746 verticalRadii->append(bottomRightRadius->item(1));
747 if (showVerticalBottomLeft)
748 verticalRadii->append(bottomLeftRadius->item(1));
749 list->append(verticalRadii);
751 return list.release();
754 static LayoutRect sizingBox(RenderObject* renderer)
756 if (!renderer->isBox())
759 RenderBox* box = toRenderBox(renderer);
760 return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
763 static PassRefPtr<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
765 RefPtr<WebKitCSSTransformValue> transformValue;
766 if (transform.isAffine()) {
767 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
769 transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
770 transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
771 transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
772 transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
773 transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
774 transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
776 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
778 transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
779 transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
780 transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
781 transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
783 transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
784 transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
785 transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
786 transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
788 transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
789 transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
790 transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
791 transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
793 transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
794 transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
795 transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
796 transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
799 return transformValue.release();
802 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
804 if (!renderer || !renderer->hasTransform() || !style->hasTransform())
805 return cssValuePool().createIdentifierValue(CSSValueNone);
808 if (renderer->isBox())
809 box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
811 TransformationMatrix transform;
812 style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
813 // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
815 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
816 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
817 list->append(matrixTransformValue(transform, style));
819 return list.release();
822 #if ENABLE(CSS_SHADERS)
823 static PassRefPtr<CSSValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
825 RefPtr<WebKitCSSArrayFunctionValue> arrayParameterValue = WebKitCSSArrayFunctionValue::create();
826 for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
827 arrayParameterValue->append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
828 return arrayParameterValue.release();
831 static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
833 RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
834 for (unsigned i = 0; i < numberParameter->size(); ++i)
835 numberParameterValue->append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
836 return numberParameterValue.release();
839 static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
841 IntSize size = renderer ? pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size() : IntSize();
842 TransformationMatrix transform;
843 transformParameter->applyTransform(transform, size);
844 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
845 return matrixTransformValue(transform, style);
848 static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
850 // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
852 switch (parameter->parameterType()) {
853 case CustomFilterParameter::ARRAY:
854 return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
855 case CustomFilterParameter::NUMBER:
856 return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
857 case CustomFilterParameter::TRANSFORM:
858 return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
861 ASSERT_NOT_REACHED();
864 #endif // ENABLE(CSS_SHADERS)
866 #if ENABLE(CSS_FILTERS)
867 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(const RenderObject* renderer, const RenderStyle* style) const
869 #if !ENABLE(CSS_SHADERS)
870 UNUSED_PARAM(renderer);
872 if (style->filter().operations().isEmpty())
873 return cssValuePool().createIdentifierValue(CSSValueNone);
875 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
877 RefPtr<WebKitCSSFilterValue> filterValue;
879 Vector<RefPtr<FilterOperation> >::const_iterator end = style->filter().operations().end();
880 for (Vector<RefPtr<FilterOperation> >::const_iterator it = style->filter().operations().begin(); it != end; ++it) {
881 FilterOperation* filterOperation = (*it).get();
882 switch (filterOperation->getOperationType()) {
883 case FilterOperation::REFERENCE: {
884 ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
885 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
886 filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
889 case FilterOperation::GRAYSCALE: {
890 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
891 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
892 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
895 case FilterOperation::SEPIA: {
896 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
897 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
898 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
901 case FilterOperation::SATURATE: {
902 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
903 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
904 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
907 case FilterOperation::HUE_ROTATE: {
908 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
909 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
910 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
913 case FilterOperation::INVERT: {
914 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
915 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
916 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
919 case FilterOperation::OPACITY: {
920 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
921 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
922 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
925 case FilterOperation::BRIGHTNESS: {
926 BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
927 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
928 filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
931 case FilterOperation::CONTRAST: {
932 BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
933 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
934 filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
937 case FilterOperation::BLUR: {
938 BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
939 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
940 filterValue->append(zoomAdjustedPixelValue(blurOperation->stdDeviation().value(), style));
943 case FilterOperation::DROP_SHADOW: {
944 DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
945 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
946 // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
947 ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
948 filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style));
951 #if ENABLE(CSS_SHADERS)
952 case FilterOperation::VALIDATED_CUSTOM:
953 // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
954 ASSERT_NOT_REACHED();
956 case FilterOperation::CUSTOM: {
957 CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
958 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
960 // The output should be verbose, even if the values are the default ones.
962 ASSERT(customOperation->program());
963 StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
965 RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
966 if (program->vertexShader())
967 shadersList->append(program->vertexShader()->cssValue());
969 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
971 const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
972 if (program->fragmentShader()) {
973 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
974 RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
975 mixFunction->append(program->fragmentShader()->cssValue());
976 mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
977 mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
978 shadersList->append(mixFunction.release());
980 shadersList->append(program->fragmentShader()->cssValue());
983 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
985 filterValue->append(shadersList.release());
987 RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
988 meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
989 meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
991 // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
992 // https://bugs.webkit.org/show_bug.cgi?id=72700
993 if (customOperation->meshType() == MeshTypeDetached)
994 meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
996 filterValue->append(meshParameters.release());
998 const CustomFilterParameterList& parameters = customOperation->parameters();
999 size_t parametersSize = parameters.size();
1000 if (!parametersSize)
1002 RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
1003 for (size_t i = 0; i < parametersSize; ++i) {
1004 const CustomFilterParameter* parameter = parameters.at(i).get();
1005 RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
1006 parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
1007 parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
1008 parametersCSSValue->append(parameterCSSNameAndValue.release());
1011 filterValue->append(parametersCSSValue.release());
1016 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
1019 list->append(filterValue);
1022 return list.release();
1026 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackBreadth, const RenderStyle* style, RenderView *renderView)
1028 if (trackBreadth.isAuto())
1029 return cssValuePool().createIdentifierValue(CSSValueAuto);
1030 if (trackBreadth.isViewportPercentage())
1031 return zoomAdjustedPixelValue(valueForLength(trackBreadth, 0, renderView), style);
1032 return zoomAdjustedPixelValueForLength(trackBreadth, style);
1035 static PassRefPtr<CSSValue> valueForGridTrackMinMax(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
1037 switch (trackSize.type()) {
1038 case LengthTrackSizing:
1039 return valueForGridTrackBreadth(trackSize.length(), style, renderView);
1040 case MinMaxTrackSizing:
1041 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1042 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
1043 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
1044 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1046 ASSERT_NOT_REACHED();
1050 static PassRefPtr<CSSValue> valueForGridTrackGroup(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView* renderView)
1052 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1053 for (size_t i = 0; i < trackSizes.size(); ++i)
1054 list->append(valueForGridTrackMinMax(trackSizes[i], style, renderView));
1055 return list.release();
1058 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView *renderView)
1060 // Handle the 'none' case here.
1061 if (!trackSizes.size())
1062 return cssValuePool().createIdentifierValue(CSSValueNone);
1064 return valueForGridTrackGroup(trackSizes, style, renderView);
1067 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1069 if (position.isAuto())
1070 return cssValuePool().createIdentifierValue(CSSValueAuto);
1072 return cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER);
1074 static PassRefPtr<CSSValue> createTransitionPropertyValue(const Animation* animation)
1076 RefPtr<CSSValue> propertyValue;
1077 if (animation->animationMode() == Animation::AnimateNone)
1078 propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
1079 else if (animation->animationMode() == Animation::AnimateAll)
1080 propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
1082 propertyValue = cssValuePool().createValue(getPropertyNameString(animation->property()), CSSPrimitiveValue::CSS_STRING);
1083 return propertyValue.release();
1085 static PassRefPtr<CSSValue> getTransitionPropertyValue(const AnimationList* animList)
1087 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1089 for (size_t i = 0; i < animList->size(); ++i)
1090 list->append(createTransitionPropertyValue(animList->animation(i)));
1092 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
1093 return list.release();
1096 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
1098 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1100 for (size_t i = 0; i < animList->size(); ++i)
1101 list->append(cssValuePool().createValue(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
1103 // Note that initialAnimationDelay() is used for both transitions and animations
1104 list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1106 return list.release();
1109 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
1111 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1113 for (size_t i = 0; i < animList->size(); ++i)
1114 list->append(cssValuePool().createValue(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
1116 // Note that initialAnimationDuration() is used for both transitions and animations
1117 list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1119 return list.release();
1122 static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1124 if (timingFunction->isCubicBezierTimingFunction()) {
1125 const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1126 if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1127 CSSValueID valueId = CSSValueInvalid;
1128 switch (bezierTimingFunction->timingFunctionPreset()) {
1129 case CubicBezierTimingFunction::Ease:
1130 valueId = CSSValueEase;
1132 case CubicBezierTimingFunction::EaseIn:
1133 valueId = CSSValueEaseIn;
1135 case CubicBezierTimingFunction::EaseOut:
1136 valueId = CSSValueEaseOut;
1138 case CubicBezierTimingFunction::EaseInOut:
1139 valueId = CSSValueEaseInOut;
1142 ASSERT_NOT_REACHED();
1145 return cssValuePool().createIdentifierValue(valueId);
1147 return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1150 if (timingFunction->isStepsTimingFunction()) {
1151 const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1152 return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1155 return CSSLinearTimingFunctionValue::create();
1158 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
1160 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1162 for (size_t i = 0; i < animList->size(); ++i)
1163 list->append(createTimingFunctionValue(animList->animation(i)->timingFunction().get()));
1165 // Note that initialAnimationTimingFunction() is used for both transitions and animations
1166 list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1167 return list.release();
1170 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1172 if (!lineBoxContain)
1173 return cssValuePool().createIdentifierValue(CSSValueNone);
1174 return CSSLineBoxContainValue::create(lineBoxContain);
1177 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1179 , m_allowVisitedStyle(allowVisitedStyle)
1182 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1183 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1184 AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1187 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1191 void CSSComputedStyleDeclaration::ref()
1196 void CSSComputedStyleDeclaration::deref()
1203 String CSSComputedStyleDeclaration::cssText() const
1205 StringBuilder result;
1207 for (unsigned i = 0; i < numComputedProperties; i++) {
1210 result.append(getPropertyName(computedProperties[i]));
1211 result.append(": ", 2);
1212 result.append(getPropertyValue(computedProperties[i]));
1216 return result.toString();
1219 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1221 ec = NO_MODIFICATION_ALLOWED_ERR;
1224 static int cssIdentifierForFontSizeKeyword(int keywordSize)
1226 ASSERT_ARG(keywordSize, keywordSize);
1227 ASSERT_ARG(keywordSize, keywordSize <= 8);
1228 return CSSValueXxSmall + keywordSize - 1;
1231 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
1236 m_node->document()->updateLayoutIgnorePendingStylesheets();
1238 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1242 if (int keywordSize = style->fontDescription().keywordSize())
1243 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1246 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1249 bool CSSComputedStyleDeclaration::useFixedFontDefaultSize() const
1254 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1258 return style->fontDescription().useFixedDefaultSize();
1261 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
1264 return cssValuePool().createIdentifierValue(CSSValueNone);
1266 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1267 for (const ShadowData* s = shadow; s; s = s->next()) {
1268 RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style);
1269 RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style);
1270 RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style);
1271 RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : zoomAdjustedPixelValue(s->spread(), style);
1272 RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
1273 RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(s->color().rgb());
1274 list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
1276 return list.release();
1279 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const
1281 return getPropertyCSSValue(propertyID, UpdateLayout);
1284 static int identifierForFamily(const AtomicString& family)
1286 if (family == cursiveFamily)
1287 return CSSValueCursive;
1288 if (family == fantasyFamily)
1289 return CSSValueFantasy;
1290 if (family == monospaceFamily)
1291 return CSSValueMonospace;
1292 if (family == pictographFamily)
1293 return CSSValueWebkitPictograph;
1294 if (family == sansSerifFamily)
1295 return CSSValueSansSerif;
1296 if (family == serifFamily)
1297 return CSSValueSerif;
1301 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1303 if (int familyIdentifier = identifierForFamily(family))
1304 return cssValuePool().createIdentifierValue(familyIdentifier);
1305 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1308 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1310 // Blink value is ignored.
1311 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1312 if (textDecoration & UNDERLINE)
1313 list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1314 if (textDecoration & OVERLINE)
1315 list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1316 if (textDecoration & LINE_THROUGH)
1317 list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1319 if (!list->length())
1320 return cssValuePool().createIdentifierValue(CSSValueNone);
1324 #if ENABLE(CSS3_TEXT)
1325 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1327 switch (textDecorationStyle) {
1328 case TextDecorationStyleSolid:
1329 return cssValuePool().createIdentifierValue(CSSValueSolid);
1330 case TextDecorationStyleDouble:
1331 return cssValuePool().createIdentifierValue(CSSValueDouble);
1332 case TextDecorationStyleDotted:
1333 return cssValuePool().createIdentifierValue(CSSValueDotted);
1334 case TextDecorationStyleDashed:
1335 return cssValuePool().createIdentifierValue(CSSValueDashed);
1336 case TextDecorationStyleWavy:
1337 return cssValuePool().createIdentifierValue(CSSValueWavy);
1340 ASSERT_NOT_REACHED();
1341 return cssValuePool().createExplicitInitialValue();
1345 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1347 // For backwards compatibility, if both values are equal, just return one of them. And
1348 // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1349 if (xRepeat == yRepeat)
1350 return cssValuePool().createValue(xRepeat);
1351 if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1352 return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1353 if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1354 return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1356 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1357 list->append(cssValuePool().createValue(xRepeat));
1358 list->append(cssValuePool().createValue(yRepeat));
1359 return list.release();
1362 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1364 if (fillSize.type == Contain)
1365 return cssValuePool().createIdentifierValue(CSSValueContain);
1367 if (fillSize.type == Cover)
1368 return cssValuePool().createIdentifierValue(CSSValueCover);
1370 if (fillSize.size.height().isAuto())
1371 return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1373 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1374 list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1375 list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1376 return list.release();
1379 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1381 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1382 for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1383 if (contentData->isCounter()) {
1384 const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1386 list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1387 } else if (contentData->isImage()) {
1388 const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1390 list->append(image->cssValue());
1391 } else if (contentData->isText())
1392 list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1394 if (!style->regionThread().isNull())
1395 list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1396 return list.release();
1399 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1401 const CounterDirectiveMap* map = style->counterDirectives();
1405 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1406 for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1407 list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1408 short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1409 list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1411 return list.release();
1414 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1416 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1417 if (!propertyIDSet.add(propertyID).isNewEntry)
1420 LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1423 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1425 const FontFamily& firstFamily = style->fontDescription().family();
1426 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1427 for (const FontFamily* family = &firstFamily; family; family = family->next())
1428 list->append(valueForFamily(family->family()));
1429 return list.release();
1432 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1434 Length length = style->lineHeight();
1435 if (length.isNegative())
1436 return cssValuePool().createIdentifierValue(CSSValueNormal);
1437 if (length.isPercent())
1438 // This is imperfect, because it doesn't include the zoom factor and the real computation
1439 // for how high to be in pixels does include things like minimum font size and the zoom factor.
1440 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1441 // that here either.
1442 return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1443 return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style);
1446 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1448 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1451 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1453 if (style->fontDescription().italic())
1454 return cssValuePool().createIdentifierValue(CSSValueItalic);
1455 return cssValuePool().createIdentifierValue(CSSValueNormal);
1458 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1460 if (style->fontDescription().smallCaps())
1461 return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1462 return cssValuePool().createIdentifierValue(CSSValueNormal);
1465 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1467 switch (style->fontDescription().weight()) {
1469 return cssValuePool().createIdentifierValue(CSSValue100);
1471 return cssValuePool().createIdentifierValue(CSSValue200);
1473 return cssValuePool().createIdentifierValue(CSSValue300);
1474 case FontWeightNormal:
1475 return cssValuePool().createIdentifierValue(CSSValueNormal);
1477 return cssValuePool().createIdentifierValue(CSSValue500);
1479 return cssValuePool().createIdentifierValue(CSSValue600);
1480 case FontWeightBold:
1481 return cssValuePool().createIdentifierValue(CSSValueBold);
1483 return cssValuePool().createIdentifierValue(CSSValue800);
1485 return cssValuePool().createIdentifierValue(CSSValue900);
1487 ASSERT_NOT_REACHED();
1488 return cssValuePool().createIdentifierValue(CSSValueNormal);
1491 static bool isLayoutDependentProperty(CSSPropertyID propertyID)
1493 switch (propertyID) {
1494 case CSSPropertyWidth:
1495 case CSSPropertyHeight:
1496 case CSSPropertyMargin:
1497 case CSSPropertyMarginTop:
1498 case CSSPropertyMarginBottom:
1499 case CSSPropertyMarginLeft:
1500 case CSSPropertyMarginRight:
1501 case CSSPropertyPadding:
1502 case CSSPropertyPaddingTop:
1503 case CSSPropertyPaddingBottom:
1504 case CSSPropertyPaddingLeft:
1505 case CSSPropertyPaddingRight:
1506 case CSSPropertyWebkitPerspectiveOrigin:
1507 case CSSPropertyWebkitTransformOrigin:
1508 case CSSPropertyWebkitTransform:
1509 #if ENABLE(CSS_FILTERS)
1510 case CSSPropertyWebkitFilter:
1518 Node* CSSComputedStyleDeclaration::styledNode() const
1522 if (m_node->isElementNode()) {
1523 if (PseudoElement* element = toElement(m_node.get())->pseudoElement(m_pseudoElementSpecifier))
1526 return m_node.get();
1529 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1531 Node* styledNode = this->styledNode();
1536 Document* document = styledNode->document();
1537 // FIXME: Some of these cases could be narrowed down or optimized better.
1538 bool forceFullLayout = isLayoutDependentProperty(propertyID)
1539 || styledNode->isInShadowTree()
1540 || (document->styleResolverIfExists() && document->styleResolverIfExists()->hasViewportDependentMediaQueries() && document->ownerElement())
1541 || document->seamlessParentIFrame();
1543 if (forceFullLayout)
1544 document->updateLayoutIgnorePendingStylesheets();
1546 bool needsStyleRecalc = document->hasPendingForcedStyleRecalc();
1547 for (Node* n = styledNode; n && !needsStyleRecalc; n = n->parentNode())
1548 needsStyleRecalc = n->needsStyleRecalc();
1549 if (needsStyleRecalc)
1550 document->updateStyleIfNeeded();
1553 // The style recalc could have caused the styled node to be discarded or replaced
1554 // if it was a PseudoElement so we need to update it.
1555 styledNode = this->styledNode();
1558 RenderObject* renderer = styledNode->renderer();
1560 RefPtr<RenderStyle> style;
1561 if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1562 AnimationUpdateBlock animationUpdateBlock(renderer->animation());
1563 style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
1564 if (m_pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1565 // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1566 style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
1569 style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
1574 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1576 switch (propertyID) {
1577 case CSSPropertyInvalid:
1578 #if ENABLE(CSS_VARIABLES)
1579 case CSSPropertyVariable:
1583 case CSSPropertyBackgroundColor:
1584 return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1585 case CSSPropertyBackgroundImage:
1586 case CSSPropertyWebkitMaskImage: {
1587 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1589 return cssValuePool().createIdentifierValue(CSSValueNone);
1591 if (!layers->next()) {
1592 if (layers->image())
1593 return layers->image()->cssValue();
1595 return cssValuePool().createIdentifierValue(CSSValueNone);
1598 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1599 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1600 if (currLayer->image())
1601 list->append(currLayer->image()->cssValue());
1603 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1605 return list.release();
1607 case CSSPropertyBackgroundSize:
1608 case CSSPropertyWebkitBackgroundSize:
1609 case CSSPropertyWebkitMaskSize: {
1610 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1611 if (!layers->next())
1612 return fillSizeToCSSValue(layers->size(), style.get());
1614 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1615 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1616 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1618 return list.release();
1620 case CSSPropertyBackgroundRepeat:
1621 case CSSPropertyWebkitMaskRepeat: {
1622 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1623 if (!layers->next())
1624 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1626 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1627 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1628 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1630 return list.release();
1632 case CSSPropertyWebkitBackgroundComposite:
1633 case CSSPropertyWebkitMaskComposite: {
1634 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1635 if (!layers->next())
1636 return cssValuePool().createValue(layers->composite());
1638 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1639 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1640 list->append(cssValuePool().createValue(currLayer->composite()));
1642 return list.release();
1644 case CSSPropertyBackgroundAttachment: {
1645 const FillLayer* layers = style->backgroundLayers();
1646 if (!layers->next())
1647 return cssValuePool().createValue(layers->attachment());
1649 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1650 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1651 list->append(cssValuePool().createValue(currLayer->attachment()));
1653 return list.release();
1655 case CSSPropertyBackgroundClip:
1656 case CSSPropertyBackgroundOrigin:
1657 case CSSPropertyWebkitBackgroundClip:
1658 case CSSPropertyWebkitBackgroundOrigin:
1659 case CSSPropertyWebkitMaskClip:
1660 case CSSPropertyWebkitMaskOrigin: {
1661 const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1662 bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1663 if (!layers->next()) {
1664 EFillBox box = isClip ? layers->clip() : layers->origin();
1665 return cssValuePool().createValue(box);
1668 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1669 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1670 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1671 list->append(cssValuePool().createValue(box));
1674 return list.release();
1676 case CSSPropertyBackgroundPosition:
1677 case CSSPropertyWebkitMaskPosition: {
1678 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1679 if (!layers->next())
1680 return createPositionListForLayer(propertyID, layers, style.get());
1682 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1683 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1684 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1685 return list.release();
1687 case CSSPropertyBackgroundPositionX:
1688 case CSSPropertyWebkitMaskPositionX: {
1689 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1690 if (!layers->next())
1691 return cssValuePool().createValue(layers->xPosition());
1693 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1694 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1695 list->append(cssValuePool().createValue(currLayer->xPosition()));
1697 return list.release();
1699 case CSSPropertyBackgroundPositionY:
1700 case CSSPropertyWebkitMaskPositionY: {
1701 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1702 if (!layers->next())
1703 return cssValuePool().createValue(layers->yPosition());
1705 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1706 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1707 list->append(cssValuePool().createValue(currLayer->yPosition()));
1709 return list.release();
1711 case CSSPropertyBorderCollapse:
1712 if (style->borderCollapse())
1713 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1714 return cssValuePool().createIdentifierValue(CSSValueSeparate);
1715 case CSSPropertyBorderSpacing: {
1716 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1717 list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1718 list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1719 return list.release();
1721 case CSSPropertyWebkitBorderHorizontalSpacing:
1722 return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1723 case CSSPropertyWebkitBorderVerticalSpacing:
1724 return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1725 case CSSPropertyBorderImageSource:
1726 if (style->borderImageSource())
1727 return style->borderImageSource()->cssValue();
1728 return cssValuePool().createIdentifierValue(CSSValueNone);
1729 case CSSPropertyBorderTopColor:
1730 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1731 case CSSPropertyBorderRightColor:
1732 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1733 case CSSPropertyBorderBottomColor:
1734 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1735 case CSSPropertyBorderLeftColor:
1736 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1737 case CSSPropertyBorderTopStyle:
1738 return cssValuePool().createValue(style->borderTopStyle());
1739 case CSSPropertyBorderRightStyle:
1740 return cssValuePool().createValue(style->borderRightStyle());
1741 case CSSPropertyBorderBottomStyle:
1742 return cssValuePool().createValue(style->borderBottomStyle());
1743 case CSSPropertyBorderLeftStyle:
1744 return cssValuePool().createValue(style->borderLeftStyle());
1745 case CSSPropertyBorderTopWidth:
1746 return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1747 case CSSPropertyBorderRightWidth:
1748 return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1749 case CSSPropertyBorderBottomWidth:
1750 return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1751 case CSSPropertyBorderLeftWidth:
1752 return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1753 case CSSPropertyBottom:
1754 return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document()->renderView());
1755 case CSSPropertyWebkitBoxAlign:
1756 return cssValuePool().createValue(style->boxAlign());
1757 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1758 case CSSPropertyWebkitBoxDecorationBreak:
1759 if (style->boxDecorationBreak() == DSLICE)
1760 return cssValuePool().createIdentifierValue(CSSValueSlice);
1761 return cssValuePool().createIdentifierValue(CSSValueClone);
1763 case CSSPropertyWebkitBoxDirection:
1764 return cssValuePool().createValue(style->boxDirection());
1765 case CSSPropertyWebkitBoxFlex:
1766 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1767 case CSSPropertyWebkitBoxFlexGroup:
1768 return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1769 case CSSPropertyWebkitBoxLines:
1770 return cssValuePool().createValue(style->boxLines());
1771 case CSSPropertyWebkitBoxOrdinalGroup:
1772 return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1773 case CSSPropertyWebkitBoxOrient:
1774 return cssValuePool().createValue(style->boxOrient());
1775 case CSSPropertyWebkitBoxPack:
1776 return cssValuePool().createValue(style->boxPack());
1777 case CSSPropertyWebkitBoxReflect:
1778 return valueForReflection(style->boxReflect(), style.get());
1779 case CSSPropertyBoxShadow:
1780 case CSSPropertyWebkitBoxShadow:
1781 return valueForShadow(style->boxShadow(), propertyID, style.get());
1782 case CSSPropertyCaptionSide:
1783 return cssValuePool().createValue(style->captionSide());
1784 case CSSPropertyClear:
1785 return cssValuePool().createValue(style->clear());
1786 case CSSPropertyColor:
1787 return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1788 case CSSPropertyWebkitPrintColorAdjust:
1789 return cssValuePool().createValue(style->printColorAdjust());
1790 case CSSPropertyWebkitColumnAxis:
1791 return cssValuePool().createValue(style->columnAxis());
1792 case CSSPropertyWebkitColumnCount:
1793 if (style->hasAutoColumnCount())
1794 return cssValuePool().createIdentifierValue(CSSValueAuto);
1795 return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
1796 case CSSPropertyWebkitColumnGap:
1797 if (style->hasNormalColumnGap())
1798 return cssValuePool().createIdentifierValue(CSSValueNormal);
1799 return zoomAdjustedPixelValue(style->columnGap(), style.get());
1800 case CSSPropertyWebkitColumnProgression:
1801 return cssValuePool().createValue(style->columnProgression());
1802 case CSSPropertyWebkitColumnRuleColor:
1803 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
1804 case CSSPropertyWebkitColumnRuleStyle:
1805 return cssValuePool().createValue(style->columnRuleStyle());
1806 case CSSPropertyWebkitColumnRuleWidth:
1807 return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
1808 case CSSPropertyWebkitColumnSpan:
1809 return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
1810 case CSSPropertyWebkitColumnBreakAfter:
1811 return cssValuePool().createValue(style->columnBreakAfter());
1812 case CSSPropertyWebkitColumnBreakBefore:
1813 return cssValuePool().createValue(style->columnBreakBefore());
1814 case CSSPropertyWebkitColumnBreakInside:
1815 return cssValuePool().createValue(style->columnBreakInside());
1816 case CSSPropertyWebkitColumnWidth:
1817 if (style->hasAutoColumnWidth())
1818 return cssValuePool().createIdentifierValue(CSSValueAuto);
1819 return zoomAdjustedPixelValue(style->columnWidth(), style.get());
1820 case CSSPropertyTabSize:
1821 return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
1822 #if ENABLE(CSS_REGIONS)
1823 case CSSPropertyWebkitRegionBreakAfter:
1824 return cssValuePool().createValue(style->regionBreakAfter());
1825 case CSSPropertyWebkitRegionBreakBefore:
1826 return cssValuePool().createValue(style->regionBreakBefore());
1827 case CSSPropertyWebkitRegionBreakInside:
1828 return cssValuePool().createValue(style->regionBreakInside());
1830 case CSSPropertyCursor: {
1831 RefPtr<CSSValueList> list;
1832 CursorList* cursors = style->cursors();
1833 if (cursors && cursors->size() > 0) {
1834 list = CSSValueList::createCommaSeparated();
1835 for (unsigned i = 0; i < cursors->size(); ++i)
1836 if (StyleImage* image = cursors->at(i).image())
1837 list->append(image->cssValue());
1839 RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
1841 list->append(value);
1842 return list.release();
1844 return value.release();
1846 case CSSPropertyDirection:
1847 return cssValuePool().createValue(style->direction());
1848 case CSSPropertyDisplay:
1849 return cssValuePool().createValue(style->display());
1850 case CSSPropertyEmptyCells:
1851 return cssValuePool().createValue(style->emptyCells());
1852 case CSSPropertyWebkitAlignContent:
1853 return cssValuePool().createValue(style->alignContent());
1854 case CSSPropertyWebkitAlignItems:
1855 return cssValuePool().createValue(style->alignItems());
1856 case CSSPropertyWebkitAlignSelf:
1857 if (style->alignSelf() == AlignAuto) {
1858 Node* parent = styledNode->parentNode();
1859 if (parent && parent->computedStyle())
1860 return cssValuePool().createValue(parent->computedStyle()->alignItems());
1861 return cssValuePool().createValue(AlignStretch);
1863 return cssValuePool().createValue(style->alignSelf());
1864 case CSSPropertyWebkitFlex:
1865 return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
1866 case CSSPropertyWebkitFlexBasis:
1867 return cssValuePool().createValue(style->flexBasis());
1868 case CSSPropertyWebkitFlexDirection:
1869 return cssValuePool().createValue(style->flexDirection());
1870 case CSSPropertyWebkitFlexFlow:
1871 return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
1872 case CSSPropertyWebkitFlexGrow:
1873 return cssValuePool().createValue(style->flexGrow());
1874 case CSSPropertyWebkitFlexShrink:
1875 return cssValuePool().createValue(style->flexShrink());
1876 case CSSPropertyWebkitFlexWrap:
1877 return cssValuePool().createValue(style->flexWrap());
1878 case CSSPropertyWebkitJustifyContent:
1879 return cssValuePool().createValue(style->justifyContent());
1880 case CSSPropertyWebkitOrder:
1881 return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
1882 case CSSPropertyFloat:
1883 if (style->display() != NONE && style->hasOutOfFlowPosition())
1884 return cssValuePool().createIdentifierValue(CSSValueNone);
1885 return cssValuePool().createValue(style->floating());
1886 case CSSPropertyFont: {
1887 RefPtr<FontValue> computedFont = FontValue::create();
1888 computedFont->style = fontStyleFromStyle(style.get());
1889 computedFont->variant = fontVariantFromStyle(style.get());
1890 computedFont->weight = fontWeightFromStyle(style.get());
1891 computedFont->size = fontSizeFromStyle(style.get());
1892 computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document()->renderView());
1893 computedFont->family = fontFamilyFromStyle(style.get());
1894 return computedFont.release();
1896 case CSSPropertyFontFamily: {
1897 RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
1898 // If there's only a single family, return that as a CSSPrimitiveValue.
1899 // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
1900 if (fontFamilyList->length() == 1)
1901 return fontFamilyList->item(0);
1902 return fontFamilyList.release();
1904 case CSSPropertyFontSize:
1905 return fontSizeFromStyle(style.get());
1906 case CSSPropertyFontStyle:
1907 return fontStyleFromStyle(style.get());
1908 case CSSPropertyFontVariant:
1909 return fontVariantFromStyle(style.get());
1910 case CSSPropertyFontWeight:
1911 return fontWeightFromStyle(style.get());
1912 case CSSPropertyWebkitFontFeatureSettings: {
1913 const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
1914 if (!featureSettings || !featureSettings->size())
1915 return cssValuePool().createIdentifierValue(CSSValueNormal);
1916 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1917 for (unsigned i = 0; i < featureSettings->size(); ++i) {
1918 const FontFeature& feature = featureSettings->at(i);
1919 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create(feature.tag(), feature.value());
1920 list->append(featureValue.release());
1922 return list.release();
1924 case CSSPropertyWebkitGridAutoFlow:
1925 return cssValuePool().createValue(style->gridAutoFlow());
1926 case CSSPropertyWebkitGridColumns:
1927 return valueForGridTrackList(style->gridColumns(), style.get(), m_node->document()->renderView());
1928 case CSSPropertyWebkitGridRows:
1929 return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
1931 case CSSPropertyWebkitGridColumn:
1932 return valueForGridPosition(style->gridItemColumn());
1933 case CSSPropertyWebkitGridRow:
1934 return valueForGridPosition(style->gridItemRow());
1936 case CSSPropertyHeight:
1938 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
1939 // the "height" property does not apply for non-replaced inline elements.
1940 if (!renderer->isReplaced() && renderer->isInline())
1941 return cssValuePool().createIdentifierValue(CSSValueAuto);
1942 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
1944 return zoomAdjustedPixelValueForLength(style->height(), style.get());
1945 case CSSPropertyWebkitHighlight:
1946 if (style->highlight() == nullAtom)
1947 return cssValuePool().createIdentifierValue(CSSValueNone);
1948 return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
1949 case CSSPropertyWebkitHyphens:
1950 return cssValuePool().createValue(style->hyphens());
1951 case CSSPropertyWebkitHyphenateCharacter:
1952 if (style->hyphenationString().isNull())
1953 return cssValuePool().createIdentifierValue(CSSValueAuto);
1954 return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
1955 case CSSPropertyWebkitHyphenateLimitAfter:
1956 if (style->hyphenationLimitAfter() < 0)
1957 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1958 return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
1959 case CSSPropertyWebkitHyphenateLimitBefore:
1960 if (style->hyphenationLimitBefore() < 0)
1961 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1962 return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
1963 case CSSPropertyWebkitHyphenateLimitLines:
1964 if (style->hyphenationLimitLines() < 0)
1965 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
1966 return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
1967 case CSSPropertyWebkitBorderFit:
1968 if (style->borderFit() == BorderFitBorder)
1969 return cssValuePool().createIdentifierValue(CSSValueBorder);
1970 return cssValuePool().createIdentifierValue(CSSValueLines);
1971 #if ENABLE(CSS_IMAGE_ORIENTATION)
1972 case CSSPropertyImageOrientation:
1973 return cssValuePool().createValue(style->imageOrientation());
1975 case CSSPropertyImageRendering:
1976 return CSSPrimitiveValue::create(style->imageRendering());
1977 #if ENABLE(CSS_IMAGE_RESOLUTION)
1978 case CSSPropertyImageResolution:
1979 return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
1981 case CSSPropertyLeft:
1982 return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document()->renderView());
1983 case CSSPropertyLetterSpacing:
1984 if (!style->letterSpacing())
1985 return cssValuePool().createIdentifierValue(CSSValueNormal);
1986 return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
1987 case CSSPropertyWebkitLineClamp:
1988 if (style->lineClamp().isNone())
1989 return cssValuePool().createIdentifierValue(CSSValueNone);
1990 return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
1991 case CSSPropertyLineHeight:
1992 return lineHeightFromStyle(style.get(), m_node->document()->renderView());
1993 case CSSPropertyListStyleImage:
1994 if (style->listStyleImage())
1995 return style->listStyleImage()->cssValue();
1996 return cssValuePool().createIdentifierValue(CSSValueNone);
1997 case CSSPropertyListStylePosition:
1998 return cssValuePool().createValue(style->listStylePosition());
1999 case CSSPropertyListStyleType:
2000 return cssValuePool().createValue(style->listStyleType());
2001 case CSSPropertyWebkitLocale:
2002 if (style->locale().isNull())
2003 return cssValuePool().createIdentifierValue(CSSValueAuto);
2004 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2005 case CSSPropertyMarginTop: {
2006 Length marginTop = style->marginTop();
2007 if (marginTop.isFixed() || !renderer || !renderer->isBox())
2008 return zoomAdjustedPixelValueForLength(marginTop, style.get());
2009 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), style.get());
2011 case CSSPropertyMarginRight: {
2012 Length marginRight = style->marginRight();
2013 if (marginRight.isFixed() || !renderer || !renderer->isBox())
2014 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2016 if (marginRight.isPercent() || marginRight.isViewportPercentage())
2017 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2018 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2019 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2020 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document()->renderView());
2022 value = toRenderBox(renderer)->marginRight();
2023 return zoomAdjustedPixelValue(value, style.get());
2025 case CSSPropertyMarginBottom: {
2026 Length marginBottom = style->marginBottom();
2027 if (marginBottom.isFixed() || !renderer || !renderer->isBox())
2028 return zoomAdjustedPixelValueForLength(marginBottom, style.get());
2029 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), style.get());
2031 case CSSPropertyMarginLeft: {
2032 Length marginLeft = style->marginLeft();
2033 if (marginLeft.isFixed() || !renderer || !renderer->isBox())
2034 return zoomAdjustedPixelValueForLength(marginLeft, style.get());
2035 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), style.get());
2037 case CSSPropertyWebkitMarqueeDirection:
2038 return cssValuePool().createValue(style->marqueeDirection());
2039 case CSSPropertyWebkitMarqueeIncrement:
2040 return cssValuePool().createValue(style->marqueeIncrement());
2041 case CSSPropertyWebkitMarqueeRepetition:
2042 if (style->marqueeLoopCount() < 0)
2043 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2044 return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2045 case CSSPropertyWebkitMarqueeStyle:
2046 return cssValuePool().createValue(style->marqueeBehavior());
2047 case CSSPropertyWebkitUserModify:
2048 return cssValuePool().createValue(style->userModify());
2049 case CSSPropertyMaxHeight: {
2050 const Length& maxHeight = style->maxHeight();
2051 if (maxHeight.isUndefined())
2052 return cssValuePool().createIdentifierValue(CSSValueNone);
2053 return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2055 case CSSPropertyMaxWidth: {
2056 const Length& maxWidth = style->maxWidth();
2057 if (maxWidth.isUndefined())
2058 return cssValuePool().createIdentifierValue(CSSValueNone);
2059 return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2061 case CSSPropertyMinHeight:
2062 // FIXME: For flex-items, min-height:auto should compute to min-content.
2063 if (style->minHeight().isAuto())
2064 return zoomAdjustedPixelValue(0, style.get());
2065 return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2066 case CSSPropertyMinWidth:
2067 // FIXME: For flex-items, min-width:auto should compute to min-content.
2068 if (style->minWidth().isAuto())
2069 return zoomAdjustedPixelValue(0, style.get());
2070 return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2071 case CSSPropertyOpacity:
2072 return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2073 case CSSPropertyOrphans:
2074 if (style->hasAutoOrphans())
2075 return cssValuePool().createIdentifierValue(CSSValueAuto);
2076 return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2077 case CSSPropertyOutlineColor:
2078 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2079 case CSSPropertyOutlineOffset:
2080 return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2081 case CSSPropertyOutlineStyle:
2082 if (style->outlineStyleIsAuto())
2083 return cssValuePool().createIdentifierValue(CSSValueAuto);
2084 return cssValuePool().createValue(style->outlineStyle());
2085 case CSSPropertyOutlineWidth:
2086 return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2087 case CSSPropertyOverflow:
2088 return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
2089 case CSSPropertyOverflowWrap:
2090 return cssValuePool().createValue(style->overflowWrap());
2091 case CSSPropertyOverflowX:
2092 return cssValuePool().createValue(style->overflowX());
2093 case CSSPropertyOverflowY:
2094 return cssValuePool().createValue(style->overflowY());
2095 case CSSPropertyPaddingTop:
2096 if (renderer && renderer->isBox())
2097 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), style.get());
2098 return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get());
2099 case CSSPropertyPaddingRight:
2100 if (renderer && renderer->isBox())
2101 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), style.get());
2102 return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get());
2103 case CSSPropertyPaddingBottom:
2104 if (renderer && renderer->isBox())
2105 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), style.get());
2106 return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get());
2107 case CSSPropertyPaddingLeft:
2108 if (renderer && renderer->isBox())
2109 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), style.get());
2110 return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get());
2111 case CSSPropertyPageBreakAfter:
2112 return cssValuePool().createValue(style->pageBreakAfter());
2113 case CSSPropertyPageBreakBefore:
2114 return cssValuePool().createValue(style->pageBreakBefore());
2115 case CSSPropertyPageBreakInside: {
2116 EPageBreak pageBreak = style->pageBreakInside();
2117 ASSERT(pageBreak != PBALWAYS);
2118 if (pageBreak == PBALWAYS)
2120 return cssValuePool().createValue(style->pageBreakInside());
2122 case CSSPropertyPosition:
2123 return cssValuePool().createValue(style->position());
2124 case CSSPropertyRight:
2125 return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document()->renderView());
2126 case CSSPropertyWebkitRubyPosition:
2127 return cssValuePool().createValue(style->rubyPosition());
2128 case CSSPropertyTableLayout:
2129 return cssValuePool().createValue(style->tableLayout());
2130 case CSSPropertyTextAlign:
2131 return cssValuePool().createValue(style->textAlign());
2132 case CSSPropertyTextDecoration:
2133 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2134 #if ENABLE(CSS3_TEXT)
2135 case CSSPropertyWebkitTextDecorationLine:
2136 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2137 case CSSPropertyWebkitTextDecorationStyle:
2138 return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2139 case CSSPropertyWebkitTextAlignLast:
2140 return cssValuePool().createValue(style->textAlignLast());
2142 case CSSPropertyWebkitTextDecorationsInEffect:
2143 return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2144 case CSSPropertyWebkitTextFillColor:
2145 return currentColorOrValidColor(style.get(), style->textFillColor());
2146 case CSSPropertyWebkitTextEmphasisColor:
2147 return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2148 case CSSPropertyWebkitTextEmphasisPosition:
2149 return cssValuePool().createValue(style->textEmphasisPosition());
2150 case CSSPropertyWebkitTextEmphasisStyle:
2151 switch (style->textEmphasisMark()) {
2152 case TextEmphasisMarkNone:
2153 return cssValuePool().createIdentifierValue(CSSValueNone);
2154 case TextEmphasisMarkCustom:
2155 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2156 case TextEmphasisMarkAuto:
2157 ASSERT_NOT_REACHED();
2159 case TextEmphasisMarkDot:
2160 case TextEmphasisMarkCircle:
2161 case TextEmphasisMarkDoubleCircle:
2162 case TextEmphasisMarkTriangle:
2163 case TextEmphasisMarkSesame: {
2164 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2165 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2166 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2167 return list.release();
2170 case CSSPropertyTextIndent:
2171 return zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2172 case CSSPropertyTextShadow:
2173 return valueForShadow(style->textShadow(), propertyID, style.get());
2174 case CSSPropertyTextRendering:
2175 return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2176 case CSSPropertyTextOverflow:
2177 if (style->textOverflow())
2178 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2179 return cssValuePool().createIdentifierValue(CSSValueClip);
2180 case CSSPropertyWebkitTextSecurity:
2181 return cssValuePool().createValue(style->textSecurity());
2182 case CSSPropertyWebkitTextSizeAdjust:
2183 if (style->textSizeAdjust())
2184 return cssValuePool().createIdentifierValue(CSSValueAuto);
2185 return cssValuePool().createIdentifierValue(CSSValueNone);
2186 case CSSPropertyWebkitTextStrokeColor:
2187 return currentColorOrValidColor(style.get(), style->textStrokeColor());
2188 case CSSPropertyWebkitTextStrokeWidth:
2189 return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2190 case CSSPropertyTextTransform:
2191 return cssValuePool().createValue(style->textTransform());
2192 case CSSPropertyTop:
2193 return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document()->renderView());
2194 case CSSPropertyUnicodeBidi:
2195 return cssValuePool().createValue(style->unicodeBidi());
2196 case CSSPropertyVerticalAlign:
2197 switch (style->verticalAlign()) {
2199 return cssValuePool().createIdentifierValue(CSSValueBaseline);
2201 return cssValuePool().createIdentifierValue(CSSValueMiddle);
2203 return cssValuePool().createIdentifierValue(CSSValueSub);
2205 return cssValuePool().createIdentifierValue(CSSValueSuper);
2207 return cssValuePool().createIdentifierValue(CSSValueTextTop);
2209 return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2211 return cssValuePool().createIdentifierValue(CSSValueTop);
2213 return cssValuePool().createIdentifierValue(CSSValueBottom);
2214 case BASELINE_MIDDLE:
2215 return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2217 return cssValuePool().createValue(style->verticalAlignLength());
2219 ASSERT_NOT_REACHED();
2221 case CSSPropertyVisibility:
2222 return cssValuePool().createValue(style->visibility());
2223 case CSSPropertyWhiteSpace:
2224 return cssValuePool().createValue(style->whiteSpace());
2225 case CSSPropertyWidows:
2226 if (style->hasAutoWidows())
2227 return cssValuePool().createIdentifierValue(CSSValueAuto);
2228 return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2229 case CSSPropertyWidth:
2231 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2232 // the "width" property does not apply for non-replaced inline elements.
2233 if (!renderer->isReplaced() && renderer->isInline())
2234 return cssValuePool().createIdentifierValue(CSSValueAuto);
2235 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2237 return zoomAdjustedPixelValueForLength(style->width(), style.get());
2238 case CSSPropertyWordBreak:
2239 return cssValuePool().createValue(style->wordBreak());
2240 case CSSPropertyWordSpacing:
2241 return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2242 case CSSPropertyWordWrap:
2243 return cssValuePool().createValue(style->overflowWrap());
2244 case CSSPropertyWebkitLineBreak:
2245 return cssValuePool().createValue(style->lineBreak());
2246 case CSSPropertyWebkitNbspMode:
2247 return cssValuePool().createValue(style->nbspMode());
2248 case CSSPropertyResize:
2249 return cssValuePool().createValue(style->resize());
2250 case CSSPropertyWebkitFontKerning:
2251 return cssValuePool().createValue(style->fontDescription().kerning());
2252 case CSSPropertyWebkitFontSmoothing:
2253 return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2254 case CSSPropertyWebkitFontVariantLigatures: {
2255 FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2256 FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2257 FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2258 if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2259 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2260 return cssValuePool().createIdentifierValue(CSSValueNormal);
2262 RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2263 if (commonLigaturesState != FontDescription::NormalLigaturesState)
2264 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2265 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2266 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2267 if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2268 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2271 case CSSPropertyZIndex:
2272 if (style->hasAutoZIndex())
2273 return cssValuePool().createIdentifierValue(CSSValueAuto);
2274 return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2275 case CSSPropertyZoom:
2276 return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2277 case CSSPropertyBoxSizing:
2278 if (style->boxSizing() == CONTENT_BOX)
2279 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2280 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2281 #if ENABLE(DASHBOARD_SUPPORT)
2282 case CSSPropertyWebkitDashboardRegion:
2284 const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2285 unsigned count = regions.size();
2286 if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2287 return cssValuePool().createIdentifierValue(CSSValueNone);
2289 RefPtr<DashboardRegion> firstRegion;
2290 DashboardRegion* previousRegion = 0;
2291 for (unsigned i = 0; i < count; i++) {
2292 RefPtr<DashboardRegion> region = DashboardRegion::create();
2293 StyleDashboardRegion styleRegion = regions[i];
2295 region->m_label = styleRegion.label;
2296 LengthBox offset = styleRegion.offset;
2297 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2298 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2299 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2300 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2301 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2302 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2305 previousRegion->m_next = region;
2307 firstRegion = region;
2308 previousRegion = region.get();
2310 return cssValuePool().createValue(firstRegion.release());
2313 #if ENABLE(DRAGGABLE_REGION)
2314 case CSSPropertyWebkitAppRegion:
2315 return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2317 case CSSPropertyWebkitAnimationDelay:
2318 return getDelayValue(style->animations());
2319 case CSSPropertyWebkitAnimationDirection: {
2320 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2321 const AnimationList* t = style->animations();
2323 for (size_t i = 0; i < t->size(); ++i) {
2324 if (t->animation(i)->direction())
2325 list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2327 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2330 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2331 return list.release();
2333 case CSSPropertyWebkitAnimationDuration:
2334 return getDurationValue(style->animations());
2335 case CSSPropertyWebkitAnimationFillMode: {
2336 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2337 const AnimationList* t = style->animations();
2339 for (size_t i = 0; i < t->size(); ++i) {
2340 switch (t->animation(i)->fillMode()) {
2341 case AnimationFillModeNone:
2342 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2344 case AnimationFillModeForwards:
2345 list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2347 case AnimationFillModeBackwards:
2348 list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2350 case AnimationFillModeBoth:
2351 list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2356 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2357 return list.release();
2359 case CSSPropertyWebkitAnimationIterationCount: {
2360 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2361 const AnimationList* t = style->animations();
2363 for (size_t i = 0; i < t->size(); ++i) {
2364 double iterationCount = t->animation(i)->iterationCount();
2365 if (iterationCount == Animation::IterationCountInfinite)
2366 list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2368 list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2371 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2372 return list.release();
2374 case CSSPropertyWebkitAnimationName: {
2375 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2376 const AnimationList* t = style->animations();
2378 for (size_t i = 0; i < t->size(); ++i)
2379 list->append(cssValuePool().createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
2381 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2382 return list.release();
2384 case CSSPropertyWebkitAnimationPlayState: {
2385 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2386 const AnimationList* t = style->animations();
2388 for (size_t i = 0; i < t->size(); ++i) {
2389 int prop = t->animation(i)->playState();
2390 if (prop == AnimPlayStatePlaying)
2391 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2393 list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2396 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2397 return list.release();
2399 case CSSPropertyWebkitAnimationTimingFunction:
2400 return getTimingFunctionValue(style->animations());
2401 case CSSPropertyWebkitAppearance:
2402 return cssValuePool().createValue(style->appearance());
2403 case CSSPropertyWebkitAspectRatio:
2404 if (!style->hasAspectRatio())
2405 return cssValuePool().createIdentifierValue(CSSValueNone);
2406 return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2407 case CSSPropertyWebkitBackfaceVisibility:
2408 return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2409 case CSSPropertyWebkitBorderImage:
2410 return valueForNinePieceImage(style->borderImage());
2411 case CSSPropertyBorderImageOutset:
2412 return valueForNinePieceImageQuad(style->borderImage().outset());
2413 case CSSPropertyBorderImageRepeat:
2414 return valueForNinePieceImageRepeat(style->borderImage());
2415 case CSSPropertyBorderImageSlice:
2416 return valueForNinePieceImageSlice(style->borderImage());
2417 case CSSPropertyBorderImageWidth:
2418 return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2419 case CSSPropertyWebkitMaskBoxImage:
2420 return valueForNinePieceImage(style->maskBoxImage());
2421 case CSSPropertyWebkitMaskBoxImageOutset:
2422 return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2423 case CSSPropertyWebkitMaskBoxImageRepeat:
2424 return valueForNinePieceImageRepeat(style->maskBoxImage());
2425 case CSSPropertyWebkitMaskBoxImageSlice:
2426 return valueForNinePieceImageSlice(style->maskBoxImage());
2427 case CSSPropertyWebkitMaskBoxImageWidth:
2428 return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2429 case CSSPropertyWebkitMaskBoxImageSource:
2430 if (style->maskBoxImageSource())
2431 return style->maskBoxImageSource()->cssValue();
2432 return cssValuePool().createIdentifierValue(CSSValueNone);
2433 case CSSPropertyWebkitFontSizeDelta:
2434 // Not a real style property -- used by the editing engine -- so has no computed value.
2436 case CSSPropertyWebkitMarginBottomCollapse:
2437 case CSSPropertyWebkitMarginAfterCollapse:
2438 return cssValuePool().createValue(style->marginAfterCollapse());
2439 case CSSPropertyWebkitMarginTopCollapse:
2440 case CSSPropertyWebkitMarginBeforeCollapse:
2441 return cssValuePool().createValue(style->marginBeforeCollapse());
2442 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2443 case CSSPropertyWebkitOverflowScrolling:
2444 if (!style->useTouchOverflowScrolling())
2445 return cssValuePool().createIdentifierValue(CSSValueAuto);
2446 return cssValuePool().createIdentifierValue(CSSValueTouch);
2448 case CSSPropertyWebkitPerspective:
2449 if (!style->hasPerspective())
2450 return cssValuePool().createIdentifierValue(CSSValueNone);
2451 return zoomAdjustedPixelValue(style->perspective(), style.get());
2452 case CSSPropertyWebkitPerspectiveOrigin: {
2453 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2456 if (renderer->isBox())
2457 box = toRenderBox(renderer)->borderBoxRect();
2459 RenderView* renderView = m_node->document()->renderView();
2460 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2461 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2464 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2465 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2468 return list.release();
2470 case CSSPropertyWebkitRtlOrdering:
2471 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2472 #if ENABLE(TOUCH_EVENTS)
2473 case CSSPropertyWebkitTapHighlightColor:
2474 return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2476 case CSSPropertyWebkitUserDrag:
2477 return cssValuePool().createValue(style->userDrag());
2478 case CSSPropertyWebkitUserSelect:
2479 return cssValuePool().createValue(style->userSelect());
2480 case CSSPropertyBorderBottomLeftRadius:
2481 return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document()->renderView());
2482 case CSSPropertyBorderBottomRightRadius:
2483 return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document()->renderView());
2484 case CSSPropertyBorderTopLeftRadius:
2485 return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document()->renderView());
2486 case CSSPropertyBorderTopRightRadius:
2487 return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document()->renderView());
2488 case CSSPropertyClip: {
2489 if (!style->hasClip())
2490 return cssValuePool().createIdentifierValue(CSSValueAuto);
2491 RefPtr<Rect> rect = Rect::create();
2492 rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2493 rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2494 rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2495 rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2496 return cssValuePool().createValue(rect.release());
2498 case CSSPropertySpeak:
2499 return cssValuePool().createValue(style->speak());
2500 case CSSPropertyWebkitTransform:
2501 return computedTransform(renderer, style.get());
2502 case CSSPropertyWebkitTransformOrigin: {
2503 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2506 if (renderer->isBox())
2507 box = toRenderBox(renderer)->borderBoxRect();
2509 RenderView* renderView = m_node->document()->renderView();
2510 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2511 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2512 if (style->transformOriginZ() != 0)
2513 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2515 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2516 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2517 if (style->transformOriginZ() != 0)
2518 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2520 return list.release();
2522 case CSSPropertyWebkitTransformStyle:
2523 return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2524 case CSSPropertyTransitionDelay:
2525 case CSSPropertyWebkitTransitionDelay:
2526 return getDelayValue(style->transitions());
2527 case CSSPropertyTransitionDuration:
2528 case CSSPropertyWebkitTransitionDuration:
2529 return getDurationValue(style->transitions());
2530 case CSSPropertyTransitionProperty:
2531 case CSSPropertyWebkitTransitionProperty:
2532 return getTransitionPropertyValue(style->transitions());
2533 case CSSPropertyTransitionTimingFunction:
2534 case CSSPropertyWebkitTransitionTimingFunction:
2535 return getTimingFunctionValue(style->transitions());
2536 case CSSPropertyTransition:
2537 case CSSPropertyWebkitTransition: {
2538 const AnimationList* animList = style->transitions();
2540 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2541 for (size_t i = 0; i < animList->size(); ++i) {
2542 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2543 const Animation* animation = animList->animation(i);
2544 list->append(createTransitionPropertyValue(animation));
2545 list->append(cssValuePool().createValue(animation->duration(), CSSPrimitiveValue::CSS_S));
2546 list->append(createTimingFunctionValue(animation->timingFunction().get()));
2547 list->append(cssValuePool().createValue(animation->delay(), CSSPrimitiveValue::CSS_S));
2548 transitionsList->append(list);
2550 return transitionsList.release();
2553 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2554 // transition-property default value.
2555 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2556 list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2557 list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2558 list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2559 return list.release();
2561 case CSSPropertyPointerEvents:
2562 return cssValuePool().createValue(style->pointerEvents());
2563 case CSSPropertyWebkitColorCorrection:
2564 return cssValuePool().createValue(style->colorSpace());
2565 case CSSPropertyWebkitLineGrid:
2566 if (style->lineGrid().isNull())
2567 return cssValuePool().createIdentifierValue(CSSValueNone);
2568 return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2569 case CSSPropertyWebkitLineSnap:
2570 return CSSPrimitiveValue::create(style->lineSnap());
2571 case CSSPropertyWebkitLineAlign:
2572 return CSSPrimitiveValue::create(style->lineAlign());
2573 case CSSPropertyWebkitWritingMode:
2574 return cssValuePool().createValue(style->writingMode());
2575 case CSSPropertyWebkitTextCombine:
2576 return cssValuePool().createValue(style->textCombine());
2577 case CSSPropertyWebkitTextOrientation:
2578 return CSSPrimitiveValue::create(style->textOrientation());
2579 case CSSPropertyWebkitLineBoxContain:
2580 return createLineBoxContainValue(style->lineBoxContain());
2581 case CSSPropertyContent:
2582 return contentToCSSValue(style.get());
2583 case CSSPropertyCounterIncrement:
2584 return counterToCSSValue(style.get(), propertyID);
2585 case CSSPropertyCounterReset:
2586 return counterToCSSValue(style.get(), propertyID);
2587 case CSSPropertyWebkitClipPath:
2588 if (ClipPathOperation* operation = style->clipPath()) {
2589 if (operation->getOperationType() == ClipPathOperation::SHAPE)
2590 return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2592 else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
2593 ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2594 return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2598 return cssValuePool().createIdentifierValue(CSSValueNone);
2599 #if ENABLE(CSS_REGIONS)
2600 case CSSPropertyWebkitFlowInto:
2601 if (style->flowThread().isNull())
2602 return cssValuePool().createIdentifierValue(CSSValueNone);
2603 return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2604 case CSSPropertyWebkitFlowFrom:
2605 if (style->regionThread().isNull())
2606 return cssValuePool().createIdentifierValue(CSSValueNone);
2607 return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2608 case CSSPropertyWebkitRegionOverflow:
2609 return cssValuePool().createValue(style->regionOverflow());
2611 #if ENABLE(CSS_EXCLUSIONS)
2612 case CSSPropertyWebkitWrapFlow:
2613 return cssValuePool().createValue(style->wrapFlow());
2614 case CSSPropertyWebkitShapeMargin:
2615 return cssValuePool().createValue(style->shapeMargin());
2616 case CSSPropertyWebkitShapePadding:
2617 return cssValuePool().createValue(style->shapePadding());
2618 case CSSPropertyWebkitShapeInside:
2619 if (!style->shapeInside())
2620 return cssValuePool().createIdentifierValue(CSSValueAuto);
2621 else if (style->shapeInside()->type() == ExclusionShapeValue::OUTSIDE)
2622 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2623 ASSERT(style->shapeInside()->type() == ExclusionShapeValue::SHAPE);
2624 return valueForBasicShape(style->shapeInside()->shape());
2625 case CSSPropertyWebkitShapeOutside:
2626 if (!style->shapeOutside())
2627 return cssValuePool().createIdentifierValue(CSSValueAuto);
2628 ASSERT(style->shapeOutside()->type() == ExclusionShapeValue::SHAPE);
2629 return valueForBasicShape(style->shapeOutside()->shape());
2630 case CSSPropertyWebkitWrapThrough:
2631 return cssValuePool().createValue(style->wrapThrough());
2633 #if ENABLE(CSS_FILTERS)
2634 case CSSPropertyWebkitFilter:
2635 return valueForFilter(renderer, style.get());
2637 #if ENABLE(CSS_COMPOSITING)
2638 case CSSPropertyWebkitBlendMode:
2639 return cssValuePool().createValue(style->blendMode());
2641 case CSSPropertyWebkitBackgroundBlendMode: {
2642 const FillLayer* layers = style->backgroundLayers();
2643 if (!layers->next())
2644 return cssValuePool().createValue(layers->blendMode());
2646 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2647 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2648 list->append(cssValuePool().createValue(currLayer->blendMode()));
2650 return list.release();
2653 case CSSPropertyBackground:
2654 return getBackgroundShorthandValue();
2655 case CSSPropertyBorder: {
2656 RefPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2657 const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2658 CSSPropertyBorderLeft };
2659 for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2660 if (!compareCSSValuePtr<CSSValue>(value, getPropertyCSSValue(properties[i], DoNotUpdateLayout)))
2663 return value.release();
2665 case CSSPropertyBorderBottom:
2666 return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2667 case CSSPropertyBorderColor:
2668 return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2669 case CSSPropertyBorderLeft:
2670 return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2671 case CSSPropertyBorderImage:
2672 return valueForNinePieceImage(style->borderImage());
2673 case CSSPropertyBorderRadius:
2674 return getBorderRadiusShorthandValue(style.get(), m_node->document()->renderView());
2675 case CSSPropertyBorderRight:
2676 return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2677 case CSSPropertyBorderStyle:
2678 return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2679 case CSSPropertyBorderTop:
2680 return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2681 case CSSPropertyBorderWidth:
2682 return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2683 case CSSPropertyWebkitColumnRule:
2684 return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2685 case CSSPropertyWebkitColumns:
2686 return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2687 case CSSPropertyListStyle:
2688 return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2689 case CSSPropertyMargin:
2690 return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2691 case CSSPropertyOutline:
2692 return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2693 case CSSPropertyPadding:
2694 return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2695 /* Individual properties not part of the spec */
2696 case CSSPropertyBackgroundRepeatX:
2697 case CSSPropertyBackgroundRepeatY:
2700 /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2701 case CSSPropertyWebkitTextEmphasis:
2702 case CSSPropertyTextLineThrough:
2703 case CSSPropertyTextLineThroughColor:
2704 case CSSPropertyTextLineThroughMode:
2705 case CSSPropertyTextLineThroughStyle:
2706 case CSSPropertyTextLineThroughWidth:
2707 case CSSPropertyTextOverline:
2708 case CSSPropertyTextOverlineColor:
2709 case CSSPropertyTextOverlineMode:
2710 case CSSPropertyTextOverlineStyle:
2711 case CSSPropertyTextOverlineWidth:
2712 case CSSPropertyTextUnderline:
2713 case CSSPropertyTextUnderlineColor:
2714 case CSSPropertyTextUnderlineMode:
2715 case CSSPropertyTextUnderlineStyle:
2716 case CSSPropertyTextUnderlineWidth:
2719 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2720 case CSSPropertyWebkitBorderEnd:
2721 case CSSPropertyWebkitBorderEndColor:
2722 case CSSPropertyWebkitBorderEndStyle:
2723 case CSSPropertyWebkitBorderEndWidth:
2724 case CSSPropertyWebkitBorderStart:
2725 case CSSPropertyWebkitBorderStartColor:
2726 case CSSPropertyWebkitBorderStartStyle:
2727 case CSSPropertyWebkitBorderStartWidth:
2728 case CSSPropertyWebkitBorderAfter:
2729 case CSSPropertyWebkitBorderAfterColor:
2730 case CSSPropertyWebkitBorderAfterStyle:
2731 case CSSPropertyWebkitBorderAfterWidth:
2732 case CSSPropertyWebkitBorderBefore:
2733 case CSSPropertyWebkitBorderBeforeColor:
2734 case CSSPropertyWebkitBorderBeforeStyle:
2735 case CSSPropertyWebkitBorderBeforeWidth:
2736 case CSSPropertyWebkitMarginEnd:
2737 case CSSPropertyWebkitMarginStart:
2738 case CSSPropertyWebkitMarginAfter:
2739 case CSSPropertyWebkitMarginBefore:
2740 case CSSPropertyWebkitPaddingEnd:
2741 case CSSPropertyWebkitPaddingStart:
2742 case CSSPropertyWebkitPaddingAfter:
2743 case CSSPropertyWebkitPaddingBefore:
2744 case CSSPropertyWebkitLogicalWidth:
2745 case CSSPropertyWebkitLogicalHeight:
2746 case CSSPropertyWebkitMinLogicalWidth:
2747 case CSSPropertyWebkitMinLogicalHeight:
2748 case CSSPropertyWebkitMaxLogicalWidth:
2749 case CSSPropertyWebkitMaxLogicalHeight:
2750 ASSERT_NOT_REACHED();
2753 /* Unimplemented @font-face properties */
2754 case CSSPropertyFontStretch:
2755 case CSSPropertySrc:
2756 case CSSPropertyUnicodeRange:
2759 /* Other unimplemented properties */
2760 case CSSPropertyPage: // for @page
2761 case CSSPropertyQuotes: // FIXME: needs implementation
2762 case CSSPropertySize: // for @page
2765 /* Unimplemented -webkit- properties */
2766 case CSSPropertyWebkitAnimation:
2767 case CSSPropertyWebkitBorderRadius:
2768 case CSSPropertyWebkitMarginCollapse:
2769 case CSSPropertyWebkitMarquee:
2770 case CSSPropertyWebkitMarqueeSpeed:
2771 case CSSPropertyWebkitMask:
2772 case CSSPropertyWebkitMaskRepeatX:
2773 case CSSPropertyWebkitMaskRepeatY:
2774 case CSSPropertyWebkitPerspectiveOriginX:
2775 case CSSPropertyWebkitPerspectiveOriginY:
2776 case CSSPropertyWebkitTextStroke:
2777 case CSSPropertyWebkitTransformOriginX:
2778 case CSSPropertyWebkitTransformOriginY:
2779 case CSSPropertyWebkitTransformOriginZ:
2780 #if ENABLE(CSS_EXCLUSIONS)
2781 case CSSPropertyWebkitWrap:
2785 #if ENABLE(CSS_DEVICE_ADAPTATION)
2786 case CSSPropertyMaxZoom:
2787 case CSSPropertyMinZoom:
2788 case CSSPropertyOrientation:
2789 case CSSPropertyUserZoom:
2794 case CSSPropertyClipPath:
2795 case CSSPropertyClipRule:
2796 case CSSPropertyMask:
2797 case CSSPropertyEnableBackground:
2798 case CSSPropertyFilter:
2799 case CSSPropertyFloodColor:
2800 case CSSPropertyFloodOpacity:
2801 case CSSPropertyLightingColor:
2802 case CSSPropertyStopColor:
2803 case CSSPropertyStopOpacity:
2804 case CSSPropertyColorInterpolation:
2805 case CSSPropertyColorInterpolationFilters:
2806 case CSSPropertyColorProfile:
2807 case CSSPropertyColorRendering:
2808 case CSSPropertyFill:
2809 case CSSPropertyFillOpacity:
2810 case CSSPropertyFillRule:
2811 case CSSPropertyMarker:
2812 case CSSPropertyMarkerEnd:
2813 case CSSPropertyMarkerMid:
2814 case CSSPropertyMarkerStart:
2815 case CSSPropertyMaskType:
2816 case CSSPropertyShapeRendering:
2817 case CSSPropertyStroke:
2818 case CSSPropertyStrokeDasharray:
2819 case CSSPropertyStrokeDashoffset:
2820 case CSSPropertyStrokeLinecap:
2821 case CSSPropertyStrokeLinejoin:
2822 case CSSPropertyStrokeMiterlimit:
2823 case CSSPropertyStrokeOpacity:
2824 case CSSPropertyStrokeWidth:
2825 case CSSPropertyAlignmentBaseline:
2826 case CSSPropertyBaselineShift:
2827 case CSSPropertyDominantBaseline:
2828 case CSSPropertyGlyphOrientationHorizontal:
2829 case CSSPropertyGlyphOrientationVertical:
2830 case CSSPropertyKerning:
2831 case CSSPropertyTextAnchor:
2832 case CSSPropertyVectorEffect:
2833 case CSSPropertyWritingMode:
2834 case CSSPropertyWebkitSvgShadow:
2835 return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
2839 logUnimplementedPropertyID(propertyID);
2843 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
2845 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2847 return value->cssText();
2852 unsigned CSSComputedStyleDeclaration::length() const
2854 Node* node = m_node.get();
2858 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
2862 return numComputedProperties;
2865 String CSSComputedStyleDeclaration::item(unsigned i) const
2870 return getPropertyNameString(computedProperties[i]);
2873 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
2875 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() && m_node) {
2876 m_node->document()->updateLayoutIgnorePendingStylesheets();
2877 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
2878 if (style && style->fontDescription().keywordSize()) {
2879 int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
2880 const CSSPrimitiveValue* primitiveValue = static_cast<const CSSPrimitiveValue*>(propertyValue);
2881 if (primitiveValue->isIdent() && primitiveValue->getIdent() == sizeValue)
2885 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2886 return value && propertyValue && value->equals(*propertyValue);
2889 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copy() const
2891 return copyPropertiesInSet(computedProperties, numComputedProperties);
2894 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::makeMutable()
2899 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
2901 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2902 for (size_t i = 0; i < shorthand.length(); ++i) {
2903 RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2904 list->append(value);
2906 return list.release();
2909 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
2911 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2912 // Assume the properties are in the usual order top, right, bottom, left.
2913 RefPtr<CSSValue> topValue = getPropertyCSSValue(shorthand.properties()[0], DoNotUpdateLayout);
2914 RefPtr<CSSValue> rightValue = getPropertyCSSValue(shorthand.properties()[1], DoNotUpdateLayout);
2915 RefPtr<CSSValue> bottomValue = getPropertyCSSValue(shorthand.properties()[2], DoNotUpdateLayout);
2916 RefPtr<CSSValue> leftValue = getPropertyCSSValue(shorthand.properties()[3], DoNotUpdateLayout);
2918 // All 4 properties must be specified.
2919 if (!topValue || !rightValue || !bottomValue || !leftValue)
2922 bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
2923 bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
2924 bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
2926 list->append(topValue);
2928 list->append(rightValue);
2930 list->append(bottomValue);
2932 list->append(leftValue);
2934 return list.release();
2937 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
2939 Vector<CSSProperty, 256> list;
2940 list.reserveInitialCapacity(length);
2941 for (unsigned i = 0; i < length; ++i) {
2942 RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
2944 list.append(CSSProperty(set[i], value.release(), false));
2946 return StylePropertySet::create(list.data(), list.size());
2949 void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
2951 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
2952 info.addMember(m_node, "node");
2955 CSSRule* CSSComputedStyleDeclaration::parentRule() const
2960 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
2962 CSSPropertyID propertyID = cssPropertyID(propertyName);
2965 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2966 return value ? value->cloneForCSSOM() : 0;
2969 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
2971 CSSPropertyID propertyID = cssPropertyID(propertyName);
2974 return getPropertyValue(propertyID);
2977 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
2979 // All computed styles have a priority of not "important".
2983 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
2988 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
2993 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
2995 ec = NO_MODIFICATION_ALLOWED_ERR;
2998 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3000 ec = NO_MODIFICATION_ALLOWED_ERR;
3004 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3006 return getPropertyCSSValue(propertyID);
3009 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3011 return getPropertyValue(propertyID);
3014 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3016 ec = NO_MODIFICATION_ALLOWED_ERR;
3019 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
3021 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3022 CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
3023 CSSPropertyBackgroundPosition };
3024 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin,
3025 CSSPropertyBackgroundClip };
3027 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3028 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3029 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3030 return list.release();
3033 } // namespace WebCore