2 * CSSComputedStyleDeclaration.cpp
4 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
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.
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.
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
24 #include "CSSComputedStyleDeclaration.h"
26 #include "CachedImage.h"
27 #include "DashboardRegion.h"
29 #include "ExceptionCode.h"
30 #include "CSSMutableStyleDeclaration.h"
31 #include "CSSPrimitiveValue.h"
32 #include "CSSPropertyNames.h"
33 #include "CSSValueKeywords.h"
34 #include "CSSValueList.h"
36 #include "RenderObject.h"
37 #include "ShadowValue.h"
39 extern WebCore::String getPropertyName(unsigned short id);
43 // List of all properties we know how to compute, omitting shorthands.
44 static const int computedProperties[] = {
45 CSS_PROP_BACKGROUND_COLOR,
46 CSS_PROP_BACKGROUND_IMAGE,
47 CSS_PROP__WEBKIT_BACKGROUND_SIZE,
48 CSS_PROP_BACKGROUND_REPEAT,
49 CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE,
50 CSS_PROP_BACKGROUND_ATTACHMENT,
51 CSS_PROP__WEBKIT_BACKGROUND_CLIP,
52 CSS_PROP__WEBKIT_BACKGROUND_ORIGIN,
53 CSS_PROP_BACKGROUND_POSITION_X,
54 CSS_PROP_BACKGROUND_POSITION_Y,
55 CSS_PROP_BORDER_COLLAPSE,
56 CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING,
57 CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING,
58 CSS_PROP_BORDER_TOP_COLOR,
59 CSS_PROP_BORDER_RIGHT_COLOR,
60 CSS_PROP_BORDER_BOTTOM_COLOR,
61 CSS_PROP_BORDER_LEFT_COLOR,
62 CSS_PROP_BORDER_TOP_STYLE,
63 CSS_PROP_BORDER_RIGHT_STYLE,
64 CSS_PROP_BORDER_BOTTOM_STYLE,
65 CSS_PROP_BORDER_LEFT_STYLE,
66 CSS_PROP_BORDER_TOP_WIDTH,
67 CSS_PROP_BORDER_RIGHT_WIDTH,
68 CSS_PROP_BORDER_BOTTOM_WIDTH,
69 CSS_PROP_BORDER_LEFT_WIDTH,
71 CSS_PROP__WEBKIT_BOX_ALIGN,
72 CSS_PROP__WEBKIT_BOX_DIRECTION,
73 CSS_PROP__WEBKIT_BOX_FLEX,
74 CSS_PROP__WEBKIT_BOX_FLEX_GROUP,
75 CSS_PROP__WEBKIT_BOX_LINES,
76 CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP,
77 CSS_PROP__WEBKIT_BOX_ORIENT,
78 CSS_PROP__WEBKIT_BOX_PACK,
79 CSS_PROP_CAPTION_SIDE,
84 CSS_PROP__WEBKIT_DASHBOARD_REGION,
93 CSS_PROP_FONT_VARIANT,
96 CSS_PROP__WEBKIT_HIGHLIGHT,
98 CSS_PROP_LETTER_SPACING,
99 CSS_PROP__WEBKIT_LINE_BREAK,
100 CSS_PROP__WEBKIT_LINE_CLAMP,
101 CSS_PROP_LINE_HEIGHT,
102 CSS_PROP_LIST_STYLE_IMAGE,
103 CSS_PROP_LIST_STYLE_POSITION,
104 CSS_PROP_LIST_STYLE_TYPE,
106 CSS_PROP_MARGIN_RIGHT,
107 CSS_PROP_MARGIN_BOTTOM,
108 CSS_PROP_MARGIN_LEFT,
109 CSS_PROP__WEBKIT_MARQUEE_DIRECTION,
110 CSS_PROP__WEBKIT_MARQUEE_INCREMENT,
111 CSS_PROP__WEBKIT_MARQUEE_REPETITION,
112 CSS_PROP__WEBKIT_MARQUEE_STYLE,
117 CSS_PROP__WEBKIT_NBSP_MODE,
120 CSS_PROP_OUTLINE_STYLE,
123 CSS_PROP_PADDING_TOP,
124 CSS_PROP_PADDING_RIGHT,
125 CSS_PROP_PADDING_BOTTOM,
126 CSS_PROP_PADDING_LEFT,
127 CSS_PROP_PAGE_BREAK_AFTER,
128 CSS_PROP_PAGE_BREAK_BEFORE,
129 CSS_PROP_PAGE_BREAK_INSIDE,
133 CSS_PROP_TABLE_LAYOUT,
135 CSS_PROP_TEXT_DECORATION,
136 CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
137 CSS_PROP_TEXT_INDENT,
138 CSS_PROP_TEXT_SHADOW,
139 CSS_PROP__WEBKIT_TEXT_SECURITY,
140 CSS_PROP_TEXT_TRANSFORM,
142 CSS_PROP_UNICODE_BIDI,
143 CSS_PROP__WEBKIT_USER_MODIFY,
144 CSS_PROP_VERTICAL_ALIGN,
146 CSS_PROP_WHITE_SPACE,
149 CSS_PROP_WORD_SPACING,
154 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
156 static CSSValue* valueForLength(const Length& length)
158 switch (length.type()) {
160 return new CSSPrimitiveValue(CSS_VAL_AUTO);
162 if (length.value() == undefinedLength)
163 return new CSSPrimitiveValue(CSS_VAL_NONE);
164 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
166 return new CSSPrimitiveValue(CSS_VAL_INTRINSIC);
168 return new CSSPrimitiveValue(CSS_VAL_MIN_INTRINSIC);
170 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
173 // Should never be reached.
176 // Should never be reached, but if we do, just return "auto".
177 return new CSSPrimitiveValue(CSS_VAL_AUTO);
180 static CSSValue *valueForBorderStyle(EBorderStyle style)
184 return new CSSPrimitiveValue(CSS_VAL_NONE);
186 return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
188 return new CSSPrimitiveValue(CSS_VAL_INSET);
190 return new CSSPrimitiveValue(CSS_VAL_GROOVE);
192 return new CSSPrimitiveValue(CSS_VAL_RIDGE);
194 return new CSSPrimitiveValue(CSS_VAL_OUTSET);
196 return new CSSPrimitiveValue(CSS_VAL_DOTTED);
198 return new CSSPrimitiveValue(CSS_VAL_DASHED);
200 return new CSSPrimitiveValue(CSS_VAL_SOLID);
202 return new CSSPrimitiveValue(CSS_VAL_DOUBLE);
204 ASSERT_NOT_REACHED();
208 static CSSValue *valueForTextAlign(ETextAlign align)
212 return new CSSPrimitiveValue(CSS_VAL_AUTO);
214 return new CSSPrimitiveValue(CSS_VAL_LEFT);
216 return new CSSPrimitiveValue(CSS_VAL_RIGHT);
218 return new CSSPrimitiveValue(CSS_VAL_CENTER);
220 return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
222 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_LEFT);
224 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_RIGHT);
226 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_CENTER);
228 ASSERT_NOT_REACHED();
232 static CSSValue* valueForShadow(const ShadowData* shadow)
235 return new CSSPrimitiveValue(CSS_VAL_NONE);
236 CSSValueList* list = new CSSValueList;
237 for (const ShadowData* s = shadow; s; s = s->next) {
238 CSSPrimitiveValue* x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
239 CSSPrimitiveValue* y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
240 CSSPrimitiveValue* blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
241 CSSPrimitiveValue* color = new CSSPrimitiveValue(s->color.rgb());
242 list->append(new ShadowValue(x, y, blur, color));
247 static CSSValue *getPositionOffsetValue(RenderObject *renderer, int propertyID)
252 RenderStyle *style = renderer->style();
257 switch (propertyID) {
267 case CSS_PROP_BOTTOM:
274 if (renderer->isPositioned())
275 return valueForLength(l);
277 if (renderer->isRelPositioned())
278 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
279 // In other words if left is auto and right is not auto, then left's computed value is negative right.
280 // So we should get the opposite length unit and see if it is auto.
281 return valueForLength(l);
283 return new CSSPrimitiveValue(CSS_VAL_AUTO);
286 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n)
291 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
295 String CSSComputedStyleDeclaration::cssText() const
299 for (unsigned i = 0; i < numComputedProperties; i++) {
302 result += getPropertyName(computedProperties[i]);
304 result += getPropertyValue(computedProperties[i]);
311 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
313 ec = NO_MODIFICATION_ALLOWED_ERR;
316 // Display integers in integer format instead of "1.0".
317 static String numberAsString(double n)
319 long i = static_cast<long>(n);
320 return i == n ? String::number(i) : String::number(n);
323 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
325 return getPropertyCSSValue(propertyID, UpdateLayout);
328 CSSPrimitiveValue* primitiveValueFromLength(Length length, RenderObject* renderer, RenderStyle* style)
331 if (length.isPercent())
332 string = numberAsString(length.value()) + "%";
333 else if (length.isFixed())
334 string = numberAsString(length.calcMinValue(0));
335 else if (length.isAuto())
337 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
340 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
342 Node* node = m_node.get();
346 // Make sure our layout is up to date before we allow a query on these attributes.
348 node->document()->updateLayout();
350 // FIXME: This should work even if we do not have a renderer.
351 RenderObject* renderer = node->renderer();
354 RenderStyle* style = renderer->style();
360 case CSS_PROP_BACKGROUND_COLOR:
361 return new CSSPrimitiveValue(style->backgroundColor().rgb());
362 case CSS_PROP_BACKGROUND_IMAGE:
363 if (style->backgroundImage())
364 return new CSSPrimitiveValue(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
365 return new CSSPrimitiveValue(CSS_VAL_NONE);
366 case CSS_PROP__WEBKIT_BACKGROUND_SIZE: {
367 Length widthLength = style->backgroundSize().width;
368 Length heightLength = style->backgroundSize().height;
369 CSSPrimitiveValue* bgWidth = primitiveValueFromLength(widthLength, renderer, style);
370 CSSPrimitiveValue* bgHeight = primitiveValueFromLength(heightLength, renderer, style);
371 Pair* pair = new Pair(bgWidth, bgHeight);
372 return new CSSPrimitiveValue(pair);
374 case CSS_PROP_BACKGROUND_REPEAT:
375 switch (style->backgroundRepeat()) {
377 return new CSSPrimitiveValue(CSS_VAL_REPEAT);
379 return new CSSPrimitiveValue(CSS_VAL_REPEAT_X);
381 return new CSSPrimitiveValue(CSS_VAL_REPEAT_Y);
383 return new CSSPrimitiveValue(CSS_VAL_NO_REPEAT);
385 ASSERT_NOT_REACHED();
387 case CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE:
388 switch (style->backgroundComposite()) {
390 return new CSSPrimitiveValue(CSS_VAL_CLEAR);
392 return new CSSPrimitiveValue(CSS_VAL_COPY);
393 case CompositeSourceOver:
394 return new CSSPrimitiveValue(CSS_VAL_SOURCE_OVER);
395 case CompositeSourceIn:
396 return new CSSPrimitiveValue(CSS_VAL_SOURCE_IN);
397 case CompositeSourceOut:
398 return new CSSPrimitiveValue(CSS_VAL_SOURCE_OUT);
399 case CompositeSourceAtop:
400 return new CSSPrimitiveValue(CSS_VAL_SOURCE_ATOP);
401 case CompositeDestinationOver:
402 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OVER);
403 case CompositeDestinationIn:
404 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_IN);
405 case CompositeDestinationOut:
406 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OUT);
407 case CompositeDestinationAtop:
408 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_ATOP);
410 return new CSSPrimitiveValue(CSS_VAL_XOR);
411 case CompositePlusDarker:
412 return new CSSPrimitiveValue(CSS_VAL_PLUS_DARKER);
413 case CompositeHighlight:
414 return new CSSPrimitiveValue(CSS_VAL_HIGHLIGHT);
415 case CompositePlusLighter:
416 return new CSSPrimitiveValue(CSS_VAL_PLUS_LIGHTER);
418 ASSERT_NOT_REACHED();
420 case CSS_PROP_BACKGROUND_ATTACHMENT:
421 if (style->backgroundAttachment())
422 return new CSSPrimitiveValue(CSS_VAL_SCROLL);
423 return new CSSPrimitiveValue(CSS_VAL_FIXED);
424 case CSS_PROP__WEBKIT_BACKGROUND_CLIP:
425 case CSS_PROP__WEBKIT_BACKGROUND_ORIGIN: {
426 EBackgroundBox box = (propertyID == CSS_PROP__WEBKIT_BACKGROUND_CLIP ? style->backgroundClip() : style->backgroundOrigin());
428 return new CSSPrimitiveValue(CSS_VAL_BORDER);
429 if (box == BGPADDING)
430 return new CSSPrimitiveValue(CSS_VAL_PADDING);
431 return new CSSPrimitiveValue(CSS_VAL_CONTENT);
433 case CSS_PROP_BACKGROUND_POSITION:
436 Length length(style->backgroundXPosition());
437 if (length.isPercent())
438 string = numberAsString(length.value()) + "%";
440 string = numberAsString(length.calcMinValue(renderer->contentWidth()));
442 length = style->backgroundYPosition();
443 if (length.isPercent())
444 string += numberAsString(length.value()) + "%";
446 string += numberAsString(length.calcMinValue(renderer->contentWidth()));
447 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
449 case CSS_PROP_BACKGROUND_POSITION_X:
450 return valueForLength(style->backgroundXPosition());
451 case CSS_PROP_BACKGROUND_POSITION_Y:
452 return valueForLength(style->backgroundYPosition());
454 case CSS_PROP__WEBKIT_BINDING:
455 // FIXME: unimplemented
458 case CSS_PROP_BORDER_COLLAPSE:
459 if (style->borderCollapse())
460 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
462 return new CSSPrimitiveValue(CSS_VAL_SEPARATE);
463 case CSS_PROP_BORDER_SPACING:
465 String string(numberAsString(style->horizontalBorderSpacing()) + "px " + numberAsString(style->verticalBorderSpacing()) + "px");
466 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
468 case CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING:
469 return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
470 case CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING:
471 return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
472 case CSS_PROP_BORDER_TOP_COLOR:
473 return new CSSPrimitiveValue(style->borderLeftColor().rgb());
474 case CSS_PROP_BORDER_RIGHT_COLOR:
475 return new CSSPrimitiveValue(style->borderRightColor().rgb());
476 case CSS_PROP_BORDER_BOTTOM_COLOR:
477 return new CSSPrimitiveValue(style->borderBottomColor().rgb());
478 case CSS_PROP_BORDER_LEFT_COLOR:
479 return new CSSPrimitiveValue(style->borderLeftColor().rgb());
480 case CSS_PROP_BORDER_TOP_STYLE:
481 return valueForBorderStyle(style->borderTopStyle());
482 case CSS_PROP_BORDER_RIGHT_STYLE:
483 return valueForBorderStyle(style->borderRightStyle());
484 case CSS_PROP_BORDER_BOTTOM_STYLE:
485 return valueForBorderStyle(style->borderBottomStyle());
486 case CSS_PROP_BORDER_LEFT_STYLE:
487 return valueForBorderStyle(style->borderLeftStyle());
488 case CSS_PROP_BORDER_TOP_WIDTH:
489 return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
490 case CSS_PROP_BORDER_RIGHT_WIDTH:
491 return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
492 case CSS_PROP_BORDER_BOTTOM_WIDTH:
493 return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
494 case CSS_PROP_BORDER_LEFT_WIDTH:
495 return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
496 case CSS_PROP_BOTTOM:
497 return getPositionOffsetValue(renderer, CSS_PROP_BOTTOM);
498 case CSS_PROP__WEBKIT_BOX_ALIGN:
499 switch (style->boxAlign()) {
501 return new CSSPrimitiveValue(CSS_VAL_STRETCH);
503 return new CSSPrimitiveValue(CSS_VAL_START);
505 return new CSSPrimitiveValue(CSS_VAL_CENTER);
507 return new CSSPrimitiveValue(CSS_VAL_END);
509 return new CSSPrimitiveValue(CSS_VAL_BASELINE);
511 break; // not allowed
513 ASSERT_NOT_REACHED();
515 case CSS_PROP__WEBKIT_BOX_DIRECTION:
516 switch (style->boxDirection()) {
518 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
520 return new CSSPrimitiveValue(CSS_VAL_REVERSE);
522 ASSERT_NOT_REACHED();
524 case CSS_PROP__WEBKIT_BOX_FLEX:
525 return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
526 case CSS_PROP__WEBKIT_BOX_FLEX_GROUP:
527 return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
528 case CSS_PROP__WEBKIT_BOX_LINES:
529 switch (style->boxLines()) {
531 return new CSSPrimitiveValue(CSS_VAL_SINGLE);
533 return new CSSPrimitiveValue(CSS_VAL_MULTIPLE);
535 ASSERT_NOT_REACHED();
537 case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP:
538 return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
539 case CSS_PROP__WEBKIT_BOX_ORIENT:
540 switch (style->boxOrient()) {
542 return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
544 return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
546 ASSERT_NOT_REACHED();
548 case CSS_PROP__WEBKIT_BOX_PACK:
549 switch (style->boxPack()) {
551 return new CSSPrimitiveValue(CSS_VAL_START);
553 return new CSSPrimitiveValue(CSS_VAL_END);
555 return new CSSPrimitiveValue(CSS_VAL_CENTER);
557 return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
560 break; // not allowed
562 ASSERT_NOT_REACHED();
564 case CSS_PROP_CAPTION_SIDE:
565 switch (style->captionSide()) {
567 return new CSSPrimitiveValue(CSS_VAL_LEFT);
569 return new CSSPrimitiveValue(CSS_VAL_RIGHT);
571 return new CSSPrimitiveValue(CSS_VAL_TOP);
573 return new CSSPrimitiveValue(CSS_VAL_BOTTOM);
575 ASSERT_NOT_REACHED();
578 switch (style->clear()) {
580 return new CSSPrimitiveValue(CSS_VAL_NONE);
582 return new CSSPrimitiveValue(CSS_VAL_LEFT);
584 return new CSSPrimitiveValue(CSS_VAL_RIGHT);
586 return new CSSPrimitiveValue(CSS_VAL_BOTH);
588 ASSERT_NOT_REACHED();
591 // FIXME: unimplemented
594 return new CSSPrimitiveValue(style->color().rgb());
595 case CSS_PROP_CONTENT:
596 // FIXME: unimplemented
598 case CSS_PROP_COUNTER_INCREMENT:
599 // FIXME: unimplemented
601 case CSS_PROP_COUNTER_RESET:
602 // FIXME: unimplemented
604 case CSS_PROP_CURSOR:
605 if (style->cursorImage())
606 return new CSSPrimitiveValue(style->cursorImage()->url(), CSSPrimitiveValue::CSS_URI);
607 switch (style->cursor()) {
609 return new CSSPrimitiveValue(CSS_VAL_AUTO);
611 return new CSSPrimitiveValue(CSS_VAL_CROSSHAIR);
613 return new CSSPrimitiveValue(CSS_VAL_DEFAULT);
615 return new CSSPrimitiveValue(CSS_VAL_POINTER);
617 return new CSSPrimitiveValue(CSS_VAL_MOVE);
618 case CURSOR_E_RESIZE:
619 return new CSSPrimitiveValue(CSS_VAL_E_RESIZE);
620 case CURSOR_NE_RESIZE:
621 return new CSSPrimitiveValue(CSS_VAL_NE_RESIZE);
622 case CURSOR_NW_RESIZE:
623 return new CSSPrimitiveValue(CSS_VAL_NW_RESIZE);
624 case CURSOR_N_RESIZE:
625 return new CSSPrimitiveValue(CSS_VAL_N_RESIZE);
626 case CURSOR_SE_RESIZE:
627 return new CSSPrimitiveValue(CSS_VAL_SE_RESIZE);
628 case CURSOR_SW_RESIZE:
629 return new CSSPrimitiveValue(CSS_VAL_SW_RESIZE);
630 case CURSOR_S_RESIZE:
631 return new CSSPrimitiveValue(CSS_VAL_S_RESIZE);
632 case CURSOR_W_RESIZE:
633 return new CSSPrimitiveValue(CSS_VAL_W_RESIZE);
634 case CURSOR_EW_RESIZE:
635 return new CSSPrimitiveValue(CSS_VAL_EW_RESIZE);
636 case CURSOR_NS_RESIZE:
637 return new CSSPrimitiveValue(CSS_VAL_NS_RESIZE);
638 case CURSOR_NESW_RESIZE:
639 return new CSSPrimitiveValue(CSS_VAL_NESW_RESIZE);
640 case CURSOR_NWSE_RESIZE:
641 return new CSSPrimitiveValue(CSS_VAL_NWSE_RESIZE);
642 case CURSOR_COL_RESIZE:
643 return new CSSPrimitiveValue(CSS_VAL_COL_RESIZE);
644 case CURSOR_ROW_RESIZE:
645 return new CSSPrimitiveValue(CSS_VAL_ROW_RESIZE);
647 return new CSSPrimitiveValue(CSS_VAL_TEXT);
649 return new CSSPrimitiveValue(CSS_VAL_WAIT);
651 return new CSSPrimitiveValue(CSS_VAL_HELP);
653 ASSERT_NOT_REACHED();
655 case CSS_PROP_DIRECTION:
656 switch (style->direction()) {
658 return new CSSPrimitiveValue(CSS_VAL_LTR);
660 return new CSSPrimitiveValue(CSS_VAL_RTL);
662 ASSERT_NOT_REACHED();
664 case CSS_PROP_DISPLAY:
665 switch (style->display()) {
667 return new CSSPrimitiveValue(CSS_VAL_INLINE);
669 return new CSSPrimitiveValue(CSS_VAL_BLOCK);
671 return new CSSPrimitiveValue(CSS_VAL_LIST_ITEM);
673 return new CSSPrimitiveValue(CSS_VAL_RUN_IN);
675 return new CSSPrimitiveValue(CSS_VAL_COMPACT);
677 return new CSSPrimitiveValue(CSS_VAL_INLINE_BLOCK);
679 return new CSSPrimitiveValue(CSS_VAL_TABLE);
681 return new CSSPrimitiveValue(CSS_VAL_INLINE_TABLE);
682 case TABLE_ROW_GROUP:
683 return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW_GROUP);
684 case TABLE_HEADER_GROUP:
685 return new CSSPrimitiveValue(CSS_VAL_TABLE_HEADER_GROUP);
686 case TABLE_FOOTER_GROUP:
687 return new CSSPrimitiveValue(CSS_VAL_TABLE_FOOTER_GROUP);
689 return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW);
690 case TABLE_COLUMN_GROUP:
691 return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN_GROUP);
693 return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN);
695 return new CSSPrimitiveValue(CSS_VAL_TABLE_CELL);
697 return new CSSPrimitiveValue(CSS_VAL_TABLE_CAPTION);
699 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BOX);
701 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_INLINE_BOX);
703 return new CSSPrimitiveValue(CSS_VAL_NONE);
705 ASSERT_NOT_REACHED();
707 case CSS_PROP_EMPTY_CELLS:
708 switch (style->emptyCells()) {
710 return new CSSPrimitiveValue(CSS_VAL_SHOW);
712 return new CSSPrimitiveValue(CSS_VAL_HIDE);
714 ASSERT_NOT_REACHED();
717 switch (style->floating()) {
719 return new CSSPrimitiveValue(CSS_VAL_NONE);
721 return new CSSPrimitiveValue(CSS_VAL_LEFT);
723 return new CSSPrimitiveValue(CSS_VAL_RIGHT);
725 ASSERT_NOT_REACHED();
727 case CSS_PROP_FONT_FAMILY:
729 // FIXME: This only returns the first family.
730 const FontDescription& desc = style->fontDescription();
731 return new CSSPrimitiveValue(desc.family().family().domString(), CSSPrimitiveValue::CSS_STRING);
733 case CSS_PROP_FONT_SIZE:
735 FontDescription desc = style->fontDescription();
736 return new CSSPrimitiveValue(desc.computedPixelSize(), CSSPrimitiveValue::CSS_PX);
738 case CSS_PROP_FONT_STRETCH:
739 // FIXME: unimplemented
741 case CSS_PROP_FONT_STYLE:
743 // FIXME: handle oblique?
744 const FontDescription& desc = style->fontDescription();
746 return new CSSPrimitiveValue(CSS_VAL_ITALIC);
748 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
750 case CSS_PROP_FONT_VARIANT:
752 const FontDescription& desc = style->fontDescription();
753 if (desc.smallCaps())
754 return new CSSPrimitiveValue(CSS_VAL_SMALL_CAPS);
756 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
758 case CSS_PROP_FONT_WEIGHT:
760 // FIXME: this does not reflect the full range of weights
761 // that can be expressed with CSS
762 const FontDescription& desc = style->fontDescription();
763 if (desc.weight() == cBoldWeight)
764 return new CSSPrimitiveValue(CSS_VAL_BOLD);
766 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
768 case CSS_PROP_HEIGHT:
769 return new CSSPrimitiveValue(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);
770 case CSS_PROP__WEBKIT_HIGHLIGHT: {
771 if (style->highlight() == nullAtom)
772 return new CSSPrimitiveValue(CSS_VAL_NONE);
774 return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
777 return getPositionOffsetValue(renderer, CSS_PROP_LEFT);
778 case CSS_PROP_LETTER_SPACING:
779 if (style->letterSpacing() == 0)
780 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
781 return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
782 case CSS_PROP__WEBKIT_LINE_CLAMP:
783 if (style->lineClamp() == -1)
784 return new CSSPrimitiveValue(CSS_VAL_NONE);
785 return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
786 case CSS_PROP_LINE_HEIGHT: {
787 Length length(style->lineHeight());
788 if (length.value() < 0)
789 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
790 if (length.isPercent()) {
791 // This is imperfect, because it doesn't include the zoom factor and the real computation
792 // for how high to be in pixels does include things like minimum font size and the zoom factor.
793 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
795 float fontSize = style->fontDescription().specifiedSize();
796 return new CSSPrimitiveValue((int)(length.value() * fontSize) / 100, CSSPrimitiveValue::CSS_PX);
799 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
802 case CSS_PROP_LIST_STYLE_IMAGE:
803 if (style->listStyleImage())
804 return new CSSPrimitiveValue(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI);
805 return new CSSPrimitiveValue(CSS_VAL_NONE);
806 case CSS_PROP_LIST_STYLE_POSITION:
807 switch (style->listStylePosition()) {
809 return new CSSPrimitiveValue(CSS_VAL_OUTSIDE);
811 return new CSSPrimitiveValue(CSS_VAL_INSIDE);
813 ASSERT_NOT_REACHED();
815 case CSS_PROP_LIST_STYLE_TYPE:
816 switch (style->listStyleType()) {
818 return new CSSPrimitiveValue(CSS_VAL_NONE);
820 return new CSSPrimitiveValue(CSS_VAL_DISC);
822 return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
824 return new CSSPrimitiveValue(CSS_VAL_SQUARE);
826 return new CSSPrimitiveValue(CSS_VAL_DECIMAL);
827 case DECIMAL_LEADING_ZERO:
828 return new CSSPrimitiveValue(CSS_VAL_DECIMAL_LEADING_ZERO);
830 return new CSSPrimitiveValue(CSS_VAL_LOWER_ROMAN);
832 return new CSSPrimitiveValue(CSS_VAL_UPPER_ROMAN);
834 return new CSSPrimitiveValue(CSS_VAL_LOWER_GREEK);
836 return new CSSPrimitiveValue(CSS_VAL_LOWER_ALPHA);
838 return new CSSPrimitiveValue(CSS_VAL_LOWER_LATIN);
840 return new CSSPrimitiveValue(CSS_VAL_UPPER_ALPHA);
842 return new CSSPrimitiveValue(CSS_VAL_UPPER_LATIN);
844 return new CSSPrimitiveValue(CSS_VAL_HEBREW);
846 return new CSSPrimitiveValue(CSS_VAL_ARMENIAN);
848 return new CSSPrimitiveValue(CSS_VAL_GEORGIAN);
849 case CJK_IDEOGRAPHIC:
850 return new CSSPrimitiveValue(CSS_VAL_CJK_IDEOGRAPHIC);
852 return new CSSPrimitiveValue(CSS_VAL_HIRAGANA);
854 return new CSSPrimitiveValue(CSS_VAL_KATAKANA);
856 return new CSSPrimitiveValue(CSS_VAL_HIRAGANA_IROHA);
858 return new CSSPrimitiveValue(CSS_VAL_KATAKANA_IROHA);
860 ASSERT_NOT_REACHED();
862 case CSS_PROP_MARGIN_TOP:
863 // FIXME: Supposed to return the percentage if percentage was specified.
864 return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
865 case CSS_PROP_MARGIN_RIGHT:
866 // FIXME: Supposed to return the percentage if percentage was specified.
867 return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
868 case CSS_PROP_MARGIN_BOTTOM:
869 // FIXME: Supposed to return the percentage if percentage was specified.
870 return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
871 case CSS_PROP_MARGIN_LEFT:
872 // FIXME: Supposed to return the percentage if percentage was specified.
873 return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
874 case CSS_PROP__WEBKIT_MARQUEE:
875 // FIXME: unimplemented
877 case CSS_PROP__WEBKIT_MARQUEE_DIRECTION:
878 switch (style->marqueeDirection()) {
880 return new CSSPrimitiveValue(CSS_VAL_FORWARDS);
882 return new CSSPrimitiveValue(CSS_VAL_BACKWARDS);
884 return new CSSPrimitiveValue(CSS_VAL_AUTO);
886 return new CSSPrimitiveValue(CSS_VAL_UP);
888 return new CSSPrimitiveValue(CSS_VAL_DOWN);
890 return new CSSPrimitiveValue(CSS_VAL_LEFT);
892 return new CSSPrimitiveValue(CSS_VAL_RIGHT);
894 ASSERT_NOT_REACHED();
896 case CSS_PROP__WEBKIT_MARQUEE_INCREMENT:
897 return valueForLength(style->marqueeIncrement());
898 case CSS_PROP__WEBKIT_MARQUEE_REPETITION:
899 if (style->marqueeLoopCount() < 0)
900 return new CSSPrimitiveValue(CSS_VAL_INFINITE);
901 return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
902 case CSS_PROP__WEBKIT_MARQUEE_SPEED:
903 // FIXME: unimplemented
905 case CSS_PROP__WEBKIT_MARQUEE_STYLE:
906 switch (style->marqueeBehavior()) {
908 return new CSSPrimitiveValue(CSS_VAL_NONE);
910 return new CSSPrimitiveValue(CSS_VAL_SCROLL);
912 return new CSSPrimitiveValue(CSS_VAL_SLIDE);
914 return new CSSPrimitiveValue(CSS_VAL_ALTERNATE);
916 return new CSSPrimitiveValue(CSS_VAL_UNFURL);
918 ASSERT_NOT_REACHED();
920 case CSS_PROP__WEBKIT_USER_MODIFY:
921 switch (style->userModify()) {
923 return new CSSPrimitiveValue(CSS_VAL_READ_ONLY);
925 return new CSSPrimitiveValue(CSS_VAL_READ_WRITE);
926 case READ_WRITE_PLAINTEXT_ONLY:
927 return new CSSPrimitiveValue(CSS_VAL_READ_WRITE_PLAINTEXT_ONLY);
929 ASSERT_NOT_REACHED();
931 case CSS_PROP_MAX_HEIGHT:
932 return valueForLength(style->maxHeight());
933 case CSS_PROP_MAX_WIDTH:
934 return valueForLength(style->maxWidth());
935 case CSS_PROP_MIN_HEIGHT:
936 return valueForLength(style->minHeight());
937 case CSS_PROP_MIN_WIDTH:
938 return valueForLength(style->minWidth());
939 case CSS_PROP_OPACITY:
940 return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
941 case CSS_PROP_ORPHANS:
942 return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
943 case CSS_PROP_OUTLINE_COLOR:
944 // FIXME: unimplemented
946 case CSS_PROP_OUTLINE_OFFSET:
947 // FIXME: unimplemented
949 case CSS_PROP_OUTLINE_STYLE:
950 if (style->outlineStyleIsAuto())
951 return new CSSPrimitiveValue(CSS_VAL_AUTO);
952 return valueForBorderStyle(style->outlineStyle());
953 case CSS_PROP_OUTLINE_WIDTH:
954 // FIXME: unimplemented
956 case CSS_PROP_OVERFLOW:
957 case CSS_PROP_OVERFLOW_X:
958 case CSS_PROP_OVERFLOW_Y:
960 switch (propertyID) {
961 case CSS_PROP_OVERFLOW_X:
962 overflow = style->overflowX();
964 case CSS_PROP_OVERFLOW_Y:
965 overflow = style->overflowY();
968 overflow = max(style->overflowX(), style->overflowY());
972 return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
974 return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
976 return new CSSPrimitiveValue(CSS_VAL_SCROLL);
978 return new CSSPrimitiveValue(CSS_VAL_AUTO);
980 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_MARQUEE);
982 return new CSSPrimitiveValue(CSS_VAL_OVERLAY);
984 ASSERT_NOT_REACHED();
986 case CSS_PROP_PADDING_TOP:
987 return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
988 case CSS_PROP_PADDING_RIGHT:
989 return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
990 case CSS_PROP_PADDING_BOTTOM:
991 return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
992 case CSS_PROP_PADDING_LEFT:
993 return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
995 // FIXME: unimplemented
997 case CSS_PROP_PAGE_BREAK_AFTER:
998 switch (style->pageBreakAfter()) {
1000 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1002 return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
1004 return new CSSPrimitiveValue(CSS_VAL_AVOID);
1006 ASSERT_NOT_REACHED();
1008 case CSS_PROP_PAGE_BREAK_BEFORE:
1009 switch (style->pageBreakBefore()) {
1011 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1013 return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
1015 return new CSSPrimitiveValue(CSS_VAL_AVOID);
1017 ASSERT_NOT_REACHED();
1019 case CSS_PROP_PAGE_BREAK_INSIDE:
1020 switch (style->pageBreakInside()) {
1022 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1024 return new CSSPrimitiveValue(CSS_VAL_AVOID);
1026 break; // not allowed
1028 ASSERT_NOT_REACHED();
1030 case CSS_PROP_POSITION:
1031 switch (style->position()) {
1032 case StaticPosition:
1033 return new CSSPrimitiveValue(CSS_VAL_STATIC);
1034 case RelativePosition:
1035 return new CSSPrimitiveValue(CSS_VAL_RELATIVE);
1036 case AbsolutePosition:
1037 return new CSSPrimitiveValue(CSS_VAL_ABSOLUTE);
1039 return new CSSPrimitiveValue(CSS_VAL_FIXED);
1041 ASSERT_NOT_REACHED();
1043 case CSS_PROP_QUOTES:
1044 // FIXME: unimplemented
1046 case CSS_PROP_RIGHT:
1047 return getPositionOffsetValue(renderer, CSS_PROP_RIGHT);
1049 // FIXME: unimplemented
1051 case CSS_PROP_TABLE_LAYOUT:
1052 switch (style->tableLayout()) {
1054 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1056 return new CSSPrimitiveValue(CSS_VAL_FIXED);
1058 ASSERT_NOT_REACHED();
1060 case CSS_PROP_TEXT_ALIGN:
1061 return valueForTextAlign(style->textAlign());
1062 case CSS_PROP_TEXT_DECORATION:
1065 if (style->textDecoration() & UNDERLINE)
1066 string += "underline";
1067 if (style->textDecoration() & OVERLINE) {
1068 if (string.length() > 0)
1070 string += "overline";
1072 if (style->textDecoration() & LINE_THROUGH) {
1073 if (string.length() > 0)
1075 string += "line-through";
1077 if (style->textDecoration() & BLINK) {
1078 if (string.length() > 0)
1082 if (string.length() == 0)
1083 return new CSSPrimitiveValue(CSS_VAL_NONE);
1084 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
1086 case CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT:
1089 if (style->textDecorationsInEffect() & UNDERLINE)
1090 string += "underline";
1091 if (style->textDecorationsInEffect() & OVERLINE) {
1092 if (string.length() > 0)
1094 string += "overline";
1096 if (style->textDecorationsInEffect() & LINE_THROUGH) {
1097 if (string.length() > 0)
1099 string += "line-through";
1101 if (style->textDecorationsInEffect() & BLINK) {
1102 if (string.length() > 0)
1106 if (string.length() == 0)
1107 return new CSSPrimitiveValue(CSS_VAL_NONE);
1108 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
1110 case CSS_PROP_TEXT_INDENT:
1111 return valueForLength(style->textIndent());
1112 case CSS_PROP_TEXT_SHADOW:
1113 return valueForShadow(style->textShadow());
1114 case CSS_PROP__WEBKIT_TEXT_SECURITY:
1116 switch (style->textSecurity()) {
1118 return new CSSPrimitiveValue(CSS_VAL_NONE);
1120 return new CSSPrimitiveValue(CSS_VAL_DISC);
1122 return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
1124 return new CSSPrimitiveValue(CSS_VAL_SQUARE);
1126 ASSERT_NOT_REACHED();
1129 case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
1130 if (style->textSizeAdjust())
1131 return new CSSPrimitiveValue(CSS_VAL_AUTO);
1133 return new CSSPrimitiveValue(CSS_VAL_NONE);
1134 case CSS_PROP_TEXT_TRANSFORM:
1135 switch (style->textTransform()) {
1137 return new CSSPrimitiveValue(CSS_VAL_CAPITALIZE);
1139 return new CSSPrimitiveValue(CSS_VAL_UPPERCASE);
1141 return new CSSPrimitiveValue(CSS_VAL_LOWERCASE);
1143 return new CSSPrimitiveValue(CSS_VAL_NONE);
1145 ASSERT_NOT_REACHED();
1148 return getPositionOffsetValue(renderer, CSS_PROP_TOP);
1149 case CSS_PROP_UNICODE_BIDI:
1150 switch (style->unicodeBidi()) {
1152 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1154 return new CSSPrimitiveValue(CSS_VAL_EMBED);
1156 return new CSSPrimitiveValue(CSS_VAL_BIDI_OVERRIDE);
1158 ASSERT_NOT_REACHED();
1160 case CSS_PROP_VERTICAL_ALIGN:
1161 switch (style->verticalAlign()) {
1163 return new CSSPrimitiveValue(CSS_VAL_BASELINE);
1165 return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
1167 return new CSSPrimitiveValue(CSS_VAL_SUB);
1169 return new CSSPrimitiveValue(CSS_VAL_SUPER);
1171 return new CSSPrimitiveValue(CSS_VAL_TEXT_TOP);
1173 return new CSSPrimitiveValue(CSS_VAL_TEXT_BOTTOM);
1175 return new CSSPrimitiveValue(CSS_VAL_TOP);
1177 return new CSSPrimitiveValue(CSS_VAL_BOTTOM);
1178 case BASELINE_MIDDLE:
1179 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BASELINE_MIDDLE);
1181 return valueForLength(style->verticalAlignLength());
1183 ASSERT_NOT_REACHED();
1185 case CSS_PROP_VISIBILITY:
1186 switch (style->visibility()) {
1188 return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
1190 return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
1192 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
1194 ASSERT_NOT_REACHED();
1196 case CSS_PROP_WHITE_SPACE:
1197 switch (style->whiteSpace()) {
1199 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1201 return new CSSPrimitiveValue(CSS_VAL_PRE);
1203 return new CSSPrimitiveValue(CSS_VAL_PRE_WRAP);
1205 return new CSSPrimitiveValue(CSS_VAL_PRE_LINE);
1207 return new CSSPrimitiveValue(CSS_VAL_NOWRAP);
1209 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_NOWRAP);
1211 ASSERT_NOT_REACHED();
1213 case CSS_PROP_WIDOWS:
1214 return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
1215 case CSS_PROP_WIDTH:
1216 return new CSSPrimitiveValue(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX);
1217 case CSS_PROP_WORD_SPACING:
1218 return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
1219 case CSS_PROP_WORD_WRAP:
1220 switch (style->wordWrap()) {
1222 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1224 return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD);
1226 ASSERT_NOT_REACHED();
1228 case CSS_PROP__WEBKIT_LINE_BREAK:
1229 switch (style->khtmlLineBreak()) {
1231 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1232 case AFTER_WHITE_SPACE:
1233 return new CSSPrimitiveValue(CSS_VAL_AFTER_WHITE_SPACE);
1235 ASSERT_NOT_REACHED();
1237 case CSS_PROP__WEBKIT_NBSP_MODE:
1238 switch (style->nbspMode()) {
1240 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1242 return new CSSPrimitiveValue(CSS_VAL_SPACE);
1244 ASSERT_NOT_REACHED();
1246 case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
1247 switch (style->matchNearestMailBlockquoteColor()) {
1249 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1251 return new CSSPrimitiveValue(CSS_VAL_MATCH);
1253 ASSERT_NOT_REACHED();
1255 case CSS_PROP_RESIZE:
1256 switch (style->resize()) {
1258 return new CSSPrimitiveValue(CSS_VAL_BOTH);
1259 case RESIZE_HORIZONTAL:
1260 return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
1261 case RESIZE_VERTICAL:
1262 return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
1265 return new CSSPrimitiveValue(CSS_VAL_NONE);
1267 case CSS_PROP_Z_INDEX:
1268 if (style->hasAutoZIndex())
1269 return new CSSPrimitiveValue(CSS_VAL_NORMAL);
1270 return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
1271 case CSS_PROP_BACKGROUND:
1272 // FIXME: unimplemented
1274 case CSS_PROP_BORDER:
1275 // FIXME: unimplemented
1277 case CSS_PROP_BORDER_COLOR:
1278 // FIXME: unimplemented
1280 case CSS_PROP_BORDER_STYLE:
1281 // FIXME: unimplemented
1283 case CSS_PROP_BORDER_TOP:
1284 // FIXME: unimplemented
1286 case CSS_PROP_BORDER_RIGHT:
1287 // FIXME: unimplemented
1289 case CSS_PROP_BORDER_BOTTOM:
1290 // FIXME: unimplemented
1292 case CSS_PROP_BORDER_LEFT:
1293 // FIXME: unimplemented
1295 case CSS_PROP_BORDER_WIDTH:
1296 // FIXME: unimplemented
1299 // FIXME: unimplemented
1301 case CSS_PROP_LIST_STYLE:
1302 // FIXME: unimplemented
1304 case CSS_PROP_MARGIN:
1305 // FIXME: unimplemented
1307 case CSS_PROP_OUTLINE:
1308 // FIXME: unimplemented
1310 case CSS_PROP_PADDING:
1311 // FIXME: unimplemented
1314 case CSS_PROP__WEBKIT_DASHBOARD_REGION: {
1315 DeprecatedValueList<StyleDashboardRegion> regions = style->dashboardRegions();
1316 unsigned count = regions.count();
1317 if (count == 1 && regions[0].type == StyleDashboardRegion::None)
1318 return new CSSPrimitiveValue(CSS_VAL_NONE);
1320 RefPtr<DashboardRegion> firstRegion;
1321 DashboardRegion* previousRegion = 0;
1322 for (unsigned i = 0; i < count; i++) {
1323 RefPtr<DashboardRegion> region = new DashboardRegion;
1324 StyleDashboardRegion styleRegion = regions[i];
1326 region->m_label = styleRegion.label;
1327 LengthBox offset = styleRegion.offset;
1328 region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX));
1329 region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX));
1330 region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX));
1331 region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX));
1332 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
1333 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
1336 previousRegion->m_next = region;
1338 firstRegion = region;
1339 previousRegion = region.get();
1341 return new CSSPrimitiveValue(firstRegion.release());
1346 LOG_ERROR("unimplemented propertyID: %d", propertyID);
1350 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const
1352 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
1354 return value->cssText();
1358 bool CSSComputedStyleDeclaration::getPropertyPriority(int) const
1360 // All computed styles have a priority of false (not "important").
1364 String CSSComputedStyleDeclaration::removeProperty(int, ExceptionCode& ec)
1366 ec = NO_MODIFICATION_ALLOWED_ERR;
1370 void CSSComputedStyleDeclaration::setProperty(int, const String&, bool, ExceptionCode& ec)
1372 ec = NO_MODIFICATION_ALLOWED_ERR;
1375 unsigned CSSComputedStyleDeclaration::length() const
1377 Node* node = m_node.get();
1380 RenderObject* renderer = node->renderer();
1383 RenderStyle* style = renderer->style();
1386 return numComputedProperties;
1389 String CSSComputedStyleDeclaration::item(unsigned i) const
1394 return getPropertyName(computedProperties[i]);
1397 // This is the list of properties we want to copy in the copyInheritableProperties() function.
1398 // It is the intersection of the list of inherited CSS properties and the
1399 // properties for which we have a computed implementation in this file.
1400 const int inheritableProperties[] = {
1401 CSS_PROP_BORDER_COLLAPSE,
1402 CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING,
1403 CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING,
1405 CSS_PROP_FONT_FAMILY,
1407 CSS_PROP_FONT_STYLE,
1408 CSS_PROP_FONT_VARIANT,
1409 CSS_PROP_FONT_WEIGHT,
1410 CSS_PROP_LETTER_SPACING,
1411 CSS_PROP_LINE_HEIGHT,
1412 CSS_PROP_TEXT_ALIGN,
1413 CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
1414 CSS_PROP_TEXT_INDENT,
1415 CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST,
1416 CSS_PROP_TEXT_TRANSFORM,
1418 CSS_PROP_WHITE_SPACE,
1420 CSS_PROP_WORD_SPACING,
1423 const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
1425 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const
1427 return copyPropertiesInSet(inheritableProperties, numInheritableProperties);
1430 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const
1432 return copyPropertiesInSet(computedProperties, numComputedProperties);
1435 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable()
1440 } // namespace WebCore