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/common/input/synthetic_pointer_action_list_params.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 SyntheticPointerActionListParams::SyntheticPointerActionListParams() {} | |
| 12 | |
| 13 SyntheticPointerActionListParams::SyntheticPointerActionListParams( | |
| 14 ParamList& param_list) { | |
| 15 params.push_back(param_list); | |
| 16 } | |
| 17 | |
| 18 SyntheticPointerActionListParams::SyntheticPointerActionListParams( | |
| 19 const SyntheticPointerActionListParams& other) | |
| 20 : SyntheticGestureParams(other), params(other.params) {} | |
| 21 | |
| 22 SyntheticPointerActionListParams::~SyntheticPointerActionListParams() {} | |
| 23 | |
| 24 SyntheticGestureParams::GestureType | |
| 25 SyntheticPointerActionListParams::GetGestureType() const { | |
| 26 return POINTER_ACTION_LIST; | |
| 27 } | |
| 28 | |
| 29 const SyntheticPointerActionListParams* SyntheticPointerActionListParams::Cast( | |
| 30 const SyntheticGestureParams* gesture_params) { | |
| 31 DCHECK(gesture_params); | |
| 32 DCHECK_EQ(POINTER_ACTION_LIST, gesture_params->GetGestureType()); | |
| 33 return static_cast<const SyntheticPointerActionListParams*>(gesture_params); | |
| 34 } | |
| 35 | |
| 36 void SyntheticPointerActionListParams::PushPointerActionParams( | |
| 37 const SyntheticPointerActionParams& param) { | |
| 38 ParamList param_list; | |
| 39 param_list.push_back(param); | |
| 40 params.push_back(param_list); | |
| 41 } | |
| 42 | |
| 43 void SyntheticPointerActionListParams::PushPointerActionParams( | |
| 44 int index, | |
| 45 const SyntheticPointerActionParams& param) { | |
|
Navid Zolghadr
2016/12/06 17:05:38
On way we can get away with this index is to just
lanwei
2016/12/07 19:04:27
You are right, exposing the index is not really sa
| |
| 46 int size = static_cast<int>(params.size()); | |
| 47 DCHECK_GE(index, 0); | |
| 48 DCHECK_LE(index, size); | |
| 49 | |
| 50 if (size > index) { | |
|
Navid Zolghadr
2016/12/06 17:05:38
We might also need to add index >=0.
| |
| 51 params[index].push_back(param); | |
| 52 return; | |
| 53 } | |
| 54 PushPointerActionParams(param); | |
| 55 } | |
| 56 | |
| 57 } // namespace content | |
| OLD | NEW |