When dragging a selection, clearing the selection in dragstart should not crash the...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jul 2017 20:32:41 +0000 (20:32 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jul 2017 20:32:41 +0000 (20:32 +0000)
commit74c55d477a9d907b560df0a7473bf65ba145aac5
treec885ca6c9c24ed6fc360bbd9927549657fddcba8
parent871503b8602bc2b0f41f62c1aa44733a95f9338e
When dragging a selection, clearing the selection in dragstart should not crash the web process
https://bugs.webkit.org/show_bug.cgi?id=174142
<rdar://problem/33067501>

Reviewed by Tim Horton.

Source/WebCore:

Currenly, if the page clears the current selection after dragging starts on selected content, the web process
will crash while attempting to write pasteboard data for a nonexistent selection. This patch adds a trivial
check for this case, bailing if no DHTML dragging data was specified by the page during a selection drag and the
selection has been cleared.

Also removes some unused code for estimating the bounds of the current selection. On iOS, dragging was actually
crashing earlier, in this codepath. However, this information isn't even used anymore, since the drag anchor
point is no longer necessary on iOS.

Test: DataInteractionTests.DoNotCrashWhenSelectionIsClearedInDragStart

* page/DragController.cpp:
(WebCore::DragController::startDrag):

Tools:

Adds a unit test checking that the web process does not crash when the selection is cleared while a selection
drag is starting up.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/dragstart-clear-selection.html: Added.
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@219153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/dragstart-clear-selection.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm