getBoundingClientRect always returns empty rect on a collapsed range
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 01:56:51 +0000 (01:56 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 01:56:51 +0000 (01:56 +0000)
commit9b4809f4684c2097a00ea5641e2f122982dac343
tree0b7267508e7ef9ef5bf9f37c3731942bec7bc109
parentf09d3b800b215ae006bb32ee465fed6a941e4fed
getBoundingClientRect always returns empty rect on a collapsed range
https://bugs.webkit.org/show_bug.cgi?id=196380

Reviewed by Wenson Hsieh.

Source/WebCore:

The bug was caused by Range::boundingRect merging rects via FloatRect::unite which ignores empty rects.
Use uniteIfNonZero instead to fix the bug. Note that we can't use uniteEvenIfEmpty because that would
set x, y to always 0, 0 as we would end up merging any rect with the initial empty rect.

Test: fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html

* dom/Range.cpp:
(WebCore::Range::boundingRect const):

LayoutTests:

Added a regression test.

* fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt: Added.
* fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Range.cpp