| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Samsung Electronics | |
| 3 * Copyright (C) 2012 Intel Corporation. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 24 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | |
| 26 | |
| 27 #include "config.h" | |
| 28 #include "ewk_view_private.h" | |
| 29 #include "PlatformWebView.h" | |
| 30 | |
| 31 #include "EWebKit2.h" | |
| 32 #include <WebKit2/WKAPICast.h> | |
| 33 #include <WebKit2/WKRetainPtr.h> | |
| 34 #include <Ecore_Evas.h> | |
| 35 | |
| 36 extern bool useX11Window; | |
| 37 | |
| 38 using namespace WebKit; | |
| 39 | |
| 40 namespace TestWebKitAPI { | |
| 41 | |
| 42 static Ecore_Evas* initEcoreEvas() | |
| 43 { | |
| 44 if (!ecore_evas_init()) | |
| 45 return 0; | |
| 46 | |
| 47 const char* engine = 0; | |
| 48 #if defined(WTF_USE_ACCELERATED_COMPOSITING) && defined(HAVE_ECORE_X) | |
| 49 engine = "opengl_x11"; | |
| 50 #endif | |
| 51 Ecore_Evas* ecoreEvas = ecore_evas_new(engine, 0, 0, 800, 600, 0); | |
| 52 | |
| 53 ASSERT(ecoreEvas); | |
| 54 | |
| 55 ecore_evas_show(ecoreEvas); | |
| 56 | |
| 57 return ecoreEvas; | |
| 58 } | |
| 59 | |
| 60 static void onWebProcessCrashed(void*, Evas_Object*, void* eventInfo) | |
| 61 { | |
| 62 bool* handled = static_cast<bool*>(eventInfo); | |
| 63 *handled = true; | |
| 64 } | |
| 65 | |
| 66 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGro
upRef) | |
| 67 { | |
| 68 m_window = initEcoreEvas(); | |
| 69 | |
| 70 m_view = EWKViewCreate(contextRef, pageGroupRef, ecore_evas_get(m_window), /
* smart */ 0); | |
| 71 | |
| 72 WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(THE
ME_DIR "/default.edj")); | |
| 73 WKViewSetThemePath(EWKViewGetWKView(m_view), wkTheme.get()); | |
| 74 | |
| 75 evas_object_smart_callback_add(m_view, "webprocess,crashed", onWebProcessCra
shed, 0); | |
| 76 resizeTo(600, 800); | |
| 77 } | |
| 78 | |
| 79 PlatformWebView::~PlatformWebView() | |
| 80 { | |
| 81 evas_object_del(m_view); | |
| 82 | |
| 83 ecore_evas_free(m_window); | |
| 84 ecore_evas_shutdown(); | |
| 85 } | |
| 86 | |
| 87 void PlatformWebView::resizeTo(unsigned width, unsigned height) | |
| 88 { | |
| 89 evas_object_resize(m_view, width, height); | |
| 90 } | |
| 91 | |
| 92 WKPageRef PlatformWebView::page() const | |
| 93 { | |
| 94 return WKViewGetPage(EWKViewGetWKView(m_view)); | |
| 95 } | |
| 96 | |
| 97 void PlatformWebView::simulateSpacebarKeyPress() | |
| 98 { | |
| 99 Evas* evas = evas_object_evas_get(m_view); | |
| 100 evas_object_focus_set(m_view, true); | |
| 101 evas_event_feed_key_down(evas, "space", "space", " ", 0, 0, 0); | |
| 102 evas_event_feed_key_up(evas, "space", "space", " ", 0, 1, 0); | |
| 103 } | |
| 104 | |
| 105 void PlatformWebView::simulateMouseMove(unsigned x, unsigned y) | |
| 106 { | |
| 107 Evas* evas = evas_object_evas_get(m_view); | |
| 108 evas_object_show(m_view); | |
| 109 evas_event_feed_mouse_move(evas, x, y, 0, 0); | |
| 110 } | |
| 111 | |
| 112 void PlatformWebView::simulateRightClick(unsigned x, unsigned y) | |
| 113 { | |
| 114 Evas* evas = evas_object_evas_get(m_view); | |
| 115 evas_object_show(m_view); | |
| 116 evas_event_feed_mouse_move(evas, x, y, 0, 0); | |
| 117 evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, 0); | |
| 118 evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, 0); | |
| 119 } | |
| 120 | |
| 121 } // namespace TestWebKitAPI | |
| OLD | NEW |