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 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 845 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
846 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 846 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); |
847 } | 847 } |
848 | 848 |
849 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 849 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
850 const blink::WebMouseEvent& mouse_event, | 850 const blink::WebMouseEvent& mouse_event, |
851 const ui::LatencyInfo& ui_latency) { | 851 const ui::LatencyInfo& ui_latency) { |
852 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 852 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
853 "x", mouse_event.x, "y", mouse_event.y); | 853 "x", mouse_event.x, "y", mouse_event.y); |
854 | 854 |
855 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
856 coordinates.push_back(std::make_pair(mouse_event.x, mouse_event.y)); | |
857 | |
855 ui::LatencyInfo latency_info = | 858 ui::LatencyInfo latency_info = |
856 CreateRWHLatencyInfoIfNotExist(&ui_latency, mouse_event.type); | 859 CreateRWHLatencyInfoIfNotExist(&ui_latency, mouse_event.type, |
860 coordinates); | |
857 | 861 |
858 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { | 862 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
859 if (mouse_event_callbacks_[i].Run(mouse_event)) | 863 if (mouse_event_callbacks_[i].Run(mouse_event)) |
860 return; | 864 return; |
861 } | 865 } |
862 | 866 |
863 if (IgnoreInputEvents()) | 867 if (IgnoreInputEvents()) |
864 return; | 868 return; |
865 | 869 |
866 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) | 870 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) |
867 return; | 871 return; |
868 | 872 |
869 input_router_->SendMouseEvent(MouseEventWithLatencyInfo(mouse_event, | 873 input_router_->SendMouseEvent(MouseEventWithLatencyInfo(mouse_event, |
870 latency_info)); | 874 latency_info)); |
871 } | 875 } |
872 | 876 |
873 void RenderWidgetHostImpl::OnPointerEventActivate() { | 877 void RenderWidgetHostImpl::OnPointerEventActivate() { |
874 } | 878 } |
875 | 879 |
876 void RenderWidgetHostImpl::ForwardWheelEvent( | 880 void RenderWidgetHostImpl::ForwardWheelEvent( |
877 const WebMouseWheelEvent& wheel_event) { | 881 const WebMouseWheelEvent& wheel_event) { |
878 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); | 882 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); |
879 } | 883 } |
880 | 884 |
881 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( | 885 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
882 const blink::WebMouseWheelEvent& wheel_event, | 886 const blink::WebMouseWheelEvent& wheel_event, |
883 const ui::LatencyInfo& ui_latency) { | 887 const ui::LatencyInfo& ui_latency) { |
884 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent"); | 888 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent"); |
885 | 889 |
890 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
891 coordinates.push_back(std::make_pair(wheel_event.x, wheel_event.y)); | |
892 | |
886 ui::LatencyInfo latency_info = | 893 ui::LatencyInfo latency_info = |
887 CreateRWHLatencyInfoIfNotExist(&ui_latency, wheel_event.type); | 894 CreateRWHLatencyInfoIfNotExist(&ui_latency, wheel_event.type, |
895 coordinates); | |
888 | 896 |
889 if (IgnoreInputEvents()) | 897 if (IgnoreInputEvents()) |
890 return; | 898 return; |
891 | 899 |
892 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) | 900 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) |
893 return; | 901 return; |
894 | 902 |
895 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event, | 903 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event, |
896 latency_info)); | 904 latency_info)); |
897 } | 905 } |
898 | 906 |
899 void RenderWidgetHostImpl::ForwardGestureEvent( | 907 void RenderWidgetHostImpl::ForwardGestureEvent( |
900 const blink::WebGestureEvent& gesture_event) { | 908 const blink::WebGestureEvent& gesture_event) { |
901 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); | 909 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); |
902 } | 910 } |
903 | 911 |
904 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( | 912 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
905 const blink::WebGestureEvent& gesture_event, | 913 const blink::WebGestureEvent& gesture_event, |
906 const ui::LatencyInfo& ui_latency) { | 914 const ui::LatencyInfo& ui_latency) { |
907 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 915 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
908 // Early out if necessary, prior to performing latency logic. | 916 // Early out if necessary, prior to performing latency logic. |
909 if (IgnoreInputEvents()) | 917 if (IgnoreInputEvents()) |
910 return; | 918 return; |
911 | 919 |
912 if (delegate_->PreHandleGestureEvent(gesture_event)) | 920 if (delegate_->PreHandleGestureEvent(gesture_event)) |
913 return; | 921 return; |
914 | 922 |
923 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
924 coordinates.push_back(std::make_pair(gesture_event.x, gesture_event.y)); | |
925 | |
915 ui::LatencyInfo latency_info = | 926 ui::LatencyInfo latency_info = |
916 CreateRWHLatencyInfoIfNotExist(&ui_latency, gesture_event.type); | 927 CreateRWHLatencyInfoIfNotExist(&ui_latency, gesture_event.type, |
928 coordinates); | |
917 | 929 |
918 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate) { | 930 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate) { |
919 latency_info.AddLatencyNumber( | 931 latency_info.AddLatencyNumber( |
920 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, | 932 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, |
921 GetLatencyComponentId(), | 933 GetLatencyComponentId(), |
922 ++last_input_number_); | 934 ++last_input_number_); |
923 | 935 |
924 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a | 936 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a |
925 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. | 937 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. |
926 // So we can track the latency specifically for scroll update events. | 938 // So we can track the latency specifically for scroll update events. |
(...skipping 10 matching lines...) Expand all Loading... | |
937 } | 949 } |
938 } | 950 } |
939 | 951 |
940 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info); | 952 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info); |
941 input_router_->SendGestureEvent(gesture_with_latency); | 953 input_router_->SendGestureEvent(gesture_with_latency); |
942 } | 954 } |
943 | 955 |
944 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( | 956 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
945 const blink::WebTouchEvent& touch_event) { | 957 const blink::WebTouchEvent& touch_event) { |
946 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); | 958 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
959 | |
960 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
961 for (size_t i = 0; i < touch_event.touches_length; i++) | |
Sami
2014/09/04 19:10:43
Add {}
cvicentiu
2014/09/05 17:19:56
Done.
| |
962 coordinates.push_back(std::make_pair( | |
963 touch_event.touches[i].position.x, | |
964 touch_event.touches[i].position.y)); | |
965 | |
947 ui::LatencyInfo latency_info = | 966 ui::LatencyInfo latency_info = |
948 CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type); | 967 CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type, coordinates); |
949 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); | 968 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
950 input_router_->SendTouchEvent(touch_with_latency); | 969 input_router_->SendTouchEvent(touch_with_latency); |
951 } | 970 } |
952 | 971 |
953 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( | 972 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
954 const blink::WebTouchEvent& touch_event, | 973 const blink::WebTouchEvent& touch_event, |
955 const ui::LatencyInfo& ui_latency) { | 974 const ui::LatencyInfo& ui_latency) { |
956 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); | 975 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); |
957 | 976 |
958 // Always forward TouchEvents for touch stream consistency. They will be | 977 // Always forward TouchEvents for touch stream consistency. They will be |
959 // ignored if appropriate in FilterInputEvent(). | 978 // ignored if appropriate in FilterInputEvent(). |
979 // | |
980 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
981 for (size_t i = 0; i < touch_event.touches_length; i++) | |
Sami
2014/09/04 19:10:43
Add {}
cvicentiu
2014/09/05 17:19:56
Done.
| |
982 coordinates.push_back(std::make_pair( | |
983 touch_event.touches[i].position.x, | |
984 touch_event.touches[i].position.y)); | |
960 | 985 |
961 ui::LatencyInfo latency_info = | 986 ui::LatencyInfo latency_info = |
962 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type); | 987 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type, |
988 coordinates); | |
963 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); | 989 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
964 | 990 |
965 if (touch_emulator_ && | 991 if (touch_emulator_ && |
966 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { | 992 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { |
967 if (view_) { | 993 if (view_) { |
968 view_->ProcessAckedTouchEvent( | 994 view_->ProcessAckedTouchEvent( |
969 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); | 995 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); |
970 } | 996 } |
971 return; | 997 return; |
972 } | 998 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) | 1057 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) |
1032 return; | 1058 return; |
1033 | 1059 |
1034 if (key_event.type == WebKeyboardEvent::RawKeyDown) | 1060 if (key_event.type == WebKeyboardEvent::RawKeyDown) |
1035 suppress_next_char_events_ = false; | 1061 suppress_next_char_events_ = false; |
1036 } | 1062 } |
1037 | 1063 |
1038 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) | 1064 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
1039 return; | 1065 return; |
1040 | 1066 |
1067 ui::LatencyInfo::LatencyScreenCoordinates coordinates; | |
Sami
2014/09/04 19:10:43
Add a comment saying key events have no coordinate
cvicentiu
2014/09/05 17:19:56
Done.
| |
1068 | |
1041 input_router_->SendKeyboardEvent( | 1069 input_router_->SendKeyboardEvent( |
1042 key_event, | 1070 key_event, |
1043 CreateRWHLatencyInfoIfNotExist(NULL, key_event.type), | 1071 CreateRWHLatencyInfoIfNotExist(NULL, key_event.type, coordinates), |
1044 is_shortcut); | 1072 is_shortcut); |
1045 } | 1073 } |
1046 | 1074 |
1047 void RenderWidgetHostImpl::QueueSyntheticGesture( | 1075 void RenderWidgetHostImpl::QueueSyntheticGesture( |
1048 scoped_ptr<SyntheticGesture> synthetic_gesture, | 1076 scoped_ptr<SyntheticGesture> synthetic_gesture, |
1049 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { | 1077 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { |
1050 if (!synthetic_gesture_controller_ && view_) { | 1078 if (!synthetic_gesture_controller_ && view_) { |
1051 synthetic_gesture_controller_.reset( | 1079 synthetic_gesture_controller_.reset( |
1052 new SyntheticGestureController( | 1080 new SyntheticGestureController( |
1053 view_->CreateSyntheticGestureTarget().Pass())); | 1081 view_->CreateSyntheticGestureTarget().Pass())); |
(...skipping 22 matching lines...) Expand all Loading... | |
1076 int64 RenderWidgetHostImpl::GetLatencyComponentId() { | 1104 int64 RenderWidgetHostImpl::GetLatencyComponentId() { |
1077 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); | 1105 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); |
1078 } | 1106 } |
1079 | 1107 |
1080 // static | 1108 // static |
1081 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { | 1109 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { |
1082 g_check_for_pending_resize_ack = false; | 1110 g_check_for_pending_resize_ack = false; |
1083 } | 1111 } |
1084 | 1112 |
1085 ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist( | 1113 ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist( |
1086 const ui::LatencyInfo* original, WebInputEvent::Type type) { | 1114 const ui::LatencyInfo* original, WebInputEvent::Type type, |
1115 ui::LatencyInfo::LatencyScreenCoordinates coordinates) { | |
Sami
2014/09/04 19:10:43
Make this parameter a const ref:
const ui::La
cvicentiu
2014/09/05 17:19:56
Done.
| |
1116 /* printf("["); | |
1117 for (size_t i = 0; i < coordinates.num_coordinates; i++) | |
1118 printf("(%d %d) ", coordinates.x[i], coordinates.y[i]); | |
1119 printf("]\n");*/ | |
1087 ui::LatencyInfo info; | 1120 ui::LatencyInfo info; |
1088 if (original) | 1121 if (original) |
1089 info = *original; | 1122 info = *original; |
1123 info.coordinates = coordinates; | |
1090 // In Aura, gesture event will already carry its original touch event's | 1124 // In Aura, gesture event will already carry its original touch event's |
1091 // INPUT_EVENT_LATENCY_RWH_COMPONENT. | 1125 // INPUT_EVENT_LATENCY_RWH_COMPONENT. |
1092 if (!info.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 1126 if (!info.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
1093 GetLatencyComponentId(), | 1127 GetLatencyComponentId(), |
1094 NULL)) { | 1128 NULL)) { |
1095 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 1129 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
1096 GetLatencyComponentId(), | 1130 GetLatencyComponentId(), |
1097 ++last_input_number_); | 1131 ++last_input_number_); |
1098 info.TraceEventType(WebInputEventTraits::GetName(type)); | 1132 info.TraceEventType(WebInputEventTraits::GetName(type)); |
Sami
2014/09/04 19:10:43
Add coordinates here instead.
cvicentiu
2014/09/05 17:19:56
Done.
| |
1099 } | 1133 } |
1100 return info; | 1134 return info; |
1101 } | 1135 } |
1102 | 1136 |
1103 | 1137 |
1104 void RenderWidgetHostImpl::AddKeyPressEventCallback( | 1138 void RenderWidgetHostImpl::AddKeyPressEventCallback( |
1105 const KeyPressEventCallback& callback) { | 1139 const KeyPressEventCallback& callback) { |
1106 key_press_event_callbacks_.push_back(callback); | 1140 key_press_event_callbacks_.push_back(callback); |
1107 } | 1141 } |
1108 | 1142 |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2317 } | 2351 } |
2318 #endif | 2352 #endif |
2319 | 2353 |
2320 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2354 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
2321 if (view_) | 2355 if (view_) |
2322 return view_->PreferredReadbackFormat(); | 2356 return view_->PreferredReadbackFormat(); |
2323 return kN32_SkColorType; | 2357 return kN32_SkColorType; |
2324 } | 2358 } |
2325 | 2359 |
2326 } // namespace content | 2360 } // namespace content |
OLD | NEW |