Roll src/third_party/skia ff271c2:b679ca8
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob072da8cede16b9ebb57799b78270db633d0ae000
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 blink::WebRect windowRect();
180 virtual void setToolTipText(const blink::WebString& text,
181 blink::WebTextDirection hint);
182 virtual void setWindowRect(const blink::WebRect&);
183 virtual blink::WebRect windowResizerRect();
184 virtual blink::WebRect rootWindowRect();
185 virtual blink::WebScreenInfo screenInfo();
186 virtual float deviceScaleFactor();
187 virtual void resetInputMethod();
188 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
189 bool event_cancelled);
190 virtual void showImeIfNeeded();
192 #if defined(OS_ANDROID)
193 // Notifies that a tap was not consumed, so showing a UI for the unhandled
194 // tap may be needed.
195 // Performs various checks on the given WebNode to apply heuristics to
196 // determine if triggering is appropriate.
197 virtual void showUnhandledTapUIIfNeeded(
198 const blink::WebPoint& tapped_position,
199 const blink::WebNode& tapped_node,
200 bool page_changed) override;
201 #endif
203 // Begins the compositor's scheduler to start producing frames.
204 void StartCompositor();
206 // Stop compositing.
207 void WillCloseLayerTreeView();
209 // Called when a plugin is moved. These events are queued up and sent with
210 // the next paint or scroll message to the host.
211 void SchedulePluginMove(const WebPluginGeometry& move);
213 // Called when a plugin window has been destroyed, to make sure the currently
214 // pending moves don't try to reference it.
215 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
217 RenderWidgetCompositor* compositor() const;
219 const ui::LatencyInfo* current_event_latency_info() const {
220 return current_event_latency_info_;
223 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
225 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
226 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
228 // Send a synthetic gesture to the browser to be queued to the synthetic
229 // gesture controller.
230 void QueueSyntheticGesture(
231 scoped_ptr<SyntheticGestureParams> gesture_params,
232 const SyntheticGestureCompletionCallback& callback);
234 // Close the underlying WebWidget.
235 virtual void Close();
237 // Notifies about a compositor frame commit operation having finished.
238 virtual void DidCommitCompositorFrame();
240 // Deliveres |message| together with compositor state change updates. The
241 // exact behavior depends on |policy|.
242 // This mechanism is not a drop-in replacement for IPC: messages sent this way
243 // will not be automatically available to BrowserMessageFilter, for example.
244 // FIFO ordering is preserved between messages enqueued with the same
245 // |policy|, the ordering between messages enqueued for different policies is
246 // undefined.
248 // |msg| message to send, ownership of |msg| is transferred.
249 // |policy| see the comment on MessageDeliveryPolicy.
250 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
252 // Handle common setup/teardown for handling IME events.
253 void StartHandlingImeEvent();
254 void FinishHandlingImeEvent();
256 // Returns whether we currently should handle an IME event.
257 bool ShouldHandleImeEvent();
259 // Called by the compositor when page scale animation completed.
260 virtual void DidCompletePageScaleAnimation() {}
262 // When paused in debugger, we send ack for mouse event early. This ensures
263 // that we continue receiving mouse moves and pass them to debugger. Returns
264 // whether we are paused in mouse move event and have sent the ack.
265 bool SendAckForMouseMoveFromDebugger();
267 // When resumed from pause in debugger while handling mouse move,
268 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
269 void IgnoreAckForMouseMoveFromDebugger();
271 // ScreenMetricsEmulator class manages screen emulation inside a render
272 // widget. This includes resizing, placing view on the screen at desired
273 // position, changing device scale factor, and scaling down the whole
274 // widget if required to fit into the browser window.
275 class ScreenMetricsEmulator;
277 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
278 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
280 void ScheduleCompositeWithForcedRedraw();
282 // Called by the compositor in single-threaded mode when a swap is posted,
283 // completes or is aborted.
284 void OnSwapBuffersPosted();
285 void OnSwapBuffersComplete();
286 void OnSwapBuffersAborted();
288 // Checks if the text input state and compose inline mode have been changed.
289 // If they are changed, the new value will be sent to the browser process.
290 void UpdateTextInputType();
292 // Checks if the selection bounds have been changed. If they are changed,
293 // the new value will be sent to the browser process.
294 void UpdateSelectionBounds();
296 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
298 void OnShowHostContextMenu(ContextMenuParams* params);
300 #if defined(OS_ANDROID) || defined(USE_AURA)
301 enum ShowIme {
302 SHOW_IME_IF_NEEDED,
303 NO_SHOW_IME,
306 enum ChangeSource {
307 FROM_NON_IME,
308 FROM_IME,
311 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
312 // be displayed, e.g. after a tap on an input field on mobile.
313 // |change_source| should be FROM_NON_IME when the renderer has to wait for
314 // the browser to acknowledge the change before the renderer handles any more
315 // IME events. This is when the text change did not originate from the IME in
316 // the browser side, such as changes by JavaScript or autofill.
317 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
318 #endif
320 // Called when animations due to focus change have completed (if any). Can be
321 // called from the renderer, browser, or compositor.
322 virtual void FocusChangeComplete() {}
324 // Checks if the composition range or composition character bounds have been
325 // changed. If they are changed, the new value will be sent to the browser
326 // process. This method does nothing when the browser process is not able to
327 // handle composition range and composition character bounds.
328 void UpdateCompositionInfo(bool should_update_range);
330 #if defined(OS_ANDROID)
331 void DidChangeBodyBackgroundColor(SkColor bg_color);
332 bool DoesRecordFullLayer() const;
333 #endif
335 bool host_closing() const { return host_closing_; }
337 protected:
338 // Friend RefCounted so that the dtor can be non-public. Using this class
339 // without ref-counting is an error.
340 friend class base::RefCounted<RenderWidget>;
341 // For unit tests.
342 friend class RenderWidgetTest;
344 enum ResizeAck {
345 SEND_RESIZE_ACK,
346 NO_RESIZE_ACK,
349 RenderWidget(blink::WebPopupType popup_type,
350 const blink::WebScreenInfo& screen_info,
351 bool swapped_out,
352 bool hidden,
353 bool never_visible);
355 ~RenderWidget() override;
357 // Initializes this view with the given opener. CompleteInit must be called
358 // later.
359 bool Init(int32 opener_id, CompositorDependencies* compositor_deps);
361 // Called by Init and subclasses to perform initialization.
362 bool DoInit(int32 opener_id,
363 CompositorDependencies* compositor_deps,
364 blink::WebWidget* web_widget,
365 IPC::SyncMessage* create_widget_message);
367 // Finishes creation of a pending view started with Init.
368 void CompleteInit();
370 // Sets whether this RenderWidget has been swapped out to be displayed by
371 // a RenderWidget in a different process. If so, no new IPC messages will be
372 // sent (only ACKs) and the process is free to exit when there are no other
373 // active RenderWidgets.
374 void SetSwappedOut(bool is_swapped_out);
376 // Allows the process to exit once the unload handler has finished, if there
377 // are no other active RenderWidgets.
378 void WasSwappedOut();
380 void FlushPendingInputEventAck();
381 void DoDeferredClose();
382 void DoDeferredSetWindowRect(const blink::WebRect& pos);
383 void NotifyOnClose();
385 // Resizes the render widget.
386 void Resize(const gfx::Size& new_size,
387 const gfx::Size& physical_backing_size,
388 bool top_controls_shrink_blink_size,
389 float top_controls_height,
390 const gfx::Size& visible_viewport_size,
391 const gfx::Rect& resizer_rect,
392 bool is_fullscreen,
393 ResizeAck resize_ack);
394 // Used to force the size of a window when running layout tests.
395 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
396 virtual void SetScreenMetricsEmulationParameters(
397 bool enabled,
398 const blink::WebDeviceEmulationParams& params);
399 #if defined(OS_MACOSX) || defined(OS_ANDROID)
400 void SetExternalPopupOriginAdjustmentsForEmulation(
401 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
402 #endif
404 // RenderWidget IPC message handlers
405 void OnHandleInputEvent(const blink::WebInputEvent* event,
406 const ui::LatencyInfo& latency_info,
407 bool keyboard_shortcut);
408 void OnCursorVisibilityChange(bool is_visible);
409 void OnMouseCaptureLost();
410 virtual void OnSetFocus(bool enable);
411 virtual void OnClose();
412 void OnCreatingNewAck();
413 virtual void OnResize(const ViewMsg_Resize_Params& params);
414 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
415 void OnDisableDeviceEmulation();
416 void OnColorProfile(const std::vector<char>& color_profile);
417 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
418 virtual void OnWasHidden();
419 virtual void OnWasShown(bool needs_repainting,
420 const ui::LatencyInfo& latency_info);
421 void OnCreateVideoAck(int32 video_id);
422 void OnUpdateVideoAck(int32 video_id);
423 void OnRequestMoveAck();
424 void OnSetInputMethodActive(bool is_active);
425 void OnCandidateWindowShown();
426 void OnCandidateWindowUpdated();
427 void OnCandidateWindowHidden();
428 virtual void OnImeSetComposition(
429 const base::string16& text,
430 const std::vector<blink::WebCompositionUnderline>& underlines,
431 int selection_start,
432 int selection_end);
433 virtual void OnImeConfirmComposition(const base::string16& text,
434 const gfx::Range& replacement_range,
435 bool keep_selection);
436 void OnRepaint(gfx::Size size_to_paint);
437 void OnSyntheticGestureCompleted();
438 void OnSetTextDirection(blink::WebTextDirection direction);
439 void OnGetFPS();
440 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
441 const gfx::Rect& window_screen_rect);
442 void OnShowImeIfNeeded();
444 #if defined(OS_ANDROID)
445 // Whenever an IME event that needs an acknowledgement is sent to the browser,
446 // the number of outstanding IME events that needs acknowledgement should be
447 // incremented. All IME events will be dropped until we receive an ack from
448 // the browser.
449 void IncrementOutstandingImeEventAcks();
451 // Called by the browser process for every required IME acknowledgement.
452 void OnImeEventAck();
453 #endif
455 // Notify the compositor about a change in viewport size. This should be
456 // used only with auto resize mode WebWidgets, as normal WebWidgets should
457 // go through OnResize.
458 void AutoResizeCompositor();
460 virtual void SetDeviceScaleFactor(float device_scale_factor);
461 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
462 virtual void ResetDeviceColorProfileForTesting();
464 virtual void OnOrientationChange();
466 // Override points to notify derived classes that a paint has happened.
467 // DidInitiatePaint happens when that has completed, and subsequent rendering
468 // won't affect the painted content. DidFlushPaint happens once we've received
469 // the ACK that the screen has been updated. For a given paint operation,
470 // these overrides will always be called in the order DidInitiatePaint,
471 // DidFlushPaint.
472 virtual void DidInitiatePaint() {}
473 virtual void DidFlushPaint() {}
475 virtual GURL GetURLForGraphicsContext3D();
477 // Gets the scroll offset of this widget, if this widget has a notion of
478 // scroll offset.
479 virtual gfx::Vector2d GetScrollOffset();
481 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
482 // use this method so that we can properly inform the RenderThread of our
483 // state.
484 void SetHidden(bool hidden);
486 void WillToggleFullscreen();
487 void DidToggleFullscreen();
489 bool next_paint_is_resize_ack() const;
490 void set_next_paint_is_resize_ack();
491 void set_next_paint_is_repaint_ack();
493 // QueueMessage implementation extracted into a static method for easy
494 // testing.
495 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
496 IPC::Message* msg,
497 MessageDeliveryPolicy policy,
498 FrameSwapMessageQueue* frame_swap_message_queue,
499 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
500 int source_frame_number);
502 // Override point to obtain that the current input method state and caret
503 // position.
504 virtual ui::TextInputType GetTextInputType();
505 virtual ui::TextInputType WebKitToUiTextInputType(
506 blink::WebTextInputType type);
508 // Override point to obtain that the current composition character bounds.
509 // In the case of surrogate pairs, the character is treated as two characters:
510 // the bounds for first character is actual one, and the bounds for second
511 // character is zero width rectangle.
512 virtual void GetCompositionCharacterBounds(
513 std::vector<gfx::Rect>* character_bounds);
515 // Returns the range of the text that is being composed or the selection if
516 // the composition does not exist.
517 virtual void GetCompositionRange(gfx::Range* range);
519 // Returns true if the composition range or composition character bounds
520 // should be sent to the browser process.
521 bool ShouldUpdateCompositionInfo(
522 const gfx::Range& range,
523 const std::vector<gfx::Rect>& bounds);
525 // Override point to obtain that the current input method state about
526 // composition text.
527 virtual bool CanComposeInline();
529 // Tells the renderer it does not have focus. Used to prevent us from getting
530 // the focus on our own when the browser did not focus us.
531 void ClearFocus();
533 // Set the pending window rect.
534 // Because the real render_widget is hosted in another process, there is
535 // a time period where we may have set a new window rect which has not yet
536 // been processed by the browser. So we maintain a pending window rect
537 // size. If JS code sets the WindowRect, and then immediately calls
538 // GetWindowRect() we'll use this pending window rect as the size.
539 void SetPendingWindowRect(const blink::WebRect& r);
541 // Called by OnHandleInputEvent() to notify subclasses that a key event was
542 // just handled.
543 virtual void DidHandleKeyEvent() {}
545 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
546 // about to be handled.
547 // Returns true if no further handling is needed. In that case, the event
548 // won't be sent to WebKit or trigger DidHandleMouseEvent().
549 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
551 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
552 // about to be handled.
553 // Returns true if no further handling is needed. In that case, the event
554 // won't be sent to WebKit.
555 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
557 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
558 // just handled.
559 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
561 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
562 // just handled.
563 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
565 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
566 // compositor thread, to effect the elastic overscroll effect.
567 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
568 bool event_processed);
570 // Check whether the WebWidget has any touch event handlers registered
571 // at the given point.
572 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
574 // Check whether the WebWidget has any touch event handlers registered.
575 virtual void hasTouchEventHandlers(bool has_handlers);
577 // Tell the browser about the actions permitted for a new touch point.
578 virtual void setTouchAction(blink::WebTouchAction touch_action);
580 // Called when value of focused text field gets dirty, e.g. value is modified
581 // by script, not by user input.
582 virtual void didUpdateTextOfFocusedElementByNonUserInput();
584 // Creates a 3D context associated with this view.
585 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
587 // Routing ID that allows us to communicate to the parent browser process
588 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
589 int32 routing_id_;
591 int32 surface_id_;
593 // Dependencies for initializing a compositor, including flags for optional
594 // features.
595 CompositorDependencies* compositor_deps_;
597 // We are responsible for destroying this object via its Close method.
598 // May be NULL when the window is closing.
599 blink::WebWidget* webwidget_;
601 // This is lazily constructed and must not outlive webwidget_.
602 scoped_ptr<RenderWidgetCompositor> compositor_;
604 // Set to the ID of the view that initiated creating this view, if any. When
605 // the view was initiated by the browser (the common case), this will be
606 // MSG_ROUTING_NONE. This is used in determining ownership when opening
607 // child tabs. See RenderWidget::createWebViewWithRequest.
609 // This ID may refer to an invalid view if that view is closed before this
610 // view is.
611 int32 opener_id_;
613 // The rect where this view should be initially shown.
614 gfx::Rect initial_rect_;
616 bool init_complete_;
618 // We store the current cursor object so we can avoid spamming SetCursor
619 // messages.
620 WebCursor current_cursor_;
622 // The size of the RenderWidget.
623 gfx::Size size_;
625 // The size of the view's backing surface in non-DPI-adjusted pixels.
626 gfx::Size physical_backing_size_;
628 // Whether or not Blink's viewport size should be shrunk by the height of the
629 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
630 bool top_controls_shrink_blink_size_;
632 // The height of the top controls (always 0 on platforms where URL-bar hiding
633 // isn't supported).
634 float top_controls_height_;
636 // The size of the visible viewport in DPI-adjusted pixels.
637 gfx::Size visible_viewport_size_;
639 // The area that must be reserved for drawing the resize corner.
640 gfx::Rect resizer_rect_;
642 // Flags for the next ViewHostMsg_UpdateRect message.
643 int next_paint_flags_;
645 // Whether the WebWidget is in auto resize mode, which is used for example
646 // by extension popups.
647 bool auto_resize_mode_;
649 // True if we need to send an UpdateRect message to notify the browser about
650 // an already-completed auto-resize.
651 bool need_update_rect_for_auto_resize_;
653 // Set to true if we should ignore RenderWidget::Show calls.
654 bool did_show_;
656 // Indicates that we shouldn't bother generated paint events.
657 bool is_hidden_;
659 // Indicates that we are never visible, so never produce graphical output.
660 bool never_visible_;
662 // Indicates that we are in fullscreen mode.
663 bool is_fullscreen_;
665 // Indicates whether we have been focused/unfocused by the browser.
666 bool has_focus_;
668 // Are we currently handling an input event?
669 bool handling_input_event_;
671 // Are we currently handling an ime event?
672 bool handling_ime_event_;
674 // Type of the input event we are currently handling.
675 blink::WebInputEvent::Type handling_event_type_;
677 // Whether we should not send ack for the current mouse move.
678 bool ignore_ack_for_mouse_move_from_debugger_;
680 // True if we have requested this widget be closed. No more messages will
681 // be sent, except for a Close.
682 bool closing_;
684 // True if it is known that the host is in the process of being shut down.
685 bool host_closing_;
687 // Whether this RenderWidget is currently swapped out, such that the view is
688 // being rendered by another process. If all RenderWidgets in a process are
689 // swapped out, the process can exit.
690 bool is_swapped_out_;
692 // Indicates if an input method is active in the browser process.
693 bool input_method_is_active_;
695 // Stores information about the current text input.
696 blink::WebTextInputInfo text_input_info_;
698 // Stores the current text input type of |webwidget_|.
699 ui::TextInputType text_input_type_;
701 // Stores the current text input mode of |webwidget_|.
702 ui::TextInputMode text_input_mode_;
704 // Stores the current text input flags of |webwidget_|.
705 int text_input_flags_;
707 // Stores the current type of composition text rendering of |webwidget_|.
708 bool can_compose_inline_;
710 // Stores the current selection bounds.
711 gfx::Rect selection_focus_rect_;
712 gfx::Rect selection_anchor_rect_;
714 // Stores the current composition character bounds.
715 std::vector<gfx::Rect> composition_character_bounds_;
717 // Stores the current composition range.
718 gfx::Range composition_range_;
720 // The kind of popup this widget represents, NONE if not a popup.
721 blink::WebPopupType popup_type_;
723 // Holds all the needed plugin window moves for a scroll.
724 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
725 WebPluginGeometryVector plugin_window_moves_;
727 // While we are waiting for the browser to update window sizes, we track the
728 // pending size temporarily.
729 int pending_window_rect_count_;
730 blink::WebRect pending_window_rect_;
732 // The screen rects of the view and the window that contains it.
733 gfx::Rect view_screen_rect_;
734 gfx::Rect window_screen_rect_;
736 scoped_ptr<IPC::Message> pending_input_event_ack_;
738 // The time spent in input handlers this frame. Used to throttle input acks.
739 base::TimeDelta total_input_handling_time_this_frame_;
741 // Indicates if the next sequence of Char events should be suppressed or not.
742 bool suppress_next_char_events_;
744 // Properties of the screen hosting this RenderWidget instance.
745 blink::WebScreenInfo screen_info_;
747 // The device scale factor. This value is computed from the DPI entries in
748 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
749 float device_scale_factor_;
751 // The device color profile on supported platforms.
752 std::vector<char> device_color_profile_;
754 // State associated with synthetic gestures. Synthetic gestures are processed
755 // in-order, so a queue is sufficient to identify the correct state for a
756 // completed gesture.
757 std::queue<SyntheticGestureCompletionCallback>
758 pending_synthetic_gesture_callbacks_;
760 const ui::LatencyInfo* current_event_latency_info_;
762 uint32 next_output_surface_id_;
764 #if defined(OS_ANDROID)
765 // Indicates value in the focused text field is in dirty state, i.e. modified
766 // by script etc., not by user input.
767 bool text_field_is_dirty_;
769 // A counter for number of outstanding messages from the renderer to the
770 // browser regarding IME-type events that have not been acknowledged by the
771 // browser. If this value is not 0 IME events will be dropped.
772 int outstanding_ime_acks_;
774 // The background color of the document body element. This is used as the
775 // default background color for filling the screen areas for which we don't
776 // have the actual content.
777 SkColor body_background_color_;
778 #endif
780 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
782 // Popups may be displaced when screen metrics emulation is enabled.
783 // These values are used to properly adjust popup position.
784 gfx::PointF popup_view_origin_for_emulation_;
785 gfx::PointF popup_screen_origin_for_emulation_;
786 float popup_origin_scale_for_emulation_;
788 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
789 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
791 // Lists of RenderFrameProxy objects that need to be notified of
792 // compositing-related events (e.g. DidCommitCompositorFrame).
793 ObserverList<RenderFrameProxy> render_frame_proxies_;
794 #if defined(VIDEO_HOLE)
795 ObserverList<RenderFrameImpl> video_hole_frames_;
796 #endif // defined(VIDEO_HOLE)
798 // A list of RenderFrames associated with this RenderWidget. Notifications
799 // are sent to each frame in the list for events such as changing
800 // visibility state for example.
801 ObserverList<RenderFrameImpl> render_frames_;
803 ui::MenuSourceType context_menu_source_type_;
804 bool has_host_context_menu_location_;
805 gfx::Point host_context_menu_location_;
807 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
810 } // namespace content
812 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_