| 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 "core/input/TouchEventManager.h" | 5 #include "core/input/TouchEventManager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/events/TouchEvent.h" | 9 #include "core/events/TouchEvent.h" |
| 10 #include "core/frame/Deprecation.h" | 10 #include "core/frame/Deprecation.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 TouchEventManager::TouchEventManager(LocalFrame& frame) : frame_(frame) { | 100 TouchEventManager::TouchEventManager(LocalFrame& frame) : frame_(frame) { |
| 101 Clear(); | 101 Clear(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void TouchEventManager::Clear() { | 104 void TouchEventManager::Clear() { |
| 105 touch_sequence_document_.Clear(); | 105 touch_sequence_document_.Clear(); |
| 106 target_for_touch_id_.clear(); | 106 target_for_touch_id_.clear(); |
| 107 region_for_touch_id_.clear(); | 107 region_for_touch_id_.clear(); |
| 108 touch_pressed_ = false; | 108 touch_pressed_ = false; |
| 109 suppressing_touchmoves_within_slop_ = false; | 109 suppressing_touchmoves_within_slop_ = false; |
| 110 current_touch_action_ = kTouchActionAuto; | 110 current_touch_action_ = TouchAction::kTouchActionAuto; |
| 111 } | 111 } |
| 112 | 112 |
| 113 DEFINE_TRACE(TouchEventManager) { | 113 DEFINE_TRACE(TouchEventManager) { |
| 114 visitor->Trace(frame_); | 114 visitor->Trace(frame_); |
| 115 visitor->Trace(touch_sequence_document_); | 115 visitor->Trace(touch_sequence_document_); |
| 116 visitor->Trace(target_for_touch_id_); | 116 visitor->Trace(target_for_touch_id_); |
| 117 } | 117 } |
| 118 | 118 |
| 119 WebInputEventResult TouchEventManager::DispatchTouchEvents( | 119 WebInputEventResult TouchEventManager::DispatchTouchEvents( |
| 120 const WebTouchEvent& event, | 120 const WebTouchEvent& event, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (!changed_touches[point_state].touches_) | 190 if (!changed_touches[point_state].touches_) |
| 191 changed_touches[point_state].touches_ = TouchList::Create(); | 191 changed_touches[point_state].touches_ = TouchList::Create(); |
| 192 changed_touches[point_state].touches_->Append(touch); | 192 changed_touches[point_state].touches_->Append(touch); |
| 193 changed_touches[point_state].targets_.insert(touch_info.touch_node); | 193 changed_touches[point_state].targets_.insert(touch_info.touch_node); |
| 194 changed_touches[point_state].pointer_type_ = point.pointer_type; | 194 changed_touches[point_state].pointer_type_ = point.pointer_type; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (all_touches_released) { | 198 if (all_touches_released) { |
| 199 touch_sequence_document_.Clear(); | 199 touch_sequence_document_.Clear(); |
| 200 current_touch_action_ = kTouchActionAuto; | 200 current_touch_action_ = TouchAction::kTouchActionAuto; |
| 201 } | 201 } |
| 202 | 202 |
| 203 WebInputEventResult event_result = WebInputEventResult::kNotHandled; | 203 WebInputEventResult event_result = WebInputEventResult::kNotHandled; |
| 204 | 204 |
| 205 // Now iterate through the |changedTouches| list and |m_targets| within it, | 205 // Now iterate through the |changedTouches| list and |m_targets| within it, |
| 206 // sending TouchEvents to the targets as required. | 206 // sending TouchEvents to the targets as required. |
| 207 for (unsigned state = 0; state <= WebTouchPoint::kStateMax; ++state) { | 207 for (unsigned state = 0; state <= WebTouchPoint::kStateMax; ++state) { |
| 208 if (!changed_touches[state].touches_) | 208 if (!changed_touches[state].touches_) |
| 209 continue; | 209 continue; |
| 210 | 210 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // down. However EventSender allows this to be violated and there's | 362 // down. However EventSender allows this to be violated and there's |
| 363 // some tests that take advantage of it. There may also be edge | 363 // some tests that take advantage of it. There may also be edge |
| 364 // cases in the browser where this happens. | 364 // cases in the browser where this happens. |
| 365 // See http://crbug.com/345372. | 365 // See http://crbug.com/345372. |
| 366 target_for_touch_id_.Set(touch_info.point.id, touch_info.touch_node); | 366 target_for_touch_id_.Set(touch_info.point.id, touch_info.touch_node); |
| 367 | 367 |
| 368 region_for_touch_id_.Set(touch_info.point.id, touch_info.region); | 368 region_for_touch_id_.Set(touch_info.point.id, touch_info.region); |
| 369 | 369 |
| 370 TouchAction effective_touch_action = | 370 TouchAction effective_touch_action = |
| 371 TouchActionUtil::ComputeEffectiveTouchAction(*touch_info.touch_node); | 371 TouchActionUtil::ComputeEffectiveTouchAction(*touch_info.touch_node); |
| 372 if (effective_touch_action != kTouchActionAuto) { | 372 if (effective_touch_action != TouchAction::kTouchActionAuto) { |
| 373 frame_->GetPage()->GetChromeClient().SetTouchAction( | 373 frame_->GetPage()->GetChromeClient().SetTouchAction( |
| 374 frame_, effective_touch_action); | 374 frame_, effective_touch_action); |
| 375 | 375 |
| 376 // Combine the current touch action sequence with the touch action | 376 // Combine the current touch action sequence with the touch action |
| 377 // for the current finger press. | 377 // for the current finger press. |
| 378 current_touch_action_ &= effective_touch_action; | 378 current_touch_action_ &= effective_touch_action; |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 } | 382 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 518 } |
| 519 | 519 |
| 520 return DispatchTouchEvents(event, touch_infos, all_touches_released); | 520 return DispatchTouchEvents(event, touch_infos, all_touches_released); |
| 521 } | 521 } |
| 522 | 522 |
| 523 bool TouchEventManager::IsAnyTouchActive() const { | 523 bool TouchEventManager::IsAnyTouchActive() const { |
| 524 return touch_pressed_; | 524 return touch_pressed_; |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace blink | 527 } // namespace blink |
| OLD | NEW |