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