[css3-text] Parsing -webkit-hanging value for text-indent from css3-text
[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             // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2200             // getPropertyCSSValue() returns CSSValue.
2201             RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2202 #if ENABLE(CSS3_TEXT)
2203             // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2204             // getPropertyCSSValue() returns CSSValueList.
2205             if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2206                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2207                 list->append(textIndent.release());
2208                 if (style->textIndentLine() == TextIndentEachLine)
2209                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2210                 if (style->textIndentType() == TextIndentHanging)
2211                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2212                 return list.release();
2213             }
2214 #endif
2215             return textIndent.release();
2216         }
2217         case CSSPropertyTextShadow:
2218             return valueForShadow(style->textShadow(), propertyID, style.get());
2219         case CSSPropertyTextRendering:
2220             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2221         case CSSPropertyTextOverflow:
2222             if (style->textOverflow())
2223                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2224             return cssValuePool().createIdentifierValue(CSSValueClip);
2225         case CSSPropertyWebkitTextSecurity:
2226             return cssValuePool().createValue(style->textSecurity());
2227         case CSSPropertyWebkitTextStrokeColor:
2228             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2229         case CSSPropertyWebkitTextStrokeWidth:
2230             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2231         case CSSPropertyTextTransform:
2232             return cssValuePool().createValue(style->textTransform());
2233         case CSSPropertyTop:
2234             return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document()->renderView());
2235         case CSSPropertyUnicodeBidi:
2236             return cssValuePool().createValue(style->unicodeBidi());
2237         case CSSPropertyVerticalAlign:
2238             switch (style->verticalAlign()) {
2239                 case BASELINE:
2240                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2241                 case MIDDLE:
2242                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2243                 case SUB:
2244                     return cssValuePool().createIdentifierValue(CSSValueSub);
2245                 case SUPER:
2246                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2247                 case TEXT_TOP:
2248                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2249                 case TEXT_BOTTOM:
2250                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2251                 case TOP:
2252                     return cssValuePool().createIdentifierValue(CSSValueTop);
2253                 case BOTTOM:
2254                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2255                 case BASELINE_MIDDLE:
2256                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2257                 case LENGTH:
2258                     return cssValuePool().createValue(style->verticalAlignLength());
2259             }
2260             ASSERT_NOT_REACHED();
2261             return 0;
2262         case CSSPropertyVisibility:
2263             return cssValuePool().createValue(style->visibility());
2264         case CSSPropertyWhiteSpace:
2265             return cssValuePool().createValue(style->whiteSpace());
2266         case CSSPropertyWidows:
2267             if (style->hasAutoWidows())
2268                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2269             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2270         case CSSPropertyWidth:
2271             if (renderer) {
2272                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2273                 // the "width" property does not apply for non-replaced inline elements.
2274                 if (!renderer->isReplaced() && renderer->isInline())
2275                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2276                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2277             }
2278             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2279         case CSSPropertyWordBreak:
2280             return cssValuePool().createValue(style->wordBreak());
2281         case CSSPropertyWordSpacing:
2282             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2283         case CSSPropertyWordWrap:
2284             return cssValuePool().createValue(style->overflowWrap());
2285         case CSSPropertyWebkitLineBreak:
2286             return cssValuePool().createValue(style->lineBreak());
2287         case CSSPropertyWebkitNbspMode:
2288             return cssValuePool().createValue(style->nbspMode());
2289         case CSSPropertyResize:
2290             return cssValuePool().createValue(style->resize());
2291         case CSSPropertyWebkitFontKerning:
2292             return cssValuePool().createValue(style->fontDescription().kerning());
2293         case CSSPropertyWebkitFontSmoothing:
2294             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2295         case CSSPropertyWebkitFontVariantLigatures: {
2296             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2297             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2298             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2299             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2300                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2301                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2302
2303             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2304             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2305                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2306             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2307                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2308             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2309                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2310             return valueList;
2311         }
2312         case CSSPropertyZIndex:
2313             if (style->hasAutoZIndex())
2314                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2315             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2316         case CSSPropertyZoom:
2317             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2318         case CSSPropertyBoxSizing:
2319             if (style->boxSizing() == CONTENT_BOX)
2320                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2321             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2322 #if ENABLE(DASHBOARD_SUPPORT)
2323         case CSSPropertyWebkitDashboardRegion:
2324         {
2325             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2326             unsigned count = regions.size();
2327             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2328                 return cssValuePool().createIdentifierValue(CSSValueNone);
2329
2330             RefPtr<DashboardRegion> firstRegion;
2331             DashboardRegion* previousRegion = 0;
2332             for (unsigned i = 0; i < count; i++) {
2333                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2334                 StyleDashboardRegion styleRegion = regions[i];
2335
2336                 region->m_label = styleRegion.label;
2337                 LengthBox offset = styleRegion.offset;
2338                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2339                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2340                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2341                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2342                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2343                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2344
2345                 if (previousRegion)
2346                     previousRegion->m_next = region;
2347                 else
2348                     firstRegion = region;
2349                 previousRegion = region.get();
2350             }
2351             return cssValuePool().createValue(firstRegion.release());
2352         }
2353 #endif
2354 #if ENABLE(DRAGGABLE_REGION)
2355         case CSSPropertyWebkitAppRegion:
2356             return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2357 #endif
2358         case CSSPropertyWebkitAnimationDelay:
2359             return getDelayValue(style->animations());
2360         case CSSPropertyWebkitAnimationDirection: {
2361             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2362             const AnimationList* t = style->animations();
2363             if (t) {
2364                 for (size_t i = 0; i < t->size(); ++i) {
2365                     if (t->animation(i)->direction())
2366                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2367                     else
2368                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2369                 }
2370             } else
2371                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2372             return list.release();
2373         }
2374         case CSSPropertyWebkitAnimationDuration:
2375             return getDurationValue(style->animations());
2376         case CSSPropertyWebkitAnimationFillMode: {
2377             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2378             const AnimationList* t = style->animations();
2379             if (t) {
2380                 for (size_t i = 0; i < t->size(); ++i) {
2381                     switch (t->animation(i)->fillMode()) {
2382                     case AnimationFillModeNone:
2383                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2384                         break;
2385                     case AnimationFillModeForwards:
2386                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2387                         break;
2388                     case AnimationFillModeBackwards:
2389                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2390                         break;
2391                     case AnimationFillModeBoth:
2392                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2393                         break;
2394                     }
2395                 }
2396             } else
2397                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2398             return list.release();
2399         }
2400         case CSSPropertyWebkitAnimationIterationCount: {
2401             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2402             const AnimationList* t = style->animations();
2403             if (t) {
2404                 for (size_t i = 0; i < t->size(); ++i) {
2405                     double iterationCount = t->animation(i)->iterationCount();
2406                     if (iterationCount == Animation::IterationCountInfinite)
2407                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2408                     else
2409                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2410                 }
2411             } else
2412                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2413             return list.release();
2414         }
2415         case CSSPropertyWebkitAnimationName: {
2416             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2417             const AnimationList* t = style->animations();
2418             if (t) {
2419                 for (size_t i = 0; i < t->size(); ++i)
2420                     list->append(cssValuePool().createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
2421             } else
2422                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2423             return list.release();
2424         }
2425         case CSSPropertyWebkitAnimationPlayState: {
2426             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2427             const AnimationList* t = style->animations();
2428             if (t) {
2429                 for (size_t i = 0; i < t->size(); ++i) {
2430                     int prop = t->animation(i)->playState();
2431                     if (prop == AnimPlayStatePlaying)
2432                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2433                     else
2434                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2435                 }
2436             } else
2437                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2438             return list.release();
2439         }
2440         case CSSPropertyWebkitAnimationTimingFunction:
2441             return getTimingFunctionValue(style->animations());
2442         case CSSPropertyWebkitAppearance:
2443             return cssValuePool().createValue(style->appearance());
2444         case CSSPropertyWebkitAspectRatio:
2445             if (!style->hasAspectRatio())
2446                 return cssValuePool().createIdentifierValue(CSSValueNone);
2447             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2448         case CSSPropertyWebkitBackfaceVisibility:
2449             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2450         case CSSPropertyWebkitBorderImage:
2451             return valueForNinePieceImage(style->borderImage());
2452         case CSSPropertyBorderImageOutset:
2453             return valueForNinePieceImageQuad(style->borderImage().outset());
2454         case CSSPropertyBorderImageRepeat:
2455             return valueForNinePieceImageRepeat(style->borderImage());
2456         case CSSPropertyBorderImageSlice:
2457             return valueForNinePieceImageSlice(style->borderImage());
2458         case CSSPropertyBorderImageWidth:
2459             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2460         case CSSPropertyWebkitMaskBoxImage:
2461             return valueForNinePieceImage(style->maskBoxImage());
2462         case CSSPropertyWebkitMaskBoxImageOutset:
2463             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2464         case CSSPropertyWebkitMaskBoxImageRepeat:
2465             return valueForNinePieceImageRepeat(style->maskBoxImage());
2466         case CSSPropertyWebkitMaskBoxImageSlice:
2467             return valueForNinePieceImageSlice(style->maskBoxImage());
2468         case CSSPropertyWebkitMaskBoxImageWidth:
2469             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2470         case CSSPropertyWebkitMaskBoxImageSource:
2471             if (style->maskBoxImageSource())
2472                 return style->maskBoxImageSource()->cssValue();
2473             return cssValuePool().createIdentifierValue(CSSValueNone);
2474         case CSSPropertyWebkitFontSizeDelta:
2475             // Not a real style property -- used by the editing engine -- so has no computed value.
2476             break;
2477         case CSSPropertyWebkitMarginBottomCollapse:
2478         case CSSPropertyWebkitMarginAfterCollapse:
2479             return cssValuePool().createValue(style->marginAfterCollapse());
2480         case CSSPropertyWebkitMarginTopCollapse:
2481         case CSSPropertyWebkitMarginBeforeCollapse:
2482             return cssValuePool().createValue(style->marginBeforeCollapse());
2483 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2484         case CSSPropertyWebkitOverflowScrolling:
2485             if (!style->useTouchOverflowScrolling())
2486                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2487             return cssValuePool().createIdentifierValue(CSSValueTouch);
2488 #endif
2489         case CSSPropertyWebkitPerspective:
2490             if (!style->hasPerspective())
2491                 return cssValuePool().createIdentifierValue(CSSValueNone);
2492             return zoomAdjustedPixelValue(style->perspective(), style.get());
2493         case CSSPropertyWebkitPerspectiveOrigin: {
2494             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2495             if (renderer) {
2496                 LayoutRect box;
2497                 if (renderer->isBox())
2498                     box = toRenderBox(renderer)->borderBoxRect();
2499
2500                 RenderView* renderView = m_node->document()->renderView();
2501                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2502                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2503             }
2504             else {
2505                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2506                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2507
2508             }
2509             return list.release();
2510         }
2511         case CSSPropertyWebkitRtlOrdering:
2512             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2513 #if ENABLE(TOUCH_EVENTS)
2514         case CSSPropertyWebkitTapHighlightColor:
2515             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2516 #endif
2517         case CSSPropertyWebkitUserDrag:
2518             return cssValuePool().createValue(style->userDrag());
2519         case CSSPropertyWebkitUserSelect:
2520             return cssValuePool().createValue(style->userSelect());
2521         case CSSPropertyBorderBottomLeftRadius:
2522             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document()->renderView());
2523         case CSSPropertyBorderBottomRightRadius:
2524             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document()->renderView());
2525         case CSSPropertyBorderTopLeftRadius:
2526             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document()->renderView());
2527         case CSSPropertyBorderTopRightRadius:
2528             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document()->renderView());
2529         case CSSPropertyClip: {
2530             if (!style->hasClip())
2531                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2532             RefPtr<Rect> rect = Rect::create();
2533             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2534             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2535             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2536             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2537             return cssValuePool().createValue(rect.release());
2538         }
2539         case CSSPropertySpeak:
2540             return cssValuePool().createValue(style->speak());
2541         case CSSPropertyWebkitTransform:
2542             return computedTransform(renderer, style.get());
2543         case CSSPropertyWebkitTransformOrigin: {
2544             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2545             if (renderer) {
2546                 LayoutRect box;
2547                 if (renderer->isBox())
2548                     box = toRenderBox(renderer)->borderBoxRect();
2549
2550                 RenderView* renderView = m_node->document()->renderView();
2551                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2552                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2553                 if (style->transformOriginZ() != 0)
2554                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2555             } else {
2556                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2557                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2558                 if (style->transformOriginZ() != 0)
2559                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2560             }
2561             return list.release();
2562         }
2563         case CSSPropertyWebkitTransformStyle:
2564             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2565         case CSSPropertyTransitionDelay:
2566         case CSSPropertyWebkitTransitionDelay:
2567             return getDelayValue(style->transitions());
2568         case CSSPropertyTransitionDuration:
2569         case CSSPropertyWebkitTransitionDuration:
2570             return getDurationValue(style->transitions());
2571         case CSSPropertyTransitionProperty:
2572         case CSSPropertyWebkitTransitionProperty:
2573             return getTransitionPropertyValue(style->transitions());
2574         case CSSPropertyTransitionTimingFunction:
2575         case CSSPropertyWebkitTransitionTimingFunction:
2576             return getTimingFunctionValue(style->transitions());
2577         case CSSPropertyTransition:
2578         case CSSPropertyWebkitTransition: {
2579             const AnimationList* animList = style->transitions();
2580             if (animList) {
2581                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2582                 for (size_t i = 0; i < animList->size(); ++i) {
2583                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2584                     const Animation* animation = animList->animation(i);
2585                     list->append(createTransitionPropertyValue(animation));
2586                     list->append(cssValuePool().createValue(animation->duration(), CSSPrimitiveValue::CSS_S));
2587                     list->append(createTimingFunctionValue(animation->timingFunction().get()));
2588                     list->append(cssValuePool().createValue(animation->delay(), CSSPrimitiveValue::CSS_S));
2589                     transitionsList->append(list);
2590                 }
2591                 return transitionsList.release();
2592             }
2593
2594             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2595             // transition-property default value.
2596             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2597             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2598             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2599             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2600             return list.release();
2601         }
2602         case CSSPropertyPointerEvents:
2603             return cssValuePool().createValue(style->pointerEvents());
2604         case CSSPropertyWebkitColorCorrection:
2605             return cssValuePool().createValue(style->colorSpace());
2606         case CSSPropertyWebkitLineGrid:
2607             if (style->lineGrid().isNull())
2608                 return cssValuePool().createIdentifierValue(CSSValueNone);
2609             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2610         case CSSPropertyWebkitLineSnap:
2611             return CSSPrimitiveValue::create(style->lineSnap());
2612         case CSSPropertyWebkitLineAlign:
2613             return CSSPrimitiveValue::create(style->lineAlign());
2614         case CSSPropertyWebkitWritingMode:
2615             return cssValuePool().createValue(style->writingMode());
2616         case CSSPropertyWebkitTextCombine:
2617             return cssValuePool().createValue(style->textCombine());
2618         case CSSPropertyWebkitTextOrientation:
2619             return CSSPrimitiveValue::create(style->textOrientation());
2620         case CSSPropertyWebkitLineBoxContain:
2621             return createLineBoxContainValue(style->lineBoxContain());
2622         case CSSPropertyContent:
2623             return contentToCSSValue(style.get());
2624         case CSSPropertyCounterIncrement:
2625             return counterToCSSValue(style.get(), propertyID);
2626         case CSSPropertyCounterReset:
2627             return counterToCSSValue(style.get(), propertyID);
2628         case CSSPropertyWebkitClipPath:
2629             if (ClipPathOperation* operation = style->clipPath()) {
2630                 if (operation->getOperationType() == ClipPathOperation::SHAPE)
2631                     return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2632 #if ENABLE(SVG)
2633                 else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
2634                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2635                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2636                 }
2637 #endif
2638             }
2639             return cssValuePool().createIdentifierValue(CSSValueNone);
2640 #if ENABLE(CSS_REGIONS)
2641         case CSSPropertyWebkitFlowInto:
2642             if (style->flowThread().isNull())
2643                 return cssValuePool().createIdentifierValue(CSSValueNone);
2644             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2645         case CSSPropertyWebkitFlowFrom:
2646             if (style->regionThread().isNull())
2647                 return cssValuePool().createIdentifierValue(CSSValueNone);
2648             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2649         case CSSPropertyWebkitRegionOverflow:
2650             return cssValuePool().createValue(style->regionOverflow());
2651 #endif
2652 #if ENABLE(CSS_EXCLUSIONS)
2653         case CSSPropertyWebkitWrapFlow:
2654             return cssValuePool().createValue(style->wrapFlow());
2655         case CSSPropertyWebkitShapeMargin:
2656             return cssValuePool().createValue(style->shapeMargin());
2657         case CSSPropertyWebkitShapePadding:
2658             return cssValuePool().createValue(style->shapePadding());
2659         case CSSPropertyWebkitShapeInside:
2660             if (!style->shapeInside())
2661                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2662             else if (style->shapeInside()->type() == ExclusionShapeValue::OUTSIDE)
2663                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2664             ASSERT(style->shapeInside()->type() == ExclusionShapeValue::SHAPE);
2665             return valueForBasicShape(style->shapeInside()->shape());
2666         case CSSPropertyWebkitShapeOutside:
2667             if (!style->shapeOutside())
2668                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2669             ASSERT(style->shapeOutside()->type() == ExclusionShapeValue::SHAPE);
2670             return valueForBasicShape(style->shapeOutside()->shape());
2671         case CSSPropertyWebkitWrapThrough:
2672             return cssValuePool().createValue(style->wrapThrough());
2673 #endif
2674 #if ENABLE(CSS_FILTERS)
2675         case CSSPropertyWebkitFilter:
2676             return valueForFilter(renderer, style.get());
2677 #endif
2678 #if ENABLE(CSS_COMPOSITING)
2679         case CSSPropertyWebkitBlendMode:
2680             return cssValuePool().createValue(style->blendMode());
2681             
2682         case CSSPropertyWebkitBackgroundBlendMode: {
2683             const FillLayer* layers = style->backgroundLayers();
2684             if (!layers->next())
2685                 return cssValuePool().createValue(layers->blendMode());
2686
2687             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2688             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2689                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2690
2691             return list.release();
2692         }
2693 #endif
2694         case CSSPropertyBackground:
2695             return getBackgroundShorthandValue();
2696         case CSSPropertyBorder: {
2697             RefPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2698             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2699                                         CSSPropertyBorderLeft };
2700             for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2701                 if (!compareCSSValuePtr<CSSValue>(value, getPropertyCSSValue(properties[i], DoNotUpdateLayout)))
2702                     return 0;
2703             }
2704             return value.release();
2705         }
2706         case CSSPropertyBorderBottom:
2707             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2708         case CSSPropertyBorderColor:
2709             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2710         case CSSPropertyBorderLeft:
2711             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2712         case CSSPropertyBorderImage:
2713             return valueForNinePieceImage(style->borderImage());
2714         case CSSPropertyBorderRadius:
2715             return getBorderRadiusShorthandValue(style.get(), m_node->document()->renderView());
2716         case CSSPropertyBorderRight:
2717             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2718         case CSSPropertyBorderStyle:
2719             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2720         case CSSPropertyBorderTop:
2721             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2722         case CSSPropertyBorderWidth:
2723             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2724         case CSSPropertyWebkitColumnRule:
2725             return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2726         case CSSPropertyWebkitColumns:
2727             return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2728         case CSSPropertyListStyle:
2729             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2730         case CSSPropertyMargin:
2731             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2732         case CSSPropertyOutline:
2733             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2734         case CSSPropertyPadding:
2735             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2736         /* Individual properties not part of the spec */
2737         case CSSPropertyBackgroundRepeatX:
2738         case CSSPropertyBackgroundRepeatY:
2739             break;
2740
2741         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2742         case CSSPropertyWebkitTextEmphasis:
2743         case CSSPropertyTextLineThrough:
2744         case CSSPropertyTextLineThroughColor:
2745         case CSSPropertyTextLineThroughMode:
2746         case CSSPropertyTextLineThroughStyle:
2747         case CSSPropertyTextLineThroughWidth:
2748         case CSSPropertyTextOverline:
2749         case CSSPropertyTextOverlineColor:
2750         case CSSPropertyTextOverlineMode:
2751         case CSSPropertyTextOverlineStyle:
2752         case CSSPropertyTextOverlineWidth:
2753         case CSSPropertyTextUnderline:
2754         case CSSPropertyTextUnderlineColor:
2755         case CSSPropertyTextUnderlineMode:
2756         case CSSPropertyTextUnderlineStyle:
2757         case CSSPropertyTextUnderlineWidth:
2758             break;
2759
2760         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2761         case CSSPropertyWebkitBorderEnd:
2762         case CSSPropertyWebkitBorderEndColor:
2763         case CSSPropertyWebkitBorderEndStyle:
2764         case CSSPropertyWebkitBorderEndWidth:
2765         case CSSPropertyWebkitBorderStart:
2766         case CSSPropertyWebkitBorderStartColor:
2767         case CSSPropertyWebkitBorderStartStyle:
2768         case CSSPropertyWebkitBorderStartWidth:
2769         case CSSPropertyWebkitBorderAfter:
2770         case CSSPropertyWebkitBorderAfterColor:
2771         case CSSPropertyWebkitBorderAfterStyle:
2772         case CSSPropertyWebkitBorderAfterWidth:
2773         case CSSPropertyWebkitBorderBefore:
2774         case CSSPropertyWebkitBorderBeforeColor:
2775         case CSSPropertyWebkitBorderBeforeStyle:
2776         case CSSPropertyWebkitBorderBeforeWidth:
2777         case CSSPropertyWebkitMarginEnd:
2778         case CSSPropertyWebkitMarginStart:
2779         case CSSPropertyWebkitMarginAfter:
2780         case CSSPropertyWebkitMarginBefore:
2781         case CSSPropertyWebkitPaddingEnd:
2782         case CSSPropertyWebkitPaddingStart:
2783         case CSSPropertyWebkitPaddingAfter:
2784         case CSSPropertyWebkitPaddingBefore:
2785         case CSSPropertyWebkitLogicalWidth:
2786         case CSSPropertyWebkitLogicalHeight:
2787         case CSSPropertyWebkitMinLogicalWidth:
2788         case CSSPropertyWebkitMinLogicalHeight:
2789         case CSSPropertyWebkitMaxLogicalWidth:
2790         case CSSPropertyWebkitMaxLogicalHeight:
2791             ASSERT_NOT_REACHED();
2792             break;
2793
2794         /* Unimplemented @font-face properties */
2795         case CSSPropertyFontStretch:
2796         case CSSPropertySrc:
2797         case CSSPropertyUnicodeRange:
2798             break;
2799
2800         /* Other unimplemented properties */
2801 #if ENABLE(CSS_SHADERS)
2802         case CSSPropertyGeometry:
2803 #endif
2804         case CSSPropertyPage: // for @page
2805         case CSSPropertyQuotes: // FIXME: needs implementation
2806         case CSSPropertySize: // for @page
2807             break;
2808
2809         /* Unimplemented -webkit- properties */
2810         case CSSPropertyWebkitAnimation:
2811         case CSSPropertyWebkitBorderRadius:
2812         case CSSPropertyWebkitMarginCollapse:
2813         case CSSPropertyWebkitMarquee:
2814         case CSSPropertyWebkitMarqueeSpeed:
2815         case CSSPropertyWebkitMask:
2816         case CSSPropertyWebkitMaskRepeatX:
2817         case CSSPropertyWebkitMaskRepeatY:
2818         case CSSPropertyWebkitPerspectiveOriginX:
2819         case CSSPropertyWebkitPerspectiveOriginY:
2820         case CSSPropertyWebkitTextStroke:
2821         case CSSPropertyWebkitTransformOriginX:
2822         case CSSPropertyWebkitTransformOriginY:
2823         case CSSPropertyWebkitTransformOriginZ:
2824 #if ENABLE(CSS_EXCLUSIONS)
2825         case CSSPropertyWebkitWrap:
2826 #endif
2827 #if ENABLE(CSS_SHADERS)
2828         case CSSPropertyMix:
2829         case CSSPropertyParameters:
2830 #endif
2831             break;
2832
2833 #if ENABLE(CSS_DEVICE_ADAPTATION)
2834         case CSSPropertyMaxZoom:
2835         case CSSPropertyMinZoom:
2836         case CSSPropertyOrientation:
2837         case CSSPropertyUserZoom:
2838             break;
2839 #endif
2840
2841 #if ENABLE(SVG)
2842         case CSSPropertyBufferedRendering:
2843         case CSSPropertyClipPath:
2844         case CSSPropertyClipRule:
2845         case CSSPropertyMask:
2846         case CSSPropertyEnableBackground:
2847         case CSSPropertyFilter:
2848         case CSSPropertyFloodColor:
2849         case CSSPropertyFloodOpacity:
2850         case CSSPropertyLightingColor:
2851         case CSSPropertyStopColor:
2852         case CSSPropertyStopOpacity:
2853         case CSSPropertyColorInterpolation:
2854         case CSSPropertyColorInterpolationFilters:
2855         case CSSPropertyColorProfile:
2856         case CSSPropertyColorRendering:
2857         case CSSPropertyFill:
2858         case CSSPropertyFillOpacity:
2859         case CSSPropertyFillRule:
2860         case CSSPropertyMarker:
2861         case CSSPropertyMarkerEnd:
2862         case CSSPropertyMarkerMid:
2863         case CSSPropertyMarkerStart:
2864         case CSSPropertyMaskType:
2865         case CSSPropertyShapeRendering:
2866         case CSSPropertyStroke:
2867         case CSSPropertyStrokeDasharray:
2868         case CSSPropertyStrokeDashoffset:
2869         case CSSPropertyStrokeLinecap:
2870         case CSSPropertyStrokeLinejoin:
2871         case CSSPropertyStrokeMiterlimit:
2872         case CSSPropertyStrokeOpacity:
2873         case CSSPropertyStrokeWidth:
2874         case CSSPropertyAlignmentBaseline:
2875         case CSSPropertyBaselineShift:
2876         case CSSPropertyDominantBaseline:
2877         case CSSPropertyGlyphOrientationHorizontal:
2878         case CSSPropertyGlyphOrientationVertical:
2879         case CSSPropertyKerning:
2880         case CSSPropertyTextAnchor:
2881         case CSSPropertyVectorEffect:
2882         case CSSPropertyWritingMode:
2883         case CSSPropertyWebkitSvgShadow:
2884             return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
2885 #endif
2886     }
2887
2888     logUnimplementedPropertyID(propertyID);
2889     return 0;
2890 }
2891
2892 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
2893 {
2894     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2895     if (value)
2896         return value->cssText();
2897     return "";
2898 }
2899
2900
2901 unsigned CSSComputedStyleDeclaration::length() const
2902 {
2903     Node* node = m_node.get();
2904     if (!node)
2905         return 0;
2906
2907     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
2908     if (!style)
2909         return 0;
2910
2911     return numComputedProperties;
2912 }
2913
2914 String CSSComputedStyleDeclaration::item(unsigned i) const
2915 {
2916     if (i >= length())
2917         return "";
2918
2919     return getPropertyNameString(computedProperties[i]);
2920 }
2921
2922 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
2923 {
2924     if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() && m_node) {
2925         m_node->document()->updateLayoutIgnorePendingStylesheets();
2926         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
2927         if (style && style->fontDescription().keywordSize()) {
2928             int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
2929             const CSSPrimitiveValue* primitiveValue = static_cast<const CSSPrimitiveValue*>(propertyValue);
2930             if (primitiveValue->isIdent() && primitiveValue->getIdent() == sizeValue)
2931                 return true;
2932         }
2933     }
2934     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2935     return value && propertyValue && value->equals(*propertyValue);
2936 }
2937
2938 PassRefPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() const
2939 {
2940     return copyPropertiesInSet(computedProperties, numComputedProperties);
2941 }
2942
2943 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
2944 {
2945     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2946     for (size_t i = 0; i < shorthand.length(); ++i) {
2947         RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2948         list->append(value);
2949     }
2950     return list.release();
2951 }
2952
2953 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
2954 {
2955     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2956     // Assume the properties are in the usual order top, right, bottom, left.
2957     RefPtr<CSSValue> topValue = getPropertyCSSValue(shorthand.properties()[0], DoNotUpdateLayout);
2958     RefPtr<CSSValue> rightValue = getPropertyCSSValue(shorthand.properties()[1], DoNotUpdateLayout);
2959     RefPtr<CSSValue> bottomValue = getPropertyCSSValue(shorthand.properties()[2], DoNotUpdateLayout);
2960     RefPtr<CSSValue> leftValue = getPropertyCSSValue(shorthand.properties()[3], DoNotUpdateLayout);
2961
2962     // All 4 properties must be specified.
2963     if (!topValue || !rightValue || !bottomValue || !leftValue)
2964         return 0;
2965
2966     bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
2967     bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
2968     bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
2969
2970     list->append(topValue);
2971     if (showRight)
2972         list->append(rightValue);
2973     if (showBottom)
2974         list->append(bottomValue);
2975     if (showLeft)
2976         list->append(leftValue);
2977
2978     return list.release();
2979 }
2980
2981 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
2982 {
2983     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
2984     for (size_t i = 0; i < shorthand.length(); ++i) {
2985         RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2986         list->append(value);
2987     }
2988     return list.release();
2989 }
2990
2991 PassRefPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
2992 {
2993     Vector<CSSProperty, 256> list;
2994     list.reserveInitialCapacity(length);
2995     for (unsigned i = 0; i < length; ++i) {
2996         RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
2997         if (value)
2998             list.append(CSSProperty(set[i], value.release(), false));
2999     }
3000     return MutableStylePropertySet::create(list.data(), list.size());
3001 }
3002
3003 void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
3004 {
3005     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
3006     info.addMember(m_node, "node");
3007 }
3008
3009 CSSRule* CSSComputedStyleDeclaration::parentRule() const
3010 {
3011     return 0;
3012 }
3013
3014 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
3015 {
3016     CSSPropertyID propertyID = cssPropertyID(propertyName);
3017     if (!propertyID)
3018         return 0;
3019     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3020     return value ? value->cloneForCSSOM() : 0;
3021 }
3022
3023 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
3024 {
3025     CSSPropertyID propertyID = cssPropertyID(propertyName);
3026     if (!propertyID)
3027         return String();
3028     return getPropertyValue(propertyID);
3029 }
3030
3031 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
3032 {
3033     // All computed styles have a priority of not "important".
3034     return "";
3035 }
3036
3037 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
3038 {
3039     return "";
3040 }
3041
3042 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
3043 {
3044     return false;
3045 }
3046
3047 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
3048 {
3049     ec = NO_MODIFICATION_ALLOWED_ERR;
3050 }
3051
3052 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3053 {
3054     ec = NO_MODIFICATION_ALLOWED_ERR;
3055     return String();
3056 }
3057     
3058 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3059 {
3060     return getPropertyCSSValue(propertyID);
3061 }
3062
3063 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3064 {
3065     return getPropertyValue(propertyID);
3066 }
3067
3068 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3069 {
3070     ec = NO_MODIFICATION_ALLOWED_ERR;
3071 }
3072
3073 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
3074 {
3075     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3076                                                                      CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,  
3077                                                                      CSSPropertyBackgroundPosition };
3078     static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, 
3079                                                                     CSSPropertyBackgroundClip };
3080
3081     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3082     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3083     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3084     return list.release();
3085 }
3086
3087 } // namespace WebCore