Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: content/common/input/gesture_event_stream_validator.cc

Issue 2250233002: Type->String helper function added to WebInputEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Blink_Common_export instead of blink_export Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gesture_event_stream_validator.h" 5 #include "content/common/input/gesture_event_stream_validator.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 #include "third_party/WebKit/public/web/WebInputEvent.h" 9 #include "third_party/WebKit/public/web/WebInputEvent.h"
10 #include "ui/events/blink/web_input_event_traits.h" 10 #include "ui/events/blink/web_input_event_traits.h"
11 11
12 using blink::WebInputEvent; 12 using blink::WebInputEvent;
13 13
14 namespace content { 14 namespace content {
15 15
16 GestureEventStreamValidator::GestureEventStreamValidator() 16 GestureEventStreamValidator::GestureEventStreamValidator()
17 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) { 17 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) {
18 } 18 }
19 19
20 GestureEventStreamValidator::~GestureEventStreamValidator() { 20 GestureEventStreamValidator::~GestureEventStreamValidator() {
21 } 21 }
22 22
23 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, 23 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
24 std::string* error_msg) { 24 std::string* error_msg) {
25 DCHECK(error_msg); 25 DCHECK(error_msg);
26 error_msg->clear(); 26 error_msg->clear();
27 if (!WebInputEvent::isGestureEventType(event.type)) { 27 if (!WebInputEvent::isGestureEventType(event.type)) {
28 error_msg->append( 28 error_msg->append(base::StringPrintf("Invalid gesture type: %s",
29 base::StringPrintf("Invalid gesture type: %s", 29 WebInputEvent::GetName(event.type)));
30 ui::WebInputEventTraits::GetName(event.type)));
31 } 30 }
32 switch (event.type) { 31 switch (event.type) {
33 case WebInputEvent::GestureScrollBegin: 32 case WebInputEvent::GestureScrollBegin:
34 if (scrolling_) 33 if (scrolling_)
35 error_msg->append("Scroll begin during scroll\n"); 34 error_msg->append("Scroll begin during scroll\n");
36 if (pinching_) 35 if (pinching_)
37 error_msg->append("Scroll begin during pinch\n"); 36 error_msg->append("Scroll begin during pinch\n");
38 scrolling_ = true; 37 scrolling_ = true;
39 break; 38 break;
40 case WebInputEvent::GestureScrollUpdate: 39 case WebInputEvent::GestureScrollUpdate:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // 'continuity check', requiring that all events between an initial tap-down 104 // 'continuity check', requiring that all events between an initial tap-down
106 // and whatever terminates the sequence to have the same source device type, 105 // and whatever terminates the sequence to have the same source device type,
107 // and that touchpad gestures are only found on ScrollEvents. 106 // and that touchpad gestures are only found on ScrollEvents.
108 if (event.sourceDevice == blink::WebGestureDeviceUninitialized) 107 if (event.sourceDevice == blink::WebGestureDeviceUninitialized)
109 error_msg->append("Gesture event source is uninitialized.\n"); 108 error_msg->append("Gesture event source is uninitialized.\n");
110 109
111 return error_msg->empty(); 110 return error_msg->empty();
112 } 111 }
113 112
114 } // namespace content 113 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698