From 998cf5d47e6d29415f9357684088e2add48378bb Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Thu, 18 Feb 2016 11:19:28 +0900 Subject: [PATCH] Use different method to narrowrize scrollbar for each platform --- defaults/preferences/treestyletab.js | 2 ++ modules/utils.js | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index fbd38228..018f3791 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -69,6 +69,8 @@ pref("extensions.treestyletab.tabbar.invertScrollbar", true); */ pref("extensions.treestyletab.tabbar.narrowScrollbar", true); pref("extensions.treestyletab.tabbar.narrowScrollbar.width", 10); +pref("extensions.treestyletab.tabbar.narrowScrollbar.resize.default", true); +pref("extensions.treestyletab.tabbar.narrowScrollbar.resize.Windows", false); /** * On some environments (ex. GNOME3 on Linux), "narrow scrollbar" cannot get diff --git a/modules/utils.js b/modules/utils.js index f6499656..36635ba4 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -600,13 +600,21 @@ var TreeStyleTabUtils = { SSS.sheetRegistered(this.lastAgentSheetForNarrowScrollbar, SSS.AGENT_SHEET)) SSS.unregisterSheet(this.lastAgentSheetForNarrowScrollbar, SSS.AGENT_SHEET); - var scrollbox = aTabBrowser.tabContainer.mTabstrip._scrollbox; - var d = scrollbox.ownerDocument; + var size = this.getTreePref('tabbar.narrowScrollbar.width'); + var rulesToSizeScrollbar; + var rulesToSizeScrollbarContents; + { + let OS = Services.appinfo.OS; + let shouldResize = this.getTreePref('tabbar.narrowScrollbar.resize.'+OS) || this.getTreePref('tabbar.narrowScrollbar.resize.default'); + let scrollbarSize = 0; + if (!shouldResize) { + let scrollbox = aTabBrowser.tabContainer.mTabstrip._scrollbox; + let d = scrollbox.ownerDocument; // We have to calculate the width of the scroll bar indirectly // based on the width of the container and the scrollable contents, // because the scrollbar is not accessible via public APIs. - var scrollbarSize = this.lastOriginalScrollbarSize; + scrollbarSize = this.lastOriginalScrollbarSize; if (scrollbarSize == 0) { let nodes = d.getAnonymousNodes(scrollbox); if (nodes) { @@ -619,11 +627,8 @@ var TreeStyleTabUtils = { } } } - - var size = this.getTreePref('tabbar.narrowScrollbar.width'); - var rulesToSizeScrollbar; - var rulesToSizeScrollbarContents; - if (scrollbarSize) { + } + if (!shouldResize && scrollbarSize > 0) { let overWidth = size - scrollbarSize; let leftMargin = Math.floor(overWidth / 2); let rightMargin = overWidth - leftMargin; @@ -635,6 +640,7 @@ var TreeStyleTabUtils = { rulesToSizeScrollbarContents = 'max-width: '+size+'px;' + 'min-width: '+size+'px;'; } + } const style = 'data:text/css,'+encodeURIComponent( ('@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");' +