| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/renderer_host/render_widget_host.h" | 5 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
| 13 #include "chrome/browser/metrics/user_metrics.h" | 13 #include "chrome/browser/metrics/user_metrics.h" |
| 14 #include "chrome/browser/renderer_host/backing_store.h" | 14 #include "chrome/browser/renderer_host/backing_store.h" |
| 15 #include "chrome/browser/renderer_host/backing_store_manager.h" | 15 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 16 #include "chrome/browser/renderer_host/render_process_host.h" | 16 #include "chrome/browser/renderer_host/render_process_host.h" |
| 17 #include "chrome/browser/renderer_host/render_widget_helper.h" | 17 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 18 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" | |
| 19 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 18 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 20 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/result_codes.h" | 20 #include "chrome/common/result_codes.h" |
| 22 #include "chrome/common/native_web_keyboard_event.h" | 21 #include "chrome/common/native_web_keyboard_event.h" |
| 23 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
| 24 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 25 #include "chrome/common/render_messages_params.h" | 24 #include "chrome/common/render_messages_params.h" |
| 26 #include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" |
| 27 #include "webkit/glue/webcursor.h" | 26 #include "webkit/glue/webcursor.h" |
| 28 #include "webkit/plugins/npapi/webplugin.h" | 27 #include "webkit/plugins/npapi/webplugin.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 66 |
| 68 /////////////////////////////////////////////////////////////////////////////// | 67 /////////////////////////////////////////////////////////////////////////////// |
| 69 // RenderWidgetHost | 68 // RenderWidgetHost |
| 70 | 69 |
| 71 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, | 70 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, |
| 72 int routing_id) | 71 int routing_id) |
| 73 : renderer_initialized_(false), | 72 : renderer_initialized_(false), |
| 74 renderer_accessible_(false), | 73 renderer_accessible_(false), |
| 75 view_(NULL), | 74 view_(NULL), |
| 76 process_(process), | 75 process_(process), |
| 77 painting_observer_(NULL), | |
| 78 routing_id_(routing_id), | 76 routing_id_(routing_id), |
| 79 is_loading_(false), | 77 is_loading_(false), |
| 80 is_hidden_(false), | 78 is_hidden_(false), |
| 81 is_accelerated_compositing_active_(false), | 79 is_accelerated_compositing_active_(false), |
| 82 repaint_ack_pending_(false), | 80 repaint_ack_pending_(false), |
| 83 resize_ack_pending_(false), | 81 resize_ack_pending_(false), |
| 84 mouse_move_pending_(false), | 82 mouse_move_pending_(false), |
| 85 mouse_wheel_pending_(false), | 83 mouse_wheel_pending_(false), |
| 86 needs_repainting_on_restore_(false), | 84 needs_repainting_on_restore_(false), |
| 87 is_unresponsive_(false), | 85 is_unresponsive_(false), |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 789 |
| 792 void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { | 790 void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { |
| 793 // Note that we ignore the position. | 791 // Note that we ignore the position. |
| 794 if (view_) { | 792 if (view_) { |
| 795 view_->SetSize(pos.size()); | 793 view_->SetSize(pos.size()); |
| 796 Send(new ViewMsg_Move_ACK(routing_id_)); | 794 Send(new ViewMsg_Move_ACK(routing_id_)); |
| 797 } | 795 } |
| 798 } | 796 } |
| 799 | 797 |
| 800 void RenderWidgetHost::OnMsgPaintAtSizeAck(int tag, const gfx::Size& size) { | 798 void RenderWidgetHost::OnMsgPaintAtSizeAck(int tag, const gfx::Size& size) { |
| 801 if (painting_observer_) { | 799 PaintAtSizeAckDetails details = {tag, size}; |
| 802 painting_observer_->WidgetDidReceivePaintAtSizeAck(this, tag, size); | 800 gfx::Size size_details = size; |
| 803 } | 801 NotificationService::current()->Notify( |
| 802 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, |
| 803 Source<RenderWidgetHost>(this), |
| 804 Details<PaintAtSizeAckDetails>(&details)); |
| 804 } | 805 } |
| 805 | 806 |
| 806 void RenderWidgetHost::OnMsgUpdateRect( | 807 void RenderWidgetHost::OnMsgUpdateRect( |
| 807 const ViewHostMsg_UpdateRect_Params& params) { | 808 const ViewHostMsg_UpdateRect_Params& params) { |
| 808 TimeTicks paint_start = TimeTicks::Now(); | 809 TimeTicks paint_start = TimeTicks::Now(); |
| 809 | 810 |
| 810 if (paint_observer_.get()) | 811 NotificationService::current()->Notify( |
| 811 paint_observer_->RenderWidgetHostWillPaint(this); | 812 NotificationType::RENDER_WIDGET_HOST_WILL_PAINT, |
| 813 Source<RenderWidgetHost>(this), |
| 814 NotificationService::NoDetails()); |
| 812 | 815 |
| 813 // Update our knowledge of the RenderWidget's size. | 816 // Update our knowledge of the RenderWidget's size. |
| 814 current_size_ = params.view_size; | 817 current_size_ = params.view_size; |
| 815 | 818 |
| 816 bool is_resize_ack = | 819 bool is_resize_ack = |
| 817 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); | 820 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); |
| 818 | 821 |
| 819 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since | 822 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since |
| 820 // that will end up reaching GetBackingStore. | 823 // that will end up reaching GetBackingStore. |
| 821 if (is_resize_ack) { | 824 if (is_resize_ack) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 // dispatch other window messages which could cause the view to be | 896 // dispatch other window messages which could cause the view to be |
| 894 // destroyed. | 897 // destroyed. |
| 895 if (view_ && !is_accelerated_compositing_active_) { | 898 if (view_ && !is_accelerated_compositing_active_) { |
| 896 view_being_painted_ = true; | 899 view_being_painted_ = true; |
| 897 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy, | 900 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy, |
| 898 params.copy_rects); | 901 params.copy_rects); |
| 899 view_being_painted_ = false; | 902 view_being_painted_ = false; |
| 900 } | 903 } |
| 901 } | 904 } |
| 902 | 905 |
| 903 if (paint_observer_.get()) | 906 NotificationService::current()->Notify( |
| 904 paint_observer_->RenderWidgetHostDidPaint(this); | 907 NotificationType::RENDER_WIDGET_HOST_DID_PAINT, |
| 908 Source<RenderWidgetHost>(this), |
| 909 NotificationService::NoDetails()); |
| 905 | 910 |
| 906 // If we got a resize ack, then perhaps we have another resize to send? | 911 // If we got a resize ack, then perhaps we have another resize to send? |
| 907 if (is_resize_ack && view_) { | 912 if (is_resize_ack && view_) { |
| 908 // WasResized checks the current size and sends the resize update only | 913 // WasResized checks the current size and sends the resize update only |
| 909 // when something was actually changed. | 914 // when something was actually changed. |
| 910 WasResized(); | 915 WasResized(); |
| 911 } | 916 } |
| 912 | 917 |
| 913 if (painting_observer_) | 918 NotificationService::current()->Notify( |
| 914 painting_observer_->WidgetDidUpdateBackingStore(this); | 919 NotificationType::RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
| 920 Source<RenderWidgetHost>(this), |
| 921 NotificationService::NoDetails()); |
| 915 | 922 |
| 916 // Log the time delta for processing a paint message. | 923 // Log the time delta for processing a paint message. |
| 917 TimeDelta delta = TimeTicks::Now() - paint_start; | 924 TimeDelta delta = TimeTicks::Now() - paint_start; |
| 918 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); | 925 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); |
| 919 } | 926 } |
| 920 | 927 |
| 921 void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { | 928 void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { |
| 922 // Log the time delta for processing an input event. | 929 // Log the time delta for processing an input event. |
| 923 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 930 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
| 924 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 931 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 return; | 1255 return; |
| 1249 | 1256 |
| 1250 for (int i = 0; i < static_cast<int>(deferred_plugin_handles_.size()); i++) { | 1257 for (int i = 0; i < static_cast<int>(deferred_plugin_handles_.size()); i++) { |
| 1251 #if defined(TOOLKIT_USES_GTK) | 1258 #if defined(TOOLKIT_USES_GTK) |
| 1252 view_->CreatePluginContainer(deferred_plugin_handles_[i]); | 1259 view_->CreatePluginContainer(deferred_plugin_handles_[i]); |
| 1253 #endif | 1260 #endif |
| 1254 } | 1261 } |
| 1255 | 1262 |
| 1256 deferred_plugin_handles_.clear(); | 1263 deferred_plugin_handles_.clear(); |
| 1257 } | 1264 } |
| OLD | NEW |