Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2007 08:39:44 +0000 (08:39 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2007 08:39:44 +0000 (08:39 +0000)
        Split most of CSSPrimitiveValue enum mapping out of CSSComputedStyleDeclaration::getPropertyCSSValue()
        and CSSStyleSelector::applyProperty() (and their SVG counterparts). This should make the code more readable.

        * WebCore.xcodeproj/project.pbxproj:
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::getPositionOffsetValue):
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/CSSPrimitiveValue.cpp:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        (WebCore::CSSPrimitiveValue::init):
        * css/CSSPrimitiveValue.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        * css/CSSPrimitiveValueMappings.h: Added.
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        (WebCore::CSSPrimitiveValue::operator EBorderStyle):
        (WebCore::CSSPrimitiveValue::operator CompositeOperator):
        (WebCore::CSSPrimitiveValue::operator EAppearance):
        (WebCore::CSSPrimitiveValue::operator EBackgroundBox):
        (WebCore::CSSPrimitiveValue::operator EBackgroundRepeat):
        (WebCore::CSSPrimitiveValue::operator EBoxAlignment):
        (WebCore::CSSPrimitiveValue::operator EBoxDirection):
        (WebCore::CSSPrimitiveValue::operator EBoxLines):
        (WebCore::CSSPrimitiveValue::operator EBoxOrient):
        (WebCore::CSSPrimitiveValue::operator ECaptionSide):
        (WebCore::CSSPrimitiveValue::operator EClear):
        (WebCore::CSSPrimitiveValue::operator ECursor):
        (WebCore::CSSPrimitiveValue::operator EDisplay):
        (WebCore::CSSPrimitiveValue::operator EEmptyCell):
        (WebCore::CSSPrimitiveValue::operator EFloat):
        (WebCore::CSSPrimitiveValue::operator EKHTMLLineBreak):
        (WebCore::CSSPrimitiveValue::operator EListStylePosition):
        (WebCore::CSSPrimitiveValue::operator EListStyleType):
        (WebCore::CSSPrimitiveValue::operator EMarginCollapse):
        (WebCore::CSSPrimitiveValue::operator EMarqueeBehavior):
        (WebCore::CSSPrimitiveValue::operator EMarqueeDirection):
        (WebCore::CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor):
        (WebCore::CSSPrimitiveValue::operator ENBSPMode):
        (WebCore::CSSPrimitiveValue::operator EOverflow):
        (WebCore::CSSPrimitiveValue::operator EPageBreak):
        (WebCore::CSSPrimitiveValue::operator EPosition):
        (WebCore::CSSPrimitiveValue::operator EResize):
        (WebCore::CSSPrimitiveValue::operator ETableLayout):
        (WebCore::CSSPrimitiveValue::operator ETextAlign):
        (WebCore::CSSPrimitiveValue::operator ETextSecurity):
        (WebCore::CSSPrimitiveValue::operator ETextTransform):
        (WebCore::CSSPrimitiveValue::operator EUnicodeBidi):
        (WebCore::CSSPrimitiveValue::operator EUserDrag):
        (WebCore::CSSPrimitiveValue::operator EUserModify):
        (WebCore::CSSPrimitiveValue::operator EUserSelect):
        (WebCore::CSSPrimitiveValue::operator EVisibility):
        (WebCore::CSSPrimitiveValue::operator EWhiteSpace):
        (WebCore::CSSPrimitiveValue::operator EWordBreak):
        (WebCore::CSSPrimitiveValue::operator EWordWrap):
        (WebCore::CSSPrimitiveValue::operator LineCap):
        (WebCore::CSSPrimitiveValue::operator LineJoin):
        (WebCore::CSSPrimitiveValue::operator TextDirection):
        (WebCore::CSSPrimitiveValue::operator WindRule):
        (WebCore::CSSPrimitiveValue::operator EAlignmentBaseline):
        (WebCore::CSSPrimitiveValue::operator EColorInterpolation):
        (WebCore::CSSPrimitiveValue::operator EColorRendering):
        (WebCore::CSSPrimitiveValue::operator EDominantBaseline):
        (WebCore::CSSPrimitiveValue::operator EImageRendering):
        (WebCore::CSSPrimitiveValue::operator EPointerEvents):
        (WebCore::CSSPrimitiveValue::operator EShapeRendering):
        (WebCore::CSSPrimitiveValue::operator ETextAnchor):
        (WebCore::CSSPrimitiveValue::operator ETextRendering):
        (WebCore::CSSPrimitiveValue::operator EWritingMode):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::checkSelector):
        (WebCore::CSSStyleSelector::checkOneSelector):
        (WebCore::CSSRuleSet::addRulesFromSheet):
        (WebCore::convertToLength):
        (WebCore::CSSStyleSelector::applyDeclarations):
        (WebCore::CSSStyleSelector::applyProperty):
        (WebCore::CSSStyleSelector::mapBackgroundAttachment):
        (WebCore::CSSStyleSelector::mapBackgroundClip):
        (WebCore::CSSStyleSelector::mapBackgroundComposite):
        (WebCore::CSSStyleSelector::mapBackgroundOrigin):
        (WebCore::CSSStyleSelector::mapBackgroundRepeat):
        (WebCore::CSSStyleSelector::mapBackgroundXPosition):
        (WebCore::CSSStyleSelector::mapBackgroundYPosition):
        * ksvg2/css/SVGCSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
        * ksvg2/css/SVGCSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applySVGProperty):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26742 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSPrimitiveValue.cpp
WebCore/css/CSSPrimitiveValue.h
WebCore/css/CSSPrimitiveValueMappings.h [new file with mode: 0644]
WebCore/css/CSSStyleSelector.cpp
WebCore/ksvg2/css/SVGCSSComputedStyleDeclaration.cpp
WebCore/ksvg2/css/SVGCSSStyleSelector.cpp

index 342b11dd98e537f59a46771e7c264e851b32b1b0..a775cfba14dddb581dc9d8763333fb260abc8cce 100644 (file)
@@ -1,3 +1,93 @@
+2007-10-18  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        Split most of CSSPrimitiveValue enum mapping out of CSSComputedStyleDeclaration::getPropertyCSSValue()
+        and CSSStyleSelector::applyProperty() (and their SVG counterparts). This should make the code more readable.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::getPositionOffsetValue):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::init):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSPrimitiveValueMappings.h: Added.
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EBorderStyle):
+        (WebCore::CSSPrimitiveValue::operator CompositeOperator):
+        (WebCore::CSSPrimitiveValue::operator EAppearance):
+        (WebCore::CSSPrimitiveValue::operator EBackgroundBox):
+        (WebCore::CSSPrimitiveValue::operator EBackgroundRepeat):
+        (WebCore::CSSPrimitiveValue::operator EBoxAlignment):
+        (WebCore::CSSPrimitiveValue::operator EBoxDirection):
+        (WebCore::CSSPrimitiveValue::operator EBoxLines):
+        (WebCore::CSSPrimitiveValue::operator EBoxOrient):
+        (WebCore::CSSPrimitiveValue::operator ECaptionSide):
+        (WebCore::CSSPrimitiveValue::operator EClear):
+        (WebCore::CSSPrimitiveValue::operator ECursor):
+        (WebCore::CSSPrimitiveValue::operator EDisplay):
+        (WebCore::CSSPrimitiveValue::operator EEmptyCell):
+        (WebCore::CSSPrimitiveValue::operator EFloat):
+        (WebCore::CSSPrimitiveValue::operator EKHTMLLineBreak):
+        (WebCore::CSSPrimitiveValue::operator EListStylePosition):
+        (WebCore::CSSPrimitiveValue::operator EListStyleType):
+        (WebCore::CSSPrimitiveValue::operator EMarginCollapse):
+        (WebCore::CSSPrimitiveValue::operator EMarqueeBehavior):
+        (WebCore::CSSPrimitiveValue::operator EMarqueeDirection):
+        (WebCore::CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor):
+        (WebCore::CSSPrimitiveValue::operator ENBSPMode):
+        (WebCore::CSSPrimitiveValue::operator EOverflow):
+        (WebCore::CSSPrimitiveValue::operator EPageBreak):
+        (WebCore::CSSPrimitiveValue::operator EPosition):
+        (WebCore::CSSPrimitiveValue::operator EResize):
+        (WebCore::CSSPrimitiveValue::operator ETableLayout):
+        (WebCore::CSSPrimitiveValue::operator ETextAlign):
+        (WebCore::CSSPrimitiveValue::operator ETextSecurity):
+        (WebCore::CSSPrimitiveValue::operator ETextTransform):
+        (WebCore::CSSPrimitiveValue::operator EUnicodeBidi):
+        (WebCore::CSSPrimitiveValue::operator EUserDrag):
+        (WebCore::CSSPrimitiveValue::operator EUserModify):
+        (WebCore::CSSPrimitiveValue::operator EUserSelect):
+        (WebCore::CSSPrimitiveValue::operator EVisibility):
+        (WebCore::CSSPrimitiveValue::operator EWhiteSpace):
+        (WebCore::CSSPrimitiveValue::operator EWordBreak):
+        (WebCore::CSSPrimitiveValue::operator EWordWrap):
+        (WebCore::CSSPrimitiveValue::operator LineCap):
+        (WebCore::CSSPrimitiveValue::operator LineJoin):
+        (WebCore::CSSPrimitiveValue::operator TextDirection):
+        (WebCore::CSSPrimitiveValue::operator WindRule):
+        (WebCore::CSSPrimitiveValue::operator EAlignmentBaseline):
+        (WebCore::CSSPrimitiveValue::operator EColorInterpolation):
+        (WebCore::CSSPrimitiveValue::operator EColorRendering):
+        (WebCore::CSSPrimitiveValue::operator EDominantBaseline):
+        (WebCore::CSSPrimitiveValue::operator EImageRendering):
+        (WebCore::CSSPrimitiveValue::operator EPointerEvents):
+        (WebCore::CSSPrimitiveValue::operator EShapeRendering):
+        (WebCore::CSSPrimitiveValue::operator ETextAnchor):
+        (WebCore::CSSPrimitiveValue::operator ETextRendering):
+        (WebCore::CSSPrimitiveValue::operator EWritingMode):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::checkSelector):
+        (WebCore::CSSStyleSelector::checkOneSelector):
+        (WebCore::CSSRuleSet::addRulesFromSheet):
+        (WebCore::convertToLength):
+        (WebCore::CSSStyleSelector::applyDeclarations):
+        (WebCore::CSSStyleSelector::applyProperty):
+        (WebCore::CSSStyleSelector::mapBackgroundAttachment):
+        (WebCore::CSSStyleSelector::mapBackgroundClip):
+        (WebCore::CSSStyleSelector::mapBackgroundComposite):
+        (WebCore::CSSStyleSelector::mapBackgroundOrigin):
+        (WebCore::CSSStyleSelector::mapBackgroundRepeat):
+        (WebCore::CSSStyleSelector::mapBackgroundXPosition):
+        (WebCore::CSSStyleSelector::mapBackgroundYPosition):
+        * ksvg2/css/SVGCSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+        * ksvg2/css/SVGCSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applySVGProperty):
+
 2007-10-18  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Maciej.
index 6d821bbdea9ad8c8caf216b29d5195c43579e096..e359c72847264f82726ca6680f6b25c74d03434b 100644 (file)
                E1EBBBD40AAC9B87001FE8E2 /* CSSCharsetRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EBBBD30AAC9B87001FE8E2 /* CSSCharsetRule.cpp */; };
                E1EC299F0BB04C6B00EA187B /* XPathNodeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EC299D0BB04C6B00EA187B /* XPathNodeSet.cpp */; };
                E1EC29A00BB04C6B00EA187B /* XPathNodeSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */; };
+               E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */; };
                E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */; };
                E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */; };
                ED048ABC0833F132006E1E67 /* textAreaResizeCorner.tiff in Resources */ = {isa = PBXBuildFile; fileRef = ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */; };
                E1EBBBD30AAC9B87001FE8E2 /* CSSCharsetRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCharsetRule.cpp; sourceTree = "<group>"; };
                E1EC299D0BB04C6B00EA187B /* XPathNodeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathNodeSet.cpp; sourceTree = "<group>"; };
                E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathNodeSet.h; sourceTree = "<group>"; };
+               E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPrimitiveValueMappings.h; sourceTree = "<group>"; };
                E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTExtensions.cpp; sourceTree = "<group>"; };
                E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; };
                ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = textAreaResizeCorner.tiff; sourceTree = "<group>"; };
                                A80E6CDB0A1989CA007FB8C5 /* CSSPrimitiveValue.cpp */,
                                A80E6CBC0A1989CA007FB8C5 /* CSSPrimitiveValue.h */,
                                9307059009E0C75800B17FE4 /* CSSPrimitiveValue.idl */,
+                               E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */,
                                A80E6CCD0A1989CA007FB8C5 /* CSSProperty.cpp */,
                                A80E6CD50A1989CA007FB8C5 /* CSSProperty.h */,
                                BCEA4789097CAAC80094C9E4 /* CSSPropertyNames.in */,
                                A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */,
                                A8A909AC0CBCD6B50029B807 /* RenderSVGTransformableContainer.h in Headers */,
                                BC9ADD230CC4032600098C4C /* CSSTransformValue.h in Headers */,
+                               E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index c012908aa7ebbc91df9fe2aa8394147da8517d48..4ae36a5388da70114f2e5673f619a39929da6fae 100644 (file)
@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,8 +25,8 @@
 
 #include "CSSMutableStyleDeclaration.h"
 #include "CSSPrimitiveValue.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertyNames.h"
-#include "CSSValueKeywords.h"
 #include "CSSValueList.h"
 #include "CachedImage.h"
 #include "DashboardRegion.h"
@@ -216,179 +217,6 @@ static const int computedProperties[] = {
 
 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]);
 
-static PassRefPtr<CSSValue> valueForLength(const Length& length)
-{
-    switch (length.type()) {
-        case Auto:
-            return new CSSPrimitiveValue(CSS_VAL_AUTO);
-        case WebCore::Fixed:
-            return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
-        case Intrinsic:
-            return new CSSPrimitiveValue(CSS_VAL_INTRINSIC);
-        case MinIntrinsic:
-            return new CSSPrimitiveValue(CSS_VAL_MIN_INTRINSIC);
-        case Percent:
-            return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
-        case Relative:
-        case Static:
-            break;
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-// Handles special value for "none".
-static PassRefPtr<CSSValue> valueForMaxLength(const Length& length)
-{
-    if (length.isFixed() && length.value() == undefinedLength)
-        return new CSSPrimitiveValue(CSS_VAL_NONE);
-    return valueForLength(length);
-}
-
-static PassRefPtr<CSSValue> valueForBorderStyle(EBorderStyle style)
-{
-    switch (style) {
-        case BNONE:
-            return new CSSPrimitiveValue(CSS_VAL_NONE);
-        case BHIDDEN:
-            return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
-        case INSET:
-            return new CSSPrimitiveValue(CSS_VAL_INSET);
-        case GROOVE:
-            return new CSSPrimitiveValue(CSS_VAL_GROOVE);
-        case RIDGE:
-            return new CSSPrimitiveValue(CSS_VAL_RIDGE);
-        case OUTSET:
-            return new CSSPrimitiveValue(CSS_VAL_OUTSET);
-        case DOTTED:
-            return new CSSPrimitiveValue(CSS_VAL_DOTTED);
-        case DASHED:
-            return new CSSPrimitiveValue(CSS_VAL_DASHED);
-        case SOLID:
-            return new CSSPrimitiveValue(CSS_VAL_SOLID);
-        case DOUBLE:
-            return new CSSPrimitiveValue(CSS_VAL_DOUBLE);
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-static PassRefPtr<CSSValue> valueForTextAlign(ETextAlign align)
-{
-    switch (align) {
-        case TAAUTO:
-            return new CSSPrimitiveValue(CSS_VAL_AUTO);
-        case LEFT:
-            return new CSSPrimitiveValue(CSS_VAL_LEFT);
-        case RIGHT:
-            return new CSSPrimitiveValue(CSS_VAL_RIGHT);
-        case CENTER:
-            return new CSSPrimitiveValue(CSS_VAL_CENTER);
-        case JUSTIFY:
-            return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
-        case WEBKIT_LEFT:
-            return new CSSPrimitiveValue(CSS_VAL__WEBKIT_LEFT);
-        case WEBKIT_RIGHT:
-            return new CSSPrimitiveValue(CSS_VAL__WEBKIT_RIGHT);
-        case WEBKIT_CENTER:
-            return new CSSPrimitiveValue(CSS_VAL__WEBKIT_CENTER);
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-static PassRefPtr<CSSValue> valueForAppearance(EAppearance appearance)
-{
-    switch (appearance) {
-        case NoAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_NONE);
-        case CheckboxAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_CHECKBOX);
-        case RadioAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_RADIO);
-        case PushButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_PUSH_BUTTON);
-        case SquareButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SQUARE_BUTTON);
-        case ButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_BUTTON);
-        case ButtonBevelAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_BUTTON_BEVEL);
-        case ListboxAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_LISTBOX);
-        case ListItemAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_LISTITEM);
-        case MenulistAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_MENULIST);
-        case MenulistButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_MENULIST_BUTTON);
-        case MenulistTextAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXT);
-        case MenulistTextFieldAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXTFIELD);
-        case ScrollbarButtonUpAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_UP);
-        case ScrollbarButtonDownAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_DOWN);
-        case ScrollbarButtonLeftAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_LEFT);
-        case ScrollbarButtonRightAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_RIGHT);
-        case ScrollbarTrackHorizontalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_HORIZONTAL);
-        case ScrollbarTrackVerticalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_VERTICAL);
-        case ScrollbarThumbHorizontalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_HORIZONTAL);
-        case ScrollbarThumbVerticalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_VERTICAL);
-        case ScrollbarGripperHorizontalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_HORIZONTAL);
-        case ScrollbarGripperVerticalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_VERTICAL);
-        case SliderHorizontalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SLIDER_HORIZONTAL);
-        case SliderVerticalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SLIDER_VERTICAL);
-        case SliderThumbHorizontalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_HORIZONTAL);
-        case SliderThumbVerticalAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_VERTICAL);
-        case CaretAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_CARET);
-        case SearchFieldAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD);
-        case SearchFieldDecorationAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_DECORATION);
-        case SearchFieldResultsDecorationAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_DECORATION);
-        case SearchFieldResultsButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_BUTTON);
-        case SearchFieldCancelButtonAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_CANCEL_BUTTON);
-        case TextFieldAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_TEXTFIELD);
-        case TextAreaAppearance:
-            return new CSSPrimitiveValue(CSS_VAL_TEXTAREA);
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-static PassRefPtr<CSSValue> valueForMarginCollapse(EMarginCollapse collapse)
-{
-    switch (collapse) {
-        case MCOLLAPSE:
-            return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
-        case MSEPARATE:
-            return new CSSPrimitiveValue(CSS_VAL_SEPARATE);
-        case MDISCARD:
-            return new CSSPrimitiveValue(CSS_VAL_DISCARD);
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
 static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow)
 {
     if (!shadow)
@@ -429,13 +257,13 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int prope
     }
 
     if (style->position() == AbsolutePosition || style->position() == FixedPosition)
-        return valueForLength(l);
+        return new CSSPrimitiveValue(l);
 
     if (style->position() == RelativePosition)
         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
         // In other words if left is auto and right is not auto, then left's computed value is negative right.
         // So we should get the opposite length unit and see if it is auto.
-        return valueForLength(l);
+        return new CSSPrimitiveValue(l);
 
     return new CSSPrimitiveValue(CSS_VAL_AUTO);
 }
@@ -493,37 +321,11 @@ void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
     ec = NO_MODIFICATION_ALLOWED_ERR;
 }
 
-// Display integers in integer format instead of "1.0".
-static String numberAsString(double n)
-{
-    long i = static_cast<long>(n);
-    return i == n ? String::number(i) : String::number(n);
-}
-
 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
 {
     return getPropertyCSSValue(propertyID, UpdateLayout);
 }
 
-PassRefPtr<CSSPrimitiveValue> primitiveValueFromLength(Length length)
-{
-    String string;
-    switch (length.type()) {
-        case Percent:
-            string = numberAsString(length.percent()) + "%";
-            break;
-        case Fixed:
-            string = numberAsString(length.calcMinValue(0));
-            break;
-        case Auto:
-            string = "auto";
-            break;
-        default:
-            break;
-    }
-    return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
-}
-
 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
 {
     Node* node = m_node.get();
@@ -552,56 +354,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return new CSSPrimitiveValue(CSS_VAL_NONE);
         case CSS_PROP__WEBKIT_BACKGROUND_SIZE: {
             RefPtr<CSSValueList> list = new CSSValueList(true);
-            list->append(valueForLength(style->backgroundSize().width));
-            list->append(valueForLength(style->backgroundSize().height));
+            list->append(new CSSPrimitiveValue(style->backgroundSize().width));
+            list->append(new CSSPrimitiveValue(style->backgroundSize().height));
             return list.release();
         }  
         case CSS_PROP_BACKGROUND_REPEAT:
-            switch (style->backgroundRepeat()) {
-                case REPEAT:
-                    return new CSSPrimitiveValue(CSS_VAL_REPEAT);
-                case REPEAT_X:
-                    return new CSSPrimitiveValue(CSS_VAL_REPEAT_X);
-                case REPEAT_Y:
-                    return new CSSPrimitiveValue(CSS_VAL_REPEAT_Y);
-                case NO_REPEAT:
-                    return new CSSPrimitiveValue(CSS_VAL_NO_REPEAT);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->backgroundRepeat());
         case CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE:
-            switch (style->backgroundComposite()) {
-                case CompositeClear:
-                    return new CSSPrimitiveValue(CSS_VAL_CLEAR);
-                case CompositeCopy:
-                    return new CSSPrimitiveValue(CSS_VAL_COPY);
-                case CompositeSourceOver:
-                    return new CSSPrimitiveValue(CSS_VAL_SOURCE_OVER);
-                case CompositeSourceIn:
-                    return new CSSPrimitiveValue(CSS_VAL_SOURCE_IN);
-                case CompositeSourceOut:
-                    return new CSSPrimitiveValue(CSS_VAL_SOURCE_OUT);
-                case CompositeSourceAtop:
-                    return new CSSPrimitiveValue(CSS_VAL_SOURCE_ATOP);
-                case CompositeDestinationOver:
-                    return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OVER);
-                case CompositeDestinationIn:
-                    return new CSSPrimitiveValue(CSS_VAL_DESTINATION_IN);
-                case CompositeDestinationOut:
-                    return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OUT);
-                case CompositeDestinationAtop:
-                    return new CSSPrimitiveValue(CSS_VAL_DESTINATION_ATOP);
-                case CompositeXOR:
-                    return new CSSPrimitiveValue(CSS_VAL_XOR);
-                case CompositePlusDarker:
-                    return new CSSPrimitiveValue(CSS_VAL_PLUS_DARKER);
-                case CompositeHighlight:
-                    return new CSSPrimitiveValue(CSS_VAL_HIGHLIGHT);
-                case CompositePlusLighter:
-                    return new CSSPrimitiveValue(CSS_VAL_PLUS_LIGHTER);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->backgroundComposite());
         case CSS_PROP_BACKGROUND_ATTACHMENT:
             if (style->backgroundAttachment())
                 return new CSSPrimitiveValue(CSS_VAL_SCROLL);
