OLD | NEW |
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) | 187 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) |
188 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); | 188 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); |
189 }.bind(this)); | 189 }.bind(this)); |
190 } | 190 } |
191 | 191 |
192 // Parse open pdf parameters. | 192 // Parse open pdf parameters. |
193 this.paramsParser_ = new OpenPDFParamsParser(); | 193 this.paramsParser_ = new OpenPDFParamsParser(); |
194 this.navigator_ = new Navigator(this.streamDetails_.originalUrl, | 194 this.navigator_ = new Navigator(this.streamDetails_.originalUrl, |
195 this.viewport_, this.paramsParser_, onNavigateInCurrentTab, | 195 this.viewport_, this.paramsParser_, onNavigateInCurrentTab, |
196 onNavigateInNewTab); | 196 onNavigateInNewTab); |
| 197 this.viewportScroller_ = |
| 198 new ViewportScroller(this.viewport_, this.plugin_, window); |
197 } | 199 } |
198 | 200 |
199 PDFViewer.prototype = { | 201 PDFViewer.prototype = { |
200 /** | 202 /** |
201 * @private | 203 * @private |
202 * Handle key events. These may come from the user directly or via the | 204 * Handle key events. These may come from the user directly or via the |
203 * scripting API. | 205 * scripting API. |
204 * @param {KeyboardEvent} e the event to handle. | 206 * @param {KeyboardEvent} e the event to handle. |
205 */ | 207 */ |
206 handleKeyEvent_: function(e) { | 208 handleKeyEvent_: function(e) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 rotateCounterClockwise_: function() { | 343 rotateCounterClockwise_: function() { |
342 this.plugin_.postMessage({ | 344 this.plugin_.postMessage({ |
343 type: 'rotateCounterclockwise' | 345 type: 'rotateCounterclockwise' |
344 }); | 346 }); |
345 }, | 347 }, |
346 | 348 |
347 /** | 349 /** |
348 * @private | 350 * @private |
349 * Notify the plugin to print. | 351 * Notify the plugin to print. |
350 */ | 352 */ |
351 print_: function() { | 353 print_: function() { this.plugin_.postMessage({type: 'print'}); }, |
352 this.plugin_.postMessage({ | |
353 type: 'print' | |
354 }); | |
355 }, | |
356 | 354 |
357 /** | 355 /** |
358 * @private | 356 * @private |
359 * Notify the plugin to save. | 357 * Notify the plugin to save. |
360 */ | 358 */ |
361 save_: function() { | 359 save_: function() { this.plugin_.postMessage({type: 'save'}); }, |
362 this.plugin_.postMessage({ | |
363 type: 'save' | |
364 }); | |
365 }, | |
366 | 360 |
367 /** | 361 /** |
368 * @private | 362 * @private |
369 * Handle open pdf parameters. This function updates the viewport as per | 363 * Handle open pdf parameters. This function updates the viewport as per |
370 * the parameters mentioned in the url while opening pdf. The order is | 364 * the parameters mentioned in the url while opening pdf. The order is |
371 * important as later actions can override the effects of previous actions. | 365 * important as later actions can override the effects of previous actions. |
372 */ | 366 */ |
373 handleURLParams_: function() { | 367 handleURLParams_: function() { |
374 var urlParams = | 368 var urlParams = |
375 this.paramsParser_.getViewportFromUrlParams( | 369 this.paramsParser_.getViewportFromUrlParams( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 case 'cancelStreamUrl': | 511 case 'cancelStreamUrl': |
518 chrome.mimeHandlerPrivate.abortStream(); | 512 chrome.mimeHandlerPrivate.abortStream(); |
519 break; | 513 break; |
520 case 'bookmarks': | 514 case 'bookmarks': |
521 this.bookmarks_ = message.data.bookmarks; | 515 this.bookmarks_ = message.data.bookmarks; |
522 if (this.isMaterial_ && this.bookmarks_.length !== 0) { | 516 if (this.isMaterial_ && this.bookmarks_.length !== 0) { |
523 $('bookmarks-container').bookmarks = this.bookmarks; | 517 $('bookmarks-container').bookmarks = this.bookmarks; |
524 this.materialToolbar_.hasBookmarks = true; | 518 this.materialToolbar_.hasBookmarks = true; |
525 } | 519 } |
526 break; | 520 break; |
| 521 case 'setIsSelecting': |
| 522 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); |
| 523 break; |
527 } | 524 } |
528 }, | 525 }, |
529 | 526 |
530 /** | 527 /** |
531 * @private | 528 * @private |
532 * A callback that's called before the zoom changes. Notify the plugin to stop | 529 * A callback that's called before the zoom changes. Notify the plugin to stop |
533 * reacting to scroll events while zoom is taking place to avoid flickering. | 530 * reacting to scroll events while zoom is taking place to avoid flickering. |
534 */ | 531 */ |
535 beforeZoom_: function() { | 532 beforeZoom_: function() { |
536 this.plugin_.postMessage({ | 533 this.plugin_.postMessage({ |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 * Each bookmark is an Object containing a: | 762 * Each bookmark is an Object containing a: |
766 * - title | 763 * - title |
767 * - page (optional) | 764 * - page (optional) |
768 * - array of children (themselves bookmarks) | 765 * - array of children (themselves bookmarks) |
769 * @type {Array} the top-level bookmarks of the PDF. | 766 * @type {Array} the top-level bookmarks of the PDF. |
770 */ | 767 */ |
771 get bookmarks() { | 768 get bookmarks() { |
772 return this.bookmarks_; | 769 return this.bookmarks_; |
773 } | 770 } |
774 }; | 771 }; |
OLD | NEW |