Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob523a38e2c522981f9a0e67dabaa50190cee60cd4
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/native_widget_types.h"
40 #include "ui/gfx/range/range.h"
41 #include "ui/gfx/rect.h"
42 #include "ui/gfx/vector2d.h"
43 #include "ui/gfx/vector2d_f.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 WebGestureEvent;
58 class WebKeyboardEvent;
59 class WebMouseEvent;
60 class WebTouchEvent;
63 namespace cc {
64 class OutputSurface;
65 class SwapPromise;
68 namespace gfx {
69 class Range;
72 namespace content {
73 class ExternalPopupMenu;
74 class FrameSwapMessageQueue;
75 class PepperPluginInstanceImpl;
76 class RenderFrameImpl;
77 class RenderFrameProxy;
78 class RenderWidgetCompositor;
79 class RenderWidgetTest;
80 class ResizingModeSelector;
81 struct ContextMenuParams;
82 struct WebPluginGeometry;
84 // RenderWidget provides a communication bridge between a WebWidget and
85 // a RenderWidgetHost, the latter of which lives in a different process.
86 class CONTENT_EXPORT RenderWidget
87 : public IPC::Listener,
88 public IPC::Sender,
89 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
90 public base::RefCounted<RenderWidget> {
91 public:
92 // Creates a new RenderWidget. The opener_id is the routing ID of the
93 // RenderView that this widget lives inside.
94 static RenderWidget* Create(int32 opener_id,
95 blink::WebPopupType popup_type,
96 const blink::WebScreenInfo& screen_info);
98 // Creates a WebWidget based on the popup type.
99 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
101 int32 routing_id() const { return routing_id_; }
102 int32 surface_id() const { return surface_id_; }
103 blink::WebWidget* webwidget() const { return webwidget_; }
104 gfx::Size size() const { return size_; }
105 bool has_focus() const { return has_focus_; }
106 bool is_fullscreen() const { return is_fullscreen_; }
107 bool is_hidden() const { return is_hidden_; }
108 bool handling_input_event() const { return handling_input_event_; }
109 // Temporary for debugging purposes...
110 bool closing() const { return closing_; }
111 bool is_swapped_out() { return is_swapped_out_; }
112 ui::MenuSourceType context_menu_source_type() {
113 return context_menu_source_type_;
115 bool has_host_context_menu_location() {
116 return has_host_context_menu_location_;
118 gfx::Point host_context_menu_location() {
119 return host_context_menu_location_;
122 // Functions to track out-of-process frames for special notifications.
123 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
124 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
126 // Functions to track all RenderFrame objects associated with this
127 // RenderWidget.
128 void RegisterRenderFrame(RenderFrameImpl* frame);
129 void UnregisterRenderFrame(RenderFrameImpl* frame);
131 #if defined(VIDEO_HOLE)
132 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
133 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
134 #endif // defined(VIDEO_HOLE)
136 // IPC::Listener
137 bool OnMessageReceived(const IPC::Message& msg) override;
139 // IPC::Sender
140 bool Send(IPC::Message* msg) override;
142 // blink::WebWidgetClient
143 virtual void willBeginCompositorFrame();
144 virtual void didAutoResize(const blink::WebSize& new_size);
145 virtual void initializeLayerTreeView();
146 virtual blink::WebLayerTreeView* layerTreeView();
147 virtual void didBecomeReadyForAdditionalInput();
148 virtual void didCommitAndDrawCompositorFrame();
149 virtual void didCompleteSwapBuffers();
150 virtual void scheduleComposite();
151 virtual void didFocus();
152 virtual void didBlur();
153 virtual void didChangeCursor(const blink::WebCursorInfo&);
154 virtual void closeWidgetSoon();
155 virtual void show(blink::WebNavigationPolicy);
156 virtual void runModal() {}
157 virtual blink::WebRect windowRect();
158 virtual void setToolTipText(const blink::WebString& text,
159 blink::WebTextDirection hint);
160 virtual void setWindowRect(const blink::WebRect&);
161 virtual blink::WebRect windowResizerRect();
162 virtual blink::WebRect rootWindowRect();
163 virtual blink::WebScreenInfo screenInfo();
164 virtual float deviceScaleFactor();
165 virtual void resetInputMethod();
166 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
167 bool event_cancelled);
168 virtual void showImeIfNeeded();
170 // Begins the compositor's scheduler to start producing frames.
171 void StartCompositor();
173 // Stop compositing.
174 void DestroyLayerTreeView();
176 // Called when a plugin is moved. These events are queued up and sent with
177 // the next paint or scroll message to the host.
178 void SchedulePluginMove(const WebPluginGeometry& move);
180 // Called when a plugin window has been destroyed, to make sure the currently
181 // pending moves don't try to reference it.
182 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
184 RenderWidgetCompositor* compositor() const;
186 const ui::LatencyInfo* current_event_latency_info() const {
187 return current_event_latency_info_;
190 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
192 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
193 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
195 // Send a synthetic gesture to the browser to be queued to the synthetic
196 // gesture controller.
197 void QueueSyntheticGesture(
198 scoped_ptr<SyntheticGestureParams> gesture_params,
199 const SyntheticGestureCompletionCallback& callback);
201 // Close the underlying WebWidget.
202 virtual void Close();
204 // Notifies about a compositor frame commit operation having finished.
205 virtual void DidCommitCompositorFrame();
207 // Deliveres |message| together with compositor state change updates. The
208 // exact behavior depends on |policy|.
209 // This mechanism is not a drop-in replacement for IPC: messages sent this way
210 // will not be automatically available to BrowserMessageFilter, for example.
211 // FIFO ordering is preserved between messages enqueued with the same
212 // |policy|, the ordering between messages enqueued for different policies is
213 // undefined.
215 // |msg| message to send, ownership of |msg| is transferred.
216 // |policy| see the comment on MessageDeliveryPolicy.
217 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
219 // Handle common setup/teardown for handling IME events.
220 void StartHandlingImeEvent();
221 void FinishHandlingImeEvent();
223 // Returns whether we currently should handle an IME event.
224 bool ShouldHandleImeEvent();
226 virtual void InstrumentWillBeginFrame(int frame_id) {}
227 virtual void InstrumentDidBeginFrame() {}
228 virtual void InstrumentDidCancelFrame() {}
229 virtual void InstrumentWillComposite() {}
231 // When paused in debugger, we send ack for mouse event early. This ensures
232 // that we continue receiving mouse moves and pass them to debugger. Returns
233 // whether we are paused in mouse move event and have sent the ack.
234 bool SendAckForMouseMoveFromDebugger();
236 // When resumed from pause in debugger while handling mouse move,
237 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
238 void IgnoreAckForMouseMoveFromDebugger();
240 // ScreenMetricsEmulator class manages screen emulation inside a render
241 // widget. This includes resizing, placing view on the screen at desired
242 // position, changing device scale factor, and scaling down the whole
243 // widget if required to fit into the browser window.
244 class ScreenMetricsEmulator;
246 // Emulates screen and widget metrics. Supplied values override everything
247 // coming from host.
248 void EnableScreenMetricsEmulation(
249 const blink::WebDeviceEmulationParams& params);
250 void DisableScreenMetricsEmulation();
251 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
252 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
254 void ScheduleCompositeWithForcedRedraw();
256 // Called by the compositor in single-threaded mode when a swap is posted,
257 // completes or is aborted.
258 void OnSwapBuffersPosted();
259 void OnSwapBuffersComplete();
260 void OnSwapBuffersAborted();
262 // Checks if the text input state and compose inline mode have been changed.
263 // If they are changed, the new value will be sent to the browser process.
264 void UpdateTextInputType();
266 // Checks if the selection bounds have been changed. If they are changed,
267 // the new value will be sent to the browser process.
268 void UpdateSelectionBounds();
270 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
272 void OnShowHostContextMenu(ContextMenuParams* params);
274 #if defined(OS_ANDROID) || defined(USE_AURA)
275 enum ShowIme {
276 SHOW_IME_IF_NEEDED,
277 NO_SHOW_IME,
280 enum ChangeSource {
281 FROM_NON_IME,
282 FROM_IME,
285 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
286 // be displayed, e.g. after a tap on an input field on mobile.
287 // |change_source| should be FROM_NON_IME when the renderer has to wait for
288 // the browser to acknowledge the change before the renderer handles any more
289 // IME events. This is when the text change did not originate from the IME in
290 // the browser side, such as changes by JavaScript or autofill.
291 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
292 #endif
294 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
295 // Checks if the composition range or composition character bounds have been
296 // changed. If they are changed, the new value will be sent to the browser
297 // process. This method does nothing when the browser process is not able to
298 // handle composition range and composition character bounds.
299 void UpdateCompositionInfo(bool should_update_range);
300 #endif
302 #if defined(OS_ANDROID)
303 void DidChangeBodyBackgroundColor(SkColor bg_color);
304 #endif
306 protected:
307 // Friend RefCounted so that the dtor can be non-public. Using this class
308 // without ref-counting is an error.
309 friend class base::RefCounted<RenderWidget>;
310 // For unit tests.
311 friend class RenderWidgetTest;
313 enum ResizeAck {
314 SEND_RESIZE_ACK,
315 NO_RESIZE_ACK,
318 RenderWidget(blink::WebPopupType popup_type,
319 const blink::WebScreenInfo& screen_info,
320 bool swapped_out,
321 bool hidden,
322 bool never_visible);
324 ~RenderWidget() override;
326 // Initializes this view with the given opener. CompleteInit must be called
327 // later.
328 bool Init(int32 opener_id);
330 // Called by Init and subclasses to perform initialization.
331 bool DoInit(int32 opener_id,
332 blink::WebWidget* web_widget,
333 IPC::SyncMessage* create_widget_message);
335 // Finishes creation of a pending view started with Init.
336 void CompleteInit();
338 // Sets whether this RenderWidget has been swapped out to be displayed by
339 // a RenderWidget in a different process. If so, no new IPC messages will be
340 // sent (only ACKs) and the process is free to exit when there are no other
341 // active RenderWidgets.
342 void SetSwappedOut(bool is_swapped_out);
344 // Allows the process to exit once the unload handler has finished, if there
345 // are no other active RenderWidgets.
346 void WasSwappedOut();
348 void FlushPendingInputEventAck();
349 void DoDeferredClose();
350 void DoDeferredSetWindowRect(const blink::WebRect& pos);
352 // Resizes the render widget.
353 void Resize(const gfx::Size& new_size,
354 const gfx::Size& physical_backing_size,
355 float top_controls_layout_height,
356 const gfx::Size& visible_viewport_size,
357 const gfx::Rect& resizer_rect,
358 bool is_fullscreen,
359 ResizeAck resize_ack);
360 // Used to force the size of a window when running layout tests.
361 void ResizeSynchronously(
362 const gfx::Rect& new_position,
363 const gfx::Size& visible_viewport_size);
364 virtual void SetScreenMetricsEmulationParameters(
365 float device_scale_factor,
366 const gfx::Point& root_layer_offset,
367 float root_layer_scale);
368 #if defined(OS_MACOSX) || defined(OS_ANDROID)
369 void SetExternalPopupOriginAdjustmentsForEmulation(
370 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
371 #endif
373 // RenderWidget IPC message handlers
374 void OnHandleInputEvent(const blink::WebInputEvent* event,
375 const ui::LatencyInfo& latency_info,
376 bool keyboard_shortcut);
377 void OnCursorVisibilityChange(bool is_visible);
378 void OnMouseCaptureLost();
379 virtual void OnSetFocus(bool enable);
380 virtual void OnClose();
381 void OnCreatingNewAck();
382 virtual void OnResize(const ViewMsg_Resize_Params& params);
383 void OnColorProfile(const std::vector<char>& color_profile);
384 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
385 virtual void OnWasHidden();
386 virtual void OnWasShown(bool needs_repainting,
387 const ui::LatencyInfo& latency_info);
388 void OnCreateVideoAck(int32 video_id);
389 void OnUpdateVideoAck(int32 video_id);
390 void OnRequestMoveAck();
391 void OnSetInputMethodActive(bool is_active);
392 void OnCandidateWindowShown();
393 void OnCandidateWindowUpdated();
394 void OnCandidateWindowHidden();
395 virtual void OnImeSetComposition(
396 const base::string16& text,
397 const std::vector<blink::WebCompositionUnderline>& underlines,
398 int selection_start,
399 int selection_end);
400 virtual void OnImeConfirmComposition(const base::string16& text,
401 const gfx::Range& replacement_range,
402 bool keep_selection);
403 void OnRepaint(gfx::Size size_to_paint);
404 void OnSyntheticGestureCompleted();
405 void OnSetTextDirection(blink::WebTextDirection direction);
406 void OnGetFPS();
407 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
408 const gfx::Rect& window_screen_rect);
409 void OnShowImeIfNeeded();
411 #if defined(OS_ANDROID)
412 // Whenever an IME event that needs an acknowledgement is sent to the browser,
413 // the number of outstanding IME events that needs acknowledgement should be
414 // incremented. All IME events will be dropped until we receive an ack from
415 // the browser.
416 void IncrementOutstandingImeEventAcks();
418 // Called by the browser process for every required IME acknowledgement.
419 void OnImeEventAck();
420 #endif
422 // Notify the compositor about a change in viewport size. This should be
423 // used only with auto resize mode WebWidgets, as normal WebWidgets should
424 // go through OnResize.
425 void AutoResizeCompositor();
427 virtual void SetDeviceScaleFactor(float device_scale_factor);
428 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
429 virtual void ResetDeviceColorProfileForTesting();
431 virtual void OnOrientationChange();
433 // Override points to notify derived classes that a paint has happened.
434 // DidInitiatePaint happens when that has completed, and subsequent rendering
435 // won't affect the painted content. DidFlushPaint happens once we've received
436 // the ACK that the screen has been updated. For a given paint operation,
437 // these overrides will always be called in the order DidInitiatePaint,
438 // DidFlushPaint.
439 virtual void DidInitiatePaint() {}
440 virtual void DidFlushPaint() {}
442 virtual GURL GetURLForGraphicsContext3D();
444 // Gets the scroll offset of this widget, if this widget has a notion of
445 // scroll offset.
446 virtual gfx::Vector2d GetScrollOffset();
448 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
449 // use this method so that we can properly inform the RenderThread of our
450 // state.
451 void SetHidden(bool hidden);
453 void WillToggleFullscreen();
454 void DidToggleFullscreen();
456 bool next_paint_is_resize_ack() const;
457 void set_next_paint_is_resize_ack();
458 void set_next_paint_is_repaint_ack();
460 // QueueMessage implementation extracted into a static method for easy
461 // testing.
462 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
463 IPC::Message* msg,
464 MessageDeliveryPolicy policy,
465 FrameSwapMessageQueue* frame_swap_message_queue,
466 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
467 bool commit_requested,
468 int source_frame_number);
470 // Override point to obtain that the current input method state and caret
471 // position.
472 virtual ui::TextInputType GetTextInputType();
473 virtual ui::TextInputType WebKitToUiTextInputType(
474 blink::WebTextInputType type);
476 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
477 // Override point to obtain that the current composition character bounds.
478 // In the case of surrogate pairs, the character is treated as two characters:
479 // the bounds for first character is actual one, and the bounds for second
480 // character is zero width rectangle.
481 virtual void GetCompositionCharacterBounds(
482 std::vector<gfx::Rect>* character_bounds);
484 // Returns the range of the text that is being composed or the selection if
485 // the composition does not exist.
486 virtual void GetCompositionRange(gfx::Range* range);
488 // Returns true if the composition range or composition character bounds
489 // should be sent to the browser process.
490 bool ShouldUpdateCompositionInfo(
491 const gfx::Range& range,
492 const std::vector<gfx::Rect>& bounds);
493 #endif
495 // Override point to obtain that the current input method state about
496 // composition text.
497 virtual bool CanComposeInline();
499 // Tells the renderer it does not have focus. Used to prevent us from getting
500 // the focus on our own when the browser did not focus us.
501 void ClearFocus();
503 // Set the pending window rect.
504 // Because the real render_widget is hosted in another process, there is
505 // a time period where we may have set a new window rect which has not yet
506 // been processed by the browser. So we maintain a pending window rect
507 // size. If JS code sets the WindowRect, and then immediately calls
508 // GetWindowRect() we'll use this pending window rect as the size.
509 void SetPendingWindowRect(const blink::WebRect& r);
511 // Called by OnHandleInputEvent() to notify subclasses that a key event was
512 // just handled.
513 virtual void DidHandleKeyEvent() {}
515 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
516 // about to be handled.
517 // Returns true if no further handling is needed. In that case, the event
518 // won't be sent to WebKit or trigger DidHandleMouseEvent().
519 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
521 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
522 // about to be handled.
523 // Returns true if no further handling is needed. In that case, the event
524 // won't be sent to WebKit.
525 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
527 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
528 // just handled.
529 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
531 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
532 // just handled.
533 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
535 // Check whether the WebWidget has any touch event handlers registered
536 // at the given point.
537 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
539 // Check whether the WebWidget has any touch event handlers registered.
540 virtual void hasTouchEventHandlers(bool has_handlers);
542 // Tell the browser about the actions permitted for a new touch point.
543 virtual void setTouchAction(blink::WebTouchAction touch_action);
545 // Called when value of focused text field gets dirty, e.g. value is modified
546 // by script, not by user input.
547 virtual void didUpdateTextOfFocusedElementByNonUserInput();
549 // Creates a 3D context associated with this view.
550 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
552 // Routing ID that allows us to communicate to the parent browser process
553 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
554 int32 routing_id_;
556 int32 surface_id_;
558 // We are responsible for destroying this object via its Close method.
559 // May be NULL when the window is closing.
560 blink::WebWidget* webwidget_;
562 // This is lazily constructed and must not outlive webwidget_.
563 scoped_ptr<RenderWidgetCompositor> compositor_;
565 // Set to the ID of the view that initiated creating this view, if any. When
566 // the view was initiated by the browser (the common case), this will be
567 // MSG_ROUTING_NONE. This is used in determining ownership when opening
568 // child tabs. See RenderWidget::createWebViewWithRequest.
570 // This ID may refer to an invalid view if that view is closed before this
571 // view is.
572 int32 opener_id_;
574 // The position where this view should be initially shown.
575 gfx::Rect initial_pos_;
577 bool init_complete_;
579 // We store the current cursor object so we can avoid spamming SetCursor
580 // messages.
581 WebCursor current_cursor_;
583 // The size of the RenderWidget.
584 gfx::Size size_;
586 // The size of the view's backing surface in non-DPI-adjusted pixels.
587 gfx::Size physical_backing_size_;
589 // The amount that the viewport size given to Blink was shrunk by the URL-bar
590 // (always 0 on platforms where URL-bar hiding isn't supported).
591 float top_controls_layout_height_;
593 // The size of the visible viewport in DPI-adjusted pixels.
594 gfx::Size visible_viewport_size_;
596 // The area that must be reserved for drawing the resize corner.
597 gfx::Rect resizer_rect_;
599 // Flags for the next ViewHostMsg_UpdateRect message.
600 int next_paint_flags_;
602 // Whether the WebWidget is in auto resize mode, which is used for example
603 // by extension popups.
604 bool auto_resize_mode_;
606 // True if we need to send an UpdateRect message to notify the browser about
607 // an already-completed auto-resize.
608 bool need_update_rect_for_auto_resize_;
610 // Set to true if we should ignore RenderWidget::Show calls.
611 bool did_show_;
613 // Indicates that we shouldn't bother generated paint events.
614 bool is_hidden_;
616 // Indicates that we are never visible, so never produce graphical output.
617 bool never_visible_;
619 // Indicates that we are in fullscreen mode.
620 bool is_fullscreen_;
622 // Indicates whether we have been focused/unfocused by the browser.
623 bool has_focus_;
625 // Are we currently handling an input event?
626 bool handling_input_event_;
628 // Are we currently handling an ime event?
629 bool handling_ime_event_;
631 // Type of the input event we are currently handling.
632 blink::WebInputEvent::Type handling_event_type_;
634 // Whether we should not send ack for the current mouse move.
635 bool ignore_ack_for_mouse_move_from_debugger_;
637 // True if we have requested this widget be closed. No more messages will
638 // be sent, except for a Close.
639 bool closing_;
641 // True if it is known that the host is in the process of being shut down.
642 bool host_closing_;
644 // Whether this RenderWidget is currently swapped out, such that the view is
645 // being rendered by another process. If all RenderWidgets in a process are
646 // swapped out, the process can exit.
647 bool is_swapped_out_;
649 // Indicates if an input method is active in the browser process.
650 bool input_method_is_active_;
652 // Stores information about the current text input.
653 blink::WebTextInputInfo text_input_info_;
655 // Stores the current text input type of |webwidget_|.
656 ui::TextInputType text_input_type_;
658 // Stores the current text input mode of |webwidget_|.
659 ui::TextInputMode text_input_mode_;
661 // Stores the current text input flags of |webwidget_|.
662 int text_input_flags_;
664 // Stores the current type of composition text rendering of |webwidget_|.
665 bool can_compose_inline_;
667 // Stores the current selection bounds.
668 gfx::Rect selection_focus_rect_;
669 gfx::Rect selection_anchor_rect_;
671 // Stores the current composition character bounds.
672 std::vector<gfx::Rect> composition_character_bounds_;
674 // Stores the current composition range.
675 gfx::Range composition_range_;
677 // The kind of popup this widget represents, NONE if not a popup.
678 blink::WebPopupType popup_type_;
680 // Holds all the needed plugin window moves for a scroll.
681 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
682 WebPluginGeometryVector plugin_window_moves_;
684 // While we are waiting for the browser to update window sizes, we track the
685 // pending size temporarily.
686 int pending_window_rect_count_;
687 blink::WebRect pending_window_rect_;
689 // The screen rects of the view and the window that contains it.
690 gfx::Rect view_screen_rect_;
691 gfx::Rect window_screen_rect_;
693 scoped_ptr<IPC::Message> pending_input_event_ack_;
695 // The time spent in input handlers this frame. Used to throttle input acks.
696 base::TimeDelta total_input_handling_time_this_frame_;
698 // Indicates if the next sequence of Char events should be suppressed or not.
699 bool suppress_next_char_events_;
701 // Properties of the screen hosting this RenderWidget instance.
702 blink::WebScreenInfo screen_info_;
704 // The device scale factor. This value is computed from the DPI entries in
705 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
706 float device_scale_factor_;
708 // The device color profile on supported platforms.
709 std::vector<char> device_color_profile_;
711 // State associated with synthetic gestures. Synthetic gestures are processed
712 // in-order, so a queue is sufficient to identify the correct state for a
713 // completed gesture.
714 std::queue<SyntheticGestureCompletionCallback>
715 pending_synthetic_gesture_callbacks_;
717 const ui::LatencyInfo* current_event_latency_info_;
719 uint32 next_output_surface_id_;
721 #if defined(OS_ANDROID)
722 // Indicates value in the focused text field is in dirty state, i.e. modified
723 // by script etc., not by user input.
724 bool text_field_is_dirty_;
726 // A counter for number of outstanding messages from the renderer to the
727 // browser regarding IME-type events that have not been acknowledged by the
728 // browser. If this value is not 0 IME events will be dropped.
729 int outstanding_ime_acks_;
731 // The background color of the document body element. This is used as the
732 // default background color for filling the screen areas for which we don't
733 // have the actual content.
734 SkColor body_background_color_;
735 #endif
737 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
739 // Popups may be displaced when screen metrics emulation is enabled.
740 // These values are used to properly adjust popup position.
741 gfx::Point popup_view_origin_for_emulation_;
742 gfx::Point popup_screen_origin_for_emulation_;
743 float popup_origin_scale_for_emulation_;
745 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
746 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
748 // Lists of RenderFrameProxy objects that need to be notified of
749 // compositing-related events (e.g. DidCommitCompositorFrame).
750 ObserverList<RenderFrameProxy> render_frame_proxies_;
751 #if defined(VIDEO_HOLE)
752 ObserverList<RenderFrameImpl> video_hole_frames_;
753 #endif // defined(VIDEO_HOLE)
755 // A list of RenderFrames associated with this RenderWidget. Notifications
756 // are sent to each frame in the list for events such as changing
757 // visibility state for example.
758 ObserverList<RenderFrameImpl> render_frames_;
760 ui::MenuSourceType context_menu_source_type_;
761 bool has_host_context_menu_location_;
762 gfx::Point host_context_menu_location_;
764 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
767 } // namespace content
769 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_