[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 8 | #include <deque> |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 9 | #include <map> |
[email protected] | 010ea08a | 2009-10-11 20:21:32 | [diff] [blame] | 10 | |
[email protected] | 8062ab26 | 2014-05-27 16:56:43 | [diff] [blame] | 11 | #include "base/auto_reset.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | #include "base/basictypes.h" |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 13 | #include "base/compiler_specific.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 14 | #include "base/memory/ref_counted.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 15 | #include "base/memory/scoped_ptr.h" |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 16 | #include "base/observer_list.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame] | 17 | #include "base/time/time.h" |
| 18 | #include "base/timer/timer.h" |
[email protected] | c1e6cc06 | 2013-08-24 03:35:35 | [diff] [blame] | 19 | #include "cc/debug/rendering_stats_instrumentation.h" |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 20 | #include "content/common/content_export.h" |
[email protected] | c2809346d | 2014-03-20 00:11:03 | [diff] [blame] | 21 | #include "content/common/cursors/webcursor.h" |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 22 | #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
[email protected] | 9017d785 | 2013-11-21 17:47:35 | [diff] [blame] | 23 | #include "content/common/input/synthetic_gesture_params.h" |
[email protected] | 4f86bdb | 2012-11-10 19:11:19 | [diff] [blame] | 24 | #include "ipc/ipc_listener.h" |
| 25 | #include "ipc/ipc_sender.h" |
[email protected] | 5c30b5e0 | 2013-05-30 03:46:08 | [diff] [blame] | 26 | #include "third_party/WebKit/public/platform/WebRect.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 27 | #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
[email protected] | c27dd4f | 2014-05-22 18:05:19 | [diff] [blame] | 28 | #include "third_party/WebKit/public/web/WebInputEvent.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 29 | #include "third_party/WebKit/public/web/WebPopupType.h" |
| 30 | #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 31 | #include "third_party/WebKit/public/web/WebTextInputInfo.h" |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 32 | #include "third_party/WebKit/public/web/WebTouchAction.h" |
[email protected] | 0e45bd0 | 2013-07-12 20:20:02 | [diff] [blame] | 33 | #include "third_party/WebKit/public/web/WebWidget.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 34 | #include "third_party/WebKit/public/web/WebWidgetClient.h" |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 35 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 36 | #include "ui/base/ime/text_input_mode.h" |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 37 | #include "ui/base/ime/text_input_type.h" |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 38 | #include "ui/base/ui_base_types.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 39 | #include "ui/gfx/native_widget_types.h" |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 40 | #include "ui/gfx/range/range.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 41 | #include "ui/gfx/rect.h" |
[email protected] | 990278ff | 2012-11-13 02:12:55 | [diff] [blame] | 42 | #include "ui/gfx/vector2d.h" |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 43 | #include "ui/gfx/vector2d_f.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 44 | #include "ui/surface/transport_dib.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 45 | |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 46 | struct ViewHostMsg_UpdateRect_Params; |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 47 | struct ViewMsg_Resize_Params; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 48 | class ViewHostMsg_UpdateRect; |
| 49 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 50 | namespace IPC { |
| 51 | class SyncMessage; |
| 52 | } |
| 53 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 54 | namespace blink { |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 55 | struct WebDeviceEmulationParams; |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 56 | class WebGestureEvent; |
[email protected] | f56c787 | 2013-06-18 12:31:57 | [diff] [blame] | 57 | class WebKeyboardEvent; |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 58 | class WebMouseEvent; |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 59 | class WebTouchEvent; |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 60 | } |
| 61 | |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 62 | namespace cc { class OutputSurface; } |
| 63 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 64 | namespace gfx { |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 65 | class Range; |
| 66 | } |
| 67 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 68 | namespace content { |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 69 | class ExternalPopupMenu; |
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 70 | class PepperPluginInstanceImpl; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 71 | class RenderFrameImpl; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 72 | class RenderWidgetCompositor; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 73 | class RenderWidgetTest; |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 74 | class ResizingModeSelector; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 75 | struct ContextMenuParams; |
[email protected] | 29e2fb4 | 2013-07-19 01:13:47 | [diff] [blame] | 76 | struct WebPluginGeometry; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 77 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 78 | // RenderWidget provides a communication bridge between a WebWidget and |
| 79 | // a RenderWidgetHost, the latter of which lives in a different process. |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 80 | class CONTENT_EXPORT RenderWidget |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 81 | : public IPC::Listener, |
| 82 | public IPC::Sender, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 83 | NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 84 | public base::RefCounted<RenderWidget> { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 85 | public: |
| 86 | // Creates a new RenderWidget. The opener_id is the routing ID of the |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 87 | // RenderView that this widget lives inside. |
[email protected] | 0ebf387 | 2008-11-07 21:35:03 | [diff] [blame] | 88 | static RenderWidget* Create(int32 opener_id, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 89 | blink::WebPopupType popup_type, |
| 90 | const blink::WebScreenInfo& screen_info); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 91 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 92 | // Creates a WebWidget based on the popup type. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 93 | static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 94 | |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 95 | int32 routing_id() const { return routing_id_; } |
| 96 | int32 surface_id() const { return surface_id_; } |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 97 | blink::WebWidget* webwidget() const { return webwidget_; } |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 98 | gfx::Size size() const { return size_; } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 99 | bool has_focus() const { return has_focus_; } |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 100 | bool is_fullscreen() const { return is_fullscreen_; } |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 101 | bool is_hidden() const { return is_hidden_; } |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 102 | bool handling_input_event() const { return handling_input_event_; } |
| 103 | // Temporary for debugging purposes... |
| 104 | bool closing() const { return closing_; } |
| 105 | bool is_swapped_out() { return is_swapped_out_; } |
| 106 | ui::MenuSourceType context_menu_source_type() { |
| 107 | return context_menu_source_type_; } |
| 108 | gfx::Point touch_editing_context_menu_location() { |
| 109 | return touch_editing_context_menu_location_; |
| 110 | } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 111 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 112 | // Functions to track out-of-process frames for special notifications. |
| 113 | void RegisterSwappedOutChildFrame(RenderFrameImpl* frame); |
| 114 | void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame); |
| 115 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 116 | // Functions to track all RenderFrame objects associated with this |
| 117 | // RenderWidget. |
| 118 | void RegisterRenderFrame(RenderFrameImpl* frame); |
| 119 | void UnregisterRenderFrame(RenderFrameImpl* frame); |
| 120 | |
[email protected] | a017938b | 2014-05-27 21:17:17 | [diff] [blame] | 121 | #if defined(VIDEO_HOLE) |
| 122 | void RegisterVideoHoleFrame(RenderFrameImpl* frame); |
| 123 | void UnregisterVideoHoleFrame(RenderFrameImpl* frame); |
| 124 | #endif // defined(VIDEO_HOLE) |
| 125 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 126 | // IPC::Listener |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 127 | virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 128 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 129 | // IPC::Sender |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 130 | virtual bool Send(IPC::Message* msg) OVERRIDE; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 131 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 132 | // blink::WebWidgetClient |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame] | 133 | virtual void suppressCompositorScheduling(bool enable); |
[email protected] | 9cd43a6 | 2012-03-26 08:03:56 | [diff] [blame] | 134 | virtual void willBeginCompositorFrame(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 135 | virtual void didAutoResize(const blink::WebSize& new_size); |
[email protected] | e195e58 | 2013-03-08 01:32:59 | [diff] [blame] | 136 | virtual void initializeLayerTreeView(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 137 | virtual blink::WebLayerTreeView* layerTreeView(); |
[email protected] | 3391a077 | 2012-03-28 00:32:07 | [diff] [blame] | 138 | virtual void didBecomeReadyForAdditionalInput(); |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 139 | virtual void didCommitAndDrawCompositorFrame(); |
| 140 | virtual void didCompleteSwapBuffers(); |
[email protected] | 8b9e52b | 2014-01-17 16:35:31 | [diff] [blame] | 141 | virtual void scheduleComposite(); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 142 | virtual void didFocus(); |
| 143 | virtual void didBlur(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 144 | virtual void didChangeCursor(const blink::WebCursorInfo&); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 145 | virtual void closeWidgetSoon(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 146 | virtual void show(blink::WebNavigationPolicy); |
[email protected] | dd48d49 | 2014-03-16 05:04:39 | [diff] [blame] | 147 | virtual void runModal() {} |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 148 | virtual blink::WebRect windowRect(); |
| 149 | virtual void setToolTipText(const blink::WebString& text, |
| 150 | blink::WebTextDirection hint); |
| 151 | virtual void setWindowRect(const blink::WebRect&); |
| 152 | virtual blink::WebRect windowResizerRect(); |
| 153 | virtual blink::WebRect rootWindowRect(); |
| 154 | virtual blink::WebScreenInfo screenInfo(); |
[email protected] | f660d9c | 2012-06-06 18:31:21 | [diff] [blame] | 155 | virtual float deviceScaleFactor(); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 156 | virtual void resetInputMethod(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 157 | virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 158 | bool event_cancelled); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 159 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 160 | // Begins the compositor's scheduler to start producing frames. |
| 161 | void StartCompositor(); |
| 162 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 163 | // Called when a plugin is moved. These events are queued up and sent with |
| 164 | // the next paint or scroll message to the host. |
[email protected] | 29e2fb4 | 2013-07-19 01:13:47 | [diff] [blame] | 165 | void SchedulePluginMove(const WebPluginGeometry& move); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 166 | |
[email protected] | 26865477 | 2009-08-06 23:02:04 | [diff] [blame] | 167 | // Called when a plugin window has been destroyed, to make sure the currently |
| 168 | // pending moves don't try to reference it. |
| 169 | void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window); |
| 170 | |
[email protected] | 24ed043 | 2013-04-24 07:50:31 | [diff] [blame] | 171 | RenderWidgetCompositor* compositor() const; |
| 172 | |
[email protected] | 8062ab26 | 2014-05-27 16:56:43 | [diff] [blame] | 173 | const ui::LatencyInfo* current_event_latency_info() const { |
| 174 | return current_event_latency_info_; |
| 175 | } |
| 176 | |
[email protected] | ebc0e1df | 2013-08-01 02:46:22 | [diff] [blame] | 177 | virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 178 | |
[email protected] | 79fa22e | 2013-08-23 15:18:12 | [diff] [blame] | 179 | // Callback for use with synthetic gestures (e.g. BeginSmoothScroll). |
| 180 | typedef base::Callback<void()> SyntheticGestureCompletionCallback; |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 181 | |
[email protected] | 9017d785 | 2013-11-21 17:47:35 | [diff] [blame] | 182 | // Send a synthetic gesture to the browser to be queued to the synthetic |
| 183 | // gesture controller. |
| 184 | void QueueSyntheticGesture( |
| 185 | scoped_ptr<SyntheticGestureParams> gesture_params, |
| 186 | const SyntheticGestureCompletionCallback& callback); |
[email protected] | 1e1dd18 | 2013-09-12 01:51:15 | [diff] [blame] | 187 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 188 | // Close the underlying WebWidget. |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 189 | virtual void Close(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 190 | |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 191 | // Notifies about a compositor frame commit operation having finished. |
| 192 | virtual void DidCommitCompositorFrame(); |
| 193 | |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 194 | // Handle common setup/teardown for handling IME events. |
| 195 | void StartHandlingImeEvent(); |
| 196 | void FinishHandlingImeEvent(); |
| 197 | |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 198 | // Returns whether we currently should handle an IME event. |
| 199 | bool ShouldHandleImeEvent(); |
| 200 | |
[email protected] | 3300477 | 2013-11-12 09:49:23 | [diff] [blame] | 201 | virtual void InstrumentWillBeginFrame(int frame_id) {} |
[email protected] | 35134e1 | 2013-02-22 20:07:40 | [diff] [blame] | 202 | virtual void InstrumentDidBeginFrame() {} |
| 203 | virtual void InstrumentDidCancelFrame() {} |
| 204 | virtual void InstrumentWillComposite() {} |
| 205 | |
[email protected] | c27dd4f | 2014-05-22 18:05:19 | [diff] [blame] | 206 | // When paused in debugger, we send ack for mouse event early. This ensures |
| 207 | // that we continue receiving mouse moves and pass them to debugger. Returns |
| 208 | // whether we are paused in mouse move event and have sent the ack. |
| 209 | bool SendAckForMouseMoveFromDebugger(); |
| 210 | |
| 211 | // When resumed from pause in debugger while handling mouse move, |
| 212 | // we should not send an extra ack (see SendAckForMouseMoveFromDebugger). |
| 213 | void IgnoreAckForMouseMoveFromDebugger(); |
| 214 | |
[email protected] | c8cbae7 | 2013-05-23 10:45:03 | [diff] [blame] | 215 | bool UsingSynchronousRendererCompositor() const; |
[email protected] | 34bb3ac | 2013-03-08 02:41:28 | [diff] [blame] | 216 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 217 | // ScreenMetricsEmulator class manages screen emulation inside a render |
| 218 | // widget. This includes resizing, placing view on the screen at desired |
| 219 | // position, changing device scale factor, and scaling down the whole |
| 220 | // widget if required to fit into the browser window. |
| 221 | class ScreenMetricsEmulator; |
| 222 | |
| 223 | // Emulates screen and widget metrics. Supplied values override everything |
| 224 | // coming from host. |
| 225 | void EnableScreenMetricsEmulation( |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 226 | const blink::WebDeviceEmulationParams& params); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 227 | void DisableScreenMetricsEmulation(); |
| 228 | void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); |
| 229 | |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 230 | void ScheduleCompositeWithForcedRedraw(); |
| 231 | |
[email protected] | 4d7e46a | 2013-11-08 05:33:40 | [diff] [blame] | 232 | // Called by the compositor in single-threaded mode when a swap is posted, |
| 233 | // completes or is aborted. |
| 234 | void OnSwapBuffersPosted(); |
| 235 | void OnSwapBuffersComplete(); |
| 236 | void OnSwapBuffersAborted(); |
| 237 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 238 | // Checks if the text input state and compose inline mode have been changed. |
| 239 | // If they are changed, the new value will be sent to the browser process. |
| 240 | void UpdateTextInputType(); |
| 241 | |
| 242 | // Checks if the selection bounds have been changed. If they are changed, |
| 243 | // the new value will be sent to the browser process. |
| 244 | void UpdateSelectionBounds(); |
| 245 | |
[email protected] | e5e438d6 | 2014-03-27 21:47:16 | [diff] [blame] | 246 | virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); |
| 247 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 248 | void OnShowHostContextMenu(ContextMenuParams* params); |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 249 | |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 250 | #if defined(OS_ANDROID) || defined(USE_AURA) |
[email protected] | 90f2415 | 2014-04-09 12:41:36 | [diff] [blame] | 251 | enum ShowIme { |
| 252 | SHOW_IME_IF_NEEDED, |
| 253 | NO_SHOW_IME, |
| 254 | }; |
| 255 | |
| 256 | enum ChangeSource { |
| 257 | FROM_NON_IME, |
| 258 | FROM_IME, |
| 259 | }; |
| 260 | |
| 261 | // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to |
| 262 | // be displayed, e.g. after a tap on an input field on mobile. |
| 263 | // |change_source| should be FROM_NON_IME when the renderer has to wait for |
| 264 | // the browser to acknowledge the change before the renderer handles any more |
| 265 | // IME events. This is when the text change did not originate from the IME in |
| 266 | // the browser side, such as changes by JavaScript or autofill. |
| 267 | void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 268 | #endif |
| 269 | |
[email protected] | f9db7d2d | 2014-04-11 16:07:11 | [diff] [blame] | 270 | #if defined(OS_MACOSX) || defined(USE_AURA) |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 271 | // Checks if the composition range or composition character bounds have been |
| 272 | // changed. If they are changed, the new value will be sent to the browser |
| 273 | // process. |
| 274 | void UpdateCompositionInfo(bool should_update_range); |
| 275 | #endif |
| 276 | |
[email protected] | 70b73b2c | 2014-05-01 04:31:39 | [diff] [blame] | 277 | #if defined(OS_MACOSX) |
| 278 | void DidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar, |
| 279 | bool has_vertical_scrollbar); |
| 280 | #endif // defined(OS_MACOSX) |
| 281 | |
[email protected] | a4f0d88 | 2014-05-01 23:48:10 | [diff] [blame] | 282 | #if defined(OS_ANDROID) |
| 283 | void DidChangeBodyBackgroundColor(SkColor bg_color); |
| 284 | #endif |
| 285 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 286 | protected: |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 287 | // Friend RefCounted so that the dtor can be non-public. Using this class |
| 288 | // without ref-counting is an error. |
| 289 | friend class base::RefCounted<RenderWidget>; |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 290 | // For unit tests. |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 291 | friend class RenderWidgetTest; |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 292 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 293 | enum ResizeAck { |
| 294 | SEND_RESIZE_ACK, |
| 295 | NO_RESIZE_ACK, |
| 296 | }; |
| 297 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 298 | RenderWidget(blink::WebPopupType popup_type, |
| 299 | const blink::WebScreenInfo& screen_info, |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 300 | bool swapped_out, |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 301 | bool hidden, |
| 302 | bool never_visible); |
[email protected] | ce2b28e | 2012-08-09 15:53:57 | [diff] [blame] | 303 | |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 304 | virtual ~RenderWidget(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 305 | |
| 306 | // Initializes this view with the given opener. CompleteInit must be called |
| 307 | // later. |
[email protected] | a635f94 | 2012-12-07 10:34:29 | [diff] [blame] | 308 | bool Init(int32 opener_id); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 309 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 310 | // Called by Init and subclasses to perform initialization. |
[email protected] | a635f94 | 2012-12-07 10:34:29 | [diff] [blame] | 311 | bool DoInit(int32 opener_id, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 312 | blink::WebWidget* web_widget, |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 313 | IPC::SyncMessage* create_widget_message); |
| 314 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 315 | // Finishes creation of a pending view started with Init. |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame] | 316 | void CompleteInit(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 317 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 318 | // Sets whether this RenderWidget has been swapped out to be displayed by |
| 319 | // a RenderWidget in a different process. If so, no new IPC messages will be |
| 320 | // sent (only ACKs) and the process is free to exit when there are no other |
| 321 | // active RenderWidgets. |
| 322 | void SetSwappedOut(bool is_swapped_out); |
| 323 | |
[email protected] | fd84779 | 2013-10-24 17:12:35 | [diff] [blame] | 324 | void FlushPendingInputEventAck(); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 325 | void DoDeferredClose(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 326 | void DoDeferredSetWindowRect(const blink::WebRect& pos); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 327 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 328 | // Resizes the render widget. |
| 329 | void Resize(const gfx::Size& new_size, |
[email protected] | 60d47ac | 2013-03-01 23:42:44 | [diff] [blame] | 330 | const gfx::Size& physical_backing_size, |
[email protected] | d908376 | 2013-03-24 01:36:40 | [diff] [blame] | 331 | float overdraw_bottom_height, |
[email protected] | bb6378fe | 2014-04-28 21:19:44 | [diff] [blame] | 332 | const gfx::Size& visible_viewport_size, |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 333 | const gfx::Rect& resizer_rect, |
| 334 | bool is_fullscreen, |
| 335 | ResizeAck resize_ack); |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 336 | // Used to force the size of a window when running layout tests. |
| 337 | void ResizeSynchronously(const gfx::Rect& new_position); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 338 | virtual void SetScreenMetricsEmulationParameters( |
[email protected] | 7f99fc2 | 2013-11-08 14:05:58 | [diff] [blame] | 339 | float device_scale_factor, |
| 340 | const gfx::Point& root_layer_offset, |
| 341 | float root_layer_scale); |
[email protected] | 5390786 | 2014-03-25 15:42:40 | [diff] [blame] | 342 | #if defined(OS_MACOSX) || defined(OS_ANDROID) |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 343 | void SetExternalPopupOriginAdjustmentsForEmulation( |
| 344 | ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator); |
[email protected] | 5390786 | 2014-03-25 15:42:40 | [diff] [blame] | 345 | #endif |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 346 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 347 | // RenderWidget IPC message handlers |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 348 | void OnHandleInputEvent(const blink::WebInputEvent* event, |
[email protected] | 205294b | 2014-03-18 20:48:35 | [diff] [blame] | 349 | const ui::LatencyInfo& latency_info, |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 350 | bool keyboard_shortcut); |
[email protected] | 34202de | 2013-05-06 23:36:22 | [diff] [blame] | 351 | void OnCursorVisibilityChange(bool is_visible); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 352 | void OnMouseCaptureLost(); |
| 353 | virtual void OnSetFocus(bool enable); |
[email protected] | 6de7fc48 | 2014-06-06 10:46:44 | [diff] [blame] | 354 | virtual void OnClose(); |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame] | 355 | void OnCreatingNewAck(); |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 356 | virtual void OnResize(const ViewMsg_Resize_Params& params); |
[email protected] | b5913d7 | 2012-02-07 22:26:54 | [diff] [blame] | 357 | void OnChangeResizeRect(const gfx::Rect& resizer_rect); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 358 | virtual void OnWasHidden(); |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 359 | virtual void OnWasShown(bool needs_repainting); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 360 | virtual void OnWasSwappedOut(); |
[email protected] | 8400e03 | 2010-02-26 18:50:11 | [diff] [blame] | 361 | void OnCreateVideoAck(int32 video_id); |
| 362 | void OnUpdateVideoAck(int32 video_id); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 363 | void OnRequestMoveAck(); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 364 | void OnSetInputMethodActive(bool is_active); |
[email protected] | 37a241c | 2013-12-03 03:16:17 | [diff] [blame] | 365 | void OnCandidateWindowShown(); |
| 366 | void OnCandidateWindowUpdated(); |
| 367 | void OnCandidateWindowHidden(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 368 | virtual void OnImeSetComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 369 | const base::string16& text, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 370 | const std::vector<blink::WebCompositionUnderline>& underlines, |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 371 | int selection_start, |
| 372 | int selection_end); |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 373 | virtual void OnImeConfirmComposition(const base::string16& text, |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 374 | const gfx::Range& replacement_range, |
[email protected] | 0e45bd0 | 2013-07-12 20:20:02 | [diff] [blame] | 375 | bool keep_selection); |
[email protected] | 0bc1f57 | 2013-04-17 01:46:31 | [diff] [blame] | 376 | void OnRepaint(gfx::Size size_to_paint); |
[email protected] | 79fa22e | 2013-08-23 15:18:12 | [diff] [blame] | 377 | void OnSyntheticGestureCompleted(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 378 | void OnSetTextDirection(blink::WebTextDirection direction); |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 379 | void OnGetFPS(); |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 380 | void OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
| 381 | const gfx::Rect& window_screen_rect); |
[email protected] | 105dffb4 | 2013-02-20 03:46:21 | [diff] [blame] | 382 | #if defined(OS_ANDROID) |
[email protected] | 2384b6c | 2013-02-28 23:58:51 | [diff] [blame] | 383 | void OnShowImeIfNeeded(); |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 384 | |
| 385 | // Whenever an IME event that needs an acknowledgement is sent to the browser, |
| 386 | // the number of outstanding IME events that needs acknowledgement should be |
| 387 | // incremented. All IME events will be dropped until we receive an ack from |
| 388 | // the browser. |
| 389 | void IncrementOutstandingImeEventAcks(); |
| 390 | |
| 391 | // Called by the browser process for every required IME acknowledgement. |
| 392 | void OnImeEventAck(); |
[email protected] | 105dffb4 | 2013-02-20 03:46:21 | [diff] [blame] | 393 | #endif |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 394 | |
[email protected] | 847a258 | 2013-03-09 02:29:51 | [diff] [blame] | 395 | // Notify the compositor about a change in viewport size. This should be |
| 396 | // used only with auto resize mode WebWidgets, as normal WebWidgets should |
| 397 | // go through OnResize. |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 398 | void AutoResizeCompositor(); |
| 399 | |
[email protected] | 468ac58 | 2012-11-20 00:53:19 | [diff] [blame] | 400 | virtual void SetDeviceScaleFactor(float device_scale_factor); |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame^] | 401 | virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile); |
[email protected] | 468ac58 | 2012-11-20 00:53:19 | [diff] [blame] | 402 | |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 403 | virtual void OnOrientationChange(); |
| 404 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 405 | // Override points to notify derived classes that a paint has happened. |
[email protected] | 0704ac3 | 2013-10-03 15:24:22 | [diff] [blame] | 406 | // DidInitiatePaint happens when that has completed, and subsequent rendering |
| 407 | // won't affect the painted content. DidFlushPaint happens once we've received |
| 408 | // the ACK that the screen has been updated. For a given paint operation, |
| 409 | // these overrides will always be called in the order DidInitiatePaint, |
| 410 | // DidFlushPaint. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 411 | virtual void DidInitiatePaint() {} |
| 412 | virtual void DidFlushPaint() {} |
[email protected] | a2f6bc11 | 2009-06-27 16:27:25 | [diff] [blame] | 413 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 414 | virtual GURL GetURLForGraphicsContext3D(); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 415 | |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 416 | virtual bool ForceCompositingModeEnabled(); |
| 417 | |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 418 | // Gets the scroll offset of this widget, if this widget has a notion of |
| 419 | // scroll offset. |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 420 | virtual gfx::Vector2d GetScrollOffset(); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 421 | |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 422 | // Sets the "hidden" state of this widget. All accesses to is_hidden_ should |
| 423 | // use this method so that we can properly inform the RenderThread of our |
| 424 | // state. |
| 425 | void SetHidden(bool hidden); |
| 426 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 427 | void WillToggleFullscreen(); |
| 428 | void DidToggleFullscreen(); |
| 429 | |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 430 | bool next_paint_is_resize_ack() const; |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 431 | void set_next_paint_is_resize_ack(); |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 432 | void set_next_paint_is_repaint_ack(); |
[email protected] | ec7dc11 | 2008-08-06 05:30:12 | [diff] [blame] | 433 | |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 434 | // Override point to obtain that the current input method state and caret |
| 435 | // position. |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 436 | virtual ui::TextInputType GetTextInputType(); |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 437 | virtual ui::TextInputType WebKitToUiTextInputType( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 438 | blink::WebTextInputType type); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 439 | |
[email protected] | f9db7d2d | 2014-04-11 16:07:11 | [diff] [blame] | 440 | #if defined(OS_MACOSX) || defined(USE_AURA) |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 441 | // Override point to obtain that the current composition character bounds. |
| 442 | // In the case of surrogate pairs, the character is treated as two characters: |
| 443 | // the bounds for first character is actual one, and the bounds for second |
| 444 | // character is zero width rectangle. |
| 445 | virtual void GetCompositionCharacterBounds( |
| 446 | std::vector<gfx::Rect>* character_bounds); |
| 447 | |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 448 | // Returns the range of the text that is being composed or the selection if |
| 449 | // the composition does not exist. |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 450 | virtual void GetCompositionRange(gfx::Range* range); |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 451 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 452 | // Returns true if the composition range or composition character bounds |
| 453 | // should be sent to the browser process. |
| 454 | bool ShouldUpdateCompositionInfo( |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 455 | const gfx::Range& range, |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 456 | const std::vector<gfx::Rect>& bounds); |
[email protected] | 501ea13d | 2013-07-09 17:03:29 | [diff] [blame] | 457 | #endif |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 458 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 459 | // Override point to obtain that the current input method state about |
| 460 | // composition text. |
| 461 | virtual bool CanComposeInline(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 462 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 463 | // Tells the renderer it does not have focus. Used to prevent us from getting |
| 464 | // the focus on our own when the browser did not focus us. |
| 465 | void ClearFocus(); |
| 466 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 467 | // Set the pending window rect. |
| 468 | // Because the real render_widget is hosted in another process, there is |
| 469 | // a time period where we may have set a new window rect which has not yet |
| 470 | // been processed by the browser. So we maintain a pending window rect |
| 471 | // size. If JS code sets the WindowRect, and then immediately calls |
| 472 | // GetWindowRect() we'll use this pending window rect as the size. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 473 | void SetPendingWindowRect(const blink::WebRect& r); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 474 | |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 475 | // Called by OnHandleInputEvent() to notify subclasses that a key event was |
| 476 | // just handled. |
| 477 | virtual void DidHandleKeyEvent() {} |
| 478 | |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 479 | // Called by OnHandleInputEvent() to notify subclasses that a mouse event is |
| 480 | // about to be handled. |
| 481 | // Returns true if no further handling is needed. In that case, the event |
| 482 | // won't be sent to WebKit or trigger DidHandleMouseEvent(). |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 483 | virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event); |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 484 | |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 485 | // Called by OnHandleInputEvent() to notify subclasses that a gesture event is |
| 486 | // about to be handled. |
| 487 | // Returns true if no further handling is needed. In that case, the event |
| 488 | // won't be sent to WebKit. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 489 | virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event); |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 490 | |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 491 | // Called by OnHandleInputEvent() to notify subclasses that a mouse event was |
| 492 | // just handled. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 493 | virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {} |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 494 | |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 495 | // Called by OnHandleInputEvent() to notify subclasses that a touch event was |
| 496 | // just handled. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 497 | virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {} |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 498 | |
[email protected] | 3d5c243b | 2012-11-30 00:26:01 | [diff] [blame] | 499 | // Check whether the WebWidget has any touch event handlers registered |
| 500 | // at the given point. |
| 501 | virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const; |
| 502 | |
[email protected] | ce6689f | 2013-03-29 12:52:55 | [diff] [blame] | 503 | // Check whether the WebWidget has any touch event handlers registered. |
| 504 | virtual void hasTouchEventHandlers(bool has_handlers); |
| 505 | |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 506 | // Tell the browser about the actions permitted for a new touch point. |
| 507 | virtual void setTouchAction(blink::WebTouchAction touch_action); |
| 508 | |
[email protected] | 90f2415 | 2014-04-09 12:41:36 | [diff] [blame] | 509 | // Called when value of focused text field gets dirty, e.g. value is modified |
| 510 | // by script, not by user input. |
| 511 | virtual void didUpdateTextOfFocusedElementByNonUserInput(); |
| 512 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 513 | // Creates a 3D context associated with this view. |
[email protected] | 828a393 | 2014-04-02 14:43:13 | [diff] [blame] | 514 | scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(); |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 515 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 516 | // Routing ID that allows us to communicate to the parent browser process |
| 517 | // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. |
| 518 | int32 routing_id_; |
| 519 | |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 520 | int32 surface_id_; |
| 521 | |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 522 | // We are responsible for destroying this object via its Close method. |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 523 | // May be NULL when the window is closing. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 524 | blink::WebWidget* webwidget_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 525 | |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 526 | // This is lazily constructed and must not outlive webwidget_. |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 527 | scoped_ptr<RenderWidgetCompositor> compositor_; |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 528 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 529 | // Set to the ID of the view that initiated creating this view, if any. When |
| 530 | // the view was initiated by the browser (the common case), this will be |
| 531 | // MSG_ROUTING_NONE. This is used in determining ownership when opening |
| 532 | // child tabs. See RenderWidget::createWebViewWithRequest. |
| 533 | // |
| 534 | // This ID may refer to an invalid view if that view is closed before this |
| 535 | // view is. |
| 536 | int32 opener_id_; |
| 537 | |
| 538 | // The position where this view should be initially shown. |
| 539 | gfx::Rect initial_pos_; |
| 540 | |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame] | 541 | bool init_complete_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 542 | |
| 543 | // We store the current cursor object so we can avoid spamming SetCursor |
| 544 | // messages. |
| 545 | WebCursor current_cursor_; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 546 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 547 | // The size of the RenderWidget. |
| 548 | gfx::Size size_; |
| 549 | |
[email protected] | 60d47ac | 2013-03-01 23:42:44 | [diff] [blame] | 550 | // The size of the view's backing surface in non-DPI-adjusted pixels. |
| 551 | gfx::Size physical_backing_size_; |
| 552 | |
[email protected] | d908376 | 2013-03-24 01:36:40 | [diff] [blame] | 553 | // The height of the physical backing surface that is overdrawn opaquely in |
| 554 | // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels). |
| 555 | float overdraw_bottom_height_; |
| 556 | |
[email protected] | bb6378fe | 2014-04-28 21:19:44 | [diff] [blame] | 557 | // The size of the visible viewport in DPI-adjusted pixels. |
| 558 | gfx::Size visible_viewport_size_; |
| 559 | |
[email protected] | f21c613a | 2009-02-12 14:46:17 | [diff] [blame] | 560 | // The area that must be reserved for drawing the resize corner. |
| 561 | gfx::Rect resizer_rect_; |
| 562 | |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 563 | // Flags for the next ViewHostMsg_UpdateRect message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 564 | int next_paint_flags_; |
| 565 | |
[email protected] | 847a258 | 2013-03-09 02:29:51 | [diff] [blame] | 566 | // Whether the WebWidget is in auto resize mode, which is used for example |
| 567 | // by extension popups. |
| 568 | bool auto_resize_mode_; |
| 569 | |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 570 | // True if we need to send an UpdateRect message to notify the browser about |
| 571 | // an already-completed auto-resize. |
| 572 | bool need_update_rect_for_auto_resize_; |
| 573 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 574 | // Set to true if we should ignore RenderWidget::Show calls. |
| 575 | bool did_show_; |
| 576 | |
| 577 | // Indicates that we shouldn't bother generated paint events. |
| 578 | bool is_hidden_; |
| 579 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 580 | // Indicates that we are never visible, so never produce graphical output. |
| 581 | bool never_visible_; |
| 582 | |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 583 | // Indicates that we are in fullscreen mode. |
| 584 | bool is_fullscreen_; |
| 585 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 586 | // Indicates whether we have been focused/unfocused by the browser. |
| 587 | bool has_focus_; |
| 588 | |
[email protected] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 589 | // Are we currently handling an input event? |
| 590 | bool handling_input_event_; |
| 591 | |
[email protected] | e8f775f | 2013-02-14 21:00:50 | [diff] [blame] | 592 | // Are we currently handling an ime event? |
| 593 | bool handling_ime_event_; |
| 594 | |
[email protected] | c27dd4f | 2014-05-22 18:05:19 | [diff] [blame] | 595 | // Type of the input event we are currently handling. |
| 596 | blink::WebInputEvent::Type handling_event_type_; |
| 597 | |
| 598 | // Whether we should not send ack for the current mouse move. |
| 599 | bool ignore_ack_for_mouse_move_from_debugger_; |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 600 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 601 | // True if we have requested this widget be closed. No more messages will |
| 602 | // be sent, except for a Close. |
| 603 | bool closing_; |
| 604 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 605 | // Whether this RenderWidget is currently swapped out, such that the view is |
| 606 | // being rendered by another process. If all RenderWidgets in a process are |
| 607 | // swapped out, the process can exit. |
| 608 | bool is_swapped_out_; |
| 609 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 610 | // Indicates if an input method is active in the browser process. |
| 611 | bool input_method_is_active_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 612 | |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 613 | // Stores information about the current text input. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 614 | blink::WebTextInputInfo text_input_info_; |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 615 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 616 | // Stores the current text input type of |webwidget_|. |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 617 | ui::TextInputType text_input_type_; |
| 618 | |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 619 | // Stores the current text input mode of |webwidget_|. |
| 620 | ui::TextInputMode text_input_mode_; |
| 621 | |
[email protected] | 86ba5fcb | 2013-09-04 00:36:53 | [diff] [blame] | 622 | // Stores the current type of composition text rendering of |webwidget_|. |
| 623 | bool can_compose_inline_; |
| 624 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 625 | // Stores the current selection bounds. |
[email protected] | 7c8873e | 2013-02-05 08:03:01 | [diff] [blame] | 626 | gfx::Rect selection_focus_rect_; |
| 627 | gfx::Rect selection_anchor_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 628 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 629 | // Stores the current composition character bounds. |
| 630 | std::vector<gfx::Rect> composition_character_bounds_; |
| 631 | |
| 632 | // Stores the current composition range. |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 633 | gfx::Range composition_range_; |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 634 | |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 635 | // The kind of popup this widget represents, NONE if not a popup. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 636 | blink::WebPopupType popup_type_; |
[email protected] | 0ebf387 | 2008-11-07 21:35:03 | [diff] [blame] | 637 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 638 | // Holds all the needed plugin window moves for a scroll. |
[email protected] | 29e2fb4 | 2013-07-19 01:13:47 | [diff] [blame] | 639 | typedef std::vector<WebPluginGeometry> WebPluginGeometryVector; |
[email protected] | 26865477 | 2009-08-06 23:02:04 | [diff] [blame] | 640 | WebPluginGeometryVector plugin_window_moves_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 641 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 642 | // While we are waiting for the browser to update window sizes, we track the |
| 643 | // pending size temporarily. |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 644 | int pending_window_rect_count_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 645 | blink::WebRect pending_window_rect_; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 646 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 647 | // The screen rects of the view and the window that contains it. |
| 648 | gfx::Rect view_screen_rect_; |
| 649 | gfx::Rect window_screen_rect_; |
| 650 | |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 651 | scoped_ptr<IPC::Message> pending_input_event_ack_; |
| 652 | |
[email protected] | fd84779 | 2013-10-24 17:12:35 | [diff] [blame] | 653 | // The time spent in input handlers this frame. Used to throttle input acks. |
| 654 | base::TimeDelta total_input_handling_time_this_frame_; |
| 655 | |
[email protected] | b68a0e5 | 2011-12-08 15:11:12 | [diff] [blame] | 656 | // Indicates if the next sequence of Char events should be suppressed or not. |
| 657 | bool suppress_next_char_events_; |
| 658 | |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 659 | // Properties of the screen hosting this RenderWidget instance. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 660 | blink::WebScreenInfo screen_info_; |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 661 | |
[email protected] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 662 | // The device scale factor. This value is computed from the DPI entries in |
| 663 | // |screen_info_| on some platforms, and defaults to 1 on other platforms. |
[email protected] | faec7b1 | 2012-06-19 14:42:13 | [diff] [blame] | 664 | float device_scale_factor_; |
[email protected] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 665 | |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame^] | 666 | // The device color profile on supported platforms. |
| 667 | std::vector<char> device_color_profile_; |
| 668 | |
[email protected] | 9017d785 | 2013-11-21 17:47:35 | [diff] [blame] | 669 | // State associated with synthetic gestures. Synthetic gestures are processed |
| 670 | // in-order, so a queue is sufficient to identify the correct state for a |
| 671 | // completed gesture. |
| 672 | std::queue<SyntheticGestureCompletionCallback> |
| 673 | pending_synthetic_gesture_callbacks_; |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 674 | |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 675 | // Specified whether the compositor will run in its own thread. |
| 676 | bool is_threaded_compositing_enabled_; |
| 677 | |
[email protected] | 8062ab26 | 2014-05-27 16:56:43 | [diff] [blame] | 678 | const ui::LatencyInfo* current_event_latency_info_; |
| 679 | |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 680 | uint32 next_output_surface_id_; |
| 681 | |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 682 | #if defined(OS_ANDROID) |
[email protected] | 90f2415 | 2014-04-09 12:41:36 | [diff] [blame] | 683 | // Indicates value in the focused text field is in dirty state, i.e. modified |
| 684 | // by script etc., not by user input. |
| 685 | bool text_field_is_dirty_; |
| 686 | |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 687 | // A counter for number of outstanding messages from the renderer to the |
| 688 | // browser regarding IME-type events that have not been acknowledged by the |
| 689 | // browser. If this value is not 0 IME events will be dropped. |
| 690 | int outstanding_ime_acks_; |
[email protected] | a4f0d88 | 2014-05-01 23:48:10 | [diff] [blame] | 691 | |
| 692 | // The background color of the document body element. This is used as the |
| 693 | // default background color for filling the screen areas for which we don't |
| 694 | // have the actual content. |
| 695 | SkColor body_background_color_; |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 696 | #endif |
| 697 | |
[email protected] | 70b73b2c | 2014-05-01 04:31:39 | [diff] [blame] | 698 | #if defined(OS_MACOSX) |
| 699 | // These store the "has scrollbars" state last sent to the browser. |
| 700 | bool cached_has_main_frame_horizontal_scrollbar_; |
| 701 | bool cached_has_main_frame_vertical_scrollbar_; |
| 702 | #endif // defined(OS_MACOSX) |
| 703 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 704 | scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_; |
| 705 | |
| 706 | // Popups may be displaced when screen metrics emulation is enabled. |
| 707 | // These values are used to properly adjust popup position. |
| 708 | gfx::Point popup_view_origin_for_emulation_; |
| 709 | gfx::Point popup_screen_origin_for_emulation_; |
| 710 | float popup_origin_scale_for_emulation_; |
| 711 | |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 712 | scoped_ptr<ResizingModeSelector> resizing_mode_selector_; |
| 713 | |
[email protected] | a017938b | 2014-05-27 21:17:17 | [diff] [blame] | 714 | // Lists of swapped out RenderFrames that need to be notified |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 715 | // of compositing-related events (e.g. DidCommitCompositorFrame). |
| 716 | ObserverList<RenderFrameImpl> swapped_out_frames_; |
[email protected] | a017938b | 2014-05-27 21:17:17 | [diff] [blame] | 717 | #if defined(VIDEO_HOLE) |
| 718 | ObserverList<RenderFrameImpl> video_hole_frames_; |
| 719 | #endif // defined(VIDEO_HOLE) |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 720 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 721 | // A list of RenderFrames associated with this RenderWidget. Notifications |
| 722 | // are sent to each frame in the list for events such as changing |
| 723 | // visibility state for example. |
| 724 | ObserverList<RenderFrameImpl> render_frames_; |
| 725 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 726 | ui::MenuSourceType context_menu_source_type_; |
| 727 | gfx::Point touch_editing_context_menu_location_; |
| 728 | |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 729 | DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 730 | }; |
| 731 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 732 | } // namespace content |
| 733 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 734 | #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |