Bug 807935 - social chatbar should be hidden in full-screen mode. r=jaws
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 13 Nov 2012 14:52:06 +1100
changeset 113055 359b234648375ba78bc4135ef18a314f1a65c310
parent 113054 f60b494448f881a35c5a1d7806bdd2aabb8d436d
child 113056 2e23d71714b4be422335257351615c7d4454396e
push id17915
push usermhammond@skippinet.com.au
push dateTue, 13 Nov 2012 03:54:28 +0000
treeherdermozilla-inbound@359b23464837 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs807935
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 807935 - social chatbar should be hidden in full-screen mode. r=jaws
browser/base/content/browser-social.js
browser/base/content/socialchat.xml
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -15,17 +15,20 @@ let SocialUI = {
     Services.obs.addObserver(this, "social:frameworker-error", false);
 
     Services.prefs.addObserver("social.sidebar.open", this, false);
     Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
 
     gBrowser.addEventListener("ActivateSocialFeature", this._activationEventHandler, true, true);
 
     // Called when we enter DOM full-screen mode.
-    window.addEventListener("mozfullscreenchange", function () SocialSidebar.updateSidebar());
+    window.addEventListener("mozfullscreenchange", function () {
+      SocialSidebar.update();
+      SocialChatBar.update();
+    });
 
     Social.init(this._providerReady.bind(this));
   },
 
   // Called on window unload
   uninit: function SocialUI_uninit() {
     Services.obs.removeObserver(this, "social:pref-changed");
     Services.obs.removeObserver(this, "social:ambient-notification-changed");
@@ -49,17 +52,17 @@ let SocialUI = {
     switch (topic) {
       case "social:pref-changed":
         // Exceptions here sometimes don't get reported properly, report them
         // manually :(
         try {
           this.updateToggleCommand();
           SocialShareButton.updateButtonHiddenState();
           SocialToolbar.updateButtonHiddenState();
-          SocialSidebar.updateSidebar();
+          SocialSidebar.update();
           SocialChatBar.update();
           SocialFlyout.unload();
         } catch (e) {
           Components.utils.reportError(e);
           throw e;
         }
         break;
       case "social:ambient-notification-changed":
@@ -73,17 +76,17 @@ let SocialUI = {
         break;
       case "social:frameworker-error":
         if (Social.provider) {
           Social.errorState = "frameworker-error";
           SocialSidebar.setSidebarErrorMessage("frameworker-error");
         }
         break;
       case "nsPref:changed":
-        SocialSidebar.updateSidebar();
+        SocialSidebar.update();
         SocialToolbar.updateButton();
         SocialMenu.populate();
         break;
     }
   },
 
   get toggleCommand() {
     return document.getElementById("Social:Toggle");
@@ -224,32 +227,36 @@ let SocialUI = {
       Social.active = false;
   }
 }
 
 let SocialChatBar = {
   get chatbar() {
     return document.getElementById("pinnedchats");
   },
-  // Whether the chats can be shown for this window.
-  get canShow() {
+  // Whether the chatbar is available for this window.  Note that in full-screen
+  // mode chats are available, but not shown.
+  get isAvailable() {
     if (!SocialUI.haveLoggedInUser())
       return false;
     let docElem = document.documentElement;
     let chromeless = docElem.getAttribute("disablechrome") ||
                      docElem.getAttribute("chromehidden").indexOf("extrachrome") >= 0;
-    return Social.uiVisible && !chromeless && !document.mozFullScreen;
+    return Social.uiVisible && !chromeless;
   },
   openChat: function(aProvider, aURL, aCallback, aMode) {
-    if (this.canShow)
+    if (this.isAvailable)
       this.chatbar.openChat(aProvider, aURL, aCallback, aMode);
   },
   update: function() {
-    if (!this.canShow)
+    if (!this.isAvailable)
       this.chatbar.removeAll();
+    else {
+      this.chatbar.hidden = document.mozFullScreen;
+    }
   },
   focus: function SocialChatBar_focus() {
     let commandDispatcher = gBrowser.ownerDocument.commandDispatcher;
     commandDispatcher.advanceFocusIntoSubtree(this.chatbar);
   }
 }
 
 function sizeSocialPanelToContent(panel, iframe) {
@@ -938,17 +945,17 @@ var SocialToolbar = {
 }
 
 var SocialSidebar = {
   // Called once, after window load, when the Social.provider object is initialized
   init: function SocialSidebar_init() {
     let sbrowser = document.getElementById("social-sidebar-browser");
     this.errorListener = new SocialErrorListener("sidebar");
     this.configureSidebarDocShell(sbrowser.docShell);
-    this.updateSidebar();
+    this.update();
   },
 
   configureSidebarDocShell: function SocialSidebar_configureDocShell(aDocShell) {
     // setting isAppTab causes clicks on untargeted links to open new tabs
     aDocShell.isAppTab = true;
     aDocShell.QueryInterface(Ci.nsIWebProgress)
              .addProgressListener(SocialSidebar.errorListener,
                                   Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
@@ -976,17 +983,17 @@ var SocialSidebar = {
   setSidebarVisibilityState: function(aEnabled) {
     let sbrowser = document.getElementById("social-sidebar-browser");
     sbrowser.docShell.isActive = aEnabled;
     let evt = sbrowser.contentDocument.createEvent("CustomEvent");
     evt.initCustomEvent(aEnabled ? "socialFrameShow" : "socialFrameHide", true, true, {});
     sbrowser.contentDocument.documentElement.dispatchEvent(evt);
   },
 
-  updateSidebar: function SocialSidebar_updateSidebar() {
+  update: function SocialSidebar_update() {
     clearTimeout(this._unloadTimeoutId);
     // Hide the toggle menu item if the sidebar cannot appear
     let command = document.getElementById("Social:ToggleSidebar");
     command.setAttribute("hidden", this.canShow ? "false" : "true");
 
     // Hide the sidebar if it cannot appear, or has been toggled off.
     // Also set the command "checked" state accordingly.
     let hideSidebar = !this.canShow || !this.opened;
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -45,27 +45,16 @@
 
           // let the chat frame know if it is being shown or hidden
           let evt = this.iframe.contentDocument.createEvent("CustomEvent");
           evt.initCustomEvent(val ? "socialFrameShow" : "socialFrameHide", true, true, {});
           this.iframe.contentDocument.documentElement.dispatchEvent(evt);
         </setter>
       </property>
 
-      <method name="init">
-        <parameter name="aProvider"/>
-        <parameter name="aURL"/>
-        <parameter name="aCallback"/>
-        <body><![CDATA[
-          this._callback = aCallback;
-          this.setAttribute("origin", aProvider.origin);
-          this.setAttribute("src", aURL);
-        ]]></body>
-      </method>
-
       <method name="close">
         <body><![CDATA[
           this.parentNode.remove(this);
         ]]></body>
       </method>
 
       <method name="toggle">
         <body><![CDATA[
@@ -371,17 +360,19 @@
             }
             this.chatboxForURL.delete(aURL);
           }
           cb = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "chatbox");
           if (aMode == "minimized")
             cb.setAttribute("minimized", "true");
           this.selectedChat = cb;
           this.insertBefore(cb, this.firstChild);
-          cb.init(aProvider, aURL, aCallback);
+          cb._callback = aCallback;
+          cb.setAttribute("origin", aProvider.origin);
+          cb.setAttribute("src", aURL);
           this.chatboxForURL.set(aURL, Cu.getWeakReference(cb));
           this.resize();
         ]]></body>
       </method>
 
       <method name="resize">
         <body><![CDATA[
         // Checks the current size against the collapsed state of children