Bug 595403 - Can't scroll up after orientation change or resize [r=mbrubeck]
authorBenjamin Stover <bstover@mozilla.com>
Fri, 17 Sep 2010 15:54:38 -0700
changeset 66672 de42cf736b90f437c81d5f9425d8846fb98dfee5
parent 66671 5d28f0c0395e069f42026324579c03028938afca
child 66673 a1077a9ece752bab9f59144121d7c4a193727b58
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs595403
Bug 595403 - Can't scroll up after orientation change or resize [r=mbrubeck]
mobile/chrome/content/bindings/browser.xml
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/chrome/content/bindings/browser.xml
@@ -144,16 +144,18 @@
                   this._searchEngines.push({ title: link.title, href: link.href });
                   break;
               }
               break;
 
             case "MozScrolledAreaChanged":
               this._contentDocumentWidth = aMessage.json.width;
               this._contentDocumentHeight = aMessage.json.height;
+              // Recalculate whether the visible area is actually in bounds
+              this.scrollBy(0, 0);
               this._updateCacheViewport();
               break;
          }
         ]]></body>
       </method>
 
       <method name="_getLinkType">
         <parameter name="aLink" />
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -244,16 +244,24 @@ var Browser = {
       BrowserUI.sizeControls(w, h);
 
       // XXX this should really only happen on browser startup, not every resize
       Browser.hideSidebars();
 
       for (let i = Browser.tabs.length - 1; i >= 0; i--)
         Browser.tabs[i].updateViewportSize();
 
+      // XXX page scrollbox jumps to a strange value on resize. Scrolling it will
+      // bound it to a sane place, but not where we were when the resize began :(
+      Browser.hideTitlebar();
+
+      // XXX Hack. Browser also behaves badly on resize.
+      getBrowser().style.display = "none";
+      getBrowser().style.display = "block";
+
       let curEl = document.activeElement;
       if (curEl && curEl.scrollIntoView)
         curEl.scrollIntoView(false);
     }
     window.addEventListener("resize", resizeHandler, false);
 
     function fullscreenHandler() {
       if (!window.fullScreen)
@@ -1079,17 +1087,17 @@ Browser.MainDragger.prototype = {
     let x = 0, y = 0, rect;
 
     rect = Rect.fromRect(Browser.pageScrollbox.getBoundingClientRect()).map(Math.round);
     if (doffset.x < 0 && rect.right < window.innerWidth)
       x = Math.max(doffset.x, rect.right - window.innerWidth);
     if (doffset.x > 0 && rect.left > 0)
       x = Math.min(doffset.x, rect.left);
 
-    let height = document.getElementById("tile-stack").getBoundingClientRect().height;
+    let height = document.getElementById("content-viewport").getBoundingClientRect().height;
     rect = Rect.fromRect(Browser.contentScrollbox.getBoundingClientRect()).map(Math.round);
     if (doffset.y < 0 && rect.bottom < height)
       y = Math.max(doffset.y, rect.bottom - height);
     if (doffset.y > 0 && rect.top > 0)
       y = Math.min(doffset.y, rect.top);
 
     doffset.subtract(x, y);
     return new Point(x, y);