32cc1d94b6eecee40362aea303770b0addc6e16c
[WebKit-https.git] / Source / WebKit2 / UIProcess / mac / PageClientImpl.h
1 /*
2  * Copyright (C) 2010, 2011 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 #ifndef PageClientImpl_h
27 #define PageClientImpl_h
28
29 #if PLATFORM(MAC)
30
31 #include "CorrectionPanel.h"
32 #include "PageClient.h"
33 #include "WebFullScreenManagerProxy.h"
34 #include <wtf/RetainPtr.h>
35
36 @class WKEditorUndoTargetObjC;
37 @class WKView;
38 @class WKWebView;
39
40 namespace WebCore {
41 class AlternativeTextUIController;
42 }
43
44 namespace WebKit {
45
46 class PageClientImpl final : public PageClient
47 #if ENABLE(FULLSCREEN_API)
48     , public WebFullScreenManagerProxyClient
49 #endif
50     {
51 public:
52     PageClientImpl(WKView *, WKWebView *);
53     virtual ~PageClientImpl();
54     
55     void viewWillMoveToAnotherWindow();
56
57 private:
58     // PageClient
59     virtual std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy();
60     virtual void setViewNeedsDisplay(const WebCore::IntRect&);
61     virtual void displayView();
62     virtual bool canScrollView();
63     virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
64     virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, bool isProgrammaticScroll);
65
66     virtual WebCore::IntSize viewSize();
67     virtual bool isViewWindowActive();
68     virtual bool isViewFocused();
69     virtual bool isViewVisible();
70     virtual bool isViewVisibleOrOccluded();
71     virtual bool isViewInWindow();
72     virtual bool isVisuallyIdle();
73     virtual LayerHostingMode viewLayerHostingMode() override;
74     virtual ColorSpaceData colorSpace() override;
75     virtual void setAcceleratedCompositingRootLayer(LayerOrView *) override;
76     virtual LayerOrView *acceleratedCompositingRootLayer() const override;
77
78     virtual void processDidExit();
79     virtual void pageClosed();
80     virtual void didRelaunchProcess();
81     virtual void preferencesDidChange() override;
82     virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
83     virtual void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
84     virtual void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
85     virtual void handleDownloadRequest(DownloadProxy*) override;
86     virtual void setCursor(const WebCore::Cursor&);
87     virtual void setCursorHiddenUntilMouseMoves(bool);
88     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
89
90     virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
91     virtual void clearAllEditCommands();
92     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
93     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
94     virtual bool executeSavedCommandBySelector(const String& selector);
95     virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
96     virtual void setPromisedData(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
97         const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer);
98     virtual void updateSecureInputState() override;
99     virtual void resetSecureInputState() override;
100     virtual void notifyInputContextAboutDiscardedComposition() override;
101 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
102     virtual void notifyApplicationAboutInputContextChange() override;
103 #endif
104
105     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
106     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
107     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&);
108     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&);
109 #if PLATFORM(IOS)
110     virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
111     virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
112 #endif
113
114     CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const;
115
116     virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled);
117
118     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
119     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
120
121 #if ENABLE(INPUT_TYPE_COLOR)
122     virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&);
123 #endif
124
125     void setTextIndicator(PassRefPtr<WebCore::TextIndicator>, bool fadeOut);
126
127     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
128     virtual void exitAcceleratedCompositingMode();
129     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
130
131     virtual PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
132     virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
133
134     virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&);
135
136     virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus);
137     virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState);
138
139     virtual void makeFirstResponder();
140     
141     virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&);
142     virtual void dismissDictionaryLookupPanel();
143     virtual void dismissActionMenuPopovers();
144
145     virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
146     virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText);
147     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText);
148     virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
149
150     virtual void recommendedScrollbarStyleDidChange(int32_t newStyle);
151
152     virtual WKView* wkView() const { return m_wkView; }
153     virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
154
155 #if USE(DICTATION_ALTERNATIVES)
156     virtual uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&);
157     virtual void removeDictationAlternatives(uint64_t dictationContext);
158     virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext);
159     virtual Vector<String> dictationAlternatives(uint64_t dictationContext);
160 #endif
161 #if USE(INSERTION_UNDO_GROUPING)
162     virtual void registerInsertionUndoGrouping() override;
163 #endif
164
165     // Auxiliary Client Creation
166 #if ENABLE(FULLSCREEN_API)
167     WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
168 #endif
169
170 #if ENABLE(FULLSCREEN_API)
171     // WebFullScreenManagerProxyClient
172     virtual void closeFullScreenManager() override;
173     virtual bool isFullScreen() override;
174     virtual void enterFullScreen() override;
175     virtual void exitFullScreen() override;
176     virtual void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
177     virtual void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
178 #endif
179
180     virtual void navigationGestureDidBegin() override;
181     virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
182     virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
183     virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
184
185     NSView *activeView() const;
186     NSWindow *activeWindow() const;
187
188     virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
189     virtual void didFinishLoadForMainFrame() override;
190     virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
191     virtual void removeNavigationGestureSnapshot() override;
192
193     virtual void didPerformActionMenuHitTest(const ActionMenuHitTestResult&, API::Object*) override;
194     virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
195
196     WKView *m_wkView;
197     WKWebView *m_webView;
198     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
199 #if USE(AUTOCORRECTION_PANEL)
200     CorrectionPanel m_correctionPanel;
201 #endif
202 #if USE(DICTATION_ALTERNATIVES)
203     OwnPtr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
204 #endif
205 };
206
207 } // namespace WebKit
208
209 #endif // PLATFORM(MAC)
210
211 #endif // PageClientImpl_h