New issue
Advanced search Search tips

Issue 596281 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

getBoundingClientRect computes wrong height for cross-element selections

Reported by rafalpi...@gmail.com, Mar 19 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36

Steps to reproduce the problem:
1. Go to http://rafalp.github.io/TextSelect/
2. Select text starting from middle of one paragraph's height and ending in middle of next paragraph.
3. The getBoundingClientRect will return invalid dimensions causing bounding box to wrap around whole last paragraph

What is the expected behavior?
getBoundingClientRect returned height should should match bottom of selection's rect, like on FF: https://github.com/rafalp/TextSelect/issues/1#issuecomment-198775305

What went wrong?
getBoundingClientRect computes wrong height for cross-element selections, rounding it to the bottom boundary of last element.

Did this work before? N/A 

Chrome version: 49.0.2623.87  Channel: stable
OS Version: OS X 10.9.5
Flash Version: Shockwave Flash 21.0 r0
 
Components: -Blink Blink>TextSelection Blink>Layout

Comment 2 by yosin@chromium.org, Mar 22 2016

Components: -Blink>Layout
Labels: -OS-Mac OS-All
Status: Available (was: Unconfirmed)
Remove Blink>Layout, since root cause is we iterator over nodes in range in
Range::getBoundingClientRect().

Range::getBoundingClientRect() 
   Node* startContainer = m_start.container();
   Node* endContainer = m_end.container();
   Node* stopNode = pastLastNode();

    WillBeHeapHashSet<RawPtrWillBeMember<Node>> nodeSet;
    for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(*node)) {
        if (node->isElementNode())
            nodeSet.add(node);
    }

In #c1 sample, we have Text, P, Text when selecting start from middle of P and to middle of another P.

This issue affects the bounding rect's height as well.

In the following JSFiddle, select `lo Wo` in latest Chrome (53.0.2782.5 Canary). The resulting `getBoundingClientRect()` will not equal the selection.

https://jsfiddle.net/b1kd0fcp/

Comment 4 by tkent@chromium.org, Oct 12 2016

Components: -Blink>TextSelection Blink>Editing>Selection

Comment 5 by agoode@chromium.org, Apr 24 2017

I see this all the time on GitHub code and other places. The highlight never extends to the top of the text.
I can confirm this bug is gone as of Chrome 58.0.3029.81
Status: WontFix (was: Available)
Closing the issue as neither of the test cases (in #0 and #3) reproduces in the latest Stable M60.

Sign in to add a comment