| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/events/blink/web_input_event_traits.h" | 5 #include "ui/events/blink/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 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 9 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 10 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" | 10 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 Apply(WebInputEventSize(), type, type, &size); | 190 Apply(WebInputEventSize(), type, type, &size); |
| 191 return size; | 191 return size; |
| 192 } | 192 } |
| 193 | 193 |
| 194 WebScopedInputEvent WebInputEventTraits::Clone(const WebInputEvent& event) { | 194 WebScopedInputEvent WebInputEventTraits::Clone(const WebInputEvent& event) { |
| 195 WebScopedInputEvent scoped_event; | 195 WebScopedInputEvent scoped_event; |
| 196 Apply(WebInputEventClone(), event.type(), event, &scoped_event); | 196 Apply(WebInputEventClone(), event.type(), event, &scoped_event); |
| 197 return scoped_event; | 197 return scoped_event; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool WebInputEventTraits::ShouldBlockEventStream(const WebInputEvent& event) { | 200 bool WebInputEventTraits::ShouldBlockEventStream( |
| 201 const WebInputEvent& event, |
| 202 bool raf_aligned_touch_enabled) { |
| 201 switch (event.type()) { | 203 switch (event.type()) { |
| 202 case WebInputEvent::MouseDown: | 204 case WebInputEvent::MouseDown: |
| 203 case WebInputEvent::MouseUp: | 205 case WebInputEvent::MouseUp: |
| 204 case WebInputEvent::MouseEnter: | 206 case WebInputEvent::MouseEnter: |
| 205 case WebInputEvent::MouseLeave: | 207 case WebInputEvent::MouseLeave: |
| 206 case WebInputEvent::ContextMenu: | 208 case WebInputEvent::ContextMenu: |
| 207 case WebInputEvent::GestureScrollBegin: | 209 case WebInputEvent::GestureScrollBegin: |
| 208 case WebInputEvent::GestureScrollEnd: | 210 case WebInputEvent::GestureScrollEnd: |
| 209 case WebInputEvent::GestureShowPress: | 211 case WebInputEvent::GestureShowPress: |
| 210 case WebInputEvent::GestureTapUnconfirmed: | 212 case WebInputEvent::GestureTapUnconfirmed: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 221 static_cast<const WebTouchEvent&>(event).dispatchType); | 223 static_cast<const WebTouchEvent&>(event).dispatchType); |
| 222 return false; | 224 return false; |
| 223 | 225 |
| 224 // Touch start and touch end indicate whether they are non-blocking | 226 // Touch start and touch end indicate whether they are non-blocking |
| 225 // (aka uncancelable) on the event. | 227 // (aka uncancelable) on the event. |
| 226 case WebInputEvent::TouchStart: | 228 case WebInputEvent::TouchStart: |
| 227 case WebInputEvent::TouchEnd: | 229 case WebInputEvent::TouchEnd: |
| 228 return static_cast<const WebTouchEvent&>(event).dispatchType == | 230 return static_cast<const WebTouchEvent&>(event).dispatchType == |
| 229 WebInputEvent::Blocking; | 231 WebInputEvent::Blocking; |
| 230 | 232 |
| 231 // Touch move events may be non-blocking but are always explicitly | |
| 232 // acknowledge by the renderer so they block the event stream. | |
| 233 case WebInputEvent::TouchMove: | 233 case WebInputEvent::TouchMove: |
| 234 // Non-blocking touch moves can be ack'd right away if raf_aligned |
| 235 // touch is enabled. |
| 236 if (raf_aligned_touch_enabled) { |
| 237 return static_cast<const WebTouchEvent&>(event).dispatchType == |
| 238 WebInputEvent::Blocking; |
| 239 } |
| 240 // Touch move events may be non-blocking but are always explicitly |
| 241 // acknowledge by the renderer so they block the event stream. |
| 242 return true; |
| 234 default: | 243 default: |
| 235 return true; | 244 return true; |
| 236 } | 245 } |
| 237 } | 246 } |
| 238 | 247 |
| 239 bool WebInputEventTraits::CanCauseScroll( | 248 bool WebInputEventTraits::CanCauseScroll( |
| 240 const blink::WebMouseWheelEvent& event) { | 249 const blink::WebMouseWheelEvent& event) { |
| 241 #if defined(USE_AURA) | 250 #if defined(USE_AURA) |
| 242 // Scroll events generated from the mouse wheel when the control key is held | 251 // Scroll events generated from the mouse wheel when the control key is held |
| 243 // don't trigger scrolling. Instead, they may cause zooming. | 252 // don't trigger scrolling. Instead, they may cause zooming. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 264 source_event_type = SourceEventType::WHEEL; | 273 source_event_type = SourceEventType::WHEEL; |
| 265 } else if (event.sourceDevice == | 274 } else if (event.sourceDevice == |
| 266 blink::WebGestureDevice::WebGestureDeviceTouchscreen) { | 275 blink::WebGestureDevice::WebGestureDeviceTouchscreen) { |
| 267 source_event_type = SourceEventType::TOUCH; | 276 source_event_type = SourceEventType::TOUCH; |
| 268 } | 277 } |
| 269 LatencyInfo latency_info(source_event_type); | 278 LatencyInfo latency_info(source_event_type); |
| 270 return latency_info; | 279 return latency_info; |
| 271 } | 280 } |
| 272 | 281 |
| 273 } // namespace ui | 282 } // namespace ui |
| OLD | NEW |