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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 "use strict"; 1 "use strict";
2 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 var global = { 6 var global = {
7 argumentsReceived: false, 7 argumentsReceived: false,
8 params: null, 8 params: null,
9 picker: null 9 picker: null
10 }; 10 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 this._element.appendChild(this._selectElement); 47 this._element.appendChild(this._selectElement);
48 this._delayedChildrenConfig = null; 48 this._delayedChildrenConfig = null;
49 this._delayedChildrenConfigIndex = 0; 49 this._delayedChildrenConfigIndex = 0;
50 this._layout(); 50 this._layout();
51 this._selectElement.addEventListener("mouseup", this._handleMouseUp.bind(thi s), false); 51 this._selectElement.addEventListener("mouseup", this._handleMouseUp.bind(thi s), false);
52 this._selectElement.addEventListener("touchstart", this._handleTouchStart.bi nd(this), false); 52 this._selectElement.addEventListener("touchstart", this._handleTouchStart.bi nd(this), false);
53 this._selectElement.addEventListener("keydown", this._handleKeyDown.bind(thi s), false); 53 this._selectElement.addEventListener("keydown", this._handleKeyDown.bind(thi s), false);
54 this._selectElement.addEventListener("change", this._handleChange.bind(this) , false); 54 this._selectElement.addEventListener("change", this._handleChange.bind(this) , false);
55 window.addEventListener("message", this._handleWindowMessage.bind(this), fal se); 55 window.addEventListener("message", this._handleWindowMessage.bind(this), fal se);
56 window.addEventListener("mousemove", this._handleWindowMouseMove.bind(this), false); 56 window.addEventListener("mousemove", this._handleWindowMouseMove.bind(this), false);
57 window.addEventListener("touchmove", this._handleWindowTouchMove.bind(this), false); 57 this._handleWindowTouchMoveBound = this._handleWindowTouchMove.bind(this);
58 window.addEventListener("touchend", this._handleWindowTouchEnd.bind(this), f alse); 58 this._handleWindowTouchEndBound = this._handleWindowTouchEnd.bind(this);
59 this._handleTouchSelectModeScrollBound = this._handleTouchSelectModeScroll.b ind(this);
59 this.lastMousePositionX = Infinity; 60 this.lastMousePositionX = Infinity;
60 this.lastMousePositionY = Infinity; 61 this.lastMousePositionY = Infinity;
61 this._selectionSetByMouseHover = false; 62 this._selectionSetByMouseHover = false;
62 63
63 this._trackingTouchId = null; 64 this._trackingTouchId = null;
64 65
65 this._handleWindowDidHide(); 66 this._handleWindowDidHide();
66 this._selectElement.focus(); 67 this._selectElement.focus();
67 this._selectElement.value = this._config.selectedIndex; 68 this._selectElement.value = this._config.selectedIndex;
68 } 69 }
(...skipping 28 matching lines...) Expand all
97 98
98 ListPicker.prototype._handleMouseUp = function(event) { 99 ListPicker.prototype._handleMouseUp = function(event) {
99 if (event.target.tagName !== "OPTION") 100 if (event.target.tagName !== "OPTION")
100 return; 101 return;
101 window.pagePopupController.setValueAndClosePopup(0, this._selectElement.valu e); 102 window.pagePopupController.setValueAndClosePopup(0, this._selectElement.valu e);
102 }; 103 };
103 104
104 ListPicker.prototype._handleTouchStart = function(event) { 105 ListPicker.prototype._handleTouchStart = function(event) {
105 if (this._trackingTouchId !== null) 106 if (this._trackingTouchId !== null)
106 return; 107 return;
108 // Enter touch select mode. In touch select mode the highlight follows the
109 // finger and on touchend the highlighted item is selected.
107 var touch = event.touches[0]; 110 var touch = event.touches[0];
108 this._trackingTouchId = touch.identifier; 111 this._trackingTouchId = touch.identifier;
109 this._highlightOption(touch.target); 112 this._highlightOption(touch.target);
110 this._selectionSetByMouseHover = false; 113 this._selectionSetByMouseHover = false;
114 this._selectElement.addEventListener("scroll", this._handleTouchSelectModeSc rollBound, false);
115 window.addEventListener("touchmove", this._handleWindowTouchMoveBound, false );
116 window.addEventListener("touchend", this._handleWindowTouchEndBound, false);
117 };
118
119 ListPicker.prototype._handleTouchSelectModeScroll = function(event) {
120 this._exitTouchSelectMode();
121 };
122
123 ListPicker.prototype._exitTouchSelectMode = function(event) {
124 this._trackingTouchId = null;
125 this._selectElement.removeEventListener("scroll", this._handleTouchSelectMod eScrollBound, false);
126 window.removeEventListener("touchmove", this._handleWindowTouchMoveBound, fa lse);
127 window.removeEventListener("touchend", this._handleWindowTouchEndBound, fals e);
111 }; 128 };
112 129
113 ListPicker.prototype._handleWindowTouchMove = function(event) { 130 ListPicker.prototype._handleWindowTouchMove = function(event) {
114 if (this._trackingTouchId === null) 131 if (this._trackingTouchId === null)
115 return; 132 return;
116 var touch = this._getTouchForId(event.touches, this._trackingTouchId); 133 var touch = this._getTouchForId(event.touches, this._trackingTouchId);
117 if (!touch) 134 if (!touch)
118 return; 135 return;
119 this._highlightOption(document.elementFromPoint(touch.clientX, touch.clientY )); 136 this._highlightOption(document.elementFromPoint(touch.clientX, touch.clientY ));
120 this._selectionSetByMouseHover = false; 137 this._selectionSetByMouseHover = false;
121 }; 138 };
122 139
123 ListPicker.prototype._handleWindowTouchEnd = function(event) { 140 ListPicker.prototype._handleWindowTouchEnd = function(event) {
124 if (this._trackingTouchId === null) 141 if (this._trackingTouchId === null)
125 return; 142 return;
126 var touch = this._getTouchForId(event.changedTouches, this._trackingTouchId) ; 143 var touch = this._getTouchForId(event.changedTouches, this._trackingTouchId) ;
127 if (!touch) 144 if (!touch)
128 return; 145 return;
129 var target = document.elementFromPoint(touch.clientX, touch.clientY) 146 var target = document.elementFromPoint(touch.clientX, touch.clientY)
130 if (target.tagName === "OPTION") 147 if (target.tagName === "OPTION")
131 window.pagePopupController.setValueAndClosePopup(0, this._selectElement. value); 148 window.pagePopupController.setValueAndClosePopup(0, this._selectElement. value);
132 this._trackingTouchId = null; 149 this._exitTouchSelectMode();
133 }; 150 };
134 151
135 ListPicker.prototype._getTouchForId = function (touchList, id) { 152 ListPicker.prototype._getTouchForId = function (touchList, id) {
136 for (var i = 0; i < touchList.length; i++) { 153 for (var i = 0; i < touchList.length; i++) {
137 if (touchList[i].identifier === id) 154 if (touchList[i].identifier === id)
138 return touchList[i]; 155 return touchList[i];
139 } 156 }
140 return null; 157 return null;
141 }; 158 };
142 159
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 421 }
405 this._applyItemStyle(element, config.style); 422 this._applyItemStyle(element, config.style);
406 }; 423 };
407 424
408 if (window.dialogArguments) { 425 if (window.dialogArguments) {
409 initialize(dialogArguments); 426 initialize(dialogArguments);
410 } else { 427 } else {
411 window.addEventListener("message", handleMessage, false); 428 window.addEventListener("message", handleMessage, false);
412 window.setTimeout(handleArgumentsTimeout, 1000); 429 window.setTimeout(handleArgumentsTimeout, 1000);
413 } 430 }
OLDNEW
« 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