[WPE] Do not use a sync IPC message to send the host FD to the web process
[WebKit-https.git] / Source / WebKit / UIProcess / API / wpe / PageClientImpl.cpp
1 /*
2  * Copyright (C) 2014 Igalia S.L.
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 #include "config.h"
27 #include "PageClientImpl.h"
28
29 #include "AcceleratedDrawingAreaProxy.h"
30 #include "NativeWebMouseEvent.h"
31 #include "NativeWebWheelEvent.h"
32 #include "ScrollGestureController.h"
33 #include "WPEView.h"
34 #include "WebContextMenuProxy.h"
35 #include "WebContextMenuProxyWPE.h"
36 #include <WebCore/ActivityState.h>
37 #include <WebCore/NotImplemented.h>
38
39 namespace WebKit {
40
41 PageClientImpl::PageClientImpl(WKWPE::View& view)
42     : m_view(view)
43     , m_scrollGestureController(std::make_unique<ScrollGestureController>())
44 {
45 }
46
47 PageClientImpl::~PageClientImpl() = default;
48
49 struct wpe_view_backend* PageClientImpl::viewBackend()
50 {
51     return m_view.backend();
52 }
53
54 IPC::Attachment PageClientImpl::hostFileDescriptor()
55 {
56     return wpe_view_backend_get_renderer_host_fd(m_view.backend());
57 }
58
59 std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(WebProcessProxy& process)
60 {
61     return std::make_unique<AcceleratedDrawingAreaProxy>(m_view.page(), process);
62 }
63
64 void PageClientImpl::setViewNeedsDisplay(const WebCore::Region&)
65 {
66 }
67
68 void PageClientImpl::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool)
69 {
70 }
71
72 WebCore::FloatPoint PageClientImpl::viewScrollPosition()
73 {
74     return { };
75 }
76
77 WebCore::IntSize PageClientImpl::viewSize()
78 {
79     return m_view.size();
80 }
81
82 bool PageClientImpl::isViewWindowActive()
83 {
84     return m_view.viewState().contains(WebCore::ActivityState::WindowIsActive);
85 }
86
87 bool PageClientImpl::isViewFocused()
88 {
89     return m_view.viewState().contains(WebCore::ActivityState::IsFocused);
90 }
91
92 bool PageClientImpl::isViewVisible()
93 {
94     return m_view.viewState().contains(WebCore::ActivityState::IsVisible);
95 }
96
97 bool PageClientImpl::isViewInWindow()
98 {
99     return m_view.viewState().contains(WebCore::ActivityState::IsInWindow);
100 }
101
102 void PageClientImpl::processDidExit()
103 {
104 }
105
106 void PageClientImpl::didRelaunchProcess()
107 {
108 }
109
110 void PageClientImpl::pageClosed()
111 {
112 }
113
114 void PageClientImpl::preferencesDidChange()
115 {
116 }
117
118 void PageClientImpl::toolTipChanged(const String&, const String&)
119 {
120 }
121
122 void PageClientImpl::didCommitLoadForMainFrame(const String&, bool)
123 {
124 }
125
126 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
127 {
128     ASSERT(download);
129     m_view.handleDownloadRequest(*download);
130 }
131
132 void PageClientImpl::didChangeContentSize(const WebCore::IntSize&)
133 {
134 }
135
136 void PageClientImpl::setCursor(const WebCore::Cursor&)
137 {
138 }
139
140 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool)
141 {
142 }
143
144 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
145 {
146 }
147
148 void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&&, UndoOrRedo)
149 {
150 }
151
152 void PageClientImpl::clearAllEditCommands()
153 {
154 }
155
156 bool PageClientImpl::canUndoRedo(UndoOrRedo)
157 {
158     return false;
159 }
160
161 void PageClientImpl::executeUndoRedo(UndoOrRedo)
162 {
163 }
164
165 WebCore::FloatRect PageClientImpl::convertToDeviceSpace(const WebCore::FloatRect& rect)
166 {
167     return rect;
168 }
169
170 WebCore::FloatRect PageClientImpl::convertToUserSpace(const WebCore::FloatRect& rect)
171 {
172     return rect;
173 }
174
175 WebCore::IntPoint PageClientImpl::screenToRootView(const WebCore::IntPoint& point)
176 {
177     return point;
178 }
179
180 WebCore::IntRect PageClientImpl::rootViewToScreen(const WebCore::IntRect& rect)
181 {
182     return rect;
183 }
184
185 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
186 {
187 }
188
189 #if ENABLE(TOUCH_EVENTS)
190 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& touchEvent, bool wasEventHandled)
191 {
192     if (wasEventHandled)
193         return;
194
195     const struct wpe_input_touch_event_raw* touchPoint = touchEvent.nativeFallbackTouchPoint();
196     if (touchPoint->type == wpe_input_touch_event_type_null)
197         return;
198
199     auto& page = m_view.page();
200
201     if (m_scrollGestureController->handleEvent(touchPoint)) {
202         struct wpe_input_axis_event* axisEvent = m_scrollGestureController->axisEvent();
203         if (axisEvent->type != wpe_input_axis_event_type_null)
204             page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor()));
205         return;
206     }
207
208     struct wpe_input_pointer_event pointerEvent {
209         wpe_input_pointer_event_type_null, touchPoint->time,
210         touchPoint->x, touchPoint->y,
211         1, 0, 0
212     };
213
214     switch (touchPoint->type) {
215     case wpe_input_touch_event_type_down:
216         pointerEvent.type = wpe_input_pointer_event_type_button;
217         pointerEvent.state = 1;
218         pointerEvent.modifiers |= wpe_input_pointer_modifier_button1;
219         break;
220     case wpe_input_touch_event_type_motion:
221         pointerEvent.type = wpe_input_pointer_event_type_motion;
222         pointerEvent.state = 1;
223         break;
224     case wpe_input_touch_event_type_up:
225         pointerEvent.type = wpe_input_pointer_event_type_button;
226         pointerEvent.state = 0;
227         pointerEvent.modifiers &= ~wpe_input_pointer_modifier_button1;
228         break;
229     case wpe_input_pointer_event_type_null:
230         ASSERT_NOT_REACHED();
231         return;
232     }
233
234     page.handleMouseEvent(NativeWebMouseEvent(&pointerEvent, page.deviceScaleFactor()));
235 }
236 #endif
237
238 void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&)
239 {
240 }
241
242 RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy&)
243 {
244     return nullptr;
245 }
246
247 #if ENABLE(CONTEXT_MENUS)
248 Ref<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy&, ContextMenuContextData&& context, const UserData& userData)
249 {
250     return WebContextMenuProxyWPE::create(WTFMove(context), userData);
251 }
252 #endif
253
254 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
255 {
256 }
257
258 void PageClientImpl::exitAcceleratedCompositingMode()
259 {
260 }
261
262 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
263 {
264 }
265
266 void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&, const IPC::DataReference&)
267 {
268 }
269
270 void PageClientImpl::navigationGestureDidBegin()
271 {
272 }
273
274 void PageClientImpl::navigationGestureWillEnd(bool, WebBackForwardListItem&)
275 {
276 }
277
278 void PageClientImpl::navigationGestureDidEnd(bool, WebBackForwardListItem&)
279 {
280 }
281
282 void PageClientImpl::navigationGestureDidEnd()
283 {
284 }
285
286 void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem&)
287 {
288 }
289
290 void PageClientImpl::didRemoveNavigationGestureSnapshot()
291 {
292 }
293
294 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
295 {
296 }
297
298 void PageClientImpl::didFinishLoadForMainFrame()
299 {
300 }
301
302 void PageClientImpl::didFailLoadForMainFrame()
303 {
304 }
305
306 void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
307 {
308 }
309
310 void PageClientImpl::didChangeBackgroundColor()
311 {
312 }
313
314 void PageClientImpl::refView()
315 {
316 }
317
318 void PageClientImpl::derefView()
319 {
320 }
321
322 #if ENABLE(VIDEO)
323 bool PageClientImpl::decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&)
324 {
325     return false;
326 }
327 #endif
328
329 void PageClientImpl::didRestoreScrollPosition()
330 {
331 }
332
333 WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
334 {
335     return WebCore::UserInterfaceLayoutDirection::LTR;
336 }
337
338 #if ENABLE(FULLSCREEN_API)
339 WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
340 {
341     return *this;
342 }
343
344 void PageClientImpl::closeFullScreenManager()
345 {
346     notImplemented();
347 }
348
349 bool PageClientImpl::isFullScreen()
350 {
351     return m_view.isFullScreen();
352 }
353
354 void PageClientImpl::enterFullScreen()
355 {
356     if (isFullScreen())
357         return;
358
359     WebFullScreenManagerProxy* fullScreenManagerProxy = m_view.page().fullScreenManager();
360     if (fullScreenManagerProxy) {
361         fullScreenManagerProxy->willEnterFullScreen();
362         m_view.setFullScreen(true);
363         fullScreenManagerProxy->didEnterFullScreen();
364     }
365 }
366
367 void PageClientImpl::exitFullScreen()
368 {
369     if (!isFullScreen())
370         return;
371
372     WebFullScreenManagerProxy* fullScreenManagerProxy = m_view.page().fullScreenManager();
373     if (fullScreenManagerProxy) {
374         fullScreenManagerProxy->willExitFullScreen();
375         m_view.setFullScreen(false);
376         fullScreenManagerProxy->didExitFullScreen();
377     }
378 }
379
380 void PageClientImpl::beganEnterFullScreen(const WebCore::IntRect& /* initialFrame */, const WebCore::IntRect& /* finalFrame */)
381 {
382     notImplemented();
383 }
384
385 void PageClientImpl::beganExitFullScreen(const WebCore::IntRect& /* initialFrame */, const WebCore::IntRect& /* finalFrame */)
386 {
387     notImplemented();
388 }
389
390 #endif // ENABLE(FULLSCREEN_API)
391
392 } // namespace WebKit