Exemplo n.º 1
0
void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
{
    CSSPrimitiveValue* primitiveValue = 0;
    if (value->isPrimitiveValue())
        primitiveValue = static_cast<CSSPrimitiveValue*>(value);

    SVGRenderStyle* svgstyle = m_style->accessSVGStyle();
    unsigned short valueType = value->cssValueType();
    
    bool isInherit = m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
    bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);

    // 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 (id)
    {
        // ident only properties
        case CSSPropertyAlignmentBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
            if (!primitiveValue)
                break;
            
            svgstyle->setAlignmentBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyBaselineShift:
        {
            HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
            if (!primitiveValue)
                break;

            if (primitiveValue->getIdent()) {
                switch (primitiveValue->getIdent()) {
                case CSSValueBaseline:
                    svgstyle->setBaselineShift(BS_BASELINE);
                    break;
                case CSSValueSub:
                    svgstyle->setBaselineShift(BS_SUB);
                    break;
                case CSSValueSuper:
                    svgstyle->setBaselineShift(BS_SUPER);
                    break;
                default:
                    break;
                }
            } else {
                svgstyle->setBaselineShift(BS_LENGTH);
                svgstyle->setBaselineShiftValue(primitiveValue);
            }

            break;
        }
        case CSSPropertyKerning:
        {
            if (isInherit) {
                HANDLE_INHERIT_COND(CSSPropertyKerning, kerning, Kerning)
                return;
            }
            else if (isInitial) {
                HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyKerning, Kerning, Kerning)
                return;
            }

            svgstyle->setKerning(primitiveValue);
            break;
        }
        case CSSPropertyPointerEvents:
        {
            HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
            if (!primitiveValue)
                break;
            
            svgstyle->setPointerEvents(*primitiveValue);
            break;
        }
        case CSSPropertyDominantBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
            if (primitiveValue)
                svgstyle->setDominantBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolation:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
            if (primitiveValue)
                svgstyle->setColorInterpolation(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolationFilters:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
            if (primitiveValue)
                svgstyle->setColorInterpolationFilters(*primitiveValue);
            break;
        }
        case CSSPropertyColorRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
            if (primitiveValue)
                svgstyle->setColorRendering(*primitiveValue);
            break;
        }
        case CSSPropertyClipRule:
        {
            HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
            if (primitiveValue)
                svgstyle->setClipRule(*primitiveValue);
            break;
        }
        case CSSPropertyFillRule:
        {
            HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
            if (primitiveValue)
                svgstyle->setFillRule(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeLinejoin:
        {
            HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
            if (primitiveValue)
                svgstyle->setJoinStyle(*primitiveValue);
            break;
        }
        case CSSPropertyImageRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
            if (primitiveValue)
                svgstyle->setImageRendering(*primitiveValue);
            break;
        }
        case CSSPropertyShapeRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
            if (primitiveValue)
                svgstyle->setShapeRendering(*primitiveValue);
            break;
        }
        case CSSPropertyTextRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(textRendering, TextRendering)
            if (primitiveValue)
                svgstyle->setTextRendering(*primitiveValue);
            break;
        }
        // end of ident only properties
        case CSSPropertyFill:
        {
            HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint)
            if (!primitiveValue && value) {
                SVGPaint *paint = static_cast<SVGPaint*>(value);
                if (paint)
                    svgstyle->setFillPaint(paint);
            }
            
            break;
        }
        case CSSPropertyStroke:
        {
            HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint)
            if (!primitiveValue && value) {
                SVGPaint *paint = static_cast<SVGPaint*>(value);
                if (paint)
                    svgstyle->setStrokePaint(paint);
            }
            
            break;
        }
        case CSSPropertyStrokeWidth:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
            if (!primitiveValue)
                return;
        
            svgstyle->setStrokeWidth(primitiveValue);
            break;
        }
        case CSSPropertyStrokeDasharray:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
            if (!primitiveValue && value) {
                CSSValueList* dashes = static_cast<CSSValueList*>(value);
                if (dashes)
                    svgstyle->setStrokeDashArray(dashes);
            }
        
            break;
        }
        case CSSPropertyStrokeDashoffset:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
            if (!primitiveValue)
                return;

            svgstyle->setStrokeDashOffset(primitiveValue);
            break;
        }
        case CSSPropertyFillOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFillOpacity(f);
            break;
        }
        case CSSPropertyStrokeOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeOpacity(f);
            break;
        }
        case CSSPropertyStopOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStopOpacity(f);
            break;
        }
        case CSSPropertyMarkerStart:
        {
            HANDLE_INHERIT_AND_INITIAL(startMarker, StartMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setStartMarker(s);
            break;
        }
        case CSSPropertyMarkerMid:
        {
            HANDLE_INHERIT_AND_INITIAL(midMarker, MidMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMidMarker(s);
            break;
        }
        case CSSPropertyMarkerEnd:
        {
            HANDLE_INHERIT_AND_INITIAL(endMarker, EndMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setEndMarker(s);
            break;
        }
        case CSSPropertyStrokeLinecap:
        {
            HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
            if (primitiveValue)
                svgstyle->setCapStyle(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeMiterlimit:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeMiterLimit(f);
            break;
        }
        case CSSPropertyFilter:
        {
            HANDLE_INHERIT_AND_INITIAL(filter, Filter)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;
            svgstyle->setFilter(s);
            break;
        }
        case CSSPropertyMask:
        {
            HANDLE_INHERIT_AND_INITIAL(maskElement, MaskElement)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMaskElement(s);
            break;
        }
        case CSSPropertyClipPath:
        {
            HANDLE_INHERIT_AND_INITIAL(clipPath, ClipPath)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setClipPath(s);
            break;
        }
        case CSSPropertyTextAnchor:
        {
            HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
            if (primitiveValue)
                svgstyle->setTextAnchor(*primitiveValue);
            break;
        }
        case CSSPropertyWritingMode:
        {
            HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
            if (primitiveValue)
                svgstyle->setWritingMode(*primitiveValue);
            break;
        }
        case CSSPropertyStopColor:
        {
            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);

            SVGColor* c = static_cast<SVGColor*>(value);
            if (!c)
                return CSSStyleSelector::applyProperty(id, value);

            Color col;
            if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
                col = m_style->color();
            else
                col = c->color();

            svgstyle->setStopColor(col);
            break;
        }
       case CSSPropertyLightingColor:
        {
            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);

            SVGColor* c = static_cast<SVGColor*>(value);
            if (!c)
                return CSSStyleSelector::applyProperty(id, value);

            Color col;
            if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
                col = m_style->color();
            else
                col = c->color();

            svgstyle->setLightingColor(col);
            break;
        }
        case CSSPropertyFloodOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFloodOpacity(f);
            break;
        }
        case CSSPropertyFloodColor:
        {
            Color col;
            if (isInitial)
                col = SVGRenderStyle::initialFloodColor();
            else {
                SVGColor *c = static_cast<SVGColor*>(value);
                if (!c)
                    return CSSStyleSelector::applyProperty(id, value);

                if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
                    col = m_style->color();
                else
                    col = c->color();
            }

            svgstyle->setFloodColor(col);
            break;
        }
        case CSSPropertyGlyphOrientationHorizontal:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
            }

            break;
        }
        case CSSPropertyGlyphOrientationVertical:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
            } else if (primitiveValue->getIdent() == CSSValueAuto)
                svgstyle->setGlyphOrientationVertical(GO_AUTO);

            break;
        }
        case CSSPropertyEnableBackground:
            // Silently ignoring this property for now
            // http://bugs.webkit.org/show_bug.cgi?id=6022
            break;
        default:
            // If you crash here, it's because you added a css property and are not handling it
            // in either this switch statement or the one in CSSStyleSelector::applyProperty
            ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
            return;
    }
