Assume the foo_test_run depends on everything needed to run the test.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob2627a3da6ef2fdd6eaa2cd457a715ad4f3c00abf
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/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/time/time.h"
17 #include "base/timer/timer.h"
18 #include "cc/debug/rendering_stats_instrumentation.h"
19 #include "content/common/content_export.h"
20 #include "content/common/cursors/webcursor.h"
21 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
22 #include "content/common/input/synthetic_gesture_params.h"
23 #include "ipc/ipc_listener.h"
24 #include "ipc/ipc_sender.h"
25 #include "third_party/WebKit/public/platform/WebRect.h"
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"
30 #include "third_party/WebKit/public/web/WebTouchAction.h"
31 #include "third_party/WebKit/public/web/WebWidget.h"
32 #include "third_party/WebKit/public/web/WebWidgetClient.h"
33 #include "third_party/skia/include/core/SkBitmap.h"
34 #include "ui/base/ime/text_input_mode.h"
35 #include "ui/base/ime/text_input_type.h"
36 #include "ui/base/ui_base_types.h"
37 #include "ui/gfx/native_widget_types.h"
38 #include "ui/gfx/range/range.h"
39 #include "ui/gfx/rect.h"
40 #include "ui/gfx/vector2d.h"
41 #include "ui/gfx/vector2d_f.h"
42 #include "ui/surface/transport_dib.h"
44 struct ViewHostMsg_UpdateRect_Params;
45 struct ViewMsg_Resize_Params;
46 class ViewHostMsg_UpdateRect;
48 namespace IPC {
49 class SyncMessage;
52 namespace blink {
53 struct WebDeviceEmulationParams;
54 class WebGestureEvent;
55 class WebInputEvent;
56 class WebKeyboardEvent;
57 class WebMouseEvent;
58 class WebTouchEvent;
61 namespace cc { class OutputSurface; }
63 namespace gfx {
64 class Range;
67 namespace content {
68 class ExternalPopupMenu;
69 class PepperPluginInstanceImpl;
70 class RenderFrameImpl;
71 class RenderWidgetCompositor;
72 class RenderWidgetTest;
73 class ResizingModeSelector;
74 struct ContextMenuParams;
75 struct WebPluginGeometry;
77 // RenderWidget provides a communication bridge between a WebWidget and
78 // a RenderWidgetHost, the latter of which lives in a different process.
79 class CONTENT_EXPORT RenderWidget
80 : public IPC::Listener,
81 public IPC::Sender,
82 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
83 public base::RefCounted<RenderWidget> {
84 public:
85 // Creates a new RenderWidget. The opener_id is the routing ID of the
86 // RenderView that this widget lives inside.
87 static RenderWidget* Create(int32 opener_id,
88 blink::WebPopupType popup_type,
89 const blink::WebScreenInfo& screen_info);
91 // Creates a WebWidget based on the popup type.
92 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
94 int32 routing_id() const { return routing_id_; }
95 int32 surface_id() const { return surface_id_; }
96 blink::WebWidget* webwidget() const { return webwidget_; }
97 gfx::Size size() const { return size_; }
98 bool has_focus() const { return has_focus_; }
99 bool is_fullscreen() const { return is_fullscreen_; }
100 bool is_hidden() const { return is_hidden_; }
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_;
111 // Functions to track out-of-process frames for special notifications.
112 void RegisterSwappedOutChildFrame(RenderFrameImpl* frame);
113 void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame);
115 // IPC::Listener
116 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
118 // IPC::Sender
119 virtual bool Send(IPC::Message* msg) OVERRIDE;
121 // blink::WebWidgetClient
122 virtual void suppressCompositorScheduling(bool enable);
123 virtual void willBeginCompositorFrame();
124 virtual void didInvalidateRect(const blink::WebRect&);
125 virtual void didScrollRect(int dx, int dy,
126 const blink::WebRect& clipRect);
127 virtual void didAutoResize(const blink::WebSize& new_size);
128 virtual void didActivateCompositor() OVERRIDE;
129 virtual void didDeactivateCompositor();
130 virtual void initializeLayerTreeView();
131 virtual blink::WebLayerTreeView* layerTreeView();
132 virtual void didBecomeReadyForAdditionalInput();
133 virtual void didCommitAndDrawCompositorFrame();
134 virtual void didCompleteSwapBuffers();
135 virtual void scheduleComposite();
136 virtual void scheduleAnimation();
137 virtual void didFocus();
138 virtual void didBlur();
139 virtual void didChangeCursor(const blink::WebCursorInfo&);
140 virtual void closeWidgetSoon();
141 virtual void show(blink::WebNavigationPolicy);
142 virtual void runModal() {}
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();
150 virtual float deviceScaleFactor();
151 virtual void resetInputMethod();
152 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
153 bool event_cancelled);
155 // Begins the compositor's scheduler to start producing frames.
156 void StartCompositor();
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.
160 void SchedulePluginMove(const WebPluginGeometry& move);
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);
166 RenderWidgetCompositor* compositor() const;
168 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
170 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
171 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
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);
179 // Close the underlying WebWidget.
180 virtual void Close();
182 // Notifies about a compositor frame commit operation having finished.
183 virtual void DidCommitCompositorFrame();
185 // Handle common setup/teardown for handling IME events.
186 void StartHandlingImeEvent();
187 void FinishHandlingImeEvent();
189 // Returns whether we currently should handle an IME event.
190 bool ShouldHandleImeEvent();
192 virtual void InstrumentWillBeginFrame(int frame_id) {}
193 virtual void InstrumentDidBeginFrame() {}
194 virtual void InstrumentDidCancelFrame() {}
195 virtual void InstrumentWillComposite() {}
197 bool UsingSynchronousRendererCompositor() const;
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;
205 // Emulates screen and widget metrics. Supplied values override everything
206 // coming from host.
207 void EnableScreenMetricsEmulation(
208 const blink::WebDeviceEmulationParams& params);
209 void DisableScreenMetricsEmulation();
210 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
212 void ScheduleCompositeWithForcedRedraw();
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();
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();
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();
228 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
230 void OnShowHostContextMenu(ContextMenuParams* params);
232 #if defined(OS_ANDROID) || defined(USE_AURA)
233 enum ShowIme {
234 SHOW_IME_IF_NEEDED,
235 NO_SHOW_IME,
238 enum ChangeSource {
239 FROM_NON_IME,
240 FROM_IME,
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);
250 #endif
252 #if defined(OS_MACOSX) || defined(USE_AURA)
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
259 #if defined(OS_MACOSX)
260 void DidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar,
261 bool has_vertical_scrollbar);
262 #endif // defined(OS_MACOSX)
264 #if defined(OS_ANDROID)
265 void DidChangeBodyBackgroundColor(SkColor bg_color);
266 #endif
268 protected:
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>;
272 // For unit tests.
273 friend class RenderWidgetTest;
275 enum ResizeAck {
276 SEND_RESIZE_ACK,
277 NO_RESIZE_ACK,
280 RenderWidget(blink::WebPopupType popup_type,
281 const blink::WebScreenInfo& screen_info,
282 bool swapped_out,
283 bool hidden,
284 bool never_visible);
286 virtual ~RenderWidget();
288 // Initializes this view with the given opener. CompleteInit must be called
289 // later.
290 bool Init(int32 opener_id);
292 // Called by Init and subclasses to perform initialization.
293 bool DoInit(int32 opener_id,
294 blink::WebWidget* web_widget,
295 IPC::SyncMessage* create_widget_message);
297 // Finishes creation of a pending view started with Init.
298 void CompleteInit();
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);
306 void AnimationCallback();
307 void InvalidationCallback();
308 void FlushPendingInputEventAck();
309 void DoDeferredUpdateAndSendInputAck();
310 void DoDeferredUpdate();
311 void DoDeferredClose();
312 void DoDeferredSetWindowRect(const blink::WebRect& pos);
314 // Set the background of the render widget to a bitmap. The bitmap will be
315 // tiled in both directions if it isn't big enough to fill the area. This is
316 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
317 virtual void SetBackground(const SkBitmap& bitmap);
319 // Resizes the render widget.
320 void Resize(const gfx::Size& new_size,
321 const gfx::Size& physical_backing_size,
322 float overdraw_bottom_height,
323 const gfx::Size& visible_viewport_size,
324 const gfx::Rect& resizer_rect,
325 bool is_fullscreen,
326 ResizeAck resize_ack);
327 // Used to force the size of a window when running layout tests.
328 void ResizeSynchronously(const gfx::Rect& new_position);
329 virtual void SetScreenMetricsEmulationParameters(
330 float device_scale_factor,
331 const gfx::Point& root_layer_offset,
332 float root_layer_scale);
333 #if defined(OS_MACOSX) || defined(OS_ANDROID)
334 void SetExternalPopupOriginAdjustmentsForEmulation(
335 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
336 #endif
338 // RenderWidget IPC message handlers
339 void OnHandleInputEvent(const blink::WebInputEvent* event,
340 const ui::LatencyInfo& latency_info,
341 bool keyboard_shortcut);
342 void OnCursorVisibilityChange(bool is_visible);
343 void OnMouseCaptureLost();
344 virtual void OnSetFocus(bool enable);
345 void OnClose();
346 void OnCreatingNewAck();
347 virtual void OnResize(const ViewMsg_Resize_Params& params);
348 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
349 virtual void OnWasHidden();
350 virtual void OnWasShown(bool needs_repainting);
351 virtual void OnWasSwappedOut();
352 void OnCreateVideoAck(int32 video_id);
353 void OnUpdateVideoAck(int32 video_id);
354 void OnRequestMoveAck();
355 void OnSetInputMethodActive(bool is_active);
356 void OnCandidateWindowShown();
357 void OnCandidateWindowUpdated();
358 void OnCandidateWindowHidden();
359 virtual void OnImeSetComposition(
360 const base::string16& text,
361 const std::vector<blink::WebCompositionUnderline>& underlines,
362 int selection_start,
363 int selection_end);
364 virtual void OnImeConfirmComposition(const base::string16& text,
365 const gfx::Range& replacement_range,
366 bool keep_selection);
367 void OnRepaint(gfx::Size size_to_paint);
368 void OnSyntheticGestureCompleted();
369 void OnSetTextDirection(blink::WebTextDirection direction);
370 void OnGetFPS();
371 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
372 const gfx::Rect& window_screen_rect);
373 #if defined(OS_ANDROID)
374 void OnShowImeIfNeeded();
376 // Whenever an IME event that needs an acknowledgement is sent to the browser,
377 // the number of outstanding IME events that needs acknowledgement should be
378 // incremented. All IME events will be dropped until we receive an ack from
379 // the browser.
380 void IncrementOutstandingImeEventAcks();
382 // Called by the browser process for every required IME acknowledgement.
383 void OnImeEventAck();
384 #endif
386 // Notify the compositor about a change in viewport size. This should be
387 // used only with auto resize mode WebWidgets, as normal WebWidgets should
388 // go through OnResize.
389 void AutoResizeCompositor();
391 virtual void SetDeviceScaleFactor(float device_scale_factor);
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() {}
402 virtual GURL GetURLForGraphicsContext3D();
404 virtual bool ForceCompositingModeEnabled();
406 // Gets the scroll offset of this widget, if this widget has a notion of
407 // scroll offset.
408 virtual gfx::Vector2d GetScrollOffset();
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);
415 void WillToggleFullscreen();
416 void DidToggleFullscreen();
418 bool next_paint_is_resize_ack() const;
419 void set_next_paint_is_resize_ack();
420 void set_next_paint_is_repaint_ack();
422 // Override point to obtain that the current input method state and caret
423 // position.
424 virtual ui::TextInputType GetTextInputType();
425 virtual ui::TextInputType WebKitToUiTextInputType(
426 blink::WebTextInputType type);
428 #if defined(OS_MACOSX) || defined(USE_AURA)
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);
436 // Returns the range of the text that is being composed or the selection if
437 // the composition does not exist.
438 virtual void GetCompositionRange(gfx::Range* range);
440 // Returns true if the composition range or composition character bounds
441 // should be sent to the browser process.
442 bool ShouldUpdateCompositionInfo(
443 const gfx::Range& range,
444 const std::vector<gfx::Rect>& bounds);
445 #endif
447 // Override point to obtain that the current input method state about
448 // composition text.
449 virtual bool CanComposeInline();
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();
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.
461 void SetPendingWindowRect(const blink::WebRect& r);
463 // Called by OnHandleInputEvent() to notify subclasses that a key event was
464 // just handled.
465 virtual void DidHandleKeyEvent() {}
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().
471 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
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.
477 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
479 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
480 // just handled.
481 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
483 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
484 // just handled.
485 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
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;
491 // Check whether the WebWidget has any touch event handlers registered.
492 virtual void hasTouchEventHandlers(bool has_handlers);
494 // Tell the browser about the actions permitted for a new touch point.
495 virtual void setTouchAction(blink::WebTouchAction touch_action);
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();
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
507 // Creates a 3D context associated with this view.
508 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
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_;
514 int32 surface_id_;
516 // We are responsible for destroying this object via its Close method.
517 // May be NULL when the window is closing.
518 blink::WebWidget* webwidget_;
520 // This is lazily constructed and must not outlive webwidget_.
521 scoped_ptr<RenderWidgetCompositor> compositor_;
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.
528 // This ID may refer to an invalid view if that view is closed before this
529 // view is.
530 int32 opener_id_;
532 // The position where this view should be initially shown.
533 gfx::Rect initial_pos_;
535 bool init_complete_;
537 // We store the current cursor object so we can avoid spamming SetCursor
538 // messages.
539 WebCursor current_cursor_;
541 // The size of the RenderWidget.
542 gfx::Size size_;
544 // The size of the view's backing surface in non-DPI-adjusted pixels.
545 gfx::Size physical_backing_size_;
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_;
551 // The size of the visible viewport in DPI-adjusted pixels.
552 gfx::Size visible_viewport_size_;
554 // The area that must be reserved for drawing the resize corner.
555 gfx::Rect resizer_rect_;
557 // Flags for the next ViewHostMsg_UpdateRect message.
558 int next_paint_flags_;
560 // Whether the WebWidget is in auto resize mode, which is used for example
561 // by extension popups.
562 bool auto_resize_mode_;
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_;
568 // Set to true if we should ignore RenderWidget::Show calls.
569 bool did_show_;
571 // Indicates that we shouldn't bother generated paint events.
572 bool is_hidden_;
574 // Indicates that we are never visible, so never produce graphical output.
575 bool never_visible_;
577 // Indicates that we are in fullscreen mode.
578 bool is_fullscreen_;
580 // Indicates whether we have been focused/unfocused by the browser.
581 bool has_focus_;
583 // Are we currently handling an input event?
584 bool handling_input_event_;
586 // Are we currently handling an ime event?
587 bool handling_ime_event_;
589 // Are we currently handling a touchstart event?
590 bool handling_touchstart_event_;
592 // True if we have requested this widget be closed. No more messages will
593 // be sent, except for a Close.
594 bool closing_;
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_;
601 // Indicates if an input method is active in the browser process.
602 bool input_method_is_active_;
604 // Stores information about the current text input.
605 blink::WebTextInputInfo text_input_info_;
607 // Stores the current text input type of |webwidget_|.
608 ui::TextInputType text_input_type_;
610 // Stores the current text input mode of |webwidget_|.
611 ui::TextInputMode text_input_mode_;
613 // Stores the current type of composition text rendering of |webwidget_|.
614 bool can_compose_inline_;
616 // Stores the current selection bounds.
617 gfx::Rect selection_focus_rect_;
618 gfx::Rect selection_anchor_rect_;
620 // Stores the current selection root bounds.
621 #if defined(OS_ANDROID)
622 gfx::Rect selection_root_rect_;
623 #endif
625 // Stores the current composition character bounds.
626 std::vector<gfx::Rect> composition_character_bounds_;
628 // Stores the current composition range.
629 gfx::Range composition_range_;
631 // The kind of popup this widget represents, NONE if not a popup.
632 blink::WebPopupType popup_type_;
634 // Holds all the needed plugin window moves for a scroll.
635 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
636 WebPluginGeometryVector plugin_window_moves_;
638 // A custom background for the widget.
639 SkBitmap background_;
641 // While we are waiting for the browser to update window sizes, we track the
642 // pending size temporarily.
643 int pending_window_rect_count_;
644 blink::WebRect pending_window_rect_;
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_;
650 scoped_ptr<IPC::Message> pending_input_event_ack_;
652 // The time spent in input handlers this frame. Used to throttle input acks.
653 base::TimeDelta total_input_handling_time_this_frame_;
655 // Indicates if the next sequence of Char events should be suppressed or not.
656 bool suppress_next_char_events_;
658 // Set to true if painting to the window is handled by the accelerated
659 // compositor.
660 bool is_accelerated_compositing_active_;
662 // Set to true if compositing has ever been active for this widget. Once a
663 // widget has used compositing, it will act as though force compositing mode
664 // is on for the remainder of the widget's lifetime.
665 bool was_accelerated_compositing_ever_active_;
667 base::OneShotTimer<RenderWidget> animation_timer_;
668 bool animation_update_pending_;
669 bool invalidation_task_posted_;
671 // Stats for legacy software mode
672 scoped_ptr<cc::RenderingStatsInstrumentation> legacy_software_mode_stats_;
674 // Properties of the screen hosting this RenderWidget instance.
675 blink::WebScreenInfo screen_info_;
677 // The device scale factor. This value is computed from the DPI entries in
678 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
679 float device_scale_factor_;
681 // State associated with synthetic gestures. Synthetic gestures are processed
682 // in-order, so a queue is sufficient to identify the correct state for a
683 // completed gesture.
684 std::queue<SyntheticGestureCompletionCallback>
685 pending_synthetic_gesture_callbacks_;
687 // Specified whether the compositor will run in its own thread.
688 bool is_threaded_compositing_enabled_;
690 uint32 next_output_surface_id_;
692 #if defined(OS_ANDROID)
693 // Indicates value in the focused text field is in dirty state, i.e. modified
694 // by script etc., not by user input.
695 bool text_field_is_dirty_;
697 // A counter for number of outstanding messages from the renderer to the
698 // browser regarding IME-type events that have not been acknowledged by the
699 // browser. If this value is not 0 IME events will be dropped.
700 int outstanding_ime_acks_;
702 // The background color of the document body element. This is used as the
703 // default background color for filling the screen areas for which we don't
704 // have the actual content.
705 SkColor body_background_color_;
706 #endif
708 #if defined(OS_MACOSX)
709 // These store the "has scrollbars" state last sent to the browser.
710 bool cached_has_main_frame_horizontal_scrollbar_;
711 bool cached_has_main_frame_vertical_scrollbar_;
712 #endif // defined(OS_MACOSX)
714 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
716 // Popups may be displaced when screen metrics emulation is enabled.
717 // These values are used to properly adjust popup position.
718 gfx::Point popup_view_origin_for_emulation_;
719 gfx::Point popup_screen_origin_for_emulation_;
720 float popup_origin_scale_for_emulation_;
722 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
724 // A list of swapped out RenderFrames that need to be notified
725 // of compositing-related events (e.g. DidCommitCompositorFrame).
726 ObserverList<RenderFrameImpl> swapped_out_frames_;
728 ui::MenuSourceType context_menu_source_type_;
729 gfx::Point touch_editing_context_menu_location_;
731 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
734 } // namespace content
736 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_