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

Unified Diff: chrome/browser/resources/pdf/gesture_detector.js

Issue 2886943006: PDF Plugin: Add compile targets for a few files. (Closed)
Patch Set: Fix test error cause. Created 3 years, 7 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
Index: chrome/browser/resources/pdf/gesture_detector.js
diff --git a/chrome/browser/resources/pdf/gesture_detector.js b/chrome/browser/resources/pdf/gesture_detector.js
index 091707649d2072235ef1aae33be0f23886b12f09..d19dd7048c1e540c5f438b8dc88aff66c351394b 100644
--- a/chrome/browser/resources/pdf/gesture_detector.js
+++ b/chrome/browser/resources/pdf/gesture_detector.js
@@ -14,21 +14,34 @@ class GestureDetector {
* @param {!Element} element The element to monitor for touch gestures.
*/
constructor(element) {
+ /** @private {!Element} */
this.element_ = element;
this.element_.addEventListener(
- 'touchstart', this.onTouchStart_.bind(this), { passive: true });
+ 'touchstart',
+ /** @type {function(!Event)} */ (this.onTouchStart_.bind(this)),
dpapad 2017/05/23 18:38:38 Changed the code to use a different function refer
+ { passive: true });
+
this.element_.addEventListener(
- 'touchmove', this.onTouch_.bind(this), { passive: false });
+ 'touchmove',
+ /** @type {function(!Event)} */ (this.onTouch_.bind(this)),
+ { passive: false });
this.element_.addEventListener(
- 'touchend', this.onTouch_.bind(this), { passive: true });
+ 'touchend',
+ /** @type {function(!Event)} */ (this.onTouch_.bind(this)),
+ { passive: true });
this.element_.addEventListener(
- 'touchcancel', this.onTouch_.bind(this), { passive: true });
+ 'touchcancel',
+ /** @type {function(!Event)} */ (this.onTouch_.bind(this)),
+ { passive: true });
this.pinchStartEvent_ = null;
this.lastTouchTouchesCount_ = 0;
+
+ /** @private {?TouchEvent} */
this.lastEvent_ = null;
+ /** @private {!Map<string, !Array<!Function>>} */
this.listeners_ = new Map([
['pinchstart', []],
['pinchupdate', []],
@@ -39,7 +52,7 @@ class GestureDetector {
/**
* Add a |listener| to be notified of |type| events.
* @param {string} type The event type to be notified for.
- * @param {Function} listener The callback.
+ * @param {!Function} listener The callback.
*/
addEventListener(type, listener) {
if (this.listeners_.has(type)) {
@@ -94,12 +107,14 @@ class GestureDetector {
if (!this.pinchStartEvent_)
return;
+ let lastEvent = /** @type {!TouchEvent} */ (this.lastEvent_);
+
// Check if the pinch ends with the current event.
if (event.touches.length < 2 ||
- this.lastEvent_.touches.length !== event.touches.length) {
+ lastEvent.touches.length !== event.touches.length) {
let startScaleRatio = GestureDetector.pinchScaleRatio_(
- this.lastEvent_, this.pinchStartEvent_);
- let center = GestureDetector.center_(this.lastEvent_);
+ lastEvent, this.pinchStartEvent_);
+ let center = GestureDetector.center_(lastEvent);
let endEvent = {
type: 'pinchend',
startScaleRatio: startScaleRatio,
@@ -115,7 +130,7 @@ class GestureDetector {
// pinch-zoom does not interfere with our way of handling the event.
event.preventDefault();
- let scaleRatio = GestureDetector.pinchScaleRatio_(event, this.lastEvent_);
+ let scaleRatio = GestureDetector.pinchScaleRatio_(event, lastEvent);
let startScaleRatio = GestureDetector.pinchScaleRatio_(
event, this.pinchStartEvent_);
let center = GestureDetector.center_(event);
« no previous file with comments | « chrome/browser/resources/pdf/compiled_resources2.gyp ('k') | chrome/browser/resources/pdf/open_pdf_params_parser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698