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

Side by Side 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, 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 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 "services/prediction/key_set.h"
6
7 namespace prediction {
8
9 int KeySet::SquaredDistanceToEdge(int x, int y, Key k) {
10 const int left = k.kx;
11 const int right = left + k.kwidth;
12 const int top = k.ky;
13 const int bottom = top + k.kheight;
14 const int edge_x = x < left ? left : (x > right ? right : x);
15 const int edge_y = y < top ? top : (y > bottom ? bottom : y);
16 const int dx = x - edge_x;
17 const int dy = y - edge_y;
18 return dx * dx + dy * dy;
19 }
20
21 } // namespace prediction
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698