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/renderer_host/backing_store.h" | 13 #include "chrome/browser/renderer_host/backing_store.h" |
14 #include "chrome/browser/renderer_host/backing_store_manager.h" | 14 #include "chrome/browser/renderer_host/backing_store_manager.h" |
15 #include "chrome/browser/renderer_host/render_process_host.h" | 15 #include "chrome/browser/renderer_host/render_process_host.h" |
16 #include "chrome/browser/renderer_host/render_widget_helper.h" | 16 #include "chrome/browser/renderer_host/render_widget_helper.h" |
17 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" | |
18 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 17 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
19 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/native_web_keyboard_event.h" | 19 #include "chrome/common/native_web_keyboard_event.h" |
21 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
22 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
23 #include "chrome/common/render_messages_params.h" | 22 #include "chrome/common/render_messages_params.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" |
25 #include "webkit/glue/webcursor.h" | 24 #include "webkit/glue/webcursor.h" |
26 #include "webkit/plugins/npapi/webplugin.h" | 25 #include "webkit/plugins/npapi/webplugin.h" |
27 | 26 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 64 |
66 /////////////////////////////////////////////////////////////////////////////// | 65 /////////////////////////////////////////////////////////////////////////////// |
67 // RenderWidgetHost | 66 // RenderWidgetHost |
68 | 67 |
69 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, | 68 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, |
70 int routing_id) | 69 int routing_id) |
71 : renderer_initialized_(false), | 70 : renderer_initialized_(false), |
72 renderer_accessible_(false), | 71 renderer_accessible_(false), |
73 view_(NULL), | 72 view_(NULL), |
74 process_(process), | 73 process_(process), |
75 painting_observer_(NULL), | |
76 routing_id_(routing_id), | 74 routing_id_(routing_id), |
77 is_loading_(false), | 75 is_loading_(false), |
78 is_hidden_(false), | 76 is_hidden_(false), |
79 is_accelerated_compositing_active_(false), | 77 is_accelerated_compositing_active_(false), |
80 repaint_ack_pending_(false), | 78 repaint_ack_pending_(false), |
81 resize_ack_pending_(false), | 79 resize_ack_pending_(false), |
82 mouse_move_pending_(false), | 80 mouse_move_pending_(false), |
83 mouse_wheel_pending_(false), | 81 mouse_wheel_pending_(false), |
84 needs_repainting_on_restore_(false), | 82 needs_repainting_on_restore_(false), |
85 is_unresponsive_(false), | 83 is_unresponsive_(false), |
(...skipping 705 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 // dispatch other window messages which could cause the view to be | 894 // dispatch other window messages which could cause the view to be |
892 // destroyed. | 895 // destroyed. |
893 if (view_ && !is_accelerated_compositing_active_) { | 896 if (view_ && !is_accelerated_compositing_active_) { |
894 view_being_painted_ = true; | 897 view_being_painted_ = true; |
895 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy, | 898 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy, |
896 params.copy_rects); | 899 params.copy_rects); |
897 view_being_painted_ = false; | 900 view_being_painted_ = false; |
898 } | 901 } |
899 } | 902 } |
900 | 903 |
901 if (paint_observer_.get()) | 904 NotificationService::current()->Notify( |
902 paint_observer_->RenderWidgetHostDidPaint(this); | 905 NotificationType::RENDER_WIDGET_HOST_DID_PAINT, |
| 906 Source<RenderWidgetHost>(this), |
| 907 NotificationService::NoDetails()); |
903 | 908 |
904 // If we got a resize ack, then perhaps we have another resize to send? | 909 // If we got a resize ack, then perhaps we have another resize to send? |
905 if (is_resize_ack && view_) { | 910 if (is_resize_ack && view_) { |
906 // WasResized checks the current size and sends the resize update only | 911 // WasResized checks the current size and sends the resize update only |
907 // when something was actually changed. | 912 // when something was actually changed. |
908 WasResized(); | 913 WasResized(); |
909 } | 914 } |
910 | 915 |
911 if (painting_observer_) | 916 NotificationService::current()->Notify( |
912 painting_observer_->WidgetDidUpdateBackingStore(this); | 917 NotificationType::RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
| 918 Source<RenderWidgetHost>(this), |
| 919 NotificationService::NoDetails()); |
913 | 920 |
914 // Log the time delta for processing a paint message. | 921 // Log the time delta for processing a paint message. |
915 TimeDelta delta = TimeTicks::Now() - paint_start; | 922 TimeDelta delta = TimeTicks::Now() - paint_start; |
916 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); | 923 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); |
917 } | 924 } |
918 | 925 |
919 void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { | 926 void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { |
920 // Log the time delta for processing an input event. | 927 // Log the time delta for processing an input event. |
921 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 928 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
922 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 929 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 return; | 1248 return; |
1242 | 1249 |
1243 for (int i = 0; i < static_cast<int>(deferred_plugin_handles_.size()); i++) { | 1250 for (int i = 0; i < static_cast<int>(deferred_plugin_handles_.size()); i++) { |
1244 #if defined(TOOLKIT_USES_GTK) | 1251 #if defined(TOOLKIT_USES_GTK) |
1245 view_->CreatePluginContainer(deferred_plugin_handles_[i]); | 1252 view_->CreatePluginContainer(deferred_plugin_handles_[i]); |
1246 #endif | 1253 #endif |
1247 } | 1254 } |
1248 | 1255 |
1249 deferred_plugin_handles_.clear(); | 1256 deferred_plugin_handles_.clear(); |
1250 } | 1257 } |
OLD | NEW |