1/* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef WebWidgetClient_h 32#define WebWidgetClient_h 33 34#include "../platform/WebCommon.h" 35#include "../platform/WebRect.h" 36#include "WebNavigationPolicy.h" 37#include "WebScreenInfo.h" 38#include "../platform/WebLayerTreeView.h" 39 40namespace WebKit { 41 42class WebGestureEvent; 43class WebString; 44class WebWidget; 45struct WebCursorInfo; 46struct WebSize; 47 48class WebWidgetClient { 49public: 50 // Called when a region of the WebWidget needs to be re-painted. 51 virtual void didInvalidateRect(const WebRect&) { } 52 53 // Called when a region of the WebWidget, given by clipRect, should be 54 // scrolled by the specified dx and dy amounts. 55 virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) { } 56 57 // Called when the Widget has changed size as a result of an auto-resize. 58 virtual void didAutoResize(const WebSize& newSize) { } 59 60 // Called when the compositor is enabled or disabled. The parameter to 61 // didActivateCompositor() is meaningless. 62 // FIXME: Remove parameter from didActivateCompositor(). 63 virtual void didActivateCompositor(int deprecated) { } 64 virtual void didDeactivateCompositor() { } 65 66 // Attempt to initialize compositing for this widget. If this is successful, 67 // layerTreeView() will return a valid WebLayerTreeView. 68 virtual void initializeLayerTreeView() { } 69 70 // Return a compositing view used for this widget. This is owned by the 71 // WebWidgetClient. 72 virtual WebLayerTreeView* layerTreeView() { return 0; } 73 74 // Sometimes the WebWidget enters a state where it will generate a sequence 75 // of invalidations that should not, by themselves, trigger the compositor 76 // to schedule a new frame. This call indicates to the embedder that it 77 // should suppress compositor scheduling temporarily. 78 virtual void suppressCompositorScheduling(bool enable) { } 79 80 // Indicates to the embedder that the compositor is about to begin a 81 // frame. This is primarily to signal to flow control mechanisms that a 82 // frame is beginning, not to perform actual painting work. 83 virtual void willBeginCompositorFrame() { } 84 85 // Indicates to the embedder that the WebWidget is ready for additional 86 // input. 87 virtual void didBecomeReadyForAdditionalInput() { } 88 89 // Called for compositing mode when a frame commit operation has finished. 90 virtual void didCommitCompositorFrame() { } 91 92 // Called for compositing mode when the draw commands for a WebKit-side 93 // frame have been issued. 94 virtual void didCommitAndDrawCompositorFrame() { } 95 96 // Called for compositing mode when swapbuffers has been posted in the GPU 97 // process. 98 virtual void didCompleteSwapBuffers() { } 99 100 // Called when a call to WebWidget::animate is required 101 virtual void scheduleAnimation() { } 102 103 // Called when the widget acquires or loses focus, respectively. 104 virtual void didFocus() { } 105 virtual void didBlur() { } 106 107 // Called when the cursor for the widget changes. 108 virtual void didChangeCursor(const WebCursorInfo&) { } 109 110 // Called when the widget should be closed. WebWidget::close() should 111 // be called asynchronously as a result of this notification. 112 virtual void closeWidgetSoon() { } 113 114 // Called to show the widget according to the given policy. 115 virtual void show(WebNavigationPolicy) { } 116 117 // Called to block execution of the current thread until the widget is 118 // closed. 119 virtual void runModal() { } 120 121 // Called to enter/exit fullscreen mode. If enterFullScreen returns true, 122 // then WebWidget::{will,Did}EnterFullScreen should bound resizing the 123 // WebWidget into fullscreen mode. Similarly, when exitFullScreen is 124 // called, WebWidget::{will,Did}ExitFullScreen should bound resizing the 125 // WebWidget out of fullscreen mode. 126 virtual bool enterFullScreen() { return false; } 127 virtual void exitFullScreen() { } 128 129 // Called to get/set the position of the widget in screen coordinates. 130 virtual WebRect windowRect() { return WebRect(); } 131 virtual void setWindowRect(const WebRect&) { } 132 133 // Called when a tooltip should be shown at the current cursor position. 134 virtual void setToolTipText(const WebString&, WebTextDirection hint) { } 135 136 // Called to get the position of the resizer rect in window coordinates. 137 virtual WebRect windowResizerRect() { return WebRect(); } 138 139 // Called to get the position of the root window containing the widget 140 // in screen coordinates. 141 virtual WebRect rootWindowRect() { return WebRect(); } 142 143 // Called to query information about the screen where this widget is 144 // displayed. 145 virtual WebScreenInfo screenInfo() { return WebScreenInfo(); } 146 147 // Called to get the scale factor of the display. 148 virtual float deviceScaleFactor() { return 1; } 149 150 // When this method gets called, WebWidgetClient implementation should 151 // reset the input method by cancelling any ongoing composition. 152 virtual void resetInputMethod() { } 153 154 // Requests to lock the mouse cursor. If true is returned, the success 155 // result will be asynchronously returned via a single call to 156 // WebWidget::didAcquirePointerLock() or 157 // WebWidget::didNotAcquirePointerLock(). 158 // If false, the request has been denied synchronously. 159 virtual bool requestPointerLock() { return false; } 160 161 // Cause the pointer lock to be released. This may be called at any time, 162 // including when a lock is pending but not yet acquired. 163 // WebWidget::didLosePointerLock() is called when unlock is complete. 164 virtual void requestPointerUnlock() { } 165 166 // Returns true iff the pointer is locked to this widget. 167 virtual bool isPointerLocked() { return false; } 168 169 // Called when a gesture event is handled. 170 virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled) { } 171 172 // Called to update if touch events should be sent. 173 virtual void hasTouchEventHandlers(bool) { } 174 175 // Called when WebKit programmatically scrolls. 176 virtual void didProgrammaticallyScroll(const WebPoint& scrollPoint) { } 177 178protected: 179 ~WebWidgetClient() { } 180}; 181 182} // namespace WebKit 183 184#endif 185