Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/input/synthetic_pointer_action_controlle r.h" | |
| 6 | |
| 7 namespace content { | |
| 8 | |
| 9 SyntheticPointerActionController::SyntheticPointerActionController() { | |
| 10 for (size_t i = 0; i < index_map_.size(); ++i) | |
| 11 index_map_[i] = -1; | |
| 12 } | |
| 13 SyntheticPointerActionController::~SyntheticPointerActionController() {} | |
| 14 | |
| 15 std::unique_ptr<SyntheticGesture> | |
| 16 SyntheticPointerActionController::CreateSyntheticPointerAction( | |
| 17 const SyntheticPointerActionParams& gesture_params) { | |
| 18 DCHECK(gesture_params.pointer_action_type() != | |
| 19 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED); | |
| 20 std::unique_ptr<SyntheticGesture> synthetic_gesture; | |
| 21 if (gesture_params.pointer_action_type() == | |
| 22 SyntheticPointerActionParams::PointerActionType::PROCESS || | |
| 23 gesture_params.pointer_action_type() == | |
| 24 SyntheticPointerActionParams::PointerActionType::FINISH) { | |
| 25 if (gesture_params.pointer_action_type() == | |
|
tdresser
2016/05/19 17:57:04
Move this outside of the outer if. I think reducin
lanwei
2016/05/20 01:48:16
Done.
| |
| 26 SyntheticPointerActionParams::PointerActionType::FINISH) { | |
| 27 action_param_list_.push_back(gesture_params); | |
| 28 } | |
| 29 | |
| 30 // TODO(lanwei): Will support multiple pointer types in the same stream | |
| 31 // later. | |
|
tdresser
2016/05/19 17:57:04
Add a bug link.
lanwei
2016/05/20 01:48:16
Done.
| |
| 32 if (!action_param_list_.empty()) { | |
| 33 if (!synthetic_pointer_) | |
| 34 SetSyntheticPointer(gesture_params); | |
| 35 | |
| 36 synthetic_gesture = | |
| 37 std::unique_ptr<SyntheticGesture>(new SyntheticPointerAction( | |
| 38 action_param_list_, synthetic_pointer_.get(), &index_map_)); | |
| 39 action_param_list_.clear(); | |
| 40 } | |
| 41 } else | |
|
tdresser
2016/05/19 17:57:03
Add {} here. In general if one clause of an if sta
| |
| 42 action_param_list_.push_back(gesture_params); | |
|
tdresser
2016/05/19 17:57:03
I'd invert this condition so the common, easy to f
lanwei
2016/05/20 01:48:16
Done.
| |
| 43 return synthetic_gesture; | |
| 44 } | |
| 45 | |
| 46 void SyntheticPointerActionController::SetSyntheticPointer( | |
| 47 const SyntheticPointerActionParams& gesture_params) { | |
| 48 SyntheticGestureParams::GestureSourceType gesture_source_type = | |
| 49 gesture_params.gesture_source_type; | |
| 50 if (gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) | |
| 51 gesture_source_type = default_type_; | |
| 52 DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); | |
| 53 synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type); | |
| 54 } | |
| 55 | |
| 56 void SyntheticPointerActionController::ResetSyntheticPointer() { | |
| 57 synthetic_pointer_.reset(); | |
| 58 } | |
| 59 | |
| 60 void SyntheticPointerActionController::SetDefaultGestureSourceType( | |
| 61 SyntheticGestureParams::GestureSourceType default_type) { | |
| 62 default_type_ = default_type; | |
| 63 } | |
| 64 | |
| 65 int SyntheticPointerActionController::PointerIndex(int index) const { | |
|
tdresser
2016/05/19 17:57:04
Do we need this method here? Could it be defined i
lanwei
2016/05/20 01:48:16
Done.
| |
| 66 CHECK_GE(index, 0); | |
| 67 CHECK_LT(index, WebTouchEvent::touchesLengthCap); | |
| 68 return index_map_[index]; | |
| 69 } | |
| 70 | |
| 71 } // namespace content | |
| OLD | NEW |