[iOS] Replace "node assistance" terminology in WebKit with "focused element"
[WebKit-https.git] / Source / WebKit / UIProcess / ios / PageClientImplIOS.h
1 /*
2  * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #pragma once
27
28 #if PLATFORM(IOS_FAMILY)
29
30 #import "PageClientImplCocoa.h"
31 #import "WebFullScreenManagerProxy.h"
32 #import <wtf/RetainPtr.h>
33
34 OBJC_CLASS WKContentView;
35 OBJC_CLASS WKEditorUndoTargetObjC;
36
37 namespace WebCore {
38 struct PromisedAttachmentInfo;
39 }
40
41 namespace WebKit {
42
43 enum class UndoOrRedo : bool;
44
45 class PageClientImpl : public PageClientImplCocoa
46 #if ENABLE(FULLSCREEN_API)
47     , public WebFullScreenManagerProxyClient
48 #endif
49     {
50 public:
51     PageClientImpl(WKContentView *, WKWebView *);
52     virtual ~PageClientImpl();
53     
54 private:
55     // PageClient
56     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
57     void setViewNeedsDisplay(const WebCore::Region&) override;
58     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
59     WebCore::FloatPoint viewScrollPosition() override;
60     WebCore::IntSize viewSize() override;
61     bool isViewWindowActive() override;
62     bool isViewFocused() override;
63     bool isViewVisible() override;
64     bool isViewInWindow() override;
65     bool isViewVisibleOrOccluded() override;
66     bool isVisuallyIdle() override;
67     void processDidExit() override;
68     void processWillSwap() override;
69     void didRelaunchProcess() override;
70     void pageClosed() override;
71     void preferencesDidChange() override;
72     void toolTipChanged(const String&, const String&) override;
73     void decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, API::SecurityOrigin&, Function<void(bool)>&) override;
74     void didStartProvisionalLoadForMainFrame() override;
75     void didFailProvisionalLoadForMainFrame() override;
76     void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
77     void handleDownloadRequest(DownloadProxy*) override;
78     void didChangeContentSize(const WebCore::IntSize&) override;
79     void setCursor(const WebCore::Cursor&) override;
80     void setCursorHiddenUntilMouseMoves(bool) override;
81     void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
82     void registerEditCommand(Ref<WebEditCommandProxy>&&, UndoOrRedo) override;
83     void clearAllEditCommands() override;
84     bool canUndoRedo(UndoOrRedo) override;
85     void executeUndoRedo(UndoOrRedo) override;
86     void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
87     bool executeSavedCommandBySelector(const String& selector) override;
88     void updateSecureInputState() override;
89     void resetSecureInputState() override;
90     void notifyInputContextAboutDiscardedComposition() override;
91     void makeFirstResponder() override;
92     void assistiveTechnologyMakeFirstResponder() override;
93     WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
94     WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
95     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
96     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
97     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) override;
98     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) override;
99     void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
100 #if ENABLE(TOUCH_EVENTS)
101     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override;
102 #endif
103     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
104     Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
105
106 #if ENABLE(INPUT_TYPE_COLOR)
107     RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) final;
108 #endif
109
110 #if ENABLE(DATALIST_ELEMENT)
111     RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy&) final;
112 #endif
113
114     void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
115     void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
116     void setTextIndicatorAnimationProgress(float) override;
117
118     void showSafeBrowsingWarning(const SafeBrowsingWarning&, CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&&) override;
119     void clearSafeBrowsingWarning() override;
120     void clearSafeBrowsingWarningIfForMainFrameNavigation() override;
121
122     void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
123     void exitAcceleratedCompositingMode() override;
124     void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
125     void setRemoteLayerTreeRootNode(RemoteLayerTreeNode*) override;
126     CALayer* acceleratedCompositingRootLayer() const override;
127     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
128
129     RefPtr<ViewSnapshot> takeViewSnapshot() override;
130     void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
131
132     void commitPotentialTapFailed() override;
133     void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) override;
134
135     void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
136     void layerTreeCommitComplete() override;
137
138     void couldNotRestorePageState() override;
139     void restorePageState(Optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatBoxExtent&, double) override;
140     void restorePageCenterAndScale(Optional<WebCore::FloatPoint>, double) override;
141
142     void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, API::Object* userData) override;
143     void elementDidBlur() override;
144     void didReceiveEditorStateUpdateAfterFocus() override;
145     bool isFocusingElement() override;
146     void selectionDidChange() override;
147     bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
148     void positionInformationDidChange(const InteractionInformationAtPosition&) override;
149     void saveImageToLibrary(Ref<WebCore::SharedBuffer>&&) override;
150     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) override;
151
152     bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
153     bool showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override;
154     
155     void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
156     double minimumZoomScale() const override;
157     WebCore::FloatRect documentRect() const override;
158
159     void showInspectorHighlight(const WebCore::Highlight&) override;
160     void hideInspectorHighlight() override;
161
162     void showInspectorIndication() override;
163     void hideInspectorIndication() override;
164
165     void enableInspectorNodeSearch() override;
166     void disableInspectorNodeSearch() override;
167
168     void scrollingNodeScrollViewWillStartPanGesture() override;
169     void scrollingNodeScrollViewDidScroll() override;
170     void scrollingNodeScrollWillStartScroll() override;
171     void scrollingNodeScrollDidEndScroll() override;
172
173     // Auxiliary Client Creation
174 #if ENABLE(FULLSCREEN_API)
175     WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
176 #endif
177
178 #if ENABLE(FULLSCREEN_API)
179     // WebFullScreenManagerProxyClient
180     void closeFullScreenManager() override;
181     bool isFullScreen() override;
182     void enterFullScreen() override;
183     void exitFullScreen() override;
184     void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
185     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
186 #endif
187
188     void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
189
190     Vector<String> mimeTypesWithCustomContentProviders() override;
191
192     void navigationGestureDidBegin() override;
193     void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
194     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
195     void navigationGestureDidEnd() override;
196     void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
197     void didRemoveNavigationGestureSnapshot() override;
198
199     void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
200     void didFinishLoadForMainFrame() override;
201     void didFailLoadForMainFrame() override;
202     void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
203     void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
204     void didCompleteSyntheticClick() override;
205
206     void didChangeBackgroundColor() override;
207     void videoControlsManagerDidChange() override;
208
209     void refView() override;
210     void derefView() override;
211
212     void didRestoreScrollPosition() override;
213
214     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
215
216 #if USE(QUICK_LOOK)
217     void requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&&) override;
218 #endif
219
220 #if ENABLE(DATA_INTERACTION)
221     void didPerformDragOperation(bool handled) override;
222     void didHandleStartDataInteractionRequest(bool started) override;
223     void didHandleAdditionalDragItemsRequest(bool added) override;
224     void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override;
225     void didConcludeEditDataInteraction(Optional<WebCore::TextIndicatorData>) override;
226     void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
227 #endif
228
229     void didFinishProcessingAllPendingMouseEvents() final { }
230
231     WKContentView *m_contentView;
232     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
233 };
234 } // namespace WebKit
235
236 #endif // PLATFORM(IOS_FAMILY)