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