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