Provide a viewport parameter to disable clipping to the safe area
[WebKit-https.git] / Source / WebKit2 / 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)
29
30 #import "PageClient.h"
31 #import "WebFullScreenManagerProxy.h"
32 #import <wtf/RetainPtr.h>
33
34 OBJC_CLASS WKContentView;
35 OBJC_CLASS WKWebView;
36 OBJC_CLASS WKEditorUndoTargetObjC;
37
38 namespace WebKit {
39     
40 class PageClientImpl : public PageClient
41 #if ENABLE(FULLSCREEN_API)
42     , public WebFullScreenManagerProxyClient
43 #endif
44     {
45 public:
46     PageClientImpl(WKContentView *, WKWebView *);
47     virtual ~PageClientImpl();
48     
49 private:
50     // PageClient
51     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
52     void setViewNeedsDisplay(const WebCore::Region&) override;
53     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
54     WebCore::FloatPoint viewScrollPosition() override;
55     WebCore::IntSize viewSize() override;
56     bool isViewWindowActive() override;
57     bool isViewFocused() override;
58     bool isViewVisible() override;
59     bool isViewInWindow() override;
60     bool isViewVisibleOrOccluded() override;
61     bool isVisuallyIdle() override;
62     void processDidExit() override;
63     void didRelaunchProcess() override;
64     void pageClosed() override;
65     void preferencesDidChange() override;
66     void toolTipChanged(const String&, const String&) override;
67     bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, API::SecurityOrigin&, GeolocationPermissionRequestProxy&) override;
68     void didStartProvisionalLoadForMainFrame() override;
69     void didFailProvisionalLoadForMainFrame() override;
70     void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
71     void handleDownloadRequest(DownloadProxy*) override;
72     void didChangeContentSize(const WebCore::IntSize&) override;
73     void setCursor(const WebCore::Cursor&) override;
74     void setCursorHiddenUntilMouseMoves(bool) override;
75     void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
76     void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) override;
77     void clearAllEditCommands() override;
78     bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
79     void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
80     void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
81     bool executeSavedCommandBySelector(const String& selector) override;
82     void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, WebCore::DragSourceAction) override;
83     void updateSecureInputState() override;
84     void resetSecureInputState() override;
85     void notifyInputContextAboutDiscardedComposition() override;
86     void makeFirstResponder() override;
87     WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
88     WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
89     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
90     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
91     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) override;
92     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) override;
93     void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
94 #if ENABLE(TOUCH_EVENTS)
95     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override;
96 #endif
97     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
98 #if ENABLE(CONTEXT_MENUS)
99     std::unique_ptr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override;
100 #endif
101     Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
102
103     void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
104     void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
105     void setTextIndicatorAnimationProgress(float) override;
106
107     void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
108     void exitAcceleratedCompositingMode() override;
109     void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
110     void setAcceleratedCompositingRootLayer(LayerOrView *) override;
111     LayerOrView *acceleratedCompositingRootLayer() const override;
112     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
113
114     PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
115     void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
116
117     void commitPotentialTapFailed() override;
118     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;
119
120     void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
121     void layerTreeCommitComplete() override;
122
123     void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override;
124     void couldNotRestorePageState() override;
125     void restorePageState(std::optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatSize&, double) override;
126     void restorePageCenterAndScale(std::optional<WebCore::FloatPoint>, double) override;
127
128     void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
129     void stopAssistingNode() override;
130     bool isAssistingNode() override;
131     void selectionDidChange() override;
132     bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
133     void positionInformationDidChange(const InteractionInformationAtPosition&) override;
134     void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>) override;
135     void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) override;
136     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
137
138     bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
139     void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
140     double minimumZoomScale() const override;
141     WebCore::FloatRect documentRect() const override;
142
143     void showInspectorHighlight(const WebCore::Highlight&) override;
144     void hideInspectorHighlight() override;
145
146     void showInspectorIndication() override;
147     void hideInspectorIndication() override;
148
149     void enableInspectorNodeSearch() override;
150     void disableInspectorNodeSearch() override;
151
152     void overflowScrollViewWillStartPanGesture() override;
153     void overflowScrollViewDidScroll() override;
154     void overflowScrollWillStartScroll() override;
155     void overflowScrollDidEndScroll() override;
156
157     // Auxiliary Client Creation
158 #if ENABLE(FULLSCREEN_API)
159     virual WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
160 #endif
161
162 #if ENABLE(FULLSCREEN_API)
163     // WebFullScreenManagerProxyClient
164     void closeFullScreenManager() override;
165     bool isFullScreen() override;
166     void enterFullScreen() override;
167     void exitFullScreen() override;
168     void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
169     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
170 #endif
171
172     void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
173
174     Vector<String> mimeTypesWithCustomContentProviders() override;
175
176     void navigationGestureDidBegin() override;
177     void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
178     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
179     void navigationGestureDidEnd() override;
180     void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
181     void didRemoveNavigationGestureSnapshot() override;
182
183     void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
184     void didFinishLoadForMainFrame() override;
185     void didFailLoadForMainFrame() override;
186     void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
187     void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
188     void didCompleteSyntheticClick() override;
189
190     void didChangeBackgroundColor() override;
191
192     void refView() override;
193     void derefView() override;
194
195     void didRestoreScrollPosition() override;
196
197     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
198
199     void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
200
201     void didChangeClipToSafeArea(bool clipToSafeArea) override;
202
203 #if USE(QUICK_LOOK)
204     void requestPasswordForQuickLookDocument(const String& fileName, std::function<void(const String&)>&&) override;
205 #endif
206
207 #if ENABLE(DATA_INTERACTION)
208     void didPerformDataInteractionControllerOperation() override;
209     void didHandleStartDataInteractionRequest(bool started) override;
210     void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) override;
211     void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) override;
212     void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
213 #endif
214
215     WKContentView *m_contentView;
216     WKWebView *m_webView;
217     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
218 };
219 } // namespace WebKit
220
221 #endif // PLATFORM(IOS)