[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / renderer / render_widget.h
blobba70c40ba3e6cb6d8f81ed2be347e0a124c41411
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/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h"
17 #include "base/time/time.h"
18 #include "content/common/content_export.h"
19 #include "content/common/cursors/webcursor.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/message_delivery_policy.h"
23 #include "ipc/ipc_listener.h"
24 #include "ipc/ipc_sender.h"
25 #include "third_party/WebKit/public/platform/WebDisplayMode.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 DidOverscrollParams;
90 struct WebPluginGeometry;
92 // RenderWidget provides a communication bridge between a WebWidget and
93 // a RenderWidgetHost, the latter of which lives in a different process.
95 // RenderWidget is used to implement:
96 // - RenderViewImpl (deprecated)
97 // - Fullscreen mode (RenderWidgetFullScreen)
98 // - Popup "menus" (like the color chooser and date picker)
99 // - Widgets for frames (for out-of-process iframe support)
100 class CONTENT_EXPORT RenderWidget
101 : public IPC::Listener,
102 public IPC::Sender,
103 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
104 public base::RefCounted<RenderWidget> {
105 public:
106 // Creates a new RenderWidget. The opener_id is the routing ID of the
107 // RenderView that this widget lives inside.
108 static RenderWidget* Create(int32 opener_id,
109 CompositorDependencies* compositor_deps,
110 blink::WebPopupType popup_type,
111 const blink::WebScreenInfo& screen_info);
113 // Creates a new RenderWidget that will be attached to a RenderFrame.
114 static RenderWidget* CreateForFrame(int routing_id,
115 int surface_id,
116 bool hidden,
117 const blink::WebScreenInfo& screen_info,
118 CompositorDependencies* compositor_deps,
119 blink::WebLocalFrame* frame);
121 // Closes a RenderWidget that was created by |CreateForFrame|.
122 void CloseForFrame();
124 int32 routing_id() const { return routing_id_; }
125 int32 surface_id() const { return surface_id_; }
126 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
127 blink::WebWidget* webwidget() const { return webwidget_; }
128 gfx::Size size() const { return size_; }
129 bool has_focus() const { return has_focus_; }
130 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
131 blink::WebDisplayMode display_mode() const { return display_mode_; }
132 bool is_hidden() const { return is_hidden_; }
133 bool handling_input_event() const { return handling_input_event_; }
134 // Temporary for debugging purposes...
135 bool closing() const { return closing_; }
136 bool is_swapped_out() { return is_swapped_out_; }
137 bool for_oopif() { return for_oopif_; }
138 ui::MenuSourceType context_menu_source_type() {
139 return context_menu_source_type_;
141 bool has_host_context_menu_location() {
142 return has_host_context_menu_location_;
144 gfx::Point host_context_menu_location() {
145 return host_context_menu_location_;
148 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
149 blink::WebScreenInfo screen_info() const { return screen_info_; }
151 // Functions to track out-of-process frames for special notifications.
152 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
153 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
155 // Functions to track all RenderFrame objects associated with this
156 // RenderWidget.
157 void RegisterRenderFrame(RenderFrameImpl* frame);
158 void UnregisterRenderFrame(RenderFrameImpl* frame);
160 #if defined(VIDEO_HOLE)
161 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
162 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
163 #endif // defined(VIDEO_HOLE)
165 // IPC::Listener
166 bool OnMessageReceived(const IPC::Message& msg) override;
168 // IPC::Sender
169 bool Send(IPC::Message* msg) override;
171 // blink::WebWidgetClient
172 virtual void didAutoResize(const blink::WebSize& new_size);
173 virtual void initializeLayerTreeView();
174 virtual blink::WebLayerTreeView* layerTreeView();
175 virtual void didFocus();
176 virtual void didBlur();
177 virtual void didChangeCursor(const blink::WebCursorInfo&);
178 virtual void closeWidgetSoon();
179 virtual void show(blink::WebNavigationPolicy);
180 virtual blink::WebRect windowRect();
181 virtual void setToolTipText(const blink::WebString& text,
182 blink::WebTextDirection hint);
183 virtual void setWindowRect(const blink::WebRect&);
184 virtual blink::WebRect windowResizerRect();
185 virtual blink::WebRect rootWindowRect();
186 virtual blink::WebScreenInfo screenInfo();
187 virtual float deviceScaleFactor();
188 virtual void resetInputMethod();
189 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
190 bool event_cancelled);
191 virtual void didOverscroll(
192 const blink::WebFloatSize& unusedDelta,
193 const blink::WebFloatSize& accumulatedRootOverScroll,
194 const blink::WebFloatPoint& position,
195 const blink::WebFloatSize& velocity);
196 virtual void showImeIfNeeded();
198 #if defined(OS_ANDROID)
199 // Notifies that a tap was not consumed, so showing a UI for the unhandled
200 // tap may be needed.
201 // Performs various checks on the given WebNode to apply heuristics to
202 // determine if triggering is appropriate.
203 virtual void showUnhandledTapUIIfNeeded(
204 const blink::WebPoint& tapped_position,
205 const blink::WebNode& tapped_node,
206 bool page_changed) override;
207 #endif
209 // Begins the compositor's scheduler to start producing frames.
210 void StartCompositor();
212 // Stop compositing.
213 void WillCloseLayerTreeView();
215 // Called when a plugin is moved. These events are queued up and sent with
216 // the next paint or scroll message to the host.
217 void SchedulePluginMove(const WebPluginGeometry& move);
219 // Called when a plugin window has been destroyed, to make sure the currently
220 // pending moves don't try to reference it.
221 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
223 RenderWidgetCompositor* compositor() const;
225 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
227 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
228 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
230 // Send a synthetic gesture to the browser to be queued to the synthetic
231 // gesture controller.
232 void QueueSyntheticGesture(
233 scoped_ptr<SyntheticGestureParams> gesture_params,
234 const SyntheticGestureCompletionCallback& callback);
236 // Deliveres |message| together with compositor state change updates. The
237 // exact behavior depends on |policy|.
238 // This mechanism is not a drop-in replacement for IPC: messages sent this way
239 // will not be automatically available to BrowserMessageFilter, for example.
240 // FIFO ordering is preserved between messages enqueued with the same
241 // |policy|, the ordering between messages enqueued for different policies is
242 // undefined.
244 // |msg| message to send, ownership of |msg| is transferred.
245 // |policy| see the comment on MessageDeliveryPolicy.
246 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
248 // Handle common setup/teardown for handling IME events.
249 void StartHandlingImeEvent();
250 void FinishHandlingImeEvent();
252 // Returns whether we currently should handle an IME event.
253 bool ShouldHandleImeEvent();
255 // Called by the compositor when page scale animation completed.
256 virtual void DidCompletePageScaleAnimation() {}
258 // When paused in debugger, we send ack for mouse event early. This ensures
259 // that we continue receiving mouse moves and pass them to debugger. Returns
260 // whether we are paused in mouse move event and have sent the ack.
261 bool SendAckForMouseMoveFromDebugger();
263 // When resumed from pause in debugger while handling mouse move,
264 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
265 void IgnoreAckForMouseMoveFromDebugger();
267 // ScreenMetricsEmulator class manages screen emulation inside a render
268 // widget. This includes resizing, placing view on the screen at desired
269 // position, changing device scale factor, and scaling down the whole
270 // widget if required to fit into the browser window.
271 class ScreenMetricsEmulator;
273 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
274 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
276 // Indicates that the compositor is about to begin a frame. This is primarily
277 // to signal to flow control mechanisms that a frame is beginning, not to
278 // perform actual painting work.
279 void WillBeginCompositorFrame();
281 // Notifies about a compositor frame commit operation having finished.
282 virtual void DidCommitCompositorFrame();
284 // Notifies that the draw commands for a committed frame have been issued.
285 void DidCommitAndDrawCompositorFrame();
287 // Notifies that the compositor has posted a swapbuffers operation to the GPU
288 // process.
289 void DidCompleteSwapBuffers();
291 void ScheduleComposite();
292 void ScheduleCompositeWithForcedRedraw();
294 // Called by the compositor in single-threaded mode when a swap is posted,
295 // completes or is aborted.
296 void OnSwapBuffersPosted();
297 void OnSwapBuffersComplete();
298 void OnSwapBuffersAborted();
300 // Checks if the selection bounds have been changed. If they are changed,
301 // the new value will be sent to the browser process.
302 void UpdateSelectionBounds();
304 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
306 void OnShowHostContextMenu(ContextMenuParams* params);
308 enum ShowIme {
309 SHOW_IME_IF_NEEDED,
310 NO_SHOW_IME,
313 enum ChangeSource {
314 FROM_NON_IME,
315 FROM_IME,
318 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
319 // be displayed, e.g. after a tap on an input field on mobile.
320 // |change_source| should be FROM_NON_IME when the renderer has to wait for
321 // the browser to acknowledge the change before the renderer handles any more
322 // IME events. This is when the text change did not originate from the IME in
323 // the browser side, such as changes by JavaScript or autofill.
324 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
326 // Called when animations due to focus change have completed (if any). Can be
327 // called from the renderer, browser, or compositor.
328 virtual void FocusChangeComplete() {}
330 // Checks if the composition range or composition character bounds have been
331 // changed. If they are changed, the new value will be sent to the browser
332 // process. This method does nothing when the browser process is not able to
333 // handle composition range and composition character bounds.
334 void UpdateCompositionInfo(bool should_update_range);
336 #if defined(OS_ANDROID)
337 void DidChangeBodyBackgroundColor(SkColor bg_color);
338 bool DoesRecordFullLayer() const;
339 #endif
341 bool host_closing() const { return host_closing_; }
343 protected:
344 // Friend RefCounted so that the dtor can be non-public. Using this class
345 // without ref-counting is an error.
346 friend class base::RefCounted<RenderWidget>;
347 // For unit tests.
348 friend class RenderWidgetTest;
350 enum ResizeAck {
351 SEND_RESIZE_ACK,
352 NO_RESIZE_ACK,
355 RenderWidget(CompositorDependencies* compositor_deps,
356 blink::WebPopupType popup_type,
357 const blink::WebScreenInfo& screen_info,
358 bool swapped_out,
359 bool hidden,
360 bool never_visible);
362 ~RenderWidget() override;
364 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
365 blink::WebLocalFrame* frame);
367 // Creates a WebWidget based on the popup type.
368 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
370 // Initializes this view with the given opener. CompleteInit must be called
371 // later.
372 bool Init(int32 opener_id);
374 // Called by Init and subclasses to perform initialization.
375 bool DoInit(int32 opener_id,
376 blink::WebWidget* web_widget,
377 IPC::SyncMessage* create_widget_message);
379 // Finishes creation of a pending view started with Init.
380 void CompleteInit();
382 // Sets whether this RenderWidget has been swapped out to be displayed by
383 // a RenderWidget in a different process. If so, no new IPC messages will be
384 // sent (only ACKs) and the process is free to exit when there are no other
385 // active RenderWidgets.
386 void SetSwappedOut(bool is_swapped_out);
388 // Allows the process to exit once the unload handler has finished, if there
389 // are no other active RenderWidgets.
390 void WasSwappedOut();
392 void FlushPendingInputEventAck();
393 void DoDeferredClose();
394 void NotifyOnClose();
396 // Close the underlying WebWidget.
397 virtual void Close();
399 // Resizes the render widget.
400 void Resize(const gfx::Size& new_size,
401 const gfx::Size& physical_backing_size,
402 bool top_controls_shrink_blink_size,
403 float top_controls_height,
404 const gfx::Size& visible_viewport_size,
405 const gfx::Rect& resizer_rect,
406 bool is_fullscreen_granted,
407 blink::WebDisplayMode display_mode,
408 ResizeAck resize_ack);
409 // Used to force the size of a window when running layout tests.
410 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
411 virtual void SetScreenMetricsEmulationParameters(
412 bool enabled,
413 const blink::WebDeviceEmulationParams& params);
414 #if defined(OS_MACOSX) || defined(OS_ANDROID)
415 void SetExternalPopupOriginAdjustmentsForEmulation(
416 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
417 #endif
419 // RenderWidget IPC message handlers
420 void OnHandleInputEvent(const blink::WebInputEvent* event,
421 const ui::LatencyInfo& latency_info,
422 bool keyboard_shortcut);
423 void OnCursorVisibilityChange(bool is_visible);
424 void OnMouseCaptureLost();
425 virtual void OnSetFocus(bool enable);
426 void OnClose();
427 void OnCreatingNewAck();
428 virtual void OnResize(const ViewMsg_Resize_Params& params);
429 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
430 void OnDisableDeviceEmulation();
431 void OnColorProfile(const std::vector<char>& color_profile);
432 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
433 virtual void OnWasHidden();
434 virtual void OnWasShown(bool needs_repainting,
435 const ui::LatencyInfo& latency_info);
436 void OnCreateVideoAck(int32 video_id);
437 void OnUpdateVideoAck(int32 video_id);
438 void OnRequestMoveAck();
439 virtual void OnImeSetComposition(
440 const base::string16& text,
441 const std::vector<blink::WebCompositionUnderline>& underlines,
442 int selection_start,
443 int selection_end);
444 virtual void OnImeConfirmComposition(const base::string16& text,
445 const gfx::Range& replacement_range,
446 bool keep_selection);
447 void OnRepaint(gfx::Size size_to_paint);
448 void OnSyntheticGestureCompleted();
449 void OnSetTextDirection(blink::WebTextDirection direction);
450 void OnGetFPS();
451 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
452 const gfx::Rect& window_screen_rect);
453 void OnShowImeIfNeeded();
454 void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace);
456 #if defined(OS_ANDROID)
457 // Called when we send IME event that expects an ACK.
458 void OnImeEventSentForAck(const blink::WebTextInputInfo& info);
460 // Called by the browser process for every required IME acknowledgement.
461 void OnImeEventAck();
462 #endif
464 // Notify the compositor about a change in viewport size. This should be
465 // used only with auto resize mode WebWidgets, as normal WebWidgets should
466 // go through OnResize.
467 void AutoResizeCompositor();
469 virtual void SetDeviceScaleFactor(float device_scale_factor);
470 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
471 virtual void ResetDeviceColorProfileForTesting();
473 virtual void OnOrientationChange();
475 // Override points to notify derived classes that a paint has happened.
476 // DidInitiatePaint happens when that has completed, and subsequent rendering
477 // won't affect the painted content. DidFlushPaint happens once we've received
478 // the ACK that the screen has been updated. For a given paint operation,
479 // these overrides will always be called in the order DidInitiatePaint,
480 // DidFlushPaint.
481 virtual void DidInitiatePaint() {}
482 virtual void DidFlushPaint() {}
484 virtual GURL GetURLForGraphicsContext3D();
486 // Gets the scroll offset of this widget, if this widget has a notion of
487 // scroll offset.
488 virtual gfx::Vector2d GetScrollOffset();
490 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
491 // use this method so that we can properly inform the RenderThread of our
492 // state.
493 void SetHidden(bool hidden);
495 void DidToggleFullscreen();
497 bool next_paint_is_resize_ack() const;
498 void set_next_paint_is_resize_ack();
499 void set_next_paint_is_repaint_ack();
501 // QueueMessage implementation extracted into a static method for easy
502 // testing.
503 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
504 IPC::Message* msg,
505 MessageDeliveryPolicy policy,
506 FrameSwapMessageQueue* frame_swap_message_queue,
507 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
508 int source_frame_number);
510 // Override point to obtain that the current input method state and caret
511 // position.
512 virtual ui::TextInputType GetTextInputType();
513 virtual ui::TextInputType WebKitToUiTextInputType(
514 blink::WebTextInputType type);
516 // Override point to obtain that the current composition character bounds.
517 // In the case of surrogate pairs, the character is treated as two characters:
518 // the bounds for first character is actual one, and the bounds for second
519 // character is zero width rectangle.
520 virtual void GetCompositionCharacterBounds(
521 std::vector<gfx::Rect>* character_bounds);
523 // Returns the range of the text that is being composed or the selection if
524 // the composition does not exist.
525 virtual void GetCompositionRange(gfx::Range* range);
527 // Returns true if the composition range or composition character bounds
528 // should be sent to the browser process.
529 bool ShouldUpdateCompositionInfo(
530 const gfx::Range& range,
531 const std::vector<gfx::Rect>& bounds);
533 // Override point to obtain that the current input method state about
534 // composition text.
535 virtual bool CanComposeInline();
537 // Tells the renderer it does not have focus. Used to prevent us from getting
538 // the focus on our own when the browser did not focus us.
539 void ClearFocus();
541 // Set the pending window rect.
542 // Because the real render_widget is hosted in another process, there is
543 // a time period where we may have set a new window rect which has not yet
544 // been processed by the browser. So we maintain a pending window rect
545 // size. If JS code sets the WindowRect, and then immediately calls
546 // GetWindowRect() we'll use this pending window rect as the size.
547 void SetPendingWindowRect(const blink::WebRect& r);
549 // Called by OnHandleInputEvent() to notify subclasses that a key event was
550 // just handled.
551 virtual void DidHandleKeyEvent() {}
553 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
554 // about to be handled.
555 // Returns true if no further handling is needed. In that case, the event
556 // won't be sent to WebKit or trigger DidHandleMouseEvent().
557 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
559 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
560 // about to be handled.
561 // Returns true if no further handling is needed. In that case, the event
562 // won't be sent to WebKit.
563 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& 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 const gfx::Vector2dF& wheel_unused_delta,
569 bool event_processed);
571 // Check whether the WebWidget has any touch event handlers registered
572 // at the given point.
573 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
575 // Check whether the WebWidget has any touch event handlers registered.
576 virtual void hasTouchEventHandlers(bool has_handlers);
578 // Tell the browser about the actions permitted for a new touch point.
579 virtual void setTouchAction(blink::WebTouchAction touch_action);
581 // Called when value of focused text field gets dirty, e.g. value is modified
582 // by script, not by user input.
583 virtual void didUpdateTextOfFocusedElementByNonUserInput();
585 // Creates a 3D context associated with this view.
586 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(
587 bool compositor);
589 // Routing ID that allows us to communicate to the parent browser process
590 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
591 int32 routing_id_;
593 int32 surface_id_;
595 // Dependencies for initializing a compositor, including flags for optional
596 // features.
597 CompositorDependencies* const compositor_deps_;
599 // We are responsible for destroying this object via its Close method.
600 // May be NULL when the window is closing.
601 blink::WebWidget* webwidget_;
603 // This is lazily constructed and must not outlive webwidget_.
604 scoped_ptr<RenderWidgetCompositor> compositor_;
606 // Set to the ID of the view that initiated creating this view, if any. When
607 // the view was initiated by the browser (the common case), this will be
608 // MSG_ROUTING_NONE. This is used in determining ownership when opening
609 // child tabs. See RenderWidget::createWebViewWithRequest.
611 // This ID may refer to an invalid view if that view is closed before this
612 // view is.
613 int32 opener_id_;
615 // The rect where this view should be initially shown.
616 gfx::Rect initial_rect_;
618 bool init_complete_;
620 // We store the current cursor object so we can avoid spamming SetCursor
621 // messages.
622 WebCursor current_cursor_;
624 // The size of the RenderWidget.
625 gfx::Size size_;
627 // The size of the view's backing surface in non-DPI-adjusted pixels.
628 gfx::Size physical_backing_size_;
630 // Whether or not Blink's viewport size should be shrunk by the height of the
631 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
632 bool top_controls_shrink_blink_size_;
634 // The height of the top controls (always 0 on platforms where URL-bar hiding
635 // isn't supported).
636 float top_controls_height_;
638 // The size of the visible viewport in DPI-adjusted pixels.
639 gfx::Size visible_viewport_size_;
641 // The area that must be reserved for drawing the resize corner.
642 gfx::Rect resizer_rect_;
644 // Flags for the next ViewHostMsg_UpdateRect message.
645 int next_paint_flags_;
647 // Whether the WebWidget is in auto resize mode, which is used for example
648 // by extension popups.
649 bool auto_resize_mode_;
651 // True if we need to send an UpdateRect message to notify the browser about
652 // an already-completed auto-resize.
653 bool need_update_rect_for_auto_resize_;
655 // Set to true if we should ignore RenderWidget::Show calls.
656 bool did_show_;
658 // Indicates that we shouldn't bother generated paint events.
659 bool is_hidden_;
661 // Indicates that we are never visible, so never produce graphical output.
662 bool never_visible_;
664 // Indicates whether tab-initiated fullscreen was granted.
665 bool is_fullscreen_granted_;
667 // Indicates the display mode.
668 blink::WebDisplayMode display_mode_;
670 // Indicates whether we have been focused/unfocused by the browser.
671 bool has_focus_;
673 // Are we currently handling an input event?
674 bool handling_input_event_;
676 // Used to intercept overscroll notifications while an event is being
677 // handled. If the event causes overscroll, the overscroll metadata can be
678 // bundled in the event ack, saving an IPC. Note that we must continue
679 // supporting overscroll IPC notifications due to fling animation updates.
680 scoped_ptr<DidOverscrollParams>* handling_event_overscroll_;
682 // Are we currently handling an ime event?
683 bool handling_ime_event_;
685 // Type of the input event we are currently handling.
686 blink::WebInputEvent::Type handling_event_type_;
688 // Whether we should not send ack for the current mouse move.
689 bool ignore_ack_for_mouse_move_from_debugger_;
691 // True if we have requested this widget be closed. No more messages will
692 // be sent, except for a Close.
693 bool closing_;
695 // True if it is known that the host is in the process of being shut down.
696 bool host_closing_;
698 // Whether this RenderWidget is currently swapped out, such that the view is
699 // being rendered by another process. If all RenderWidgets in a process are
700 // swapped out, the process can exit.
701 bool is_swapped_out_;
703 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
704 // OOPIF(crbug.com/471411).
705 // Whether this RenderWidget is for an out-of-process iframe or not.
706 bool for_oopif_;
708 // Stores information about the current text input.
709 blink::WebTextInputInfo text_input_info_;
711 // Stores the current text input type of |webwidget_|.
712 ui::TextInputType text_input_type_;
714 // Stores the current text input mode of |webwidget_|.
715 ui::TextInputMode text_input_mode_;
717 // Stores the current text input flags of |webwidget_|.
718 int text_input_flags_;
720 // Stores the current type of composition text rendering of |webwidget_|.
721 bool can_compose_inline_;
723 // Stores the current selection bounds.
724 gfx::Rect selection_focus_rect_;
725 gfx::Rect selection_anchor_rect_;
727 // Stores the current composition character bounds.
728 std::vector<gfx::Rect> composition_character_bounds_;
730 // Stores the current composition range.
731 gfx::Range composition_range_;
733 // The kind of popup this widget represents, NONE if not a popup.
734 blink::WebPopupType popup_type_;
736 // Holds all the needed plugin window moves for a scroll.
737 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
738 WebPluginGeometryVector plugin_window_moves_;
740 // While we are waiting for the browser to update window sizes, we track the
741 // pending size temporarily.
742 int pending_window_rect_count_;
743 blink::WebRect pending_window_rect_;
745 // The screen rects of the view and the window that contains it.
746 gfx::Rect view_screen_rect_;
747 gfx::Rect window_screen_rect_;
749 scoped_ptr<IPC::Message> pending_input_event_ack_;
751 // The time spent in input handlers this frame. Used to throttle input acks.
752 base::TimeDelta total_input_handling_time_this_frame_;
754 // Indicates if the next sequence of Char events should be suppressed or not.
755 bool suppress_next_char_events_;
757 // Properties of the screen hosting this RenderWidget instance.
758 blink::WebScreenInfo screen_info_;
760 // The device scale factor. This value is computed from the DPI entries in
761 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
762 float device_scale_factor_;
764 // The device color profile on supported platforms.
765 std::vector<char> device_color_profile_;
767 // State associated with synthetic gestures. Synthetic gestures are processed
768 // in-order, so a queue is sufficient to identify the correct state for a
769 // completed gesture.
770 std::queue<SyntheticGestureCompletionCallback>
771 pending_synthetic_gesture_callbacks_;
773 uint32 next_output_surface_id_;
775 #if defined(OS_ANDROID)
776 // Indicates value in the focused text field is in dirty state, i.e. modified
777 // by script etc., not by user input.
778 bool text_field_is_dirty_;
780 // Stores the history of text input infos from the last ACK'ed one from the
781 // current one. The size is the number of pending ACKs plus one, since we
782 // intentionally keep the last ack'd value to know what the browser is
783 // currently aware of.
784 std::deque<blink::WebTextInputInfo> text_input_info_history_;
786 // The background color of the document body element. This is used as the
787 // default background color for filling the screen areas for which we don't
788 // have the actual content.
789 SkColor body_background_color_;
790 #endif
792 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
794 // Popups may be displaced when screen metrics emulation is enabled.
795 // These values are used to properly adjust popup position.
796 gfx::PointF popup_view_origin_for_emulation_;
797 gfx::PointF popup_screen_origin_for_emulation_;
798 float popup_origin_scale_for_emulation_;
800 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
801 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
803 // Lists of RenderFrameProxy objects that need to be notified of
804 // compositing-related events (e.g. DidCommitCompositorFrame).
805 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
806 #if defined(VIDEO_HOLE)
807 base::ObserverList<RenderFrameImpl> video_hole_frames_;
808 #endif // defined(VIDEO_HOLE)
810 // A list of RenderFrames associated with this RenderWidget. Notifications
811 // are sent to each frame in the list for events such as changing
812 // visibility state for example.
813 base::ObserverList<RenderFrameImpl> render_frames_;
815 ui::MenuSourceType context_menu_source_type_;
816 bool has_host_context_menu_location_;
817 gfx::Point host_context_menu_location_;
819 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
822 } // namespace content
824 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_