Skip to content

Commit

Permalink
Clean up:
Browse files Browse the repository at this point in the history
Use attribute for orient
Replace _scrollbox with scrollbox
Replace mTabstrip with arrowScrollbox
  • Loading branch information
onemen committed Jan 29, 2021
1 parent 06b5130 commit fb6614b
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 68 deletions.
2 changes: 1 addition & 1 deletion addon/chrome/content/click/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ var TabmixAllTabs = {
if (aTab.selected)
gBrowser.ensureTabIsVisible(aTab);
else
// if we select another tab _handleTabSelect will call mTabstrip.ensureElementIsVisible
// if we select another tab _handleTabSelect will call arrowScrollbox.ensureElementIsVisible
gBrowser.selectedTab = aTab;
},

Expand Down
10 changes: 5 additions & 5 deletions addon/chrome/content/minit/minit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var TMP_tabDNDObserver = {
const tabsDragUtils = "piro.sakura.ne.jp" in window &&
"tabsDragUtils" in window["piro.sakura.ne.jp"];
Tabmix.handleAnimateTabMove = function(dragContext) {
if (gBrowser.tabContainer.orient != "horizontal") {
if (gBrowser.tabContainer.getAttribute("orient") != "horizontal") {
return false;
}
return !dragContext || !dragContext.draggedTabs ||
Expand Down Expand Up @@ -123,7 +123,7 @@ var TMP_tabDNDObserver = {
delete TMP_tabDNDObserver.draggedTab.__tabmixDragStart;
TMP_tabDNDObserver.draggedTab = null;
}
return this.orient == "horizontal" &&
return this.getAttribute("orient") == "horizontal" &&
(!this.moveTabOnDragging || this.hasAttribute("multibar") ||
aEvent.altKey);
};
Expand All @@ -134,7 +134,7 @@ var TMP_tabDNDObserver = {
TMP_tabDNDObserver.getDragType(tab) == TMP_tabDNDObserver.DRAG_TAB_TO_NEW_WINDOW;
}

return this.orient == "horizontal" &&
return this.getAttribute("orient") == "horizontal" &&
(!this.moveTabOnDragging || this.hasAttribute("multibar") ||
checkTab(aEvent.dataTransfer));
};
Expand Down Expand Up @@ -380,9 +380,9 @@ var TMP_tabDNDObserver = {
if (TabmixTabbar.scrollButtonsMode != TabmixTabbar.SCROLL_BUTTONS_HIDDEN) // scroll with button
targetAnonid = event.originalTarget.getAttribute("anonid");
// scroll without button
else if (event.screenX <= tabStrip.scrollBoxObject.screenX)
else if (event.screenX <= tabStrip.scrollbox.screenX)
targetAnonid = ltr ? "scrollbutton-up" : "scrollbutton-down";
else if (event.screenX >= (tabStrip.scrollBoxObject.screenX + tabStrip.scrollBoxObject.width))
else if (event.screenX >= (tabStrip.scrollbox.screenX + tabStrip.scrollbox.getBoundingClientRect().width))
targetAnonid = ltr ? "scrollbutton-down" : "scrollbutton-up";
switch (targetAnonid) {
case "scrollbutton-up":
Expand Down
4 changes: 2 additions & 2 deletions addon/chrome/content/minit/tablib.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ Tabmix.tablib = {
if (!Tabmix.extensions.verticalTabs) {
Tabmix.changeCode(tabBar, "gBrowser.tabContainer._lockTabSizing")._replace(
'{',
'{if (this.orient != "horizontal" || !Tabmix.prefs.getBoolPref("lockTabSizingOnClose")) return;'
'{if (this.getAttribute("orient") != "horizontal" || !Tabmix.prefs.getBoolPref("lockTabSizingOnClose")) return;'
)._replace(
/(var|let) isEndTab =|faviconize.o_lockTabSizing/,
' if (TabmixTabbar.widthFitTitle) {' +
Expand Down Expand Up @@ -1214,7 +1214,7 @@ Tabmix.tablib = {
if (!tab.pinned)
this.removeTab(tab, {animate: false});
}, this);
// _handleTabSelect will call mTabstrip.ensureElementIsVisible
// _handleTabSelect will call arrowScrollbox.ensureElementIsVisible
}
};

Expand Down
6 changes: 3 additions & 3 deletions addon/chrome/content/places/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ var TMP_Places = {
if (!TabmixTabbar.isMultiRow) {
let scrollPosition = tabstrip.scrollPosition;
if (scrollPosition < 100) {
if (tabstrip.orient == "vertical") {
tabstrip._scrollbox.scrollTop = 0;
if (tabstrip.getAttribute("orient") == "vertical") {
tabstrip.scrollbox.scrollTop = 0;
} else {
tabstrip._scrollbox.scrollLeft = 0;
tabstrip.scrollbox.scrollLeft = 0;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion addon/chrome/content/session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,7 @@ TabmixSessionManager = {
gBrowser._lastRelatedTab = null;
}

// call mTabstrip.ensureElementIsVisible before we restore the tab
// call arrowScrollbox.ensureElementIsVisible before we restore the tab
// we call from TMP_eventListener.onSSTabRestoring again
gBrowser.ensureTabIsVisible(gBrowser.selectedTab);

Expand Down
52 changes: 10 additions & 42 deletions addon/chrome/content/tab/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ var TabmixTabbar = {
// if we are in overflow in one line we will have more then one line
// in multi-row. we try to prevent extra over/underflow events by setting
// the height in front.
tabstrip.orient = "vertical";
if (Tabmix.tabsUtils.updateVerticalTabStrip() == "scrollbar")
Tabmix.tabsUtils.overflow = true;
}
Expand All @@ -117,16 +116,6 @@ var TabmixTabbar = {

this.widthFitTitle = Tabmix.prefs.getBoolPref("flexTabs") &&
(tabBar.mTabMaxWidth != tabBar.mTabMinWidth);
if (!Tabmix.extensions.verticalTabBar) {
if (start) {
// Don't change tabstrip orient on start before sessionStore ends.
// if we set orient to vertical before sessionStore finish
// sessionStore don't select the selected tab from last session.
setTimeout(() => Tabmix.tabsUtils.setTabStripOrient(), 0);
} else {
Tabmix.tabsUtils.setTabStripOrient();
}
}
Tabmix.setItem(tabBar, "widthFitTitle", this.widthFitTitle || null);

if (Tabmix.prefs.getIntPref("tabs.closeButtons") == 5 && this.widthFitTitle)
Expand Down Expand Up @@ -622,8 +611,7 @@ Tabmix.tabsUtils = {
},

getInnerbox() {
return this.tabBar.arrowScrollbox.scrollbox.getElementsByClassName("box-inherit scrollbox-innerbox"
)[0];
return document.getElementById("tabbrowser-arrowscrollbox").scrollbox;
},

get inDOMFullscreen() {
Expand All @@ -634,7 +622,7 @@ Tabmix.tabsUtils = {
return !this.getCollapsedState.collapsed;
},

getCollapsedState() {
get getCollapsedState() {
const toolbar = document.getElementById("TabsToolbar");
const tabBar = gBrowser.tabContainer;
const toolbarCollapsed = toolbar.collapsed;
Expand Down Expand Up @@ -814,7 +802,6 @@ Tabmix.tabsUtils = {
}

TabmixTabbar.flowing = this.tabBar.getAttribute("flowing");
this.setTabStripOrient();
Tabmix.navToolbox.setScrollButtons(true);

// fix incompatibility with Personal Titlebar extension
Expand Down Expand Up @@ -904,28 +891,15 @@ Tabmix.tabsUtils = {
return multibar;
},

setTabStripOrient() {
// we can't set display:block and orient=vertical when widthFitTitle is false
// and we are in one row.
let vertical = TabmixTabbar.isMultiRow &&
(TabmixTabbar.widthFitTitle || this.tabBar.hasAttribute("multibar"));
let tabstrip = this.tabBar.arrowScrollbox;
Tabmix.setItem(tabstrip, "orient", vertical ? "vertical" : "horizontal");
if (Tabmix.isVersion(550)) {
// arrowscrollbox._startEndProps is field since Firefox 55 (Bug 1371604)
tabstrip._startEndProps = vertical ? ["top", "bottom"] : ["left", "right"];
}
tabstrip._isRTLScrollbox = !vertical && Tabmix.rtl;
},

/**
* check that we have enough room to show new tab button after the last tab
* in the current row. we don't want the button to be on the next row when the
* tab is on the current row
*/
adjustNewtabButtonVisibility() {
if (!TabmixTabbar.isMultiRow && this.tabBar.arrowScrollbox.getAttribute('orient') == "vertical")
if (!TabmixTabbar.isMultiRow || this.tabBar.arrowScrollbox.getAttribute('orient') == "vertical") {
return;
}

if (!this.checkNewtabButtonVisibility) {
this.showNewTabButtonOnSide(this.overflow, "right-side");
Expand Down Expand Up @@ -1018,9 +992,9 @@ Tabmix.tabsUtils = {

set overflow(val) {
// don't do anything if other extensions set orient to vertical
// when we aren't use it.
if (!TabmixTabbar.isMultiRow && this.tabBar.arrowScrollbox.getAttribute('orient') == "vertical")
if (this.tabBar.arrowScrollbox.getAttribute('orient') == "vertical") {
return val;
}

if (val != this.overflow) {
let tabBar = this.tabBar;
Expand All @@ -1032,7 +1006,7 @@ Tabmix.tabsUtils = {
this.showNewTabButtonOnSide(val, "right-side");

if (typeof tabstrip.updateOverflow == "function") {
tabstrip.updateOverflow(val);
tabstrip.updateOverflow(val);
// overflow/underflow handler from tabbrowser-arrowscrollbox binding
if (val) {
tabBar._positionPinnedTabs();
Expand Down Expand Up @@ -1104,10 +1078,10 @@ Tabmix.tabsUtils = {
return this.getTabRowNumber(tabs[tabs.length - 2], this.topTabY) == 1;
},

/**** gBrowser.tabContainer.mTabstrip helpers ****/
/**** gBrowser.tabContainer.arrowScrollbox helpers ****/
/**
* this function is here for the case restart-less extension override our
* mTabstrip binding when Tabmix's uses its own scroll buttons
* arrowScrollbox binding when Tabmix's uses its own scroll buttons
*/
updateScrollButtons(useTabmixButtons) {
let tabstrip = this.tabBar.arrowScrollbox;
Expand All @@ -1122,12 +1096,6 @@ Tabmix.tabsUtils = {
tabstrip._scrollButtonUpLeft || // fall back to original
tabstrip.shadowRoot.getElementById("scrollbutton-up");
tabstrip._updateScrollButtonsDisabledState();

if (!Tabmix.isVersion(320, 270)) {
let overflow = this.overflow;
tabstrip._scrollButtonUp.collapsed = !overflow;
tabstrip._scrollButtonDown.collapsed = !overflow;
}
},

isElementVisible(element) {
Expand Down Expand Up @@ -2350,7 +2318,7 @@ gTMPprefObserver = {
}

let tabsToolbar = document.getElementById("TabsToolbar");
// when we here after many tabs closed fast mTabstrip height can larger
// when we here after many tabs closed fast arrowScrollbox height can larger
// then one row.
let newHeight = TabmixTabbar.visibleRows == 1 ? TabmixTabbar.singleRowHeight :
gBrowser.tabContainer.arrowScrollbox.scrollClientRect.height;
Expand Down
5 changes: 0 additions & 5 deletions addon/chrome/content/tab/tabsBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
Tabmix.initialization.init.initialized = false;
Tabmix.initialization.run("onContentLoaded", gBrowser.tabContainer);

// temporary workaround until we fix multi-row feture
if (!gBrowser.tabContainer.arrowScrollbox._scrollbox) {
gBrowser.tabContainer.arrowScrollbox._scrollbox = {};
}

Tabmix.setNewFunction(gBrowser.tabContainer, "_notifyBackgroundTab", function _notifyBackgroundTab(aTab) {
if (aTab.pinned || aTab.hidden) {
return;
Expand Down
14 changes: 7 additions & 7 deletions addon/chrome/content/tabmix.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Tabmix.sessionInitialized = function() {
// we call gTMPprefObserver.miscellaneousRules to add some dynamic rules
// from Tabmix.afterDelayedStartup
Tabmix.getButtonsHeight = function(setDefault) {
if (gBrowser.tabContainer.orient == "horizontal") {
if (gBrowser.tabContainer.getAttribute("orient") == "horizontal") {
const {toolbar, tabBar, collapsed, tabBarCollapsed, toolbarCollapsed} =
Tabmix.tabsUtils.getCollapsedState;
let stripIsHidden = TabmixTabbar.hideMode !== 0 && collapsed;
Expand Down Expand Up @@ -135,7 +135,7 @@ Tabmix.getButtonsHeight = function(setDefault) {
};

Tabmix.getAfterTabsButtonsWidth = function TMP_getAfterTabsButtonsWidth() {
if (gBrowser.tabContainer.orient == "horizontal") {
if (gBrowser.tabContainer.getAttribute("orient") == "horizontal") {
const {toolbar, tabBar, collapsed, tabBarCollapsed, toolbarCollapsed} =
Tabmix.tabsUtils.getCollapsedState;
let stripIsHidden = TabmixTabbar.hideMode !== 0 && collapsed;
Expand All @@ -146,7 +146,7 @@ Tabmix.getAfterTabsButtonsWidth = function TMP_getAfterTabsButtonsWidth() {
// save tabsNewtabButton width
let lwtheme = !this.isVersion(280) && document.getElementById("main-window").getAttribute("lwtheme");
this.tabsNewtabButton =
tabBar.getElementsByAttribute("command", "cmd_newNavigatorTab");
tabBar.getElementsByAttribute("command", "cmd_newNavigatorTab")[0];
this.tabsNewtabButton.setAttribute("force-display", true);
let openNewTabRect = Tabmix.getBoundsWithoutFlushing(this.tabsNewtabButton);
let style = window.getComputedStyle(this.tabsNewtabButton);
Expand Down Expand Up @@ -979,7 +979,7 @@ var TMP_eventListener = {
// for ColorfulTabs 6.0+
// ColorfulTabs traps TabSelect event after we do
// we need to set standout class before we check for getTabRowNumber
// and mTabstrip.ensureElementIsVisible
// and arrowScrollbox.ensureElementIsVisible
// this class change tab height (by changing the borders)
if (typeof window.colorfulTabs == "object" && window.colorfulTabs.standout &&
!tab.classList.contains("standout")) {
Expand Down Expand Up @@ -1057,7 +1057,7 @@ var TMP_eventListener = {
}
let tabBar = gBrowser.tabContainer;
let tabStrip = tabBar.arrowScrollbox;
let orient = tabStrip.orient;
let orient = tabStrip.getAttribute("orient");
TabmixTabbar.removeShowButtonAttr();

let shouldMoveFocus = scrollTabs == 1;
Expand Down Expand Up @@ -1218,9 +1218,9 @@ var TMP_eventListener = {
// some theme not using up to date Tabmix tab binding
// we check here that all of our attribute exist
setTabAttribute: function TMP_EL_setTabAttribute(aTab) {
let reloadIcon = aTab.getElementsByAttribute("class", "tab-reload-icon");
let reloadIcon = aTab.getElementsByAttribute("class", "tab-reload-icon")[0];
if (!reloadIcon) {
let lockIcon = aTab.getElementsByAttribute("class", "tab-lock-icon");
let lockIcon = aTab.getElementsByAttribute("class", "tab-lock-icon")[0];
if (lockIcon) {
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let image = document.createElementNS(XULNS, "image");
Expand Down
3 changes: 1 addition & 2 deletions addon/modules/DynamicRules.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ XPCOMUtils.defineLazyGetter(this, "isMac", () => {
return TabmixSvc.isMac && !TabmixSvc.isPaleMoon;
});

//const NAMESPACE = '@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n'; //set namespace now preventing style been apply to elements which are nolonger of xul. pending to remove
const STYLENAMES = ["currentTab", "unloadedTab", "unreadTab", "otherTab", "progressMeter"];
const EXTRAPREFS = ["squaredTabsStyle"];

Expand Down Expand Up @@ -303,7 +302,7 @@ this.DynamicRules = {
updateButtonHeight(Tabmix, gTMPprefObserver.dynamicRules);

// update multi-row heights
gBrowser.tabContainer.mTabstrip._singleRowHeight = null;
gBrowser.tabContainer.arrowScrollbox._singleRowHeight = null;
TabmixTabbar._heights = [];
TabmixTabbar.visibleRows = 1;
Tabmix.tabsUtils.updateVerticalTabStrip();
Expand Down

0 comments on commit fb6614b

Please sign in to comment.