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