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

Unified Diff: services/prediction/touch_position_correction.cc

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: format README and CHROMIUM.diff Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/prediction/touch_position_correction.h ('k') | third_party/android_prediction/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/prediction/touch_position_correction.cc
diff --git a/services/prediction/touch_position_correction.cc b/services/prediction/touch_position_correction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e2eea2baa5a06ed93dd0009b990e444a0756a183
--- /dev/null
+++ b/services/prediction/touch_position_correction.cc
@@ -0,0 +1,72 @@
+// 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 "services/prediction/touch_position_correction.h"
+
+// NOTE: This class has been translated to C++ and modified from the Android
+// Open Source Project. Specifically from some functions of the following file:
+// https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/
+// android-5.1.1_r8/java/src/com/android/inputmethod/keyboard/internal/
+// TouchPositionCorrection.java
+
+namespace prediction {
+
+const int TouchPositionCorrection::TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3;
+
+TouchPositionCorrection::TouchPositionCorrection() {
+ // value currently used by Android TouchPositionCorrection
+ std::string data[9] = {"0.0038756",
+ "-0.0005677",
+ "0.1577026",
+ "-0.0236678",
+ "0.0381731",
+ "0.1529972",
+ "-0.0086827",
+ "0.0880847",
+ "0.1522819"};
+ const int data_length = 9;
+ if (data_length % TOUCH_POSITION_CORRECTION_RECORD_SIZE != 0) {
+ return;
+ }
+
+ for (int i = 0; i < data_length; ++i) {
+ const int type = i % TOUCH_POSITION_CORRECTION_RECORD_SIZE;
+ const int index = i / TOUCH_POSITION_CORRECTION_RECORD_SIZE;
+ const float value = std::stof(data[i]);
+ if (type == 0) {
+ xs_[index] = value;
+ } else if (type == 1) {
+ ys_[index] = value;
+ } else {
+ radii_[index] = value;
+ }
+ }
+ enabled_ = data_length > 0;
+}
+
+TouchPositionCorrection::~TouchPositionCorrection() {
+}
+
+bool TouchPositionCorrection::IsValid() {
+ return enabled_;
+}
+
+int TouchPositionCorrection::GetRows() {
+ return 3;
+}
+
+float TouchPositionCorrection::GetX(const int row) {
+ // Touch position correction data for X coordinate is obsolete.
+ return 0.0f;
+}
+
+float TouchPositionCorrection::GetY(const int row) {
+ return ys_[row];
+}
+
+float TouchPositionCorrection::GetRadius(const int row) {
+ return radii_[row];
+}
+
+} // namespace prediction
« no previous file with comments | « services/prediction/touch_position_correction.h ('k') | third_party/android_prediction/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698