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

Unified Diff: services/prediction/key_set.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 side-by-side diff with in-line comments
Download patch
Index: services/prediction/key_set.cc
diff --git a/services/prediction/key_set.cc b/services/prediction/key_set.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6e83f94f1992875fdc3fb52754330bbe32f5fc6a
--- /dev/null
+++ b/services/prediction/key_set.cc
@@ -0,0 +1,21 @@
+// 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/key_set.h"
+
+namespace prediction {
+
+int KeySet::SquaredDistanceToEdge(int x, int y, Key k) {
+ const int left = k.kx;
+ const int right = left + k.kwidth;
+ const int top = k.ky;
+ const int bottom = top + k.kheight;
+ const int edge_x = x < left ? left : (x > right ? right : x);
+ const int edge_y = y < top ? top : (y > bottom ? bottom : y);
+ const int dx = x - edge_x;
+ const int dy = y - edge_y;
+ return dx * dx + dy * dy;
+}
+
+} // namespace prediction

Powered by Google App Engine
This is Rietveld 408576698