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