Exemplo n.º 1
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);
    }
}
Exemplo n.º 2
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;
    }
}