8291748f8a5318bbb79d9b7d52285eb9928c6740
[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
1071 static PassRefPtr<CSSValue> valueForGridPositions(const GridPositions& positions)
1072 {
1073     return valueForGridPosition(positions.firstPosition());
1074 }
1075
1076 static PassRefPtr<CSSValue> createTransitionPropertyValue(const Animation* animation)
1077 {
1078     RefPtr<CSSValue> propertyValue;
1079     if (animation->animationMode() == Animation::AnimateNone)
1080         propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
1081     else if (animation->animationMode() == Animation::AnimateAll)
1082         propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
1083     else
1084         propertyValue = cssValuePool().createValue(getPropertyNameString(animation->property()), CSSPrimitiveValue::CSS_STRING);
1085     return propertyValue.release();
1086 }
1087 static PassRefPtr<CSSValue> getTransitionPropertyValue(const AnimationList* animList)
1088 {
1089     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1090     if (animList) {
1091         for (size_t i = 0; i < animList->size(); ++i)
1092             list->append(createTransitionPropertyValue(animList->animation(i)));
1093     } else
1094         list->append(cssValuePool().createIdentifierValue(CSSValueAll));
1095     return list.release();
1096 }
1097
1098 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
1099 {
1100     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1101     if (animList) {
1102         for (size_t i = 0; i < animList->size(); ++i)
1103             list->append(cssValuePool().createValue(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
1104     } else {
1105         // Note that initialAnimationDelay() is used for both transitions and animations
1106         list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1107     }
1108     return list.release();
1109 }
1110
1111 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
1112 {
1113     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1114     if (animList) {
1115         for (size_t i = 0; i < animList->size(); ++i)
1116             list->append(cssValuePool().createValue(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
1117     } else {
1118         // Note that initialAnimationDuration() is used for both transitions and animations
1119         list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1120     }
1121     return list.release();
1122 }
1123
1124 static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1125 {
1126     if (timingFunction->isCubicBezierTimingFunction()) {
1127         const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1128         if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1129             CSSValueID valueId = CSSValueInvalid;
1130             switch (bezierTimingFunction->timingFunctionPreset()) {
1131             case CubicBezierTimingFunction::Ease:
1132                 valueId = CSSValueEase;
1133                 break;
1134             case CubicBezierTimingFunction::EaseIn:
1135                 valueId = CSSValueEaseIn;
1136                 break;
1137             case CubicBezierTimingFunction::EaseOut:
1138                 valueId = CSSValueEaseOut;
1139                 break;
1140             case CubicBezierTimingFunction::EaseInOut:
1141                 valueId = CSSValueEaseInOut;
1142                 break;
1143             default:
1144                 ASSERT_NOT_REACHED();
1145                 return 0;
1146             }
1147             return cssValuePool().createIdentifierValue(valueId);
1148         }
1149         return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1150     }
1151
1152     if (timingFunction->isStepsTimingFunction()) {
1153         const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1154         return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1155     }
1156
1157     return CSSLinearTimingFunctionValue::create();
1158 }
1159
1160 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
1161 {
1162     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1163     if (animList) {
1164         for (size_t i = 0; i < animList->size(); ++i)
1165             list->append(createTimingFunctionValue(animList->animation(i)->timingFunction().get()));
1166     } else
1167         // Note that initialAnimationTimingFunction() is used for both transitions and animations
1168         list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1169     return list.release();
1170 }
1171
1172 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1173 {
1174     if (!lineBoxContain)
1175         return cssValuePool().createIdentifierValue(CSSValueNone);
1176     return CSSLineBoxContainValue::create(lineBoxContain);
1177 }
1178
1179 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1180     : m_node(n)
1181     , m_allowVisitedStyle(allowVisitedStyle)
1182     , m_refCount(1)
1183 {
1184     unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1185     m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1186         AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1187 }
1188
1189 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1190 {
1191 }
1192
1193 void CSSComputedStyleDeclaration::ref()
1194 {
1195     ++m_refCount;
1196 }
1197
1198 void CSSComputedStyleDeclaration::deref()
1199 {
1200     ASSERT(m_refCount);
1201     if (!--m_refCount)
1202         delete this;
1203 }
1204
1205 String CSSComputedStyleDeclaration::cssText() const
1206 {
1207     StringBuilder result;
1208
1209     for (unsigned i = 0; i < numComputedProperties; i++) {
1210         if (i)
1211             result.append(' ');
1212         result.append(getPropertyName(computedProperties[i]));
1213         result.append(": ", 2);
1214         result.append(getPropertyValue(computedProperties[i]));
1215         result.append(';');
1216     }
1217
1218     return result.toString();
1219 }
1220
1221 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1222 {
1223     ec = NO_MODIFICATION_ALLOWED_ERR;
1224 }
1225
1226 static int cssIdentifierForFontSizeKeyword(int keywordSize)
1227 {
1228     ASSERT_ARG(keywordSize, keywordSize);
1229     ASSERT_ARG(keywordSize, keywordSize <= 8);
1230     return CSSValueXxSmall + keywordSize - 1;
1231 }
1232
1233 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
1234 {
1235     if (!m_node)
1236         return 0;
1237
1238     m_node->document()->updateLayoutIgnorePendingStylesheets();
1239
1240     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1241     if (!style)
1242         return 0;
1243
1244     if (int keywordSize = style->fontDescription().keywordSize())
1245         return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1246
1247
1248     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1249 }
1250
1251 bool CSSComputedStyleDeclaration::useFixedFontDefaultSize() const
1252 {
1253     if (!m_node)
1254         return false;
1255
1256     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1257     if (!style)
1258         return false;
1259
1260     return style->fontDescription().useFixedDefaultSize();
1261 }
1262
1263 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
1264 {
1265     if (!shadow)
1266         return cssValuePool().createIdentifierValue(CSSValueNone);
1267
1268     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1269     for (const ShadowData* s = shadow; s; s = s->next()) {
1270         RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style);
1271         RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style);
1272         RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style);
1273         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : zoomAdjustedPixelValue(s->spread(), style);
1274         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
1275         RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(s->color().rgb());
1276         list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
1277     }
1278     return list.release();
1279 }
1280
1281 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const
1282 {
1283     return getPropertyCSSValue(propertyID, UpdateLayout);
1284 }
1285
1286 static int identifierForFamily(const AtomicString& family)
1287 {
1288     if (family == cursiveFamily)
1289         return CSSValueCursive;
1290     if (family == fantasyFamily)
1291         return CSSValueFantasy;
1292     if (family == monospaceFamily)
1293         return CSSValueMonospace;
1294     if (family == pictographFamily)
1295         return CSSValueWebkitPictograph;
1296     if (family == sansSerifFamily)
1297         return CSSValueSansSerif;
1298     if (family == serifFamily)
1299         return CSSValueSerif;
1300     return 0;
1301 }
1302
1303 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1304 {
1305     if (int familyIdentifier = identifierForFamily(family))
1306         return cssValuePool().createIdentifierValue(familyIdentifier);
1307     return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1308 }
1309
1310 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1311 {
1312     // Blink value is ignored.
1313     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1314     if (textDecoration & UNDERLINE)
1315         list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1316     if (textDecoration & OVERLINE)
1317         list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1318     if (textDecoration & LINE_THROUGH)
1319         list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1320
1321     if (!list->length())
1322         return cssValuePool().createIdentifierValue(CSSValueNone);
1323     return list;
1324 }
1325
1326 #if ENABLE(CSS3_TEXT)
1327 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1328 {
1329     switch (textDecorationStyle) {
1330     case TextDecorationStyleSolid:
1331         return cssValuePool().createIdentifierValue(CSSValueSolid);
1332     case TextDecorationStyleDouble:
1333         return cssValuePool().createIdentifierValue(CSSValueDouble);
1334     case TextDecorationStyleDotted:
1335         return cssValuePool().createIdentifierValue(CSSValueDotted);
1336     case TextDecorationStyleDashed:
1337         return cssValuePool().createIdentifierValue(CSSValueDashed);
1338     case TextDecorationStyleWavy:
1339         return cssValuePool().createIdentifierValue(CSSValueWavy);
1340     }
1341
1342     ASSERT_NOT_REACHED();
1343     return cssValuePool().createExplicitInitialValue();
1344 }
1345 #endif // CSS3_TEXT
1346
1347 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1348 {
1349     // For backwards compatibility, if both values are equal, just return one of them. And
1350     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1351     if (xRepeat == yRepeat)
1352         return cssValuePool().createValue(xRepeat);
1353     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1354         return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1355     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1356         return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1357
1358     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1359     list->append(cssValuePool().createValue(xRepeat));
1360     list->append(cssValuePool().createValue(yRepeat));
1361     return list.release();
1362 }
1363
1364 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1365 {
1366     if (fillSize.type == Contain)
1367         return cssValuePool().createIdentifierValue(CSSValueContain);
1368
1369     if (fillSize.type == Cover)
1370         return cssValuePool().createIdentifierValue(CSSValueCover);
1371
1372     if (fillSize.size.height().isAuto())
1373         return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1374
1375     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1376     list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1377     list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1378     return list.release();
1379 }
1380
1381 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1382 {
1383     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1384     for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1385         if (contentData->isCounter()) {
1386             const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1387             ASSERT(counter);
1388             list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1389         } else if (contentData->isImage()) {
1390             const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1391             ASSERT(image);
1392             list->append(image->cssValue());
1393         } else if (contentData->isText())
1394             list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1395     }
1396     if (!style->regionThread().isNull())
1397         list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1398     return list.release();
1399 }
1400
1401 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1402 {
1403     const CounterDirectiveMap* map = style->counterDirectives();
1404     if (!map)
1405         return 0;
1406
1407     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1408     for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1409         list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1410         short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1411         list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1412     }
1413     return list.release();
1414 }
1415
1416 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1417 {
1418     DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1419     if (!propertyIDSet.add(propertyID).isNewEntry)
1420         return;
1421
1422     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1423 }
1424
1425 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1426 {
1427     const FontFamily& firstFamily = style->fontDescription().family();
1428     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1429     for (const FontFamily* family = &firstFamily; family; family = family->next())
1430         list->append(valueForFamily(family->family()));
1431     return list.release();
1432 }
1433
1434 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1435 {
1436     Length length = style->lineHeight();
1437     if (length.isNegative())
1438         return cssValuePool().createIdentifierValue(CSSValueNormal);
1439     if (length.isPercent())
1440         // This is imperfect, because it doesn't include the zoom factor and the real computation
1441         // for how high to be in pixels does include things like minimum font size and the zoom factor.
1442         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1443         // that here either.
1444         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1445     return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style);
1446 }
1447
1448 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1449 {
1450     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1451 }
1452
1453 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1454 {
1455     if (style->fontDescription().italic())
1456         return cssValuePool().createIdentifierValue(CSSValueItalic);
1457     return cssValuePool().createIdentifierValue(CSSValueNormal);
1458 }
1459
1460 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1461 {
1462     if (style->fontDescription().smallCaps())
1463         return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1464     return cssValuePool().createIdentifierValue(CSSValueNormal);
1465 }
1466
1467 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1468 {
1469     switch (style->fontDescription().weight()) {
1470     case FontWeight100:
1471         return cssValuePool().createIdentifierValue(CSSValue100);
1472     case FontWeight200:
1473         return cssValuePool().createIdentifierValue(CSSValue200);
1474     case FontWeight300:
1475         return cssValuePool().createIdentifierValue(CSSValue300);
1476     case FontWeightNormal:
1477         return cssValuePool().createIdentifierValue(CSSValueNormal);
1478     case FontWeight500:
1479         return cssValuePool().createIdentifierValue(CSSValue500);
1480     case FontWeight600:
1481         return cssValuePool().createIdentifierValue(CSSValue600);
1482     case FontWeightBold:
1483         return cssValuePool().createIdentifierValue(CSSValueBold);
1484     case FontWeight800:
1485         return cssValuePool().createIdentifierValue(CSSValue800);
1486     case FontWeight900:
1487         return cssValuePool().createIdentifierValue(CSSValue900);
1488     }
1489     ASSERT_NOT_REACHED();
1490     return cssValuePool().createIdentifierValue(CSSValueNormal);
1491 }
1492
1493 static bool isLayoutDependentProperty(CSSPropertyID propertyID)
1494 {
1495     switch (propertyID) {
1496     case CSSPropertyWidth:
1497     case CSSPropertyHeight:
1498     case CSSPropertyMargin:
1499     case CSSPropertyMarginTop:
1500     case CSSPropertyMarginBottom:
1501     case CSSPropertyMarginLeft:
1502     case CSSPropertyMarginRight:
1503     case CSSPropertyPadding:
1504     case CSSPropertyPaddingTop:
1505     case CSSPropertyPaddingBottom:
1506     case CSSPropertyPaddingLeft:
1507     case CSSPropertyPaddingRight:
1508     case CSSPropertyWebkitPerspectiveOrigin:
1509     case CSSPropertyWebkitTransformOrigin:
1510     case CSSPropertyWebkitTransform:
1511 #if ENABLE(CSS_FILTERS)
1512     case CSSPropertyWebkitFilter:
1513 #endif
1514         return true;
1515     default:
1516         return false;
1517     }
1518 }
1519
1520 Node* CSSComputedStyleDeclaration::styledNode() const
1521 {
1522     if (!m_node)
1523         return 0;
1524     if (m_node->isElementNode()) {
1525         if (PseudoElement* element = toElement(m_node.get())->pseudoElement(m_pseudoElementSpecifier))
1526             return element;
1527     }
1528     return m_node.get();
1529 }
1530
1531 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1532 {
1533     Node* styledNode = this->styledNode();
1534     if (!styledNode)
1535         return 0;
1536
1537     if (updateLayout) {
1538         Document* document = styledNode->document();
1539         // FIXME: Some of these cases could be narrowed down or optimized better.
1540         bool forceFullLayout = isLayoutDependentProperty(propertyID)
1541             || styledNode->isInShadowTree()
1542             || (document->styleResolverIfExists() && document->styleResolverIfExists()->hasViewportDependentMediaQueries() && document->ownerElement())
1543             || document->seamlessParentIFrame();
1544
1545         if (forceFullLayout)
1546             document->updateLayoutIgnorePendingStylesheets();
1547         else {
1548             bool needsStyleRecalc = document->hasPendingForcedStyleRecalc();
1549             for (Node* n = styledNode; n && !needsStyleRecalc; n = n->parentNode())
1550                 needsStyleRecalc = n->needsStyleRecalc();
1551             if (needsStyleRecalc)
1552                 document->updateStyleIfNeeded();
1553         }
1554
1555         // The style recalc could have caused the styled node to be discarded or replaced
1556         // if it was a PseudoElement so we need to update it.
1557         styledNode = this->styledNode();
1558     }
1559
1560     RenderObject* renderer = styledNode->renderer();
1561
1562     RefPtr<RenderStyle> style;
1563     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1564         AnimationUpdateBlock animationUpdateBlock(renderer->animation());
1565         style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
1566         if (m_pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1567             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1568             style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
1569         }
1570     } else
1571         style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
1572
1573     if (!style)
1574         return 0;
1575
1576     propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1577
1578     switch (propertyID) {
1579         case CSSPropertyInvalid:
1580 #if ENABLE(CSS_VARIABLES)
1581         case CSSPropertyVariable:
1582 #endif
1583             break;
1584
1585         case CSSPropertyBackgroundColor:
1586             return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1587         case CSSPropertyBackgroundImage:
1588         case CSSPropertyWebkitMaskImage: {
1589             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1590             if (!layers)
1591                 return cssValuePool().createIdentifierValue(CSSValueNone);
1592
1593             if (!layers->next()) {
1594                 if (layers->image())
1595                     return layers->image()->cssValue();
1596
1597                 return cssValuePool().createIdentifierValue(CSSValueNone);
1598             }
1599
1600             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1601             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1602                 if (currLayer->image())
1603                     list->append(currLayer->image()->cssValue());
1604                 else
1605                     list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1606             }
1607             return list.release();
1608         }
1609         case CSSPropertyBackgroundSize:
1610         case CSSPropertyWebkitBackgroundSize:
1611         case CSSPropertyWebkitMaskSize: {
1612             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1613             if (!layers->next())
1614                 return fillSizeToCSSValue(layers->size(), style.get());
1615
1616             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1617             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1618                 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1619
1620             return list.release();
1621         }
1622         case CSSPropertyBackgroundRepeat:
1623         case CSSPropertyWebkitMaskRepeat: {
1624             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1625             if (!layers->next())
1626                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1627
1628             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1629             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1630                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1631
1632             return list.release();
1633         }
1634         case CSSPropertyWebkitBackgroundComposite:
1635         case CSSPropertyWebkitMaskComposite: {
1636             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1637             if (!layers->next())
1638                 return cssValuePool().createValue(layers->composite());
1639
1640             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1641             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1642                 list->append(cssValuePool().createValue(currLayer->composite()));
1643
1644             return list.release();
1645         }
1646         case CSSPropertyBackgroundAttachment: {
1647             const FillLayer* layers = style->backgroundLayers();
1648             if (!layers->next())
1649                 return cssValuePool().createValue(layers->attachment());
1650
1651             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1652             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1653                 list->append(cssValuePool().createValue(currLayer->attachment()));
1654
1655             return list.release();
1656         }
1657         case CSSPropertyBackgroundClip:
1658         case CSSPropertyBackgroundOrigin:
1659         case CSSPropertyWebkitBackgroundClip:
1660         case CSSPropertyWebkitBackgroundOrigin:
1661         case CSSPropertyWebkitMaskClip:
1662         case CSSPropertyWebkitMaskOrigin: {
1663             const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1664             bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1665             if (!layers->next()) {
1666                 EFillBox box = isClip ? layers->clip() : layers->origin();
1667                 return cssValuePool().createValue(box);
1668             }
1669
1670             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1671             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1672                 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1673                 list->append(cssValuePool().createValue(box));
1674             }
1675
1676             return list.release();
1677         }
1678         case CSSPropertyBackgroundPosition:
1679         case CSSPropertyWebkitMaskPosition: {
1680             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1681             if (!layers->next())
1682                 return createPositionListForLayer(propertyID, layers, style.get());
1683
1684             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1685             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1686                 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1687             return list.release();
1688         }
1689         case CSSPropertyBackgroundPositionX:
1690         case CSSPropertyWebkitMaskPositionX: {
1691             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1692             if (!layers->next())
1693                 return cssValuePool().createValue(layers->xPosition());
1694
1695             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1696             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1697                 list->append(cssValuePool().createValue(currLayer->xPosition()));
1698
1699             return list.release();
1700         }
1701         case CSSPropertyBackgroundPositionY:
1702         case CSSPropertyWebkitMaskPositionY: {
1703             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1704             if (!layers->next())
1705                 return cssValuePool().createValue(layers->yPosition());
1706
1707             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1708             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1709                 list->append(cssValuePool().createValue(currLayer->yPosition()));
1710
1711             return list.release();
1712         }
1713         case CSSPropertyBorderCollapse:
1714             if (style->borderCollapse())
1715                 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1716             return cssValuePool().createIdentifierValue(CSSValueSeparate);
1717         case CSSPropertyBorderSpacing: {
1718             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1719             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1720             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1721             return list.release();
1722         }
1723         case CSSPropertyWebkitBorderHorizontalSpacing:
1724             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1725         case CSSPropertyWebkitBorderVerticalSpacing:
1726             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1727         case CSSPropertyBorderImageSource:
1728             if (style->borderImageSource())
1729                 return style->borderImageSource()->cssValue();
1730             return cssValuePool().createIdentifierValue(CSSValueNone);
1731         case CSSPropertyBorderTopColor:
1732             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1733         case CSSPropertyBorderRightColor:
1734             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1735         case CSSPropertyBorderBottomColor:
1736             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1737         case CSSPropertyBorderLeftColor:
1738             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1739         case CSSPropertyBorderTopStyle:
1740             return cssValuePool().createValue(style->borderTopStyle());
1741         case CSSPropertyBorderRightStyle:
1742             return cssValuePool().createValue(style->borderRightStyle());
1743         case CSSPropertyBorderBottomStyle:
1744             return cssValuePool().createValue(style->borderBottomStyle());
1745         case CSSPropertyBorderLeftStyle:
1746             return cssValuePool().createValue(style->borderLeftStyle());
1747         case CSSPropertyBorderTopWidth:
1748             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1749         case CSSPropertyBorderRightWidth:
1750             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1751         case CSSPropertyBorderBottomWidth:
1752             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1753         case CSSPropertyBorderLeftWidth:
1754             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1755         case CSSPropertyBottom:
1756             return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document()->renderView());
1757         case CSSPropertyWebkitBoxAlign:
1758             return cssValuePool().createValue(style->boxAlign());
1759 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1760         case CSSPropertyWebkitBoxDecorationBreak:
1761             if (style->boxDecorationBreak() == DSLICE)
1762                 return cssValuePool().createIdentifierValue(CSSValueSlice);
1763         return cssValuePool().createIdentifierValue(CSSValueClone);
1764 #endif
1765         case CSSPropertyWebkitBoxDirection:
1766             return cssValuePool().createValue(style->boxDirection());
1767         case CSSPropertyWebkitBoxFlex:
1768             return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1769         case CSSPropertyWebkitBoxFlexGroup:
1770             return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1771         case CSSPropertyWebkitBoxLines:
1772             return cssValuePool().createValue(style->boxLines());
1773         case CSSPropertyWebkitBoxOrdinalGroup:
1774             return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1775         case CSSPropertyWebkitBoxOrient:
1776             return cssValuePool().createValue(style->boxOrient());
1777         case CSSPropertyWebkitBoxPack:
1778             return cssValuePool().createValue(style->boxPack());
1779         case CSSPropertyWebkitBoxReflect:
1780             return valueForReflection(style->boxReflect(), style.get());
1781         case CSSPropertyBoxShadow:
1782         case CSSPropertyWebkitBoxShadow:
1783             return valueForShadow(style->boxShadow(), propertyID, style.get());
1784         case CSSPropertyCaptionSide:
1785             return cssValuePool().createValue(style->captionSide());
1786         case CSSPropertyClear:
1787             return cssValuePool().createValue(style->clear());
1788         case CSSPropertyColor:
1789             return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1790         case CSSPropertyWebkitPrintColorAdjust:
1791             return cssValuePool().createValue(style->printColorAdjust());
1792         case CSSPropertyWebkitColumnAxis:
1793             return cssValuePool().createValue(style->columnAxis());
1794         case CSSPropertyWebkitColumnCount:
1795             if (style->hasAutoColumnCount())
1796                 return cssValuePool().createIdentifierValue(CSSValueAuto);
1797             return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
1798         case CSSPropertyWebkitColumnGap:
1799             if (style->hasNormalColumnGap())
1800                 return cssValuePool().createIdentifierValue(CSSValueNormal);
1801             return zoomAdjustedPixelValue(style->columnGap(), style.get());
1802         case CSSPropertyWebkitColumnProgression:
1803             return cssValuePool().createValue(style->columnProgression());
1804         case CSSPropertyWebkitColumnRuleColor:
1805             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
1806         case CSSPropertyWebkitColumnRuleStyle:
1807             return cssValuePool().createValue(style->columnRuleStyle());
1808         case CSSPropertyWebkitColumnRuleWidth:
1809             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
1810         case CSSPropertyWebkitColumnSpan:
1811             return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
1812         case CSSPropertyWebkitColumnBreakAfter:
1813             return cssValuePool().createValue(style->columnBreakAfter());
1814         case CSSPropertyWebkitColumnBreakBefore:
1815             return cssValuePool().createValue(style->columnBreakBefore());
1816         case CSSPropertyWebkitColumnBreakInside:
1817             return cssValuePool().createValue(style->columnBreakInside());
1818         case CSSPropertyWebkitColumnWidth:
1819             if (style->hasAutoColumnWidth())
1820                 return cssValuePool().createIdentifierValue(CSSValueAuto);
1821             return zoomAdjustedPixelValue(style->columnWidth(), style.get());
1822         case CSSPropertyTabSize:
1823             return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
1824 #if ENABLE(CSS_REGIONS)
1825         case CSSPropertyWebkitRegionBreakAfter:
1826             return cssValuePool().createValue(style->regionBreakAfter());
1827         case CSSPropertyWebkitRegionBreakBefore:
1828             return cssValuePool().createValue(style->regionBreakBefore());
1829         case CSSPropertyWebkitRegionBreakInside:
1830             return cssValuePool().createValue(style->regionBreakInside());
1831 #endif
1832         case CSSPropertyCursor: {
1833             RefPtr<CSSValueList> list;
1834             CursorList* cursors = style->cursors();
1835             if (cursors && cursors->size() > 0) {
1836                 list = CSSValueList::createCommaSeparated();
1837                 for (unsigned i = 0; i < cursors->size(); ++i)
1838                     if (StyleImage* image = cursors->at(i).image())
1839                         list->append(image->cssValue());
1840             }
1841             RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
1842             if (list) {
1843                 list->append(value);
1844                 return list.release();
1845             }
1846             return value.release();
1847         }
1848         case CSSPropertyDirection:
1849             return cssValuePool().createValue(style->direction());
1850         case CSSPropertyDisplay:
1851             return cssValuePool().createValue(style->display());
1852         case CSSPropertyEmptyCells:
1853             return cssValuePool().createValue(style->emptyCells());
1854         case CSSPropertyWebkitAlignContent:
1855             return cssValuePool().createValue(style->alignContent());
1856         case CSSPropertyWebkitAlignItems:
1857             return cssValuePool().createValue(style->alignItems());
1858         case CSSPropertyWebkitAlignSelf:
1859             if (style->alignSelf() == AlignAuto) {
1860                 Node* parent = styledNode->parentNode();
1861                 if (parent && parent->computedStyle())
1862                     return cssValuePool().createValue(parent->computedStyle()->alignItems());
1863                 return cssValuePool().createValue(AlignStretch);
1864             }
1865             return cssValuePool().createValue(style->alignSelf());
1866         case CSSPropertyWebkitFlex:
1867             return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
1868         case CSSPropertyWebkitFlexBasis:
1869             return cssValuePool().createValue(style->flexBasis());
1870         case CSSPropertyWebkitFlexDirection:
1871             return cssValuePool().createValue(style->flexDirection());
1872         case CSSPropertyWebkitFlexFlow:
1873             return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
1874         case CSSPropertyWebkitFlexGrow:
1875             return cssValuePool().createValue(style->flexGrow());
1876         case CSSPropertyWebkitFlexShrink:
1877             return cssValuePool().createValue(style->flexShrink());
1878         case CSSPropertyWebkitFlexWrap:
1879             return cssValuePool().createValue(style->flexWrap());
1880         case CSSPropertyWebkitJustifyContent:
1881             return cssValuePool().createValue(style->justifyContent());
1882         case CSSPropertyWebkitOrder:
1883             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
1884         case CSSPropertyFloat:
1885             if (style->display() != NONE && style->hasOutOfFlowPosition())
1886                 return cssValuePool().createIdentifierValue(CSSValueNone);
1887             return cssValuePool().createValue(style->floating());
1888         case CSSPropertyFont: {
1889             RefPtr<FontValue> computedFont = FontValue::create();
1890             computedFont->style = fontStyleFromStyle(style.get());
1891             computedFont->variant = fontVariantFromStyle(style.get());
1892             computedFont->weight = fontWeightFromStyle(style.get());
1893             computedFont->size = fontSizeFromStyle(style.get());
1894             computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document()->renderView());
1895             computedFont->family = fontFamilyFromStyle(style.get());
1896             return computedFont.release();
1897         }
1898         case CSSPropertyFontFamily: {
1899             RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
1900             // If there's only a single family, return that as a CSSPrimitiveValue.
1901             // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
1902             if (fontFamilyList->length() == 1)
1903                 return fontFamilyList->item(0);
1904             return fontFamilyList.release();
1905         }
1906         case CSSPropertyFontSize:
1907             return fontSizeFromStyle(style.get());
1908         case CSSPropertyFontStyle:
1909             return fontStyleFromStyle(style.get());
1910         case CSSPropertyFontVariant:
1911             return fontVariantFromStyle(style.get());
1912         case CSSPropertyFontWeight:
1913             return fontWeightFromStyle(style.get());
1914         case CSSPropertyWebkitFontFeatureSettings: {
1915             const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
1916             if (!featureSettings || !featureSettings->size())
1917                 return cssValuePool().createIdentifierValue(CSSValueNormal);
1918             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1919             for (unsigned i = 0; i < featureSettings->size(); ++i) {
1920                 const FontFeature& feature = featureSettings->at(i);
1921                 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create(feature.tag(), feature.value());
1922                 list->append(featureValue.release());
1923             }
1924             return list.release();
1925         }
1926         case CSSPropertyWebkitGridAutoFlow:
1927             return cssValuePool().createValue(style->gridAutoFlow());
1928         case CSSPropertyWebkitGridColumns:
1929             return valueForGridTrackList(style->gridColumns(), style.get(), m_node->document()->renderView());
1930         case CSSPropertyWebkitGridRows:
1931             return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
1932
1933         case CSSPropertyWebkitGridColumn:
1934             return valueForGridPositions(style->gridItemColumn());
1935         case CSSPropertyWebkitGridRow:
1936             return valueForGridPositions(style->gridItemRow());
1937
1938         case CSSPropertyHeight:
1939             if (renderer) {
1940                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
1941                 // the "height" property does not apply for non-replaced inline elements.
1942                 if (!renderer->isReplaced() && renderer->isInline())
1943                     return cssValuePool().createIdentifierValue(CSSValueAuto);
1944                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
1945             }
1946             return zoomAdjustedPixelValueForLength(style->height(), style.get());
1947         case CSSPropertyWebkitHighlight:
1948             if (style->highlight() == nullAtom)
1949                 return cssValuePool().createIdentifierValue(CSSValueNone);
1950             return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
1951         case CSSPropertyWebkitHyphens:
1952             return cssValuePool().createValue(style->hyphens());
1953         case CSSPropertyWebkitHyphenateCharacter:
1954             if (style->hyphenationString().isNull())
1955                 return cssValuePool().createIdentifierValue(CSSValueAuto);
1956             return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
1957         case CSSPropertyWebkitHyphenateLimitAfter:
1958             if (style->hyphenationLimitAfter() < 0)
1959                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1960             return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
1961         case CSSPropertyWebkitHyphenateLimitBefore:
1962             if (style->hyphenationLimitBefore() < 0)
1963                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1964             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
1965         case CSSPropertyWebkitHyphenateLimitLines:
1966             if (style->hyphenationLimitLines() < 0)
1967                 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
1968             return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
1969         case CSSPropertyWebkitBorderFit:
1970             if (style->borderFit() == BorderFitBorder)
1971                 return cssValuePool().createIdentifierValue(CSSValueBorder);
1972             return cssValuePool().createIdentifierValue(CSSValueLines);
1973 #if ENABLE(CSS_IMAGE_ORIENTATION)
1974         case CSSPropertyImageOrientation:
1975             return cssValuePool().createValue(style->imageOrientation());
1976 #endif
1977         case CSSPropertyImageRendering:
1978             return CSSPrimitiveValue::create(style->imageRendering());
1979 #if ENABLE(CSS_IMAGE_RESOLUTION)
1980         case CSSPropertyImageResolution:
1981             return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
1982 #endif
1983         case CSSPropertyLeft:
1984             return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document()->renderView());
1985         case CSSPropertyLetterSpacing:
1986             if (!style->letterSpacing())
1987                 return cssValuePool().createIdentifierValue(CSSValueNormal);
1988             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
1989         case CSSPropertyWebkitLineClamp:
1990             if (style->lineClamp().isNone())
1991                 return cssValuePool().createIdentifierValue(CSSValueNone);
1992             return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
1993         case CSSPropertyLineHeight:
1994             return lineHeightFromStyle(style.get(), m_node->document()->renderView());
1995         case CSSPropertyListStyleImage:
1996             if (style->listStyleImage())
1997                 return style->listStyleImage()->cssValue();
1998             return cssValuePool().createIdentifierValue(CSSValueNone);
1999         case CSSPropertyListStylePosition:
2000             return cssValuePool().createValue(style->listStylePosition());
2001         case CSSPropertyListStyleType:
2002             return cssValuePool().createValue(style->listStyleType());
2003         case CSSPropertyWebkitLocale:
2004             if (style->locale().isNull())
2005                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2006             return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2007         case CSSPropertyMarginTop: {
2008             Length marginTop = style->marginTop();
2009             if (marginTop.isFixed() || !renderer || !renderer->isBox())
2010                 return zoomAdjustedPixelValueForLength(marginTop, style.get());
2011             return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), style.get());
2012         }
2013         case CSSPropertyMarginRight: {
2014             Length marginRight = style->marginRight();
2015             if (marginRight.isFixed() || !renderer || !renderer->isBox())
2016                 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2017             float value;
2018             if (marginRight.isPercent() || marginRight.isViewportPercentage())
2019                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2020                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2021                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2022                 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document()->renderView());
2023             else
2024                 value = toRenderBox(renderer)->marginRight();
2025             return zoomAdjustedPixelValue(value, style.get());
2026         }
2027         case CSSPropertyMarginBottom: {
2028             Length marginBottom = style->marginBottom();
2029             if (marginBottom.isFixed() || !renderer || !renderer->isBox())
2030                 return zoomAdjustedPixelValueForLength(marginBottom, style.get());
2031             return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), style.get());
2032         }
2033         case CSSPropertyMarginLeft: {
2034             Length marginLeft = style->marginLeft();
2035             if (marginLeft.isFixed() || !renderer || !renderer->isBox())
2036                 return zoomAdjustedPixelValueForLength(marginLeft, style.get());
2037             return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), style.get());
2038         }
2039         case CSSPropertyWebkitMarqueeDirection:
2040             return cssValuePool().createValue(style->marqueeDirection());
2041         case CSSPropertyWebkitMarqueeIncrement:
2042             return cssValuePool().createValue(style->marqueeIncrement());
2043         case CSSPropertyWebkitMarqueeRepetition:
2044             if (style->marqueeLoopCount() < 0)
2045                 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2046             return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2047         case CSSPropertyWebkitMarqueeStyle:
2048             return cssValuePool().createValue(style->marqueeBehavior());
2049         case CSSPropertyWebkitUserModify:
2050             return cssValuePool().createValue(style->userModify());
2051         case CSSPropertyMaxHeight: {
2052             const Length& maxHeight = style->maxHeight();
2053             if (maxHeight.isUndefined())
2054                 return cssValuePool().createIdentifierValue(CSSValueNone);
2055             return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2056         }
2057         case CSSPropertyMaxWidth: {
2058             const Length& maxWidth = style->maxWidth();
2059             if (maxWidth.isUndefined())
2060                 return cssValuePool().createIdentifierValue(CSSValueNone);
2061             return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2062         }
2063         case CSSPropertyMinHeight:
2064             // FIXME: For flex-items, min-height:auto should compute to min-content.
2065             if (style->minHeight().isAuto())
2066                 return zoomAdjustedPixelValue(0, style.get());
2067             return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2068         case CSSPropertyMinWidth:
2069             // FIXME: For flex-items, min-width:auto should compute to min-content.
2070             if (style->minWidth().isAuto())
2071                 return zoomAdjustedPixelValue(0, style.get());
2072             return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2073         case CSSPropertyOpacity:
2074             return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2075         case CSSPropertyOrphans:
2076             if (style->hasAutoOrphans())
2077                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2078             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2079         case CSSPropertyOutlineColor:
2080             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2081         case CSSPropertyOutlineOffset:
2082             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2083         case CSSPropertyOutlineStyle:
2084             if (style->outlineStyleIsAuto())
2085                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2086             return cssValuePool().createValue(style->outlineStyle());
2087         case CSSPropertyOutlineWidth:
2088             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2089         case CSSPropertyOverflow:
2090             return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
2091         case CSSPropertyOverflowWrap:
2092             return cssValuePool().createValue(style->overflowWrap());
2093         case CSSPropertyOverflowX:
2094             return cssValuePool().createValue(style->overflowX());
2095         case CSSPropertyOverflowY:
2096             return cssValuePool().createValue(style->overflowY());
2097         case CSSPropertyPaddingTop:
2098             if (renderer && renderer->isBox())
2099                 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), style.get());
2100             return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get());
2101         case CSSPropertyPaddingRight:
2102             if (renderer && renderer->isBox())
2103                 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), style.get());
2104             return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get());
2105         case CSSPropertyPaddingBottom:
2106             if (renderer && renderer->isBox())
2107                 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), style.get());
2108             return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get());
2109         case CSSPropertyPaddingLeft:
2110             if (renderer && renderer->isBox())
2111                 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), style.get());
2112             return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get());
2113         case CSSPropertyPageBreakAfter:
2114             return cssValuePool().createValue(style->pageBreakAfter());
2115         case CSSPropertyPageBreakBefore:
2116             return cssValuePool().createValue(style->pageBreakBefore());
2117         case CSSPropertyPageBreakInside: {
2118             EPageBreak pageBreak = style->pageBreakInside();
2119             ASSERT(pageBreak != PBALWAYS);
2120             if (pageBreak == PBALWAYS)
2121                 return 0;
2122             return cssValuePool().createValue(style->pageBreakInside());
2123         }
2124         case CSSPropertyPosition:
2125             return cssValuePool().createValue(style->position());
2126         case CSSPropertyRight:
2127             return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document()->renderView());
2128         case CSSPropertyWebkitRubyPosition:
2129             return cssValuePool().createValue(style->rubyPosition());
2130         case CSSPropertyTableLayout:
2131             return cssValuePool().createValue(style->tableLayout());
2132         case CSSPropertyTextAlign:
2133             return cssValuePool().createValue(style->textAlign());
2134         case CSSPropertyTextDecoration:
2135             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2136 #if ENABLE(CSS3_TEXT)
2137         case CSSPropertyWebkitTextDecorationLine:
2138             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2139         case CSSPropertyWebkitTextDecorationStyle:
2140             return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2141         case CSSPropertyWebkitTextAlignLast:
2142             return cssValuePool().createValue(style->textAlignLast());
2143 #endif // CSS3_TEXT
2144         case CSSPropertyWebkitTextDecorationsInEffect:
2145             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2146         case CSSPropertyWebkitTextFillColor:
2147             return currentColorOrValidColor(style.get(), style->textFillColor());
2148         case CSSPropertyWebkitTextEmphasisColor:
2149             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2150         case CSSPropertyWebkitTextEmphasisPosition:
2151             return cssValuePool().createValue(style->textEmphasisPosition());
2152         case CSSPropertyWebkitTextEmphasisStyle:
2153             switch (style->textEmphasisMark()) {
2154             case TextEmphasisMarkNone:
2155                 return cssValuePool().createIdentifierValue(CSSValueNone);
2156             case TextEmphasisMarkCustom:
2157                 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2158             case TextEmphasisMarkAuto:
2159                 ASSERT_NOT_REACHED();
2160                 // Fall through
2161             case TextEmphasisMarkDot:
2162             case TextEmphasisMarkCircle:
2163             case TextEmphasisMarkDoubleCircle:
2164             case TextEmphasisMarkTriangle:
2165             case TextEmphasisMarkSesame: {
2166                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2167                 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2168                 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2169                 return list.release();
2170             }
2171             }
2172         case CSSPropertyTextIndent:
2173             return zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2174         case CSSPropertyTextShadow:
2175             return valueForShadow(style->textShadow(), propertyID, style.get());
2176         case CSSPropertyTextRendering:
2177             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2178         case CSSPropertyTextOverflow:
2179             if (style->textOverflow())
2180                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2181             return cssValuePool().createIdentifierValue(CSSValueClip);
2182         case CSSPropertyWebkitTextSecurity:
2183             return cssValuePool().createValue(style->textSecurity());
2184         case CSSPropertyWebkitTextSizeAdjust:
2185             if (style->textSizeAdjust())
2186                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2187             return cssValuePool().createIdentifierValue(CSSValueNone);
2188         case CSSPropertyWebkitTextStrokeColor:
2189             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2190         case CSSPropertyWebkitTextStrokeWidth:
2191             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2192         case CSSPropertyTextTransform:
2193             return cssValuePool().createValue(style->textTransform());
2194         case CSSPropertyTop:
2195             return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document()->renderView());
2196         case CSSPropertyUnicodeBidi:
2197             return cssValuePool().createValue(style->unicodeBidi());
2198         case CSSPropertyVerticalAlign:
2199             switch (style->verticalAlign()) {
2200                 case BASELINE:
2201                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2202                 case MIDDLE:
2203                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2204                 case SUB:
2205                     return cssValuePool().createIdentifierValue(CSSValueSub);
2206                 case SUPER:
2207                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2208                 case TEXT_TOP:
2209                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2210                 case TEXT_BOTTOM:
2211                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2212                 case TOP:
2213                     return cssValuePool().createIdentifierValue(CSSValueTop);
2214                 case BOTTOM:
2215                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2216                 case BASELINE_MIDDLE:
2217                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2218                 case LENGTH:
2219                     return cssValuePool().createValue(style->verticalAlignLength());
2220             }
2221             ASSERT_NOT_REACHED();
2222             return 0;
2223         case CSSPropertyVisibility:
2224             return cssValuePool().createValue(style->visibility());
2225         case CSSPropertyWhiteSpace:
2226             return cssValuePool().createValue(style->whiteSpace());
2227         case CSSPropertyWidows:
2228             if (style->hasAutoWidows())
2229                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2230             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2231         case CSSPropertyWidth:
2232             if (renderer) {
2233                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2234                 // the "width" property does not apply for non-replaced inline elements.
2235                 if (!renderer->isReplaced() && renderer->isInline())
2236                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2237                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2238             }
2239             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2240         case CSSPropertyWordBreak:
2241             return cssValuePool().createValue(style->wordBreak());
2242         case CSSPropertyWordSpacing:
2243             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2244         case CSSPropertyWordWrap:
2245             return cssValuePool().createValue(style->overflowWrap());
2246         case CSSPropertyWebkitLineBreak:
2247             return cssValuePool().createValue(style->lineBreak());
2248         case CSSPropertyWebkitNbspMode:
2249             return cssValuePool().createValue(style->nbspMode());
2250         case CSSPropertyResize:
2251             return cssValuePool().createValue(style->resize());
2252         case CSSPropertyWebkitFontKerning:
2253             return cssValuePool().createValue(style->fontDescription().kerning());
2254         case CSSPropertyWebkitFontSmoothing:
2255             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2256         case CSSPropertyWebkitFontVariantLigatures: {
2257             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2258             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2259             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2260             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2261                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2262                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2263
2264             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2265             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2266                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2267             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2268                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2269             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2270                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2271             return valueList;
2272         }
2273         case CSSPropertyZIndex:
2274             if (style->hasAutoZIndex())
2275                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2276             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2277         case CSSPropertyZoom:
2278             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2279         case CSSPropertyBoxSizing:
2280             if (style->boxSizing() == CONTENT_BOX)
2281                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2282             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2283 #if ENABLE(DASHBOARD_SUPPORT)
2284         case CSSPropertyWebkitDashboardRegion:
2285         {
2286             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2287             unsigned count = regions.size();
2288             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2289                 return cssValuePool().createIdentifierValue(CSSValueNone);
2290
2291             RefPtr<DashboardRegion> firstRegion;
2292             DashboardRegion* previousRegion = 0;
2293             for (unsigned i = 0; i < count; i++) {
2294                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2295                 StyleDashboardRegion styleRegion = regions[i];
2296
2297                 region->m_label = styleRegion.label;
2298                 LengthBox offset = styleRegion.offset;
2299                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2300                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2301                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2302                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2303                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2304                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2305
2306                 if (previousRegion)
2307                     previousRegion->m_next = region;
2308                 else
2309                     firstRegion = region;
2310                 previousRegion = region.get();
2311             }
2312             return cssValuePool().createValue(firstRegion.release());
2313         }
2314 #endif
2315 #if ENABLE(DRAGGABLE_REGION)
2316         case CSSPropertyWebkitAppRegion:
2317             return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2318 #endif
2319         case CSSPropertyWebkitAnimationDelay:
2320             return getDelayValue(style->animations());
2321         case CSSPropertyWebkitAnimationDirection: {
2322             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2323             const AnimationList* t = style->animations();
2324             if (t) {
2325                 for (size_t i = 0; i < t->size(); ++i) {
2326                     if (t->animation(i)->direction())
2327                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2328                     else
2329                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2330                 }
2331             } else
2332                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2333             return list.release();
2334         }
2335         case CSSPropertyWebkitAnimationDuration:
2336             return getDurationValue(style->animations());
2337         case CSSPropertyWebkitAnimationFillMode: {
2338             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2339             const AnimationList* t = style->animations();
2340             if (t) {
2341                 for (size_t i = 0; i < t->size(); ++i) {
2342                     switch (t->animation(i)->fillMode()) {
2343                     case AnimationFillModeNone:
2344                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2345                         break;
2346                     case AnimationFillModeForwards:
2347                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2348                         break;
2349                     case AnimationFillModeBackwards:
2350                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2351                         break;
2352                     case AnimationFillModeBoth:
2353                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2354                         break;
2355                     }
2356                 }
2357             } else
2358                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2359             return list.release();
2360         }
2361         case CSSPropertyWebkitAnimationIterationCount: {
2362             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2363             const AnimationList* t = style->animations();
2364             if (t) {
2365                 for (size_t i = 0; i < t->size(); ++i) {
2366                     double iterationCount = t->animation(i)->iterationCount();
2367                     if (iterationCount == Animation::IterationCountInfinite)
2368                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2369                     else
2370                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2371                 }
2372             } else
2373                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2374             return list.release();
2375         }
2376         case CSSPropertyWebkitAnimationName: {
2377             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2378             const AnimationList* t = style->animations();
2379             if (t) {
2380                 for (size_t i = 0; i < t->size(); ++i)
2381                     list->append(cssValuePool().createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
2382             } else
2383                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2384             return list.release();
2385         }
2386         case CSSPropertyWebkitAnimationPlayState: {
2387             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2388             const AnimationList* t = style->animations();
2389             if (t) {
2390                 for (size_t i = 0; i < t->size(); ++i) {
2391                     int prop = t->animation(i)->playState();
2392                     if (prop == AnimPlayStatePlaying)
2393                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2394                     else
2395                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2396                 }
2397             } else
2398                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2399             return list.release();
2400         }
2401         case CSSPropertyWebkitAnimationTimingFunction:
2402             return getTimingFunctionValue(style->animations());
2403         case CSSPropertyWebkitAppearance:
2404             return cssValuePool().createValue(style->appearance());
2405         case CSSPropertyWebkitAspectRatio:
2406             if (!style->hasAspectRatio())
2407                 return cssValuePool().createIdentifierValue(CSSValueNone);
2408             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2409         case CSSPropertyWebkitBackfaceVisibility:
2410             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2411         case CSSPropertyWebkitBorderImage:
2412             return valueForNinePieceImage(style->borderImage());
2413         case CSSPropertyBorderImageOutset:
2414             return valueForNinePieceImageQuad(style->borderImage().outset());
2415         case CSSPropertyBorderImageRepeat:
2416             return valueForNinePieceImageRepeat(style->borderImage());
2417         case CSSPropertyBorderImageSlice:
2418             return valueForNinePieceImageSlice(style->borderImage());
2419         case CSSPropertyBorderImageWidth:
2420             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2421         case CSSPropertyWebkitMaskBoxImage:
2422             return valueForNinePieceImage(style->maskBoxImage());
2423         case CSSPropertyWebkitMaskBoxImageOutset:
2424             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2425         case CSSPropertyWebkitMaskBoxImageRepeat:
2426             return valueForNinePieceImageRepeat(style->maskBoxImage());
2427         case CSSPropertyWebkitMaskBoxImageSlice:
2428             return valueForNinePieceImageSlice(style->maskBoxImage());
2429         case CSSPropertyWebkitMaskBoxImageWidth:
2430             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2431         case CSSPropertyWebkitMaskBoxImageSource:
2432             if (style->maskBoxImageSource())
2433                 return style->maskBoxImageSource()->cssValue();
2434             return cssValuePool().createIdentifierValue(CSSValueNone);
2435         case CSSPropertyWebkitFontSizeDelta:
2436             // Not a real style property -- used by the editing engine -- so has no computed value.
2437             break;
2438         case CSSPropertyWebkitMarginBottomCollapse:
2439         case CSSPropertyWebkitMarginAfterCollapse:
2440             return cssValuePool().createValue(style->marginAfterCollapse());
2441         case CSSPropertyWebkitMarginTopCollapse:
2442         case CSSPropertyWebkitMarginBeforeCollapse:
2443             return cssValuePool().createValue(style->marginBeforeCollapse());
2444 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2445         case CSSPropertyWebkitOverflowScrolling:
2446             if (!style->useTouchOverflowScrolling())
2447                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2448             return cssValuePool().createIdentifierValue(CSSValueTouch);
2449 #endif
2450         case CSSPropertyWebkitPerspective:
2451             if (!style->hasPerspective())
2452                 return cssValuePool().createIdentifierValue(CSSValueNone);
2453             return zoomAdjustedPixelValue(style->perspective(), style.get());
2454         case CSSPropertyWebkitPerspectiveOrigin: {
2455             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2456             if (renderer) {
2457                 LayoutRect box;
2458                 if (renderer->isBox())
2459                     box = toRenderBox(renderer)->borderBoxRect();
2460
2461                 RenderView* renderView = m_node->document()->renderView();
2462                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2463                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2464             }
2465             else {
2466                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2467                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2468
2469             }
2470             return list.release();
2471         }
2472         case CSSPropertyWebkitRtlOrdering:
2473             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2474 #if ENABLE(TOUCH_EVENTS)
2475         case CSSPropertyWebkitTapHighlightColor:
2476             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2477 #endif
2478         case CSSPropertyWebkitUserDrag:
2479             return cssValuePool().createValue(style->userDrag());
2480         case CSSPropertyWebkitUserSelect:
2481             return cssValuePool().createValue(style->userSelect());
2482         case CSSPropertyBorderBottomLeftRadius:
2483             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document()->renderView());
2484         case CSSPropertyBorderBottomRightRadius:
2485             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document()->renderView());
2486         case CSSPropertyBorderTopLeftRadius:
2487             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document()->renderView());
2488         case CSSPropertyBorderTopRightRadius:
2489             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document()->renderView());
2490         case CSSPropertyClip: {
2491             if (!style->hasClip())
2492                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2493             RefPtr<Rect> rect = Rect::create();
2494             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2495             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2496             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2497             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2498             return cssValuePool().createValue(rect.release());
2499         }
2500         case CSSPropertySpeak:
2501             return cssValuePool().createValue(style->speak());
2502         case CSSPropertyWebkitTransform:
2503             return computedTransform(renderer, style.get());
2504         case CSSPropertyWebkitTransformOrigin: {
2505             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2506             if (renderer) {
2507                 LayoutRect box;
2508                 if (renderer->isBox())
2509                     box = toRenderBox(renderer)->borderBoxRect();
2510
2511                 RenderView* renderView = m_node->document()->renderView();
2512                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2513                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2514                 if (style->transformOriginZ() != 0)
2515                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2516             } else {
2517                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2518                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2519                 if (style->transformOriginZ() != 0)
2520                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2521             }
2522             return list.release();
2523         }
2524         case CSSPropertyWebkitTransformStyle:
2525             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2526         case CSSPropertyWebkitTransitionDelay:
2527             return getDelayValue(style->transitions());
2528         case CSSPropertyWebkitTransitionDuration:
2529             return getDurationValue(style->transitions());
2530         case CSSPropertyWebkitTransitionProperty:
2531             return getTransitionPropertyValue(style->transitions());
2532         case CSSPropertyWebkitTransitionTimingFunction:
2533             return getTimingFunctionValue(style->transitions());
2534         case CSSPropertyWebkitTransition: {
2535             const AnimationList* animList = style->transitions();
2536             if (animList) {
2537                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2538                 for (size_t i = 0; i < animList->size(); ++i) {
2539                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2540                     const Animation* animation = animList->animation(i);
2541                     list->append(createTransitionPropertyValue(animation));
2542                     list->append(cssValuePool().createValue(animation->duration(), CSSPrimitiveValue::CSS_S));
2543                     list->append(createTimingFunctionValue(animation->timingFunction().get()));
2544                     list->append(cssValuePool().createValue(animation->delay(), CSSPrimitiveValue::CSS_S));
2545                     transitionsList->append(list);
2546                 }
2547                 return transitionsList.release();
2548             }
2549
2550             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2551             // transition-property default value.
2552             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2553             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2554             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2555             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2556             return list.release();
2557         }
2558         case CSSPropertyPointerEvents:
2559             return cssValuePool().createValue(style->pointerEvents());
2560         case CSSPropertyWebkitColorCorrection:
2561             return cssValuePool().createValue(style->colorSpace());
2562         case CSSPropertyWebkitLineGrid:
2563             if (style->lineGrid().isNull())
2564                 return cssValuePool().createIdentifierValue(CSSValueNone);
2565             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2566         case CSSPropertyWebkitLineSnap:
2567             return CSSPrimitiveValue::create(style->lineSnap());
2568         case CSSPropertyWebkitLineAlign:
2569             return CSSPrimitiveValue::create(style->lineAlign());
2570         case CSSPropertyWebkitWritingMode:
2571             return cssValuePool().createValue(style->writingMode());
2572         case CSSPropertyWebkitTextCombine:
2573             return cssValuePool().createValue(style->textCombine());
2574         case CSSPropertyWebkitTextOrientation:
2575             return CSSPrimitiveValue::create(style->textOrientation());
2576         case CSSPropertyWebkitLineBoxContain:
2577             return createLineBoxContainValue(style->lineBoxContain());
2578         case CSSPropertyContent:
2579             return contentToCSSValue(style.get());
2580         case CSSPropertyCounterIncrement:
2581             return counterToCSSValue(style.get(), propertyID);
2582         case CSSPropertyCounterReset:
2583             return counterToCSSValue(style.get(), propertyID);
2584         case CSSPropertyWebkitClipPath:
2585             if (ClipPathOperation* operation = style->clipPath()) {
2586                 if (operation->getOperationType() == ClipPathOperation::SHAPE)
2587                     return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2588 #if ENABLE(SVG)
2589                 else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
2590                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2591                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2592                 }
2593 #endif
2594             }
2595             return cssValuePool().createIdentifierValue(CSSValueNone);
2596 #if ENABLE(CSS_REGIONS)
2597         case CSSPropertyWebkitFlowInto:
2598             if (style->flowThread().isNull())
2599                 return cssValuePool().createIdentifierValue(CSSValueNone);
2600             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2601         case CSSPropertyWebkitFlowFrom:
2602             if (style->regionThread().isNull())
2603                 return cssValuePool().createIdentifierValue(CSSValueNone);
2604             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2605         case CSSPropertyWebkitRegionOverflow:
2606             return cssValuePool().createValue(style->regionOverflow());
2607 #endif
2608 #if ENABLE(CSS_EXCLUSIONS)
2609         case CSSPropertyWebkitWrapFlow:
2610             return cssValuePool().createValue(style->wrapFlow());
2611         case CSSPropertyWebkitShapeMargin:
2612             return cssValuePool().createValue(style->shapeMargin());
2613         case CSSPropertyWebkitShapePadding:
2614             return cssValuePool().createValue(style->shapePadding());
2615         case CSSPropertyWebkitShapeInside:
2616             if (!style->shapeInside())
2617                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2618             else if (style->shapeInside()->type() == ExclusionShapeValue::OUTSIDE)
2619                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2620             ASSERT(style->shapeInside()->type() == ExclusionShapeValue::SHAPE);
2621             return valueForBasicShape(style->shapeInside()->shape());
2622         case CSSPropertyWebkitShapeOutside:
2623             if (!style->shapeOutside())
2624                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2625             ASSERT(style->shapeOutside()->type() == ExclusionShapeValue::SHAPE);
2626             return valueForBasicShape(style->shapeOutside()->shape());
2627         case CSSPropertyWebkitWrapThrough:
2628             return cssValuePool().createValue(style->wrapThrough());
2629 #endif
2630 #if ENABLE(CSS_FILTERS)
2631         case CSSPropertyWebkitFilter:
2632             return valueForFilter(renderer, style.get());
2633 #endif
2634 #if ENABLE(CSS_COMPOSITING)
2635         case CSSPropertyWebkitBlendMode:
2636             return cssValuePool().createValue(style->blendMode());
2637             
2638         case CSSPropertyWebkitBackgroundBlendMode: {
2639             const FillLayer* layers = style->backgroundLayers();
2640             if (!layers->next())
2641                 return cssValuePool().createValue(layers->blendMode());
2642
2643             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2644             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2645                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2646
2647             return list.release();
2648         }
2649 #endif
2650         case CSSPropertyBackground:
2651             return getBackgroundShorthandValue();
2652         case CSSPropertyBorder: {
2653             RefPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2654             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2655                                         CSSPropertyBorderLeft };
2656             for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2657                 if (!compareCSSValuePtr<CSSValue>(value, getPropertyCSSValue(properties[i], DoNotUpdateLayout)))
2658                     return 0;
2659             }
2660             return value.release();
2661         }
2662         case CSSPropertyBorderBottom:
2663             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2664         case CSSPropertyBorderColor:
2665             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2666         case CSSPropertyBorderLeft:
2667             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2668         case CSSPropertyBorderImage:
2669             return valueForNinePieceImage(style->borderImage());
2670         case CSSPropertyBorderRadius:
2671             return getBorderRadiusShorthandValue(style.get(), m_node->document()->renderView());
2672         case CSSPropertyBorderRight:
2673             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2674         case CSSPropertyBorderStyle:
2675             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2676         case CSSPropertyBorderTop:
2677             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2678         case CSSPropertyBorderWidth:
2679             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2680         case CSSPropertyListStyle:
2681             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2682         case CSSPropertyMargin:
2683             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2684         case CSSPropertyOutline:
2685             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2686         case CSSPropertyPadding:
2687             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2688         /* Individual properties not part of the spec */
2689         case CSSPropertyBackgroundRepeatX:
2690         case CSSPropertyBackgroundRepeatY:
2691             break;
2692
2693         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2694         case CSSPropertyWebkitTextEmphasis:
2695         case CSSPropertyTextLineThrough:
2696         case CSSPropertyTextLineThroughColor:
2697         case CSSPropertyTextLineThroughMode:
2698         case CSSPropertyTextLineThroughStyle:
2699         case CSSPropertyTextLineThroughWidth:
2700         case CSSPropertyTextOverline:
2701         case CSSPropertyTextOverlineColor:
2702         case CSSPropertyTextOverlineMode:
2703         case CSSPropertyTextOverlineStyle:
2704         case CSSPropertyTextOverlineWidth:
2705         case CSSPropertyTextUnderline:
2706         case CSSPropertyTextUnderlineColor:
2707         case CSSPropertyTextUnderlineMode:
2708         case CSSPropertyTextUnderlineStyle:
2709         case CSSPropertyTextUnderlineWidth:
2710             break;
2711
2712         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2713         case CSSPropertyWebkitBorderEnd:
2714         case CSSPropertyWebkitBorderEndColor:
2715         case CSSPropertyWebkitBorderEndStyle:
2716         case CSSPropertyWebkitBorderEndWidth:
2717         case CSSPropertyWebkitBorderStart:
2718         case CSSPropertyWebkitBorderStartColor:
2719         case CSSPropertyWebkitBorderStartStyle:
2720         case CSSPropertyWebkitBorderStartWidth:
2721         case CSSPropertyWebkitBorderAfter:
2722         case CSSPropertyWebkitBorderAfterColor:
2723         case CSSPropertyWebkitBorderAfterStyle:
2724         case CSSPropertyWebkitBorderAfterWidth:
2725         case CSSPropertyWebkitBorderBefore:
2726         case CSSPropertyWebkitBorderBeforeColor:
2727         case CSSPropertyWebkitBorderBeforeStyle:
2728         case CSSPropertyWebkitBorderBeforeWidth:
2729         case CSSPropertyWebkitMarginEnd:
2730         case CSSPropertyWebkitMarginStart:
2731         case CSSPropertyWebkitMarginAfter:
2732         case CSSPropertyWebkitMarginBefore:
2733         case CSSPropertyWebkitPaddingEnd:
2734         case CSSPropertyWebkitPaddingStart:
2735         case CSSPropertyWebkitPaddingAfter:
2736         case CSSPropertyWebkitPaddingBefore:
2737         case CSSPropertyWebkitLogicalWidth:
2738         case CSSPropertyWebkitLogicalHeight:
2739         case CSSPropertyWebkitMinLogicalWidth:
2740         case CSSPropertyWebkitMinLogicalHeight:
2741         case CSSPropertyWebkitMaxLogicalWidth:
2742         case CSSPropertyWebkitMaxLogicalHeight:
2743             ASSERT_NOT_REACHED();
2744             break;
2745
2746         /* Unimplemented @font-face properties */
2747         case CSSPropertyFontStretch:
2748         case CSSPropertySrc:
2749         case CSSPropertyUnicodeRange:
2750             break;
2751
2752         /* Other unimplemented properties */
2753         case CSSPropertyPage: // for @page
2754         case CSSPropertyQuotes: // FIXME: needs implementation
2755         case CSSPropertySize: // for @page
2756             break;
2757
2758         /* Unimplemented -webkit- properties */
2759         case CSSPropertyWebkitAnimation:
2760         case CSSPropertyWebkitBorderRadius:
2761         case CSSPropertyWebkitColumns:
2762         case CSSPropertyWebkitColumnRule:
2763         case CSSPropertyWebkitMarginCollapse:
2764         case CSSPropertyWebkitMarquee:
2765         case CSSPropertyWebkitMarqueeSpeed:
2766         case CSSPropertyWebkitMask:
2767         case CSSPropertyWebkitMaskRepeatX:
2768         case CSSPropertyWebkitMaskRepeatY:
2769         case CSSPropertyWebkitPerspectiveOriginX:
2770         case CSSPropertyWebkitPerspectiveOriginY:
2771         case CSSPropertyWebkitTextStroke:
2772         case CSSPropertyWebkitTransformOriginX:
2773         case CSSPropertyWebkitTransformOriginY:
2774         case CSSPropertyWebkitTransformOriginZ:
2775 #if ENABLE(CSS_EXCLUSIONS)
2776         case CSSPropertyWebkitWrap:
2777 #endif
2778             break;
2779
2780 #if ENABLE(CSS_DEVICE_ADAPTATION)
2781         case CSSPropertyMaxZoom:
2782         case CSSPropertyMinZoom:
2783         case CSSPropertyOrientation:
2784         case CSSPropertyUserZoom:
2785             break;
2786 #endif
2787
2788 #if ENABLE(SVG)
2789         case CSSPropertyClipPath:
2790         case CSSPropertyClipRule:
2791         case CSSPropertyMask:
2792         case CSSPropertyEnableBackground:
2793         case CSSPropertyFilter:
2794         case CSSPropertyFloodColor:
2795         case CSSPropertyFloodOpacity:
2796         case CSSPropertyLightingColor:
2797         case CSSPropertyStopColor:
2798         case CSSPropertyStopOpacity:
2799         case CSSPropertyColorInterpolation:
2800         case CSSPropertyColorInterpolationFilters:
2801         case CSSPropertyColorProfile:
2802         case CSSPropertyColorRendering:
2803         case CSSPropertyFill:
2804         case CSSPropertyFillOpacity:
2805         case CSSPropertyFillRule:
2806         case CSSPropertyMarker:
2807         case CSSPropertyMarkerEnd:
2808         case CSSPropertyMarkerMid:
2809         case CSSPropertyMarkerStart:
2810         case CSSPropertyMaskType:
2811         case CSSPropertyShapeRendering:
2812         case CSSPropertyStroke:
2813         case CSSPropertyStrokeDasharray:
2814         case CSSPropertyStrokeDashoffset:
2815         case CSSPropertyStrokeLinecap:
2816         case CSSPropertyStrokeLinejoin:
2817         case CSSPropertyStrokeMiterlimit:
2818         case CSSPropertyStrokeOpacity:
2819         case CSSPropertyStrokeWidth:
2820         case CSSPropertyAlignmentBaseline:
2821         case CSSPropertyBaselineShift:
2822         case CSSPropertyDominantBaseline:
2823         case CSSPropertyGlyphOrientationHorizontal:
2824         case CSSPropertyGlyphOrientationVertical:
2825         case CSSPropertyKerning:
2826         case CSSPropertyTextAnchor:
2827         case CSSPropertyVectorEffect:
2828         case CSSPropertyWritingMode:
2829         case CSSPropertyWebkitSvgShadow:
2830             return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
2831 #endif
2832     }
2833
2834     logUnimplementedPropertyID(propertyID);
2835     return 0;
2836 }
2837
2838 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
2839 {
2840     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2841     if (value)
2842         return value->cssText();
2843     return "";
2844 }
2845
2846
2847 unsigned CSSComputedStyleDeclaration::length() const
2848 {
2849     Node* node = m_node.get();
2850     if (!node)
2851         return 0;
2852
2853     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
2854     if (!style)
2855         return 0;
2856
2857     return numComputedProperties;
2858 }
2859
2860 String CSSComputedStyleDeclaration::item(unsigned i) const
2861 {
2862     if (i >= length())
2863         return "";
2864
2865     return getPropertyNameString(computedProperties[i]);
2866 }
2867
2868 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
2869 {
2870     if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() && m_node) {
2871         m_node->document()->updateLayoutIgnorePendingStylesheets();
2872         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
2873         if (style && style->fontDescription().keywordSize()) {
2874             int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
2875             const CSSPrimitiveValue* primitiveValue = static_cast<const CSSPrimitiveValue*>(propertyValue);
2876             if (primitiveValue->isIdent() && primitiveValue->getIdent() == sizeValue)
2877                 return true;
2878         }
2879     }
2880     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2881     return value && propertyValue && value->equals(*propertyValue);
2882 }
2883
2884 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copy() const
2885 {
2886     return copyPropertiesInSet(computedProperties, numComputedProperties);
2887 }
2888
2889 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::makeMutable()
2890 {
2891     return copy();
2892 }
2893
2894 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
2895 {
2896     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2897     for (size_t i = 0; i < shorthand.length(); ++i) {
2898         RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2899         list->append(value);
2900     }
2901     return list.release();
2902 }
2903
2904 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
2905 {
2906     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2907     // Assume the properties are in the usual order top, right, bottom, left.
2908     RefPtr<CSSValue> topValue = getPropertyCSSValue(shorthand.properties()[0], DoNotUpdateLayout);
2909     RefPtr<CSSValue> rightValue = getPropertyCSSValue(shorthand.properties()[1], DoNotUpdateLayout);
2910     RefPtr<CSSValue> bottomValue = getPropertyCSSValue(shorthand.properties()[2], DoNotUpdateLayout);
2911     RefPtr<CSSValue> leftValue = getPropertyCSSValue(shorthand.properties()[3], DoNotUpdateLayout);
2912
2913     // All 4 properties must be specified.
2914     if (!topValue || !rightValue || !bottomValue || !leftValue)
2915         return 0;
2916
2917     bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
2918     bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
2919     bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
2920
2921     list->append(topValue);
2922     if (showRight)
2923         list->append(rightValue);
2924     if (showBottom)
2925         list->append(bottomValue);
2926     if (showLeft)
2927         list->append(leftValue);
2928
2929     return list.release();
2930 }
2931
2932 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
2933 {
2934     Vector<CSSProperty, 256> list;
2935     list.reserveInitialCapacity(length);
2936     for (unsigned i = 0; i < length; ++i) {
2937         RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
2938         if (value)
2939             list.append(CSSProperty(set[i], value.release(), false));
2940     }
2941     return StylePropertySet::create(list.data(), list.size());
2942 }
2943
2944 void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
2945 {
2946     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
2947     info.addMember(m_node, "node");
2948 }
2949
2950 CSSRule* CSSComputedStyleDeclaration::parentRule() const
2951 {
2952     return 0;
2953 }
2954
2955 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
2956 {
2957     CSSPropertyID propertyID = cssPropertyID(propertyName);
2958     if (!propertyID)
2959         return 0;
2960     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2961     return value ? value->cloneForCSSOM() : 0;
2962 }
2963
2964 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
2965 {
2966     CSSPropertyID propertyID = cssPropertyID(propertyName);
2967     if (!propertyID)
2968         return String();
2969     return getPropertyValue(propertyID);
2970 }
2971
2972 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
2973 {
2974     // All computed styles have a priority of not "important".
2975     return "";
2976 }
2977
2978 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
2979 {
2980     return "";
2981 }
2982
2983 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
2984 {
2985     return false;
2986 }
2987
2988 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
2989 {
2990     ec = NO_MODIFICATION_ALLOWED_ERR;
2991 }
2992
2993 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
2994 {
2995     ec = NO_MODIFICATION_ALLOWED_ERR;
2996     return String();
2997 }
2998     
2999 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3000 {
3001     return getPropertyCSSValue(propertyID);
3002 }
3003
3004 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3005 {
3006     return getPropertyValue(propertyID);
3007 }
3008
3009 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3010 {
3011     ec = NO_MODIFICATION_ALLOWED_ERR;
3012 }
3013
3014 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
3015 {
3016     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3017                                                                      CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,  
3018                                                                      CSSPropertyBackgroundPosition };
3019     static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, 
3020                                                                     CSSPropertyBackgroundClip };
3021
3022     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3023     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3024     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3025     return list.release();
3026 }
3027
3028 } // namespace WebCore