WebKit Bugzilla
Attachment 358343 Details for
Bug 193130
: Share ink choice and ruler between all editable images
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193130-20190104112554.patch (text/plain), 26.94 KB, created by
Tim Horton
on 2019-01-04 11:25:54 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2019-01-04 11:25:54 PST
Size:
26.94 KB
patch
obsolete
>Subversion Revision: 239596 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index a4835ba42b6cfd6fdc471db3989d1a8e4f216af9..c9247270ed407840f6108c2c9a1040b193567335 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,59 @@ >+2019-01-03 Tim Horton <timothy_horton@apple.com> >+ >+ Share ink choice and ruler between all editable images >+ https://bugs.webkit.org/show_bug.cgi?id=193130 >+ <rdar://problem/46826491> >+ >+ Reviewed by Wenson Hsieh. >+ >+ * SourcesCocoa.txt: >+ Add WKDrawingCoordinator, which maintains WKWebView-wide drawing state, >+ and manages a single shared ink picker. >+ >+ * UIProcess/PageClient.h: >+ (WebKit::PageClient::createDrawingView): >+ * UIProcess/ios/EditableImageController.mm: >+ (WebKit::EditableImageController::ensureEditableImage): >+ * UIProcess/ios/PageClientImplIOS.h: >+ * UIProcess/ios/PageClientImplIOS.mm: >+ (WebKit::PageClientImpl::createDrawingView): >+ Plumb WKDrawingView creation through PageClient, so that it can be instantiated >+ with knowledge of its owning WKContentView. >+ >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]): >+ (-[WKContentView _elementDidBlur]): >+ (-[WKContentView _drawingCoordinator]): >+ (-[WKContentView _installInkPickerForDrawingViewWithID:]): Deleted. >+ (-[WKContentView _uninstallInkPicker]): Deleted. >+ Move ink picker management into WKDrawingCoordinator. >+ >+ * UIProcess/ios/WKDrawingView.h: >+ * UIProcess/ios/WKDrawingView.mm: >+ (-[WKDrawingView initWithEmbeddedViewID:contentView:]): >+ (-[WKDrawingView _canvasViewWillBeginDrawing:]): >+ (-[WKDrawingView invalidateAttachment]): >+ (-[WKDrawingView didChangeRulerState:]): >+ (-[WKDrawingView initWithEmbeddedViewID:webPageProxy:]): Deleted. >+ (-[WKDrawingView canvasView]): Deleted. >+ Use a shared ruler, owned by WKDrawingCoordinator. >+ Update the editable image's ink when drawing begins. This way, we don't have >+ to push ink changes to all drawings as they happen. >+ >+ * UIProcess/ios/WKInkPickerView.h: >+ * UIProcess/ios/WKInkPickerView.mm: >+ (-[WKInkPickerView initWithContentView:]): >+ (-[WKInkPickerView inlineInkPickerDidToggleRuler:]): >+ (-[WKInkPickerView viewControllerForPopoverPresentationFromInlineInkPicker:]): >+ (-[WKInkPickerView setInk:]): >+ (-[WKInkPickerView ink]): >+ (-[WKInkPickerView initWithDrawingView:]): Deleted. >+ (-[WKInkPickerView didPickInk]): Deleted. >+ (-[WKInkPickerView inlineInkPicker:didSelectTool:]): Deleted. >+ (-[WKInkPickerView inlineInkPicker:didSelectColor:]): Deleted. >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2019-01-03 Brent Fulgham <bfulgham@apple.com> > > Remove logic handling DNT header during redirects >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index 56f3c45c4119e7dcfc8db4b09e53d2b005801e7a..a5855ba7e999770a527e017087f04e9637df246b 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -389,6 +389,7 @@ UIProcess/ios/WKActionSheetAssistant.mm > UIProcess/ios/WKApplicationStateTrackingView.mm > UIProcess/ios/WKContentView.mm @no-unify > UIProcess/ios/WKContentViewInteraction.mm @no-unify >+UIProcess/ios/WKDrawingCoordinator.mm > UIProcess/ios/WKDrawingView.mm > UIProcess/ios/WKGeolocationProviderIOS.mm > UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index c722b7d7066812c749d727cb7f8dd4b95204de52..0b858c46ee474d696ddc3d435bd54c1323003c2d 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -49,6 +49,7 @@ > OBJC_CLASS CALayer; > OBJC_CLASS NSFileWrapper; > OBJC_CLASS NSSet; >+OBJC_CLASS WKDrawingView; > OBJC_CLASS _WKRemoteObjectRegistry; > > #if USE(APPKIT) >@@ -462,6 +463,10 @@ public: > virtual NSSet *serializableFileWrapperClasses() const { return nullptr; } > #endif > #endif >+ >+#if HAVE(PENCILKIT) >+ virtual RetainPtr<WKDrawingView> createDrawingView(WebCore::GraphicsLayer::EmbeddedViewID) { return nullptr; } >+#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/ios/EditableImageController.mm b/Source/WebKit/UIProcess/ios/EditableImageController.mm >index 2e51e310cc0b8489dab6a0bac3de72527bb34eb3..a9ae981df888a193a8396d3bfe35565ac1f69bd8 100644 >--- a/Source/WebKit/UIProcess/ios/EditableImageController.mm >+++ b/Source/WebKit/UIProcess/ios/EditableImageController.mm >@@ -30,6 +30,7 @@ > > #import "APIAttachment.h" > #import "EditableImageControllerMessages.h" >+#import "PageClientImplIOS.h" > #import "PencilKitSPI.h" > #import "WKDrawingView.h" > #import "WebPageProxy.h" >@@ -56,7 +57,7 @@ EditableImage& EditableImageController::ensureEditableImage(WebCore::GraphicsLay > { > auto result = m_editableImages.ensure(embeddedViewID, [&] { > std::unique_ptr<EditableImage> image = std::make_unique<EditableImage>(); >- image->drawingView = adoptNS([[WKDrawingView alloc] initWithEmbeddedViewID:embeddedViewID webPageProxy:*m_webPageProxy]); >+ image->drawingView = m_webPageProxy->pageClient().createDrawingView(embeddedViewID); > return image; > }); > return *result.iterator->value; >diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >index de741c722abe6c08e5081622c80f478a3bd60894..4b420d16738ad8a6f2250c2d999e9e0f58a96496 100644 >--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >@@ -228,6 +228,10 @@ private: > > void didFinishProcessingAllPendingMouseEvents() final { } > >+#if HAVE(PENCILKIT) >+ RetainPtr<WKDrawingView> createDrawingView(WebCore::GraphicsLayer::EmbeddedViewID) override; >+#endif >+ > WKContentView *m_contentView; > RetainPtr<WKEditorUndoTarget> m_undoTarget; > }; >diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >index 421521b7483bec1dd9198a3b0bb5eed154d6574f..56d9adfca44443e0c4fe1e0a04b7617b6ce0b4ae 100644 >--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >@@ -41,6 +41,7 @@ > #import "ViewSnapshotStore.h" > #import "WKContentView.h" > #import "WKContentViewInteraction.h" >+#import "WKDrawingView.h" > #import "WKEditCommand.h" > #import "WKGeolocationProviderIOS.h" > #import "WKPasswordView.h" >@@ -817,6 +818,13 @@ void PageClientImpl::requestPasswordForQuickLookDocument(const String& fileName, > } > #endif > >+#if HAVE(PENCILKIT) >+RetainPtr<WKDrawingView> PageClientImpl::createDrawingView(WebCore::GraphicsLayer::EmbeddedViewID embeddedViewID) >+{ >+ return adoptNS([[WKDrawingView alloc] initWithEmbeddedViewID:embeddedViewID contentView:m_contentView]); >+} >+#endif >+ > } // namespace WebKit > > #endif // PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 7cc65fb43d79f4893965b9a98c7bb0f91f794056..ff2139eb200b88dd14e7ae2fe12b36d3bf36f4f2 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -93,10 +93,10 @@ class WebPageProxy; > @class UIHoverGestureRecognizer; > @class WebEvent; > @class WKActionSheetAssistant; >+@class WKDrawingCoordinator; > @class WKFocusedFormControlView; > @class WKFormInputControl; > @class WKFormInputSession; >-@class WKInkPickerView; > @class WKInspectorNodeSearchGestureRecognizer; > > typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput); >@@ -278,7 +278,7 @@ struct WKAutoCorrectionData { > #endif > > #if HAVE(PENCILKIT) >- RetainPtr<WKInkPickerView> _inkPicker; >+ RetainPtr<WKDrawingCoordinator> _drawingCoordinator; > #endif > > BOOL _isEditable; >@@ -440,6 +440,10 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW) > - (void)updateTextSuggestionsForInputDelegate; > #endif > >+#if HAVE(PENCILKIT) >+- (WKDrawingCoordinator *)_drawingCoordinator; >+#endif >+ > @end > > @interface WKContentView (WKTesting) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index f5162b00591d497775b6779f8b0fc577ac9ec9c7..e4189fdd7225e2136047c2af42431be81c796b25 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -42,6 +42,7 @@ > #import "UIKitSPI.h" > #import "WKActionSheetAssistant.h" > #import "WKDatePickerViewController.h" >+#import "WKDrawingCoordinator.h" > #import "WKError.h" > #import "WKFocusedFormControlView.h" > #import "WKFormInputControl.h" >@@ -848,6 +849,8 @@ - (void)cleanupInteraction > [_keyboardScrollingAnimator invalidate]; > _keyboardScrollingAnimator = nil; > >+ _drawingCoordinator = nil; >+ > #if ENABLE(DATALIST_ELEMENT) > _dataListTextSuggestionsInputView = nil; > _dataListTextSuggestions = nil; >@@ -4497,7 +4500,7 @@ - (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information u > > #if HAVE(PENCILKIT) > if (information.elementType == WebKit::InputType::Drawing) >- [self _installInkPickerForDrawingViewWithID:information.embeddedViewID]; >+ [_drawingCoordinator installInkPickerForDrawing:information.embeddedViewID]; > #endif > > if (!shouldShowKeyboard) >@@ -4589,8 +4592,7 @@ - (void)_elementDidBlur > SetForScope<BOOL> isBlurringFocusedNodeForScope { _isBlurringFocusedNode, YES }; > > #if HAVE(PENCILKIT) >- if (_inkPicker) >- [self _uninstallInkPicker]; >+ [_drawingCoordinator uninstallInkPicker]; > #endif > > [_formInputSession invalidate]; >@@ -6293,27 +6295,12 @@ - (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer > #endif > > #if HAVE(PENCILKIT) >-- (void)_installInkPickerForDrawingViewWithID:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID >-{ >- _inkPicker = adoptNS([[WKInkPickerView alloc] initWithDrawingView:_page->editableImageController().editableImage(embeddedViewID)->drawingView.get()]); >- [_inkPicker sizeToFit]; >- [_inkPicker setTranslatesAutoresizingMaskIntoConstraints:NO]; >- [_webView addSubview:_inkPicker.get()]; >- >- [NSLayoutConstraint activateConstraints:@[ >- [[_inkPicker heightAnchor] constraintEqualToConstant:[_inkPicker frame].size.height], >- [[_inkPicker bottomAnchor] constraintEqualToAnchor:_webView.safeAreaLayoutGuide.bottomAnchor], >- [[_inkPicker leftAnchor] constraintEqualToAnchor:_webView.safeAreaLayoutGuide.leftAnchor], >- [[_inkPicker rightAnchor] constraintEqualToAnchor:_webView.safeAreaLayoutGuide.rightAnchor], >- ]]; >-} >- >-- (void)_uninstallInkPicker >+- (WKDrawingCoordinator *)_drawingCoordinator > { >- [_inkPicker removeFromSuperview]; >- _inkPicker = nil; >+ if (!_drawingCoordinator) >+ _drawingCoordinator = adoptNS([[WKDrawingCoordinator alloc] initWithContentView:self]); >+ return _drawingCoordinator.get(); > } >- > #endif // HAVE(PENCILKIT) > > @end >diff --git a/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.h b/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e129d95e39b80443f9933d60c7da0c99f7b39b61 >--- /dev/null >+++ b/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.h >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#if HAVE(PENCILKIT) >+ >+#import <WebCore/GraphicsLayer.h> >+ >+OBJC_CLASS PKInk; >+OBJC_CLASS WKContentView; >+OBJC_CLASS WKInkPickerView; >+ >+@interface WKDrawingCoordinator : NSObject >+ >+- (instancetype)init NS_UNAVAILABLE; >+- (instancetype)initWithContentView:(WKContentView *)contentView; >+ >+- (void)installInkPickerForDrawing:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID; >+- (void)uninstallInkPicker; >+ >+- (void)didChangeRulerState:(BOOL)rulerEnabled; >+- (void)didChangeInk:(PKInk *)ink; >+ >+@property (nonatomic, readonly, retain) WKInkPickerView *inkPicker; >+ >+@end >+ >+ >+#endif // HAVE(PENCILKIT) >diff --git a/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.mm b/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..d2daed75bc5b264691d79ae081e28654e14d8dab >--- /dev/null >+++ b/Source/WebKit/UIProcess/ios/WKDrawingCoordinator.mm >@@ -0,0 +1,125 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "WKDrawingCoordinator.h" >+ >+#if HAVE(PENCILKIT) >+ >+#import "EditableImageController.h" >+#import "WKContentViewInteraction.h" >+#import "WKInkPickerView.h" >+#import "WKWebView.h" >+#import <wtf/RetainPtr.h> >+ >+#import "PencilKitSoftLink.h" >+ >+@interface WKDrawingCoordinator () <PKRulerHostingDelegate> >+@end >+ >+@implementation WKDrawingCoordinator { >+ __weak WKContentView *_contentView; >+ >+ RetainPtr<WKInkPickerView> _inkPicker; >+ >+ WebCore::GraphicsLayer::EmbeddedViewID _focusedEmbeddedViewID; >+} >+ >+- (instancetype)initWithContentView:(WKContentView *)contentView >+{ >+ self = [super init]; >+ if (!self) >+ return nil; >+ >+ _contentView = contentView; >+ _inkPicker = adoptNS([[WKInkPickerView alloc] initWithContentView:_contentView]); >+ >+ return self; >+} >+ >+- (WKInkPickerView *)inkPicker >+{ >+ return _inkPicker.get(); >+} >+ >+- (UIView *)rulerHostingView >+{ >+ return _contentView; >+} >+ >+- (BOOL)rulerHostWantsSharedRuler >+{ >+ return YES; >+} >+ >+- (WKDrawingView *)_focusedDrawingView >+{ >+ WebKit::EditableImage *focusedEditableImage = _contentView.page->editableImageController().editableImage(_focusedEmbeddedViewID); >+ if (!focusedEditableImage) >+ return nil; >+ return focusedEditableImage->drawingView.get(); >+} >+ >+- (void)didChangeRulerState:(BOOL)rulerEnabled >+{ >+ [self._focusedDrawingView didChangeRulerState:rulerEnabled]; >+} >+ >+- (void)didChangeInk:(PKInk *)ink >+{ >+ [self._focusedDrawingView didChangeInk:ink]; >+} >+ >+- (void)installInkPickerForDrawing:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID >+{ >+ _focusedEmbeddedViewID = embeddedViewID; >+ >+ WKWebView *webView = _contentView->_webView; >+ >+ [_inkPicker sizeToFit]; >+ [_inkPicker setTranslatesAutoresizingMaskIntoConstraints:NO]; >+ [webView addSubview:_inkPicker.get()]; >+ >+ [NSLayoutConstraint activateConstraints:@[ >+ [[_inkPicker heightAnchor] constraintEqualToConstant:[_inkPicker frame].size.height], >+ [[_inkPicker bottomAnchor] constraintEqualToAnchor:webView.safeAreaLayoutGuide.bottomAnchor], >+ [[_inkPicker leftAnchor] constraintEqualToAnchor:webView.safeAreaLayoutGuide.leftAnchor], >+ [[_inkPicker rightAnchor] constraintEqualToAnchor:webView.safeAreaLayoutGuide.rightAnchor], >+ ]]; >+ >+ // When focused, push the ruler state down to the canvas so that it doesn't get out of sync >+ // and early-return from later changes. >+ [self._focusedDrawingView didChangeRulerState:[_inkPicker rulerEnabled]]; >+} >+ >+- (void)uninstallInkPicker >+{ >+ [_inkPicker removeFromSuperview]; >+ _focusedEmbeddedViewID = 0; >+} >+ >+@end >+ >+#endif // HAVE(PENCILKIT) >diff --git a/Source/WebKit/UIProcess/ios/WKDrawingView.h b/Source/WebKit/UIProcess/ios/WKDrawingView.h >index 2b2de2528cf602fa85c370dbd356131f7db8602c..9d81b203b440b853d1bc35830e102a888e979902 100644 >--- a/Source/WebKit/UIProcess/ios/WKDrawingView.h >+++ b/Source/WebKit/UIProcess/ios/WKDrawingView.h >@@ -28,16 +28,18 @@ > #import "RemoteLayerTreeHost.h" > #import "RemoteLayerTreeViews.h" > >-OBJC_CLASS PKCanvasView; >+OBJC_CLASS PKInk; >+OBJC_CLASS WKContentView; > > @interface WKDrawingView : WKEmbeddedView <WKNativelyInteractible> > >-- (instancetype)initWithEmbeddedViewID:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID webPageProxy:(WebKit::WebPageProxy&)webPageProxy; >+- (instancetype)initWithEmbeddedViewID:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID contentView:(WKContentView *)contentView; > > - (NSData *)PNGRepresentation; > - (void)loadDrawingFromPNGRepresentation:(NSData *)PNGData; > >-@property (nonatomic, readonly) PKCanvasView *canvasView; >+- (void)didChangeRulerState:(BOOL)rulerEnabled; >+- (void)didChangeInk:(PKInk *)ink; > > @end > >diff --git a/Source/WebKit/UIProcess/ios/WKDrawingView.mm b/Source/WebKit/UIProcess/ios/WKDrawingView.mm >index ce07d48796202a7dd6b3cfbe161f93186b3252a0..df1d0c543124f8c0c36ed2a41b367cadf00e2a6b 100644 >--- a/Source/WebKit/UIProcess/ios/WKDrawingView.mm >+++ b/Source/WebKit/UIProcess/ios/WKDrawingView.mm >@@ -29,10 +29,12 @@ > #if HAVE(PENCILKIT) > > #import "EditableImageController.h" >-#import "PencilKitSoftLink.h" >+#import "WKInkPickerView.h" > #import <wtf/OSObjectPtr.h> > #import <wtf/RetainPtr.h> > >+#import "PencilKitSoftLink.h" >+ > @interface WKDrawingView () <PKCanvasViewDelegate> > @end > >@@ -44,16 +46,16 @@ @implementation WKDrawingView { > RetainPtr<PKImageRenderer> _renderer; > #endif > >- WeakPtr<WebKit::WebPageProxy> _webPageProxy; >+ __weak WKContentView *_contentView; > } > >-- (instancetype)initWithEmbeddedViewID:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID webPageProxy:(WebKit::WebPageProxy&)webPageProxy >+- (instancetype)initWithEmbeddedViewID:(WebCore::GraphicsLayer::EmbeddedViewID)embeddedViewID contentView:(WKContentView *)contentView > { > self = [super initWithEmbeddedViewID:embeddedViewID]; > if (!self) > return nil; > >- _webPageProxy = makeWeakPtr(webPageProxy); >+ _contentView = contentView; > > _pencilView = adoptNS([WebKit::allocPKCanvasViewInstance() initWithFrame:CGRectZero]); > >@@ -61,6 +63,7 @@ - (instancetype)initWithEmbeddedViewID:(WebCore::GraphicsLayer::EmbeddedViewID)e > [_pencilView setUserInteractionEnabled:YES]; > [_pencilView setOpaque:NO]; > [_pencilView setDelegate:self]; >+ [_pencilView setRulerHostingDelegate:_contentView._drawingCoordinator]; > > [self addSubview:_pencilView.get()]; > >@@ -165,18 +168,28 @@ - (void)drawingDidChange:(PKCanvasView *)canvasView > [self invalidateAttachment]; > } > >+- (void)_canvasViewWillBeginDrawing:(PKCanvasView *)canvasView >+{ >+ [_pencilView setInk:_contentView._drawingCoordinator.inkPicker.ink]; >+} >+ > - (void)invalidateAttachment > { >- if (!_webPageProxy) >+ if (!_contentView.page) > return; >- auto& page = *_webPageProxy; >+ auto& page = *_contentView.page; > > page.editableImageController().invalidateAttachmentForEditableImage(self.embeddedViewID); > } > >-- (PKCanvasView *)canvasView >+- (void)didChangeRulerState:(BOOL)rulerEnabled >+{ >+ [_pencilView setRulerEnabled:rulerEnabled]; >+} >+ >+- (void)didChangeInk:(PKInk *)ink > { >- return _pencilView.get(); >+ [_pencilView setInk:ink]; > } > > @end >diff --git a/Source/WebKit/UIProcess/ios/WKInkPickerView.h b/Source/WebKit/UIProcess/ios/WKInkPickerView.h >index 2133a275b923f15afbe2d8eb7a9322a3ab21b26b..3f6d7bc32aec66fba7b4489c6c04abca347d34fb 100644 >--- a/Source/WebKit/UIProcess/ios/WKInkPickerView.h >+++ b/Source/WebKit/UIProcess/ios/WKInkPickerView.h >@@ -27,7 +27,8 @@ > > #import <UIKit/UIKit.h> > >-OBJC_CLASS WKDrawingView; >+OBJC_CLASS PKInk; >+OBJC_CLASS WKContentView; > > @interface WKInkPickerView : UIView > >@@ -35,7 +36,10 @@ OBJC_CLASS WKDrawingView; > - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; > - (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE; > >-- (instancetype)initWithDrawingView:(WKDrawingView *)drawingView NS_DESIGNATED_INITIALIZER; >+- (instancetype)initWithContentView:(WKContentView *)contentView NS_DESIGNATED_INITIALIZER; >+ >+@property (nonatomic) BOOL rulerEnabled; >+@property (nonatomic, retain) PKInk *ink; > > @end > >diff --git a/Source/WebKit/UIProcess/ios/WKInkPickerView.mm b/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >index 9a37438e5872588d440050c4bf4bb81dd4afca83..d4e35fee56b370f719d49325fb8cdb0cf0a696c9 100644 >--- a/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >+++ b/Source/WebKit/UIProcess/ios/WKInkPickerView.mm >@@ -28,7 +28,7 @@ > > #if HAVE(PENCILKIT) > >-#import "WKDrawingView.h" >+#import "WKContentViewInteraction.h" > > #import "PencilKitSoftLink.h" > >@@ -37,21 +37,19 @@ @end > > @implementation WKInkPickerView { > RetainPtr<PKInlineInkPicker> _inlinePicker; >- RetainPtr<WKDrawingView> _drawingView; >+ __weak WKContentView *_contentView; > } > >-- (instancetype)initWithDrawingView:(WKDrawingView *)drawingView >+- (instancetype)initWithContentView:(WKContentView *)contentView > { > self = [super initWithFrame:CGRectZero]; > if (!self) > return nil; > > _inlinePicker = adoptNS([WebKit::allocPKInlineInkPickerInstance() init]); >- [_inlinePicker setSelectedInk:[drawingView canvasView].ink animated:NO]; >- [_inlinePicker addTarget:self action:@selector(didPickInk) forControlEvents:UIControlEventValueChanged]; > [_inlinePicker setDelegate:self]; > >- _drawingView = drawingView; >+ _contentView = contentView; > [self addSubview:_inlinePicker.get()]; > > return self; >@@ -59,12 +57,13 @@ - (instancetype)initWithDrawingView:(WKDrawingView *)drawingView > > - (void)didPickInk > { >- [_drawingView canvasView].ink = [_inlinePicker selectedInk]; >+ [_contentView._drawingCoordinator didChangeInk:[_inlinePicker selectedInk]]; > } > > - (void)inlineInkPickerDidToggleRuler:(PKInlineInkPicker *)inlineInkPicker > { >- [_drawingView canvasView].rulerEnabled = ![_drawingView canvasView].rulerEnabled; >+ _rulerEnabled = !_rulerEnabled; >+ [_contentView._drawingCoordinator didChangeRulerState:_rulerEnabled]; > } > > - (void)inlineInkPicker:(PKInlineInkPicker *)inlineInkPicker didSelectTool:(PKInkIdentifier)identifer >@@ -97,7 +96,17 @@ - (CGSize)sizeThatFits:(CGSize)size > > - (UIViewController *)viewControllerForPopoverPresentationFromInlineInkPicker:(PKInlineInkPicker *)inlineInkPicker > { >- return [UIViewController _viewControllerForFullScreenPresentationFromView:_drawingView.get()]; >+ return [UIViewController _viewControllerForFullScreenPresentationFromView:_contentView]; >+} >+ >+- (void)setInk:(PKInk *)ink >+{ >+ [_inlinePicker setSelectedInk:ink]; >+} >+ >+- (PKInk *)ink >+{ >+ return [_inlinePicker selectedInk]; > } > > @end >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 92dd695e246f72d39e228407108c6443994f217c..49c40cba173db33ce3b9d3841b9eadbe15957392 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -2487,6 +2487,8 @@ > 2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewGestureControllerMessages.h; path = DerivedSources/WebKit2/ViewGestureControllerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; }; > 2D1E8221216FFF5000A15265 /* WKWebEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKWebEvent.h; path = ios/WKWebEvent.h; sourceTree = "<group>"; }; > 2D1E8222216FFF5100A15265 /* WKWebEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKWebEvent.mm; path = ios/WKWebEvent.mm; sourceTree = "<group>"; }; >+ 2D21A45821DED49B002487E7 /* WKDrawingCoordinator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKDrawingCoordinator.mm; path = ios/WKDrawingCoordinator.mm; sourceTree = "<group>"; }; >+ 2D21A45921DED49B002487E7 /* WKDrawingCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKDrawingCoordinator.h; path = ios/WKDrawingCoordinator.h; sourceTree = "<group>"; }; > 2D28A4951AF965A100F190C9 /* WKViewLayoutStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKViewLayoutStrategy.h; sourceTree = "<group>"; }; > 2D28A4961AF965A100F190C9 /* WKViewLayoutStrategy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKViewLayoutStrategy.mm; sourceTree = "<group>"; }; > 2D28F3E01885CCC1004B9EAE /* WebChromeClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebChromeClientIOS.mm; path = ios/WebChromeClientIOS.mm; sourceTree = "<group>"; }; >@@ -5844,6 +5846,8 @@ > 0FCB4E3D18BBE044000FCFC9 /* WKContentView.mm */, > 0FCB4E6A18BBF26A000FCFC9 /* WKContentViewInteraction.h */, > 0FCB4E6B18BBF26A000FCFC9 /* WKContentViewInteraction.mm */, >+ 2D21A45921DED49B002487E7 /* WKDrawingCoordinator.h */, >+ 2D21A45821DED49B002487E7 /* WKDrawingCoordinator.mm */, > 2DC18FAB218910480025A88D /* WKDrawingView.h */, > 2DC18FAC218910480025A88D /* WKDrawingView.mm */, > 0FCB4E3F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193130
:
358295
|
358297
| 358343