[webkit-reviews] review denied: [Bug 63029] Fix legacy color attribute parsing to match HTML spec : [Attachment 97909] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Jun 20 20:28:30 PDT 2011
Simon Fraser (smfr) <simon.fraser at apple.com> has denied Tab Atkins
<tabatkins at google.com>'s request for review:
Bug 63029: Fix legacy color attribute parsing to match HTML spec
https://bugs.webkit.org/show_bug.cgi?id=63029
Attachment 97909: Patch
https://bugs.webkit.org/attachment.cgi?id=97909&action=review
------- Additional Comments from Simon Fraser (smfr) <simon.fraser at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=97909&action=review
r- on the return after else, and you might want to do one final round.
> Source/WebCore/dom/StyledElement.cpp:332
> + int colors[3] = { 0, 0, 0 };
This would be better called 'components'.
> Source/WebCore/dom/StyledElement.cpp:340
> + colors[2] = foundColor.blue();
Can't we call setProperty() here directly, rather than doing a String::format()
which we have to re-parse again later?
> Source/WebCore/dom/StyledElement.cpp:344
> + } else {
We avoid 'else' after return.
> Source/WebCore/dom/StyledElement.cpp:345
> + // Otherwise, use the crazy legacy parsing rules.
Might be nice to put the legacy parsing code into its own method, then the code
becomes self-documenting.
> Source/WebCore/dom/StyledElement.cpp:347
> + // FIXME: Replace all non-BMP characters in color with "00".
You should file a follow-up bug for this FIXME, but is this not what the
isASCIIHexDigit() code below is doing?
> Source/WebCore/dom/StyledElement.cpp:369
> + // Otherwise, we have at least 6 digits.
You should ASSERT this
> Source/WebCore/dom/StyledElement.cpp:372
> + int componentSearchWindowSize = min(componentLength,
static_cast<size_t>(8));
You can avoid the ugly static_cast by using min<int>()
> Source/WebCore/dom/StyledElement.cpp:395
> + color = String::format("#%02x%02x%02x", colors[0], colors[1],
colors[2]);
It's a shame to do all this work to compute the color components, and then turn
around and make a String out of them.
More information about the webkit-reviews
mailing list