Update UnusedResources lint suppressions.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob92a0f387f119804f52f04ef666589fb1036323d1
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/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;
51 namespace IPC {
52 class SyncMessage;
53 class SyncMessageFilter;
56 namespace blink {
57 struct WebDeviceEmulationParams;
58 class WebFrameWidget;
59 class WebGestureEvent;
60 class WebKeyboardEvent;
61 class WebLocalFrame;
62 class WebMouseEvent;
63 class WebNode;
64 struct WebPoint;
65 class WebTouchEvent;
66 class WebView;
69 namespace cc {
70 struct InputHandlerScrollResult;
71 class OutputSurface;
72 class SwapPromise;
75 namespace gfx {
76 class Range;
79 namespace content {
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 DidOverscrollParams;
91 struct WebPluginGeometry;
93 // RenderWidget provides a communication bridge between a WebWidget and
94 // a RenderWidgetHost, the latter of which lives in a different process.
95 class CONTENT_EXPORT RenderWidget
96 : public IPC::Listener,
97 public IPC::Sender,
98 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
99 public base::RefCounted<RenderWidget> {
100 public:
101 // Creates a new RenderWidget. The opener_id is the routing ID of the
102 // RenderView that this widget lives inside.
103 static RenderWidget* Create(int32 opener_id,
104 CompositorDependencies* compositor_deps,
105 blink::WebPopupType popup_type,
106 const blink::WebScreenInfo& screen_info);
108 // Creates a new RenderWidget that will be attached to a RenderFrame.
109 static RenderWidget* CreateForFrame(int routing_id,
110 int surface_id,
111 bool hidden,
112 const blink::WebScreenInfo& screen_info,
113 CompositorDependencies* compositor_deps,
114 blink::WebLocalFrame* frame);
116 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
117 blink::WebLocalFrame* frame);
119 // Creates a WebWidget based on the popup type.
120 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
122 int32 routing_id() const { return routing_id_; }
123 int32 surface_id() const { return surface_id_; }
124 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
125 blink::WebWidget* webwidget() const { return webwidget_; }
126 gfx::Size size() const { return size_; }
127 bool has_focus() const { return has_focus_; }
128 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
129 blink::WebDisplayMode display_mode() const { return display_mode_; }
130 bool is_hidden() const { return is_hidden_; }
131 bool handling_input_event() const { return handling_input_event_; }
132 // Temporary for debugging purposes...
133 bool closing() const { return closing_; }
134 bool is_swapped_out() { return is_swapped_out_; }
135 bool for_oopif() { return for_oopif_; }
136 ui::MenuSourceType context_menu_source_type() {
137 return context_menu_source_type_;
139 bool has_host_context_menu_location() {
140 return has_host_context_menu_location_;
142 gfx::Point host_context_menu_location() {
143 return host_context_menu_location_;
146 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
147 blink::WebScreenInfo screen_info() const { return screen_info_; }
149 // Functions to track out-of-process frames for special notifications.
150 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
151 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
153 // Functions to track all RenderFrame objects associated with this
154 // RenderWidget.
155 void RegisterRenderFrame(RenderFrameImpl* frame);
156 void UnregisterRenderFrame(RenderFrameImpl* frame);
158 #if defined(VIDEO_HOLE)
159 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
160 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
161 #endif // defined(VIDEO_HOLE)
163 // IPC::Listener
164 bool OnMessageReceived(const IPC::Message& msg) override;
166 // IPC::Sender
167 bool Send(IPC::Message* msg) override;
169 // blink::WebWidgetClient
170 virtual void didAutoResize(const blink::WebSize& new_size);
171 virtual void initializeLayerTreeView();
172 virtual blink::WebLayerTreeView* layerTreeView();
173 virtual void didFocus();
174 virtual void didBlur();
175 virtual void didChangeCursor(const blink::WebCursorInfo&);
176 virtual void closeWidgetSoon();
177 virtual void show(blink::WebNavigationPolicy);
178 virtual blink::WebRect windowRect();
179 virtual void setToolTipText(const blink::WebString& text,
180 blink::WebTextDirection hint);
181 virtual void setWindowRect(const blink::WebRect&);
182 virtual blink::WebRect windowResizerRect();
183 virtual blink::WebRect rootWindowRect();
184 virtual blink::WebScreenInfo screenInfo();
185 virtual float deviceScaleFactor();
186 virtual void resetInputMethod();
187 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
188 bool event_cancelled);
189 virtual void didOverscroll(
190 const blink::WebFloatSize& unusedDelta,
191 const blink::WebFloatSize& accumulatedRootOverScroll,
192 const blink::WebFloatPoint& position,
193 const blink::WebFloatSize& velocity);
194 virtual void showImeIfNeeded();
196 #if defined(OS_ANDROID)
197 // Notifies that a tap was not consumed, so showing a UI for the unhandled
198 // tap may be needed.
199 // Performs various checks on the given WebNode to apply heuristics to
200 // determine if triggering is appropriate.
201 virtual void showUnhandledTapUIIfNeeded(
202 const blink::WebPoint& tapped_position,
203 const blink::WebNode& tapped_node,
204 bool page_changed) override;
205 #endif
207 // Begins the compositor's scheduler to start producing frames.
208 void StartCompositor();
210 // Stop compositing.
211 void WillCloseLayerTreeView();
213 // Called when a plugin is moved. These events are queued up and sent with
214 // the next paint or scroll message to the host.
215 void SchedulePluginMove(const WebPluginGeometry& move);
217 // Called when a plugin window has been destroyed, to make sure the currently
218 // pending moves don't try to reference it.
219 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
221 RenderWidgetCompositor* compositor() const;
223 const ui::LatencyInfo* current_event_latency_info() const {
224 return current_event_latency_info_;
227 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
229 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
230 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
232 // Send a synthetic gesture to the browser to be queued to the synthetic
233 // gesture controller.
234 void QueueSyntheticGesture(
235 scoped_ptr<SyntheticGestureParams> gesture_params,
236 const SyntheticGestureCompletionCallback& callback);
238 // Close the underlying WebWidget.
239 virtual void Close();
241 // Deliveres |message| together with compositor state change updates. The
242 // exact behavior depends on |policy|.
243 // This mechanism is not a drop-in replacement for IPC: messages sent this way
244 // will not be automatically available to BrowserMessageFilter, for example.
245 // FIFO ordering is preserved between messages enqueued with the same
246 // |policy|, the ordering between messages enqueued for different policies is
247 // undefined.
249 // |msg| message to send, ownership of |msg| is transferred.
250 // |policy| see the comment on MessageDeliveryPolicy.
251 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
253 // Handle common setup/teardown for handling IME events.
254 void StartHandlingImeEvent();
255 void FinishHandlingImeEvent();
257 // Returns whether we currently should handle an IME event.
258 bool ShouldHandleImeEvent();
260 // Called by the compositor when page scale animation completed.
261 virtual void DidCompletePageScaleAnimation() {}
263 // When paused in debugger, we send ack for mouse event early. This ensures
264 // that we continue receiving mouse moves and pass them to debugger. Returns
265 // whether we are paused in mouse move event and have sent the ack.
266 bool SendAckForMouseMoveFromDebugger();
268 // When resumed from pause in debugger while handling mouse move,
269 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
270 void IgnoreAckForMouseMoveFromDebugger();
272 // ScreenMetricsEmulator class manages screen emulation inside a render
273 // widget. This includes resizing, placing view on the screen at desired
274 // position, changing device scale factor, and scaling down the whole
275 // widget if required to fit into the browser window.
276 class ScreenMetricsEmulator;
278 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
279 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
281 // Indicates that the compositor is about to begin a frame. This is primarily
282 // to signal to flow control mechanisms that a frame is beginning, not to
283 // perform actual painting work.
284 void WillBeginCompositorFrame();
286 // Notifies about a compositor frame commit operation having finished.
287 virtual void DidCommitCompositorFrame();
289 // Notifies that the draw commands for a committed frame have been issued.
290 void DidCommitAndDrawCompositorFrame();
292 // Notifies that the compositor has posted a swapbuffers operation to the GPU
293 // process.
294 void DidCompleteSwapBuffers();
296 void ScheduleComposite();
297 void ScheduleCompositeWithForcedRedraw();
299 // Called by the compositor in single-threaded mode when a swap is posted,
300 // completes or is aborted.
301 void OnSwapBuffersPosted();
302 void OnSwapBuffersComplete();
303 void OnSwapBuffersAborted();
305 // Checks if the text input state and compose inline mode have been changed.
306 // If they are changed, the new value will be sent to the browser process.
307 void UpdateTextInputType();
309 // Checks if the selection bounds have been changed. If they are changed,
310 // the new value will be sent to the browser process.
311 void UpdateSelectionBounds();
313 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
315 void OnShowHostContextMenu(ContextMenuParams* params);
317 #if defined(OS_ANDROID) || defined(USE_AURA)
318 enum ShowIme {
319 SHOW_IME_IF_NEEDED,
320 NO_SHOW_IME,
323 enum ChangeSource {
324 FROM_NON_IME,
325 FROM_IME,
328 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
329 // be displayed, e.g. after a tap on an input field on mobile.
330 // |change_source| should be FROM_NON_IME when the renderer has to wait for
331 // the browser to acknowledge the change before the renderer handles any more
332 // IME events. This is when the text change did not originate from the IME in
333 // the browser side, such as changes by JavaScript or autofill.
334 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
335 #endif
337 // Called when animations due to focus change have completed (if any). Can be
338 // called from the renderer, browser, or compositor.
339 virtual void FocusChangeComplete() {}
341 // Checks if the composition range or composition character bounds have been
342 // changed. If they are changed, the new value will be sent to the browser
343 // process. This method does nothing when the browser process is not able to
344 // handle composition range and composition character bounds.
345 void UpdateCompositionInfo(bool should_update_range);
347 #if defined(OS_ANDROID)
348 void DidChangeBodyBackgroundColor(SkColor bg_color);
349 bool DoesRecordFullLayer() const;
350 #endif
352 bool host_closing() const { return host_closing_; }
354 protected:
355 // Friend RefCounted so that the dtor can be non-public. Using this class
356 // without ref-counting is an error.
357 friend class base::RefCounted<RenderWidget>;
358 // For unit tests.
359 friend class RenderWidgetTest;
361 enum ResizeAck {
362 SEND_RESIZE_ACK,
363 NO_RESIZE_ACK,
366 RenderWidget(blink::WebPopupType popup_type,
367 const blink::WebScreenInfo& screen_info,
368 bool swapped_out,
369 bool hidden,
370 bool never_visible);
372 ~RenderWidget() override;
374 // Initializes this view with the given opener. CompleteInit must be called
375 // later.
376 bool Init(int32 opener_id, CompositorDependencies* compositor_deps);
378 // Called by Init and subclasses to perform initialization.
379 bool DoInit(int32 opener_id,
380 CompositorDependencies* compositor_deps,
381 blink::WebWidget* web_widget,
382 IPC::SyncMessage* create_widget_message);
384 // Finishes creation of a pending view started with Init.
385 void CompleteInit();
387 // Sets whether this RenderWidget has been swapped out to be displayed by
388 // a RenderWidget in a different process. If so, no new IPC messages will be
389 // sent (only ACKs) and the process is free to exit when there are no other
390 // active RenderWidgets.
391 void SetSwappedOut(bool is_swapped_out);
393 // Allows the process to exit once the unload handler has finished, if there
394 // are no other active RenderWidgets.
395 void WasSwappedOut();
397 void FlushPendingInputEventAck();
398 void DoDeferredClose();
399 void DoDeferredSetWindowRect(const blink::WebRect& pos);
400 void NotifyOnClose();
402 // Resizes the render widget.
403 void Resize(const gfx::Size& new_size,
404 const gfx::Size& physical_backing_size,
405 bool top_controls_shrink_blink_size,
406 float top_controls_height,
407 const gfx::Size& visible_viewport_size,
408 const gfx::Rect& resizer_rect,
409 bool is_fullscreen_granted,
410 blink::WebDisplayMode display_mode,
411 ResizeAck resize_ack);
412 // Used to force the size of a window when running layout tests.
413 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
414 virtual void SetScreenMetricsEmulationParameters(
415 bool enabled,
416 const blink::WebDeviceEmulationParams& params);
417 #if defined(OS_MACOSX) || defined(OS_ANDROID)
418 void SetExternalPopupOriginAdjustmentsForEmulation(
419 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
420 #endif
422 // RenderWidget IPC message handlers
423 void OnHandleInputEvent(const blink::WebInputEvent* event,
424 const ui::LatencyInfo& latency_info,
425 bool keyboard_shortcut);
426 void OnCursorVisibilityChange(bool is_visible);
427 void OnMouseCaptureLost();
428 virtual void OnSetFocus(bool enable);
429 void OnClose();
430 void OnCreatingNewAck();
431 virtual void OnResize(const ViewMsg_Resize_Params& params);
432 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
433 void OnDisableDeviceEmulation();
434 void OnColorProfile(const std::vector<char>& color_profile);
435 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
436 virtual void OnWasHidden();
437 virtual void OnWasShown(bool needs_repainting,
438 const ui::LatencyInfo& latency_info);
439 void OnCreateVideoAck(int32 video_id);
440 void OnUpdateVideoAck(int32 video_id);
441 void OnRequestMoveAck();
442 void OnSetInputMethodActive(bool is_active);
443 virtual void OnImeSetComposition(
444 const base::string16& text,
445 const std::vector<blink::WebCompositionUnderline>& underlines,
446 int selection_start,
447 int selection_end);
448 virtual void OnImeConfirmComposition(const base::string16& text,
449 const gfx::Range& replacement_range,
450 bool keep_selection);
451 void OnRepaint(gfx::Size size_to_paint);
452 void OnSyntheticGestureCompleted();
453 void OnSetTextDirection(blink::WebTextDirection direction);
454 void OnGetFPS();
455 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
456 const gfx::Rect& window_screen_rect);
457 void OnShowImeIfNeeded();
458 void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace);
460 #if defined(OS_ANDROID)
461 // Whenever an IME event that needs an acknowledgement is sent to the browser,
462 // the number of outstanding IME events that needs acknowledgement should be
463 // incremented. All IME events will be dropped until we receive an ack from
464 // the browser.
465 void IncrementOutstandingImeEventAcks();
467 // Called by the browser process for every required IME acknowledgement.
468 void OnImeEventAck();
469 #endif
471 // Notify the compositor about a change in viewport size. This should be
472 // used only with auto resize mode WebWidgets, as normal WebWidgets should
473 // go through OnResize.
474 void AutoResizeCompositor();
476 virtual void SetDeviceScaleFactor(float device_scale_factor);
477 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
478 virtual void ResetDeviceColorProfileForTesting();
480 virtual void OnOrientationChange();
482 // Override points to notify derived classes that a paint has happened.
483 // DidInitiatePaint happens when that has completed, and subsequent rendering
484 // won't affect the painted content. DidFlushPaint happens once we've received
485 // the ACK that the screen has been updated. For a given paint operation,
486 // these overrides will always be called in the order DidInitiatePaint,
487 // DidFlushPaint.
488 virtual void DidInitiatePaint() {}
489 virtual void DidFlushPaint() {}
491 virtual GURL GetURLForGraphicsContext3D();
493 // Gets the scroll offset of this widget, if this widget has a notion of
494 // scroll offset.
495 virtual gfx::Vector2d GetScrollOffset();
497 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
498 // use this method so that we can properly inform the RenderThread of our
499 // state.
500 void SetHidden(bool hidden);
502 void WillToggleFullscreen();
503 void DidToggleFullscreen();
505 bool next_paint_is_resize_ack() const;
506 void set_next_paint_is_resize_ack();
507 void set_next_paint_is_repaint_ack();
509 // QueueMessage implementation extracted into a static method for easy
510 // testing.
511 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
512 IPC::Message* msg,
513 MessageDeliveryPolicy policy,
514 FrameSwapMessageQueue* frame_swap_message_queue,
515 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
516 int source_frame_number);
518 // Override point to obtain that the current input method state and caret
519 // position.
520 virtual ui::TextInputType GetTextInputType();
521 virtual ui::TextInputType WebKitToUiTextInputType(
522 blink::WebTextInputType type);
524 // Override point to obtain that the current composition character bounds.
525 // In the case of surrogate pairs, the character is treated as two characters:
526 // the bounds for first character is actual one, and the bounds for second
527 // character is zero width rectangle.
528 virtual void GetCompositionCharacterBounds(
529 std::vector<gfx::Rect>* character_bounds);
531 // Returns the range of the text that is being composed or the selection if
532 // the composition does not exist.
533 virtual void GetCompositionRange(gfx::Range* range);
535 // Returns true if the composition range or composition character bounds
536 // should be sent to the browser process.
537 bool ShouldUpdateCompositionInfo(
538 const gfx::Range& range,
539 const std::vector<gfx::Rect>& bounds);
541 // Override point to obtain that the current input method state about
542 // composition text.
543 virtual bool CanComposeInline();
545 // Tells the renderer it does not have focus. Used to prevent us from getting
546 // the focus on our own when the browser did not focus us.
547 void ClearFocus();
549 // Set the pending window rect.
550 // Because the real render_widget is hosted in another process, there is
551 // a time period where we may have set a new window rect which has not yet
552 // been processed by the browser. So we maintain a pending window rect
553 // size. If JS code sets the WindowRect, and then immediately calls
554 // GetWindowRect() we'll use this pending window rect as the size.
555 void SetPendingWindowRect(const blink::WebRect& r);
557 // Called by OnHandleInputEvent() to notify subclasses that a key event was
558 // just handled.
559 virtual void DidHandleKeyEvent() {}
561 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
562 // about to be handled.
563 // Returns true if no further handling is needed. In that case, the event
564 // won't be sent to WebKit or trigger DidHandleMouseEvent().
565 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
567 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
568 // about to be handled.
569 // Returns true if no further handling is needed. In that case, the event
570 // won't be sent to WebKit.
571 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
573 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
574 // compositor thread, to effect the elastic overscroll effect.
575 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
576 bool event_processed);
578 // Check whether the WebWidget has any touch event handlers registered
579 // at the given point.
580 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
582 // Check whether the WebWidget has any touch event handlers registered.
583 virtual void hasTouchEventHandlers(bool has_handlers);
585 // Tell the browser about the actions permitted for a new touch point.
586 virtual void setTouchAction(blink::WebTouchAction touch_action);
588 // Called when value of focused text field gets dirty, e.g. value is modified
589 // by script, not by user input.
590 virtual void didUpdateTextOfFocusedElementByNonUserInput();
592 // Creates a 3D context associated with this view.
593 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
595 // Routing ID that allows us to communicate to the parent browser process
596 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
597 int32 routing_id_;
599 int32 surface_id_;
601 // Dependencies for initializing a compositor, including flags for optional
602 // features.
603 CompositorDependencies* compositor_deps_;
605 // We are responsible for destroying this object via its Close method.
606 // May be NULL when the window is closing.
607 blink::WebWidget* webwidget_;
609 // This is lazily constructed and must not outlive webwidget_.
610 scoped_ptr<RenderWidgetCompositor> compositor_;
612 // Set to the ID of the view that initiated creating this view, if any. When
613 // the view was initiated by the browser (the common case), this will be
614 // MSG_ROUTING_NONE. This is used in determining ownership when opening
615 // child tabs. See RenderWidget::createWebViewWithRequest.
617 // This ID may refer to an invalid view if that view is closed before this
618 // view is.
619 int32 opener_id_;
621 // The rect where this view should be initially shown.
622 gfx::Rect initial_rect_;
624 bool init_complete_;
626 // We store the current cursor object so we can avoid spamming SetCursor
627 // messages.
628 WebCursor current_cursor_;
630 // The size of the RenderWidget.
631 gfx::Size size_;
633 // The size of the view's backing surface in non-DPI-adjusted pixels.
634 gfx::Size physical_backing_size_;
636 // Whether or not Blink's viewport size should be shrunk by the height of the
637 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
638 bool top_controls_shrink_blink_size_;
640 // The height of the top controls (always 0 on platforms where URL-bar hiding
641 // isn't supported).
642 float top_controls_height_;
644 // The size of the visible viewport in DPI-adjusted pixels.
645 gfx::Size visible_viewport_size_;
647 // The area that must be reserved for drawing the resize corner.
648 gfx::Rect resizer_rect_;
650 // Flags for the next ViewHostMsg_UpdateRect message.
651 int next_paint_flags_;
653 // Whether the WebWidget is in auto resize mode, which is used for example
654 // by extension popups.
655 bool auto_resize_mode_;
657 // True if we need to send an UpdateRect message to notify the browser about
658 // an already-completed auto-resize.
659 bool need_update_rect_for_auto_resize_;
661 // Set to true if we should ignore RenderWidget::Show calls.
662 bool did_show_;
664 // Indicates that we shouldn't bother generated paint events.
665 bool is_hidden_;
667 // Indicates that we are never visible, so never produce graphical output.
668 bool never_visible_;
670 // Indicates whether tab-initiated fullscreen was granted.
671 bool is_fullscreen_granted_;
673 // Indicates the display mode.
674 blink::WebDisplayMode display_mode_;
676 // Indicates whether we have been focused/unfocused by the browser.
677 bool has_focus_;
679 // Are we currently handling an input event?
680 bool handling_input_event_;
682 // Used to intercept overscroll notifications while an event is being
683 // handled. If the event causes overscroll, the overscroll metadata can be
684 // bundled in the event ack, saving an IPC. Note that we must continue
685 // supporting overscroll IPC notifications due to fling animation updates.
686 scoped_ptr<DidOverscrollParams>* handling_event_overscroll_;
688 // Are we currently handling an ime event?
689 bool handling_ime_event_;
691 // Type of the input event we are currently handling.
692 blink::WebInputEvent::Type handling_event_type_;
694 // Whether we should not send ack for the current mouse move.
695 bool ignore_ack_for_mouse_move_from_debugger_;
697 // True if we have requested this widget be closed. No more messages will
698 // be sent, except for a Close.
699 bool closing_;
701 // True if it is known that the host is in the process of being shut down.
702 bool host_closing_;
704 // Whether this RenderWidget is currently swapped out, such that the view is
705 // being rendered by another process. If all RenderWidgets in a process are
706 // swapped out, the process can exit.
707 bool is_swapped_out_;
709 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
710 // OOPIF(crbug.com/471411).
711 // Whether this RenderWidget is for an out-of-process iframe or not.
712 bool for_oopif_;
714 // Indicates if an input method is active in the browser process.
715 bool input_method_is_active_;
717 // Stores information about the current text input.
718 blink::WebTextInputInfo text_input_info_;
720 // Stores the current text input type of |webwidget_|.
721 ui::TextInputType text_input_type_;
723 // Stores the current text input mode of |webwidget_|.
724 ui::TextInputMode text_input_mode_;
726 // Stores the current text input flags of |webwidget_|.
727 int text_input_flags_;
729 // Stores the current type of composition text rendering of |webwidget_|.
730 bool can_compose_inline_;
732 // Stores the current selection bounds.
733 gfx::Rect selection_focus_rect_;
734 gfx::Rect selection_anchor_rect_;
736 // Stores the current composition character bounds.
737 std::vector<gfx::Rect> composition_character_bounds_;
739 // Stores the current composition range.
740 gfx::Range composition_range_;
742 // The kind of popup this widget represents, NONE if not a popup.
743 blink::WebPopupType popup_type_;
745 // Holds all the needed plugin window moves for a scroll.
746 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
747 WebPluginGeometryVector plugin_window_moves_;
749 // While we are waiting for the browser to update window sizes, we track the
750 // pending size temporarily.
751 int pending_window_rect_count_;
752 blink::WebRect pending_window_rect_;
754 // The screen rects of the view and the window that contains it.
755 gfx::Rect view_screen_rect_;
756 gfx::Rect window_screen_rect_;
758 scoped_ptr<IPC::Message> pending_input_event_ack_;
760 // The time spent in input handlers this frame. Used to throttle input acks.
761 base::TimeDelta total_input_handling_time_this_frame_;
763 // Indicates if the next sequence of Char events should be suppressed or not.
764 bool suppress_next_char_events_;
766 // Properties of the screen hosting this RenderWidget instance.
767 blink::WebScreenInfo screen_info_;
769 // The device scale factor. This value is computed from the DPI entries in
770 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
771 float device_scale_factor_;
773 // The device color profile on supported platforms.
774 std::vector<char> device_color_profile_;
776 // State associated with synthetic gestures. Synthetic gestures are processed
777 // in-order, so a queue is sufficient to identify the correct state for a
778 // completed gesture.
779 std::queue<SyntheticGestureCompletionCallback>
780 pending_synthetic_gesture_callbacks_;
782 const ui::LatencyInfo* current_event_latency_info_;
784 uint32 next_output_surface_id_;
786 #if defined(OS_ANDROID)
787 // Indicates value in the focused text field is in dirty state, i.e. modified
788 // by script etc., not by user input.
789 bool text_field_is_dirty_;
791 // A counter for number of outstanding messages from the renderer to the
792 // browser regarding IME-type events that have not been acknowledged by the
793 // browser. If this value is not 0 IME events will be dropped.
794 int outstanding_ime_acks_;
796 // The background color of the document body element. This is used as the
797 // default background color for filling the screen areas for which we don't
798 // have the actual content.
799 SkColor body_background_color_;
800 #endif
802 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
804 // Popups may be displaced when screen metrics emulation is enabled.
805 // These values are used to properly adjust popup position.
806 gfx::PointF popup_view_origin_for_emulation_;
807 gfx::PointF popup_screen_origin_for_emulation_;
808 float popup_origin_scale_for_emulation_;
810 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
811 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
813 // Lists of RenderFrameProxy objects that need to be notified of
814 // compositing-related events (e.g. DidCommitCompositorFrame).
815 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
816 #if defined(VIDEO_HOLE)
817 base::ObserverList<RenderFrameImpl> video_hole_frames_;
818 #endif // defined(VIDEO_HOLE)
820 // A list of RenderFrames associated with this RenderWidget. Notifications
821 // are sent to each frame in the list for events such as changing
822 // visibility state for example.
823 base::ObserverList<RenderFrameImpl> render_frames_;
825 ui::MenuSourceType context_menu_source_type_;
826 bool has_host_context_menu_location_;
827 gfx::Point host_context_menu_location_;
829 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
832 } // namespace content
834 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_