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

Unified Diff: Source/web/resources/listPicker.js

Issue 1287003002: Touch scrolling in list picker shouldn't close the popup (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebaseline mac test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/mac/fast/forms/select/popup-menu-touch-operations-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/resources/listPicker.js
diff --git a/Source/web/resources/listPicker.js b/Source/web/resources/listPicker.js
index 8cc50ab628f5c16c5de8056460f3195118ec51d1..167ad3cd77cc1ceb90b253edb6253f6541488ac0 100644
--- a/Source/web/resources/listPicker.js
+++ b/Source/web/resources/listPicker.js
@@ -54,8 +54,9 @@ function ListPicker(element, config) {
this._selectElement.addEventListener("change", this._handleChange.bind(this), false);
window.addEventListener("message", this._handleWindowMessage.bind(this), false);
window.addEventListener("mousemove", this._handleWindowMouseMove.bind(this), false);
- window.addEventListener("touchmove", this._handleWindowTouchMove.bind(this), false);
- window.addEventListener("touchend", this._handleWindowTouchEnd.bind(this), false);
+ this._handleWindowTouchMoveBound = this._handleWindowTouchMove.bind(this);
+ this._handleWindowTouchEndBound = this._handleWindowTouchEnd.bind(this);
+ this._handleTouchSelectModeScrollBound = this._handleTouchSelectModeScroll.bind(this);
this.lastMousePositionX = Infinity;
this.lastMousePositionY = Infinity;
this._selectionSetByMouseHover = false;
@@ -104,10 +105,26 @@ ListPicker.prototype._handleMouseUp = function(event) {
ListPicker.prototype._handleTouchStart = function(event) {
if (this._trackingTouchId !== null)
return;
+ // Enter touch select mode. In touch select mode the highlight follows the
+ // finger and on touchend the highlighted item is selected.
var touch = event.touches[0];
this._trackingTouchId = touch.identifier;
this._highlightOption(touch.target);
this._selectionSetByMouseHover = false;
+ this._selectElement.addEventListener("scroll", this._handleTouchSelectModeScrollBound, false);
+ window.addEventListener("touchmove", this._handleWindowTouchMoveBound, false);
+ window.addEventListener("touchend", this._handleWindowTouchEndBound, false);
+};
+
+ListPicker.prototype._handleTouchSelectModeScroll = function(event) {
+ this._exitTouchSelectMode();
+};
+
+ListPicker.prototype._exitTouchSelectMode = function(event) {
+ this._trackingTouchId = null;
+ this._selectElement.removeEventListener("scroll", this._handleTouchSelectModeScrollBound, false);
+ window.removeEventListener("touchmove", this._handleWindowTouchMoveBound, false);
+ window.removeEventListener("touchend", this._handleWindowTouchEndBound, false);
};
ListPicker.prototype._handleWindowTouchMove = function(event) {
@@ -129,7 +146,7 @@ ListPicker.prototype._handleWindowTouchEnd = function(event) {
var target = document.elementFromPoint(touch.clientX, touch.clientY)
if (target.tagName === "OPTION")
window.pagePopupController.setValueAndClosePopup(0, this._selectElement.value);
- this._trackingTouchId = null;
+ this._exitTouchSelectMode();
};
ListPicker.prototype._getTouchForId = function (touchList, id) {
« no previous file with comments | « LayoutTests/platform/mac/fast/forms/select/popup-menu-touch-operations-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698