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