Example #1
0
EncodedJSValue JSC_HOST_CALL jsSVGColorPrototypeFunctionSetColor(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSSVGColor::s_info))
        return throwVMTypeError(exec);
    JSSVGColor* castedThis = static_cast<JSSVGColor*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSSVGColor::s_info);
    SVGColor* imp = static_cast<SVGColor*>(castedThis->impl());
    if (exec->argumentCount() < 3)
        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
    ExceptionCode ec = 0;
    unsigned short colorType(exec->argument(0).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& rgbColor(ustringToString(exec->argument(1).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& iccColor(ustringToString(exec->argument(2).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->setColor(colorType, rgbColor, iccColor, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}
Example #2
0
JSValue jsSVGColorColorType(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGColor* castedThis = static_cast<JSSVGColor*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGColor* imp = static_cast<SVGColor*>(castedThis->impl());
    JSValue result = jsNumber(imp->colorType());
    return result;
}
Example #3
0
JSValue jsSVGColorRgbColor(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGColor* castedThis = static_cast<JSSVGColor*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGColor* imp = static_cast<SVGColor*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->rgbColor()));
    return result;
}
static Color colorFromSVGColorCSSValue(CSSValue* value, RenderStyle* style)
{
    ASSERT(value->isSVGColor());
    SVGColor* c = static_cast<SVGColor*>(value);
    Color color;
    if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
        color = style->color();
    else
        color = c->color();
    return color;
}
static v8::Handle<v8::Value> rgbColorAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    SVGColor* imp = V8SVGColor::toNative(info.Holder());
    RefPtr<RGBColor> result = imp->rgbColor();
    v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();
    if (wrapper.IsEmpty()) {
        wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
        if (!wrapper.IsEmpty())
            V8DOMWrapper::setNamedHiddenReference(info.Holder(), "rgbColor", wrapper);
    }
    return wrapper;
}
static v8::Handle<v8::Value> setRGBColorCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    SVGColor* imp = V8SVGColor::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, rgbColor, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    imp->setRGBColor(rgbColor, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
Example #7
0
JSValue* JSSVGColor::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case ColorTypeAttrNum: {
        SVGColor* imp = static_cast<SVGColor*>(impl());

        return jsNumber(imp->colorType());
    }
    case RgbColorAttrNum: {
        SVGColor* imp = static_cast<SVGColor*>(impl());

        return getJSRGBColor(exec, imp->rgbColor());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
Example #8
0
OP_STATUS
SVGPaintParser::ParsePaint(const uni_char *input_string, unsigned input_string_length,
						   SVGPaint& paint)
{
    if (input_string_length == 4 && uni_strncmp(input_string, "none", 4) == 0)
    {
		paint.SetPaintType(SVGPaint::NONE);
		return OpStatus::OK;
    }
    else if (input_string_length == 12 && uni_strncmp(input_string, "currentColor", 12) == 0)
    {
		paint.SetPaintType(SVGPaint::CURRENT_COLOR);
		return OpStatus::OK;
    }
    else
    {
		SVGColor color;
		const uni_char *url_string;
		unsigned url_string_length;
		status = OpStatus::OK;

		tokenizer.Reset(input_string, input_string_length);
		if (tokenizer.ScanURL(url_string, url_string_length))
		{
			paint.SetPaintType(SVGPaint::URI);
			paint.SetURI(url_string, url_string_length);

			tokenizer.EatWsp();
			if (!tokenizer.IsEnd())
				ScanBackupPaint(paint);
		}
		else if (ScanColor(color))
		{
			paint.SetPaintType(SVGPaint::RGBCOLOR);
			paint.SetColorRef(color.GetColorRef());
		}
		else
		{
			status = OpStatus::ERR;
		}

		return tokenizer.ReturnStatus(status);
    }
}
Example #9
0
void
SVGPaintParser::ScanBackupPaint(SVGPaint &paint)
{
    SVGColor color;
    if (tokenizer.Scan("none"))
    {
		paint.SetPaintType(SVGPaint::URI_NONE);
    }
    else if (tokenizer.Scan("currentColor"))
    {
		paint.SetPaintType(SVGPaint::URI_CURRENT_COLOR);
    }
    else if (ScanColor(color))
    {
		paint.SetPaintType(SVGPaint::URI_RGBCOLOR);
		paint.SetColorRef(color.GetColorRef());
    }
    else
    {
		status = OpStatus::ERR;
    }
}
Example #10
0
JSValue* JSSVGColorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSSVGColor::info))
      return throwError(exec, TypeError);

    SVGColor* imp = static_cast<SVGColor*>(static_cast<JSSVGColor*>(thisObj)->impl());

    switch (id) {
    case JSSVGColor::SetRGBColorFuncNum: {
        ExceptionCode ec = 0;
        String rgbColor = args[0]->toString(exec);

        imp->setRGBColor(rgbColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSSVGColor::SetRGBColorICCColorFuncNum: {
        ExceptionCode ec = 0;
        String rgbColor = args[0]->toString(exec);
        String iccColor = args[1]->toString(exec);

        imp->setRGBColorICCColor(rgbColor, iccColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSSVGColor::SetColorFuncNum: {
        ExceptionCode ec = 0;
        unsigned short colorType = args[0]->toInt32(exec);
        String rgbColor = args[1]->toString(exec);
        String iccColor = args[2]->toString(exec);

        imp->setColor(colorType, rgbColor, iccColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    }
    return 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;
    }
static v8::Handle<v8::Value> colorTypeAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    SVGColor* imp = V8SVGColor::toNative(info.Holder());
    return v8Integer(imp->colorType(), info.GetIsolate());
}
Example #13
0
BOOL
SVGPaintParser::ScanColor(SVGColor &color)
{
	BOOL rgb = tokenizer.Scan("rgb");
	if (rgb || tokenizer.Scan("hsl"))
    {
		BOOL has_alpha = tokenizer.Scan('a');

		if (!tokenizer.Scan('('))
			return FALSE;

		COLORREF cref;
		if (rgb)
		{
			unsigned int r,g,b;

			ColorChannel(r);
			ColorChannel(g);
			ColorChannel(b);

			if (has_alpha)
			{
				UINT8 a = AChannel();
				cref = OP_RGBA(r, g, b, a);
			}
			else
				cref = OP_RGB(r,g,b);
		}
		else // hsl
		{
			unsigned int h,s,l;

			if (!ColorChannel(h, 360, ALLOW_NUMBER) ||
				!ColorChannel(s, 100, ALLOW_PERCENTAGE) ||
				!ColorChannel(l, 100, ALLOW_PERCENTAGE))
				return FALSE;

			if (has_alpha)
			{
				UINT8 a = AChannel();
				cref = HSLA_TO_RGBA((float)h, (float)s, (float)l, (a+0.5f)/255.0f);
			}
			else
				cref = HSLA_TO_RGBA((float)h, (float)s, (float)l);
		}

		color.SetColorType(SVGColor::SVGCOLOR_RGBCOLOR);
		color.SetColorRef(cref);
		return tokenizer.Scan(')');
    }
    else
    {
		COLORREF cref = USE_DEFAULT_COLOR;

		// Hex-form or color name (eg. '#cacaca' or 'black'). No
		// color names contains other letters than alphabetic one
		// (lowercase). Hex-form contains digits and some lower or
		// upper case
		if (tokenizer.Scan('#'))
		{
			cref = ScanHexColor();
		}
		else
		{
			SVGTokenizer::State saved_state = tokenizer.state;

			const uni_char *color_string = tokenizer.CurrentString();
			unsigned c = tokenizer.CurrentCharacter();
			unsigned n = 0;

			while (c >= 'a' && c <= 'z' ||
				   c >= 'A' && c <= 'Z')
			{
				c = tokenizer.Shift(n);
			}

			if (n > 0)
			{
				cref = HTM_Lex::GetColIdxByName(color_string, n);
				if(cref == USE_DEFAULT_COLOR)
				{
					short keyword = CSS_GetKeyword(color_string, n);
					if(CSS_is_ui_color_val(keyword))
					{
						cref = keyword | CSS_COLOR_KEYWORD_TYPE_ui_color;
					}
				}
			}

			if (cref == USE_DEFAULT_COLOR)
			{
				// Rewind and try to match as a (hash-less) hex-color
				tokenizer.state = saved_state;

				cref = ScanHexColor();
			}
		}

		if (cref == USE_DEFAULT_COLOR)
			return FALSE;

		color.SetColorType(SVGColor::SVGCOLOR_RGBCOLOR);
		color.SetColorRef(cref);
		return TRUE;
    }
}