third_party/re2: Remove remove-static-initializers.patch.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blobecd41bbede2e548563f17326dff638dfe93a4f13
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 WebPluginGeometry;
92 // RenderWidget provides a communication bridge between a WebWidget and
93 // a RenderWidgetHost, the latter of which lives in a different process.
94 class CONTENT_EXPORT RenderWidget
95 : public IPC::Listener,
96 public IPC::Sender,
97 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
98 public base::RefCounted<RenderWidget> {
99 public:
100 // Creates a new RenderWidget. The opener_id is the routing ID of the
101 // RenderView that this widget lives inside.
102 static RenderWidget* Create(int32 opener_id,
103 CompositorDependencies* compositor_deps,
104 blink::WebPopupType popup_type,
105 const blink::WebScreenInfo& screen_info);
107 // Creates a new RenderWidget that will be attached to a RenderFrame.
108 static RenderWidget* CreateForFrame(int routing_id,
109 int surface_id,
110 bool hidden,
111 const blink::WebScreenInfo& screen_info,
112 CompositorDependencies* compositor_deps,
113 blink::WebLocalFrame* frame);
115 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
116 blink::WebLocalFrame* frame);
118 // Creates a WebWidget based on the popup type.
119 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
121 int32 routing_id() const { return routing_id_; }
122 int32 surface_id() const { return surface_id_; }
123 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
124 blink::WebWidget* webwidget() const { return webwidget_; }
125 gfx::Size size() const { return size_; }
126 bool has_focus() const { return has_focus_; }
127 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
128 blink::WebDisplayMode display_mode() const { return display_mode_; }
129 bool is_hidden() const { return is_hidden_; }
130 bool handling_input_event() const { return handling_input_event_; }
131 // Temporary for debugging purposes...
132 bool closing() const { return closing_; }
133 bool is_swapped_out() { return is_swapped_out_; }
134 ui::MenuSourceType context_menu_source_type() {
135 return context_menu_source_type_;
137 bool has_host_context_menu_location() {
138 return has_host_context_menu_location_;
140 gfx::Point host_context_menu_location() {
141 return host_context_menu_location_;
144 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
145 blink::WebScreenInfo screen_info() const { return screen_info_; }
147 // Functions to track out-of-process frames for special notifications.
148 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
149 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
151 // Functions to track all RenderFrame objects associated with this
152 // RenderWidget.
153 void RegisterRenderFrame(RenderFrameImpl* frame);
154 void UnregisterRenderFrame(RenderFrameImpl* frame);
156 #if defined(VIDEO_HOLE)
157 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
158 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
159 #endif // defined(VIDEO_HOLE)
161 // IPC::Listener
162 bool OnMessageReceived(const IPC::Message& msg) override;
164 // IPC::Sender
165 bool Send(IPC::Message* msg) override;
167 // blink::WebWidgetClient
168 virtual void willBeginCompositorFrame();
169 virtual void didAutoResize(const blink::WebSize& new_size);
170 virtual void initializeLayerTreeView();
171 virtual blink::WebLayerTreeView* layerTreeView();
172 virtual void didBecomeReadyForAdditionalInput();
173 virtual void didCommitAndDrawCompositorFrame();
174 virtual void didCompleteSwapBuffers();
175 virtual void scheduleComposite();
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 showImeIfNeeded();
194 #if defined(OS_ANDROID)
195 // Notifies that a tap was not consumed, so showing a UI for the unhandled
196 // tap may be needed.
197 // Performs various checks on the given WebNode to apply heuristics to
198 // determine if triggering is appropriate.
199 virtual void showUnhandledTapUIIfNeeded(
200 const blink::WebPoint& tapped_position,
201 const blink::WebNode& tapped_node,
202 bool page_changed) override;
203 #endif
205 // Begins the compositor's scheduler to start producing frames.
206 void StartCompositor();
208 // Stop compositing.
209 void WillCloseLayerTreeView();
211 // Called when a plugin is moved. These events are queued up and sent with
212 // the next paint or scroll message to the host.
213 void SchedulePluginMove(const WebPluginGeometry& move);
215 // Called when a plugin window has been destroyed, to make sure the currently
216 // pending moves don't try to reference it.
217 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
219 RenderWidgetCompositor* compositor() const;
221 const ui::LatencyInfo* current_event_latency_info() const {
222 return current_event_latency_info_;
225 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
227 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
228 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
230 // Send a synthetic gesture to the browser to be queued to the synthetic
231 // gesture controller.
232 void QueueSyntheticGesture(
233 scoped_ptr<SyntheticGestureParams> gesture_params,
234 const SyntheticGestureCompletionCallback& callback);
236 // Close the underlying WebWidget.
237 virtual void Close();
239 // Notifies about a compositor frame commit operation having finished.
240 virtual void DidCommitCompositorFrame();
242 // Deliveres |message| together with compositor state change updates. The
243 // exact behavior depends on |policy|.
244 // This mechanism is not a drop-in replacement for IPC: messages sent this way
245 // will not be automatically available to BrowserMessageFilter, for example.
246 // FIFO ordering is preserved between messages enqueued with the same
247 // |policy|, the ordering between messages enqueued for different policies is
248 // undefined.
250 // |msg| message to send, ownership of |msg| is transferred.
251 // |policy| see the comment on MessageDeliveryPolicy.
252 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
254 // Handle common setup/teardown for handling IME events.
255 void StartHandlingImeEvent();
256 void FinishHandlingImeEvent();
258 // Returns whether we currently should handle an IME event.
259 bool ShouldHandleImeEvent();
261 // Called by the compositor when page scale animation completed.
262 virtual void DidCompletePageScaleAnimation() {}
264 // When paused in debugger, we send ack for mouse event early. This ensures
265 // that we continue receiving mouse moves and pass them to debugger. Returns
266 // whether we are paused in mouse move event and have sent the ack.
267 bool SendAckForMouseMoveFromDebugger();
269 // When resumed from pause in debugger while handling mouse move,
270 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
271 void IgnoreAckForMouseMoveFromDebugger();
273 // ScreenMetricsEmulator class manages screen emulation inside a render
274 // widget. This includes resizing, placing view on the screen at desired
275 // position, changing device scale factor, and scaling down the whole
276 // widget if required to fit into the browser window.
277 class ScreenMetricsEmulator;
279 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
280 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
282 void ScheduleCompositeWithForcedRedraw();
284 // Called by the compositor in single-threaded mode when a swap is posted,
285 // completes or is aborted.
286 void OnSwapBuffersPosted();
287 void OnSwapBuffersComplete();
288 void OnSwapBuffersAborted();
290 // Checks if the text input state and compose inline mode have been changed.
291 // If they are changed, the new value will be sent to the browser process.
292 void UpdateTextInputType();
294 // Checks if the selection bounds have been changed. If they are changed,
295 // the new value will be sent to the browser process.
296 void UpdateSelectionBounds();
298 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
300 void OnShowHostContextMenu(ContextMenuParams* params);
302 #if defined(OS_ANDROID) || defined(USE_AURA)
303 enum ShowIme {
304 SHOW_IME_IF_NEEDED,
305 NO_SHOW_IME,
308 enum ChangeSource {
309 FROM_NON_IME,
310 FROM_IME,
313 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
314 // be displayed, e.g. after a tap on an input field on mobile.
315 // |change_source| should be FROM_NON_IME when the renderer has to wait for
316 // the browser to acknowledge the change before the renderer handles any more
317 // IME events. This is when the text change did not originate from the IME in
318 // the browser side, such as changes by JavaScript or autofill.
319 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
320 #endif
322 // Called when animations due to focus change have completed (if any). Can be
323 // called from the renderer, browser, or compositor.
324 virtual void FocusChangeComplete() {}
326 // Checks if the composition range or composition character bounds have been
327 // changed. If they are changed, the new value will be sent to the browser
328 // process. This method does nothing when the browser process is not able to
329 // handle composition range and composition character bounds.
330 void UpdateCompositionInfo(bool should_update_range);
332 #if defined(OS_ANDROID)
333 void DidChangeBodyBackgroundColor(SkColor bg_color);
334 bool DoesRecordFullLayer() const;
335 #endif
337 bool host_closing() const { return host_closing_; }
339 protected:
340 // Friend RefCounted so that the dtor can be non-public. Using this class
341 // without ref-counting is an error.
342 friend class base::RefCounted<RenderWidget>;
343 // For unit tests.
344 friend class RenderWidgetTest;
346 enum ResizeAck {
347 SEND_RESIZE_ACK,
348 NO_RESIZE_ACK,
351 RenderWidget(blink::WebPopupType popup_type,
352 const blink::WebScreenInfo& screen_info,
353 bool swapped_out,
354 bool hidden,
355 bool never_visible);
357 ~RenderWidget() override;
359 // Initializes this view with the given opener. CompleteInit must be called
360 // later.
361 bool Init(int32 opener_id, CompositorDependencies* compositor_deps);
363 // Called by Init and subclasses to perform initialization.
364 bool DoInit(int32 opener_id,
365 CompositorDependencies* compositor_deps,
366 blink::WebWidget* web_widget,
367 IPC::SyncMessage* create_widget_message);
369 // Finishes creation of a pending view started with Init.
370 void CompleteInit();
372 // Sets whether this RenderWidget has been swapped out to be displayed by
373 // a RenderWidget in a different process. If so, no new IPC messages will be
374 // sent (only ACKs) and the process is free to exit when there are no other
375 // active RenderWidgets.
376 void SetSwappedOut(bool is_swapped_out);
378 // Allows the process to exit once the unload handler has finished, if there
379 // are no other active RenderWidgets.
380 void WasSwappedOut();
382 void FlushPendingInputEventAck();
383 void DoDeferredClose();
384 void DoDeferredSetWindowRect(const blink::WebRect& pos);
385 void NotifyOnClose();
387 // Resizes the render widget.
388 void Resize(const gfx::Size& new_size,
389 const gfx::Size& physical_backing_size,
390 bool top_controls_shrink_blink_size,
391 float top_controls_height,
392 const gfx::Size& visible_viewport_size,
393 const gfx::Rect& resizer_rect,
394 bool is_fullscreen_granted,
395 blink::WebDisplayMode display_mode,
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 bool enabled,
401 const blink::WebDeviceEmulationParams& params);
402 #if defined(OS_MACOSX) || defined(OS_ANDROID)
403 void SetExternalPopupOriginAdjustmentsForEmulation(
404 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
405 #endif
407 // RenderWidget IPC message handlers
408 void OnHandleInputEvent(const blink::WebInputEvent* event,
409 const ui::LatencyInfo& latency_info,
410 bool keyboard_shortcut);
411 void OnCursorVisibilityChange(bool is_visible);
412 void OnMouseCaptureLost();
413 virtual void OnSetFocus(bool enable);
414 virtual void OnClose();
415 void OnCreatingNewAck();
416 virtual void OnResize(const ViewMsg_Resize_Params& params);
417 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
418 void OnDisableDeviceEmulation();
419 void OnColorProfile(const std::vector<char>& color_profile);
420 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
421 virtual void OnWasHidden();
422 virtual void OnWasShown(bool needs_repainting,
423 const ui::LatencyInfo& latency_info);
424 void OnCreateVideoAck(int32 video_id);
425 void OnUpdateVideoAck(int32 video_id);
426 void OnRequestMoveAck();
427 void OnSetInputMethodActive(bool is_active);
428 void OnCandidateWindowShown();
429 void OnCandidateWindowUpdated();
430 void OnCandidateWindowHidden();
431 virtual void OnImeSetComposition(
432 const base::string16& text,
433 const std::vector<blink::WebCompositionUnderline>& underlines,
434 int selection_start,
435 int selection_end);
436 virtual void OnImeConfirmComposition(const base::string16& text,
437 const gfx::Range& replacement_range,
438 bool keep_selection);
439 void OnRepaint(gfx::Size size_to_paint);
440 void OnSyntheticGestureCompleted();
441 void OnSetTextDirection(blink::WebTextDirection direction);
442 void OnGetFPS();
443 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
444 const gfx::Rect& window_screen_rect);
445 void OnShowImeIfNeeded();
447 #if defined(OS_ANDROID)
448 // Whenever an IME event that needs an acknowledgement is sent to the browser,
449 // the number of outstanding IME events that needs acknowledgement should be
450 // incremented. All IME events will be dropped until we receive an ack from
451 // the browser.
452 void IncrementOutstandingImeEventAcks();
454 // Called by the browser process for every required IME acknowledgement.
455 void OnImeEventAck();
456 #endif
458 // Notify the compositor about a change in viewport size. This should be
459 // used only with auto resize mode WebWidgets, as normal WebWidgets should
460 // go through OnResize.
461 void AutoResizeCompositor();
463 virtual void SetDeviceScaleFactor(float device_scale_factor);
464 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
465 virtual void ResetDeviceColorProfileForTesting();
467 virtual void OnOrientationChange();
469 // Override points to notify derived classes that a paint has happened.
470 // DidInitiatePaint happens when that has completed, and subsequent rendering
471 // won't affect the painted content. DidFlushPaint happens once we've received
472 // the ACK that the screen has been updated. For a given paint operation,
473 // these overrides will always be called in the order DidInitiatePaint,
474 // DidFlushPaint.
475 virtual void DidInitiatePaint() {}
476 virtual void DidFlushPaint() {}
478 virtual GURL GetURLForGraphicsContext3D();
480 // Gets the scroll offset of this widget, if this widget has a notion of
481 // scroll offset.
482 virtual gfx::Vector2d GetScrollOffset();
484 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
485 // use this method so that we can properly inform the RenderThread of our
486 // state.
487 void SetHidden(bool hidden);
489 void WillToggleFullscreen();
490 void DidToggleFullscreen();
492 bool next_paint_is_resize_ack() const;
493 void set_next_paint_is_resize_ack();
494 void set_next_paint_is_repaint_ack();
496 // QueueMessage implementation extracted into a static method for easy
497 // testing.
498 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
499 IPC::Message* msg,
500 MessageDeliveryPolicy policy,
501 FrameSwapMessageQueue* frame_swap_message_queue,
502 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
503 int source_frame_number);
505 // Override point to obtain that the current input method state and caret
506 // position.
507 virtual ui::TextInputType GetTextInputType();
508 virtual ui::TextInputType WebKitToUiTextInputType(
509 blink::WebTextInputType type);
511 // Override point to obtain that the current composition character bounds.
512 // In the case of surrogate pairs, the character is treated as two characters:
513 // the bounds for first character is actual one, and the bounds for second
514 // character is zero width rectangle.
515 virtual void GetCompositionCharacterBounds(
516 std::vector<gfx::Rect>* character_bounds);
518 // Returns the range of the text that is being composed or the selection if
519 // the composition does not exist.
520 virtual void GetCompositionRange(gfx::Range* range);
522 // Returns true if the composition range or composition character bounds
523 // should be sent to the browser process.
524 bool ShouldUpdateCompositionInfo(
525 const gfx::Range& range,
526 const std::vector<gfx::Rect>& bounds);
528 // Override point to obtain that the current input method state about
529 // composition text.
530 virtual bool CanComposeInline();
532 // Tells the renderer it does not have focus. Used to prevent us from getting
533 // the focus on our own when the browser did not focus us.
534 void ClearFocus();
536 // Set the pending window rect.
537 // Because the real render_widget is hosted in another process, there is
538 // a time period where we may have set a new window rect which has not yet
539 // been processed by the browser. So we maintain a pending window rect
540 // size. If JS code sets the WindowRect, and then immediately calls
541 // GetWindowRect() we'll use this pending window rect as the size.
542 void SetPendingWindowRect(const blink::WebRect& r);
544 // Called by OnHandleInputEvent() to notify subclasses that a key event was
545 // just handled.
546 virtual void DidHandleKeyEvent() {}
548 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
549 // about to be handled.
550 // Returns true if no further handling is needed. In that case, the event
551 // won't be sent to WebKit or trigger DidHandleMouseEvent().
552 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
554 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
555 // about to be handled.
556 // Returns true if no further handling is needed. In that case, the event
557 // won't be sent to WebKit.
558 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
560 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
561 // just handled.
562 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
564 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
565 // just handled.
566 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
568 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
569 // compositor thread, to effect the elastic overscroll effect.
570 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
571 bool event_processed);
573 // Check whether the WebWidget has any touch event handlers registered
574 // at the given point.
575 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
577 // Check whether the WebWidget has any touch event handlers registered.
578 virtual void hasTouchEventHandlers(bool has_handlers);
580 // Tell the browser about the actions permitted for a new touch point.
581 virtual void setTouchAction(blink::WebTouchAction touch_action);
583 // Called when value of focused text field gets dirty, e.g. value is modified
584 // by script, not by user input.
585 virtual void didUpdateTextOfFocusedElementByNonUserInput();
587 // Creates a 3D context associated with this view.
588 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
590 // Routing ID that allows us to communicate to the parent browser process
591 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
592 int32 routing_id_;
594 int32 surface_id_;
596 // Dependencies for initializing a compositor, including flags for optional
597 // features.
598 CompositorDependencies* compositor_deps_;
600 // We are responsible for destroying this object via its Close method.
601 // May be NULL when the window is closing.
602 blink::WebWidget* webwidget_;
604 // This is lazily constructed and must not outlive webwidget_.
605 scoped_ptr<RenderWidgetCompositor> compositor_;
607 // Set to the ID of the view that initiated creating this view, if any. When
608 // the view was initiated by the browser (the common case), this will be
609 // MSG_ROUTING_NONE. This is used in determining ownership when opening
610 // child tabs. See RenderWidget::createWebViewWithRequest.
612 // This ID may refer to an invalid view if that view is closed before this
613 // view is.
614 int32 opener_id_;
616 // The rect where this view should be initially shown.
617 gfx::Rect initial_rect_;
619 bool init_complete_;
621 // We store the current cursor object so we can avoid spamming SetCursor
622 // messages.
623 WebCursor current_cursor_;
625 // The size of the RenderWidget.
626 gfx::Size size_;
628 // The size of the view's backing surface in non-DPI-adjusted pixels.
629 gfx::Size physical_backing_size_;
631 // Whether or not Blink's viewport size should be shrunk by the height of the
632 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
633 bool top_controls_shrink_blink_size_;
635 // The height of the top controls (always 0 on platforms where URL-bar hiding
636 // isn't supported).
637 float top_controls_height_;
639 // The size of the visible viewport in DPI-adjusted pixels.
640 gfx::Size visible_viewport_size_;
642 // The area that must be reserved for drawing the resize corner.
643 gfx::Rect resizer_rect_;
645 // Flags for the next ViewHostMsg_UpdateRect message.
646 int next_paint_flags_;
648 // Whether the WebWidget is in auto resize mode, which is used for example
649 // by extension popups.
650 bool auto_resize_mode_;
652 // True if we need to send an UpdateRect message to notify the browser about
653 // an already-completed auto-resize.
654 bool need_update_rect_for_auto_resize_;
656 // Set to true if we should ignore RenderWidget::Show calls.
657 bool did_show_;
659 // Indicates that we shouldn't bother generated paint events.
660 bool is_hidden_;
662 // Indicates that we are never visible, so never produce graphical output.
663 bool never_visible_;
665 // Indicates whether tab-initiated fullscreen was granted.
666 bool is_fullscreen_granted_;
668 // Indicates the display mode.
669 blink::WebDisplayMode display_mode_;
671 // Indicates whether we have been focused/unfocused by the browser.
672 bool has_focus_;
674 // Are we currently handling an input event?
675 bool handling_input_event_;
677 // Are we currently handling an ime event?
678 bool handling_ime_event_;
680 // Type of the input event we are currently handling.
681 blink::WebInputEvent::Type handling_event_type_;
683 // Whether we should not send ack for the current mouse move.
684 bool ignore_ack_for_mouse_move_from_debugger_;
686 // True if we have requested this widget be closed. No more messages will
687 // be sent, except for a Close.
688 bool closing_;
690 // True if it is known that the host is in the process of being shut down.
691 bool host_closing_;
693 // Whether this RenderWidget is currently swapped out, such that the view is
694 // being rendered by another process. If all RenderWidgets in a process are
695 // swapped out, the process can exit.
696 bool is_swapped_out_;
698 // Indicates if an input method is active in the browser process.
699 bool input_method_is_active_;
701 // Stores information about the current text input.
702 blink::WebTextInputInfo text_input_info_;
704 // Stores the current text input type of |webwidget_|.
705 ui::TextInputType text_input_type_;
707 // Stores the current text input mode of |webwidget_|.
708 ui::TextInputMode text_input_mode_;
710 // Stores the current text input flags of |webwidget_|.
711 int text_input_flags_;
713 // Stores the current type of composition text rendering of |webwidget_|.
714 bool can_compose_inline_;
716 // Stores the current selection bounds.
717 gfx::Rect selection_focus_rect_;
718 gfx::Rect selection_anchor_rect_;
720 // Stores the current composition character bounds.
721 std::vector<gfx::Rect> composition_character_bounds_;
723 // Stores the current composition range.
724 gfx::Range composition_range_;
726 // The kind of popup this widget represents, NONE if not a popup.
727 blink::WebPopupType popup_type_;
729 // Holds all the needed plugin window moves for a scroll.
730 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
731 WebPluginGeometryVector plugin_window_moves_;
733 // While we are waiting for the browser to update window sizes, we track the
734 // pending size temporarily.
735 int pending_window_rect_count_;
736 blink::WebRect pending_window_rect_;
738 // The screen rects of the view and the window that contains it.
739 gfx::Rect view_screen_rect_;
740 gfx::Rect window_screen_rect_;
742 scoped_ptr<IPC::Message> pending_input_event_ack_;
744 // The time spent in input handlers this frame. Used to throttle input acks.
745 base::TimeDelta total_input_handling_time_this_frame_;
747 // Indicates if the next sequence of Char events should be suppressed or not.
748 bool suppress_next_char_events_;
750 // Properties of the screen hosting this RenderWidget instance.
751 blink::WebScreenInfo screen_info_;
753 // The device scale factor. This value is computed from the DPI entries in
754 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
755 float device_scale_factor_;
757 // The device color profile on supported platforms.
758 std::vector<char> device_color_profile_;
760 // State associated with synthetic gestures. Synthetic gestures are processed
761 // in-order, so a queue is sufficient to identify the correct state for a
762 // completed gesture.
763 std::queue<SyntheticGestureCompletionCallback>
764 pending_synthetic_gesture_callbacks_;
766 const ui::LatencyInfo* current_event_latency_info_;
768 uint32 next_output_surface_id_;
770 #if defined(OS_ANDROID)
771 // Indicates value in the focused text field is in dirty state, i.e. modified
772 // by script etc., not by user input.
773 bool text_field_is_dirty_;
775 // A counter for number of outstanding messages from the renderer to the
776 // browser regarding IME-type events that have not been acknowledged by the
777 // browser. If this value is not 0 IME events will be dropped.
778 int outstanding_ime_acks_;
780 // The background color of the document body element. This is used as the
781 // default background color for filling the screen areas for which we don't
782 // have the actual content.
783 SkColor body_background_color_;
784 #endif
786 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
788 // Popups may be displaced when screen metrics emulation is enabled.
789 // These values are used to properly adjust popup position.
790 gfx::PointF popup_view_origin_for_emulation_;
791 gfx::PointF popup_screen_origin_for_emulation_;
792 float popup_origin_scale_for_emulation_;
794 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
795 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
797 // Lists of RenderFrameProxy objects that need to be notified of
798 // compositing-related events (e.g. DidCommitCompositorFrame).
799 ObserverList<RenderFrameProxy> render_frame_proxies_;
800 #if defined(VIDEO_HOLE)
801 ObserverList<RenderFrameImpl> video_hole_frames_;
802 #endif // defined(VIDEO_HOLE)
804 // A list of RenderFrames associated with this RenderWidget. Notifications
805 // are sent to each frame in the list for events such as changing
806 // visibility state for example.
807 ObserverList<RenderFrameImpl> render_frames_;
809 ui::MenuSourceType context_menu_source_type_;
810 bool has_host_context_menu_location_;
811 gfx::Point host_context_menu_location_;
813 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
816 } // namespace content
818 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_