summaryrefslogtreecommitdiffstats
path: root/ui/keyboard
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 00:09:50 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 00:09:50 +0000
commita93fbd1834a993d49827007efde25be46333d2dd (patch)
tree9f201f984e4b0113570dbef82bbb6310a449b07d /ui/keyboard
parent297b5a354b71c6e38afd52b7797deffcdcca56d6 (diff)
downloadchromium_src-a93fbd1834a993d49827007efde25be46333d2dd.zip
chromium_src-a93fbd1834a993d49827007efde25be46333d2dd.tar.gz
chromium_src-a93fbd1834a993d49827007efde25be46333d2dd.tar.bz2
Prevent key drop if finger moves out of key area slightly before release
When typing quickly, it is quite possible that users move their fingers slightly out of the key area before release the key. This is likely an unintended move and the key shouldn't be dropped. We also increased the triggering condition of swipe gesture to reduce the accidental cursor movement. BUG=301631 Review URL: https://codereview.chromium.org/26233005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/keyboard')
-rw-r--r--ui/keyboard/resources/elements/kb-key-base.html10
-rw-r--r--ui/keyboard/resources/elements/kb-keyboard.html35
-rw-r--r--ui/keyboard/resources/elements/kb-keyset.html2
3 files changed, 37 insertions, 10 deletions
diff --git a/ui/keyboard/resources/elements/kb-key-base.html b/ui/keyboard/resources/elements/kb-key-base.html
index dbc823a..963097e 100644
--- a/ui/keyboard/resources/elements/kb-key-base.html
+++ b/ui/keyboard/resources/elements/kb-key-base.html
@@ -118,7 +118,6 @@
},
out: function(event) {
this.classList.remove('active');
- this.pointerId = undefined;
clearTimeout(this.longPressTimer);
},
up: function(event) {
@@ -143,6 +142,15 @@
},
/**
+ * Drops the pressed key.
+ */
+ dropKey: function() {
+ this.classList.remove('active');
+ clearTimeout(this.longPressTimer);
+ this.pointerId = undefined;
+ },
+
+ /**
* Character value associated with the key. Typically, the value is a
* single character, but may be multi-character in cases like a ".com"
* button.
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html
index 9fdec95..f5ab543 100644
--- a/ui/keyboard/resources/elements/kb-keyboard.html
+++ b/ui/keyboard/resources/elements/kb-keyboard.html
@@ -285,15 +285,25 @@
return;
swipeStatus.offset_x += event.screenX - swipeStatus.pre_x;
swipeStatus.offset_y += event.screenY - swipeStatus.pre_y;
- if (Math.abs(swipeStatus.offset_x) > MIN_SWIPE_DIST ||
- Math.abs(swipeStatus.offset_y) > MIN_SWIPE_DIST) {
+ // Inflates the initial minimal swipe distance that triggers swipe
+ // gesture. It can reduce the accidental cursor movements during fast
+ // typing. After entered swipe gesture mode, the minimal swipe distance
+ // is set to a smaller distance to allow for more responsive cursor
+ // movement.
+ var minSwipeDist =
+ swipeInProgress ? MIN_SWIPE_DIST : 2 * MIN_SWIPE_DIST;
+ if (Math.abs(swipeStatus.offset_x) > minSwipeDist ||
+ Math.abs(swipeStatus.offset_y) > minSwipeDist) {
swipeInProgress = true;
- this.lastPressedKey.classList.remove('active');
+ if (this.lastPressedKey) {
+ this.lastPressedKey.classList.remove('active');
+ this.lastPressedKey = null;
+ }
}
- if (swipeStatus.offset_x > MIN_SWIPE_DIST) {
+ if (swipeStatus.offset_x > minSwipeDist) {
swipeStatus.swipeDirection |= SWIPE_DIRECTION.RIGHT;
swipeStatus.offset_x = 0;
- } else if (swipeStatus.offset_x < -MIN_SWIPE_DIST) {
+ } else if (swipeStatus.offset_x < -minSwipeDist) {
swipeStatus.swipeDirection |= SWIPE_DIRECTION.LEFT;
swipeStatus.offset_x = 0;
}
@@ -301,10 +311,10 @@
// degree. This can also be larger.
if (Math.abs(event.screenY - swipeStatus.pre_y) >
Math.abs(event.screenX - swipeStatus.pre_x)) {
- if (swipeStatus.offset_y > MIN_SWIPE_DIST) {
+ if (swipeStatus.offset_y > minSwipeDist) {
swipeStatus.swipeDirection |= SWIPE_DIRECTION.DOWN;
swipeStatus.offset_y = 0;
- } else if (swipeStatus.offset_y < -MIN_SWIPE_DIST) {
+ } else if (swipeStatus.offset_y < -minSwipeDist) {
swipeStatus.swipeDirection |= SWIPE_DIRECTION.UP;
swipeStatus.offset_y = 0;
}
@@ -423,6 +433,14 @@
* kb-keyboard.
*/
up: function(event) {
+ // When touch typing, it is very possible that finger moves slightly out
+ // of the key area before releases. The key should not be dropped in
+ // this case.
+ if (this.lastPressedKey &&
+ this.lastPressedKey.pointerId == event.pointerId) {
+ this.lastPressedKey.autoRelease();
+ }
+
if (this.dblDetail_) {
this.dblDetail_.clickCount++;
if (this.dblDetail_.clickCount == 2) {
@@ -466,8 +484,9 @@
this.changeKeyset(detail);
if (this.lastPressedKey &&
- this.lastPressedKey.charValue != event.target.charValue)
+ this.lastPressedKey.charValue != event.target.charValue) {
return;
+ }
if (repeatKey.key == event.target) {
repeatKey.cancel();
this.lastPressedKey = null;
diff --git a/ui/keyboard/resources/elements/kb-keyset.html b/ui/keyboard/resources/elements/kb-keyset.html
index 92dd8b7..d5e35e2 100644
--- a/ui/keyboard/resources/elements/kb-keyset.html
+++ b/ui/keyboard/resources/elements/kb-keyset.html
@@ -61,7 +61,7 @@
}
altkeyContainer.keyset = id;
- event.target.classList.remove('active');
+ event.target.dropKey();
activeAltKeySet.style.width = event.target.clientWidth *
activeAltKeySet.childElementCount + 'px';
activeAltKeySet.style.height = event.target.clientHeight + 'px';