Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1444)

Unified Diff: chrome/browser/resources/pdf/viewport.js

Issue 475933004: OOP PDF - Update zoom factor to fall within range (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/viewport.js
diff --git a/chrome/browser/resources/pdf/viewport.js b/chrome/browser/resources/pdf/viewport.js
index b42206c77a74dc84fe9092b2931eaf062933e7b3..7a225da2043546ef105544d78f385bb0c865ea54 100644
--- a/chrome/browser/resources/pdf/viewport.js
+++ b/chrome/browser/resources/pdf/viewport.js
@@ -77,6 +77,14 @@ Viewport.ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1,
1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5];
/**
+ * The minimum and maximum range to be used to clip zoom factor.
+ */
+Viewport.ZOOM_FACTOR_RANGE = {
+ min: Viewport.ZOOM_FACTORS[0],
+ max: Viewport.ZOOM_FACTORS[Viewport.ZOOM_FACTORS.length - 1]
+};
+
+/**
* The width of the page shadow around pages in pixels.
*/
Viewport.PAGE_SHADOW = {top: 3, bottom: 7, left: 5, right: 5};
@@ -231,6 +239,8 @@ Viewport.prototype = {
* @param {number} newZoom the zoom level to zoom to.
*/
setZoom: function(newZoom) {
+ newZoom = Math.max(Viewport.ZOOM_FACTOR_RANGE.min,
+ Math.min(newZoom, Viewport.ZOOM_FACTOR_RANGE.max));
this.mightZoom_(function() {
this.setZoomInternal_(newZoom);
this.updateViewport_();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698