Add ICU message format support
[chromium-blink-merge.git] / content / renderer / render_widget.h
blob3329426b264d6f02261b57250b93fc0e4d10779c
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 // Whenever an IME event that needs an acknowledgement is sent to the browser,
458 // the number of outstanding IME events that needs acknowledgement should be
459 // incremented. All IME events will be dropped until we receive an ack from
460 // the browser.
461 void IncrementOutstandingImeEventAcks();
463 // Called by the browser process for every required IME acknowledgement.
464 void OnImeEventAck();
465 #endif
467 // Notify the compositor about a change in viewport size. This should be
468 // used only with auto resize mode WebWidgets, as normal WebWidgets should
469 // go through OnResize.
470 void AutoResizeCompositor();
472 virtual void SetDeviceScaleFactor(float device_scale_factor);
473 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
474 virtual void ResetDeviceColorProfileForTesting();
476 virtual void OnOrientationChange();
478 // Override points to notify derived classes that a paint has happened.
479 // DidInitiatePaint happens when that has completed, and subsequent rendering
480 // won't affect the painted content. DidFlushPaint happens once we've received
481 // the ACK that the screen has been updated. For a given paint operation,
482 // these overrides will always be called in the order DidInitiatePaint,
483 // DidFlushPaint.
484 virtual void DidInitiatePaint() {}
485 virtual void DidFlushPaint() {}
487 virtual GURL GetURLForGraphicsContext3D();
489 // Gets the scroll offset of this widget, if this widget has a notion of
490 // scroll offset.
491 virtual gfx::Vector2d GetScrollOffset();
493 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
494 // use this method so that we can properly inform the RenderThread of our
495 // state.
496 void SetHidden(bool hidden);
498 void DidToggleFullscreen();
500 bool next_paint_is_resize_ack() const;
501 void set_next_paint_is_resize_ack();
502 void set_next_paint_is_repaint_ack();
504 // QueueMessage implementation extracted into a static method for easy
505 // testing.
506 static scoped_ptr<cc::SwapPromise> QueueMessageImpl(
507 IPC::Message* msg,
508 MessageDeliveryPolicy policy,
509 FrameSwapMessageQueue* frame_swap_message_queue,
510 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
511 int source_frame_number);
513 // Override point to obtain that the current input method state and caret
514 // position.
515 virtual ui::TextInputType GetTextInputType();
516 virtual ui::TextInputType WebKitToUiTextInputType(
517 blink::WebTextInputType type);
519 // Override point to obtain that the current composition character bounds.
520 // In the case of surrogate pairs, the character is treated as two characters:
521 // the bounds for first character is actual one, and the bounds for second
522 // character is zero width rectangle.
523 virtual void GetCompositionCharacterBounds(
524 std::vector<gfx::Rect>* character_bounds);
526 // Returns the range of the text that is being composed or the selection if
527 // the composition does not exist.
528 virtual void GetCompositionRange(gfx::Range* range);
530 // Returns true if the composition range or composition character bounds
531 // should be sent to the browser process.
532 bool ShouldUpdateCompositionInfo(
533 const gfx::Range& range,
534 const std::vector<gfx::Rect>& bounds);
536 // Override point to obtain that the current input method state about
537 // composition text.
538 virtual bool CanComposeInline();
540 // Tells the renderer it does not have focus. Used to prevent us from getting
541 // the focus on our own when the browser did not focus us.
542 void ClearFocus();
544 // Set the pending window rect.
545 // Because the real render_widget is hosted in another process, there is
546 // a time period where we may have set a new window rect which has not yet
547 // been processed by the browser. So we maintain a pending window rect
548 // size. If JS code sets the WindowRect, and then immediately calls
549 // GetWindowRect() we'll use this pending window rect as the size.
550 void SetPendingWindowRect(const blink::WebRect& r);
552 // Called by OnHandleInputEvent() to notify subclasses that a key event was
553 // just handled.
554 virtual void DidHandleKeyEvent() {}
556 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
557 // about to be handled.
558 // Returns true if no further handling is needed. In that case, the event
559 // won't be sent to WebKit or trigger DidHandleMouseEvent().
560 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
562 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
563 // about to be handled.
564 // Returns true if no further handling is needed. In that case, the event
565 // won't be sent to WebKit.
566 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
568 // Called by OnHandleInputEvent() to forward a mouse wheel event to the
569 // compositor thread, to effect the elastic overscroll effect.
570 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
571 const gfx::Vector2dF& wheel_unused_delta,
572 bool event_processed);
574 // Check whether the WebWidget has any touch event handlers registered
575 // at the given point.
576 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
578 // Check whether the WebWidget has any touch event handlers registered.
579 virtual void hasTouchEventHandlers(bool has_handlers);
581 // Tell the browser about the actions permitted for a new touch point.
582 virtual void setTouchAction(blink::WebTouchAction touch_action);
584 // Called when value of focused text field gets dirty, e.g. value is modified
585 // by script, not by user input.
586 virtual void didUpdateTextOfFocusedElementByNonUserInput();
588 // Creates a 3D context associated with this view.
589 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(
590 bool compositor);
592 // Routing ID that allows us to communicate to the parent browser process
593 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
594 int32 routing_id_;
596 int32 surface_id_;
598 // Dependencies for initializing a compositor, including flags for optional
599 // features.
600 CompositorDependencies* const compositor_deps_;
602 // We are responsible for destroying this object via its Close method.
603 // May be NULL when the window is closing.
604 blink::WebWidget* webwidget_;
606 // This is lazily constructed and must not outlive webwidget_.
607 scoped_ptr<RenderWidgetCompositor> compositor_;
609 // Set to the ID of the view that initiated creating this view, if any. When
610 // the view was initiated by the browser (the common case), this will be
611 // MSG_ROUTING_NONE. This is used in determining ownership when opening
612 // child tabs. See RenderWidget::createWebViewWithRequest.
614 // This ID may refer to an invalid view if that view is closed before this
615 // view is.
616 int32 opener_id_;
618 // The rect where this view should be initially shown.
619 gfx::Rect initial_rect_;
621 bool init_complete_;
623 // We store the current cursor object so we can avoid spamming SetCursor
624 // messages.
625 WebCursor current_cursor_;
627 // The size of the RenderWidget.
628 gfx::Size size_;
630 // The size of the view's backing surface in non-DPI-adjusted pixels.
631 gfx::Size physical_backing_size_;
633 // Whether or not Blink's viewport size should be shrunk by the height of the
634 // URL-bar (always false on platforms where URL-bar hiding isn't supported).
635 bool top_controls_shrink_blink_size_;
637 // The height of the top controls (always 0 on platforms where URL-bar hiding
638 // isn't supported).
639 float top_controls_height_;
641 // The size of the visible viewport in DPI-adjusted pixels.
642 gfx::Size visible_viewport_size_;
644 // The area that must be reserved for drawing the resize corner.
645 gfx::Rect resizer_rect_;
647 // Flags for the next ViewHostMsg_UpdateRect message.
648 int next_paint_flags_;
650 // Whether the WebWidget is in auto resize mode, which is used for example
651 // by extension popups.
652 bool auto_resize_mode_;
654 // True if we need to send an UpdateRect message to notify the browser about
655 // an already-completed auto-resize.
656 bool need_update_rect_for_auto_resize_;
658 // Set to true if we should ignore RenderWidget::Show calls.
659 bool did_show_;
661 // Indicates that we shouldn't bother generated paint events.
662 bool is_hidden_;
664 // Indicates that we are never visible, so never produce graphical output.
665 bool never_visible_;
667 // Indicates whether tab-initiated fullscreen was granted.
668 bool is_fullscreen_granted_;
670 // Indicates the display mode.
671 blink::WebDisplayMode display_mode_;
673 // Indicates whether we have been focused/unfocused by the browser.
674 bool has_focus_;
676 // Are we currently handling an input event?
677 bool handling_input_event_;
679 // Used to intercept overscroll notifications while an event is being
680 // handled. If the event causes overscroll, the overscroll metadata can be
681 // bundled in the event ack, saving an IPC. Note that we must continue
682 // supporting overscroll IPC notifications due to fling animation updates.
683 scoped_ptr<DidOverscrollParams>* handling_event_overscroll_;
685 // Are we currently handling an ime event?
686 bool handling_ime_event_;
688 // Type of the input event we are currently handling.
689 blink::WebInputEvent::Type handling_event_type_;
691 // Whether we should not send ack for the current mouse move.
692 bool ignore_ack_for_mouse_move_from_debugger_;
694 // True if we have requested this widget be closed. No more messages will
695 // be sent, except for a Close.
696 bool closing_;
698 // True if it is known that the host is in the process of being shut down.
699 bool host_closing_;
701 // Whether this RenderWidget is currently swapped out, such that the view is
702 // being rendered by another process. If all RenderWidgets in a process are
703 // swapped out, the process can exit.
704 bool is_swapped_out_;
706 // TODO(simonhong): Remove this when we enable BeginFrame scheduling for
707 // OOPIF(crbug.com/471411).
708 // Whether this RenderWidget is for an out-of-process iframe or not.
709 bool for_oopif_;
711 // Stores information about the current text input.
712 blink::WebTextInputInfo text_input_info_;
714 // Stores the current text input type of |webwidget_|.
715 ui::TextInputType text_input_type_;
717 // Stores the current text input mode of |webwidget_|.
718 ui::TextInputMode text_input_mode_;
720 // Stores the current text input flags of |webwidget_|.
721 int text_input_flags_;
723 // Stores the current type of composition text rendering of |webwidget_|.
724 bool can_compose_inline_;
726 // Stores the current selection bounds.
727 gfx::Rect selection_focus_rect_;
728 gfx::Rect selection_anchor_rect_;
730 // Stores the current composition character bounds.
731 std::vector<gfx::Rect> composition_character_bounds_;
733 // Stores the current composition range.
734 gfx::Range composition_range_;
736 // The kind of popup this widget represents, NONE if not a popup.
737 blink::WebPopupType popup_type_;
739 // Holds all the needed plugin window moves for a scroll.
740 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
741 WebPluginGeometryVector plugin_window_moves_;
743 // While we are waiting for the browser to update window sizes, we track the
744 // pending size temporarily.
745 int pending_window_rect_count_;
746 blink::WebRect pending_window_rect_;
748 // The screen rects of the view and the window that contains it.
749 gfx::Rect view_screen_rect_;
750 gfx::Rect window_screen_rect_;
752 scoped_ptr<IPC::Message> pending_input_event_ack_;
754 // The time spent in input handlers this frame. Used to throttle input acks.
755 base::TimeDelta total_input_handling_time_this_frame_;
757 // Indicates if the next sequence of Char events should be suppressed or not.
758 bool suppress_next_char_events_;
760 // Properties of the screen hosting this RenderWidget instance.
761 blink::WebScreenInfo screen_info_;
763 // The device scale factor. This value is computed from the DPI entries in
764 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
765 float device_scale_factor_;
767 // The device color profile on supported platforms.
768 std::vector<char> device_color_profile_;
770 // State associated with synthetic gestures. Synthetic gestures are processed
771 // in-order, so a queue is sufficient to identify the correct state for a
772 // completed gesture.
773 std::queue<SyntheticGestureCompletionCallback>
774 pending_synthetic_gesture_callbacks_;
776 uint32 next_output_surface_id_;
778 #if defined(OS_ANDROID)
779 // Indicates value in the focused text field is in dirty state, i.e. modified
780 // by script etc., not by user input.
781 bool text_field_is_dirty_;
783 // A counter for number of outstanding messages from the renderer to the
784 // browser regarding IME-type events that have not been acknowledged by the
785 // browser. If this value is not 0 IME events will be dropped.
786 int outstanding_ime_acks_;
788 // The background color of the document body element. This is used as the
789 // default background color for filling the screen areas for which we don't
790 // have the actual content.
791 SkColor body_background_color_;
792 #endif
794 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
796 // Popups may be displaced when screen metrics emulation is enabled.
797 // These values are used to properly adjust popup position.
798 gfx::PointF popup_view_origin_for_emulation_;
799 gfx::PointF popup_screen_origin_for_emulation_;
800 float popup_origin_scale_for_emulation_;
802 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
803 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
805 // Lists of RenderFrameProxy objects that need to be notified of
806 // compositing-related events (e.g. DidCommitCompositorFrame).
807 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
808 #if defined(VIDEO_HOLE)
809 base::ObserverList<RenderFrameImpl> video_hole_frames_;
810 #endif // defined(VIDEO_HOLE)
812 // A list of RenderFrames associated with this RenderWidget. Notifications
813 // are sent to each frame in the list for events such as changing
814 // visibility state for example.
815 base::ObserverList<RenderFrameImpl> render_frames_;
817 ui::MenuSourceType context_menu_source_type_;
818 bool has_host_context_menu_location_;
819 gfx::Point host_context_menu_location_;
821 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
824 } // namespace content
826 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_