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