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_
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;
54 class SyncMessageFilter;
58 struct WebDeviceEmulationParams;
59 class WebGestureEvent;
60 class WebKeyboardEvent;
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,
91 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
92 public base::RefCounted<RenderWidget> {
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
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)
139 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
142 virtual bool Send(IPC::Message* msg) OVERRIDE;
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();
172 // Begins the compositor's scheduler to start producing frames.
173 void StartCompositor();
176 void DestroyLayerTreeView();
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);
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);
186 RenderWidgetCompositor* compositor() const;
188 const ui::LatencyInfo* current_event_latency_info() const {
189 return current_event_latency_info_;
192 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
194 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
195 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
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);
203 // Close the underlying WebWidget.
204 virtual void Close();
206 // Notifies about a compositor frame commit operation having finished.
207 virtual void DidCommitCompositorFrame();
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
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);
221 // Handle common setup/teardown for handling IME events.
222 void StartHandlingImeEvent();
223 void FinishHandlingImeEvent();
225 // Returns whether we currently should handle an IME event.
226 bool ShouldHandleImeEvent();
228 virtual void InstrumentWillBeginFrame(int frame_id) {}
229 virtual void InstrumentDidBeginFrame() {}
230 virtual void InstrumentDidCancelFrame() {}
231 virtual void InstrumentWillComposite() {}
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();
238 // When resumed from pause in debugger while handling mouse move,
239 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
240 void IgnoreAckForMouseMoveFromDebugger();
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;
248 // Emulates screen and widget metrics. Supplied values override everything
250 void EnableScreenMetricsEmulation(
251 const blink::WebDeviceEmulationParams& params);
252 void DisableScreenMetricsEmulation();
253 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
254 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
256 void ScheduleCompositeWithForcedRedraw();
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();
264 // Checks if the text input state and compose inline mode have been changed.
265 // If they are changed, the new value will be sent to the browser process.
266 void UpdateTextInputType();
268 // Checks if the selection bounds have been changed. If they are changed,
269 // the new value will be sent to the browser process.
270 void UpdateSelectionBounds();
272 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
274 void OnShowHostContextMenu(ContextMenuParams* params);
276 #if defined(OS_ANDROID) || defined(USE_AURA)
287 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
288 // be displayed, e.g. after a tap on an input field on mobile.
289 // |change_source| should be FROM_NON_IME when the renderer has to wait for
290 // the browser to acknowledge the change before the renderer handles any more
291 // IME events. This is when the text change did not originate from the IME in
292 // the browser side, such as changes by JavaScript or autofill.
293 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
296 #if defined(OS_MACOSX) || defined(USE_AURA)
297 // Checks if the composition range or composition character bounds have been
298 // changed. If they are changed, the new value will be sent to the browser
300 void UpdateCompositionInfo(bool should_update_range);
303 #if defined(OS_ANDROID)
304 void DidChangeBodyBackgroundColor(SkColor bg_color);
308 // Friend RefCounted so that the dtor can be non-public. Using this class
309 // without ref-counting is an error.
310 friend class base::RefCounted<RenderWidget>;
312 friend class RenderWidgetTest;
319 RenderWidget(blink::WebPopupType popup_type,
320 const blink::WebScreenInfo& screen_info,
325 virtual ~RenderWidget();
327 // Initializes this view with the given opener. CompleteInit must be called
329 bool Init(int32 opener_id);
331 // Called by Init and subclasses to perform initialization.
332 bool DoInit(int32 opener_id,
333 blink::WebWidget* web_widget,
334 IPC::SyncMessage* create_widget_message);
336 // Finishes creation of a pending view started with Init.
339 // Sets whether this RenderWidget has been swapped out to be displayed by
340 // a RenderWidget in a different process. If so, no new IPC messages will be
341 // sent (only ACKs) and the process is free to exit when there are no other
342 // active RenderWidgets.
343 void SetSwappedOut(bool is_swapped_out);
345 // Allows the process to exit once the unload handler has finished, if there
346 // are no other active RenderWidgets.
347 void WasSwappedOut();
349 void FlushPendingInputEventAck();
350 void DoDeferredClose();
351 void DoDeferredSetWindowRect(const blink::WebRect& pos);
353 // Resizes the render widget.
354 void Resize(const gfx::Size& new_size,
355 const gfx::Size& physical_backing_size,
356 float top_controls_layout_height,
357 const gfx::Size& visible_viewport_size,
358 const gfx::Rect& resizer_rect,
360 ResizeAck resize_ack);
361 // Used to force the size of a window when running layout tests.
362 void ResizeSynchronously(const gfx::Rect& new_position);
363 virtual void SetScreenMetricsEmulationParameters(
364 float device_scale_factor,
365 const gfx::Point& root_layer_offset,
366 float root_layer_scale);
367 #if defined(OS_MACOSX) || defined(OS_ANDROID)
368 void SetExternalPopupOriginAdjustmentsForEmulation(
369 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
372 // RenderWidget IPC message handlers
373 void OnHandleInputEvent(const blink::WebInputEvent* event,
374 const ui::LatencyInfo& latency_info,
375 bool keyboard_shortcut);
376 void OnCursorVisibilityChange(bool is_visible);
377 void OnMouseCaptureLost();
378 virtual void OnSetFocus(bool enable);
379 virtual void OnClose();
380 void OnCreatingNewAck();
381 virtual void OnResize(const ViewMsg_Resize_Params& params);
382 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
383 virtual void OnWasHidden();
384 virtual void OnWasShown(bool needs_repainting,
385 const ui::LatencyInfo& latency_info);
386 void OnCreateVideoAck(int32 video_id);
387 void OnUpdateVideoAck(int32 video_id);
388 void OnRequestMoveAck();
389 void OnSetInputMethodActive(bool is_active);
390 void OnCandidateWindowShown();
391 void OnCandidateWindowUpdated();
392 void OnCandidateWindowHidden();
393 virtual void OnImeSetComposition(
394 const base::string16& text,
395 const std::vector<blink::WebCompositionUnderline>& underlines,
398 virtual void OnImeConfirmComposition(const base::string16& text,
399 const gfx::Range& replacement_range,
400 bool keep_selection);
401 void OnRepaint(gfx::Size size_to_paint);
402 void OnSyntheticGestureCompleted();
403 void OnSetTextDirection(blink::WebTextDirection direction);
405 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
406 const gfx::Rect& window_screen_rect);
407 void OnShowImeIfNeeded();
409 #if defined(OS_ANDROID)
410 // Whenever an IME event that needs an acknowledgement is sent to the browser,
411 // the number of outstanding IME events that needs acknowledgement should be
412 // incremented. All IME events will be dropped until we receive an ack from
414 void IncrementOutstandingImeEventAcks();
416 // Called by the browser process for every required IME acknowledgement.
417 void OnImeEventAck();
420 // Notify the compositor about a change in viewport size. This should be
421 // used only with auto resize mode WebWidgets, as normal WebWidgets should
422 // go through OnResize.
423 void AutoResizeCompositor();
425 virtual void SetDeviceScaleFactor(float device_scale_factor);
426 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
427 virtual void ResetDeviceColorProfileForTesting();
429 virtual void OnOrientationChange();
431 // Override points to notify derived classes that a paint has happened.
432 // DidInitiatePaint happens when that has completed, and subsequent rendering
433 // won't affect the painted content. DidFlushPaint happens once we've received
434 // the ACK that the screen has been updated. For a given paint operation,
435 // these overrides will always be called in the order DidInitiatePaint,
437 virtual void DidInitiatePaint() {}
438 virtual void DidFlushPaint() {}
440 virtual GURL GetURLForGraphicsContext3D();
442 // Gets the scroll offset of this widget, if this widget has a notion of
444 virtual gfx::Vector2d GetScrollOffset();
446 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
447 // use this method so that we can properly inform the RenderThread of our
449 void SetHidden(bool hidden);
451 void WillToggleFullscreen();
452 void DidToggleFullscreen();
454 bool next_paint_is_resize_ack() const;
455 void set_next_paint_is_resize_ack();
456 void set_next_paint_is_repaint_ack();
458 // QueueMessage implementation extracted into a static method for easy
460 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
462 MessageDeliveryPolicy policy,
463 FrameSwapMessageQueue* frame_swap_message_queue,
464 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
465 bool commit_requested,
466 int source_frame_number);
468 // Override point to obtain that the current input method state and caret
470 virtual ui::TextInputType GetTextInputType();
471 virtual ui::TextInputType WebKitToUiTextInputType(
472 blink::WebTextInputType type);
474 #if defined(OS_MACOSX) || defined(USE_AURA)
475 // Override point to obtain that the current composition character bounds.
476 // In the case of surrogate pairs, the character is treated as two characters:
477 // the bounds for first character is actual one, and the bounds for second
478 // character is zero width rectangle.
479 virtual void GetCompositionCharacterBounds(
480 std::vector<gfx::Rect>* character_bounds);
482 // Returns the range of the text that is being composed or the selection if
483 // the composition does not exist.
484 virtual void GetCompositionRange(gfx::Range* range);
486 // Returns true if the composition range or composition character bounds
487 // should be sent to the browser process.
488 bool ShouldUpdateCompositionInfo(
489 const gfx::Range& range,
490 const std::vector<gfx::Rect>& bounds);
493 // Override point to obtain that the current input method state about
495 virtual bool CanComposeInline();
497 // Tells the renderer it does not have focus. Used to prevent us from getting
498 // the focus on our own when the browser did not focus us.
501 // Set the pending window rect.
502 // Because the real render_widget is hosted in another process, there is
503 // a time period where we may have set a new window rect which has not yet
504 // been processed by the browser. So we maintain a pending window rect
505 // size. If JS code sets the WindowRect, and then immediately calls
506 // GetWindowRect() we'll use this pending window rect as the size.
507 void SetPendingWindowRect(const blink::WebRect& r);
509 // Called by OnHandleInputEvent() to notify subclasses that a key event was
511 virtual void DidHandleKeyEvent() {}
513 // Called by OnHandleInputEvent() to notify subclasses that a mouse 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 or trigger DidHandleMouseEvent().
517 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
519 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
520 // about to be handled.
521 // Returns true if no further handling is needed. In that case, the event
522 // won't be sent to WebKit.
523 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
525 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
527 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
529 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
531 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
533 // Check whether the WebWidget has any touch event handlers registered
534 // at the given point.
535 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
537 // Check whether the WebWidget has any touch event handlers registered.
538 virtual void hasTouchEventHandlers(bool has_handlers);
540 // Tell the browser about the actions permitted for a new touch point.
541 virtual void setTouchAction(blink::WebTouchAction touch_action);
543 // Called when value of focused text field gets dirty, e.g. value is modified
544 // by script, not by user input.
545 virtual void didUpdateTextOfFocusedElementByNonUserInput();
547 // Creates a 3D context associated with this view.
548 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
550 // Routing ID that allows us to communicate to the parent browser process
551 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
556 // We are responsible for destroying this object via its Close method.
557 // May be NULL when the window is closing.
558 blink::WebWidget* webwidget_;
560 // This is lazily constructed and must not outlive webwidget_.
561 scoped_ptr<RenderWidgetCompositor> compositor_;
563 // Set to the ID of the view that initiated creating this view, if any. When
564 // the view was initiated by the browser (the common case), this will be
565 // MSG_ROUTING_NONE. This is used in determining ownership when opening
566 // child tabs. See RenderWidget::createWebViewWithRequest.
568 // This ID may refer to an invalid view if that view is closed before this
572 // The position where this view should be initially shown.
573 gfx::Rect initial_pos_;
577 // We store the current cursor object so we can avoid spamming SetCursor
579 WebCursor current_cursor_;
581 // The size of the RenderWidget.
584 // The size of the view's backing surface in non-DPI-adjusted pixels.
585 gfx::Size physical_backing_size_;
587 // The amount that the viewport size given to Blink was shrunk by the URL-bar
588 // (always 0 on platforms where URL-bar hiding isn't supported).
589 float top_controls_layout_height_;
591 // The size of the visible viewport in DPI-adjusted pixels.
592 gfx::Size visible_viewport_size_;
594 // The area that must be reserved for drawing the resize corner.
595 gfx::Rect resizer_rect_;
597 // Flags for the next ViewHostMsg_UpdateRect message.
598 int next_paint_flags_;
600 // Whether the WebWidget is in auto resize mode, which is used for example
601 // by extension popups.
602 bool auto_resize_mode_;
604 // True if we need to send an UpdateRect message to notify the browser about
605 // an already-completed auto-resize.
606 bool need_update_rect_for_auto_resize_;
608 // Set to true if we should ignore RenderWidget::Show calls.
611 // Indicates that we shouldn't bother generated paint events.
614 // Indicates that we are never visible, so never produce graphical output.
617 // Indicates that we are in fullscreen mode.
620 // Indicates whether we have been focused/unfocused by the browser.
623 // Are we currently handling an input event?
624 bool handling_input_event_;
626 // Are we currently handling an ime event?
627 bool handling_ime_event_;
629 // Type of the input event we are currently handling.
630 blink::WebInputEvent::Type handling_event_type_;
632 // Whether we should not send ack for the current mouse move.
633 bool ignore_ack_for_mouse_move_from_debugger_;
635 // True if we have requested this widget be closed. No more messages will
636 // be sent, except for a Close.
639 // True if it is known that the host is in the process of being shut down.
642 // Whether this RenderWidget is currently swapped out, such that the view is
643 // being rendered by another process. If all RenderWidgets in a process are
644 // swapped out, the process can exit.
645 bool is_swapped_out_;
647 // Indicates if an input method is active in the browser process.
648 bool input_method_is_active_;
650 // Stores information about the current text input.
651 blink::WebTextInputInfo text_input_info_;
653 // Stores the current text input type of |webwidget_|.
654 ui::TextInputType text_input_type_;
656 // Stores the current text input mode of |webwidget_|.
657 ui::TextInputMode text_input_mode_;
659 // Stores the current type of composition text rendering of |webwidget_|.
660 bool can_compose_inline_;
662 // Stores the current selection bounds.
663 gfx::Rect selection_focus_rect_;
664 gfx::Rect selection_anchor_rect_;
666 // Stores the current composition character bounds.
667 std::vector<gfx::Rect> composition_character_bounds_;
669 // Stores the current composition range.
670 gfx::Range composition_range_;
672 // The kind of popup this widget represents, NONE if not a popup.
673 blink::WebPopupType popup_type_;
675 // Holds all the needed plugin window moves for a scroll.
676 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
677 WebPluginGeometryVector plugin_window_moves_;
679 // While we are waiting for the browser to update window sizes, we track the
680 // pending size temporarily.
681 int pending_window_rect_count_;
682 blink::WebRect pending_window_rect_;
684 // The screen rects of the view and the window that contains it.
685 gfx::Rect view_screen_rect_;
686 gfx::Rect window_screen_rect_;
688 scoped_ptr<IPC::Message> pending_input_event_ack_;
690 // The time spent in input handlers this frame. Used to throttle input acks.
691 base::TimeDelta total_input_handling_time_this_frame_;
693 // Indicates if the next sequence of Char events should be suppressed or not.
694 bool suppress_next_char_events_;
696 // Properties of the screen hosting this RenderWidget instance.
697 blink::WebScreenInfo screen_info_;
699 // The device scale factor. This value is computed from the DPI entries in
700 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
701 float device_scale_factor_;
703 // The device color profile on supported platforms.
704 std::vector<char> device_color_profile_;
706 // State associated with synthetic gestures. Synthetic gestures are processed
707 // in-order, so a queue is sufficient to identify the correct state for a
708 // completed gesture.
709 std::queue<SyntheticGestureCompletionCallback>
710 pending_synthetic_gesture_callbacks_;
712 const ui::LatencyInfo* current_event_latency_info_;
714 uint32 next_output_surface_id_;
716 #if defined(OS_ANDROID)
717 // Indicates value in the focused text field is in dirty state, i.e. modified
718 // by script etc., not by user input.
719 bool text_field_is_dirty_;
721 // A counter for number of outstanding messages from the renderer to the
722 // browser regarding IME-type events that have not been acknowledged by the
723 // browser. If this value is not 0 IME events will be dropped.
724 int outstanding_ime_acks_;
726 // The background color of the document body element. This is used as the
727 // default background color for filling the screen areas for which we don't
728 // have the actual content.
729 SkColor body_background_color_;
732 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
734 // Popups may be displaced when screen metrics emulation is enabled.
735 // These values are used to properly adjust popup position.
736 gfx::Point popup_view_origin_for_emulation_;
737 gfx::Point popup_screen_origin_for_emulation_;
738 float popup_origin_scale_for_emulation_;
740 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
741 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
743 // Lists of RenderFrameProxy objects that need to be notified of
744 // compositing-related events (e.g. DidCommitCompositorFrame).
745 ObserverList<RenderFrameProxy> render_frame_proxies_;
746 #if defined(VIDEO_HOLE)
747 ObserverList<RenderFrameImpl> video_hole_frames_;
748 #endif // defined(VIDEO_HOLE)
750 // A list of RenderFrames associated with this RenderWidget. Notifications
751 // are sent to each frame in the list for events such as changing
752 // visibility state for example.
753 ObserverList<RenderFrameImpl> render_frames_;
755 ui::MenuSourceType context_menu_source_type_;
756 bool has_host_context_menu_location_;
757 gfx::Point host_context_menu_location_;
759 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
762 } // namespace content
764 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_