Bug 783605 - DOM full screen should disable social sidebar. r=jaws
authorShane Caraveo <mixedpuppy@gmail.com>
Wed, 03 Oct 2012 16:11:52 -0700
changeset 109313 a05bad13ec397418972b97079a0dd2dcacbf5e15
parent 109312 b287821e8d5f5118a5c5c8e4dab6a0c21ecd01ca
child 109314 d5abea9273a98c97b56ed0177292d59d5e34a298
push id15964
push userjwein@mozilla.com
push dateFri, 05 Oct 2012 03:40:56 +0000
treeherdermozilla-inbound@a05bad13ec39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs783605
milestone18.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 783605 - DOM full screen should disable social sidebar. r=jaws
browser/base/content/browser-social.js
browser/base/content/test/browser_social_sidebar.js
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -13,16 +13,19 @@ let SocialUI = {
     Services.obs.addObserver(this, "social:ambient-notification-changed", false);
     Services.obs.addObserver(this, "social:profile-changed", 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());
+
     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");
     Services.obs.removeObserver(this, "social:profile-changed");
@@ -183,17 +186,17 @@ let SocialChatBar = {
   },
   // Whether the chats can be shown for this window.
   get canShow() {
     if (!SocialUI.haveLoggedInUser())
       return false;
     let docElem = document.documentElement;
     let chromeless = docElem.getAttribute("disablechrome") ||
                      docElem.getAttribute("chromehidden").indexOf("extrachrome") >= 0;
-    return Social.uiVisible && !chromeless;
+    return Social.uiVisible && !chromeless && !document.mozFullScreen;
   },
   openChat: function(aProvider, aURL, aCallback, aMode) {
     if (this.canShow)
       this.chatbar.openChat(aProvider, aURL, aCallback, aMode);
   },
   update: function() {
     if (!this.canShow)
       this.chatbar.removeAll();
@@ -748,35 +751,35 @@ var SocialSidebar = {
   // the sidebar in these windows.
   get chromeless() {
     let docElem = document.documentElement;
     return docElem.getAttribute('disablechrome') ||
            docElem.getAttribute('chromehidden').contains("toolbar");
   },
 
   // Whether the user has toggled the sidebar on (for windows where it can appear)
-  get enabled() {
-    return Services.prefs.getBoolPref("social.sidebar.open");
+  get opened() {
+    return Services.prefs.getBoolPref("social.sidebar.open") && !document.mozFullScreen;
   },
 
   dispatchEvent: function(aType, aDetail) {
     let sbrowser = document.getElementById("social-sidebar-browser");
     let evt = sbrowser.contentDocument.createEvent("CustomEvent");
     evt.initCustomEvent(aType, true, true, aDetail ? aDetail : {});
     sbrowser.contentDocument.documentElement.dispatchEvent(evt);
   },
 
   updateSidebar: function SocialSidebar_updateSidebar() {
     // Hide the toggle menu item if the sidebar cannot appear
     let command = document.getElementById("Social:ToggleSidebar");
     command.hidden = !this.canShow;
 
     // Hide the sidebar if it cannot appear, or has been toggled off.
     // Also set the command "checked" state accordingly.
-    let hideSidebar = !this.canShow || !this.enabled;
+    let hideSidebar = !this.canShow || !this.opened;
     let broadcaster = document.getElementById("socialSidebarBroadcaster");
     broadcaster.hidden = hideSidebar;
     command.setAttribute("checked", !hideSidebar);
 
     let sbrowser = document.getElementById("social-sidebar-browser");
     sbrowser.docShell.isActive = !hideSidebar;
     if (hideSidebar) {
       this.dispatchEvent("socialFrameHide");
--- a/browser/base/content/test/browser_social_sidebar.js
+++ b/browser/base/content/test/browser_social_sidebar.js
@@ -12,17 +12,17 @@ function test() {
     workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js",
     iconURL: "chrome://branding/content/icon48.png"
   };
   runSocialTestWithProvider(manifest, doTest);
 }
 
 function doTest(finishcb) {
   ok(SocialSidebar.canShow, "social sidebar should be able to be shown");
-  ok(SocialSidebar.enabled, "social sidebar should be on by default");
+  ok(SocialSidebar.opened, "social sidebar should be open by default");
 
   let command = document.getElementById("Social:ToggleSidebar");
   let sidebar = document.getElementById("social-sidebar-box");
   let browser = sidebar.firstChild;
 
   function checkShown(shouldBeShown) {
     is(command.getAttribute("checked"), shouldBeShown ? "true" : "false",
        "toggle command should be " + (shouldBeShown ? "checked" : "unchecked"));