Index: ui/keyboard/resources/touch_fuzzing.js |
diff --git a/ui/keyboard/resources/touch_fuzzing.js b/ui/keyboard/resources/touch_fuzzing.js |
index f610dbe47911cec534f8c0df1c178408f7bf8768..7a6a2ce5c88284987ac81cb94ae9173f336466c5 100644 |
--- a/ui/keyboard/resources/touch_fuzzing.js |
+++ b/ui/keyboard/resources/touch_fuzzing.js |
@@ -67,7 +67,12 @@ |
*/ |
findClosestKey: function(x, y) { |
var closestNode = this.tree.findClosestNode(x, y); |
- return closestNode.data ? closestNode.data.key : null; |
+ var key = closestNode.data; |
+ if (!key) |
+ return; |
+ // Ignore touches that aren't close. |
+ return key.distanceTo(x,y) <= MAX_TOUCH_FUZZ_DISTANCE ? |
+ key.key : null; |
}, |
/** |
@@ -107,7 +112,8 @@ |
* @return {number}. |
*/ |
distanceTo: function (x, y) { |
- return Math.abs(this.intersect(x)) + Math.abs(this.intersect(y, true)); |
+ return Math.abs(this.intersect(new Line(x))) + |
+ Math.abs(this.intersect(new Line(y, true))); |
}, |
/** |