2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef PageClientImpl_h
27 #define PageClientImpl_h
31 #include "CorrectionPanel.h"
32 #include "PageClient.h"
33 #include "WebFullScreenManagerProxy.h"
34 #include <wtf/RetainPtr.h>
36 @class WKEditorUndoTargetObjC;
41 class AlternativeTextUIController;
46 class PageClientImpl final : public PageClient
47 #if ENABLE(FULLSCREEN_API)
48 , public WebFullScreenManagerProxyClient
52 PageClientImpl(WKView *, WKWebView *);
53 virtual ~PageClientImpl();
55 void viewWillMoveToAnotherWindow();
59 virtual std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
60 virtual void setViewNeedsDisplay(const WebCore::IntRect&) override;
61 virtual void displayView() override;
62 virtual bool canScrollView() override;
63 virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) override;
64 virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, bool isProgrammaticScroll) override;
66 virtual WebCore::IntSize viewSize() override;
67 virtual bool isViewWindowActive() override;
68 virtual bool isViewFocused() override;
69 virtual bool isViewVisible() override;
70 virtual bool isViewVisibleOrOccluded() override;
71 virtual bool isViewInWindow() override;
72 virtual bool isVisuallyIdle() override;
73 virtual LayerHostingMode viewLayerHostingMode() override;
74 virtual ColorSpaceData colorSpace() override;
75 virtual void setAcceleratedCompositingRootLayer(LayerOrView *) override;
76 virtual LayerOrView *acceleratedCompositingRootLayer() const override;
78 virtual void processDidExit() override;
79 virtual void pageClosed() override;
80 virtual void didRelaunchProcess() override;
81 virtual void preferencesDidChange() override;
82 virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip) override;
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&) override;
87 virtual void setCursorHiddenUntilMouseMoves(bool) override;
88 virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
90 virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) override;
91 virtual void clearAllEditCommands() override;
92 virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
93 virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
94 virtual bool executeSavedCommandBySelector(const String& selector) override;
95 virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override;
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) override;
98 virtual void updateSecureInputState() override;
99 virtual void resetSecureInputState() override;
100 virtual void notifyInputContextAboutDiscardedComposition() override;
101 virtual void selectionDidChange() override;
102 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
103 virtual void notifyApplicationAboutInputContextChange() override;
106 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
107 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
108 virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
109 virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
111 virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
112 virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
115 CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const override;
117 virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
119 virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*) override;
120 virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) override;
122 #if ENABLE(INPUT_TYPE_COLOR)
123 virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override;
126 virtual void setTextIndicator(PassRefPtr<WebCore::TextIndicator>, bool fadeOut) override;
127 virtual void setTextIndicatorAnimationProgress(float) override;
129 virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
130 virtual void exitAcceleratedCompositingMode() override;
131 virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
133 virtual PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
134 virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
136 virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
138 virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) override;
139 virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) override;
141 virtual void makeFirstResponder() override;
143 virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) override;
144 virtual void dismissContentRelativeChildWindows() override;
146 virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
147 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) override;
148 virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) override;
149 virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) override;
151 virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) override;
153 virtual WKView* wkView() const override { return m_wkView; }
154 virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
156 #if USE(DICTATION_ALTERNATIVES)
157 virtual uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&) override;
158 virtual void removeDictationAlternatives(uint64_t dictationContext) override;
159 virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
160 virtual Vector<String> dictationAlternatives(uint64_t dictationContext) override;
162 #if USE(INSERTION_UNDO_GROUPING)
163 virtual void registerInsertionUndoGrouping() override;
166 // Auxiliary Client Creation
167 #if ENABLE(FULLSCREEN_API)
168 WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
171 #if ENABLE(FULLSCREEN_API)
172 // WebFullScreenManagerProxyClient
173 virtual void closeFullScreenManager() override;
174 virtual bool isFullScreen() override;
175 virtual void enterFullScreen() override;
176 virtual void exitFullScreen() override;
177 virtual void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
178 virtual void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
181 virtual void navigationGestureDidBegin() override;
182 virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
183 virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
184 virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
186 NSView *activeView() const;
187 NSWindow *activeWindow() const;
189 virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
190 virtual void didFinishLoadForMainFrame() override;
191 virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
192 virtual void removeNavigationGestureSnapshot() override;
194 virtual void didPerformActionMenuHitTest(const ActionMenuHitTestResult&, bool forImmediateAction, API::Object*) override;
195 virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
198 WKWebView *m_webView;
199 RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
200 #if USE(AUTOCORRECTION_PANEL)
201 CorrectionPanel m_correctionPanel;
203 #if USE(DICTATION_ALTERNATIVES)
204 std::unique_ptr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
208 } // namespace WebKit
210 #endif // PLATFORM(MAC)
212 #endif // PageClientImpl_h