@@ -609,48 +369,20 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP__WEBKIT_BACKGROUND_CLIP:
         case CSS_PROP__WEBKIT_BACKGROUND_ORIGIN: {
             EBackgroundBox box = (propertyID == CSS_PROP__WEBKIT_BACKGROUND_CLIP ? style->backgroundClip() : style->backgroundOrigin());
-            switch (box) {
-                case BGBORDER:
-                    return new CSSPrimitiveValue(CSS_VAL_BORDER);
-                case BGPADDING:
-                    return new CSSPrimitiveValue(CSS_VAL_PADDING);
-                case BGCONTENT:
-                    return new CSSPrimitiveValue(CSS_VAL_CONTENT);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(box);
         }
         case CSS_PROP_BACKGROUND_POSITION: {
             RefPtr<CSSValueList> list = new CSSValueList(true);
 
-            Length length(style->backgroundXPosition());
-            if (length.isPercent())
-                list->append(new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
-            else
-                list->append(new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX));
-
-            length = style->backgroundYPosition();
-            if (length.isPercent())
-                list->append(new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
-            else
-                list->append(new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX));
+            list->append(new CSSPrimitiveValue(style->backgroundXPosition()));
+            list->append(new CSSPrimitiveValue(style->backgroundYPosition()));
 
             return list.release();
         }
-        case CSS_PROP_BACKGROUND_POSITION_X: {
-            Length length(style->backgroundXPosition());
-            if (length.isPercent())
-                return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
-            else
-                return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
-        }
-        case CSS_PROP_BACKGROUND_POSITION_Y: {
-            Length length(style->backgroundYPosition());
-            if (length.isPercent())
-                return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
-            else
-                return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
-        }
+        case CSS_PROP_BACKGROUND_POSITION_X:
+            return new CSSPrimitiveValue(style->backgroundXPosition());
+        case CSS_PROP_BACKGROUND_POSITION_Y:
+            return new CSSPrimitiveValue(style->backgroundYPosition());
         case CSS_PROP_BORDER_COLLAPSE:
             if (style->borderCollapse())
                 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
@@ -674,13 +406,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP_BORDER_LEFT_COLOR:
             return currentColorOrValidColor(style, style->borderLeftColor());
         case CSS_PROP_BORDER_TOP_STYLE:
-            return valueForBorderStyle(style->borderTopStyle());
+            return new CSSPrimitiveValue(style->borderTopStyle());
         case CSS_PROP_BORDER_RIGHT_STYLE:
-            return valueForBorderStyle(style->borderRightStyle());
+            return new CSSPrimitiveValue(style->borderRightStyle());
         case CSS_PROP_BORDER_BOTTOM_STYLE:
-            return valueForBorderStyle(style->borderBottomStyle());
+            return new CSSPrimitiveValue(style->borderBottomStyle());
         case CSS_PROP_BORDER_LEFT_STYLE:
-            return valueForBorderStyle(style->borderLeftStyle());
+            return new CSSPrimitiveValue(style->borderLeftStyle());
         case CSS_PROP_BORDER_TOP_WIDTH:
             return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
         case CSS_PROP_BORDER_RIGHT_WIDTH:
@@ -692,99 +424,33 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP_BOTTOM:
             return getPositionOffsetValue(style, CSS_PROP_BOTTOM);
         case CSS_PROP__WEBKIT_BOX_ALIGN:
-            switch (style->boxAlign()) {
-                case BSTRETCH:
-                    return new CSSPrimitiveValue(CSS_VAL_STRETCH);
-                case BSTART:
-                    return new CSSPrimitiveValue(CSS_VAL_START);
-                case BCENTER:
-                    return new CSSPrimitiveValue(CSS_VAL_CENTER);
-                case BEND:
-                    return new CSSPrimitiveValue(CSS_VAL_END);
-                case BBASELINE:
-                    return new CSSPrimitiveValue(CSS_VAL_BASELINE);
-                case BJUSTIFY:
-                    break; // not allowed
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->boxAlign());
         case CSS_PROP__WEBKIT_BOX_DIRECTION:
-            switch (style->boxDirection()) {
-                case BNORMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case BREVERSE:
-                    return new CSSPrimitiveValue(CSS_VAL_REVERSE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->boxDirection());
         case CSS_PROP__WEBKIT_BOX_FLEX:
             return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP__WEBKIT_BOX_FLEX_GROUP:
             return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP__WEBKIT_BOX_LINES:
-            switch (style->boxLines()) {
-                case SINGLE:
-                    return new CSSPrimitiveValue(CSS_VAL_SINGLE);
-                case MULTIPLE:
-                    return new CSSPrimitiveValue(CSS_VAL_MULTIPLE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->boxLines());
         case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP:
             return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP__WEBKIT_BOX_ORIENT:
-            switch (style->boxOrient()) {
-                case HORIZONTAL:
-                    return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
-                case VERTICAL:
-                    return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
-        case CSS_PROP__WEBKIT_BOX_PACK:
-            switch (style->boxPack()) {
-                case BSTART:
-                    return new CSSPrimitiveValue(CSS_VAL_START);
-                case BEND:
-                    return new CSSPrimitiveValue(CSS_VAL_END);
-                case BCENTER:
-                    return new CSSPrimitiveValue(CSS_VAL_CENTER);
-                case BJUSTIFY:
-                    return new CSSPrimitiveValue(CSS_VAL_JUSTIFY);
-                case BSTRETCH:
-                case BBASELINE:
-                    break; // not allowed
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->boxOrient());
+        case CSS_PROP__WEBKIT_BOX_PACK: {
+            EBoxAlignment boxPack = style->boxPack();
+            ASSERT(boxPack != BSTRETCH);
+            ASSERT(boxPack != BBASELINE);
+            if (boxPack == BJUSTIFY || boxPack== BBASELINE)
+                return 0;
+            return new CSSPrimitiveValue(boxPack);
+        }
         case CSS_PROP__WEBKIT_BOX_SHADOW:
             return valueForShadow(style->boxShadow());
         case CSS_PROP_CAPTION_SIDE:
-            switch (style->captionSide()) {
-                case CAPLEFT:
-                    return new CSSPrimitiveValue(CSS_VAL_LEFT);
-                case CAPRIGHT:
-                    return new CSSPrimitiveValue(CSS_VAL_RIGHT);
-                case CAPTOP:
-                    return new CSSPrimitiveValue(CSS_VAL_TOP);
-                case CAPBOTTOM:
-                    return new CSSPrimitiveValue(CSS_VAL_BOTTOM);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->captionSide());
         case CSS_PROP_CLEAR:
-            switch (style->clear()) {
-                case CNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case CLEFT:
-                    return new CSSPrimitiveValue(CSS_VAL_LEFT);
-                case CRIGHT:
-                    return new CSSPrimitiveValue(CSS_VAL_RIGHT);
-                case CBOTH:
-                    return new CSSPrimitiveValue(CSS_VAL_BOTH);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->clear());
         case CSS_PROP_COLOR:
             return new CSSPrimitiveValue(style->color().rgb());
         case CSS_PROP__WEBKIT_COLUMN_COUNT:
@@ -798,42 +464,15 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP__WEBKIT_COLUMN_RULE_COLOR:
             return currentColorOrValidColor(style, style->columnRuleColor());
         case CSS_PROP__WEBKIT_COLUMN_RULE_STYLE:
-            return valueForBorderStyle(style->columnRuleStyle());
+            return new CSSPrimitiveValue(style->columnRuleStyle());
         case CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH:
             return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
         case CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER:
-            switch (style->columnBreakAfter()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBALWAYS:
-                    return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->columnBreakAfter());
         case CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE:
-            switch (style->columnBreakBefore()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBALWAYS:
-                    return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->columnBreakBefore());
         case CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE:
-            switch (style->columnBreakInside()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-                case PBALWAYS:
-                    break; // not allowed
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->columnBreakInside());
         case CSS_PROP__WEBKIT_COLUMN_WIDTH:
             if (style->hasAutoColumnWidth())
                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
@@ -846,112 +485,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 for (unsigned i = 0; i < cursors->size(); ++i)
                     list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
             }
-            RefPtr<CSSValue> value;
-            switch (style->cursor()) {
-                case CURSOR_AUTO:
-                    value = new CSSPrimitiveValue(CSS_VAL_AUTO);
-                    break;
-                case CURSOR_CROSS:
-                    value = new CSSPrimitiveValue(CSS_VAL_CROSSHAIR);
-                    break;
-                case CURSOR_DEFAULT:
-                    value = new CSSPrimitiveValue(CSS_VAL_DEFAULT);
-                    break;
-                case CURSOR_POINTER:
-                    value = new CSSPrimitiveValue(CSS_VAL_POINTER);
-                    break;
-                case CURSOR_MOVE:
-                    value = new CSSPrimitiveValue(CSS_VAL_MOVE);
-                    break;
-                case CURSOR_CELL:
-                    value = new CSSPrimitiveValue(CSS_VAL_CELL);
-                    break;
-                case CURSOR_VERTICAL_TEXT:
-                    value = new CSSPrimitiveValue(CSS_VAL_VERTICAL_TEXT);
-                    break;
-                case CURSOR_CONTEXT_MENU:
-                    value = new CSSPrimitiveValue(CSS_VAL_CONTEXT_MENU);
-                    break;
-                case CURSOR_ALIAS:
-                    value = new CSSPrimitiveValue(CSS_VAL_ALIAS);
-                    break;
-                case CURSOR_COPY:
-                    value = new CSSPrimitiveValue(CSS_VAL_COPY);
-                    break;
-                case CURSOR_NONE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NONE);
-                    break;
-                case CURSOR_PROGRESS:
-                    value = new CSSPrimitiveValue(CSS_VAL_PROGRESS);
-                    break;
-                case CURSOR_NO_DROP:
-                    value = new CSSPrimitiveValue(CSS_VAL_NO_DROP);
-                    break;
-                case CURSOR_NOT_ALLOWED:
-                    value = new CSSPrimitiveValue(CSS_VAL_NOT_ALLOWED);
-                    break;
-                case CURSOR_WEBKIT_ZOOM_IN:
-                    value = new CSSPrimitiveValue(CSS_VAL__WEBKIT_ZOOM_IN);
-                    break;
-                case CURSOR_WEBKIT_ZOOM_OUT:
-                    value = new CSSPrimitiveValue(CSS_VAL__WEBKIT_ZOOM_OUT);
-                    break;
-                case CURSOR_E_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_E_RESIZE);
-                    break;
-                case CURSOR_NE_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NE_RESIZE);
-                    break;
-                case CURSOR_NW_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NW_RESIZE);
-                    break;
-                case CURSOR_N_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_N_RESIZE);
-                    break;
-                case CURSOR_SE_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_SE_RESIZE);
-                    break;
-                case CURSOR_SW_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_SW_RESIZE);
-                    break;
-                case CURSOR_S_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_S_RESIZE);
-                    break;
-                case CURSOR_W_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_W_RESIZE);
-                    break;
-                case CURSOR_EW_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_EW_RESIZE);
-                    break;
-                case CURSOR_NS_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NS_RESIZE);
-                    break;
-                case CURSOR_NESW_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NESW_RESIZE);
-                    break;
-                case CURSOR_NWSE_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_NWSE_RESIZE);
-                    break;
-                case CURSOR_COL_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_COL_RESIZE);
-                    break;
-                case CURSOR_ROW_RESIZE:
-                    value = new CSSPrimitiveValue(CSS_VAL_ROW_RESIZE);
-                    break;
-                case CURSOR_TEXT:
-                    value = new CSSPrimitiveValue(CSS_VAL_TEXT);
-                    break;
-                case CURSOR_WAIT:
-                    value = new CSSPrimitiveValue(CSS_VAL_WAIT);
-                    break;
-                case CURSOR_HELP:
-                    value = new CSSPrimitiveValue(CSS_VAL_HELP);
-                    break;
-                case CURSOR_ALL_SCROLL:
-                    value = new CSSPrimitiveValue(CSS_VAL_ALL_SCROLL);
-                    break;
-            }
-            ASSERT(value);
+            RefPtr<CSSValue> value = new CSSPrimitiveValue(style->cursor());
             if (list) {
                 list->append(value);
                 return list.release();
@@ -959,77 +493,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return value.release();
         }
         case CSS_PROP_DIRECTION:
-            switch (style->direction()) {
-                case LTR:
-                    return new CSSPrimitiveValue(CSS_VAL_LTR);
-                case RTL:
-                    return new CSSPrimitiveValue(CSS_VAL_RTL);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->direction());
         case CSS_PROP_DISPLAY:
-            switch (style->display()) {
-                case INLINE:
-                    return new CSSPrimitiveValue(CSS_VAL_INLINE);
-                case BLOCK:
-                    return new CSSPrimitiveValue(CSS_VAL_BLOCK);
-                case LIST_ITEM:
-                    return new CSSPrimitiveValue(CSS_VAL_LIST_ITEM);
-                case RUN_IN:
-                    return new CSSPrimitiveValue(CSS_VAL_RUN_IN);
-                case COMPACT:
-                    return new CSSPrimitiveValue(CSS_VAL_COMPACT);
-                case INLINE_BLOCK:
-                    return new CSSPrimitiveValue(CSS_VAL_INLINE_BLOCK);
-                case TABLE:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE);
-                case INLINE_TABLE:
-                    return new CSSPrimitiveValue(CSS_VAL_INLINE_TABLE);
-                case TABLE_ROW_GROUP:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW_GROUP);
-                case TABLE_HEADER_GROUP:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_HEADER_GROUP);
-                case TABLE_FOOTER_GROUP:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_FOOTER_GROUP);
-                case TABLE_ROW:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW);
-                case TABLE_COLUMN_GROUP:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN_GROUP);
-                case TABLE_COLUMN:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN);
-                case TABLE_CELL:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_CELL);
-                case TABLE_CAPTION:
-                    return new CSSPrimitiveValue(CSS_VAL_TABLE_CAPTION);
-                case BOX:
-                    return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BOX);
-                case INLINE_BOX:
-                    return new CSSPrimitiveValue(CSS_VAL__WEBKIT_INLINE_BOX);
-                case NONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->display());
         case CSS_PROP_EMPTY_CELLS:
-            switch (style->emptyCells()) {
-                case SHOW:
-                    return new CSSPrimitiveValue(CSS_VAL_SHOW);
-                case HIDE:
-                    return new CSSPrimitiveValue(CSS_VAL_HIDE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->emptyCells());
         case CSS_PROP_FLOAT:
-            switch (style->floating()) {
-                case FNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case FLEFT:
-                    return new CSSPrimitiveValue(CSS_VAL_LEFT);
-                case FRIGHT:
-                    return new CSSPrimitiveValue(CSS_VAL_RIGHT);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->floating());
         case CSS_PROP_FONT_FAMILY:
             // FIXME: This only returns the first family.
             return new CSSPrimitiveValue(style->fontDescription().family().family().domString(), CSSPrimitiveValue::CSS_STRING);
@@ -1054,7 +524,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP_HEIGHT:
             if (renderer)
                 return new CSSPrimitiveValue(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->height());
+            return new CSSPrimitiveValue(style->height());
         case CSS_PROP__WEBKIT_HIGHLIGHT:
             if (style->highlight() == nullAtom)
                 return new CSSPrimitiveValue(CSS_VAL_NONE);
@@ -1090,138 +560,57 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 return new CSSPrimitiveValue(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI);
             return new CSSPrimitiveValue(CSS_VAL_NONE);
         case CSS_PROP_LIST_STYLE_POSITION:
-            switch (style->listStylePosition()) {
-                case OUTSIDE:
-                    return new CSSPrimitiveValue(CSS_VAL_OUTSIDE);
-                case INSIDE:
-                    return new CSSPrimitiveValue(CSS_VAL_INSIDE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->listStylePosition());
         case CSS_PROP_LIST_STYLE_TYPE:
-            switch (style->listStyleType()) {
-                case LNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case DISC:
-                    return new CSSPrimitiveValue(CSS_VAL_DISC);
-                case CIRCLE:
-                    return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
-                case SQUARE:
-                    return new CSSPrimitiveValue(CSS_VAL_SQUARE);
-                case LDECIMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_DECIMAL);
-                case DECIMAL_LEADING_ZERO:
-                    return new CSSPrimitiveValue(CSS_VAL_DECIMAL_LEADING_ZERO);
-                case LOWER_ROMAN:
-                    return new CSSPrimitiveValue(CSS_VAL_LOWER_ROMAN);
-                case UPPER_ROMAN:
-                    return new CSSPrimitiveValue(CSS_VAL_UPPER_ROMAN);
-                case LOWER_GREEK:
-                    return new CSSPrimitiveValue(CSS_VAL_LOWER_GREEK);
-                case LOWER_ALPHA:
-                    return new CSSPrimitiveValue(CSS_VAL_LOWER_ALPHA);
-                case LOWER_LATIN:
-                    return new CSSPrimitiveValue(CSS_VAL_LOWER_LATIN);
-                case UPPER_ALPHA:
-                    return new CSSPrimitiveValue(CSS_VAL_UPPER_ALPHA);
-                case UPPER_LATIN:
-                    return new CSSPrimitiveValue(CSS_VAL_UPPER_LATIN);
-                case HEBREW:
-                    return new CSSPrimitiveValue(CSS_VAL_HEBREW);
-                case ARMENIAN:
-                    return new CSSPrimitiveValue(CSS_VAL_ARMENIAN);
-                case GEORGIAN:
-                    return new CSSPrimitiveValue(CSS_VAL_GEORGIAN);
-                case CJK_IDEOGRAPHIC:
-                    return new CSSPrimitiveValue(CSS_VAL_CJK_IDEOGRAPHIC);
-                case HIRAGANA:
-                    return new CSSPrimitiveValue(CSS_VAL_HIRAGANA);
-                case KATAKANA:
-                    return new CSSPrimitiveValue(CSS_VAL_KATAKANA);
-                case HIRAGANA_IROHA:
-                    return new CSSPrimitiveValue(CSS_VAL_HIRAGANA_IROHA);
-                case KATAKANA_IROHA:
-                    return new CSSPrimitiveValue(CSS_VAL_KATAKANA_IROHA);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->listStyleType());
         case CSS_PROP_MARGIN_TOP:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
                 return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->marginTop());
+            return new CSSPrimitiveValue(style->marginTop());
         case CSS_PROP_MARGIN_RIGHT:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
                 return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->marginRight());
+            return new CSSPrimitiveValue(style->marginRight());
         case CSS_PROP_MARGIN_BOTTOM:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
                 return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->marginBottom());
+            return new CSSPrimitiveValue(style->marginBottom());
         case CSS_PROP_MARGIN_LEFT:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
                 return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->marginLeft());
+            return new CSSPrimitiveValue(style->marginLeft());
         case CSS_PROP__WEBKIT_MARQUEE_DIRECTION:
-            switch (style->marqueeDirection()) {
-                case MFORWARD:
-                    return new CSSPrimitiveValue(CSS_VAL_FORWARDS);
-                case MBACKWARD:
-                    return new CSSPrimitiveValue(CSS_VAL_BACKWARDS);
-                case MAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case MUP:
-                    return new CSSPrimitiveValue(CSS_VAL_UP);
-                case MDOWN:
-                    return new CSSPrimitiveValue(CSS_VAL_DOWN);
-                case MLEFT:
-                    return new CSSPrimitiveValue(CSS_VAL_LEFT);
-                case MRIGHT:
-                    return new CSSPrimitiveValue(CSS_VAL_RIGHT);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->marqueeDirection());
         case CSS_PROP__WEBKIT_MARQUEE_INCREMENT:
-            return valueForLength(style->marqueeIncrement());
+            return new CSSPrimitiveValue(style->marqueeIncrement());
         case CSS_PROP__WEBKIT_MARQUEE_REPETITION:
             if (style->marqueeLoopCount() < 0)
                 return new CSSPrimitiveValue(CSS_VAL_INFINITE);
             return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP__WEBKIT_MARQUEE_STYLE:
-            switch (style->marqueeBehavior()) {
-                case MNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case MSCROLL:
-                    return new CSSPrimitiveValue(CSS_VAL_SCROLL);
-                case MSLIDE:
-                    return new CSSPrimitiveValue(CSS_VAL_SLIDE);
-                case MALTERNATE:
-                    return new CSSPrimitiveValue(CSS_VAL_ALTERNATE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->marqueeBehavior());
         case CSS_PROP__WEBKIT_USER_MODIFY:
-            switch (style->userModify()) {
-                case READ_ONLY:
-                    return new CSSPrimitiveValue(CSS_VAL_READ_ONLY);
-                case READ_WRITE:
-                    return new CSSPrimitiveValue(CSS_VAL_READ_WRITE);
-                case READ_WRITE_PLAINTEXT_ONLY:
-                    return new CSSPrimitiveValue(CSS_VAL_READ_WRITE_PLAINTEXT_ONLY);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
-        case CSS_PROP_MAX_HEIGHT:
-            return valueForMaxLength(style->maxHeight());
-        case CSS_PROP_MAX_WIDTH:
-            return valueForMaxLength(style->maxWidth());
+            return new CSSPrimitiveValue(style->userModify());
+        case CSS_PROP_MAX_HEIGHT: {
+            const Length& maxHeight = style->maxHeight();
+            if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
+                return new CSSPrimitiveValue(CSS_VAL_NONE);
+            return new CSSPrimitiveValue(maxHeight);
+        }
+        case CSS_PROP_MAX_WIDTH: {
+            const Length& maxWidth = style->maxHeight();
+            if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
+                return new CSSPrimitiveValue(CSS_VAL_NONE);
+            return new CSSPrimitiveValue(maxWidth);
+        }
         case CSS_PROP_MIN_HEIGHT:
-            return valueForLength(style->minHeight());
+            return new CSSPrimitiveValue(style->minHeight());
         case CSS_PROP_MIN_WIDTH:
-            return valueForLength(style->minWidth());
+            return new CSSPrimitiveValue(style->minWidth());
         case CSS_PROP_OPACITY:
             return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP_ORPHANS:
@@ -1231,115 +620,50 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP_OUTLINE_STYLE:
             if (style->outlineStyleIsAuto())
                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            return valueForBorderStyle(style->outlineStyle());
+            return new CSSPrimitiveValue(style->outlineStyle());
         case CSS_PROP_OUTLINE_WIDTH:
             return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
         case CSS_PROP_OVERFLOW:
+            return new CSSPrimitiveValue(max(style->overflowX(), style->overflowY()));
         case CSS_PROP_OVERFLOW_X:
-        case CSS_PROP_OVERFLOW_Y: {
-            EOverflow overflow;
-            switch (propertyID) {
-                case CSS_PROP_OVERFLOW_X:
-                    overflow = style->overflowX();
-                    break;
-                case CSS_PROP_OVERFLOW_Y:
-                    overflow = style->overflowY();
-                    break;
-                default:
-                    overflow = max(style->overflowX(), style->overflowY());
-            }
-            switch (overflow) {
-                case OVISIBLE:
-                    return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
-                case OHIDDEN:
-                    return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
-                case OSCROLL:
-                    return new CSSPrimitiveValue(CSS_VAL_SCROLL);
-                case OAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case OMARQUEE:
-                    return new CSSPrimitiveValue(CSS_VAL__WEBKIT_MARQUEE);
-                case OOVERLAY:
-                    return new CSSPrimitiveValue(CSS_VAL_OVERLAY);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
-        }
+            return new CSSPrimitiveValue(style->overflowX());
+        case CSS_PROP_OVERFLOW_Y:
+            return new CSSPrimitiveValue(style->overflowY());
         case CSS_PROP_PADDING_TOP:
             if (renderer)
                 return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->paddingTop());
+            return new CSSPrimitiveValue(style->paddingTop());
         case CSS_PROP_PADDING_RIGHT:
             if (renderer)
                 return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->paddingRight());
+            return new CSSPrimitiveValue(style->paddingRight());
         case CSS_PROP_PADDING_BOTTOM:
             if (renderer)
                 return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->paddingBottom());
+            return new CSSPrimitiveValue(style->paddingBottom());
         case CSS_PROP_PADDING_LEFT:
             if (renderer)
                 return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->paddingLeft());
+            return new CSSPrimitiveValue(style->paddingLeft());
         case CSS_PROP_PAGE_BREAK_AFTER:
-            switch (style->pageBreakAfter()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBALWAYS:
-                    return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->pageBreakAfter());
         case CSS_PROP_PAGE_BREAK_BEFORE:
