Commit 4271e16b authored by n.bansal@samsung.com's avatar n.bansal@samsung.com

OOP PDF - Update zoom factor to fall within range

Currently setZoom() doesn't check whether zoom factor provided
falls within range or not. It is possible to pass big zoom level
through 'zoom' open pdf parameter which can make browser unresponsive.

This patch updates the zoom factor provided in setZoom() to fall
within range.

BUG=303491

Review URL: https://codereview.chromium.org/475933004

Cr-Commit-Position: refs/heads/master@{#291387}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291387 0039d316-1c4b-4281-b951-d872f2087c98
parent ce66a65c
...@@ -76,6 +76,14 @@ Viewport.SCROLL_INCREMENT = 40; ...@@ -76,6 +76,14 @@ Viewport.SCROLL_INCREMENT = 40;
Viewport.ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1, 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]; 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. * The width of the page shadow around pages in pixels.
*/ */
...@@ -231,6 +239,8 @@ Viewport.prototype = { ...@@ -231,6 +239,8 @@ Viewport.prototype = {
* @param {number} newZoom the zoom level to zoom to. * @param {number} newZoom the zoom level to zoom to.
*/ */
setZoom: function(newZoom) { setZoom: function(newZoom) {
newZoom = Math.max(Viewport.ZOOM_FACTOR_RANGE.min,
Math.min(newZoom, Viewport.ZOOM_FACTOR_RANGE.max));
this.mightZoom_(function() { this.mightZoom_(function() {
this.setZoomInternal_(newZoom); this.setZoomInternal_(newZoom);
this.updateViewport_(); this.updateViewport_();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment