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. 4 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ 7 8 #include <deque> 9 #include <map> 10 11 #include "base/auto_reset.h" 12 #include "base/basictypes.h" 13 #include "base/callback.h" 14 #include "base/compiler_specific.h" 15 #include "base/memory/ref_counted.h" 16 #include "base/memory/scoped_ptr.h" 17 #include "base/observer_list.h" 18 #include "base/time/time.h" 19 #include "base/timer/timer.h" 20 #include "cc/debug/rendering_stats_instrumentation.h" 21 #include "content/common/content_export.h" 22 #include "content/common/cursors/webcursor.h" 23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 24 #include "content/common/input/synthetic_gesture_params.h" 25 #include "content/renderer/message_delivery_policy.h" 26 #include "ipc/ipc_listener.h" 27 #include "ipc/ipc_sender.h" 28 #include "third_party/WebKit/public/platform/WebRect.h" 29 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 30 #include "third_party/WebKit/public/web/WebInputEvent.h" 31 #include "third_party/WebKit/public/web/WebPopupType.h" 32 #include "third_party/WebKit/public/web/WebTextDirection.h" 33 #include "third_party/WebKit/public/web/WebTextInputInfo.h" 34 #include "third_party/WebKit/public/web/WebTouchAction.h" 35 #include "third_party/WebKit/public/web/WebWidget.h" 36 #include "third_party/WebKit/public/web/WebWidgetClient.h" 37 #include "third_party/skia/include/core/SkBitmap.h" 38 #include "ui/base/ime/text_input_mode.h" 39 #include "ui/base/ime/text_input_type.h" 40 #include "ui/base/ui_base_types.h" 41 #include "ui/gfx/native_widget_types.h" 42 #include "ui/gfx/range/range.h" 43 #include "ui/gfx/rect.h" 44 #include "ui/gfx/vector2d.h" 45 #include "ui/gfx/vector2d_f.h" 46 #include "ui/surface/transport_dib.h" 47 48 struct ViewHostMsg_UpdateRect_Params; 49 struct ViewMsg_Resize_Params; 50 class ViewHostMsg_UpdateRect; 51 52 namespace IPC { 53 class SyncMessage; 54 class SyncMessageFilter; 55 } 56 57 namespace blink { 58 struct WebDeviceEmulationParams; 59 class WebGestureEvent; 60 class WebKeyboardEvent; 61 class WebMouseEvent; 62 class WebTouchEvent; 63 } 64 65 namespace cc { 66 class OutputSurface; 67 class SwapPromise; 68 } 69 70 namespace gfx { 71 class Range; 72 } 73 74 namespace content { 75 class ExternalPopupMenu; 76 class FrameSwapMessageQueue; 77 class PepperPluginInstanceImpl; 78 class RenderFrameImpl; 79 class RenderFrameProxy; 80 class RenderWidgetCompositor; 81 class RenderWidgetTest; 82 class ResizingModeSelector; 83 struct ContextMenuParams; 84 struct WebPluginGeometry; 85 86 // RenderWidget provides a communication bridge between a WebWidget and 87 // a RenderWidgetHost, the latter of which lives in a different process. 88 class CONTENT_EXPORT RenderWidget 89 : public IPC::Listener, 90 public IPC::Sender, 91 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), 92 public base::RefCounted<RenderWidget> { 93 public: 94 // Creates a new RenderWidget. The opener_id is the routing ID of the 95 // RenderView that this widget lives inside. 96 static RenderWidget* Create(int32 opener_id, 97 blink::WebPopupType popup_type, 98 const blink::WebScreenInfo& screen_info); 99 100 // Creates a WebWidget based on the popup type. 101 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); 102 routing_id()103 int32 routing_id() const { return routing_id_; } surface_id()104 int32 surface_id() const { return surface_id_; } webwidget()105 blink::WebWidget* webwidget() const { return webwidget_; } size()106 gfx::Size size() const { return size_; } has_focus()107 bool has_focus() const { return has_focus_; } is_fullscreen()108 bool is_fullscreen() const { return is_fullscreen_; } is_hidden()109 bool is_hidden() const { return is_hidden_; } handling_input_event()110 bool handling_input_event() const { return handling_input_event_; } 111 // Temporary for debugging purposes... closing()112 bool closing() const { return closing_; } is_swapped_out()113 bool is_swapped_out() { return is_swapped_out_; } context_menu_source_type()114 ui::MenuSourceType context_menu_source_type() { 115 return context_menu_source_type_; 116 } has_host_context_menu_location()117 bool has_host_context_menu_location() { 118 return has_host_context_menu_location_; 119 } host_context_menu_location()120 gfx::Point host_context_menu_location() { 121 return host_context_menu_location_; 122 } 123 124 // Functions to track out-of-process frames for special notifications. 125 void RegisterRenderFrameProxy(RenderFrameProxy* proxy); 126 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy); 127 128 // Functions to track all RenderFrame objects associated with this 129 // RenderWidget. 130 void RegisterRenderFrame(RenderFrameImpl* frame); 131 void UnregisterRenderFrame(RenderFrameImpl* frame); 132 133 #if defined(VIDEO_HOLE) 134 void RegisterVideoHoleFrame(RenderFrameImpl* frame); 135 void UnregisterVideoHoleFrame(RenderFrameImpl* frame); 136 #endif // defined(VIDEO_HOLE) 137 138 // IPC::Listener 139 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 140 141 // IPC::Sender 142 virtual bool Send(IPC::Message* msg) OVERRIDE; 143 144 // blink::WebWidgetClient 145 virtual void willBeginCompositorFrame(); 146 virtual void didAutoResize(const blink::WebSize& new_size); 147 virtual void initializeLayerTreeView(); 148 virtual blink::WebLayerTreeView* layerTreeView(); 149 virtual void didBecomeReadyForAdditionalInput(); 150 virtual void didCommitAndDrawCompositorFrame(); 151 virtual void didCompleteSwapBuffers(); 152 virtual void scheduleComposite(); 153 virtual void didFocus(); 154 virtual void didBlur(); 155 virtual void didChangeCursor(const blink::WebCursorInfo&); 156 virtual void closeWidgetSoon(); 157 virtual void show(blink::WebNavigationPolicy); runModal()158 virtual void runModal() {} 159 virtual blink::WebRect windowRect(); 160 virtual void setToolTipText(const blink::WebString& text, 161 blink::WebTextDirection hint); 162 virtual void setWindowRect(const blink::WebRect&); 163 virtual blink::WebRect windowResizerRect(); 164 virtual blink::WebRect rootWindowRect(); 165 virtual blink::WebScreenInfo screenInfo(); 166 virtual float deviceScaleFactor(); 167 virtual void resetInputMethod(); 168 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, 169 bool event_cancelled); 170 virtual void showImeIfNeeded(); 171 172 // Begins the compositor's scheduler to start producing frames. 173 void StartCompositor(); 174 175 // Stop compositing. 176 void DestroyLayerTreeView(); 177 178 // Called when a plugin is moved. These events are queued up and sent with 179 // the next paint or scroll message to the host. 180 void SchedulePluginMove(const WebPluginGeometry& move); 181 182 // Called when a plugin window has been destroyed, to make sure the currently 183 // pending moves don't try to reference it. 184 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window); 185 186 RenderWidgetCompositor* compositor() const; 187 current_event_latency_info()188 const ui::LatencyInfo* current_event_latency_info() const { 189 return current_event_latency_info_; 190 } 191 192 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback); 193 194 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll). 195 typedef base::Callback<void()> SyntheticGestureCompletionCallback; 196 197 // Send a synthetic gesture to the browser to be queued to the synthetic 198 // gesture controller. 199 void QueueSyntheticGesture( 200 scoped_ptr<SyntheticGestureParams> gesture_params, 201 const SyntheticGestureCompletionCallback& callback); 202 203 // Close the underlying WebWidget. 204 virtual void Close(); 205 206 // Notifies about a compositor frame commit operation having finished. 207 virtual void DidCommitCompositorFrame(); 208 209 // Deliveres |message| together with compositor state change updates. The 210 // exact behavior depends on |policy|. 211 // This mechanism is not a drop-in replacement for IPC: messages sent this way 212 // will not be automatically available to BrowserMessageFilter, for example. 213 // FIFO ordering is preserved between messages enqueued with the same 214 // |policy|, the ordering between messages enqueued for different policies is 215 // undefined. 216 // 217 // |msg| message to send, ownership of |msg| is transferred. 218 // |policy| see the comment on MessageDeliveryPolicy. 219 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy); 220 221 // Handle common setup/teardown for handling IME events. 222 void StartHandlingImeEvent(); 223 void FinishHandlingImeEvent(); 224 225 // Returns whether we currently should handle an IME event. 226 bool ShouldHandleImeEvent(); 227 InstrumentWillBeginFrame(int frame_id)228 virtual void InstrumentWillBeginFrame(int frame_id) {} InstrumentDidBeginFrame()229 virtual void InstrumentDidBeginFrame() {} InstrumentDidCancelFrame()230 virtual void InstrumentDidCancelFrame() {} InstrumentWillComposite()231 virtual void InstrumentWillComposite() {} 232 233 // When paused in debugger, we send ack for mouse event early. This ensures 234 // that we continue receiving mouse moves and pass them to debugger. Returns 235 // whether we are paused in mouse move event and have sent the ack. 236 bool SendAckForMouseMoveFromDebugger(); 237 238 // When resumed from pause in debugger while handling mouse move, 239 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger). 240 void IgnoreAckForMouseMoveFromDebugger(); 241 242 // ScreenMetricsEmulator class manages screen emulation inside a render 243 // widget. This includes resizing, placing view on the screen at desired 244 // position, changing device scale factor, and scaling down the whole 245 // widget if required to fit into the browser window. 246 class ScreenMetricsEmulator; 247 248 // Emulates screen and widget metrics. Supplied values override everything 249 // coming from host. 250 void EnableScreenMetricsEmulation( 251 const blink::WebDeviceEmulationParams& params); 252 void DisableScreenMetricsEmulation(); 253 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); 254 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); 255 256 void ScheduleCompositeWithForcedRedraw(); 257 258 // Called by the compositor in single-threaded mode when a swap is posted, 259 // completes or is aborted. 260 void OnSwapBuffersPosted(); 261 void OnSwapBuffersComplete(); 262 void OnSwapBuffersAborted(); 263 264 // Checks if the text input state and compose inline mode have been changed. 265 // If they are changed, the new value will be sent to the browser process. 266 void UpdateTextInputType(); 267 268 // Checks if the selection bounds have been changed. If they are changed, 269 // the new value will be sent to the browser process. 270 void UpdateSelectionBounds(); 271 272 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); 273 274 void OnShowHostContextMenu(ContextMenuParams* params); 275 276 #if defined(OS_ANDROID) || defined(USE_AURA) 277 enum ShowIme { 278 SHOW_IME_IF_NEEDED, 279 NO_SHOW_IME, 280 }; 281 282 enum ChangeSource { 283 FROM_NON_IME, 284 FROM_IME, 285 }; 286 287 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to 288 // be displayed, e.g. after a tap on an input field on mobile. 289 // |change_source| should be FROM_NON_IME when the renderer has to wait for 290 // the browser to acknowledge the change before the renderer handles any more 291 // IME events. This is when the text change did not originate from the IME in 292 // the browser side, such as changes by JavaScript or autofill. 293 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source); 294 #endif 295 296 #if defined(OS_MACOSX) || defined(USE_AURA) 297 // Checks if the composition range or composition character bounds have been 298 // changed. If they are changed, the new value will be sent to the browser 299 // process. 300 void UpdateCompositionInfo(bool should_update_range); 301 #endif 302 303 #if defined(OS_ANDROID) 304 void DidChangeBodyBackgroundColor(SkColor bg_color); 305 #endif 306 307 protected: 308 // Friend RefCounted so that the dtor can be non-public. Using this class 309 // without ref-counting is an error. 310 friend class base::RefCounted<RenderWidget>; 311 // For unit tests. 312 friend class RenderWidgetTest; 313 314 enum ResizeAck { 315 SEND_RESIZE_ACK, 316 NO_RESIZE_ACK, 317 }; 318 319 RenderWidget(blink::WebPopupType popup_type, 320 const blink::WebScreenInfo& screen_info, 321 bool swapped_out, 322 bool hidden, 323 bool never_visible); 324 325 virtual ~RenderWidget(); 326 327 // Initializes this view with the given opener. CompleteInit must be called 328 // later. 329 bool Init(int32 opener_id); 330 331 // Called by Init and subclasses to perform initialization. 332 bool DoInit(int32 opener_id, 333 blink::WebWidget* web_widget, 334 IPC::SyncMessage* create_widget_message); 335 336 // Finishes creation of a pending view started with Init. 337 void CompleteInit(); 338 339 // Sets whether this RenderWidget has been swapped out to be displayed by 340 // a RenderWidget in a different process. If so, no new IPC messages will be 341 // sent (only ACKs) and the process is free to exit when there are no other 342 // active RenderWidgets. 343 void SetSwappedOut(bool is_swapped_out); 344 345 // Allows the process to exit once the unload handler has finished, if there 346 // are no other active RenderWidgets. 347 void WasSwappedOut(); 348 349 void FlushPendingInputEventAck(); 350 void DoDeferredClose(); 351 void DoDeferredSetWindowRect(const blink::WebRect& pos); 352 353 // Resizes the render widget. 354 void Resize(const gfx::Size& new_size, 355 const gfx::Size& physical_backing_size, 356 float top_controls_layout_height, 357 const gfx::Size& visible_viewport_size, 358 const gfx::Rect& resizer_rect, 359 bool is_fullscreen, 360 ResizeAck resize_ack); 361 // Used to force the size of a window when running layout tests. 362 void ResizeSynchronously(const gfx::Rect& new_position); 363 virtual void SetScreenMetricsEmulationParameters( 364 float device_scale_factor, 365 const gfx::Point& root_layer_offset, 366 float root_layer_scale); 367 #if defined(OS_MACOSX) || defined(OS_ANDROID) 368 void SetExternalPopupOriginAdjustmentsForEmulation( 369 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator); 370 #endif 371 372 // RenderWidget IPC message handlers 373 void OnHandleInputEvent(const blink::WebInputEvent* event, 374 const ui::LatencyInfo& latency_info, 375 bool keyboard_shortcut); 376 void OnCursorVisibilityChange(bool is_visible); 377 void OnMouseCaptureLost(); 378 virtual void OnSetFocus(bool enable); 379 virtual void OnClose(); 380 void OnCreatingNewAck(); 381 virtual void OnResize(const ViewMsg_Resize_Params& params); 382 void OnChangeResizeRect(const gfx::Rect& resizer_rect); 383 virtual void OnWasHidden(); 384 virtual void OnWasShown(bool needs_repainting, 385 const ui::LatencyInfo& latency_info); 386 void OnCreateVideoAck(int32 video_id); 387 void OnUpdateVideoAck(int32 video_id); 388 void OnRequestMoveAck(); 389 void OnSetInputMethodActive(bool is_active); 390 void OnCandidateWindowShown(); 391 void OnCandidateWindowUpdated(); 392 void OnCandidateWindowHidden(); 393 virtual void OnImeSetComposition( 394 const base::string16& text, 395 const std::vector<blink::WebCompositionUnderline>& underlines, 396 int selection_start, 397 int selection_end); 398 virtual void OnImeConfirmComposition(const base::string16& text, 399 const gfx::Range& replacement_range, 400 bool keep_selection); 401 void OnRepaint(gfx::Size size_to_paint); 402 void OnSyntheticGestureCompleted(); 403 void OnSetTextDirection(blink::WebTextDirection direction); 404 void OnGetFPS(); 405 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect, 406 const gfx::Rect& window_screen_rect); 407 void OnShowImeIfNeeded(); 408 409 #if defined(OS_ANDROID) 410 // Whenever an IME event that needs an acknowledgement is sent to the browser, 411 // the number of outstanding IME events that needs acknowledgement should be 412 // incremented. All IME events will be dropped until we receive an ack from 413 // the browser. 414 void IncrementOutstandingImeEventAcks(); 415 416 // Called by the browser process for every required IME acknowledgement. 417 void OnImeEventAck(); 418 #endif 419 420 // Notify the compositor about a change in viewport size. This should be 421 // used only with auto resize mode WebWidgets, as normal WebWidgets should 422 // go through OnResize. 423 void AutoResizeCompositor(); 424 425 virtual void SetDeviceScaleFactor(float device_scale_factor); 426 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile); 427 virtual void ResetDeviceColorProfileForTesting(); 428 429 virtual void OnOrientationChange(); 430 431 // Override points to notify derived classes that a paint has happened. 432 // DidInitiatePaint happens when that has completed, and subsequent rendering 433 // won't affect the painted content. DidFlushPaint happens once we've received 434 // the ACK that the screen has been updated. For a given paint operation, 435 // these overrides will always be called in the order DidInitiatePaint, 436 // DidFlushPaint. DidInitiatePaint()437 virtual void DidInitiatePaint() {} DidFlushPaint()438 virtual void DidFlushPaint() {} 439 440 virtual GURL GetURLForGraphicsContext3D(); 441 442 // Gets the scroll offset of this widget, if this widget has a notion of 443 // scroll offset. 444 virtual gfx::Vector2d GetScrollOffset(); 445 446 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should 447 // use this method so that we can properly inform the RenderThread of our 448 // state. 449 void SetHidden(bool hidden); 450 451 void WillToggleFullscreen(); 452 void DidToggleFullscreen(); 453 454 bool next_paint_is_resize_ack() const; 455 void set_next_paint_is_resize_ack(); 456 void set_next_paint_is_repaint_ack(); 457 458 // QueueMessage implementation extracted into a static method for easy 459 // testing. 460 static scoped_ptr<cc::SwapPromise> QueueMessageImpl( 461 IPC::Message* msg, 462 MessageDeliveryPolicy policy, 463 FrameSwapMessageQueue* frame_swap_message_queue, 464 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, 465 bool commit_requested, 466 int source_frame_number); 467 468 // Override point to obtain that the current input method state and caret 469 // position. 470 virtual ui::TextInputType GetTextInputType(); 471 virtual ui::TextInputType WebKitToUiTextInputType( 472 blink::WebTextInputType type); 473 474 #if defined(OS_MACOSX) || defined(USE_AURA) 475 // Override point to obtain that the current composition character bounds. 476 // In the case of surrogate pairs, the character is treated as two characters: 477 // the bounds for first character is actual one, and the bounds for second 478 // character is zero width rectangle. 479 virtual void GetCompositionCharacterBounds( 480 std::vector<gfx::Rect>* character_bounds); 481 482 // Returns the range of the text that is being composed or the selection if 483 // the composition does not exist. 484 virtual void GetCompositionRange(gfx::Range* range); 485 486 // Returns true if the composition range or composition character bounds 487 // should be sent to the browser process. 488 bool ShouldUpdateCompositionInfo( 489 const gfx::Range& range, 490 const std::vector<gfx::Rect>& bounds); 491 #endif 492 493 // Override point to obtain that the current input method state about 494 // composition text. 495 virtual bool CanComposeInline(); 496 497 // Tells the renderer it does not have focus. Used to prevent us from getting 498 // the focus on our own when the browser did not focus us. 499 void ClearFocus(); 500 501 // Set the pending window rect. 502 // Because the real render_widget is hosted in another process, there is 503 // a time period where we may have set a new window rect which has not yet 504 // been processed by the browser. So we maintain a pending window rect 505 // size. If JS code sets the WindowRect, and then immediately calls 506 // GetWindowRect() we'll use this pending window rect as the size. 507 void SetPendingWindowRect(const blink::WebRect& r); 508 509 // Called by OnHandleInputEvent() to notify subclasses that a key event was 510 // just handled. DidHandleKeyEvent()511 virtual void DidHandleKeyEvent() {} 512 513 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is 514 // about to be handled. 515 // Returns true if no further handling is needed. In that case, the event 516 // won't be sent to WebKit or trigger DidHandleMouseEvent(). 517 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event); 518 519 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is 520 // about to be handled. 521 // Returns true if no further handling is needed. In that case, the event 522 // won't be sent to WebKit. 523 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event); 524 525 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was 526 // just handled. DidHandleMouseEvent(const blink::WebMouseEvent & event)527 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {} 528 529 // Called by OnHandleInputEvent() to notify subclasses that a touch event was 530 // just handled. DidHandleTouchEvent(const blink::WebTouchEvent & event)531 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {} 532 533 // Check whether the WebWidget has any touch event handlers registered 534 // at the given point. 535 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const; 536 537 // Check whether the WebWidget has any touch event handlers registered. 538 virtual void hasTouchEventHandlers(bool has_handlers); 539 540 // Tell the browser about the actions permitted for a new touch point. 541 virtual void setTouchAction(blink::WebTouchAction touch_action); 542 543 // Called when value of focused text field gets dirty, e.g. value is modified 544 // by script, not by user input. 545 virtual void didUpdateTextOfFocusedElementByNonUserInput(); 546 547 // Creates a 3D context associated with this view. 548 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D(); 549 550 // Routing ID that allows us to communicate to the parent browser process 551 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. 552 int32 routing_id_; 553 554 int32 surface_id_; 555 556 // We are responsible for destroying this object via its Close method. 557 // May be NULL when the window is closing. 558 blink::WebWidget* webwidget_; 559 560 // This is lazily constructed and must not outlive webwidget_. 561 scoped_ptr<RenderWidgetCompositor> compositor_; 562 563 // Set to the ID of the view that initiated creating this view, if any. When 564 // the view was initiated by the browser (the common case), this will be 565 // MSG_ROUTING_NONE. This is used in determining ownership when opening 566 // child tabs. See RenderWidget::createWebViewWithRequest. 567 // 568 // This ID may refer to an invalid view if that view is closed before this 569 // view is. 570 int32 opener_id_; 571 572 // The position where this view should be initially shown. 573 gfx::Rect initial_pos_; 574 575 bool init_complete_; 576 577 // We store the current cursor object so we can avoid spamming SetCursor 578 // messages. 579 WebCursor current_cursor_; 580 581 // The size of the RenderWidget. 582 gfx::Size size_; 583 584 // The size of the view's backing surface in non-DPI-adjusted pixels. 585 gfx::Size physical_backing_size_; 586 587 // The amount that the viewport size given to Blink was shrunk by the URL-bar 588 // (always 0 on platforms where URL-bar hiding isn't supported). 589 float top_controls_layout_height_; 590 591 // The size of the visible viewport in DPI-adjusted pixels. 592 gfx::Size visible_viewport_size_; 593 594 // The area that must be reserved for drawing the resize corner. 595 gfx::Rect resizer_rect_; 596 597 // Flags for the next ViewHostMsg_UpdateRect message. 598 int next_paint_flags_; 599 600 // Whether the WebWidget is in auto resize mode, which is used for example 601 // by extension popups. 602 bool auto_resize_mode_; 603 604 // True if we need to send an UpdateRect message to notify the browser about 605 // an already-completed auto-resize. 606 bool need_update_rect_for_auto_resize_; 607 608 // Set to true if we should ignore RenderWidget::Show calls. 609 bool did_show_; 610 611 // Indicates that we shouldn't bother generated paint events. 612 bool is_hidden_; 613 614 // Indicates that we are never visible, so never produce graphical output. 615 bool never_visible_; 616 617 // Indicates that we are in fullscreen mode. 618 bool is_fullscreen_; 619 620 // Indicates whether we have been focused/unfocused by the browser. 621 bool has_focus_; 622 623 // Are we currently handling an input event? 624 bool handling_input_event_; 625 626 // Are we currently handling an ime event? 627 bool handling_ime_event_; 628 629 // Type of the input event we are currently handling. 630 blink::WebInputEvent::Type handling_event_type_; 631 632 // Whether we should not send ack for the current mouse move. 633 bool ignore_ack_for_mouse_move_from_debugger_; 634 635 // True if we have requested this widget be closed. No more messages will 636 // be sent, except for a Close. 637 bool closing_; 638 639 // True if it is known that the host is in the process of being shut down. 640 bool host_closing_; 641 642 // Whether this RenderWidget is currently swapped out, such that the view is 643 // being rendered by another process. If all RenderWidgets in a process are 644 // swapped out, the process can exit. 645 bool is_swapped_out_; 646 647 // Indicates if an input method is active in the browser process. 648 bool input_method_is_active_; 649 650 // Stores information about the current text input. 651 blink::WebTextInputInfo text_input_info_; 652 653 // Stores the current text input type of |webwidget_|. 654 ui::TextInputType text_input_type_; 655 656 // Stores the current text input mode of |webwidget_|. 657 ui::TextInputMode text_input_mode_; 658 659 // Stores the current type of composition text rendering of |webwidget_|. 660 bool can_compose_inline_; 661 662 // Stores the current selection bounds. 663 gfx::Rect selection_focus_rect_; 664 gfx::Rect selection_anchor_rect_; 665 666 // Stores the current composition character bounds. 667 std::vector<gfx::Rect> composition_character_bounds_; 668 669 // Stores the current composition range. 670 gfx::Range composition_range_; 671 672 // The kind of popup this widget represents, NONE if not a popup. 673 blink::WebPopupType popup_type_; 674 675 // Holds all the needed plugin window moves for a scroll. 676 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector; 677 WebPluginGeometryVector plugin_window_moves_; 678 679 // While we are waiting for the browser to update window sizes, we track the 680 // pending size temporarily. 681 int pending_window_rect_count_; 682 blink::WebRect pending_window_rect_; 683 684 // The screen rects of the view and the window that contains it. 685 gfx::Rect view_screen_rect_; 686 gfx::Rect window_screen_rect_; 687 688 scoped_ptr<IPC::Message> pending_input_event_ack_; 689 690 // The time spent in input handlers this frame. Used to throttle input acks. 691 base::TimeDelta total_input_handling_time_this_frame_; 692 693 // Indicates if the next sequence of Char events should be suppressed or not. 694 bool suppress_next_char_events_; 695 696 // Properties of the screen hosting this RenderWidget instance. 697 blink::WebScreenInfo screen_info_; 698 699 // The device scale factor. This value is computed from the DPI entries in 700 // |screen_info_| on some platforms, and defaults to 1 on other platforms. 701 float device_scale_factor_; 702 703 // The device color profile on supported platforms. 704 std::vector<char> device_color_profile_; 705 706 // State associated with synthetic gestures. Synthetic gestures are processed 707 // in-order, so a queue is sufficient to identify the correct state for a 708 // completed gesture. 709 std::queue<SyntheticGestureCompletionCallback> 710 pending_synthetic_gesture_callbacks_; 711 712 const ui::LatencyInfo* current_event_latency_info_; 713 714 uint32 next_output_surface_id_; 715 716 #if defined(OS_ANDROID) 717 // Indicates value in the focused text field is in dirty state, i.e. modified 718 // by script etc., not by user input. 719 bool text_field_is_dirty_; 720 721 // A counter for number of outstanding messages from the renderer to the 722 // browser regarding IME-type events that have not been acknowledged by the 723 // browser. If this value is not 0 IME events will be dropped. 724 int outstanding_ime_acks_; 725 726 // The background color of the document body element. This is used as the 727 // default background color for filling the screen areas for which we don't 728 // have the actual content. 729 SkColor body_background_color_; 730 #endif 731 732 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_; 733 734 // Popups may be displaced when screen metrics emulation is enabled. 735 // These values are used to properly adjust popup position. 736 gfx::Point popup_view_origin_for_emulation_; 737 gfx::Point popup_screen_origin_for_emulation_; 738 float popup_origin_scale_for_emulation_; 739 740 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; 741 scoped_ptr<ResizingModeSelector> resizing_mode_selector_; 742 743 // Lists of RenderFrameProxy objects that need to be notified of 744 // compositing-related events (e.g. DidCommitCompositorFrame). 745 ObserverList<RenderFrameProxy> render_frame_proxies_; 746 #if defined(VIDEO_HOLE) 747 ObserverList<RenderFrameImpl> video_hole_frames_; 748 #endif // defined(VIDEO_HOLE) 749 750 // A list of RenderFrames associated with this RenderWidget. Notifications 751 // are sent to each frame in the list for events such as changing 752 // visibility state for example. 753 ObserverList<RenderFrameImpl> render_frames_; 754 755 ui::MenuSourceType context_menu_source_type_; 756 bool has_host_context_menu_location_; 757 gfx::Point host_context_menu_location_; 758 759 DISALLOW_COPY_AND_ASSIGN(RenderWidget); 760 }; 761 762 } // namespace content 763 764 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ 765