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