Bug 30694

Summary: Selection draws over content that won't get copied
Product: WebKit Reporter: Evan Martin <evan>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ap, hyatt, ivan.stetsenko, michael.vm, pkasting, simon.fraser, tonikitoo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
screenshot of selection on webkit.org none

Description Evan Martin 2009-10-22 16:55:53 PDT
Created attachment 41698 [details]
screenshot of selection on webkit.org

In the attached screenshot, observe how the selection paints over the sidebar.

Maciej wrote:
"http://daringfireball.net/ is another site that has the same problem, likely for the very same reason. I expect this will happen on any site  uses a large left margin on the main content to lay out around an absolute-positioned sidebar. Some sites use floats for this kind of thing and are not affected. I'm not sure what the best fix is. Maybe we should be stopping selection painting at the border box and not draw into margins. I'm not sure if this would have negative consequences on other sites."
Comment 1 Peter Kasting 2010-06-20 18:32:20 PDT
Ojan has been doing work on selection bugs, so he's a good triage person for this.
Comment 2 Ojan Vafai 2010-07-08 12:23:18 PDT
Stopping selection painting at the border box makes sense to me. The downside, I think, is that you'd get a jagged right edge in some cases. For example:

<div style="width:200px">foo</div>
<div style="width:400px">foo</div>

If you were to select all that, then the top part of the selection would be smaller. My intuition is that's a less common case than the cases like this one that it would fix.
Comment 3 Peter Kasting 2010-07-08 12:24:44 PDT
Seems like hyatt checked in something years ago explicitly to make selection not have jagged edges.  I wonder if that patch is the exact opposite of the suggested fix here.
Comment 4 Ojan Vafai 2012-04-09 11:41:01 PDT
(In reply to comment #3)
> Seems like hyatt checked in something years ago explicitly to make selection not have jagged edges.  I wonder if that patch is the exact opposite of the suggested fix here.

These are all heuristics. We need to pick the one that maximizes only highlighting the part of the DOM you have selected while minimizing jagged edges. I expect highlighting the border-box of elements instead of their margin-box would almost always be better. 

I can easily construct pages where selections would look bad with either approach. Would be great for someone to put together a patch that we could try locally and see how it feels on different real pages.