Bug 1415537 - Rename mTabstrip to arrowScrollbox. r?florian
MozReview-Commit-ID: IcGH5npSsrg
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -3351,17 +3351,17 @@
this._windowIsClosing = true;
while (this._removingTabs.length)
this._endRemoveTab(this._removingTabs[0]);
} else if (!this._windowIsClosing) {
if (aNewTab)
focusAndSelectUrlBar();
// workaround for bug 345399
- this.tabContainer.mTabstrip._updateScrollButtonsDisabledState();
+ this.tabContainer.arrowScrollbox._updateScrollButtonsDisabledState();
}
// We're going to remove the tab and the browser now.
this._tabFilters.delete(aTab);
this._tabListeners.delete(aTab);
var browser = this.getBrowserForTab(aTab);
@@ -6435,17 +6435,17 @@
<field name="tabbox" readonly="true">
this.tabbrowser.mTabBox;
</field>
<field name="contextMenu" readonly="true">
document.getElementById("tabContextMenu");
</field>
- <field name="mTabstrip">
+ <field name="arrowScrollbox">
document.getAnonymousElementByAttribute(this, "anonid", "arrowscrollbox");
</field>
<field name="_firstTab">null</field>
<field name="_lastTab">null</field>
<field name="_beforeSelectedTab">null</field>
<field name="_beforeHoveredTab">null</field>
<field name="_afterHoveredTab">null</field>
@@ -6474,33 +6474,33 @@
let {restoreTabsButton, restoreTabsButtonWrapperWidth, windowUtils} = this;
let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
if (!restoreTabsButtonWrapper.getAttribute("session-exists")) {
restoreTabsButtonWrapper.removeAttribute("shown");
return;
}
- let tabstripWidth = this.mTabstrip.clientWidth;
+ let arrowScrollboxWidth = this.arrowScrollbox.clientWidth;
let newTabButton = document.getAnonymousElementByAttribute(
this, "anonid", "tabs-newtab-button");
// If there are no pinned tabs it will multiply by 0 and result in 0
let pinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.firstChild).width * this._lastNumPinned;
let numUnpinnedTabs = this.childNodes.length - this._lastNumPinned;
let unpinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.lastChild).width * numUnpinnedTabs;
let tabbarUsedSpace = pinnedTabsWidth + unpinnedTabsWidth
+ windowUtils.getBoundsWithoutFlushing(newTabButton).width;
// Subtract the elements' widths from the available space to ensure
// that showing the restoreTabsButton won't cause any overflow.
- if (tabstripWidth - tabbarUsedSpace > restoreTabsButtonWrapperWidth) {
+ if (arrowScrollboxWidth - tabbarUsedSpace > restoreTabsButtonWrapperWidth) {
restoreTabsButtonWrapper.setAttribute("shown", "true");
} else {
restoreTabsButtonWrapper.removeAttribute("shown");
}
]]></body>
</method>
<method name="observe">
@@ -6715,17 +6715,17 @@
});
]]></body>
</method>
<method name="_handleTabSelect">
<parameter name="aInstant"/>
<body><![CDATA[
if (this.getAttribute("overflow") == "true")
- this.mTabstrip.ensureElementIsVisible(this.selectedItem, aInstant);
+ this.arrowScrollbox.ensureElementIsVisible(this.selectedItem, aInstant);
this.selectedItem._notselectedsinceload = false;
]]></body>
</method>
<field name="_closingTabsSpacer">
document.getAnonymousElementByAttribute(this, "anonid", "closing-tabs-spacer");
</field>
@@ -6748,17 +6748,17 @@
if (!this._tabDefaultMaxWidth)
this._tabDefaultMaxWidth =
parseFloat(window.getComputedStyle(aTab).maxWidth);
this._lastTabClosedByMouse = true;
if (this.getAttribute("overflow") == "true") {
// Don't need to do anything if we're in overflow mode and aren't scrolled
// all the way to the right, or if we're closing the last tab.
- if (isEndTab || !this.mTabstrip._scrollButtonDown.disabled)
+ if (isEndTab || !this.arrowScrollbox._scrollButtonDown.disabled)
return;
// If the tab has an owner that will become the active tab, the owner will
// be to the left of it, so we actually want the left tab to slide over.
// This can't be done as easily in non-overflow mode, so we don't bother.
if (aTab.owner)
return;
@@ -6833,20 +6833,20 @@
var doPosition = this.getAttribute("overflow") == "true" &&
numPinned > 0;
if (doPosition) {
this.setAttribute("positionpinnedtabs", "true");
let layoutData = this._pinnedTabsLayoutCache;
if (!layoutData) {
- let tabstrip = this.mTabstrip;
+ let arrowScrollbox = this.arrowScrollbox;
layoutData = this._pinnedTabsLayoutCache = {
pinnedTabWidth: this.childNodes[0].getBoundingClientRect().width,
- scrollButtonWidth: tabstrip._scrollButtonDown.getBoundingClientRect().width
+ scrollButtonWidth: arrowScrollbox._scrollButtonDown.getBoundingClientRect().width
};
}
let width = 0;
for (let i = numPinned - 1; i >= 0; i--) {
let tab = this.childNodes[i];
width += layoutData.pinnedTabWidth;
tab.style.marginInlineStart = -(width + layoutData.scrollButtonWidth) + "px";
@@ -6903,17 +6903,17 @@
// Move the dragged tab based on the mouse position.
let leftTab = tabs[0];
let rightTab = tabs[tabs.length - 1];
let tabScreenX = draggedTab.boxObject.screenX;
let translateX = screenX - draggedTab._dragData.screenX;
if (!pinned)
- translateX += this.mTabstrip._scrollbox.scrollLeft - draggedTab._dragData.scrollX;
+ translateX += this.arrowScrollbox._scrollbox.scrollLeft - draggedTab._dragData.scrollX;
let leftBound = leftTab.boxObject.screenX - tabScreenX;
let rightBound = (rightTab.boxObject.screenX + rightTab.boxObject.width) -
(tabScreenX + tabWidth);
translateX = Math.max(translateX, leftBound);
translateX = Math.min(translateX, rightBound);
draggedTab.style.transform = "translateX(" + translateX + "px)";
draggedTab._dragData.translateX = translateX;
@@ -7014,50 +7014,50 @@
if (document.getElementById("tabContextMenu").state != "open")
this._unlockTabSizing();
break;
}
]]></body>
</method>
<field name="_animateElement">
- this.mTabstrip._scrollButtonDown;
+ this.arrowScrollbox._scrollButtonDown;
</field>
<method name="_notifyBackgroundTab">
<parameter name="aTab"/>
<body><![CDATA[
if (aTab.pinned || aTab.hidden)
return;
- var scrollRect = this.mTabstrip.scrollClientRect;
+ var scrollRect = this.arrowScrollbox.scrollClientRect;
var tab = aTab.getBoundingClientRect();
// DOMRect left/right properties are immutable.
tab = {left: tab.left, right: tab.right};
// Is the new tab already completely visible?
if (scrollRect.left <= tab.left && tab.right <= scrollRect.right)
return;
- if (this.mTabstrip.smoothScroll) {
+ if (this.arrowScrollbox.smoothScroll) {
let selected = !this.selectedItem.pinned &&
this.selectedItem.getBoundingClientRect();
// Can we make both the new tab and the selected tab completely visible?
if (!selected ||
Math.max(tab.right - selected.left, selected.right - tab.left) <=
scrollRect.width) {
- this.mTabstrip.ensureElementIsVisible(aTab);
+ this.arrowScrollbox.ensureElementIsVisible(aTab);
return;
}
- this.mTabstrip.scrollByPixels(this.mTabstrip._isRTLScrollbox ?
- selected.right - scrollRect.right :
- selected.left - scrollRect.left);
+ this.arrowScrollbox.scrollByPixels(this.arrowScrollbox._isRTLScrollbox ?
+ selected.right - scrollRect.right :
+ selected.left - scrollRect.left);
}
if (!this._animateElement.hasAttribute("highlight")) {
this._animateElement.setAttribute("highlight", "true");
setTimeout(function(ele) {
ele.removeAttribute("highlight");
}, 150, this._animateElement);
}
@@ -7150,17 +7150,17 @@
this._notifyBackgroundTab(tab);
}
// XXXmano: this is a temporary workaround for bug 345399
// We need to manually update the scroll buttons disabled state
// if a tab was inserted to the overflow area or removed from it
// without any scrolling and when the tabbar has already
// overflowed.
- this.mTabstrip._updateScrollButtonsDisabledState();
+ this.arrowScrollbox._updateScrollButtonsDisabledState();
// Preload the next about:newtab if there isn't one already.
this.tabbrowser._createPreloadBrowser();
]]></body>
</method>
<method name="_canAdvanceToTab">
<parameter name="aTab"/>
@@ -7443,17 +7443,17 @@
// relative to the corner of the dragged tab.
function clientX(ele) {
return ele.getBoundingClientRect().left;
}
let tabOffsetX = clientX(tab) - clientX(this);
tab._dragData = {
offsetX: event.screenX - window.screenX - tabOffsetX,
offsetY: event.screenY - window.screenY,
- scrollX: this.mTabstrip._scrollbox.scrollLeft,
+ scrollX: this.arrowScrollbox._scrollbox.scrollLeft,
screenX: event.screenX
};
event.stopPropagation();
]]></handler>
<handler event="dragover"><![CDATA[
var effects = this._getDropEffectForTabDrag(event);
@@ -7461,35 +7461,35 @@
var ind = this._tabDropIndicator;
if (effects == "" || effects == "none") {
ind.collapsed = true;
return;
}
event.preventDefault();
event.stopPropagation();
- var tabStrip = this.mTabstrip;
+ var arrowScrollbox = this.arrowScrollbox;
var ltr = (window.getComputedStyle(this).direction == "ltr");
// autoscroll the tab strip if we drag over the scroll
// buttons, even if we aren't dragging a tab, but then
// return to avoid drawing the drop indicator
var pixelsToScroll = 0;
if (this.getAttribute("overflow") == "true") {
var targetAnonid = event.originalTarget.getAttribute("anonid");
switch (targetAnonid) {
case "scrollbutton-up":
- pixelsToScroll = tabStrip.scrollIncrement * -1;
+ pixelsToScroll = arrowScrollbox.scrollIncrement * -1;
break;
case "scrollbutton-down":
- pixelsToScroll = tabStrip.scrollIncrement;
+ pixelsToScroll = arrowScrollbox.scrollIncrement;
break;
}
if (pixelsToScroll)
- tabStrip.scrollByPixels((ltr ? 1 : -1) * pixelsToScroll, true);
+ arrowScrollbox.scrollByPixels((ltr ? 1 : -1) * pixelsToScroll, true);
}
if (effects == "move" &&
this == event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0).parentNode) {
ind.collapsed = true;
this._animateTabMove(event);
return;
}
@@ -7503,22 +7503,22 @@
this._dragTime = Date.now();
if (Date.now() >= this._dragTime + this._dragOverDelay)
this.selectedItem = tab;
ind.collapsed = true;
return;
}
}
- var rect = tabStrip.getBoundingClientRect();
+ var rect = arrowScrollbox.getBoundingClientRect();
var newMargin;
if (pixelsToScroll) {
// if we are scrolling, put the drop indicator at the edge
// so that it doesn't jump while scrolling
- let scrollRect = tabStrip.scrollClientRect;
+ let scrollRect = arrowScrollbox.scrollClientRect;
let minMargin = scrollRect.left - rect.left;
let maxMargin = Math.min(minMargin + scrollRect.width,
scrollRect.right);
if (!ltr)
[minMargin, maxMargin] = [this.clientWidth - maxMargin,
this.clientWidth - minMargin];
newMargin = (pixelsToScroll > 0) ? maxMargin : minMargin;
} else {
@@ -7666,17 +7666,17 @@
}
// Disable detach within the browser toolbox
var eX = event.screenX;
var eY = event.screenY;
var wX = window.screenX;
// check if the drop point is horizontally within the window
if (eX > wX && eX < (wX + window.outerWidth)) {
- let bo = this.mTabstrip.boxObject;
+ let bo = this.arrowScrollbox.boxObject;
// also avoid detaching if the the tab was dropped too close to
// the tabbar (half a tab)
let endScreenY = bo.screenY + 1.5 * bo.height;
if (eY < endScreenY && eY > window.screenY)
return;
}
// screen.availLeft et. al. only check the screen that this window is on,
@@ -8245,26 +8245,26 @@
var tabContainer = gBrowser.tabContainer;
// We don't want menu item decoration unless there is overflow.
if (tabContainer.getAttribute("overflow") != "true") {
return;
}
let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
- let tabstripRect = windowUtils.getBoundsWithoutFlushing(tabContainer.mTabstrip);
+ let arrowScrollboxRect = windowUtils.getBoundsWithoutFlushing(tabContainer.arrowScrollbox);
for (let menuitem of this.childNodes) {
let curTab = menuitem.tab;
if (!curTab) {
// "Undo close tab", menuseparator, or entries put here by addons.
continue;
}
let curTabRect = windowUtils.getBoundsWithoutFlushing(curTab);
- if (curTabRect.left >= tabstripRect.left &&
- curTabRect.right <= tabstripRect.right) {
+ if (curTabRect.left >= arrowScrollboxRect.left &&
+ curTabRect.right <= arrowScrollboxRect.right) {
menuitem.setAttribute("tabIsVisible", "true");
} else {
menuitem.removeAttribute("tabIsVisible");
}
}
]]></body>
</method>
--- a/browser/base/content/test/performance/browser_tabstrip_overflow_underflow_reflows.js
+++ b/browser/base/content/test/performance/browser_tabstrip_overflow_underflow_reflows.js
@@ -41,17 +41,17 @@ add_task(async function() {
await withReflowObserver(async function(dirtyFrame) {
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
BrowserOpenTab();
await BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "transitionend",
false, e => e.propertyName === "max-width");
await switchDone;
await BrowserTestUtils.waitForCondition(() => {
- return gBrowser.tabContainer.mTabstrip.hasAttribute("scrolledtoend");
+ return gBrowser.tabContainer.arrowScrollbox.hasAttribute("scrolledtoend");
});
}, EXPECTED_OVERFLOW_REFLOWS, window);
await withReflowObserver(async function() {
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
let transitionPromise =
BrowserTestUtils.waitForEvent(gBrowser.selectedTab,
"transitionend", false,
--- a/browser/base/content/test/performance/head.js
+++ b/browser/base/content/test/performance/head.js
@@ -193,17 +193,17 @@ async function ensureNoPreloadedBrowser(
* tabstrip without causing it to overflow.
*/
function computeMaxTabCount() {
let currentTabCount = gBrowser.tabs.length;
let newTabButton =
document.getAnonymousElementByAttribute(gBrowser.tabContainer,
"anonid", "tabs-newtab-button");
let newTabRect = newTabButton.getBoundingClientRect();
- let tabStripRect = gBrowser.tabContainer.mTabstrip.getBoundingClientRect();
+ let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
let availableTabStripWidth = tabStripRect.width - newTabRect.width;
let tabMinWidth =
parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth, 10);
let maxTabCount = Math.floor(availableTabStripWidth / tabMinWidth) - currentTabCount;
Assert.ok(maxTabCount > 0,
"Tabstrip needs to be wide enough to accomodate at least 1 more tab " +
--- a/browser/base/content/test/tabs/browser_overflowScroll.js
+++ b/browser/base/content/test/tabs/browser_overflowScroll.js
@@ -2,56 +2,56 @@
requestLongerTimeout(2);
/**
* Tests that scrolling the tab strip via the scroll buttons scrolls the right
* amount in non-smoothscroll mode.
*/
add_task(async function() {
- let tabstrip = gBrowser.tabContainer.mTabstrip;
- let scrollbox = tabstrip._scrollbox;
- let originalSmoothScroll = tabstrip.smoothScroll;
+ let arrowScrollbox = gBrowser.tabContainer.arrowScrollbox;
+ let scrollbox = arrowScrollbox._scrollbox;
+ let originalSmoothScroll = arrowScrollbox.smoothScroll;
let tabs = gBrowser.tabs;
let tabMinWidth = parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth);
let rect = ele => ele.getBoundingClientRect();
let width = ele => rect(ele).width;
- let tabCountForOverflow = Math.ceil(width(tabstrip) / tabMinWidth * 3);
+ let tabCountForOverflow = Math.ceil(width(arrowScrollbox) / tabMinWidth * 3);
let left = ele => rect(ele).left;
let right = ele => rect(ele).right;
let isLeft = (ele, msg) => is(left(ele), left(scrollbox), msg);
let isRight = (ele, msg) => is(right(ele), right(scrollbox), msg);
- let elementFromPoint = x => tabstrip._elementFromPoint(x);
+ let elementFromPoint = x => arrowScrollbox._elementFromPoint(x);
let nextLeftElement = () => elementFromPoint(left(scrollbox) - 1);
let nextRightElement = () => elementFromPoint(right(scrollbox) + 1);
let firstScrollable = () => tabs[gBrowser._numPinnedTabs];
- tabstrip.smoothScroll = false;
+ arrowScrollbox.smoothScroll = false;
registerCleanupFunction(() => {
- tabstrip.smoothScroll = originalSmoothScroll;
+ arrowScrollbox.smoothScroll = originalSmoothScroll;
});
while (tabs.length < tabCountForOverflow) {
BrowserTestUtils.addTab(gBrowser, "about:blank", { skipAnimation: true });
}
gBrowser.pinTab(tabs[0]);
await BrowserTestUtils.waitForCondition(() => {
return Array.from(gBrowser.tabs).every(tab => tab._fullyOpen);
});
ok(!scrollbox.hasAttribute("notoverflowing"),
"Tab strip should be overflowing");
- let upButton = tabstrip._scrollButtonUp;
- let downButton = tabstrip._scrollButtonDown;
+ let upButton = arrowScrollbox._scrollButtonUp;
+ let downButton = arrowScrollbox._scrollButtonDown;
let element;
gBrowser.selectedTab = firstScrollable();
ok(left(scrollbox) <= left(firstScrollable()), "Selecting the first tab scrolls it into view " +
"(" + left(scrollbox) + " <= " + left(firstScrollable()) + ")");
element = nextRightElement();
EventUtils.synthesizeMouseAtCenter(downButton, {});
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3345,19 +3345,19 @@ var SessionStoreInternal = {
selectTab = Math.min(selectTab, winData.tabs.length);
}
let tabbrowser = aWindow.gBrowser;
let newTabCount = winData.tabs.length;
var tabs = [];
// disable smooth scrolling while adding, moving, removing and selecting tabs
- let tabstrip = tabbrowser.tabContainer.mTabstrip;
- let smoothScroll = tabstrip.smoothScroll;
- tabstrip.smoothScroll = false;
+ let arrowScrollbox = tabbrowser.tabContainer.arrowScrollbox;
+ let smoothScroll = arrowScrollbox.smoothScroll;
+ arrowScrollbox.smoothScroll = false;
// We need to keep track of the initially open tabs so that they
// can be moved to the end of the restored tabs.
let initialTabs;
if (!overwriteTabs && firstWindow) {
initialTabs = Array.slice(tabbrowser.tabs);
}
@@ -3489,17 +3489,17 @@ var SessionStoreInternal = {
}
// Restore tabs, if any.
if (winData.tabs.length) {
this.restoreTabs(aWindow, tabs, winData.tabs, selectTab);
}
// set smoothScroll back to the original value
- tabstrip.smoothScroll = smoothScroll;
+ arrowScrollbox.smoothScroll = smoothScroll;
TelemetryStopwatch.finish("FX_SESSION_RESTORE_RESTORE_WINDOW_MS");
if (Services.prefs.getIntPref("browser.tabs.restorebutton") != 0 ) {
Services.telemetry.scalarAdd("browser.session.restore.number_of_tabs", winData.tabs.length);
Services.telemetry.scalarAdd("browser.session.restore.number_of_win", 1);
}
this._setWindowStateReady(aWindow);