[iOS WK2] Can't place caret or select in content that overflows a contenteditable...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 21:35:08 +0000 (21:35 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 21:35:08 +0000 (21:35 +0000)
commit8b2601b575d9070b5ff3fb090a11255877dfc6bc
treee4e20e8400447c78837258ac4e8a58164d333a36
parentefe12ed1653c7e5d400605d7b0149832b243469e
[iOS WK2] Can't place caret or select in content that overflows a contenteditable element
https://bugs.webkit.org/show_bug.cgi?id=199741
rdar://problem/50545233

Reviewed by Wenson Hsieh.
Source/WebCore:

Various code paths for editing used renderer->absoluteBoundingBoxRect(), which is the border
box of the element (or a set of line boxes for inline elements) converted to absolute
coordinates. This excludes overflow content, but contenteditable needs to be able to
place the caret in overflow content, and allow selection rects to be in the overflow area
(if the element has visible overflow).

Try to clean this up by adding some static helpers on WebPage for accessing the relevant
rects, and use them in code call from visiblePositionInFocusedNodeForPoint(), and
code that is input to selectionClipRect.

This changes selectionClipRect to use the padding box (excluding borders), which is a progression.

Tests: editing/caret/ios/caret-in-overflow-area.html
       editing/selection/ios/place-selection-in-overflow-area.html
       editing/selection/ios/selection-extends-into-overflow-area.html

* editing/FrameSelection.cpp:
(WebCore::DragCaretController::editableElementRectInRootViewCoordinates const):

Source/WebKit:

Various code paths for editing used renderer->absoluteBoundingBoxRect(), which is the border
box of the element (or a set of line boxes for inline elements) converted to absolute
coordinates. This excludes overflow content, but contenteditable needs to be able to
place the caret in overflow content, and allow selection rects to be in the overflow area
(if the element has visible overflow).

Try to clean this up by adding some static helpers on WebPage for accessing the relevant
rects, and use them in code call from visiblePositionInFocusedNodeForPoint(), and
code that is input to selectionClipRect.

This changes selectionClipRect to use the padding box (excluding borders), which is a progression.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const):
(WebKit::elementBoundsInFrame):
(WebKit::constrainPoint):
(WebKit::WebPage::rootViewBoundsForElement):
(WebKit::WebPage::absoluteInteractionBoundsForElement):
(WebKit::WebPage::rootViewInteractionBoundsForElement):
(WebKit::WebPage::dispatchSyntheticMouseEventsForSelectionGesture):
(WebKit::WebPage::getFocusedElementInformation):
(WebKit::innerFrameQuad): Deleted.
(WebKit::elementRectInRootViewCoordinates): Deleted.

LayoutTests:

Re-enable editing/caret/ios, fixing the result of emoji.html which for some reason was
checked in as an html file (the test still fails).

* editing/caret/ios/caret-in-overflow-area-expected.txt: Added.
* editing/caret/ios/caret-in-overflow-area.html: Added.
* editing/caret/ios/emoji-expected.txt: Renamed from LayoutTests/editing/caret/ios/emoji-expected.html.
* editing/caret/ios/fixed-caret-position-after-scroll-expected.txt:
* editing/caret/ios/fixed-caret-position-after-scroll.html:
* editing/selection/ios/place-selection-in-overflow-area-expected.txt: Added.
* editing/selection/ios/place-selection-in-overflow-area.html: Added.
* editing/selection/ios/selection-extends-into-overflow-area-expected.txt: Added.
* editing/selection/ios/selection-extends-into-overflow-area.html: Added.
* platform/ios-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/caret/ios/caret-in-overflow-area-expected.txt [new file with mode: 0644]
LayoutTests/editing/caret/ios/caret-in-overflow-area.html [new file with mode: 0644]
LayoutTests/editing/caret/ios/emoji-expected.txt [moved from LayoutTests/editing/caret/ios/emoji-expected.html with 100% similarity]
LayoutTests/editing/caret/ios/fixed-caret-position-after-scroll-expected.txt
LayoutTests/editing/caret/ios/fixed-caret-position-after-scroll.html
LayoutTests/editing/selection/ios/place-selection-in-overflow-area-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/ios/place-selection-in-overflow-area.html [new file with mode: 0644]
LayoutTests/editing/selection/ios/selection-extends-into-overflow-area-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/ios/selection-extends-into-overflow-area.html [new file with mode: 0644]
LayoutTests/platform/ios-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm