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

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

Issue 712133003: Track whether a scroll sequence has been partially prevented (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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"
9 #include "content/common/input/web_input_event_traits.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 10 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 11
10 using blink::WebInputEvent; 12 using blink::WebInputEvent;
11 13
12 namespace content { 14 namespace content {
13 15
14 GestureEventStreamValidator::GestureEventStreamValidator() 16 GestureEventStreamValidator::GestureEventStreamValidator()
15 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) { 17 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) {
16 } 18 }
17 19
18 GestureEventStreamValidator::~GestureEventStreamValidator() { 20 GestureEventStreamValidator::~GestureEventStreamValidator() {
19 } 21 }
20 22
21 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, 23 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
22 std::string* error_msg) { 24 std::string* error_msg) {
23 DCHECK(error_msg); 25 DCHECK(error_msg);
24 error_msg->clear(); 26 error_msg->clear();
27 if (!WebInputEvent::isGestureEventType(event.type)) {
28 error_msg->append(base::StringPrintf(
29 "Invalid gesture type: %s", WebInputEventTraits::GetName(event.type)));
30 }
25 switch (event.type) { 31 switch (event.type) {
26 case WebInputEvent::GestureScrollBegin: 32 case WebInputEvent::GestureScrollBegin:
27 if (scrolling_) 33 if (scrolling_)
28 error_msg->append("Scroll begin during scroll\n"); 34 error_msg->append("Scroll begin during scroll\n");
29 if (pinching_) 35 if (pinching_)
30 error_msg->append("Scroll begin during pinch\n"); 36 error_msg->append("Scroll begin during pinch\n");
31 scrolling_ = true; 37 scrolling_ = true;
32 break; 38 break;
33 case WebInputEvent::GestureScrollUpdate: 39 case WebInputEvent::GestureScrollUpdate:
34 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 40 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // not require a preceding TapDown. 83 // not require a preceding TapDown.
78 waiting_for_tap_end_ = false; 84 waiting_for_tap_end_ = false;
79 break; 85 break;
80 default: 86 default:
81 break; 87 break;
82 } 88 }
83 return error_msg->empty(); 89 return error_msg->empty();
84 } 90 }
85 91
86 } // namespace content 92 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698