Change ipc_perftests large-message test count to 1,000
[chromium-blink-merge.git] / content / renderer / render_widget.h
bloba149616cb14cd1ac0eb73f9288ad8bfd9bc640cd
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 bool commit_requested,
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 that we are in fullscreen mode.
666 bool is_fullscreen_;
668 // Indicates whether we have been focused/unfocused by the browser.
669 bool has_focus_;
671 // Are we currently handling an input event?
672 bool handling_input_event_;
674 // Are we currently handling an ime event?
675 bool handling_ime_event_;
677 // Type of the input event we are currently handling.
678 blink::WebInputEvent::Type handling_event_type_;
680 // Whether we should not send ack for the current mouse move.
681 bool ignore_ack_for_mouse_move_from_debugger_;
683 // True if we have requested this widget be closed. No more messages will
684 // be sent, except for a Close.
685 bool closing_;
687 // True if it is known that the host is in the process of being shut down.
688 bool host_closing_;
690 // Whether this RenderWidget is currently swapped out, such that the view is
691 // being rendered by another process. If all RenderWidgets in a process are
692 // swapped out, the process can exit.
693 bool is_swapped_out_;
695 // Indicates if an input method is active in the browser process.
696 bool input_method_is_active_;
698 // Stores information about the current text input.
699 blink::WebTextInputInfo text_input_info_;
701 // Stores the current text input type of |webwidget_|.
702 ui::TextInputType text_input_type_;
704 // Stores the current text input mode of |webwidget_|.
705 ui::TextInputMode text_input_mode_;
707 // Stores the current text input flags of |webwidget_|.
708 int text_input_flags_;
710 // Stores the current type of composition text rendering of |webwidget_|.
711 bool can_compose_inline_;
713 // Stores the current selection bounds.
714 gfx::Rect selection_focus_rect_;
715 gfx::Rect selection_anchor_rect_;
717 // Stores the current composition character bounds.
718 std::vector<gfx::Rect> composition_character_bounds_;
720 // Stores the current composition range.
721 gfx::Range composition_range_;
723 // The kind of popup this widget represents, NONE if not a popup.
724 blink::WebPopupType popup_type_;
726 // Holds all the needed plugin window moves for a scroll.
727 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
728 WebPluginGeometryVector plugin_window_moves_;
730 // While we are waiting for the browser to update window sizes, we track the
731 // pending size temporarily.
732 int pending_window_rect_count_;
733 blink::WebRect pending_window_rect_;
735 // The screen rects of the view and the window that contains it.
736 gfx::Rect view_screen_rect_;
737 gfx::Rect window_screen_rect_;
739 scoped_ptr<IPC::Message> pending_input_event_ack_;
741 // The time spent in input handlers this frame. Used to throttle input acks.
742 base::TimeDelta total_input_handling_time_this_frame_;
744 // Indicates if the next sequence of Char events should be suppressed or not.
745 bool suppress_next_char_events_;
747 // Properties of the screen hosting this RenderWidget instance.
748 blink::WebScreenInfo screen_info_;
750 // The device scale factor. This value is computed from the DPI entries in
751 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
752 float device_scale_factor_;
754 // The device color profile on supported platforms.
755 std::vector<char> device_color_profile_;
757 // State associated with synthetic gestures. Synthetic gestures are processed
758 // in-order, so a queue is sufficient to identify the correct state for a
759 // completed gesture.
760 std::queue<SyntheticGestureCompletionCallback>
761 pending_synthetic_gesture_callbacks_;
763 const ui::LatencyInfo* current_event_latency_info_;
765 uint32 next_output_surface_id_;
767 #if defined(OS_ANDROID)
768 // Indicates value in the focused text field is in dirty state, i.e. modified
769 // by script etc., not by user input.
770 bool text_field_is_dirty_;
772 // A counter for number of outstanding messages from the renderer to the
773 // browser regarding IME-type events that have not been acknowledged by the
774 // browser. If this value is not 0 IME events will be dropped.
775 int outstanding_ime_acks_;
777 // The background color of the document body element. This is used as the
778 // default background color for filling the screen areas for which we don't
779 // have the actual content.
780 SkColor body_background_color_;
781 #endif
783 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
785 // Popups may be displaced when screen metrics emulation is enabled.
786 // These values are used to properly adjust popup position.
787 gfx::Point popup_view_origin_for_emulation_;
788 gfx::Point popup_screen_origin_for_emulation_;
789 float popup_origin_scale_for_emulation_;
791 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
792 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
794 // Lists of RenderFrameProxy objects that need to be notified of
795 // compositing-related events (e.g. DidCommitCompositorFrame).
796 ObserverList<RenderFrameProxy> render_frame_proxies_;
797 #if defined(VIDEO_HOLE)
798 ObserverList<RenderFrameImpl> video_hole_frames_;
799 #endif // defined(VIDEO_HOLE)
801 // A list of RenderFrames associated with this RenderWidget. Notifications
802 // are sent to each frame in the list for events such as changing
803 // visibility state for example.
804 ObserverList<RenderFrameImpl> render_frames_;
806 ui::MenuSourceType context_menu_source_type_;
807 bool has_host_context_menu_location_;
808 gfx::Point host_context_menu_location_;
810 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
813 } // namespace content
815 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_