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

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/handler/pointerhandler.js

Issue 1046933003: Updates google-input-tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License. 2 // limitations under the License.
3 // See the License for the specific language governing permissions and 3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS, 5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software 6 // Unless required by applicable law or agreed to in writing, software
7 // 7 //
8 // http://www.apache.org/licenses/LICENSE-2.0 8 // http://www.apache.org/licenses/LICENSE-2.0
9 // 9 //
10 // You may obtain a copy of the License at 10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License. 11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License"); 12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // 13 //
14 goog.provide('i18n.input.chrome.inputview.handler.PointerHandler'); 14 goog.provide('i18n.input.chrome.inputview.handler.PointerHandler');
15 15
16 goog.require('goog.Timer'); 16 goog.require('goog.Timer');
17 goog.require('goog.events.EventHandler'); 17 goog.require('goog.events.EventHandler');
18 goog.require('goog.events.EventTarget'); 18 goog.require('goog.events.EventTarget');
19 goog.require('goog.events.EventType'); 19 goog.require('goog.events.EventType');
20 goog.require('goog.math.Coordinate');
21 goog.require('i18n.input.chrome.inputview.events.PointerEvent');
22 goog.require('i18n.input.chrome.inputview.handler.PointerActionBundle'); 20 goog.require('i18n.input.chrome.inputview.handler.PointerActionBundle');
21 goog.require('i18n.input.chrome.inputview.handler.Util');
23 22
24 goog.scope(function() { 23 goog.scope(function() {
25 24
26 25
27 26
28 /** 27 /**
29 * The pointer controller. 28 * The pointer controller.
30 * 29 *
31 * @param {!Element=} opt_target . 30 * @param {!Element=} opt_target .
32 * @constructor 31 * @constructor
(...skipping 14 matching lines...) Expand all
47 * The event handler. 46 * The event handler.
48 * 47 *
49 * @type {!goog.events.EventHandler} 48 * @type {!goog.events.EventHandler}
50 * @private 49 * @private
51 */ 50 */
52 this.eventHandler_ = new goog.events.EventHandler(this); 51 this.eventHandler_ = new goog.events.EventHandler(this);
53 52
54 var target = opt_target || document; 53 var target = opt_target || document;
55 this.eventHandler_. 54 this.eventHandler_.
56 listen(target, [goog.events.EventType.MOUSEDOWN, 55 listen(target, [goog.events.EventType.MOUSEDOWN,
57 goog.events.EventType.TOUCHSTART], this.onPointerDown_, true). 56 goog.events.EventType.TOUCHSTART], this.onPointerDown_, true).
58 listen(document, goog.events.EventType.TOUCHEND, this.onPointerUp_, true). 57 listen(document, goog.events.EventType.TOUCHEND, this.onPointerUp_, true).
59 listen(document, goog.events.EventType.MOUSEUP, this.onPointerUp_, true). 58 listen(document, goog.events.EventType.MOUSEUP, this.onPointerUp_, true).
60 listen(target, goog.events.EventType.TOUCHMOVE, this.onPointerMove_, 59 listen(target, [goog.events.EventType.TOUCHMOVE,
61 true). 60 goog.events.EventType.MOUSEMOVE], this.onPointerMove_,
62 listen(target, goog.events.EventType.MOUSEMOVE, this.onPointerMove_,
63 true); 61 true);
64 }; 62 };
65 goog.inherits(i18n.input.chrome.inputview.handler.PointerHandler, 63 goog.inherits(i18n.input.chrome.inputview.handler.PointerHandler,
66 goog.events.EventTarget); 64 goog.events.EventTarget);
67 var PointerHandler = i18n.input.chrome.inputview.handler.PointerHandler; 65 var PointerHandler = i18n.input.chrome.inputview.handler.PointerHandler;
68 var PointerActionBundle = 66 var PointerActionBundle =
69 i18n.input.chrome.inputview.handler.PointerActionBundle; 67 i18n.input.chrome.inputview.handler.PointerActionBundle;
70 var Util = i18n.input.chrome.inputview.handler.Util; 68 var Util = i18n.input.chrome.inputview.handler.Util;
71 69
72 70
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 121
124 /** 122 /**
125 * Callback for mouse/touch down on the target. 123 * Callback for mouse/touch down on the target.
126 * 124 *
127 * @param {!goog.events.BrowserEvent} e The event. 125 * @param {!goog.events.BrowserEvent} e The event.
128 * @private 126 * @private
129 */ 127 */
130 PointerHandler.prototype.onPointerDown_ = function(e) { 128 PointerHandler.prototype.onPointerDown_ = function(e) {
131 var view = Util.getView(/** @type {!Node} */ (e.target)); 129 var view = Util.getView(/** @type {!Node} */ (e.target));
132 if (!view) { 130 if (!view) {
133 this.dispatchEvent(new i18n.input.chrome.inputview.events.PointerEvent(
134 null, i18n.input.chrome.inputview.events.EventType.POINTER_DOWN,
135 e.target, 0, 0, new Date().getTime()));
136 return; 131 return;
137 } 132 }
138 var pointerActionBundle = this.getPointerActionBundle_(view); 133 var pointerActionBundle = this.getPointerActionBundle_(view);
139 if (this.previousPointerActionBundle_ && 134 if (this.previousPointerActionBundle_ &&
140 this.previousPointerActionBundle_ != pointerActionBundle) { 135 this.previousPointerActionBundle_ != pointerActionBundle) {
141 this.previousPointerActionBundle_.cancelDoubleClick(); 136 this.previousPointerActionBundle_.cancelDoubleClick();
142 } 137 }
143 this.previousPointerActionBundle_ = pointerActionBundle; 138 this.previousPointerActionBundle_ = pointerActionBundle;
144 pointerActionBundle.handlePointerDown(e); 139 pointerActionBundle.handlePointerDown(e);
145 if (view.pointerConfig.preventDefault) { 140 if (view.pointerConfig.preventDefault) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 212 }
218 var shouldPreventDefault = false; 213 var shouldPreventDefault = false;
219 var shouldStopEventPropagation = false; 214 var shouldStopEventPropagation = false;
220 for (var i = 0; i < touches.length; i++) { 215 for (var i = 0; i < touches.length; i++) {
221 var view = Util.getView(/** @type {!Node} */ (touches[i].target)); 216 var view = Util.getView(/** @type {!Node} */ (touches[i].target));
222 if (view) { 217 if (view) {
223 var pointerActionBundle = this.pointerActionBundles_[goog.getUid(view)]; 218 var pointerActionBundle = this.pointerActionBundles_[goog.getUid(view)];
224 if (pointerActionBundle) { 219 if (pointerActionBundle) {
225 pointerActionBundle.handlePointerMove(touches[i]); 220 pointerActionBundle.handlePointerMove(touches[i]);
226 } 221 }
227 if (view.pointerConfig.preventDefauat) { 222 if (view.pointerConfig.preventDefault) {
228 shouldPreventDefault = true; 223 shouldPreventDefault = true;
229 } 224 }
230 if (view.pointerConfig.stopEventPropagation) { 225 if (view.pointerConfig.stopEventPropagation) {
231 shouldStopEventPropagation = true; 226 shouldStopEventPropagation = true;
232 } 227 }
233 } 228 }
234 } 229 }
235 if (shouldPreventDefault) { 230 if (shouldPreventDefault) {
236 e.preventDefault(); 231 e.preventDefault();
237 } 232 }
238 if (shouldStopEventPropagation) { 233 if (shouldStopEventPropagation) {
239 e.stopPropagation(); 234 e.stopPropagation();
240 } 235 }
241 }; 236 };
242 237
243 238
244 /** @override */ 239 /** @override */
245 PointerHandler.prototype.disposeInternal = function() { 240 PointerHandler.prototype.disposeInternal = function() {
246 for (var bundle in this.pointerActionBundles_) { 241 for (var bundle in this.pointerActionBundles_) {
247 goog.dispose(bundle); 242 goog.dispose(bundle);
248 } 243 }
249 goog.dispose(this.eventHandler_); 244 goog.dispose(this.eventHandler_);
250 245
251 goog.base(this, 'disposeInternal'); 246 goog.base(this, 'disposeInternal');
252 }; 247 };
253 248
254 }); // goog.scope 249 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698