Reviewed by John
[WebKit-https.git] / WebCore / khtml / css / css_computedstyle.cpp
1 /**
2  * css_computedstyle.cpp
3  *
4  * Copyright (C)  2004  Zack Rusin <zack@kde.org>
5  * Copyright (C) 2004 Apple Computer, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307  USA
21  */
22
23 #include "css_computedstyle.h"
24
25 #include "cssproperties.h"
26 #include "cssvalues.h"
27 #include "dom_atomicstring.h"
28 #include "dom_exception.h"
29 #include "dom_string.h"
30 #include "font.h"
31 #include "khtmllayout.h"
32 #include "loader.h"
33 #include "rendering/render_style.h"
34 #include "rendering/render_object.h"
35
36 #if APPLE_CHANGES
37 #import "KWQAssertions.h"
38 #import "KWQFontFamily.h"
39 #import "KWQLogging.h"
40 #endif
41
42 using khtml::EBorderStyle;
43 using khtml::ETextAlign;
44 using khtml::Font;
45 using khtml::FontDef;
46 using khtml::Length;
47 using khtml::LengthBox;
48 using khtml::RenderObject;
49 using khtml::RenderStyle;
50 using khtml::ShadowData;
51 using khtml::StyleDashboardRegion;
52
53 namespace DOM {
54
55 // List of all properties we know how to compute, omitting shorthands.
56 static const int computedProperties[] = {
57     CSS_PROP_BACKGROUND_COLOR,
58     CSS_PROP_BACKGROUND_IMAGE,
59     CSS_PROP_BACKGROUND_REPEAT,
60     CSS_PROP_BACKGROUND_ATTACHMENT,
61     CSS_PROP_BACKGROUND_POSITION,
62     CSS_PROP_BACKGROUND_POSITION_X,
63     CSS_PROP_BACKGROUND_POSITION_Y,
64     CSS_PROP_BORDER_COLLAPSE,
65     CSS_PROP_BORDER_SPACING,
66     CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING,
67     CSS_PROP__KHTML_BORDER_VERTICAL_SPACING,
68     CSS_PROP_BORDER_TOP_COLOR,
69     CSS_PROP_BORDER_RIGHT_COLOR,
70     CSS_PROP_BORDER_BOTTOM_COLOR,
71     CSS_PROP_BORDER_LEFT_COLOR,
72     CSS_PROP_BORDER_TOP_STYLE,
73     CSS_PROP_BORDER_RIGHT_STYLE,
74     CSS_PROP_BORDER_BOTTOM_STYLE,
75     CSS_PROP_BORDER_LEFT_STYLE,
76     CSS_PROP_BORDER_TOP_WIDTH,
77     CSS_PROP_BORDER_RIGHT_WIDTH,
78     CSS_PROP_BORDER_BOTTOM_WIDTH,
79     CSS_PROP_BORDER_LEFT_WIDTH,
80     CSS_PROP_BOTTOM,
81     CSS_PROP__KHTML_BOX_ALIGN,
82     CSS_PROP__KHTML_BOX_DIRECTION,
83     CSS_PROP__KHTML_BOX_FLEX,
84     CSS_PROP__KHTML_BOX_FLEX_GROUP,
85     CSS_PROP__KHTML_BOX_LINES,
86     CSS_PROP__KHTML_BOX_ORDINAL_GROUP,
87     CSS_PROP__KHTML_BOX_ORIENT,
88     CSS_PROP__KHTML_BOX_PACK,
89     CSS_PROP_CAPTION_SIDE,
90     CSS_PROP_CLEAR,
91     CSS_PROP_COLOR,
92     CSS_PROP_CURSOR,
93     CSS_PROP__APPLE_DASHBOARD_REGION,
94     CSS_PROP_DIRECTION,
95     CSS_PROP_DISPLAY,
96     CSS_PROP_EMPTY_CELLS,
97     CSS_PROP_FLOAT,
98     CSS_PROP_FONT_FAMILY,
99     CSS_PROP_FONT_SIZE,
100     CSS_PROP_FONT_STYLE,
101     CSS_PROP_FONT_VARIANT,
102     CSS_PROP_FONT_WEIGHT,
103     CSS_PROP_HEIGHT,
104     CSS_PROP_LEFT,
105     CSS_PROP_LETTER_SPACING,
106     CSS_PROP__KHTML_LINE_BREAK,
107     CSS_PROP__APPLE_LINE_CLAMP,
108     CSS_PROP_LINE_HEIGHT,
109     CSS_PROP_LIST_STYLE_IMAGE,
110     CSS_PROP_LIST_STYLE_POSITION,
111     CSS_PROP_LIST_STYLE_TYPE,
112     CSS_PROP_MARGIN_TOP,
113     CSS_PROP_MARGIN_RIGHT,
114     CSS_PROP_MARGIN_BOTTOM,
115     CSS_PROP_MARGIN_LEFT,
116     CSS_PROP__KHTML_MARQUEE_DIRECTION,
117     CSS_PROP__KHTML_MARQUEE_INCREMENT,
118     CSS_PROP__KHTML_MARQUEE_REPETITION,
119     CSS_PROP__KHTML_MARQUEE_STYLE,
120     CSS_PROP_MAX_HEIGHT,
121     CSS_PROP_MAX_WIDTH,
122     CSS_PROP_MIN_HEIGHT,
123     CSS_PROP_MIN_WIDTH,
124     CSS_PROP__KHTML_NBSP_MODE,
125     CSS_PROP_OPACITY,
126     CSS_PROP_ORPHANS,
127     CSS_PROP_OUTLINE_STYLE,
128     CSS_PROP_OVERFLOW,
129     CSS_PROP_PADDING_TOP,
130     CSS_PROP_PADDING_RIGHT,
131     CSS_PROP_PADDING_BOTTOM,
132     CSS_PROP_PADDING_LEFT,
133     CSS_PROP_PAGE_BREAK_AFTER,
134     CSS_PROP_PAGE_BREAK_BEFORE,
135     CSS_PROP_PAGE_BREAK_INSIDE,
136     CSS_PROP_POSITION,
137     CSS_PROP_RIGHT,
138     CSS_PROP_TABLE_LAYOUT,
139     CSS_PROP_TEXT_ALIGN,
140     CSS_PROP_TEXT_DECORATION,
141     CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT,
142     CSS_PROP_TEXT_INDENT,
143     CSS_PROP_TEXT_SHADOW,
144     CSS_PROP_TEXT_TRANSFORM,
145     CSS_PROP_TOP,
146     CSS_PROP_UNICODE_BIDI,
147     CSS_PROP__KHTML_USER_MODIFY,
148     CSS_PROP_VERTICAL_ALIGN,
149     CSS_PROP_VISIBILITY,
150     CSS_PROP_WHITE_SPACE,
151     CSS_PROP_WIDOWS,
152     CSS_PROP_WIDTH,
153     CSS_PROP_WORD_SPACING,
154     CSS_PROP_WORD_WRAP,
155     CSS_PROP_Z_INDEX,
156 };
157
158 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
159
160 static CSSValueImpl* valueForLength(const Length &length)
161 {
162     switch (length.type) {
163         case khtml::Percent:
164             return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PERCENTAGE);
165         case khtml::Fixed:
166             return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX);
167         default: // FIXME: Intrinsic and MinIntrinsic should probably return keywords.
168             return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
169     }
170 }
171
172 static CSSValueImpl *valueForBorderStyle(EBorderStyle style)
173 {
174     switch (style) {
175         case khtml::BNONE:
176             return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
177         case khtml::BHIDDEN:
178             return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
179         case khtml::INSET:
180             return new CSSPrimitiveValueImpl(CSS_VAL_INSET);
181         case khtml::GROOVE:
182             return new CSSPrimitiveValueImpl(CSS_VAL_GROOVE);
183         case khtml::RIDGE:
184             return new CSSPrimitiveValueImpl(CSS_VAL_RIDGE);
185         case khtml::OUTSET:
186             return new CSSPrimitiveValueImpl(CSS_VAL_OUTSET);
187         case khtml::DOTTED:
188             return new CSSPrimitiveValueImpl(CSS_VAL_DOTTED);
189         case khtml::DASHED:
190             return new CSSPrimitiveValueImpl(CSS_VAL_DASHED);
191         case khtml::SOLID:
192             return new CSSPrimitiveValueImpl(CSS_VAL_SOLID);
193         case khtml::DOUBLE:
194             return new CSSPrimitiveValueImpl(CSS_VAL_DOUBLE);
195     }
196     ASSERT_NOT_REACHED();
197     return 0;
198 }
199
200 static CSSValueImpl *valueForTextAlign(ETextAlign align)
201 {
202     switch (align) {
203         case khtml::TAAUTO:
204             return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
205         case khtml::LEFT:
206             return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
207         case khtml::RIGHT:
208             return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
209         case khtml::CENTER:
210             return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
211         case khtml::JUSTIFY:
212             return new CSSPrimitiveValueImpl(CSS_VAL_JUSTIFY);
213         case khtml::KHTML_LEFT:
214             return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_LEFT);
215         case khtml::KHTML_RIGHT:
216             return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_RIGHT);
217         case khtml::KHTML_CENTER:
218             return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_CENTER);
219     }
220     ASSERT_NOT_REACHED();
221     return 0;
222 }
223
224 static CSSValueImpl* valueForShadow(const ShadowData *shadow)
225 {
226     if (!shadow)
227         return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
228     CSSValueListImpl *list = new CSSValueListImpl;
229     for (const ShadowData *s = shadow; s; s = s->next) {
230         CSSPrimitiveValueImpl *x = new CSSPrimitiveValueImpl(s->x, CSSPrimitiveValue::CSS_PX);
231         CSSPrimitiveValueImpl *y = new CSSPrimitiveValueImpl(s->y, CSSPrimitiveValue::CSS_PX);
232         CSSPrimitiveValueImpl *blur = new CSSPrimitiveValueImpl(s->blur, CSSPrimitiveValue::CSS_PX);
233         CSSPrimitiveValueImpl *color = new CSSPrimitiveValueImpl(s->color.rgb());
234         list->append(new ShadowValueImpl(x, y, blur, color));
235     }
236     return list;
237 }
238
239 static CSSValueImpl *getPositionOffsetValue(RenderObject *renderer, int propertyID)
240 {
241     if (!renderer)
242         return 0;
243
244     RenderStyle *style = renderer->style();
245     if (!style)
246         return 0;
247
248     Length l;
249     switch (propertyID) {
250     case CSS_PROP_LEFT:
251         l = style->left();
252         break;
253     case CSS_PROP_RIGHT:
254         l = style->right();
255         break;
256     case CSS_PROP_TOP:
257         l = style->top();
258         break;
259     case CSS_PROP_BOTTOM:
260         l = style->bottom();
261         break;
262     default:
263         return 0;
264     }
265
266     if (renderer->isPositioned())
267         return valueForLength(l);
268     
269     if (renderer->isRelPositioned())
270         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
271         // In other words if left is auto and right is not auto, then left's computed value is negative right.
272         // So we should get the opposite length unit and see if it is auto.
273         return valueForLength(l);
274     
275     return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
276 }
277
278 CSSComputedStyleDeclarationImpl::CSSComputedStyleDeclarationImpl(NodeImpl *n)
279     : m_node(n)
280 {
281 }
282
283 CSSComputedStyleDeclarationImpl::~CSSComputedStyleDeclarationImpl()
284 {
285 }
286
287 DOMString CSSComputedStyleDeclarationImpl::cssText() const
288 {
289     ERROR("unimplemented");
290     return DOMString();
291 }
292
293 void CSSComputedStyleDeclarationImpl::setCssText(const DOMString &, int &exceptionCode)
294 {
295     exceptionCode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
296 }
297
298 // Display integers in integer format instead of "1.0".
299 static QString numberAsString(double n)
300 {
301     long i = static_cast<long>(n);
302     return i == n ? QString::number(i) : QString::number(n);
303 }
304
305 CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID) const
306 {
307     return getPropertyCSSValue(propertyID, UpdateLayout);
308 }
309
310 CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
311 {
312     NodeImpl *node = m_node.handle();
313     if (!node)
314         return 0;
315
316     // Make sure our layout is up to date before we allow a query on these attributes.
317     DocumentImpl* docimpl = node->getDocument();
318     if (docimpl && updateLayout)
319         docimpl->updateLayout();
320
321     RenderObject *renderer = node->renderer();
322     if (!renderer)
323         return 0;
324     RenderStyle *style = renderer->style();
325     if (!style)
326         return 0;
327
328     switch (propertyID)
329     {
330     case CSS_PROP_BACKGROUND_COLOR:
331         return new CSSPrimitiveValueImpl(style->backgroundColor().rgb());
332     case CSS_PROP_BACKGROUND_IMAGE:
333         if (style->backgroundImage())
334             return new CSSPrimitiveValueImpl(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
335         return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
336     case CSS_PROP_BACKGROUND_REPEAT:
337         switch (style->backgroundRepeat()) {
338             case khtml::REPEAT:
339                 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT);
340             case khtml::REPEAT_X:
341                 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_X);
342             case khtml::REPEAT_Y:
343                 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_Y);
344             case khtml::NO_REPEAT:
345                 return new CSSPrimitiveValueImpl(CSS_VAL_NO_REPEAT);
346         }
347         ASSERT_NOT_REACHED();
348         return 0;
349     case CSS_PROP_BACKGROUND_ATTACHMENT:
350         if (style->backgroundAttachment())
351             return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
352         else
353             return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
354     case CSS_PROP_BACKGROUND_POSITION:
355     {
356         DOMString string;
357         Length length(style->backgroundXPosition());
358         if (length.isPercent())
359             string = numberAsString(length.length()) + "%";
360         else
361             string = numberAsString(length.minWidth(renderer->contentWidth()));
362         string += " ";
363         length = style->backgroundYPosition();
364         if (length.isPercent())
365             string += numberAsString(length.length()) + "%";
366         else
367             string += numberAsString(length.minWidth(renderer->contentWidth()));
368         return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
369     }
370     case CSS_PROP_BACKGROUND_POSITION_X:
371         return valueForLength(style->backgroundXPosition());
372     case CSS_PROP_BACKGROUND_POSITION_Y:
373         return valueForLength(style->backgroundYPosition());
374 #ifndef KHTML_NO_XBL
375     case CSS_PROP__KHTML_BINDING:
376         // FIXME: unimplemented
377         break;
378 #endif
379     case CSS_PROP_BORDER_COLLAPSE:
380         if (style->borderCollapse())
381             return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
382         else
383             return new CSSPrimitiveValueImpl(CSS_VAL_SEPARATE);
384     case CSS_PROP_BORDER_SPACING:
385     {
386         QString string(numberAsString(style->horizontalBorderSpacing()) + 
387             "px " + 
388             numberAsString(style->verticalBorderSpacing()) +
389             "px");
390         return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
391     }
392     case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING:
393         return new CSSPrimitiveValueImpl(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
394     case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING:
395         return new CSSPrimitiveValueImpl(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
396     case CSS_PROP_BORDER_TOP_COLOR:
397         return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
398     case CSS_PROP_BORDER_RIGHT_COLOR:
399         return new CSSPrimitiveValueImpl(style->borderRightColor().rgb());
400     case CSS_PROP_BORDER_BOTTOM_COLOR:
401         return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb());
402     case CSS_PROP_BORDER_LEFT_COLOR:
403         return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
404     case CSS_PROP_BORDER_TOP_STYLE:
405         return valueForBorderStyle(style->borderTopStyle());
406     case CSS_PROP_BORDER_RIGHT_STYLE:
407         return valueForBorderStyle(style->borderRightStyle());
408     case CSS_PROP_BORDER_BOTTOM_STYLE:
409         return valueForBorderStyle(style->borderBottomStyle());
410     case CSS_PROP_BORDER_LEFT_STYLE:
411         return valueForBorderStyle(style->borderLeftStyle());
412     case CSS_PROP_BORDER_TOP_WIDTH:
413         return new CSSPrimitiveValueImpl(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
414     case CSS_PROP_BORDER_RIGHT_WIDTH:
415         return new CSSPrimitiveValueImpl(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
416     case CSS_PROP_BORDER_BOTTOM_WIDTH:
417         return new CSSPrimitiveValueImpl(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
418     case CSS_PROP_BORDER_LEFT_WIDTH:
419         return new CSSPrimitiveValueImpl(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
420     case CSS_PROP_BOTTOM:
421         return getPositionOffsetValue(renderer, CSS_PROP_BOTTOM);
422     case CSS_PROP__KHTML_BOX_ALIGN:
423         switch (style->boxAlign()) {
424             case khtml::BSTRETCH:
425                 return new CSSPrimitiveValueImpl(CSS_VAL_STRETCH);
426             case khtml::BSTART:
427                 return new CSSPrimitiveValueImpl(CSS_VAL_START);
428             case khtml::BCENTER:
429                 return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
430             case khtml::BEND:
431                 return new CSSPrimitiveValueImpl(CSS_VAL_END);
432             case khtml::BBASELINE:
433                 return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE);
434             case khtml::BJUSTIFY:
435                 break; // not allowed
436         }
437         ASSERT_NOT_REACHED();
438         return 0;
439     case CSS_PROP__KHTML_BOX_DIRECTION:
440         switch (style->boxDirection()) {
441             case khtml::BNORMAL:
442                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
443             case khtml::BREVERSE:
444                 return new CSSPrimitiveValueImpl(CSS_VAL_REVERSE);
445         }
446         ASSERT_NOT_REACHED();
447         return 0;
448     case CSS_PROP__KHTML_BOX_FLEX:
449         return new CSSPrimitiveValueImpl(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
450     case CSS_PROP__KHTML_BOX_FLEX_GROUP:
451         return new CSSPrimitiveValueImpl(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
452     case CSS_PROP__KHTML_BOX_LINES:
453         switch (style->boxLines()) {
454             case khtml::SINGLE:
455                 return new CSSPrimitiveValueImpl(CSS_VAL_SINGLE);
456             case khtml::MULTIPLE:
457                 return new CSSPrimitiveValueImpl(CSS_VAL_MULTIPLE);
458         }
459         ASSERT_NOT_REACHED();
460         return 0;
461     case CSS_PROP__KHTML_BOX_ORDINAL_GROUP:
462         return new CSSPrimitiveValueImpl(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
463     case CSS_PROP__KHTML_BOX_ORIENT:
464         switch (style->boxOrient()) {
465             case khtml::HORIZONTAL:
466                 return new CSSPrimitiveValueImpl(CSS_VAL_HORIZONTAL);
467             case khtml::VERTICAL:
468                 return new CSSPrimitiveValueImpl(CSS_VAL_VERTICAL);
469         }
470         ASSERT_NOT_REACHED();
471         return 0;
472     case CSS_PROP__KHTML_BOX_PACK:
473         switch (style->boxPack()) {
474             case khtml::BSTART:
475                 return new CSSPrimitiveValueImpl(CSS_VAL_START);
476             case khtml::BEND:
477                 return new CSSPrimitiveValueImpl(CSS_VAL_END);
478             case khtml::BCENTER:
479                 return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
480             case khtml::BJUSTIFY:
481                 return new CSSPrimitiveValueImpl(CSS_VAL_JUSTIFY);
482             case khtml::BSTRETCH:
483             case khtml::BBASELINE:
484                 break; // not allowed
485         }
486         ASSERT_NOT_REACHED();
487         return 0;
488     case CSS_PROP_CAPTION_SIDE:
489         switch (style->captionSide()) {
490             case khtml::CAPLEFT:
491                 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
492             case khtml::CAPRIGHT:
493                 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
494             case khtml::CAPTOP:
495                 return new CSSPrimitiveValueImpl(CSS_VAL_TOP);
496             case khtml::CAPBOTTOM:
497                 return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM);
498         }
499         ASSERT_NOT_REACHED();
500         return 0;
501     case CSS_PROP_CLEAR:
502         switch (style->clear()) {
503             case khtml::CNONE:
504                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
505             case khtml::CLEFT:
506                 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
507             case khtml::CRIGHT:
508                 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
509             case khtml::CBOTH:
510                 return new CSSPrimitiveValueImpl(CSS_VAL_BOTH);
511         }
512         ASSERT_NOT_REACHED();
513         return 0;
514     case CSS_PROP_CLIP:
515         // FIXME: unimplemented
516         break;
517     case CSS_PROP_COLOR:
518         return new CSSPrimitiveValueImpl(style->color().rgb());
519     case CSS_PROP_CONTENT:
520         // FIXME: unimplemented
521         break;
522     case CSS_PROP_COUNTER_INCREMENT:
523         // FIXME: unimplemented
524         break;
525     case CSS_PROP_COUNTER_RESET:
526         // FIXME: unimplemented
527         break;
528     case CSS_PROP_CURSOR:
529         switch (style->cursor()) {
530             case khtml::CURSOR_AUTO:
531                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
532             case khtml::CURSOR_CROSS:
533                 return new CSSPrimitiveValueImpl(CSS_VAL_CROSSHAIR);
534             case khtml::CURSOR_DEFAULT:
535                 return new CSSPrimitiveValueImpl(CSS_VAL_DEFAULT);
536             case khtml::CURSOR_POINTER:
537                 return new CSSPrimitiveValueImpl(CSS_VAL_POINTER);
538             case khtml::CURSOR_MOVE:
539                 return new CSSPrimitiveValueImpl(CSS_VAL_MOVE);
540             case khtml::CURSOR_E_RESIZE:
541                 return new CSSPrimitiveValueImpl(CSS_VAL_E_RESIZE);
542             case khtml::CURSOR_NE_RESIZE:
543                 return new CSSPrimitiveValueImpl(CSS_VAL_NE_RESIZE);
544             case khtml::CURSOR_NW_RESIZE:
545                 return new CSSPrimitiveValueImpl(CSS_VAL_NW_RESIZE);
546             case khtml::CURSOR_N_RESIZE:
547                 return new CSSPrimitiveValueImpl(CSS_VAL_N_RESIZE);
548             case khtml::CURSOR_SE_RESIZE:
549                 return new CSSPrimitiveValueImpl(CSS_VAL_SE_RESIZE);
550             case khtml::CURSOR_SW_RESIZE:
551                 return new CSSPrimitiveValueImpl(CSS_VAL_SW_RESIZE);
552             case khtml::CURSOR_S_RESIZE:
553                 return new CSSPrimitiveValueImpl(CSS_VAL_S_RESIZE);
554             case khtml::CURSOR_W_RESIZE:
555                 return new CSSPrimitiveValueImpl(CSS_VAL_W_RESIZE);
556             case khtml::CURSOR_TEXT:
557                 return new CSSPrimitiveValueImpl(CSS_VAL_TEXT);
558             case khtml::CURSOR_WAIT:
559                 return new CSSPrimitiveValueImpl(CSS_VAL_WAIT);
560             case khtml::CURSOR_HELP:
561                 return new CSSPrimitiveValueImpl(CSS_VAL_HELP);
562         }
563         ASSERT_NOT_REACHED();
564         return 0;
565     case CSS_PROP_DIRECTION:
566         switch (style->direction()) {
567             case khtml::LTR:
568                 return new CSSPrimitiveValueImpl(CSS_VAL_LTR);
569             case khtml::RTL:
570                 return new CSSPrimitiveValueImpl(CSS_VAL_RTL);
571         }
572         ASSERT_NOT_REACHED();
573         return 0;
574     case CSS_PROP_DISPLAY:
575         switch (style->display()) {
576             case khtml::INLINE:
577                 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE);
578             case khtml::BLOCK:
579                 return new CSSPrimitiveValueImpl(CSS_VAL_BLOCK);
580             case khtml::LIST_ITEM:
581                 return new CSSPrimitiveValueImpl(CSS_VAL_LIST_ITEM);
582             case khtml::RUN_IN:
583                 return new CSSPrimitiveValueImpl(CSS_VAL_RUN_IN);
584             case khtml::COMPACT:
585                 return new CSSPrimitiveValueImpl(CSS_VAL_COMPACT);
586             case khtml::INLINE_BLOCK:
587                 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_BLOCK);
588             case khtml::TABLE:
589                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE);
590             case khtml::INLINE_TABLE:
591                 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_TABLE);
592             case khtml::TABLE_ROW_GROUP:
593                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW_GROUP);
594             case khtml::TABLE_HEADER_GROUP:
595                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_HEADER_GROUP);
596             case khtml::TABLE_FOOTER_GROUP:
597                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_FOOTER_GROUP);
598             case khtml::TABLE_ROW:
599                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW);
600             case khtml::TABLE_COLUMN_GROUP:
601                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN_GROUP);
602             case khtml::TABLE_COLUMN:
603                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN);
604             case khtml::TABLE_CELL:
605                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CELL);
606             case khtml::TABLE_CAPTION:
607                 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CAPTION);
608             case khtml::BOX:
609                 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BOX);
610             case khtml::INLINE_BOX:
611                 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_INLINE_BOX);
612             case khtml::NONE:
613                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
614         }
615         ASSERT_NOT_REACHED();
616         return 0;
617     case CSS_PROP_EMPTY_CELLS:
618         switch (style->emptyCells()) {
619             case khtml::SHOW:
620                 return new CSSPrimitiveValueImpl(CSS_VAL_SHOW);
621             case khtml::HIDE:
622                 return new CSSPrimitiveValueImpl(CSS_VAL_HIDE);
623         }
624         ASSERT_NOT_REACHED();
625         return 0;
626     case CSS_PROP_FLOAT:
627         switch (style->floating()) {
628             case khtml::FNONE:
629                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
630             case khtml::FLEFT:
631                 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
632             case khtml::FRIGHT:
633                 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
634         }
635         ASSERT_NOT_REACHED();
636         return 0;
637     case CSS_PROP_FONT_FAMILY:
638     {
639         FontDef def = style->htmlFont().getFontDef();
640         return new CSSPrimitiveValueImpl(def.firstFamily().family().domString(), CSSPrimitiveValue::CSS_STRING);
641     }
642     case CSS_PROP_FONT_SIZE:
643     {
644         FontDef def = style->htmlFont().getFontDef();
645         return new CSSPrimitiveValueImpl(def.specifiedSize, CSSPrimitiveValue::CSS_PX);
646     }
647     case CSS_PROP_FONT_STRETCH:
648         // FIXME: unimplemented
649         break;
650     case CSS_PROP_FONT_STYLE:
651     {
652         // FIXME: handle oblique?
653         FontDef def = style->htmlFont().getFontDef();
654         if (def.italic)
655             return new CSSPrimitiveValueImpl(CSS_VAL_ITALIC);
656         else
657             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
658     }
659     case CSS_PROP_FONT_VARIANT:
660     {
661         FontDef def = style->htmlFont().getFontDef();
662         if (def.smallCaps)
663             return new CSSPrimitiveValueImpl(CSS_VAL_SMALL_CAPS);
664         else
665             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
666     }
667     case CSS_PROP_FONT_WEIGHT:
668     {
669         // FIXME: this does not reflect the full range of weights
670         // that can be expressed with CSS
671         FontDef def = style->htmlFont().getFontDef();
672         if (def.weight == QFont::Bold)
673             return new CSSPrimitiveValueImpl(CSS_VAL_BOLD);
674         else
675             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
676     }
677     case CSS_PROP_HEIGHT:
678         return new CSSPrimitiveValueImpl(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);
679     case CSS_PROP_LEFT:
680         return getPositionOffsetValue(renderer, CSS_PROP_LEFT);
681     case CSS_PROP_LETTER_SPACING:
682         if (style->letterSpacing() == 0)
683             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
684         return new CSSPrimitiveValueImpl(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
685     case CSS_PROP__APPLE_LINE_CLAMP:
686         return new CSSPrimitiveValueImpl(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
687     case CSS_PROP_LINE_HEIGHT: {
688         Length length(style->lineHeight());
689         if (length.value < 0)
690             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
691         if (length.isPercent()) {
692             // This is imperfect, because it doesn't include the zoom factor and the real computation
693             // for how high to be in pixels does include things like minimum font size and the zoom factor.
694             // On the other hand, since font-size doesn't include the zoom factor, we really can't do
695             // that here either.
696             float fontSize = style->htmlFont().getFontDef().specifiedSize;
697             return new CSSPrimitiveValueImpl((int)(length.length() * fontSize) / 100, CSSPrimitiveValue::CSS_PX);
698         }
699         else {
700             return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX);
701         }
702     }
703     case CSS_PROP_LIST_STYLE_IMAGE:
704         if (style->listStyleImage())
705             return new CSSPrimitiveValueImpl(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI);
706         return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
707     case CSS_PROP_LIST_STYLE_POSITION:
708         switch (style->listStylePosition()) {
709             case khtml::OUTSIDE:
710                 return new CSSPrimitiveValueImpl(CSS_VAL_OUTSIDE);
711             case khtml::INSIDE:
712                 return new CSSPrimitiveValueImpl(CSS_VAL_INSIDE);
713         }
714         ASSERT_NOT_REACHED();
715         return 0;
716     case CSS_PROP_LIST_STYLE_TYPE:
717         switch (style->listStyleType()) {
718             case khtml::LNONE:
719                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
720             case khtml::DISC:
721                 return new CSSPrimitiveValueImpl(CSS_VAL_DISC);
722             case khtml::CIRCLE:
723                 return new CSSPrimitiveValueImpl(CSS_VAL_CIRCLE);
724             case khtml::SQUARE:
725                 return new CSSPrimitiveValueImpl(CSS_VAL_SQUARE);
726             case khtml::LDECIMAL:
727                 return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL);
728             case khtml::DECIMAL_LEADING_ZERO:
729                 return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL_LEADING_ZERO);
730             case khtml::LOWER_ROMAN:
731                 return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ROMAN);
732             case khtml::UPPER_ROMAN:
733                 return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ROMAN);
734             case khtml::LOWER_GREEK:
735                 return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_GREEK);
736             case khtml::LOWER_ALPHA:
737                 return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ALPHA);
738             case khtml::LOWER_LATIN:
739                 return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_LATIN);
740             case khtml::UPPER_ALPHA:
741                 return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ALPHA);
742             case khtml::UPPER_LATIN:
743                 return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_LATIN);
744             case khtml::HEBREW:
745                 return new CSSPrimitiveValueImpl(CSS_VAL_HEBREW);
746             case khtml::ARMENIAN:
747                 return new CSSPrimitiveValueImpl(CSS_VAL_ARMENIAN);
748             case khtml::GEORGIAN:
749                 return new CSSPrimitiveValueImpl(CSS_VAL_GEORGIAN);
750             case khtml::CJK_IDEOGRAPHIC:
751                 return new CSSPrimitiveValueImpl(CSS_VAL_CJK_IDEOGRAPHIC);
752             case khtml::HIRAGANA:
753                 return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA);
754             case khtml::KATAKANA:
755                 return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA);
756             case khtml::HIRAGANA_IROHA:
757                 return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA_IROHA);
758             case khtml::KATAKANA_IROHA:
759                 return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA_IROHA);
760         }
761         ASSERT_NOT_REACHED();
762         return 0;
763     case CSS_PROP_MARGIN_TOP:
764         return valueForLength(style->marginTop());
765     case CSS_PROP_MARGIN_RIGHT:
766         return valueForLength(style->marginRight());
767     case CSS_PROP_MARGIN_BOTTOM:
768         return valueForLength(style->marginBottom());
769     case CSS_PROP_MARGIN_LEFT:
770         return valueForLength(style->marginLeft());
771     case CSS_PROP__KHTML_MARQUEE:
772         // FIXME: unimplemented
773         break;
774     case CSS_PROP__KHTML_MARQUEE_DIRECTION:
775         switch (style->marqueeDirection()) {
776             case khtml::MFORWARD:
777                 return new CSSPrimitiveValueImpl(CSS_VAL_FORWARDS);
778             case khtml::MBACKWARD:
779                 return new CSSPrimitiveValueImpl(CSS_VAL_BACKWARDS);
780             case khtml::MAUTO:
781                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
782             case khtml::MUP:
783                 return new CSSPrimitiveValueImpl(CSS_VAL_UP);
784             case khtml::MDOWN:
785                 return new CSSPrimitiveValueImpl(CSS_VAL_DOWN);
786             case khtml::MLEFT:
787                 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
788             case khtml::MRIGHT:
789                 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
790         }
791         ASSERT_NOT_REACHED();
792         return 0;
793     case CSS_PROP__KHTML_MARQUEE_INCREMENT:
794         return valueForLength(style->marqueeIncrement());
795     case CSS_PROP__KHTML_MARQUEE_REPETITION:
796         if (style->marqueeLoopCount() < 0)
797             return new CSSPrimitiveValueImpl(CSS_VAL_INFINITE);
798         return new CSSPrimitiveValueImpl(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
799     case CSS_PROP__KHTML_MARQUEE_SPEED:
800         // FIXME: unimplemented
801         break;
802     case CSS_PROP__KHTML_MARQUEE_STYLE:
803         switch (style->marqueeBehavior()) {
804             case khtml::MNONE:
805                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
806             case khtml::MSCROLL:
807                 return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
808             case khtml::MSLIDE:
809                 return new CSSPrimitiveValueImpl(CSS_VAL_SLIDE);
810             case khtml::MALTERNATE:
811                 return new CSSPrimitiveValueImpl(CSS_VAL_ALTERNATE);
812             case khtml::MUNFURL:
813                 return new CSSPrimitiveValueImpl(CSS_VAL_UNFURL);
814         }
815         ASSERT_NOT_REACHED();
816         return 0;
817     case CSS_PROP__KHTML_USER_MODIFY:
818         switch (style->userModify()) {
819             case khtml::READ_ONLY:
820                 return new CSSPrimitiveValueImpl(CSS_VAL_READ_ONLY);
821             case khtml::READ_WRITE:
822                 return new CSSPrimitiveValueImpl(CSS_VAL_READ_WRITE);
823         }
824         ASSERT_NOT_REACHED();
825         return 0;
826     case CSS_PROP_MAX_HEIGHT:
827         return valueForLength(style->maxHeight());
828     case CSS_PROP_MAX_WIDTH:
829         return valueForLength(style->maxWidth());
830     case CSS_PROP_MIN_HEIGHT:
831         return valueForLength(style->minHeight());
832     case CSS_PROP_MIN_WIDTH:
833         return valueForLength(style->minWidth());
834     case CSS_PROP_OPACITY:
835         return new CSSPrimitiveValueImpl(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
836     case CSS_PROP_ORPHANS:
837         return new CSSPrimitiveValueImpl(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
838     case CSS_PROP_OUTLINE_COLOR:
839         // FIXME: unimplemented
840         break;
841     case CSS_PROP_OUTLINE_OFFSET:
842         // FIXME: unimplemented
843         break;
844     case CSS_PROP_OUTLINE_STYLE:
845         if (style->outlineStyleIsAuto())
846             return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
847         return valueForBorderStyle(style->outlineStyle());
848     case CSS_PROP_OUTLINE_WIDTH:
849         // FIXME: unimplemented
850         break;
851     case CSS_PROP_OVERFLOW:
852         switch (style->overflow()) {
853             case khtml::OVISIBLE:
854                 return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
855             case khtml::OHIDDEN:
856                 return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
857             case khtml::OSCROLL:
858                 return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
859             case khtml::OAUTO:
860                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
861             case khtml::OMARQUEE:
862                 return new CSSPrimitiveValueImpl(CSS_VAL_MARQUEE);
863             case khtml::OOVERLAY:
864                 return new CSSPrimitiveValueImpl(CSS_VAL_OVERLAY);
865         }
866         ASSERT_NOT_REACHED();
867         return 0;
868     case CSS_PROP_PADDING_TOP:
869         return valueForLength(style->paddingTop());
870     case CSS_PROP_PADDING_RIGHT:
871         return valueForLength(style->paddingRight());
872     case CSS_PROP_PADDING_BOTTOM:
873         return valueForLength(style->paddingBottom());
874     case CSS_PROP_PADDING_LEFT:
875         return valueForLength(style->paddingLeft());
876     case CSS_PROP_PAGE:
877         // FIXME: unimplemented
878         break;
879     case CSS_PROP_PAGE_BREAK_AFTER:
880         switch (style->pageBreakAfter()) {
881             case khtml::PBAUTO:
882                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
883             case khtml::PBALWAYS:
884                 return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS);
885             case khtml::PBAVOID:
886                 return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
887         }
888         ASSERT_NOT_REACHED();
889         return 0;
890     case CSS_PROP_PAGE_BREAK_BEFORE:
891         switch (style->pageBreakBefore()) {
892             case khtml::PBAUTO:
893                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
894             case khtml::PBALWAYS:
895                 return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS);
896             case khtml::PBAVOID:
897                 return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
898         }
899         ASSERT_NOT_REACHED();
900         return 0;
901     case CSS_PROP_PAGE_BREAK_INSIDE:
902         switch (style->pageBreakInside()) {
903             case khtml::PBAUTO:
904                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
905             case khtml::PBAVOID:
906                 return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
907             case khtml::PBALWAYS:
908                 break; // not allowed
909         }
910         ASSERT_NOT_REACHED();
911         return 0;
912     case CSS_PROP_POSITION:
913         switch (style->position()) {
914             case khtml::STATIC:
915                 return new CSSPrimitiveValueImpl(CSS_VAL_STATIC);
916             case khtml::RELATIVE:
917                 return new CSSPrimitiveValueImpl(CSS_VAL_RELATIVE);
918             case khtml::ABSOLUTE:
919                 return new CSSPrimitiveValueImpl(CSS_VAL_ABSOLUTE);
920             case khtml::FIXED:
921                 return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
922         }
923         ASSERT_NOT_REACHED();
924         return 0;
925     case CSS_PROP_QUOTES:
926         // FIXME: unimplemented
927         break;
928     case CSS_PROP_RIGHT:
929         return getPositionOffsetValue(renderer, CSS_PROP_RIGHT);
930     case CSS_PROP_SIZE:
931         // FIXME: unimplemented
932         break;
933     case CSS_PROP_TABLE_LAYOUT:
934         switch (style->tableLayout()) {
935             case khtml::TAUTO:
936                 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
937             case khtml::TFIXED:
938                 return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
939         }
940         ASSERT_NOT_REACHED();
941         return 0;
942     case CSS_PROP_TEXT_ALIGN:
943         return valueForTextAlign(style->textAlign());
944     case CSS_PROP_TEXT_DECORATION:
945     {
946         QString string;
947         if (style->textDecoration() & khtml::UNDERLINE)
948             string += "underline";
949         if (style->textDecoration() & khtml::OVERLINE) {
950             if (string.length() > 0)
951                 string += " ";
952             string += "overline";
953         }
954         if (style->textDecoration() & khtml::LINE_THROUGH) {
955             if (string.length() > 0)
956                 string += " ";
957             string += "line-through";
958         }
959         if (style->textDecoration() & khtml::BLINK) {
960             if (string.length() > 0)
961                 string += " ";
962             string += "blink";
963         }
964         if (string.length() == 0)
965             return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
966         return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
967     }
968     case CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT:
969     {
970         QString string;
971         if (style->textDecorationsInEffect() & khtml::UNDERLINE)
972             string += "underline";
973         if (style->textDecorationsInEffect() & khtml::OVERLINE) {
974             if (string.length() > 0)
975                 string += " ";
976             string += "overline";
977         }
978         if (style->textDecorationsInEffect() & khtml::LINE_THROUGH) {
979             if (string.length() > 0)
980                 string += " ";
981             string += "line-through";
982         }
983         if (style->textDecorationsInEffect() & khtml::BLINK) {
984             if (string.length() > 0)
985                 string += " ";
986             string += "blink";
987         }
988         if (string.length() == 0)
989             return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
990         return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
991     }
992     case CSS_PROP_TEXT_INDENT:
993         return valueForLength(style->textIndent());
994     case CSS_PROP_TEXT_SHADOW:
995         return valueForShadow(style->textShadow());
996     case CSS_PROP__APPLE_TEXT_SIZE_ADJUST:
997         if (style->textSizeAdjust()) 
998             return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
999         else
1000             return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
1001     case CSS_PROP_TEXT_TRANSFORM:
1002         switch (style->textTransform()) {
1003             case khtml::CAPITALIZE:
1004                 return new CSSPrimitiveValueImpl(CSS_VAL_CAPITALIZE);
1005             case khtml::UPPERCASE:
1006                 return new CSSPrimitiveValueImpl(CSS_VAL_UPPERCASE);
1007             case khtml::LOWERCASE:
1008                 return new CSSPrimitiveValueImpl(CSS_VAL_LOWERCASE);
1009             case khtml::TTNONE:
1010                 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
1011         }
1012         ASSERT_NOT_REACHED();
1013         return 0;
1014     case CSS_PROP_TOP:
1015         return getPositionOffsetValue(renderer, CSS_PROP_TOP);
1016     case CSS_PROP_UNICODE_BIDI:
1017         switch (style->unicodeBidi()) {
1018             case khtml::UBNormal:
1019                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1020             case khtml::Embed:
1021                 return new CSSPrimitiveValueImpl(CSS_VAL_EMBED);
1022             case khtml::Override:
1023                 return new CSSPrimitiveValueImpl(CSS_VAL_BIDI_OVERRIDE);
1024         }
1025         ASSERT_NOT_REACHED();
1026         return 0;
1027     case CSS_PROP_VERTICAL_ALIGN:
1028         switch (style->verticalAlign()) {
1029             case khtml::BASELINE:
1030                 return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE);
1031             case khtml::MIDDLE:
1032                 return new CSSPrimitiveValueImpl(CSS_VAL_MIDDLE);
1033             case khtml::SUB:
1034                 return new CSSPrimitiveValueImpl(CSS_VAL_SUB);
1035             case khtml::SUPER:
1036                 return new CSSPrimitiveValueImpl(CSS_VAL_SUPER);
1037             case khtml::TEXT_TOP:
1038                 return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_TOP);
1039             case khtml::TEXT_BOTTOM:
1040                 return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_BOTTOM);
1041             case khtml::TOP:
1042                 return new CSSPrimitiveValueImpl(CSS_VAL_TOP);
1043             case khtml::BOTTOM:
1044                 return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM);
1045             case khtml::BASELINE_MIDDLE:
1046                 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BASELINE_MIDDLE);
1047             case khtml::LENGTH:
1048                 return valueForLength(style->verticalAlignLength());
1049         }
1050         ASSERT_NOT_REACHED();
1051         return 0;
1052     case CSS_PROP_VISIBILITY:
1053         switch (style->visibility()) {
1054             case khtml::VISIBLE:
1055                 return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
1056             case khtml::HIDDEN:
1057                 return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
1058             case khtml::COLLAPSE:
1059                 return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
1060         }
1061         ASSERT_NOT_REACHED();
1062         return 0;
1063     case CSS_PROP_WHITE_SPACE:
1064         switch (style->whiteSpace()) {
1065             case khtml::NORMAL:
1066                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1067             case khtml::PRE:
1068                 return new CSSPrimitiveValueImpl(CSS_VAL_PRE);
1069             case khtml::NOWRAP:
1070                 return new CSSPrimitiveValueImpl(CSS_VAL_NOWRAP);
1071             case khtml::KHTML_NOWRAP:
1072                 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_NOWRAP);
1073         }
1074         ASSERT_NOT_REACHED();
1075         return 0;
1076     case CSS_PROP_WIDOWS:
1077         return new CSSPrimitiveValueImpl(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
1078     case CSS_PROP_WIDTH:
1079         return new CSSPrimitiveValueImpl(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX);
1080     case CSS_PROP_WORD_SPACING:
1081         return new CSSPrimitiveValueImpl(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
1082     case CSS_PROP_WORD_WRAP:
1083         switch (style->wordWrap()) {
1084             case khtml::WBNORMAL:
1085                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1086             case khtml::BREAK_WORD:
1087                 return new CSSPrimitiveValueImpl(CSS_VAL_BREAK_WORD);
1088         }
1089         ASSERT_NOT_REACHED();
1090         return 0;
1091     case CSS_PROP__KHTML_LINE_BREAK:
1092         switch (style->khtmlLineBreak()) {
1093             case khtml::LBNORMAL:
1094                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1095             case khtml::AFTER_WHITE_SPACE:
1096                 return new CSSPrimitiveValueImpl(CSS_VAL_AFTER_WHITE_SPACE);
1097         }
1098         ASSERT_NOT_REACHED();
1099         return 0;
1100     case CSS_PROP__KHTML_NBSP_MODE:
1101         switch (style->nbspMode()) {
1102             case khtml::NBNORMAL:
1103                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1104             case khtml::SPACE:
1105                 return new CSSPrimitiveValueImpl(CSS_VAL_SPACE);
1106         }
1107         ASSERT_NOT_REACHED();
1108         return 0;
1109     case CSS_PROP__KHTML_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
1110         switch (style->matchNearestMailBlockquoteColor()) {
1111             case khtml::BCNORMAL:
1112                 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1113             case khtml::MATCH:
1114                 return new CSSPrimitiveValueImpl(CSS_VAL_MATCH);
1115         }
1116         ASSERT_NOT_REACHED();
1117         return 0;
1118     case CSS_PROP_Z_INDEX:
1119         if (style->hasAutoZIndex())
1120             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
1121         return new CSSPrimitiveValueImpl(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
1122     case CSS_PROP_BACKGROUND:
1123         // FIXME: unimplemented
1124         break;
1125     case CSS_PROP_BORDER:
1126         // FIXME: unimplemented
1127         break;
1128     case CSS_PROP_BORDER_COLOR:
1129         // FIXME: unimplemented
1130         break;
1131     case CSS_PROP_BORDER_STYLE:
1132         // FIXME: unimplemented
1133         break;
1134     case CSS_PROP_BORDER_TOP:
1135         // FIXME: unimplemented
1136         break;
1137     case CSS_PROP_BORDER_RIGHT:
1138         // FIXME: unimplemented
1139         break;
1140     case CSS_PROP_BORDER_BOTTOM:
1141         // FIXME: unimplemented
1142         break;
1143     case CSS_PROP_BORDER_LEFT:
1144         // FIXME: unimplemented
1145         break;
1146     case CSS_PROP_BORDER_WIDTH:
1147         // FIXME: unimplemented
1148         break;
1149     case CSS_PROP_FONT:
1150         // FIXME: unimplemented
1151         break;
1152     case CSS_PROP_LIST_STYLE:
1153         // FIXME: unimplemented
1154         break;
1155     case CSS_PROP_MARGIN:
1156         // FIXME: unimplemented
1157         break;
1158     case CSS_PROP_OUTLINE:
1159         // FIXME: unimplemented
1160         break;
1161     case CSS_PROP_PADDING:
1162         // FIXME: unimplemented
1163         break;
1164 #if !APPLE_CHANGES
1165     case CSS_PROP_SCROLLBAR_FACE_COLOR:
1166         // FIXME: unimplemented
1167         break;
1168     case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
1169         // FIXME: unimplemented
1170         break;
1171     case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
1172         // FIXME: unimplemented
1173         break;
1174     case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
1175         // FIXME: unimplemented
1176         break;
1177     case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
1178         // FIXME: unimplemented
1179         break;
1180     case CSS_PROP_SCROLLBAR_TRACK_COLOR:
1181         // FIXME: unimplemented
1182         break;
1183     case CSS_PROP_SCROLLBAR_ARROW_COLOR:
1184         // FIXME: unimplemented
1185         break;
1186 #endif
1187 #if APPLE_CHANGES
1188         case CSS_PROP__APPLE_DASHBOARD_REGION: {
1189             QValueList<StyleDashboardRegion> regions = style->dashboardRegions();
1190             uint i, count = regions.count();
1191             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
1192                 return new CSSPrimitiveValueImpl (CSS_VAL_NONE);
1193                 
1194             DashboardRegionImpl *firstRegion = new DashboardRegionImpl(), *region;
1195             region = firstRegion;
1196             for (i = 0; i < count; i++) {
1197                 StyleDashboardRegion styleRegion = regions[i];
1198                 region->m_label = styleRegion.label;
1199                 LengthBox offset = styleRegion.offset;
1200                 region->setTop (new CSSPrimitiveValueImpl(offset.top.value, CSSPrimitiveValue::CSS_PX));
1201                 region->setRight (new CSSPrimitiveValueImpl(offset.right.value, CSSPrimitiveValue::CSS_PX));
1202                 region->setBottom (new CSSPrimitiveValueImpl(offset.bottom.value, CSSPrimitiveValue::CSS_PX));
1203                 region->setLeft (new CSSPrimitiveValueImpl(offset.left.value, CSSPrimitiveValue::CSS_PX));
1204                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); 
1205                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
1206                 if (i != count-1) {
1207                     DashboardRegionImpl *newRegion = new DashboardRegionImpl();
1208                     region->setNext (newRegion);
1209                     region = newRegion;
1210                 }
1211             }
1212             return new CSSPrimitiveValueImpl(firstRegion);
1213         }
1214 #endif
1215     }
1216
1217     ERROR("unimplemented propertyID: %d", propertyID);
1218     return 0;
1219 }
1220
1221 DOMString CSSComputedStyleDeclarationImpl::getPropertyValue(int propertyID) const
1222 {
1223     CSSValueImpl* value = getPropertyCSSValue(propertyID);
1224     if (value) {
1225         value->ref();
1226         DOMString result = value->cssText();
1227         value->deref();
1228         return result;
1229     }
1230     return "";
1231 }
1232
1233 bool CSSComputedStyleDeclarationImpl::getPropertyPriority(int) const
1234 {
1235     // All computed styles have a priority of false (not "important").
1236     return false;
1237 }
1238
1239 DOMString CSSComputedStyleDeclarationImpl::removeProperty(int, int &exceptionCode)
1240 {
1241     exceptionCode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
1242     return DOMString();
1243 }
1244
1245 void CSSComputedStyleDeclarationImpl::setProperty(int, const DOMString &, bool, int &exceptionCode)
1246 {
1247     exceptionCode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
1248 }
1249
1250 unsigned long CSSComputedStyleDeclarationImpl::length() const
1251 {
1252     return numComputedProperties;
1253 }
1254
1255 DOMString CSSComputedStyleDeclarationImpl::item(unsigned long i) const
1256 {
1257     if (i >= numComputedProperties)
1258         return DOMString();
1259     return getPropertyValue(computedProperties[i]);
1260 }
1261
1262 CSSMutableStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copyInheritableProperties() const
1263 {
1264     return copyPropertiesInSet(inheritableProperties, numInheritableProperties);
1265 }
1266
1267 CSSMutableStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copy() const
1268 {
1269     return copyPropertiesInSet(computedProperties, numComputedProperties);
1270 }
1271
1272 CSSMutableStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::makeMutable()
1273 {
1274     return copy();
1275 }
1276
1277 } // namespace DOM