2 * css_computedstyle.cpp
4 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
5 * Copyright (C) 2004 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
22 #include "css_computedstyle.h"
24 #include "cssproperties.h"
25 #include "cssvalues.h"
26 #include "dom_atomicstring.h"
27 #include "dom_string.h"
29 #include "khtmllayout.h"
31 #include "rendering/render_style.h"
32 #include "rendering/render_object.h"
35 #import "KWQAssertions.h"
36 #import "KWQFontFamily.h"
37 #import "KWQLogging.h"
40 using khtml::EBorderStyle;
41 using khtml::ETextAlign;
45 using khtml::LengthBox;
46 using khtml::RenderStyle;
47 using khtml::ShadowData;
48 using khtml::StyleDashboardRegion;
52 // This is the list of properties we want to copy in the copyInheritableProperties() function.
53 // It is the intersection of the list of inherited CSS properties and the
54 // properties for which we have a computed implementation in this file.
55 static const int InheritableProperties[] = {
56 CSS_PROP_BORDER_COLLAPSE,
57 CSS_PROP_BORDER_SPACING,
62 CSS_PROP_FONT_VARIANT,
64 CSS_PROP_LETTER_SPACING,
67 CSS_PROP_TEXT_DECORATION, // this is not inheritable, yet we do want to consider it for typing style (name change needed? redesign?)
69 CSS_PROP_TEXT_TRANSFORM,
71 CSS_PROP_WORD_SPACING,
74 static CSSValueImpl* valueForLength(const Length &length)
76 switch (length.type) {
78 return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PERCENTAGE);
80 return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX);
81 default: // FIXME: Intrinsic and MinIntrinsic should probably return keywords.
82 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
86 static CSSValueImpl *valueForBorderStyle(EBorderStyle style)
90 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
92 return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
94 return new CSSPrimitiveValueImpl(CSS_VAL_INSET);
96 return new CSSPrimitiveValueImpl(CSS_VAL_GROOVE);
98 return new CSSPrimitiveValueImpl(CSS_VAL_RIDGE);
100 return new CSSPrimitiveValueImpl(CSS_VAL_OUTSET);
102 return new CSSPrimitiveValueImpl(CSS_VAL_DOTTED);
104 return new CSSPrimitiveValueImpl(CSS_VAL_DASHED);
106 return new CSSPrimitiveValueImpl(CSS_VAL_SOLID);
108 return new CSSPrimitiveValueImpl(CSS_VAL_DOUBLE);
110 ASSERT_NOT_REACHED();
114 static CSSValueImpl *valueForTextAlign(ETextAlign align)
118 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
120 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
122 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
124 return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
126 return new CSSPrimitiveValueImpl(CSS_VAL_JUSTIFY);
127 case khtml::KHTML_LEFT:
128 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_LEFT);
129 case khtml::KHTML_RIGHT:
130 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_RIGHT);
131 case khtml::KHTML_CENTER:
132 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_CENTER);
134 ASSERT_NOT_REACHED();
138 static CSSValueImpl* valueForShadow(const ShadowData *shadow)
141 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
142 CSSValueListImpl *list = new CSSValueListImpl;
143 for (const ShadowData *s = shadow; s; s = s->next) {
144 CSSPrimitiveValueImpl *x = new CSSPrimitiveValueImpl(s->x, CSSPrimitiveValue::CSS_PX);
145 CSSPrimitiveValueImpl *y = new CSSPrimitiveValueImpl(s->y, CSSPrimitiveValue::CSS_PX);
146 CSSPrimitiveValueImpl *blur = new CSSPrimitiveValueImpl(s->blur, CSSPrimitiveValue::CSS_PX);
147 CSSPrimitiveValueImpl *color = new CSSPrimitiveValueImpl(s->color.rgb());
148 list->append(new ShadowValueImpl(x, y, blur, color));
153 CSSValueImpl* CSSComputedStyleDeclarationImpl::getPositionOffsetValue(int propertyID) const
156 switch (propertyID) {
158 l = m_renderer->style()->left();
161 l = m_renderer->style()->right();
164 l = m_renderer->style()->top();
166 case CSS_PROP_BOTTOM:
167 l = m_renderer->style()->bottom();
173 if (m_renderer->isPositioned())
174 return valueForLength(l);
176 if (m_renderer->isRelPositioned())
177 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
178 // In other words if left is auto and right is not auto, then left's computed value is negative right.
179 // So we should get the opposite length unit and see if it is auto.
180 return valueForLength(l);
182 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
185 CSSComputedStyleDeclarationImpl::CSSComputedStyleDeclarationImpl(NodeImpl *n)
186 : CSSStyleDeclarationImpl(0)
189 m_renderer = node()->renderer();
192 CSSComputedStyleDeclarationImpl::~CSSComputedStyleDeclarationImpl()
196 DOMString CSSComputedStyleDeclarationImpl::cssText() const
198 ERROR("unimplemented");
202 void CSSComputedStyleDeclarationImpl::setCssText(const DOMString &)
204 ERROR("CSSComputedStyleDeclarationImpl is a read-only object");
207 // Display integers in integer format instead of "1.0".
208 static QString numberAsString(double n)
210 long i = static_cast<long>(n);
211 return i == n ? QString::number(i) : QString::number(n);
214 CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID) const
216 return getPropertyCSSValue(propertyID, UpdateLayout);
219 CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID, bool updateLayout) const
221 // Make sure our layout is up to date before we allow a query on these attributes.
222 DocumentImpl* docimpl = node()->getDocument();
223 if (docimpl && updateLayout)
224 docimpl->updateLayout();
228 RenderStyle *style = m_renderer->style();
234 case CSS_PROP_BACKGROUND_COLOR:
235 return new CSSPrimitiveValueImpl(style->backgroundColor().rgb());
236 case CSS_PROP_BACKGROUND_IMAGE:
237 if (style->backgroundImage())
238 return new CSSPrimitiveValueImpl(style->backgroundImage()->url(),
239 CSSPrimitiveValue::CSS_URI);
241 case CSS_PROP_BACKGROUND_REPEAT:
242 switch (style->backgroundRepeat()) {
244 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT);
245 case khtml::REPEAT_X:
246 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_X);
247 case khtml::REPEAT_Y:
248 return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_Y);
249 case khtml::NO_REPEAT:
250 return new CSSPrimitiveValueImpl(CSS_VAL_NO_REPEAT);
252 ASSERT_NOT_REACHED();
254 case CSS_PROP_BACKGROUND_ATTACHMENT:
255 if (style->backgroundAttachment())
256 return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
258 return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
259 case CSS_PROP_BACKGROUND_POSITION:
262 Length length(style->backgroundXPosition());
263 if (length.isPercent())
264 string = numberAsString(length.length()) + "%";
266 string = numberAsString(length.minWidth(m_renderer->contentWidth()));
268 length = style->backgroundYPosition();
269 if (length.isPercent())
270 string += numberAsString(length.length()) + "%";
272 string += numberAsString(length.minWidth(m_renderer->contentWidth()));
273 return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
275 case CSS_PROP_BACKGROUND_POSITION_X:
276 return valueForLength(style->backgroundXPosition());
277 case CSS_PROP_BACKGROUND_POSITION_Y:
278 return valueForLength(style->backgroundYPosition());
280 case CSS_PROP__KHTML_BINDING:
281 // FIXME: unimplemented
284 case CSS_PROP_BORDER_COLLAPSE:
285 if (style->borderCollapse())
286 return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
288 return new CSSPrimitiveValueImpl(CSS_VAL_SEPARATE);
289 case CSS_PROP_BORDER_SPACING:
291 QString string(numberAsString(style->horizontalBorderSpacing()) +
293 numberAsString(style->verticalBorderSpacing()) +
295 return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
297 case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING:
298 return new CSSPrimitiveValueImpl(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
299 case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING:
300 return new CSSPrimitiveValueImpl(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
301 case CSS_PROP_BORDER_TOP_COLOR:
302 return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
303 case CSS_PROP_BORDER_RIGHT_COLOR:
304 return new CSSPrimitiveValueImpl(style->borderRightColor().rgb());
305 case CSS_PROP_BORDER_BOTTOM_COLOR:
306 return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb());
307 case CSS_PROP_BORDER_LEFT_COLOR:
308 return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
309 case CSS_PROP_BORDER_TOP_STYLE:
310 return valueForBorderStyle(style->borderTopStyle());
311 case CSS_PROP_BORDER_RIGHT_STYLE:
312 return valueForBorderStyle(style->borderRightStyle());
313 case CSS_PROP_BORDER_BOTTOM_STYLE:
314 return valueForBorderStyle(style->borderBottomStyle());
315 case CSS_PROP_BORDER_LEFT_STYLE:
316 return valueForBorderStyle(style->borderLeftStyle());
317 case CSS_PROP_BORDER_TOP_WIDTH:
318 return new CSSPrimitiveValueImpl(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
319 case CSS_PROP_BORDER_RIGHT_WIDTH:
320 return new CSSPrimitiveValueImpl(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
321 case CSS_PROP_BORDER_BOTTOM_WIDTH:
322 return new CSSPrimitiveValueImpl(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
323 case CSS_PROP_BORDER_LEFT_WIDTH:
324 return new CSSPrimitiveValueImpl(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
325 case CSS_PROP_BOTTOM:
326 return getPositionOffsetValue(CSS_PROP_BOTTOM);
327 case CSS_PROP__KHTML_BOX_ALIGN:
328 // FIXME: unimplemented
330 case CSS_PROP__KHTML_BOX_DIRECTION:
331 // FIXME: unimplemented
333 case CSS_PROP__KHTML_BOX_FLEX:
334 // FIXME: unimplemented
336 case CSS_PROP__KHTML_BOX_FLEX_GROUP:
337 // FIXME: unimplemented
339 case CSS_PROP__KHTML_BOX_LINES:
340 // FIXME: unimplemented
342 case CSS_PROP__KHTML_BOX_ORDINAL_GROUP:
343 // FIXME: unimplemented
345 case CSS_PROP__KHTML_BOX_ORIENT:
346 // FIXME: unimplemented
348 case CSS_PROP__KHTML_BOX_PACK:
349 // FIXME: unimplemented
351 case CSS_PROP_CAPTION_SIDE:
352 // FIXME: unimplemented
355 // FIXME: unimplemented
358 // FIXME: unimplemented
361 return new CSSPrimitiveValueImpl(style->color().rgb());
362 case CSS_PROP_CONTENT:
363 // FIXME: unimplemented
365 case CSS_PROP_COUNTER_INCREMENT:
366 // FIXME: unimplemented
368 case CSS_PROP_COUNTER_RESET:
369 // FIXME: unimplemented
371 case CSS_PROP_CURSOR:
372 // FIXME: unimplemented
374 case CSS_PROP_DIRECTION:
375 // FIXME: unimplemented
377 case CSS_PROP_DISPLAY:
378 switch (style->display()) {
380 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE);
382 return new CSSPrimitiveValueImpl(CSS_VAL_BLOCK);
383 case khtml::LIST_ITEM:
384 return new CSSPrimitiveValueImpl(CSS_VAL_LIST_ITEM);
386 return new CSSPrimitiveValueImpl(CSS_VAL_RUN_IN);
388 return new CSSPrimitiveValueImpl(CSS_VAL_COMPACT);
389 case khtml::INLINE_BLOCK:
390 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_BLOCK);
392 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE);
393 case khtml::INLINE_TABLE:
394 return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_TABLE);
395 case khtml::TABLE_ROW_GROUP:
396 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW_GROUP);
397 case khtml::TABLE_HEADER_GROUP:
398 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_HEADER_GROUP);
399 case khtml::TABLE_FOOTER_GROUP:
400 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_FOOTER_GROUP);
401 case khtml::TABLE_ROW:
402 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW);
403 case khtml::TABLE_COLUMN_GROUP:
404 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN_GROUP);
405 case khtml::TABLE_COLUMN:
406 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN);
407 case khtml::TABLE_CELL:
408 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CELL);
409 case khtml::TABLE_CAPTION:
410 return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CAPTION);
412 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BOX);
413 case khtml::INLINE_BOX:
414 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_INLINE_BOX);
416 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
418 ASSERT_NOT_REACHED();
420 case CSS_PROP_EMPTY_CELLS:
421 switch (style->emptyCells()) {
423 return new CSSPrimitiveValueImpl(CSS_VAL_SHOW);
425 return new CSSPrimitiveValueImpl(CSS_VAL_HIDE);
427 ASSERT_NOT_REACHED();
430 switch (style->floating()) {
432 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
434 return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
436 return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
438 ASSERT_NOT_REACHED();
440 case CSS_PROP_FONT_FAMILY:
442 FontDef def = style->htmlFont().getFontDef();
443 return new CSSPrimitiveValueImpl(def.firstFamily().family().domString(), CSSPrimitiveValue::CSS_STRING);
445 case CSS_PROP_FONT_SIZE:
447 FontDef def = style->htmlFont().getFontDef();
448 return new CSSPrimitiveValueImpl(def.specifiedSize, CSSPrimitiveValue::CSS_PX);
450 case CSS_PROP_FONT_SIZE_ADJUST:
451 // FIXME: unimplemented
453 case CSS_PROP_FONT_STRETCH:
454 // FIXME: unimplemented
456 case CSS_PROP_FONT_STYLE:
458 // FIXME: handle oblique?
459 FontDef def = style->htmlFont().getFontDef();
461 return new CSSPrimitiveValueImpl(CSS_VAL_ITALIC);
463 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
465 case CSS_PROP_FONT_VARIANT:
467 FontDef def = style->htmlFont().getFontDef();
469 return new CSSPrimitiveValueImpl(CSS_VAL_SMALL_CAPS);
471 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
473 case CSS_PROP_FONT_WEIGHT:
475 // FIXME: this does not reflect the full range of weights
476 // that can be expressed with CSS
477 FontDef def = style->htmlFont().getFontDef();
478 if (def.weight == QFont::Bold)
479 return new CSSPrimitiveValueImpl(CSS_VAL_BOLD);
481 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
483 case CSS_PROP_HEIGHT:
484 return new CSSPrimitiveValueImpl(m_renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);
486 return getPositionOffsetValue(CSS_PROP_LEFT);
487 case CSS_PROP_LETTER_SPACING:
488 if (style->letterSpacing() == 0)
489 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
490 return new CSSPrimitiveValueImpl(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
491 case CSS_PROP_LINE_HEIGHT: {
492 Length length(style->lineHeight());
493 if (length.isPercent()) {
494 float computedSize = style->htmlFont().getFontDef().computedSize;
495 return new CSSPrimitiveValueImpl((int)(length.length() * computedSize) / 100, CSSPrimitiveValue::CSS_PX);
498 return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX);
501 case CSS_PROP_LIST_STYLE_IMAGE:
502 // FIXME: unimplemented
504 case CSS_PROP_LIST_STYLE_POSITION:
505 // FIXME: unimplemented
507 case CSS_PROP_LIST_STYLE_TYPE:
508 // FIXME: unimplemented
510 case CSS_PROP_MARGIN_TOP:
511 return valueForLength(style->marginTop());
512 case CSS_PROP_MARGIN_RIGHT:
513 return valueForLength(style->marginRight());
514 case CSS_PROP_MARGIN_BOTTOM:
515 return valueForLength(style->marginBottom());
516 case CSS_PROP_MARGIN_LEFT:
517 return valueForLength(style->marginLeft());
518 case CSS_PROP__KHTML_MARQUEE:
519 // FIXME: unimplemented
521 case CSS_PROP__KHTML_MARQUEE_DIRECTION:
522 // FIXME: unimplemented
524 case CSS_PROP__KHTML_MARQUEE_INCREMENT:
525 return valueForLength(style->marqueeIncrement());
526 case CSS_PROP__KHTML_MARQUEE_REPETITION:
527 // FIXME: unimplemented
529 case CSS_PROP__KHTML_MARQUEE_SPEED:
530 // FIXME: unimplemented
532 case CSS_PROP__KHTML_MARQUEE_STYLE:
533 // FIXME: unimplemented
535 case CSS_PROP__KHTML_USER_MODIFY:
536 // FIXME: unimplemented
538 case CSS_PROP_MAX_HEIGHT:
539 return valueForLength(style->maxHeight());
540 case CSS_PROP_MAX_WIDTH:
541 return valueForLength(style->maxWidth());
542 case CSS_PROP_MIN_HEIGHT:
543 return valueForLength(style->minHeight());
544 case CSS_PROP_MIN_WIDTH:
545 return valueForLength(style->minWidth());
546 case CSS_PROP_OPACITY:
547 // FIXME: unimplemented
549 case CSS_PROP_ORPHANS:
550 // FIXME: unimplemented
552 // FIXME: unimplemented
554 case CSS_PROP_OUTLINE_COLOR:
555 // FIXME: unimplemented
557 case CSS_PROP_OUTLINE_OFFSET:
558 // FIXME: unimplemented
560 case CSS_PROP_OUTLINE_STYLE:
561 // FIXME: unimplemented
563 case CSS_PROP_OUTLINE_WIDTH:
564 // FIXME: unimplemented
566 case CSS_PROP_OVERFLOW:
567 switch (style->overflow()) {
568 case khtml::OVISIBLE:
569 return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
571 return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
573 return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
575 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
576 case khtml::OMARQUEE:
577 return new CSSPrimitiveValueImpl(CSS_VAL_MARQUEE);
578 case khtml::OOVERLAY:
579 return new CSSPrimitiveValueImpl(CSS_VAL_OVERLAY);
581 ASSERT_NOT_REACHED();
583 case CSS_PROP_PADDING_TOP:
584 return valueForLength(style->paddingTop());
585 case CSS_PROP_PADDING_RIGHT:
586 return valueForLength(style->paddingRight());
587 case CSS_PROP_PADDING_BOTTOM:
588 return valueForLength(style->paddingBottom());
589 case CSS_PROP_PADDING_LEFT:
590 return valueForLength(style->paddingLeft());
592 // FIXME: unimplemented
594 case CSS_PROP_PAGE_BREAK_AFTER:
595 // FIXME: unimplemented
597 case CSS_PROP_PAGE_BREAK_BEFORE:
598 // FIXME: unimplemented
600 case CSS_PROP_PAGE_BREAK_INSIDE:
601 // FIXME: unimplemented
603 case CSS_PROP_POSITION:
604 // FIXME: unimplemented
606 case CSS_PROP_QUOTES:
607 // FIXME: unimplemented
610 return getPositionOffsetValue(CSS_PROP_RIGHT);
612 // FIXME: unimplemented
614 case CSS_PROP_TABLE_LAYOUT:
615 switch (style->tableLayout()) {
617 return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
619 return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
621 ASSERT_NOT_REACHED();
623 case CSS_PROP_TEXT_ALIGN:
624 return valueForTextAlign(style->textAlign());
625 case CSS_PROP_TEXT_DECORATION:
628 if (style->textDecoration() & khtml::UNDERLINE)
629 string += "underline";
630 if (style->textDecoration() & khtml::OVERLINE) {
631 if (string.length() > 0)
633 string += "overline";
635 if (style->textDecoration() & khtml::LINE_THROUGH) {
636 if (string.length() > 0)
638 string += "line-through";
640 if (style->textDecoration() & khtml::BLINK) {
641 if (string.length() > 0)
645 if (string.length() == 0)
646 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
647 return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
649 case CSS_PROP_TEXT_INDENT:
650 return valueForLength(style->textIndent());
651 case CSS_PROP_TEXT_SHADOW:
652 return valueForShadow(style->textShadow());
653 case CSS_PROP_TEXT_TRANSFORM:
654 switch (style->textTransform()) {
655 case khtml::CAPITALIZE:
656 return new CSSPrimitiveValueImpl(CSS_VAL_CAPITALIZE);
657 case khtml::UPPERCASE:
658 return new CSSPrimitiveValueImpl(CSS_VAL_UPPERCASE);
659 case khtml::LOWERCASE:
660 return new CSSPrimitiveValueImpl(CSS_VAL_LOWERCASE);
662 return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
664 ASSERT_NOT_REACHED();
667 return getPositionOffsetValue(CSS_PROP_TOP);
668 case CSS_PROP_UNICODE_BIDI:
669 // FIXME: unimplemented
671 case CSS_PROP_VERTICAL_ALIGN:
672 switch (style->verticalAlign()) {
673 case khtml::BASELINE:
674 return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE);
676 return new CSSPrimitiveValueImpl(CSS_VAL_MIDDLE);
678 return new CSSPrimitiveValueImpl(CSS_VAL_SUB);
680 return new CSSPrimitiveValueImpl(CSS_VAL_SUPER);
681 case khtml::TEXT_TOP:
682 return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_TOP);
683 case khtml::TEXT_BOTTOM:
684 return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_BOTTOM);
686 return new CSSPrimitiveValueImpl(CSS_VAL_TOP);
688 return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM);
689 case khtml::BASELINE_MIDDLE:
690 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BASELINE_MIDDLE);
692 return valueForLength(style->verticalAlignLength());
694 ASSERT_NOT_REACHED();
696 case CSS_PROP_VISIBILITY:
697 switch (style->visibility()) {
699 return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
701 return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
702 case khtml::COLLAPSE:
703 return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
705 ASSERT_NOT_REACHED();
707 case CSS_PROP_WHITE_SPACE:
708 switch (style->whiteSpace()) {
710 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
712 return new CSSPrimitiveValueImpl(CSS_VAL_PRE);
714 return new CSSPrimitiveValueImpl(CSS_VAL_NOWRAP);
715 case khtml::KHTML_NOWRAP:
716 return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_NOWRAP);
718 ASSERT_NOT_REACHED();
720 case CSS_PROP_WIDOWS:
721 // FIXME: unimplemented
724 return new CSSPrimitiveValueImpl(m_renderer->contentWidth(), CSSPrimitiveValue::CSS_PX);
725 case CSS_PROP_WORD_SPACING:
726 return new CSSPrimitiveValueImpl(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
727 case CSS_PROP_WORD_WRAP:
728 switch (style->wordWrap()) {
729 case khtml::WBNORMAL:
730 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
731 case khtml::BREAK_WORD:
732 return new CSSPrimitiveValueImpl(CSS_VAL_BREAK_WORD);
734 ASSERT_NOT_REACHED();
736 case CSS_PROP__KHTML_LINE_BREAK:
737 switch (style->khtmlLineBreak()) {
738 case khtml::LBNORMAL:
739 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
740 case khtml::AFTER_WHITE_SPACE:
741 return new CSSPrimitiveValueImpl(CSS_VAL_AFTER_WHITE_SPACE);
743 ASSERT_NOT_REACHED();
745 case CSS_PROP__KHTML_NBSP_MODE:
746 switch (style->nbspMode()) {
747 case khtml::NBNORMAL:
748 return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
750 return new CSSPrimitiveValueImpl(CSS_VAL_SPACE);
752 ASSERT_NOT_REACHED();
754 case CSS_PROP_Z_INDEX:
755 // FIXME: unimplemented
757 case CSS_PROP_BACKGROUND:
758 // FIXME: unimplemented
760 case CSS_PROP_BORDER:
761 // FIXME: unimplemented
763 case CSS_PROP_BORDER_COLOR:
764 // FIXME: unimplemented
766 case CSS_PROP_BORDER_STYLE:
767 // FIXME: unimplemented
769 case CSS_PROP_BORDER_TOP:
770 // FIXME: unimplemented
772 case CSS_PROP_BORDER_RIGHT:
773 // FIXME: unimplemented
775 case CSS_PROP_BORDER_BOTTOM:
776 // FIXME: unimplemented
778 case CSS_PROP_BORDER_LEFT:
779 // FIXME: unimplemented
781 case CSS_PROP_BORDER_WIDTH:
782 // FIXME: unimplemented
785 // FIXME: unimplemented
787 case CSS_PROP_LIST_STYLE:
788 // FIXME: unimplemented
790 case CSS_PROP_MARGIN:
791 // FIXME: unimplemented
793 case CSS_PROP_OUTLINE:
794 // FIXME: unimplemented
796 case CSS_PROP_PADDING:
797 // FIXME: unimplemented
800 case CSS_PROP_SCROLLBAR_FACE_COLOR:
801 // FIXME: unimplemented
803 case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
804 // FIXME: unimplemented
806 case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
807 // FIXME: unimplemented
809 case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
810 // FIXME: unimplemented
812 case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
813 // FIXME: unimplemented
815 case CSS_PROP_SCROLLBAR_TRACK_COLOR:
816 // FIXME: unimplemented
818 case CSS_PROP_SCROLLBAR_ARROW_COLOR:
819 // FIXME: unimplemented
822 case CSS_PROP__KHTML_FLOW_MODE:
823 // FIXME: unimplemented
826 case CSS_PROP__APPLE_DASHBOARD_REGION: {
827 QValueList<StyleDashboardRegion> regions = style->dashboardRegions();
828 uint i, count = regions.count();
829 DashboardRegionImpl *firstRegion = new DashboardRegionImpl(), *region;
830 region = firstRegion;
832 if (count == 1 && regions[0].type == StyleDashboardRegion::None)
833 return new CSSPrimitiveValueImpl (CSS_VAL_NONE);
835 for (i = 0; i < count; i++) {
836 StyleDashboardRegion styleRegion = regions[i];
837 region->m_label = styleRegion.label;
838 LengthBox offset = styleRegion.offset;
839 region->setTop (new CSSPrimitiveValueImpl(offset.top.value, CSSPrimitiveValue::CSS_PX));
840 region->setRight (new CSSPrimitiveValueImpl(offset.right.value, CSSPrimitiveValue::CSS_PX));
841 region->setBottom (new CSSPrimitiveValueImpl(offset.bottom.value, CSSPrimitiveValue::CSS_PX));
842 region->setLeft (new CSSPrimitiveValueImpl(offset.left.value, CSSPrimitiveValue::CSS_PX));
843 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
844 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
846 DashboardRegionImpl *newRegion = new DashboardRegionImpl();
847 region->setNext (newRegion);
851 return new CSSPrimitiveValueImpl(firstRegion);
856 ERROR("unimplemented propertyID: %d", propertyID);
860 DOMString CSSComputedStyleDeclarationImpl::getPropertyValue(int propertyID) const
862 CSSValueImpl* value = getPropertyCSSValue(propertyID);
864 return value->cssText();
868 bool CSSComputedStyleDeclarationImpl::getPropertyPriority(int) const
870 // This class does not support the notion of priority, since the object
871 // is a computed value.
875 DOMString CSSComputedStyleDeclarationImpl::removeProperty(int)
877 ASSERT_NOT_REACHED();
881 bool CSSComputedStyleDeclarationImpl::setProperty(int, const DOMString &, bool)
883 ASSERT_NOT_REACHED();
887 void CSSComputedStyleDeclarationImpl::setProperty(int, int, bool)
889 ASSERT_NOT_REACHED();
892 void CSSComputedStyleDeclarationImpl::setLengthProperty(int, const DOMString&, bool, bool)
894 ASSERT_NOT_REACHED();
897 void CSSComputedStyleDeclarationImpl::setProperty(const DOMString &)
899 ASSERT_NOT_REACHED();
902 DOMString CSSComputedStyleDeclarationImpl::item(unsigned long) const
904 ERROR("unimplemented");
909 CSSProperty CSSComputedStyleDeclarationImpl::property(int id) const
913 prop.m_bImportant = false;
914 prop.setValue(getPropertyCSSValue(id));
918 CSSStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copyInheritableProperties() const
920 return copyPropertiesInSet(InheritableProperties, sizeof(InheritableProperties) / sizeof(InheritableProperties[0]));