Exemplo n.º 2
0
void CSSStyleSelector::applySVGRule(int id, DOM::CSSValueImpl* value)
{
    CSSPrimitiveValueImpl* primitiveValue = 0;
    if (value->isPrimitiveValue())
        primitiveValue = static_cast<CSSPrimitiveValueImpl*>(value);

    SVGRenderStyle* svgstyle = style->accessSVGStyle();
    unsigned short valueType = value->cssValueType();
    
    bool isInherit = parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
    bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);

    // 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 (id) {
        // ident only properties
        case CSS_PROP_ALIGNMENT_BASELINE:
        {
            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:
                break;
            }
            break;
        }
        case CSS_PROP_BASELINE_SHIFT:
        {
            HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
            if (!primitiveValue)
                break;

            if (primitiveValue->getIdent()) {
                switch (primitiveValue->getIdent()) {
                case CSS_VAL_BASELINE:
                    svgstyle->setBaselineShift(BS_BASELINE);
                    break;
                case CSS_VAL_SUB:
                    svgstyle->setBaselineShift(BS_SUB);
                    break;
                case CSS_VAL_SUPER:
                    svgstyle->setBaselineShift(BS_SUPER);
                    break;
                default:
                    break;
                }
            } else {
                svgstyle->setBaselineShift(BS_LENGTH);
                svgstyle->setBaselineShiftValue(primitiveValue);
            }

            break;
        }
        case CSS_PROP_KERNING:
        {
            if (isInherit) {
                HANDLE_INHERIT_COND(CSS_PROP_KERNING, kerning, Kerning)
                return;
            }
            else if (isInitial) {
                HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_KERNING, Kerning, Kerning)
                return;
            }
            svgstyle->setKerning(primitiveValue);
            break;
        }
        case CSS_PROP_POINTER_EVENTS:
        {
            HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
            case CSS_VAL_NONE:
                svgstyle->setPointerEvents(PE_NONE);
                break;
            case CSS_VAL_STROKE:
                svgstyle->setPointerEvents(PE_STROKE);
                break;
            case CSS_VAL_FILL:
                svgstyle->setPointerEvents(PE_FILL);
                break;
            case CSS_VAL_PAINTED:
                svgstyle->setPointerEvents(PE_PAINTED);
                break;
            case CSS_VAL_VISIBLE:
                svgstyle->setPointerEvents(PE_VISIBLE);
                break;
            case CSS_VAL_VISIBLESTROKE:
                svgstyle->setPointerEvents(PE_VISIBLE_STROKE);
                break;
            case CSS_VAL_VISIBLEFILL:
                svgstyle->setPointerEvents(PE_VISIBLE_FILL);
                break;
            case CSS_VAL_VISIBLEPAINTED:
                svgstyle->setPointerEvents(PE_VISIBLE_PAINTED);
                break;
            case CSS_VAL_ALL:
                svgstyle->setPointerEvents(PE_ALL);
                break;
            default:
                break;
            }
            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:
                break;
            }

            break;
        }
        case CSS_PROP_COLOR_INTERPOLATION:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation);

            svgstyle->setColorInterpolation(colorInterpolationForValue(primitiveValue));
            break;
        }
        case CSS_PROP_COLOR_INTERPOLATION_FILTERS:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)

            svgstyle->setColorInterpolationFilters(colorInterpolationForValue(primitiveValue));
            break;
        }
        case CSS_PROP_COLOR_RENDERING:
        {
            HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
            case CSS_VAL_AUTO:
                svgstyle->setColorRendering(CR_AUTO);
                break;
            case CSS_VAL_OPTIMIZESPEED:
                svgstyle->setColorRendering(CR_OPTIMIZESPEED);
                break;
            case CSS_VAL_OPTIMIZEQUALITY:
                svgstyle->setColorRendering(CR_OPTIMIZEQUALITY);
                break;
            default:
                break;
            }
            break;
        }
        case CSS_PROP_CLIP_RULE:
        {
            HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
            if (primitiveValue)
                svgstyle->setClipRule((primitiveValue->getIdent() == CSS_VAL_NONZERO) ? RULE_NONZERO : RULE_EVENODD);
            break;
        }
        case CSS_PROP_FILL_RULE:
        {
            HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
            if (primitiveValue)
                svgstyle->setFillRule((primitiveValue->getIdent() == CSS_VAL_NONZERO) ? RULE_NONZERO : RULE_EVENODD);
            break;
        }

        case CSS_PROP_STROKE_LINEJOIN:
        {
            HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
                case CSS_VAL_MITER:
                    svgstyle->setJoinStyle(khtml::MiterJoin);
                    break;
                case CSS_VAL_ROUND:
                    svgstyle->setJoinStyle(khtml::RoundJoin);
                    break;
                case CSS_VAL_BEVEL:
                    svgstyle->setJoinStyle(khtml::BevelJoin);
                    break;
                default:
                    break;
            }
            break;
        }
        case CSS_PROP_IMAGE_RENDERING:
        {
            HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
                case CSS_VAL_AUTO:
                    svgstyle->setImageRendering(IR_AUTO);
                    break;
                case CSS_VAL_OPTIMIZESPEED:
                    svgstyle->setImageRendering(IR_OPTIMIZESPEED);
                    break;
                case CSS_VAL_OPTIMIZEQUALITY:
                    svgstyle->setImageRendering(IR_OPTIMIZEQUALITY);
                    break;
                default:
                    break;
            }
            break;
        }
        case CSS_PROP_SHAPE_RENDERING:
        {
            HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
                case CSS_VAL_AUTO:
                    svgstyle->setShapeRendering(SR_AUTO);
                    break;
                case CSS_VAL_OPTIMIZESPEED:
                    svgstyle->setShapeRendering(SR_OPTIMIZESPEED);
                    break;
                case CSS_VAL_CRISPEDGES:
                    svgstyle->setShapeRendering(SR_CRISPEDGES);
                    break;
                case CSS_VAL_GEOMETRICPRECISION:
                    svgstyle->setShapeRendering(SR_GEOMETRICPRECISION);
                    break;
                default:
                    break;
            }
            break;
        }
        case CSS_PROP_TEXT_RENDERING:
        {
            HANDLE_INHERIT_AND_INITIAL(textRendering, TextRendering)
            if (!primitiveValue)
                break;

            switch (primitiveValue->getIdent()) {
                case CSS_VAL_AUTO:
                    svgstyle->setTextRendering(TR_AUTO);
                    break;
                case CSS_VAL_OPTIMIZESPEED:
                    svgstyle->setTextRendering(TR_OPTIMIZESPEED);
                    break;
                case CSS_VAL_OPTIMIZELEGIBILITY:
                    svgstyle->setTextRendering(TR_OPTIMIZELEGIBILITY);
                    break;
                case CSS_VAL_GEOMETRICPRECISION:
                    svgstyle->setTextRendering(TR_GEOMETRICPRECISION);
                    break;
                default:
                    break;
            }

            break;
        }
        // end of ident only properties
        case CSS_PROP_FILL:
        {
            HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint)
            if (SVGPaintImpl* paint = toPaint(value))
                svgstyle->setFillPaint(paint);
            break;
        }
        case CSS_PROP_STROKE:
        {
            HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint)
            if (SVGPaintImpl* paint = toPaint(value))
                svgstyle->setStrokePaint(paint);
            break;
        }
        case CSS_PROP_STROKE_WIDTH:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
            if (!primitiveValue)
                return;

            svgstyle->setStrokeWidth(primitiveValue);
            break;
        }

        case CSS_PROP_STROKE_DASHARRAY:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
            if (!primitiveValue && value && value->isValueList()) {
                CSSValueListImpl* dashes = static_cast<CSSValueListImpl*>(value);
                svgstyle->setStrokeDashArray(dashes);
            }
            break;
        }
        case CSS_PROP_STROKE_DASHOFFSET:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
            if (!primitiveValue)
                return;

            svgstyle->setStrokeDashOffset(primitiveValue);
            break;
        }
        case CSS_PROP_FILL_OPACITY:
        {
            HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->floatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->floatValue();
            else
                return;

            svgstyle->setFillOpacity(f);
            break;
        }
        case CSS_PROP_STROKE_OPACITY:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->floatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->floatValue();
            else
                return;

            svgstyle->setStrokeOpacity(f);
            break;
        }

        case CSS_PROP_STOP_OPACITY:
        {
            HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->floatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->floatValue();
            else
                return;

            svgstyle->setStopOpacity(f);
            break;
        }

        case CSS_PROP_MARKER_START:
        {
            HANDLE_INHERIT_AND_INITIAL(startMarker, StartMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setStartMarker(s);
            break;
        }
        case CSS_PROP_MARKER_MID:
        {
            HANDLE_INHERIT_AND_INITIAL(midMarker, MidMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMidMarker(s);
            break;
        }
        case CSS_PROP_MARKER_END:
        {
            HANDLE_INHERIT_AND_INITIAL(endMarker, EndMarker)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setEndMarker(s);
            break;
        }
        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);
                break;
            default:
                break;
            }
            break;
        }
        case CSS_PROP_STROKE_MITERLIMIT:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->floatValue();
            else
                return;

            svgstyle->setStrokeMiterLimit(f);
            break;
        }
        case CSS_PROP_FILTER:
        {
            HANDLE_INHERIT_AND_INITIAL(filter, Filter)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;
            svgstyle->setFilter(s);
            break;
        }
        case CSS_PROP_MASK:
        {
            HANDLE_INHERIT_AND_INITIAL(maskElement, MaskElement)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMaskElement(s);
            break;
        }
        case CSS_PROP_CLIP_PATH:
        {
            HANDLE_INHERIT_AND_INITIAL(clipPath, ClipPath)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setClipPath(s);
            break;
        }

        case CSS_PROP_TEXT_ANCHOR:
        {
            HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
            if (primitiveValue) {
                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);
                        break;
                }
            }
            break;
        }

        case CSS_PROP_WRITING_MODE:
        {
            HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
            if (!primitiveValue)
                return;

            switch (primitiveValue->getIdent()) {
                case CSS_VAL_LR_TB:
                    svgstyle->setWritingMode(WM_LRTB);
                    break;
                case CSS_VAL_LR:
                    svgstyle->setWritingMode(WM_LR);
                    break;
                case CSS_VAL_RL_TB:
                    svgstyle->setWritingMode(WM_RLTB);
                    break;
                case CSS_VAL_RL:
                    svgstyle->setWritingMode(WM_RL);
                    break;
                case CSS_VAL_TB_RL:
                    svgstyle->setWritingMode(WM_TBRL);
                    break;
                case CSS_VAL_TB:
                    svgstyle->setWritingMode(WM_TB);
                    break;
                default:
                    break;
            }
            break;
        }

        case CSS_PROP_STOP_COLOR:
        {
            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);

            SVGColorImpl* c = toColor(value);
            if (!c)
                break;

            QColor col;
            if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR)
                col = style->color();
            else
                col = c->color();

            svgstyle->setStopColor(col);
            break;
        }

        case CSS_PROP_LIGHTING_COLOR:
        {
            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);

            SVGColorImpl* c = toColor(value);
            if (!c)
                break;

            QColor col;
            if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR)
                col = style->color();
            else
                col = c->color();

            svgstyle->setLightingColor(col);
            break;
        }
        case CSS_PROP_FLOOD_OPACITY:
        {
            HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->floatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->floatValue();
            else
                return;

            svgstyle->setFloodOpacity(f);
            break;
        }
        case CSS_PROP_FLOOD_COLOR:
        {
            QColor col;
            if (isInitial)
                col = SVGRenderStyle::initialFloodColor();
            else {
                SVGColorImpl* c = toColor(value);
                if (!c)
                    break;

                if (c->colorType() == SVGColorImpl::SVG_COLORTYPE_CURRENTCOLOR)
                    col = style->color();
                else
                    col = c->color();
            }

            svgstyle->setFloodColor(col);
            break;
        }
        case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->floatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
            }

            break;
        }
        case CSS_PROP_GLYPH_ORIENTATION_VERTICAL:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->floatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
            } else if (primitiveValue->getIdent() == CSS_VAL_AUTO)
                svgstyle->setGlyphOrientationVertical(GO_AUTO);

            break;
        }
        case CSS_PROP_ENABLE_BACKGROUND:
            // Silently ignoring this property for now
            // http://bugs.webkit.org/show_bug.cgi?id=6022
            break;
        default:
            // If you crash here, it's because you added a css property and are not handling it
            // in either this switch statement or the one in CSSStyleSelector::applyProperty
            kWarning() << "unimplemented property" << id << getPropertyName(id).string();
            return;
    }