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