Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob610a0b5f4f2c148c490bfdcdd2aa3f2f5058e060
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 didFirstVisuallyNonEmptyLayout();
176 virtual void didFirstLayoutAfterFinishedParsing();
177 virtual void didFocus();
178 virtual void didBlur();
179 virtual void didChangeCursor(const blink::WebCursorInfo&);
180 virtual void closeWidgetSoon();
181 virtual void show(blink::WebNavigationPolicy);
182 virtual blink::WebRect windowRect();
183 virtual void setToolTipText(const blink::WebString& text,
184 blink::WebTextDirection hint);
185 virtual void setWindowRect(const blink::WebRect&);
186 virtual blink::WebRect windowResizerRect();
187 virtual blink::WebRect rootWindowRect();
188 virtual blink::WebScreenInfo screenInfo();
189 virtual float deviceScaleFactor();
190 virtual void resetInputMethod();
191 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
192 bool event_cancelled);
193 virtual void didOverscroll(
194 const blink::WebFloatSize& unusedDelta,
195 const blink::WebFloatSize& accumulatedRootOverScroll,
196 const blink::WebFloatPoint& position,
197 const blink::WebFloatSize& velocity);
198 virtual void showImeIfNeeded();
200 #if defined(OS_ANDROID)
201 // Notifies that a tap was not consumed, so showing a UI for the unhandled
202 // tap may be needed.
203 // Performs various checks on the given WebNode to apply heuristics to
204 // determine if triggering is appropriate.
205 virtual void showUnhandledTapUIIfNeeded(
206 const blink::WebPoint& tapped_position,
207 const blink::WebNode& tapped_node,
208 bool page_changed) override;
209 #endif
211 // Begins the compositor's scheduler to start producing frames.
212 void StartCompositor();
214 // Stop compositing.
215 void WillCloseLayerTreeView();
217 // Called when a plugin is moved. These events are queued up and sent with
218 // the next paint or scroll message to the host.
219 void SchedulePluginMove(const WebPluginGeometry& move);
221 // Called when a plugin window has been destroyed, to make sure the currently
222 // pending moves don't try to reference it.
223 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
225 RenderWidgetCompositor* compositor() const;
227 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
229 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
230 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
232 // Send a synthetic gesture to the browser to be queued to the synthetic
233 // gesture controller.
234 void QueueSyntheticGesture(
235 scoped_ptr<SyntheticGestureParams> gesture_params,
236 const SyntheticGestureCompletionCallback& callback);
238 // Deliveres |message| together with compositor state change updates. The
239 // exact behavior depends on |policy|.
240 // This mechanism is not a drop-in replacement for IPC: messages sent this way
241 // will not be automatically available to BrowserMessageFilter, for example.
242 // FIFO ordering is preserved between messages enqueued with the same
243 // |policy|, the ordering between messages enqueued for different policies is
244 // undefined.
246 // |msg| message to send, ownership of |msg| is transferred.
247 // |policy| see the comment on MessageDeliveryPolicy.
248 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
250 // Handle common setup/teardown for handling IME events.
251 void StartHandlingImeEvent();
252 void FinishHandlingImeEvent();
254 // Returns whether we currently should handle an IME event.
255 bool ShouldHandleImeEvent();
257 // Called by the compositor when page scale animation completed.
258 virtual void DidCompletePageScaleAnimation() {}
260 // When paused in debugger, we send ack for mouse event early. This ensures
261 // that we continue receiving mouse moves and pass them to debugger. Returns
262 // whether we are paused in mouse move event and have sent the ack.
263 bool SendAckForMouseMoveFromDebugger();
265 // When resumed from pause in debugger while handling mouse move,
266 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
267 void IgnoreAckForMouseMoveFromDebugger();
269 // ScreenMetricsEmulator class manages screen emulation inside a render
270 // widget. This includes resizing, placing view on the screen at desired
271 // position, changing device scale factor, and scaling down the whole
272 // widget if required to fit into the browser window.
273 class ScreenMetricsEmulator;
275 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
276 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
278 // Indicates that the compositor is about to begin a frame. This is primarily
279 // to signal to flow control mechanisms that a frame is beginning, not to
280 // perform actual painting work.
281 void WillBeginCompositorFrame();
283 // Notifies about a compositor frame commit operation having finished.
284 virtual void DidCommitCompositorFrame();
286 // Notifies that the draw commands for a committed frame have been issued.
287 void DidCommitAndDrawCompositorFrame();
289 // Notifies that the compositor has posted a swapbuffers operation to the GPU
290 // process.
291 void DidCompleteSwapBuffers();
293 void ScheduleComposite();
294 void ScheduleCompositeWithForcedRedraw();
296 // Called by the compositor in single-threaded mode when a swap is posted,
297 // completes or is aborted.
298 void OnSwapBuffersPosted();
299 void OnSwapBuffersComplete();
300 void OnSwapBuffersAborted();
302 // Checks if the selection bounds have been changed. If they are changed,
303 // the new value will be sent to the browser process.
304 void UpdateSelectionBounds();
306 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
308 void OnShowHostContextMenu(ContextMenuParams* params);
310 enum ShowIme {
311 SHOW_IME_IF_NEEDED,
312 NO_SHOW_IME,
315 enum ChangeSource {
316 FROM_NON_IME,
317 FROM_IME,
320 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
321 // be displayed, e.g. after a tap on an input field on mobile.
322 // |change_source| should be FROM_NON_IME when the renderer has to wait for
323 // the browser to acknowledge the change before the renderer handles any more
324 // IME events. This is when the text change did not originate from the IME in
325 // the browser side, such as changes by JavaScript or autofill.
326 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
328 // Called when animations due to focus change have completed (if any). Can be
329 // called from the renderer, browser, or compositor.
330 virtual void FocusChangeComplete() {}
332 // Checks if the composition range or composition character bounds have been
333 // changed. If they are changed, the new value will be sent to the browser
334 // process. This method does nothing when the browser process is not able to
335 // handle composition range and composition character bounds.
336 void UpdateCompositionInfo(bool should_update_range);
338 #if defined(OS_ANDROID)
339 virtual bool DoesRecordFullLayer() const;
340 #endif
342 bool host_closing() const { return host_closing_; }
344 protected:
345 // Friend RefCounted so that the dtor can be non-public. Using this class
346 // without ref-counting is an error.
347 friend class base::RefCounted<RenderWidget>;
348 // For unit tests.
349 friend class RenderWidgetTest;
351 enum ResizeAck {
352 SEND_RESIZE_ACK,
353 NO_RESIZE_ACK,
356 RenderWidget(CompositorDependencies* compositor_deps,
357 blink::WebPopupType popup_type,
358 const blink::WebScreenInfo& screen_info,
359 bool swapped_out,
360 bool hidden,
361 bool never_visible);
363 ~RenderWidget() override;
365 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget,
366 blink::WebLocalFrame* frame);
368 // Creates a WebWidget based on the popup type.
369 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
371 // Initializes this view with the given opener. CompleteInit must be called
372 // later.
373 bool Init(int32 opener_id);
375 // Called by Init and subclasses to perform initialization.
376 bool DoInit(int32 opener_id,
377 blink::WebWidget* web_widget,
378 IPC::SyncMessage* create_widget_message);
380 // Finishes creation of a pending view started with Init.
381 void CompleteInit();
383 // Sets whether this RenderWidget has been swapped out to be displayed by
384 // a RenderWidget in a different process. If so, no new IPC messages will be
385 // sent (only ACKs) and the process is free to exit when there are no other
386 // active RenderWidgets.
387 void SetSwappedOut(bool is_swapped_out);
389 // Allows the process to exit once the unload handler has finished, if there
390 // are no other active RenderWidgets.
391 void WasSwappedOut();
393 void FlushPendingInputEventAck();
394 void DoDeferredClose();
395 void NotifyOnClose();
397 // Close the underlying WebWidget.
398 virtual void Close();
400 // Resizes the render widget.
401 void Resize(const gfx::Size& new_size,
402 const gfx::Size& physical_backing_size,
403 bool top_controls_shrink_blink_size,
404 float top_controls_height,
405 const gfx::Size& visible_viewport_size,
406 const gfx::Rect& resizer_rect,
407 bool is_fullscreen_granted,
408 blink::WebDisplayMode display_mode,
409 ResizeAck resize_ack);
410 // Used to force the size of a window when running layout tests.
411 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
412 virtual void SetScreenMetricsEmulationParameters(
413 bool enabled,
414 const blink::WebDeviceEmulationParams& params);
415 #if defined(OS_MACOSX) || defined(OS_ANDROID)
416 void SetExternalPopupOriginAdjustmentsForEmulation(
417 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
418 #endif
420 // RenderWidget IPC message handlers
421 void OnHandleInputEvent(const blink::WebInputEvent* event,
422 const ui::LatencyInfo& latency_info,
423 bool keyboard_shortcut);
424 void OnCursorVisibilityChange(bool is_visible);
425 void OnMouseCaptureLost();
426 virtual void OnSetFocus(bool enable);
427 void OnClose();
428 void OnCreatingNewAck();
429 virtual void OnResize(const ViewMsg_Resize_Params& params);
430 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
431 void OnDisableDeviceEmulation();
432 void OnColorProfile(const std::vector<char>& color_profile);
433 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
434 virtual void OnWasHidden();
435 virtual void OnWasShown(bool needs_repainting,
436 const ui::LatencyInfo& latency_info);
437 void OnCreateVideoAck(int32 video_id);
438 void OnUpdateVideoAck(int32 video_id);
439 void OnRequestMoveAck();
440 virtual void OnImeSetComposition(
441 const base::string16& text,
442 const std::vector<blink::WebCompositionUnderline>& underlines,
443 int selection_start,
444 int selection_end);
445 virtual void OnImeConfirmComposition(const base::string16& text,
446 const gfx::Range& replacement_range,
447 bool keep_selection);
448 void OnRepaint(gfx::Size size_to_paint);
449 void OnSyntheticGestureCompleted();
450 void OnSetTextDirection(blink::WebTextDirection direction);
451 void OnGetFPS();
452 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
453 const gfx::Rect& window_screen_rect);
454 void OnShowImeIfNeeded();
455 void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace);
457 #if defined(OS_ANDROID)
458 // Called when we send IME event that expects an ACK.
459 void OnImeEventSentForAck(const blink::WebTextInputInfo& info);
461 // Called by the browser process for every required IME acknowledgement.
462 void OnImeEventAck();
463 #endif
465 // Notify the compositor about a change in viewport size. This should be
466 // used only with auto resize mode WebWidgets, as normal WebWidgets should
467 // go through OnResize.
468 void AutoResizeCompositor();
470 virtual void SetDeviceScaleFactor(float device_scale_factor);
471 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
472 virtual void ResetDeviceColorProfileForTesting();
474 virtual void OnOrientationChange();
476 // Override points to notify derived classes that a paint has happened.
477 // DidInitiatePaint happens when that has completed, and subsequent rendering
478 // won't affect the painted content. DidFlushPaint happens once we've received
479 // the ACK that the screen has been updated. For a given paint operation,
480 // these overrides will always be called in the order DidInitiatePaint,
481 // DidFlushPaint.
482 virtual void DidInitiatePaint() {}
483 virtual void DidFlushPaint() {}
485 virtual GURL GetURLForGraphicsContext3D();
487 // Gets the scroll offset of this widget, if this widget has a notion of
488 // scroll offset.
489 virtual gfx::Vector2d GetScrollOffset();
491 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
492 // use this method so that we can properly inform the RenderThread of our
493 // state.
494 void SetHidden(bool hidden);
496 void DidToggleFullscreen();
498 bool next_paint_is_resize_ack() const;
499 void set_next_paint_is_resize_ack();
500 void set_next_paint_is_repaint_ack();
502 // QueueMessage implementation extracted into a static method for easy
503 // testing.
504 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
505 IPC::Message* msg,
506 MessageDeliveryPolicy policy,
507 FrameSwapMessageQueue* frame_swap_message_queue,
508 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
509 int source_frame_number);
511 // Override point to obtain that the current input method state and caret
512 // position.
513 virtual ui::TextInputType GetTextInputType();
514 virtual ui::TextInputType WebKitToUiTextInputType(
515 blink::WebTextInputType type);
517 // Override point to obtain that the current composition character bounds.
518 // In the case of surrogate pairs, the character is treated as two characters:
519 // the bounds for first character is actual one, and the bounds for second
520 // character is zero width rectangle.
521 virtual void GetCompositionCharacterBounds(
522 std::vector<gfx::Rect>* character_bounds);
524 // Returns the range of the text that is being composed or the selection if
525 // the composition does not exist.
526 virtual void GetCompositionRange(gfx::Range* range);
528 // Returns true if the composition range or composition character bounds
529 // should be sent to the browser process.
530 bool ShouldUpdateCompositionInfo(
531 const gfx::Range& range,
532 const std::vector<gfx::Rect>& bounds);
534 // Override point to obtain that the current input method state about
535 // composition text.
536 virtual bool CanComposeInline();
538 // Tells the renderer it does not have focus. Used to prevent us from getting
539 // the focus on our own when the browser did not focus us.
540 void ClearFocus();
542 // Set the pending window rect.
543 // Because the real render_widget is hosted in another process, there is
544 // a time period where we may have set a new window rect which has not yet
545 // been processed by the browser. So we maintain a pending window rect
546 // size. If JS code sets the WindowRect, and then immediately calls
547 // GetWindowRect() we'll use this pending window rect as the size.
548 void SetPendingWindowRect(const blink::WebRect& r);
550 // Called by OnHandleInputEvent() to notify subclasses that a key event was
551 // just handled.
552 virtual void DidHandleKeyEvent() {}
554 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
555 // about to be handled.
556 // Returns true if no further handling is needed. In that case, the event
557 // won't be sent to WebKit or trigger DidHandleMouseEvent().
558 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
560 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
561 // about to be handled.
562 // Returns true if no further handling is needed. In that case, the event
563 // won't be sent to WebKit.
564 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
566 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
567 // compositor thread, to effect the elastic overscroll effect.
568 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
569 const gfx::Vector2dF& wheel_unused_delta,
570 bool event_processed);
572 // Check whether the WebWidget has any touch event handlers registered
573 // at the given point.
574 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
576 // Check whether the WebWidget has any touch event handlers registered.
577 virtual void hasTouchEventHandlers(bool has_handlers);
579 // Tell the browser about the actions permitted for a new touch point.
580 virtual void setTouchAction(blink::WebTouchAction touch_action);
582 // Called when value of focused text field gets dirty, e.g. value is modified
583 // by script, not by user input.
584 virtual void didUpdateTextOfFocusedElementByNonUserInput();
586 // Creates a 3D context associated with this view.
587 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(
588 bool compositor);
590 // Routing ID that allows us to communicate to the parent browser process
591 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
592 int32 routing_id_;
594 int32 surface_id_;
596 // Dependencies for initializing a compositor, including flags for optional
597 // features.
598 CompositorDependencies* const compositor_deps_;
600 // We are responsible for destroying this object via its Close method.
601 // May be NULL when the window is closing.
602 blink::WebWidget* webwidget_;
604 // This is lazily constructed and must not outlive webwidget_.
605 scoped_ptr<RenderWidgetCompositor> compositor_;
607 // Set to the ID of the view that initiated creating this view, if any. When
608 // the view was initiated by the browser (the common case), this will be
609 // MSG_ROUTING_NONE. This is used in determining ownership when opening
610 // child tabs. See RenderWidget::createWebViewWithRequest.
612 // This ID may refer to an invalid view if that view is closed before this
613 // view is.
614 int32 opener_id_;
616 // The rect where this view should be initially shown.
617 gfx::Rect initial_rect_;
619 bool init_complete_;
621 // We store the current cursor object so we can avoid spamming SetCursor
622 // messages.
623 WebCursor current_cursor_;
625 // The size of the RenderWidget.
626 gfx::Size size_;
628 // The size of the view's backing surface in non-DPI-adjusted pixels.
629 gfx::Size physical_backing_size_;
631 // Whether or not Blink's viewport size should be shrunk by the height of the
632 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
633 bool top_controls_shrink_blink_size_;
635 // The height of the top controls (always 0 on platforms where URL-bar hiding
636 // isn't supported).
637 float top_controls_height_;
639 // The size of the visible viewport in DPI-adjusted pixels.
640 gfx::Size visible_viewport_size_;
642 // The area that must be reserved for drawing the resize corner.
643 gfx::Rect resizer_rect_;
645 // Flags for the next ViewHostMsg_UpdateRect message.
646 int next_paint_flags_;
648 // Whether the WebWidget is in auto resize mode, which is used for example
649 // by extension popups.
650 bool auto_resize_mode_;
652 // True if we need to send an UpdateRect message to notify the browser about
653 // an already-completed auto-resize.
654 bool need_update_rect_for_auto_resize_;
656 // Set to true if we should ignore RenderWidget::Show calls.
657 bool did_show_;
659 // Indicates that we shouldn't bother generated paint events.
660 bool is_hidden_;
662 // Indicates that we are never visible, so never produce graphical output.
663 bool never_visible_;
665 // Indicates whether tab-initiated fullscreen was granted.
666 bool is_fullscreen_granted_;
668 // Indicates the display mode.
669 blink::WebDisplayMode display_mode_;
671 // Indicates whether we have been focused/unfocused by the browser.
672 bool has_focus_;
674 // Are we currently handling an input event?
675 bool handling_input_event_;
677 // Used to intercept overscroll notifications while an event is being
678 // handled. If the event causes overscroll, the overscroll metadata can be
679 // bundled in the event ack, saving an IPC. Note that we must continue
680 // supporting overscroll IPC notifications due to fling animation updates.
681 scoped_ptr<DidOverscrollParams>* handling_event_overscroll_;
683 // Are we currently handling an ime event?
684 bool handling_ime_event_;
686 // Type of the input event we are currently handling.
687 blink::WebInputEvent::Type handling_event_type_;
689 // Whether we should not send ack for the current mouse move.
690 bool ignore_ack_for_mouse_move_from_debugger_;
692 // True if we have requested this widget be closed. No more messages will
693 // be sent, except for a Close.
694 bool closing_;
696 // True if it is known that the host is in the process of being shut down.
697 bool host_closing_;
699 // Whether this RenderWidget is currently swapped out, such that the view is
700 // being rendered by another process. If all RenderWidgets in a process are
701 // swapped out, the process can exit.
702 bool is_swapped_out_;
704 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
705 // OOPIF(crbug.com/471411).
706 // Whether this RenderWidget is for an out-of-process iframe or not.
707 bool for_oopif_;
709 // Stores information about the current text input.
710 blink::WebTextInputInfo text_input_info_;
712 // Stores the current text input type of |webwidget_|.
713 ui::TextInputType text_input_type_;
715 // Stores the current text input mode of |webwidget_|.
716 ui::TextInputMode text_input_mode_;
718 // Stores the current text input flags of |webwidget_|.
719 int text_input_flags_;
721 // Stores the current type of composition text rendering of |webwidget_|.
722 bool can_compose_inline_;
724 // Stores the current selection bounds.
725 gfx::Rect selection_focus_rect_;
726 gfx::Rect selection_anchor_rect_;
728 // Stores the current composition character bounds.
729 std::vector<gfx::Rect> composition_character_bounds_;
731 // Stores the current composition range.
732 gfx::Range composition_range_;
734 // The kind of popup this widget represents, NONE if not a popup.
735 blink::WebPopupType popup_type_;
737 // Holds all the needed plugin window moves for a scroll.
738 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
739 WebPluginGeometryVector plugin_window_moves_;
741 // While we are waiting for the browser to update window sizes, we track the
742 // pending size temporarily.
743 int pending_window_rect_count_;
744 blink::WebRect pending_window_rect_;
746 // The screen rects of the view and the window that contains it.
747 gfx::Rect view_screen_rect_;
748 gfx::Rect window_screen_rect_;
750 scoped_ptr<IPC::Message> pending_input_event_ack_;
752 // The time spent in input handlers this frame. Used to throttle input acks.
753 base::TimeDelta total_input_handling_time_this_frame_;
755 // Indicates if the next sequence of Char events should be suppressed or not.
756 bool suppress_next_char_events_;
758 // Properties of the screen hosting this RenderWidget instance.
759 blink::WebScreenInfo screen_info_;
761 // The device scale factor. This value is computed from the DPI entries in
762 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
763 float device_scale_factor_;
765 // The device color profile on supported platforms.
766 std::vector<char> device_color_profile_;
768 // State associated with synthetic gestures. Synthetic gestures are processed
769 // in-order, so a queue is sufficient to identify the correct state for a
770 // completed gesture.
771 std::queue<SyntheticGestureCompletionCallback>
772 pending_synthetic_gesture_callbacks_;
774 uint32 next_output_surface_id_;
776 #if defined(OS_ANDROID)
777 // Indicates value in the focused text field is in dirty state, i.e. modified
778 // by script etc., not by user input.
779 bool text_field_is_dirty_;
781 // Stores the history of text input infos from the last ACK'ed one from the
782 // current one. The size is the number of pending ACKs plus one, since we
783 // intentionally keep the last ack'd value to know what the browser is
784 // currently aware of.
785 std::deque<blink::WebTextInputInfo> text_input_info_history_;
786 #endif
788 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
790 // Popups may be displaced when screen metrics emulation is enabled.
791 // These values are used to properly adjust popup position.
792 gfx::PointF popup_view_origin_for_emulation_;
793 gfx::PointF popup_screen_origin_for_emulation_;
794 float popup_origin_scale_for_emulation_;
796 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
797 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
799 // Lists of RenderFrameProxy objects that need to be notified of
800 // compositing-related events (e.g. DidCommitCompositorFrame).
801 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
802 #if defined(VIDEO_HOLE)
803 base::ObserverList<RenderFrameImpl> video_hole_frames_;
804 #endif // defined(VIDEO_HOLE)
806 // A list of RenderFrames associated with this RenderWidget. Notifications
807 // are sent to each frame in the list for events such as changing
808 // visibility state for example.
809 base::ObserverList<RenderFrameImpl> render_frames_;
811 ui::MenuSourceType context_menu_source_type_;
812 bool has_host_context_menu_location_;
813 gfx::Point host_context_menu_location_;
815 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
818 } // namespace content
820 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_