From 696bda9e8dd677d609fb2352ba1366c2b4815fb1 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Mon, 15 Feb 2016 19:18:42 +0900 Subject: [PATCH] Break too long line in group tabs --- modules/groupTab.js | 25 +++++++++++++++++++++++++ modules/pseudoTreeBuilder.js | 19 +++++++++++++------ skin/classic/treestyletab/group.css | 4 ++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/modules/groupTab.js b/modules/groupTab.js index 58281ea1..b64e034d 100644 --- a/modules/groupTab.js +++ b/modules/groupTab.js @@ -272,6 +272,11 @@ GroupTab.prototype = inherit(TreeStyleTabBase, { case 'TabSelect': return this.onTabSelect(aEvent); + case 'overflow': + return this.onOverflow(aEvent); + case 'underflow': + return this.onUnderflow(aEvent); + case this.kEVENT_TYPE_ATTACHED: return this.onTabAttached(aEvent); case this.kEVENT_TYPE_DETACHED: @@ -293,6 +298,8 @@ GroupTab.prototype = inherit(TreeStyleTabBase, { this.window.addEventListener('unload', this, false); this.window.addEventListener('click', this, false); this.window.addEventListener('dblclick', this, false); + this.window.addEventListener('overflow', this, false); + this.window.addEventListener('underflow', this, false); tab.addEventListener('TabSelect', this, false); tab.addEventListener('TabClose', this, false); @@ -324,6 +331,8 @@ GroupTab.prototype = inherit(TreeStyleTabBase, { this.window.removeEventListener('unload', this, false); this.window.removeEventListener('click', this, false); this.window.removeEventListener('dblclick', this, false); + this.window.removeEventListener('overflow', this, false); + this.window.removeEventListener('underflow', this, false); tab.removeEventListener('TabSelect', this, false); tab.removeEventListener('TabClose', this, false); @@ -394,6 +403,22 @@ GroupTab.prototype = inherit(TreeStyleTabBase, { this.shouldUpdate = false; }, + onOverflow : function GT_onOverflow(aEvent) + { + var target = aEvent.originalTarget; + if (target.className != PseudoTreeBuilder.kTREEITEM) + return; + target.style.minHeight = target.lastChild.boxObject.height + 'px'; + }, + + onUnderflow : function GT_onUnderflow(aEvent) + { + var target = aEvent.originalTarget; + if (target.className != PseudoTreeBuilder.kTREEITEM) + return; + target.style.minHeight = ''; + }, + onTabAttached : function GT_onTabAttached(aEvent) { var tab = aEvent.detail.parentTab; diff --git a/modules/pseudoTreeBuilder.js b/modules/pseudoTreeBuilder.js index 5907d54e..4ce62ee8 100644 --- a/modules/pseudoTreeBuilder.js +++ b/modules/pseudoTreeBuilder.js @@ -96,30 +96,37 @@ var PseudoTreeBuilder = { var w = doc.defaultView; var item = doc.createElement('hbox'); - item.setAttribute('class', this.kTREEROW); + item.setAttribute('class', this.kTREEITEM); + item.setAttribute('flex', 1); var favicon = item.appendChild(doc.createElement('image')); favicon.setAttribute('src', aTab.getAttribute('image') || 'chrome://mozapps/skin/places/defaultFavicon.png'); favicon.setAttribute('class', this.kFAVICON); var label = item.appendChild(doc.createElement('label')); - label.setAttribute('value', aTab.label); + label.setAttribute('flex', 1); + label.textContent = aTab.label; var tooltip = aTab.label; var uri = aTab.linkedBrowser.currentURI.spec; if (w.isBlankPageURL ? !w.isBlankPageURL(uri) : (uri != 'about:blank')) tooltip += '\n' + uri; label.setAttribute('tooltiptext', tooltip); - label.setAttribute('class', 'text-link '+this.kTREEITEM); + label.setAttribute('class', 'text-link'); label.setAttribute('tab-id', TreeStyleTabBase.getTabValue(aTab, TreeStyleTabBase.kID)); + var row = doc.createElement('hbox'); + row.setAttribute('class', this.kTREEROW); + row.setAttribute('flex', 1); + row.appendChild(item); + var children = this.createTabChildren(aTab); if (children) { let container = doc.createElement('vbox'); - container.appendChild(item); + container.appendChild(row); container.appendChild(children); return container; } else { - return item; + return row; } }, @@ -132,11 +139,11 @@ var PseudoTreeBuilder = { return null; var container = doc.createElement('vbox'); + container.setAttribute('class', this.kTREECHILDREN); for (let i = 0, maxi = children.length; i < maxi; i++) { container.appendChild(this.createTabItem(children[i])); } - container.setAttribute('class', this.kTREECHILDREN); return container; } }; diff --git a/skin/classic/treestyletab/group.css b/skin/classic/treestyletab/group.css index eb4457df..0ff9d88c 100644 --- a/skin/classic/treestyletab/group.css +++ b/skin/classic/treestyletab/group.css @@ -66,3 +66,7 @@ .treestyletab-pseudo-tree-root-item { display: none; } + +.treestyletab-pseudo-tree-item { + overflow: hidden; +}