| 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 /** | 5 /** |
| 6 * Predefined zoom factors to be used when zooming in/out. These are in | 6 * Predefined zoom factors to be used when zooming in/out. These are in |
| 7 * ascending order. | 7 * ascending order. |
| 8 */ | 8 */ |
| 9 var ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, | 9 var ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, |
| 10 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0]; | 10 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0]; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 (currentScrollPos[1] * newZoom) - this.window_.innerHeight / 2.0); | 120 (currentScrollPos[1] * newZoom) - this.window_.innerHeight / 2.0); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @private | 124 * @private |
| 125 * Called when the viewport should be updated. | 125 * Called when the viewport should be updated. |
| 126 */ | 126 */ |
| 127 Viewport.prototype.updateViewport_ = function() { | 127 Viewport.prototype.updateViewport_ = function() { |
| 128 // Shift the toolbar so that it doesn't move when the scrollbars display | 128 // Shift the toolbar so that it doesn't move when the scrollbars display |
| 129 var needsScrollbars = this.documentHasScrollbars(); | 129 var needsScrollbars = this.documentHasScrollbars(); |
| 130 var page = this.getMostVisiblePage(); |
| 130 this.viewportChangedCallback_(this.zoom_, | 131 this.viewportChangedCallback_(this.zoom_, |
| 131 this.window_.pageXOffset, | 132 this.window_.pageXOffset, |
| 132 this.window_.pageYOffset, | 133 this.window_.pageYOffset, |
| 133 this.scrollbarWidth_, | 134 this.scrollbarWidth_, |
| 134 needsScrollbars); | 135 needsScrollbars, |
| 136 page); |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 /** | 139 /** |
| 138 * @private | 140 * @private |
| 139 * Returns a rect representing the current viewport. | 141 * Returns a rect representing the current viewport. |
| 140 * @return {dictionary} a rect representing the current viewport. | 142 * @return {dictionary} a rect representing the current viewport. |
| 141 */ | 143 */ |
| 142 Viewport.prototype.getCurrentViewportRect_ = function() { | 144 Viewport.prototype.getCurrentViewportRect_ = function() { |
| 143 return { | 145 return { |
| 144 'x': this.window_.pageXOffset / this.zoom_, | 146 'x': this.window_.pageXOffset / this.zoom_, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 /** | 295 /** |
| 294 * Set the dimensions of the document. | 296 * Set the dimensions of the document. |
| 295 * @param {dictionary} documentDimensions the dimensions of the document | 297 * @param {dictionary} documentDimensions the dimensions of the document |
| 296 */ | 298 */ |
| 297 Viewport.prototype.setDocumentDimensions = function(documentDimensions) { | 299 Viewport.prototype.setDocumentDimensions = function(documentDimensions) { |
| 298 this.documentDimensions_ = documentDimensions; | 300 this.documentDimensions_ = documentDimensions; |
| 299 this.pageDimensions_ = this.documentDimensions_.pageDimensions; | 301 this.pageDimensions_ = this.documentDimensions_.pageDimensions; |
| 300 this.contentSizeChanged_(); | 302 this.contentSizeChanged_(); |
| 301 this.updateViewport_(); | 303 this.updateViewport_(); |
| 302 }; | 304 }; |
| OLD | NEW |