Bug 76839

Summary: Range.getClientRects() should not include rects for partially selected elements
Product: WebKit Reporter: JuanCar Gallego <jcgallego74>
Component: DOMAssignee: Andy Estes <aestes>
Status: RESOLVED FIXED    
Severity: Normal CC: aestes, agustin.moreton+webkit, commit-queue, esprehn+autocc, futurama, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch sam: review+

JuanCar Gallego
Reported 2012-01-23 10:29:43 PST
Range.getclientrects returns too much rects, some of them incorrect (out of the range), at least when: - the end point of the range (endOffset) doesn't match the last position of the endContainer element - AND the beguinning of the endContainer is included in the range, but it's not the startOffset In addition of the range rects, it's returning the rects of the whole endContainer element. Tested in Chrome and Safari, working right in FireFox. Described with an example here: http://stackoverflow.com/questions/7232723/semantics-of-clientrect-from-getclientrects-in-webkit-browsers
Attachments
Patch (9.46 KB, patch)
2013-04-22 03:38 PDT, Andy Estes
sam: review+
theTestTube
Comment 1 2012-01-26 04:30:40 PST
Subscribe this. I'm afraid we're also suffering it with Chrome and Safari.-
JuanCar Gallego
Comment 2 2012-01-27 05:25:49 PST
More information. It seems like two close problems: 1. Range.getClientRects return rects for the partially selected text nodes in the startContaniner and endContainer. Correct. But for the not border elements it returns both rects for the whole elements, and rects for any text "fragment" inside them. It's redundant and confusing, and I think uncompliant with http://www.w3.org/TR/cssom-view/#extensions-to-the-range-interface 2. Correcting my first description of the problem: When endContainer is partially selected, and endContainer doesn't match startContainer, Range.getClientRects returns rect for the topmost ancestor of the endContainer whose parent contains the whole range (the child of range.commonAncestorContainer containing or being endContainer). This is clearly an error, because part of that rect (remember endContainer is partially selected) is outside the range.
Andy Estes
Comment 3 2013-04-18 20:31:01 PDT
JuanCar Gallego
Comment 4 2013-04-22 03:34:08 PDT
(In reply to comment #3) > <rdar://problem/13387823> Hi, Andy. I'm not sure to understand why you changed the subject of the bug. IMHO not returning any rects for partially selected elements is worst than returning partial and total rects. With actual behaviour, at least I'm able to detect and discard wrong rects.
Andy Estes
Comment 5 2013-04-22 03:38:57 PDT
Andy Estes
Comment 6 2013-04-22 03:44:45 PDT
(In reply to comment #4) > (In reply to comment #3) > > <rdar://problem/13387823> > > Hi, Andy. > I'm not sure to understand why you changed the subject of the bug. > IMHO not returning any rects for partially selected elements is worst than returning partial and total rects. With actual behaviour, at least I'm able to detect and discard wrong rects. You will still get rects for the selected children of the partially selected element.
JuanCar Gallego
Comment 7 2013-04-22 03:51:41 PDT
(In reply to comment #6) > (In reply to comment #4) > > (In reply to comment #3) > > > <rdar://problem/13387823> > > > > Hi, Andy. > > I'm not sure to understand why you changed the subject of the bug. > > IMHO not returning any rects for partially selected elements is worst than returning partial and total rects. With actual behaviour, at least I'm able to detect and discard wrong rects. > > You will still get rects for the selected children of the partially selected element. If it includes portions of partially selected text elements, as it does now, that's fine. Thank you.
Andy Estes
Comment 8 2013-04-22 11:22:49 PDT
Note You need to log in before you can comment on or make changes to this bug.