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