Bug 884492 - run TabsInTitlebar._update when nodes are added/removed in tab/menubar, r=mconley

This commit is contained in:
Gijs Kruitbosch 2013-11-13 21:56:42 +01:00
parent 35947d2cb9
commit e45753dc4a
4 changed files with 49 additions and 1 deletions

View File

@ -4197,6 +4197,17 @@ var TabsInTitlebar = {
this._menuObserver.observe(menu, {attributes: true});
gNavToolbox.addEventListener("customization-transitionend", this);
this.onAreaReset = function(aArea) {
if (aArea == CustomizableUI.AREA_TABSTRIP || aArea == CustomizableUI.AREA_MENUBAR)
this._update(true);
};
this.onWidgetAdded = this.onWidgetRemoved = function(aWidgetId, aArea) {
if (aArea == CustomizableUI.AREA_TABSTRIP || aArea == CustomizableUI.AREA_MENUBAR)
this._update(true);
};
CustomizableUI.addListener(this);
this._initialized = true;
#endif
},
@ -4441,6 +4452,7 @@ var TabsInTitlebar = {
this._initialized = false;
Services.prefs.removeObserver(this._prefName, this);
this._menuObserver.disconnect();
CustomizableUI.removeListener(this);
#endif
}
};

View File

@ -295,6 +295,9 @@ skip-if = true # disabled until the tree view is added
[browser_tab_dragdrop.js]
[browser_tab_dragdrop2.js]
[browser_tab_dragdrop2_frame1.xul]
[browser_tabbar_big_widgets.js]
skip-if = os == "linux" # No tabs in titlebar on linux
[browser_tabfocus.js]
[browser_tabopen_reflows.js]
[browser_tabs_isActive.js]

View File

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const kButtonId = "test-tabbar-size-with-large-buttons";
function test() {
registerCleanupFunction(cleanup);
let titlebar = document.getElementById("titlebar");
let originalHeight = titlebar.getBoundingClientRect().height;
let button = document.createElement("toolbarbutton");
button.id = kButtonId;
button.setAttribute("style", "min-height: 100px");
gNavToolbox.palette.appendChild(button);
CustomizableUI.addWidgetToArea(kButtonId, CustomizableUI.AREA_TABSTRIP);
let currentHeight = titlebar.getBoundingClientRect().height;
ok(currentHeight > originalHeight, "Titlebar should have grown");
CustomizableUI.removeWidgetFromArea(kButtonId);
currentHeight = titlebar.getBoundingClientRect().height;
is(currentHeight, originalHeight, "Titlebar should have gone back to its original size.");
}
function cleanup() {
let btn = document.getElementById(kButtonId);
if (btn) {
btn.remove();
}
}

View File

@ -401,7 +401,7 @@ let CustomizableUIInternal = {
this.insertWidgetBefore(node, currentNode, container, aArea);
if (gResetting) {
this.notifyListeners("onWidgetReset", id);
this.notifyListeners("onWidgetReset", id, aArea);
}
}
@ -450,6 +450,10 @@ let CustomizableUIInternal = {
}
}
if (gResetting) {
this.notifyListeners("onAreaReset", aArea);
}
this.endBatchUpdate();
},