Use toCSSFooValue() instead of using static_cast<const CSSFooValue*>
[WebKit-https.git] / Source / WebCore / css / CSSComputedStyleDeclaration.cpp
1 /*
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.
7  *
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.
12  *
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.
17  *
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
21  * 02110-1301  USA
22  */
23
24 #include "config.h"
25 #include "CSSComputedStyleDeclaration.h"
26
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 "CSSFontFeatureValue.h"
34 #include "CSSFontValue.h"
35 #include "CSSFunctionValue.h"
36 #include "CSSLineBoxContainValue.h"
37 #include "CSSParser.h"
38 #include "CSSPrimitiveValue.h"
39 #include "CSSPrimitiveValueMappings.h"
40 #include "CSSPropertyNames.h"
41 #include "CSSReflectValue.h"
42 #include "CSSSelector.h"
43 #include "CSSShadowValue.h"
44 #include "CSSTimingFunctionValue.h"
45 #include "CSSValueList.h"
46 #include "CSSValuePool.h"
47 #include "ContentData.h"
48 #include "CounterContent.h"
49 #include "CursorList.h"
50 #include "Document.h"
51 #include "ExceptionCode.h"
52 #include "FontFeatureSettings.h"
53 #include "HTMLFrameOwnerElement.h"
54 #include "Pair.h"
55 #include "PseudoElement.h"
56 #include "Rect.h"
57 #include "RenderBox.h"
58 #include "RenderStyle.h"
59 #include "RenderView.h"
60 #include "StyleInheritedData.h"
61 #include "StylePropertySet.h"
62 #include "StylePropertyShorthand.h"
63 #include "StyleResolver.h"
64 #include "WebKitCSSTransformValue.h"
65 #include "WebKitFontFamilyNames.h"
66 #include <wtf/text/StringBuilder.h>
67
68 #if ENABLE(CSS_SHAPES)
69 #include "ShapeValue.h"
70 #endif
71
72 #if ENABLE(CSS_SHADERS)
73 #include "CustomFilterArrayParameter.h"
74 #include "CustomFilterColorParameter.h"
75 #include "CustomFilterNumberParameter.h"
76 #include "CustomFilterOperation.h"
77 #include "CustomFilterParameter.h"
78 #include "CustomFilterTransformParameter.h"
79 #include "WebKitCSSArrayFunctionValue.h"
80 #include "WebKitCSSMatFunctionValue.h"
81 #include "WebKitCSSMixFunctionValue.h"
82 #endif
83
84 #if ENABLE(CSS_FILTERS)
85 #include "StyleCustomFilterProgram.h"
86 #include "WebKitCSSFilterValue.h"
87 #endif
88
89 #if ENABLE(DASHBOARD_SUPPORT)
90 #include "DashboardRegion.h"
91 #endif
92
93 namespace WebCore {
94
95 // List of all properties we know how to compute, omitting shorthands.
96 static const CSSPropertyID computedProperties[] = {
97     CSSPropertyBackgroundAttachment,
98     CSSPropertyBackgroundClip,
99     CSSPropertyBackgroundColor,
100     CSSPropertyBackgroundImage,
101     CSSPropertyBackgroundOrigin,
102     CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
103     CSSPropertyBackgroundRepeat,
104     CSSPropertyBackgroundSize,
105     CSSPropertyBorderBottomColor,
106     CSSPropertyBorderBottomLeftRadius,
107     CSSPropertyBorderBottomRightRadius,
108     CSSPropertyBorderBottomStyle,
109     CSSPropertyBorderBottomWidth,
110     CSSPropertyBorderCollapse,
111     CSSPropertyBorderImageOutset,
112     CSSPropertyBorderImageRepeat,
113     CSSPropertyBorderImageSlice,
114     CSSPropertyBorderImageSource,
115     CSSPropertyBorderImageWidth,
116     CSSPropertyBorderLeftColor,
117     CSSPropertyBorderLeftStyle,
118     CSSPropertyBorderLeftWidth,
119     CSSPropertyBorderRightColor,
120     CSSPropertyBorderRightStyle,
121     CSSPropertyBorderRightWidth,
122     CSSPropertyBorderTopColor,
123     CSSPropertyBorderTopLeftRadius,
124     CSSPropertyBorderTopRightRadius,
125     CSSPropertyBorderTopStyle,
126     CSSPropertyBorderTopWidth,
127     CSSPropertyBottom,
128     CSSPropertyBoxShadow,
129     CSSPropertyBoxSizing,
130     CSSPropertyCaptionSide,
131     CSSPropertyClear,
132     CSSPropertyClip,
133     CSSPropertyColor,
134     CSSPropertyCursor,
135     CSSPropertyDirection,
136     CSSPropertyDisplay,
137     CSSPropertyEmptyCells,
138     CSSPropertyFloat,
139     CSSPropertyFontFamily,
140     CSSPropertyFontSize,
141     CSSPropertyFontStyle,
142     CSSPropertyFontVariant,
143     CSSPropertyFontWeight,
144     CSSPropertyHeight,
145 #if ENABLE(CSS_IMAGE_ORIENTATION)
146     CSSPropertyImageOrientation,
147 #endif
148     CSSPropertyImageRendering,
149 #if ENABLE(CSS_IMAGE_RESOLUTION)
150     CSSPropertyImageResolution,
151 #endif
152     CSSPropertyLeft,
153     CSSPropertyLetterSpacing,
154     CSSPropertyLineHeight,
155     CSSPropertyListStyleImage,
156     CSSPropertyListStylePosition,
157     CSSPropertyListStyleType,
158     CSSPropertyMarginBottom,
159     CSSPropertyMarginLeft,
160     CSSPropertyMarginRight,
161     CSSPropertyMarginTop,
162     CSSPropertyMaxHeight,
163     CSSPropertyMaxWidth,
164     CSSPropertyMinHeight,
165     CSSPropertyMinWidth,
166     CSSPropertyOpacity,
167     CSSPropertyOrphans,
168     CSSPropertyOutlineColor,
169     CSSPropertyOutlineOffset,
170     CSSPropertyOutlineStyle,
171     CSSPropertyOutlineWidth,
172     CSSPropertyOverflowWrap,
173     CSSPropertyOverflowX,
174     CSSPropertyOverflowY,
175     CSSPropertyPaddingBottom,
176     CSSPropertyPaddingLeft,
177     CSSPropertyPaddingRight,
178     CSSPropertyPaddingTop,
179     CSSPropertyPageBreakAfter,
180     CSSPropertyPageBreakBefore,
181     CSSPropertyPageBreakInside,
182     CSSPropertyPointerEvents,
183     CSSPropertyPosition,
184     CSSPropertyResize,
185     CSSPropertyRight,
186     CSSPropertySpeak,
187     CSSPropertyTableLayout,
188     CSSPropertyTabSize,
189     CSSPropertyTextAlign,
190     CSSPropertyTextDecoration,
191 #if ENABLE(CSS3_TEXT)
192     CSSPropertyWebkitTextDecorationLine,
193     CSSPropertyWebkitTextDecorationStyle,
194     CSSPropertyWebkitTextDecorationColor,
195     CSSPropertyWebkitTextAlignLast,
196     CSSPropertyWebkitTextJustify,
197     CSSPropertyWebkitTextUnderlinePosition,
198 #endif // CSS3_TEXT
199     CSSPropertyTextIndent,
200     CSSPropertyTextRendering,
201     CSSPropertyTextShadow,
202     CSSPropertyTextOverflow,
203     CSSPropertyTextTransform,
204     CSSPropertyTop,
205     CSSPropertyTransitionDelay,
206     CSSPropertyTransitionDuration,
207     CSSPropertyTransitionProperty,
208     CSSPropertyTransitionTimingFunction,
209     CSSPropertyUnicodeBidi,
210     CSSPropertyVerticalAlign,
211     CSSPropertyVisibility,
212     CSSPropertyWhiteSpace,
213     CSSPropertyWidows,
214     CSSPropertyWidth,
215     CSSPropertyWordBreak,
216     CSSPropertyWordSpacing,
217     CSSPropertyWordWrap,
218     CSSPropertyZIndex,
219     CSSPropertyZoom,
220
221     CSSPropertyWebkitAnimationDelay,
222     CSSPropertyWebkitAnimationDirection,
223     CSSPropertyWebkitAnimationDuration,
224     CSSPropertyWebkitAnimationFillMode,
225     CSSPropertyWebkitAnimationIterationCount,
226     CSSPropertyWebkitAnimationName,
227     CSSPropertyWebkitAnimationPlayState,
228     CSSPropertyWebkitAnimationTimingFunction,
229     CSSPropertyWebkitAppearance,
230     CSSPropertyWebkitBackfaceVisibility,
231     CSSPropertyWebkitBackgroundBlendMode,
232     CSSPropertyWebkitBackgroundClip,
233     CSSPropertyWebkitBackgroundComposite,
234     CSSPropertyWebkitBackgroundOrigin,
235     CSSPropertyWebkitBackgroundSize,
236 #if ENABLE(CSS_COMPOSITING)
237     CSSPropertyWebkitBlendMode,
238 #endif
239     CSSPropertyWebkitBorderFit,
240     CSSPropertyWebkitBorderHorizontalSpacing,
241     CSSPropertyWebkitBorderImage,
242     CSSPropertyWebkitBorderVerticalSpacing,
243     CSSPropertyWebkitBoxAlign,
244 #if ENABLE(CSS_BOX_DECORATION_BREAK)
245     CSSPropertyWebkitBoxDecorationBreak,
246 #endif
247     CSSPropertyWebkitBoxDirection,
248     CSSPropertyWebkitBoxFlex,
249     CSSPropertyWebkitBoxFlexGroup,
250     CSSPropertyWebkitBoxLines,
251     CSSPropertyWebkitBoxOrdinalGroup,
252     CSSPropertyWebkitBoxOrient,
253     CSSPropertyWebkitBoxPack,
254     CSSPropertyWebkitBoxReflect,
255     CSSPropertyWebkitBoxShadow,
256     CSSPropertyWebkitClipPath,
257     CSSPropertyWebkitColorCorrection,
258     CSSPropertyWebkitColumnBreakAfter,
259     CSSPropertyWebkitColumnBreakBefore,
260     CSSPropertyWebkitColumnBreakInside,
261     CSSPropertyWebkitColumnAxis,
262     CSSPropertyWebkitColumnCount,
263     CSSPropertyWebkitColumnGap,
264     CSSPropertyWebkitColumnProgression,
265     CSSPropertyWebkitColumnRuleColor,
266     CSSPropertyWebkitColumnRuleStyle,
267     CSSPropertyWebkitColumnRuleWidth,
268     CSSPropertyWebkitColumnSpan,
269     CSSPropertyWebkitColumnWidth,
270 #if ENABLE(CURSOR_VISIBILITY)
271     CSSPropertyWebkitCursorVisibility,
272 #endif
273 #if ENABLE(DASHBOARD_SUPPORT)
274     CSSPropertyWebkitDashboardRegion,
275 #endif
276 #if ENABLE(CSS_FILTERS)
277     CSSPropertyWebkitFilter,
278 #endif
279     CSSPropertyWebkitAlignContent,
280     CSSPropertyWebkitAlignItems,
281     CSSPropertyWebkitAlignSelf,
282     CSSPropertyWebkitFlexBasis,
283     CSSPropertyWebkitFlexGrow,
284     CSSPropertyWebkitFlexShrink,
285     CSSPropertyWebkitFlexDirection,
286     CSSPropertyWebkitFlexWrap,
287     CSSPropertyWebkitJustifyContent,
288     CSSPropertyWebkitFontKerning,
289     CSSPropertyWebkitFontSmoothing,
290     CSSPropertyWebkitFontVariantLigatures,
291     CSSPropertyWebkitGridAutoColumns,
292     CSSPropertyWebkitGridAutoFlow,
293     CSSPropertyWebkitGridAutoRows,
294     CSSPropertyWebkitGridColumnEnd,
295     CSSPropertyWebkitGridColumnStart,
296     CSSPropertyWebkitGridDefinitionColumns,
297     CSSPropertyWebkitGridDefinitionRows,
298     CSSPropertyWebkitGridRowEnd,
299     CSSPropertyWebkitGridRowStart,
300     CSSPropertyWebkitHighlight,
301     CSSPropertyWebkitHyphenateCharacter,
302     CSSPropertyWebkitHyphenateLimitAfter,
303     CSSPropertyWebkitHyphenateLimitBefore,
304     CSSPropertyWebkitHyphenateLimitLines,
305     CSSPropertyWebkitHyphens,
306     CSSPropertyWebkitLineAlign,
307     CSSPropertyWebkitLineBoxContain,
308     CSSPropertyWebkitLineBreak,
309     CSSPropertyWebkitLineClamp,
310     CSSPropertyWebkitLineGrid,
311     CSSPropertyWebkitLineSnap,
312     CSSPropertyWebkitLocale,
313     CSSPropertyWebkitMarginBeforeCollapse,
314     CSSPropertyWebkitMarginAfterCollapse,
315     CSSPropertyWebkitMarqueeDirection,
316     CSSPropertyWebkitMarqueeIncrement,
317     CSSPropertyWebkitMarqueeRepetition,
318     CSSPropertyWebkitMarqueeStyle,
319     CSSPropertyWebkitMaskBoxImage,
320     CSSPropertyWebkitMaskBoxImageOutset,
321     CSSPropertyWebkitMaskBoxImageRepeat,
322     CSSPropertyWebkitMaskBoxImageSlice,
323     CSSPropertyWebkitMaskBoxImageSource,
324     CSSPropertyWebkitMaskBoxImageWidth,
325     CSSPropertyWebkitMaskClip,
326     CSSPropertyWebkitMaskComposite,
327     CSSPropertyWebkitMaskImage,
328     CSSPropertyWebkitMaskOrigin,
329     CSSPropertyWebkitMaskPosition,
330     CSSPropertyWebkitMaskRepeat,
331     CSSPropertyWebkitMaskSize,
332     CSSPropertyWebkitMaskSourceType,
333     CSSPropertyWebkitNbspMode,
334     CSSPropertyWebkitOrder,
335 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
336     CSSPropertyWebkitOverflowScrolling,
337 #endif
338     CSSPropertyWebkitPerspective,
339     CSSPropertyWebkitPerspectiveOrigin,
340     CSSPropertyWebkitPrintColorAdjust,
341     CSSPropertyWebkitRtlOrdering,
342 #if PLATFORM(IOS)
343     CSSPropertyWebkitTouchCallout,
344 #endif
345 #if ENABLE(CSS_SHAPES)
346     CSSPropertyWebkitShapeInside,
347     CSSPropertyWebkitShapeOutside,
348 #endif
349 #if ENABLE(TOUCH_EVENTS)
350     CSSPropertyWebkitTapHighlightColor,
351 #endif
352     CSSPropertyWebkitTextCombine,
353     CSSPropertyWebkitTextDecorationsInEffect,
354     CSSPropertyWebkitTextEmphasisColor,
355     CSSPropertyWebkitTextEmphasisPosition,
356     CSSPropertyWebkitTextEmphasisStyle,
357     CSSPropertyWebkitTextFillColor,
358     CSSPropertyWebkitTextOrientation,
359     CSSPropertyWebkitTextSecurity,
360 #if ENABLE(IOS_TEXT_AUTOSIZING)
361     CSSPropertyWebkitTextSizeAdjust,
362 #endif
363     CSSPropertyWebkitTextStrokeColor,
364     CSSPropertyWebkitTextStrokeWidth,
365     CSSPropertyWebkitTransform,
366     CSSPropertyWebkitTransformOrigin,
367     CSSPropertyWebkitTransformStyle,
368     CSSPropertyWebkitTransitionDelay,
369     CSSPropertyWebkitTransitionDuration,
370     CSSPropertyWebkitTransitionProperty,
371     CSSPropertyWebkitTransitionTimingFunction,
372     CSSPropertyWebkitUserDrag,
373     CSSPropertyWebkitUserModify,
374     CSSPropertyWebkitUserSelect,
375     CSSPropertyWebkitWritingMode,
376 #if ENABLE(CSS_REGIONS)
377     CSSPropertyWebkitFlowInto,
378     CSSPropertyWebkitFlowFrom,
379     CSSPropertyWebkitRegionBreakAfter,
380     CSSPropertyWebkitRegionBreakBefore,
381     CSSPropertyWebkitRegionBreakInside,
382     CSSPropertyWebkitRegionFragment,
383 #endif
384 #if ENABLE(DRAGGABLE_REGION)
385     CSSPropertyWebkitAppRegion,
386 #endif
387 #if ENABLE(CSS_EXCLUSIONS)
388     CSSPropertyWebkitWrapFlow,
389     CSSPropertyWebkitWrapThrough,
390 #endif
391 #if ENABLE(CSS_SHAPES)
392     CSSPropertyWebkitShapeMargin,
393     CSSPropertyWebkitShapePadding,
394     CSSPropertyWebkitShapeImageThreshold,
395 #endif
396 #if ENABLE(SVG)
397     CSSPropertyBufferedRendering,
398     CSSPropertyClipPath,
399     CSSPropertyClipRule,
400     CSSPropertyMask,
401     CSSPropertyFilter,
402     CSSPropertyFloodColor,
403     CSSPropertyFloodOpacity,
404     CSSPropertyLightingColor,
405     CSSPropertyStopColor,
406     CSSPropertyStopOpacity,
407     CSSPropertyColorInterpolation,
408     CSSPropertyColorInterpolationFilters,
409     CSSPropertyColorRendering,
410     CSSPropertyFill,
411     CSSPropertyFillOpacity,
412     CSSPropertyFillRule,
413     CSSPropertyMarkerEnd,
414     CSSPropertyMarkerMid,
415     CSSPropertyMarkerStart,
416     CSSPropertyMaskType,
417     CSSPropertyShapeRendering,
418     CSSPropertyStroke,
419     CSSPropertyStrokeDasharray,
420     CSSPropertyStrokeDashoffset,
421     CSSPropertyStrokeLinecap,
422     CSSPropertyStrokeLinejoin,
423     CSSPropertyStrokeMiterlimit,
424     CSSPropertyStrokeOpacity,
425     CSSPropertyStrokeWidth,
426     CSSPropertyAlignmentBaseline,
427     CSSPropertyBaselineShift,
428     CSSPropertyDominantBaseline,
429     CSSPropertyKerning,
430     CSSPropertyTextAnchor,
431     CSSPropertyWritingMode,
432     CSSPropertyGlyphOrientationHorizontal,
433     CSSPropertyGlyphOrientationVertical,
434     CSSPropertyWebkitSvgShadow,
435     CSSPropertyVectorEffect
436 #endif
437 };
438
439 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
440
441 static CSSValueID valueForRepeatRule(int rule)
442 {
443     switch (rule) {
444         case RepeatImageRule:
445             return CSSValueRepeat;
446         case RoundImageRule:
447             return CSSValueRound;
448         case SpaceImageRule:
449             return CSSValueSpace;
450         default:
451             return CSSValueStretch;
452     }
453 }
454
455 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
456 {
457     // Create the slices.
458     RefPtr<CSSPrimitiveValue> top;
459     RefPtr<CSSPrimitiveValue> right;
460     RefPtr<CSSPrimitiveValue> bottom;
461     RefPtr<CSSPrimitiveValue> left;
462
463     if (image.imageSlices().top().isPercent())
464         top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
465     else
466         top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
467
468     if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
469         && image.imageSlices().left() == image.imageSlices().top()) {
470         right = top;
471         bottom = top;
472         left = top;
473     } else {
474         if (image.imageSlices().right().isPercent())
475             right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
476         else
477             right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
478
479         if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
480             bottom = top;
481             left = right;
482         } else {
483             if (image.imageSlices().bottom().isPercent())
484                 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
485             else
486                 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
487
488             if (image.imageSlices().left() == image.imageSlices().right())
489                 left = right;
490             else {
491                 if (image.imageSlices().left().isPercent())
492                     left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
493                 else
494                     left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
495             }
496         }
497     }
498
499     RefPtr<Quad> quad = Quad::create();
500     quad->setTop(top);
501     quad->setRight(right);
502     quad->setBottom(bottom);
503     quad->setLeft(left);
504
505     return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
506 }
507
508 static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
509 {
510     // Create the slices.
511     RefPtr<CSSPrimitiveValue> top;
512     RefPtr<CSSPrimitiveValue> right;
513     RefPtr<CSSPrimitiveValue> bottom;
514     RefPtr<CSSPrimitiveValue> left;
515
516     if (box.top().isRelative())
517         top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
518     else
519         top = cssValuePool().createValue(box.top());
520
521     if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
522         right = top;
523         bottom = top;
524         left = top;
525     } else {
526         if (box.right().isRelative())
527             right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
528         else
529             right = cssValuePool().createValue(box.right());
530
531         if (box.bottom() == box.top() && box.right() == box.left()) {
532             bottom = top;
533             left = right;
534         } else {
535             if (box.bottom().isRelative())
536                 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
537             else
538                 bottom = cssValuePool().createValue(box.bottom());
539
540             if (box.left() == box.right())
541                 left = right;
542             else {
543                 if (box.left().isRelative())
544                     left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
545                 else
546                     left = cssValuePool().createValue(box.left());
547             }
548         }
549     }
550
551     RefPtr<Quad> quad = Quad::create();
552     quad->setTop(top);
553     quad->setRight(right);
554     quad->setBottom(bottom);
555     quad->setLeft(left);
556
557     return cssValuePool().createValue(quad.release());
558 }
559
560 static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
561 {
562     RefPtr<CSSPrimitiveValue> horizontalRepeat;
563     RefPtr<CSSPrimitiveValue> verticalRepeat;
564
565     horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
566     if (image.horizontalRule() == image.verticalRule())
567         verticalRepeat = horizontalRepeat;
568     else
569         verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
570     return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
571 }
572
573 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
574 {
575     if (!image.hasImage())
576         return cssValuePool().createIdentifierValue(CSSValueNone);
577
578     // Image first.
579     RefPtr<CSSValue> imageValue;
580     if (image.image())
581         imageValue = image.image()->cssValue();
582
583     // Create the image slice.
584     RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
585
586     // Create the border area slices.
587     RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
588
589     // Create the border outset.
590     RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
591
592     // Create the repeat rules.
593     RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
594
595     return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
596 }
597
598 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
599 {
600     return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
601 }
602
603 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
604 {
605     return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
606 }
607
608 static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
609 {
610     if (length.isFixed())
611         return zoomAdjustedPixelValue(length.value(), style);
612     return cssValuePool().createValue(length);
613 }
614
615 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
616 {
617     if (!reflection)
618         return cssValuePool().createIdentifierValue(CSSValueNone);
619
620     RefPtr<CSSPrimitiveValue> offset;
621     if (reflection->offset().isPercent())
622         offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
623     else
624         offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
625
626     RefPtr<CSSPrimitiveValue> direction;
627     switch (reflection->direction()) {
628     case ReflectionBelow:
629         direction = cssValuePool().createIdentifierValue(CSSValueBelow);
630         break;
631     case ReflectionAbove:
632         direction = cssValuePool().createIdentifierValue(CSSValueAbove);
633         break;
634     case ReflectionLeft:
635         direction = cssValuePool().createIdentifierValue(CSSValueLeft);
636         break;
637     case ReflectionRight:
638         direction = cssValuePool().createIdentifierValue(CSSValueRight);
639         break;
640     }
641
642     return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
643 }
644
645 static PassRefPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
646 {
647     RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
648     if (layer->isBackgroundOriginSet()) {
649         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
650         positionList->append(cssValuePool().createValue(layer->backgroundXOrigin()));
651     }
652     positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
653     if (layer->isBackgroundOriginSet()) {
654         ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
655         positionList->append(cssValuePool().createValue(layer->backgroundYOrigin()));
656     }
657     positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
658     return positionList.release();
659 }
660
661 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
662 {
663     if (!style)
664         return 0;
665
666     Length l;
667     switch (propertyID) {
668         case CSSPropertyLeft:
669             l = style->left();
670             break;
671         case CSSPropertyRight:
672             l = style->right();
673             break;
674         case CSSPropertyTop:
675             l = style->top();
676             break;
677         case CSSPropertyBottom:
678             l = style->bottom();
679             break;
680         default:
681             return 0;
682     }
683
684     if (style->hasOutOfFlowPosition()) {
685         if (l.type() == WebCore::Fixed)
686             return zoomAdjustedPixelValue(l.value(), style);
687         else if (l.isViewportPercentage())
688             return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
689         return cssValuePool().createValue(l);
690     }
691
692     if (style->hasInFlowPosition()) {
693         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
694         // In other words if left is auto and right is not auto, then left's computed value is negative right().
695         // So we should get the opposite length unit and see if it is auto.
696         return cssValuePool().createValue(l);
697     }
698
699     return cssValuePool().createIdentifierValue(CSSValueAuto);
700 }
701
702 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::currentColorOrValidColor(RenderStyle* style, const Color& color) const
703 {
704     // This function does NOT look at visited information, so that computed style doesn't expose that.
705     if (!color.isValid())
706         return cssValuePool().createColorValue(style->color().rgb());
707     return cssValuePool().createColorValue(color.rgb());
708 }
709
710 static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
711 {
712     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
713     if (radius.width().type() == Percent)
714         list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
715     else
716         list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
717     if (radius.height().type() == Percent)
718         list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
719     else
720         list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
721     return list.release();
722 }
723
724 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
725 {
726     if (radius.width() == radius.height()) {
727         if (radius.width().type() == Percent)
728             return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
729         return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
730     }
731     return getBorderRadiusCornerValues(radius, style, renderView);
732 }
733
734 static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
735 {
736     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
737     bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
738     bool showHorizontalBottomRight = style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width();
739     bool showHorizontalTopRight = style->borderTopRightRadius().width() != style->borderTopLeftRadius().width();
740
741     bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
742     bool showVerticalBottomRight = (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomLeft;
743     bool showVerticalTopRight = (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomRight;
744     bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
745
746     RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
747     RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
748     RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
749     RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
750
751     RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
752     horizontalRadii->append(topLeftRadius->item(0));
753     if (showHorizontalTopRight)
754         horizontalRadii->append(topRightRadius->item(0));
755     if (showHorizontalBottomRight)
756         horizontalRadii->append(bottomRightRadius->item(0));
757     if (showHorizontalBottomLeft)
758         horizontalRadii->append(bottomLeftRadius->item(0));
759
760     list->append(horizontalRadii.release());
761
762     if (showVerticalTopLeft) {
763         RefPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
764         verticalRadii->append(topLeftRadius->item(1));
765         if (showVerticalTopRight)
766             verticalRadii->append(topRightRadius->item(1));
767         if (showVerticalBottomRight)
768             verticalRadii->append(bottomRightRadius->item(1));
769         if (showVerticalBottomLeft)
770             verticalRadii->append(bottomLeftRadius->item(1));
771         list->append(verticalRadii.release());
772     }
773     return list.release();
774 }
775
776 static LayoutRect sizingBox(RenderObject* renderer)
777 {
778     if (!renderer->isBox())
779         return LayoutRect();
780
781     RenderBox* box = toRenderBox(renderer);
782     return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
783 }
784
785 static PassRefPtr<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
786 {
787     RefPtr<WebKitCSSTransformValue> transformValue;
788     if (transform.isAffine()) {
789         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
790
791         transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
792         transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
793         transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
794         transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
795         transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
796         transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
797     } else {
798         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
799
800         transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
801         transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
802         transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
803         transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
804
805         transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
806         transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
807         transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
808         transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
809
810         transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
811         transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
812         transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
813         transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
814
815         transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
816         transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
817         transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
818         transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
819     }
820
821     return transformValue.release();
822 }
823
824 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
825 {
826     if (!renderer || !renderer->hasTransform() || !style->hasTransform())
827         return cssValuePool().createIdentifierValue(CSSValueNone);
828
829     IntRect box;
830     if (renderer->isBox())
831         box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
832
833     TransformationMatrix transform;
834     style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
835     // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
836
837     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
838     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
839     list->append(matrixTransformValue(transform, style));
840
841     return list.release();
842 }
843
844 #if ENABLE(CSS_SHADERS)
845 static PassRefPtr<CSSValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
846 {
847     RefPtr<WebKitCSSArrayFunctionValue> arrayParameterValue = WebKitCSSArrayFunctionValue::create();
848     for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
849         arrayParameterValue->append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
850     return arrayParameterValue.release();
851 }
852
853 static PassRefPtr<CSSValue> valueForCustomFilterMatParameter(const CustomFilterArrayParameter* matrixParameter)
854 {
855     RefPtr<WebKitCSSMatFunctionValue> matrixParameterValue = WebKitCSSMatFunctionValue::create();
856     for (unsigned i = 0, size = matrixParameter->size(); i < size; ++i)
857         matrixParameterValue->append(cssValuePool().createValue(matrixParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
858     return matrixParameterValue.release();
859 }
860
861 static PassRefPtr<CSSValue> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
862 {
863     RefPtr<CSSValueList> colorParameterValue = CSSValueList::createSpaceSeparated();
864     colorParameterValue->append(cssValuePool().createColorValue(colorParameter->color().rgb()));
865     return colorParameterValue.release();
866 }
867
868 static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
869 {
870     RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
871     for (unsigned i = 0; i < numberParameter->size(); ++i)
872         numberParameterValue->append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
873     return numberParameterValue.release();
874 }
875
876 static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
877 {
878     IntSize size;
879     if (renderer && renderer->isBox())
880         size = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size();
881
882     TransformationMatrix transform;
883     transformParameter->applyTransform(transform, size);
884     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
885     return matrixTransformValue(transform, style);
886 }
887
888 static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
889 {
890     // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
891     ASSERT(parameter);
892     switch (parameter->parameterType()) {
893     case CustomFilterParameter::ARRAY:
894         return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
895     case CustomFilterParameter::COLOR:
896         return valueForCustomFilterColorParameter(static_cast<const CustomFilterColorParameter*>(parameter));
897     case CustomFilterParameter::MATRIX:
898         return valueForCustomFilterMatParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
899     case CustomFilterParameter::NUMBER:
900         return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
901     case CustomFilterParameter::TRANSFORM:
902         return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
903     }
904     
905     ASSERT_NOT_REACHED();
906     return 0;
907 }
908 #endif // ENABLE(CSS_SHADERS)
909
910 static inline PassRefPtr<CSSPrimitiveValue> adjustLengthForZoom(double length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
911 {
912     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length, style) : cssValuePool().createValue(length, CSSPrimitiveValue::CSS_PX);
913 }
914
915 static inline PassRefPtr<CSSPrimitiveValue> adjustLengthForZoom(const Length& length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
916 {
917     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length.value(), style) : cssValuePool().createValue(length);
918 }
919
920 PassRefPtr<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
921 {
922     if (!shadow)
923         return cssValuePool().createIdentifierValue(CSSValueNone);
924
925     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
926     for (const ShadowData* currShadowData = shadow; currShadowData; currShadowData = currShadowData->next()) {
927         RefPtr<CSSPrimitiveValue> x = adjustLengthForZoom(currShadowData->x(), style, adjust);
928         RefPtr<CSSPrimitiveValue> y = adjustLengthForZoom(currShadowData->y(), style, adjust);
929         RefPtr<CSSPrimitiveValue> blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
930         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
931         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
932         RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(currShadowData->color().rgb());
933         list->prepend(CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
934     }
935     return list.release();
936 }
937
938 #if ENABLE(CSS_FILTERS)
939 PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
940 {
941 #if !ENABLE(CSS_SHADERS)
942     UNUSED_PARAM(renderer);
943 #endif
944     if (filterOperations.operations().isEmpty())
945         return cssValuePool().createIdentifierValue(CSSValueNone);
946
947     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
948
949     RefPtr<WebKitCSSFilterValue> filterValue;
950
951     Vector<RefPtr<FilterOperation> >::const_iterator end = filterOperations.operations().end();
952     for (Vector<RefPtr<FilterOperation> >::const_iterator it = filterOperations.operations().begin(); it != end; ++it) {
953         FilterOperation* filterOperation = (*it).get();
954         switch (filterOperation->getOperationType()) {
955         case FilterOperation::REFERENCE: {
956             ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
957             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
958             filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
959             break;
960         }
961         case FilterOperation::GRAYSCALE: {
962             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
963             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
964             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
965             break;
966         }
967         case FilterOperation::SEPIA: {
968             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
969             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
970             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
971             break;
972         }
973         case FilterOperation::SATURATE: {
974             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
975             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
976             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
977             break;
978         }
979         case FilterOperation::HUE_ROTATE: {
980             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
981             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
982             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
983             break;
984         }
985         case FilterOperation::INVERT: {
986             BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
987             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
988             filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
989             break;
990         }
991         case FilterOperation::OPACITY: {
992             BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
993             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
994             filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
995             break;
996         }
997         case FilterOperation::BRIGHTNESS: {
998             BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
999             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
1000             filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1001             break;
1002         }
1003         case FilterOperation::CONTRAST: {
1004             BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
1005             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
1006             filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1007             break;
1008         }
1009         case FilterOperation::BLUR: {
1010             BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
1011             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
1012             filterValue->append(adjustLengthForZoom(blurOperation->stdDeviation(), style, adjust));
1013             break;
1014         }
1015         case FilterOperation::DROP_SHADOW: {
1016             DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
1017             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
1018             // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
1019             ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
1020             filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style, adjust));
1021             break;
1022         }
1023 #if ENABLE(CSS_SHADERS)
1024         case FilterOperation::VALIDATED_CUSTOM:
1025             // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
1026             ASSERT_NOT_REACHED();
1027             break;
1028         case FilterOperation::CUSTOM: {
1029             CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
1030             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
1031             
1032             // The output should be verbose, even if the values are the default ones.
1033             
1034             ASSERT(customOperation->program());
1035             StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
1036             
1037             RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
1038             if (program->vertexShader())
1039                 shadersList->append(program->vertexShader()->cssValue());
1040             else
1041                 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1042
1043             const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
1044             if (program->fragmentShader()) {
1045                 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
1046                     RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
1047                     mixFunction->append(program->fragmentShader()->cssValue());
1048                     mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
1049                     mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
1050                     shadersList->append(mixFunction.release());
1051                 } else
1052                     shadersList->append(program->fragmentShader()->cssValue());
1053             }
1054             else
1055                 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1056
1057             filterValue->append(shadersList.release());
1058             
1059             RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
1060             meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
1061             meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
1062             
1063             // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
1064             // https://bugs.webkit.org/show_bug.cgi?id=72700
1065             if (customOperation->meshType() == MeshTypeDetached)
1066                 meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
1067             
1068             filterValue->append(meshParameters.release());
1069             
1070             const CustomFilterParameterList& parameters = customOperation->parameters();
1071             size_t parametersSize = parameters.size();
1072             if (!parametersSize)
1073                 break;
1074             RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
1075             for (size_t i = 0; i < parametersSize; ++i) {
1076                 const CustomFilterParameter* parameter = parameters.at(i).get();
1077                 RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
1078                 parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
1079                 parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
1080                 parametersCSSValue->append(parameterCSSNameAndValue.release());
1081             }
1082             
1083             filterValue->append(parametersCSSValue.release());
1084             break;
1085         }
1086 #endif
1087         default:
1088             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
1089             break;
1090         }
1091         list->append(filterValue.release());
1092     }
1093
1094     return list.release();
1095 }
1096 #endif
1097
1098 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackBreadth, const RenderStyle* style, RenderView *renderView)
1099 {
1100     if (trackBreadth.isAuto())
1101         return cssValuePool().createIdentifierValue(CSSValueAuto);
1102     if (trackBreadth.isViewportPercentage())
1103         return zoomAdjustedPixelValue(valueForLength(trackBreadth, 0, renderView), style);
1104     return zoomAdjustedPixelValueForLength(trackBreadth, style);
1105 }
1106
1107 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
1108 {
1109     switch (trackSize.type()) {
1110     case LengthTrackSizing:
1111         return valueForGridTrackBreadth(trackSize.length(), style, renderView);
1112     case MinMaxTrackSizing:
1113         RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1114         minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
1115         minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
1116         return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1117     }
1118     ASSERT_NOT_REACHED();
1119     return 0;
1120 }
1121
1122 static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGridLines, size_t i, CSSValueList& list)
1123 {
1124     // Note that this won't return the results in the order specified in the style sheet,
1125     // which is probably fine as we still *do* return all the expected values.
1126     NamedGridLinesMap::const_iterator it = namedGridLines.begin();
1127     NamedGridLinesMap::const_iterator end = namedGridLines.end();
1128     for (; it != end; ++it) {
1129         const Vector<size_t>& linesIndexes = it->value;
1130         for (size_t j = 0; j < linesIndexes.size(); ++j) {
1131             if (linesIndexes[j] != i)
1132                 continue;
1133
1134             list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1135             break;
1136         }
1137     }
1138 }
1139
1140 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, RenderView* renderView)
1141 {
1142     // Handle the 'none' case here.
1143     if (!trackSizes.size()) {
1144         ASSERT(namedGridLines.isEmpty());
1145         return cssValuePool().createIdentifierValue(CSSValueNone);
1146     }
1147
1148     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1149     for (size_t i = 0; i < trackSizes.size(); ++i) {
1150         addValuesForNamedGridLinesAtIndex(namedGridLines, i, *list);
1151         list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
1152     }
1153     // Those are the trailing <string>* allowed in the syntax.
1154     addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), *list);
1155     return list.release();
1156 }
1157
1158 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1159 {
1160     if (position.isAuto())
1161         return cssValuePool().createIdentifierValue(CSSValueAuto);
1162
1163     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1164     if (position.isSpan()) {
1165         list->append(cssValuePool().createIdentifierValue(CSSValueSpan));
1166         list->append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
1167     } else
1168         list->append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
1169
1170     if (!position.namedGridLine().isNull())
1171         list->append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
1172     return list.release();
1173 }
1174
1175 static PassRefPtr<CSSValue> createTransitionPropertyValue(const Animation& animation)
1176 {
1177     RefPtr<CSSValue> propertyValue;
1178     if (animation.animationMode() == Animation::AnimateNone)
1179         propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
1180     else if (animation.animationMode() == Animation::AnimateAll)
1181         propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
1182     else
1183         propertyValue = cssValuePool().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING);
1184     return propertyValue.release();
1185 }
1186
1187 static PassRefPtr<CSSValue> getTransitionPropertyValue(const AnimationList* animList)
1188 {
1189     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1190     if (animList) {
1191         for (size_t i = 0; i < animList->size(); ++i)
1192             list->append(createTransitionPropertyValue(animList->animation(i)));
1193     } else
1194         list->append(cssValuePool().createIdentifierValue(CSSValueAll));
1195     return list.release();
1196 }
1197
1198 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
1199 {
1200     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1201     if (animList) {
1202         for (size_t i = 0; i < animList->size(); ++i)
1203             list->append(cssValuePool().createValue(animList->animation(i).delay(), CSSPrimitiveValue::CSS_S));
1204     } else {
1205         // Note that initialAnimationDelay() is used for both transitions and animations
1206         list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1207     }
1208     return list.release();
1209 }
1210
1211 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
1212 {
1213     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1214     if (animList) {
1215         for (size_t i = 0; i < animList->size(); ++i)
1216             list->append(cssValuePool().createValue(animList->animation(i).duration(), CSSPrimitiveValue::CSS_S));
1217     } else {
1218         // Note that initialAnimationDuration() is used for both transitions and animations
1219         list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1220     }
1221     return list.release();
1222 }
1223
1224 static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1225 {
1226     switch (timingFunction->type()) {
1227     case TimingFunction::CubicBezierFunction: {
1228         const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1229         if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1230             CSSValueID valueId = CSSValueInvalid;
1231             switch (bezierTimingFunction->timingFunctionPreset()) {
1232             case CubicBezierTimingFunction::Ease:
1233                 valueId = CSSValueEase;
1234                 break;
1235             case CubicBezierTimingFunction::EaseIn:
1236                 valueId = CSSValueEaseIn;
1237                 break;
1238             case CubicBezierTimingFunction::EaseOut:
1239                 valueId = CSSValueEaseOut;
1240                 break;
1241             case CubicBezierTimingFunction::EaseInOut:
1242                 valueId = CSSValueEaseInOut;
1243                 break;
1244             default:
1245                 ASSERT_NOT_REACHED();
1246                 return 0;
1247             }
1248             return cssValuePool().createIdentifierValue(valueId);
1249         }
1250         return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1251     }
1252     case TimingFunction::StepsFunction: {
1253         const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1254         return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1255     }
1256     case TimingFunction::LinearFunction:
1257         return cssValuePool().createIdentifierValue(CSSValueLinear);
1258     }
1259     ASSERT_NOT_REACHED();
1260     return 0;
1261 }
1262
1263 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
1264 {
1265     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1266     if (animList) {
1267         for (size_t i = 0; i < animList->size(); ++i)
1268             list->append(createTimingFunctionValue(animList->animation(i).timingFunction().get()));
1269     } else
1270         // Note that initialAnimationTimingFunction() is used for both transitions and animations
1271         list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1272     return list.release();
1273 }
1274
1275 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1276 {
1277     if (!lineBoxContain)
1278         return cssValuePool().createIdentifierValue(CSSValueNone);
1279     return CSSLineBoxContainValue::create(lineBoxContain);
1280 }
1281
1282 ComputedStyleExtractor::ComputedStyleExtractor(PassRefPtr<Node> node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
1283     : m_node(node)
1284     , m_pseudoElementSpecifier(pseudoElementSpecifier)
1285     , m_allowVisitedStyle(allowVisitedStyle)
1286 {
1287 }
1288
1289
1290 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1291     : m_node(n)
1292     , m_allowVisitedStyle(allowVisitedStyle)
1293     , m_refCount(1)
1294 {
1295     unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1296     m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1297         AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1298 }
1299
1300 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1301 {
1302 }
1303
1304 void CSSComputedStyleDeclaration::ref()
1305 {
1306     ++m_refCount;
1307 }
1308
1309 void CSSComputedStyleDeclaration::deref()
1310 {
1311     ASSERT(m_refCount);
1312     if (!--m_refCount)
1313         delete this;
1314 }
1315
1316 String CSSComputedStyleDeclaration::cssText() const
1317 {
1318     StringBuilder result;
1319
1320     for (unsigned i = 0; i < numComputedProperties; i++) {
1321         if (i)
1322             result.append(' ');
1323         result.append(getPropertyName(computedProperties[i]));
1324         result.append(": ", 2);
1325         result.append(getPropertyValue(computedProperties[i]));
1326         result.append(';');
1327     }
1328
1329     return result.toString();
1330 }
1331
1332 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1333 {
1334     ec = NO_MODIFICATION_ALLOWED_ERR;
1335 }
1336
1337 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
1338 {
1339     ASSERT_ARG(keywordSize, keywordSize);
1340     ASSERT_ARG(keywordSize, keywordSize <= 8);
1341     return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
1342 }
1343
1344 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
1345 {
1346     if (!m_node)
1347         return 0;
1348
1349     m_node->document().updateLayoutIgnorePendingStylesheets();
1350
1351     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1352     if (!style)
1353         return 0;
1354
1355     if (int keywordSize = style->fontDescription().keywordSize())
1356         return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1357
1358     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1359 }
1360
1361 bool ComputedStyleExtractor::useFixedFontDefaultSize() const
1362 {
1363     if (!m_node)
1364         return false;
1365
1366     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1367     if (!style)
1368         return false;
1369
1370     return style->fontDescription().useFixedDefaultSize();
1371 }
1372
1373
1374 static CSSValueID identifierForFamily(const AtomicString& family)
1375 {
1376     if (family == cursiveFamily)
1377         return CSSValueCursive;
1378     if (family == fantasyFamily)
1379         return CSSValueFantasy;
1380     if (family == monospaceFamily)
1381         return CSSValueMonospace;
1382     if (family == pictographFamily)
1383         return CSSValueWebkitPictograph;
1384     if (family == sansSerifFamily)
1385         return CSSValueSansSerif;
1386     if (family == serifFamily)
1387         return CSSValueSerif;
1388     return CSSValueInvalid;
1389 }
1390
1391 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1392 {
1393     if (CSSValueID familyIdentifier = identifierForFamily(family))
1394         return cssValuePool().createIdentifierValue(familyIdentifier);
1395     return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1396 }
1397
1398 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1399 {
1400     // Blink value is ignored.
1401     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1402     if (textDecoration & TextDecorationUnderline)
1403         list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1404     if (textDecoration & TextDecorationOverline)
1405         list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1406     if (textDecoration & TextDecorationLineThrough)
1407         list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1408
1409     if (!list->length())
1410         return cssValuePool().createIdentifierValue(CSSValueNone);
1411     return list.release();
1412 }
1413
1414 #if ENABLE(CSS3_TEXT)
1415 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1416 {
1417     switch (textDecorationStyle) {
1418     case TextDecorationStyleSolid:
1419         return cssValuePool().createIdentifierValue(CSSValueSolid);
1420     case TextDecorationStyleDouble:
1421         return cssValuePool().createIdentifierValue(CSSValueDouble);
1422     case TextDecorationStyleDotted:
1423         return cssValuePool().createIdentifierValue(CSSValueDotted);
1424     case TextDecorationStyleDashed:
1425         return cssValuePool().createIdentifierValue(CSSValueDashed);
1426     case TextDecorationStyleWavy:
1427         return cssValuePool().createIdentifierValue(CSSValueWavy);
1428     }
1429
1430     ASSERT_NOT_REACHED();
1431     return cssValuePool().createExplicitInitialValue();
1432 }
1433 #endif // CSS3_TEXT
1434
1435 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1436 {
1437     // For backwards compatibility, if both values are equal, just return one of them. And
1438     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1439     if (xRepeat == yRepeat)
1440         return cssValuePool().createValue(xRepeat);
1441     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1442         return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1443     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1444         return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1445
1446     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1447     list->append(cssValuePool().createValue(xRepeat));
1448     list->append(cssValuePool().createValue(yRepeat));
1449     return list.release();
1450 }
1451
1452 static PassRefPtr<CSSValue> fillSourceTypeToCSSValue(EMaskSourceType type)
1453 {
1454     switch (type) {
1455     case MaskAlpha:
1456         return cssValuePool().createValue(CSSValueAlpha);
1457     case MaskLuminance:
1458         return cssValuePool().createValue(CSSValueLuminance);
1459     }
1460
1461     ASSERT_NOT_REACHED();
1462
1463     return 0;
1464 }
1465 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1466 {
1467     if (fillSize.type == Contain)
1468         return cssValuePool().createIdentifierValue(CSSValueContain);
1469
1470     if (fillSize.type == Cover)
1471         return cssValuePool().createIdentifierValue(CSSValueCover);
1472
1473     if (fillSize.size.height().isAuto())
1474         return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1475
1476     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1477     list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1478     list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1479     return list.release();
1480 }
1481
1482 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1483 {
1484     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1485     for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1486         if (contentData->isCounter()) {
1487             const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1488             ASSERT(counter);
1489             list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1490         } else if (contentData->isImage()) {
1491             const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1492             ASSERT(image);
1493             list->append(image->cssValue());
1494         } else if (contentData->isText())
1495             list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1496     }
1497     if (!style->regionThread().isNull())
1498         list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1499     return list.release();
1500 }
1501
1502 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1503 {
1504     const CounterDirectiveMap* map = style->counterDirectives();
1505     if (!map)
1506         return 0;
1507
1508     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1509     for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1510         list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1511         short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1512         list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1513     }
1514     return list.release();
1515 }
1516
1517 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1518 {
1519     DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1520     if (!propertyIDSet.add(propertyID).isNewEntry)
1521         return;
1522
1523     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1524 }
1525
1526 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1527     {
1528     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1529     for (unsigned i = 0; i < style->font().familyCount(); ++i)
1530         list->append(valueForFamily(style->font().familyAt(i)));
1531     return list.release();
1532 }
1533
1534 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1535 {
1536     Length length = style->lineHeight();
1537     if (length.isNegative())
1538         return cssValuePool().createIdentifierValue(CSSValueNormal);
1539     if (length.isPercent())
1540         // This is imperfect, because it doesn't include the zoom factor and the real computation
1541         // for how high to be in pixels does include things like minimum font size and the zoom factor.
1542         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1543         // that here either.
1544         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1545     return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style);
1546 }
1547
1548 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1549 {
1550     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1551 }
1552
1553 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1554 {
1555     if (style->fontDescription().italic())
1556         return cssValuePool().createIdentifierValue(CSSValueItalic);
1557     return cssValuePool().createIdentifierValue(CSSValueNormal);
1558 }
1559
1560 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1561 {
1562     if (style->fontDescription().smallCaps())
1563         return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1564     return cssValuePool().createIdentifierValue(CSSValueNormal);
1565 }
1566
1567 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1568 {
1569     switch (style->fontDescription().weight()) {
1570     case FontWeight100:
1571         return cssValuePool().createIdentifierValue(CSSValue100);
1572     case FontWeight200:
1573         return cssValuePool().createIdentifierValue(CSSValue200);
1574     case FontWeight300:
1575         return cssValuePool().createIdentifierValue(CSSValue300);
1576     case FontWeightNormal:
1577         return cssValuePool().createIdentifierValue(CSSValueNormal);
1578     case FontWeight500:
1579         return cssValuePool().createIdentifierValue(CSSValue500);
1580     case FontWeight600:
1581         return cssValuePool().createIdentifierValue(CSSValue600);
1582     case FontWeightBold:
1583         return cssValuePool().createIdentifierValue(CSSValueBold);
1584     case FontWeight800:
1585         return cssValuePool().createIdentifierValue(CSSValue800);
1586     case FontWeight900:
1587         return cssValuePool().createIdentifierValue(CSSValue900);
1588     }
1589     ASSERT_NOT_REACHED();
1590     return cssValuePool().createIdentifierValue(CSSValueNormal);
1591 }
1592
1593 typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
1594 typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
1595
1596 template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
1597 inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
1598 {
1599     Length unzoomzedLength = (style->*lengthGetter)();
1600     if (!renderer || !renderer->isBox() || unzoomzedLength.isFixed())
1601         return zoomAdjustedPixelValueForLength(unzoomzedLength, style);
1602     return zoomAdjustedPixelValue((toRenderBox(renderer)->*computedCSSValueGetter)(), style);
1603 }
1604
1605 template<RenderStyleLengthGetter lengthGetter>
1606 inline bool paddingOrMarginIsRendererDependent(RenderStyle* style, RenderObject* renderer)
1607 {
1608     if (!renderer || !renderer->isBox())
1609         return false;
1610     return !(style && (style->*lengthGetter)().isFixed());
1611 }
1612
1613 static bool isLayoutDependent(CSSPropertyID propertyID, RenderStyle* style, RenderObject* renderer)
1614 {
1615     switch (propertyID) {
1616     case CSSPropertyWidth:
1617     case CSSPropertyHeight:
1618     case CSSPropertyWebkitPerspectiveOrigin:
1619     case CSSPropertyWebkitTransformOrigin:
1620     case CSSPropertyWebkitTransform:
1621 #if ENABLE(CSS_FILTERS)
1622     case CSSPropertyWebkitFilter:
1623 #endif
1624         return true;
1625     case CSSPropertyMargin: {
1626         if (!renderer || !renderer->isBox())
1627             return false;
1628         return !(style && style->marginTop().isFixed() && style->marginRight().isFixed()
1629             && style->marginBottom().isFixed() && style->marginLeft().isFixed());
1630     }
1631     case CSSPropertyMarginTop:
1632         return paddingOrMarginIsRendererDependent<&RenderStyle::marginTop>(style, renderer);
1633     case CSSPropertyMarginRight:
1634         return paddingOrMarginIsRendererDependent<&RenderStyle::marginRight>(style, renderer);
1635     case CSSPropertyMarginBottom:
1636         return paddingOrMarginIsRendererDependent<&RenderStyle::marginBottom>(style, renderer);
1637     case CSSPropertyMarginLeft:
1638         return paddingOrMarginIsRendererDependent<&RenderStyle::marginLeft>(style, renderer);
1639     case CSSPropertyPadding: {
1640         if (!renderer || !renderer->isBox())
1641             return false;
1642         return !(style && style->paddingTop().isFixed() && style->paddingRight().isFixed()
1643             && style->paddingBottom().isFixed() && style->paddingLeft().isFixed());
1644     }
1645     case CSSPropertyPaddingTop:
1646         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingTop>(style, renderer);
1647     case CSSPropertyPaddingRight:
1648         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingRight>(style, renderer);
1649     case CSSPropertyPaddingBottom:
1650         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingBottom>(style, renderer);
1651     case CSSPropertyPaddingLeft:
1652         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingLeft>(style, renderer); 
1653     default:
1654         return false;
1655     }
1656 }
1657
1658 Node* ComputedStyleExtractor::styledNode() const
1659 {
1660     if (!m_node)
1661         return 0;
1662     if (!m_node->isElementNode())
1663         return m_node.get();
1664     Element* element = toElement(m_node.get());
1665     PseudoElement* pseudoElement;
1666     if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element->beforePseudoElement()))
1667         return pseudoElement;
1668     if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element->afterPseudoElement()))
1669         return pseudoElement;
1670     return element;
1671 }
1672
1673 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1674 {
1675     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
1676 }
1677
1678 PassRefPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() const
1679 {
1680     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
1681 }
1682
1683 static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
1684 {
1685     if (styledNode->document().hasPendingForcedStyleRecalc())
1686         return true;
1687     for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: Call parentOrShadowHostNode() instead
1688         if (n->needsStyleRecalc())
1689             return true;
1690     }
1691     return false;
1692 }
1693
1694 static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
1695 {
1696     RenderObject* renderer = styledNode->renderer();
1697
1698     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1699         AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
1700         RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(toRenderElement(renderer));
1701         if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1702             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1703             return style->getCachedPseudoStyle(pseudoElementSpecifier);
1704         }
1705         return style.release();
1706     }
1707
1708     return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
1709 }
1710
1711 PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1712 {
1713     Node* styledNode = this->styledNode();
1714     if (!styledNode)
1715         return 0;
1716
1717     RefPtr<RenderStyle> style;
1718     RenderObject* renderer = 0;
1719     bool forceFullLayout = false;
1720     if (updateLayout) {
1721         Document& document = styledNode->document();
1722
1723         if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
1724             document.updateStyleIfNeeded();
1725             // The style recalc could have caused the styled node to be discarded or replaced
1726             // if it was a PseudoElement so we need to update it.
1727             styledNode = this->styledNode();
1728         }
1729
1730         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1731         renderer = styledNode->renderer();
1732
1733         // FIXME: Some of these cases could be narrowed down or optimized better.
1734         forceFullLayout = isLayoutDependent(propertyID, style.get(), renderer)
1735             || styledNode->isInShadowTree()
1736             || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement())
1737             || document.seamlessParentIFrame();
1738
1739         if (forceFullLayout) {
1740             document.updateLayoutIgnorePendingStylesheets();
1741             styledNode = this->styledNode();
1742         }
1743     }
1744
1745     if (!updateLayout || forceFullLayout) {
1746         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1747         renderer = styledNode->renderer();
1748     }
1749
1750     if (!style)
1751         return 0;
1752
1753     propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1754
1755     switch (propertyID) {
1756         case CSSPropertyInvalid:
1757 #if ENABLE(CSS_VARIABLES)
1758         case CSSPropertyVariable:
1759 #endif
1760             break;
1761
1762         case CSSPropertyBackgroundColor:
1763             return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1764         case CSSPropertyBackgroundImage:
1765         case CSSPropertyWebkitMaskImage: {
1766             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1767             if (!layers)
1768                 return cssValuePool().createIdentifierValue(CSSValueNone);
1769
1770             if (!layers->next()) {
1771                 if (layers->image())
1772                     return layers->image()->cssValue();
1773
1774                 return cssValuePool().createIdentifierValue(CSSValueNone);
1775             }
1776
1777             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1778             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1779                 if (currLayer->image())
1780                     list->append(currLayer->image()->cssValue());
1781                 else
1782                     list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1783             }
1784             return list.release();
1785         }
1786         case CSSPropertyBackgroundSize:
1787         case CSSPropertyWebkitBackgroundSize:
1788         case CSSPropertyWebkitMaskSize: {
1789             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1790             if (!layers->next())
1791                 return fillSizeToCSSValue(layers->size(), style.get());
1792
1793             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1794             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1795                 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1796
1797             return list.release();
1798         }
1799         case CSSPropertyBackgroundRepeat:
1800         case CSSPropertyWebkitMaskRepeat: {
1801             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1802             if (!layers->next())
1803                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1804
1805             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1806             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1807                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1808
1809             return list.release();
1810         }
1811         case CSSPropertyWebkitMaskSourceType: {
1812             const FillLayer* layers = style->maskLayers();
1813
1814             if (!layers)
1815                 return cssValuePool().createIdentifierValue(CSSValueNone);
1816
1817             if (!layers->next())
1818                 return fillSourceTypeToCSSValue(layers->maskSourceType());
1819
1820             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1821             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1822                 list->append(fillSourceTypeToCSSValue(currLayer->maskSourceType()));
1823
1824             return list.release();
1825         }
1826         case CSSPropertyWebkitBackgroundComposite:
1827         case CSSPropertyWebkitMaskComposite: {
1828             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1829             if (!layers->next())
1830                 return cssValuePool().createValue(layers->composite());
1831
1832             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1833             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1834                 list->append(cssValuePool().createValue(currLayer->composite()));
1835
1836             return list.release();
1837         }
1838         case CSSPropertyBackgroundAttachment: {
1839             const FillLayer* layers = style->backgroundLayers();
1840             if (!layers->next())
1841                 return cssValuePool().createValue(layers->attachment());
1842
1843             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1844             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1845                 list->append(cssValuePool().createValue(currLayer->attachment()));
1846
1847             return list.release();
1848         }
1849         case CSSPropertyBackgroundClip:
1850         case CSSPropertyBackgroundOrigin:
1851         case CSSPropertyWebkitBackgroundClip:
1852         case CSSPropertyWebkitBackgroundOrigin:
1853         case CSSPropertyWebkitMaskClip:
1854         case CSSPropertyWebkitMaskOrigin: {
1855             const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1856             bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1857             if (!layers->next()) {
1858                 EFillBox box = isClip ? layers->clip() : layers->origin();
1859                 return cssValuePool().createValue(box);
1860             }
1861
1862             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1863             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1864                 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1865                 list->append(cssValuePool().createValue(box));
1866             }
1867
1868             return list.release();
1869         }
1870         case CSSPropertyBackgroundPosition:
1871         case CSSPropertyWebkitMaskPosition: {
1872             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1873             if (!layers->next())
1874                 return createPositionListForLayer(propertyID, layers, style.get());
1875
1876             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1877             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1878                 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1879             return list.release();
1880         }
1881         case CSSPropertyBackgroundPositionX:
1882         case CSSPropertyWebkitMaskPositionX: {
1883             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1884             if (!layers->next())
1885                 return cssValuePool().createValue(layers->xPosition());
1886
1887             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1888             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1889                 list->append(cssValuePool().createValue(currLayer->xPosition()));
1890
1891             return list.release();
1892         }
1893         case CSSPropertyBackgroundPositionY:
1894         case CSSPropertyWebkitMaskPositionY: {
1895             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1896             if (!layers->next())
1897                 return cssValuePool().createValue(layers->yPosition());
1898
1899             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1900             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1901                 list->append(cssValuePool().createValue(currLayer->yPosition()));
1902
1903             return list.release();
1904         }
1905         case CSSPropertyBorderCollapse:
1906             if (style->borderCollapse())
1907                 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1908             return cssValuePool().createIdentifierValue(CSSValueSeparate);
1909         case CSSPropertyBorderSpacing: {
1910             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1911             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1912             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1913             return list.release();
1914         }
1915         case CSSPropertyWebkitBorderHorizontalSpacing:
1916             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1917         case CSSPropertyWebkitBorderVerticalSpacing:
1918             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1919         case CSSPropertyBorderImageSource:
1920             if (style->borderImageSource())
1921                 return style->borderImageSource()->cssValue();
1922             return cssValuePool().createIdentifierValue(CSSValueNone);
1923         case CSSPropertyBorderTopColor:
1924             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1925         case CSSPropertyBorderRightColor:
1926             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1927         case CSSPropertyBorderBottomColor:
1928             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1929         case CSSPropertyBorderLeftColor:
1930             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1931         case CSSPropertyBorderTopStyle:
1932             return cssValuePool().createValue(style->borderTopStyle());
1933         case CSSPropertyBorderRightStyle:
1934             return cssValuePool().createValue(style->borderRightStyle());
1935         case CSSPropertyBorderBottomStyle:
1936             return cssValuePool().createValue(style->borderBottomStyle());
1937         case CSSPropertyBorderLeftStyle:
1938             return cssValuePool().createValue(style->borderLeftStyle());
1939         case CSSPropertyBorderTopWidth:
1940             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1941         case CSSPropertyBorderRightWidth:
1942             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1943         case CSSPropertyBorderBottomWidth:
1944             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1945         case CSSPropertyBorderLeftWidth:
1946             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1947         case CSSPropertyBottom:
1948             return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document().renderView());
1949         case CSSPropertyWebkitBoxAlign:
1950             return cssValuePool().createValue(style->boxAlign());
1951 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1952         case CSSPropertyWebkitBoxDecorationBreak:
1953             if (style->boxDecorationBreak() == DSLICE)
1954                 return cssValuePool().createIdentifierValue(CSSValueSlice);
1955         return cssValuePool().createIdentifierValue(CSSValueClone);
1956 #endif
1957         case CSSPropertyWebkitBoxDirection:
1958             return cssValuePool().createValue(style->boxDirection());
1959         case CSSPropertyWebkitBoxFlex:
1960             return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1961         case CSSPropertyWebkitBoxFlexGroup:
1962             return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1963         case CSSPropertyWebkitBoxLines:
1964             return cssValuePool().createValue(style->boxLines());
1965         case CSSPropertyWebkitBoxOrdinalGroup:
1966             return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1967         case CSSPropertyWebkitBoxOrient:
1968             return cssValuePool().createValue(style->boxOrient());
1969         case CSSPropertyWebkitBoxPack:
1970             return cssValuePool().createValue(style->boxPack());
1971         case CSSPropertyWebkitBoxReflect:
1972             return valueForReflection(style->boxReflect(), style.get());
1973         case CSSPropertyBoxShadow:
1974         case CSSPropertyWebkitBoxShadow:
1975             return valueForShadow(style->boxShadow(), propertyID, style.get());
1976         case CSSPropertyCaptionSide:
1977             return cssValuePool().createValue(style->captionSide());
1978         case CSSPropertyClear:
1979             return cssValuePool().createValue(style->clear());
1980         case CSSPropertyColor:
1981             return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1982         case CSSPropertyWebkitPrintColorAdjust:
1983             return cssValuePool().createValue(style->printColorAdjust());
1984         case CSSPropertyWebkitColumnAxis:
1985             return cssValuePool().createValue(style->columnAxis());
1986         case CSSPropertyWebkitColumnCount:
1987             if (style->hasAutoColumnCount())
1988                 return cssValuePool().createIdentifierValue(CSSValueAuto);
1989             return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
1990         case CSSPropertyWebkitColumnGap:
1991             if (style->hasNormalColumnGap())
1992                 return cssValuePool().createIdentifierValue(CSSValueNormal);
1993             return zoomAdjustedPixelValue(style->columnGap(), style.get());
1994         case CSSPropertyWebkitColumnProgression:
1995             return cssValuePool().createValue(style->columnProgression());
1996         case CSSPropertyWebkitColumnRuleColor:
1997             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
1998         case CSSPropertyWebkitColumnRuleStyle:
1999             return cssValuePool().createValue(style->columnRuleStyle());
2000         case CSSPropertyWebkitColumnRuleWidth:
2001             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
2002         case CSSPropertyWebkitColumnSpan:
2003             return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
2004         case CSSPropertyWebkitColumnBreakAfter:
2005             return cssValuePool().createValue(style->columnBreakAfter());
2006         case CSSPropertyWebkitColumnBreakBefore:
2007             return cssValuePool().createValue(style->columnBreakBefore());
2008         case CSSPropertyWebkitColumnBreakInside:
2009             return cssValuePool().createValue(style->columnBreakInside());
2010         case CSSPropertyWebkitColumnWidth:
2011             if (style->hasAutoColumnWidth())
2012                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2013             return zoomAdjustedPixelValue(style->columnWidth(), style.get());
2014         case CSSPropertyTabSize:
2015             return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
2016 #if ENABLE(CSS_REGIONS)
2017         case CSSPropertyWebkitRegionBreakAfter:
2018             return cssValuePool().createValue(style->regionBreakAfter());
2019         case CSSPropertyWebkitRegionBreakBefore:
2020             return cssValuePool().createValue(style->regionBreakBefore());
2021         case CSSPropertyWebkitRegionBreakInside:
2022             return cssValuePool().createValue(style->regionBreakInside());
2023 #endif
2024         case CSSPropertyCursor: {
2025             RefPtr<CSSValueList> list;
2026             CursorList* cursors = style->cursors();
2027             if (cursors && cursors->size() > 0) {
2028                 list = CSSValueList::createCommaSeparated();
2029                 for (unsigned i = 0; i < cursors->size(); ++i)
2030                     if (StyleImage* image = cursors->at(i).image())
2031                         list->append(image->cssValue());
2032             }
2033             RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
2034             if (list) {
2035                 list->append(value.release());
2036                 return list.release();
2037             }
2038             return value.release();
2039         }
2040 #if ENABLE(CURSOR_VISIBILITY)
2041         case CSSPropertyWebkitCursorVisibility:
2042             return cssValuePool().createValue(style->cursorVisibility());
2043 #endif
2044         case CSSPropertyDirection:
2045             return cssValuePool().createValue(style->direction());
2046         case CSSPropertyDisplay:
2047             return cssValuePool().createValue(style->display());
2048         case CSSPropertyEmptyCells:
2049             return cssValuePool().createValue(style->emptyCells());
2050         case CSSPropertyWebkitAlignContent:
2051             return cssValuePool().createValue(style->alignContent());
2052         case CSSPropertyWebkitAlignItems:
2053             return cssValuePool().createValue(style->alignItems());
2054         case CSSPropertyWebkitAlignSelf:
2055             if (style->alignSelf() == AlignAuto) {
2056                 Node* parent = styledNode->parentNode();
2057                 if (parent && parent->computedStyle())
2058                     return cssValuePool().createValue(parent->computedStyle()->alignItems());
2059                 return cssValuePool().createValue(AlignStretch);
2060             }
2061             return cssValuePool().createValue(style->alignSelf());
2062         case CSSPropertyWebkitFlex:
2063             return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
2064         case CSSPropertyWebkitFlexBasis:
2065             return cssValuePool().createValue(style->flexBasis());
2066         case CSSPropertyWebkitFlexDirection:
2067             return cssValuePool().createValue(style->flexDirection());
2068         case CSSPropertyWebkitFlexFlow:
2069             return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
2070         case CSSPropertyWebkitFlexGrow:
2071             return cssValuePool().createValue(style->flexGrow());
2072         case CSSPropertyWebkitFlexShrink:
2073             return cssValuePool().createValue(style->flexShrink());
2074         case CSSPropertyWebkitFlexWrap:
2075             return cssValuePool().createValue(style->flexWrap());
2076         case CSSPropertyWebkitJustifyContent:
2077             return cssValuePool().createValue(style->justifyContent());
2078         case CSSPropertyWebkitOrder:
2079             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
2080         case CSSPropertyFloat:
2081             if (style->display() != NONE && style->hasOutOfFlowPosition())
2082                 return cssValuePool().createIdentifierValue(CSSValueNone);
2083             return cssValuePool().createValue(style->floating());
2084         case CSSPropertyFont: {
2085             RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2086             computedFont->style = fontStyleFromStyle(style.get());
2087             computedFont->variant = fontVariantFromStyle(style.get());
2088             computedFont->weight = fontWeightFromStyle(style.get());
2089             computedFont->size = fontSizeFromStyle(style.get());
2090             computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document().renderView());
2091             computedFont->family = fontFamilyFromStyle(style.get());
2092             return computedFont.release();
2093         }
2094         case CSSPropertyFontFamily: {
2095             RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
2096             // If there's only a single family, return that as a CSSPrimitiveValue.
2097             // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
2098             if (fontFamilyList->length() == 1)
2099                 return fontFamilyList->item(0);
2100             return fontFamilyList.release();
2101         }
2102         case CSSPropertyFontSize:
2103             return fontSizeFromStyle(style.get());
2104         case CSSPropertyFontStyle:
2105             return fontStyleFromStyle(style.get());
2106         case CSSPropertyFontVariant:
2107             return fontVariantFromStyle(style.get());
2108         case CSSPropertyFontWeight:
2109             return fontWeightFromStyle(style.get());
2110         case CSSPropertyWebkitFontFeatureSettings: {
2111             const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
2112             if (!featureSettings || !featureSettings->size())
2113                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2114             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2115             for (unsigned i = 0; i < featureSettings->size(); ++i) {
2116                 const FontFeature& feature = featureSettings->at(i);
2117                 RefPtr<CSSFontFeatureValue> featureValue = CSSFontFeatureValue::create(feature.tag(), feature.value());
2118                 list->append(featureValue.release());
2119             }
2120             return list.release();
2121         }
2122         case CSSPropertyWebkitGridAutoColumns:
2123             return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView());
2124         case CSSPropertyWebkitGridAutoFlow:
2125             return cssValuePool().createValue(style->gridAutoFlow());
2126         case CSSPropertyWebkitGridAutoRows:
2127             return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document().renderView());
2128         case CSSPropertyWebkitGridDefinitionColumns:
2129             return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document().renderView());
2130         case CSSPropertyWebkitGridDefinitionRows:
2131             return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document().renderView());
2132
2133         case CSSPropertyWebkitGridColumnStart:
2134             return valueForGridPosition(style->gridItemColumnStart());
2135         case CSSPropertyWebkitGridColumnEnd:
2136             return valueForGridPosition(style->gridItemColumnEnd());
2137         case CSSPropertyWebkitGridRowStart:
2138             return valueForGridPosition(style->gridItemRowStart());
2139         case CSSPropertyWebkitGridRowEnd:
2140             return valueForGridPosition(style->gridItemRowEnd());
2141         case CSSPropertyWebkitGridArea:
2142             return getCSSPropertyValuesForGridShorthand(webkitGridAreaShorthand());
2143         case CSSPropertyWebkitGridColumn:
2144             return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
2145         case CSSPropertyWebkitGridRow:
2146             return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
2147
2148         case CSSPropertyHeight:
2149             if (renderer) {
2150                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
2151                 // the "height" property does not apply for non-replaced inline elements.
2152                 if (!renderer->isReplaced() && renderer->isInline())
2153                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2154                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
2155             }
2156             return zoomAdjustedPixelValueForLength(style->height(), style.get());
2157         case CSSPropertyWebkitHighlight:
2158             if (style->highlight() == nullAtom)
2159                 return cssValuePool().createIdentifierValue(CSSValueNone);
2160             return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
2161         case CSSPropertyWebkitHyphens:
2162             return cssValuePool().createValue(style->hyphens());
2163         case CSSPropertyWebkitHyphenateCharacter:
2164             if (style->hyphenationString().isNull())
2165                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2166             return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
2167         case CSSPropertyWebkitHyphenateLimitAfter:
2168             if (style->hyphenationLimitAfter() < 0)
2169                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2170             return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
2171         case CSSPropertyWebkitHyphenateLimitBefore:
2172             if (style->hyphenationLimitBefore() < 0)
2173                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2174             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
2175         case CSSPropertyWebkitHyphenateLimitLines:
2176             if (style->hyphenationLimitLines() < 0)
2177                 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
2178             return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
2179         case CSSPropertyWebkitBorderFit:
2180             if (style->borderFit() == BorderFitBorder)
2181                 return cssValuePool().createIdentifierValue(CSSValueBorder);
2182             return cssValuePool().createIdentifierValue(CSSValueLines);
2183 #if ENABLE(CSS_IMAGE_ORIENTATION)
2184         case CSSPropertyImageOrientation:
2185             return cssValuePool().createValue(style->imageOrientation());
2186 #endif
2187         case CSSPropertyImageRendering:
2188             return CSSPrimitiveValue::create(style->imageRendering());
2189 #if ENABLE(CSS_IMAGE_RESOLUTION)
2190         case CSSPropertyImageResolution:
2191             return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
2192 #endif
2193         case CSSPropertyLeft:
2194             return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document().renderView());
2195         case CSSPropertyLetterSpacing:
2196             if (!style->letterSpacing())
2197                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2198             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
2199         case CSSPropertyWebkitLineClamp:
2200             if (style->lineClamp().isNone())
2201                 return cssValuePool().createIdentifierValue(CSSValueNone);
2202             return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2203         case CSSPropertyLineHeight:
2204             return lineHeightFromStyle(style.get(), m_node->document().renderView());
2205         case CSSPropertyListStyleImage:
2206             if (style->listStyleImage())
2207                 return style->listStyleImage()->cssValue();
2208             return cssValuePool().createIdentifierValue(CSSValueNone);
2209         case CSSPropertyListStylePosition:
2210             return cssValuePool().createValue(style->listStylePosition());
2211         case CSSPropertyListStyleType:
2212             return cssValuePool().createValue(style->listStyleType());
2213         case CSSPropertyWebkitLocale:
2214             if (style->locale().isNull())
2215                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2216             return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2217         case CSSPropertyMarginTop:
2218             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
2219         case CSSPropertyMarginRight: {
2220             Length marginRight = style->marginRight();
2221             if (marginRight.isFixed() || !renderer || !renderer->isBox())
2222                 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2223             float value;
2224             if (marginRight.isPercent() || marginRight.isViewportPercentage())
2225                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2226                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2227                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2228                 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document().renderView());
2229             else
2230                 value = toRenderBox(renderer)->marginRight();
2231             return zoomAdjustedPixelValue(value, style.get());
2232         }
2233         case CSSPropertyMarginBottom:
2234             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
2235         case CSSPropertyMarginLeft:
2236             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
2237         case CSSPropertyWebkitMarqueeDirection:
2238             return cssValuePool().createValue(style->marqueeDirection());
2239         case CSSPropertyWebkitMarqueeIncrement:
2240             return cssValuePool().createValue(style->marqueeIncrement());
2241         case CSSPropertyWebkitMarqueeRepetition:
2242             if (style->marqueeLoopCount() < 0)
2243                 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2244             return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2245         case CSSPropertyWebkitMarqueeStyle:
2246             return cssValuePool().createValue(style->marqueeBehavior());
2247         case CSSPropertyWebkitUserModify:
2248             return cssValuePool().createValue(style->userModify());
2249         case CSSPropertyMaxHeight: {
2250             const Length& maxHeight = style->maxHeight();
2251             if (maxHeight.isUndefined())
2252                 return cssValuePool().createIdentifierValue(CSSValueNone);
2253             return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2254         }
2255         case CSSPropertyMaxWidth: {
2256             const Length& maxWidth = style->maxWidth();
2257             if (maxWidth.isUndefined())
2258                 return cssValuePool().createIdentifierValue(CSSValueNone);
2259             return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2260         }
2261         case CSSPropertyMinHeight:
2262             // FIXME: For flex-items, min-height:auto should compute to min-content.
2263             if (style->minHeight().isAuto())
2264                 return zoomAdjustedPixelValue(0, style.get());
2265             return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2266         case CSSPropertyMinWidth:
2267             // FIXME: For flex-items, min-width:auto should compute to min-content.
2268             if (style->minWidth().isAuto())
2269                 return zoomAdjustedPixelValue(0, style.get());
2270             return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2271         case CSSPropertyObjectFit:
2272             return cssValuePool().createValue(style->objectFit());
2273         case CSSPropertyOpacity:
2274             return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2275         case CSSPropertyOrphans:
2276             if (style->hasAutoOrphans())
2277                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2278             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2279         case CSSPropertyOutlineColor:
2280             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2281         case CSSPropertyOutlineOffset:
2282             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2283         case CSSPropertyOutlineStyle:
2284             if (style->outlineStyleIsAuto())
2285                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2286             return cssValuePool().createValue(style->outlineStyle());
2287         case CSSPropertyOutlineWidth:
2288             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2289         case CSSPropertyOverflow:
2290             return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
2291         case CSSPropertyOverflowWrap:
2292             return cssValuePool().createValue(style->overflowWrap());
2293         case CSSPropertyOverflowX:
2294             return cssValuePool().createValue(style->overflowX());
2295         case CSSPropertyOverflowY:
2296             return cssValuePool().createValue(style->overflowY());
2297         case CSSPropertyPaddingTop:
2298             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
2299         case CSSPropertyPaddingRight:
2300             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
2301         case CSSPropertyPaddingBottom:
2302             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
2303         case CSSPropertyPaddingLeft:
2304             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
2305         case CSSPropertyPageBreakAfter:
2306             return cssValuePool().createValue(style->pageBreakAfter());
2307         case CSSPropertyPageBreakBefore:
2308             return cssValuePool().createValue(style->pageBreakBefore());
2309         case CSSPropertyPageBreakInside: {
2310             EPageBreak pageBreak = style->pageBreakInside();
2311             ASSERT(pageBreak != PBALWAYS);
2312             if (pageBreak == PBALWAYS)
2313                 return 0;
2314             return cssValuePool().createValue(style->pageBreakInside());
2315         }
2316         case CSSPropertyPosition:
2317             return cssValuePool().createValue(style->position());
2318         case CSSPropertyRight:
2319             return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document().renderView());
2320         case CSSPropertyWebkitRubyPosition:
2321             return cssValuePool().createValue(style->rubyPosition());
2322         case CSSPropertyTableLayout:
2323             return cssValuePool().createValue(style->tableLayout());
2324         case CSSPropertyTextAlign:
2325             return cssValuePool().createValue(style->textAlign());
2326         case CSSPropertyTextDecoration:
2327             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2328 #if ENABLE(CSS3_TEXT)
2329         case CSSPropertyWebkitTextDecoration:
2330             return getCSSPropertyValuesForShorthandProperties(webkitTextDecorationShorthand());
2331         case CSSPropertyWebkitTextDecorationLine:
2332             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2333         case CSSPropertyWebkitTextDecorationStyle:
2334             return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2335         case CSSPropertyWebkitTextDecorationColor:
2336             return currentColorOrValidColor(style.get(), style->textDecorationColor());
2337         case CSSPropertyWebkitTextAlignLast:
2338             return cssValuePool().createValue(style->textAlignLast());
2339         case CSSPropertyWebkitTextJustify:
2340             return cssValuePool().createValue(style->textJustify());
2341         case CSSPropertyWebkitTextUnderlinePosition:
2342             return cssValuePool().createValue(style->textUnderlinePosition());
2343 #endif // CSS3_TEXT
2344         case CSSPropertyWebkitTextDecorationsInEffect:
2345             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2346         case CSSPropertyWebkitTextFillColor:
2347             return currentColorOrValidColor(style.get(), style->textFillColor());
2348         case CSSPropertyWebkitTextEmphasisColor:
2349             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2350         case CSSPropertyWebkitTextEmphasisPosition:
2351             return cssValuePool().createValue(style->textEmphasisPosition());
2352         case CSSPropertyWebkitTextEmphasisStyle:
2353             switch (style->textEmphasisMark()) {
2354             case TextEmphasisMarkNone:
2355                 return cssValuePool().createIdentifierValue(CSSValueNone);
2356             case TextEmphasisMarkCustom:
2357                 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2358             case TextEmphasisMarkAuto:
2359                 ASSERT_NOT_REACHED();
2360                 // Fall through
2361             case TextEmphasisMarkDot:
2362             case TextEmphasisMarkCircle:
2363             case TextEmphasisMarkDoubleCircle:
2364             case TextEmphasisMarkTriangle:
2365             case TextEmphasisMarkSesame: {
2366                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2367                 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2368                 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2369                 return list.release();
2370             }
2371             }
2372         case CSSPropertyTextIndent: {
2373             // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2374             // getPropertyCSSValue() returns CSSValue.
2375             RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2376 #if ENABLE(CSS3_TEXT)
2377             // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2378             // getPropertyCSSValue() returns CSSValueList.
2379             if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2380                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2381                 list->append(textIndent.release());
2382                 if (style->textIndentLine() == TextIndentEachLine)
2383                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2384                 if (style->textIndentType() == TextIndentHanging)
2385                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2386                 return list.release();
2387             }
2388 #endif
2389             return textIndent.release();
2390         }
2391         case CSSPropertyTextShadow:
2392             return valueForShadow(style->textShadow(), propertyID, style.get());
2393         case CSSPropertyTextRendering:
2394             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2395         case CSSPropertyTextOverflow:
2396             if (style->textOverflow())
2397                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2398             return cssValuePool().createIdentifierValue(CSSValueClip);
2399         case CSSPropertyWebkitTextSecurity:
2400             return cssValuePool().createValue(style->textSecurity());
2401 #if ENABLE(IOS_TEXT_AUTOSIZING)
2402         case CSSPropertyWebkitTextSizeAdjust:
2403             if (style->textSizeAdjust().isAuto())
2404                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2405             if (style->textSizeAdjust().isNone())
2406                 return cssValuePool().createIdentifierValue(CSSValueNone);
2407             return CSSPrimitiveValue::create(style->textSizeAdjust().percentage(), CSSPrimitiveValue::CSS_PERCENTAGE);
2408 #endif
2409         case CSSPropertyWebkitTextStrokeColor:
2410             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2411         case CSSPropertyWebkitTextStrokeWidth:
2412             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2413         case CSSPropertyTextTransform:
2414             return cssValuePool().createValue(style->textTransform());
2415         case CSSPropertyTop:
2416             return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document().renderView());
2417         case CSSPropertyUnicodeBidi:
2418             return cssValuePool().createValue(style->unicodeBidi());
2419         case CSSPropertyVerticalAlign:
2420             switch (style->verticalAlign()) {
2421                 case BASELINE:
2422                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2423                 case MIDDLE:
2424                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2425                 case SUB:
2426                     return cssValuePool().createIdentifierValue(CSSValueSub);
2427                 case SUPER:
2428                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2429                 case TEXT_TOP:
2430                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2431                 case TEXT_BOTTOM:
2432                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2433                 case TOP:
2434                     return cssValuePool().createIdentifierValue(CSSValueTop);
2435                 case BOTTOM:
2436                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2437                 case BASELINE_MIDDLE:
2438                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2439                 case LENGTH:
2440                     return cssValuePool().createValue(style->verticalAlignLength());
2441             }
2442             ASSERT_NOT_REACHED();
2443             return 0;
2444         case CSSPropertyVisibility:
2445             return cssValuePool().createValue(style->visibility());
2446         case CSSPropertyWhiteSpace:
2447             return cssValuePool().createValue(style->whiteSpace());
2448         case CSSPropertyWidows:
2449             if (style->hasAutoWidows())
2450                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2451             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2452         case CSSPropertyWidth:
2453             if (renderer) {
2454                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2455                 // the "width" property does not apply for non-replaced inline elements.
2456                 if (!renderer->isReplaced() && renderer->isInline())
2457                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2458                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2459             }
2460             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2461         case CSSPropertyWordBreak:
2462             return cssValuePool().createValue(style->wordBreak());
2463         case CSSPropertyWordSpacing:
2464             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2465         case CSSPropertyWordWrap:
2466             return cssValuePool().createValue(style->overflowWrap());
2467         case CSSPropertyWebkitLineBreak:
2468             return cssValuePool().createValue(style->lineBreak());
2469         case CSSPropertyWebkitNbspMode:
2470             return cssValuePool().createValue(style->nbspMode());
2471         case CSSPropertyResize:
2472             return cssValuePool().createValue(style->resize());
2473         case CSSPropertyWebkitFontKerning:
2474             return cssValuePool().createValue(style->fontDescription().kerning());
2475         case CSSPropertyWebkitFontSmoothing:
2476             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2477         case CSSPropertyWebkitFontVariantLigatures: {
2478             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2479             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2480             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2481             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2482                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2483                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2484
2485             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2486             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2487                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2488             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2489                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2490             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2491                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2492             return valueList;
2493         }
2494         case CSSPropertyZIndex:
2495             if (style->hasAutoZIndex())
2496                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2497             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2498         case CSSPropertyZoom:
2499             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2500         case CSSPropertyBoxSizing:
2501             if (style->boxSizing() == CONTENT_BOX)
2502                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2503             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2504 #if ENABLE(DASHBOARD_SUPPORT)
2505         case CSSPropertyWebkitDashboardRegion:
2506         {
2507             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2508             unsigned count = regions.size();
2509             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2510                 return cssValuePool().createIdentifierValue(CSSValueNone);
2511
2512             RefPtr<DashboardRegion> firstRegion;
2513             DashboardRegion* previousRegion = 0;
2514             for (unsigned i = 0; i < count; i++) {
2515                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2516                 StyleDashboardRegion styleRegion = regions[i];
2517
2518                 region->m_label = styleRegion.label;
2519                 LengthBox offset = styleRegion.offset;
2520                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2521                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2522                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2523                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2524                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2525                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2526
2527                 if (previousRegion)
2528                     previousRegion->m_next = region;
2529                 else
2530                     firstRegion = region;
2531                 previousRegion = region.get();
2532             }
2533             return cssValuePool().createValue(firstRegion.release());
2534         }
2535 #endif
2536 #if ENABLE(DRAGGABLE_REGION)
2537         case CSSPropertyWebkitAppRegion:
2538             return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2539 #endif
2540         case CSSPropertyWebkitAnimationDelay:
2541             return getDelayValue(style->animations());
2542         case CSSPropertyWebkitAnimationDirection: {
2543             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2544             const AnimationList* t = style->animations();
2545             if (t) {
2546                 for (size_t i = 0; i < t->size(); ++i) {
2547                     if (t->animation(i).direction())
2548                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2549                     else
2550                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2551                 }
2552             } else
2553                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2554             return list.release();
2555         }
2556         case CSSPropertyWebkitAnimationDuration:
2557             return getDurationValue(style->animations());
2558         case CSSPropertyWebkitAnimationFillMode: {
2559             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2560             const AnimationList* t = style->animations();
2561             if (t) {
2562                 for (size_t i = 0; i < t->size(); ++i) {
2563                     switch (t->animation(i).fillMode()) {
2564                     case AnimationFillModeNone:
2565                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2566                         break;
2567                     case AnimationFillModeForwards:
2568                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2569                         break;
2570                     case AnimationFillModeBackwards:
2571                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2572                         break;
2573                     case AnimationFillModeBoth:
2574                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2575                         break;
2576                     }
2577                 }
2578             } else
2579                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2580             return list.release();
2581         }
2582         case CSSPropertyWebkitAnimationIterationCount: {
2583             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2584             const AnimationList* t = style->animations();
2585             if (t) {
2586                 for (size_t i = 0; i < t->size(); ++i) {
2587                     double iterationCount = t->animation(i).iterationCount();
2588                     if (iterationCount == Animation::IterationCountInfinite)
2589                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2590                     else
2591                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2592                 }
2593             } else
2594                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2595             return list.release();
2596         }
2597         case CSSPropertyWebkitAnimationName: {
2598             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2599             const AnimationList* t = style->animations();
2600             if (t) {
2601                 for (size_t i = 0; i < t->size(); ++i)
2602                     list->append(cssValuePool().createValue(t->animation(i).name(), CSSPrimitiveValue::CSS_STRING));
2603             } else
2604                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2605             return list.release();
2606         }
2607         case CSSPropertyWebkitAnimationPlayState: {
2608             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2609             const AnimationList* t = style->animations();
2610             if (t) {
2611                 for (size_t i = 0; i < t->size(); ++i) {
2612                     int prop = t->animation(i).playState();
2613                     if (prop == AnimPlayStatePlaying)
2614                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2615                     else
2616                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2617                 }
2618             } else
2619                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2620             return list.release();
2621         }
2622         case CSSPropertyWebkitAnimationTimingFunction:
2623             return getTimingFunctionValue(style->animations());
2624         case CSSPropertyWebkitAppearance:
2625             return cssValuePool().createValue(style->appearance());
2626         case CSSPropertyWebkitAspectRatio:
2627             if (!style->hasAspectRatio())
2628                 return cssValuePool().createIdentifierValue(CSSValueNone);
2629             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2630         case CSSPropertyWebkitBackfaceVisibility:
2631             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2632         case CSSPropertyWebkitBorderImage:
2633             return valueForNinePieceImage(style->borderImage());
2634         case CSSPropertyBorderImageOutset:
2635             return valueForNinePieceImageQuad(style->borderImage().outset());
2636         case CSSPropertyBorderImageRepeat:
2637             return valueForNinePieceImageRepeat(style->borderImage());
2638         case CSSPropertyBorderImageSlice:
2639             return valueForNinePieceImageSlice(style->borderImage());
2640         case CSSPropertyBorderImageWidth:
2641             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2642         case CSSPropertyWebkitMaskBoxImage:
2643             return valueForNinePieceImage(style->maskBoxImage());
2644         case CSSPropertyWebkitMaskBoxImageOutset:
2645             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2646         case CSSPropertyWebkitMaskBoxImageRepeat:
2647             return valueForNinePieceImageRepeat(style->maskBoxImage());
2648         case CSSPropertyWebkitMaskBoxImageSlice:
2649             return valueForNinePieceImageSlice(style->maskBoxImage());
2650         case CSSPropertyWebkitMaskBoxImageWidth:
2651             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2652         case CSSPropertyWebkitMaskBoxImageSource:
2653             if (style->maskBoxImageSource())
2654                 return style->maskBoxImageSource()->cssValue();
2655             return cssValuePool().createIdentifierValue(CSSValueNone);
2656         case CSSPropertyWebkitFontSizeDelta:
2657             // Not a real style property -- used by the editing engine -- so has no computed value.
2658             break;
2659         case CSSPropertyWebkitMarginBottomCollapse:
2660         case CSSPropertyWebkitMarginAfterCollapse:
2661             return cssValuePool().createValue(style->marginAfterCollapse());
2662         case CSSPropertyWebkitMarginTopCollapse:
2663         case CSSPropertyWebkitMarginBeforeCollapse:
2664             return cssValuePool().createValue(style->marginBeforeCollapse());
2665 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2666         case CSSPropertyWebkitOverflowScrolling:
2667             if (!style->useTouchOverflowScrolling())
2668                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2669             return cssValuePool().createIdentifierValue(CSSValueTouch);
2670 #endif
2671         case CSSPropertyWebkitPerspective:
2672             if (!style->hasPerspective())
2673                 return cssValuePool().createIdentifierValue(CSSValueNone);
2674             return zoomAdjustedPixelValue(style->perspective(), style.get());
2675         case CSSPropertyWebkitPerspectiveOrigin: {
2676             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2677             if (renderer) {
2678                 LayoutRect box;
2679                 if (renderer->isBox())
2680                     box = toRenderBox(renderer)->borderBoxRect();
2681
2682                 RenderView* renderView = m_node->document().renderView();
2683                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2684                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2685             }
2686             else {
2687                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2688                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2689
2690             }
2691             return list.release();
2692         }
2693         case CSSPropertyWebkitRtlOrdering:
2694             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2695 #if ENABLE(TOUCH_EVENTS)
2696         case CSSPropertyWebkitTapHighlightColor:
2697             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2698 #endif
2699 #if PLATFORM(IOS)
2700         case CSSPropertyWebkitTouchCallout:
2701             return cssValuePool().createIdentifierValue(style->touchCalloutEnabled() ? CSSValueDefault : CSSValueNone);
2702 #endif
2703         case CSSPropertyWebkitUserDrag:
2704             return cssValuePool().createValue(style->userDrag());
2705         case CSSPropertyWebkitUserSelect:
2706             return cssValuePool().createValue(style->userSelect());
2707         case CSSPropertyBorderBottomLeftRadius:
2708             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document().renderView());
2709         case CSSPropertyBorderBottomRightRadius:
2710             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document().renderView());
2711         case CSSPropertyBorderTopLeftRadius:
2712             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document().renderView());
2713         case CSSPropertyBorderTopRightRadius:
2714             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document().renderView());
2715         case CSSPropertyClip: {
2716             if (!style->hasClip())
2717                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2718             RefPtr<Rect> rect = Rect::create();
2719             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2720             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2721             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2722             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2723             return cssValuePool().createValue(rect.release());
2724         }
2725         case CSSPropertySpeak:
2726             return cssValuePool().createValue(style->speak());
2727         case CSSPropertyWebkitTransform:
2728             return computedTransform(renderer, style.get());
2729         case CSSPropertyWebkitTransformOrigin: {
2730             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2731             if (renderer) {
2732                 LayoutRect box;
2733                 if (renderer->isBox())
2734                     box = toRenderBox(renderer)->borderBoxRect();
2735
2736                 RenderView* renderView = m_node->document().renderView();
2737                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2738                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2739                 if (style->transformOriginZ() != 0)
2740                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2741             } else {
2742                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2743                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2744                 if (style->transformOriginZ() != 0)
2745                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2746             }
2747             return list.release();
2748         }
2749         case CSSPropertyWebkitTransformStyle:
2750             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2751         case CSSPropertyTransitionDelay:
2752         case CSSPropertyWebkitTransitionDelay:
2753             return getDelayValue(style->transitions());
2754         case CSSPropertyTransitionDuration:
2755         case CSSPropertyWebkitTransitionDuration:
2756             return getDurationValue(style->transitions());
2757         case CSSPropertyTransitionProperty:
2758         case CSSPropertyWebkitTransitionProperty:
2759             return getTransitionPropertyValue(style->transitions());
2760         case CSSPropertyTransitionTimingFunction:
2761         case CSSPropertyWebkitTransitionTimingFunction:
2762             return getTimingFunctionValue(style->transitions());
2763         case CSSPropertyTransition:
2764         case CSSPropertyWebkitTransition: {
2765             const AnimationList* animList = style->transitions();
2766             if (animList) {
2767                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2768                 for (size_t i = 0; i < animList->size(); ++i) {
2769                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2770                     const Animation& animation = animList->animation(i);
2771                     list->append(createTransitionPropertyValue(animation));
2772                     list->append(cssValuePool().createValue(animation.duration(), CSSPrimitiveValue::CSS_S));
2773                     list->append(createTimingFunctionValue(animation.timingFunction().get()));
2774                     list->append(cssValuePool().createValue(animation.delay(), CSSPrimitiveValue::CSS_S));
2775                     transitionsList->append(list);
2776                 }
2777                 return transitionsList.release();
2778             }
2779
2780             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2781             // transition-property default value.
2782             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2783             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2784             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2785             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2786             return list.release();
2787         }
2788         case CSSPropertyPointerEvents:
2789             return cssValuePool().createValue(style->pointerEvents());
2790         case CSSPropertyWebkitColorCorrection:
2791             return cssValuePool().createValue(style->colorSpace());
2792         case CSSPropertyWebkitLineGrid:
2793             if (style->lineGrid().isNull())
2794                 return cssValuePool().createIdentifierValue(CSSValueNone);
2795             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2796         case CSSPropertyWebkitLineSnap:
2797             return CSSPrimitiveValue::create(style->lineSnap());
2798         case CSSPropertyWebkitLineAlign:
2799             return CSSPrimitiveValue::create(style->lineAlign());
2800         case CSSPropertyWebkitWritingMode:
2801             return cssValuePool().createValue(style->writingMode());
2802         case CSSPropertyWebkitTextCombine:
2803             return cssValuePool().createValue(style->textCombine());
2804         case CSSPropertyWebkitTextOrientation:
2805             return CSSPrimitiveValue::create(style->textOrientation());
2806         case CSSPropertyWebkitLineBoxContain:
2807             return createLineBoxContainValue(style->lineBoxContain());
2808         case CSSPropertyContent:
2809             return contentToCSSValue(style.get());
2810         case CSSPropertyCounterIncrement:
2811             return counterToCSSValue(style.get(), propertyID);
2812         case CSSPropertyCounterReset:
2813             return counterToCSSValue(style.get(), propertyID);
2814         case CSSPropertyWebkitClipPath:
2815             if (ClipPathOperation* operation = style->clipPath()) {
2816                 if (operation->getOperationType() == ClipPathOperation::SHAPE)
2817                     return valueForBasicShape(style.get(), static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2818 #if ENABLE(SVG)
2819                 else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
2820                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2821                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2822                 }
2823 #endif
2824             }
2825             return cssValuePool().createIdentifierValue(CSSValueNone);
2826 #if ENABLE(CSS_REGIONS)
2827         case CSSPropertyWebkitFlowInto:
2828             if (style->flowThread().isNull())
2829                 return cssValuePool().createIdentifierValue(CSSValueNone);
2830             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2831         case CSSPropertyWebkitFlowFrom:
2832             if (style->regionThread().isNull())
2833                 return cssValuePool().createIdentifierValue(CSSValueNone);
2834             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2835         case CSSPropertyWebkitRegionFragment:
2836             return cssValuePool().createValue(style->regionFragment());
2837 #endif
2838 #if ENABLE(CSS_EXCLUSIONS)
2839         case CSSPropertyWebkitWrapFlow:
2840             return cssValuePool().createValue(style->wrapFlow());
2841         case CSSPropertyWebkitWrapThrough:
2842             return cssValuePool().createValue(style->wrapThrough());
2843 #endif
2844 #if ENABLE(CSS_SHAPES)
2845         case CSSPropertyWebkitShapeMargin:
2846             return cssValuePool().createValue(style->shapeMargin());
2847         case CSSPropertyWebkitShapePadding:
2848             return cssValuePool().createValue(style->shapePadding());
2849         case CSSPropertyWebkitShapeImageThreshold:
2850             return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2851         case CSSPropertyWebkitShapeInside:
2852             if (!style->shapeInside())
2853                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2854             if (style->shapeInside()->type() == ShapeValue::Outside)
2855                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2856             if (style->shapeInside()->type() == ShapeValue::Image) {
2857                 if (style->shapeInside()->image())
2858                     return style->shapeInside()->image()->cssValue();
2859                 return cssValuePool().createIdentifierValue(CSSValueNone);
2860             }
2861             ASSERT(style->shapeInside()->type() == ShapeValue::Shape);
2862             return valueForBasicShape(style.get(), style->shapeInside()->shape());
2863         case CSSPropertyWebkitShapeOutside:
2864             if (!style->shapeOutside())
2865                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2866             if (style->shapeOutside()->type() == ShapeValue::Image) {
2867                 if (style->shapeOutside()->image())
2868                     return style->shapeOutside()->image()->cssValue();
2869                 return cssValuePool().createIdentifierValue(CSSValueNone);
2870             }
2871             ASSERT(style->shapeOutside()->type() == ShapeValue::Shape);
2872             return valueForBasicShape(style.get(), style->shapeOutside()->shape());
2873 #endif
2874 #if ENABLE(CSS_FILTERS)
2875         case CSSPropertyWebkitFilter:
2876             return valueForFilter(renderer, style.get(), style->filter());
2877 #endif
2878 #if ENABLE(CSS_COMPOSITING)
2879         case CSSPropertyWebkitBlendMode:
2880             return cssValuePool().createValue(style->blendMode());
2881 #endif
2882         case CSSPropertyWebkitBackgroundBlendMode: {
2883             const FillLayer* layers = style->backgroundLayers();
2884             if (!layers->next())
2885                 return cssValuePool().createValue(layers->blendMode());
2886
2887             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2888             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2889                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2890
2891             return list.release();
2892         }
2893         case CSSPropertyBackground:
2894             return getBackgroundShorthandValue();
2895         case CSSPropertyBorder: {
2896             RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2897             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2898                                         CSSPropertyBorderLeft };
2899             for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2900                 if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
2901                     return 0;
2902             }
2903             return value.release();
2904         }
2905         case CSSPropertyBorderBottom:
2906             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2907         case CSSPropertyBorderColor:
2908             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2909         case CSSPropertyBorderLeft:
2910             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2911         case CSSPropertyBorderImage:
2912             return valueForNinePieceImage(style->borderImage());
2913         case CSSPropertyBorderRadius:
2914             return getBorderRadiusShorthandValue(style.get(), m_node->document().renderView());
2915         case CSSPropertyBorderRight:
2916             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2917         case CSSPropertyBorderStyle:
2918             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2919         case CSSPropertyBorderTop:
2920             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2921         case CSSPropertyBorderWidth:
2922             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2923         case CSSPropertyWebkitColumnRule:
2924             return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2925         case CSSPropertyWebkitColumns:
2926             return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2927         case CSSPropertyListStyle:
2928             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2929         case CSSPropertyMargin:
2930             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2931         case CSSPropertyOutline:
2932             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2933         case CSSPropertyPadding:
2934             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2935         /* Individual properties not part of the spec */
2936         case CSSPropertyBackgroundRepeatX:
2937         case CSSPropertyBackgroundRepeatY:
2938             break;
2939
2940         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2941         case CSSPropertyWebkitTextEmphasis:
2942         case CSSPropertyTextLineThrough:
2943         case CSSPropertyTextLineThroughColor:
2944         case CSSPropertyTextLineThroughMode:
2945         case CSSPropertyTextLineThroughStyle:
2946         case CSSPropertyTextLineThroughWidth:
2947         case CSSPropertyTextOverline:
2948         case CSSPropertyTextOverlineColor:
2949         case CSSPropertyTextOverlineMode:
2950         case CSSPropertyTextOverlineStyle:
2951         case CSSPropertyTextOverlineWidth:
2952         case CSSPropertyTextUnderline:
2953         case CSSPropertyTextUnderlineColor:
2954         case CSSPropertyTextUnderlineMode:
2955         case CSSPropertyTextUnderlineStyle:
2956         case CSSPropertyTextUnderlineWidth:
2957             break;
2958
2959         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2960         case CSSPropertyWebkitBorderEnd:
2961         case CSSPropertyWebkitBorderEndColor:
2962         case CSSPropertyWebkitBorderEndStyle:
2963         case CSSPropertyWebkitBorderEndWidth:
2964         case CSSPropertyWebkitBorderStart:
2965         case CSSPropertyWebkitBorderStartColor:
2966         case CSSPropertyWebkitBorderStartStyle:
2967         case CSSPropertyWebkitBorderStartWidth:
2968         case CSSPropertyWebkitBorderAfter:
2969         case CSSPropertyWebkitBorderAfterColor:
2970         case CSSPropertyWebkitBorderAfterStyle:
2971         case CSSPropertyWebkitBorderAfterWidth:
2972         case CSSPropertyWebkitBorderBefore:
2973         case CSSPropertyWebkitBorderBeforeColor:
2974         case CSSPropertyWebkitBorderBeforeStyle:
2975         case CSSPropertyWebkitBorderBeforeWidth:
2976         case CSSPropertyWebkitMarginEnd:
2977         case CSSPropertyWebkitMarginStart:
2978         case CSSPropertyWebkitMarginAfter:
2979         case CSSPropertyWebkitMarginBefore:
2980         case CSSPropertyWebkitPaddingEnd:
2981         case CSSPropertyWebkitPaddingStart:
2982         case CSSPropertyWebkitPaddingAfter:
2983         case CSSPropertyWebkitPaddingBefore:
2984         case CSSPropertyWebkitLogicalWidth:
2985         case CSSPropertyWebkitLogicalHeight:
2986         case CSSPropertyWebkitMinLogicalWidth:
2987         case CSSPropertyWebkitMinLogicalHeight:
2988         case CSSPropertyWebkitMaxLogicalWidth:
2989         case CSSPropertyWebkitMaxLogicalHeight:
2990             ASSERT_NOT_REACHED();
2991             break;
2992
2993         /* Unimplemented @font-face properties */
2994         case CSSPropertyFontStretch:
2995         case CSSPropertySrc:
2996         case CSSPropertyUnicodeRange:
2997             break;
2998
2999         /* Other unimplemented properties */
3000 #if ENABLE(CSS_SHADERS)
3001         case CSSPropertyGeometry:
3002 #endif
3003         case CSSPropertyPage: // for @page
3004         case CSSPropertyQuotes: // FIXME: needs implementation
3005         case CSSPropertySize: // for @page
3006             break;
3007
3008         /* Unimplemented -webkit- properties */
3009         case CSSPropertyWebkitAnimation:
3010         case CSSPropertyWebkitBorderRadius:
3011         case CSSPropertyWebkitMarginCollapse:
3012         case CSSPropertyWebkitMarquee:
3013         case CSSPropertyWebkitMarqueeSpeed:
3014         case CSSPropertyWebkitMask:
3015         case CSSPropertyWebkitMaskRepeatX:
3016         case CSSPropertyWebkitMaskRepeatY:
3017         case CSSPropertyWebkitPerspectiveOriginX:
3018         case CSSPropertyWebkitPerspectiveOriginY:
3019         case CSSPropertyWebkitTextStroke:
3020         case CSSPropertyWebkitTransformOriginX:
3021         case CSSPropertyWebkitTransformOriginY:
3022         case CSSPropertyWebkitTransformOriginZ:
3023 #if ENABLE(CSS_SHADERS)
3024         case CSSPropertyMix:
3025         case CSSPropertyParameters:
3026 #endif
3027             break;
3028
3029 #if ENABLE(CSS_DEVICE_ADAPTATION)
3030         case CSSPropertyMaxZoom:
3031         case CSSPropertyMinZoom:
3032         case CSSPropertyOrientation:
3033         case CSSPropertyUserZoom:
3034             break;
3035 #endif
3036
3037 #if ENABLE(SVG)
3038         case CSSPropertyBufferedRendering:
3039         case CSSPropertyClipPath:
3040         case CSSPropertyClipRule:
3041         case CSSPropertyMask:
3042         case CSSPropertyEnableBackground:
3043         case CSSPropertyFilter:
3044         case CSSPropertyFloodColor:
3045         case CSSPropertyFloodOpacity:
3046         case CSSPropertyLightingColor:
3047         case CSSPropertyStopColor:
3048         case CSSPropertyStopOpacity:
3049         case CSSPropertyColorInterpolation:
3050         case CSSPropertyColorInterpolationFilters:
3051         case CSSPropertyColorProfile:
3052         case CSSPropertyColorRendering:
3053         case CSSPropertyFill:
3054         case CSSPropertyFillOpacity:
3055         case CSSPropertyFillRule:
3056         case CSSPropertyMarker:
3057         case CSSPropertyMarkerEnd:
3058         case CSSPropertyMarkerMid:
3059         case CSSPropertyMarkerStart:
3060         case CSSPropertyMaskType:
3061         case CSSPropertyShapeRendering:
3062         case CSSPropertyStroke:
3063         case CSSPropertyStrokeDasharray:
3064         case CSSPropertyStrokeDashoffset:
3065         case CSSPropertyStrokeLinecap:
3066         case CSSPropertyStrokeLinejoin:
3067         case CSSPropertyStrokeMiterlimit:
3068         case CSSPropertyStrokeOpacity:
3069         case CSSPropertyStrokeWidth:
3070         case CSSPropertyAlignmentBaseline:
3071         case CSSPropertyBaselineShift:
3072         case CSSPropertyDominantBaseline:
3073         case CSSPropertyGlyphOrientationHorizontal:
3074         case CSSPropertyGlyphOrientationVertical:
3075         case CSSPropertyKerning:
3076         case CSSPropertyTextAnchor:
3077         case CSSPropertyVectorEffect:
3078         case CSSPropertyWritingMode:
3079         case CSSPropertyWebkitSvgShadow:
3080             return svgPropertyValue(propertyID, DoNotUpdateLayout);
3081 #endif
3082     }
3083
3084     logUnimplementedPropertyID(propertyID);
3085     return 0;
3086 }
3087
3088 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
3089 {
3090     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3091     if (value)
3092         return value->cssText();
3093     return "";
3094 }
3095
3096 unsigned CSSComputedStyleDeclaration::length() const
3097 {
3098     Node* node = m_node.get();
3099     if (!node)
3100         return 0;
3101
3102     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
3103     if (!style)
3104         return 0;
3105
3106     return numComputedProperties;
3107 }
3108
3109 String CSSComputedStyleDeclaration::item(unsigned i) const
3110 {
3111     if (i >= length())
3112         return "";
3113
3114     return getPropertyNameString(computedProperties[i]);
3115 }
3116
3117 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const
3118 {
3119     if (propertyID == CSSPropertyFontSize && value->isPrimitiveValue() && m_node) {
3120         m_node->document().updateLayoutIgnorePendingStylesheets();
3121         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
3122         if (style && style->fontDescription().keywordSize()) {
3123             CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
3124             const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
3125             if (primitiveValue->isValueID() && primitiveValue->getValueID() == sizeValue)
3126                 return true;
3127         }
3128     }
3129     RefPtr<CSSValue> computedValue = propertyValue(propertyID);
3130     return computedValue && value && computedValue->equals(*value);
3131 }
3132
3133 PassRefPtr<MutableStylePropertySet> ComputedStyleExtractor::copyProperties() const
3134 {
3135     return copyPropertiesInSet(computedProperties, numComputedProperties);
3136 }
3137
3138 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
3139 {
3140     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3141     for (size_t i = 0; i < shorthand.length(); ++i) {
3142         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3143         list->append(value);
3144     }
3145     return list.release();
3146 }
3147
3148 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
3149 {
3150     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3151     // Assume the properties are in the usual order top, right, bottom, left.
3152     RefPtr<CSSValue> topValue = propertyValue(shorthand.properties()[0], DoNotUpdateLayout);
3153     RefPtr<CSSValue> rightValue = propertyValue(shorthand.properties()[1], DoNotUpdateLayout);
3154     RefPtr<CSSValue> bottomValue = propertyValue(shorthand.properties()[2], DoNotUpdateLayout);
3155     RefPtr<CSSValue> leftValue = propertyValue(shorthand.properties()[3], DoNotUpdateLayout);
3156
3157     // All 4 properties must be specified.
3158     if (!topValue || !rightValue || !bottomValue || !leftValue)
3159         return 0;
3160
3161     bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
3162     bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
3163     bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
3164
3165     list->append(topValue.release());
3166     if (showRight)
3167         list->append(rightValue.release());
3168     if (showBottom)
3169         list->append(bottomValue.release());
3170     if (showLeft)
3171         list->append(leftValue.release());
3172
3173     return list.release();
3174 }
3175
3176 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
3177 {
3178     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3179     for (size_t i = 0; i < shorthand.length(); ++i) {
3180         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3181         list->append(value.release());
3182     }
3183     return list.release();
3184 }
3185
3186 PassRefPtr<MutableStylePropertySet> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
3187 {
3188     Vector<CSSProperty, 256> list;
3189     list.reserveInitialCapacity(length);
3190     for (unsigned i = 0; i < length; ++i) {
3191         RefPtr<CSSValue> value = propertyValue(set[i]);
3192         if (value)
3193             list.append(CSSProperty(set[i], value.release(), false));
3194     }
3195     return MutableStylePropertySet::create(list.data(), list.size());
3196 }
3197
3198 CSSRule* CSSComputedStyleDeclaration::parentRule() const
3199 {
3200     return 0;
3201 }
3202
3203 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
3204 {
3205     CSSPropertyID propertyID = cssPropertyID(propertyName);
3206     if (!propertyID)
3207         return 0;
3208     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3209     return value ? value->cloneForCSSOM() : 0;
3210 }
3211
3212 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
3213 {
3214     CSSPropertyID propertyID = cssPropertyID(propertyName);
3215     if (!propertyID)
3216         return String();
3217     return getPropertyValue(propertyID);
3218 }
3219
3220 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
3221 {
3222     // All computed styles have a priority of not "important".
3223     return "";
3224 }
3225
3226 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
3227 {
3228     return "";
3229 }
3230
3231 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
3232 {
3233     return false;
3234 }
3235
3236 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
3237 {
3238     ec = NO_MODIFICATION_ALLOWED_ERR;
3239 }
3240
3241 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3242 {
3243     ec = NO_MODIFICATION_ALLOWED_ERR;
3244     return String();
3245 }
3246     
3247 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3248 {
3249     return getPropertyCSSValue(propertyID);
3250 }
3251
3252 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3253 {
3254     return getPropertyValue(propertyID);
3255 }
3256
3257 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3258 {
3259     ec = NO_MODIFICATION_ALLOWED_ERR;
3260 }
3261
3262 PassRefPtr<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
3263 {
3264     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3265                                                                      CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,  
3266                                                                      CSSPropertyBackgroundPosition };
3267     static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, 
3268                                                                     CSSPropertyBackgroundClip };
3269
3270     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3271     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3272     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3273     return list.release();
3274 }
3275
3276 } // namespace WebCore