blob: 8cc3b71a73218233f404a94162fe0585a86720f2 [file] [log] [blame]
carlosgc@webkit.orgf7e0d8a2017-11-20 09:51:07 +00001/*
2 * Copyright (C) 2012 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 "PlatformWebView.h"
28
29#include "HeadlessViewBackend.h"
30#include <WebKit/WKRetainPtr.h>
31#include <WebKit/WKView.h>
32
33namespace TestWebKitAPI {
34
35PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
36 : m_window(nullptr)
37{
38 WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
39 WKPageConfigurationSetContext(configuration.get(), contextRef);
40 WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
41
42 initialize(configuration.get());
43}
44
45PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
46 : m_window(nullptr)
47{
48 initialize(configuration);
49}
50
51PlatformWebView::PlatformWebView(WKPageRef relatedPage)
52 : m_window(nullptr)
53{
54 WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
55 WKPageConfigurationSetContext(configuration.get(), WKPageGetContext(relatedPage));
56 WKPageConfigurationSetPageGroup(configuration.get(), WKPageGetPageGroup(relatedPage));
57 WKPageConfigurationSetRelatedPage(configuration.get(), relatedPage);
58
59 initialize(configuration.get());
60}
61
62PlatformWebView::~PlatformWebView()
63{
carlosgc@webkit.orgf7e0d8a2017-11-20 09:51:07 +000064 delete m_window;
65}
66
67void PlatformWebView::initialize(WKPageConfigurationRef configuration)
68{
carlosgc@webkit.org2c873db2018-06-11 06:43:14 +000069 m_window = new WPEToolingBackends::HeadlessViewBackend(800, 600);
zandobersek@gmail.comae700432018-04-12 08:19:35 +000070 m_view = WKViewCreate(m_window->backend(), configuration);
carlosgc@webkit.orgf7e0d8a2017-11-20 09:51:07 +000071}
72
73WKPageRef PlatformWebView::page() const
74{
75 return WKViewGetPage(m_view);
76}
77
78void PlatformWebView::resizeTo(unsigned width, unsigned height)
79{
80 // FIXME: implement this.
81}
82
83void PlatformWebView::simulateSpacebarKeyPress()
84{
85 // FIXME: implement this.
86}
87
88void PlatformWebView::simulateAltKeyPress()
89{
90 // FIXME: implement this.
91}
92
93void PlatformWebView::simulateRightClick(unsigned x, unsigned y)
94{
95 // FIXME: implement this.
96}
97
98void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers)
99{
100 // FIXME: implement this.
101}
102
103} // namespace TestWebKitAPI