Bug 1362542 - Avoid flusing layout when updating tabs' visiblity status for the overflow menu. r?florian
MozReview-Commit-ID: CuqI1gXcg0i
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -7522,41 +7522,44 @@
<body><![CDATA[
switch (aEvent.type) {
case "TabAttrModified":
this._tabOnAttrModified(aEvent);
break;
case "TabClose":
this._tabOnTabClose(aEvent);
break;
- case "scroll":
- this._updateTabsVisibilityStatus();
- break;
}
]]></body>
</method>
<method name="_updateTabsVisibilityStatus">
<body><![CDATA[
var tabContainer = gBrowser.tabContainer;
// We don't want menu item decoration unless there is overflow.
- if (tabContainer.getAttribute("overflow") != "true")
+ if (tabContainer.getAttribute("overflow") != "true") {
return;
-
- var tabstripBO = tabContainer.mTabstrip.scrollBoxObject;
- for (var i = 0; i < this.childNodes.length; i++) {
- let curTab = this.childNodes[i].tab;
- if (!curTab) // "Undo close tab", menuseparator, or entries put here by addons.
+ }
+
+ let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ let tabstripRect = windowUtils.getBoundsWithoutFlushing(tabContainer.mTabstrip);
+ for (let menuitem of this.childNodes) {
+ let curTab = menuitem.tab;
+ if (!curTab) {
+ // "Undo close tab", menuseparator, or entries put here by addons.
continue;
- let curTabBO = curTab.boxObject;
- if (curTabBO.screenX >= tabstripBO.screenX &&
- curTabBO.screenX + curTabBO.width <= tabstripBO.screenX + tabstripBO.width)
- this.childNodes[i].setAttribute("tabIsVisible", "true");
- else
- this.childNodes[i].removeAttribute("tabIsVisible");
+ }
+ let curTabRect = windowUtils.getBoundsWithoutFlushing(curTab);
+ if (curTabRect.left >= tabstripRect.left &&
+ curTabRect.right <= tabstripRect.right) {
+ menuitem.setAttribute("tabIsVisible", "true");
+ } else {
+ menuitem.removeAttribute("tabIsVisible");
+ }
}
]]></body>
</method>
<method name="_createTabMenuItem">
<parameter name="aTab"/>
<body><![CDATA[
var menuItem = document.createElementNS(
@@ -7645,17 +7648,16 @@
document.getElementById("alltabs_undoCloseTab").disabled =
SessionStore.getClosedTabCount(window) == 0;
var tabcontainer = gBrowser.tabContainer;
// Listen for changes in the tab bar.
tabcontainer.addEventListener("TabAttrModified", this);
tabcontainer.addEventListener("TabClose", this);
- tabcontainer.mTabstrip.addEventListener("scroll", this);
let tabs = gBrowser.visibleTabs;
for (var i = 0; i < tabs.length; i++) {
if (!tabs[i].pinned)
this._createTabMenuItem(tabs[i]);
}
this._updateTabsVisibilityStatus();
}
@@ -7674,17 +7676,16 @@
menuItem.tab.mCorrespondingMenuitem = null;
this.removeChild(menuItem);
}
if (menuItem.hasAttribute("usercontextid")) {
this.removeChild(menuItem);
}
}
var tabcontainer = gBrowser.tabContainer;
- tabcontainer.mTabstrip.removeEventListener("scroll", this);
tabcontainer.removeEventListener("TabAttrModified", this);
tabcontainer.removeEventListener("TabClose", this);
]]></handler>
<handler event="DOMMenuItemActive">
<![CDATA[
var tab = event.target.tab;
if (tab) {