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