Make drawing tools available when an editable image is focused
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 00:32:14 +0000 (00:32 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 00:32:14 +0000 (00:32 +0000)
commit640fcfb387f82b2c87670321259306f4dcc26a2e
treeaeeb6523232c64f418cbba947ac7d01661fadaf7
parentbc7aa8644995b33ca49848cc6eaeedd1db67f422
Make drawing tools available when an editable image is focused
https://bugs.webkit.org/show_bug.cgi?id=192172
<rdar://problem/30337960>

Reviewed by Dean Jackson.

* Platform/spi/ios/PencilKitSPI.h:
Add some more SPI.

* Shared/AssistedNodeInformation.cpp:
(WebKit::AssistedNodeInformation::encode const):
(WebKit::AssistedNodeInformation::decode):
* Shared/AssistedNodeInformation.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleStylusSingleTapAtPoint):
(WebKit::isAssistableElement):
(WebKit::WebPage::getAssistedNodeInformation):
Plumb the assisted node's embedded view ID, if available.
Also add a new input type for drawings, and use it when appropriate.

* SourcesCocoa.txt:
* UIProcess/API/Cocoa/_WKFocusedElementInfo.h:
Add WKInputTypeDrawing.

* UIProcess/ios/PencilKitSoftLink.h: Added.
* UIProcess/ios/PencilKitSoftLink.mm: Added.
Pull soft-linking out into its own file, to fix unified sources.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFocusedElementInfo initWithAssistedNodeInformation:isUserInitiated:userObject:]):
(-[WKContentView _requiresKeyboardWhenFirstResponder]):
(-[WKContentView requiresAccessoryView]):
Install a keyboard when a drawing is focused.
Also, deduplicate one "curretUserInterfaceIdiomIsPad"; just fall through.

(-[WKContentView inputView]):
Make a WKInkPickerControl when a drawing is focused.

(-[WKContentView textInputTraits]):
(isAssistableInputType):
* UIProcess/ios/WKDrawingView.h:
* UIProcess/ios/WKDrawingView.mm:
(-[WKDrawingView initWithEmbeddedViewID:webPageProxy:]):
(-[WKDrawingView PNGRepresentation]):
(-[WKDrawingView loadDrawingFromPNGRepresentation:]):
Adopt PencilKitSoftLink.

(-[WKDrawingView canvasView]):
Expose the internal canvas view for use by WKInkPickerControl.

* UIProcess/ios/WKInkPickerControl.h: Copied from Source/WebKit/Platform/spi/ios/PencilKitSPI.h.
* UIProcess/ios/WKInkPickerControl.mm: Added.
(-[WKInkPickerView initWithFrame:drawingView:]):
(-[WKInkPickerView didPickInk]):
(-[WKInkPickerView inlineInkPickerDidToggleRuler:]):
(-[WKInkPickerView inlineInkPicker:didSelectTool:]):
(-[WKInkPickerView inlineInkPicker:didSelectColor:]):
(-[WKInkPickerView inkPickerSize]):
(-[WKInkPickerView layoutSubviews]):
(-[WKInkPickerView sizeThatFits:]):
(-[WKInkPickerView viewControllerForPopoverPresentationFromInlineInkPicker:]):
(-[WKInkPickerControl initWithDrawingView:]):
(-[WKInkPickerControl beginEditing]):
(-[WKInkPickerControl endEditing]):
(-[WKInkPickerControl assistantView]):
Install and hook up a PKInlineInkPicker.
Center it in the keyboard.
Plumb changes through to the canvas view.

* WebKit.xcodeproj/project.pbxproj:

* editing/Editor.cpp:
(WebCore::Editor::insertEditableImage):
* editing/Editor.h:
* editing/InsertEditableImageCommand.cpp:
(WebCore::InsertEditableImageCommand::insertEditableImage):
(WebCore::InsertEditableImageCommand::doApply):
* editing/InsertEditableImageCommand.h:
Add InsertEditableImageCommand::insertEditableImage, which returns the
inserted image element.

* html/HTMLImageElement.h:
Make HTMLImageElement focusable if it is editable.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238708 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/InsertEditableImageCommand.cpp
Source/WebCore/editing/InsertEditableImageCommand.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/PencilKitSPI.h
Source/WebKit/Shared/AssistedNodeInformation.cpp
Source/WebKit/Shared/AssistedNodeInformation.h
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/Cocoa/_WKFocusedElementInfo.h
Source/WebKit/UIProcess/ios/PencilKitSoftLink.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/PencilKitSoftLink.mm [new file with mode: 0644]
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WKDrawingView.h
Source/WebKit/UIProcess/ios/WKDrawingView.mm
Source/WebKit/UIProcess/ios/WKInkPickerControl.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/WKInkPickerControl.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm