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