WebCore:
[WebKit-https.git] / WebCore / css / CSSComputedStyleDeclaration.cpp
1 /**
2  *
3  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
4  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
6  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
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 "CSSBorderImageValue.h"
28 #include "CSSMutableStyleDeclaration.h"
29 #include "CSSPrimitiveValue.h"
30 #include "CSSPrimitiveValueMappings.h"
31 #include "CSSPropertyNames.h"
32 #include "CSSValueList.h"
33 #include "CachedImage.h"
34 #include "DashboardRegion.h"
35 #include "Document.h"
36 #include "ExceptionCode.h"
37 #include "Pair.h"
38 #include "RenderObject.h"
39 #include "ShadowValue.h"
40
41 namespace WebCore {
42
43 // List of all properties we know how to compute, omitting shorthands.
44 static const int computedProperties[] = {
45     CSSPropertyBackgroundAttachment,
46     CSSPropertyBackgroundColor,
47     CSSPropertyBackgroundImage,
48     // more specific background-position-x/y are non-standard
49     CSSPropertyBackgroundPosition,
50     CSSPropertyBackgroundRepeat,
51     CSSPropertyBorderBottomColor,
52     CSSPropertyBorderBottomStyle,
53     CSSPropertyBorderBottomWidth,
54     CSSPropertyBorderCollapse,
55     CSSPropertyBorderLeftColor,
56     CSSPropertyBorderLeftStyle,
57     CSSPropertyBorderLeftWidth,
58     CSSPropertyBorderRightColor,
59     CSSPropertyBorderRightStyle,
60     CSSPropertyBorderRightWidth,
61     CSSPropertyBorderTopColor,
62     CSSPropertyBorderTopStyle,
63     CSSPropertyBorderTopWidth,
64     CSSPropertyBottom,
65     CSSPropertyCaptionSide,
66     CSSPropertyClear,
67     CSSPropertyColor,
68     CSSPropertyCursor,
69     CSSPropertyDirection,
70     CSSPropertyDisplay,
71     CSSPropertyEmptyCells,
72     CSSPropertyFloat,
73     CSSPropertyFontFamily,
74     CSSPropertyFontSize,
75     CSSPropertyFontStyle,
76     CSSPropertyFontVariant,
77     CSSPropertyFontWeight,
78     CSSPropertyHeight,
79     CSSPropertyLeft,
80     CSSPropertyLetterSpacing,
81     CSSPropertyLineHeight,
82     CSSPropertyListStyleImage,
83     CSSPropertyListStylePosition,
84     CSSPropertyListStyleType,
85     CSSPropertyMarginBottom,
86     CSSPropertyMarginLeft,
87     CSSPropertyMarginRight,
88     CSSPropertyMarginTop,
89     CSSPropertyMaxHeight,
90     CSSPropertyMaxWidth,
91     CSSPropertyMinHeight,
92     CSSPropertyMinWidth,
93     CSSPropertyOpacity,
94     CSSPropertyOrphans,
95     CSSPropertyOutlineColor,
96     CSSPropertyOutlineStyle,
97     CSSPropertyOutlineWidth,
98     CSSPropertyOverflowX,
99     CSSPropertyOverflowY,
100     CSSPropertyPaddingBottom,
101     CSSPropertyPaddingLeft,
102     CSSPropertyPaddingRight,
103     CSSPropertyPaddingTop,
104     CSSPropertyPageBreakAfter,
105     CSSPropertyPageBreakBefore,
106     CSSPropertyPageBreakInside,
107     CSSPropertyPosition,
108     CSSPropertyResize,
109     CSSPropertyRight,
110     CSSPropertyTableLayout,
111     CSSPropertyTextAlign,
112     CSSPropertyTextDecoration,
113     CSSPropertyTextIndent,
114     CSSPropertyTextShadow,
115     CSSPropertyTextTransform,
116     CSSPropertyTop,
117     CSSPropertyUnicodeBidi,
118     CSSPropertyVerticalAlign,
119     CSSPropertyVisibility,
120     CSSPropertyWhiteSpace,
121     CSSPropertyWidows,
122     CSSPropertyWidth,
123     CSSPropertyWordSpacing,
124     CSSPropertyWordWrap,
125     CSSPropertyZIndex,
126     CSSPropertyZoom,
127
128     CSSPropertyWebkitAppearance,
129     CSSPropertyWebkitBackgroundClip,
130     CSSPropertyWebkitBackgroundComposite,
131     CSSPropertyWebkitBackgroundOrigin,
132     CSSPropertyWebkitBackgroundSize,
133     CSSPropertyWebkitBorderFit,
134     CSSPropertyWebkitBorderImage,
135     CSSPropertyWebkitBorderHorizontalSpacing,
136     CSSPropertyWebkitBorderVerticalSpacing,
137     CSSPropertyWebkitBoxAlign,
138     CSSPropertyWebkitBoxDirection,
139     CSSPropertyWebkitBoxFlex,
140     CSSPropertyWebkitBoxFlexGroup,
141     CSSPropertyWebkitBoxLines,
142     CSSPropertyWebkitBoxOrdinalGroup,
143     CSSPropertyWebkitBoxOrient,
144     CSSPropertyWebkitBoxPack,
145     CSSPropertyWebkitBoxReflect,
146     CSSPropertyWebkitBoxShadow,
147     CSSPropertyWebkitBoxSizing,
148     CSSPropertyWebkitColumnBreakAfter,
149     CSSPropertyWebkitColumnBreakBefore,
150     CSSPropertyWebkitColumnBreakInside,
151     CSSPropertyWebkitColumnCount,
152     CSSPropertyWebkitColumnGap,
153     CSSPropertyWebkitColumnRuleColor,
154     CSSPropertyWebkitColumnRuleStyle,
155     CSSPropertyWebkitColumnRuleWidth,
156     CSSPropertyWebkitColumnWidth,
157     CSSPropertyWebkitHighlight,
158     CSSPropertyWebkitLineBreak,
159     CSSPropertyWebkitLineClamp,
160     CSSPropertyWebkitMarginBottomCollapse,
161     CSSPropertyWebkitMarginTopCollapse,
162     CSSPropertyWebkitMarqueeDirection,
163     CSSPropertyWebkitMarqueeIncrement,
164     CSSPropertyWebkitMarqueeRepetition,
165     CSSPropertyWebkitMarqueeStyle,
166     CSSPropertyWebkitMaskAttachment,
167     CSSPropertyWebkitMaskBoxImage,
168     CSSPropertyWebkitMaskImage,
169     CSSPropertyWebkitMaskPosition,
170     CSSPropertyWebkitMaskRepeat,
171     CSSPropertyWebkitMaskClip,
172     CSSPropertyWebkitMaskComposite,
173     CSSPropertyWebkitMaskOrigin,
174     CSSPropertyWebkitMaskSize,
175     CSSPropertyWebkitNbspMode,
176     CSSPropertyWebkitRtlOrdering,
177     CSSPropertyWebkitTextDecorationsInEffect,
178     CSSPropertyWebkitTextFillColor,
179     CSSPropertyWebkitTextSecurity,
180     CSSPropertyWebkitTextStrokeColor,
181     CSSPropertyWebkitTextStrokeWidth,
182     CSSPropertyWebkitUserDrag,
183     CSSPropertyWebkitUserModify,
184     CSSPropertyWebkitUserSelect,
185     CSSPropertyWebkitDashboardRegion,
186     CSSPropertyWebkitBorderBottomLeftRadius,
187     CSSPropertyWebkitBorderBottomRightRadius,
188     CSSPropertyWebkitBorderTopLeftRadius,
189     CSSPropertyWebkitBorderTopRightRadius
190     
191 #if ENABLE(SVG)
192     ,
193     CSSPropertyClipPath,
194     CSSPropertyClipRule,
195     CSSPropertyMask,
196     CSSPropertyFilter,
197     CSSPropertyFloodColor,
198     CSSPropertyFloodOpacity,
199     CSSPropertyLightingColor,
200     CSSPropertyStopColor,
201     CSSPropertyStopOpacity,
202     CSSPropertyPointerEvents,
203     CSSPropertyColorInterpolation,
204     CSSPropertyColorInterpolationFilters,
205     CSSPropertyColorRendering,
206     CSSPropertyFill,
207     CSSPropertyFillOpacity,
208     CSSPropertyFillRule,
209     CSSPropertyImageRendering,
210     CSSPropertyMarkerEnd,
211     CSSPropertyMarkerMid,
212     CSSPropertyMarkerStart,
213     CSSPropertyShapeRendering,
214     CSSPropertyStroke,
215     CSSPropertyStrokeDasharray,
216     CSSPropertyStrokeDashoffset,
217     CSSPropertyStrokeLinecap,
218     CSSPropertyStrokeLinejoin,
219     CSSPropertyStrokeMiterlimit,
220     CSSPropertyStrokeOpacity,
221     CSSPropertyStrokeWidth,
222     CSSPropertyTextRendering,
223     CSSPropertyAlignmentBaseline,
224     CSSPropertyBaselineShift,
225     CSSPropertyDominantBaseline,
226     CSSPropertyKerning,
227     CSSPropertyTextAnchor,
228     CSSPropertyWritingMode,
229     CSSPropertyGlyphOrientationHorizontal,
230     CSSPropertyGlyphOrientationVertical
231 #endif
232 };
233
234 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
235
236 static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow)
237 {
238     if (!shadow)
239         return new CSSPrimitiveValue(CSSValueNone);
240
241     RefPtr<CSSValueList> list = new CSSValueList;
242     for (const ShadowData* s = shadow; s; s = s->next) {
243         RefPtr<CSSPrimitiveValue> x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
244         RefPtr<CSSPrimitiveValue> y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
245         RefPtr<CSSPrimitiveValue> blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
246         RefPtr<CSSPrimitiveValue> color = new CSSPrimitiveValue(s->color.rgb());
247         list->prepend(new ShadowValue(x.release(), y.release(), blur.release(), color.release()));
248     }
249     return list.release();
250 }
251
252 static int valueForRepeatRule(int rule)
253 {
254     switch (rule) {
255         case RepeatImageRule:
256             return CSSValueRepeat;
257         case RoundImageRule:
258             return CSSValueRound;
259         default:
260             return CSSValueStretch;
261     }
262     
263     ASSERT_NOT_REACHED();
264     return CSSValueStretch;
265 }
266         
267 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
268 {
269     if (!image.hasImage())
270         return new CSSPrimitiveValue(CSSValueNone);
271     
272     // Image first.
273     RefPtr<CSSValue> imageValue;
274     if (image.image())
275         imageValue = image.image()->cssValue();
276     
277     // Create the slices.
278     RefPtr<CSSPrimitiveValue> top;
279     if (image.m_slices.top.isPercent())
280         top = new CSSPrimitiveValue(image.m_slices.top.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
281     else
282         top = new CSSPrimitiveValue(image.m_slices.top.value(), CSSPrimitiveValue::CSS_NUMBER);
283         
284     RefPtr<CSSPrimitiveValue> right;
285     if (image.m_slices.right.isPercent())
286         right = new CSSPrimitiveValue(image.m_slices.right.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
287     else
288         right = new CSSPrimitiveValue(image.m_slices.right.value(), CSSPrimitiveValue::CSS_NUMBER);
289         
290     RefPtr<CSSPrimitiveValue> bottom;
291     if (image.m_slices.bottom.isPercent())
292         bottom = new CSSPrimitiveValue(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
293     else
294         bottom = new CSSPrimitiveValue(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_NUMBER);
295     
296     RefPtr<CSSPrimitiveValue> left;
297     if (image.m_slices.left.isPercent())
298         left = new CSSPrimitiveValue(image.m_slices.left.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
299     else
300         left = new CSSPrimitiveValue(image.m_slices.left.value(), CSSPrimitiveValue::CSS_NUMBER);
301
302     RefPtr<Rect> rect = new Rect();
303     rect->setTop(top);
304     rect->setRight(right);
305     rect->setBottom(bottom);
306     rect->setLeft(left);
307
308     return new CSSBorderImageValue(imageValue, rect, valueForRepeatRule(image.m_horizontalRule), valueForRepeatRule(image.m_verticalRule));
309 }
310
311 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection)
312 {
313     if (!reflection)
314         return new CSSPrimitiveValue(CSSValueNone);
315
316     RefPtr<CSSReflectValue> reflectValue = new CSSReflectValue();
317     reflectValue->setDirection(reflection->direction());
318     if (reflection->offset().isPercent())
319         reflectValue->setOffset(new CSSPrimitiveValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
320     else
321         reflectValue->setOffset(new CSSPrimitiveValue(reflection->offset().value(), CSSPrimitiveValue::CSS_PX));
322     
323     reflectValue->setMask(valueForNinePieceImage(reflection->mask()));
324     return reflectValue.release();
325 }
326
327 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID)
328 {
329     if (!style)
330         return 0;
331
332     Length l;
333     switch (propertyID) {
334         case CSSPropertyLeft:
335             l = style->left();
336             break;
337         case CSSPropertyRight:
338             l = style->right();
339             break;
340         case CSSPropertyTop:
341             l = style->top();
342             break;
343         case CSSPropertyBottom:
344             l = style->bottom();
345             break;
346         default:
347             return 0;
348     }
349
350     if (style->position() == AbsolutePosition || style->position() == FixedPosition)
351         return new CSSPrimitiveValue(l);
352
353     if (style->position() == RelativePosition)
354         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
355         // In other words if left is auto and right is not auto, then left's computed value is negative right.
356         // So we should get the opposite length unit and see if it is auto.
357         return new CSSPrimitiveValue(l);
358
359     return new CSSPrimitiveValue(CSSValueAuto);
360 }
361
362 static PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle* style, const Color& color)
363 {
364     if (!color.isValid())
365         return new CSSPrimitiveValue(style->color().rgb());
366     return new CSSPrimitiveValue(color.rgb());
367 }
368
369 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius)
370 {
371     if (radius.width() == radius.height())
372         return new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX);
373
374     RefPtr<CSSValueList> list = new CSSValueList(true);
375     list->append(new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX));
376     list->append(new CSSPrimitiveValue(radius.height(), CSSPrimitiveValue::CSS_PX));
377     return list.release();
378 }
379
380 static IntRect sizingBox(RenderObject* renderer)
381 {
382     return renderer->style()->boxSizing() == CONTENT_BOX ? renderer->contentBox() : renderer->borderBox();
383 }
384
385 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n)
386     : m_node(n)
387 {
388 }
389
390 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
391 {
392 }
393
394 String CSSComputedStyleDeclaration::cssText() const
395 {
396     String result("");
397
398     for (unsigned i = 0; i < numComputedProperties; i++) {
399         if (i)
400             result += " ";
401         result += getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
402         result += ": ";
403         result += getPropertyValue(computedProperties[i]);
404         result += ";";
405     }
406
407     return result;
408 }
409
410 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
411 {
412     ec = NO_MODIFICATION_ALLOWED_ERR;
413 }
414
415 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
416 {
417     return getPropertyCSSValue(propertyID, UpdateLayout);
418 }
419
420 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
421 {
422     Node* node = m_node.get();
423     if (!node)
424         return 0;
425
426     // Make sure our layout is up to date before we allow a query on these attributes.
427     if (updateLayout)
428         node->document()->updateLayoutIgnorePendingStylesheets();
429
430     RenderObject* renderer = node->renderer();
431
432     RenderStyle* style = node->computedStyle();
433     if (!style)
434         return 0;
435
436     switch (static_cast<CSSPropertyID>(propertyID)) {
437         case CSSPropertyInvalid:
438             break;
439
440         case CSSPropertyBackgroundColor:
441             return new CSSPrimitiveValue(style->backgroundColor().rgb());
442         case CSSPropertyBackgroundImage:
443             if (style->backgroundImage())
444                 return style->backgroundImage()->cssValue();
445             return new CSSPrimitiveValue(CSSValueNone);
446         case CSSPropertyWebkitBackgroundSize: {
447             RefPtr<CSSValueList> list = new CSSValueList(true);
448             list->append(new CSSPrimitiveValue(style->backgroundSize().width));
449             list->append(new CSSPrimitiveValue(style->backgroundSize().height));
450             return list.release();
451         }  
452         case CSSPropertyBackgroundRepeat:
453             return new CSSPrimitiveValue(style->backgroundRepeat());
454         case CSSPropertyWebkitBackgroundComposite:
455             return new CSSPrimitiveValue(style->backgroundComposite());
456         case CSSPropertyBackgroundAttachment:
457             if (style->backgroundAttachment())
458                 return new CSSPrimitiveValue(CSSValueScroll);
459             return new CSSPrimitiveValue(CSSValueFixed);
460         case CSSPropertyWebkitBackgroundClip:
461         case CSSPropertyWebkitBackgroundOrigin: {
462             EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip ? style->backgroundClip() : style->backgroundOrigin());
463             return new CSSPrimitiveValue(box);
464         }
465         case CSSPropertyBackgroundPosition: {
466             RefPtr<CSSValueList> list = new CSSValueList(true);
467
468             list->append(new CSSPrimitiveValue(style->backgroundXPosition()));
469             list->append(new CSSPrimitiveValue(style->backgroundYPosition()));
470
471             return list.release();
472         }
473         case CSSPropertyBackgroundPositionX:
474             return new CSSPrimitiveValue(style->backgroundXPosition());
475         case CSSPropertyBackgroundPositionY:
476             return new CSSPrimitiveValue(style->backgroundYPosition());
477         case CSSPropertyBorderCollapse:
478             if (style->borderCollapse())
479                 return new CSSPrimitiveValue(CSSValueCollapse);
480             return new CSSPrimitiveValue(CSSValueSeparate);
481         case CSSPropertyBorderSpacing: {
482             RefPtr<CSSValueList> list = new CSSValueList(true);
483             list->append(new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
484             list->append(new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
485             return list.release();
486         }  
487         case CSSPropertyWebkitBorderHorizontalSpacing:
488             return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
489         case CSSPropertyWebkitBorderVerticalSpacing:
490             return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
491         case CSSPropertyBorderTopColor:
492             return currentColorOrValidColor(style, style->borderTopColor());
493         case CSSPropertyBorderRightColor:
494             return currentColorOrValidColor(style, style->borderRightColor());
495         case CSSPropertyBorderBottomColor:
496             return currentColorOrValidColor(style, style->borderBottomColor());
497         case CSSPropertyBorderLeftColor:
498             return currentColorOrValidColor(style, style->borderLeftColor());
499         case CSSPropertyBorderTopStyle:
500             return new CSSPrimitiveValue(style->borderTopStyle());
501         case CSSPropertyBorderRightStyle:
502             return new CSSPrimitiveValue(style->borderRightStyle());
503         case CSSPropertyBorderBottomStyle:
504             return new CSSPrimitiveValue(style->borderBottomStyle());
505         case CSSPropertyBorderLeftStyle:
506             return new CSSPrimitiveValue(style->borderLeftStyle());
507         case CSSPropertyBorderTopWidth:
508             return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
509         case CSSPropertyBorderRightWidth:
510             return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
511         case CSSPropertyBorderBottomWidth:
512             return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
513         case CSSPropertyBorderLeftWidth:
514             return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
515         case CSSPropertyBottom:
516             return getPositionOffsetValue(style, CSSPropertyBottom);
517         case CSSPropertyWebkitBoxAlign:
518             return new CSSPrimitiveValue(style->boxAlign());
519         case CSSPropertyWebkitBoxDirection:
520             return new CSSPrimitiveValue(style->boxDirection());
521         case CSSPropertyWebkitBoxFlex:
522             return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
523         case CSSPropertyWebkitBoxFlexGroup:
524             return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
525         case CSSPropertyWebkitBoxLines:
526             return new CSSPrimitiveValue(style->boxLines());
527         case CSSPropertyWebkitBoxOrdinalGroup:
528             return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
529         case CSSPropertyWebkitBoxOrient:
530             return new CSSPrimitiveValue(style->boxOrient());
531         case CSSPropertyWebkitBoxPack: {
532             EBoxAlignment boxPack = style->boxPack();
533             ASSERT(boxPack != BSTRETCH);
534             ASSERT(boxPack != BBASELINE);
535             if (boxPack == BJUSTIFY || boxPack== BBASELINE)
536                 return 0;
537             return new CSSPrimitiveValue(boxPack);
538         }
539         case CSSPropertyWebkitBoxReflect:
540             return valueForReflection(style->boxReflect());
541         case CSSPropertyWebkitBoxShadow:
542             return valueForShadow(style->boxShadow());
543         case CSSPropertyCaptionSide:
544             return new CSSPrimitiveValue(style->captionSide());
545         case CSSPropertyClear:
546             return new CSSPrimitiveValue(style->clear());
547         case CSSPropertyColor:
548             return new CSSPrimitiveValue(style->color().rgb());
549         case CSSPropertyWebkitColumnCount:
550             if (style->hasAutoColumnCount())
551                 return new CSSPrimitiveValue(CSSValueAuto);
552             return new CSSPrimitiveValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
553         case CSSPropertyWebkitColumnGap:
554             if (style->hasNormalColumnGap())
555                 return new CSSPrimitiveValue(CSSValueNormal);
556             return new CSSPrimitiveValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
557         case CSSPropertyWebkitColumnRuleColor:
558             return currentColorOrValidColor(style, style->columnRuleColor());
559         case CSSPropertyWebkitColumnRuleStyle:
560             return new CSSPrimitiveValue(style->columnRuleStyle());
561         case CSSPropertyWebkitColumnRuleWidth:
562             return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
563         case CSSPropertyWebkitColumnBreakAfter:
564             return new CSSPrimitiveValue(style->columnBreakAfter());
565         case CSSPropertyWebkitColumnBreakBefore:
566             return new CSSPrimitiveValue(style->columnBreakBefore());
567         case CSSPropertyWebkitColumnBreakInside:
568             return new CSSPrimitiveValue(style->columnBreakInside());
569         case CSSPropertyWebkitColumnWidth:
570             if (style->hasAutoColumnWidth())
571                 return new CSSPrimitiveValue(CSSValueAuto);
572             return new CSSPrimitiveValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
573         case CSSPropertyCursor: {
574             RefPtr<CSSValueList> list;
575             CursorList* cursors = style->cursors();
576             if (cursors && cursors->size() > 0) {
577                 list = new CSSValueList;
578                 for (unsigned i = 0; i < cursors->size(); ++i)
579                     list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
580             }
581             RefPtr<CSSValue> value = new CSSPrimitiveValue(style->cursor());
582             if (list) {
583                 list->append(value);
584                 return list.release();
585             }
586             return value.release();
587         }
588         case CSSPropertyDirection:
589             return new CSSPrimitiveValue(style->direction());
590         case CSSPropertyDisplay:
591             return new CSSPrimitiveValue(style->display());
592         case CSSPropertyEmptyCells:
593             return new CSSPrimitiveValue(style->emptyCells());
594         case CSSPropertyFloat:
595             return new CSSPrimitiveValue(style->floating());
596         case CSSPropertyFontFamily:
597             // FIXME: This only returns the first family.
598             return new CSSPrimitiveValue(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING);
599         case CSSPropertyFontSize:
600             return new CSSPrimitiveValue(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
601         case CSSPropertyWebkitBinding:
602             break;
603         case CSSPropertyFontStyle:
604             if (style->fontDescription().italic())
605                 return new CSSPrimitiveValue(CSSValueItalic);
606             return new CSSPrimitiveValue(CSSValueNormal);
607         case CSSPropertyFontVariant:
608             if (style->fontDescription().smallCaps())
609                 return new CSSPrimitiveValue(CSSValueSmallCaps);
610             return new CSSPrimitiveValue(CSSValueNormal);
611         case CSSPropertyFontWeight:
612             switch (style->fontDescription().weight()) {
613                 case FontWeight100:
614                     return new CSSPrimitiveValue(CSSValue100);
615                 case FontWeight200:
616                     return new CSSPrimitiveValue(CSSValue200);
617                 case FontWeight300:
618                     return new CSSPrimitiveValue(CSSValue300);
619                 case FontWeightNormal:
620                     return new CSSPrimitiveValue(CSSValueNormal);
621                 case FontWeight500:
622                     return new CSSPrimitiveValue(CSSValue500);
623                 case FontWeight600:
624                     return new CSSPrimitiveValue(CSSValue600);
625                 case FontWeightBold:
626                     return new CSSPrimitiveValue(CSSValueBold);
627                 case FontWeight800:
628                     return new CSSPrimitiveValue(CSSValue800);
629                 case FontWeight900:
630                     return new CSSPrimitiveValue(CSSValue900);
631             }
632             ASSERT_NOT_REACHED();
633             return new CSSPrimitiveValue(CSSValueNormal);
634         case CSSPropertyHeight:
635             if (renderer)
636                 return new CSSPrimitiveValue(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX);
637             return new CSSPrimitiveValue(style->height());
638         case CSSPropertyWebkitHighlight:
639             if (style->highlight() == nullAtom)
640                 return new CSSPrimitiveValue(CSSValueNone);
641             return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
642         case CSSPropertyWebkitBorderFit:
643             if (style->borderFit() == BorderFitBorder)
644                 return new CSSPrimitiveValue(CSSValueBorder);
645             return new CSSPrimitiveValue(CSSValueLines);
646         case CSSPropertyLeft:
647             return getPositionOffsetValue(style, CSSPropertyLeft);
648         case CSSPropertyLetterSpacing:
649             if (!style->letterSpacing())
650                 return new CSSPrimitiveValue(CSSValueNormal);
651             return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
652         case CSSPropertyWebkitLineClamp:
653             if (style->lineClamp() == -1)
654                 return new CSSPrimitiveValue(CSSValueNone);
655             return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
656         case CSSPropertyLineHeight: {
657             Length length = style->lineHeight();
658             if (length.isNegative())
659                 return new CSSPrimitiveValue(CSSValueNormal);
660             if (length.isPercent())
661                 // This is imperfect, because it doesn't include the zoom factor and the real computation
662                 // for how high to be in pixels does include things like minimum font size and the zoom factor.
663                 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
664                 // that here either.
665                 return new CSSPrimitiveValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX);
666             return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
667         }
668         case CSSPropertyListStyleImage:
669             if (style->listStyleImage())
670                 return style->listStyleImage()->cssValue();
671             return new CSSPrimitiveValue(CSSValueNone);
672         case CSSPropertyListStylePosition:
673             return new CSSPrimitiveValue(style->listStylePosition());
674         case CSSPropertyListStyleType:
675             return new CSSPrimitiveValue(style->listStyleType());
676         case CSSPropertyMarginTop:
677             if (renderer)
678                 // FIXME: Supposed to return the percentage if percentage was specified.
679                 return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
680             return new CSSPrimitiveValue(style->marginTop());
681         case CSSPropertyMarginRight:
682             if (renderer)
683                 // FIXME: Supposed to return the percentage if percentage was specified.
684                 return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
685             return new CSSPrimitiveValue(style->marginRight());
686         case CSSPropertyMarginBottom:
687             if (renderer)
688                 // FIXME: Supposed to return the percentage if percentage was specified.
689                 return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
690             return new CSSPrimitiveValue(style->marginBottom());
691         case CSSPropertyMarginLeft:
692             if (renderer)
693                 // FIXME: Supposed to return the percentage if percentage was specified.
694                 return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
695             return new CSSPrimitiveValue(style->marginLeft());
696         case CSSPropertyWebkitMarqueeDirection:
697             return new CSSPrimitiveValue(style->marqueeDirection());
698         case CSSPropertyWebkitMarqueeIncrement:
699             return new CSSPrimitiveValue(style->marqueeIncrement());
700         case CSSPropertyWebkitMarqueeRepetition:
701             if (style->marqueeLoopCount() < 0)
702                 return new CSSPrimitiveValue(CSSValueInfinite);
703             return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
704         case CSSPropertyWebkitMarqueeStyle:
705             return new CSSPrimitiveValue(style->marqueeBehavior());
706         case CSSPropertyWebkitMaskImage:
707             if (style->maskImage())
708                 return style->maskImage()->cssValue();
709             return new CSSPrimitiveValue(CSSValueNone);
710         case CSSPropertyWebkitMaskSize: {
711             RefPtr<CSSValueList> list = new CSSValueList(true);
712             list->append(new CSSPrimitiveValue(style->maskSize().width));
713             list->append(new CSSPrimitiveValue(style->maskSize().height));
714             return list.release();
715         }  
716         case CSSPropertyWebkitMaskRepeat:
717             return new CSSPrimitiveValue(style->maskRepeat());
718         case CSSPropertyWebkitMaskAttachment:
719             if (style->maskAttachment())
720                 return new CSSPrimitiveValue(CSSValueScroll);
721             return new CSSPrimitiveValue(CSSValueFixed);
722         case CSSPropertyWebkitMaskComposite:
723             return new CSSPrimitiveValue(style->maskComposite());
724         case CSSPropertyWebkitMaskClip:
725         case CSSPropertyWebkitMaskOrigin: {
726             EFillBox box = (propertyID == CSSPropertyWebkitMaskClip ? style->maskClip() : style->maskOrigin());
727             return new CSSPrimitiveValue(box);
728         }
729         case CSSPropertyWebkitMaskPosition: {
730             RefPtr<CSSValueList> list = new CSSValueList(true);
731
732             list->append(new CSSPrimitiveValue(style->maskXPosition()));
733             list->append(new CSSPrimitiveValue(style->maskYPosition()));
734
735             return list.release();
736         }
737         case CSSPropertyWebkitMaskPositionX:
738             return new CSSPrimitiveValue(style->maskXPosition());
739         case CSSPropertyWebkitMaskPositionY:
740             return new CSSPrimitiveValue(style->maskYPosition());
741         case CSSPropertyWebkitUserModify:
742             return new CSSPrimitiveValue(style->userModify());
743         case CSSPropertyMaxHeight: {
744             const Length& maxHeight = style->maxHeight();
745             if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
746                 return new CSSPrimitiveValue(CSSValueNone);
747             return new CSSPrimitiveValue(maxHeight);
748         }
749         case CSSPropertyMaxWidth: {
750             const Length& maxWidth = style->maxHeight();
751             if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
752                 return new CSSPrimitiveValue(CSSValueNone);
753             return new CSSPrimitiveValue(maxWidth);
754         }
755         case CSSPropertyMinHeight:
756             return new CSSPrimitiveValue(style->minHeight());
757         case CSSPropertyMinWidth:
758             return new CSSPrimitiveValue(style->minWidth());
759         case CSSPropertyOpacity:
760             return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
761         case CSSPropertyOrphans:
762             return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
763         case CSSPropertyOutlineColor:
764             return currentColorOrValidColor(style, style->outlineColor());
765         case CSSPropertyOutlineStyle:
766             if (style->outlineStyleIsAuto())
767                 return new CSSPrimitiveValue(CSSValueAuto);
768             return new CSSPrimitiveValue(style->outlineStyle());
769         case CSSPropertyOutlineWidth:
770             return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
771         case CSSPropertyOverflow:
772             return new CSSPrimitiveValue(max(style->overflowX(), style->overflowY()));
773         case CSSPropertyOverflowX:
774             return new CSSPrimitiveValue(style->overflowX());
775         case CSSPropertyOverflowY:
776             return new CSSPrimitiveValue(style->overflowY());
777         case CSSPropertyPaddingTop:
778             if (renderer)
779                 return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
780             return new CSSPrimitiveValue(style->paddingTop());
781         case CSSPropertyPaddingRight:
782             if (renderer)
783                 return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
784             return new CSSPrimitiveValue(style->paddingRight());
785         case CSSPropertyPaddingBottom:
786             if (renderer)
787                 return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
788             return new CSSPrimitiveValue(style->paddingBottom());
789         case CSSPropertyPaddingLeft:
790             if (renderer)
791                 return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
792             return new CSSPrimitiveValue(style->paddingLeft());
793         case CSSPropertyPageBreakAfter:
794             return new CSSPrimitiveValue(style->pageBreakAfter());
795         case CSSPropertyPageBreakBefore:
796             return new CSSPrimitiveValue(style->pageBreakBefore());
797         case CSSPropertyPageBreakInside: {
798             EPageBreak pageBreak = style->pageBreakInside();
799             ASSERT(pageBreak != PBALWAYS);
800             if (pageBreak == PBALWAYS)
801                 return 0;
802             return new CSSPrimitiveValue(style->pageBreakInside());
803         }
804         case CSSPropertyPosition:
805             return new CSSPrimitiveValue(style->position());
806         case CSSPropertyRight:
807             return getPositionOffsetValue(style, CSSPropertyRight);
808         case CSSPropertyTableLayout:
809             return new CSSPrimitiveValue(style->tableLayout());
810         case CSSPropertyTextAlign:
811             return new CSSPrimitiveValue(style->textAlign());
812         case CSSPropertyTextDecoration: {
813             String string;
814             if (style->textDecoration() & UNDERLINE)
815                 string += "underline";
816             if (style->textDecoration() & OVERLINE) {
817                 if (string.length())
818                     string += " ";
819                 string += "overline";
820             }
821             if (style->textDecoration() & LINE_THROUGH) {
822                 if (string.length())
823                     string += " ";
824                 string += "line-through";
825             }
826             if (style->textDecoration() & BLINK) {
827                 if (string.length())
828                     string += " ";
829                 string += "blink";
830             }
831             if (!string.length())
832                 return new CSSPrimitiveValue(CSSValueNone);
833             return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
834         }
835         case CSSPropertyWebkitTextDecorationsInEffect: {
836             String string;
837             if (style->textDecorationsInEffect() & UNDERLINE)
838                 string += "underline";
839             if (style->textDecorationsInEffect() & OVERLINE) {
840                 if (string.length())
841                     string += " ";
842                 string += "overline";
843             }
844             if (style->textDecorationsInEffect() & LINE_THROUGH) {
845                 if (string.length())
846                     string += " ";
847                 string += "line-through";
848             }
849             if (style->textDecorationsInEffect() & BLINK) {
850                 if (string.length())
851                     string += " ";
852                 string += "blink";
853             }
854             if (!string.length())
855                 return new CSSPrimitiveValue(CSSValueNone);
856             return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
857         }
858         case CSSPropertyWebkitTextFillColor:
859             return currentColorOrValidColor(style, style->textFillColor());
860         case CSSPropertyTextIndent:
861             return new CSSPrimitiveValue(style->textIndent());
862         case CSSPropertyTextShadow:
863             return valueForShadow(style->textShadow());
864         case CSSPropertyWebkitTextSecurity:
865             return new CSSPrimitiveValue(style->textSecurity());
866         case CSSPropertyWebkitTextSizeAdjust:
867             if (style->textSizeAdjust())
868                 return new CSSPrimitiveValue(CSSValueAuto);
869             return new CSSPrimitiveValue(CSSValueNone);
870         case CSSPropertyWebkitTextStrokeColor:
871             return currentColorOrValidColor(style, style->textStrokeColor());
872         case CSSPropertyWebkitTextStrokeWidth:
873             return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX);
874         case CSSPropertyTextTransform:
875             return new CSSPrimitiveValue(style->textTransform());
876         case CSSPropertyTop:
877             return getPositionOffsetValue(style, CSSPropertyTop);
878         case CSSPropertyUnicodeBidi:
879             return new CSSPrimitiveValue(style->unicodeBidi());
880         case CSSPropertyVerticalAlign:
881             switch (style->verticalAlign()) {
882                 case BASELINE:
883                     return new CSSPrimitiveValue(CSSValueBaseline);
884                 case MIDDLE:
885                     return new CSSPrimitiveValue(CSSValueMiddle);
886                 case SUB:
887                     return new CSSPrimitiveValue(CSSValueSub);
888                 case SUPER:
889                     return new CSSPrimitiveValue(CSSValueSuper);
890                 case TEXT_TOP:
891                     return new CSSPrimitiveValue(CSSValueTextTop);
892                 case TEXT_BOTTOM:
893                     return new CSSPrimitiveValue(CSSValueTextBottom);
894                 case TOP:
895                     return new CSSPrimitiveValue(CSSValueTop);
896                 case BOTTOM:
897                     return new CSSPrimitiveValue(CSSValueBottom);
898                 case BASELINE_MIDDLE:
899                     return new CSSPrimitiveValue(CSSValueWebkitBaselineMiddle);
900                 case LENGTH:
901                     return new CSSPrimitiveValue(style->verticalAlignLength());
902             }
903             ASSERT_NOT_REACHED();
904             return 0;
905         case CSSPropertyVisibility:
906             return new CSSPrimitiveValue(style->visibility());
907         case CSSPropertyWhiteSpace:
908             return new CSSPrimitiveValue(style->whiteSpace());
909         case CSSPropertyWidows:
910             return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
911         case CSSPropertyWidth:
912             if (renderer)
913                 return new CSSPrimitiveValue(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX);
914             return new CSSPrimitiveValue(style->width());
915         case CSSPropertyWordBreak:
916             return new CSSPrimitiveValue(style->wordBreak());
917         case CSSPropertyWordSpacing:
918             return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
919         case CSSPropertyWordWrap:
920             return new CSSPrimitiveValue(style->wordWrap());
921         case CSSPropertyWebkitLineBreak:
922             return new CSSPrimitiveValue(style->khtmlLineBreak());
923         case CSSPropertyWebkitNbspMode:
924             return new CSSPrimitiveValue(style->nbspMode());
925         case CSSPropertyWebkitMatchNearestMailBlockquoteColor:
926             return new CSSPrimitiveValue(style->matchNearestMailBlockquoteColor());
927         case CSSPropertyResize:
928             return new CSSPrimitiveValue(style->resize());
929         case CSSPropertyZIndex:
930             if (style->hasAutoZIndex())
931                 return new CSSPrimitiveValue(CSSValueAuto);
932             return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
933         case CSSPropertyZoom:
934             return new CSSPrimitiveValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
935         case CSSPropertyWebkitBoxSizing:
936             if (style->boxSizing() == CONTENT_BOX)
937                 return new CSSPrimitiveValue(CSSValueContentBox);
938             return new CSSPrimitiveValue(CSSValueBorderBox);
939         case CSSPropertyWebkitDashboardRegion:
940         {
941             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
942             unsigned count = regions.size();
943             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
944                 return new CSSPrimitiveValue(CSSValueNone);
945
946             RefPtr<DashboardRegion> firstRegion;
947             DashboardRegion* previousRegion = 0;
948             for (unsigned i = 0; i < count; i++) {
949                 RefPtr<DashboardRegion> region = new DashboardRegion;
950                 StyleDashboardRegion styleRegion = regions[i];
951
952                 region->m_label = styleRegion.label;
953                 LengthBox offset = styleRegion.offset;
954                 region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX));
955                 region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX));
956                 region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX));
957                 region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX));
958                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
959                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
960
961                 if (previousRegion)
962                     previousRegion->m_next = region;
963                 else
964                     firstRegion = region;
965                 previousRegion = region.get();
966             }
967             return new CSSPrimitiveValue(firstRegion.release());
968         }
969         case CSSPropertyWebkitAppearance:
970             return new CSSPrimitiveValue(style->appearance());
971         case CSSPropertyWebkitBorderImage:
972             return valueForNinePieceImage(style->borderImage());
973         case CSSPropertyWebkitMaskBoxImage:
974             return valueForNinePieceImage(style->maskBoxImage());
975         case CSSPropertyWebkitFontSizeDelta:
976             // Not a real style property -- used by the editing engine -- so has no computed value.
977             break;
978         case CSSPropertyWebkitMarginBottomCollapse:
979             return new CSSPrimitiveValue(style->marginBottomCollapse());
980         case CSSPropertyWebkitMarginTopCollapse:
981             return new CSSPrimitiveValue(style->marginTopCollapse());
982         case CSSPropertyWebkitRtlOrdering:
983             if (style->visuallyOrdered())
984                 return new CSSPrimitiveValue(CSSValueVisual);
985             return new CSSPrimitiveValue(CSSValueLogical);
986         case CSSPropertyWebkitUserDrag:
987             return new CSSPrimitiveValue(style->userDrag());
988         case CSSPropertyWebkitUserSelect:
989             return new CSSPrimitiveValue(style->userSelect());
990         case CSSPropertyWebkitBorderBottomLeftRadius:
991             return getBorderRadiusCornerValue(style->borderBottomLeftRadius());
992         case CSSPropertyWebkitBorderBottomRightRadius:
993             return getBorderRadiusCornerValue(style->borderBottomRightRadius());
994         case CSSPropertyWebkitBorderTopLeftRadius:
995             return getBorderRadiusCornerValue(style->borderTopLeftRadius());
996         case CSSPropertyWebkitBorderTopRightRadius:
997             return getBorderRadiusCornerValue(style->borderTopRightRadius());
998         case CSSPropertyBackground:
999         case CSSPropertyBorder:
1000         case CSSPropertyBorderBottom:
1001         case CSSPropertyBorderColor:
1002         case CSSPropertyBorderLeft:
1003         case CSSPropertyBorderRight:
1004         case CSSPropertyBorderStyle:
1005         case CSSPropertyBorderTop:
1006         case CSSPropertyBorderWidth:
1007         case CSSPropertyClip:
1008         case CSSPropertyContent:
1009         case CSSPropertyCounterIncrement:
1010         case CSSPropertyCounterReset:
1011         case CSSPropertyFont:
1012         case CSSPropertyFontStretch:
1013         case CSSPropertyListStyle:
1014         case CSSPropertyMargin:
1015         case CSSPropertyOutline:
1016         case CSSPropertyOutlineOffset:
1017         case CSSPropertyPadding:
1018         case CSSPropertyPage:
1019         case CSSPropertyQuotes:
1020         case CSSPropertyScrollbar3dlightColor:
1021         case CSSPropertyScrollbarArrowColor:
1022         case CSSPropertyScrollbarDarkshadowColor:
1023         case CSSPropertyScrollbarFaceColor:
1024         case CSSPropertyScrollbarHighlightColor:
1025         case CSSPropertyScrollbarShadowColor:
1026         case CSSPropertyScrollbarTrackColor:
1027         case CSSPropertySrc: // Only used in @font-face rules.
1028         case CSSPropertySize:
1029         case CSSPropertyTextLineThrough:
1030         case CSSPropertyTextLineThroughColor:
1031         case CSSPropertyTextLineThroughMode:
1032         case CSSPropertyTextLineThroughStyle:
1033         case CSSPropertyTextLineThroughWidth:
1034         case CSSPropertyTextOverflow:
1035         case CSSPropertyTextOverline:
1036         case CSSPropertyTextOverlineColor:
1037         case CSSPropertyTextOverlineMode:
1038         case CSSPropertyTextOverlineStyle:
1039         case CSSPropertyTextOverlineWidth:
1040         case CSSPropertyTextUnderline:
1041         case CSSPropertyTextUnderlineColor:
1042         case CSSPropertyTextUnderlineMode:
1043         case CSSPropertyTextUnderlineStyle:
1044         case CSSPropertyTextUnderlineWidth:
1045         case CSSPropertyUnicodeRange: // Only used in @font-face rules.
1046         case CSSPropertyWebkitBorderRadius:
1047         case CSSPropertyWebkitColumns:
1048         case CSSPropertyWebkitColumnRule:
1049         case CSSPropertyWebkitMarginCollapse:
1050         case CSSPropertyWebkitMarginStart:
1051         case CSSPropertyWebkitMarquee:
1052         case CSSPropertyWebkitMarqueeSpeed:
1053         case CSSPropertyWebkitPaddingStart:
1054         case CSSPropertyWebkitTextStroke:
1055         case CSSPropertyWebkitTransform:
1056         case CSSPropertyWebkitTransformOrigin:
1057         case CSSPropertyWebkitTransformOriginX:
1058         case CSSPropertyWebkitTransformOriginY:
1059         case CSSPropertyWebkitTransition:
1060         case CSSPropertyWebkitTransitionDuration:
1061         case CSSPropertyWebkitTransitionProperty:
1062         case CSSPropertyWebkitTransitionRepeatCount:
1063         case CSSPropertyWebkitTransitionTimingFunction:
1064             // FIXME: The above are unimplemented.
1065             break;
1066 #if ENABLE(SVG)
1067         default:
1068             return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
1069 #endif
1070     }
1071
1072     LOG_ERROR("unimplemented propertyID: %d", propertyID);
1073     return 0;
1074 }
1075
1076 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const
1077 {
1078     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
1079     if (value)
1080         return value->cssText();
1081     return "";
1082 }
1083
1084 bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const
1085 {
1086     // All computed styles have a priority of false (not "important").
1087     return false;
1088 }
1089
1090 String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec)
1091 {
1092     ec = NO_MODIFICATION_ALLOWED_ERR;
1093     return String();
1094 }
1095
1096 void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec)
1097 {
1098     ec = NO_MODIFICATION_ALLOWED_ERR;
1099 }
1100
1101 unsigned CSSComputedStyleDeclaration::length() const
1102 {
1103     Node* node = m_node.get();
1104     if (!node)
1105         return 0;
1106
1107     RenderStyle* style = node->computedStyle();
1108     if (!style)
1109         return 0;
1110
1111     return numComputedProperties;
1112 }
1113
1114 String CSSComputedStyleDeclaration::item(unsigned i) const
1115 {
1116     if (i >= length())
1117         return String();
1118
1119     return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
1120 }
1121
1122 // This is the list of properties we want to copy in the copyInheritableProperties() function.
1123 // It is the intersection of the list of inherited CSS properties and the
1124 // properties for which we have a computed implementation in this file.
1125 const int inheritableProperties[] = {
1126     CSSPropertyBorderCollapse,
1127     CSSPropertyColor,
1128     CSSPropertyFontFamily,
1129     CSSPropertyFontSize,
1130     CSSPropertyFontStyle,
1131     CSSPropertyFontVariant,
1132     CSSPropertyFontWeight,
1133     CSSPropertyLetterSpacing,
1134     CSSPropertyLineHeight,
1135     CSSPropertyOrphans,
1136     CSSPropertyTextAlign,
1137     CSSPropertyTextIndent,
1138     CSSPropertyTextTransform,
1139     CSSPropertyWhiteSpace,
1140     CSSPropertyWidows,
1141     CSSPropertyWordSpacing,
1142     CSSPropertyWebkitBorderHorizontalSpacing,
1143     CSSPropertyWebkitBorderVerticalSpacing,
1144     CSSPropertyWebkitTextDecorationsInEffect,
1145     CSSPropertyWebkitTextFillColor,
1146     CSSPropertyWebkitTextSizeAdjust,
1147     CSSPropertyWebkitTextStrokeColor,
1148     CSSPropertyWebkitTextStrokeWidth,
1149 };
1150
1151 const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
1152
1153 void CSSComputedStyleDeclaration::removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration* declaration)
1154 {
1155     declaration->removePropertiesInSet(inheritableProperties, numInheritableProperties);
1156 }
1157
1158 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const
1159 {
1160     RefPtr<CSSMutableStyleDeclaration> style = copyPropertiesInSet(inheritableProperties, numInheritableProperties);
1161     if (style && m_node && m_node->computedStyle()) {
1162         // If a node's text fill color is invalid, then its children use 
1163         // their font-color as their text fill color (they don't
1164         // inherit it).  Likewise for stroke color.
1165         ExceptionCode ec = 0;
1166         if (!m_node->computedStyle()->textFillColor().isValid())
1167             style->removeProperty(CSSPropertyWebkitTextFillColor, ec);
1168         if (!m_node->computedStyle()->textStrokeColor().isValid())
1169             style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec);
1170         ASSERT(ec == 0);
1171     }
1172     return style.release();
1173 }
1174
1175 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const
1176 {
1177     return copyPropertiesInSet(computedProperties, numComputedProperties);
1178 }
1179
1180 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable()
1181 {
1182     return copy();
1183 }
1184
1185 PassRefPtr<CSSComputedStyleDeclaration> computedStyle(Node* node)
1186 {
1187     return new CSSComputedStyleDeclaration(node);
1188 }
1189
1190 } // namespace WebCore