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

Side by Side Diff: chrome/browser/resources/pdf/pdf.js

Issue 2855953003: Handle long press in PDF documents. (Closed)
Patch Set: Add long press test 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 this.browserApi_.setZoom.bind(this.browserApi_), 238 this.browserApi_.setZoom.bind(this.browserApi_),
239 this.browserApi_.getInitialZoom()); 239 this.browserApi_.getInitialZoom());
240 this.viewport_.zoomManager = this.zoomManager_; 240 this.viewport_.zoomManager = this.zoomManager_;
241 this.browserApi_.addZoomEventListener( 241 this.browserApi_.addZoomEventListener(
242 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 242 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
243 243
244 // Setup the keyboard event listener. 244 // Setup the keyboard event listener.
245 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 245 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
246 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 246 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
247 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 247 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
248 document.addEventListener('contextmenu',
249 this.handleContextMenuEvent_.bind(this));
248 250
249 var tabId = this.browserApi_.getStreamInfo().tabId; 251 var tabId = this.browserApi_.getStreamInfo().tabId;
250 this.navigator_ = new Navigator( 252 this.navigator_ = new Navigator(
251 this.originalUrl_, this.viewport_, this.paramsParser_, 253 this.originalUrl_, this.viewport_, this.paramsParser_,
252 new NavigatorDelegate(tabId)); 254 new NavigatorDelegate(tabId));
253 this.viewportScroller_ = 255 this.viewportScroller_ =
254 new ViewportScroller(this.viewport_, this.plugin_, window); 256 new ViewportScroller(this.viewport_, this.plugin_, window);
255 257
256 // Request translated strings. 258 // Request translated strings.
257 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 259 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 405 }
404 }, 406 },
405 407
406 handleMouseEvent_: function(e) { 408 handleMouseEvent_: function(e) {
407 if (e.type == 'mousemove') 409 if (e.type == 'mousemove')
408 this.toolbarManager_.handleMouseMove(e); 410 this.toolbarManager_.handleMouseMove(e);
409 else if (e.type == 'mouseout') 411 else if (e.type == 'mouseout')
410 this.toolbarManager_.hideToolbarsForMouseOut(); 412 this.toolbarManager_.hideToolbarsForMouseOut();
411 }, 413 },
412 414
415 handleContextMenuEvent_: function(e) {
416 // Stop Chrome from popping up the context menu on long press. We need to
417 // make sure the start event did not have 2 touches because we don't want
418 // to block two finger tap opening the context menu. We check for
419 // firesTouchEvents in order to not block the context menu on right click.
420 if (e.sourceCapabilities.firesTouchEvents &&
421 !this.gestureDetector_.wasTwoFingerTouch()) {
422 e.preventDefault();
423 }
424 },
425
413 /** 426 /**
414 * @private 427 * @private
415 * Rotate the plugin clockwise. 428 * Rotate the plugin clockwise.
416 */ 429 */
417 rotateClockwise_: function() { 430 rotateClockwise_: function() {
418 this.plugin_.postMessage({ 431 this.plugin_.postMessage({
419 type: 'rotateClockwise' 432 type: 'rotateClockwise'
420 }); 433 });
421 }, 434 },
422 435
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 * Each bookmark is an Object containing a: 936 * Each bookmark is an Object containing a:
924 * - title 937 * - title
925 * - page (optional) 938 * - page (optional)
926 * - array of children (themselves bookmarks) 939 * - array of children (themselves bookmarks)
927 * @type {Array} the top-level bookmarks of the PDF. 940 * @type {Array} the top-level bookmarks of the PDF.
928 */ 941 */
929 get bookmarks() { 942 get bookmarks() {
930 return this.bookmarks_; 943 return this.bookmarks_;
931 } 944 }
932 }; 945 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698