Make it possible to insert editable images with a gesture
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Nov 2018 12:11:16 +0000 (12:11 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Nov 2018 12:11:16 +0000 (12:11 +0000)
commitc109f883d638de6baa51a30dfa052f7ca9cc3300
tree93224bd74d1631fbc870ebf09ac3d27c5701a669
parent39a161fd4aa9a8d8b86f46d838d23eda60320763
Make it possible to insert editable images with a gesture
https://bugs.webkit.org/show_bug.cgi?id=191937

Reviewed by Wenson Hsieh.

Source/WebCore:

Tests:
    editing/images/redo-insert-editable-image-maintains-strokes.html,
    editing/images/undo-insert-editable-image.html,
    editing/images/basic-editable-image-from-execCommand.html

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/editing/EditorCommand.cpp:
* Source/WebCore/en.lproj/Localizable.strings:
* editing/EditAction.h:
* editing/Editor.cpp:
(WebCore::Editor::insertEditableImage):
* editing/Editor.h:
* editing/InsertEditableImageCommand.cpp: Added.
(WebCore::InsertEditableImageCommand::InsertEditableImageCommand):
(WebCore::InsertEditableImageCommand::doApply):
* editing/InsertEditableImageCommand.h: Added.
(WebCore::InsertEditableImageCommand::create):
* editing/VisibleSelection.cpp:
Add an editor command that inserts an editable image.
It will likely get a bit more complicated, but for now it just inserts
a 100% by 300px editable image.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _stylusTapGestureShouldCreateEditableImage]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
Add a internal getter for a WKWebViewConfiguration property.

* UIProcess/WebEditCommandProxy.cpp:
(WebKit::WebEditCommandProxy::nameForEditAction):
Add a undo name.

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
Add a single-stylus-tap gesture recognizer.

(-[WKContentView _stylusSingleTapRecognized:]):
If allowed, request to insert an editable image when a stylus tap occurs.

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::handleStylusSingleTapAtPoint):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleStylusSingleTapAtPoint):
Do a hit test, select the hit position, insert an editable image, and
then de-assist any assisted node (to make the keyboard go away).
For now, we'll only insert if we hit non-replaced elements,
though this heuristic will need to be enhanced significantly once we
decide on a design.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.mm:
(undoNameForEditAction):
Add a undo name.

Tools:

* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::drawSquareInEditableImage):
If the canvas already has a drawing, draw a new stroke on top of it
instead of removing the existing stroke.

LayoutTests:

* editing/images/basic-editable-image-from-execCommand-expected.txt: Added.
* editing/images/basic-editable-image-from-execCommand.html: Added.
Add a test that ensures that editable images also work when
inserted via the editor command.

* editing/images/redo-insert-editable-image-maintains-strokes-expected.txt: Added.
* editing/images/redo-insert-editable-image-maintains-strokes.html: Added.
Add a test that ensures that strokes are maintained when re-doing an
un-done editable image insertion.

* editing/images/undo-insert-editable-image-expected.txt: Added.
* editing/images/undo-insert-editable-image.html: Added.
Add a test that ensures that the selection stays in a sensible place
when undoing and redoing editable image insertion.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/images/basic-editable-image-from-execCommand-expected.txt [new file with mode: 0644]
LayoutTests/editing/images/basic-editable-image-from-execCommand.html [new file with mode: 0644]
LayoutTests/editing/images/redo-insert-editable-image-maintains-strokes-expected.txt [new file with mode: 0644]
LayoutTests/editing/images/redo-insert-editable-image-maintains-strokes.html [new file with mode: 0644]
LayoutTests/editing/images/undo-insert-editable-image-expected.txt [new file with mode: 0644]
LayoutTests/editing/images/undo-insert-editable-image.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/editing/EditAction.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/InsertEditableImageCommand.cpp [new file with mode: 0644]
Source/WebCore/editing/InsertEditableImageCommand.h [new file with mode: 0644]
Source/WebCore/editing/VisibleSelection.cpp
Source/WebCore/en.lproj/Localizable.strings
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit/UIProcess/WebEditCommandProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Tools/ChangeLog
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm