From ada3f333754771da8fdff6c4d0378fab971a1791 Mon Sep 17 00:00:00 2001
From: Julian Viereck <julian.viereck@gmail.com>
Date: Thu, 19 Jan 2012 19:25:29 +0100
Subject: [PATCH 1/4] Replace some setScale by parseScale calls to update 
 value

---
 web/viewer.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/web/viewer.js b/web/viewer.js
index ac3fbff0c..5da8b8314 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -203,12 +203,12 @@ var PDFView = {
 
   zoomIn: function pdfViewZoomIn() {
     var newScale = Math.min(kMaxScale, this.currentScale * kDefaultScaleDelta);
-    this.setScale(newScale, true);
+    this.parseScale(newScale, true);
   },
 
   zoomOut: function pdfViewZoomOut() {
     var newScale = Math.max(kMinScale, this.currentScale / kDefaultScaleDelta);
-    this.setScale(newScale, true);
+    this.parseScale(newScale, true);
   },
 
   set page(val) {
@@ -1234,7 +1234,7 @@ window.addEventListener('keydown', function keydown(evt) {
       handled = true;
       break;
     case 48: // '0'
-      PDFView.setScale(kDefaultScale, true);
+      PDFView.parseScale(kDefaultScale, true);
       handled = true;
       break;
     case 37: // left arrow

From 19622406da911244d88ca15a073c185d0d83612d Mon Sep 17 00:00:00 2001
From: Jeff Wagner <jwagner@gmail.com>
Date: Tue, 24 Jan 2012 12:19:52 -0800
Subject: [PATCH 2/4] define console for IE9 when debugging tools is not opened

---
 web/compatibility.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/web/compatibility.js b/web/compatibility.js
index 26405ad8f..7addbe3e2 100644
--- a/web/compatibility.js
+++ b/web/compatibility.js
@@ -224,3 +224,10 @@
     }
   });
 })();
+
+//IE9 console
+(function checkConsoleCompatibility() {
+  if (typeof console == "undefined") {
+    console = {log: function() {}};
+  }
+})();

From 08f8aed5215d4ba861d4675f91aabb9bffa5997f Mon Sep 17 00:00:00 2001
From: Jeff Wagner <jwagner@gmail.com>
Date: Tue, 24 Jan 2012 14:19:41 -0800
Subject: [PATCH 3/4] define console for IE9; updated to fix lint errors and
 comment

---
 web/compatibility.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/web/compatibility.js b/web/compatibility.js
index 7addbe3e2..b22153516 100644
--- a/web/compatibility.js
+++ b/web/compatibility.js
@@ -225,9 +225,9 @@
   });
 })();
 
-//IE9 console
+// Check console compatability
 (function checkConsoleCompatibility() {
-  if (typeof console == "undefined") {
+  if (typeof console == 'undefined') {
     console = {log: function() {}};
   }
 })();

From 2b2e4b19abf2fc5728cf5551455174b8dbb60e22 Mon Sep 17 00:00:00 2001
From: notmasteryet <async.processingjs@yahoo.com>
Date: Wed, 25 Jan 2012 21:52:10 -0600
Subject: [PATCH 4/4] Fixing initial scale when named destination is specified

---
 web/viewer.js | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/web/viewer.js b/web/viewer.js
index dcd3f51b6..dd16b0282 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -6,6 +6,7 @@
 var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
 var kDefaultScale = 'auto';
 var kDefaultScaleDelta = 1.1;
+var kUnknownScale = 0;
 var kCacheSize = 20;
 var kCssUnits = 96.0 / 72.0;
 var kScrollbarPadding = 40;
@@ -148,7 +149,7 @@ var currentPageNumber = 1;
 var PDFView = {
   pages: [],
   thumbnails: [],
-  currentScale: 0,
+  currentScale: kUnknownScale,
   currentScaleValue: null,
   initialBookmark: document.location.hash.substring(1),
 
@@ -452,10 +453,16 @@ var PDFView = {
     }
     else if (storedHash)
       this.setHash(storedHash);
-    else {
-      this.parseScale(scale || kDefaultScale, true);
+    else if (scale) {
+      this.parseScale(scale, true);
       this.page = 1;
     }
+
+    if (PDFView.currentScale === kUnknownScale) {
+      // Scale was not initialized: invalid bookmark or scale was not specified.
+      // Setting the default one.
+      this.parseScale(kDefaultScale, true);
+    }
   },
 
   setHash: function pdfViewSetHash(hash) {
@@ -742,6 +749,8 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
 
       if (scale && scale !== PDFView.currentScale)
         PDFView.parseScale(scale, true);
+      else if (PDFView.currentScale === kUnknownScale)
+        PDFView.parseScale(kDefaultScale, true);
 
       setTimeout(function pageViewScrollIntoViewRelayout() {
         // letting page to re-layout before scrolling