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