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