From 1bbf0e55b09e73cf794ff9f0459214e46f208aa2 Mon Sep 17 00:00:00 2001
From: Brendan Dahl <brendan.dahl@gmail.com>
Date: Mon, 25 Nov 2013 14:08:28 -0800
Subject: [PATCH] Fix rotation regression from #3970.

---
 web/page_view.js | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/web/page_view.js b/web/page_view.js
index b4783e7da..be3619c35 100644
--- a/web/page_view.js
+++ b/web/page_view.js
@@ -28,7 +28,7 @@ var PageView = function pageView(container, id, scale,
   this.rotation = 0;
   this.scale = scale || 1.0;
   this.viewport = defaultViewport;
-  this.pdfPageRotate = defaultViewport.rotate;
+  this.pdfPageRotate = defaultViewport.rotation;
 
   this.renderingState = RenderingStates.INITIAL;
   this.resume = null;
@@ -54,19 +54,12 @@ var PageView = function pageView(container, id, scale,
   this.setPdfPage = function pageViewSetPdfPage(pdfPage) {
     this.pdfPage = pdfPage;
     this.pdfPageRotate = pdfPage.rotate;
-    this.updateViewport();
+    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
+    this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS, totalRotation);
     this.stats = pdfPage.stats;
     this.reset();
   };
 
-  this.updateViewport = function pageViewUpdateViewport() {
-    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
-    this.viewport = this.viewport.clone({
-      scale: this.scale * CSS_UNITS,
-      rotation: totalRotation
-    });
-  },
-
   this.destroy = function pageViewDestroy() {
     this.zoomLayer = null;
     this.reset();
@@ -111,7 +104,11 @@ var PageView = function pageView(container, id, scale,
       this.rotation = rotation;
     }
 
-    this.updateViewport();
+    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
+    this.viewport = this.viewport.clone({
+      scale: this.scale * CSS_UNITS,
+      rotation: totalRotation
+    });
 
     if (USE_ONLY_CSS_ZOOM && this.canvas) {
       this.cssTransform(this.canvas);