Revert 291214 "Fixes three crashes" in an attempt to find the cause of Athena related...
[chromium-blink-merge.git] / content / renderer / render_widget.h
blobf299a1910f89498a539e38d8d2318bfb230e73dc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6 #define CONTENT_RENDERER_RENDER_WIDGET_H_
8 #include <deque>
9 #include <map>
11 #include "base/auto_reset.h"
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/observer_list.h"
18 #include "base/time/time.h"
19 #include "base/timer/timer.h"
20 #include "cc/debug/rendering_stats_instrumentation.h"
21 #include "content/common/content_export.h"
22 #include "content/common/cursors/webcursor.h"
23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
24 #include "content/common/input/synthetic_gesture_params.h"
25 #include "content/renderer/message_delivery_policy.h"
26 #include "ipc/ipc_listener.h"
27 #include "ipc/ipc_sender.h"
28 #include "third_party/WebKit/public/platform/WebRect.h"
29 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
30 #include "third_party/WebKit/public/web/WebInputEvent.h"
31 #include "third_party/WebKit/public/web/WebPopupType.h"
32 #include "third_party/WebKit/public/web/WebTextDirection.h"
33 #include "third_party/WebKit/public/web/WebTextInputInfo.h"
34 #include "third_party/WebKit/public/web/WebTouchAction.h"
35 #include "third_party/WebKit/public/web/WebWidget.h"
36 #include "third_party/WebKit/public/web/WebWidgetClient.h"
37 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "ui/base/ime/text_input_mode.h"
39 #include "ui/base/ime/text_input_type.h"
40 #include "ui/base/ui_base_types.h"
41 #include "ui/gfx/native_widget_types.h"
42 #include "ui/gfx/range/range.h"
43 #include "ui/gfx/rect.h"
44 #include "ui/gfx/vector2d.h"
45 #include "ui/gfx/vector2d_f.h"
46 #include "ui/surface/transport_dib.h"
48 struct ViewHostMsg_UpdateRect_Params;
49 struct ViewMsg_Resize_Params;
50 class ViewHostMsg_UpdateRect;
52 namespace IPC {
53 class SyncMessage;
54 class SyncMessageFilter;
57 namespace blink {
58 struct WebDeviceEmulationParams;
59 class WebGestureEvent;
60 class WebKeyboardEvent;
61 class WebMouseEvent;
62 class WebTouchEvent;
65 namespace cc {
66 class OutputSurface;
67 class SwapPromise;
70 namespace gfx {
71 class Range;
74 namespace content {
75 class ExternalPopupMenu;
76 class FrameSwapMessageQueue;
77 class PepperPluginInstanceImpl;
78 class RenderFrameImpl;
79 class RenderFrameProxy;
80 class RenderWidgetCompositor;
81 class RenderWidgetTest;
82 class ResizingModeSelector;
83 struct ContextMenuParams;
84 struct WebPluginGeometry;
86 // RenderWidget provides a communication bridge between a WebWidget and
87 // a RenderWidgetHost, the latter of which lives in a different process.
88 class CONTENT_EXPORT RenderWidget
89 : public IPC::Listener,
90 public IPC::Sender,
91 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
92 public base::RefCounted<RenderWidget> {
93 public:
94 // Creates a new RenderWidget. The opener_id is the routing ID of the
95 // RenderView that this widget lives inside.
96 static RenderWidget* Create(int32 opener_id,
97 blink::WebPopupType popup_type,
98 const blink::WebScreenInfo& screen_info);
100 // Creates a WebWidget based on the popup type.
101 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
103 int32 routing_id() const { return routing_id_; }
104 int32 surface_id() const { return surface_id_; }
105 blink::WebWidget* webwidget() const { return webwidget_; }
106 gfx::Size size() const { return size_; }
107 bool has_focus() const { return has_focus_; }
108 bool is_fullscreen() const { return is_fullscreen_; }
109 bool is_hidden() const { return is_hidden_; }
110 bool handling_input_event() const { return handling_input_event_; }
111 // Temporary for debugging purposes...
112 bool closing() const { return closing_; }
113 bool is_swapped_out() { return is_swapped_out_; }
114 ui::MenuSourceType context_menu_source_type() {
115 return context_menu_source_type_;
117 bool has_host_context_menu_location() {
118 return has_host_context_menu_location_;
120 gfx::Point host_context_menu_location() {
121 return host_context_menu_location_;
124 // Functions to track out-of-process frames for special notifications.
125 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
126 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
128 // Functions to track all RenderFrame objects associated with this
129 // RenderWidget.
130 void RegisterRenderFrame(RenderFrameImpl* frame);
131 void UnregisterRenderFrame(RenderFrameImpl* frame);
133 #if defined(VIDEO_HOLE)
134 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
135 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
136 #endif // defined(VIDEO_HOLE)
138 // IPC::Listener
139 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
141 // IPC::Sender
142 virtual bool Send(IPC::Message* msg) OVERRIDE;
144 // blink::WebWidgetClient
145 virtual void suppressCompositorScheduling(bool enable);
146 virtual void willBeginCompositorFrame();
147 virtual void didAutoResize(const blink::WebSize& new_size);
148 virtual void initializeLayerTreeView();
149 virtual blink::WebLayerTreeView* layerTreeView();
150 virtual void didBecomeReadyForAdditionalInput();
151 virtual void didCommitAndDrawCompositorFrame();
152 virtual void didCompleteSwapBuffers();
153 virtual void scheduleComposite();
154 virtual void didFocus();
155 virtual void didBlur();
156 virtual void didChangeCursor(const blink::WebCursorInfo&);
157 virtual void closeWidgetSoon();
158 virtual void show(blink::WebNavigationPolicy);
159 virtual void runModal() {}
160 virtual blink::WebRect windowRect();
161 virtual void setToolTipText(const blink::WebString& text,
162 blink::WebTextDirection hint);
163 virtual void setWindowRect(const blink::WebRect&);
164 virtual blink::WebRect windowResizerRect();
165 virtual blink::WebRect rootWindowRect();
166 virtual blink::WebScreenInfo screenInfo();
167 virtual float deviceScaleFactor();
168 virtual void resetInputMethod();
169 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
170 bool event_cancelled);
171 virtual void showImeIfNeeded();
173 // Begins the compositor's scheduler to start producing frames.
174 void StartCompositor();
176 // Called when a plugin is moved. These events are queued up and sent with
177 // the next paint or scroll message to the host.
178 void SchedulePluginMove(const WebPluginGeometry& move);
180 // Called when a plugin window has been destroyed, to make sure the currently
181 // pending moves don't try to reference it.
182 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
184 RenderWidgetCompositor* compositor() const;
186 const ui::LatencyInfo* current_event_latency_info() const {
187 return current_event_latency_info_;
190 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
192 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
193 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
195 // Send a synthetic gesture to the browser to be queued to the synthetic
196 // gesture controller.
197 void QueueSyntheticGesture(
198 scoped_ptr<SyntheticGestureParams> gesture_params,
199 const SyntheticGestureCompletionCallback& callback);
201 // Close the underlying WebWidget.
202 virtual void Close();
204 // Notifies about a compositor frame commit operation having finished.
205 virtual void DidCommitCompositorFrame();
207 // Deliveres |message| together with compositor state change updates. The
208 // exact behavior depends on |policy|.
209 // This mechanism is not a drop-in replacement for IPC: messages sent this way
210 // will not be automatically available to BrowserMessageFilter, for example.
211 // FIFO ordering is preserved between messages enqueued with the same
212 // |policy|, the ordering between messages enqueued for different policies is
213 // undefined.
215 // |msg| message to send, ownership of |msg| is transferred.
216 // |policy| see the comment on MessageDeliveryPolicy.
217 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
219 // Handle common setup/teardown for handling IME events.
220 void StartHandlingImeEvent();
221 void FinishHandlingImeEvent();
223 // Returns whether we currently should handle an IME event.
224 bool ShouldHandleImeEvent();
226 virtual void InstrumentWillBeginFrame(int frame_id) {}
227 virtual void InstrumentDidBeginFrame() {}
228 virtual void InstrumentDidCancelFrame() {}
229 virtual void InstrumentWillComposite() {}
231 // When paused in debugger, we send ack for mouse event early. This ensures
232 // that we continue receiving mouse moves and pass them to debugger. Returns
233 // whether we are paused in mouse move event and have sent the ack.
234 bool SendAckForMouseMoveFromDebugger();
236 // When resumed from pause in debugger while handling mouse move,
237 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
238 void IgnoreAckForMouseMoveFromDebugger();
240 // ScreenMetricsEmulator class manages screen emulation inside a render
241 // widget. This includes resizing, placing view on the screen at desired
242 // position, changing device scale factor, and scaling down the whole
243 // widget if required to fit into the browser window.
244 class ScreenMetricsEmulator;
246 // Emulates screen and widget metrics. Supplied values override everything
247 // coming from host.
248 void EnableScreenMetricsEmulation(
249 const blink::WebDeviceEmulationParams& params);
250 void DisableScreenMetricsEmulation();
251 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
252 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
254 void ScheduleCompositeWithForcedRedraw();
256 // Called by the compositor in single-threaded mode when a swap is posted,
257 // completes or is aborted.
258 void OnSwapBuffersPosted();
259 void OnSwapBuffersComplete();
260 void OnSwapBuffersAborted();
262 // Checks if the selection bounds have been changed. If they are changed,
263 // the new value will be sent to the browser process.
264 void UpdateSelectionBounds();
266 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
268 void OnShowHostContextMenu(ContextMenuParams* params);
270 enum ShowIme {
271 SHOW_IME_IF_NEEDED,
272 NO_SHOW_IME,
275 enum ChangeSource {
276 FROM_NON_IME,
277 FROM_IME,
280 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
281 // be displayed, e.g. after a tap on an input field on mobile.
282 // |change_source| should be FROM_NON_IME when the renderer has to wait for
283 // the browser to acknowledge the change before the renderer handles any more
284 // IME events. This is when the text change did not originate from the IME in
285 // the browser side, such as changes by JavaScript or autofill.
286 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
288 #if defined(OS_MACOSX) || defined(USE_AURA)
289 // Checks if the composition range or composition character bounds have been
290 // changed. If they are changed, the new value will be sent to the browser
291 // process.
292 void UpdateCompositionInfo(bool should_update_range);
293 #endif
295 #if defined(OS_ANDROID)
296 void DidChangeBodyBackgroundColor(SkColor bg_color);
297 #endif
299 protected:
300 // Friend RefCounted so that the dtor can be non-public. Using this class
301 // without ref-counting is an error.
302 friend class base::RefCounted<RenderWidget>;
303 // For unit tests.
304 friend class RenderWidgetTest;
306 enum ResizeAck {
307 SEND_RESIZE_ACK,
308 NO_RESIZE_ACK,
311 RenderWidget(blink::WebPopupType popup_type,
312 const blink::WebScreenInfo& screen_info,
313 bool swapped_out,
314 bool hidden,
315 bool never_visible);
317 virtual ~RenderWidget();
319 // Initializes this view with the given opener. CompleteInit must be called
320 // later.
321 bool Init(int32 opener_id);
323 // Called by Init and subclasses to perform initialization.
324 bool DoInit(int32 opener_id,
325 blink::WebWidget* web_widget,
326 IPC::SyncMessage* create_widget_message);
328 // Finishes creation of a pending view started with Init.
329 void CompleteInit();
331 // Sets whether this RenderWidget has been swapped out to be displayed by
332 // a RenderWidget in a different process. If so, no new IPC messages will be
333 // sent (only ACKs) and the process is free to exit when there are no other
334 // active RenderWidgets.
335 void SetSwappedOut(bool is_swapped_out);
337 // Allows the process to exit once the unload handler has finished, if there
338 // are no other active RenderWidgets.
339 void WasSwappedOut();
341 void FlushPendingInputEventAck();
342 void DoDeferredClose();
343 void DoDeferredSetWindowRect(const blink::WebRect& pos);
345 // Resizes the render widget.
346 void Resize(const gfx::Size& new_size,
347 const gfx::Size& physical_backing_size,
348 float top_controls_layout_height,
349 const gfx::Size& visible_viewport_size,
350 const gfx::Rect& resizer_rect,
351 bool is_fullscreen,
352 ResizeAck resize_ack);
353 // Used to force the size of a window when running layout tests.
354 void ResizeSynchronously(const gfx::Rect& new_position);
355 virtual void SetScreenMetricsEmulationParameters(
356 float device_scale_factor,
357 const gfx::Point& root_layer_offset,
358 float root_layer_scale);
359 #if defined(OS_MACOSX) || defined(OS_ANDROID)
360 void SetExternalPopupOriginAdjustmentsForEmulation(
361 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
362 #endif
364 // RenderWidget IPC message handlers
365 void OnHandleInputEvent(const blink::WebInputEvent* event,
366 const ui::LatencyInfo& latency_info,
367 bool keyboard_shortcut);
368 void OnCursorVisibilityChange(bool is_visible);
369 void OnMouseCaptureLost();
370 virtual void OnSetFocus(bool enable);
371 virtual void OnClose();
372 void OnCreatingNewAck();
373 virtual void OnResize(const ViewMsg_Resize_Params& params);
374 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
375 virtual void OnWasHidden();
376 virtual void OnWasShown(bool needs_repainting,
377 const ui::LatencyInfo& latency_info);
378 void OnCreateVideoAck(int32 video_id);
379 void OnUpdateVideoAck(int32 video_id);
380 void OnRequestMoveAck();
381 void OnSetInputMethodActive(bool is_active);
382 void OnCandidateWindowShown();
383 void OnCandidateWindowUpdated();
384 void OnCandidateWindowHidden();
385 virtual void OnImeSetComposition(
386 const base::string16& text,
387 const std::vector<blink::WebCompositionUnderline>& underlines,
388 int selection_start,
389 int selection_end);
390 virtual void OnImeConfirmComposition(const base::string16& text,
391 const gfx::Range& replacement_range,
392 bool keep_selection);
393 void OnRepaint(gfx::Size size_to_paint);
394 void OnSyntheticGestureCompleted();
395 void OnSetTextDirection(blink::WebTextDirection direction);
396 void OnGetFPS();
397 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
398 const gfx::Rect& window_screen_rect);
399 void OnShowImeIfNeeded();
401 #if defined(OS_ANDROID)
402 // Whenever an IME event that needs an acknowledgement is sent to the browser,
403 // the number of outstanding IME events that needs acknowledgement should be
404 // incremented. All IME events will be dropped until we receive an ack from
405 // the browser.
406 void IncrementOutstandingImeEventAcks();
408 // Called by the browser process for every required IME acknowledgement.
409 void OnImeEventAck();
410 #endif
412 // Notify the compositor about a change in viewport size. This should be
413 // used only with auto resize mode WebWidgets, as normal WebWidgets should
414 // go through OnResize.
415 void AutoResizeCompositor();
417 virtual void SetDeviceScaleFactor(float device_scale_factor);
418 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
420 virtual void OnOrientationChange();
422 // Override points to notify derived classes that a paint has happened.
423 // DidInitiatePaint happens when that has completed, and subsequent rendering
424 // won't affect the painted content. DidFlushPaint happens once we've received
425 // the ACK that the screen has been updated. For a given paint operation,
426 // these overrides will always be called in the order DidInitiatePaint,
427 // DidFlushPaint.
428 virtual void DidInitiatePaint() {}
429 virtual void DidFlushPaint() {}
431 virtual GURL GetURLForGraphicsContext3D();
433 // Gets the scroll offset of this widget, if this widget has a notion of
434 // scroll offset.
435 virtual gfx::Vector2d GetScrollOffset();
437 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
438 // use this method so that we can properly inform the RenderThread of our
439 // state.
440 void SetHidden(bool hidden);
442 void WillToggleFullscreen();
443 void DidToggleFullscreen();
445 bool next_paint_is_resize_ack() const;
446 void set_next_paint_is_resize_ack();
447 void set_next_paint_is_repaint_ack();
449 // QueueMessage implementation extracted into a static method for easy
450 // testing.
451 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
452 IPC::Message* msg,
453 MessageDeliveryPolicy policy,
454 FrameSwapMessageQueue* frame_swap_message_queue,
455 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
456 bool commit_requested,
457 int source_frame_number);
459 // Override point to obtain that the current input method state and caret
460 // position.
461 virtual ui::TextInputType GetTextInputType();
462 virtual ui::TextInputType WebKitToUiTextInputType(
463 blink::WebTextInputType type);
465 #if defined(OS_MACOSX) || defined(USE_AURA)
466 // Override point to obtain that the current composition character bounds.
467 // In the case of surrogate pairs, the character is treated as two characters:
468 // the bounds for first character is actual one, and the bounds for second
469 // character is zero width rectangle.
470 virtual void GetCompositionCharacterBounds(
471 std::vector<gfx::Rect>* character_bounds);
473 // Returns the range of the text that is being composed or the selection if
474 // the composition does not exist.
475 virtual void GetCompositionRange(gfx::Range* range);
477 // Returns true if the composition range or composition character bounds
478 // should be sent to the browser process.
479 bool ShouldUpdateCompositionInfo(
480 const gfx::Range& range,
481 const std::vector<gfx::Rect>& bounds);
482 #endif
484 // Override point to obtain that the current input method state about
485 // composition text.
486 virtual bool CanComposeInline();
488 // Tells the renderer it does not have focus. Used to prevent us from getting
489 // the focus on our own when the browser did not focus us.
490 void ClearFocus();
492 // Set the pending window rect.
493 // Because the real render_widget is hosted in another process, there is
494 // a time period where we may have set a new window rect which has not yet
495 // been processed by the browser. So we maintain a pending window rect
496 // size. If JS code sets the WindowRect, and then immediately calls
497 // GetWindowRect() we'll use this pending window rect as the size.
498 void SetPendingWindowRect(const blink::WebRect& r);
500 // Called by OnHandleInputEvent() to notify subclasses that a key event was
501 // just handled.
502 virtual void DidHandleKeyEvent() {}
504 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
505 // about to be handled.
506 // Returns true if no further handling is needed. In that case, the event
507 // won't be sent to WebKit or trigger DidHandleMouseEvent().
508 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
510 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
511 // about to be handled.
512 // Returns true if no further handling is needed. In that case, the event
513 // won't be sent to WebKit.
514 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
516 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
517 // just handled.
518 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
520 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
521 // just handled.
522 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
524 // Check whether the WebWidget has any touch event handlers registered
525 // at the given point.
526 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
528 // Check whether the WebWidget has any touch event handlers registered.
529 virtual void hasTouchEventHandlers(bool has_handlers);
531 // Tell the browser about the actions permitted for a new touch point.
532 virtual void setTouchAction(blink::WebTouchAction touch_action);
534 // Called when value of focused text field gets dirty, e.g. value is modified
535 // by script, not by user input.
536 virtual void didUpdateTextOfFocusedElementByNonUserInput();
538 // Creates a 3D context associated with this view.
539 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
541 // Routing ID that allows us to communicate to the parent browser process
542 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
543 int32 routing_id_;
545 int32 surface_id_;
547 // We are responsible for destroying this object via its Close method.
548 // May be NULL when the window is closing.
549 blink::WebWidget* webwidget_;
551 // This is lazily constructed and must not outlive webwidget_.
552 scoped_ptr<RenderWidgetCompositor> compositor_;
554 // Set to the ID of the view that initiated creating this view, if any. When
555 // the view was initiated by the browser (the common case), this will be
556 // MSG_ROUTING_NONE. This is used in determining ownership when opening
557 // child tabs. See RenderWidget::createWebViewWithRequest.
559 // This ID may refer to an invalid view if that view is closed before this
560 // view is.
561 int32 opener_id_;
563 // The position where this view should be initially shown.
564 gfx::Rect initial_pos_;
566 bool init_complete_;
568 // We store the current cursor object so we can avoid spamming SetCursor
569 // messages.
570 WebCursor current_cursor_;
572 // The size of the RenderWidget.
573 gfx::Size size_;
575 // The size of the view's backing surface in non-DPI-adjusted pixels.
576 gfx::Size physical_backing_size_;
578 // The amount that the viewport size given to Blink was shrunk by the URL-bar
579 // (always 0 on platforms where URL-bar hiding isn't supported).
580 float top_controls_layout_height_;
582 // The size of the visible viewport in DPI-adjusted pixels.
583 gfx::Size visible_viewport_size_;
585 // The area that must be reserved for drawing the resize corner.
586 gfx::Rect resizer_rect_;
588 // Flags for the next ViewHostMsg_UpdateRect message.
589 int next_paint_flags_;
591 // Whether the WebWidget is in auto resize mode, which is used for example
592 // by extension popups.
593 bool auto_resize_mode_;
595 // True if we need to send an UpdateRect message to notify the browser about
596 // an already-completed auto-resize.
597 bool need_update_rect_for_auto_resize_;
599 // Set to true if we should ignore RenderWidget::Show calls.
600 bool did_show_;
602 // Indicates that we shouldn't bother generated paint events.
603 bool is_hidden_;
605 // Indicates that we are never visible, so never produce graphical output.
606 bool never_visible_;
608 // Indicates that we are in fullscreen mode.
609 bool is_fullscreen_;
611 // Indicates whether we have been focused/unfocused by the browser.
612 bool has_focus_;
614 // Are we currently handling an input event?
615 bool handling_input_event_;
617 // Are we currently handling an ime event?
618 bool handling_ime_event_;
620 // Type of the input event we are currently handling.
621 blink::WebInputEvent::Type handling_event_type_;
623 // Whether we should not send ack for the current mouse move.
624 bool ignore_ack_for_mouse_move_from_debugger_;
626 // True if we have requested this widget be closed. No more messages will
627 // be sent, except for a Close.
628 bool closing_;
630 // Whether this RenderWidget is currently swapped out, such that the view is
631 // being rendered by another process. If all RenderWidgets in a process are
632 // swapped out, the process can exit.
633 bool is_swapped_out_;
635 // Indicates if an input method is active in the browser process.
636 bool input_method_is_active_;
638 // Stores information about the current text input.
639 blink::WebTextInputInfo text_input_info_;
641 // Stores the current text input type of |webwidget_|.
642 ui::TextInputType text_input_type_;
644 // Stores the current text input mode of |webwidget_|.
645 ui::TextInputMode text_input_mode_;
647 // Stores the current type of composition text rendering of |webwidget_|.
648 bool can_compose_inline_;
650 // Stores the current selection bounds.
651 gfx::Rect selection_focus_rect_;
652 gfx::Rect selection_anchor_rect_;
654 // Stores the current composition character bounds.
655 std::vector<gfx::Rect> composition_character_bounds_;
657 // Stores the current composition range.
658 gfx::Range composition_range_;
660 // The kind of popup this widget represents, NONE if not a popup.
661 blink::WebPopupType popup_type_;
663 // Holds all the needed plugin window moves for a scroll.
664 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
665 WebPluginGeometryVector plugin_window_moves_;
667 // While we are waiting for the browser to update window sizes, we track the
668 // pending size temporarily.
669 int pending_window_rect_count_;
670 blink::WebRect pending_window_rect_;
672 // The screen rects of the view and the window that contains it.
673 gfx::Rect view_screen_rect_;
674 gfx::Rect window_screen_rect_;
676 scoped_ptr<IPC::Message> pending_input_event_ack_;
678 // The time spent in input handlers this frame. Used to throttle input acks.
679 base::TimeDelta total_input_handling_time_this_frame_;
681 // Indicates if the next sequence of Char events should be suppressed or not.
682 bool suppress_next_char_events_;
684 // Properties of the screen hosting this RenderWidget instance.
685 blink::WebScreenInfo screen_info_;
687 // The device scale factor. This value is computed from the DPI entries in
688 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
689 float device_scale_factor_;
691 // The device color profile on supported platforms.
692 std::vector<char> device_color_profile_;
694 // State associated with synthetic gestures. Synthetic gestures are processed
695 // in-order, so a queue is sufficient to identify the correct state for a
696 // completed gesture.
697 std::queue<SyntheticGestureCompletionCallback>
698 pending_synthetic_gesture_callbacks_;
700 const ui::LatencyInfo* current_event_latency_info_;
702 uint32 next_output_surface_id_;
704 #if defined(OS_ANDROID)
705 // Indicates value in the focused text field is in dirty state, i.e. modified
706 // by script etc., not by user input.
707 bool text_field_is_dirty_;
709 // A counter for number of outstanding messages from the renderer to the
710 // browser regarding IME-type events that have not been acknowledged by the
711 // browser. If this value is not 0 IME events will be dropped.
712 int outstanding_ime_acks_;
714 // The background color of the document body element. This is used as the
715 // default background color for filling the screen areas for which we don't
716 // have the actual content.
717 SkColor body_background_color_;
718 #endif
720 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
722 // Popups may be displaced when screen metrics emulation is enabled.
723 // These values are used to properly adjust popup position.
724 gfx::Point popup_view_origin_for_emulation_;
725 gfx::Point popup_screen_origin_for_emulation_;
726 float popup_origin_scale_for_emulation_;
728 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
729 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
731 // Lists of RenderFrameProxy objects that need to be notified of
732 // compositing-related events (e.g. DidCommitCompositorFrame).
733 ObserverList<RenderFrameProxy> render_frame_proxies_;
734 #if defined(VIDEO_HOLE)
735 ObserverList<RenderFrameImpl> video_hole_frames_;
736 #endif // defined(VIDEO_HOLE)
738 // A list of RenderFrames associated with this RenderWidget. Notifications
739 // are sent to each frame in the list for events such as changing
740 // visibility state for example.
741 ObserverList<RenderFrameImpl> render_frames_;
743 ui::MenuSourceType context_menu_source_type_;
744 bool has_host_context_menu_location_;
745 gfx::Point host_context_menu_location_;
747 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
750 } // namespace content
752 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_