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

Unified Diff: ui/keyboard/resources/touch_fuzzing.js

Issue 230993003: Limits the range of touch fuzzing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 | « ui/keyboard/resources/constants.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)));
},
/**
« no previous file with comments | « ui/keyboard/resources/constants.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698