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_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <peninputpanel_i.c> | 8 #include <peninputpanel_i.c> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
41 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
42 #include "content/public/common/page_zoom.h" | 42 #include "content/public/common/page_zoom.h" |
43 #include "content/public/common/process_type.h" | 43 #include "content/public/common/process_type.h" |
44 #include "skia/ext/skia_utils_win.h" | 44 #include "skia/ext/skia_utils_win.h" |
45 #include "third_party/skia/include/core/SkRegion.h" | 45 #include "third_party/skia/include/core/SkRegion.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFact ory.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFact ory.h" |
49 #include "ui/base/gestures/gesture_recognizer.h" | |
49 #include "ui/base/ime/composition_text.h" | 50 #include "ui/base/ime/composition_text.h" |
50 #include "ui/base/l10n/l10n_util_win.h" | 51 #include "ui/base/l10n/l10n_util_win.h" |
51 #include "ui/base/text/text_elider.h" | 52 #include "ui/base/text/text_elider.h" |
52 #include "ui/base/ui_base_switches.h" | 53 #include "ui/base/ui_base_switches.h" |
53 #include "ui/base/view_prop.h" | 54 #include "ui/base/view_prop.h" |
54 #include "ui/base/win/hwnd_util.h" | 55 #include "ui/base/win/hwnd_util.h" |
55 #include "ui/base/win/mouse_wheel_util.h" | 56 #include "ui/base/win/mouse_wheel_util.h" |
56 #include "ui/gfx/canvas.h" | 57 #include "ui/gfx/canvas.h" |
57 #include "ui/gfx/gdi_util.h" | 58 #include "ui/gfx/gdi_util.h" |
58 #include "ui/gfx/rect.h" | 59 #include "ui/gfx/rect.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 is_loading_(false), | 327 is_loading_(false), |
327 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 328 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
328 is_fullscreen_(false), | 329 is_fullscreen_(false), |
329 ignore_mouse_movement_(true), | 330 ignore_mouse_movement_(true), |
330 composition_range_(ui::Range::InvalidRange()), | 331 composition_range_(ui::Range::InvalidRange()), |
331 touch_state_(this), | 332 touch_state_(this), |
332 pointer_down_context_(false), | 333 pointer_down_context_(false), |
333 focus_on_editable_field_(false), | 334 focus_on_editable_field_(false), |
334 received_focus_change_after_pointer_down_(false), | 335 received_focus_change_after_pointer_down_(false), |
335 touch_events_enabled_(false), | 336 touch_events_enabled_(false), |
337 ALLOW_THIS_IN_INITIALIZER_LIST( | |
338 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | |
336 ALLOW_THIS_IN_INITIALIZER_LIST(sys_color_change_listener_(this)) { | 339 ALLOW_THIS_IN_INITIALIZER_LIST(sys_color_change_listener_(this)) { |
337 render_widget_host_->SetView(this); | 340 render_widget_host_->SetView(this); |
338 registrar_.Add(this, | 341 registrar_.Add(this, |
339 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 342 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
340 content::NotificationService::AllBrowserContextsAndSources()); | 343 content::NotificationService::AllBrowserContextsAndSources()); |
341 registrar_.Add(this, | 344 registrar_.Add(this, |
342 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | 345 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
343 content::NotificationService::AllBrowserContextsAndSources()); | 346 content::NotificationService::AllBrowserContextsAndSources()); |
344 } | 347 } |
345 | 348 |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
929 callback.Run(CopyFromCompositingSurface(size, output)); | 932 callback.Run(CopyFromCompositingSurface(size, output)); |
930 } | 933 } |
931 | 934 |
932 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { | 935 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { |
933 content::RenderWidgetHostViewBase::SetBackground(background); | 936 content::RenderWidgetHostViewBase::SetBackground(background); |
934 render_widget_host_->SetBackground(background); | 937 render_widget_host_->SetBackground(background); |
935 } | 938 } |
936 | 939 |
937 void RenderWidgetHostViewWin::ProcessTouchAck( | 940 void RenderWidgetHostViewWin::ProcessTouchAck( |
938 WebKit::WebInputEvent::Type type, bool processed) { | 941 WebKit::WebInputEvent::Type type, bool processed) { |
942 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
943 gestures.reset(gesture_recognizer_->AdvanceTouchQueue(this, processed)); | |
944 ProcessGestures(gestures.get()); | |
945 | |
939 if (type == WebKit::WebInputEvent::TouchStart) | 946 if (type == WebKit::WebInputEvent::TouchStart) |
940 UpdateDesiredTouchMode(processed); | 947 UpdateDesiredTouchMode(processed); |
941 } | 948 } |
942 | 949 |
943 void RenderWidgetHostViewWin::SetToGestureMode() { | 950 void RenderWidgetHostViewWin::SetToGestureMode() { |
944 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 951 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
945 return; | 952 return; |
946 UnregisterTouchWindow(m_hWnd); | 953 UnregisterTouchWindow(m_hWnd); |
947 // Single finger panning is consistent with other windows applications. | 954 // Single finger panning is consistent with other windows applications. |
948 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | | 955 const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 // state. If we want touch mode, then we attempt to register for touch | 991 // state. If we want touch mode, then we attempt to register for touch |
985 // events, and otherwise to unregister. | 992 // events, and otherwise to unregister. |
986 if (touch_mode) { | 993 if (touch_mode) { |
987 touch_mode = SetToTouchMode(); | 994 touch_mode = SetToTouchMode(); |
988 } | 995 } |
989 if (!touch_mode) { | 996 if (!touch_mode) { |
990 SetToGestureMode(); | 997 SetToGestureMode(); |
991 } | 998 } |
992 } | 999 } |
993 | 1000 |
1001 template <class IINTERFACE, class PAYLOAD> | |
rjkroege
2012/05/09 16:48:15
I have a imprecise style-guide-kind-of-feeling tha
girard
2012/05/09 22:49:19
Moved to the top of the file (in the local anonymo
| |
1002 class WrappedObject: public IINTERFACE { | |
1003 public: | |
1004 WrappedObject() { | |
1005 } | |
1006 WrappedObject(const PAYLOAD ©) : | |
1007 data_(copy) { | |
1008 } | |
1009 const PAYLOAD& data() { | |
1010 return data_; | |
1011 } | |
1012 protected: | |
1013 PAYLOAD data_; | |
1014 }; | |
1015 | |
1016 class LocalGestureEvent : | |
1017 public WrappedObject<ui::GestureEvent, WebKit::WebGestureEvent> { | |
1018 public: | |
1019 LocalGestureEvent( | |
1020 ui::EventType type, | |
1021 const gfx::Point& location, | |
1022 int flags, | |
1023 base::Time time, | |
1024 float param_first, | |
1025 float param_second, | |
1026 unsigned int touch_id_bitfield) : | |
1027 type_(type), | |
1028 touch_ids_bitfield_(touch_id_bitfield) { | |
1029 data_.x = location.x(); | |
1030 data_.y = location.y(); | |
1031 data_.deltaX = param_first; | |
1032 data_.deltaY = param_second; | |
1033 data_.type = ConvertToWebKit(type); | |
1034 } | |
1035 | |
1036 virtual int GetLowestTouchId() const OVERRIDE { | |
1037 if (touch_ids_bitfield_ == 0) | |
1038 return -1; | |
1039 int i = -1; | |
1040 // Find the index of the least significant 1 bit | |
1041 while (!((1 << ++i) & touch_ids_bitfield_)); | |
1042 return i; | |
1043 } | |
1044 | |
1045 ui::EventType type() { | |
1046 return type_; | |
1047 } | |
1048 private: | |
1049 // The set of indices of ones in the binary representation of | |
1050 // |touch_ids_bitfield_| is the set of touch_ids associate with this gesture. | |
1051 // This value is stored as a bitfield because the number of touch ids varies, | |
1052 // but we currently don't need more than 32 touches at a time. | |
1053 const unsigned int touch_ids_bitfield_; | |
1054 | |
1055 ui::EventType type_; | |
1056 static ui::EventType ConvertToUI( WebKit::WebGestureEvent::Type t) | |
rjkroege
2012/05/09 16:48:15
we have this same switch statement in more than on
girard
2012/05/09 22:49:19
Agree that we should combine these operations toge
| |
1057 { | |
1058 switch (t) { | |
1059 case WebKit::WebGestureEvent::GestureScrollBegin: | |
1060 return ui::ET_GESTURE_SCROLL_BEGIN; | |
1061 case WebKit::WebGestureEvent::GestureScrollEnd: | |
1062 return ui::ET_GESTURE_SCROLL_END; | |
1063 case WebKit::WebGestureEvent::GestureScrollUpdate: | |
1064 return ui::ET_GESTURE_SCROLL_UPDATE; | |
1065 // case WebKit::WebGestureEvent::GestureFlingStart: | |
rjkroege
2012/05/09 16:48:15
this will break fling. why do you want to do that?
girard
2012/05/09 22:49:19
There is no ui::ET_GESTURE_FLING_START. Is it com
| |
1066 // case WebKit::WebGestureEvent::GestureFlingCancel: | |
1067 case WebKit::WebGestureEvent::GestureTap: | |
1068 return ui::ET_GESTURE_TAP; | |
1069 case WebKit::WebGestureEvent::GestureTapDown: | |
1070 return ui::ET_GESTURE_TAP_DOWN; | |
1071 case WebKit::WebGestureEvent::GestureDoubleTap: | |
1072 return ui::ET_GESTURE_DOUBLE_TAP; | |
1073 case WebKit::WebGestureEvent::GestureLongPress: | |
1074 return ui::ET_GESTURE_LONG_PRESS; | |
1075 case WebKit::WebGestureEvent::GesturePinchBegin: | |
1076 return ui::ET_GESTURE_PINCH_BEGIN; | |
1077 case WebKit::WebGestureEvent::GesturePinchEnd: | |
1078 return ui::ET_GESTURE_PINCH_END; | |
1079 case WebKit::WebGestureEvent::GesturePinchUpdate: | |
1080 return ui::ET_GESTURE_PINCH_UPDATE; | |
1081 default: | |
1082 // Unexpected type mapping! | |
1083 return ui::ET_UNKNOWN; | |
1084 } | |
1085 } | |
1086 | |
1087 static WebKit::WebGestureEvent::Type ConvertToWebKit( ui::EventType t) | |
1088 { | |
1089 switch (t) { | |
1090 case ui::ET_UNKNOWN: | |
1091 return WebKit::WebGestureEvent::Undefined; | |
1092 case ui::ET_GESTURE_SCROLL_BEGIN: | |
1093 return WebKit::WebGestureEvent::GestureScrollBegin; | |
1094 case ui::ET_GESTURE_SCROLL_END: | |
1095 return WebKit::WebGestureEvent::GestureScrollEnd; | |
1096 case ui::ET_GESTURE_SCROLL_UPDATE: | |
1097 return WebKit::WebGestureEvent::GestureScrollUpdate; | |
1098 // return WebKit::WebGestureEvent::GestureFlingStart: | |
1099 // return WebKit::WebGestureEvent::GestureFlingCancel: | |
1100 case ui::ET_GESTURE_TAP: | |
1101 return WebKit::WebGestureEvent::GestureTap; | |
1102 case ui::ET_GESTURE_TAP_DOWN: | |
1103 return WebKit::WebGestureEvent::GestureTapDown; | |
1104 case ui::ET_GESTURE_DOUBLE_TAP: | |
1105 return WebKit::WebGestureEvent::GestureDoubleTap; | |
1106 case ui::ET_GESTURE_LONG_PRESS: | |
1107 return WebKit::WebGestureEvent::GestureLongPress; | |
1108 case ui::ET_GESTURE_PINCH_BEGIN: | |
1109 return WebKit::WebGestureEvent::GesturePinchBegin; | |
1110 case ui::ET_GESTURE_PINCH_END: | |
1111 return WebKit::WebGestureEvent::GesturePinchEnd; | |
1112 case ui::ET_GESTURE_PINCH_UPDATE: | |
1113 return WebKit::WebGestureEvent::GesturePinchUpdate; | |
1114 default: | |
1115 // Unexpected type mapping! | |
rjkroege
2012/05/09 16:48:15
add DCHECK instead.
girard
2012/05/09 22:49:19
Done.
| |
1116 return WebKit::WebGestureEvent::Undefined; | |
1117 } | |
1118 } | |
1119 }; | |
1120 | |
1121 ui::GestureEvent* RenderWidgetHostViewWin::CreateGestureEvent( | |
1122 ui::EventType type, | |
1123 const gfx::Point& location, | |
1124 int flags, | |
1125 base::Time time, | |
1126 float param_first, | |
1127 float param_second, | |
1128 unsigned int touch_id_bitfield) { | |
1129 | |
1130 return new LocalGestureEvent(type, location, flags, time, | |
1131 param_first, param_second, touch_id_bitfield); | |
1132 } | |
1133 | |
1134 class LocalTouchEvent : | |
1135 public WrappedObject<ui::TouchEvent, WebKit::WebTouchEvent> { | |
1136 public: | |
1137 LocalTouchEvent( | |
1138 ui::EventType type, | |
1139 const gfx::Point& location, | |
1140 int touch_id, | |
1141 base::TimeDelta time_stamp) : | |
1142 location_(location), | |
1143 touch_id_(touch_id), | |
1144 time_stamp_(time_stamp) { | |
1145 data_.type = ConvertToWebKit(type); | |
1146 } | |
1147 | |
1148 LocalTouchEvent(const WebKit::WebTouchEvent& copy, | |
1149 ui::EventType type, | |
1150 base::TimeDelta time_stamp) : | |
1151 WrappedObject<ui::TouchEvent, WebKit::WebTouchEvent>(copy), | |
1152 time_stamp_(time_stamp) { | |
1153 data_.type = ConvertToWebKit(type); | |
1154 // This is an experiment! | |
1155 touch_id_ = copy.touches[0].id; | |
1156 location_ = gfx::Point(0,0); | |
1157 data_.type = copy.type; | |
1158 } | |
1159 | |
1160 virtual ui::EventType GetEventType() const OVERRIDE { | |
rjkroege
2012/05/09 16:48:15
Unfortunately, these would appear to have to be vi
girard
2012/05/11 14:21:49
Done.
| |
1161 return ConvertToUI(data_.type); | |
1162 } | |
1163 virtual gfx::Point GetLocation() const OVERRIDE { | |
1164 return location_; | |
1165 } | |
1166 virtual int GetTouchId() const OVERRIDE { | |
1167 return touch_id_; | |
1168 } | |
1169 virtual int GetEventFlags() const OVERRIDE { | |
1170 return 0; | |
1171 } | |
1172 virtual base::TimeDelta GetTimestamp() const OVERRIDE { | |
1173 return time_stamp_; | |
1174 } | |
1175 | |
1176 // Returns a copy of this touch event. Used when queueing events for | |
1177 // asynchronous gesture recognition. | |
1178 virtual TouchEvent* Copy() const OVERRIDE { | |
1179 return new LocalTouchEvent( | |
1180 GetEventType(),GetLocation(),GetTouchId(),GetTimestamp()); | |
1181 } | |
1182 private: | |
1183 int touch_id_; | |
1184 base::TimeDelta time_stamp_; | |
1185 gfx::Point location_; | |
1186 | |
1187 static ui::EventType ConvertToUI( WebKit::WebTouchEvent::Type t) | |
1188 { | |
1189 switch (t) { | |
1190 case WebKit::WebInputEvent::Undefined: | |
1191 return ui::ET_UNKNOWN; | |
1192 case WebKit::WebInputEvent::TouchStart: | |
1193 return ui::ET_TOUCH_PRESSED; | |
1194 case WebKit::WebInputEvent::TouchMove: | |
1195 //return ui::ET_TOUCH_STATIONARY; | |
1196 return ui::ET_TOUCH_MOVED; | |
1197 case WebKit::WebInputEvent::TouchEnd: | |
1198 return ui::ET_TOUCH_RELEASED; | |
1199 case WebKit::WebInputEvent::TouchCancel: | |
1200 return ui::ET_TOUCH_CANCELLED; | |
1201 default: | |
1202 // Unexpected type mapping! | |
1203 return ui::ET_UNKNOWN; | |
1204 } | |
1205 } | |
1206 | |
1207 static WebKit::WebTouchEvent::Type ConvertToWebKit( ui::EventType t) | |
1208 { | |
1209 switch (t) { | |
1210 case ui::ET_UNKNOWN: | |
1211 return WebKit::WebInputEvent::Undefined; | |
1212 case ui::ET_TOUCH_PRESSED: | |
1213 return WebKit::WebInputEvent::TouchStart; | |
1214 case ui::ET_TOUCH_MOVED: | |
1215 case ui::ET_TOUCH_STATIONARY: | |
1216 return WebKit::WebInputEvent::TouchMove; | |
1217 case ui::ET_TOUCH_RELEASED: | |
1218 return WebKit::WebInputEvent::TouchEnd; | |
1219 case ui::ET_TOUCH_CANCELLED: | |
1220 return WebKit::WebInputEvent::TouchCancel; | |
1221 default: | |
1222 // Unexpected ui type mapping! | |
1223 return WebKit::WebInputEvent::Undefined; | |
1224 } | |
1225 } | |
1226 }; | |
1227 | |
1228 ui::TouchEvent* RenderWidgetHostViewWin::CreateTouchEvent( | |
1229 ui::EventType type, | |
1230 const gfx::Point& location, | |
1231 int touch_id, | |
1232 base::TimeDelta time_stamp) { | |
1233 return new LocalTouchEvent( type, location, touch_id, time_stamp); | |
1234 } | |
1235 | |
1236 bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent( | |
1237 ui::GestureEvent* event) { | |
1238 return ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureLongPress, | |
1239 event); | |
1240 } | |
1241 | |
1242 bool RenderWidgetHostViewWin::DispatchCancelTouchEvent( | |
1243 ui::TouchEvent* event) { | |
1244 if (!render_widget_host_) | |
1245 return false; | |
1246 | |
1247 WebKit::WebTouchEvent generatedEvent; | |
1248 generatedEvent.changedTouchesLength = 1; | |
1249 generatedEvent.changedTouches[0].id = event->GetTouchId(); | |
1250 generatedEvent.type = WebKit::WebInputEvent::TouchCancel; | |
1251 render_widget_host_->ForwardTouchEvent(generatedEvent); | |
1252 return true; | |
1253 } | |
1254 | |
994 void RenderWidgetHostViewWin::SetHasHorizontalScrollbar( | 1255 void RenderWidgetHostViewWin::SetHasHorizontalScrollbar( |
995 bool has_horizontal_scrollbar) { | 1256 bool has_horizontal_scrollbar) { |
996 } | 1257 } |
997 | 1258 |
998 void RenderWidgetHostViewWin::SetScrollOffsetPinning( | 1259 void RenderWidgetHostViewWin::SetScrollOffsetPinning( |
999 bool is_pinned_to_left, bool is_pinned_to_right) { | 1260 bool is_pinned_to_left, bool is_pinned_to_right) { |
1000 } | 1261 } |
1001 | 1262 |
1002 /////////////////////////////////////////////////////////////////////////////// | 1263 /////////////////////////////////////////////////////////////////////////////// |
1003 // RenderWidgetHostViewWin, private: | 1264 // RenderWidgetHostViewWin, private: |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1891 static_cast<int>(WebKit::WebTouchEvent::touchesLengthCap)); | 2152 static_cast<int>(WebKit::WebTouchEvent::touchesLengthCap)); |
1892 TOUCHINPUT points[WebKit::WebTouchEvent::touchesLengthCap]; | 2153 TOUCHINPUT points[WebKit::WebTouchEvent::touchesLengthCap]; |
1893 | 2154 |
1894 if (!total || !GetTouchInputInfo((HTOUCHINPUT)lparam, total, | 2155 if (!total || !GetTouchInputInfo((HTOUCHINPUT)lparam, total, |
1895 points, sizeof(TOUCHINPUT))) { | 2156 points, sizeof(TOUCHINPUT))) { |
1896 return 0; | 2157 return 0; |
1897 } | 2158 } |
1898 | 2159 |
1899 for (size_t start = 0; start < total;) { | 2160 for (size_t start = 0; start < total;) { |
1900 start += touch_state_.UpdateTouchPoints(points + start, total - start); | 2161 start += touch_state_.UpdateTouchPoints(points + start, total - start); |
1901 if (touch_state_.is_changed()) | 2162 if (touch_state_.is_changed()) { |
1902 render_widget_host_->ForwardTouchEvent(touch_state_.touch_event()); | 2163 render_widget_host_->ForwardTouchEvent(touch_state_.touch_event()); |
sadrul
2012/05/10 01:49:26
Perhaps this should also check 'if (render_widget_
girard
2012/05/11 14:21:49
Thanks! Done.
| |
2164 } | |
2165 } | |
2166 | |
2167 // Send a copy of the touch events on to the gesture recognizer. | |
2168 for (size_t index = 0; index < total; ++index) { | |
2169 //bool hasAreaInfo = | |
rjkroege
2012/05/09 16:48:15
remove dead code
girard
2012/05/09 22:49:19
Done.
| |
2170 // (points[index].dwMask & TOUCHINPUTMASKF_CONTACTAREA) != 0; | |
2171 base::TimeDelta time_stamp = | |
2172 base::TimeDelta::FromMilliseconds(points[index].dwTime); | |
2173 DWORD flags = points[index].dwFlags; | |
2174 ui::EventType eventType = ui::ET_TOUCH_STATIONARY; | |
2175 | |
2176 if ((flags & TOUCHEVENTF_UP) != 0) | |
2177 eventType = ui::ET_TOUCH_RELEASED; | |
2178 else if ((flags & TOUCHEVENTF_MOVE) != 0) { | |
2179 eventType = ui::ET_TOUCH_MOVED; | |
2180 // Ignore this touch if there is a backlog. | |
rjkroege
2012/05/09 16:48:15
I don't recall you answering me as to why there wo
girard
2012/05/09 22:49:19
On my machine, sending all messages on to the GR g
sadrul
2012/05/10 01:49:26
Note: because this is dropping some of the touch-e
girard
2012/05/11 14:21:49
After some more testing, I determined that this is
| |
2181 if (!gesture_recognizer_->IsQueueEmpty(this)) | |
2182 continue; | |
2183 } | |
2184 else if ((flags & TOUCHEVENTF_DOWN) != 0) | |
2185 eventType = ui::ET_TOUCH_PRESSED; | |
2186 | |
2187 ui::TouchEvent *touchEvent = CreateTouchEvent( | |
2188 eventType, | |
2189 gfx::Point( | |
2190 TOUCH_COORD_TO_PIXEL( points[index].x), | |
2191 TOUCH_COORD_TO_PIXEL( points[index].y)), | |
2192 points[index].dwID, | |
2193 time_stamp); | |
2194 GestureConsumer* consumer = this; | |
2195 gesture_recognizer_->QueueTouchEventForGesture( | |
2196 consumer, *touchEvent); | |
1903 } | 2197 } |
1904 | 2198 |
1905 CloseTouchInputHandle((HTOUCHINPUT)lparam); | 2199 CloseTouchInputHandle((HTOUCHINPUT)lparam); |
1906 | 2200 |
1907 return 0; | 2201 return 0; |
1908 } | 2202 } |
1909 | 2203 |
2204 void RenderWidgetHostViewWin::ProcessGestures( | |
2205 ui::GestureRecognizer::Gestures* gestures) { | |
2206 if ((gestures == 0) || gestures->empty()) | |
2207 return; | |
2208 for (ui::GestureRecognizer::Gestures::iterator g_it = gestures->begin(); | |
rjkroege
2012/05/09 16:48:15
given the switches above, can't you just send all
girard
2012/05/09 22:49:19
Good point. This code can be removed.
girard
2012/05/09 22:49:19
Done.
| |
2209 g_it != gestures->end(); | |
2210 ++g_it) { | |
2211 LocalGestureEvent* gesture = | |
2212 reinterpret_cast<LocalGestureEvent *>( *g_it); | |
2213 switch (gesture->type()) { | |
2214 case ui::ET_GESTURE_SCROLL_BEGIN: | |
2215 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureScrollBegin, | |
2216 gesture); | |
2217 break; | |
2218 case ui::ET_GESTURE_SCROLL_END: | |
2219 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureScrollEnd, | |
2220 gesture); | |
2221 break; | |
2222 case ui::ET_GESTURE_SCROLL_UPDATE: | |
2223 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureScrollUpdate, | |
2224 gesture); | |
2225 break; | |
2226 case ui::ET_GESTURE_PINCH_BEGIN: | |
2227 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GesturePinchBegin, | |
2228 gesture); | |
2229 break; | |
2230 case ui::ET_GESTURE_PINCH_END: | |
2231 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GesturePinchEnd, | |
2232 gesture); | |
2233 break; | |
2234 case ui::ET_GESTURE_PINCH_UPDATE: | |
2235 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GesturePinchUpdate, | |
2236 gesture); | |
2237 break; | |
2238 case ui::ET_GESTURE_LONG_PRESS: | |
2239 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureLongPress, | |
2240 gesture); | |
2241 break; | |
2242 case ui::ET_GESTURE_THREE_FINGER_SWIPE: | |
rjkroege
2012/05/09 16:48:15
why not forward it anyway? If no events are being
girard
2012/05/09 22:49:19
Forward as what kind of WebGestureEvent? Are there
| |
2243 // TODO: Add this code when three finger swipes are added. | |
2244 //ForwardGestureEventToRenderer( | |
2245 // WebKit::WebInputEvent::GestureThreeFingerSwipe, gesture); | |
2246 break; | |
2247 case ui::ET_GESTURE_TAP: | |
2248 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureTap, | |
2249 gesture); | |
2250 break; | |
2251 case ui::ET_GESTURE_TAP_DOWN: | |
2252 ForwardGestureEventToRenderer(WebKit::WebInputEvent::GestureTapDown, | |
2253 gesture); | |
2254 break; | |
2255 case ui::ET_GESTURE_DOUBLE_TAP: | |
2256 ForwardGestureEventToRenderer( | |
2257 WebKit::WebInputEvent::GestureDoubleTap, gesture); | |
2258 break; | |
2259 } | |
2260 } | |
2261 } | |
2262 | |
1910 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT message, | 2263 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT message, |
1911 WPARAM wparam, | 2264 WPARAM wparam, |
1912 LPARAM lparam, | 2265 LPARAM lparam, |
1913 BOOL& handled) { | 2266 BOOL& handled) { |
1914 if (!render_widget_host_) | 2267 if (!render_widget_host_) |
1915 return MA_NOACTIVATE; | 2268 return MA_NOACTIVATE; |
1916 | 2269 |
1917 if (!IsActivatable()) | 2270 if (!IsActivatable()) |
1918 return MA_NOACTIVATE; | 2271 return MA_NOACTIVATE; |
1919 | 2272 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2443 GetClientRect(&ti.rect); | 2796 GetClientRect(&ti.rect); |
2444 SendMessage(tooltip_hwnd_, message, NULL, reinterpret_cast<LPARAM>(&ti)); | 2797 SendMessage(tooltip_hwnd_, message, NULL, reinterpret_cast<LPARAM>(&ti)); |
2445 } | 2798 } |
2446 | 2799 |
2447 void RenderWidgetHostViewWin::ResetTooltip() { | 2800 void RenderWidgetHostViewWin::ResetTooltip() { |
2448 if (::IsWindow(tooltip_hwnd_)) | 2801 if (::IsWindow(tooltip_hwnd_)) |
2449 ::DestroyWindow(tooltip_hwnd_); | 2802 ::DestroyWindow(tooltip_hwnd_); |
2450 tooltip_hwnd_ = NULL; | 2803 tooltip_hwnd_ = NULL; |
2451 } | 2804 } |
2452 | 2805 |
2806 bool RenderWidgetHostViewWin::ForwardGestureEventToRenderer( | |
2807 WebKit::WebInputEvent::Type eventType, | |
2808 ui::GestureEvent* gesture) { | |
2809 if (!render_widget_host_) | |
2810 return false; | |
2811 | |
2812 LocalGestureEvent *local = reinterpret_cast<LocalGestureEvent *>( gesture); | |
2813 const WebKit::WebGestureEvent& generatedEvent = local->data(); | |
2814 DCHECK(generatedEvent.type == eventType); | |
2815 render_widget_host_->ForwardGestureEvent(generatedEvent); | |
2816 return true; | |
2817 } | |
2818 | |
2453 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, | 2819 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, |
2454 WPARAM wparam, | 2820 WPARAM wparam, |
2455 LPARAM lparam) { | 2821 LPARAM lparam) { |
2456 if (!render_widget_host_) | 2822 if (!render_widget_host_) |
2457 return; | 2823 return; |
2458 | 2824 |
2459 WebMouseEvent event( | 2825 WebMouseEvent event( |
2460 WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); | 2826 WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); |
2461 | 2827 |
2462 if (mouse_locked_) { | 2828 if (mouse_locked_) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2695 void RenderWidgetHostViewWin::ResetPointerDownContext() { | 3061 void RenderWidgetHostViewWin::ResetPointerDownContext() { |
2696 // If the default focus on the page is on an edit field and we did not | 3062 // If the default focus on the page is on an edit field and we did not |
2697 // receive a focus change in the context of a pointer down message, it means | 3063 // receive a focus change in the context of a pointer down message, it means |
2698 // that the pointer down message occurred on the edit field and we should | 3064 // that the pointer down message occurred on the edit field and we should |
2699 // display the on screen keyboard | 3065 // display the on screen keyboard |
2700 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3066 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
2701 DisplayOnScreenKeyboardIfNeeded(); | 3067 DisplayOnScreenKeyboardIfNeeded(); |
2702 received_focus_change_after_pointer_down_ = false; | 3068 received_focus_change_after_pointer_down_ = false; |
2703 pointer_down_context_ = false; | 3069 pointer_down_context_ = false; |
2704 } | 3070 } |
OLD | NEW |