Chromium Code Reviews| Index: services/prediction/input_info.cc |
| diff --git a/services/prediction/input_info.cc b/services/prediction/input_info.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..410adfa32984ec4a90448b0280bb0d177d8d12b1 |
| --- /dev/null |
| +++ b/services/prediction/input_info.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <new> |
| + |
| +#include "services/prediction/input_info.h" |
| +#include "services/prediction/key_set.h" |
| + |
| +namespace prediction { |
| + |
| +InputInfo::InputInfo(int input_size) { |
| + size = input_size; |
| + codepoints = new int[size]; |
| + x_coordinates = new int[size]; |
| + y_coordinates = new int[size]; |
| + pointer_ids = new int[size]; |
| + times = new int[size]; |
| +} |
| + |
| +InputInfo::~InputInfo() { |
| + delete[] codepoints; |
| + delete[] x_coordinates; |
| + delete[] y_coordinates; |
| + delete[] pointer_ids; |
| + delete[] times; |
| +} |
| + |
| +int* InputInfo::GetCodepoints() { |
| + return codepoints; |
| +} |
| + |
| +int* InputInfo::GetXCoordinates() { |
| + return x_coordinates; |
| +} |
| + |
| +int* InputInfo::GetYCoordinates() { |
| + return y_coordinates; |
| +} |
| + |
| +int* InputInfo::GetPointerIds() { |
| + return pointer_ids; |
| +} |
| + |
| +int* InputInfo::GetTimes() { |
| + return times; |
| +} |
| + |
| +void InputInfo::ProcessInput(mojo::String& input) { |
|
APW
2015/07/23 20:11:28
You should check that input size is >= size - othe
riajiang
2015/07/31 02:13:04
It would be equal because of "size = input_size;"
|
| + for (int i = 0; i < size; i++) { |
| + int codepoint = (int)input[i]; |
| + codepoints[i] = codepoint; |
| + for (int j = 0; j < KeySet::key_count; j++) { |
| + if (KeySet::key_set[j].kcode == tolower(codepoint)) { |
| + x_coordinates[i] = |
| + KeySet::key_set[j].kx + KeySet::key_set[j].kwidth / 2; |
| + y_coordinates[i] = |
| + KeySet::key_set[j].ky + KeySet::key_set[j].kheight / 2; |
| + pointer_ids[i] = 0; |
|
APW
2015/07/23 20:11:28
shouldn't you set pointer_ids and times all the ti
riajiang
2015/07/31 02:13:04
Done.
|
| + times[i] = 0; |
| + break; |
| + } |
| + } |
| + } |
| +} |
| + |
| +} // namespace prediction |