Bug 80382 - Selection Background Color Error
Summary: Selection Background Color Error
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.7
: P5 Trivial
Assignee: Shezan Baig
URL: http://jsfiddle.net/JamesKyle/3zAsJ/
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-05 22:58 PST by James Kyle
Modified: 2012-05-07 14:30 PDT (History)
10 users (show)

See Also:


Attachments
first attempt (21.91 KB, patch)
2012-04-12 15:04 PDT, Shezan Baig
no flags Details | Formatted Diff | Diff
simple test case (1.43 KB, text/html)
2012-04-26 12:41 PDT, Shezan Baig
no flags Details
Patch (12.37 KB, patch)
2012-04-26 12:59 PDT, Shezan Baig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Kyle 2012-03-05 22:58:45 PST
* { color: #### }
*::selection { background:  #### }

Selection Background color turns black or white. 

Whenever both #### have the same alpha transparency using HSLa or RGBa. Limited when HSL or RGB is BLACK or WHITE.


Not a major one but probably a quick fix, I captured my experimenting in a jsFiddle: http://jsfiddle.net/JamesKyle/3zAsJ/
Comment 1 Shezan Baig 2012-04-12 15:04:25 PDT
Created attachment 136980 [details]
first attempt

First attempt at this bug.  The selection background color is being compared against the regular text color instead of the selection text color.  This patch fixes this by computing the selection text color first, and using that to compare with the selection background color when choosing whether or not to invert.
Comment 2 Alexey Proskuryakov 2012-04-12 17:06:15 PDT
Please set r? flag, not r+.
Comment 3 Shezan Baig 2012-04-12 17:24:23 PDT
Oops, sorry.  changed to r?
Comment 4 Shezan Baig 2012-04-17 14:40:26 PDT
Behavior in other browsers:

* Firefox 11.0: Seems to completely ignore the ::selection style (which is obviously wrong).

* MSIE 9: Respects the ::selection style.  In the selection-background-color.html test in the patch, the background for the first block is black, and the bavkground for the second block is green.
Comment 5 Shezan Baig 2012-04-26 12:32:00 PDT
update for firefox behavior:

Firefox works as expected when using "::-moz-selection" (the background for the first block is black, and the background for the second block is green)
Comment 6 Shezan Baig 2012-04-26 12:33:55 PDT
Opera also works the same as IE9.  Right now only WebKit paints the wrong background color
Comment 7 Shezan Baig 2012-04-26 12:41:47 PDT
Created attachment 139046 [details]
simple test case
Comment 8 Shezan Baig 2012-04-26 12:59:33 PDT
Created attachment 139049 [details]
Patch

new patch uploaded:
* same changes in WebCore
* changed pixel test into a reftest
Comment 9 Dave Hyatt 2012-05-07 14:17:33 PDT
Comment on attachment 139049 [details]
Patch

r=me
Comment 10 WebKit Review Bot 2012-05-07 14:30:14 PDT
Comment on attachment 139049 [details]
Patch

Clearing flags on attachment: 139049

Committed r116353: <http://trac.webkit.org/changeset/116353>
Comment 11 WebKit Review Bot 2012-05-07 14:30:21 PDT
All reviewed patches have been landed.  Closing bug.