RESOLVED FIXED Bug 12059
SVG colors have two separate parsing paths (one CSS and one SVGColor::setRGBColor)
https://bugs.webkit.org/show_bug.cgi?id=12059
Summary SVG colors have two separate parsing paths (one CSS and one SVGColor::setRGBC...
Eric Seidel (no email)
Reported 2007-01-01 11:53:21 PST
SVG colors have two separate parsing paths (one CSS and one SVGColor::setRGBColor) That's just an accident waiting to happen. Ideally these should be unified into a single parser.
Attachments
First attempt (12.39 KB, patch)
2007-08-19 10:08 PDT, Rob Buis
sam: review-
Added some comments (12.54 KB, patch)
2007-08-20 11:50 PDT, Rob Buis
sam: review-
Slightly different approach (17.38 KB, patch)
2007-08-21 13:29 PDT, Rob Buis
sam: review+
Rob Buis
Comment 1 2007-06-12 10:31:04 PDT
Needs to be done, but low prio.
Rob Buis
Comment 2 2007-08-19 10:08:09 PDT
Created attachment 16022 [details] First attempt This tries to combine the two codepaths. Note that unfortunately I have to test for rgba,hsl and hsla constructs. One way to avoid it may be to make the parser aware that it is parsing svg css, but that needs more discussion I suppose. One further thing that could fix is to parse SVG color property and deliver a SVGColor, not a CSSPrimitiveValue like now. Cheers, Rob.
Sam Weinig
Comment 3 2007-08-19 17:49:31 PDT
in RGBA32 CSSParser::parseColor(const String& string, bool strict) + parseColor(color, string, strict); + return color; Is it okay to ignore the return boolean of parseColor here?
Sam Weinig
Comment 4 2007-08-19 17:51:15 PDT
Another question, is this line + if (s.startsWith("hsl") || s.startsWith("rgba") || supposed to be s.startsWith("rgba") and not s.startsWith("rgb") ?
Sam Weinig
Comment 5 2007-08-19 17:54:01 PDT
Comment on attachment 16022 [details] First attempt r- until the above questions are answered.
Rob Buis
Comment 6 2007-08-19 23:48:56 PDT
Hi, (In reply to comment #4) > Another question, is this line > > + if (s.startsWith("hsl") || s.startsWith("rgba") || > > supposed to be s.startsWith("rgba") and not s.startsWith("rgb") ? Yes, if you look at CSSParser::parseColorFromValue you see rgb( is accepted by svg, but a check is made for rgba(, hsl( and hsla( to not be accepted if the svg flag is true. Cheers, Rob.
Rob Buis
Comment 7 2007-08-19 23:51:51 PDT
Hi Sam, (In reply to comment #3) > in RGBA32 CSSParser::parseColor(const String& string, bool strict) > > + parseColor(color, string, strict); > + return color; > > Is it okay to ignore the return boolean of parseColor here? Well, the old behaviour returned transparent color (all 0) but still valid color unless a color was found, I am emulating that behaviour here. Cheers, Rob.
Sam Weinig
Comment 8 2007-08-20 09:04:51 PDT
Rob, Sounds good. If you would add a comment in the code about those 2 cases it would be great.
Rob Buis
Comment 9 2007-08-20 11:50:24 PDT
Created attachment 16035 [details] Added some comments Added some comments as per Sam's suggestion. Cheers, Rob.
Sam Weinig
Comment 10 2007-08-21 11:59:48 PDT
Comment on attachment 16035 [details] Added some comments Talked to Rob in IRC about expanding the explanation in the comments to be more.
Rob Buis
Comment 11 2007-08-21 13:29:33 PDT
Created attachment 16062 [details] Slightly different approach This one has just one method and enables the client to set up a rgba32 default value, like what has happened in the past for html canvas code. Cheers, Rob.
Rob Buis
Comment 12 2007-08-22 02:03:06 PDT
Landed in r25183.
Note You need to log in before you can comment on or make changes to this bug.