| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
| 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ | 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <deque> | 11 #include <deque> |
| 9 #include <map> | 12 #include <map> |
| 10 | 13 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/callback.h" | 14 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 17 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "build/build_config.h" |
| 18 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 19 #include "content/common/cursors/webcursor.h" | 23 #include "content/common/cursors/webcursor.h" |
| 20 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 21 #include "content/common/input/synthetic_gesture_params.h" | 25 #include "content/common/input/synthetic_gesture_params.h" |
| 22 #include "content/renderer/input/render_widget_input_handler.h" | 26 #include "content/renderer/input/render_widget_input_handler.h" |
| 23 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 27 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
| 24 #include "content/renderer/message_delivery_policy.h" | 28 #include "content/renderer/message_delivery_policy.h" |
| 25 #include "ipc/ipc_listener.h" | 29 #include "ipc/ipc_listener.h" |
| 26 #include "ipc/ipc_sender.h" | 30 #include "ipc/ipc_sender.h" |
| 27 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 31 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // - Widgets for frames (for out-of-process iframe support) | 101 // - Widgets for frames (for out-of-process iframe support) |
| 98 class CONTENT_EXPORT RenderWidget | 102 class CONTENT_EXPORT RenderWidget |
| 99 : public IPC::Listener, | 103 : public IPC::Listener, |
| 100 public IPC::Sender, | 104 public IPC::Sender, |
| 101 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), | 105 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), |
| 102 public RenderWidgetInputHandlerDelegate, | 106 public RenderWidgetInputHandlerDelegate, |
| 103 public base::RefCounted<RenderWidget> { | 107 public base::RefCounted<RenderWidget> { |
| 104 public: | 108 public: |
| 105 // Creates a new RenderWidget. The opener_id is the routing ID of the | 109 // Creates a new RenderWidget. The opener_id is the routing ID of the |
| 106 // RenderView that this widget lives inside. | 110 // RenderView that this widget lives inside. |
| 107 static RenderWidget* Create(int32 opener_id, | 111 static RenderWidget* Create(int32_t opener_id, |
| 108 CompositorDependencies* compositor_deps, | 112 CompositorDependencies* compositor_deps, |
| 109 blink::WebPopupType popup_type, | 113 blink::WebPopupType popup_type, |
| 110 const blink::WebScreenInfo& screen_info); | 114 const blink::WebScreenInfo& screen_info); |
| 111 | 115 |
| 112 // Creates a new RenderWidget that will be attached to a RenderFrame. | 116 // Creates a new RenderWidget that will be attached to a RenderFrame. |
| 113 static RenderWidget* CreateForFrame(int routing_id, | 117 static RenderWidget* CreateForFrame(int routing_id, |
| 114 bool hidden, | 118 bool hidden, |
| 115 const blink::WebScreenInfo& screen_info, | 119 const blink::WebScreenInfo& screen_info, |
| 116 CompositorDependencies* compositor_deps, | 120 CompositorDependencies* compositor_deps, |
| 117 blink::WebLocalFrame* frame); | 121 blink::WebLocalFrame* frame); |
| 118 | 122 |
| 119 // Closes a RenderWidget that was created by |CreateForFrame|. | 123 // Closes a RenderWidget that was created by |CreateForFrame|. |
| 120 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. | 124 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. |
| 121 // https://crbug.com/545684 | 125 // https://crbug.com/545684 |
| 122 virtual void CloseForFrame(); | 126 virtual void CloseForFrame(); |
| 123 | 127 |
| 124 int32 routing_id() const { return routing_id_; } | 128 int32_t routing_id() const { return routing_id_; } |
| 125 CompositorDependencies* compositor_deps() const { return compositor_deps_; } | 129 CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
| 126 blink::WebWidget* webwidget() const { return webwidget_; } | 130 blink::WebWidget* webwidget() const { return webwidget_; } |
| 127 gfx::Size size() const { return size_; } | 131 gfx::Size size() const { return size_; } |
| 128 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } | 132 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
| 129 blink::WebDisplayMode display_mode() const { return display_mode_; } | 133 blink::WebDisplayMode display_mode() const { return display_mode_; } |
| 130 bool is_hidden() const { return is_hidden_; } | 134 bool is_hidden() const { return is_hidden_; } |
| 131 // Temporary for debugging purposes... | 135 // Temporary for debugging purposes... |
| 132 bool closing() const { return closing_; } | 136 bool closing() const { return closing_; } |
| 133 bool is_swapped_out() { return is_swapped_out_; } | 137 bool is_swapped_out() { return is_swapped_out_; } |
| 134 bool for_oopif() { return for_oopif_; } | 138 bool for_oopif() { return for_oopif_; } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 360 |
| 357 ~RenderWidget() override; | 361 ~RenderWidget() override; |
| 358 | 362 |
| 359 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget, | 363 static blink::WebWidget* CreateWebFrameWidget(RenderWidget* render_widget, |
| 360 blink::WebLocalFrame* frame); | 364 blink::WebLocalFrame* frame); |
| 361 | 365 |
| 362 // Creates a WebWidget based on the popup type. | 366 // Creates a WebWidget based on the popup type. |
| 363 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); | 367 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
| 364 | 368 |
| 365 // Initializes this view with the given opener. | 369 // Initializes this view with the given opener. |
| 366 bool Init(int32 opener_id); | 370 bool Init(int32_t opener_id); |
| 367 | 371 |
| 368 // Called by Init and subclasses to perform initialization. | 372 // Called by Init and subclasses to perform initialization. |
| 369 bool DoInit(int32 opener_id, | 373 bool DoInit(int32_t opener_id, |
| 370 blink::WebWidget* web_widget, | 374 blink::WebWidget* web_widget, |
| 371 IPC::SyncMessage* create_widget_message); | 375 IPC::SyncMessage* create_widget_message); |
| 372 | 376 |
| 373 // Sets whether this RenderWidget has been swapped out to be displayed by | 377 // Sets whether this RenderWidget has been swapped out to be displayed by |
| 374 // a RenderWidget in a different process. If so, no new IPC messages will be | 378 // a RenderWidget in a different process. If so, no new IPC messages will be |
| 375 // sent (only ACKs) and the process is free to exit when there are no other | 379 // sent (only ACKs) and the process is free to exit when there are no other |
| 376 // active RenderWidgets. | 380 // active RenderWidgets. |
| 377 void SetSwappedOut(bool is_swapped_out); | 381 void SetSwappedOut(bool is_swapped_out); |
| 378 | 382 |
| 379 // Allows the process to exit once the unload handler has finished, if there | 383 // Allows the process to exit once the unload handler has finished, if there |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void OnClose(); | 419 void OnClose(); |
| 416 void OnCreatingNewAck(); | 420 void OnCreatingNewAck(); |
| 417 virtual void OnResize(const ViewMsg_Resize_Params& params); | 421 virtual void OnResize(const ViewMsg_Resize_Params& params); |
| 418 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params); | 422 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params); |
| 419 void OnDisableDeviceEmulation(); | 423 void OnDisableDeviceEmulation(); |
| 420 void OnColorProfile(const std::vector<char>& color_profile); | 424 void OnColorProfile(const std::vector<char>& color_profile); |
| 421 void OnChangeResizeRect(const gfx::Rect& resizer_rect); | 425 void OnChangeResizeRect(const gfx::Rect& resizer_rect); |
| 422 virtual void OnWasHidden(); | 426 virtual void OnWasHidden(); |
| 423 virtual void OnWasShown(bool needs_repainting, | 427 virtual void OnWasShown(bool needs_repainting, |
| 424 const ui::LatencyInfo& latency_info); | 428 const ui::LatencyInfo& latency_info); |
| 425 void OnCreateVideoAck(int32 video_id); | 429 void OnCreateVideoAck(int32_t video_id); |
| 426 void OnUpdateVideoAck(int32 video_id); | 430 void OnUpdateVideoAck(int32_t video_id); |
| 427 void OnRequestMoveAck(); | 431 void OnRequestMoveAck(); |
| 428 virtual void OnImeSetComposition( | 432 virtual void OnImeSetComposition( |
| 429 const base::string16& text, | 433 const base::string16& text, |
| 430 const std::vector<blink::WebCompositionUnderline>& underlines, | 434 const std::vector<blink::WebCompositionUnderline>& underlines, |
| 431 int selection_start, | 435 int selection_start, |
| 432 int selection_end); | 436 int selection_end); |
| 433 virtual void OnImeConfirmComposition(const base::string16& text, | 437 virtual void OnImeConfirmComposition(const base::string16& text, |
| 434 const gfx::Range& replacement_range, | 438 const gfx::Range& replacement_range, |
| 435 bool keep_selection); | 439 bool keep_selection); |
| 436 // Called when the device scale factor is changed, or the layer tree is | 440 // Called when the device scale factor is changed, or the layer tree is |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // Called when value of focused text field gets dirty, e.g. value is modified | 543 // Called when value of focused text field gets dirty, e.g. value is modified |
| 540 // by script, not by user input. | 544 // by script, not by user input. |
| 541 void didUpdateTextOfFocusedElementByNonUserInput() override; | 545 void didUpdateTextOfFocusedElementByNonUserInput() override; |
| 542 | 546 |
| 543 // Creates a 3D context associated with this view. | 547 // Creates a 3D context associated with this view. |
| 544 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D( | 548 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D( |
| 545 bool compositor); | 549 bool compositor); |
| 546 | 550 |
| 547 // Routing ID that allows us to communicate to the parent browser process | 551 // Routing ID that allows us to communicate to the parent browser process |
| 548 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. | 552 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. |
| 549 int32 routing_id_; | 553 int32_t routing_id_; |
| 550 | 554 |
| 551 // Dependencies for initializing a compositor, including flags for optional | 555 // Dependencies for initializing a compositor, including flags for optional |
| 552 // features. | 556 // features. |
| 553 CompositorDependencies* const compositor_deps_; | 557 CompositorDependencies* const compositor_deps_; |
| 554 | 558 |
| 555 // We are responsible for destroying this object via its Close method. | 559 // We are responsible for destroying this object via its Close method. |
| 556 // May be NULL when the window is closing. | 560 // May be NULL when the window is closing. |
| 557 blink::WebWidget* webwidget_; | 561 blink::WebWidget* webwidget_; |
| 558 | 562 |
| 559 // This is lazily constructed and must not outlive webwidget_. | 563 // This is lazily constructed and must not outlive webwidget_. |
| 560 scoped_ptr<RenderWidgetCompositor> compositor_; | 564 scoped_ptr<RenderWidgetCompositor> compositor_; |
| 561 | 565 |
| 562 // Set to the ID of the view that initiated creating this view, if any. When | 566 // Set to the ID of the view that initiated creating this view, if any. When |
| 563 // the view was initiated by the browser (the common case), this will be | 567 // the view was initiated by the browser (the common case), this will be |
| 564 // MSG_ROUTING_NONE. This is used in determining ownership when opening | 568 // MSG_ROUTING_NONE. This is used in determining ownership when opening |
| 565 // child tabs. See RenderWidget::createWebViewWithRequest. | 569 // child tabs. See RenderWidget::createWebViewWithRequest. |
| 566 // | 570 // |
| 567 // This ID may refer to an invalid view if that view is closed before this | 571 // This ID may refer to an invalid view if that view is closed before this |
| 568 // view is. | 572 // view is. |
| 569 int32 opener_id_; | 573 int32_t opener_id_; |
| 570 | 574 |
| 571 // The rect where this view should be initially shown. | 575 // The rect where this view should be initially shown. |
| 572 gfx::Rect initial_rect_; | 576 gfx::Rect initial_rect_; |
| 573 | 577 |
| 574 // We store the current cursor object so we can avoid spamming SetCursor | 578 // We store the current cursor object so we can avoid spamming SetCursor |
| 575 // messages. | 579 // messages. |
| 576 WebCursor current_cursor_; | 580 WebCursor current_cursor_; |
| 577 | 581 |
| 578 // The size of the RenderWidget. | 582 // The size of the RenderWidget. |
| 579 gfx::Size size_; | 583 gfx::Size size_; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 701 |
| 698 // The device color profile on supported platforms. | 702 // The device color profile on supported platforms. |
| 699 std::vector<char> device_color_profile_; | 703 std::vector<char> device_color_profile_; |
| 700 | 704 |
| 701 // State associated with synthetic gestures. Synthetic gestures are processed | 705 // State associated with synthetic gestures. Synthetic gestures are processed |
| 702 // in-order, so a queue is sufficient to identify the correct state for a | 706 // in-order, so a queue is sufficient to identify the correct state for a |
| 703 // completed gesture. | 707 // completed gesture. |
| 704 std::queue<SyntheticGestureCompletionCallback> | 708 std::queue<SyntheticGestureCompletionCallback> |
| 705 pending_synthetic_gesture_callbacks_; | 709 pending_synthetic_gesture_callbacks_; |
| 706 | 710 |
| 707 uint32 next_output_surface_id_; | 711 uint32_t next_output_surface_id_; |
| 708 | 712 |
| 709 #if defined(OS_ANDROID) | 713 #if defined(OS_ANDROID) |
| 710 // Indicates value in the focused text field is in dirty state, i.e. modified | 714 // Indicates value in the focused text field is in dirty state, i.e. modified |
| 711 // by script etc., not by user input. | 715 // by script etc., not by user input. |
| 712 bool text_field_is_dirty_; | 716 bool text_field_is_dirty_; |
| 713 | 717 |
| 714 // Stores the history of text input infos from the last ACK'ed one from the | 718 // Stores the history of text input infos from the last ACK'ed one from the |
| 715 // current one. The size is the number of pending ACKs plus one, since we | 719 // current one. The size is the number of pending ACKs plus one, since we |
| 716 // intentionally keep the last ack'd value to know what the browser is | 720 // intentionally keep the last ack'd value to know what the browser is |
| 717 // currently aware of. | 721 // currently aware of. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 746 | 750 |
| 747 scoped_ptr<scheduler::RenderWidgetSchedulingState> | 751 scoped_ptr<scheduler::RenderWidgetSchedulingState> |
| 748 render_widget_scheduling_state_; | 752 render_widget_scheduling_state_; |
| 749 | 753 |
| 750 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 754 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
| 751 }; | 755 }; |
| 752 | 756 |
| 753 } // namespace content | 757 } // namespace content |
| 754 | 758 |
| 755 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 759 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
| OLD | NEW |