2 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "WebViewEfl.h"
29 #include "DownloadManagerEfl.h"
31 #include "InputMethodContextEfl.h"
32 #include "NativeWebMouseEvent.h"
33 #include "NotImplemented.h"
34 #include "WebContextMenuProxyEfl.h"
35 #include "WebPopupMenuListenerEfl.h"
36 #include "ewk_context_private.h"
37 #include <WebCore/CoordinatedGraphicsScene.h>
38 #include <WebCore/PlatformContextCairo.h>
40 #if ENABLE(FULLSCREEN_API)
41 #include "WebFullScreenManagerProxy.h"
44 #if ENABLE(TOUCH_EVENTS)
45 #include "EwkTouchEvent.h"
48 #if ENABLE(INPUT_TYPE_COLOR)
49 #include "WebColorPickerEfl.h"
52 using namespace EwkViewCallbacks;
53 using namespace WebCore;
57 PassRefPtr<WebView> WebView::create(WebContext* context, WebPageGroup* pageGroup)
59 return adoptRef(new WebViewEfl(context, pageGroup));
62 WebViewEfl::WebViewEfl(WebContext* context, WebPageGroup* pageGroup)
63 : WebView(context, pageGroup)
65 , m_hasRequestedFullScreen(false)
69 void WebViewEfl::setEwkView(EwkView* ewkView)
74 void WebViewEfl::paintToCairoSurface(cairo_surface_t* surface)
76 CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
80 PlatformContextCairo context(cairo_create(surface));
82 const FloatPoint& position = contentPosition();
83 double effectiveScale = m_page->deviceScaleFactor() * contentScaleFactor();
85 cairo_matrix_t transform = { effectiveScale, 0, 0, effectiveScale, - position.x() * m_page->deviceScaleFactor(), - position.y() * m_page->deviceScaleFactor() };
86 cairo_set_matrix(context.cr(), &transform);
87 scene->paintToGraphicsContext(&context);
90 PassRefPtr<WebPopupMenuProxy> WebViewEfl::createPopupMenuProxy(WebPageProxy* page)
92 return WebPopupMenuListenerEfl::create(page);
95 #if ENABLE(CONTEXT_MENUS)
96 PassRefPtr<WebContextMenuProxy> WebViewEfl::createContextMenuProxy(WebPageProxy* page)
98 return WebContextMenuProxyEfl::create(m_ewkView, page);
102 void WebViewEfl::setCursor(const Cursor& cursor)
104 m_ewkView->setCursor(cursor);
107 void WebViewEfl::updateTextInputState()
109 if (InputMethodContextEfl* inputMethodContext = m_ewkView->inputMethodContext())
110 inputMethodContext->updateTextInputState();
113 void WebViewEfl::handleDownloadRequest(DownloadProxy* download)
115 EwkContext* context = m_ewkView->ewkContext();
116 context->downloadManager()->registerDownloadJob(toAPI(download), m_ewkView);
119 void WebViewEfl::setThemePath(const String& theme)
121 m_page->setThemePath(theme);
124 #if ENABLE(TOUCH_EVENTS)
125 void WebViewEfl::sendTouchEvent(EwkTouchEvent* touchEvent)
128 m_page->handleTouchEvent(NativeWebTouchEvent(touchEvent, transformFromScene()));
132 void WebViewEfl::sendMouseEvent(const Evas_Event_Mouse_Down* event)
135 m_page->handleMouseEvent(NativeWebMouseEvent(event, transformFromScene(), m_userViewportTransform.toAffineTransform()));
138 void WebViewEfl::sendMouseEvent(const Evas_Event_Mouse_Up* event)
141 m_page->handleMouseEvent(NativeWebMouseEvent(event, transformFromScene(), m_userViewportTransform.toAffineTransform()));
144 void WebViewEfl::sendMouseEvent(const Evas_Event_Mouse_Move* event)
147 m_page->handleMouseEvent(NativeWebMouseEvent(event, transformFromScene(), m_userViewportTransform.toAffineTransform()));
150 void WebViewEfl::setViewBackgroundColor(const WebCore::Color& color)
152 CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
156 scene->setViewBackgroundColor(color);
159 WebCore::Color WebViewEfl::viewBackgroundColor()
161 CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
165 return scene->viewBackgroundColor();
168 #if ENABLE(FULLSCREEN_API)
170 // WebFullScreenManagerProxyClient
171 bool WebViewEfl::isFullScreen()
173 return m_hasRequestedFullScreen;
176 void WebViewEfl::enterFullScreen()
178 if (!m_ewkView || m_hasRequestedFullScreen)
181 m_hasRequestedFullScreen = true;
183 WebFullScreenManagerProxy* manager = m_page->fullScreenManager();
184 manager->willEnterFullScreen();
185 m_ewkView->enterFullScreen();
186 manager->didEnterFullScreen();
189 void WebViewEfl::exitFullScreen()
191 if (!m_ewkView || !m_hasRequestedFullScreen)
194 m_hasRequestedFullScreen = false;
196 WebFullScreenManagerProxy* manager = m_page->fullScreenManager();
197 manager->willExitFullScreen();
198 m_ewkView->exitFullScreen();
199 manager->didExitFullScreen();
201 #endif // ENABLE(FULLSCREEN_API)
203 void WebViewEfl::didFinishLoadingDataForCustomContentProvider(const String&, const IPC::DataReference&)
208 #if ENABLE(INPUT_TYPE_COLOR)
209 void WebViewEfl::initializeColorPickerClient(const WKColorPickerClientBase* client)
211 m_colorPickerClient.initialize(client);
214 PassRefPtr<WebColorPicker> WebViewEfl::createColorPicker(WebPageProxy* page, const WebCore::Color& color, const WebCore::IntRect&)
216 return WebColorPickerEfl::create(this, page, color);
220 } // namespace WebKit