| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/input/web_input_event_traits.h" | 5 #include "content/common/input/web_input_event_traits.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 | 9 |
| 10 using base::StringAppendF; | 10 using base::StringAppendF; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 event.movedBeyondSlopRegion, event.uniqueTouchEventId); | 101 event.movedBeyondSlopRegion, event.uniqueTouchEventId); |
| 102 for (unsigned i = 0; i < event.touchesLength; ++i) | 102 for (unsigned i = 0; i < event.touchesLength; ++i) |
| 103 ApppendTouchPointDetails(event.touches[i], result); | 103 ApppendTouchPointDetails(event.touches[i], result); |
| 104 result->append(" ]\n}"); | 104 result->append(" ]\n}"); |
| 105 } | 105 } |
| 106 | 106 |
| 107 struct WebInputEventToString { | 107 struct WebInputEventToString { |
| 108 template <class EventType> | 108 template <class EventType> |
| 109 bool Execute(const WebInputEvent& event, std::string* result) const { | 109 bool Execute(const WebInputEvent& event, std::string* result) const { |
| 110 SStringPrintf(result, "%s (Time: %lf, Modifiers: %d)\n", | 110 SStringPrintf(result, "%s (Time: %lf, Modifiers: %d)\n", |
| 111 WebInputEventTraits::GetName(event.type), | 111 WebInputEvent::GetName(event.type), event.timeStampSeconds, |
| 112 event.timeStampSeconds, | |
| 113 event.modifiers); | 112 event.modifiers); |
| 114 const EventType& typed_event = static_cast<const EventType&>(event); | 113 const EventType& typed_event = static_cast<const EventType&>(event); |
| 115 ApppendEventDetails(typed_event, result); | 114 ApppendEventDetails(typed_event, result); |
| 116 return true; | 115 return true; |
| 117 } | 116 } |
| 118 }; | 117 }; |
| 119 | 118 |
| 120 struct WebInputEventSize { | 119 struct WebInputEventSize { |
| 121 template <class EventType> | 120 template <class EventType> |
| 122 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const { | 121 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return op.template Execute<WebTouchEvent>(arg_in, arg_out); | 161 return op.template Execute<WebTouchEvent>(arg_in, arg_out); |
| 163 else if (WebInputEvent::isGestureEventType(type)) | 162 else if (WebInputEvent::isGestureEventType(type)) |
| 164 return op.template Execute<WebGestureEvent>(arg_in, arg_out); | 163 return op.template Execute<WebGestureEvent>(arg_in, arg_out); |
| 165 | 164 |
| 166 NOTREACHED() << "Unknown webkit event type " << type; | 165 NOTREACHED() << "Unknown webkit event type " << type; |
| 167 return false; | 166 return false; |
| 168 } | 167 } |
| 169 | 168 |
| 170 } // namespace | 169 } // namespace |
| 171 | 170 |
| 172 const char* WebInputEventTraits::GetName(WebInputEvent::Type type) { | |
| 173 #define CASE_TYPE(t) case WebInputEvent::t: return #t | |
| 174 switch(type) { | |
| 175 CASE_TYPE(Undefined); | |
| 176 CASE_TYPE(MouseDown); | |
| 177 CASE_TYPE(MouseUp); | |
| 178 CASE_TYPE(MouseMove); | |
| 179 CASE_TYPE(MouseEnter); | |
| 180 CASE_TYPE(MouseLeave); | |
| 181 CASE_TYPE(ContextMenu); | |
| 182 CASE_TYPE(MouseWheel); | |
| 183 CASE_TYPE(RawKeyDown); | |
| 184 CASE_TYPE(KeyDown); | |
| 185 CASE_TYPE(KeyUp); | |
| 186 CASE_TYPE(Char); | |
| 187 CASE_TYPE(GestureScrollBegin); | |
| 188 CASE_TYPE(GestureScrollEnd); | |
| 189 CASE_TYPE(GestureScrollUpdate); | |
| 190 CASE_TYPE(GestureFlingStart); | |
| 191 CASE_TYPE(GestureFlingCancel); | |
| 192 CASE_TYPE(GestureShowPress); | |
| 193 CASE_TYPE(GestureTap); | |
| 194 CASE_TYPE(GestureTapUnconfirmed); | |
| 195 CASE_TYPE(GestureTapDown); | |
| 196 CASE_TYPE(GestureTapCancel); | |
| 197 CASE_TYPE(GestureDoubleTap); | |
| 198 CASE_TYPE(GestureTwoFingerTap); | |
| 199 CASE_TYPE(GestureLongPress); | |
| 200 CASE_TYPE(GestureLongTap); | |
| 201 CASE_TYPE(GesturePinchBegin); | |
| 202 CASE_TYPE(GesturePinchEnd); | |
| 203 CASE_TYPE(GesturePinchUpdate); | |
| 204 CASE_TYPE(TouchStart); | |
| 205 CASE_TYPE(TouchMove); | |
| 206 CASE_TYPE(TouchEnd); | |
| 207 CASE_TYPE(TouchCancel); | |
| 208 CASE_TYPE(TouchScrollStarted); | |
| 209 default: | |
| 210 // Must include default to let blink::WebInputEvent add new event types | |
| 211 // before they're added here. | |
| 212 DLOG(WARNING) << | |
| 213 "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n"; | |
| 214 break; | |
| 215 } | |
| 216 #undef CASE_TYPE | |
| 217 return ""; | |
| 218 } | |
| 219 | |
| 220 std::string WebInputEventTraits::ToString(const WebInputEvent& event) { | 171 std::string WebInputEventTraits::ToString(const WebInputEvent& event) { |
| 221 std::string result; | 172 std::string result; |
| 222 Apply(WebInputEventToString(), event.type, event, &result); | 173 Apply(WebInputEventToString(), event.type, event, &result); |
| 223 return result; | 174 return result; |
| 224 } | 175 } |
| 225 | 176 |
| 226 size_t WebInputEventTraits::GetSize(WebInputEvent::Type type) { | 177 size_t WebInputEventTraits::GetSize(WebInputEvent::Type type) { |
| 227 size_t size = 0; | 178 size_t size = 0; |
| 228 Apply(WebInputEventSize(), type, type, &size); | 179 Apply(WebInputEventSize(), type, type, &size); |
| 229 return size; | 180 return size; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 246 |
| 296 uint32_t WebInputEventTraits::GetUniqueTouchEventId( | 247 uint32_t WebInputEventTraits::GetUniqueTouchEventId( |
| 297 const WebInputEvent& event) { | 248 const WebInputEvent& event) { |
| 298 if (WebInputEvent::isTouchEventType(event.type)) { | 249 if (WebInputEvent::isTouchEventType(event.type)) { |
| 299 return static_cast<const WebTouchEvent&>(event).uniqueTouchEventId; | 250 return static_cast<const WebTouchEvent&>(event).uniqueTouchEventId; |
| 300 } | 251 } |
| 301 return 0U; | 252 return 0U; |
| 302 } | 253 } |
| 303 | 254 |
| 304 } // namespace content | 255 } // namespace content |
| OLD | NEW |