Bug 157402 - 4 and 8 digit color attributes should use the crazypants algorithm, not the CSS one.
Summary: 4 and 8 digit color attributes should use the crazypants algorithm, not the C...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-05-05 18:01 PDT by Dean Jackson
Modified: 2016-05-05 18:26 PDT (History)
5 users (show)

See Also:


Attachments
Patch (6.74 KB, patch)
2016-05-05 18:06 PDT, Dean Jackson
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2016-05-05 18:01:37 PDT
4 and 8 digit color attributes should use the crazypants algorithm, not the CSS one.
Comment 1 Dean Jackson 2016-05-05 18:06:35 PDT
Created attachment 278213 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2016-05-05 18:07:49 PDT
<rdar://problem/26131142>
Comment 3 Simon Fraser (smfr) 2016-05-05 18:17:24 PDT
Comment on attachment 278213 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278213&action=review

> Source/WebCore/html/HTMLElement.cpp:1150
> +    if ((colorString.length() == 4 || colorString.length() == 7) && colorString[0] == '#')
> +        color = Color(colorString);
> +    if (!color.isValid())
> +        color.setNamedColor(colorString);

Should there be an 'else' here since a named color will never start with a '#' ?
Comment 4 Dean Jackson 2016-05-05 18:22:51 PDT
Comment on attachment 278213 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278213&action=review

>> Source/WebCore/html/HTMLElement.cpp:1150
>> +        color.setNamedColor(colorString);
> 
> Should there be an 'else' here since a named color will never start with a '#' ?

No. If it is a named color, it didn't pass the conditional above, which means it is still its default value (invalid).

However, if it *is* something like "#abc" and it fails Color(colorString) then we want the next condition to execute. This is because "#fzz" is actually an ok value in HTML color attributes - it becomes rgb(15, 0, 0)!!! Yes, the whole thing is crazy. I don't even understand how this behaviour happened in the first place.
Comment 5 Dean Jackson 2016-05-05 18:26:13 PDT
Committed r200501: <http://trac.webkit.org/changeset/200501>