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_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/time/time.h"
17 #include "base/timer/timer.h"
18 #include "cc/debug/rendering_stats_instrumentation.h"
19 #include "content/common/content_export.h"
20 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
21 #include "content/common/input/synthetic_gesture_params.h"
22 #include "content/renderer/paint_aggregator.h"
23 #include "ipc/ipc_listener.h"
24 #include "ipc/ipc_sender.h"
25 #include "third_party/WebKit/public/platform/WebRect.h"
26 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
27 #include "third_party/WebKit/public/web/WebPopupType.h"
28 #include "third_party/WebKit/public/web/WebTextDirection.h"
29 #include "third_party/WebKit/public/web/WebTextInputInfo.h"
30 #include "third_party/WebKit/public/web/WebTouchAction.h"
31 #include "third_party/WebKit/public/web/WebWidget.h"
32 #include "third_party/WebKit/public/web/WebWidgetClient.h"
33 #include "third_party/skia/include/core/SkBitmap.h"
34 #include "ui/base/ime/text_input_mode.h"
35 #include "ui/base/ime/text_input_type.h"
36 #include "ui/base/ui_base_types.h"
37 #include "ui/gfx/native_widget_types.h"
38 #include "ui/gfx/range/range.h"
39 #include "ui/gfx/rect.h"
40 #include "ui/gfx/vector2d.h"
41 #include "ui/gfx/vector2d_f.h"
42 #include "ui/surface/transport_dib.h"
43 #include "webkit/common/cursors/webcursor.h"
45 struct ViewHostMsg_UpdateRect_Params;
46 struct ViewMsg_Resize_Params;
47 class ViewHostMsg_UpdateRect;
54 class WebGestureEvent;
56 class WebKeyboardEvent;
61 namespace cc { class OutputSurface; }
68 class ExternalPopupMenu;
69 class PepperPluginInstanceImpl;
70 class RenderFrameImpl;
71 class RenderWidgetCompositor;
72 class RenderWidgetTest;
73 class ResizingModeSelector;
74 struct ContextMenuParams;
75 struct WebPluginGeometry;
77 // RenderWidget provides a communication bridge between a WebWidget and
78 // a RenderWidgetHost, the latter of which lives in a different process.
79 class CONTENT_EXPORT RenderWidget
80 : public IPC::Listener,
82 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
83 public base::RefCounted<RenderWidget> {
85 // Creates a new RenderWidget. The opener_id is the routing ID of the
86 // RenderView that this widget lives inside.
87 static RenderWidget* Create(int32 opener_id,
88 blink::WebPopupType popup_type,
89 const blink::WebScreenInfo& screen_info);
91 // Creates a WebWidget based on the popup type.
92 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
94 // The compositing surface assigned by the RenderWidgetHost
95 // (or RenderViewHost). Will be gfx::kNullPluginWindow if not assigned yet,
96 // in which case we should not create any GPU command buffers with it.
97 // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
98 // not yet assigned a view ID, in which case, the process MUST NOT send
99 // messages with this ID to the parent.
100 int32 routing_id() const {
104 int32 surface_id() const {
108 // May return NULL when the window is closing.
109 blink::WebWidget* webwidget() const { return webwidget_; }
111 gfx::Size size() const { return size_; }
112 bool has_focus() const { return has_focus_; }
113 bool is_fullscreen() const { return is_fullscreen_; }
114 bool is_hidden() const { return is_hidden_; }
116 // Functions to track out-of-process frames for special notifications.
117 void RegisterSwappedOutChildFrame(RenderFrameImpl* frame);
118 void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame);
121 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
124 virtual bool Send(IPC::Message* msg) OVERRIDE;
126 // blink::WebWidgetClient
127 virtual void suppressCompositorScheduling(bool enable);
128 virtual void willBeginCompositorFrame();
129 virtual void didInvalidateRect(const blink::WebRect&);
130 virtual void didScrollRect(int dx, int dy,
131 const blink::WebRect& clipRect);
132 virtual void didAutoResize(const blink::WebSize& new_size);
133 virtual void didActivateCompositor(int input_handler_identifier);
134 virtual void didDeactivateCompositor();
135 virtual void initializeLayerTreeView();
136 virtual blink::WebLayerTreeView* layerTreeView();
137 virtual void didBecomeReadyForAdditionalInput();
138 virtual void didCommitAndDrawCompositorFrame();
139 virtual void didCompleteSwapBuffers();
140 virtual void scheduleComposite();
141 virtual void scheduleAnimation();
142 virtual void didFocus();
143 virtual void didBlur();
144 virtual void didChangeCursor(const blink::WebCursorInfo&);
145 virtual void closeWidgetSoon();
146 virtual void show(blink::WebNavigationPolicy);
147 virtual void runModal() {}
148 virtual blink::WebRect windowRect();
149 virtual void setToolTipText(const blink::WebString& text,
150 blink::WebTextDirection hint);
151 virtual void setWindowRect(const blink::WebRect&);
152 virtual blink::WebRect windowResizerRect();
153 virtual blink::WebRect rootWindowRect();
154 virtual blink::WebScreenInfo screenInfo();
155 virtual float deviceScaleFactor();
156 virtual void resetInputMethod();
157 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
158 bool event_cancelled);
160 // Called when a plugin is moved. These events are queued up and sent with
161 // the next paint or scroll message to the host.
162 void SchedulePluginMove(const WebPluginGeometry& move);
164 // Called when a plugin window has been destroyed, to make sure the currently
165 // pending moves don't try to reference it.
166 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
168 RenderWidgetCompositor* compositor() const;
170 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
172 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
173 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
175 // Send a synthetic gesture to the browser to be queued to the synthetic
176 // gesture controller.
177 void QueueSyntheticGesture(
178 scoped_ptr<SyntheticGestureParams> gesture_params,
179 const SyntheticGestureCompletionCallback& callback);
181 // Close the underlying WebWidget.
182 virtual void Close();
184 // Notifies about a compositor frame commit operation having finished.
185 virtual void DidCommitCompositorFrame();
187 float filtered_time_per_frame() const {
188 return filtered_time_per_frame_;
191 // Handle common setup/teardown for handling IME events.
192 void StartHandlingImeEvent();
193 void FinishHandlingImeEvent();
195 virtual void InstrumentWillBeginFrame(int frame_id) {}
196 virtual void InstrumentDidBeginFrame() {}
197 virtual void InstrumentDidCancelFrame() {}
198 virtual void InstrumentWillComposite() {}
200 virtual bool AllowPartialSwap() const;
201 bool UsingSynchronousRendererCompositor() const;
203 bool is_swapped_out() { return is_swapped_out_; }
205 // ScreenMetricsEmulator class manages screen emulation inside a render
206 // widget. This includes resizing, placing view on the screen at desired
207 // position, changing device scale factor, and scaling down the whole
208 // widget if required to fit into the browser window.
209 class ScreenMetricsEmulator;
211 // Emulates screen and widget metrics. Supplied values override everything
213 void EnableScreenMetricsEmulation(
214 const gfx::Rect& device_rect,
215 const gfx::Rect& widget_rect,
216 float device_scale_factor,
218 void DisableScreenMetricsEmulation();
219 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
221 void ScheduleCompositeWithForcedRedraw();
223 // Called by the compositor in single-threaded mode when a swap is posted,
224 // completes or is aborted.
225 void OnSwapBuffersPosted();
226 void OnSwapBuffersComplete();
227 void OnSwapBuffersAborted();
229 // Checks if the text input state and compose inline mode have been changed.
230 // If they are changed, the new value will be sent to the browser process.
231 void UpdateTextInputType();
233 // Checks if the selection bounds have been changed. If they are changed,
234 // the new value will be sent to the browser process.
235 void UpdateSelectionBounds();
237 void OnShowHostContextMenu(ContextMenuParams* params);
239 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
240 // Checks if the composition range or composition character bounds have been
241 // changed. If they are changed, the new value will be sent to the browser
243 void UpdateCompositionInfo(bool should_update_range);
246 // Temporary for debugging purposes...
247 bool closing() const { return closing_; }
249 ui::MenuSourceType context_menu_source_type() {
250 return context_menu_source_type_; }
251 gfx::Point touch_editing_context_menu_location() {
252 return touch_editing_context_menu_location_;
256 // Friend RefCounted so that the dtor can be non-public. Using this class
257 // without ref-counting is an error.
258 friend class base::RefCounted<RenderWidget>;
260 friend class RenderWidgetTest;
267 RenderWidget(blink::WebPopupType popup_type,
268 const blink::WebScreenInfo& screen_info,
272 virtual ~RenderWidget();
274 // Initializes this view with the given opener. CompleteInit must be called
276 bool Init(int32 opener_id);
278 // Called by Init and subclasses to perform initialization.
279 bool DoInit(int32 opener_id,
280 blink::WebWidget* web_widget,
281 IPC::SyncMessage* create_widget_message);
283 // Finishes creation of a pending view started with Init.
286 // Sets whether this RenderWidget has been swapped out to be displayed by
287 // a RenderWidget in a different process. If so, no new IPC messages will be
288 // sent (only ACKs) and the process is free to exit when there are no other
289 // active RenderWidgets.
290 void SetSwappedOut(bool is_swapped_out);
292 // Paints the given rectangular region of the WebWidget into canvas (a
293 // shared memory segment returned by AllocPaintBuf on Windows). The caller
294 // must ensure that the given rect fits within the bounds of the WebWidget.
295 void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin,
298 // Paints a border at the given rect for debugging purposes.
299 void PaintDebugBorder(const gfx::Rect& rect, SkCanvas* canvas);
301 bool IsRenderingVSynced();
302 void AnimationCallback();
303 void AnimateIfNeeded();
304 void InvalidationCallback();
305 void FlushPendingInputEventAck();
306 void DoDeferredUpdateAndSendInputAck();
307 void DoDeferredUpdate();
308 void DoDeferredClose();
309 void DoDeferredSetWindowRect(const blink::WebRect& pos);
310 virtual void Composite(base::TimeTicks frame_begin_time);
312 // Set the background of the render widget to a bitmap. The bitmap will be
313 // tiled in both directions if it isn't big enough to fill the area. This is
314 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
315 virtual void SetBackground(const SkBitmap& bitmap);
317 // Resizes the render widget.
318 void Resize(const gfx::Size& new_size,
319 const gfx::Size& physical_backing_size,
320 float overdraw_bottom_height,
321 const gfx::Rect& resizer_rect,
323 ResizeAck resize_ack);
324 // Used to force the size of a window when running layout tests.
325 void ResizeSynchronously(const gfx::Rect& new_position);
326 virtual void SetScreenMetricsEmulationParameters(
327 float device_scale_factor,
328 const gfx::Point& root_layer_offset,
329 float root_layer_scale);
330 void SetExternalPopupOriginAdjustmentsForEmulation(
331 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
333 // RenderWidget IPC message handlers
334 void OnHandleInputEvent(const blink::WebInputEvent* event,
335 ui::LatencyInfo latency_info,
336 bool keyboard_shortcut);
337 void OnCursorVisibilityChange(bool is_visible);
338 void OnMouseCaptureLost();
339 virtual void OnSetFocus(bool enable);
341 void OnCreatingNewAck();
342 virtual void OnResize(const ViewMsg_Resize_Params& params);
343 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
344 virtual void OnWasHidden();
345 virtual void OnWasShown(bool needs_repainting);
346 virtual void OnWasSwappedOut();
347 void OnUpdateRectAck();
348 void OnCreateVideoAck(int32 video_id);
349 void OnUpdateVideoAck(int32 video_id);
350 void OnRequestMoveAck();
351 void OnSetInputMethodActive(bool is_active);
352 void OnCandidateWindowShown();
353 void OnCandidateWindowUpdated();
354 void OnCandidateWindowHidden();
355 virtual void OnImeSetComposition(
356 const base::string16& text,
357 const std::vector<blink::WebCompositionUnderline>& underlines,
360 virtual void OnImeConfirmComposition(const base::string16& text,
361 const gfx::Range& replacement_range,
362 bool keep_selection);
363 void OnRepaint(gfx::Size size_to_paint);
364 void OnSyntheticGestureCompleted();
365 void OnSetTextDirection(blink::WebTextDirection direction);
367 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
368 const gfx::Rect& window_screen_rect);
369 #if defined(OS_ANDROID)
370 void OnShowImeIfNeeded();
372 // Whenever an IME event that needs an acknowledgement is sent to the browser,
373 // the number of outstanding IME events that needs acknowledgement should be
374 // incremented. All IME events will be dropped until we receive an ack from
376 void IncrementOutstandingImeEventAcks();
378 // Called by the browser process for every required IME acknowledgement.
379 void OnImeEventAck();
381 // Returns whether we currently should handle an IME event.
382 bool ShouldHandleImeEvent();
384 void OnSnapshot(const gfx::Rect& src_subrect);
386 // Notify the compositor about a change in viewport size. This should be
387 // used only with auto resize mode WebWidgets, as normal WebWidgets should
388 // go through OnResize.
389 void AutoResizeCompositor();
391 virtual void SetDeviceScaleFactor(float device_scale_factor);
393 // Override points to notify derived classes that a paint has happened.
394 // DidInitiatePaint happens when that has completed, and subsequent rendering
395 // won't affect the painted content. DidFlushPaint happens once we've received
396 // the ACK that the screen has been updated. For a given paint operation,
397 // these overrides will always be called in the order DidInitiatePaint,
399 virtual void DidInitiatePaint() {}
400 virtual void DidFlushPaint() {}
402 // Override and return true when the widget is rendered with a graphics
403 // context that supports asynchronous swapbuffers. When returning true, the
404 // subclass must call OnSwapBuffersPosted() when swap is posted,
405 // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if
406 // the context is lost.
407 virtual bool SupportsAsynchronousSwapBuffers();
408 virtual GURL GetURLForGraphicsContext3D();
410 virtual bool ForceCompositingModeEnabled();
412 // Detects if a suitable opaque plugin covers the given paint bounds with no
413 // compositing necessary.
415 // Returns the plugin instance that's the source of the paint if the paint
416 // can be handled by just blitting the plugin bitmap. In this case, the
417 // location, clipping, and ID of the backing store will be filled into the
418 // given output parameters.
420 // A return value of null means optimized painting can not be used and we
421 // should continue with the normal painting code path.
422 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint(
423 const gfx::Rect& paint_bounds,
427 float* scale_factor);
429 // Gets the scroll offset of this widget, if this widget has a notion of
431 virtual gfx::Vector2d GetScrollOffset();
433 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
434 // use this method so that we can properly inform the RenderThread of our
436 void SetHidden(bool hidden);
438 void WillToggleFullscreen();
439 void DidToggleFullscreen();
441 bool next_paint_is_resize_ack() const;
442 bool next_paint_is_restore_ack() const;
443 void set_next_paint_is_resize_ack();
444 void set_next_paint_is_restore_ack();
445 void set_next_paint_is_repaint_ack();
447 #if defined(OS_ANDROID) || defined(USE_AURA)
448 // |show_ime_if_needed| should be true iff the update may cause the ime to be
449 // displayed, e.g. after a tap on an input field on mobile.
450 // |send_ime_ack| should be true iff the browser side is required to
451 // acknowledge the change before the renderer handles any more IME events.
452 // This is when the event did not originate from the browser side IME, such as
453 // changes from JavaScript or autofill.
454 void UpdateTextInputState(bool show_ime_if_needed, bool send_ime_ack);
457 // Override point to obtain that the current input method state and caret
459 virtual ui::TextInputType GetTextInputType();
460 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
461 virtual ui::TextInputType WebKitToUiTextInputType(
462 blink::WebTextInputType type);
464 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
465 // Override point to obtain that the current composition character bounds.
466 // In the case of surrogate pairs, the character is treated as two characters:
467 // the bounds for first character is actual one, and the bounds for second
468 // character is zero width rectangle.
469 virtual void GetCompositionCharacterBounds(
470 std::vector<gfx::Rect>* character_bounds);
472 // Returns the range of the text that is being composed or the selection if
473 // the composition does not exist.
474 virtual void GetCompositionRange(gfx::Range* range);
476 // Returns true if the composition range or composition character bounds
477 // should be sent to the browser process.
478 bool ShouldUpdateCompositionInfo(
479 const gfx::Range& range,
480 const std::vector<gfx::Rect>& bounds);
483 // Override point to obtain that the current input method state about
485 virtual bool CanComposeInline();
487 // Tells the renderer it does not have focus. Used to prevent us from getting
488 // the focus on our own when the browser did not focus us.
491 // Set the pending window rect.
492 // Because the real render_widget is hosted in another process, there is
493 // a time period where we may have set a new window rect which has not yet
494 // been processed by the browser. So we maintain a pending window rect
495 // size. If JS code sets the WindowRect, and then immediately calls
496 // GetWindowRect() we'll use this pending window rect as the size.
497 void SetPendingWindowRect(const blink::WebRect& r);
499 // Called by OnHandleInputEvent() to notify subclasses that a key event was
501 virtual void DidHandleKeyEvent() {}
503 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
504 // about to be handled.
505 // Returns true if no further handling is needed. In that case, the event
506 // won't be sent to WebKit or trigger DidHandleMouseEvent().
507 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
509 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
510 // about to be handled.
511 // Returns true if no further handling is needed. In that case, the event
512 // won't be sent to WebKit.
513 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
515 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
517 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
519 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
521 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
523 // Check whether the WebWidget has any touch event handlers registered
524 // at the given point.
525 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
527 // Check whether the WebWidget has any touch event handlers registered.
528 virtual void hasTouchEventHandlers(bool has_handlers);
530 // Tell the browser about the actions permitted for a new touch point.
531 virtual void setTouchAction(blink::WebTouchAction touch_action);
533 // Creates a 3D context associated with this view.
534 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(
535 const blink::WebGraphicsContext3D::Attributes& attributes);
537 bool OnSnapshotHelper(const gfx::Rect& src_subrect, SkBitmap* bitmap);
539 // Routing ID that allows us to communicate to the parent browser process
540 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
545 // We are responsible for destroying this object via its Close method.
546 blink::WebWidget* webwidget_;
548 // This is lazily constructed and must not outlive webwidget_.
549 scoped_ptr<RenderWidgetCompositor> compositor_;
551 // Set to the ID of the view that initiated creating this view, if any. When
552 // the view was initiated by the browser (the common case), this will be
553 // MSG_ROUTING_NONE. This is used in determining ownership when opening
554 // child tabs. See RenderWidget::createWebViewWithRequest.
556 // This ID may refer to an invalid view if that view is closed before this
560 // The position where this view should be initially shown.
561 gfx::Rect initial_pos_;
565 // We store the current cursor object so we can avoid spamming SetCursor
567 WebCursor current_cursor_;
569 // The size of the RenderWidget.
572 // The TransportDIB that is being used to transfer an image to the browser.
573 TransportDIB* current_paint_buf_;
575 PaintAggregator paint_aggregator_;
577 // The size of the view's backing surface in non-DPI-adjusted pixels.
578 gfx::Size physical_backing_size_;
580 // The height of the physical backing surface that is overdrawn opaquely in
581 // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels).
582 float overdraw_bottom_height_;
584 // The area that must be reserved for drawing the resize corner.
585 gfx::Rect resizer_rect_;
587 // Flags for the next ViewHostMsg_UpdateRect message.
588 int next_paint_flags_;
590 // Filtered time per frame based on UpdateRect messages.
591 float filtered_time_per_frame_;
593 // True if we are expecting an UpdateRect_ACK message (i.e., that a
594 // UpdateRect message has been sent).
595 bool update_reply_pending_;
597 // Whether the WebWidget is in auto resize mode, which is used for example
598 // by extension popups.
599 bool auto_resize_mode_;
601 // True if we need to send an UpdateRect message to notify the browser about
602 // an already-completed auto-resize.
603 bool need_update_rect_for_auto_resize_;
605 // True if the underlying graphics context supports asynchronous swap.
606 // Cached on the RenderWidget because determining support is costly.
607 bool using_asynchronous_swapbuffers_;
609 // Number of OnSwapBuffersComplete we are expecting. Incremented each time
610 // WebWidget::composite has been been performed when the RenderWidget subclass
611 // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block
613 int num_swapbuffers_complete_pending_;
615 // When accelerated rendering is on, is the maximum number of swapbuffers that
616 // can be outstanding before we start throttling based on
617 // OnSwapBuffersComplete callback.
618 static const int kMaxSwapBuffersPending = 2;
620 // Set to true if we should ignore RenderWidget::Show calls.
623 // Indicates that we shouldn't bother generated paint events.
626 // Indicates that we are in fullscreen mode.
629 // Indicates that we should be repainted when restored. This flag is set to
630 // true if we receive an invalidation / scroll event from webkit while our
631 // is_hidden_ flag is set to true. This is used to force a repaint once we
632 // restore to account for the fact that our host would not know about the
633 // invalidation / scroll event(s) from webkit while we are hidden.
634 bool needs_repainting_on_restore_;
636 // Indicates whether we have been focused/unfocused by the browser.
639 // Are we currently handling an input event?
640 bool handling_input_event_;
642 // Are we currently handling an ime event?
643 bool handling_ime_event_;
645 // Are we currently handling a touchstart event?
646 bool handling_touchstart_event_;
648 // True if we have requested this widget be closed. No more messages will
649 // be sent, except for a Close.
652 // Whether this RenderWidget is currently swapped out, such that the view is
653 // being rendered by another process. If all RenderWidgets in a process are
654 // swapped out, the process can exit.
655 bool is_swapped_out_;
657 // Indicates if an input method is active in the browser process.
658 bool input_method_is_active_;
660 // Stores information about the current text input.
661 blink::WebTextInputInfo text_input_info_;
663 // Stores the current text input type of |webwidget_|.
664 ui::TextInputType text_input_type_;
666 // Stores the current text input mode of |webwidget_|.
667 ui::TextInputMode text_input_mode_;
669 // Stores the current type of composition text rendering of |webwidget_|.
670 bool can_compose_inline_;
672 // Stores the current selection bounds.
673 gfx::Rect selection_focus_rect_;
674 gfx::Rect selection_anchor_rect_;
676 // Stores the current composition character bounds.
677 std::vector<gfx::Rect> composition_character_bounds_;
679 // Stores the current composition range.
680 gfx::Range composition_range_;
682 // The kind of popup this widget represents, NONE if not a popup.
683 blink::WebPopupType popup_type_;
685 // Holds all the needed plugin window moves for a scroll.
686 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
687 WebPluginGeometryVector plugin_window_moves_;
689 // A custom background for the widget.
690 SkBitmap background_;
692 // While we are waiting for the browser to update window sizes, we track the
693 // pending size temporarily.
694 int pending_window_rect_count_;
695 blink::WebRect pending_window_rect_;
697 // The screen rects of the view and the window that contains it.
698 gfx::Rect view_screen_rect_;
699 gfx::Rect window_screen_rect_;
701 scoped_ptr<IPC::Message> pending_input_event_ack_;
703 // The time spent in input handlers this frame. Used to throttle input acks.
704 base::TimeDelta total_input_handling_time_this_frame_;
706 // Indicates if the next sequence of Char events should be suppressed or not.
707 bool suppress_next_char_events_;
709 // Set to true if painting to the window is handled by the accelerated
711 bool is_accelerated_compositing_active_;
713 // Set to true if compositing has ever been active for this widget. Once a
714 // widget has used compositing, it will act as though force compositing mode
715 // is on for the remainder of the widget's lifetime.
716 bool was_accelerated_compositing_ever_active_;
718 base::OneShotTimer<RenderWidget> animation_timer_;
719 base::Time animation_floor_time_;
720 bool animation_update_pending_;
721 bool invalidation_task_posted_;
723 bool has_disable_gpu_vsync_switch_;
724 base::TimeTicks last_do_deferred_update_time_;
726 // Stats for legacy software mode
727 scoped_ptr<cc::RenderingStatsInstrumentation> legacy_software_mode_stats_;
729 // UpdateRect parameters for the current compositing pass. This is used to
730 // pass state between DoDeferredUpdate and OnSwapBuffersPosted.
731 scoped_ptr<ViewHostMsg_UpdateRect_Params> pending_update_params_;
733 // Queue of UpdateRect messages corresponding to a SwapBuffers. We want to
734 // delay sending of UpdateRect until the corresponding SwapBuffers has been
735 // executed. Since we can have several in flight, we need to keep them in a
736 // queue. Note: some SwapBuffers may not correspond to an update, in which
737 // case NULL is added to the queue.
738 std::deque<ViewHostMsg_UpdateRect*> updates_pending_swap_;
740 // Properties of the screen hosting this RenderWidget instance.
741 blink::WebScreenInfo screen_info_;
743 // The device scale factor. This value is computed from the DPI entries in
744 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
745 float device_scale_factor_;
747 // State associated with synthetic gestures. Synthetic gestures are processed
748 // in-order, so a queue is sufficient to identify the correct state for a
749 // completed gesture.
750 std::queue<SyntheticGestureCompletionCallback>
751 pending_synthetic_gesture_callbacks_;
753 // Specified whether the compositor will run in its own thread.
754 bool is_threaded_compositing_enabled_;
756 // The latency information for any current non-accelerated-compositing
758 std::vector<ui::LatencyInfo> latency_info_;
760 uint32 next_output_surface_id_;
762 #if defined(OS_ANDROID)
763 // A counter for number of outstanding messages from the renderer to the
764 // browser regarding IME-type events that have not been acknowledged by the
765 // browser. If this value is not 0 IME events will be dropped.
766 int outstanding_ime_acks_;
769 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
771 // Popups may be displaced when screen metrics emulation is enabled.
772 // These values are used to properly adjust popup position.
773 gfx::Point popup_view_origin_for_emulation_;
774 gfx::Point popup_screen_origin_for_emulation_;
775 float popup_origin_scale_for_emulation_;
777 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
779 // A list of swapped out RenderFrames that need to be notified
780 // of compositing-related events (e.g. DidCommitCompositorFrame).
781 ObserverList<RenderFrameImpl> swapped_out_frames_;
783 ui::MenuSourceType context_menu_source_type_;
784 gfx::Point touch_editing_context_menu_location_;
786 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
789 } // namespace content
791 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_