Bug 946335 - Scrollbar on Metro start page is covered by navbar [r=emtwo a=lsblakk]
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 09 Dec 2013 10:20:56 -0800
changeset 175265 e51e3611210aec6d195c2ee3fa69dab990c72667
parent 175264 bab4f38bfe7c4376388b086185b08e28f706429e
child 175266 0e3bd70f2295b0bd0f082f8872945972359f1509
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemtwo, lsblakk
bugs946335
milestone28.0a2
Bug 946335 - Scrollbar on Metro start page is covered by navbar [r=emtwo a=lsblakk]
browser/metro/base/content/browser-ui.js
browser/metro/base/content/browser.js
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -303,27 +303,35 @@ var BrowserUI = {
   },
 
   get isStartTabVisible() {
     return this.isStartURI();
   },
 
   isStartURI: function isStartURI(aURI) {
     aURI = aURI || Browser.selectedBrowser.currentURI.spec;
-    return aURI == kStartURI;
+    return aURI == kStartURI || aURI == "about:home";
   },
 
   updateStartURIAttributes: function (aURI) {
+    let wasStart = Elements.windowState.hasAttribute("startpage");
     aURI = aURI || Browser.selectedBrowser.currentURI.spec;
     if (this.isStartURI(aURI)) {
       ContextUI.displayNavbar();
       Elements.windowState.setAttribute("startpage", "true");
     } else if (aURI != "about:blank") { // about:blank is loaded briefly for new tabs; ignore it
       Elements.windowState.removeAttribute("startpage");
     }
+
+    let isStart = Elements.windowState.hasAttribute("startpage");
+    if (wasStart != isStart) {
+      let event = document.createEvent("Events");
+      event.initEvent("StartUIChange", true, true);
+      Browser.selectedBrowser.dispatchEvent(event);
+    }
   },
 
   getDisplayURI: function(browser) {
     let uri = browser.currentURI;
     let spec = uri.spec;
 
     try {
       spec = gURIFixup.createExposableURI(uri).spec;
--- a/browser/metro/base/content/browser.js
+++ b/browser/metro/base/content/browser.js
@@ -1300,33 +1300,41 @@ Tab.prototype = {
       browser.removeEventListener("pageshow", onPageShowEvent);
       if (self._eventDeferred) {
         self._eventDeferred.resolve(self);
       }
       self._eventDeferred = null;
     }
     browser.addEventListener("pageshow", onPageShowEvent, true);
     browser.addEventListener("DOMWindowCreated", this, false);
+    browser.addEventListener("StartUIChange", this, false);
     Elements.browsers.addEventListener("SizeChanged", this, false);
 
     browser.messageManager.addMessageListener("Content:StateChange", this);
 
     if (aOwner)
       this._copyHistoryFrom(aOwner);
     this._loadUsingParams(browser, aURI, aParams);
   },
 
   updateViewport: function (aEvent) {
     // <meta name=viewport> is not yet supported; just use the browser size.
-    this.browser.setWindowSize(this.browser.clientWidth, this.browser.clientHeight);
+    let browser = this.browser;
+
+    // On the start page we add padding to keep the browser above the navbar.
+    let paddingBottom = parseInt(getComputedStyle(browser).paddingBottom, 10);
+    let height = browser.clientHeight - paddingBottom;
+
+    browser.setWindowSize(browser.clientWidth, height);
   },
 
   handleEvent: function (aEvent) {
     switch (aEvent.type) {
       case "DOMWindowCreated":
+      case "StartUIChange":
         this.updateViewport();
         break;
       case "SizeChanged":
         this.updateViewport();
         this._delayUpdateThumbnail();
         break;
     }
   },
@@ -1349,16 +1357,17 @@ Tab.prototype = {
     this._updateThumbnailTimeout = setTimeout(() => {
       this.updateThumbnail();
     }, kTabThumbnailDelayCapture);
   },
 
   destroy: function destroy() {
     this._browser.messageManager.removeMessageListener("Content:StateChange", this);
     this._browser.removeEventListener("DOMWindowCreated", this, false);
+    this._browser.removeEventListener("StartUIChange", this, false);
     Elements.browsers.removeEventListener("SizeChanged", this, false);
     clearTimeout(this._updateThumbnailTimeout);
 
     Elements.tabList.removeTab(this._chromeTab);
     this._chromeTab = null;
     this._destroyBrowser();
   },