From 2f4246abe4c0c5405c0b8edb861f92590b117560 Mon Sep 17 00:00:00 2001
From: Yury Delendik <ydelendik@mozilla.com>
Date: Fri, 10 Jan 2014 12:15:09 -0600
Subject: [PATCH] Fixes FitV scrolling

---
 web/page_view.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/web/page_view.js b/web/page_view.js
index d897d21c4..34c7be32a 100644
--- a/web/page_view.js
+++ b/web/page_view.js
@@ -336,6 +336,11 @@ var PageView = function pageView(container, id, scale,
 
     var x = 0, y = 0;
     var width = 0, height = 0, widthScale, heightScale;
+    var changeOrientation = !!(this.rotation % 180);
+    var pageWidth = (changeOrientation ? this.height : this.width) /
+      this.scale / CSS_UNITS;
+    var pageHeight = (changeOrientation ? this.width : this.height) /
+      this.scale / CSS_UNITS;
     var scale = 0;
     switch (dest[1].name) {
       case 'XYZ':
@@ -347,7 +352,7 @@ var PageView = function pageView(container, id, scale,
         // since aligning the bottom of the intended page with the
         // top of the window is rarely helpful).
         x = x !== null ? x : 0;
-        y = y !== null ? y : (this.height / this.scale) / CSS_UNITS;
+        y = y !== null ? y : pageHeight;
         break;
       case 'Fit':
       case 'FitB':
@@ -361,6 +366,8 @@ var PageView = function pageView(container, id, scale,
       case 'FitV':
       case 'FitBV':
         x = dest[2];
+        width = pageWidth;
+        height = pageHeight;
         scale = 'page-height';
         break;
       case 'FitR':