carlosgc@webkit.org | f7e0d8a | 2017-11-20 09:51:07 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 33 | namespace TestWebKitAPI { |
| 34 | |
| 35 | PlatformWebView::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 | |
| 45 | PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration) |
| 46 | : m_window(nullptr) |
| 47 | { |
| 48 | initialize(configuration); |
| 49 | } |
| 50 | |
| 51 | PlatformWebView::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 | |
| 62 | PlatformWebView::~PlatformWebView() |
| 63 | { |
carlosgc@webkit.org | f7e0d8a | 2017-11-20 09:51:07 +0000 | [diff] [blame] | 64 | delete m_window; |
| 65 | } |
| 66 | |
| 67 | void PlatformWebView::initialize(WKPageConfigurationRef configuration) |
| 68 | { |
carlosgc@webkit.org | 2c873db | 2018-06-11 06:43:14 +0000 | [diff] [blame] | 69 | m_window = new WPEToolingBackends::HeadlessViewBackend(800, 600); |
zandobersek@gmail.com | ae70043 | 2018-04-12 08:19:35 +0000 | [diff] [blame] | 70 | m_view = WKViewCreate(m_window->backend(), configuration); |
carlosgc@webkit.org | f7e0d8a | 2017-11-20 09:51:07 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | WKPageRef PlatformWebView::page() const |
| 74 | { |
| 75 | return WKViewGetPage(m_view); |
| 76 | } |
| 77 | |
| 78 | void PlatformWebView::resizeTo(unsigned width, unsigned height) |
| 79 | { |
| 80 | // FIXME: implement this. |
| 81 | } |
| 82 | |
| 83 | void PlatformWebView::simulateSpacebarKeyPress() |
| 84 | { |
| 85 | // FIXME: implement this. |
| 86 | } |
| 87 | |
| 88 | void PlatformWebView::simulateAltKeyPress() |
| 89 | { |
| 90 | // FIXME: implement this. |
| 91 | } |
| 92 | |
| 93 | void PlatformWebView::simulateRightClick(unsigned x, unsigned y) |
| 94 | { |
| 95 | // FIXME: implement this. |
| 96 | } |
| 97 | |
| 98 | void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers) |
| 99 | { |
| 100 | // FIXME: implement this. |
| 101 | } |
| 102 | |
| 103 | } // namespace TestWebKitAPI |