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