Chromium Code Reviews| Index: content/renderer/gpu/actions_parser.cc |
| diff --git a/content/renderer/gpu/actions_parser.cc b/content/renderer/gpu/actions_parser.cc |
| index 41b5a3e25a748187d3187ee8718f5bfd9a2236e3..a469ce30cbc18c41a1ad73176d94110cd15b4dae 100644 |
| --- a/content/renderer/gpu/actions_parser.cc |
| +++ b/content/renderer/gpu/actions_parser.cc |
| @@ -37,6 +37,16 @@ SyntheticGestureParams::GestureSourceType ToSyntheticGestureSourceType( |
| return SyntheticGestureParams::DEFAULT_INPUT; |
| } |
| +SyntheticPointerActionParams::Button ToSyntheticMouseButton( |
| + std::string button) { |
| + if (button == "left") |
| + return SyntheticPointerActionParams::Button::LEFT; |
| + else if (button == "middle") |
| + return SyntheticPointerActionParams::Button::MIDDLE; |
| + else |
|
tdresser
2017/01/19 14:41:57
Let's be explicit here, DCHECK if the string isn't
|
| + return SyntheticPointerActionParams::Button::RIGHT; |
| +} |
| + |
| } // namespace |
| ActionsParser::ActionsParser(base::Value* pointer_actions_value) |
| @@ -192,6 +202,20 @@ bool ActionsParser::ParseAction( |
| return false; |
| } |
| + std::string button_name = "left"; |
| + if (action.HasKey("button") && !action.GetString("button", &button_name)) { |
| + error_message_ = base::StringPrintf( |
| + "actions[%d].actions.button is not a string", action_index_); |
| + return false; |
| + } else if (button_name != "left" && button_name != "middle" && |
| + button_name != "right") { |
| + error_message_ = base::StringPrintf( |
| + "actions[%d].actions.button is an unsupported button", action_index_); |
| + return false; |
| + } |
| + SyntheticPointerActionParams::Button button = |
| + ToSyntheticMouseButton(button_name); |
| + |
| double duration = 0; |
| int num_idle = 0; |
| if (pointer_action_type == |
| @@ -212,11 +236,20 @@ bool ActionsParser::ParseAction( |
| SyntheticPointerActionParams action_param(pointer_action_type); |
| action_param.set_index(action_index_); |
| - if (pointer_action_type == |
| - SyntheticPointerActionParams::PointerActionType::PRESS || |
| - pointer_action_type == |
| - SyntheticPointerActionParams::PointerActionType::MOVE) { |
| - action_param.set_position(gfx::PointF(position_x, position_y)); |
| + switch (pointer_action_type) { |
| + case SyntheticPointerActionParams::PointerActionType::PRESS: |
| + action_param.set_position(gfx::PointF(position_x, position_y)); |
| + action_param.set_button(button); |
| + break; |
| + case SyntheticPointerActionParams::PointerActionType::MOVE: |
| + action_param.set_position(gfx::PointF(position_x, position_y)); |
| + break; |
| + case SyntheticPointerActionParams::PointerActionType::RELEASE: |
| + action_param.set_button(button); |
| + break; |
| + case SyntheticPointerActionParams::PointerActionType::IDLE: |
| + case SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED: |
| + break; |
| } |
| param_list.push_back(action_param); |