Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blobdca45ed2a7f5e3633a44614c9731778e7098ccc9
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/WebRect.h"
27 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
28 #include "third_party/WebKit/public/web/WebInputEvent.h"
29 #include "third_party/WebKit/public/web/WebPopupType.h"
30 #include "third_party/WebKit/public/web/WebTextDirection.h"
31 #include "third_party/WebKit/public/web/WebTextInputInfo.h"
32 #include "third_party/WebKit/public/web/WebTouchAction.h"
33 #include "third_party/WebKit/public/web/WebWidget.h"
34 #include "third_party/WebKit/public/web/WebWidgetClient.h"
35 #include "third_party/skia/include/core/SkBitmap.h"
36 #include "ui/base/ime/text_input_mode.h"
37 #include "ui/base/ime/text_input_type.h"
38 #include "ui/base/ui_base_types.h"
39 #include "ui/gfx/geometry/rect.h"
40 #include "ui/gfx/geometry/vector2d.h"
41 #include "ui/gfx/geometry/vector2d_f.h"
42 #include "ui/gfx/native_widget_types.h"
43 #include "ui/gfx/range/range.h"
44 #include "ui/surface/transport_dib.h"
46 struct ViewHostMsg_UpdateRect_Params;
47 struct ViewMsg_Resize_Params;
48 class ViewHostMsg_UpdateRect;
50 namespace IPC {
51 class SyncMessage;
52 class SyncMessageFilter;
55 namespace blink {
56 struct WebDeviceEmulationParams;
57 class WebFrameWidget;
58 class WebGestureEvent;
59 class WebKeyboardEvent;
60 class WebLocalFrame;
61 class WebMouseEvent;
62 class WebNode;
63 struct WebPoint;
64 class WebTouchEvent;
65 class WebView;
68 namespace cc {
69 struct InputHandlerScrollResult;
70 class OutputSurface;
71 class SwapPromise;
74 namespace gfx {
75 class Range;
78 namespace content {
79 class CompositorDependencies;
80 class ExternalPopupMenu;
81 class FrameSwapMessageQueue;
82 class PepperPluginInstanceImpl;
83 class RenderFrameImpl;
84 class RenderFrameProxy;
85 class RenderWidgetCompositor;
86 class RenderWidgetTest;
87 class ResizingModeSelector;
88 struct ContextMenuParams;
89 struct WebPluginGeometry;
91 // RenderWidget provides a communication bridge between a WebWidget and
92 // a RenderWidgetHost, the latter of which lives in a different process.
93 class CONTENT_EXPORT RenderWidget
94 : public IPC::Listener,
95 public IPC::Sender,
96 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
97 public base::RefCounted<RenderWidget> {
98 public:
99 // Creates a new RenderWidget. The opener_id is the routing ID of the
100 // RenderView that this widget lives inside.
101 static RenderWidget* Create(int32 opener_id,
102 CompositorDependencies* compositor_deps,
103 blink::WebPopupType popup_type,
104 const blink::WebScreenInfo& screen_info);
106 // Creates a new RenderWidget that will be attached to a RenderFrame.
107 static RenderWidget* CreateForFrame(int routing_id,
108 int surface_id,
109 bool hidden,
110 const blink::WebScreenInfo& screen_info,
111 CompositorDependencies* compositor_deps,
112 blink::WebLocalFrame* frame);
114 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
115 blink::WebLocalFrame* frame);
117 // Creates a WebWidget based on the popup type.
118 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
120 int32 routing_id() const { return routing_id_; }
121 int32 surface_id() const { return surface_id_; }
122 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
123 blink::WebWidget* webwidget() const { return webwidget_; }
124 gfx::Size size() const { return size_; }
125 bool has_focus() const { return has_focus_; }
126 bool is_fullscreen() const { return is_fullscreen_; }
127 bool is_hidden() const { return is_hidden_; }
128 bool handling_input_event() const { return handling_input_event_; }
129 // Temporary for debugging purposes...
130 bool closing() const { return closing_; }
131 bool is_swapped_out() { return is_swapped_out_; }
132 ui::MenuSourceType context_menu_source_type() {
133 return context_menu_source_type_;
135 bool has_host_context_menu_location() {
136 return has_host_context_menu_location_;
138 gfx::Point host_context_menu_location() {
139 return host_context_menu_location_;
142 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
143 blink::WebScreenInfo screen_info() const { return screen_info_; }
145 // Functions to track out-of-process frames for special notifications.
146 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
147 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
149 // Functions to track all RenderFrame objects associated with this
150 // RenderWidget.
151 void RegisterRenderFrame(RenderFrameImpl* frame);
152 void UnregisterRenderFrame(RenderFrameImpl* frame);
154 #if defined(VIDEO_HOLE)
155 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
156 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
157 #endif // defined(VIDEO_HOLE)
159 // IPC::Listener
160 bool OnMessageReceived(const IPC::Message& msg) override;
162 // IPC::Sender
163 bool Send(IPC::Message* msg) override;
165 // blink::WebWidgetClient
166 virtual void willBeginCompositorFrame();
167 virtual void didAutoResize(const blink::WebSize& new_size);
168 virtual void initializeLayerTreeView();
169 virtual blink::WebLayerTreeView* layerTreeView();
170 virtual void didBecomeReadyForAdditionalInput();
171 virtual void didCommitAndDrawCompositorFrame();
172 virtual void didCompleteSwapBuffers();
173 virtual void scheduleComposite();
174 virtual void didFocus();
175 virtual void didBlur();
176 virtual void didChangeCursor(const blink::WebCursorInfo&);
177 virtual void closeWidgetSoon();
178 virtual void show(blink::WebNavigationPolicy);
179 virtual void runModal() {}
180 virtual blink::WebRect windowRect();
181 virtual void setToolTipText(const blink::WebString& text,
182 blink::WebTextDirection hint);
183 virtual void setWindowRect(const blink::WebRect&);
184 virtual blink::WebRect windowResizerRect();
185 virtual blink::WebRect rootWindowRect();
186 virtual blink::WebScreenInfo screenInfo();
187 virtual float deviceScaleFactor();
188 virtual void resetInputMethod();
189 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
190 bool event_cancelled);
191 virtual void showImeIfNeeded();
193 #if defined(OS_ANDROID)
194 // Notifies that a tap was not consumed, so showing a UI for the unhandled
195 // tap may be needed.
196 virtual void showUnhandledTapUIIfNeeded(
197 const blink::WebPoint& tapped_position,
198 const blink::WebNode& tapped_node,
199 bool page_changed) override;
200 #endif
202 // Begins the compositor's scheduler to start producing frames.
203 void StartCompositor();
205 // Stop compositing.
206 void WillCloseLayerTreeView();
208 // Called when a plugin is moved. These events are queued up and sent with
209 // the next paint or scroll message to the host.
210 void SchedulePluginMove(const WebPluginGeometry& move);
212 // Called when a plugin window has been destroyed, to make sure the currently
213 // pending moves don't try to reference it.
214 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
216 RenderWidgetCompositor* compositor() const;
218 const ui::LatencyInfo* current_event_latency_info() const {
219 return current_event_latency_info_;
222 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
224 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
225 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
227 // Send a synthetic gesture to the browser to be queued to the synthetic
228 // gesture controller.
229 void QueueSyntheticGesture(
230 scoped_ptr<SyntheticGestureParams> gesture_params,
231 const SyntheticGestureCompletionCallback& callback);
233 // Close the underlying WebWidget.
234 virtual void Close();
236 // Notifies about a compositor frame commit operation having finished.
237 virtual void DidCommitCompositorFrame();
239 // Deliveres |message| together with compositor state change updates. The
240 // exact behavior depends on |policy|.
241 // This mechanism is not a drop-in replacement for IPC: messages sent this way
242 // will not be automatically available to BrowserMessageFilter, for example.
243 // FIFO ordering is preserved between messages enqueued with the same
244 // |policy|, the ordering between messages enqueued for different policies is
245 // undefined.
247 // |msg| message to send, ownership of |msg| is transferred.
248 // |policy| see the comment on MessageDeliveryPolicy.
249 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
251 // Handle common setup/teardown for handling IME events.
252 void StartHandlingImeEvent();
253 void FinishHandlingImeEvent();
255 // Returns whether we currently should handle an IME event.
256 bool ShouldHandleImeEvent();
258 // Called by the compositor when page scale animation completed.
259 virtual void DidCompletePageScaleAnimation() {}
261 // When paused in debugger, we send ack for mouse event early. This ensures
262 // that we continue receiving mouse moves and pass them to debugger. Returns
263 // whether we are paused in mouse move event and have sent the ack.
264 bool SendAckForMouseMoveFromDebugger();
266 // When resumed from pause in debugger while handling mouse move,
267 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
268 void IgnoreAckForMouseMoveFromDebugger();
270 // ScreenMetricsEmulator class manages screen emulation inside a render
271 // widget. This includes resizing, placing view on the screen at desired
272 // position, changing device scale factor, and scaling down the whole
273 // widget if required to fit into the browser window.
274 class ScreenMetricsEmulator;
276 // Emulates screen and widget metrics. Supplied values override everything
277 // coming from host.
278 void EnableScreenMetricsEmulation(
279 const blink::WebDeviceEmulationParams& params);
280 void DisableScreenMetricsEmulation();
281 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
282 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
284 void ScheduleCompositeWithForcedRedraw();
286 // Called by the compositor in single-threaded mode when a swap is posted,
287 // completes or is aborted.
288 void OnSwapBuffersPosted();
289 void OnSwapBuffersComplete();
290 void OnSwapBuffersAborted();
292 // Checks if the text input state and compose inline mode have been changed.
293 // If they are changed, the new value will be sent to the browser process.
294 void UpdateTextInputType();
296 // Checks if the selection bounds have been changed. If they are changed,
297 // the new value will be sent to the browser process.
298 void UpdateSelectionBounds();
300 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
302 void OnShowHostContextMenu(ContextMenuParams* params);
304 #if defined(OS_ANDROID) || defined(USE_AURA)
305 enum ShowIme {
306 SHOW_IME_IF_NEEDED,
307 NO_SHOW_IME,
310 enum ChangeSource {
311 FROM_NON_IME,
312 FROM_IME,
315 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
316 // be displayed, e.g. after a tap on an input field on mobile.
317 // |change_source| should be FROM_NON_IME when the renderer has to wait for
318 // the browser to acknowledge the change before the renderer handles any more
319 // IME events. This is when the text change did not originate from the IME in
320 // the browser side, such as changes by JavaScript or autofill.
321 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
322 #endif
324 // Called when animations due to focus change have completed (if any). Can be
325 // called from the renderer, browser, or compositor.
326 virtual void FocusChangeComplete() {}
328 // Checks if the composition range or composition character bounds have been
329 // changed. If they are changed, the new value will be sent to the browser
330 // process. This method does nothing when the browser process is not able to
331 // handle composition range and composition character bounds.
332 void UpdateCompositionInfo(bool should_update_range);
334 #if defined(OS_ANDROID)
335 void DidChangeBodyBackgroundColor(SkColor bg_color);
336 bool DoesRecordFullLayer() const;
337 #endif
339 bool host_closing() const { return host_closing_; }
341 protected:
342 // Friend RefCounted so that the dtor can be non-public. Using this class
343 // without ref-counting is an error.
344 friend class base::RefCounted<RenderWidget>;
345 // For unit tests.
346 friend class RenderWidgetTest;
348 enum ResizeAck {
349 SEND_RESIZE_ACK,
350 NO_RESIZE_ACK,
353 RenderWidget(blink::WebPopupType popup_type,
354 const blink::WebScreenInfo& screen_info,
355 bool swapped_out,
356 bool hidden,
357 bool never_visible);
359 ~RenderWidget() override;
361 // Initializes this view with the given opener. CompleteInit must be called
362 // later.
363 bool Init(int32 opener_id, CompositorDependencies* compositor_deps);
365 // Called by Init and subclasses to perform initialization.
366 bool DoInit(int32 opener_id,
367 CompositorDependencies* compositor_deps,
368 blink::WebWidget* web_widget,
369 IPC::SyncMessage* create_widget_message);
371 // Finishes creation of a pending view started with Init.
372 void CompleteInit();
374 // Sets whether this RenderWidget has been swapped out to be displayed by
375 // a RenderWidget in a different process. If so, no new IPC messages will be
376 // sent (only ACKs) and the process is free to exit when there are no other
377 // active RenderWidgets.
378 void SetSwappedOut(bool is_swapped_out);
380 // Allows the process to exit once the unload handler has finished, if there
381 // are no other active RenderWidgets.
382 void WasSwappedOut();
384 void FlushPendingInputEventAck();
385 void DoDeferredClose();
386 void DoDeferredSetWindowRect(const blink::WebRect& pos);
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,
396 ResizeAck resize_ack);
397 // Used to force the size of a window when running layout tests.
398 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
399 virtual void SetScreenMetricsEmulationParameters(
400 float device_scale_factor,
401 const gfx::Point& root_layer_offset,
402 float root_layer_scale);
403 #if defined(OS_MACOSX) || defined(OS_ANDROID)
404 void SetExternalPopupOriginAdjustmentsForEmulation(
405 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
406 #endif
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);
415 virtual void OnClose();
416 void OnCreatingNewAck();
417 virtual void OnResize(const ViewMsg_Resize_Params& params);
418 void OnColorProfile(const std::vector<char>& color_profile);
419 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
420 virtual void OnWasHidden();
421 virtual void OnWasShown(bool needs_repainting,
422 const ui::LatencyInfo& latency_info);
423 void OnCreateVideoAck(int32 video_id);
424 void OnUpdateVideoAck(int32 video_id);
425 void OnRequestMoveAck();
426 void OnSetInputMethodActive(bool is_active);
427 void OnCandidateWindowShown();
428 void OnCandidateWindowUpdated();
429 void OnCandidateWindowHidden();
430 virtual void OnImeSetComposition(
431 const base::string16& text,
432 const std::vector<blink::WebCompositionUnderline>& underlines,
433 int selection_start,
434 int selection_end);
435 virtual void OnImeConfirmComposition(const base::string16& text,
436 const gfx::Range& replacement_range,
437 bool keep_selection);
438 void OnRepaint(gfx::Size size_to_paint);
439 void OnSyntheticGestureCompleted();
440 void OnSetTextDirection(blink::WebTextDirection direction);
441 void OnGetFPS();
442 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
443 const gfx::Rect& window_screen_rect);
444 void OnShowImeIfNeeded();
446 #if defined(OS_ANDROID)
447 // Whenever an IME event that needs an acknowledgement is sent to the browser,
448 // the number of outstanding IME events that needs acknowledgement should be
449 // incremented. All IME events will be dropped until we receive an ack from
450 // the browser.
451 void IncrementOutstandingImeEventAcks();
453 // Called by the browser process for every required IME acknowledgement.
454 void OnImeEventAck();
455 #endif
457 // Notify the compositor about a change in viewport size. This should be
458 // used only with auto resize mode WebWidgets, as normal WebWidgets should
459 // go through OnResize.
460 void AutoResizeCompositor();
462 virtual void SetDeviceScaleFactor(float device_scale_factor);
463 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
464 virtual void ResetDeviceColorProfileForTesting();
466 virtual void OnOrientationChange();
468 // Override points to notify derived classes that a paint has happened.
469 // DidInitiatePaint happens when that has completed, and subsequent rendering
470 // won't affect the painted content. DidFlushPaint happens once we've received
471 // the ACK that the screen has been updated. For a given paint operation,
472 // these overrides will always be called in the order DidInitiatePaint,
473 // DidFlushPaint.
474 virtual void DidInitiatePaint() {}
475 virtual void DidFlushPaint() {}
477 virtual GURL GetURLForGraphicsContext3D();
479 // Gets the scroll offset of this widget, if this widget has a notion of
480 // scroll offset.
481 virtual gfx::Vector2d GetScrollOffset();
483 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
484 // use this method so that we can properly inform the RenderThread of our
485 // state.
486 void SetHidden(bool hidden);
488 void WillToggleFullscreen();
489 void DidToggleFullscreen();
491 bool next_paint_is_resize_ack() const;
492 void set_next_paint_is_resize_ack();
493 void set_next_paint_is_repaint_ack();
495 // QueueMessage implementation extracted into a static method for easy
496 // testing.
497 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
498 IPC::Message* msg,
499 MessageDeliveryPolicy policy,
500 FrameSwapMessageQueue* frame_swap_message_queue,
501 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
502 int source_frame_number);
504 // Override point to obtain that the current input method state and caret
505 // position.
506 virtual ui::TextInputType GetTextInputType();
507 virtual ui::TextInputType WebKitToUiTextInputType(
508 blink::WebTextInputType type);
510 // Override point to obtain that the current composition character bounds.
511 // In the case of surrogate pairs, the character is treated as two characters:
512 // the bounds for first character is actual one, and the bounds for second
513 // character is zero width rectangle.
514 virtual void GetCompositionCharacterBounds(
515 std::vector<gfx::Rect>* character_bounds);
517 // Returns the range of the text that is being composed or the selection if
518 // the composition does not exist.
519 virtual void GetCompositionRange(gfx::Range* range);
521 // Returns true if the composition range or composition character bounds
522 // should be sent to the browser process.
523 bool ShouldUpdateCompositionInfo(
524 const gfx::Range& range,
525 const std::vector<gfx::Rect>& bounds);
527 // Override point to obtain that the current input method state about
528 // composition text.
529 virtual bool CanComposeInline();
531 // Tells the renderer it does not have focus. Used to prevent us from getting
532 // the focus on our own when the browser did not focus us.
533 void ClearFocus();
535 // Set the pending window rect.
536 // Because the real render_widget is hosted in another process, there is
537 // a time period where we may have set a new window rect which has not yet
538 // been processed by the browser. So we maintain a pending window rect
539 // size. If JS code sets the WindowRect, and then immediately calls
540 // GetWindowRect() we'll use this pending window rect as the size.
541 void SetPendingWindowRect(const blink::WebRect& r);
543 // Called by OnHandleInputEvent() to notify subclasses that a key event was
544 // just handled.
545 virtual void DidHandleKeyEvent() {}
547 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
548 // about to be handled.
549 // Returns true if no further handling is needed. In that case, the event
550 // won't be sent to WebKit or trigger DidHandleMouseEvent().
551 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
553 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
554 // about to be handled.
555 // Returns true if no further handling is needed. In that case, the event
556 // won't be sent to WebKit.
557 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
559 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
560 // just handled.
561 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
563 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
564 // just handled.
565 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
567 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
568 // compositor thread, to effect the elastic overscroll effect.
569 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
570 bool event_processed);
572 // Check whether the WebWidget has any touch event handlers registered
573 // at the given point.
574 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
576 // Check whether the WebWidget has any touch event handlers registered.
577 virtual void hasTouchEventHandlers(bool has_handlers);
579 // Tell the browser about the actions permitted for a new touch point.
580 virtual void setTouchAction(blink::WebTouchAction touch_action);
582 // Called when value of focused text field gets dirty, e.g. value is modified
583 // by script, not by user input.
584 virtual void didUpdateTextOfFocusedElementByNonUserInput();
586 // Creates a 3D context associated with this view.
587 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
589 // Routing ID that allows us to communicate to the parent browser process
590 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
591 int32 routing_id_;
593 int32 surface_id_;
595 // Dependencies for initializing a compositor, including flags for optional
596 // features.
597 CompositorDependencies* compositor_deps_;
599 // We are responsible for destroying this object via its Close method.
600 // May be NULL when the window is closing.
601 blink::WebWidget* webwidget_;
603 // This is lazily constructed and must not outlive webwidget_.
604 scoped_ptr<RenderWidgetCompositor> compositor_;
606 // Set to the ID of the view that initiated creating this view, if any. When
607 // the view was initiated by the browser (the common case), this will be
608 // MSG_ROUTING_NONE. This is used in determining ownership when opening
609 // child tabs. See RenderWidget::createWebViewWithRequest.
611 // This ID may refer to an invalid view if that view is closed before this
612 // view is.
613 int32 opener_id_;
615 // The rect where this view should be initially shown.
616 gfx::Rect initial_rect_;
618 bool init_complete_;
620 // We store the current cursor object so we can avoid spamming SetCursor
621 // messages.
622 WebCursor current_cursor_;
624 // The size of the RenderWidget.
625 gfx::Size size_;
627 // The size of the view's backing surface in non-DPI-adjusted pixels.
628 gfx::Size physical_backing_size_;
630 // Whether or not Blink's viewport size should be shrunk by the height of the
631 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
632 bool top_controls_shrink_blink_size_;
634 // The height of the top controls (always 0 on platforms where URL-bar hiding
635 // isn't supported).
636 float top_controls_height_;
638 // The size of the visible viewport in DPI-adjusted pixels.
639 gfx::Size visible_viewport_size_;
641 // The area that must be reserved for drawing the resize corner.
642 gfx::Rect resizer_rect_;
644 // Flags for the next ViewHostMsg_UpdateRect message.
645 int next_paint_flags_;
647 // Whether the WebWidget is in auto resize mode, which is used for example
648 // by extension popups.
649 bool auto_resize_mode_;
651 // True if we need to send an UpdateRect message to notify the browser about
652 // an already-completed auto-resize.
653 bool need_update_rect_for_auto_resize_;
655 // Set to true if we should ignore RenderWidget::Show calls.
656 bool did_show_;
658 // Indicates that we shouldn't bother generated paint events.
659 bool is_hidden_;
661 // Indicates that we are never visible, so never produce graphical output.
662 bool never_visible_;
664 // Indicates that we are in fullscreen mode.
665 bool is_fullscreen_;
667 // Indicates whether we have been focused/unfocused by the browser.
668 bool has_focus_;
670 // Are we currently handling an input event?
671 bool handling_input_event_;
673 // Are we currently handling an ime event?
674 bool handling_ime_event_;
676 // Type of the input event we are currently handling.
677 blink::WebInputEvent::Type handling_event_type_;
679 // Whether we should not send ack for the current mouse move.
680 bool ignore_ack_for_mouse_move_from_debugger_;
682 // True if we have requested this widget be closed. No more messages will
683 // be sent, except for a Close.
684 bool closing_;
686 // True if it is known that the host is in the process of being shut down.
687 bool host_closing_;
689 // Whether this RenderWidget is currently swapped out, such that the view is
690 // being rendered by another process. If all RenderWidgets in a process are
691 // swapped out, the process can exit.
692 bool is_swapped_out_;
694 // Indicates if an input method is active in the browser process.
695 bool input_method_is_active_;
697 // Stores information about the current text input.
698 blink::WebTextInputInfo text_input_info_;
700 // Stores the current text input type of |webwidget_|.
701 ui::TextInputType text_input_type_;
703 // Stores the current text input mode of |webwidget_|.
704 ui::TextInputMode text_input_mode_;
706 // Stores the current text input flags of |webwidget_|.
707 int text_input_flags_;
709 // Stores the current type of composition text rendering of |webwidget_|.
710 bool can_compose_inline_;
712 // Stores the current selection bounds.
713 gfx::Rect selection_focus_rect_;
714 gfx::Rect selection_anchor_rect_;
716 // Stores the current composition character bounds.
717 std::vector<gfx::Rect> composition_character_bounds_;
719 // Stores the current composition range.
720 gfx::Range composition_range_;
722 // The kind of popup this widget represents, NONE if not a popup.
723 blink::WebPopupType popup_type_;
725 // Holds all the needed plugin window moves for a scroll.
726 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
727 WebPluginGeometryVector plugin_window_moves_;
729 // While we are waiting for the browser to update window sizes, we track the
730 // pending size temporarily.
731 int pending_window_rect_count_;
732 blink::WebRect pending_window_rect_;
734 // The screen rects of the view and the window that contains it.
735 gfx::Rect view_screen_rect_;
736 gfx::Rect window_screen_rect_;
738 scoped_ptr<IPC::Message> pending_input_event_ack_;
740 // The time spent in input handlers this frame. Used to throttle input acks.
741 base::TimeDelta total_input_handling_time_this_frame_;
743 // Indicates if the next sequence of Char events should be suppressed or not.
744 bool suppress_next_char_events_;
746 // Properties of the screen hosting this RenderWidget instance.
747 blink::WebScreenInfo screen_info_;
749 // The device scale factor. This value is computed from the DPI entries in
750 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
751 float device_scale_factor_;
753 // The device color profile on supported platforms.
754 std::vector<char> device_color_profile_;
756 // State associated with synthetic gestures. Synthetic gestures are processed
757 // in-order, so a queue is sufficient to identify the correct state for a
758 // completed gesture.
759 std::queue<SyntheticGestureCompletionCallback>
760 pending_synthetic_gesture_callbacks_;
762 const ui::LatencyInfo* current_event_latency_info_;
764 uint32 next_output_surface_id_;
766 #if defined(OS_ANDROID)
767 // Indicates value in the focused text field is in dirty state, i.e. modified
768 // by script etc., not by user input.
769 bool text_field_is_dirty_;
771 // A counter for number of outstanding messages from the renderer to the
772 // browser regarding IME-type events that have not been acknowledged by the
773 // browser. If this value is not 0 IME events will be dropped.
774 int outstanding_ime_acks_;
776 // The background color of the document body element. This is used as the
777 // default background color for filling the screen areas for which we don't
778 // have the actual content.
779 SkColor body_background_color_;
780 #endif
782 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
784 // Popups may be displaced when screen metrics emulation is enabled.
785 // These values are used to properly adjust popup position.
786 gfx::Point popup_view_origin_for_emulation_;
787 gfx::Point popup_screen_origin_for_emulation_;
788 float popup_origin_scale_for_emulation_;
790 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
791 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
793 // Lists of RenderFrameProxy objects that need to be notified of
794 // compositing-related events (e.g. DidCommitCompositorFrame).
795 ObserverList<RenderFrameProxy> render_frame_proxies_;
796 #if defined(VIDEO_HOLE)
797 ObserverList<RenderFrameImpl> video_hole_frames_;
798 #endif // defined(VIDEO_HOLE)
800 // A list of RenderFrames associated with this RenderWidget. Notifications
801 // are sent to each frame in the list for events such as changing
802 // visibility state for example.
803 ObserverList<RenderFrameImpl> render_frames_;
805 ui::MenuSourceType context_menu_source_type_;
806 bool has_host_context_menu_location_;
807 gfx::Point host_context_menu_location_;
809 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
812 } // namespace content
814 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_