b61a6b228740f08ed09960354835c3357362a9b6
[WebKit-https.git] / WebCore / css / CSSComputedStyleDeclaration.cpp
1 /*
2  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301  USA
21  */
22
23 #include "config.h"
24 #include "CSSComputedStyleDeclaration.h"
25
26 #include "AnimationController.h"
27 #include "CSSBorderImageValue.h"
28 #include "CSSMutableStyleDeclaration.h"
29 #include "CSSPrimitiveValue.h"
30 #include "CSSPrimitiveValueMappings.h"
31 #include "CSSProperty.h"
32 #include "CSSPropertyNames.h"
33 #include "CSSReflectValue.h"
34 #include "CSSSelector.h"
35 #include "CSSTimingFunctionValue.h"
36 #include "CSSValueList.h"
37 #include "Document.h"
38 #include "ExceptionCode.h"
39 #include "Rect.h"
40 #include "RenderBox.h"
41 #include "RenderLayer.h"
42 #include "ShadowValue.h"
43 #include "WebKitCSSTransformValue.h"
44
45 #if ENABLE(DASHBOARD_SUPPORT)
46 #include "DashboardRegion.h"
47 #endif
48
49 namespace WebCore {
50
51 // List of all properties we know how to compute, omitting shorthands.
52 static const int computedProperties[] = {
53     CSSPropertyBackgroundAttachment,
54     CSSPropertyBackgroundClip,
55     CSSPropertyBackgroundColor,
56     CSSPropertyBackgroundImage,
57     CSSPropertyBackgroundOrigin,
58     CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
59     CSSPropertyBackgroundRepeat,
60     CSSPropertyBackgroundSize,
61     CSSPropertyBorderBottomColor,
62     CSSPropertyBorderBottomLeftRadius,
63     CSSPropertyBorderBottomRightRadius,
64     CSSPropertyBorderBottomStyle,
65     CSSPropertyBorderBottomWidth,
66     CSSPropertyBorderCollapse,
67     CSSPropertyBorderLeftColor,
68     CSSPropertyBorderLeftStyle,
69     CSSPropertyBorderLeftWidth,
70     CSSPropertyBorderRightColor,
71     CSSPropertyBorderRightStyle,
72     CSSPropertyBorderRightWidth,
73     CSSPropertyBorderTopColor,
74     CSSPropertyBorderTopLeftRadius,
75     CSSPropertyBorderTopRightRadius,
76     CSSPropertyBorderTopStyle,
77     CSSPropertyBorderTopWidth,
78     CSSPropertyBottom,
79     CSSPropertyCaptionSide,
80     CSSPropertyClear,
81     CSSPropertyClip,
82     CSSPropertyColor,
83     CSSPropertyCursor,
84     CSSPropertyDirection,
85     CSSPropertyDisplay,
86     CSSPropertyEmptyCells,
87     CSSPropertyFloat,
88     CSSPropertyFontFamily,
89     CSSPropertyFontSize,
90     CSSPropertyFontStyle,
91     CSSPropertyFontVariant,
92     CSSPropertyFontWeight,
93     CSSPropertyHeight,
94     CSSPropertyLeft,
95     CSSPropertyLetterSpacing,
96     CSSPropertyLineHeight,
97     CSSPropertyListStyleImage,
98     CSSPropertyListStylePosition,
99     CSSPropertyListStyleType,
100     CSSPropertyMarginBottom,
101     CSSPropertyMarginLeft,
102     CSSPropertyMarginRight,
103     CSSPropertyMarginTop,
104     CSSPropertyMaxHeight,
105     CSSPropertyMaxWidth,
106     CSSPropertyMinHeight,
107     CSSPropertyMinWidth,
108     CSSPropertyOpacity,
109     CSSPropertyOrphans,
110     CSSPropertyOutlineColor,
111     CSSPropertyOutlineStyle,
112     CSSPropertyOutlineWidth,
113     CSSPropertyOverflowX,
114     CSSPropertyOverflowY,
115     CSSPropertyPaddingBottom,
116     CSSPropertyPaddingLeft,
117     CSSPropertyPaddingRight,
118     CSSPropertyPaddingTop,
119     CSSPropertyPageBreakAfter,
120     CSSPropertyPageBreakBefore,
121     CSSPropertyPageBreakInside,
122     CSSPropertyPointerEvents,
123     CSSPropertyPosition,
124     CSSPropertyResize,
125     CSSPropertyRight,
126     CSSPropertyTableLayout,
127     CSSPropertyTextAlign,
128     CSSPropertyTextDecoration,
129     CSSPropertyTextIndent,
130     CSSPropertyTextRendering,
131     CSSPropertyTextShadow,
132     CSSPropertyTextOverflow,
133     CSSPropertyTextTransform,
134     CSSPropertyTop,
135     CSSPropertyUnicodeBidi,
136     CSSPropertyVerticalAlign,
137     CSSPropertyVisibility,
138     CSSPropertyWhiteSpace,
139     CSSPropertyWidows,
140     CSSPropertyWidth,
141     CSSPropertyWordBreak,
142     CSSPropertyWordSpacing,
143     CSSPropertyWordWrap,
144     CSSPropertyZIndex,
145     CSSPropertyZoom,
146
147     CSSPropertyWebkitAnimationDelay,
148     CSSPropertyWebkitAnimationDirection,
149     CSSPropertyWebkitAnimationDuration,
150     CSSPropertyWebkitAnimationFillMode,
151     CSSPropertyWebkitAnimationIterationCount,
152     CSSPropertyWebkitAnimationName,
153     CSSPropertyWebkitAnimationPlayState,
154     CSSPropertyWebkitAnimationTimingFunction,
155     CSSPropertyWebkitAppearance,
156     CSSPropertyWebkitBackfaceVisibility,
157     CSSPropertyWebkitBackgroundClip,
158     CSSPropertyWebkitBackgroundComposite,
159     CSSPropertyWebkitBackgroundOrigin,
160     CSSPropertyWebkitBackgroundSize,
161     CSSPropertyWebkitBorderFit,
162     CSSPropertyWebkitBorderHorizontalSpacing,
163     CSSPropertyWebkitBorderImage,
164     CSSPropertyWebkitBorderVerticalSpacing,
165     CSSPropertyWebkitBoxAlign,
166     CSSPropertyWebkitBoxDirection,
167     CSSPropertyWebkitBoxFlex,
168     CSSPropertyWebkitBoxFlexGroup,
169     CSSPropertyWebkitBoxLines,
170     CSSPropertyWebkitBoxOrdinalGroup,
171     CSSPropertyWebkitBoxOrient,
172     CSSPropertyWebkitBoxPack,
173     CSSPropertyWebkitBoxReflect,
174     CSSPropertyWebkitBoxShadow,
175     CSSPropertyWebkitBoxSizing,
176     CSSPropertyWebkitColorCorrection,
177     CSSPropertyWebkitColumnBreakAfter,
178     CSSPropertyWebkitColumnBreakBefore,
179     CSSPropertyWebkitColumnBreakInside,
180     CSSPropertyWebkitColumnCount,
181     CSSPropertyWebkitColumnGap,
182     CSSPropertyWebkitColumnRuleColor,
183     CSSPropertyWebkitColumnRuleStyle,
184     CSSPropertyWebkitColumnRuleWidth,
185     CSSPropertyWebkitColumnWidth,
186 #if ENABLE(DASHBOARD_SUPPORT)
187     CSSPropertyWebkitDashboardRegion,
188 #endif
189     CSSPropertyWebkitFontSmoothing,
190     CSSPropertyWebkitHighlight,
191     CSSPropertyWebkitLineBreak,
192     CSSPropertyWebkitLineClamp,
193     CSSPropertyWebkitMarginBottomCollapse,
194     CSSPropertyWebkitMarginTopCollapse,
195     CSSPropertyWebkitMarqueeDirection,
196     CSSPropertyWebkitMarqueeIncrement,
197     CSSPropertyWebkitMarqueeRepetition,
198     CSSPropertyWebkitMarqueeStyle,
199     CSSPropertyWebkitMaskAttachment,
200     CSSPropertyWebkitMaskBoxImage,
201     CSSPropertyWebkitMaskClip,
202     CSSPropertyWebkitMaskComposite,
203     CSSPropertyWebkitMaskImage,
204     CSSPropertyWebkitMaskOrigin,
205     CSSPropertyWebkitMaskPosition,
206     CSSPropertyWebkitMaskRepeat,
207     CSSPropertyWebkitMaskSize,
208     CSSPropertyWebkitNbspMode,
209     CSSPropertyWebkitPerspective,
210     CSSPropertyWebkitPerspectiveOrigin,
211     CSSPropertyWebkitRtlOrdering,
212     CSSPropertyWebkitTextDecorationsInEffect,
213     CSSPropertyWebkitTextFillColor,
214     CSSPropertyWebkitTextSecurity,
215     CSSPropertyWebkitTextStrokeColor,
216     CSSPropertyWebkitTextStrokeWidth,
217     CSSPropertyWebkitTransform,
218     CSSPropertyWebkitTransformOrigin,
219     CSSPropertyWebkitTransformStyle,
220     CSSPropertyWebkitTransitionDelay,
221     CSSPropertyWebkitTransitionDuration,
222     CSSPropertyWebkitTransitionProperty,
223     CSSPropertyWebkitTransitionTimingFunction,
224     CSSPropertyWebkitUserDrag,
225     CSSPropertyWebkitUserModify,
226     CSSPropertyWebkitUserSelect
227
228 #if ENABLE(SVG)
229     ,
230     CSSPropertyClipPath,
231     CSSPropertyClipRule,
232     CSSPropertyMask,
233     CSSPropertyFilter,
234     CSSPropertyFloodColor,
235     CSSPropertyFloodOpacity,
236     CSSPropertyLightingColor,
237     CSSPropertyStopColor,
238     CSSPropertyStopOpacity,
239     CSSPropertyColorInterpolation,
240     CSSPropertyColorInterpolationFilters,
241     CSSPropertyColorRendering,
242     CSSPropertyFill,
243     CSSPropertyFillOpacity,
244     CSSPropertyFillRule,
245     CSSPropertyImageRendering,
246     CSSPropertyMarkerEnd,
247     CSSPropertyMarkerMid,
248     CSSPropertyMarkerStart,
249     CSSPropertyShapeRendering,
250     CSSPropertyStroke,
251     CSSPropertyStrokeDasharray,
252     CSSPropertyStrokeDashoffset,
253     CSSPropertyStrokeLinecap,
254     CSSPropertyStrokeLinejoin,
255     CSSPropertyStrokeMiterlimit,
256     CSSPropertyStrokeOpacity,
257     CSSPropertyStrokeWidth,
258     CSSPropertyAlignmentBaseline,
259     CSSPropertyBaselineShift,
260     CSSPropertyDominantBaseline,
261     CSSPropertyKerning,
262     CSSPropertyTextAnchor,
263     CSSPropertyWritingMode,
264     CSSPropertyGlyphOrientationHorizontal,
265     CSSPropertyGlyphOrientationVertical,
266     CSSPropertyWebkitSvgShadow
267 #endif
268 };
269
270 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
271
272 static int valueForRepeatRule(int rule)
273 {
274     switch (rule) {
275         case RepeatImageRule:
276             return CSSValueRepeat;
277         case RoundImageRule:
278             return CSSValueRound;
279         default:
280             return CSSValueStretch;
281     }
282 }
283         
284 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
285 {
286     if (!image.hasImage())
287         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
288     
289     // Image first.
290     RefPtr<CSSValue> imageValue;
291     if (image.image())
292         imageValue = image.image()->cssValue();
293     
294     // Create the slices.
295     RefPtr<CSSPrimitiveValue> top;
296     if (image.slices().top().isPercent())
297         top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
298     else
299         top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
300         
301     RefPtr<CSSPrimitiveValue> right;
302     if (image.slices().right().isPercent())
303         right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
304     else
305         right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
306         
307     RefPtr<CSSPrimitiveValue> bottom;
308     if (image.slices().bottom().isPercent())
309         bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
310     else
311         bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
312     
313     RefPtr<CSSPrimitiveValue> left;
314     if (image.slices().left().isPercent())
315         left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
316     else
317         left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
318
319     RefPtr<Rect> rect = Rect::create();
320     rect->setTop(top);
321     rect->setRight(right);
322     rect->setBottom(bottom);
323     rect->setLeft(left);
324
325     return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.horizontalRule()), valueForRepeatRule(image.verticalRule()));
326 }
327
328 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection)
329 {
330     if (!reflection)
331         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
332
333     RefPtr<CSSPrimitiveValue> offset;
334     if (reflection->offset().isPercent())
335         offset = CSSPrimitiveValue::create(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
336     else
337         offset = CSSPrimitiveValue::create(reflection->offset().value(), CSSPrimitiveValue::CSS_PX);
338     
339     return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
340 }
341
342 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID)
343 {
344     if (!style)
345         return 0;
346
347     Length l;
348     switch (propertyID) {
349         case CSSPropertyLeft:
350             l = style->left();
351             break;
352         case CSSPropertyRight:
353             l = style->right();
354             break;
355         case CSSPropertyTop:
356             l = style->top();
357             break;
358         case CSSPropertyBottom:
359             l = style->bottom();
360             break;
361         default:
362             return 0;
363     }
364
365     if (style->position() == AbsolutePosition || style->position() == FixedPosition)
366         return CSSPrimitiveValue::create(l);
367
368     if (style->position() == RelativePosition)
369         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
370         // In other words if left is auto and right is not auto, then left's computed value is negative right().
371         // So we should get the opposite length unit and see if it is auto.
372         return CSSPrimitiveValue::create(l);
373
374     return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
375 }
376
377 PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const Color& color) const
378 {
379     // This function does NOT look at visited information, so that computed style doesn't expose that.
380     if (!color.isValid())
381         return CSSPrimitiveValue::createColor(style->color().rgb());
382     return CSSPrimitiveValue::createColor(color.rgb());
383 }
384
385 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius)
386 {
387     if (radius.width() == radius.height())
388         return CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX);
389
390     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
391     list->append(CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX));
392     list->append(CSSPrimitiveValue::create(radius.height(), CSSPrimitiveValue::CSS_PX));
393     return list.release();
394 }
395
396 static IntRect sizingBox(RenderObject* renderer)
397 {
398     if (!renderer->isBox())
399         return IntRect();
400     
401     RenderBox* box = toRenderBox(renderer);
402     return box->style()->boxSizing() == CONTENT_BOX ? box->contentBoxRect() : box->borderBoxRect();
403 }
404
405 static inline bool hasCompositedLayer(RenderObject* renderer)
406 {
407     return renderer && renderer->hasLayer() && toRenderBoxModelObject(renderer)->layer()->isComposited();
408 }
409
410 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
411 {
412     if (!renderer || style->transform().operations().isEmpty())
413         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
414     
415     IntRect box = sizingBox(renderer);
416
417     TransformationMatrix transform;
418     style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
419     // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
420
421     RefPtr<WebKitCSSTransformValue> transformVal;
422
423     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
424     if (transform.isAffine()) {
425         transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
426
427         transformVal->append(CSSPrimitiveValue::create(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
428         transformVal->append(CSSPrimitiveValue::create(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
429         transformVal->append(CSSPrimitiveValue::create(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
430         transformVal->append(CSSPrimitiveValue::create(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
431         transformVal->append(CSSPrimitiveValue::create(transform.e(), CSSPrimitiveValue::CSS_NUMBER));
432         transformVal->append(CSSPrimitiveValue::create(transform.f(), CSSPrimitiveValue::CSS_NUMBER));
433     } else {
434         transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
435
436         transformVal->append(CSSPrimitiveValue::create(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
437         transformVal->append(CSSPrimitiveValue::create(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
438         transformVal->append(CSSPrimitiveValue::create(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
439         transformVal->append(CSSPrimitiveValue::create(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
440
441         transformVal->append(CSSPrimitiveValue::create(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
442         transformVal->append(CSSPrimitiveValue::create(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
443         transformVal->append(CSSPrimitiveValue::create(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
444         transformVal->append(CSSPrimitiveValue::create(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
445
446         transformVal->append(CSSPrimitiveValue::create(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
447         transformVal->append(CSSPrimitiveValue::create(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
448         transformVal->append(CSSPrimitiveValue::create(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
449         transformVal->append(CSSPrimitiveValue::create(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
450
451         transformVal->append(CSSPrimitiveValue::create(transform.m41(), CSSPrimitiveValue::CSS_NUMBER));
452         transformVal->append(CSSPrimitiveValue::create(transform.m42(), CSSPrimitiveValue::CSS_NUMBER));
453         transformVal->append(CSSPrimitiveValue::create(transform.m43(), CSSPrimitiveValue::CSS_NUMBER));
454         transformVal->append(CSSPrimitiveValue::create(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
455     }
456
457     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
458     list->append(transformVal);
459
460     return list.release();
461 }
462
463 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
464 {
465     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
466     if (animList) {
467         for (size_t i = 0; i < animList->size(); ++i)
468             list->append(CSSPrimitiveValue::create(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
469     } else {
470         // Note that initialAnimationDelay() is used for both transitions and animations
471         list->append(CSSPrimitiveValue::create(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
472     }
473     return list.release();
474 }
475
476 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
477 {
478     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
479     if (animList) {
480         for (size_t i = 0; i < animList->size(); ++i)
481             list->append(CSSPrimitiveValue::create(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
482     } else {
483         // Note that initialAnimationDuration() is used for both transitions and animations
484         list->append(CSSPrimitiveValue::create(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
485     }
486     return list.release();
487 }
488
489 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
490 {
491     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
492     if (animList) {
493         for (size_t i = 0; i < animList->size(); ++i) {
494             const TimingFunction& tf = animList->animation(i)->timingFunction();
495             list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2()));
496         }
497     } else {
498         // Note that initialAnimationTimingFunction() is used for both transitions and animations
499         const TimingFunction& tf = Animation::initialAnimationTimingFunction();
500         list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2()));
501     }
502     return list.release();
503 }
504
505 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
506     : m_node(n)
507     , m_allowVisitedStyle(allowVisitedStyle)
508 {
509     unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
510     m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
511         AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
512 }
513
514 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
515 {
516 }
517
518 String CSSComputedStyleDeclaration::cssText() const
519 {
520     String result("");
521
522     for (unsigned i = 0; i < numComputedProperties; i++) {
523         if (i)
524             result += " ";
525         result += getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
526         result += ": ";
527         result += getPropertyValue(computedProperties[i]);
528         result += ";";
529     }
530
531     return result;
532 }
533
534 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
535 {
536     ec = NO_MODIFICATION_ALLOWED_ERR;
537 }
538
539 static int cssIdentifierForFontSizeKeyword(int keywordSize)
540 {
541     ASSERT_ARG(keywordSize, keywordSize);
542     ASSERT_ARG(keywordSize, keywordSize <= 8);
543     return CSSValueXxSmall + keywordSize - 1;
544 }
545
546 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
547 {
548     Node* node = m_node.get();
549     if (!node)
550         return 0;
551
552     node->document()->updateLayoutIgnorePendingStylesheets();
553
554     RefPtr<RenderStyle> style = node->computedStyle(m_pseudoElementSpecifier);
555     if (!style)
556         return 0;
557
558     if (int keywordSize = style->fontDescription().keywordSize())
559         return CSSPrimitiveValue::createIdentifier(cssIdentifierForFontSizeKeyword(keywordSize));
560
561     return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
562 }
563
564 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, int id) const
565 {
566     if (!shadow)
567         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
568
569     CSSPropertyID propertyID = static_cast<CSSPropertyID>(id);
570
571     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
572     for (const ShadowData* s = shadow; s; s = s->next()) {
573         RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x(), CSSPrimitiveValue::CSS_PX);
574         RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y(), CSSPrimitiveValue::CSS_PX);
575         RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur(), CSSPrimitiveValue::CSS_PX);
576         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread(), CSSPrimitiveValue::CSS_PX);
577         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset);
578         RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color().rgb());
579         list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
580     }
581     return list.release();
582 }
583
584 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
585 {
586     return getPropertyCSSValue(propertyID, UpdateLayout);
587 }
588
589 static int identifierForFamily(const AtomicString& family)
590 {
591     DEFINE_STATIC_LOCAL(AtomicString, cursiveFamily, ("-webkit-cursive")); 
592     DEFINE_STATIC_LOCAL(AtomicString, fantasyFamily, ("-webkit-fantasy")); 
593     DEFINE_STATIC_LOCAL(AtomicString, monospaceFamily, ("-webkit-monospace")); 
594     DEFINE_STATIC_LOCAL(AtomicString, sansSerifFamily, ("-webkit-sans-serif")); 
595     DEFINE_STATIC_LOCAL(AtomicString, serifFamily, ("-webkit-serif")); 
596     if (family == cursiveFamily)
597         return CSSValueCursive;
598     if (family == fantasyFamily)
599         return CSSValueFantasy;
600     if (family == monospaceFamily)
601         return CSSValueMonospace;
602     if (family == sansSerifFamily)
603         return CSSValueSansSerif;
604     if (family == serifFamily)
605         return CSSValueSerif;
606     return 0;
607 }
608
609 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
610 {
611     if (int familyIdentifier = identifierForFamily(family))
612         return CSSPrimitiveValue::createIdentifier(familyIdentifier);
613     return CSSPrimitiveValue::create(family.string(), CSSPrimitiveValue::CSS_STRING);
614 }
615
616 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
617 {
618     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
619     if (textDecoration & UNDERLINE)
620         list->append(CSSPrimitiveValue::createIdentifier(CSSValueUnderline));
621     if (textDecoration & OVERLINE)
622         list->append(CSSPrimitiveValue::createIdentifier(CSSValueOverline));
623     if (textDecoration & LINE_THROUGH)
624         list->append(CSSPrimitiveValue::createIdentifier(CSSValueLineThrough));
625     if (textDecoration & BLINK)
626         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBlink));
627
628     if (!list->length())
629         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
630     return list;
631 }
632
633 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
634 {
635     // For backwards compatibility, if both values are equal, just return one of them. And
636     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
637     if (xRepeat == yRepeat)
638         return CSSPrimitiveValue::create(xRepeat);
639     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
640         return CSSPrimitiveValue::createIdentifier(CSSValueRepeatX);
641     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
642         return CSSPrimitiveValue::createIdentifier(CSSValueRepeatY);
643
644     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
645     list->append(CSSPrimitiveValue::create(xRepeat));
646     list->append(CSSPrimitiveValue::create(yRepeat));
647     return list.release();
648 }
649
650 static void logUnimplementedPropertyID(int propertyID)
651 {
652     DEFINE_STATIC_LOCAL(HashSet<int>, propertyIDSet, ());
653     if (!propertyIDSet.add(propertyID).second)
654         return;
655
656     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(static_cast<CSSPropertyID>(propertyID)));
657
658
659 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
660 {
661     Node* node = m_node.get();
662     if (!node)
663         return 0;
664
665     // Make sure our layout is up to date before we allow a query on these attributes.
666     if (updateLayout)
667         node->document()->updateLayoutIgnorePendingStylesheets();
668
669     RenderObject* renderer = node->renderer();
670
671     RefPtr<RenderStyle> style;
672     if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(static_cast<CSSPropertyID>(propertyID))) {
673         style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
674         if (m_pseudoElementSpecifier) {
675             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
676             style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
677         }
678     } else
679         style = node->computedStyle(m_pseudoElementSpecifier);
680
681     if (!style)
682         return 0;
683
684     switch (static_cast<CSSPropertyID>(propertyID)) {
685         case CSSPropertyInvalid:
686             break;
687
688         case CSSPropertyBackgroundColor:
689             return CSSPrimitiveValue::createColor(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
690         case CSSPropertyBackgroundImage:
691             if (style->backgroundImage())
692                 return style->backgroundImage()->cssValue();
693             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
694         case CSSPropertyBackgroundSize:
695         case CSSPropertyWebkitBackgroundSize: {
696             EFillSizeType size = style->backgroundSizeType();
697             if (size == Contain)
698                 return CSSPrimitiveValue::createIdentifier(CSSValueContain);
699             if (size == Cover)
700                 return CSSPrimitiveValue::createIdentifier(CSSValueCover);
701             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
702             list->append(CSSPrimitiveValue::create(style->backgroundSizeLength().width()));
703             list->append(CSSPrimitiveValue::create(style->backgroundSizeLength().height()));
704             return list.release();
705         }  
706         case CSSPropertyBackgroundRepeat:
707             return fillRepeatToCSSValue(style->backgroundRepeatX(), style->backgroundRepeatY());
708         case CSSPropertyWebkitBackgroundComposite:
709             return CSSPrimitiveValue::create(style->backgroundComposite());
710         case CSSPropertyBackgroundAttachment:
711             return CSSPrimitiveValue::create(style->backgroundAttachment());
712         case CSSPropertyBackgroundClip:
713         case CSSPropertyBackgroundOrigin:
714         case CSSPropertyWebkitBackgroundClip:
715         case CSSPropertyWebkitBackgroundOrigin: {
716             EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyBackgroundClip) ? style->backgroundClip() : style->backgroundOrigin();
717             return CSSPrimitiveValue::create(box);
718         }
719         case CSSPropertyBackgroundPosition: {
720             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
721
722             list->append(CSSPrimitiveValue::create(style->backgroundXPosition()));
723             list->append(CSSPrimitiveValue::create(style->backgroundYPosition()));
724
725             return list.release();
726         }
727         case CSSPropertyBackgroundPositionX:
728             return CSSPrimitiveValue::create(style->backgroundXPosition());
729         case CSSPropertyBackgroundPositionY:
730             return CSSPrimitiveValue::create(style->backgroundYPosition());
731         case CSSPropertyBorderCollapse:
732             if (style->borderCollapse())
733                 return CSSPrimitiveValue::createIdentifier(CSSValueCollapse);
734             return CSSPrimitiveValue::createIdentifier(CSSValueSeparate);
735         case CSSPropertyBorderSpacing: {
736             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
737             list->append(CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
738             list->append(CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
739             return list.release();
740         }  
741         case CSSPropertyWebkitBorderHorizontalSpacing:
742             return CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
743         case CSSPropertyWebkitBorderVerticalSpacing:
744             return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
745         case CSSPropertyBorderTopColor:
746             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
747         case CSSPropertyBorderRightColor:
748             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
749         case CSSPropertyBorderBottomColor:
750             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
751         case CSSPropertyBorderLeftColor:
752             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
753         case CSSPropertyBorderTopStyle:
754             return CSSPrimitiveValue::create(style->borderTopStyle());
755         case CSSPropertyBorderRightStyle:
756             return CSSPrimitiveValue::create(style->borderRightStyle());
757         case CSSPropertyBorderBottomStyle:
758             return CSSPrimitiveValue::create(style->borderBottomStyle());
759         case CSSPropertyBorderLeftStyle:
760             return CSSPrimitiveValue::create(style->borderLeftStyle());
761         case CSSPropertyBorderTopWidth:
762             return CSSPrimitiveValue::create(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
763         case CSSPropertyBorderRightWidth:
764             return CSSPrimitiveValue::create(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
765         case CSSPropertyBorderBottomWidth:
766             return CSSPrimitiveValue::create(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
767         case CSSPropertyBorderLeftWidth:
768             return CSSPrimitiveValue::create(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
769         case CSSPropertyBottom:
770             return getPositionOffsetValue(style.get(), CSSPropertyBottom);
771         case CSSPropertyWebkitBoxAlign:
772             return CSSPrimitiveValue::create(style->boxAlign());
773         case CSSPropertyWebkitBoxDirection:
774             return CSSPrimitiveValue::create(style->boxDirection());
775         case CSSPropertyWebkitBoxFlex:
776             return CSSPrimitiveValue::create(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
777         case CSSPropertyWebkitBoxFlexGroup:
778             return CSSPrimitiveValue::create(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
779         case CSSPropertyWebkitBoxLines:
780             return CSSPrimitiveValue::create(style->boxLines());
781         case CSSPropertyWebkitBoxOrdinalGroup:
782             return CSSPrimitiveValue::create(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
783         case CSSPropertyWebkitBoxOrient:
784             return CSSPrimitiveValue::create(style->boxOrient());
785         case CSSPropertyWebkitBoxPack: {
786             EBoxAlignment boxPack = style->boxPack();
787             ASSERT(boxPack != BSTRETCH);
788             ASSERT(boxPack != BBASELINE);
789             if (boxPack == BJUSTIFY || boxPack== BBASELINE)
790                 return 0;
791             return CSSPrimitiveValue::create(boxPack);
792         }
793         case CSSPropertyWebkitBoxReflect:
794             return valueForReflection(style->boxReflect());
795         case CSSPropertyWebkitBoxShadow:
796             return valueForShadow(style->boxShadow(), propertyID);
797         case CSSPropertyCaptionSide:
798             return CSSPrimitiveValue::create(style->captionSide());
799         case CSSPropertyClear:
800             return CSSPrimitiveValue::create(style->clear());
801         case CSSPropertyColor:
802             return CSSPrimitiveValue::createColor(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
803         case CSSPropertyWebkitColumnCount:
804             if (style->hasAutoColumnCount())
805                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
806             return CSSPrimitiveValue::create(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
807         case CSSPropertyWebkitColumnGap:
808             if (style->hasNormalColumnGap())
809                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
810             return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
811         case CSSPropertyWebkitColumnRuleColor:
812             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
813         case CSSPropertyWebkitColumnRuleStyle:
814             return CSSPrimitiveValue::create(style->columnRuleStyle());
815         case CSSPropertyWebkitColumnRuleWidth:
816             return CSSPrimitiveValue::create(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
817         case CSSPropertyWebkitColumnBreakAfter:
818             return CSSPrimitiveValue::create(style->columnBreakAfter());
819         case CSSPropertyWebkitColumnBreakBefore:
820             return CSSPrimitiveValue::create(style->columnBreakBefore());
821         case CSSPropertyWebkitColumnBreakInside:
822             return CSSPrimitiveValue::create(style->columnBreakInside());
823         case CSSPropertyWebkitColumnWidth:
824             if (style->hasAutoColumnWidth())
825                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
826             return CSSPrimitiveValue::create(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
827         case CSSPropertyCursor: {
828             RefPtr<CSSValueList> list;
829             CursorList* cursors = style->cursors();
830             if (cursors && cursors->size() > 0) {
831                 list = CSSValueList::createCommaSeparated();
832                 for (unsigned i = 0; i < cursors->size(); ++i)
833                     list->append(CSSPrimitiveValue::create((*cursors)[i].image()->url(), CSSPrimitiveValue::CSS_URI));
834             }
835             RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor());
836             if (list) {
837                 list->append(value);
838                 return list.release();
839             }
840             return value.release();
841         }
842         case CSSPropertyDirection:
843             return CSSPrimitiveValue::create(style->direction());
844         case CSSPropertyDisplay:
845             return CSSPrimitiveValue::create(style->display());
846         case CSSPropertyEmptyCells:
847             return CSSPrimitiveValue::create(style->emptyCells());
848         case CSSPropertyFloat:
849             return CSSPrimitiveValue::create(style->floating());
850         case CSSPropertyFontFamily: {
851             const FontFamily& firstFamily = style->fontDescription().family();
852             if (!firstFamily.next())
853                 return valueForFamily(firstFamily.family());
854             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
855             for (const FontFamily* family = &firstFamily; family; family = family->next())
856                 list->append(valueForFamily(family->family()));
857             return list.release();
858         }
859         case CSSPropertyFontSize:
860             return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
861         case CSSPropertyWebkitBinding:
862             break;
863         case CSSPropertyFontStyle:
864             if (style->fontDescription().italic())
865                 return CSSPrimitiveValue::createIdentifier(CSSValueItalic);
866             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
867         case CSSPropertyFontVariant:
868             if (style->fontDescription().smallCaps())
869                 return CSSPrimitiveValue::createIdentifier(CSSValueSmallCaps);
870             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
871         case CSSPropertyFontWeight:
872             switch (style->fontDescription().weight()) {
873                 case FontWeight100:
874                     return CSSPrimitiveValue::createIdentifier(CSSValue100);
875                 case FontWeight200:
876                     return CSSPrimitiveValue::createIdentifier(CSSValue200);
877                 case FontWeight300:
878                     return CSSPrimitiveValue::createIdentifier(CSSValue300);
879                 case FontWeightNormal:
880                     return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
881                 case FontWeight500:
882                     return CSSPrimitiveValue::createIdentifier(CSSValue500);
883                 case FontWeight600:
884                     return CSSPrimitiveValue::createIdentifier(CSSValue600);
885                 case FontWeightBold:
886                     return CSSPrimitiveValue::createIdentifier(CSSValueBold);
887                 case FontWeight800:
888                     return CSSPrimitiveValue::createIdentifier(CSSValue800);
889                 case FontWeight900:
890                     return CSSPrimitiveValue::createIdentifier(CSSValue900);
891             }
892             ASSERT_NOT_REACHED();
893             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
894         case CSSPropertyHeight:
895             if (renderer)
896                 return CSSPrimitiveValue::create(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX);
897             return CSSPrimitiveValue::create(style->height());
898         case CSSPropertyWebkitHighlight:
899             if (style->highlight() == nullAtom)
900                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
901             return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING);
902         case CSSPropertyWebkitBorderFit:
903             if (style->borderFit() == BorderFitBorder)
904                 return CSSPrimitiveValue::createIdentifier(CSSValueBorder);
905             return CSSPrimitiveValue::createIdentifier(CSSValueLines);
906         case CSSPropertyLeft:
907             return getPositionOffsetValue(style.get(), CSSPropertyLeft);
908         case CSSPropertyLetterSpacing:
909             if (!style->letterSpacing())
910                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
911             return CSSPrimitiveValue::create(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
912         case CSSPropertyWebkitLineClamp:
913             if (style->lineClamp().isNone())
914                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
915             return CSSPrimitiveValue::create(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
916         case CSSPropertyLineHeight: {
917             Length length = style->lineHeight();
918             if (length.isNegative())
919                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
920             if (length.isPercent())
921                 // This is imperfect, because it doesn't include the zoom factor and the real computation
922                 // for how high to be in pixels does include things like minimum font size and the zoom factor.
923                 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
924                 // that here either.
925                 return CSSPrimitiveValue::create(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX);
926             return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::CSS_PX);
927         }
928         case CSSPropertyListStyleImage:
929             if (style->listStyleImage())
930                 return style->listStyleImage()->cssValue();
931             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
932         case CSSPropertyListStylePosition:
933             return CSSPrimitiveValue::create(style->listStylePosition());
934         case CSSPropertyListStyleType:
935             return CSSPrimitiveValue::create(style->listStyleType());
936         case CSSPropertyMarginTop:
937             if (renderer && renderer->isBox())
938                 // FIXME: Supposed to return the percentage if percentage was specified.
939                 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginTop(), CSSPrimitiveValue::CSS_PX);
940             return CSSPrimitiveValue::create(style->marginTop());
941         case CSSPropertyMarginRight:
942             if (renderer && renderer->isBox())
943                 // FIXME: Supposed to return the percentage if percentage was specified.
944                 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginRight(), CSSPrimitiveValue::CSS_PX);
945             return CSSPrimitiveValue::create(style->marginRight());
946         case CSSPropertyMarginBottom:
947             if (renderer && renderer->isBox())
948                 // FIXME: Supposed to return the percentage if percentage was specified.
949                 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginBottom(), CSSPrimitiveValue::CSS_PX);
950             return CSSPrimitiveValue::create(style->marginBottom());
951         case CSSPropertyMarginLeft:
952             if (renderer && renderer->isBox())
953                 // FIXME: Supposed to return the percentage if percentage was specified.
954                 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginLeft(), CSSPrimitiveValue::CSS_PX);
955             return CSSPrimitiveValue::create(style->marginLeft());
956         case CSSPropertyWebkitMarqueeDirection:
957             return CSSPrimitiveValue::create(style->marqueeDirection());
958         case CSSPropertyWebkitMarqueeIncrement:
959             return CSSPrimitiveValue::create(style->marqueeIncrement());
960         case CSSPropertyWebkitMarqueeRepetition:
961             if (style->marqueeLoopCount() < 0)
962                 return CSSPrimitiveValue::createIdentifier(CSSValueInfinite);
963             return CSSPrimitiveValue::create(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
964         case CSSPropertyWebkitMarqueeStyle:
965             return CSSPrimitiveValue::create(style->marqueeBehavior());
966         case CSSPropertyWebkitMaskImage:
967             if (style->maskImage())
968                 return style->maskImage()->cssValue();
969             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
970         case CSSPropertyWebkitMaskSize: {
971             EFillSizeType size = style->maskSizeType();
972             if (size == Contain)
973                 return CSSPrimitiveValue::createIdentifier(CSSValueContain);
974             if (size == Cover)
975                 return CSSPrimitiveValue::createIdentifier(CSSValueCover);
976             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
977             list->append(CSSPrimitiveValue::create(style->maskSizeLength().width()));
978             list->append(CSSPrimitiveValue::create(style->maskSizeLength().height()));
979             return list.release();
980         }  
981         case CSSPropertyWebkitMaskRepeat:
982             return fillRepeatToCSSValue(style->maskRepeatX(), style->maskRepeatY());
983         case CSSPropertyWebkitMaskAttachment:
984             return CSSPrimitiveValue::create(style->maskAttachment());
985         case CSSPropertyWebkitMaskComposite:
986             return CSSPrimitiveValue::create(style->maskComposite());
987         case CSSPropertyWebkitMaskClip:
988         case CSSPropertyWebkitMaskOrigin: {
989             EFillBox box = (propertyID == CSSPropertyWebkitMaskClip ? style->maskClip() : style->maskOrigin());
990             return CSSPrimitiveValue::create(box);
991         }
992         case CSSPropertyWebkitMaskPosition: {
993             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
994
995             list->append(CSSPrimitiveValue::create(style->maskXPosition()));
996             list->append(CSSPrimitiveValue::create(style->maskYPosition()));
997
998             return list.release();
999         }
1000         case CSSPropertyWebkitMaskPositionX:
1001             return CSSPrimitiveValue::create(style->maskXPosition());
1002         case CSSPropertyWebkitMaskPositionY:
1003             return CSSPrimitiveValue::create(style->maskYPosition());
1004         case CSSPropertyWebkitUserModify:
1005             return CSSPrimitiveValue::create(style->userModify());
1006         case CSSPropertyMaxHeight: {
1007             const Length& maxHeight = style->maxHeight();
1008             if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
1009                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
1010             return CSSPrimitiveValue::create(maxHeight);
1011         }
1012         case CSSPropertyMaxWidth: {
1013             const Length& maxWidth = style->maxWidth();
1014             if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
1015                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
1016             return CSSPrimitiveValue::create(maxWidth);
1017         }
1018         case CSSPropertyMinHeight:
1019             return CSSPrimitiveValue::create(style->minHeight());
1020         case CSSPropertyMinWidth:
1021             return CSSPrimitiveValue::create(style->minWidth());
1022         case CSSPropertyOpacity:
1023             return CSSPrimitiveValue::create(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
1024         case CSSPropertyOrphans:
1025             return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
1026         case CSSPropertyOutlineColor:
1027             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
1028         case CSSPropertyOutlineStyle:
1029             if (style->outlineStyleIsAuto())
1030                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1031             return CSSPrimitiveValue::create(style->outlineStyle());
1032         case CSSPropertyOutlineWidth:
1033             return CSSPrimitiveValue::create(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
1034         case CSSPropertyOverflow:
1035             return CSSPrimitiveValue::create(max(style->overflowX(), style->overflowY()));
1036         case CSSPropertyOverflowX:
1037             return CSSPrimitiveValue::create(style->overflowX());
1038         case CSSPropertyOverflowY:
1039             return CSSPrimitiveValue::create(style->overflowY());
1040         case CSSPropertyPaddingTop:
1041             if (renderer && renderer->isBox())
1042                 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingTop(false), CSSPrimitiveValue::CSS_PX);
1043             return CSSPrimitiveValue::create(style->paddingTop());
1044         case CSSPropertyPaddingRight:
1045             if (renderer && renderer->isBox())
1046                 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingRight(false), CSSPrimitiveValue::CSS_PX);
1047             return CSSPrimitiveValue::create(style->paddingRight());
1048         case CSSPropertyPaddingBottom:
1049             if (renderer && renderer->isBox())
1050                 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingBottom(false), CSSPrimitiveValue::CSS_PX);
1051             return CSSPrimitiveValue::create(style->paddingBottom());
1052         case CSSPropertyPaddingLeft:
1053             if (renderer && renderer->isBox())
1054                 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingLeft(false), CSSPrimitiveValue::CSS_PX);
1055             return CSSPrimitiveValue::create(style->paddingLeft());
1056         case CSSPropertyPageBreakAfter:
1057             return CSSPrimitiveValue::create(style->pageBreakAfter());
1058         case CSSPropertyPageBreakBefore:
1059             return CSSPrimitiveValue::create(style->pageBreakBefore());
1060         case CSSPropertyPageBreakInside: {
1061             EPageBreak pageBreak = style->pageBreakInside();
1062             ASSERT(pageBreak != PBALWAYS);
1063             if (pageBreak == PBALWAYS)
1064                 return 0;
1065             return CSSPrimitiveValue::create(style->pageBreakInside());
1066         }
1067         case CSSPropertyPosition:
1068             return CSSPrimitiveValue::create(style->position());
1069         case CSSPropertyRight:
1070             return getPositionOffsetValue(style.get(), CSSPropertyRight);
1071         case CSSPropertyTableLayout:
1072             return CSSPrimitiveValue::create(style->tableLayout());
1073         case CSSPropertyTextAlign:
1074             return CSSPrimitiveValue::create(style->textAlign());
1075         case CSSPropertyTextDecoration:
1076             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
1077         case CSSPropertyWebkitTextDecorationsInEffect:
1078             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
1079         case CSSPropertyWebkitTextFillColor:
1080             return currentColorOrValidColor(style.get(), style->textFillColor());
1081         case CSSPropertyTextIndent:
1082             return CSSPrimitiveValue::create(style->textIndent());
1083         case CSSPropertyTextShadow:
1084             return valueForShadow(style->textShadow(), propertyID);
1085         case CSSPropertyTextRendering:
1086             return CSSPrimitiveValue::create(style->fontDescription().textRenderingMode());
1087         case CSSPropertyTextOverflow:
1088             if (style->textOverflow())
1089                 return CSSPrimitiveValue::createIdentifier(CSSValueEllipsis);
1090             return CSSPrimitiveValue::createIdentifier(CSSValueClip);
1091         case CSSPropertyWebkitTextSecurity:
1092             return CSSPrimitiveValue::create(style->textSecurity());
1093         case CSSPropertyWebkitTextSizeAdjust:
1094             if (style->textSizeAdjust())
1095                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1096             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
1097         case CSSPropertyWebkitTextStrokeColor:
1098             return currentColorOrValidColor(style.get(), style->textStrokeColor());
1099         case CSSPropertyWebkitTextStrokeWidth:
1100             return CSSPrimitiveValue::create(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX);
1101         case CSSPropertyTextTransform:
1102             return CSSPrimitiveValue::create(style->textTransform());
1103         case CSSPropertyTop:
1104             return getPositionOffsetValue(style.get(), CSSPropertyTop);
1105         case CSSPropertyUnicodeBidi:
1106             return CSSPrimitiveValue::create(style->unicodeBidi());
1107         case CSSPropertyVerticalAlign:
1108             switch (style->verticalAlign()) {
1109                 case BASELINE:
1110                     return CSSPrimitiveValue::createIdentifier(CSSValueBaseline);
1111                 case MIDDLE:
1112                     return CSSPrimitiveValue::createIdentifier(CSSValueMiddle);
1113                 case SUB:
1114                     return CSSPrimitiveValue::createIdentifier(CSSValueSub);
1115                 case SUPER:
1116                     return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
1117                 case TEXT_TOP:
1118                     return CSSPrimitiveValue::createIdentifier(CSSValueTextTop);
1119                 case TEXT_BOTTOM:
1120                     return CSSPrimitiveValue::createIdentifier(CSSValueTextBottom);
1121                 case TOP:
1122                     return CSSPrimitiveValue::createIdentifier(CSSValueTop);
1123                 case BOTTOM:
1124                     return CSSPrimitiveValue::createIdentifier(CSSValueBottom);
1125                 case BASELINE_MIDDLE:
1126                     return CSSPrimitiveValue::createIdentifier(CSSValueWebkitBaselineMiddle);
1127                 case LENGTH:
1128                     return CSSPrimitiveValue::create(style->verticalAlignLength());
1129             }
1130             ASSERT_NOT_REACHED();
1131             return 0;
1132         case CSSPropertyVisibility:
1133             return CSSPrimitiveValue::create(style->visibility());
1134         case CSSPropertyWhiteSpace:
1135             return CSSPrimitiveValue::create(style->whiteSpace());
1136         case CSSPropertyWidows:
1137             return CSSPrimitiveValue::create(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
1138         case CSSPropertyWidth:
1139             if (renderer)
1140                 return CSSPrimitiveValue::create(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX);
1141             return CSSPrimitiveValue::create(style->width());
1142         case CSSPropertyWordBreak:
1143             return CSSPrimitiveValue::create(style->wordBreak());
1144         case CSSPropertyWordSpacing:
1145             return CSSPrimitiveValue::create(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
1146         case CSSPropertyWordWrap:
1147             return CSSPrimitiveValue::create(style->wordWrap());
1148         case CSSPropertyWebkitLineBreak:
1149             return CSSPrimitiveValue::create(style->khtmlLineBreak());
1150         case CSSPropertyWebkitNbspMode:
1151             return CSSPrimitiveValue::create(style->nbspMode());
1152         case CSSPropertyWebkitMatchNearestMailBlockquoteColor:
1153             return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor());
1154         case CSSPropertyResize:
1155             return CSSPrimitiveValue::create(style->resize());
1156         case CSSPropertyWebkitFontSmoothing:
1157             return CSSPrimitiveValue::create(style->fontDescription().fontSmoothing());
1158         case CSSPropertyZIndex:
1159             if (style->hasAutoZIndex())
1160                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1161             return CSSPrimitiveValue::create(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
1162         case CSSPropertyZoom:
1163             return CSSPrimitiveValue::create(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
1164         case CSSPropertyWebkitBoxSizing:
1165             if (style->boxSizing() == CONTENT_BOX)
1166                 return CSSPrimitiveValue::createIdentifier(CSSValueContentBox);
1167             return CSSPrimitiveValue::createIdentifier(CSSValueBorderBox);
1168 #if ENABLE(DASHBOARD_SUPPORT)
1169         case CSSPropertyWebkitDashboardRegion:
1170         {
1171             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
1172             unsigned count = regions.size();
1173             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
1174                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
1175
1176             RefPtr<DashboardRegion> firstRegion;
1177             DashboardRegion* previousRegion = 0;
1178             for (unsigned i = 0; i < count; i++) {
1179                 RefPtr<DashboardRegion> region = DashboardRegion::create();
1180                 StyleDashboardRegion styleRegion = regions[i];
1181
1182                 region->m_label = styleRegion.label;
1183                 LengthBox offset = styleRegion.offset;
1184                 region->setTop(CSSPrimitiveValue::create(offset.top().value(), CSSPrimitiveValue::CSS_PX));
1185                 region->setRight(CSSPrimitiveValue::create(offset.right().value(), CSSPrimitiveValue::CSS_PX));
1186                 region->setBottom(CSSPrimitiveValue::create(offset.bottom().value(), CSSPrimitiveValue::CSS_PX));
1187                 region->setLeft(CSSPrimitiveValue::create(offset.left().value(), CSSPrimitiveValue::CSS_PX));
1188                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
1189                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
1190
1191                 if (previousRegion)
1192                     previousRegion->m_next = region;
1193                 else
1194                     firstRegion = region;
1195                 previousRegion = region.get();
1196             }
1197             return CSSPrimitiveValue::create(firstRegion.release());
1198         }
1199 #endif
1200         case CSSPropertyWebkitAnimationDelay:
1201             return getDelayValue(style->animations());
1202         case CSSPropertyWebkitAnimationDirection: {
1203             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1204             const AnimationList* t = style->animations();
1205             if (t) {
1206                 for (size_t i = 0; i < t->size(); ++i) {
1207                     if (t->animation(i)->direction())
1208                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueAlternate));
1209                     else
1210                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal));
1211                 }
1212             } else
1213                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal));
1214             return list.release();
1215         }
1216         case CSSPropertyWebkitAnimationDuration:
1217             return getDurationValue(style->animations());
1218         case CSSPropertyWebkitAnimationFillMode: {
1219             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1220             const AnimationList* t = style->animations();
1221             if (t) {
1222                 for (size_t i = 0; i < t->size(); ++i) {
1223                     switch (t->animation(i)->fillMode()) {
1224                     case AnimationFillModeNone:
1225                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
1226                         break;
1227                     case AnimationFillModeForwards:
1228                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueForwards));
1229                         break;
1230                     case AnimationFillModeBackwards:
1231                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBackwards));
1232                         break;
1233                     case AnimationFillModeBoth:
1234                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBoth));
1235                         break;
1236                     }
1237                 }
1238             } else
1239                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
1240             return list.release();
1241         }
1242         case CSSPropertyWebkitAnimationIterationCount: {
1243             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1244             const AnimationList* t = style->animations();
1245             if (t) {
1246                 for (size_t i = 0; i < t->size(); ++i) {
1247                     int iterationCount = t->animation(i)->iterationCount();
1248                     if (iterationCount == Animation::IterationCountInfinite)
1249                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueInfinite));
1250                     else
1251                         list->append(CSSPrimitiveValue::create(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
1252                 }
1253             } else
1254                 list->append(CSSPrimitiveValue::create(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
1255             return list.release();
1256         }
1257         case CSSPropertyWebkitAnimationName: {
1258             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1259             const AnimationList* t = style->animations();
1260             if (t) {
1261                 for (size_t i = 0; i < t->size(); ++i) {
1262                     list->append(CSSPrimitiveValue::create(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
1263                 }
1264             } else
1265                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
1266             return list.release();
1267         }
1268         case CSSPropertyWebkitAnimationPlayState: {
1269             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1270             const AnimationList* t = style->animations();
1271             if (t) {
1272                 for (size_t i = 0; i < t->size(); ++i) {
1273                     int prop = t->animation(i)->playState();
1274                     if (prop == AnimPlayStatePlaying)
1275                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
1276                     else
1277                         list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused));
1278                 }
1279             } else
1280                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
1281             return list.release();
1282         }
1283         case CSSPropertyWebkitAnimationTimingFunction:
1284             return getTimingFunctionValue(style->animations());
1285         case CSSPropertyWebkitAppearance:
1286             return CSSPrimitiveValue::create(style->appearance());
1287         case CSSPropertyWebkitBackfaceVisibility:
1288             return CSSPrimitiveValue::createIdentifier((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
1289         case CSSPropertyWebkitBorderImage:
1290             return valueForNinePieceImage(style->borderImage());
1291         case CSSPropertyWebkitMaskBoxImage:
1292             return valueForNinePieceImage(style->maskBoxImage());
1293         case CSSPropertyWebkitFontSizeDelta:
1294             // Not a real style property -- used by the editing engine -- so has no computed value.
1295             break;
1296         case CSSPropertyWebkitMarginBottomCollapse:
1297             return CSSPrimitiveValue::create(style->marginBottomCollapse());
1298         case CSSPropertyWebkitMarginTopCollapse:
1299             return CSSPrimitiveValue::create(style->marginTopCollapse());
1300         case CSSPropertyWebkitPerspective:
1301             if (!style->hasPerspective())
1302                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
1303             return CSSPrimitiveValue::create(style->perspective(), CSSPrimitiveValue::CSS_NUMBER);
1304         case CSSPropertyWebkitPerspectiveOrigin: {
1305             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1306             if (renderer) {
1307                 IntRect box = sizingBox(renderer);
1308                 list->append(CSSPrimitiveValue::create(style->perspectiveOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX));
1309                 list->append(CSSPrimitiveValue::create(style->perspectiveOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX));
1310             }
1311             else {
1312                 list->append(CSSPrimitiveValue::create(style->perspectiveOriginX()));
1313                 list->append(CSSPrimitiveValue::create(style->perspectiveOriginY()));
1314             }
1315             return list.release();
1316         }
1317         case CSSPropertyWebkitRtlOrdering:
1318             if (style->visuallyOrdered())
1319                 return CSSPrimitiveValue::createIdentifier(CSSValueVisual);
1320             return CSSPrimitiveValue::createIdentifier(CSSValueLogical);
1321         case CSSPropertyWebkitUserDrag:
1322             return CSSPrimitiveValue::create(style->userDrag());
1323         case CSSPropertyWebkitUserSelect:
1324             return CSSPrimitiveValue::create(style->userSelect());
1325         case CSSPropertyBorderBottomLeftRadius:
1326             return getBorderRadiusCornerValue(style->borderBottomLeftRadius());
1327         case CSSPropertyBorderBottomRightRadius:
1328             return getBorderRadiusCornerValue(style->borderBottomRightRadius());
1329         case CSSPropertyBorderTopLeftRadius:
1330             return getBorderRadiusCornerValue(style->borderTopLeftRadius());
1331         case CSSPropertyBorderTopRightRadius:
1332             return getBorderRadiusCornerValue(style->borderTopRightRadius());
1333         case CSSPropertyClip: {
1334             if (!style->hasClip())
1335                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1336             RefPtr<Rect> rect = Rect::create();
1337             rect->setTop(CSSPrimitiveValue::create(style->clip().top().value(), CSSPrimitiveValue::CSS_PX));
1338             rect->setRight(CSSPrimitiveValue::create(style->clip().right().value(), CSSPrimitiveValue::CSS_PX));
1339             rect->setBottom(CSSPrimitiveValue::create(style->clip().bottom().value(), CSSPrimitiveValue::CSS_PX));
1340             rect->setLeft(CSSPrimitiveValue::create(style->clip().left().value(), CSSPrimitiveValue::CSS_PX));
1341             return CSSPrimitiveValue::create(rect.release());
1342         }
1343         case CSSPropertyWebkitTransform:
1344             return computedTransform(renderer, style.get());
1345         case CSSPropertyWebkitTransformOrigin: {
1346             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1347             if (renderer) {
1348                 IntRect box = sizingBox(renderer);
1349                 list->append(CSSPrimitiveValue::create(style->transformOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX));
1350                 list->append(CSSPrimitiveValue::create(style->transformOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX));
1351                 if (style->transformOriginZ() != 0)
1352                     list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX));
1353             } else {
1354                 list->append(CSSPrimitiveValue::create(style->transformOriginX()));
1355                 list->append(CSSPrimitiveValue::create(style->transformOriginY()));
1356                 if (style->transformOriginZ() != 0)
1357                     list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX));
1358             }
1359             return list.release();
1360         }
1361         case CSSPropertyWebkitTransformStyle:
1362             return CSSPrimitiveValue::createIdentifier((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
1363         case CSSPropertyWebkitTransitionDelay:
1364             return getDelayValue(style->transitions());
1365         case CSSPropertyWebkitTransitionDuration:
1366             return getDurationValue(style->transitions());
1367         case CSSPropertyWebkitTransitionProperty: {
1368             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1369             const AnimationList* t = style->transitions();
1370             if (t) {
1371                 for (size_t i = 0; i < t->size(); ++i) {
1372                     int prop = t->animation(i)->property();
1373                     RefPtr<CSSValue> propertyValue;
1374                     if (prop == cAnimateNone)
1375                         propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueNone);
1376                     else if (prop == cAnimateAll)
1377                         propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueAll);
1378                     else
1379                         propertyValue = CSSPrimitiveValue::create(getPropertyName(static_cast<CSSPropertyID>(prop)), CSSPrimitiveValue::CSS_STRING);
1380                     list->append(propertyValue);
1381                 }
1382             } else
1383                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAll));
1384             return list.release();
1385         }
1386         case CSSPropertyWebkitTransitionTimingFunction:
1387             return getTimingFunctionValue(style->transitions());
1388         case CSSPropertyPointerEvents:
1389             return CSSPrimitiveValue::create(style->pointerEvents());
1390         case CSSPropertyWebkitColorCorrection:
1391             return CSSPrimitiveValue::create(style->colorSpace());
1392
1393         /* Shorthand properties, currently not supported see bug 13658*/
1394         case CSSPropertyBackground:
1395         case CSSPropertyBorder:
1396         case CSSPropertyBorderBottom:
1397         case CSSPropertyBorderColor:
1398         case CSSPropertyBorderLeft:
1399         case CSSPropertyBorderRadius:
1400         case CSSPropertyBorderRight:
1401         case CSSPropertyBorderStyle:
1402         case CSSPropertyBorderTop:
1403         case CSSPropertyBorderWidth:
1404         case CSSPropertyFont:
1405         case CSSPropertyListStyle:
1406         case CSSPropertyMargin:
1407         case CSSPropertyPadding:
1408             break;
1409
1410         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
1411         case CSSPropertyTextLineThrough:
1412         case CSSPropertyTextLineThroughColor:
1413         case CSSPropertyTextLineThroughMode:
1414         case CSSPropertyTextLineThroughStyle:
1415         case CSSPropertyTextLineThroughWidth:
1416         case CSSPropertyTextOverline:
1417         case CSSPropertyTextOverlineColor:
1418         case CSSPropertyTextOverlineMode:
1419         case CSSPropertyTextOverlineStyle:
1420         case CSSPropertyTextOverlineWidth:
1421         case CSSPropertyTextUnderline:
1422         case CSSPropertyTextUnderlineColor:
1423         case CSSPropertyTextUnderlineMode:
1424         case CSSPropertyTextUnderlineStyle:
1425         case CSSPropertyTextUnderlineWidth:
1426             break;
1427
1428         /* Unimplemented @font-face properties */
1429         case CSSPropertyFontStretch:
1430         case CSSPropertySrc:
1431         case CSSPropertyUnicodeRange:
1432             break;
1433
1434         /* Other unimplemented properties */
1435         case CSSPropertyBackgroundRepeatX:
1436         case CSSPropertyBackgroundRepeatY:
1437         case CSSPropertyContent: // FIXME: needs implementation, bug 23668
1438         case CSSPropertyCounterIncrement:
1439         case CSSPropertyCounterReset:
1440         case CSSPropertyOutline: // FIXME: needs implementation
1441         case CSSPropertyOutlineOffset: // FIXME: needs implementation
1442         case CSSPropertyPage: // for @page
1443         case CSSPropertyQuotes: // FIXME: needs implementation
1444         case CSSPropertySize: // for @page
1445             break;
1446
1447         /* Unimplemented -webkit- properties */
1448         case CSSPropertyWebkitAnimation:
1449         case CSSPropertyWebkitBorderRadius:
1450         case CSSPropertyWebkitColumns:
1451         case CSSPropertyWebkitColumnRule:
1452         case CSSPropertyWebkitMarginCollapse:
1453         case CSSPropertyWebkitMarginStart:
1454         case CSSPropertyWebkitMarquee:
1455         case CSSPropertyWebkitMarqueeSpeed:
1456         case CSSPropertyWebkitMask:
1457         case CSSPropertyWebkitMaskRepeatX:
1458         case CSSPropertyWebkitMaskRepeatY:
1459         case CSSPropertyWebkitPaddingStart:
1460         case CSSPropertyWebkitPerspectiveOriginX:
1461         case CSSPropertyWebkitPerspectiveOriginY:
1462         case CSSPropertyWebkitTextStroke:
1463         case CSSPropertyWebkitTransformOriginX:
1464         case CSSPropertyWebkitTransformOriginY:
1465         case CSSPropertyWebkitTransformOriginZ:
1466         case CSSPropertyWebkitTransition:
1467         case CSSPropertyWebkitVariableDeclarationBlock:
1468             break;
1469 #if ENABLE(SVG)
1470         // FIXME: This default case ruins the point of using an enum for
1471         // properties -- it prevents us from getting a warning when we
1472         // forget to list a property above.
1473         default:
1474             return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
1475 #endif
1476     }
1477
1478     logUnimplementedPropertyID(propertyID);
1479     return 0;
1480 }
1481
1482 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const
1483 {
1484     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
1485     if (value)
1486         return value->cssText();
1487     return "";
1488 }
1489
1490 bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const
1491 {
1492     // All computed styles have a priority of false (not "important").
1493     return false;
1494 }
1495
1496 String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec)
1497 {
1498     ec = NO_MODIFICATION_ALLOWED_ERR;
1499     return String();
1500 }
1501
1502 void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec)
1503 {
1504     ec = NO_MODIFICATION_ALLOWED_ERR;
1505 }
1506
1507 unsigned CSSComputedStyleDeclaration::virtualLength() const
1508 {
1509     Node* node = m_node.get();
1510     if (!node)
1511         return 0;
1512
1513     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
1514     if (!style)
1515         return 0;
1516
1517     return numComputedProperties;
1518 }
1519
1520 String CSSComputedStyleDeclaration::item(unsigned i) const
1521 {
1522     if (i >= length())
1523         return "";
1524
1525     return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
1526 }
1527
1528 bool CSSComputedStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
1529 {
1530     if (property->id() == CSSPropertyFontSize && property->value()->isPrimitiveValue() && m_node) {
1531         m_node->document()->updateLayoutIgnorePendingStylesheets();
1532         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
1533         if (style && style->fontDescription().keywordSize()) {
1534             int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
1535             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(property->value());
1536             if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_IDENT && primitiveValue->getIdent() == sizeValue)
1537                 return true;
1538         }
1539     }
1540
1541     return CSSStyleDeclaration::cssPropertyMatches(property);
1542 }
1543
1544 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const
1545 {
1546     return copyPropertiesInSet(computedProperties, numComputedProperties);
1547 }
1548
1549 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable()
1550 {
1551     return copy();
1552 }
1553
1554 } // namespace WebCore