Index: chrome/browser/resources/pdf/viewport.js |
diff --git a/chrome/browser/resources/pdf/viewport.js b/chrome/browser/resources/pdf/viewport.js |
index 77e715e0888985e6b9e90366ad5cbd86a8520a23..418ad44071df99f1c4f585d3ed862399e4f6977e 100644 |
--- a/chrome/browser/resources/pdf/viewport.js |
+++ b/chrome/browser/resources/pdf/viewport.js |
@@ -206,9 +206,11 @@ Viewport.prototype = { |
* Sets the zoom of the viewport. |
* @param {number} newZoom the zoom level to zoom to. |
*/ |
- setZoom_: function(newZoom) { |
- if (!this.allowedToChangeZoom_) |
- throw 'Called Viewport.setZoom_ without calling Viewport.mightZoom_.'; |
+ setZoomInternal_: function(newZoom) { |
+ if (!this.allowedToChangeZoom_) { |
+ throw 'Called Viewport.setZoomInternal_ without calling ' + |
+ 'Viewport.mightZoom_.'; |
+ } |
var oldZoom = this.zoom_; |
this.zoom_ = newZoom; |
// Record the scroll position (relative to the middle of the window). |
@@ -224,12 +226,13 @@ Viewport.prototype = { |
}, |
/** |
- * @private |
- * Sets the zoom for testing purposes. |
+ * Sets the zoom to the given zoom level. |
+ * @param {number} newZoom the zoom level to zoom to. |
*/ |
- setZoomForTest_: function(newZoom) { |
+ setZoom: function(newZoom) { |
this.mightZoom_(function() { |
- this.setZoom_(newZoom); |
+ this.setZoomInternal_(newZoom); |
+ this.updateViewport_(); |
}.bind(this)); |
}, |
@@ -381,7 +384,8 @@ Viewport.prototype = { |
var oldY = this.window_.pageYOffset / this.zoom_; |
// When computing fit-to-width, the maximum width of a page in the |
// document is used, which is equal to the size of the document width. |
- this.setZoom_(this.computeFittingZoom_(this.documentDimensions_, true)); |
+ this.setZoomInternal_(this.computeFittingZoom_(this.documentDimensions_, |
+ true)); |
var page = this.getMostVisiblePage(); |
this.window_.scrollTo(0, oldY * this.zoom_); |
this.updateViewport_(); |
@@ -398,7 +402,7 @@ Viewport.prototype = { |
if (!this.documentDimensions_) |
return; |
var page = this.getMostVisiblePage(); |
- this.setZoom_(this.computeFittingZoom_( |
+ this.setZoomInternal_(this.computeFittingZoom_( |
this.pageDimensions_[page], false)); |
// Center the document in the page by scrolling by the amount of empty |
// space to the left of the document. |
@@ -422,7 +426,7 @@ Viewport.prototype = { |
if (Viewport.ZOOM_FACTORS[i] < this.zoom_) |
nextZoom = Viewport.ZOOM_FACTORS[i]; |
} |
- this.setZoom_(nextZoom); |
+ this.setZoomInternal_(nextZoom); |
this.updateViewport_(); |
}.bind(this)); |
}, |
@@ -438,7 +442,7 @@ Viewport.prototype = { |
if (Viewport.ZOOM_FACTORS[i] > this.zoom_) |
nextZoom = Viewport.ZOOM_FACTORS[i]; |
} |
- this.setZoom_(nextZoom); |
+ this.setZoomInternal_(nextZoom); |
this.updateViewport_(); |
}.bind(this)); |
}, |
@@ -472,9 +476,10 @@ Viewport.prototype = { |
this.documentDimensions_ = documentDimensions; |
this.pageDimensions_ = this.documentDimensions_.pageDimensions; |
if (initialDimensions) { |
- this.setZoom_(this.computeFittingZoom_(this.documentDimensions_, true)); |
+ this.setZoomInternal_(this.computeFittingZoom_(this.documentDimensions_, |
+ true)); |
if (this.zoom_ > 1) |
- this.setZoom_(1); |
+ this.setZoomInternal_(1); |
this.window_.scrollTo(0, 0); |
} |
this.contentSizeChanged_(); |