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