Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: services/prediction/input_info.cc

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 <new>
6
7 #include "services/prediction/input_info.h"
8 #include "services/prediction/key_set.h"
9
10 namespace prediction {
11
12 InputInfo::InputInfo(int input_size) {
13 size = input_size;
14 codepoints = new int[size];
15 x_coordinates = new int[size];
16 y_coordinates = new int[size];
17 pointer_ids = new int[size];
18 times = new int[size];
19 }
20
21 InputInfo::~InputInfo() {
22 delete[] codepoints;
23 delete[] x_coordinates;
24 delete[] y_coordinates;
25 delete[] pointer_ids;
26 delete[] times;
27 }
28
29 int* InputInfo::GetCodepoints() {
30 return codepoints;
31 }
32
33 int* InputInfo::GetXCoordinates() {
34 return x_coordinates;
35 }
36
37 int* InputInfo::GetYCoordinates() {
38 return y_coordinates;
39 }
40
41 int* InputInfo::GetPointerIds() {
42 return pointer_ids;
43 }
44
45 int* InputInfo::GetTimes() {
46 return times;
47 }
48
49 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;"
50 for (int i = 0; i < size; i++) {
51 int codepoint = (int)input[i];
52 codepoints[i] = codepoint;
53 for (int j = 0; j < KeySet::key_count; j++) {
54 if (KeySet::key_set[j].kcode == tolower(codepoint)) {
55 x_coordinates[i] =
56 KeySet::key_set[j].kx + KeySet::key_set[j].kwidth / 2;
57 y_coordinates[i] =
58 KeySet::key_set[j].ky + KeySet::key_set[j].kheight / 2;
59 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.
60 times[i] = 0;
61 break;
62 }
63 }
64 }
65 }
66
67 } // namespace prediction
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698