Commit 1a7a344e authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Enable opening context menu by two-finger tap.

The context menu has once disabled by 606068 when we assigned long-tap
to enter the selection mode.

Bug: 755757
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I282901d190e63c264eb6238abd34bf0cff107a66
Reviewed-on: https://chromium-review.googlesource.com/625506Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496599}
parent a8807399
...@@ -108,13 +108,17 @@ FileTapHandler.prototype.handleTouchEvents = function(event, index, callback) { ...@@ -108,13 +108,17 @@ FileTapHandler.prototype.handleTouchEvents = function(event, index, callback) {
case 'touchstart': case 'touchstart':
// Only process single touches. If there is already a touch happening, or // Only process single touches. If there is already a touch happening, or
// two simultaneous touches then just ignore them. // two simultaneous touches then just ignore them.
if (event.touches.length > 1) if (event.touches.length > 1) {
// Note that we could cancel an active touch here. That would make // Note that we could cancel an active touch here. That would make
// simultaneous touch behave similar to near-simultaneous. However, if // simultaneous touch behave similar to near-simultaneous. However, if
// the user is dragging something, an accidental second touch could be // the user is dragging something, an accidental second touch could be
// quite disruptive if it cancelled their drag. Better to just ignore // quite disruptive if it cancelled their drag. Better to just ignore
// it. // it.
// Invalidate current touch to distinguish it from normal tap.
this.tapStarted_ = false;
return false; return false;
}
// It's still possible there could be an active "touch" if the user is // It's still possible there could be an active "touch" if the user is
// simultaneously using a mouse and a touch input. // simultaneously using a mouse and a touch input.
...@@ -142,8 +146,6 @@ FileTapHandler.prototype.handleTouchEvents = function(event, index, callback) { ...@@ -142,8 +146,6 @@ FileTapHandler.prototype.handleTouchEvents = function(event, index, callback) {
break; break;
case 'touchmove': case 'touchmove':
assert(this.findActiveTouch_(event.touches), 'Missing touchEnd');
var touch = this.findActiveTouch_(event.changedTouches); var touch = this.findActiveTouch_(event.changedTouches);
if (!touch) if (!touch)
break; break;
......
...@@ -105,6 +105,13 @@ function ListContainer(element, table, grid) { ...@@ -105,6 +105,13 @@ function ListContainer(element, table, grid) {
*/ */
this.textSearchState = new TextSearchState(); this.textSearchState = new TextSearchState();
/**
* Whtehter to allow or cancel a context menu event.
* @type {boolean}
* @private
*/
this.allowContextMenuByTouch_ = false;
// Overriding the default role 'list' to 'listbox' for better accessibility // Overriding the default role 'list' to 'listbox' for better accessibility
// on ChromeOS. // on ChromeOS.
this.table.list.setAttribute('role', 'listbox'); this.table.list.setAttribute('role', 'listbox');
...@@ -118,12 +125,7 @@ function ListContainer(element, table, grid) { ...@@ -118,12 +125,7 @@ function ListContainer(element, table, grid) {
util.isTouchModeEnabled().then(function(enabled) { util.isTouchModeEnabled().then(function(enabled) {
if (!enabled) if (!enabled)
return; return;
// Prevent opening context menu in file list by tap. this.disableContextMenuByLongTap_();
this.element.addEventListener('contextmenu', function(e) {
if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) {
e.stopPropagation();
}
}, true);
}.bind(this)); }.bind(this));
} }
...@@ -241,6 +243,34 @@ ListContainer.prototype.setCurrentListType = function(listType) { ...@@ -241,6 +243,34 @@ ListContainer.prototype.setCurrentListType = function(listType) {
this.endBatchUpdates(); this.endBatchUpdates();
}; };
/**
* Disables context menu by long-tap but not two-finger tap.
* @private
*/
ListContainer.prototype.disableContextMenuByLongTap_ = function() {
this.element.addEventListener('touchstart', function(e) {
if (e.touches.length > 1) {
this.allowContextMenuByTouch_ = true;
}
}.bind(this));
this.element.addEventListener('touchend', function(e) {
if (e.touches.length == 0) {
// contextmenu event will be sent right after touchend.
setTimeout(function() {
this.allowContextMenuByTouch_ = false;
}.bind(this));
}
}.bind(this));
this.element.addEventListener('contextmenu', function(e) {
// Block context menu triggered by touch event unless it is right after
// multi-touch.
if (!this.allowContextMenuByTouch_ && e.sourceCapabilities &&
e.sourceCapabilities.firesTouchEvents) {
e.stopPropagation();
}
}.bind(this), true);
};
/** /**
* Clears hover highlighting in the list container until next mouse move. * Clears hover highlighting in the list container until next mouse move.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment