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