Bug 80382

Summary: Selection Background Color Error
Product: WebKit Reporter: James Kyle <me>
Component: Layout and RenderingAssignee: Shezan Baig <shezbaig.wk>
Status: RESOLVED FIXED    
Severity: Trivial CC: andersca, ap, bdakin, hyatt, mitz, rniwa, shanestephens, shezbaig.wk, simon.fraser, webkit.review.bot
Priority: P5    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.7   
URL: http://jsfiddle.net/JamesKyle/3zAsJ/
Attachments:
Description Flags
first attempt
none
simple test case
none
Patch none

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.