From a6eb66c21627719a7de61aca57211ef7cfcee2e1 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Sun, 8 Nov 2015 22:50:39 +0900 Subject: [PATCH] Activate "draw in titlebar" when the menubar is permanently shown #893 Because the special binding chrome://browser/content/customizableui/toolbar.xml#toolbar-drag works only when the "chromemargin" attribute is specified for the root element like "0,2,2,2". In other words, draggable UI elements don't work as expected for regular window. --- modules/window.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/window.js b/modules/window.js index 1cda1740..8d005a47 100644 --- a/modules/window.js +++ b/modules/window.js @@ -424,6 +424,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { this.fullscreenObserver = new FullscreenObserver(this.window); this.initUIShowHideObserver(); + this.initMenubarShowHideObserver(); var appcontent = d.getElementById('appcontent'); appcontent.addEventListener('SubBrowserAdded', this, false); @@ -519,6 +520,19 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { if (socialBox) this.socialBoxObserver = new BrowserUIShowHideObserver(this, socialBox); }, + + initMenubarShowHideObserver : function TSTWindow_initMenubarShowHideObserver() + { + var w = this.window; + var MutationObserver = w.MutationObserver || w.MozMutationObserver; + this.menubarShowHideObserver = new MutationObserver((function(aMutations, aObserver) { + this.updateTabsInTitlebar(); + }).bind(this)); + this.menubarShowHideObserver.observe(w.document.getElementById('toolbar-menubar'), { + attributes : true, + attributeFilter : ['autohide'] + }); + }, destroy : function TSTWindow_destroy() { @@ -578,6 +592,11 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { delete this.socialBoxObserver; } + if (this.menubarShowHideObserver) { + this.menubarShowHideObserver.disconnect(); + delete this.menubarShowHideObserver; + } + for (let i = 0, maxi = this._tabFocusAllowance.length; i < maxi; i++) { w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this._tabFocusAllowance[i], false); @@ -1143,7 +1162,11 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { try { if (TabsInTitlebar) { - let allowed = isTopTabbar && this.browser.treeStyleTab.fixed; + let menubar = this.window.document.getElementById('toolbar-menubar'); + let allowed = ( + (isTopTabbar && this.browser.treeStyleTab.fixed) || + menubar.getAttribute('autohide') !== 'true' + ); if ( (this.window.TabsOnBottom && utils.getTreePref('compatibility.TabsOnBottom')) || ('navbarontop' in this.window && utils.getTreePref('compatibility.NavbarOnTitlebar')) ||