881d69600c363a2d7cca7e1de45c20448631f397
[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  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19  * 02111-1307  USA
20  */
21
22 #include "config.h"
23 #include "CSSComputedStyleDeclaration.h"
24
25 #include "CSSMutableStyleDeclaration.h"
26 #include "CSSPrimitiveValue.h"
27 #include "CSSPropertyNames.h"
28 #include "CSSValueKeywords.h"
29 #include "CSSValueList.h"
30 #include "CachedImage.h"
31 #include "DashboardRegion.h"
32 #include "Document.h"
33 #include "ExceptionCode.h"
34 #include "Pair.h"
35 #include "RenderObject.h"
36 #include "ShadowValue.h"
37
38 namespace WebCore {
39
40 // List of all properties we know how to compute, omitting shorthands.
41 static const int computedProperties[] = {
42     CSS_PROP_BACKGROUND_ATTACHMENT,
43     CSS_PROP_BACKGROUND_COLOR,
44     CSS_PROP_BACKGROUND_IMAGE,
45     CSS_PROP_BACKGROUND_POSITION_X,
46     CSS_PROP_BACKGROUND_POSITION_Y,
47     CSS_PROP_BACKGROUND_REPEAT,
48     CSS_PROP_BORDER_BOTTOM_COLOR,
49     CSS_PROP_BORDER_BOTTOM_STYLE,
50     CSS_PROP_BORDER_BOTTOM_WIDTH,
51     CSS_PROP_BORDER_COLLAPSE,
52     CSS_PROP_BORDER_LEFT_COLOR,
53     CSS_PROP_BORDER_LEFT_STYLE,
54     CSS_PROP_BORDER_LEFT_WIDTH,
55     CSS_PROP_BORDER_RIGHT_COLOR,
56     CSS_PROP_BORDER_RIGHT_STYLE,
57     CSS_PROP_BORDER_RIGHT_WIDTH,
58     CSS_PROP_BORDER_TOP_COLOR,
59     CSS_PROP_BORDER_TOP_STYLE,
60     CSS_PROP_BORDER_TOP_WIDTH,
61     CSS_PROP_BOTTOM,
62     CSS_PROP_BOX_SIZING,
63     CSS_PROP_CAPTION_SIDE,
64     CSS_PROP_CLEAR,
65     CSS_PROP_COLOR,
66     CSS_PROP_CURSOR,
67     CSS_PROP_DIRECTION,
68     CSS_PROP_DISPLAY,
69     CSS_PROP_EMPTY_CELLS,
70     CSS_PROP_FLOAT,
71     CSS_PROP_FONT_FAMILY,
72     CSS_PROP_FONT_SIZE,
73     CSS_PROP_FONT_STRETCH,
74     CSS_PROP_FONT_STYLE,
75     CSS_PROP_FONT_VARIANT,
76     CSS_PROP_FONT_WEIGHT,
77     CSS_PROP_HEIGHT,
78     CSS_PROP_LEFT,
79     CSS_PROP_LETTER_SPACING,
80     CSS_PROP_LINE_HEIGHT,
81     CSS_PROP_LIST_STYLE_IMAGE,
82     CSS_PROP_LIST_STYLE_POSITION,
83     CSS_PROP_LIST_STYLE_TYPE,
84     CSS_PROP_MARGIN_BOTTOM,
85     CSS_PROP_MARGIN_LEFT,
86     CSS_PROP_MARGIN_RIGHT,
87     CSS_PROP_MARGIN_TOP,
88     CSS_PROP_MAX_HEIGHT,
89     CSS_PROP_MAX_WIDTH,
90     CSS_PROP_MIN_HEIGHT,
91     CSS_PROP_MIN_WIDTH,
92     CSS_PROP_OPACITY,
93     CSS_PROP_ORPHANS,
94     CSS_PROP_OUTLINE_COLOR,
95     CSS_PROP_OUTLINE_STYLE,
96     CSS_PROP_OUTLINE_WIDTH,
97     CSS_PROP_OVERFLOW_X,
98     CSS_PROP_OVERFLOW_Y,
99     CSS_PROP_PADDING_BOTTOM,
100     CSS_PROP_PADDING_LEFT,
101     CSS_PROP_PADDING_RIGHT,
102     CSS_PROP_PADDING_TOP,
103     CSS_PROP_PAGE_BREAK_AFTER,
104     CSS_PROP_PAGE_BREAK_BEFORE,
105     CSS_PROP_PAGE_BREAK_INSIDE,
106     CSS_PROP_POSITION,
107     CSS_PROP_RESIZE,
108     CSS_PROP_RIGHT,
109     CSS_PROP_TABLE_LAYOUT,
110     CSS_PROP_TEXT_ALIGN,
111     CSS_PROP_TEXT_DECORATION,
112     CSS_PROP_TEXT_INDENT,
113     CSS_PROP_TEXT_SHADOW,
114     CSS_PROP_TEXT_TRANSFORM,
115     CSS_PROP_TOP,
116     CSS_PROP_UNICODE_BIDI,
117     CSS_PROP_VERTICAL_ALIGN,
118     CSS_PROP_VISIBILITY,
119     CSS_PROP_WHITE_SPACE,
120     CSS_PROP_WIDOWS,
121     CSS_PROP_WIDTH,
122     CSS_PROP_WORD_SPACING,
123     CSS_PROP_WORD_WRAP,
124     CSS_PROP_Z_INDEX,
125
126     CSS_PROP__WEBKIT_APPEARANCE,
127     CSS_PROP__WEBKIT_BACKGROUND_CLIP,
128     CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE,
129     CSS_PROP__WEBKIT_BACKGROUND_ORIGIN,
130     CSS_PROP__WEBKIT_BACKGROUND_SIZE,
131     CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING,
132     CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING,
133     CSS_PROP__WEBKIT_BOX_ALIGN,
134     CSS_PROP__WEBKIT_BOX_DIRECTION,
135     CSS_PROP__WEBKIT_BOX_FLEX,
136     CSS_PROP__WEBKIT_BOX_FLEX_GROUP,
137     CSS_PROP__WEBKIT_BOX_LINES,
138     CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP,
139     CSS_PROP__WEBKIT_BOX_ORIENT,
140     CSS_PROP__WEBKIT_BOX_PACK,
141     CSS_PROP__WEBKIT_BOX_SHADOW,
142     CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER,
143     CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE,
144     CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE,
145     CSS_PROP__WEBKIT_COLUMN_COUNT,
146     CSS_PROP__WEBKIT_COLUMN_GAP,
147     CSS_PROP__WEBKIT_COLUMN_RULE_COLOR,
148     CSS_PROP__WEBKIT_COLUMN_RULE_STYLE,
149     CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH,
150     CSS_PROP__WEBKIT_COLUMN_WIDTH,
151     CSS_PROP__WEBKIT_HIGHLIGHT,
152     CSS_PROP__WEBKIT_LINE_BREAK,
153     CSS_PROP__WEBKIT_LINE_CLAMP,
154     CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE,
155     CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE,
156     CSS_PROP__WEBKIT_MARQUEE_DIRECTION,
157     CSS_PROP__WEBKIT_MARQUEE_INCREMENT,
158     CSS_PROP__WEBKIT_MARQUEE_REPETITION,
159     CSS_PROP__WEBKIT_MARQUEE_STYLE,
160     CSS_PROP__WEBKIT_NBSP_MODE,
161     CSS_PROP__WEBKIT_RTL_ORDERING,
162     CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
163     CSS_PROP__WEBKIT_TEXT_FILL_COLOR,
164     CSS_PROP__WEBKIT_TEXT_SECURITY,
165     CSS_PROP__WEBKIT_TEXT_STROKE_COLOR,
166     CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH,
167     CSS_PROP__WEBKIT_USER_DRAG,
168     CSS_PROP__WEBKIT_USER_MODIFY,
169     CSS_PROP__WEBKIT_USER_SELECT,
170
171 #if PLATFORM(MAC)
172     CSS_PROP__WEBKIT_DASHBOARD_REGION,
173 #endif
174 };
175
176 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
177
178 static PassRefPtr<CSSValue> valueForLength(const Length& length)
179 {
180     switch (length.type()) {
181         case Auto:
182             return new CSSPrimitiveValue(CSS_VAL_AUTO);
183         case WebCore::Fixed:
184             return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
185         case Intrinsic:
186             return new CSSPrimitiveValue(CSS_VAL_INTRINSIC);
187         case MinIntrinsic:
188             return new CSSPrimitiveValue(CSS_VAL_MIN_INTRINSIC);
189         case Percent:
190             return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
191         case Relative:
192         case Static:
193             break;
194     }
195     ASSERT_NOT_REACHED();
196     return 0;
197 }
198
199 // Handles special value for "none".
200 static PassRefPtr<CSSValue> valueForMaxLength(const Length& length)
201 {
202     if (length.isFixed() && length.value() == undefinedLength)
203         return new CSSPrimitiveValue(CSS_VAL_NONE);
204     return valueForLength(length);
205 }
206
207 static PassRefPtr<CSSValue> valueForBorderStyle(EBorderStyle style)
208 {
209     switch (style) {
210         case BNONE:
211             return new CSSPrimitiveValue(CSS_VAL_NONE);
212         case BHIDDEN:
213             return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
214         case INSET:
215             return new CSSPrimitiveValue(CSS_VAL_INSET);
216         case GROOVE:
217             return new CSSPrimitiveValue(CSS_VAL_GROOVE);
218         case RIDGE:
219             return new CSSPrimitiveValue(CSS_VAL_RIDGE);
220         case OUTSET:
221             return new CSSPrimitiveValue(CSS_VAL_OUTSET);
222         case DOTTED:
223             return new CSSPrimitiveValue(CSS_VAL_DOTTED);
224         case DASHED:
225             return new CSSPrimitiveValue(CSS_VAL_DASHED);
226         case SOLID:
227             return new CSSPrimitiveValue(CSS_VAL_SOLID);
228         case DOUBLE:
229             return new CSSPrimitiveValue(CSS_VAL_DOUBLE);
230     }
231     ASSERT_NOT_REACHED();
232     return 0;
233 }
234
235 static PassRefPtr<CSSValue> valueForTextAlign(ETextAlign align)
236 {
237     switch (align) {
238         case TAAUTO:
239             return new CSSPrimitiveValue(CSS_VAL_AUTO);
240         case LEFT:
241             return new CSSPrimitiveValue(CSS_VAL_LEFT);
242         case RIGHT:
243             return new CSSPrimitiveValue(CSS_VAL_RIGHT);
244         case CENTER:
245             return new CSSPrimitiveValue(CSS_VAL_CENTER);
246         case JUSTIFY:
247             return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
248         case KHTML_LEFT:
249             return new CSSPrimitiveValue(CSS_VAL__WEBKIT_LEFT);
250         case KHTML_RIGHT:
251             return new CSSPrimitiveValue(CSS_VAL__WEBKIT_RIGHT);
252         case KHTML_CENTER:
253             return new CSSPrimitiveValue(CSS_VAL__WEBKIT_CENTER);
254     }
255     ASSERT_NOT_REACHED();
256     return 0;
257 }
258
259 static PassRefPtr<CSSValue> valueForAppearance(EAppearance appearance)
260 {
261     switch (appearance) {
262         case NoAppearance:
263             return new CSSPrimitiveValue(CSS_VAL_NONE);
264         case CheckboxAppearance:
265             return new CSSPrimitiveValue(CSS_VAL_CHECKBOX);
266         case RadioAppearance:
267             return new CSSPrimitiveValue(CSS_VAL_RADIO);
268         case PushButtonAppearance:
269             return new CSSPrimitiveValue(CSS_VAL_PUSH_BUTTON);
270         case SquareButtonAppearance:
271             return new CSSPrimitiveValue(CSS_VAL_SQUARE_BUTTON);
272         case ButtonAppearance:
273             return new CSSPrimitiveValue(CSS_VAL_BUTTON);
274         case ButtonBevelAppearance:
275             return new CSSPrimitiveValue(CSS_VAL_BUTTON_BEVEL);
276         case ListboxAppearance:
277             return new CSSPrimitiveValue(CSS_VAL_LISTBOX);
278         case ListItemAppearance:
279             return new CSSPrimitiveValue(CSS_VAL_LISTITEM);
280         case MenulistAppearance:
281             return new CSSPrimitiveValue(CSS_VAL_MENULIST);
282         case MenulistButtonAppearance:
283             return new CSSPrimitiveValue(CSS_VAL_MENULIST_BUTTON);
284         case MenulistTextAppearance:
285             return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXT);
286         case MenulistTextFieldAppearance:
287             return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXTFIELD);
288         case ScrollbarButtonUpAppearance:
289             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_UP);
290         case ScrollbarButtonDownAppearance:
291             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_DOWN);
292         case ScrollbarButtonLeftAppearance:
293             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_LEFT);
294         case ScrollbarButtonRightAppearance:
295             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_RIGHT);
296         case ScrollbarTrackHorizontalAppearance:
297             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_HORIZONTAL);
298         case ScrollbarTrackVerticalAppearance:
299             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_VERTICAL);
300         case ScrollbarThumbHorizontalAppearance:
301             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_HORIZONTAL);
302         case ScrollbarThumbVerticalAppearance:
303             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_VERTICAL);
304         case ScrollbarGripperHorizontalAppearance:
305             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_HORIZONTAL);
306         case ScrollbarGripperVerticalAppearance:
307             return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_VERTICAL);
308         case SliderHorizontalAppearance:
309             return new CSSPrimitiveValue(CSS_VAL_SLIDER_HORIZONTAL);
310         case SliderVerticalAppearance:
311             return new CSSPrimitiveValue(CSS_VAL_SLIDER_VERTICAL);
312         case SliderThumbHorizontalAppearance:
313             return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_HORIZONTAL);
314         case SliderThumbVerticalAppearance:
315             return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_VERTICAL);
316         case CaretAppearance:
317             return new CSSPrimitiveValue(CSS_VAL_CARET);
318         case SearchFieldAppearance:
319             return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD);
320         case SearchFieldDecorationAppearance:
321             return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_DECORATION);
322         case SearchFieldResultsDecorationAppearance:
323             return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_DECORATION);
324         case SearchFieldResultsButtonAppearance:
325             return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_BUTTON);
326         case SearchFieldCancelButtonAppearance:
327             return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_CANCEL_BUTTON);
328         case TextFieldAppearance:
329             return new CSSPrimitiveValue(CSS_VAL_TEXTFIELD);
330         case TextAreaAppearance:
331             return new CSSPrimitiveValue(CSS_VAL_TEXTAREA);
332     }
333     ASSERT_NOT_REACHED();
334     return 0;
335 }
336
337 static PassRefPtr<CSSValue> valueForMarginCollapse(EMarginCollapse collapse)
338 {
339     switch (collapse) {
340         case MCOLLAPSE:
341             return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
342         case MSEPARATE:
343             return new CSSPrimitiveValue(CSS_VAL_SEPARATE);
344         case MDISCARD:
345             return new CSSPrimitiveValue(CSS_VAL_DISCARD);
346     }
347     ASSERT_NOT_REACHED();
348     return 0;
349 }
350
351 static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow)
352 {
353     if (!shadow)
354         return new CSSPrimitiveValue(CSS_VAL_NONE);
355
356     CSSValueList* list = new CSSValueList;
357     for (const ShadowData* s = shadow; s; s = s->next) {
358         CSSPrimitiveValue* x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
359         CSSPrimitiveValue* y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
360         CSSPrimitiveValue* blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
361         CSSPrimitiveValue* color = new CSSPrimitiveValue(s->color.rgb());
362         list->append(new ShadowValue(x, y, blur, color));
363     }
364     return list;
365 }
366
367 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderObject* renderer, int propertyID)
368 {
369     if (!renderer)
370         return 0;
371
372     RenderStyle* style = renderer->style();
373     if (!style)
374         return 0;
375
376     Length l;
377     switch (propertyID) {
378         case CSS_PROP_LEFT:
379             l = style->left();
380             break;
381         case CSS_PROP_RIGHT:
382             l = style->right();
383             break;
384         case CSS_PROP_TOP:
385             l = style->top();
386             break;
387         case CSS_PROP_BOTTOM:
388             l = style->bottom();
389             break;
390         default:
391             return 0;
392     }
393
394     if (renderer->isPositioned())
395         return valueForLength(l);
396
397     if (renderer->isRelPositioned())
398         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
399         // In other words if left is auto and right is not auto, then left's computed value is negative right.
400         // So we should get the opposite length unit and see if it is auto.
401         return valueForLength(l);
402
403     return new CSSPrimitiveValue(CSS_VAL_AUTO);
404 }
405
406 static PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle* style, const Color& color)
407 {
408     if (!color.isValid())
409         return new CSSPrimitiveValue(style->color().rgb());
410     return new CSSPrimitiveValue(color.rgb());
411 }
412
413 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n)
414     : m_node(n)
415 {
416 }
417
418 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
419 {
420 }
421
422 String CSSComputedStyleDeclaration::cssText() const
423 {
424     String result("");
425
426     for (unsigned i = 0; i < numComputedProperties; i++) {
427         if (i)
428             result += " ";
429         result += getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
430         result += ": ";
431         result += getPropertyValue(computedProperties[i]);
432         result += ";";
433     }
434
435     return result;
436 }
437
438 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
439 {
440     ec = NO_MODIFICATION_ALLOWED_ERR;
441 }
442
443 // Display integers in integer format instead of "1.0".
444 static String numberAsString(double n)
445 {
446     long i = static_cast<long>(n);
447     return i == n ? String::number(i) : String::number(n);
448 }
449
450 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
451 {
452     return getPropertyCSSValue(propertyID, UpdateLayout);
453 }
454
455 PassRefPtr<CSSPrimitiveValue> primitiveValueFromLength(Length length)
456 {
457     String string;
458     switch (length.type()) {
459         case Percent:
460             string = numberAsString(length.percent()) + "%";
461             break;
462         case Fixed:
463             string = numberAsString(length.calcMinValue(0));
464             break;
465         case Auto:
466             string = "auto";
467             break;
468         default:
469             break;
470     }
471     return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
472 }
473
474 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
475 {
476     Node* node = m_node.get();
477     if (!node)
478         return 0;
479
480     // Make sure our layout is up to date before we allow a query on these attributes.
481     if (updateLayout)
482         node->document()->updateLayout();
483
484     // FIXME: This should work even if we do not have a renderer.
485     RenderObject* renderer = node->renderer();
486     if (!renderer)
487         return 0;
488
489     RenderStyle* style = renderer->style();
490     if (!style)
491         return 0;
492
493     switch (static_cast<CSSPropertyID>(propertyID)) {
494         case CSS_PROP_INVALID:
495             break;
496
497         case CSS_PROP_BACKGROUND_COLOR:
498             return new CSSPrimitiveValue(style->backgroundColor().rgb());
499         case CSS_PROP_BACKGROUND_IMAGE:
500             if (style->backgroundImage())
501                 return new CSSPrimitiveValue(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
502             return new CSSPrimitiveValue(CSS_VAL_NONE);
503         case CSS_PROP__WEBKIT_BACKGROUND_SIZE:
504             return new CSSPrimitiveValue(new Pair(primitiveValueFromLength(style->backgroundSize().width),
505                 primitiveValueFromLength(style->backgroundSize().height)));
506         case CSS_PROP_BACKGROUND_REPEAT:
507             switch (style->backgroundRepeat()) {
508                 case REPEAT:
509                     return new CSSPrimitiveValue(CSS_VAL_REPEAT);
510                 case REPEAT_X:
511                     return new CSSPrimitiveValue(CSS_VAL_REPEAT_X);
512                 case REPEAT_Y:
513                     return new CSSPrimitiveValue(CSS_VAL_REPEAT_Y);
514                 case NO_REPEAT:
515                     return new CSSPrimitiveValue(CSS_VAL_NO_REPEAT);
516             }
517             ASSERT_NOT_REACHED();
518             return 0;
519         case CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE:
520             switch (style->backgroundComposite()) {
521                 case CompositeClear:
522                     return new CSSPrimitiveValue(CSS_VAL_CLEAR);
523                 case CompositeCopy:
524                     return new CSSPrimitiveValue(CSS_VAL_COPY);
525                 case CompositeSourceOver:
526                     return new CSSPrimitiveValue(CSS_VAL_SOURCE_OVER);
527                 case CompositeSourceIn:
528                     return new CSSPrimitiveValue(CSS_VAL_SOURCE_IN);
529                 case CompositeSourceOut:
530                     return new CSSPrimitiveValue(CSS_VAL_SOURCE_OUT);
531                 case CompositeSourceAtop:
532                     return new CSSPrimitiveValue(CSS_VAL_SOURCE_ATOP);
533                 case CompositeDestinationOver:
534                     return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OVER);
535                 case CompositeDestinationIn:
536                     return new CSSPrimitiveValue(CSS_VAL_DESTINATION_IN);
537                 case CompositeDestinationOut:
538                     return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OUT);
539                 case CompositeDestinationAtop:
540                     return new CSSPrimitiveValue(CSS_VAL_DESTINATION_ATOP);
541                 case CompositeXOR:
542                     return new CSSPrimitiveValue(CSS_VAL_XOR);
543                 case CompositePlusDarker:
544                     return new CSSPrimitiveValue(CSS_VAL_PLUS_DARKER);
545                 case CompositeHighlight:
546                     return new CSSPrimitiveValue(CSS_VAL_HIGHLIGHT);
547                 case CompositePlusLighter:
548                     return new CSSPrimitiveValue(CSS_VAL_PLUS_LIGHTER);
549             }
550             ASSERT_NOT_REACHED();
551             return 0;
552         case CSS_PROP_BACKGROUND_ATTACHMENT:
553             if (style->backgroundAttachment())
554                 return new CSSPrimitiveValue(CSS_VAL_SCROLL);
555             return new CSSPrimitiveValue(CSS_VAL_FIXED);
556         case CSS_PROP__WEBKIT_BACKGROUND_CLIP:
557         case CSS_PROP__WEBKIT_BACKGROUND_ORIGIN: {
558             EBackgroundBox box = (propertyID == CSS_PROP__WEBKIT_BACKGROUND_CLIP ? style->backgroundClip() : style->backgroundOrigin());
559             switch (box) {
560                 case BGBORDER:
561                     return new CSSPrimitiveValue(CSS_VAL_BORDER);
562                 case BGPADDING:
563                     return new CSSPrimitiveValue(CSS_VAL_PADDING);
564                 case BGCONTENT:
565                     return new CSSPrimitiveValue(CSS_VAL_CONTENT);
566             }
567             ASSERT_NOT_REACHED();
568             return 0;
569         }
570         case CSS_PROP_BACKGROUND_POSITION: {
571             String string;
572             Length length(style->backgroundXPosition());
573             if (length.isPercent())
574                 string = numberAsString(length.percent()) + "%";
575             else
576                 string = numberAsString(length.calcMinValue(renderer->contentWidth()));
577             string += " ";
578             length = style->backgroundYPosition();
579             if (length.isPercent())
580                 string += numberAsString(length.percent()) + "%";
581             else
582                 string += numberAsString(length.calcMinValue(renderer->contentWidth()));
583             return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
584         }
585         case CSS_PROP_BACKGROUND_POSITION_X:
586             return valueForLength(style->backgroundXPosition());
587         case CSS_PROP_BACKGROUND_POSITION_Y:
588             return valueForLength(style->backgroundYPosition());
589         case CSS_PROP_BORDER_COLLAPSE:
590             if (style->borderCollapse())
591                 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
592             return new CSSPrimitiveValue(CSS_VAL_SEPARATE);
593         case CSS_PROP_BORDER_SPACING:
594             return new CSSPrimitiveValue(numberAsString(style->horizontalBorderSpacing()) + "px "
595                 + numberAsString(style->verticalBorderSpacing()) + "px", CSSPrimitiveValue::CSS_STRING);
596         case CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING:
597             return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
598         case CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING:
599             return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
600         case CSS_PROP_BORDER_TOP_COLOR:
601             return currentColorOrValidColor(style, style->borderTopColor());
602         case CSS_PROP_BORDER_RIGHT_COLOR:
603             return currentColorOrValidColor(style, style->borderRightColor());
604         case CSS_PROP_BORDER_BOTTOM_COLOR:
605             return currentColorOrValidColor(style, style->borderBottomColor());
606         case CSS_PROP_BORDER_LEFT_COLOR:
607             return currentColorOrValidColor(style, style->borderLeftColor());
608         case CSS_PROP_BORDER_TOP_STYLE:
609             return valueForBorderStyle(style->borderTopStyle());
610         case CSS_PROP_BORDER_RIGHT_STYLE:
611             return valueForBorderStyle(style->borderRightStyle());
612         case CSS_PROP_BORDER_BOTTOM_STYLE:
613             return valueForBorderStyle(style->borderBottomStyle());
614         case CSS_PROP_BORDER_LEFT_STYLE:
615             return valueForBorderStyle(style->borderLeftStyle());
616         case CSS_PROP_BORDER_TOP_WIDTH:
617             return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
618         case CSS_PROP_BORDER_RIGHT_WIDTH:
619             return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
620         case CSS_PROP_BORDER_BOTTOM_WIDTH:
621             return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
622         case CSS_PROP_BORDER_LEFT_WIDTH:
623             return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
624         case CSS_PROP_BOTTOM:
625             return getPositionOffsetValue(renderer, CSS_PROP_BOTTOM);
626         case CSS_PROP__WEBKIT_BOX_ALIGN:
627             switch (style->boxAlign()) {
628                 case BSTRETCH:
629                     return new CSSPrimitiveValue(CSS_VAL_STRETCH);
630                 case BSTART:
631                     return new CSSPrimitiveValue(CSS_VAL_START);
632                 case BCENTER:
633                     return new CSSPrimitiveValue(CSS_VAL_CENTER);
634                 case BEND:
635                     return new CSSPrimitiveValue(CSS_VAL_END);
636                 case BBASELINE:
637                     return new CSSPrimitiveValue(CSS_VAL_BASELINE);
638                 case BJUSTIFY:
639                     break; // not allowed
640             }
641             ASSERT_NOT_REACHED();
642             return 0;
643         case CSS_PROP__WEBKIT_BOX_DIRECTION:
644             switch (style->boxDirection()) {
645                 case BNORMAL:
646                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
647                 case BREVERSE:
648                     return new CSSPrimitiveValue(CSS_VAL_REVERSE);
649             }
650             ASSERT_NOT_REACHED();
651             return 0;
652         case CSS_PROP__WEBKIT_BOX_FLEX:
653             return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
654         case CSS_PROP__WEBKIT_BOX_FLEX_GROUP:
655             return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
656         case CSS_PROP__WEBKIT_BOX_LINES:
657             switch (style->boxLines()) {
658                 case SINGLE:
659                     return new CSSPrimitiveValue(CSS_VAL_SINGLE);
660                 case MULTIPLE:
661                     return new CSSPrimitiveValue(CSS_VAL_MULTIPLE);
662             }
663             ASSERT_NOT_REACHED();
664             return 0;
665         case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP:
666             return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
667         case CSS_PROP__WEBKIT_BOX_ORIENT:
668             switch (style->boxOrient()) {
669                 case HORIZONTAL:
670                     return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
671                 case VERTICAL:
672                     return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
673             }
674             ASSERT_NOT_REACHED();
675             return 0;
676         case CSS_PROP__WEBKIT_BOX_PACK:
677             switch (style->boxPack()) {
678                 case BSTART:
679                     return new CSSPrimitiveValue(CSS_VAL_START);
680                 case BEND:
681                     return new CSSPrimitiveValue(CSS_VAL_END);
682                 case BCENTER:
683                     return new CSSPrimitiveValue(CSS_VAL_CENTER);
684                 case BJUSTIFY:
685                     return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
686                 case BSTRETCH:
687                 case BBASELINE:
688                     break; // not allowed
689             }
690             ASSERT_NOT_REACHED();
691             return 0;
692         case CSS_PROP__WEBKIT_BOX_SHADOW:
693             return valueForShadow(style->boxShadow());
694         case CSS_PROP_CAPTION_SIDE:
695             switch (style->captionSide()) {
696                 case CAPLEFT:
697                     return new CSSPrimitiveValue(CSS_VAL_LEFT);
698                 case CAPRIGHT:
699                     return new CSSPrimitiveValue(CSS_VAL_RIGHT);
700                 case CAPTOP:
701                     return new CSSPrimitiveValue(CSS_VAL_TOP);
702                 case CAPBOTTOM:
703                     return new CSSPrimitiveValue(CSS_VAL_BOTTOM);
704             }
705             ASSERT_NOT_REACHED();
706             return 0;
707         case CSS_PROP_CLEAR:
708             switch (style->clear()) {
709                 case CNONE:
710                     return new CSSPrimitiveValue(CSS_VAL_NONE);
711                 case CLEFT:
712                     return new CSSPrimitiveValue(CSS_VAL_LEFT);
713                 case CRIGHT:
714                     return new CSSPrimitiveValue(CSS_VAL_RIGHT);
715                 case CBOTH:
716                     return new CSSPrimitiveValue(CSS_VAL_BOTH);
717             }
718             ASSERT_NOT_REACHED();
719             return 0;
720         case CSS_PROP_COLOR:
721             return new CSSPrimitiveValue(style->color().rgb());
722         case CSS_PROP__WEBKIT_COLUMN_COUNT:
723             if (style->hasAutoColumnCount())
724                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
725             return new CSSPrimitiveValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
726         case CSS_PROP__WEBKIT_COLUMN_GAP:
727             if (style->hasNormalColumnGap())
728                 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
729             return new CSSPrimitiveValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
730         case CSS_PROP__WEBKIT_COLUMN_RULE_COLOR:
731             return currentColorOrValidColor(style, style->columnRuleColor());
732         case CSS_PROP__WEBKIT_COLUMN_RULE_STYLE:
733             return valueForBorderStyle(style->columnRuleStyle());
734         case CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH:
735             return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
736         case CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER:
737             switch (style->columnBreakAfter()) {
738                 case PBAUTO:
739                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
740                 case PBALWAYS:
741                     return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
742                 case PBAVOID:
743                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
744             }
745             ASSERT_NOT_REACHED();
746             return 0;
747         case CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE:
748             switch (style->columnBreakBefore()) {
749                 case PBAUTO:
750                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
751                 case PBALWAYS:
752                     return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
753                 case PBAVOID:
754                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
755             }
756             ASSERT_NOT_REACHED();
757             return 0;
758         case CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE:
759             switch (style->columnBreakInside()) {
760                 case PBAUTO:
761                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
762                 case PBAVOID:
763                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
764                 case PBALWAYS:
765                     break; // not allowed
766             }
767             ASSERT_NOT_REACHED();
768             return 0;
769         case CSS_PROP__WEBKIT_COLUMN_WIDTH:
770             if (style->hasAutoColumnWidth())
771                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
772             return new CSSPrimitiveValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
773         case CSS_PROP_CURSOR: {
774             CSSValueList* list = 0;
775             CursorList* cursors = style->cursors();
776             if (cursors && cursors->size() > 0) {
777                 list = new CSSValueList;
778                 for (unsigned i = 0; i < cursors->size(); ++i)
779                     list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
780             }
781             CSSValue* value = 0;
782             switch (style->cursor()) {
783                 case CURSOR_AUTO:
784                     value = new CSSPrimitiveValue(CSS_VAL_AUTO);
785                     break;
786                 case CURSOR_CROSS:
787                     value = new CSSPrimitiveValue(CSS_VAL_CROSSHAIR);
788                     break;
789                 case CURSOR_DEFAULT:
790                     value = new CSSPrimitiveValue(CSS_VAL_DEFAULT);
791                     break;
792                 case CURSOR_POINTER:
793                     value = new CSSPrimitiveValue(CSS_VAL_POINTER);
794                     break;
795                 case CURSOR_MOVE:
796                     value = new CSSPrimitiveValue(CSS_VAL_MOVE);
797                     break;
798                 case CURSOR_CELL:
799                     value = new CSSPrimitiveValue(CSS_VAL_CELL);
800                     break;
801                 case CURSOR_VERTICAL_TEXT:
802                     value = new CSSPrimitiveValue(CSS_VAL_VERTICAL_TEXT);
803                     break;
804                 case CURSOR_CONTEXT_MENU:
805                     value = new CSSPrimitiveValue(CSS_VAL_CONTEXT_MENU);
806                     break;
807                 case CURSOR_ALIAS:
808                     value = new CSSPrimitiveValue(CSS_VAL_ALIAS);
809                     break;
810                 case CURSOR_COPY:
811                     value = new CSSPrimitiveValue(CSS_VAL_COPY);
812                     break;
813                 case CURSOR_NONE:
814                     value = new CSSPrimitiveValue(CSS_VAL_NONE);
815                     break;
816                 case CURSOR_PROGRESS:
817                     value = new CSSPrimitiveValue(CSS_VAL_PROGRESS);
818                     break;
819                 case CURSOR_NO_DROP:
820                     value = new CSSPrimitiveValue(CSS_VAL_NO_DROP);
821                     break;
822                 case CURSOR_NOT_ALLOWED:
823                     value = new CSSPrimitiveValue(CSS_VAL_NOT_ALLOWED);
824                     break;
825                 case CURSOR_E_RESIZE:
826                     value = new CSSPrimitiveValue(CSS_VAL_E_RESIZE);
827                     break;
828                 case CURSOR_NE_RESIZE:
829                     value = new CSSPrimitiveValue(CSS_VAL_NE_RESIZE);
830                     break;
831                 case CURSOR_NW_RESIZE:
832                     value = new CSSPrimitiveValue(CSS_VAL_NW_RESIZE);
833                     break;
834                 case CURSOR_N_RESIZE:
835                     value = new CSSPrimitiveValue(CSS_VAL_N_RESIZE);
836                     break;
837                 case CURSOR_SE_RESIZE:
838                     value = new CSSPrimitiveValue(CSS_VAL_SE_RESIZE);
839                     break;
840                 case CURSOR_SW_RESIZE:
841                     value = new CSSPrimitiveValue(CSS_VAL_SW_RESIZE);
842                     break;
843                 case CURSOR_S_RESIZE:
844                     value = new CSSPrimitiveValue(CSS_VAL_S_RESIZE);
845                     break;
846                 case CURSOR_W_RESIZE:
847                     value = new CSSPrimitiveValue(CSS_VAL_W_RESIZE);
848                     break;
849                 case CURSOR_EW_RESIZE:
850                     value = new CSSPrimitiveValue(CSS_VAL_EW_RESIZE);
851                     break;
852                 case CURSOR_NS_RESIZE:
853                     value = new CSSPrimitiveValue(CSS_VAL_NS_RESIZE);
854                     break;
855                 case CURSOR_NESW_RESIZE:
856                     value = new CSSPrimitiveValue(CSS_VAL_NESW_RESIZE);
857                     break;
858                 case CURSOR_NWSE_RESIZE:
859                     value = new CSSPrimitiveValue(CSS_VAL_NWSE_RESIZE);
860                     break;
861                 case CURSOR_COL_RESIZE:
862                     value = new CSSPrimitiveValue(CSS_VAL_COL_RESIZE);
863                     break;
864                 case CURSOR_ROW_RESIZE:
865                     value = new CSSPrimitiveValue(CSS_VAL_ROW_RESIZE);
866                     break;
867                 case CURSOR_TEXT:
868                     value = new CSSPrimitiveValue(CSS_VAL_TEXT);
869                     break;
870                 case CURSOR_WAIT:
871                     value = new CSSPrimitiveValue(CSS_VAL_WAIT);
872                     break;
873                 case CURSOR_HELP:
874                     value = new CSSPrimitiveValue(CSS_VAL_HELP);
875                     break;
876                 case CURSOR_ALL_SCROLL:
877                     value = new CSSPrimitiveValue(CSS_VAL_ALL_SCROLL);
878                     break;
879             }
880             ASSERT(value);
881             if (list) {
882                 list->append(value);
883                 return list;
884             }
885             return value;
886         }
887         case CSS_PROP_DIRECTION:
888             switch (style->direction()) {
889                 case LTR:
890                     return new CSSPrimitiveValue(CSS_VAL_LTR);
891                 case RTL:
892                     return new CSSPrimitiveValue(CSS_VAL_RTL);
893             }
894             ASSERT_NOT_REACHED();
895             return 0;
896         case CSS_PROP_DISPLAY:
897             switch (style->display()) {
898                 case INLINE:
899                     return new CSSPrimitiveValue(CSS_VAL_INLINE);
900                 case BLOCK:
901                     return new CSSPrimitiveValue(CSS_VAL_BLOCK);
902                 case LIST_ITEM:
903                     return new CSSPrimitiveValue(CSS_VAL_LIST_ITEM);
904                 case RUN_IN:
905                     return new CSSPrimitiveValue(CSS_VAL_RUN_IN);
906                 case COMPACT:
907                     return new CSSPrimitiveValue(CSS_VAL_COMPACT);
908                 case INLINE_BLOCK:
909                     return new CSSPrimitiveValue(CSS_VAL_INLINE_BLOCK);
910                 case TABLE:
911                     return new CSSPrimitiveValue(CSS_VAL_TABLE);
912                 case INLINE_TABLE:
913                     return new CSSPrimitiveValue(CSS_VAL_INLINE_TABLE);
914                 case TABLE_ROW_GROUP:
915                     return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW_GROUP);
916                 case TABLE_HEADER_GROUP:
917                     return new CSSPrimitiveValue(CSS_VAL_TABLE_HEADER_GROUP);
918                 case TABLE_FOOTER_GROUP:
919                     return new CSSPrimitiveValue(CSS_VAL_TABLE_FOOTER_GROUP);
920                 case TABLE_ROW:
921                     return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW);
922                 case TABLE_COLUMN_GROUP:
923                     return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN_GROUP);
924                 case TABLE_COLUMN:
925                     return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN);
926                 case TABLE_CELL:
927                     return new CSSPrimitiveValue(CSS_VAL_TABLE_CELL);
928                 case TABLE_CAPTION:
929                     return new CSSPrimitiveValue(CSS_VAL_TABLE_CAPTION);
930                 case BOX:
931                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BOX);
932                 case INLINE_BOX:
933                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_INLINE_BOX);
934                 case NONE:
935                     return new CSSPrimitiveValue(CSS_VAL_NONE);
936             }
937             ASSERT_NOT_REACHED();
938             return 0;
939         case CSS_PROP_EMPTY_CELLS:
940             switch (style->emptyCells()) {
941                 case SHOW:
942                     return new CSSPrimitiveValue(CSS_VAL_SHOW);
943                 case HIDE:
944                     return new CSSPrimitiveValue(CSS_VAL_HIDE);
945             }
946             ASSERT_NOT_REACHED();
947             return 0;
948         case CSS_PROP_FLOAT:
949             switch (style->floating()) {
950                 case FNONE:
951                     return new CSSPrimitiveValue(CSS_VAL_NONE);
952                 case FLEFT:
953                     return new CSSPrimitiveValue(CSS_VAL_LEFT);
954                 case FRIGHT:
955                     return new CSSPrimitiveValue(CSS_VAL_RIGHT);
956             }
957             ASSERT_NOT_REACHED();
958             return 0;
959         case CSS_PROP_FONT_FAMILY:
960             // FIXME: This only returns the first family.
961             return new CSSPrimitiveValue(style->fontDescription().family().family().domString(), CSSPrimitiveValue::CSS_STRING);
962         case CSS_PROP_FONT_SIZE:
963             return new CSSPrimitiveValue(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
964         case CSS_PROP__WEBKIT_BINDING:
965             break;
966         case CSS_PROP_FONT_STRETCH:
967             if (style->fontDescription().stretch() == FontStretchCondensed)
968                 return new CSSPrimitiveValue(CSS_VAL_CONDENSED);
969             if (style->fontDescription().stretch() == FontStretchExpanded)
970                 return new CSSPrimitiveValue(CSS_VAL_EXPANDED);
971             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
972         case CSS_PROP_FONT_STYLE:
973             if (style->fontDescription().italic())
974                 return new CSSPrimitiveValue(CSS_VAL_ITALIC);
975             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
976         case CSS_PROP_FONT_VARIANT:
977             if (style->fontDescription().smallCaps())
978                 return new CSSPrimitiveValue(CSS_VAL_SMALL_CAPS);
979             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
980         case CSS_PROP_FONT_WEIGHT:
981             // FIXME: this does not reflect the full range of weights
982             // that can be expressed with CSS
983             if (style->fontDescription().weight() == cBoldWeight)
984                 return new CSSPrimitiveValue(CSS_VAL_BOLD);
985             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
986         case CSS_PROP_HEIGHT:
987             return new CSSPrimitiveValue(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);
988         case CSS_PROP__WEBKIT_HIGHLIGHT:
989             if (style->highlight() == nullAtom)
990                 return new CSSPrimitiveValue(CSS_VAL_NONE);
991             return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
992         case CSS_PROP_LEFT:
993             return getPositionOffsetValue(renderer, CSS_PROP_LEFT);
994         case CSS_PROP_LETTER_SPACING:
995             if (!style->letterSpacing())
996                 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
997             return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
998         case CSS_PROP__WEBKIT_LINE_CLAMP:
999             if (style->lineClamp() == -1)
1000                 return new CSSPrimitiveValue(CSS_VAL_NONE);
1001             return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
1002         case CSS_PROP_LINE_HEIGHT: {
1003             Length length = style->lineHeight();
1004             if (length.isNegative())
1005                 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1006             if (length.isPercent())
1007                 // This is imperfect, because it doesn't include the zoom factor and the real computation
1008                 // for how high to be in pixels does include things like minimum font size and the zoom factor.
1009                 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1010                 // that here either.
1011                 return new CSSPrimitiveValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX);
1012             return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
1013         }
1014         case CSS_PROP_LIST_STYLE_IMAGE:
1015             if (style->listStyleImage())
1016                 return new CSSPrimitiveValue(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI);
1017             return new CSSPrimitiveValue(CSS_VAL_NONE);
1018         case CSS_PROP_LIST_STYLE_POSITION:
1019             switch (style->listStylePosition()) {
1020                 case OUTSIDE:
1021                     return new CSSPrimitiveValue(CSS_VAL_OUTSIDE);
1022                 case INSIDE:
1023                     return new CSSPrimitiveValue(CSS_VAL_INSIDE);
1024             }
1025             ASSERT_NOT_REACHED();
1026             return 0;
1027         case CSS_PROP_LIST_STYLE_TYPE:
1028             switch (style->listStyleType()) {
1029                 case LNONE:
1030                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1031                 case DISC:
1032                     return new CSSPrimitiveValue(CSS_VAL_DISC);
1033                 case CIRCLE:
1034                     return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
1035                 case SQUARE:
1036                     return new CSSPrimitiveValue(CSS_VAL_SQUARE);
1037                 case LDECIMAL:
1038                     return new CSSPrimitiveValue(CSS_VAL_DECIMAL);
1039                 case DECIMAL_LEADING_ZERO:
1040                     return new CSSPrimitiveValue(CSS_VAL_DECIMAL_LEADING_ZERO);
1041                 case LOWER_ROMAN:
1042                     return new CSSPrimitiveValue(CSS_VAL_LOWER_ROMAN);
1043                 case UPPER_ROMAN:
1044                     return new CSSPrimitiveValue(CSS_VAL_UPPER_ROMAN);
1045                 case LOWER_GREEK:
1046                     return new CSSPrimitiveValue(CSS_VAL_LOWER_GREEK);
1047                 case LOWER_ALPHA:
1048                     return new CSSPrimitiveValue(CSS_VAL_LOWER_ALPHA);
1049                 case LOWER_LATIN:
1050                     return new CSSPrimitiveValue(CSS_VAL_LOWER_LATIN);
1051                 case UPPER_ALPHA:
1052                     return new CSSPrimitiveValue(CSS_VAL_UPPER_ALPHA);
1053                 case UPPER_LATIN:
1054                     return new CSSPrimitiveValue(CSS_VAL_UPPER_LATIN);
1055                 case HEBREW:
1056                     return new CSSPrimitiveValue(CSS_VAL_HEBREW);
1057                 case ARMENIAN:
1058                     return new CSSPrimitiveValue(CSS_VAL_ARMENIAN);
1059                 case GEORGIAN:
1060                     return new CSSPrimitiveValue(CSS_VAL_GEORGIAN);
1061                 case CJK_IDEOGRAPHIC:
1062                     return new CSSPrimitiveValue(CSS_VAL_CJK_IDEOGRAPHIC);
1063                 case HIRAGANA:
1064                     return new CSSPrimitiveValue(CSS_VAL_HIRAGANA);
1065                 case KATAKANA:
1066                     return new CSSPrimitiveValue(CSS_VAL_KATAKANA);
1067                 case HIRAGANA_IROHA:
1068                     return new CSSPrimitiveValue(CSS_VAL_HIRAGANA_IROHA);
1069                 case KATAKANA_IROHA:
1070                     return new CSSPrimitiveValue(CSS_VAL_KATAKANA_IROHA);
1071             }
1072             ASSERT_NOT_REACHED();
1073             return 0;
1074         case CSS_PROP_MARGIN_TOP:
1075             // FIXME: Supposed to return the percentage if percentage was specified.
1076             return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
1077         case CSS_PROP_MARGIN_RIGHT:
1078             // FIXME: Supposed to return the percentage if percentage was specified.
1079             return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
1080         case CSS_PROP_MARGIN_BOTTOM:
1081             // FIXME: Supposed to return the percentage if percentage was specified.
1082             return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
1083         case CSS_PROP_MARGIN_LEFT:
1084             // FIXME: Supposed to return the percentage if percentage was specified.
1085             return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
1086         case CSS_PROP__WEBKIT_MARQUEE_DIRECTION:
1087             switch (style->marqueeDirection()) {
1088                 case MFORWARD:
1089                     return new CSSPrimitiveValue(CSS_VAL_FORWARDS);
1090                 case MBACKWARD:
1091                     return new CSSPrimitiveValue(CSS_VAL_BACKWARDS);
1092                 case MAUTO:
1093                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1094                 case MUP:
1095                     return new CSSPrimitiveValue(CSS_VAL_UP);
1096                 case MDOWN:
1097                     return new CSSPrimitiveValue(CSS_VAL_DOWN);
1098                 case MLEFT:
1099                     return new CSSPrimitiveValue(CSS_VAL_LEFT);
1100                 case MRIGHT:
1101                     return new CSSPrimitiveValue(CSS_VAL_RIGHT);
1102             }
1103             ASSERT_NOT_REACHED();
1104             return 0;
1105         case CSS_PROP__WEBKIT_MARQUEE_INCREMENT:
1106             return valueForLength(style->marqueeIncrement());
1107         case CSS_PROP__WEBKIT_MARQUEE_REPETITION:
1108             if (style->marqueeLoopCount() < 0)
1109                 return new CSSPrimitiveValue(CSS_VAL_INFINITE);
1110             return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
1111         case CSS_PROP__WEBKIT_MARQUEE_STYLE:
1112             switch (style->marqueeBehavior()) {
1113                 case MNONE:
1114                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1115                 case MSCROLL:
1116                     return new CSSPrimitiveValue(CSS_VAL_SCROLL);
1117                 case MSLIDE:
1118                     return new CSSPrimitiveValue(CSS_VAL_SLIDE);
1119                 case MALTERNATE:
1120                     return new CSSPrimitiveValue(CSS_VAL_ALTERNATE);
1121             }
1122             ASSERT_NOT_REACHED();
1123             return 0;
1124         case CSS_PROP__WEBKIT_USER_MODIFY:
1125             switch (style->userModify()) {
1126                 case READ_ONLY:
1127                     return new CSSPrimitiveValue(CSS_VAL_READ_ONLY);
1128                 case READ_WRITE:
1129                     return new CSSPrimitiveValue(CSS_VAL_READ_WRITE);
1130                 case READ_WRITE_PLAINTEXT_ONLY:
1131                     return new CSSPrimitiveValue(CSS_VAL_READ_WRITE_PLAINTEXT_ONLY);
1132             }
1133             ASSERT_NOT_REACHED();
1134             return 0;
1135         case CSS_PROP_MAX_HEIGHT:
1136             return valueForMaxLength(style->maxHeight());
1137         case CSS_PROP_MAX_WIDTH:
1138             return valueForMaxLength(style->maxWidth());
1139         case CSS_PROP_MIN_HEIGHT:
1140             return valueForLength(style->minHeight());
1141         case CSS_PROP_MIN_WIDTH:
1142             return valueForLength(style->minWidth());
1143         case CSS_PROP_OPACITY:
1144             return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
1145         case CSS_PROP_ORPHANS:
1146             return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
1147         case CSS_PROP_OUTLINE_COLOR:
1148             return currentColorOrValidColor(style, style->outlineColor());
1149         case CSS_PROP_OUTLINE_STYLE:
1150             if (style->outlineStyleIsAuto())
1151                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1152             return valueForBorderStyle(style->outlineStyle());
1153         case CSS_PROP_OUTLINE_WIDTH:
1154             return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
1155         case CSS_PROP_OVERFLOW:
1156         case CSS_PROP_OVERFLOW_X:
1157         case CSS_PROP_OVERFLOW_Y: {
1158             EOverflow overflow;
1159             switch (propertyID) {
1160                 case CSS_PROP_OVERFLOW_X:
1161                     overflow = style->overflowX();
1162                     break;
1163                 case CSS_PROP_OVERFLOW_Y:
1164                     overflow = style->overflowY();
1165                     break;
1166                 default:
1167                     overflow = max(style->overflowX(), style->overflowY());
1168             }
1169             switch (overflow) {
1170                 case OVISIBLE:
1171                     return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
1172                 case OHIDDEN:
1173                     return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
1174                 case OSCROLL:
1175                     return new CSSPrimitiveValue(CSS_VAL_SCROLL);
1176                 case OAUTO:
1177                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1178                 case OMARQUEE:
1179                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_MARQUEE);
1180                 case OOVERLAY:
1181                     return new CSSPrimitiveValue(CSS_VAL_OVERLAY);
1182             }
1183             ASSERT_NOT_REACHED();
1184             return 0;
1185         }
1186         case CSS_PROP_PADDING_TOP:
1187             return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
1188         case CSS_PROP_PADDING_RIGHT:
1189             return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
1190         case CSS_PROP_PADDING_BOTTOM:
1191             return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
1192         case CSS_PROP_PADDING_LEFT:
1193             return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
1194         case CSS_PROP_PAGE_BREAK_AFTER:
1195             switch (style->pageBreakAfter()) {
1196                 case PBAUTO:
1197                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1198                 case PBALWAYS:
1199                     return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
1200                 case PBAVOID:
1201                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
1202             }
1203             ASSERT_NOT_REACHED();
1204             return 0;
1205         case CSS_PROP_PAGE_BREAK_BEFORE:
1206             switch (style->pageBreakBefore()) {
1207                 case PBAUTO:
1208                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1209                 case PBALWAYS:
1210                     return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
1211                 case PBAVOID:
1212                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
1213             }
1214             ASSERT_NOT_REACHED();
1215             return 0;
1216         case CSS_PROP_PAGE_BREAK_INSIDE:
1217             switch (style->pageBreakInside()) {
1218                 case PBAUTO:
1219                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1220                 case PBAVOID:
1221                     return new CSSPrimitiveValue(CSS_VAL_AVOID);
1222                 case PBALWAYS:
1223                     break; // not allowed
1224             }
1225             ASSERT_NOT_REACHED();
1226             return 0;
1227         case CSS_PROP_POSITION:
1228             switch (style->position()) {
1229                 case StaticPosition:
1230                     return new CSSPrimitiveValue(CSS_VAL_STATIC);
1231                 case RelativePosition:
1232                     return new CSSPrimitiveValue(CSS_VAL_RELATIVE);
1233                 case AbsolutePosition:
1234                     return new CSSPrimitiveValue(CSS_VAL_ABSOLUTE);
1235                 case FixedPosition:
1236                     return new CSSPrimitiveValue(CSS_VAL_FIXED);
1237             }
1238             ASSERT_NOT_REACHED();
1239             return 0;
1240         case CSS_PROP_RIGHT:
1241             return getPositionOffsetValue(renderer, CSS_PROP_RIGHT);
1242         case CSS_PROP_TABLE_LAYOUT:
1243             switch (style->tableLayout()) {
1244                 case TAUTO:
1245                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1246                 case TFIXED:
1247                     return new CSSPrimitiveValue(CSS_VAL_FIXED);
1248             }
1249             ASSERT_NOT_REACHED();
1250             return 0;
1251         case CSS_PROP_TEXT_ALIGN:
1252             return valueForTextAlign(style->textAlign());
1253         case CSS_PROP_TEXT_DECORATION: {
1254             String string;
1255             if (style->textDecoration() & UNDERLINE)
1256                 string += "underline";
1257             if (style->textDecoration() & OVERLINE) {
1258                 if (string.length())
1259                     string += " ";
1260                 string += "overline";
1261             }
1262             if (style->textDecoration() & LINE_THROUGH) {
1263                 if (string.length())
1264                     string += " ";
1265                 string += "line-through";
1266             }
1267             if (style->textDecoration() & BLINK) {
1268                 if (string.length())
1269                     string += " ";
1270                 string += "blink";
1271             }
1272             if (!string.length())
1273                 return new CSSPrimitiveValue(CSS_VAL_NONE);
1274             return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
1275         }
1276         case CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT: {
1277             String string;
1278             if (style->textDecorationsInEffect() & UNDERLINE)
1279                 string += "underline";
1280             if (style->textDecorationsInEffect() & OVERLINE) {
1281                 if (string.length())
1282                     string += " ";
1283                 string += "overline";
1284             }
1285             if (style->textDecorationsInEffect() & LINE_THROUGH) {
1286                 if (string.length())
1287                     string += " ";
1288                 string += "line-through";
1289             }
1290             if (style->textDecorationsInEffect() & BLINK) {
1291                 if (string.length())
1292                     string += " ";
1293                 string += "blink";
1294             }
1295             if (!string.length())
1296                 return new CSSPrimitiveValue(CSS_VAL_NONE);
1297             return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
1298         }
1299         case CSS_PROP__WEBKIT_TEXT_FILL_COLOR:
1300             return currentColorOrValidColor(style, style->textFillColor());
1301         case CSS_PROP_TEXT_INDENT:
1302             return valueForLength(style->textIndent());
1303         case CSS_PROP_TEXT_SHADOW:
1304             return valueForShadow(style->textShadow());
1305         case CSS_PROP__WEBKIT_TEXT_SECURITY:
1306             switch (style->textSecurity()) {
1307                 case TSNONE:
1308                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1309                 case TSDISC:
1310                     return new CSSPrimitiveValue(CSS_VAL_DISC);
1311                 case TSCIRCLE:
1312                     return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
1313                 case TSSQUARE:
1314                     return new CSSPrimitiveValue(CSS_VAL_SQUARE);
1315             }
1316             ASSERT_NOT_REACHED();
1317             return 0;
1318         case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
1319             if (style->textSizeAdjust())
1320                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1321             return new CSSPrimitiveValue(CSS_VAL_NONE);
1322         case CSS_PROP__WEBKIT_TEXT_STROKE_COLOR:
1323             return currentColorOrValidColor(style, style->textStrokeColor());
1324         case CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH:
1325             return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_NUMBER);
1326         case CSS_PROP_TEXT_TRANSFORM:
1327             switch (style->textTransform()) {
1328                 case CAPITALIZE:
1329                     return new CSSPrimitiveValue(CSS_VAL_CAPITALIZE);
1330                 case UPPERCASE:
1331                     return new CSSPrimitiveValue(CSS_VAL_UPPERCASE);
1332                 case LOWERCASE:
1333                     return new CSSPrimitiveValue(CSS_VAL_LOWERCASE);
1334                 case TTNONE:
1335                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1336             }
1337             ASSERT_NOT_REACHED();
1338             return 0;
1339         case CSS_PROP_TOP:
1340             return getPositionOffsetValue(renderer, CSS_PROP_TOP);
1341         case CSS_PROP_UNICODE_BIDI:
1342             switch (style->unicodeBidi()) {
1343                 case UBNormal:
1344                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1345                 case Embed:
1346                     return new CSSPrimitiveValue(CSS_VAL_EMBED);
1347                 case Override:
1348                     return new CSSPrimitiveValue(CSS_VAL_BIDI_OVERRIDE);
1349             }
1350             ASSERT_NOT_REACHED();
1351             return 0;
1352         case CSS_PROP_VERTICAL_ALIGN:
1353             switch (style->verticalAlign()) {
1354                 case BASELINE:
1355                     return new CSSPrimitiveValue(CSS_VAL_BASELINE);
1356                 case MIDDLE:
1357                     return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
1358                 case SUB:
1359                     return new CSSPrimitiveValue(CSS_VAL_SUB);
1360                 case SUPER:
1361                     return new CSSPrimitiveValue(CSS_VAL_SUPER);
1362                 case TEXT_TOP:
1363                     return new CSSPrimitiveValue(CSS_VAL_TEXT_TOP);
1364                 case TEXT_BOTTOM:
1365                     return new CSSPrimitiveValue(CSS_VAL_TEXT_BOTTOM);
1366                 case TOP:
1367                     return new CSSPrimitiveValue(CSS_VAL_TOP);
1368                 case BOTTOM:
1369                     return new CSSPrimitiveValue(CSS_VAL_BOTTOM);
1370                 case BASELINE_MIDDLE:
1371                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BASELINE_MIDDLE);
1372                 case LENGTH:
1373                     return valueForLength(style->verticalAlignLength());
1374             }
1375             ASSERT_NOT_REACHED();
1376             return 0;
1377         case CSS_PROP_VISIBILITY:
1378             switch (style->visibility()) {
1379                 case VISIBLE:
1380                     return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
1381                 case HIDDEN:
1382                     return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
1383                 case COLLAPSE:
1384                     return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
1385             }
1386             ASSERT_NOT_REACHED();
1387             return 0;
1388         case CSS_PROP_WHITE_SPACE:
1389             switch (style->whiteSpace()) {
1390                 case NORMAL:
1391                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1392                 case PRE:
1393                     return new CSSPrimitiveValue(CSS_VAL_PRE);
1394                 case PRE_WRAP:
1395                     return new CSSPrimitiveValue(CSS_VAL_PRE_WRAP);
1396                 case PRE_LINE:
1397                     return new CSSPrimitiveValue(CSS_VAL_PRE_LINE);
1398                 case NOWRAP:
1399                     return new CSSPrimitiveValue(CSS_VAL_NOWRAP);
1400                 case KHTML_NOWRAP:
1401                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_NOWRAP);
1402             }
1403             ASSERT_NOT_REACHED();
1404             return 0;
1405         case CSS_PROP_WIDOWS:
1406             return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
1407         case CSS_PROP_WIDTH:
1408             return new CSSPrimitiveValue(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX);
1409         case CSS_PROP_WORD_SPACING:
1410             return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
1411         case CSS_PROP_WORD_WRAP:
1412             switch (style->wordWrap()) {
1413                 case WBNORMAL:
1414                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1415                 case BREAK_WORD:
1416                     return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD);
1417             }
1418             ASSERT_NOT_REACHED();
1419             return 0;
1420         case CSS_PROP__WEBKIT_LINE_BREAK:
1421             switch (style->khtmlLineBreak()) {
1422                 case LBNORMAL:
1423                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1424                 case AFTER_WHITE_SPACE:
1425                     return new CSSPrimitiveValue(CSS_VAL_AFTER_WHITE_SPACE);
1426             }
1427             ASSERT_NOT_REACHED();
1428             return 0;
1429         case CSS_PROP__WEBKIT_NBSP_MODE:
1430             switch (style->nbspMode()) {
1431                 case NBNORMAL:
1432                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1433                 case SPACE:
1434                     return new CSSPrimitiveValue(CSS_VAL_SPACE);
1435             }
1436             ASSERT_NOT_REACHED();
1437             return 0;
1438         case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
1439             switch (style->matchNearestMailBlockquoteColor()) {
1440                 case BCNORMAL:
1441                     return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1442                 case MATCH:
1443                     return new CSSPrimitiveValue(CSS_VAL_MATCH);
1444             }
1445             ASSERT_NOT_REACHED();
1446             return 0;
1447         case CSS_PROP_RESIZE:
1448             switch (style->resize()) {
1449                 case RESIZE_BOTH:
1450                     return new CSSPrimitiveValue(CSS_VAL_BOTH);
1451                 case RESIZE_HORIZONTAL:
1452                     return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
1453                 case RESIZE_VERTICAL:
1454                     return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
1455                 case RESIZE_NONE:
1456                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1457             }
1458             ASSERT_NOT_REACHED();
1459             return 0;
1460         case CSS_PROP_Z_INDEX:
1461             if (style->hasAutoZIndex())
1462                 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1463             return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
1464         case CSS_PROP_BOX_SIZING:
1465             if (style->boxSizing() == CONTENT_BOX)
1466                 new CSSPrimitiveValue(CSS_VAL_CONTENT_BOX);
1467             return new CSSPrimitiveValue(CSS_VAL_BORDER_BOX);
1468         case CSS_PROP__WEBKIT_DASHBOARD_REGION:
1469 #if PLATFORM(MAC)
1470         {
1471             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
1472             unsigned count = regions.size();
1473             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
1474                 return new CSSPrimitiveValue(CSS_VAL_NONE);
1475
1476             RefPtr<DashboardRegion> firstRegion;
1477             DashboardRegion* previousRegion = 0;
1478             for (unsigned i = 0; i < count; i++) {
1479                 RefPtr<DashboardRegion> region = new DashboardRegion;
1480                 StyleDashboardRegion styleRegion = regions[i];
1481
1482                 region->m_label = styleRegion.label;
1483                 LengthBox offset = styleRegion.offset;
1484                 region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX));
1485                 region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX));
1486                 region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX));
1487                 region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX));
1488                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
1489                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
1490
1491                 if (previousRegion)
1492                     previousRegion->m_next = region;
1493                 else
1494                     firstRegion = region;
1495                 previousRegion = region.get();
1496             }
1497             return new CSSPrimitiveValue(firstRegion.release());
1498         }
1499 #else
1500             break;
1501 #endif
1502         case CSS_PROP__WEBKIT_APPEARANCE:
1503             return valueForAppearance(style->appearance());
1504         case CSS_PROP__WEBKIT_FONT_SIZE_DELTA:
1505             // Not a real style property -- used by the editing engine -- so has no computed value.
1506             break;
1507         case CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE:
1508             return valueForMarginCollapse(style->marginBottomCollapse());
1509         case CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE:
1510             return valueForMarginCollapse(style->marginTopCollapse());
1511         case CSS_PROP__WEBKIT_RTL_ORDERING:
1512             if (style->visuallyOrdered())
1513                 return new CSSPrimitiveValue(CSS_VAL_VISUAL);
1514             return new CSSPrimitiveValue(CSS_VAL_LOGICAL);
1515         case CSS_PROP__WEBKIT_USER_DRAG:
1516             switch (style->userDrag()) {
1517                 case DRAG_AUTO:
1518                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1519                 case DRAG_NONE:
1520                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1521                 case DRAG_ELEMENT:
1522                     return new CSSPrimitiveValue(CSS_VAL_ELEMENT);
1523             }
1524             break;
1525         case CSS_PROP__WEBKIT_USER_SELECT:
1526             switch (style->userSelect()) {
1527                 case SELECT_AUTO:
1528                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
1529                 case SELECT_NONE:
1530                     return new CSSPrimitiveValue(CSS_VAL_NONE);
1531                 case SELECT_TEXT:
1532                     return new CSSPrimitiveValue(CSS_VAL_TEXT);
1533                 case SELECT_IGNORE:
1534                     return new CSSPrimitiveValue(CSS_VAL_IGNORE);
1535             }
1536             break;
1537         case CSS_PROP_BACKGROUND:
1538         case CSS_PROP_BORDER:
1539         case CSS_PROP_BORDER_BOTTOM:
1540         case CSS_PROP_BORDER_COLOR:
1541         case CSS_PROP_BORDER_LEFT:
1542         case CSS_PROP_BORDER_RIGHT:
1543         case CSS_PROP_BORDER_STYLE:
1544         case CSS_PROP_BORDER_TOP:
1545         case CSS_PROP_BORDER_WIDTH:
1546         case CSS_PROP_CLIP:
1547         case CSS_PROP_CONTENT:
1548         case CSS_PROP_COUNTER_INCREMENT:
1549         case CSS_PROP_COUNTER_RESET:
1550         case CSS_PROP_FONT:
1551         case CSS_PROP_LIST_STYLE:
1552         case CSS_PROP_MARGIN:
1553         case CSS_PROP_OUTLINE:
1554         case CSS_PROP_OUTLINE_OFFSET:
1555         case CSS_PROP_PADDING:
1556         case CSS_PROP_PAGE:
1557         case CSS_PROP_QUOTES:
1558         case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
1559         case CSS_PROP_SCROLLBAR_ARROW_COLOR:
1560         case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
1561         case CSS_PROP_SCROLLBAR_FACE_COLOR:
1562         case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
1563         case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
1564         case CSS_PROP_SCROLLBAR_TRACK_COLOR:
1565         case CSS_PROP_SIZE:
1566         case CSS_PROP_TEXT_LINE_THROUGH:
1567         case CSS_PROP_TEXT_LINE_THROUGH_COLOR:
1568         case CSS_PROP_TEXT_LINE_THROUGH_MODE:
1569         case CSS_PROP_TEXT_LINE_THROUGH_STYLE:
1570         case CSS_PROP_TEXT_LINE_THROUGH_WIDTH:
1571         case CSS_PROP_TEXT_OVERFLOW:
1572         case CSS_PROP_TEXT_OVERLINE:
1573         case CSS_PROP_TEXT_OVERLINE_COLOR:
1574         case CSS_PROP_TEXT_OVERLINE_MODE:
1575         case CSS_PROP_TEXT_OVERLINE_STYLE:
1576         case CSS_PROP_TEXT_OVERLINE_WIDTH:
1577         case CSS_PROP_TEXT_UNDERLINE:
1578         case CSS_PROP_TEXT_UNDERLINE_COLOR:
1579         case CSS_PROP_TEXT_UNDERLINE_MODE:
1580         case CSS_PROP_TEXT_UNDERLINE_STYLE:
1581         case CSS_PROP_TEXT_UNDERLINE_WIDTH:
1582         case CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS:
1583         case CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS:
1584         case CSS_PROP__WEBKIT_BORDER_IMAGE:
1585         case CSS_PROP__WEBKIT_BORDER_RADIUS:
1586         case CSS_PROP__WEBKIT_BORDER_TOP_LEFT_RADIUS:
1587         case CSS_PROP__WEBKIT_BORDER_TOP_RIGHT_RADIUS:
1588         case CSS_PROP__WEBKIT_COLUMNS:
1589         case CSS_PROP__WEBKIT_COLUMN_RULE:
1590         case CSS_PROP__WEBKIT_MARGIN_COLLAPSE:
1591         case CSS_PROP__WEBKIT_MARGIN_START:
1592         case CSS_PROP__WEBKIT_MARQUEE:
1593         case CSS_PROP__WEBKIT_MARQUEE_SPEED:
1594         case CSS_PROP__WEBKIT_PADDING_START:
1595         case CSS_PROP__WEBKIT_TEXT_STROKE:
1596             // FIXME: The above are unimplemented.
1597             break;
1598     }
1599
1600     LOG_ERROR("unimplemented propertyID: %d", propertyID);
1601     return 0;
1602 }
1603
1604 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const
1605 {
1606     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
1607     if (value)
1608         return value->cssText();
1609     return "";
1610 }
1611
1612 bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const
1613 {
1614     // All computed styles have a priority of false (not "important").
1615     return false;
1616 }
1617
1618 String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec)
1619 {
1620     ec = NO_MODIFICATION_ALLOWED_ERR;
1621     return String();
1622 }
1623
1624 void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec)
1625 {
1626     ec = NO_MODIFICATION_ALLOWED_ERR;
1627 }
1628
1629 unsigned CSSComputedStyleDeclaration::length() const
1630 {
1631     Node* node = m_node.get();
1632     if (!node)
1633         return 0;
1634
1635     RenderObject* renderer = node->renderer();
1636     if (!renderer)
1637         return 0;
1638
1639     RenderStyle* style = renderer->style();
1640     if (!style)
1641         return 0;
1642
1643     return numComputedProperties;
1644 }
1645
1646 String CSSComputedStyleDeclaration::item(unsigned i) const
1647 {
1648     if (i >= length())
1649         return String();
1650
1651     return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
1652 }
1653
1654 // This is the list of properties we want to copy in the copyInheritableProperties() function.
1655 // It is the intersection of the list of inherited CSS properties and the
1656 // properties for which we have a computed implementation in this file.
1657 const int inheritableProperties[] = {
1658     CSS_PROP_BORDER_COLLAPSE,
1659     CSS_PROP_COLOR,
1660     CSS_PROP_FONT_FAMILY,
1661     CSS_PROP_FONT_SIZE,
1662     CSS_PROP_FONT_STRETCH,
1663     CSS_PROP_FONT_STYLE,
1664     CSS_PROP_FONT_VARIANT,
1665     CSS_PROP_FONT_WEIGHT,
1666     CSS_PROP_LETTER_SPACING,
1667     CSS_PROP_LINE_HEIGHT,
1668     CSS_PROP_ORPHANS,
1669     CSS_PROP_TEXT_ALIGN,
1670     CSS_PROP_TEXT_INDENT,
1671     CSS_PROP_TEXT_TRANSFORM,
1672     CSS_PROP_WHITE_SPACE,
1673     CSS_PROP_WIDOWS,
1674     CSS_PROP_WORD_SPACING,
1675     CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING,
1676     CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING,
1677     CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
1678     CSS_PROP__WEBKIT_TEXT_FILL_COLOR,
1679     CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST,
1680     CSS_PROP__WEBKIT_TEXT_STROKE_COLOR,
1681     CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH,
1682 };
1683
1684 const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
1685
1686 void CSSComputedStyleDeclaration::removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration* declaration)
1687 {
1688     declaration->removePropertiesInSet(inheritableProperties, numInheritableProperties);
1689 }
1690
1691 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const
1692 {
1693     return copyPropertiesInSet(inheritableProperties, numInheritableProperties);
1694 }
1695
1696 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const
1697 {
1698     return copyPropertiesInSet(computedProperties, numComputedProperties);
1699 }
1700
1701 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable()
1702 {
1703     return copy();
1704 }
1705
1706 } // namespace WebCore