[Qt][WK2] Split the QtWebPageProxy into PageClient and QtPageProxy
[WebKit.git] / Source / WebKit2 / UIProcess / qt / QtPageClient.cpp
1 /*
2  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #include "config.h"
22 #include "QtPageClient.h"
23
24 #include "QtWebPageEventHandler.h"
25 #include "QtWebPageProxy.h"
26 #include "QtWebUndoCommand.h"
27 #include "WebContextMenuProxyQt.h"
28 #include "WebEditCommandProxy.h"
29 #include "WebPopupMenuProxyQtDesktop.h"
30 #include <QGuiApplication>
31 #include <QUndoStack>
32 #include <WebCore/Cursor.h>
33 #include <WebCore/DragData.h>
34 #include <WebCore/FloatRect.h>
35 #include <WebCore/NotImplemented.h>
36
37 using namespace WebKit;
38 using namespace WebCore;
39
40 QtPageClient::QtPageClient()
41     : m_qtWebPageProxy(0)
42 {
43 }
44
45 QtPageClient::~QtPageClient()
46 {
47 }
48
49 PassOwnPtr<DrawingAreaProxy> QtPageClient::createDrawingAreaProxy()
50 {
51     return m_qtWebPageProxy->createDrawingAreaProxy();
52 }
53
54 void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect)
55 {
56     m_qtWebPageProxy->setViewNeedsDisplay(rect);
57 }
58
59 void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
60 {
61     m_qtWebPageProxy->pageDidRequestScroll(pos);
62 }
63
64 void QtPageClient::processDidCrash()
65 {
66     m_qtWebPageProxy->processDidCrash();
67 }
68
69 void QtPageClient::didRelaunchProcess()
70 {
71     m_qtWebPageProxy->didRelaunchProcess();
72 }
73
74 void QtPageClient::didChangeContentsSize(const IntSize& newSize)
75 {
76     m_qtWebPageProxy->didChangeContentsSize(newSize);
77 }
78
79 void QtPageClient::didChangeViewportProperties(const WebCore::ViewportArguments& args)
80 {
81     m_qtWebPageProxy->didChangeViewportProperties(args);
82 }
83
84 void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
85 {
86     m_qtWebPageProxy->startDrag(dragData, dragImage);
87 }
88
89 void QtPageClient::handleDownloadRequest(DownloadProxy* download)
90 {
91     m_qtWebPageProxy->handleDownloadRequest(download);
92 }
93
94 void QtPageClient::setCursor(const WebCore::Cursor& cursor)
95 {
96     // FIXME: This is a temporary fix until we get cursor support in QML items.
97     QGuiApplication::setOverrideCursor(*cursor.platformCursor());
98 }
99
100 void QtPageClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
101 {
102     notImplemented();
103 }
104
105 void QtPageClient::toolTipChanged(const String&, const String& newTooltip)
106 {
107     // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
108 }
109
110 void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
111 {
112     m_qtWebPageProxy->registerEditCommand(command, undoOrRedo);
113 }
114
115 void QtPageClient::clearAllEditCommands()
116 {
117     m_qtWebPageProxy->clearAllEditCommands();
118 }
119
120 bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
121 {
122     return m_qtWebPageProxy->canUndoRedo(undoOrRedo);
123 }
124
125 void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
126 {
127     m_qtWebPageProxy->executeUndoRedo(undoOrRedo);
128 }
129
130 FloatRect QtPageClient::convertToDeviceSpace(const FloatRect& rect)
131 {
132     return rect;
133 }
134
135 FloatRect QtPageClient::convertToUserSpace(const FloatRect& rect)
136 {
137     return rect;
138 }
139
140 IntPoint QtPageClient::screenToWindow(const IntPoint& point)
141 {
142     return point;
143 }
144
145 IntRect QtPageClient::windowToScreen(const IntRect& rect)
146 {
147     return rect;
148 }
149
150 PassRefPtr<WebPopupMenuProxy> QtPageClient::createPopupMenuProxy(WebPageProxy* webPageProxy)
151 {
152     return m_qtWebPageProxy->createPopupMenuProxy(webPageProxy);
153 }
154
155 PassRefPtr<WebContextMenuProxy> QtPageClient::createContextMenuProxy(WebPageProxy*)
156 {
157     return WebContextMenuProxyQt::create(m_qtWebPageProxy);
158 }
159
160 void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&)
161 {
162     notImplemented();
163 }
164
165 void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area)
166 {
167     ASSERT(m_eventHandler);
168     m_eventHandler->didFindZoomableArea(target, area);
169 }
170
171 void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
172 {
173     m_qtWebPageProxy->didReceiveMessageFromNavigatorQtObject(message);
174 }
175
176 #if ENABLE(TOUCH_EVENTS)
177 void QtPageClient::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
178 {
179     ASSERT(m_eventHandler);
180     m_eventHandler->doneWithTouchEvent(event, wasEventHandled);
181 }
182 #endif
183
184 void QtPageClient::displayView()
185 {
186     // FIXME: Implement.
187 }
188
189 void QtPageClient::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
190 {
191     // FIXME: Implement.
192 }
193
194 WebCore::IntSize QtPageClient::viewSize()
195 {
196     return m_qtWebPageProxy->viewSize();
197 }
198
199 bool QtPageClient::isViewWindowActive()
200 {
201     // FIXME: The scene graph does not have the concept of being active or not when this was written.
202     return true;
203 }
204
205 bool QtPageClient::isViewFocused()
206 {
207     if (!m_qtWebPageProxy)
208         return false;
209
210     return m_qtWebPageProxy->isViewFocused();
211 }
212
213 bool QtPageClient::isViewVisible()
214 {
215     if (!m_qtWebPageProxy)
216         return false;
217
218     return m_qtWebPageProxy->isViewVisible();
219 }
220
221 bool QtPageClient::isViewInWindow()
222 {
223     // FIXME: Implement.
224     return true;
225 }
226
227 void QtPageClient::enterAcceleratedCompositingMode(const LayerTreeContext&)
228 {
229     // FIXME: Implement.
230 }
231
232 void QtPageClient::exitAcceleratedCompositingMode()
233 {
234     // FIXME: Implement.
235 }
236