Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob45570832b684139b11465f57c68136879576478c
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.
96 // RenderWidget is used to implement:
97 // - RenderViewImpl (deprecated)
98 // - Fullscreen mode (RenderWidgetFullScreen)
99 // - Popup "menus" (like the color chooser and date picker)
100 // - Widgets for frames (for out-of-process iframe support)
101 class CONTENT_EXPORT RenderWidget
102 : public IPC::Listener,
103 public IPC::Sender,
104 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
105 public base::RefCounted<RenderWidget> {
106 public:
107 // Creates a new RenderWidget. The opener_id is the routing ID of the
108 // RenderView that this widget lives inside.
109 static RenderWidget* Create(int32 opener_id,
110 CompositorDependencies* compositor_deps,
111 blink::WebPopupType popup_type,
112 const blink::WebScreenInfo& screen_info);
114 // Creates a new RenderWidget that will be attached to a RenderFrame.
115 static RenderWidget* CreateForFrame(int routing_id,
116 int surface_id,
117 bool hidden,
118 const blink::WebScreenInfo& screen_info,
119 CompositorDependencies* compositor_deps,
120 blink::WebLocalFrame* frame);
122 // Closes a RenderWidget that was created by |CreateForFrame|.
123 void CloseForFrame();
125 int32 routing_id() const { return routing_id_; }
126 int32 surface_id() const { return surface_id_; }
127 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
128 blink::WebWidget* webwidget() const { return webwidget_; }
129 gfx::Size size() const { return size_; }
130 bool has_focus() const { return has_focus_; }
131 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
132 blink::WebDisplayMode display_mode() const { return display_mode_; }
133 bool is_hidden() const { return is_hidden_; }
134 bool handling_input_event() const { return handling_input_event_; }
135 // Temporary for debugging purposes...
136 bool closing() const { return closing_; }
137 bool is_swapped_out() { return is_swapped_out_; }
138 bool for_oopif() { return for_oopif_; }
139 ui::MenuSourceType context_menu_source_type() {
140 return context_menu_source_type_;
142 bool has_host_context_menu_location() {
143 return has_host_context_menu_location_;
145 gfx::Point host_context_menu_location() {
146 return host_context_menu_location_;
149 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
150 blink::WebScreenInfo screen_info() const { return screen_info_; }
152 // Functions to track out-of-process frames for special notifications.
153 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
154 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
156 // Functions to track all RenderFrame objects associated with this
157 // RenderWidget.
158 void RegisterRenderFrame(RenderFrameImpl* frame);
159 void UnregisterRenderFrame(RenderFrameImpl* frame);
161 #if defined(VIDEO_HOLE)
162 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
163 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
164 #endif // defined(VIDEO_HOLE)
166 // IPC::Listener
167 bool OnMessageReceived(const IPC::Message& msg) override;
169 // IPC::Sender
170 bool Send(IPC::Message* msg) override;
172 // blink::WebWidgetClient
173 virtual void didAutoResize(const blink::WebSize& new_size);
174 virtual void initializeLayerTreeView();
175 virtual blink::WebLayerTreeView* layerTreeView();
176 virtual void didFocus();
177 virtual void didBlur();
178 virtual void didChangeCursor(const blink::WebCursorInfo&);
179 virtual void closeWidgetSoon();
180 virtual void show(blink::WebNavigationPolicy);
181 virtual blink::WebRect windowRect();
182 virtual void setToolTipText(const blink::WebString& text,
183 blink::WebTextDirection hint);
184 virtual void setWindowRect(const blink::WebRect&);
185 virtual blink::WebRect windowResizerRect();
186 virtual blink::WebRect rootWindowRect();
187 virtual blink::WebScreenInfo screenInfo();
188 virtual float deviceScaleFactor();
189 virtual void resetInputMethod();
190 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
191 bool event_cancelled);
192 virtual void didOverscroll(
193 const blink::WebFloatSize& unusedDelta,
194 const blink::WebFloatSize& accumulatedRootOverScroll,
195 const blink::WebFloatPoint& position,
196 const blink::WebFloatSize& velocity);
197 virtual void showImeIfNeeded();
199 #if defined(OS_ANDROID)
200 // Notifies that a tap was not consumed, so showing a UI for the unhandled
201 // tap may be needed.
202 // Performs various checks on the given WebNode to apply heuristics to
203 // determine if triggering is appropriate.
204 virtual void showUnhandledTapUIIfNeeded(
205 const blink::WebPoint& tapped_position,
206 const blink::WebNode& tapped_node,
207 bool page_changed) override;
208 #endif
210 // Begins the compositor's scheduler to start producing frames.
211 void StartCompositor();
213 // Stop compositing.
214 void WillCloseLayerTreeView();
216 // Called when a plugin is moved. These events are queued up and sent with
217 // the next paint or scroll message to the host.
218 void SchedulePluginMove(const WebPluginGeometry& move);
220 // Called when a plugin window has been destroyed, to make sure the currently
221 // pending moves don't try to reference it.
222 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
224 RenderWidgetCompositor* compositor() const;
226 const ui::LatencyInfo* current_event_latency_info() const {
227 return current_event_latency_info_;
230 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
232 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
233 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
235 // Send a synthetic gesture to the browser to be queued to the synthetic
236 // gesture controller.
237 void QueueSyntheticGesture(
238 scoped_ptr<SyntheticGestureParams> gesture_params,
239 const SyntheticGestureCompletionCallback& callback);
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(CompositorDependencies* compositor_deps,
367 blink::WebPopupType popup_type,
368 const blink::WebScreenInfo& screen_info,
369 bool swapped_out,
370 bool hidden,
371 bool never_visible);
373 ~RenderWidget() override;
375 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
376 blink::WebLocalFrame* frame);
378 // Creates a WebWidget based on the popup type.
379 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
381 // Initializes this view with the given opener. CompleteInit must be called
382 // later.
383 bool Init(int32 opener_id);
385 // Called by Init and subclasses to perform initialization.
386 bool DoInit(int32 opener_id,
387 blink::WebWidget* web_widget,
388 IPC::SyncMessage* create_widget_message);
390 // Finishes creation of a pending view started with Init.
391 void CompleteInit();
393 // Sets whether this RenderWidget has been swapped out to be displayed by
394 // a RenderWidget in a different process. If so, no new IPC messages will be
395 // sent (only ACKs) and the process is free to exit when there are no other
396 // active RenderWidgets.
397 void SetSwappedOut(bool is_swapped_out);
399 // Allows the process to exit once the unload handler has finished, if there
400 // are no other active RenderWidgets.
401 void WasSwappedOut();
403 void FlushPendingInputEventAck();
404 void DoDeferredClose();
405 void NotifyOnClose();
407 // Close the underlying WebWidget.
408 virtual void Close();
410 // Resizes the render widget.
411 void Resize(const gfx::Size& new_size,
412 const gfx::Size& physical_backing_size,
413 bool top_controls_shrink_blink_size,
414 float top_controls_height,
415 const gfx::Size& visible_viewport_size,
416 const gfx::Rect& resizer_rect,
417 bool is_fullscreen_granted,
418 blink::WebDisplayMode display_mode,
419 ResizeAck resize_ack);
420 // Used to force the size of a window when running layout tests.
421 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
422 virtual void SetScreenMetricsEmulationParameters(
423 bool enabled,
424 const blink::WebDeviceEmulationParams& params);
425 #if defined(OS_MACOSX) || defined(OS_ANDROID)
426 void SetExternalPopupOriginAdjustmentsForEmulation(
427 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
428 #endif
430 // RenderWidget IPC message handlers
431 void OnHandleInputEvent(const blink::WebInputEvent* event,
432 const ui::LatencyInfo& latency_info,
433 bool keyboard_shortcut);
434 void OnCursorVisibilityChange(bool is_visible);
435 void OnMouseCaptureLost();
436 virtual void OnSetFocus(bool enable);
437 void OnClose();
438 void OnCreatingNewAck();
439 virtual void OnResize(const ViewMsg_Resize_Params& params);
440 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
441 void OnDisableDeviceEmulation();
442 void OnColorProfile(const std::vector<char>& color_profile);
443 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
444 virtual void OnWasHidden();
445 virtual void OnWasShown(bool needs_repainting,
446 const ui::LatencyInfo& latency_info);
447 void OnCreateVideoAck(int32 video_id);
448 void OnUpdateVideoAck(int32 video_id);
449 void OnRequestMoveAck();
450 virtual void OnImeSetComposition(
451 const base::string16& text,
452 const std::vector<blink::WebCompositionUnderline>& underlines,
453 int selection_start,
454 int selection_end);
455 virtual void OnImeConfirmComposition(const base::string16& text,
456 const gfx::Range& replacement_range,
457 bool keep_selection);
458 void OnRepaint(gfx::Size size_to_paint);
459 void OnSyntheticGestureCompleted();
460 void OnSetTextDirection(blink::WebTextDirection direction);
461 void OnGetFPS();
462 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
463 const gfx::Rect& window_screen_rect);
464 void OnShowImeIfNeeded();
465 void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace);
467 #if defined(OS_ANDROID)
468 // Whenever an IME event that needs an acknowledgement is sent to the browser,
469 // the number of outstanding IME events that needs acknowledgement should be
470 // incremented. All IME events will be dropped until we receive an ack from
471 // the browser.
472 void IncrementOutstandingImeEventAcks();
474 // Called by the browser process for every required IME acknowledgement.
475 void OnImeEventAck();
476 #endif
478 // Notify the compositor about a change in viewport size. This should be
479 // used only with auto resize mode WebWidgets, as normal WebWidgets should
480 // go through OnResize.
481 void AutoResizeCompositor();
483 virtual void SetDeviceScaleFactor(float device_scale_factor);
484 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
485 virtual void ResetDeviceColorProfileForTesting();
487 virtual void OnOrientationChange();
489 // Override points to notify derived classes that a paint has happened.
490 // DidInitiatePaint happens when that has completed, and subsequent rendering
491 // won't affect the painted content. DidFlushPaint happens once we've received
492 // the ACK that the screen has been updated. For a given paint operation,
493 // these overrides will always be called in the order DidInitiatePaint,
494 // DidFlushPaint.
495 virtual void DidInitiatePaint() {}
496 virtual void DidFlushPaint() {}
498 virtual GURL GetURLForGraphicsContext3D();
500 // Gets the scroll offset of this widget, if this widget has a notion of
501 // scroll offset.
502 virtual gfx::Vector2d GetScrollOffset();
504 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
505 // use this method so that we can properly inform the RenderThread of our
506 // state.
507 void SetHidden(bool hidden);
509 void DidToggleFullscreen();
511 bool next_paint_is_resize_ack() const;
512 void set_next_paint_is_resize_ack();
513 void set_next_paint_is_repaint_ack();
515 // QueueMessage implementation extracted into a static method for easy
516 // testing.
517 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
518 IPC::Message* msg,
519 MessageDeliveryPolicy policy,
520 FrameSwapMessageQueue* frame_swap_message_queue,
521 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
522 int source_frame_number);
524 // Override point to obtain that the current input method state and caret
525 // position.
526 virtual ui::TextInputType GetTextInputType();
527 virtual ui::TextInputType WebKitToUiTextInputType(
528 blink::WebTextInputType type);
530 // Override point to obtain that the current composition character bounds.
531 // In the case of surrogate pairs, the character is treated as two characters:
532 // the bounds for first character is actual one, and the bounds for second
533 // character is zero width rectangle.
534 virtual void GetCompositionCharacterBounds(
535 std::vector<gfx::Rect>* character_bounds);
537 // Returns the range of the text that is being composed or the selection if
538 // the composition does not exist.
539 virtual void GetCompositionRange(gfx::Range* range);
541 // Returns true if the composition range or composition character bounds
542 // should be sent to the browser process.
543 bool ShouldUpdateCompositionInfo(
544 const gfx::Range& range,
545 const std::vector<gfx::Rect>& bounds);
547 // Override point to obtain that the current input method state about
548 // composition text.
549 virtual bool CanComposeInline();
551 // Tells the renderer it does not have focus. Used to prevent us from getting
552 // the focus on our own when the browser did not focus us.
553 void ClearFocus();
555 // Set the pending window rect.
556 // Because the real render_widget is hosted in another process, there is
557 // a time period where we may have set a new window rect which has not yet
558 // been processed by the browser. So we maintain a pending window rect
559 // size. If JS code sets the WindowRect, and then immediately calls
560 // GetWindowRect() we'll use this pending window rect as the size.
561 void SetPendingWindowRect(const blink::WebRect& r);
563 // Called by OnHandleInputEvent() to notify subclasses that a key event was
564 // just handled.
565 virtual void DidHandleKeyEvent() {}
567 // Called by OnHandleInputEvent() to notify subclasses that a mouse 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 or trigger DidHandleMouseEvent().
571 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
573 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
574 // about to be handled.
575 // Returns true if no further handling is needed. In that case, the event
576 // won't be sent to WebKit.
577 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
579 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
580 // compositor thread, to effect the elastic overscroll effect.
581 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
582 const gfx::Vector2dF& wheel_unused_delta,
583 bool event_processed);
585 // Check whether the WebWidget has any touch event handlers registered
586 // at the given point.
587 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
589 // Check whether the WebWidget has any touch event handlers registered.
590 virtual void hasTouchEventHandlers(bool has_handlers);
592 // Tell the browser about the actions permitted for a new touch point.
593 virtual void setTouchAction(blink::WebTouchAction touch_action);
595 // Called when value of focused text field gets dirty, e.g. value is modified
596 // by script, not by user input.
597 virtual void didUpdateTextOfFocusedElementByNonUserInput();
599 // Creates a 3D context associated with this view.
600 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
602 // Routing ID that allows us to communicate to the parent browser process
603 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
604 int32 routing_id_;
606 int32 surface_id_;
608 // Dependencies for initializing a compositor, including flags for optional
609 // features.
610 CompositorDependencies* const compositor_deps_;
612 // We are responsible for destroying this object via its Close method.
613 // May be NULL when the window is closing.
614 blink::WebWidget* webwidget_;
616 // This is lazily constructed and must not outlive webwidget_.
617 scoped_ptr<RenderWidgetCompositor> compositor_;
619 // Set to the ID of the view that initiated creating this view, if any. When
620 // the view was initiated by the browser (the common case), this will be
621 // MSG_ROUTING_NONE. This is used in determining ownership when opening
622 // child tabs. See RenderWidget::createWebViewWithRequest.
624 // This ID may refer to an invalid view if that view is closed before this
625 // view is.
626 int32 opener_id_;
628 // The rect where this view should be initially shown.
629 gfx::Rect initial_rect_;
631 bool init_complete_;
633 // We store the current cursor object so we can avoid spamming SetCursor
634 // messages.
635 WebCursor current_cursor_;
637 // The size of the RenderWidget.
638 gfx::Size size_;
640 // The size of the view's backing surface in non-DPI-adjusted pixels.
641 gfx::Size physical_backing_size_;
643 // Whether or not Blink's viewport size should be shrunk by the height of the
644 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
645 bool top_controls_shrink_blink_size_;
647 // The height of the top controls (always 0 on platforms where URL-bar hiding
648 // isn't supported).
649 float top_controls_height_;
651 // The size of the visible viewport in DPI-adjusted pixels.
652 gfx::Size visible_viewport_size_;
654 // The area that must be reserved for drawing the resize corner.
655 gfx::Rect resizer_rect_;
657 // Flags for the next ViewHostMsg_UpdateRect message.
658 int next_paint_flags_;
660 // Whether the WebWidget is in auto resize mode, which is used for example
661 // by extension popups.
662 bool auto_resize_mode_;
664 // True if we need to send an UpdateRect message to notify the browser about
665 // an already-completed auto-resize.
666 bool need_update_rect_for_auto_resize_;
668 // Set to true if we should ignore RenderWidget::Show calls.
669 bool did_show_;
671 // Indicates that we shouldn't bother generated paint events.
672 bool is_hidden_;
674 // Indicates that we are never visible, so never produce graphical output.
675 bool never_visible_;
677 // Indicates whether tab-initiated fullscreen was granted.
678 bool is_fullscreen_granted_;
680 // Indicates the display mode.
681 blink::WebDisplayMode display_mode_;
683 // Indicates whether we have been focused/unfocused by the browser.
684 bool has_focus_;
686 // Are we currently handling an input event?
687 bool handling_input_event_;
689 // Used to intercept overscroll notifications while an event is being
690 // handled. If the event causes overscroll, the overscroll metadata can be
691 // bundled in the event ack, saving an IPC. Note that we must continue
692 // supporting overscroll IPC notifications due to fling animation updates.
693 scoped_ptr<DidOverscrollParams>* handling_event_overscroll_;
695 // Are we currently handling an ime event?
696 bool handling_ime_event_;
698 // Type of the input event we are currently handling.
699 blink::WebInputEvent::Type handling_event_type_;
701 // Whether we should not send ack for the current mouse move.
702 bool ignore_ack_for_mouse_move_from_debugger_;
704 // True if we have requested this widget be closed. No more messages will
705 // be sent, except for a Close.
706 bool closing_;
708 // True if it is known that the host is in the process of being shut down.
709 bool host_closing_;
711 // Whether this RenderWidget is currently swapped out, such that the view is
712 // being rendered by another process. If all RenderWidgets in a process are
713 // swapped out, the process can exit.
714 bool is_swapped_out_;
716 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
717 // OOPIF(crbug.com/471411).
718 // Whether this RenderWidget is for an out-of-process iframe or not.
719 bool for_oopif_;
721 // Stores information about the current text input.
722 blink::WebTextInputInfo text_input_info_;
724 // Stores the current text input type of |webwidget_|.
725 ui::TextInputType text_input_type_;
727 // Stores the current text input mode of |webwidget_|.
728 ui::TextInputMode text_input_mode_;
730 // Stores the current text input flags of |webwidget_|.
731 int text_input_flags_;
733 // Stores the current type of composition text rendering of |webwidget_|.
734 bool can_compose_inline_;
736 // Stores the current selection bounds.
737 gfx::Rect selection_focus_rect_;
738 gfx::Rect selection_anchor_rect_;
740 // Stores the current composition character bounds.
741 std::vector<gfx::Rect> composition_character_bounds_;
743 // Stores the current composition range.
744 gfx::Range composition_range_;
746 // The kind of popup this widget represents, NONE if not a popup.
747 blink::WebPopupType popup_type_;
749 // Holds all the needed plugin window moves for a scroll.
750 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
751 WebPluginGeometryVector plugin_window_moves_;
753 // While we are waiting for the browser to update window sizes, we track the
754 // pending size temporarily.
755 int pending_window_rect_count_;
756 blink::WebRect pending_window_rect_;
758 // The screen rects of the view and the window that contains it.
759 gfx::Rect view_screen_rect_;
760 gfx::Rect window_screen_rect_;
762 scoped_ptr<IPC::Message> pending_input_event_ack_;
764 // The time spent in input handlers this frame. Used to throttle input acks.
765 base::TimeDelta total_input_handling_time_this_frame_;
767 // Indicates if the next sequence of Char events should be suppressed or not.
768 bool suppress_next_char_events_;
770 // Properties of the screen hosting this RenderWidget instance.
771 blink::WebScreenInfo screen_info_;
773 // The device scale factor. This value is computed from the DPI entries in
774 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
775 float device_scale_factor_;
777 // The device color profile on supported platforms.
778 std::vector<char> device_color_profile_;
780 // State associated with synthetic gestures. Synthetic gestures are processed
781 // in-order, so a queue is sufficient to identify the correct state for a
782 // completed gesture.
783 std::queue<SyntheticGestureCompletionCallback>
784 pending_synthetic_gesture_callbacks_;
786 const ui::LatencyInfo* current_event_latency_info_;
788 uint32 next_output_surface_id_;
790 #if defined(OS_ANDROID)
791 // Indicates value in the focused text field is in dirty state, i.e. modified
792 // by script etc., not by user input.
793 bool text_field_is_dirty_;
795 // A counter for number of outstanding messages from the renderer to the
796 // browser regarding IME-type events that have not been acknowledged by the
797 // browser. If this value is not 0 IME events will be dropped.
798 int outstanding_ime_acks_;
800 // The background color of the document body element. This is used as the
801 // default background color for filling the screen areas for which we don't
802 // have the actual content.
803 SkColor body_background_color_;
804 #endif
806 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
808 // Popups may be displaced when screen metrics emulation is enabled.
809 // These values are used to properly adjust popup position.
810 gfx::PointF popup_view_origin_for_emulation_;
811 gfx::PointF popup_screen_origin_for_emulation_;
812 float popup_origin_scale_for_emulation_;
814 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
815 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
817 // Lists of RenderFrameProxy objects that need to be notified of
818 // compositing-related events (e.g. DidCommitCompositorFrame).
819 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
820 #if defined(VIDEO_HOLE)
821 base::ObserverList<RenderFrameImpl> video_hole_frames_;
822 #endif // defined(VIDEO_HOLE)
824 // A list of RenderFrames associated with this RenderWidget. Notifications
825 // are sent to each frame in the list for events such as changing
826 // visibility state for example.
827 base::ObserverList<RenderFrameImpl> render_frames_;
829 ui::MenuSourceType context_menu_source_type_;
830 bool has_host_context_menu_location_;
831 gfx::Point host_context_menu_location_;
833 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
836 } // namespace content
838 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_