Bug 598391 - Hide browser chrome on scroll events [r=stechz]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 23 Sep 2010 12:16:52 -0700
changeset 2057 53e27f03c0bc61a4a79ac53026f94adaa280d0bb
parent 2056 f013636c46bdd29683c0d2cf6164a46194173de7
child 2058 81c0b2569f9e2056a98e922b137772e106e013e1
push id1741
push usermbrubeck@mozilla.com
push dateThu, 23 Sep 2010 19:17:36 +0000
reviewersstechz
bugs598391
Bug 598391 - Hide browser chrome on scroll events [r=stechz]
chrome/content/browser.js
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -337,16 +337,17 @@ var Browser = {
       }
       Services.prefs.clearUserPref("extensions.disabledAddons");
     }
 
     messageManager.addMessageListener("Browser:ViewportMetadata", this);
     messageManager.addMessageListener("Browser:FormSubmit", this);
     messageManager.addMessageListener("Browser:KeyPress", this);
     messageManager.addMessageListener("Browser:ZoomToPoint:Return", this);
+    messageManager.addMessageListener("scroll", this);
     messageManager.addMessageListener("Browser:MozApplicationManifest", OfflineApps);
 
     // broadcast a UIReady message so add-ons know we are finished with startup
     let event = document.createEvent("Events");
     event.initEvent("UIReady", true, false);
     window.dispatchEvent(event);
   },
 
@@ -1009,27 +1010,28 @@ var Browser = {
   },
 
   forceChromeReflow: function forceChromeReflow() {
     let dummy = getComputedStyle(document.documentElement, "").width;
   },
 
   receiveMessage: function receiveMessage(aMessage) {
     let json = aMessage.json;
+    let browser = aMessage.target;
+
     switch (aMessage.name) {
       case "Browser:ViewportMetadata":
-        let tab = Browser.getTabForBrowser(aMessage.target);
+        let tab = Browser.getTabForBrowser(browser);
         // Some browser such as iframes loaded dynamically into the chrome UI
         // does not have any assigned tab
         if (tab)
           tab.updateViewportMetadata(json);
         break;
 
       case "Browser:FormSubmit":
-        let browser = aMessage.target;
         browser.lastLocation = null;
         break;
 
       case "Browser:KeyPress":
         let event = document.createEvent("KeyEvents");
         event.initKeyEvent("keypress", true, true, null,
                         json.ctrlKey, json.altKey, json.shiftKey, json.metaKey,
                         json.keyCode, json.charCode)
@@ -1037,16 +1039,23 @@ var Browser = {
         break;
 
       case "Browser:ZoomToPoint:Return":
         // JSON-ified rect needs to be recreated so the methods exist
         let rect = Rect.fromRect(json.rect);
         if (!Browser.zoomToPoint(json.x, json.y, rect))
           Browser.zoomFromPoint(json.x, json.y);
         break;
+
+      case "scroll":
+        if (browser == this.selectedBrowser) {
+          Browser.hideTitlebar();
+          Browser.hideSidebars();
+        }
+        break;
     }
   }
 };
 
 
 Browser.MainDragger = function MainDragger() {
 };