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