REGRESSION (r233778): Text selection sometimes cannot be extended in iframes
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 18:32:42 +0000 (18:32 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 18:32:42 +0000 (18:32 +0000)
commit43f1a5bd5895e00d5be155fec47901df808176f5
treefe54731c8ddd922f157107bc5c623017bcf4a69c
parent585d1ea7ba8035ce966fd225358223fe4e8fff4e
REGRESSION (r233778): Text selection sometimes cannot be extended in iframes
https://bugs.webkit.org/show_bug.cgi?id=188374
<rdar://problem/42928657>

Reviewed by Simon Fraser.

Source/WebKit:

rangeForPoint contains logic for converting a selection handle location in root view coordinates to an updated
selection. In doing so, we first convert the selection handle location to content coordinates; however, the call
site to EventHandler::hitTestResultAtPoint still hit-tests using the location in root view coordinates rather
than content coordinates, which means that when the focused frame is a subframe, hit-testing will fail to find
nodes within the subframe under the selection handle. This manifests in behaviors such as snapping to a single
character when selecting text in subframes.

To fix this, we just need to pass in the point in the frame's content coordinates when hit-testing.

Tests:  editing/selection/ios/selection-handles-in-iframe.html
        editing/selection/ios/selection-handles-in-readonly-input.html

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::rangeForPointInRootViewCoordinates):

Make a couple of other minor adjustments:
1.  Take a Frame& instead of a Frame*, since Frame& is assumed to be non-null here.
2.  Rename rangeForPoint to rangeForPointInRootViewCoordinates, as well as the point argument to
    pointInRootViewCoordinates.

(WebKit::WebPage::updateSelectionWithTouches):
(WebKit::rangeForPoint): Deleted.

LayoutTests:

Add 2 new layout tests to cover the original bug that r233778 fixed, as well as the regression in this bug.

* editing/selection/ios/selection-handles-in-iframe-expected.txt: Added.
* editing/selection/ios/selection-handles-in-iframe.html: Added.

Add a test to verify that the user can select text in an iframe by dragging selection handles.

* editing/selection/ios/selection-handles-in-readonly-input-expected.txt: Added.
* editing/selection/ios/selection-handles-in-readonly-input.html: Added.

Add a test to verify that dragging a selection handle outside of a readonly input does not cause the selection
to jump outside of the input and clear out the selection in the input.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/selection/ios/selection-handles-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/ios/selection-handles-in-iframe.html [new file with mode: 0644]
LayoutTests/editing/selection/ios/selection-handles-in-readonly-input-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/ios/selection-handles-in-readonly-input.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm