WebView.cpp revision 81bc750723a18f21cd17d1b173cd2a4dda9cea6e
1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. 4 * Copyright (C) 2011 Igalia S.L. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 25 * THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include "config.h" 29#include "WebView.h" 30 31#include "ChunkedUpdateDrawingAreaProxy.h" 32#include "NativeWebKeyboardEvent.h" 33#include "NotImplemented.h" 34#include "WebContext.h" 35#include "WebContextMenuProxy.h" 36#include "WebEventFactory.h" 37#include "WebViewWidget.h" 38#include "WebPageProxy.h" 39#include <wtf/text/WTFString.h> 40 41using namespace WebCore; 42 43namespace WebKit { 44 45 46void WebView::handleFocusInEvent(GtkWidget* widget) 47{ 48 if (!(m_isPageActive)) { 49 m_isPageActive = true; 50 m_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); 51 } 52 53 m_page->viewStateDidChange(WebPageProxy::ViewIsFocused); 54} 55 56void WebView::handleFocusOutEvent(GtkWidget* widget) 57{ 58 m_isPageActive = false; 59 m_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); 60} 61 62WebView::WebView(WebContext* context, WebPageGroup* pageGroup) 63 : m_isPageActive(true) 64{ 65 m_page = context->createWebPage(this, pageGroup); 66 67 m_viewWidget = static_cast<GtkWidget*>(g_object_new(WEB_VIEW_TYPE_WIDGET, NULL)); 68 ASSERT(m_viewWidget); 69 70 m_page->initializeWebPage(); 71 72 WebViewWidget* webViewWidget = WEB_VIEW_WIDGET(m_viewWidget); 73 webViewWidgetSetWebViewInstance(webViewWidget, this); 74} 75 76WebView::~WebView() 77{ 78} 79 80GdkWindow* WebView::getWebViewWindow() 81{ 82 return gtk_widget_get_window(m_viewWidget); 83} 84 85void WebView::paint(GtkWidget* widget, GdkRectangle rect, cairo_t* cr) 86{ 87 m_page->drawingArea()->paint(IntRect(rect), cr); 88} 89 90void WebView::setSize(GtkWidget*, IntSize windowSize) 91{ 92 m_page->drawingArea()->setSize(windowSize, IntSize()); 93} 94 95void WebView::handleKeyboardEvent(GdkEventKey* event) 96{ 97 m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event))); 98} 99 100void WebView::handleMouseEvent(GdkEvent* event, int currentClickCount) 101{ 102 m_page->handleMouseEvent(WebEventFactory::createWebMouseEvent(event, currentClickCount)); 103} 104 105void WebView::handleWheelEvent(GdkEventScroll* event) 106{ 107 m_page->handleWheelEvent(WebEventFactory::createWebWheelEvent(event)); 108} 109 110bool WebView::isActive() 111{ 112 return m_isPageActive; 113} 114 115void WebView::close() 116{ 117 m_page->close(); 118} 119 120// PageClient's pure virtual functions 121PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy() 122{ 123 return ChunkedUpdateDrawingAreaProxy::create(this, m_page.get()); 124} 125 126void WebView::setViewNeedsDisplay(const WebCore::IntRect&) 127{ 128 notImplemented(); 129} 130 131void WebView::displayView() 132{ 133 notImplemented(); 134} 135 136void WebView::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) 137{ 138 notImplemented(); 139} 140 141WebCore::IntSize WebView::viewSize() 142{ 143 GtkAllocation allocation; 144 gtk_widget_get_allocation(m_viewWidget, &allocation); 145 return IntSize(allocation.width, allocation.height); 146} 147 148bool WebView::isViewWindowActive() 149{ 150 notImplemented(); 151 return true; 152} 153 154bool WebView::isViewFocused() 155{ 156 notImplemented(); 157 return true; 158} 159 160bool WebView::isViewVisible() 161{ 162 notImplemented(); 163 return true; 164} 165 166bool WebView::isViewInWindow() 167{ 168 notImplemented(); 169 return true; 170} 171 172void WebView::WebView::processDidCrash() 173{ 174 notImplemented(); 175} 176 177void WebView::didRelaunchProcess() 178{ 179 notImplemented(); 180} 181 182void WebView::takeFocus(bool) 183{ 184 notImplemented(); 185} 186 187void WebView::toolTipChanged(const String&, const String&) 188{ 189 notImplemented(); 190} 191 192void WebView::setCursor(const Cursor&) 193{ 194 notImplemented(); 195} 196 197void WebView::setViewportArguments(const WebCore::ViewportArguments&) 198{ 199 notImplemented(); 200} 201 202void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) 203{ 204 notImplemented(); 205} 206 207void WebView::clearAllEditCommands() 208{ 209 notImplemented(); 210} 211 212FloatRect WebView::convertToDeviceSpace(const FloatRect& viewRect) 213{ 214 notImplemented(); 215 return viewRect; 216} 217 218FloatRect WebView::convertToUserSpace(const FloatRect& viewRect) 219{ 220 notImplemented(); 221 return viewRect; 222} 223 224void WebView::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) 225{ 226 notImplemented(); 227} 228 229void WebView::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event) 230{ 231 notImplemented(); 232} 233 234PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy(WebPageProxy*) 235{ 236 notImplemented(); 237 return 0; 238} 239 240PassRefPtr<WebContextMenuProxy> WebView::createContextMenuProxy(WebPageProxy*) 241{ 242 notImplemented(); 243 return 0; 244} 245 246void WebView::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) 247{ 248 notImplemented(); 249} 250 251#if USE(ACCELERATED_COMPOSITING) 252void WebView::pageDidEnterAcceleratedCompositing() 253{ 254 notImplemented(); 255} 256 257void WebView::pageDidLeaveAcceleratedCompositing() 258{ 259 notImplemented(); 260} 261#endif // USE(ACCELERATED_COMPOSITING) 262 263void WebView::didCommitLoadForMainFrame(bool useCustomRepresentation) 264{ 265} 266 267void WebView::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) 268{ 269} 270 271double WebView::customRepresentationZoomFactor() 272{ 273 notImplemented(); 274 return 0; 275} 276 277void WebView::setCustomRepresentationZoomFactor(double) 278{ 279 notImplemented(); 280} 281 282void WebView::pageClosed() 283{ 284 notImplemented(); 285} 286 287void WebView::didChangeScrollbarsForMainFrame() const 288{ 289} 290 291void WebView::flashBackingStoreUpdates(const Vector<IntRect>&) 292{ 293 notImplemented(); 294} 295 296 297} // namespace WebKit 298