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 "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 "content/renderer/message_delivery_policy.h"
24 #include "ipc/ipc_listener.h"
25 #include "ipc/ipc_sender.h"
26 #include "third_party/WebKit/public/platform/WebDisplayMode.h"
27 #include "third_party/WebKit/public/platform/WebRect.h"
28 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
29 #include "third_party/WebKit/public/web/WebInputEvent.h"
30 #include "third_party/WebKit/public/web/WebPopupType.h"
31 #include "third_party/WebKit/public/web/WebTextDirection.h"
32 #include "third_party/WebKit/public/web/WebTextInputInfo.h"
33 #include "third_party/WebKit/public/web/WebTouchAction.h"
34 #include "third_party/WebKit/public/web/WebWidget.h"
35 #include "third_party/WebKit/public/web/WebWidgetClient.h"
36 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "ui/base/ime/text_input_mode.h"
38 #include "ui/base/ime/text_input_type.h"
39 #include "ui/base/ui_base_types.h"
40 #include "ui/gfx/geometry/rect.h"
41 #include "ui/gfx/geometry/vector2d.h"
42 #include "ui/gfx/geometry/vector2d_f.h"
43 #include "ui/gfx/native_widget_types.h"
44 #include "ui/gfx/range/range.h"
45 #include "ui/surface/transport_dib.h"
47 struct ViewHostMsg_UpdateRect_Params
;
48 struct ViewMsg_Resize_Params
;
49 class ViewHostMsg_UpdateRect
;
53 class SyncMessageFilter
;
57 struct WebDeviceEmulationParams
;
59 class WebGestureEvent
;
60 class WebKeyboardEvent
;
70 struct InputHandlerScrollResult
;
80 class CompositorDependencies
;
81 class ExternalPopupMenu
;
82 class FrameSwapMessageQueue
;
83 class PepperPluginInstanceImpl
;
84 class RenderFrameImpl
;
85 class RenderFrameProxy
;
86 class RenderWidgetCompositor
;
87 class RenderWidgetTest
;
88 class ResizingModeSelector
;
89 struct ContextMenuParams
;
90 struct WebPluginGeometry
;
92 // RenderWidget provides a communication bridge between a WebWidget and
93 // a RenderWidgetHost, the latter of which lives in a different process.
94 class CONTENT_EXPORT RenderWidget
95 : public IPC::Listener
,
97 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient
),
98 public base::RefCounted
<RenderWidget
> {
100 // Creates a new RenderWidget. The opener_id is the routing ID of the
101 // RenderView that this widget lives inside.
102 static RenderWidget
* Create(int32 opener_id
,
103 CompositorDependencies
* compositor_deps
,
104 blink::WebPopupType popup_type
,
105 const blink::WebScreenInfo
& screen_info
);
107 // Creates a new RenderWidget that will be attached to a RenderFrame.
108 static RenderWidget
* CreateForFrame(int routing_id
,
111 const blink::WebScreenInfo
& screen_info
,
112 CompositorDependencies
* compositor_deps
,
113 blink::WebLocalFrame
* frame
);
115 static blink::WebWidget
* CreateWebFrameWidget(RenderWidget
* render_widget
,
116 blink::WebLocalFrame
* frame
);
118 // Creates a WebWidget based on the popup type.
119 static blink::WebWidget
* CreateWebWidget(RenderWidget
* render_widget
);
121 int32
routing_id() const { return routing_id_
; }
122 int32
surface_id() const { return surface_id_
; }
123 CompositorDependencies
* compositor_deps() const { return compositor_deps_
; }
124 blink::WebWidget
* webwidget() const { return webwidget_
; }
125 gfx::Size
size() const { return size_
; }
126 bool has_focus() const { return has_focus_
; }
127 bool is_fullscreen_granted() const { return is_fullscreen_granted_
; }
128 blink::WebDisplayMode
display_mode() const { return display_mode_
; }
129 bool is_hidden() const { return is_hidden_
; }
130 bool handling_input_event() const { return handling_input_event_
; }
131 // Temporary for debugging purposes...
132 bool closing() const { return closing_
; }
133 bool is_swapped_out() { return is_swapped_out_
; }
134 bool for_oopif() { return for_oopif_
; }
135 ui::MenuSourceType
context_menu_source_type() {
136 return context_menu_source_type_
;
138 bool has_host_context_menu_location() {
139 return has_host_context_menu_location_
;
141 gfx::Point
host_context_menu_location() {
142 return host_context_menu_location_
;
145 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
146 blink::WebScreenInfo
screen_info() const { return screen_info_
; }
148 // Functions to track out-of-process frames for special notifications.
149 void RegisterRenderFrameProxy(RenderFrameProxy
* proxy
);
150 void UnregisterRenderFrameProxy(RenderFrameProxy
* proxy
);
152 // Functions to track all RenderFrame objects associated with this
154 void RegisterRenderFrame(RenderFrameImpl
* frame
);
155 void UnregisterRenderFrame(RenderFrameImpl
* frame
);
157 #if defined(VIDEO_HOLE)
158 void RegisterVideoHoleFrame(RenderFrameImpl
* frame
);
159 void UnregisterVideoHoleFrame(RenderFrameImpl
* frame
);
160 #endif // defined(VIDEO_HOLE)
163 bool OnMessageReceived(const IPC::Message
& msg
) override
;
166 bool Send(IPC::Message
* msg
) override
;
168 // blink::WebWidgetClient
169 virtual void willBeginCompositorFrame();
170 virtual void didAutoResize(const blink::WebSize
& new_size
);
171 virtual void initializeLayerTreeView();
172 virtual blink::WebLayerTreeView
* layerTreeView();
173 virtual void didBecomeReadyForAdditionalInput();
174 virtual void didCommitAndDrawCompositorFrame();
175 virtual void didCompleteSwapBuffers();
176 virtual void scheduleComposite();
177 virtual void didFocus();
178 virtual void didBlur();
179 virtual void didChangeCursor(const blink::WebCursorInfo
&);
180 virtual void closeWidgetSoon();
181 virtual void show(blink::WebNavigationPolicy
);
182 virtual blink::WebRect
windowRect();
183 virtual void setToolTipText(const blink::WebString
& text
,
184 blink::WebTextDirection hint
);
185 virtual void setWindowRect(const blink::WebRect
&);
186 virtual blink::WebRect
windowResizerRect();
187 virtual blink::WebRect
rootWindowRect();
188 virtual blink::WebScreenInfo
screenInfo();
189 virtual float deviceScaleFactor();
190 virtual void resetInputMethod();
191 virtual void didHandleGestureEvent(const blink::WebGestureEvent
& event
,
192 bool event_cancelled
);
193 virtual void showImeIfNeeded();
195 #if defined(OS_ANDROID)
196 // Notifies that a tap was not consumed, so showing a UI for the unhandled
197 // tap may be needed.
198 // Performs various checks on the given WebNode to apply heuristics to
199 // determine if triggering is appropriate.
200 virtual void showUnhandledTapUIIfNeeded(
201 const blink::WebPoint
& tapped_position
,
202 const blink::WebNode
& tapped_node
,
203 bool page_changed
) override
;
206 // Begins the compositor's scheduler to start producing frames.
207 void StartCompositor();
210 void WillCloseLayerTreeView();
212 // Called when a plugin is moved. These events are queued up and sent with
213 // the next paint or scroll message to the host.
214 void SchedulePluginMove(const WebPluginGeometry
& move
);
216 // Called when a plugin window has been destroyed, to make sure the currently
217 // pending moves don't try to reference it.
218 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window
);
220 RenderWidgetCompositor
* compositor() const;
222 const ui::LatencyInfo
* current_event_latency_info() const {
223 return current_event_latency_info_
;
226 virtual scoped_ptr
<cc::OutputSurface
> CreateOutputSurface(bool fallback
);
228 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
229 typedef base::Callback
<void()> SyntheticGestureCompletionCallback
;
231 // Send a synthetic gesture to the browser to be queued to the synthetic
232 // gesture controller.
233 void QueueSyntheticGesture(
234 scoped_ptr
<SyntheticGestureParams
> gesture_params
,
235 const SyntheticGestureCompletionCallback
& callback
);
237 // Close the underlying WebWidget.
238 virtual void Close();
240 // Notifies about a compositor frame commit operation having finished.
241 virtual void DidCommitCompositorFrame();
243 // Deliveres |message| together with compositor state change updates. The
244 // exact behavior depends on |policy|.
245 // This mechanism is not a drop-in replacement for IPC: messages sent this way
246 // will not be automatically available to BrowserMessageFilter, for example.
247 // FIFO ordering is preserved between messages enqueued with the same
248 // |policy|, the ordering between messages enqueued for different policies is
251 // |msg| message to send, ownership of |msg| is transferred.
252 // |policy| see the comment on MessageDeliveryPolicy.
253 void QueueMessage(IPC::Message
* msg
, MessageDeliveryPolicy policy
);
255 // Handle common setup/teardown for handling IME events.
256 void StartHandlingImeEvent();
257 void FinishHandlingImeEvent();
259 // Returns whether we currently should handle an IME event.
260 bool ShouldHandleImeEvent();
262 // Called by the compositor when page scale animation completed.
263 virtual void DidCompletePageScaleAnimation() {}
265 // When paused in debugger, we send ack for mouse event early. This ensures
266 // that we continue receiving mouse moves and pass them to debugger. Returns
267 // whether we are paused in mouse move event and have sent the ack.
268 bool SendAckForMouseMoveFromDebugger();
270 // When resumed from pause in debugger while handling mouse move,
271 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
272 void IgnoreAckForMouseMoveFromDebugger();
274 // ScreenMetricsEmulator class manages screen emulation inside a render
275 // widget. This includes resizing, placing view on the screen at desired
276 // position, changing device scale factor, and scaling down the whole
277 // widget if required to fit into the browser window.
278 class ScreenMetricsEmulator
;
280 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator
* emulator
);
281 gfx::Rect
AdjustValidationMessageAnchor(const gfx::Rect
& anchor
);
283 void ScheduleCompositeWithForcedRedraw();
285 // Called by the compositor in single-threaded mode when a swap is posted,
286 // completes or is aborted.
287 void OnSwapBuffersPosted();
288 void OnSwapBuffersComplete();
289 void OnSwapBuffersAborted();
291 // Checks if the text input state and compose inline mode have been changed.
292 // If they are changed, the new value will be sent to the browser process.
293 void UpdateTextInputType();
295 // Checks if the selection bounds have been changed. If they are changed,
296 // the new value will be sent to the browser process.
297 void UpdateSelectionBounds();
299 virtual void GetSelectionBounds(gfx::Rect
* start
, gfx::Rect
* end
);
301 void OnShowHostContextMenu(ContextMenuParams
* params
);
303 #if defined(OS_ANDROID) || defined(USE_AURA)
314 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
315 // be displayed, e.g. after a tap on an input field on mobile.
316 // |change_source| should be FROM_NON_IME when the renderer has to wait for
317 // the browser to acknowledge the change before the renderer handles any more
318 // IME events. This is when the text change did not originate from the IME in
319 // the browser side, such as changes by JavaScript or autofill.
320 void UpdateTextInputState(ShowIme show_ime
, ChangeSource change_source
);
323 // Called when animations due to focus change have completed (if any). Can be
324 // called from the renderer, browser, or compositor.
325 virtual void FocusChangeComplete() {}
327 // Checks if the composition range or composition character bounds have been
328 // changed. If they are changed, the new value will be sent to the browser
329 // process. This method does nothing when the browser process is not able to
330 // handle composition range and composition character bounds.
331 void UpdateCompositionInfo(bool should_update_range
);
333 #if defined(OS_ANDROID)
334 void DidChangeBodyBackgroundColor(SkColor bg_color
);
335 bool DoesRecordFullLayer() const;
338 bool host_closing() const { return host_closing_
; }
341 // Friend RefCounted so that the dtor can be non-public. Using this class
342 // without ref-counting is an error.
343 friend class base::RefCounted
<RenderWidget
>;
345 friend class RenderWidgetTest
;
352 RenderWidget(blink::WebPopupType popup_type
,
353 const blink::WebScreenInfo
& screen_info
,
358 ~RenderWidget() override
;
360 // Initializes this view with the given opener. CompleteInit must be called
362 bool Init(int32 opener_id
, CompositorDependencies
* compositor_deps
);
364 // Called by Init and subclasses to perform initialization.
365 bool DoInit(int32 opener_id
,
366 CompositorDependencies
* compositor_deps
,
367 blink::WebWidget
* web_widget
,
368 IPC::SyncMessage
* create_widget_message
);
370 // Finishes creation of a pending view started with Init.
373 // Sets whether this RenderWidget has been swapped out to be displayed by
374 // a RenderWidget in a different process. If so, no new IPC messages will be
375 // sent (only ACKs) and the process is free to exit when there are no other
376 // active RenderWidgets.
377 void SetSwappedOut(bool is_swapped_out
);
379 // Allows the process to exit once the unload handler has finished, if there
380 // are no other active RenderWidgets.
381 void WasSwappedOut();
383 void FlushPendingInputEventAck();
384 void DoDeferredClose();
385 void DoDeferredSetWindowRect(const blink::WebRect
& pos
);
386 void NotifyOnClose();
388 // Resizes the render widget.
389 void Resize(const gfx::Size
& new_size
,
390 const gfx::Size
& physical_backing_size
,
391 bool top_controls_shrink_blink_size
,
392 float top_controls_height
,
393 const gfx::Size
& visible_viewport_size
,
394 const gfx::Rect
& resizer_rect
,
395 bool is_fullscreen_granted
,
396 blink::WebDisplayMode display_mode
,
397 ResizeAck resize_ack
);
398 // Used to force the size of a window when running layout tests.
399 void SetWindowRectSynchronously(const gfx::Rect
& new_window_rect
);
400 virtual void SetScreenMetricsEmulationParameters(
402 const blink::WebDeviceEmulationParams
& params
);
403 #if defined(OS_MACOSX) || defined(OS_ANDROID)
404 void SetExternalPopupOriginAdjustmentsForEmulation(
405 ExternalPopupMenu
* popup
, ScreenMetricsEmulator
* emulator
);
408 // RenderWidget IPC message handlers
409 void OnHandleInputEvent(const blink::WebInputEvent
* event
,
410 const ui::LatencyInfo
& latency_info
,
411 bool keyboard_shortcut
);
412 void OnCursorVisibilityChange(bool is_visible
);
413 void OnMouseCaptureLost();
414 virtual void OnSetFocus(bool enable
);
416 void OnCreatingNewAck();
417 virtual void OnResize(const ViewMsg_Resize_Params
& params
);
418 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams
& params
);
419 void OnDisableDeviceEmulation();
420 void OnColorProfile(const std::vector
<char>& color_profile
);
421 void OnChangeResizeRect(const gfx::Rect
& resizer_rect
);
422 virtual void OnWasHidden();
423 virtual void OnWasShown(bool needs_repainting
,
424 const ui::LatencyInfo
& latency_info
);
425 void OnCreateVideoAck(int32 video_id
);
426 void OnUpdateVideoAck(int32 video_id
);
427 void OnRequestMoveAck();
428 void OnSetInputMethodActive(bool is_active
);
429 void OnCandidateWindowShown();
430 void OnCandidateWindowUpdated();
431 void OnCandidateWindowHidden();
432 virtual void OnImeSetComposition(
433 const base::string16
& text
,
434 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
437 virtual void OnImeConfirmComposition(const base::string16
& text
,
438 const gfx::Range
& replacement_range
,
439 bool keep_selection
);
440 void OnRepaint(gfx::Size size_to_paint
);
441 void OnSyntheticGestureCompleted();
442 void OnSetTextDirection(blink::WebTextDirection direction
);
444 void OnUpdateScreenRects(const gfx::Rect
& view_screen_rect
,
445 const gfx::Rect
& window_screen_rect
);
446 void OnShowImeIfNeeded();
447 void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace
);
449 #if defined(OS_ANDROID)
450 // Whenever an IME event that needs an acknowledgement is sent to the browser,
451 // the number of outstanding IME events that needs acknowledgement should be
452 // incremented. All IME events will be dropped until we receive an ack from
454 void IncrementOutstandingImeEventAcks();
456 // Called by the browser process for every required IME acknowledgement.
457 void OnImeEventAck();
460 // Notify the compositor about a change in viewport size. This should be
461 // used only with auto resize mode WebWidgets, as normal WebWidgets should
462 // go through OnResize.
463 void AutoResizeCompositor();
465 virtual void SetDeviceScaleFactor(float device_scale_factor
);
466 virtual bool SetDeviceColorProfile(const std::vector
<char>& color_profile
);
467 virtual void ResetDeviceColorProfileForTesting();
469 virtual void OnOrientationChange();
471 // Override points to notify derived classes that a paint has happened.
472 // DidInitiatePaint happens when that has completed, and subsequent rendering
473 // won't affect the painted content. DidFlushPaint happens once we've received
474 // the ACK that the screen has been updated. For a given paint operation,
475 // these overrides will always be called in the order DidInitiatePaint,
477 virtual void DidInitiatePaint() {}
478 virtual void DidFlushPaint() {}
480 virtual GURL
GetURLForGraphicsContext3D();
482 // Gets the scroll offset of this widget, if this widget has a notion of
484 virtual gfx::Vector2d
GetScrollOffset();
486 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
487 // use this method so that we can properly inform the RenderThread of our
489 void SetHidden(bool hidden
);
491 void WillToggleFullscreen();
492 void DidToggleFullscreen();
494 bool next_paint_is_resize_ack() const;
495 void set_next_paint_is_resize_ack();
496 void set_next_paint_is_repaint_ack();
498 // QueueMessage implementation extracted into a static method for easy
500 static scoped_ptr
<cc::SwapPromise
> QueueMessageImpl(
502 MessageDeliveryPolicy policy
,
503 FrameSwapMessageQueue
* frame_swap_message_queue
,
504 scoped_refptr
<IPC::SyncMessageFilter
> sync_message_filter
,
505 int source_frame_number
);
507 // Override point to obtain that the current input method state and caret
509 virtual ui::TextInputType
GetTextInputType();
510 virtual ui::TextInputType
WebKitToUiTextInputType(
511 blink::WebTextInputType type
);
513 // Override point to obtain that the current composition character bounds.
514 // In the case of surrogate pairs, the character is treated as two characters:
515 // the bounds for first character is actual one, and the bounds for second
516 // character is zero width rectangle.
517 virtual void GetCompositionCharacterBounds(
518 std::vector
<gfx::Rect
>* character_bounds
);
520 // Returns the range of the text that is being composed or the selection if
521 // the composition does not exist.
522 virtual void GetCompositionRange(gfx::Range
* range
);
524 // Returns true if the composition range or composition character bounds
525 // should be sent to the browser process.
526 bool ShouldUpdateCompositionInfo(
527 const gfx::Range
& range
,
528 const std::vector
<gfx::Rect
>& bounds
);
530 // Override point to obtain that the current input method state about
532 virtual bool CanComposeInline();
534 // Tells the renderer it does not have focus. Used to prevent us from getting
535 // the focus on our own when the browser did not focus us.
538 // Set the pending window rect.
539 // Because the real render_widget is hosted in another process, there is
540 // a time period where we may have set a new window rect which has not yet
541 // been processed by the browser. So we maintain a pending window rect
542 // size. If JS code sets the WindowRect, and then immediately calls
543 // GetWindowRect() we'll use this pending window rect as the size.
544 void SetPendingWindowRect(const blink::WebRect
& r
);
546 // Called by OnHandleInputEvent() to notify subclasses that a key event was
548 virtual void DidHandleKeyEvent() {}
550 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
551 // about to be handled.
552 // Returns true if no further handling is needed. In that case, the event
553 // won't be sent to WebKit or trigger DidHandleMouseEvent().
554 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent
& event
);
556 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
557 // about to be handled.
558 // Returns true if no further handling is needed. In that case, the event
559 // won't be sent to WebKit.
560 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent
& event
);
562 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
564 virtual void DidHandleMouseEvent(const blink::WebMouseEvent
& event
) {}
566 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
567 // compositor thread, to effect the elastic overscroll effect.
568 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent
& wheel_event
,
569 bool event_processed
);
571 // Check whether the WebWidget has any touch event handlers registered
572 // at the given point.
573 virtual bool HasTouchEventHandlersAt(const gfx::Point
& point
) const;
575 // Check whether the WebWidget has any touch event handlers registered.
576 virtual void hasTouchEventHandlers(bool has_handlers
);
578 // Tell the browser about the actions permitted for a new touch point.
579 virtual void setTouchAction(blink::WebTouchAction touch_action
);
581 // Called when value of focused text field gets dirty, e.g. value is modified
582 // by script, not by user input.
583 virtual void didUpdateTextOfFocusedElementByNonUserInput();
585 // Creates a 3D context associated with this view.
586 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
> CreateGraphicsContext3D();
588 // Routing ID that allows us to communicate to the parent browser process
589 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
594 // Dependencies for initializing a compositor, including flags for optional
596 CompositorDependencies
* compositor_deps_
;
598 // We are responsible for destroying this object via its Close method.
599 // May be NULL when the window is closing.
600 blink::WebWidget
* webwidget_
;
602 // This is lazily constructed and must not outlive webwidget_.
603 scoped_ptr
<RenderWidgetCompositor
> compositor_
;
605 // Set to the ID of the view that initiated creating this view, if any. When
606 // the view was initiated by the browser (the common case), this will be
607 // MSG_ROUTING_NONE. This is used in determining ownership when opening
608 // child tabs. See RenderWidget::createWebViewWithRequest.
610 // This ID may refer to an invalid view if that view is closed before this
614 // The rect where this view should be initially shown.
615 gfx::Rect initial_rect_
;
619 // We store the current cursor object so we can avoid spamming SetCursor
621 WebCursor current_cursor_
;
623 // The size of the RenderWidget.
626 // The size of the view's backing surface in non-DPI-adjusted pixels.
627 gfx::Size physical_backing_size_
;
629 // Whether or not Blink's viewport size should be shrunk by the height of the
630 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
631 bool top_controls_shrink_blink_size_
;
633 // The height of the top controls (always 0 on platforms where URL-bar hiding
635 float top_controls_height_
;
637 // The size of the visible viewport in DPI-adjusted pixels.
638 gfx::Size visible_viewport_size_
;
640 // The area that must be reserved for drawing the resize corner.
641 gfx::Rect resizer_rect_
;
643 // Flags for the next ViewHostMsg_UpdateRect message.
644 int next_paint_flags_
;
646 // Whether the WebWidget is in auto resize mode, which is used for example
647 // by extension popups.
648 bool auto_resize_mode_
;
650 // True if we need to send an UpdateRect message to notify the browser about
651 // an already-completed auto-resize.
652 bool need_update_rect_for_auto_resize_
;
654 // Set to true if we should ignore RenderWidget::Show calls.
657 // Indicates that we shouldn't bother generated paint events.
660 // Indicates that we are never visible, so never produce graphical output.
663 // Indicates whether tab-initiated fullscreen was granted.
664 bool is_fullscreen_granted_
;
666 // Indicates the display mode.
667 blink::WebDisplayMode display_mode_
;
669 // Indicates whether we have been focused/unfocused by the browser.
672 // Are we currently handling an input event?
673 bool handling_input_event_
;
675 // Are we currently handling an ime event?
676 bool handling_ime_event_
;
678 // Type of the input event we are currently handling.
679 blink::WebInputEvent::Type handling_event_type_
;
681 // Whether we should not send ack for the current mouse move.
682 bool ignore_ack_for_mouse_move_from_debugger_
;
684 // True if we have requested this widget be closed. No more messages will
685 // be sent, except for a Close.
688 // True if it is known that the host is in the process of being shut down.
691 // Whether this RenderWidget is currently swapped out, such that the view is
692 // being rendered by another process. If all RenderWidgets in a process are
693 // swapped out, the process can exit.
694 bool is_swapped_out_
;
696 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
697 // OOPIF(crbug.com/471411).
698 // Whether this RenderWidget is for an out-of-process iframe or not.
701 // Indicates if an input method is active in the browser process.
702 bool input_method_is_active_
;
704 // Stores information about the current text input.
705 blink::WebTextInputInfo text_input_info_
;
707 // Stores the current text input type of |webwidget_|.
708 ui::TextInputType text_input_type_
;
710 // Stores the current text input mode of |webwidget_|.
711 ui::TextInputMode text_input_mode_
;
713 // Stores the current text input flags of |webwidget_|.
714 int text_input_flags_
;
716 // Stores the current type of composition text rendering of |webwidget_|.
717 bool can_compose_inline_
;
719 // Stores the current selection bounds.
720 gfx::Rect selection_focus_rect_
;
721 gfx::Rect selection_anchor_rect_
;
723 // Stores the current composition character bounds.
724 std::vector
<gfx::Rect
> composition_character_bounds_
;
726 // Stores the current composition range.
727 gfx::Range composition_range_
;
729 // The kind of popup this widget represents, NONE if not a popup.
730 blink::WebPopupType popup_type_
;
732 // Holds all the needed plugin window moves for a scroll.
733 typedef std::vector
<WebPluginGeometry
> WebPluginGeometryVector
;
734 WebPluginGeometryVector plugin_window_moves_
;
736 // While we are waiting for the browser to update window sizes, we track the
737 // pending size temporarily.
738 int pending_window_rect_count_
;
739 blink::WebRect pending_window_rect_
;
741 // The screen rects of the view and the window that contains it.
742 gfx::Rect view_screen_rect_
;
743 gfx::Rect window_screen_rect_
;
745 scoped_ptr
<IPC::Message
> pending_input_event_ack_
;
747 // The time spent in input handlers this frame. Used to throttle input acks.
748 base::TimeDelta total_input_handling_time_this_frame_
;
750 // Indicates if the next sequence of Char events should be suppressed or not.
751 bool suppress_next_char_events_
;
753 // Properties of the screen hosting this RenderWidget instance.
754 blink::WebScreenInfo screen_info_
;
756 // The device scale factor. This value is computed from the DPI entries in
757 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
758 float device_scale_factor_
;
760 // The device color profile on supported platforms.
761 std::vector
<char> device_color_profile_
;
763 // State associated with synthetic gestures. Synthetic gestures are processed
764 // in-order, so a queue is sufficient to identify the correct state for a
765 // completed gesture.
766 std::queue
<SyntheticGestureCompletionCallback
>
767 pending_synthetic_gesture_callbacks_
;
769 const ui::LatencyInfo
* current_event_latency_info_
;
771 uint32 next_output_surface_id_
;
773 #if defined(OS_ANDROID)
774 // Indicates value in the focused text field is in dirty state, i.e. modified
775 // by script etc., not by user input.
776 bool text_field_is_dirty_
;
778 // A counter for number of outstanding messages from the renderer to the
779 // browser regarding IME-type events that have not been acknowledged by the
780 // browser. If this value is not 0 IME events will be dropped.
781 int outstanding_ime_acks_
;
783 // The background color of the document body element. This is used as the
784 // default background color for filling the screen areas for which we don't
785 // have the actual content.
786 SkColor body_background_color_
;
789 scoped_ptr
<ScreenMetricsEmulator
> screen_metrics_emulator_
;
791 // Popups may be displaced when screen metrics emulation is enabled.
792 // These values are used to properly adjust popup position.
793 gfx::PointF popup_view_origin_for_emulation_
;
794 gfx::PointF popup_screen_origin_for_emulation_
;
795 float popup_origin_scale_for_emulation_
;
797 scoped_refptr
<FrameSwapMessageQueue
> frame_swap_message_queue_
;
798 scoped_ptr
<ResizingModeSelector
> resizing_mode_selector_
;
800 // Lists of RenderFrameProxy objects that need to be notified of
801 // compositing-related events (e.g. DidCommitCompositorFrame).
802 ObserverList
<RenderFrameProxy
> render_frame_proxies_
;
803 #if defined(VIDEO_HOLE)
804 ObserverList
<RenderFrameImpl
> video_hole_frames_
;
805 #endif // defined(VIDEO_HOLE)
807 // A list of RenderFrames associated with this RenderWidget. Notifications
808 // are sent to each frame in the list for events such as changing
809 // visibility state for example.
810 ObserverList
<RenderFrameImpl
> render_frames_
;
812 ui::MenuSourceType context_menu_source_type_
;
813 bool has_host_context_menu_location_
;
814 gfx::Point host_context_menu_location_
;
816 DISALLOW_COPY_AND_ASSIGN(RenderWidget
);
819 } // namespace content
821 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_