-            switch (style->pageBreakBefore()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBALWAYS:
-                    return new CSSPrimitiveValue(CSS_VAL_ALWAYS);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
-        case CSS_PROP_PAGE_BREAK_INSIDE:
-            switch (style->pageBreakInside()) {
-                case PBAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case PBAVOID:
-                    return new CSSPrimitiveValue(CSS_VAL_AVOID);
-                case PBALWAYS:
-                    break; // not allowed
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->pageBreakBefore());
+        case CSS_PROP_PAGE_BREAK_INSIDE: {
+            EPageBreak pageBreak = style->pageBreakInside();
+            ASSERT(pageBreak != PBALWAYS);
+            if (pageBreak == PBALWAYS)
+                return 0;
+            return new CSSPrimitiveValue(style->pageBreakInside());
+        }
         case CSS_PROP_POSITION:
-            switch (style->position()) {
-                case StaticPosition:
-                    return new CSSPrimitiveValue(CSS_VAL_STATIC);
-                case RelativePosition:
-                    return new CSSPrimitiveValue(CSS_VAL_RELATIVE);
-                case AbsolutePosition:
-                    return new CSSPrimitiveValue(CSS_VAL_ABSOLUTE);
-                case FixedPosition:
-                    return new CSSPrimitiveValue(CSS_VAL_FIXED);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->position());
         case CSS_PROP_RIGHT:
             return getPositionOffsetValue(style, CSS_PROP_RIGHT);
         case CSS_PROP_TABLE_LAYOUT:
-            switch (style->tableLayout()) {
-                case TAUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case TFIXED:
-                    return new CSSPrimitiveValue(CSS_VAL_FIXED);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->tableLayout());
         case CSS_PROP_TEXT_ALIGN:
-            return valueForTextAlign(style->textAlign());
+            return new CSSPrimitiveValue(style->textAlign());
         case CSS_PROP_TEXT_DECORATION: {
             String string;
             if (style->textDecoration() & UNDERLINE)
@@ -1389,22 +713,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP__WEBKIT_TEXT_FILL_COLOR:
             return currentColorOrValidColor(style, style->textFillColor());
         case CSS_PROP_TEXT_INDENT:
-            return valueForLength(style->textIndent());
+            return new CSSPrimitiveValue(style->textIndent());
         case CSS_PROP_TEXT_SHADOW:
             return valueForShadow(style->textShadow());
         case CSS_PROP__WEBKIT_TEXT_SECURITY:
-            switch (style->textSecurity()) {
-                case TSNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case TSDISC:
-                    return new CSSPrimitiveValue(CSS_VAL_DISC);
-                case TSCIRCLE:
-                    return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
-                case TSSQUARE:
-                    return new CSSPrimitiveValue(CSS_VAL_SQUARE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->textSecurity());
         case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
             if (style->textSizeAdjust())
                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
@@ -1414,31 +727,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH:
             return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP_TEXT_TRANSFORM:
-            switch (style->textTransform()) {
-                case CAPITALIZE:
-                    return new CSSPrimitiveValue(CSS_VAL_CAPITALIZE);
-                case UPPERCASE:
-                    return new CSSPrimitiveValue(CSS_VAL_UPPERCASE);
-                case LOWERCASE:
-                    return new CSSPrimitiveValue(CSS_VAL_LOWERCASE);
-                case TTNONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->textTransform());
         case CSS_PROP_TOP:
             return getPositionOffsetValue(style, CSS_PROP_TOP);
         case CSS_PROP_UNICODE_BIDI:
-            switch (style->unicodeBidi()) {
-                case UBNormal:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case Embed:
-                    return new CSSPrimitiveValue(CSS_VAL_EMBED);
-                case Override:
-                    return new CSSPrimitiveValue(CSS_VAL_BIDI_OVERRIDE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->unicodeBidi());
         case CSS_PROP_VERTICAL_ALIGN:
             switch (style->verticalAlign()) {
                 case BASELINE:
@@ -1460,104 +753,34 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 case BASELINE_MIDDLE:
                     return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BASELINE_MIDDLE);
                 case LENGTH:
-                    return valueForLength(style->verticalAlignLength());
+                    return new CSSPrimitiveValue(style->verticalAlignLength());
             }
             ASSERT_NOT_REACHED();
             return 0;
         case CSS_PROP_VISIBILITY:
-            switch (style->visibility()) {
-                case VISIBLE:
-                    return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
-                case HIDDEN:
-                    return new CSSPrimitiveValue(CSS_VAL_HIDDEN);
-                case COLLAPSE:
-                    return new CSSPrimitiveValue(CSS_VAL_COLLAPSE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->visibility());
         case CSS_PROP_WHITE_SPACE:
-            switch (style->whiteSpace()) {
-                case NORMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case PRE:
-                    return new CSSPrimitiveValue(CSS_VAL_PRE);
-                case PRE_WRAP:
-                    return new CSSPrimitiveValue(CSS_VAL_PRE_WRAP);
-                case PRE_LINE:
-                    return new CSSPrimitiveValue(CSS_VAL_PRE_LINE);
-                case NOWRAP:
-                    return new CSSPrimitiveValue(CSS_VAL_NOWRAP);
-                case KHTML_NOWRAP:
-                    return new CSSPrimitiveValue(CSS_VAL__WEBKIT_NOWRAP);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->whiteSpace());
         case CSS_PROP_WIDOWS:
             return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP_WIDTH:
             if (renderer)
                 return new CSSPrimitiveValue(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX);
-            return valueForLength(style->width());
+            return new CSSPrimitiveValue(style->width());
         case CSS_PROP_WORD_BREAK:
-            switch (style->wordBreak()) {
-                case NormalWordBreak:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case BreakAllWordBreak:
-                    return new CSSPrimitiveValue(CSS_VAL_BREAK_ALL);
-                case BreakWordBreak:
-                    return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD);
-            }
+            return new CSSPrimitiveValue(style->wordBreak());
         case CSS_PROP_WORD_SPACING:
             return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSS_PROP_WORD_WRAP:
-            switch (style->wordWrap()) {
-                case NormalWordWrap:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case BreakWordWrap:
-                    return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->wordWrap());
         case CSS_PROP__WEBKIT_LINE_BREAK:
-            switch (style->khtmlLineBreak()) {
-                case LBNORMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case AFTER_WHITE_SPACE:
-                    return new CSSPrimitiveValue(CSS_VAL_AFTER_WHITE_SPACE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->khtmlLineBreak());
         case CSS_PROP__WEBKIT_NBSP_MODE:
-            switch (style->nbspMode()) {
-                case NBNORMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case SPACE:
-                    return new CSSPrimitiveValue(CSS_VAL_SPACE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->nbspMode());
         case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
-            switch (style->matchNearestMailBlockquoteColor()) {
-                case BCNORMAL:
-                    return new CSSPrimitiveValue(CSS_VAL_NORMAL);
-                case MATCH:
-                    return new CSSPrimitiveValue(CSS_VAL_MATCH);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->matchNearestMailBlockquoteColor());
         case CSS_PROP_RESIZE:
-            switch (style->resize()) {
-                case RESIZE_BOTH:
-                    return new CSSPrimitiveValue(CSS_VAL_BOTH);
-                case RESIZE_HORIZONTAL:
-                    return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL);
-                case RESIZE_VERTICAL:
-                    return new CSSPrimitiveValue(CSS_VAL_VERTICAL);
-                case RESIZE_NONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-            }
-            ASSERT_NOT_REACHED();
-            return 0;
+            return new CSSPrimitiveValue(style->resize());
         case CSS_PROP_Z_INDEX:
             if (style->hasAutoZIndex())
                 return new CSSPrimitiveValue(CSS_VAL_AUTO);
@@ -1597,36 +820,22 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return new CSSPrimitiveValue(firstRegion.release());
         }
         case CSS_PROP__WEBKIT_APPEARANCE:
-            return valueForAppearance(style->appearance());
+            return new CSSPrimitiveValue(style->appearance());
         case CSS_PROP__WEBKIT_FONT_SIZE_DELTA:
             // Not a real style property -- used by the editing engine -- so has no computed value.
             break;
         case CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE:
-            return valueForMarginCollapse(style->marginBottomCollapse());
+            return new CSSPrimitiveValue(style->marginBottomCollapse());
         case CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE:
-            return valueForMarginCollapse(style->marginTopCollapse());
+            return new CSSPrimitiveValue(style->marginTopCollapse());
         case CSS_PROP__WEBKIT_RTL_ORDERING:
             if (style->visuallyOrdered())
                 return new CSSPrimitiveValue(CSS_VAL_VISUAL);
             return new CSSPrimitiveValue(CSS_VAL_LOGICAL);
         case CSS_PROP__WEBKIT_USER_DRAG:
-            switch (style->userDrag()) {
-                case DRAG_AUTO:
-                    return new CSSPrimitiveValue(CSS_VAL_AUTO);
-                case DRAG_NONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case DRAG_ELEMENT:
-                    return new CSSPrimitiveValue(CSS_VAL_ELEMENT);
-            }
-            break;
+            return new CSSPrimitiveValue(style->userDrag());
         case CSS_PROP__WEBKIT_USER_SELECT:
-            switch (style->userSelect()) {
-                case SELECT_NONE:
-                    return new CSSPrimitiveValue(CSS_VAL_NONE);
-                case SELECT_TEXT:
-                    return new CSSPrimitiveValue(CSS_VAL_TEXT);
-            }
-            break;
+            return new CSSPrimitiveValue(style->userSelect());
         case CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS:
             return getBorderRadiusCornerValue(style->borderBottomLeftRadius());
         case CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS:
index 9e9bf5315b8735ab28afdd52677c6f0719582b0f..c7d84181a20807935f2897fd8e0f3f45f86131b3 100644 (file)
@@ -131,33 +131,63 @@ CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
         m_value.string->ref();
 }
 
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Counter> c)
-    : m_type(CSS_COUNTER)
+CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
+    : m_type(CSS_RGBCOLOR)
 {
-    m_value.counter = c.releaseRef();
+    m_value.rgbcolor = color;
 }
 
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Rect> r)
-    : m_type(CSS_RECT)
+CSSPrimitiveValue::CSSPrimitiveValue(const Length& length)
 {
-    m_value.rect = r.releaseRef();
+    switch (length.type()) {
+        case Auto:
+            m_type = CSS_IDENT;
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case WebCore::Fixed:
+            m_type = CSS_PX;
+            m_value.num = length.value();
+            break;
+        case Intrinsic:
+            m_type = CSS_IDENT;
+            m_value.ident = CSS_VAL_INTRINSIC;
+            break;
+        case MinIntrinsic:
+            m_type = CSS_IDENT;
+            m_value.ident = CSS_VAL_MIN_INTRINSIC;
+            break;
+        case Percent:
+            m_type = CSS_PERCENTAGE;
+            m_value.num = length.percent();
+            break;
+        case Relative:
+        case Static:
+            ASSERT_NOT_REACHED();
+            break;
+    }
 }
 
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<DashboardRegion> r)
-    : m_type(CSS_DASHBOARD_REGION)
+void CSSPrimitiveValue::init(PassRefPtr<Counter> c)
 {
-    m_value.region = r.releaseRef();
+    m_type = CSS_COUNTER;
+    m_value.counter = c.releaseRef();
 }
 
-CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
-    : m_type(CSS_RGBCOLOR)
+void CSSPrimitiveValue::init(PassRefPtr<Rect> r)
 {
-    m_value.rgbcolor = color;
+    m_type = CSS_RECT;
+    m_value.rect = r.releaseRef();
+}
+
+void CSSPrimitiveValue::init(PassRefPtr<DashboardRegion> r)
+{
+    m_type = CSS_DASHBOARD_REGION;
+    m_value.region = r.releaseRef();
 }
 
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Pair> p)
-    : m_type(CSS_PAIR)
+void CSSPrimitiveValue::init(PassRefPtr<Pair> p)
 {
+    m_type = CSS_PAIR;
     m_value.pair = p.releaseRef();
 }
 
index 6d05e003b8843488498b1fbaa772898108b09b32..6d1f3a9d2fe2ddead0099427b3687b1ab14f07fb 100644 (file)
@@ -3,6 +3,7 @@
  *
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -30,6 +31,7 @@ namespace WebCore {
 
 class Counter;
 class DashboardRegion;
+struct Length;
 class Pair;
 class Rect;
 class RenderStyle;
@@ -75,11 +77,11 @@ public:
     CSSPrimitiveValue(int ident);
     CSSPrimitiveValue(double, UnitTypes);
     CSSPrimitiveValue(const String&, UnitTypes);
-    CSSPrimitiveValue(PassRefPtr<Counter>);
-    CSSPrimitiveValue(PassRefPtr<Rect>);
     CSSPrimitiveValue(unsigned color); // RGB value
-    CSSPrimitiveValue(PassRefPtr<Pair>);
-    CSSPrimitiveValue(PassRefPtr<DashboardRegion>); // FIXME: Why is dashboard region a primitive value? This makes no sense.
+    CSSPrimitiveValue(const Length&);
+    template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h
+    template<typename T> CSSPrimitiveValue(T* val) { init(PassRefPtr<T>(val)); }
+    template<typename T> CSSPrimitiveValue(PassRefPtr<T> val) { init(val); }
 
     virtual ~CSSPrimitiveValue();
 
@@ -133,6 +135,7 @@ public:
     virtual unsigned short cssValueType() const;
 
     int getIdent();
+    template<typename T> operator T() const; // Defined in CSSPrimitiveValueMappings.h
 
     virtual bool parseString(const String&, bool = false);
     virtual String cssText() const;
@@ -151,6 +154,14 @@ protected:
         Pair* pair;
         DashboardRegion* region;
     } m_value;
+
+private:
+    template<typename T> operator T*(); // compile-time guard
+
+    void init(PassRefPtr<Counter>);
+    void init(PassRefPtr<Rect>);
+    void init(PassRefPtr<Pair>);
+    void init(PassRefPtr<DashboardRegion>); // FIXME: Why is dashboard region a primitive value? This makes no sense.
 };
 
 } // namespace WebCore
diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h
new file mode 100644 (file)
index 0000000..8960636
--- /dev/null
@@ -0,0 +1,2147 @@
+/*
+ * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSPrimitiveValueMappings_h
+#define CSSPrimitiveValueMappings_h
+
+#include "CSSPrimitiveValue.h"
+#include "CSSValueKeywords.h"
+#include "RenderStyle.h"
+
+namespace WebCore {
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderStyle e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case BNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case BHIDDEN:
+            m_value.ident = CSS_VAL_HIDDEN;
+            break;
+        case INSET:
+            m_value.ident = CSS_VAL_INSET;
+            break;
+        case GROOVE:
+            m_value.ident = CSS_VAL_GROOVE;
+            break;
+        case RIDGE:
+            m_value.ident = CSS_VAL_RIDGE;
+            break;
+        case OUTSET:
+            m_value.ident = CSS_VAL_OUTSET;
+            break;
+        case DOTTED:
+            m_value.ident = CSS_VAL_DOTTED;
+            break;
+        case DASHED:
+            m_value.ident = CSS_VAL_DASHED;
+            break;
+        case SOLID:
+            m_value.ident = CSS_VAL_SOLID;
+            break;
+        case DOUBLE:
+            m_value.ident = CSS_VAL_DOUBLE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBorderStyle() const
+{
+    return (EBorderStyle)(m_value.ident - CSS_VAL_NONE);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CompositeOperator e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CompositeClear:
+            m_value.ident = CSS_VAL_CLEAR;
+            break;
+        case CompositeCopy:
+            m_value.ident = CSS_VAL_COPY;
+            break;
+        case CompositeSourceOver:
+            m_value.ident = CSS_VAL_SOURCE_OVER;
+            break;
+        case CompositeSourceIn:
+            m_value.ident = CSS_VAL_SOURCE_IN;
+            break;
+        case CompositeSourceOut:
+            m_value.ident = CSS_VAL_SOURCE_OUT;
+            break;
+        case CompositeSourceAtop:
+            m_value.ident = CSS_VAL_SOURCE_ATOP;
+            break;
+        case CompositeDestinationOver:
+            m_value.ident = CSS_VAL_DESTINATION_OVER;
+            break;
+        case CompositeDestinationIn:
+            m_value.ident = CSS_VAL_DESTINATION_IN;
+            break;
+        case CompositeDestinationOut:
+            m_value.ident = CSS_VAL_DESTINATION_OUT;
+            break;
+        case CompositeDestinationAtop:
+            m_value.ident = CSS_VAL_DESTINATION_ATOP;
+            break;
+        case CompositeXOR:
+            m_value.ident = CSS_VAL_XOR;
+            break;
+        case CompositePlusDarker:
+            m_value.ident = CSS_VAL_PLUS_DARKER;
+            break;
+        case CompositeHighlight:
+            m_value.ident = CSS_VAL_HIGHLIGHT;
+            break;
+        case CompositePlusLighter:
+            m_value.ident = CSS_VAL_PLUS_LIGHTER;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator CompositeOperator() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_CLEAR:
+            return CompositeClear;
+        case CSS_VAL_COPY:
+            return CompositeCopy;
+        case CSS_VAL_SOURCE_OVER:
+            return CompositeSourceOver;
+        case CSS_VAL_SOURCE_IN:
+            return CompositeSourceIn;
+        case CSS_VAL_SOURCE_OUT:
+            return CompositeSourceOut;
+        case CSS_VAL_SOURCE_ATOP:
+            return CompositeSourceAtop;
+        case CSS_VAL_DESTINATION_OVER:
+            return CompositeDestinationOver;
+        case CSS_VAL_DESTINATION_IN:
+            return CompositeDestinationIn;
+        case CSS_VAL_DESTINATION_OUT:
+            return CompositeDestinationOut;
+        case CSS_VAL_DESTINATION_ATOP:
+            return CompositeDestinationAtop;
+        case CSS_VAL_XOR:
+            return CompositeXOR;
+        case CSS_VAL_PLUS_DARKER:
+            return CompositePlusDarker;
+        case CSS_VAL_HIGHLIGHT:
+            return CompositeHighlight;
+        case CSS_VAL_PLUS_LIGHTER:
+            return CompositePlusLighter;
+    }
+    ASSERT_NOT_REACHED();
+    return CompositeClear;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAppearance e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case NoAppearance:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case CheckboxAppearance:
+            m_value.ident = CSS_VAL_CHECKBOX;
+            break;
+        case RadioAppearance:
+            m_value.ident = CSS_VAL_RADIO;
+            break;
+        case PushButtonAppearance:
+            m_value.ident = CSS_VAL_PUSH_BUTTON;
+            break;
+        case SquareButtonAppearance:
+            m_value.ident = CSS_VAL_SQUARE_BUTTON;
+            break;
+        case ButtonAppearance:
+            m_value.ident = CSS_VAL_BUTTON;
+            break;
+        case ButtonBevelAppearance:
+            m_value.ident = CSS_VAL_BUTTON_BEVEL;
+            break;
+        case ListboxAppearance:
+            m_value.ident = CSS_VAL_LISTBOX;
+            break;
+        case ListItemAppearance:
+            m_value.ident = CSS_VAL_LISTITEM;
+            break;
+        case MenulistAppearance:
+            m_value.ident = CSS_VAL_MENULIST;
+            break;
+        case MenulistButtonAppearance:
+            m_value.ident = CSS_VAL_MENULIST_BUTTON;
+            break;
+        case MenulistTextAppearance:
+            m_value.ident = CSS_VAL_MENULIST_TEXT;
+            break;
+        case MenulistTextFieldAppearance:
+            m_value.ident = CSS_VAL_MENULIST_TEXTFIELD;
+            break;
+        case ScrollbarButtonUpAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARBUTTON_UP;
+            break;
+        case ScrollbarButtonDownAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARBUTTON_DOWN;
+            break;
+        case ScrollbarButtonLeftAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARBUTTON_LEFT;
+            break;
+        case ScrollbarButtonRightAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARBUTTON_RIGHT;
+            break;
+        case ScrollbarTrackHorizontalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARTRACK_HORIZONTAL;
+            break;
+        case ScrollbarTrackVerticalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARTRACK_VERTICAL;
+            break;
+        case ScrollbarThumbHorizontalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARTHUMB_HORIZONTAL;
+            break;
+        case ScrollbarThumbVerticalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARTHUMB_VERTICAL;
+            break;
+        case ScrollbarGripperHorizontalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARGRIPPER_HORIZONTAL;
+            break;
+        case ScrollbarGripperVerticalAppearance:
+            m_value.ident = CSS_VAL_SCROLLBARGRIPPER_VERTICAL;
+            break;
+        case SliderHorizontalAppearance:
+            m_value.ident = CSS_VAL_SLIDER_HORIZONTAL;
+            break;
+        case SliderVerticalAppearance:
+            m_value.ident = CSS_VAL_SLIDER_VERTICAL;
+            break;
+        case SliderThumbHorizontalAppearance:
+            m_value.ident = CSS_VAL_SLIDERTHUMB_HORIZONTAL;
+            break;
+        case SliderThumbVerticalAppearance:
+            m_value.ident = CSS_VAL_SLIDERTHUMB_VERTICAL;
+            break;
+        case CaretAppearance:
+            m_value.ident = CSS_VAL_CARET;
+            break;
+        case SearchFieldAppearance:
+            m_value.ident = CSS_VAL_SEARCHFIELD;
+            break;
+        case SearchFieldDecorationAppearance:
+            m_value.ident = CSS_VAL_SEARCHFIELD_DECORATION;
+            break;
+        case SearchFieldResultsDecorationAppearance:
+            m_value.ident = CSS_VAL_SEARCHFIELD_RESULTS_DECORATION;
+            break;
+        case SearchFieldResultsButtonAppearance:
+            m_value.ident = CSS_VAL_SEARCHFIELD_RESULTS_BUTTON;
+            break;
+        case SearchFieldCancelButtonAppearance:
+            m_value.ident = CSS_VAL_SEARCHFIELD_CANCEL_BUTTON;
+            break;
+        case TextFieldAppearance:
+            m_value.ident = CSS_VAL_TEXTFIELD;
+            break;
+        case TextAreaAppearance:
+            m_value.ident = CSS_VAL_TEXTAREA;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EAppearance() const
+{
+    if (m_value.ident == CSS_VAL_NONE)
+        return NoAppearance;
+    else
+        return EAppearance(m_value.ident - CSS_VAL_CHECKBOX + 1);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBackgroundBox e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case BGBORDER:
+            m_value.ident = CSS_VAL_BORDER;
+            break;
+        case BGPADDING:
+            m_value.ident = CSS_VAL_PADDING;
+            break;
+        case BGCONTENT:
+            m_value.ident = CSS_VAL_CONTENT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBackgroundBox() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_BORDER:
+            return BGBORDER;
+        case CSS_VAL_PADDING:
+            return BGPADDING;
+        case CSS_VAL_CONTENT:
+            return BGCONTENT;
+    }
+    ASSERT_NOT_REACHED();
+    return BGBORDER;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBackgroundRepeat e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case REPEAT:
+            m_value.ident = CSS_VAL_REPEAT;
+            break;
+        case REPEAT_X:
+            m_value.ident = CSS_VAL_REPEAT_X;
+            break;
+        case REPEAT_Y:
+            m_value.ident = CSS_VAL_REPEAT_Y;
+            break;
+        case NO_REPEAT:
+            m_value.ident = CSS_VAL_NO_REPEAT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBackgroundRepeat() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_REPEAT:
+            return REPEAT;
+        case CSS_VAL_REPEAT_X:
+            return REPEAT_X;
+        case CSS_VAL_REPEAT_Y:
+            return REPEAT_Y;
+        case CSS_VAL_NO_REPEAT:
+            return NO_REPEAT;
+    }
+    ASSERT_NOT_REACHED();
+    return REPEAT;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case BSTRETCH:
+            m_value.ident = CSS_VAL_STRETCH;
+            break;
+        case BSTART:
+            m_value.ident = CSS_VAL_START;
+            break;
+        case BCENTER:
+            m_value.ident = CSS_VAL_CENTER;
+            break;
+        case BEND:
+            m_value.ident = CSS_VAL_END;
+            break;
+        case BBASELINE:
+            m_value.ident = CSS_VAL_BASELINE;
+            break;
+        case BJUSTIFY:
+            m_value.ident = CSS_VAL_JUSTIFY;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBoxAlignment() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_STRETCH:
+            return BSTRETCH;
+        case CSS_VAL_START:
+            return BSTART;
+        case CSS_VAL_END:
+            return BEND;
+        case CSS_VAL_CENTER:
+            return BCENTER;
+        case CSS_VAL_BASELINE:
+            return BBASELINE;
+        case CSS_VAL_JUSTIFY:
+            return BJUSTIFY;
+    }
+    ASSERT_NOT_REACHED();
+    return BSTRETCH;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDirection e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case BNORMAL:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case BREVERSE:
+            m_value.ident = CSS_VAL_REVERSE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBoxDirection() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NORMAL:
+            return BNORMAL;
+        case CSS_VAL_REVERSE:
+            return BREVERSE;
+    }
+    ASSERT_NOT_REACHED();
+    return BNORMAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxLines e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case SINGLE:
+            m_value.ident = CSS_VAL_SINGLE;
+            break;
+        case MULTIPLE:
+            m_value.ident = CSS_VAL_MULTIPLE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBoxLines() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_SINGLE:
+            return SINGLE;
+        case CSS_VAL_MULTIPLE:
+            return MULTIPLE;
+    }
+    ASSERT_NOT_REACHED();
+    return SINGLE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxOrient e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case HORIZONTAL:
+            m_value.ident = CSS_VAL_HORIZONTAL;
+            break;
+        case VERTICAL:
+            m_value.ident = CSS_VAL_VERTICAL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBoxOrient() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_HORIZONTAL:
+        case CSS_VAL_INLINE_AXIS:
+            return HORIZONTAL;
+        case CSS_VAL_VERTICAL:
+            return VERTICAL;
+    }
+    ASSERT_NOT_REACHED();
+    return HORIZONTAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECaptionSide e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CAPLEFT:
+            m_value.ident = CSS_VAL_LEFT;
+            break;
+        case CAPRIGHT:
+            m_value.ident = CSS_VAL_RIGHT;
+            break;
+        case CAPTOP:
+            m_value.ident = CSS_VAL_TOP;
+            break;
+        case CAPBOTTOM:
+            m_value.ident = CSS_VAL_BOTTOM;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ECaptionSide() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_LEFT:
+            return CAPLEFT;
+        case CSS_VAL_RIGHT:
+            return CAPRIGHT;
+        case CSS_VAL_TOP:
+            return CAPTOP;
+        case CSS_VAL_BOTTOM:
+            return CAPBOTTOM;
+    }
+    ASSERT_NOT_REACHED();
+    return CAPTOP;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EClear e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case CLEFT:
+            m_value.ident = CSS_VAL_LEFT;
+            break;
+        case CRIGHT:
+            m_value.ident = CSS_VAL_RIGHT;
+            break;
+        case CBOTH:
+            m_value.ident = CSS_VAL_BOTH;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EClear() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NONE:
+            return CNONE;
+        case CSS_VAL_LEFT:
+            return CLEFT;
+        case CSS_VAL_RIGHT:
+            return CRIGHT;
+        case CSS_VAL_BOTH:
+            return CBOTH;
+    }
+    ASSERT_NOT_REACHED();
+    return CNONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ECursor e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CURSOR_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case CURSOR_CROSS:
+            m_value.ident = CSS_VAL_CROSSHAIR;
+            break;
+        case CURSOR_DEFAULT:
+            m_value.ident = CSS_VAL_DEFAULT;
+            break;
+        case CURSOR_POINTER:
+            m_value.ident = CSS_VAL_POINTER;
+            break;
+        case CURSOR_MOVE:
+            m_value.ident = CSS_VAL_MOVE;
+            break;
+        case CURSOR_CELL:
+            m_value.ident = CSS_VAL_CELL;
+            break;
+        case CURSOR_VERTICAL_TEXT:
+            m_value.ident = CSS_VAL_VERTICAL_TEXT;
+            break;
+        case CURSOR_CONTEXT_MENU:
+            m_value.ident = CSS_VAL_CONTEXT_MENU;
+            break;
+        case CURSOR_ALIAS:
+            m_value.ident = CSS_VAL_ALIAS;
+            break;
+        case CURSOR_COPY:
+            m_value.ident = CSS_VAL_COPY;
+            break;
+        case CURSOR_NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case CURSOR_PROGRESS:
+            m_value.ident = CSS_VAL_PROGRESS;
+            break;
+        case CURSOR_NO_DROP:
+            m_value.ident = CSS_VAL_NO_DROP;
+            break;
+        case CURSOR_NOT_ALLOWED:
+            m_value.ident = CSS_VAL_NOT_ALLOWED;
+            break;
+        case CURSOR_WEBKIT_ZOOM_IN:
+            m_value.ident = CSS_VAL__WEBKIT_ZOOM_IN;
+            break;
+        case CURSOR_WEBKIT_ZOOM_OUT:
+            m_value.ident = CSS_VAL__WEBKIT_ZOOM_OUT;
+            break;
+        case CURSOR_E_RESIZE:
+            m_value.ident = CSS_VAL_E_RESIZE;
+            break;
+        case CURSOR_NE_RESIZE:
+            m_value.ident = CSS_VAL_NE_RESIZE;
+            break;
+        case CURSOR_NW_RESIZE:
+            m_value.ident = CSS_VAL_NW_RESIZE;
+            break;
+        case CURSOR_N_RESIZE:
+            m_value.ident = CSS_VAL_N_RESIZE;
+            break;
+        case CURSOR_SE_RESIZE:
+            m_value.ident = CSS_VAL_SE_RESIZE;
+            break;
+        case CURSOR_SW_RESIZE:
+            m_value.ident = CSS_VAL_SW_RESIZE;
+            break;
+        case CURSOR_S_RESIZE:
+            m_value.ident = CSS_VAL_S_RESIZE;
+            break;
+        case CURSOR_W_RESIZE:
+            m_value.ident = CSS_VAL_W_RESIZE;
+            break;
+        case CURSOR_EW_RESIZE:
+            m_value.ident = CSS_VAL_EW_RESIZE;
+            break;
+        case CURSOR_NS_RESIZE:
+            m_value.ident = CSS_VAL_NS_RESIZE;
+            break;
+        case CURSOR_NESW_RESIZE:
+            m_value.ident = CSS_VAL_NESW_RESIZE;
+            break;
+        case CURSOR_NWSE_RESIZE:
+            m_value.ident = CSS_VAL_NWSE_RESIZE;
+            break;
+        case CURSOR_COL_RESIZE:
+            m_value.ident = CSS_VAL_COL_RESIZE;
+            break;
+        case CURSOR_ROW_RESIZE:
+            m_value.ident = CSS_VAL_ROW_RESIZE;
+            break;
+        case CURSOR_TEXT:
+            m_value.ident = CSS_VAL_TEXT;
+            break;
+        case CURSOR_WAIT:
+            m_value.ident = CSS_VAL_WAIT;
+            break;
+        case CURSOR_HELP:
+            m_value.ident = CSS_VAL_HELP;
+            break;
+        case CURSOR_ALL_SCROLL:
+            m_value.ident = CSS_VAL_ALL_SCROLL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ECursor() const
+{
+    if (m_value.ident == CSS_VAL_COPY)
+        return CURSOR_COPY;
+    else if (m_value.ident == CSS_VAL_NONE)
+        return CURSOR_NONE;
+    else
+        return (ECursor)(m_value.ident - CSS_VAL_AUTO);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case INLINE:
+            m_value.ident = CSS_VAL_INLINE;
+            break;
+        case BLOCK:
+            m_value.ident = CSS_VAL_BLOCK;
+            break;
+        case LIST_ITEM:
+            m_value.ident = CSS_VAL_LIST_ITEM;
+            break;
+        case RUN_IN:
+            m_value.ident = CSS_VAL_RUN_IN;
+            break;
+        case COMPACT:
+            m_value.ident = CSS_VAL_COMPACT;
+            break;
+        case INLINE_BLOCK:
+            m_value.ident = CSS_VAL_INLINE_BLOCK;
+            break;
+        case TABLE:
+            m_value.ident = CSS_VAL_TABLE;
+            break;
+        case INLINE_TABLE:
+            m_value.ident = CSS_VAL_INLINE_TABLE;
+            break;
+        case TABLE_ROW_GROUP:
+            m_value.ident = CSS_VAL_TABLE_ROW_GROUP;
+            break;
+        case TABLE_HEADER_GROUP:
+            m_value.ident = CSS_VAL_TABLE_HEADER_GROUP;
+            break;
+        case TABLE_FOOTER_GROUP:
+            m_value.ident = CSS_VAL_TABLE_FOOTER_GROUP;
+            break;
+        case TABLE_ROW:
+            m_value.ident = CSS_VAL_TABLE_ROW;
+            break;
+        case TABLE_COLUMN_GROUP:
+            m_value.ident = CSS_VAL_TABLE_COLUMN_GROUP;
+            break;
+        case TABLE_COLUMN:
+            m_value.ident = CSS_VAL_TABLE_COLUMN;
+            break;
+        case TABLE_CELL:
+            m_value.ident = CSS_VAL_TABLE_CELL;
+            break;
+        case TABLE_CAPTION:
+            m_value.ident = CSS_VAL_TABLE_CAPTION;
+            break;
+        case BOX:
+            m_value.ident = CSS_VAL__WEBKIT_BOX;
+            break;
+        case INLINE_BOX:
+            m_value.ident = CSS_VAL__WEBKIT_INLINE_BOX;
+            break;
+        case NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EDisplay() const
+{
+    if (m_value.ident == CSS_VAL_NONE)
+        return NONE;
+    else
+        return EDisplay(m_value.ident - CSS_VAL_INLINE);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EEmptyCell e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case SHOW:
+            m_value.ident = CSS_VAL_SHOW;
+            break;
+        case HIDE:
+            m_value.ident = CSS_VAL_HIDE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EEmptyCell() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_SHOW:
+            return SHOW;
+        case CSS_VAL_HIDE:
+            return HIDE;
+    }
+    ASSERT_NOT_REACHED();
+    return SHOW;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case FNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case FLEFT:
+            m_value.ident = CSS_VAL_LEFT;
+            break;
+        case FRIGHT:
+            m_value.ident = CSS_VAL_RIGHT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EFloat() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_LEFT:
+            return FLEFT;
+        case CSS_VAL_RIGHT:
+            return FRIGHT;
+        case CSS_VAL_NONE:
+        case CSS_VAL_CENTER:  // Non-standard CSS value
+            return FNONE;
+    }
+    ASSERT_NOT_REACHED();
+    return FNONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EKHTMLLineBreak e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case LBNORMAL:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case AFTER_WHITE_SPACE:
+            m_value.ident = CSS_VAL_AFTER_WHITE_SPACE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EKHTMLLineBreak() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AFTER_WHITE_SPACE:
+            return AFTER_WHITE_SPACE;
+        case CSS_VAL_NORMAL:
+            return LBNORMAL;
+    }
+    ASSERT_NOT_REACHED();
+    return LBNORMAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStylePosition e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case OUTSIDE:
+            m_value.ident = CSS_VAL_OUTSIDE;
+            break;
+        case INSIDE:
+            m_value.ident = CSS_VAL_INSIDE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EListStylePosition() const
+{
+    return (EListStylePosition)(m_value.ident - CSS_VAL_OUTSIDE);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case LNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case DISC:
+            m_value.ident = CSS_VAL_DISC;
+            break;
+        case CIRCLE:
+            m_value.ident = CSS_VAL_CIRCLE;
+            break;
+        case SQUARE:
+            m_value.ident = CSS_VAL_SQUARE;
+            break;
+        case LDECIMAL:
+            m_value.ident = CSS_VAL_DECIMAL;
+            break;
+        case DECIMAL_LEADING_ZERO:
+            m_value.ident = CSS_VAL_DECIMAL_LEADING_ZERO;
+            break;
+        case LOWER_ROMAN:
+            m_value.ident = CSS_VAL_LOWER_ROMAN;
+            break;
+        case UPPER_ROMAN:
+            m_value.ident = CSS_VAL_UPPER_ROMAN;
+            break;
+        case LOWER_GREEK:
+            m_value.ident = CSS_VAL_LOWER_GREEK;
+            break;
+        case LOWER_ALPHA:
+            m_value.ident = CSS_VAL_LOWER_ALPHA;
+            break;
+        case LOWER_LATIN:
+            m_value.ident = CSS_VAL_LOWER_LATIN;
+            break;
+        case UPPER_ALPHA:
+            m_value.ident = CSS_VAL_UPPER_ALPHA;
+            break;
+        case UPPER_LATIN:
+            m_value.ident = CSS_VAL_UPPER_LATIN;
+            break;
+        case HEBREW:
+            m_value.ident = CSS_VAL_HEBREW;
+            break;
+        case ARMENIAN:
+            m_value.ident = CSS_VAL_ARMENIAN;
+            break;
+        case GEORGIAN:
+            m_value.ident = CSS_VAL_GEORGIAN;
+            break;
+        case CJK_IDEOGRAPHIC:
+            m_value.ident = CSS_VAL_CJK_IDEOGRAPHIC;
+            break;
+        case HIRAGANA:
+            m_value.ident = CSS_VAL_HIRAGANA;
+            break;
+        case KATAKANA:
+            m_value.ident = CSS_VAL_KATAKANA;
+            break;
+        case HIRAGANA_IROHA:
+            m_value.ident = CSS_VAL_HIRAGANA_IROHA;
+            break;
+        case KATAKANA_IROHA:
+            m_value.ident = CSS_VAL_KATAKANA_IROHA;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EListStyleType() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NONE:
+            return LNONE;
+        default:
+            return EListStyleType(m_value.ident - CSS_VAL_DISC);
+    }
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarginCollapse e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case MCOLLAPSE:
+            m_value.ident = CSS_VAL_COLLAPSE;
+            break;
+        case MSEPARATE:
+            m_value.ident = CSS_VAL_SEPARATE;
+            break;
+        case MDISCARD:
+            m_value.ident = CSS_VAL_DISCARD;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EMarginCollapse() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_COLLAPSE:
+            return MCOLLAPSE;
+        case CSS_VAL_SEPARATE:
+            return MSEPARATE;
+        case CSS_VAL_DISCARD:
+            return MDISCARD;
+    }
+    ASSERT_NOT_REACHED();
+    return MCOLLAPSE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeBehavior e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case MNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case MSCROLL:
+            m_value.ident = CSS_VAL_SCROLL;
+            break;
+        case MSLIDE:
+            m_value.ident = CSS_VAL_SLIDE;
+            break;
+        case MALTERNATE:
+            m_value.ident = CSS_VAL_ALTERNATE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EMarqueeBehavior() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NONE:
+            return MNONE;
+        case CSS_VAL_SCROLL:
+            return MSCROLL;
+        case CSS_VAL_SLIDE:
+            return MSLIDE;
+        case CSS_VAL_ALTERNATE:
+            return MALTERNATE;
+    }
+    ASSERT_NOT_REACHED();
+    return MNONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMarqueeDirection e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case MFORWARD:
+            m_value.ident = CSS_VAL_FORWARDS;
+            break;
+        case MBACKWARD:
+            m_value.ident = CSS_VAL_BACKWARDS;
+            break;
+        case MAUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case MUP:
+            m_value.ident = CSS_VAL_UP;
+            break;
+        case MDOWN:
+            m_value.ident = CSS_VAL_DOWN;
+            break;
+        case MLEFT:
+            m_value.ident = CSS_VAL_LEFT;
+            break;
+        case MRIGHT:
+            m_value.ident = CSS_VAL_RIGHT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_FORWARDS:
+            return MFORWARD;
+        case CSS_VAL_BACKWARDS:
+            return MBACKWARD;
+        case CSS_VAL_AUTO:
+            return MAUTO;
+        case CSS_VAL_AHEAD:
+        case CSS_VAL_UP: // We don't support vertical languages, so AHEAD just maps to UP.
+            return MUP;
+        case CSS_VAL_REVERSE:
+        case CSS_VAL_DOWN: // REVERSE just maps to DOWN, since we don't do vertical text.
+            return MDOWN;
+        case CSS_VAL_LEFT:
+            return MLEFT;
+        case CSS_VAL_RIGHT:
+            return MRIGHT;
+    }
+    ASSERT_NOT_REACHED();
+    return MAUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case BCNORMAL:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case MATCH:
+            m_value.ident = CSS_VAL_MATCH;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NORMAL:
+            return BCNORMAL;
+        case CSS_VAL_MATCH:
+            return MATCH;
+    }
+    ASSERT_NOT_REACHED();
+    return BCNORMAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case NBNORMAL:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case SPACE:
+            m_value.ident = CSS_VAL_SPACE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ENBSPMode() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_SPACE:
+            return SPACE;
+        case CSS_VAL_NORMAL:
+            return NBNORMAL;
+    }
+    ASSERT_NOT_REACHED();
+    return NBNORMAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflow e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case OVISIBLE:
+            m_value.ident = CSS_VAL_VISIBLE;
+            break;
+        case OHIDDEN:
+            m_value.ident = CSS_VAL_HIDDEN;
+            break;
+        case OSCROLL:
+            m_value.ident = CSS_VAL_SCROLL;
+            break;
+        case OAUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case OMARQUEE:
+            m_value.ident = CSS_VAL__WEBKIT_MARQUEE;
+            break;
+        case OOVERLAY:
+            m_value.ident = CSS_VAL_OVERLAY;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EOverflow() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_VISIBLE:
+            return OVISIBLE;
+        case CSS_VAL_HIDDEN:
+            return OHIDDEN;
+        case CSS_VAL_SCROLL:
+            return OSCROLL;
+        case CSS_VAL_AUTO:
+            return OAUTO;
+        case CSS_VAL__WEBKIT_MARQUEE:
+            return OMARQUEE;
+        case CSS_VAL_OVERLAY:
+            return OOVERLAY;
+    }
+    ASSERT_NOT_REACHED();
+    return OVISIBLE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPageBreak e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case PBAUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case PBALWAYS:
+            m_value.ident = CSS_VAL_ALWAYS;
+            break;
+        case PBAVOID:
+            m_value.ident = CSS_VAL_AVOID;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EPageBreak() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return PBAUTO;
+        case CSS_VAL_LEFT:
+        case CSS_VAL_RIGHT:
+        case CSS_VAL_ALWAYS:
+            return PBALWAYS; // CSS2.1: "Conforming user agents may map left/right to always."
+        case CSS_VAL_AVOID:
+            return PBAVOID;
+    }
+    ASSERT_NOT_REACHED();
+    return PBAUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case StaticPosition:
+            m_value.ident = CSS_VAL_STATIC;
+            break;
+        case RelativePosition:
+            m_value.ident = CSS_VAL_RELATIVE;
+            break;
+        case AbsolutePosition:
+            m_value.ident = CSS_VAL_ABSOLUTE;
+            break;
+        case FixedPosition:
+            m_value.ident = CSS_VAL_FIXED;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EPosition() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_STATIC:
+            return StaticPosition;
+        case CSS_VAL_RELATIVE:
+            return RelativePosition;
+        case CSS_VAL_ABSOLUTE:
+            return AbsolutePosition;
+        case CSS_VAL_FIXED:
+            return FixedPosition;
+    }
+    ASSERT_NOT_REACHED();
+    return StaticPosition;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EResize e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case RESIZE_BOTH:
+            m_value.ident = CSS_VAL_BOTH;
+            break;
+        case RESIZE_HORIZONTAL:
+            m_value.ident = CSS_VAL_HORIZONTAL;
+            break;
+        case RESIZE_VERTICAL:
+            m_value.ident = CSS_VAL_VERTICAL;
+            break;
+        case RESIZE_NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EResize() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_BOTH:
+            return RESIZE_BOTH;
+        case CSS_VAL_HORIZONTAL:
+            return RESIZE_HORIZONTAL;
+        case CSS_VAL_VERTICAL:
+            return RESIZE_VERTICAL;
+        case CSS_VAL_AUTO:
+            ASSERT_NOT_REACHED(); // Depends on settings, thus should be handled by the caller.
+            return RESIZE_NONE;
+        case CSS_VAL_NONE:
+            return RESIZE_NONE;
+    }
+    ASSERT_NOT_REACHED();
+    return RESIZE_NONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETableLayout e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case TAUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case TFIXED:
+            m_value.ident = CSS_VAL_FIXED;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETableLayout() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_FIXED:
+            return TFIXED;
+        case CSS_VAL_AUTO:
+            return TAUTO;
+    }
+    ASSERT_NOT_REACHED();
+    return TAUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case TAAUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case LEFT:
+            m_value.ident = CSS_VAL_LEFT;
+            break;
+        case RIGHT:
+            m_value.ident = CSS_VAL_RIGHT;
+            break;
+        case CENTER:
+            m_value.ident = CSS_VAL_CENTER;
+            break;
+        case JUSTIFY:
+            m_value.ident = CSS_VAL_JUSTIFY;
+            break;
+        case WEBKIT_LEFT:
+            m_value.ident = CSS_VAL__WEBKIT_LEFT;
+            break;
+        case WEBKIT_RIGHT:
+            m_value.ident = CSS_VAL__WEBKIT_RIGHT;
+            break;
+        case WEBKIT_CENTER:
+            m_value.ident = CSS_VAL__WEBKIT_CENTER;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETextAlign() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_START:
+        case CSS_VAL_END:
+            ASSERT_NOT_REACHED(); // Depends on direction, thus should be handled by the caller.
+            return LEFT;
+        default:
+            return (ETextAlign)(m_value.ident - CSS_VAL__WEBKIT_AUTO);
+    }
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case TSNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case TSDISC:
+            m_value.ident = CSS_VAL_DISC;
+            break;
+        case TSCIRCLE:
+            m_value.ident = CSS_VAL_CIRCLE;
+            break;
+        case TSSQUARE:
+            m_value.ident = CSS_VAL_SQUARE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETextSecurity() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NONE:
+            return TSNONE;
+        case CSS_VAL_DISC:
+            return TSDISC;
+        case CSS_VAL_CIRCLE:
+            return TSCIRCLE;
+        case CSS_VAL_SQUARE:
+            return TSSQUARE;
+    }
+    ASSERT_NOT_REACHED();
+    return TSNONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextTransform e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CAPITALIZE:
+            m_value.ident = CSS_VAL_CAPITALIZE;
+            break;
+        case UPPERCASE:
+            m_value.ident = CSS_VAL_UPPERCASE;
+            break;
+        case LOWERCASE:
+            m_value.ident = CSS_VAL_LOWERCASE;
+            break;
+        case TTNONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETextTransform() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_CAPITALIZE:
+            return CAPITALIZE;
+        case CSS_VAL_UPPERCASE:
+            return UPPERCASE;
+        case CSS_VAL_LOWERCASE:
+            return LOWERCASE;
+        case CSS_VAL_NONE:
+            return TTNONE;
+    }
+    ASSERT_NOT_REACHED();
+    return TTNONE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case UBNormal:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case Embed:
+            m_value.ident = CSS_VAL_EMBED;
+            break;
+        case Override:
+            m_value.ident = CSS_VAL_BIDI_OVERRIDE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NORMAL:
+            return UBNormal; 
+        case CSS_VAL_EMBED:
+            return Embed; 
+        case CSS_VAL_BIDI_OVERRIDE:
+            return Override;
+    }
+    ASSERT_NOT_REACHED();
+    return UBNormal;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserDrag e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case DRAG_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case DRAG_NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case DRAG_ELEMENT:
+            m_value.ident = CSS_VAL_ELEMENT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EUserDrag() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return DRAG_AUTO;
+        case CSS_VAL_NONE:
+            return DRAG_NONE;
+        case CSS_VAL_ELEMENT:
+            return DRAG_ELEMENT;
+    }
+    ASSERT_NOT_REACHED();
+    return DRAG_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserModify e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case READ_ONLY:
+            m_value.ident = CSS_VAL_READ_ONLY;
+            break;
+        case READ_WRITE:
+            m_value.ident = CSS_VAL_READ_WRITE;
+            break;
+        case READ_WRITE_PLAINTEXT_ONLY:
+            m_value.ident = CSS_VAL_READ_WRITE_PLAINTEXT_ONLY;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EUserModify() const
+{
+    return EUserModify(m_value.ident - CSS_VAL_READ_ONLY);
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case SELECT_NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case SELECT_TEXT:
+            m_value.ident = CSS_VAL_TEXT;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EUserSelect() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return SELECT_TEXT;
+        case CSS_VAL_NONE:
+            return SELECT_NONE;
+        case CSS_VAL_TEXT:
+            return SELECT_TEXT;
+    }
+    ASSERT_NOT_REACHED();
+    return SELECT_TEXT;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case VISIBLE:
+            m_value.ident = CSS_VAL_VISIBLE;
+            break;
+        case HIDDEN:
+            m_value.ident = CSS_VAL_HIDDEN;
+            break;
+        case COLLAPSE:
+            m_value.ident = CSS_VAL_COLLAPSE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EVisibility() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_HIDDEN:
+            return HIDDEN;
+        case CSS_VAL_VISIBLE:
+            return VISIBLE;
+        case CSS_VAL_COLLAPSE:
+            return COLLAPSE;
+    }
+    ASSERT_NOT_REACHED();
+    return VISIBLE;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWhiteSpace e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case NORMAL:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case PRE:
+            m_value.ident = CSS_VAL_PRE;
+            break;
+        case PRE_WRAP:
+            m_value.ident = CSS_VAL_PRE_WRAP;
+            break;
+        case PRE_LINE:
+            m_value.ident = CSS_VAL_PRE_LINE;
+            break;
+        case NOWRAP:
+            m_value.ident = CSS_VAL_NOWRAP;
+            break;
+        case KHTML_NOWRAP:
+            m_value.ident = CSS_VAL__WEBKIT_NOWRAP;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EWhiteSpace() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL__WEBKIT_NOWRAP:
+            return KHTML_NOWRAP;
+        case CSS_VAL_NOWRAP:
+            return NOWRAP;
+        case CSS_VAL_PRE:
+            return PRE;
+        case CSS_VAL_PRE_WRAP:
+            return PRE_WRAP;
+        case CSS_VAL_PRE_LINE:
+            return PRE_LINE;
+        case CSS_VAL_NORMAL:
+            return NORMAL;
+    }
+    ASSERT_NOT_REACHED();
+    return NORMAL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordBreak e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case NormalWordBreak:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case BreakAllWordBreak:
+            m_value.ident = CSS_VAL_BREAK_ALL;
+            break;
+        case BreakWordBreak:
+            m_value.ident = CSS_VAL_BREAK_WORD;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EWordBreak() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_BREAK_ALL:
+            return BreakAllWordBreak;
+        case CSS_VAL_BREAK_WORD:
+            return BreakWordBreak;
+        case CSS_VAL_NORMAL:
+            return NormalWordBreak;
+    }
+    ASSERT_NOT_REACHED();
+    return NormalWordBreak;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordWrap e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case NormalWordWrap:
+            m_value.ident = CSS_VAL_NORMAL;
+            break;
+        case BreakWordWrap:
+            m_value.ident = CSS_VAL_BREAK_WORD;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EWordWrap() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_BREAK_WORD:
+            return BreakWordWrap;
+        case CSS_VAL_NORMAL:
+            return NormalWordWrap;
+    }
+    ASSERT_NOT_REACHED();
+    return NormalWordWrap;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case ButtCap:
+            m_value.ident = CSS_VAL_BUTT;
+            break;
+        case RoundCap:
+            m_value.ident = CSS_VAL_ROUND;
+            break;
+        case SquareCap:
+            m_value.ident = CSS_VAL_SQUARE;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator LineCap() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_BUTT:
+            return ButtCap;
+        case CSS_VAL_ROUND:
+            return RoundCap;
+        case CSS_VAL_SQUARE:
+            return SquareCap;
+    }
+    ASSERT_NOT_REACHED();
+    return ButtCap;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineJoin e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case MiterJoin:
+            m_value.ident = CSS_VAL_MITER;
+            break;
+        case RoundJoin:
+            m_value.ident = CSS_VAL_ROUND;
+            break;
+        case BevelJoin:
+            m_value.ident = CSS_VAL_BEVEL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator LineJoin() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_MITER:
+            return MiterJoin;
+        case CSS_VAL_ROUND:
+            return RoundJoin;
+        case CSS_VAL_BEVEL:
+            return BevelJoin;
+    }
+    ASSERT_NOT_REACHED();
+    return MiterJoin;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case LTR:
+            m_value.ident = CSS_VAL_LTR;
+            break;
+        case RTL:
+            m_value.ident = CSS_VAL_RTL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator TextDirection() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_LTR:
+            return LTR;
+        case CSS_VAL_RTL:
+            return RTL;
+    }
+    ASSERT_NOT_REACHED();
+    return LTR;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WindRule e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case RULE_NONZERO:
+            m_value.ident = CSS_VAL_NONZERO;
+            break;
+        case RULE_EVENODD:
+            m_value.ident = CSS_VAL_EVENODD;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator WindRule() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_NONZERO:
+            return RULE_NONZERO;
+        case CSS_VAL_EVENODD:
+            return RULE_EVENODD;
+    }
+    ASSERT_NOT_REACHED();
+    return RULE_NONZERO;
+}
+
+#if ENABLE(SVG)
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignmentBaseline e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case AB_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case AB_BASELINE:
+            m_value.ident = CSS_VAL_BASELINE;
+            break;
+        case AB_BEFORE_EDGE:
+            m_value.ident = CSS_VAL_BEFORE_EDGE;
+            break;
+        case AB_TEXT_BEFORE_EDGE:
+            m_value.ident = CSS_VAL_TEXT_BEFORE_EDGE;
+            break;
+        case AB_MIDDLE:
+            m_value.ident = CSS_VAL_MIDDLE;
+            break;
+        case AB_CENTRAL:
+            m_value.ident = CSS_VAL_CENTRAL;
+            break;
+        case AB_AFTER_EDGE:
+            m_value.ident = CSS_VAL_AFTER_EDGE;
+            break;
+        case AB_TEXT_AFTER_EDGE:
+            m_value.ident = CSS_VAL_TEXT_AFTER_EDGE;
+            break;
+        case AB_IDEOGRAPHIC:
+            m_value.ident = CSS_VAL_IDEOGRAPHIC;
+            break;
+        case AB_ALPHABETIC:
+            m_value.ident = CSS_VAL_ALPHABETIC;
+            break;
+        case AB_HANGING:
+            m_value.ident = CSS_VAL_HANGING;
+            break;
+        case AB_MATHEMATICAL:
+            m_value.ident = CSS_VAL_MATHEMATICAL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return AB_AUTO;
+        case CSS_VAL_BASELINE:
+            return AB_BASELINE;
+        case CSS_VAL_BEFORE_EDGE:
+            return AB_BEFORE_EDGE;
+        case CSS_VAL_TEXT_BEFORE_EDGE:
+            return AB_TEXT_BEFORE_EDGE;
+        case CSS_VAL_MIDDLE:
+            return AB_MIDDLE;
+        case CSS_VAL_CENTRAL:
+            return AB_CENTRAL;
+        case CSS_VAL_AFTER_EDGE:
+            return AB_AFTER_EDGE;
+        case CSS_VAL_TEXT_AFTER_EDGE:
+            return AB_TEXT_AFTER_EDGE;
+        case CSS_VAL_IDEOGRAPHIC:
+            return AB_IDEOGRAPHIC;
+        case CSS_VAL_ALPHABETIC:
+            return AB_ALPHABETIC;
+        case CSS_VAL_HANGING:
+            return AB_HANGING;
+        case CSS_VAL_MATHEMATICAL:
+            return AB_MATHEMATICAL;
+    }
+    ASSERT_NOT_REACHED();
+    return AB_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CI_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case CI_SRGB:
+            m_value.ident = CSS_VAL_SRGB;
+            break;
+        case CI_LINEARRGB:
+            m_value.ident = CSS_VAL_LINEARRGB;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EColorInterpolation() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_SRGB:
+            return CI_SRGB;
+        case CSS_VAL_LINEARRGB:
+            return CI_LINEARRGB;
+        case CSS_VAL_AUTO:
+            return CI_AUTO;
+    }
+    ASSERT_NOT_REACHED();
+    return CI_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorRendering e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case CR_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case CR_OPTIMIZESPEED:
+            m_value.ident = CSS_VAL_OPTIMIZESPEED;
+            break;
+        case CR_OPTIMIZEQUALITY:
+            m_value.ident = CSS_VAL_OPTIMIZEQUALITY;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EColorRendering() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_OPTIMIZESPEED:
+            return CR_OPTIMIZESPEED;
+        case CSS_VAL_OPTIMIZEQUALITY:
+            return CR_OPTIMIZEQUALITY;
+        case CSS_VAL_AUTO:
+            return CR_AUTO;
+    }
+    ASSERT_NOT_REACHED();
+    return CR_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDominantBaseline e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case DB_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case DB_USE_SCRIPT:
+            m_value.ident = CSS_VAL_USE_SCRIPT;
+            break;
+        case DB_NO_CHANGE:
+            m_value.ident = CSS_VAL_NO_CHANGE;
+            break;
+        case DB_RESET_SIZE:
+            m_value.ident = CSS_VAL_RESET_SIZE;
+            break;
+        case DB_CENTRAL:
+            m_value.ident = CSS_VAL_CENTRAL;
+            break;
+        case DB_MIDDLE:
+            m_value.ident = CSS_VAL_MIDDLE;
+            break;
+        case DB_TEXT_BEFORE_EDGE:
+            m_value.ident = CSS_VAL_TEXT_BEFORE_EDGE;
+            break;
+        case DB_TEXT_AFTER_EDGE:
+            m_value.ident = CSS_VAL_TEXT_AFTER_EDGE;
+            break;
+        case DB_IDEOGRAPHIC:
+            m_value.ident = CSS_VAL_IDEOGRAPHIC;
+            break;
+        case DB_ALPHABETIC:
+            m_value.ident = CSS_VAL_ALPHABETIC;
+            break;
+        case DB_HANGING:
+            m_value.ident = CSS_VAL_HANGING;
+            break;
+        case DB_MATHEMATICAL:
+            m_value.ident = CSS_VAL_MATHEMATICAL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EDominantBaseline() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return DB_AUTO;
+        case CSS_VAL_USE_SCRIPT:
+            return DB_USE_SCRIPT;
+        case CSS_VAL_NO_CHANGE:
+            return DB_NO_CHANGE;
+        case CSS_VAL_RESET_SIZE:
+            return DB_RESET_SIZE;
+        case CSS_VAL_IDEOGRAPHIC:
+            return DB_IDEOGRAPHIC;
+        case CSS_VAL_ALPHABETIC:
+            return DB_ALPHABETIC;
+        case CSS_VAL_HANGING:
+            return DB_HANGING;
+        case CSS_VAL_MATHEMATICAL:
+            return DB_MATHEMATICAL;
+        case CSS_VAL_CENTRAL:
+            return DB_CENTRAL;
+        case CSS_VAL_MIDDLE:
+            return DB_MIDDLE;
+        case CSS_VAL_TEXT_AFTER_EDGE:
+            return DB_TEXT_AFTER_EDGE;
+        case CSS_VAL_TEXT_BEFORE_EDGE:
+            return DB_TEXT_BEFORE_EDGE;
+    }
+    ASSERT_NOT_REACHED();
+    return DB_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case IR_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case IR_OPTIMIZESPEED:
+            m_value.ident = CSS_VAL_OPTIMIZESPEED;
+            break;
+        case IR_OPTIMIZEQUALITY:
+            m_value.ident = CSS_VAL_OPTIMIZEQUALITY;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EImageRendering() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return IR_AUTO;
+        case CSS_VAL_OPTIMIZESPEED:
+            return IR_OPTIMIZESPEED;
+        case CSS_VAL_OPTIMIZEQUALITY:
+            return IR_OPTIMIZEQUALITY;
+    }
+    ASSERT_NOT_REACHED();
+    return IR_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPointerEvents e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case PE_NONE:
+            m_value.ident = CSS_VAL_NONE;
+            break;
+        case PE_STROKE:
+            m_value.ident = CSS_VAL_STROKE;
+            break;
+        case PE_FILL:
+            m_value.ident = CSS_VAL_FILL;
+            break;
+        case PE_PAINTED:
+            m_value.ident = CSS_VAL_PAINTED;
+            break;
+        case PE_VISIBLE:
+            m_value.ident = CSS_VAL_VISIBLE;
+            break;
+        case PE_VISIBLE_STROKE:
+            m_value.ident = CSS_VAL_VISIBLESTROKE;
+            break;
+        case PE_VISIBLE_FILL:
+            m_value.ident = CSS_VAL_VISIBLEFILL;
+            break;
+        case PE_VISIBLE_PAINTED:
+            m_value.ident = CSS_VAL_VISIBLEPAINTED;
+            break;
+        case PE_ALL:
+            m_value.ident = CSS_VAL_ALL;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EPointerEvents() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_ALL:
+            return PE_ALL;
+        case CSS_VAL_NONE:
+            return PE_NONE;
+        case CSS_VAL_VISIBLEPAINTED:
+            return PE_VISIBLE_PAINTED;
+        case CSS_VAL_VISIBLEFILL:
+            return PE_VISIBLE_FILL;
+        case CSS_VAL_VISIBLESTROKE:
+            return PE_VISIBLE_STROKE;
+        case CSS_VAL_VISIBLE:
+            return PE_VISIBLE;
+        case CSS_VAL_PAINTED:
+            return PE_PAINTED;
+        case CSS_VAL_FILL:
+            return PE_FILL;
+        case CSS_VAL_STROKE:
+            return PE_STROKE;
+    }
+    ASSERT_NOT_REACHED();
+    return PE_ALL;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case IR_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case IR_OPTIMIZESPEED:
+            m_value.ident = CSS_VAL_OPTIMIZESPEED;
+            break;
+        case SR_CRISPEDGES:
+            m_value.ident = CSS_VAL_CRISPEDGES;
+            break;
+        case SR_GEOMETRICPRECISION:
+            m_value.ident = CSS_VAL_GEOMETRICPRECISION;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EShapeRendering() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return SR_AUTO;
+        case CSS_VAL_OPTIMIZESPEED:
+            return SR_OPTIMIZESPEED;
+        case CSS_VAL_CRISPEDGES:
+            return SR_CRISPEDGES;
+        case CSS_VAL_GEOMETRICPRECISION:
+            return SR_GEOMETRICPRECISION;
+    }
+    ASSERT_NOT_REACHED();
+    return SR_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAnchor e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case TA_START:
+            m_value.ident = CSS_VAL_START;
+            break;
+        case TA_MIDDLE:
+            m_value.ident = CSS_VAL_MIDDLE;
+            break;
+        case TA_END:
+            m_value.ident = CSS_VAL_END;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETextAnchor() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_START:
+            return TA_START;
+        case CSS_VAL_MIDDLE:
+            return TA_MIDDLE;
+        case CSS_VAL_END:
+            return TA_END;
+    }
+    ASSERT_NOT_REACHED();
+    return TA_START;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextRendering e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case TR_AUTO:
+            m_value.ident = CSS_VAL_AUTO;
+            break;
+        case TR_OPTIMIZESPEED:
+            m_value.ident = CSS_VAL_OPTIMIZESPEED;
+            break;
+        case TR_OPTIMIZELEGIBILITY:
+            m_value.ident = CSS_VAL_OPTIMIZELEGIBILITY;
+            break;
+        case TR_GEOMETRICPRECISION:
+            m_value.ident = CSS_VAL_GEOMETRICPRECISION;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ETextRendering() const
+{
+    switch (m_value.ident) {
+        case CSS_VAL_AUTO:
+            return TR_AUTO;
+        case CSS_VAL_OPTIMIZESPEED:
+            return TR_OPTIMIZESPEED;
+        case CSS_VAL_OPTIMIZELEGIBILITY:
+            return TR_OPTIMIZELEGIBILITY;
+        case CSS_VAL_GEOMETRICPRECISION:
+            return TR_GEOMETRICPRECISION;
+    }
+    ASSERT_NOT_REACHED();
+    return TR_AUTO;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWritingMode e)
+    : m_type(CSS_IDENT)
+{
+    switch (e) {
+        case WM_LRTB:
+            m_value.ident = CSS_VAL_LR_TB;
+            break;
+        case WM_LR:
+            m_value.ident = CSS_VAL_LR;
+            break;
+        case WM_RLTB:
+            m_value.ident = CSS_VAL_RL_TB;
+            break;
+        case WM_RL:
+            m_value.ident = CSS_VAL_RL;
+            break;
+        case WM_TBRL:
+            m_value.ident = CSS_VAL_TB_RL;
+            break;
+        case WM_TB:
+            m_value.ident = CSS_VAL_TB;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EWritingMode() const
+{
+    return (EWritingMode)(m_value.ident - CSS_VAL_LR_TB);
+}
+
+#endif
+
+}
+
+#endif
index 34561f74ad9341bbf73f2c297e2f5c0b25c4ca02..101f14bd0795822623f122100f7837c8c44b1600 100644 (file)
@@ -5,6 +5,7 @@
  *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
  *           (C) 2006 Nicholas Shanks (webkit@nickshanks.com)
  * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "CSSImageValue.h"
 #include "CSSImportRule.h"
 #include "CSSMediaRule.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSProperty.h"
 #include "CSSPropertyNames.h"
 #include "CSSRuleList.h"
 #include "CSSSelector.h"
 #include "CSSStyleRule.h"
 #include "CSSStyleSheet.h"
-#include "CSSValueKeywords.h"
 #include "CSSValueList.h"
 #include "CachedImage.h"
 #include "Counter.h"
@@ -1205,7 +1206,7 @@ bool CSSStyleSelector::checkSelector(CSSSelector* sel)
 
     // Check the selector
     SelectorMatch match = checkSelector(sel, element, true, false);
-    if(match != SelectorMatches) return false;
+    if (match != SelectorMatches) return false;
 
     if (pseudoStyle != RenderStyle::NOPSEUDO && pseudoStyle != dynamicPseudo)
         return false;
@@ -1236,10 +1237,9 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel
         if (pseudoStyle != RenderStyle::NOPSEUDO && pseudoStyle != dynamicPseudo)
             return SelectorFailsCompletely;
 
-    switch(relation) {
+    switch (relation) {
         case CSSSelector::Descendant:
-            while(true)
-            {
+            while (true) {
                 Node* n = e->parentNode();
                 if (!n || !n->isElementNode())
                     return SelectorFailsCompletely;
@@ -1268,10 +1268,9 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel
             return checkSelector(sel, e, false, false); 
         }
         case CSSSelector::IndirectAdjacent:
-            while(true)
-            {
+            while (true) {
                 Node* n = e->previousSibling();
-                while(n && !n->isElementNode())
+                while (n && !n->isElementNode())
                     n = n->previousSibling();
                 if (!n)
                     return SelectorFailsLocally;
@@ -1293,7 +1292,7 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel
 
 bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAncestor, bool isSubSelector)
 {
-    if(!e)
+    if (!e)
         return false;
 
     if (sel->hasTag()) {
@@ -1327,7 +1326,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAnc
         if (value.isNull())
             return false; // attribute is not set
 
-        switch(sel->m_match) {
+        switch (sel->m_match) {
         case CSSSelector::Exact:
             if ((isXMLDoc && sel->m_value != value) || (!isXMLDoc && !equalIgnoringCase(sel->m_value, value)))
                 return false;
@@ -1381,7 +1380,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAnc
             break;
         }
     }
-    if(sel->m_match == CSSSelector::PseudoClass) 
+    if (sel->m_match == CSSSelector::PseudoClass) 
     {
         switch (sel->pseudoType()) {
             // Pseudo classes:
@@ -1661,12 +1660,12 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet,  MediaQueryEvaluator* m
             for (CSSSelector* s = rule->selector(); s; s = s->next())
                 addRule(rule, s);
         }
-        else if(item->isImportRule()) {
+        else if (item->isImportRule()) {
             CSSImportRule* import = static_cast<CSSImportRule*>(item);
             if (!import->media() || medium->eval(import->media()))
                 addRulesFromSheet(import->styleSheet(), medium, styleSelector);
         }
-        else if(item->isMediaRule()) {
+        else if (item->isMediaRule()) {
             CSSMediaRule* r = static_cast<CSSMediaRule*>(item);
             CSSRuleList* rules = r->cssRules();
 
@@ -1705,11 +1704,11 @@ static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *st
             *ok = false;
     } else {
         int type = primitiveValue->primitiveType();
-        if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+        if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
-        else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
             l = Length(primitiveValue->getDoubleValue(), Percent);
-        else if(type == CSSPrimitiveValue::CSS_NUMBER)
+        else if (type == CSSPrimitiveValue::CSS_NUMBER)
             l = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
         else if (ok)
             *ok = false;
@@ -1729,7 +1728,7 @@ void CSSStyleSelector::applyDeclarations(bool applyFirst, bool isImportant,
             // give special priority to font-xxx, color properties
             if (isImportant == current.isImportant()) {
                 bool first;
-                switch(current.id()) {
+                switch (current.id()) {
                     case CSS_PROP_LINE_HEIGHT:
                         m_lineHeightValue = current.value();
                         first = !applyFirst; // we apply line-height later
@@ -1794,8 +1793,9 @@ static void applyCounterList(RenderStyle* style, CSSValueList* list, bool isRese
 
 void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 {
-    CSSPrimitiveValue *primitiveValue = 0;
-    if(value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+    CSSPrimitiveValue* primitiveValue = 0;
+    if (value->isPrimitiveValue())
+        primitiveValue = static_cast<CSSPrimitiveValue*>(value);
 
     Length l;
     bool apply = false;
@@ -1814,8 +1814,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     // What follows is a list that maps the CSS properties into their corresponding front-end
     // RenderStyle values.  Shorthands (e.g. border, background) occur in this list as well and
     // are only hit when mapping "inherit" or "initial" into front-end values.
-    switch (static_cast<CSSPropertyID>(id))
-    {
+    switch (static_cast<CSSPropertyID>(id)) {
 // ident only properties
     case CSS_PROP_BACKGROUND_ATTACHMENT:
         HANDLE_BACKGROUND_VALUE(backgroundAttachment, BackgroundAttachment, value)
@@ -1837,142 +1836,90 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
     case CSS_PROP_BORDER_COLLAPSE:
         HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
-        if(!primitiveValue) return;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_COLLAPSE:
-            style->setBorderCollapse(true);
-            break;
-        case CSS_VAL_SEPARATE:
-            style->setBorderCollapse(false);
-            break;
-        default:
+        if (!primitiveValue)
             return;
+        switch (primitiveValue->getIdent()) {
+            case CSS_VAL_COLLAPSE:
+                style->setBorderCollapse(true);
+                break;
+            case CSS_VAL_SEPARATE:
+                style->setBorderCollapse(false);
+                break;
+            default:
+                return;
         }
         return;
         
     case CSS_PROP_BORDER_TOP_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderTopStyle, BorderTopStyle, BorderStyle)
-        if (!primitiveValue) return;
-        style->setBorderTopStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        if (primitiveValue)
+            style->setBorderTopStyle(*primitiveValue);
         return;
     case CSS_PROP_BORDER_RIGHT_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderRightStyle, BorderRightStyle, BorderStyle)
-        if (!primitiveValue) return;
-        style->setBorderRightStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        if (primitiveValue)
+            style->setBorderRightStyle(*primitiveValue);
         return;
     case CSS_PROP_BORDER_BOTTOM_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderBottomStyle, BorderBottomStyle, BorderStyle)
-        if (!primitiveValue) return;
-        style->setBorderBottomStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        if (primitiveValue)
+            style->setBorderBottomStyle(*primitiveValue);
         return;
     case CSS_PROP_BORDER_LEFT_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderLeftStyle, BorderLeftStyle, BorderStyle)
-        if (!primitiveValue) return;
-        style->setBorderLeftStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        if (primitiveValue)
+            style->setBorderLeftStyle(*primitiveValue);
         return;
     case CSS_PROP_OUTLINE_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(outlineStyle, OutlineStyle, BorderStyle)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent() == CSS_VAL_AUTO)
-            style->setOutlineStyle(DOTTED, true);
-        else
-            style->setOutlineStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        if (primitiveValue) {
+            if (primitiveValue->getIdent() == CSS_VAL_AUTO)
+                style->setOutlineStyle(DOTTED, true);
+            else
+                style->setOutlineStyle(*primitiveValue);
+        }
         return;
     case CSS_PROP_CAPTION_SIDE:
     {
         HANDLE_INHERIT_AND_INITIAL(captionSide, CaptionSide)
-        if(!primitiveValue) return;
-        ECaptionSide c = RenderStyle::initialCaptionSide();
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_LEFT:
-            c = CAPLEFT; break;
-        case CSS_VAL_RIGHT:
-            c = CAPRIGHT; break;
-        case CSS_VAL_TOP:
-            c = CAPTOP; break;
-        case CSS_VAL_BOTTOM:
-            c = CAPBOTTOM; break;
-        default:
-            return;
-        }
-        style->setCaptionSide(c);
+        if (primitiveValue)
+            style->setCaptionSide(*primitiveValue);
         return;
     }
     case CSS_PROP_CLEAR:
     {
         HANDLE_INHERIT_AND_INITIAL(clear, Clear)
-        if(!primitiveValue) return;
-        EClear c;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_NONE:
-            c = CNONE; break;
-        case CSS_VAL_LEFT:
-            c = CLEFT; break;
-        case CSS_VAL_RIGHT:
-            c = CRIGHT; break;
-        case CSS_VAL_BOTH:
-            c = CBOTH; break;
-        default:
-            return;
-        }
-        style->setClear(c);
+        if (primitiveValue)
+            style->setClear(*primitiveValue);
         return;
     }
     case CSS_PROP_DIRECTION:
     {
         HANDLE_INHERIT_AND_INITIAL(direction, Direction)
-        if(!primitiveValue) break;
-        style->setDirection(primitiveValue->getIdent() == CSS_VAL_LTR ? LTR : RTL);
+        if (primitiveValue)
+            style->setDirection(*primitiveValue);
         return;
     }
     case CSS_PROP_DISPLAY:
     {
         HANDLE_INHERIT_AND_INITIAL(display, Display)
-        if(!primitiveValue) break;
-        int id = primitiveValue->getIdent();
-        EDisplay d;
-        if (id == CSS_VAL_NONE)
-            d = NONE;
-        else
-            d = EDisplay(primitiveValue->getIdent() - CSS_VAL_INLINE);
-
-        style->setDisplay(d);
+        if (primitiveValue)
+            style->setDisplay(*primitiveValue);
         return;
     }
 
     case CSS_PROP_EMPTY_CELLS:
     {
         HANDLE_INHERIT_AND_INITIAL(emptyCells, EmptyCells)
-        if (!primitiveValue) break;
-        int id = primitiveValue->getIdent();
-        if (id == CSS_VAL_SHOW)
-            style->setEmptyCells(SHOW);
-        else if (id == CSS_VAL_HIDE)
-            style->setEmptyCells(HIDE);
+        if (primitiveValue)
+            style->setEmptyCells(*primitiveValue);
         return;
     }
     case CSS_PROP_FLOAT:
     {
         HANDLE_INHERIT_AND_INITIAL(floating, Floating)
-        if(!primitiveValue) return;
-        EFloat f;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_LEFT:
-            f = FLEFT; break;
-        case CSS_VAL_RIGHT:
-            f = FRIGHT; break;
-        case CSS_VAL_NONE:
-        case CSS_VAL_CENTER:  //Non standart CSS-Value
-            f = FNONE; break;
-        default:
-            return;
-        }
-        
-        style->setFloating(f);
+        if (primitiveValue)
+            style->setFloating(*primitiveValue);
         return;
     }
 
@@ -1984,7 +1931,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         else if (isInitial)
             fontDescription.setItalic(false);
         else {
-            if (!primitiveValue) return;
+            if (!primitiveValue)
+                return;
             switch (primitiveValue->getIdent()) {
                 case CSS_VAL_OBLIQUE:
                 // FIXME: oblique is the same as italic for the moment...
@@ -2011,7 +1959,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         else if (isInitial)
             fontDescription.setSmallCaps(false);
         else {
-            if (!primitiveValue) return;
+            if (!primitiveValue)
+                return;
             int id = primitiveValue->getIdent();
             if (id == CSS_VAL_NORMAL)
                 fontDescription.setSmallCaps(false);
@@ -2033,7 +1982,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         else if (isInitial)
             fontDescription.setWeight(cNormalWeight);
         else {
-            if (!primitiveValue) return;
+            if (!primitiveValue)
+                return;
             if (primitiveValue->getIdent()) {
                 switch (primitiveValue->getIdent()) {
                     // FIXME: We aren't genuinely supporting specific weight values.
@@ -2071,27 +2021,16 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSS_PROP_LIST_STYLE_POSITION:
     {
         HANDLE_INHERIT_AND_INITIAL(listStylePosition, ListStylePosition)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent())
-            style->setListStylePosition((EListStylePosition) (primitiveValue->getIdent() - CSS_VAL_OUTSIDE));
+        if (primitiveValue)
+            style->setListStylePosition(*primitiveValue);
         return;
     }
 
     case CSS_PROP_LIST_STYLE_TYPE:
     {
         HANDLE_INHERIT_AND_INITIAL(listStyleType, ListStyleType)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent())
-        {
-            EListStyleType t;
-            int id = primitiveValue->getIdent();
-            if (id == CSS_VAL_NONE) { // important!!
-              t = LNONE;
-            } else {
-              t = EListStyleType(id - CSS_VAL_DISC);
-            }
-            style->setListStyleType(t);
-        }
+        if (primitiveValue)
+            style->setListStyleType(*primitiveValue);
         return;
     }
 
@@ -2109,23 +2048,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             return;
         }
             
-        EOverflow o;
-        switch(primitiveValue->getIdent()) {
-            case CSS_VAL_VISIBLE:
-                o = OVISIBLE; break;
-            case CSS_VAL_HIDDEN:
-                o = OHIDDEN; break;
-            case CSS_VAL_SCROLL:
-                o = OSCROLL; break;
-            case CSS_VAL_AUTO:
-                o = OAUTO; break;
-            case CSS_VAL__WEBKIT_MARQUEE:
-                o = OMARQUEE; break;
-            case CSS_VAL_OVERLAY:
-                o = OOVERLAY; break;
-            default:
-                return;
-        }
+        EOverflow o = *primitiveValue;
+
         style->setOverflowX(o);
         style->setOverflowY(o);
         return;
@@ -2134,228 +2058,82 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSS_PROP_OVERFLOW_X:
     {
         HANDLE_INHERIT_AND_INITIAL(overflowX, OverflowX)
-        EOverflow o;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_VISIBLE:
-            o = OVISIBLE; break;
-        case CSS_VAL_HIDDEN:
-            o = OHIDDEN; break;
-        case CSS_VAL_SCROLL:
-            o = OSCROLL; break;
-        case CSS_VAL_AUTO:
-            o = OAUTO; break;
-        case CSS_VAL__WEBKIT_MARQUEE:
-            o = OMARQUEE; break;
-        case CSS_VAL_OVERLAY:
-            o = OOVERLAY; break;
-        default:
-            return;
-        }
-        style->setOverflowX(o);
+        style->setOverflowX(*primitiveValue);
         return;
     }
 
     case CSS_PROP_OVERFLOW_Y:
     {
         HANDLE_INHERIT_AND_INITIAL(overflowY, OverflowY)
-        EOverflow o;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_VISIBLE:
-            o = OVISIBLE; break;
-        case CSS_VAL_HIDDEN:
-            o = OHIDDEN; break;
-        case CSS_VAL_SCROLL:
-            o = OSCROLL; break;
-        case CSS_VAL_AUTO:
-            o = OAUTO; break;
-        case CSS_VAL__WEBKIT_MARQUEE:
-            o = OMARQUEE; break;
-        case CSS_VAL_OVERLAY:
-            o = OOVERLAY; break;
-        default:
-            return;
-        }
-        style->setOverflowY(o);
+        style->setOverflowY(*primitiveValue);
         return;
     }
 
     case CSS_PROP_PAGE_BREAK_BEFORE:
     {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakBefore, PageBreakBefore, PageBreak)
-        if (!primitiveValue) return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setPageBreakBefore(PBAUTO);
-                break;
-            case CSS_VAL_LEFT:
-            case CSS_VAL_RIGHT:
-            case CSS_VAL_ALWAYS:
-                style->setPageBreakBefore(PBALWAYS); // CSS2.1: "Conforming user agents may map left/right to always."
-                break;
-            case CSS_VAL_AVOID:
-                style->setPageBreakBefore(PBAVOID);
-                break;
-        }
+        if (primitiveValue)
+            style->setPageBreakBefore(*primitiveValue);
         return;
     }
 
     case CSS_PROP_PAGE_BREAK_AFTER:
     {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakAfter, PageBreakAfter, PageBreak)
-        if (!primitiveValue) return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setPageBreakAfter(PBAUTO);
-                break;
-            case CSS_VAL_LEFT:
-            case CSS_VAL_RIGHT:
-            case CSS_VAL_ALWAYS:
-                style->setPageBreakAfter(PBALWAYS); // CSS2.1: "Conforming user agents may map left/right to always."
-                break;
-            case CSS_VAL_AVOID:
-                style->setPageBreakAfter(PBAVOID);
-                break;
-        }
+        if (primitiveValue)
+            style->setPageBreakAfter(*primitiveValue);
         return;
     }
 
     case CSS_PROP_PAGE_BREAK_INSIDE: {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakInside, PageBreakInside, PageBreak)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent() == CSS_VAL_AUTO)
-            style->setPageBreakInside(PBAUTO);
-        else if (primitiveValue->getIdent() == CSS_VAL_AVOID)
-            style->setPageBreakInside(PBAVOID);
+        if (!primitiveValue)
+            return;
+        EPageBreak pageBreak = *primitiveValue;
+        if (pageBreak != PBALWAYS)
+            style->setPageBreakInside(pageBreak);
         return;
     }
         
     case CSS_PROP_POSITION:
     {
         HANDLE_INHERIT_AND_INITIAL(position, Position)
-        if(!primitiveValue) return;
-        EPosition p;
-        switch(primitiveValue->getIdent())
-        {
-        case CSS_VAL_STATIC:
-            p = StaticPosition;
-            break;
-        case CSS_VAL_RELATIVE:
-            p = RelativePosition;
-            break;
-        case CSS_VAL_ABSOLUTE:
-            p = AbsolutePosition;
-            break;
-        case CSS_VAL_FIXED:
-            p = FixedPosition;
-            break;
-        default:
-            return;
-        }
-        style->setPosition(p);
+        if (primitiveValue)
+            style->setPosition(*primitiveValue);
         return;
     }
 
     case CSS_PROP_TABLE_LAYOUT: {
         HANDLE_INHERIT_AND_INITIAL(tableLayout, TableLayout)
 
-        if (!primitiveValue->getIdent())
-            return;
+        ETableLayout l = *primitiveValue;
+        if (l == TAUTO)
+            l = RenderStyle::initialTableLayout();
 
-        ETableLayout l = RenderStyle::initialTableLayout();
-        switch(primitiveValue->getIdent()) {
-            case CSS_VAL_FIXED:
-                l = TFIXED;
-                // fall through
-            case CSS_VAL_AUTO:
-                style->setTableLayout(l);
-            default:
-                break;
-        }
+        style->setTableLayout(l);
         return;
     }
         
     case CSS_PROP_UNICODE_BIDI: {
         HANDLE_INHERIT_AND_INITIAL(unicodeBidi, UnicodeBidi)
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_NORMAL:
-                style->setUnicodeBidi(UBNormal); 
-                break;
-            case CSS_VAL_EMBED:
-                style->setUnicodeBidi(Embed); 
-                break;
-            case CSS_VAL_BIDI_OVERRIDE:
-                style->setUnicodeBidi(Override);
-                break;
-            default:
-                return;
-        }
+        style->setUnicodeBidi(*primitiveValue);
         return;
     }
     case CSS_PROP_TEXT_TRANSFORM: {
         HANDLE_INHERIT_AND_INITIAL(textTransform, TextTransform)
-        
-        if(!primitiveValue->getIdent()) return;
-
-        ETextTransform tt;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_CAPITALIZE:  tt = CAPITALIZE;  break;
-        case CSS_VAL_UPPERCASE:   tt = UPPERCASE;   break;
-        case CSS_VAL_LOWERCASE:   tt = LOWERCASE;   break;
-        case CSS_VAL_NONE:
-        default:                  tt = TTNONE;      break;
-        }
-        style->setTextTransform(tt);
+        style->setTextTransform(*primitiveValue);
         return;
-        }
+    }
 
     case CSS_PROP_VISIBILITY:
     {
         HANDLE_INHERIT_AND_INITIAL(visibility, Visibility)
-
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_HIDDEN:
-            style->setVisibility(HIDDEN);
-            break;
-        case CSS_VAL_VISIBLE:
-            style->setVisibility(VISIBLE);
-            break;
-        case CSS_VAL_COLLAPSE:
-            style->setVisibility(COLLAPSE);
-        default:
-            break;
-        }
+        style->setVisibility(*primitiveValue);
         return;
     }
     case CSS_PROP_WHITE_SPACE:
         HANDLE_INHERIT_AND_INITIAL(whiteSpace, WhiteSpace)
-
-        if(!primitiveValue->getIdent()) return;
-
-        EWhiteSpace s;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL__WEBKIT_NOWRAP:
-            s = KHTML_NOWRAP;
-            break;
-        case CSS_VAL_NOWRAP:
-            s = NOWRAP;
-            break;
-        case CSS_VAL_PRE:
-            s = PRE;
-            break;
-        case CSS_VAL_PRE_WRAP:
-            s = PRE_WRAP;
-            break;
-        case CSS_VAL_PRE_LINE:
-            s = PRE_LINE;
-            break;
-        case CSS_VAL_NORMAL:
-        default:
-            s = NORMAL;
-            break;
-        }
-        style->setWhiteSpace(s);
+        style->setWhiteSpace(*primitiveValue);
         return;
 
     case CSS_PROP_BACKGROUND_POSITION:
@@ -2383,14 +2161,16 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING: {
         HANDLE_INHERIT_AND_INITIAL(horizontalBorderSpacing, HorizontalBorderSpacing)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         short spacing =  primitiveValue->computeLengthShort(style);
         style->setHorizontalBorderSpacing(spacing);
         return;
     }
     case CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING: {
         HANDLE_INHERIT_AND_INITIAL(verticalBorderSpacing, VerticalBorderSpacing)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         short spacing =  primitiveValue->computeLengthShort(style);
         style->setVerticalBorderSpacing(spacing);
         return;
@@ -2426,27 +2206,13 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                         CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
                         style->addCursor(image->image(element->document()->docLoader()), image->hotspot());
                     }
-                } else if (type == CSSPrimitiveValue::CSS_IDENT) {
-                    int ident = primitiveValue->getIdent();
-                    if (ident == CSS_VAL_COPY)
-                        style->setCursor(CURSOR_COPY);
-                    else if (ident == CSS_VAL_NONE)
-                        style->setCursor(CURSOR_NONE);
-                    else
-                        style->setCursor((ECursor)(ident - CSS_VAL_AUTO));
-                }
+                } else if (type == CSSPrimitiveValue::CSS_IDENT)
+                    style->setCursor(*primitiveValue);
             }
         } else if (primitiveValue) {
             int type = primitiveValue->primitiveType();
-            if (type == CSSPrimitiveValue::CSS_IDENT) {
-                int ident = primitiveValue->getIdent();
-                if (ident == CSS_VAL_COPY)
-                    style->setCursor(CURSOR_COPY);
-                else if (ident == CSS_VAL_NONE)
-                    style->setCursor(CURSOR_NONE);
-                else
-                    style->setCursor((ECursor)(ident - CSS_VAL_AUTO));
-            }
+            if (type == CSSPrimitiveValue::CSS_IDENT)
+                style->setCursor(*primitiveValue);
         }
         return;
 // colors || inherit
@@ -2486,7 +2252,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             col = getColorFromPrimitiveValue(primitiveValue);
         }
 
-        switch(id) {
+        switch (id) {
         case CSS_PROP_BACKGROUND_COLOR:
             style->setBackgroundColor(col); break;
         case CSS_PROP_BORDER_TOP_COLOR:
@@ -2555,10 +2321,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             return;
         }
 
-        if(!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         short width = 3;
-        switch(primitiveValue->getIdent())
-        {
+        switch (primitiveValue->getIdent()) {
         case CSS_VAL_THIN:
             width = 1;
             break;
@@ -2575,9 +2341,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             return;
         }
 
-        if(width < 0) return;
-        switch(id)
-        {
+        if (width < 0) return;
+        switch (id) {
         case CSS_PROP_BORDER_TOP_WIDTH:
             style->setBorderTopWidth(width);
             break;
@@ -2621,11 +2386,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         if (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NORMAL){
             width = 0;
         } else {
-            if(!primitiveValue) return;
+            if (!primitiveValue)
+                return;
             width = primitiveValue->computeLengthInt(style);
         }
-        switch(id)
-        {
+        switch (id) {
         case CSS_PROP_LETTER_SPACING:
             style->setLetterSpacing(width);
             break;
@@ -2640,99 +2405,34 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 
     case CSS_PROP_WORD_BREAK: {
         HANDLE_INHERIT_AND_INITIAL(wordBreak, WordBreak)
-
-        EWordBreak b;
-        switch (primitiveValue->getIdent()) {
-        case CSS_VAL_BREAK_ALL:
-            b = BreakAllWordBreak;
-            break;
-        case CSS_VAL_BREAK_WORD:
-            b = BreakWordBreak;
-            break;
-        case CSS_VAL_NORMAL:
-        default:
-            b = NormalWordBreak;
-            break;
-        }
-        style->setWordBreak(b);
+        style->setWordBreak(*primitiveValue);
         return;
     }
 
     case CSS_PROP_WORD_WRAP: {
         HANDLE_INHERIT_AND_INITIAL(wordWrap, WordWrap)
-
-        EWordWrap s;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_BREAK_WORD:
-            s = BreakWordWrap;
-            break;
-        case CSS_VAL_NORMAL:
-        default:
-            s = NormalWordWrap;
-            break;
-        }
-
-        style->setWordWrap(s);
+        style->setWordWrap(*primitiveValue);
         return;
     }
 
     case CSS_PROP__WEBKIT_NBSP_MODE:
     {
         HANDLE_INHERIT_AND_INITIAL(nbspMode, NBSPMode)
-
-        if (!primitiveValue->getIdent()) return;
-
-        ENBSPMode m;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_SPACE:
-            m = SPACE;
-            break;
-        case CSS_VAL_NORMAL:
-        default:
-            m = NBNORMAL;
-            break;
-        }
-        style->setNBSPMode(m);
+        style->setNBSPMode(*primitiveValue);
         return;
     }
 
     case CSS_PROP__WEBKIT_LINE_BREAK:
     {
         HANDLE_INHERIT_AND_INITIAL(khtmlLineBreak, KHTMLLineBreak)
-
-        if (!primitiveValue->getIdent()) return;
-
-        EKHTMLLineBreak b;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_AFTER_WHITE_SPACE:
-            b = AFTER_WHITE_SPACE;
-            break;
-        case CSS_VAL_NORMAL:
-        default:
-            b = LBNORMAL;
-            break;
-        }
-        style->setKHTMLLineBreak(b);
+        style->setKHTMLLineBreak(*primitiveValue);
         return;
     }
 
     case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
     {
         HANDLE_INHERIT_AND_INITIAL(matchNearestMailBlockquoteColor, MatchNearestMailBlockquoteColor)
-
-        if (!primitiveValue->getIdent()) return;
-
-        EMatchNearestMailBlockquoteColor c;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_NORMAL:
-            c = BCNORMAL;
-            break;
-        case CSS_VAL_MATCH:
-        default:
-            c = MATCH;
-            break;
-        }
-        style->setMatchNearestMailBlockquoteColor(c);
+        style->setMatchNearestMailBlockquoteColor(*primitiveValue);
         return;
     }
 
@@ -2740,28 +2440,16 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     {
         HANDLE_INHERIT_AND_INITIAL(resize, Resize)
 
-        if (!primitiveValue->getIdent()) return;
+        if (!primitiveValue->getIdent())
+            return;
 
-        EResize r = RESIZE_NONE;
-        switch(primitiveValue->getIdent()) {
-        case CSS_VAL_BOTH:
-            r = RESIZE_BOTH;
-            break;
-        case CSS_VAL_HORIZONTAL:
-            r = RESIZE_HORIZONTAL;
-            break;
-        case CSS_VAL_VERTICAL:
-            r = RESIZE_VERTICAL;
-            break;
-        case CSS_VAL_AUTO:
+        EResize r;
+        if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
             if (Settings* settings = m_document->settings())
                 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
-            break;
-        case CSS_VAL_NONE:
-        default:
-            r = RESIZE_NONE;
-            break;
-        }
+        } else
+            r = *primitiveValue;
+            
         style->setResize(r);
         return;
     }
@@ -2769,7 +2457,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     // length, percent
     case CSS_PROP_MAX_WIDTH:
         // +none +inherit
-        if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
+        if (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
             apply = true;
     case CSS_PROP_TOP:
     case CSS_PROP_LEFT:
@@ -2842,11 +2530,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 
         if (primitiveValue && !apply) {
             int type = primitiveValue->primitiveType();
-            if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+            if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
                 // Handle our quirky margin units if we have them.
                 l = Length(primitiveValue->computeLengthIntForLength(style), Fixed, 
                            primitiveValue->isQuirkValue());
-            else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 l = Length(primitiveValue->getDoubleValue(), Percent);
             else
                 return;
@@ -2857,9 +2545,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             else
                 apply = true;
         }
-        if(!apply) return;
-        switch(id)
-            {
+        if (!apply) return;
+        switch (id) {
             case CSS_PROP_MAX_WIDTH:
                 style->setMaxWidth(l); break;
             case CSS_PROP_BOTTOM:
@@ -2951,12 +2638,12 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 
     case CSS_PROP_VERTICAL_ALIGN:
         HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         if (primitiveValue->getIdent()) {
           EVerticalAlign align;
 
-          switch(primitiveValue->getIdent())
-            {
+          switch (primitiveValue->getIdent()) {
                 case CSS_VAL_TOP:
                     align = TOP; break;
                 case CSS_VAL_BOTTOM:
@@ -2983,9 +2670,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         } else {
           int type = primitiveValue->primitiveType();
           Length l;
-          if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+          if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
-          else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+          else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
             l = Length(primitiveValue->getDoubleValue(), Percent);
 
           style->setVerticalAlign(LENGTH);
@@ -3049,7 +2736,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                                                type != CSSPrimitiveValue::CSS_EXS));
             if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
                 size = primitiveValue->computeLengthFloat(parentStyle, false);
-            else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 size = (primitiveValue->getFloatValue() * oldSize) / 100.0f;
             else
                 return;
@@ -3104,7 +2791,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSS_PROP_LINE_HEIGHT:
     {
         HANDLE_INHERIT_AND_INITIAL(lineHeight, LineHeight)
-        if(!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         Length lineHeight;
         int type = primitiveValue->primitiveType();
         if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
@@ -3135,11 +2823,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             return;
         int id = primitiveValue->getIdent();
         if (id == CSS_VAL_START)
-            id = style->direction() == LTR ? CSS_VAL_LEFT : CSS_VAL_RIGHT;
+            style->setTextAlign(style->direction() == LTR ? LEFT : RIGHT);
         else if (id == CSS_VAL_END)
-            id = style->direction() == LTR ? CSS_VAL_RIGHT : CSS_VAL_LEFT;
-        
-        style->setTextAlign((ETextAlign) (id - CSS_VAL__WEBKIT_AUTO));
+            style->setTextAlign(style->direction() == LTR ? RIGHT : LEFT);
+        else
+            style->setTextAlign(*primitiveValue);
         return;
     }
 
@@ -3292,9 +2980,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         bool oldFamilyIsMonospace = fontDescription.genericFamily() == FontDescription::MonospaceFamily;
         fontDescription.setGenericFamily(FontDescription::NoFamily);
 
-        for(int i = 0; i < len; i++) {
+        for (int i = 0; i < len; i++) {
             CSSValue *item = list->item(i);
-            if(!item->isPrimitiveValue()) continue;
+            if (!item->isPrimitiveValue()) continue;
             CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
             AtomicString face;
             Settings* settings = m_document->settings();
@@ -3354,19 +3042,18 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         // list of ident
         HANDLE_INHERIT_AND_INITIAL(textDecoration, TextDecoration)
         int t = RenderStyle::initialTextDecoration();
-        if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
+        if (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
             // do nothing
         } else {
-            if(!value->isValueList()) return;
+            if (!value->isValueList()) return;
             CSSValueList *list = static_cast<CSSValueList*>(value);
             int len = list->length();
-            for(int i = 0; i < len; i++)
+            for (int i = 0; i < len; i++)
             {
                 CSSValue *item = list->item(i);
-                if(!item->isPrimitiveValue()) continue;
+                if (!item->isPrimitiveValue()) continue;
                 primitiveValue = static_cast<CSSPrimitiveValue*>(item);
-                switch(primitiveValue->getIdent())
-                {
+                switch (primitiveValue->getIdent()) {
                     case CSS_VAL_NONE:
                         t = TDNONE; break;
                     case CSS_VAL_UNDERLINE:
@@ -3572,14 +3259,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     // CSS3 Properties
     case CSS_PROP__WEBKIT_APPEARANCE: {
         HANDLE_INHERIT_AND_INITIAL(appearance, Appearance)
-        if (!primitiveValue) break;
-        int id = primitiveValue->getIdent();
-        EAppearance appearance;
-        if (id == CSS_VAL_NONE)
-            appearance = NoAppearance;
-        else
-            appearance = EAppearance(id - CSS_VAL_CHECKBOX + 1);
-        style->setAppearance(appearance);
+        if (!primitiveValue)
+            return;
+        style->setAppearance(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_BINDING: {
@@ -3793,73 +3475,36 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
     case CSS_PROP__WEBKIT_BOX_ALIGN:
         HANDLE_INHERIT_AND_INITIAL(boxAlign, BoxAlign)
-        if (!primitiveValue) return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_STRETCH:
-                style->setBoxAlign(BSTRETCH);
-                break;
-            case CSS_VAL_START:
-                style->setBoxAlign(BSTART);
-                break;
-            case CSS_VAL_END:
-                style->setBoxAlign(BEND);
-                break;
-            case CSS_VAL_CENTER:
-                style->setBoxAlign(BCENTER);
-                break;
-            case CSS_VAL_BASELINE:
-                style->setBoxAlign(BBASELINE);
-                break;
-            default:
-                return;
-        }
+        if (!primitiveValue)
+            return;
+        EBoxAlignment boxAlignment = *primitiveValue;
+        if (boxAlignment != BJUSTIFY)
+            style->setBoxAlign(boxAlignment);
         return;
     case CSS_PROP_SRC: // Only used in @font-face rules.
         return;
     case CSS_PROP__WEBKIT_BOX_DIRECTION:
         HANDLE_INHERIT_AND_INITIAL(boxDirection, BoxDirection)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
-            style->setBoxDirection(BNORMAL);
-        else
-            style->setBoxDirection(BREVERSE);
+        if (primitiveValue)
+            style->setBoxDirection(*primitiveValue);
         return;        
     case CSS_PROP__WEBKIT_BOX_LINES:
         HANDLE_INHERIT_AND_INITIAL(boxLines, BoxLines)
-        if(!primitiveValue) return;
-        if (primitiveValue->getIdent() == CSS_VAL_SINGLE)
-            style->setBoxLines(SINGLE);
-        else
-            style->setBoxLines(MULTIPLE);
+        if (primitiveValue)
+            style->setBoxLines(*primitiveValue);
         return;     
     case CSS_PROP__WEBKIT_BOX_ORIENT:
         HANDLE_INHERIT_AND_INITIAL(boxOrient, BoxOrient)
-        if (!primitiveValue) return;
-        if (primitiveValue->getIdent() == CSS_VAL_HORIZONTAL ||
-            primitiveValue->getIdent() == CSS_VAL_INLINE_AXIS)
-            style->setBoxOrient(HORIZONTAL);
-        else
-            style->setBoxOrient(VERTICAL);
+        if (primitiveValue)
+            style->setBoxOrient(*primitiveValue);
         return;     
     case CSS_PROP__WEBKIT_BOX_PACK:
         HANDLE_INHERIT_AND_INITIAL(boxPack, BoxPack)
-        if (!primitiveValue) return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_START:
-                style->setBoxPack(BSTART);
-                break;
-            case CSS_VAL_END:
-                style->setBoxPack(BEND);
-                break;
-            case CSS_VAL_CENTER:
-                style->setBoxPack(BCENTER);
-                break;
-            case CSS_VAL_JUSTIFY:
-                style->setBoxPack(BJUSTIFY);
-                break;
-            default:
-                return;
-        }
+        if (!primitiveValue)
+            return;
+        EBoxAlignment boxPack = *primitiveValue;
+        if (boxPack != BSTRETCH && boxPack != BBASELINE)
+            style->setBoxPack(boxPack);
         return;        
     case CSS_PROP__WEBKIT_BOX_FLEX:
         HANDLE_INHERIT_AND_INITIAL(boxFlex, BoxFlex)
@@ -3881,7 +3526,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
     case CSS_PROP__WEBKIT_BOX_SIZING:
         HANDLE_INHERIT_AND_INITIAL(boxSizing, BoxSizing)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         if (primitiveValue->getIdent() == CSS_VAL_CONTENT_BOX)
             style->setBoxSizing(CONTENT_BOX);
         else
@@ -3931,48 +3577,23 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_COLUMN_RULE_STYLE:
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(columnRuleStyle, ColumnRuleStyle, BorderStyle)
-        style->setColumnRuleStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+        style->setColumnRuleStyle(*primitiveValue);
         return;
     case CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE: {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(columnBreakBefore, ColumnBreakBefore, PageBreak)
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setColumnBreakBefore(PBAUTO);
-                break;
-            case CSS_VAL_LEFT:
-            case CSS_VAL_RIGHT:
-            case CSS_VAL_ALWAYS:
-                style->setColumnBreakBefore(PBALWAYS);
-                break;
-            case CSS_VAL_AVOID:
-                style->setColumnBreakBefore(PBAVOID);
-                break;
-        }
+        style->setColumnBreakBefore(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER: {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(columnBreakAfter, ColumnBreakAfter, PageBreak)
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setColumnBreakAfter(PBAUTO);
-                break;
-            case CSS_VAL_LEFT:
-            case CSS_VAL_RIGHT:
-            case CSS_VAL_ALWAYS:
-                style->setColumnBreakAfter(PBALWAYS);
-                break;
-            case CSS_VAL_AVOID:
-                style->setColumnBreakAfter(PBAVOID);
-                break;
-        }
+        style->setColumnBreakAfter(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE: {
         HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(columnBreakInside, ColumnBreakInside, PageBreak)
-        if (primitiveValue->getIdent() == CSS_VAL_AUTO)
-            style->setColumnBreakInside(PBAUTO);
-        else if (primitiveValue->getIdent() == CSS_VAL_AVOID)
-            style->setColumnBreakInside(PBAVOID);
+        EPageBreak pb = *primitiveValue;
+        if (pb != PBALWAYS)
+            style->setColumnBreakInside(pb);
         return;
     }
      case CSS_PROP__WEBKIT_COLUMN_RULE:
@@ -4006,7 +3627,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
     case CSS_PROP__WEBKIT_MARQUEE_REPETITION: {
         HANDLE_INHERIT_AND_INITIAL(marqueeLoopCount, MarqueeLoopCount)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         if (primitiveValue->getIdent() == CSS_VAL_INFINITE)
             style->setMarqueeLoopCount(-1); // -1 means repeat forever.
         else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
@@ -4015,10 +3637,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_MARQUEE_SPEED: {
         HANDLE_INHERIT_AND_INITIAL(marqueeSpeed, MarqueeSpeed)      
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         if (primitiveValue->getIdent()) {
-            switch (primitiveValue->getIdent())
-            {
+            switch (primitiveValue->getIdent()) {
                 case CSS_VAL_SLOW:
                     style->setMarqueeSpeed(500); // 500 msec.
                     break;
@@ -4040,10 +3662,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_MARQUEE_INCREMENT: {
         HANDLE_INHERIT_AND_INITIAL(marqueeIncrement, MarqueeIncrement)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         if (primitiveValue->getIdent()) {
-            switch (primitiveValue->getIdent())
-            {
+            switch (primitiveValue->getIdent()) {
                 case CSS_VAL_SMALL:
                     style->setMarqueeIncrement(Length(1, Fixed)); // 1px.
                     break;
@@ -4065,97 +3687,32 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_MARQUEE_STYLE: {
         HANDLE_INHERIT_AND_INITIAL(marqueeBehavior, MarqueeBehavior)      
-        if (!primitiveValue || !primitiveValue->getIdent()) return;
-        switch (primitiveValue->getIdent())
-        {
-            case CSS_VAL_NONE:
-                style->setMarqueeBehavior(MNONE);
-                break;
-            case CSS_VAL_SCROLL:
-                style->setMarqueeBehavior(MSCROLL);
-                break;
-            case CSS_VAL_SLIDE:
-                style->setMarqueeBehavior(MSLIDE);
-                break;
-            case CSS_VAL_ALTERNATE:
-                style->setMarqueeBehavior(MALTERNATE);
-                break;
-        }
+        if (primitiveValue)
+            style->setMarqueeBehavior(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_MARQUEE_DIRECTION: {
         HANDLE_INHERIT_AND_INITIAL(marqueeDirection, MarqueeDirection)
-        if (!primitiveValue || !primitiveValue->getIdent()) return;
-        switch (primitiveValue->getIdent())
-        {
-            case CSS_VAL_FORWARDS:
-                style->setMarqueeDirection(MFORWARD);
-                break;
-            case CSS_VAL_BACKWARDS:
-                style->setMarqueeDirection(MBACKWARD);
-                break;
-            case CSS_VAL_AUTO:
-                style->setMarqueeDirection(MAUTO);
-                break;
-            case CSS_VAL_AHEAD:
-            case CSS_VAL_UP: // We don't support vertical languages, so AHEAD just maps to UP.
-                style->setMarqueeDirection(MUP);
-                break;
-            case CSS_VAL_REVERSE:
-            case CSS_VAL_DOWN: // REVERSE just maps to DOWN, since we don't do vertical text.
-                style->setMarqueeDirection(MDOWN);
-                break;
-            case CSS_VAL_LEFT:
-                style->setMarqueeDirection(MLEFT);
-                break;
-            case CSS_VAL_RIGHT:
-                style->setMarqueeDirection(MRIGHT);
-                break;
-        }
+        if (primitiveValue)
+            style->setMarqueeDirection(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_USER_DRAG: {
         HANDLE_INHERIT_AND_INITIAL(userDrag, UserDrag)      
-        if (!primitiveValue || !primitiveValue->getIdent())
-            return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setUserDrag(DRAG_AUTO);
-                break;
-            case CSS_VAL_NONE:
-                style->setUserDrag(DRAG_NONE);
-                break;
-            case CSS_VAL_ELEMENT:
-                style->setUserDrag(DRAG_ELEMENT);
-            default:
-                return;
-        }
+        if (primitiveValue)
+            style->setUserDrag(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_USER_MODIFY: {
         HANDLE_INHERIT_AND_INITIAL(userModify, UserModify)      
-        if (!primitiveValue || !primitiveValue->getIdent())
-            return;
-        EUserModify userModify = EUserModify(primitiveValue->getIdent() - CSS_VAL_READ_ONLY);
-        style->setUserModify(userModify);
+        if (primitiveValue)
+            style->setUserModify(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_USER_SELECT: {
         HANDLE_INHERIT_AND_INITIAL(userSelect, UserSelect)      
-        if (!primitiveValue || !primitiveValue->getIdent())
-            return;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_AUTO:
-                style->setUserSelect(SELECT_TEXT);
-                break;
-            case CSS_VAL_NONE:
-                style->setUserSelect(SELECT_NONE);
-                break;
-            case CSS_VAL_TEXT:
-                style->setUserSelect(SELECT_TEXT);
-            default:
-                return;
-        }
+        if (primitiveValue)
+            style->setUserSelect(*primitiveValue);
         return;
     }
     case CSS_PROP_TEXT_OVERFLOW: {
@@ -4180,43 +3737,22 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE: {
         HANDLE_INHERIT_AND_INITIAL(marginTopCollapse, MarginTopCollapse)
-        if (!primitiveValue || !primitiveValue->getIdent()) return;
-        EMarginCollapse val;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_SEPARATE:
-                val = MSEPARATE;
-                break;
-            case CSS_VAL_DISCARD:
-                val = MDISCARD;
-                break;
-            default:
-                val = MCOLLAPSE;
-        }
-        style->setMarginTopCollapse(val);
+        if (primitiveValue)
+            style->setMarginTopCollapse(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE: {
         HANDLE_INHERIT_AND_INITIAL(marginBottomCollapse, MarginBottomCollapse)
-        if (!primitiveValue || !primitiveValue->getIdent()) return;
-        EMarginCollapse val;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_SEPARATE:
-                val = MSEPARATE;
-                break;
-            case CSS_VAL_DISCARD:
-                val = MDISCARD;
-                break;
-            default:
-                val = MCOLLAPSE;
-        }
-        style->setMarginBottomCollapse(val);
+        if (primitiveValue)
+            style->setMarginBottomCollapse(*primitiveValue);
         return;
     }
 
     // Apple-specific changes.  Do not merge these properties into KHTML.
     case CSS_PROP__WEBKIT_LINE_CLAMP: {
         HANDLE_INHERIT_AND_INITIAL(lineClamp, LineClamp)
-        if (!primitiveValue) return;
+        if (!primitiveValue)
+            return;
         style->setLineClamp(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_PERCENTAGE));
         return;
     }
@@ -4245,21 +3781,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     }
     case CSS_PROP__WEBKIT_TEXT_SECURITY: {
         HANDLE_INHERIT_AND_INITIAL(textSecurity, TextSecurity)
-        if (!primitiveValue)
-            return;
-        ETextSecurity textSecurity = TSNONE;
-        switch (primitiveValue->getIdent()) {
-            case CSS_VAL_DISC:
-                textSecurity = TSDISC;
-                break;
-            case CSS_VAL_CIRCLE:
-                textSecurity = TSCIRCLE;
-                break;
-            case CSS_VAL_SQUARE:
-                textSecurity= TSSQUARE;
-                break;
-        }
-        style->setTextSecurity(textSecurity);
+        if (primitiveValue)
+            style->setTextSecurity(*primitiveValue);
         return;
     }
     case CSS_PROP__WEBKIT_DASHBOARD_REGION: {
@@ -4267,7 +3790,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         if (!primitiveValue)
             return;
 
-        if(primitiveValue->getIdent() == CSS_VAL_NONE) {
+        if (primitiveValue->getIdent() == CSS_VAL_NONE) {
             style->setDashboardRegions(RenderStyle::noneDashboardRegions());
             return;
         }
@@ -4527,7 +4050,8 @@ void CSSStyleSelector::mapBackgroundAttachment(BackgroundLayer* layer, CSSValue*
         return;
     }
 
-    if (!value->isPrimitiveValue()) return;
+    if (!value->isPrimitiveValue())
+        return;
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     switch (primitiveValue->getIdent()) {
         case CSS_VAL_FIXED:
@@ -4548,19 +4072,10 @@ void CSSStyleSelector::mapBackgroundClip(BackgroundLayer* layer, CSSValue* value
         return;
     }
 
-    if (!value->isPrimitiveValue()) return;
+    if (!value->isPrimitiveValue())
+        return;
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
-    switch (primitiveValue->getIdent()) {
-        case CSS_VAL_BORDER:
-            layer->setBackgroundClip(BGBORDER);
-            break;
-        case CSS_VAL_PADDING:
-            layer->setBackgroundClip(BGPADDING);
-            break;
-        default: // CSS_VAL_CONTENT
-            layer->setBackgroundClip(BGCONTENT);
-            break;
-    }
+    layer->setBackgroundClip(*primitiveValue);
 }
 
 void CSSStyleSelector::mapBackgroundComposite(BackgroundLayer* layer, CSSValue* value)
@@ -4573,52 +4088,7 @@ void CSSStyleSelector::mapBackgroundComposite(BackgroundLayer* layer, CSSValue*
     if (!value->isPrimitiveValue())
         return;
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
-    switch(primitiveValue->getIdent()) {
-        case CSS_VAL_CLEAR:
-            layer->setBackgroundComposite(CompositeClear);
-            break;
-        case CSS_VAL_COPY:
-            layer->setBackgroundComposite(CompositeCopy);
-            break;
-        case CSS_VAL_SOURCE_OVER:
-            layer->setBackgroundComposite(CompositeSourceOver);
-            break;
-        case CSS_VAL_SOURCE_IN:
-            layer->setBackgroundComposite(CompositeSourceIn);
-            break;
-        case CSS_VAL_SOURCE_OUT:
-            layer->setBackgroundComposite(CompositeSourceOut);
-            break;
-        case CSS_VAL_SOURCE_ATOP:
-            layer->setBackgroundComposite(CompositeSourceAtop);
-            break;
-        case CSS_VAL_DESTINATION_OVER:
-            layer->setBackgroundComposite(CompositeDestinationOver);
-            break;
-        case CSS_VAL_DESTINATION_IN:
-            layer->setBackgroundComposite(CompositeDestinationIn);
-            break;
-        case CSS_VAL_DESTINATION_OUT:
-            layer->setBackgroundComposite(CompositeDestinationOut);
-            break;
-        case CSS_VAL_DESTINATION_ATOP:
-            layer->setBackgroundComposite(CompositeDestinationAtop);
-            break;
-        case CSS_VAL_XOR:
-            layer->setBackgroundComposite(CompositeXOR);
-            break;
-        case CSS_VAL_PLUS_DARKER:
-            layer->setBackgroundComposite(CompositePlusDarker);
-            break;
-        case CSS_VAL_HIGHLIGHT:
-            layer->setBackgroundComposite(CompositeHighlight);
-            break;
-        case CSS_VAL_PLUS_LIGHTER:
-            layer->setBackgroundComposite(CompositePlusLighter);
-            break;
-        default:
-            return;
-    }
+    layer->setBackgroundComposite(*primitiveValue);
 }
 
 void CSSStyleSelector::mapBackgroundOrigin(BackgroundLayer* layer, CSSValue* value)
@@ -4628,19 +4098,10 @@ void CSSStyleSelector::mapBackgroundOrigin(BackgroundLayer* layer, CSSValue* val
         return;
     }
 
-    if (!value->isPrimitiveValue()) return;
+    if (!value->isPrimitiveValue())
+        return;
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
-    switch (primitiveValue->getIdent()) {
-        case CSS_VAL_BORDER:
-            layer->setBackgroundOrigin(BGBORDER);
-            break;
-        case CSS_VAL_PADDING:
-            layer->setBackgroundOrigin(BGPADDING);
-            break;
-        default: // CSS_VAL_CONTENT
-            layer->setBackgroundOrigin(BGCONTENT);
-            break;
-    }
+    layer->setBackgroundOrigin(*primitiveValue);
 }
 
 void CSSStyleSelector::mapBackgroundImage(BackgroundLayer* layer, CSSValue* value)
@@ -4665,22 +4126,7 @@ void CSSStyleSelector::mapBackgroundRepeat(BackgroundLayer* layer, CSSValue* val
     if (!value->isPrimitiveValue())
         return;
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
-    switch(primitiveValue->getIdent()) {
-        case CSS_VAL_REPEAT:
-            layer->setBackgroundRepeat(REPEAT);
-            break;
-        case CSS_VAL_REPEAT_X:
-            layer->setBackgroundRepeat(REPEAT_X);
-            break;
-        case CSS_VAL_REPEAT_Y:
-            layer->setBackgroundRepeat(REPEAT_Y);
-            break;
-        case CSS_VAL_NO_REPEAT:
-            layer->setBackgroundRepeat(NO_REPEAT);
-            break;
-        default:
-            return;
-    }
+    layer->setBackgroundRepeat(*primitiveValue);
 }
 
 void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value)
@@ -4745,9 +4191,9 @@ void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, CSSValue*
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     Length l;
     int type = primitiveValue->primitiveType();
-    if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+    if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
-    else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
         l = Length(primitiveValue->getDoubleValue(), Percent);
     else
         return;
@@ -4766,9 +4212,9 @@ void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, CSSValue*
     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     Length l;
     int type = primitiveValue->primitiveType();
-    if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+    if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
-    else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
         l = Length(primitiveValue->getDoubleValue(), Percent);
     else
         return;
index d966b5327cd2c623a149e326bf44070198bbb7ca..eff1d5ab550253d555a9d4a0397dccefecc41437 100644 (file)
@@ -1,5 +1,6 @@
 /*
     Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+    Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
 #if ENABLE(SVG)
 #include "CSSComputedStyleDeclaration.h"
 
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertyNames.h"
-#include "CSSValueKeywords.h"
 #include "Document.h"
-#include "RenderStyle.h"
 
 namespace WebCore {
     
@@ -47,200 +47,46 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
         return 0;
     
     switch (static_cast<CSSPropertyID>(propertyID)) {
-        case CSS_PROP_CLIP_RULE: {
-            if (svgStyle->clipRule() == RULE_NONZERO)
-                return new CSSPrimitiveValue(CSS_VAL_NONZERO);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_EVENODD);
-        }
+        case CSS_PROP_CLIP_RULE:
+            return new CSSPrimitiveValue(svgStyle->clipRule());
         case CSS_PROP_FLOOD_OPACITY:
             return new CSSPrimitiveValue(svgStyle->floodOpacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP_STOP_OPACITY:
             return new CSSPrimitiveValue(svgStyle->stopOpacity(), CSSPrimitiveValue::CSS_NUMBER);
-        case CSS_PROP_POINTER_EVENTS: {
-            switch (svgStyle->pointerEvents()) {
-            case PE_NONE:
-                return new CSSPrimitiveValue(CSS_VAL_NONE);
-            case PE_STROKE:
-                return new CSSPrimitiveValue(CSS_VAL_STROKE);
-            case PE_FILL:
-                return new CSSPrimitiveValue(CSS_VAL_FILL);
-            case PE_PAINTED:
-                return new CSSPrimitiveValue(CSS_VAL_PAINTED);
-            case PE_VISIBLE:
-                return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
-            case PE_VISIBLE_STROKE:
-                return new CSSPrimitiveValue(CSS_VAL_VISIBLESTROKE);
-            case PE_VISIBLE_FILL:
-                return new CSSPrimitiveValue(CSS_VAL_VISIBLEFILL);
-            case PE_VISIBLE_PAINTED:
-                return new CSSPrimitiveValue(CSS_VAL_VISIBLEPAINTED);
-            case PE_ALL:
-                return new CSSPrimitiveValue(CSS_VAL_ALL);
-            }
-        }
-        case CSS_PROP_COLOR_INTERPOLATION: {
-            if (svgStyle->colorInterpolation() == CI_AUTO)
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            else if (svgStyle->colorInterpolation() == CI_SRGB)
-                return new CSSPrimitiveValue(CSS_VAL_SRGB);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_LINEARRGB);
-        }
-        case CSS_PROP_COLOR_INTERPOLATION_FILTERS: {
-            if (svgStyle->colorInterpolationFilters() == CI_AUTO)
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            else if (svgStyle->colorInterpolationFilters() == CI_SRGB)
-                return new CSSPrimitiveValue(CSS_VAL_SRGB);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_LINEARRGB);
-        }
+        case CSS_PROP_POINTER_EVENTS:
+            return new CSSPrimitiveValue(svgStyle->pointerEvents());
+        case CSS_PROP_COLOR_INTERPOLATION:
+            return new CSSPrimitiveValue(svgStyle->colorInterpolation());
+        case CSS_PROP_COLOR_INTERPOLATION_FILTERS:
+            return new CSSPrimitiveValue(svgStyle->colorInterpolationFilters());
         case CSS_PROP_FILL_OPACITY:
             return new CSSPrimitiveValue(svgStyle->fillOpacity(), CSSPrimitiveValue::CSS_NUMBER);
-        case CSS_PROP_FILL_RULE: {
-            if (svgStyle->fillRule() == RULE_NONZERO)
-                return new CSSPrimitiveValue(CSS_VAL_NONZERO);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_EVENODD);
-        }
-        case CSS_PROP_COLOR_RENDERING: {
-            if (svgStyle->colorRendering() == CR_AUTO)
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            else if (svgStyle->colorRendering() == CR_OPTIMIZESPEED)
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZESPEED);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZEQUALITY);
-        }
-        case CSS_PROP_IMAGE_RENDERING: {
-            if (svgStyle->imageRendering() == IR_AUTO)
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            else if (svgStyle->imageRendering() == IR_OPTIMIZESPEED)
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZESPEED);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZEQUALITY);
-        }
-        case CSS_PROP_SHAPE_RENDERING: {
-            if (svgStyle->shapeRendering() == SR_AUTO)
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            else if (svgStyle->shapeRendering() == SR_OPTIMIZESPEED)
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZESPEED);
-            else if (svgStyle->shapeRendering() == SR_CRISPEDGES)
-                return new CSSPrimitiveValue(CSS_VAL_CRISPEDGES);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_GEOMETRICPRECISION);
-        }
-        case CSS_PROP_STROKE_LINECAP: {
-            if (svgStyle->capStyle() == ButtCap)
-                return new CSSPrimitiveValue(CSS_VAL_BUTT);
-            else if (svgStyle->capStyle() == RoundCap)
-                return new CSSPrimitiveValue(CSS_VAL_ROUND);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_SQUARE);
-        }
-        case CSS_PROP_STROKE_LINEJOIN: {
-            if (svgStyle->joinStyle() == MiterJoin)
-                return new CSSPrimitiveValue(CSS_VAL_MITER);
-            else if (svgStyle->joinStyle() == RoundJoin)
-                return new CSSPrimitiveValue(CSS_VAL_ROUND);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_BEVEL);
-        }
+        case CSS_PROP_FILL_RULE:
+            return new CSSPrimitiveValue(svgStyle->fillRule());
+        case CSS_PROP_COLOR_RENDERING:
+            return new CSSPrimitiveValue(svgStyle->colorRendering());
+        case CSS_PROP_IMAGE_RENDERING:
+            return new CSSPrimitiveValue(svgStyle->imageRendering());
+        case CSS_PROP_SHAPE_RENDERING:
+            return new CSSPrimitiveValue(svgStyle->shapeRendering());
+        case CSS_PROP_STROKE_LINECAP:
+            return new CSSPrimitiveValue(svgStyle->capStyle());
+        case CSS_PROP_STROKE_LINEJOIN:
+            return new CSSPrimitiveValue(svgStyle->joinStyle());
         case CSS_PROP_STROKE_MITERLIMIT:
             return new CSSPrimitiveValue(svgStyle->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
         case CSS_PROP_STROKE_OPACITY:
             return new CSSPrimitiveValue(svgStyle->strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER);
-        case CSS_PROP_TEXT_RENDERING: {
-            switch (svgStyle->textRendering()) {
-            case TR_AUTO:
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            case TR_OPTIMIZESPEED:
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZESPEED);
-            case TR_OPTIMIZELEGIBILITY:
-                return new CSSPrimitiveValue(CSS_VAL_OPTIMIZELEGIBILITY);
-            case TR_GEOMETRICPRECISION:
-                return new CSSPrimitiveValue(CSS_VAL_GEOMETRICPRECISION);
-            }
-        }
-        case CSS_PROP_ALIGNMENT_BASELINE: {
-            switch (svgStyle->alignmentBaseline()) {
-            case AB_AUTO:
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            case AB_BASELINE:
-                return new CSSPrimitiveValue(CSS_VAL_BASELINE);
-            case AB_BEFORE_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_BEFORE_EDGE);
-            case AB_TEXT_BEFORE_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_TEXT_BEFORE_EDGE);
-            case AB_MIDDLE:
-                return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
-            case AB_CENTRAL:
-                return new CSSPrimitiveValue(CSS_VAL_CENTRAL);
-            case AB_AFTER_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_AFTER_EDGE);
-            case AB_TEXT_AFTER_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_TEXT_AFTER_EDGE);
-            case AB_IDEOGRAPHIC:
-                return new CSSPrimitiveValue(CSS_VAL_IDEOGRAPHIC);
-            case AB_ALPHABETIC:
-                return new CSSPrimitiveValue(CSS_VAL_ALPHABETIC);
-            case AB_HANGING:
-                return new CSSPrimitiveValue(CSS_VAL_HANGING);
-            case AB_MATHEMATICAL:
-                return new CSSPrimitiveValue(CSS_VAL_MATHEMATICAL);
-            }
-        }
-        case CSS_PROP_DOMINANT_BASELINE: {
-            switch (svgStyle->dominantBaseline()) {
-            case DB_AUTO:
-                return new CSSPrimitiveValue(CSS_VAL_AUTO);
-            case DB_USE_SCRIPT:
-                return new CSSPrimitiveValue(CSS_VAL_USE_SCRIPT);
-            case DB_NO_CHANGE:
-                return new CSSPrimitiveValue(CSS_VAL_NO_CHANGE);
-            case DB_RESET_SIZE:
-                return new CSSPrimitiveValue(CSS_VAL_RESET_SIZE);
-            case DB_CENTRAL:
-                return new CSSPrimitiveValue(CSS_VAL_CENTRAL);
-            case DB_MIDDLE:
-                return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
-            case DB_TEXT_BEFORE_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_TEXT_BEFORE_EDGE);
-            case DB_TEXT_AFTER_EDGE:
-                return new CSSPrimitiveValue(CSS_VAL_TEXT_AFTER_EDGE);
-            case DB_IDEOGRAPHIC:
-                return new CSSPrimitiveValue(CSS_VAL_IDEOGRAPHIC);
-            case DB_ALPHABETIC:
-                return new CSSPrimitiveValue(CSS_VAL_ALPHABETIC);
-            case DB_HANGING:
-                return new CSSPrimitiveValue(CSS_VAL_HANGING);
-            case DB_MATHEMATICAL:
-                return new CSSPrimitiveValue(CSS_VAL_MATHEMATICAL);
-            }
-        }
-        case CSS_PROP_TEXT_ANCHOR: {
-            if (svgStyle->textAnchor() == TA_START)
-                return new CSSPrimitiveValue(CSS_VAL_START);
-            else if (svgStyle->textAnchor() == TA_MIDDLE)
-                return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
-            else
-                return new CSSPrimitiveValue(CSS_VAL_END);
-        }
-        case CSS_PROP_WRITING_MODE: {
-            switch (svgStyle->writingMode()) {
-            case WM_LRTB:
-                return new CSSPrimitiveValue(CSS_VAL_LR_TB);
-            case WM_LR:
-                return new CSSPrimitiveValue(CSS_VAL_LR);
-            case WM_RLTB:
-                return new CSSPrimitiveValue(CSS_VAL_RL_TB);
-            case WM_RL:
-                return new CSSPrimitiveValue(CSS_VAL_RL);
-            case WM_TBRL:
-                return new CSSPrimitiveValue(CSS_VAL_TB_RL);
-            case WM_TB:
-                return new CSSPrimitiveValue(CSS_VAL_TB);
-            }
-        }
+        case CSS_PROP_TEXT_RENDERING:
+            return new CSSPrimitiveValue(svgStyle->textRendering());
+        case CSS_PROP_ALIGNMENT_BASELINE:
+            return new CSSPrimitiveValue(svgStyle->alignmentBaseline());
+        case CSS_PROP_DOMINANT_BASELINE:
+            return new CSSPrimitiveValue(svgStyle->dominantBaseline());
+        case CSS_PROP_TEXT_ANCHOR:
+            return new CSSPrimitiveValue(svgStyle->textAnchor());
+        case CSS_PROP_WRITING_MODE:
+            return new CSSPrimitiveValue(svgStyle->writingMode());
         case CSS_PROP_CLIP_PATH:
             if (!svgStyle->clipPath().isEmpty())
                 return new CSSPrimitiveValue(svgStyle->clipPath(), CSSPrimitiveValue::CSS_URI);
@@ -285,14 +131,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
             return svgStyle->strokeWidth();
         case CSS_PROP_BASELINE_SHIFT: {
             switch (svgStyle->baselineShift()) {
-            case BS_BASELINE:
-                return new CSSPrimitiveValue(CSS_VAL_BASELINE);
-            case BS_SUPER:
-                return new CSSPrimitiveValue(CSS_VAL_SUPER);
-            case BS_SUB:
-                return new CSSPrimitiveValue(CSS_VAL_SUB);
-            case BS_LENGTH:
-                return svgStyle->baselineShiftValue();
+                case BS_BASELINE:
+                    return new CSSPrimitiveValue(CSS_VAL_BASELINE);
+                case BS_SUPER:
+                    return new CSSPrimitiveValue(CSS_VAL_SUPER);
+                case BS_SUB:
+                    return new CSSPrimitiveValue(CSS_VAL_SUB);
+                case BS_LENGTH:
+                    return svgStyle->baselineShiftValue();
             }
         }
         case CSS_PROP_MARKER:
index 60bc50044e78c0a7c1f469f54b548674bb5cd730..d81dad3638efabd794a1ef7744025c5f09db5329 100644 (file)
@@ -2,6 +2,7 @@
     Copyright (C) 2005 Apple Computer, Inc.
     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
                   2004, 2005 Rob Buis <buis@kde.org>
+    Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
 
     Based on khtml css code by:
     Copyright(C) 1999-2003 Lars Knoll(knoll@kde.org)
@@ -31,8 +32,8 @@
 #if ENABLE(SVG)
 #include "CSSStyleSelector.h"
 
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertyNames.h"
-#include "CSSValueKeywords.h"
 #include "CSSValueList.h"
 #include "SVGColor.h"
 #include "SVGNames.h"
@@ -102,48 +103,8 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
             HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
             if (!primitiveValue)
                 break;
-
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_AUTO:
-                    svgstyle->setAlignmentBaseline(AB_AUTO);
-                    break;
-                case CSS_VAL_BASELINE:
-                    svgstyle->setAlignmentBaseline(AB_BASELINE);
-                    break;
-                case CSS_VAL_BEFORE_EDGE:
-                    svgstyle->setAlignmentBaseline(AB_BEFORE_EDGE);
-                    break;
-                case CSS_VAL_TEXT_BEFORE_EDGE:
-                    svgstyle->setAlignmentBaseline(AB_TEXT_BEFORE_EDGE);
-                    break;
-                case CSS_VAL_MIDDLE:
-                    svgstyle->setAlignmentBaseline(AB_MIDDLE);
-                    break;
-                case CSS_VAL_CENTRAL:
-                    svgstyle->setAlignmentBaseline(AB_CENTRAL);
-                    break;
-                case CSS_VAL_AFTER_EDGE:
-                    svgstyle->setAlignmentBaseline(AB_AFTER_EDGE);
-                    break;
-                case CSS_VAL_TEXT_AFTER_EDGE:
-                    svgstyle->setAlignmentBaseline(AB_TEXT_AFTER_EDGE);
-                    break;
-                case CSS_VAL_IDEOGRAPHIC:
-                    svgstyle->setAlignmentBaseline(AB_IDEOGRAPHIC);
-                    break;
-                case CSS_VAL_ALPHABETIC:
-                    svgstyle->setAlignmentBaseline(AB_ALPHABETIC);
-                    break;
-                case CSS_VAL_HANGING:
-                    svgstyle->setAlignmentBaseline(AB_HANGING);
-                    break;
-                case CSS_VAL_MATHEMATICAL:
-                    svgstyle->setAlignmentBaseline(AB_MATHEMATICAL);
-                    break;
-                default:
-                    return;
-            }
-
+            
+            svgstyle->setAlignmentBaseline(*primitiveValue);
             break;
         }
         case CSS_PROP_BASELINE_SHIFT:
@@ -192,240 +153,78 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
             HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
             if (!primitiveValue)
                 break;
-                
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_ALL:
-                    svgstyle->setPointerEvents(PE_ALL);
-                    break;
-                case CSS_VAL_NONE:
-                    svgstyle->setPointerEvents(PE_NONE);
-                    break;
-                case CSS_VAL_VISIBLEPAINTED:
-                    svgstyle->setPointerEvents(PE_VISIBLE_PAINTED);
-                    break;
-                case CSS_VAL_VISIBLEFILL:
-                    svgstyle->setPointerEvents(PE_VISIBLE_FILL);
-                    break;
-                case CSS_VAL_VISIBLESTROKE:
-                    svgstyle->setPointerEvents(PE_VISIBLE_STROKE);
-                    break;
-                case CSS_VAL_VISIBLE:
-                    svgstyle->setPointerEvents(PE_VISIBLE);
-                    break;
-                case CSS_VAL_PAINTED:
-                    svgstyle->setPointerEvents(PE_PAINTED);
-                    break;
-                case CSS_VAL_FILL:
-                    svgstyle->setPointerEvents(PE_FILL);
-                    break;
-                case CSS_VAL_STROKE:
-                    svgstyle->setPointerEvents(PE_STROKE);
-                default:
-                    return;
-            }
-
+            
+            svgstyle->setPointerEvents(*primitiveValue);
             break;
         }
         case CSS_PROP_DOMINANT_BASELINE:
         {
             HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
-            if (!primitiveValue)
-                break;
-    
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_AUTO:
-                    svgstyle->setDominantBaseline(DB_AUTO);
-                    break;
-                case CSS_VAL_USE_SCRIPT:
-                    svgstyle->setDominantBaseline(DB_USE_SCRIPT);
-                    break;
-                case CSS_VAL_NO_CHANGE:
-                    svgstyle->setDominantBaseline(DB_NO_CHANGE);
-                    break;
-                case CSS_VAL_RESET_SIZE:
-                    svgstyle->setDominantBaseline(DB_RESET_SIZE);
-                    break;
-                case CSS_VAL_IDEOGRAPHIC:
-                    svgstyle->setDominantBaseline(DB_IDEOGRAPHIC);
-                    break;
-                case CSS_VAL_ALPHABETIC:
-                    svgstyle->setDominantBaseline(DB_ALPHABETIC);
-                    break;
-                case CSS_VAL_HANGING:
-                    svgstyle->setDominantBaseline(DB_HANGING);
-                    break;
-                case CSS_VAL_MATHEMATICAL:
-                    svgstyle->setDominantBaseline(DB_MATHEMATICAL);
-                    break;
-                case CSS_VAL_CENTRAL:
-                    svgstyle->setDominantBaseline(DB_CENTRAL);
-                    break;
-                case CSS_VAL_MIDDLE:
-                    svgstyle->setDominantBaseline(DB_MIDDLE);
-                    break;
-                case CSS_VAL_TEXT_AFTER_EDGE:
-                    svgstyle->setDominantBaseline(DB_TEXT_AFTER_EDGE);
-                    break;
-                case CSS_VAL_TEXT_BEFORE_EDGE:
-                    svgstyle->setDominantBaseline(DB_TEXT_BEFORE_EDGE);
-                    break;
-                default:
-                    return;
-            }
-    
+            if (primitiveValue)
+                svgstyle->setDominantBaseline(*primitiveValue);
             break;
         }
         case CSS_PROP_COLOR_INTERPOLATION:
         {
             HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
-            if (!primitiveValue)
-                return;
-                
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_SRGB:
-                    svgstyle->setColorInterpolation(CI_SRGB);
-                    break;
-                case CSS_VAL_LINEARRGB:
-                    svgstyle->setColorInterpolation(CI_LINEARRGB);
-                    break;
-                case CSS_VAL_AUTO:
-                    svgstyle->setColorInterpolation(CI_AUTO);
-                default:
-                    return;
-            }
-    
+            if (primitiveValue)
+                svgstyle->setColorInterpolation(*primitiveValue);
             break;
         }
         case CSS_PROP_COLOR_INTERPOLATION_FILTERS:
         {
             HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
-            if (!primitiveValue)
-                return;
-                
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_SRGB:
-                    svgstyle->setColorInterpolationFilters(CI_SRGB);
-                    break;
-                case CSS_VAL_LINEARRGB:
-                    svgstyle->setColorInterpolationFilters(CI_LINEARRGB);
-                    break;
-                case CSS_VAL_AUTO:
-                    svgstyle->setColorInterpolationFilters(CI_AUTO);
-                default:
-                    return;
-            }
-            
+            if (primitiveValue)
+                svgstyle->setColorInterpolationFilters(*primitiveValue);
+            break;
+        }
+        case CSS_PROP_COLOR_RENDERING:
+        {
+            HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
+            if (primitiveValue)
+                svgstyle->setColorRendering(*primitiveValue);
             break;
         }
         case CSS_PROP_CLIP_RULE:
         {
             HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
-            if (!primitiveValue)
-                break;
-                
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_NONZERO:
-                    svgstyle->setClipRule(RULE_NONZERO);
-                    break;
-                case CSS_VAL_EVENODD:
-                    svgstyle->setClipRule(RULE_EVENODD);
-                    break;
-                default:
-                    break;
-            }
-        
+            if (primitiveValue)
+                svgstyle->setClipRule(*primitiveValue);
             break;
         }
         case CSS_PROP_FILL_RULE:
         {
             HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
-            if (!primitiveValue)
-                break;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_NONZERO:
-                    svgstyle->setFillRule(RULE_NONZERO);
-                    break;
-                case CSS_VAL_EVENODD:
-                    svgstyle->setFillRule(RULE_EVENODD);
-                default:
-                    return;
-            }
-        
+            if (primitiveValue)
+                svgstyle->setFillRule(*primitiveValue);
             break;
         }
         case CSS_PROP_STROKE_LINEJOIN:
         {
             HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
-
-            if (!primitiveValue)
-                break;
-                
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_MITER:
-                    svgstyle->setJoinStyle(MiterJoin);
-                    break;
-                case CSS_VAL_ROUND:
-                    svgstyle->setJoinStyle(RoundJoin);
-                    break;
-                case CSS_VAL_BEVEL:
-                    svgstyle->setJoinStyle(BevelJoin);
-                default:
-                    return;
-            }
-            
+            if (primitiveValue)
+                svgstyle->setJoinStyle(*primitiveValue);
             break;
         }
         case CSS_PROP_IMAGE_RENDERING:
         {
             HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
-            if (!primitiveValue)
-                return;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_AUTO:
-                    svgstyle->setImageRendering(IR_AUTO);
-                case CSS_VAL_OPTIMIZESPEED:
-                    svgstyle->setImageRendering(IR_OPTIMIZESPEED);
-                case CSS_VAL_OPTIMIZEQUALITY:
-                    svgstyle->setImageRendering(IR_OPTIMIZEQUALITY);
-            }
+            if (primitiveValue)
+                svgstyle->setImageRendering(*primitiveValue);
             break;
         }
         case CSS_PROP_SHAPE_RENDERING:
         {
             HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
-            if (!primitiveValue)
-                return;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_AUTO:
-                    svgstyle->setShapeRendering(SR_AUTO);
-                case CSS_VAL_OPTIMIZESPEED:
-                    svgstyle->setShapeRendering(SR_OPTIMIZESPEED);
-                case CSS_VAL_CRISPEDGES:
-                    svgstyle->setShapeRendering(SR_CRISPEDGES);
-                case CSS_VAL_GEOMETRICPRECISION:
-                    svgstyle->setShapeRendering(SR_GEOMETRICPRECISION);
-            }
+            if (primitiveValue)
+                svgstyle->setShapeRendering(*primitiveValue);
             break;
         }
         case CSS_PROP_TEXT_RENDERING:
         {
             HANDLE_INHERIT_AND_INITIAL(textRendering, TextRendering)
-            if (!primitiveValue)
-                return;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_AUTO:
-                    svgstyle->setTextRendering(TR_AUTO);
-                case CSS_VAL_OPTIMIZESPEED:
-                    svgstyle->setTextRendering(TR_OPTIMIZESPEED);
-                case CSS_VAL_OPTIMIZELEGIBILITY:
-                    svgstyle->setTextRendering(TR_OPTIMIZELEGIBILITY);
-                case CSS_VAL_GEOMETRICPRECISION:
-                    svgstyle->setTextRendering(TR_GEOMETRICPRECISION);
-            }
+            if (primitiveValue)
+                svgstyle->setTextRendering(*primitiveValue);
             break;
         }
         // end of ident only properties
@@ -585,22 +384,8 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
         case CSS_PROP_STROKE_LINECAP:
         {
             HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
-            if (!primitiveValue)
-                break;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_BUTT:
-                    svgstyle->setCapStyle(ButtCap);
-                    break;
-                case CSS_VAL_ROUND:
-                    svgstyle->setCapStyle(RoundCap);
-                    break;
-                case CSS_VAL_SQUARE:
-                    svgstyle->setCapStyle(SquareCap);
-                default:
-                    return;
-            }
-
+            if (primitiveValue)
+                svgstyle->setCapStyle(*primitiveValue);
             break;
         }
         case CSS_PROP_STROKE_MITERLIMIT:
@@ -669,29 +454,15 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
         case CSS_PROP_TEXT_ANCHOR:
         {
             HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
-            if (!primitiveValue)
-                break;
-            
-            switch (primitiveValue->getIdent()) {
-                case CSS_VAL_START:
-                    svgstyle->setTextAnchor(TA_START);
-                    break;
-                case CSS_VAL_MIDDLE:
-                    svgstyle->setTextAnchor(TA_MIDDLE);
-                    break;
-                case CSS_VAL_END:
-                    svgstyle->setTextAnchor(TA_END);
-                default:
-                    return;
-            }
-            
+            if (primitiveValue)
+                svgstyle->setTextAnchor(*primitiveValue);
             break;
         }
         case CSS_PROP_WRITING_MODE:
         {
             HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
             if (primitiveValue)
-                svgstyle->setWritingMode((EWritingMode)(primitiveValue->getIdent() - CSS_VAL_LR_TB));
+                svgstyle->setWritingMode(*primitiveValue);
             break;
         }
         case CSS_PROP_STOP_COLOR: