[Qt] [WK2] Support customizing popup menus with QML
[WebKit-https.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 <QGuiApplication>
30 #include <QUndoStack>
31 #include <WebCore/Cursor.h>
32 #include <WebCore/DragData.h>
33 #include <WebCore/FloatRect.h>
34 #include <WebCore/NotImplemented.h>
35
36 using namespace WebKit;
37 using namespace WebCore;
38
39 QtPageClient::QtPageClient()
40     : m_qtWebPageProxy(0)
41 {
42 }
43
44 QtPageClient::~QtPageClient()
45 {
46 }
47
48 PassOwnPtr<DrawingAreaProxy> QtPageClient::createDrawingAreaProxy()
49 {
50     return m_qtWebPageProxy->createDrawingAreaProxy();
51 }
52
53 void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect)
54 {
55     m_qtWebPageProxy->setViewNeedsDisplay(rect);
56 }
57
58 void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
59 {
60     m_qtWebPageProxy->pageDidRequestScroll(pos);
61 }
62
63 void QtPageClient::processDidCrash()
64 {
65     m_qtWebPageProxy->processDidCrash();
66 }
67
68 void QtPageClient::didRelaunchProcess()
69 {
70     m_qtWebPageProxy->didRelaunchProcess();
71 }
72
73 void QtPageClient::didChangeContentsSize(const IntSize& newSize)
74 {
75     m_qtWebPageProxy->didChangeContentsSize(newSize);
76 }
77
78 void QtPageClient::didChangeViewportProperties(const WebCore::ViewportArguments& args)
79 {
80     m_qtWebPageProxy->didChangeViewportProperties(args);
81 }
82
83 void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
84 {
85     m_qtWebPageProxy->startDrag(dragData, dragImage);
86 }
87
88 void QtPageClient::handleDownloadRequest(DownloadProxy* download)
89 {
90     m_qtWebPageProxy->handleDownloadRequest(download);
91 }
92
93 void QtPageClient::setCursor(const WebCore::Cursor& cursor)
94 {
95     // FIXME: This is a temporary fix until we get cursor support in QML items.
96     QGuiApplication::setOverrideCursor(*cursor.platformCursor());
97 }
98
99 void QtPageClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
100 {
101     notImplemented();
102 }
103
104 void QtPageClient::toolTipChanged(const String&, const String& newTooltip)
105 {
106     // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
107 }
108
109 void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
110 {
111     m_qtWebPageProxy->registerEditCommand(command, undoOrRedo);
112 }
113
114 void QtPageClient::clearAllEditCommands()
115 {
116     m_qtWebPageProxy->clearAllEditCommands();
117 }
118
119 bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
120 {
121     return m_qtWebPageProxy->canUndoRedo(undoOrRedo);
122 }
123
124 void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
125 {
126     m_qtWebPageProxy->executeUndoRedo(undoOrRedo);
127 }
128
129 FloatRect QtPageClient::convertToDeviceSpace(const FloatRect& rect)
130 {
131     return rect;
132 }
133
134 FloatRect QtPageClient::convertToUserSpace(const FloatRect& rect)
135 {
136     return rect;
137 }
138
139 IntPoint QtPageClient::screenToWindow(const IntPoint& point)
140 {
141     return point;
142 }
143
144 IntRect QtPageClient::windowToScreen(const IntRect& rect)
145 {
146     return rect;
147 }
148
149 PassRefPtr<WebPopupMenuProxy> QtPageClient::createPopupMenuProxy(WebPageProxy* webPageProxy)
150 {
151     return m_qtWebPageProxy->createPopupMenuProxy(webPageProxy);
152 }
153
154 PassRefPtr<WebContextMenuProxy> QtPageClient::createContextMenuProxy(WebPageProxy*)
155 {
156     return WebContextMenuProxyQt::create(m_qtWebPageProxy);
157 }
158
159 void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&)
160 {
161     notImplemented();
162 }
163
164 void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area)
165 {
166     ASSERT(m_eventHandler);
167     m_eventHandler->didFindZoomableArea(target, area);
168 }
169
170 void QtPageClient::focusEditableArea(const IntRect& caret, const IntRect& area)
171 {
172     ASSERT(m_eventHandler);
173     m_eventHandler->focusEditableArea(caret, area);
174 }
175
176 void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
177 {
178     m_qtWebPageProxy->didReceiveMessageFromNavigatorQtObject(message);
179 }
180
181 #if ENABLE(TOUCH_EVENTS)
182 void QtPageClient::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
183 {
184     ASSERT(m_eventHandler);
185     m_eventHandler->doneWithTouchEvent(event, wasEventHandled);
186 }
187 #endif
188
189 void QtPageClient::displayView()
190 {
191     // FIXME: Implement.
192 }
193
194 void QtPageClient::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
195 {
196     // FIXME: Implement.
197 }
198
199 WebCore::IntSize QtPageClient::viewSize()
200 {
201     return m_qtWebPageProxy->viewSize();
202 }
203
204 bool QtPageClient::isViewWindowActive()
205 {
206     // FIXME: The scene graph does not have the concept of being active or not when this was written.
207     return true;
208 }
209
210 bool QtPageClient::isViewFocused()
211 {
212     if (!m_qtWebPageProxy)
213         return false;
214
215     return m_qtWebPageProxy->isViewFocused();
216 }
217
218 bool QtPageClient::isViewVisible()
219 {
220     if (!m_qtWebPageProxy)
221         return false;
222
223     return m_qtWebPageProxy->isViewVisible();
224 }
225
226 bool QtPageClient::isViewInWindow()
227 {
228     // FIXME: Implement.
229     return true;
230 }
231
232 void QtPageClient::enterAcceleratedCompositingMode(const LayerTreeContext&)
233 {
234     // FIXME: Implement.
235 }
236
237 void QtPageClient::exitAcceleratedCompositingMode()
238 {
239     // FIXME: Implement.
240 }
241