[Pkg-mozext-commits] [tree-style-tab] 01/04: Imported Upstream version 0.14.2014020901

Damyan Ivanov dmn at moszumanska.debian.org
Sat Mar 22 08:39:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to branch master
in repository tree-style-tab.

commit be3eaa39bf0f74d6b2f659a413bc3053c10bd74c
Author: Damyan Ivanov <dmn at debian.org>
Date:   Sat Mar 22 06:56:58 2014 +0000

    Imported Upstream version 0.14.2014020901
---
 chrome.manifest                            |   6 +-
 content/treestyletab/bookmarksOverlay.js   |  78 ++++++++++-----------
 content/treestyletab/config.js             |  17 +----
 content/treestyletab/config.xul            |   5 --
 content/treestyletab/license.txt           |   2 +-
 content/treestyletab/treestyletab.css      |  39 +++++++++--
 content/treestyletab/windowHelper.js       |  84 +++++++----------------
 content/treestyletab/windowHelperHacks.js  |  26 +++++++
 defaults/preferences/treestyletab.js       |   3 +-
 install.rdf                                |   4 +-
 locale/da-DK/treestyletab/treestyletab.dtd |   1 -
 locale/de-DE/treestyletab/treestyletab.dtd |   1 -
 locale/en-US/treestyletab/license.txt      |   2 +-
 locale/en-US/treestyletab/treestyletab.dtd |   1 -
 locale/es-ES/treestyletab/treestyletab.dtd |   1 -
 locale/fr-FR/treestyletab/treestyletab.dtd |   1 -
 locale/it-IT/treestyletab/treestyletab.dtd |   1 -
 locale/ja/treestyletab/license.txt         |   2 +-
 locale/ja/treestyletab/treestyletab.dtd    |   1 -
 locale/pl/treestyletab/treestyletab.dtd    |   1 -
 locale/ru/treestyletab/treestyletab.dtd    |   1 -
 locale/sv-SE/treestyletab/treestyletab.dtd |   1 -
 locale/zh-CN/treestyletab/treestyletab.dtd |   1 -
 locale/zh-TW/treestyletab/treestyletab.dtd |   1 -
 modules/autoHide.js                        |  74 +++++++++++++-------
 modules/base.js                            |  19 ++----
 modules/browser.js                         |  64 +++++++++++------
 modules/browserUIShowHideObserver.js       |   5 --
 modules/constants.js                       |   5 +-
 modules/fullscreenObserver.js              | 106 +++++++++++++++++++++++++++++
 modules/tabbarDNDObserver.js               |  42 ++++++------
 modules/utils.js                           |  18 +++--
 modules/window.js                          |  39 ++++++++++-
 skin/classic/treestyletab/Darwin-base.css  |  20 ------
 skin/classic/treestyletab/WINNT-base.css   |  37 ----------
 skin/classic/treestyletab/group.css        |   8 +--
 36 files changed, 412 insertions(+), 305 deletions(-)

diff --git a/chrome.manifest b/chrome.manifest
index 980e4e9..c9dbf04 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -34,10 +34,10 @@ skin	treestyletab-group	classic/1.0	skin/classic/treestyletab-group-basic/
 skin	treestyletab-group	classic/1.0	skin/classic/treestyletab-group-aero/	os=WINNT osversion>=6
 
 override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/dummy.css	os=Darwin
-override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/Darwin-base.css	os=Darwin appversion>=28.0a1
+override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/Darwin-base.css	os=Darwin appversion>=29.0a1
 override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/Linux-base.css	os=Linux
 override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/dummy.css	os=WINNT
-override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/WINNT-base.css	os=WINNT appversion>=28.0a1
+override chrome://treestyletab/skin/platform-base.css	chrome://treestyletab/skin/WINNT-base.css	os=WINNT appversion>=29.0a1
 override chrome://treestyletab/skin/platform-styled.css	chrome://treestyletab/skin/Darwin-styled.css	os=Darwin
 override chrome://treestyletab/skin/platform-styled.css	chrome://treestyletab/skin/dummy.css	os=Linux
 override chrome://treestyletab/skin/platform-styled.css	chrome://treestyletab/skin/WINNT-styled.css	os=WINNT
@@ -55,7 +55,7 @@ override chrome://treestyletab/skin/platform-config.css	chrome://treestyletab/sk
 override chrome://treestyletab/skin/platform-config.css	chrome://treestyletab/skin/dummy.css	os=WINNT
 
 override chrome://treestyletab/content/base-toolbar-binding.xml	chrome://global/content/bindings/toolbar.xml
-override chrome://treestyletab/content/base-toolbar-binding.xml	chrome://browser/content/customizableui/toolbar.xml	appversion>=28.0a1
+override chrome://treestyletab/content/base-toolbar-binding.xml	chrome://browser/content/customizableui/toolbar.xml	appversion>=29.0a1
 
 
 resource treestyletab-modules modules/
diff --git a/content/treestyletab/bookmarksOverlay.js b/content/treestyletab/bookmarksOverlay.js
index 61b32ba..69ee846 100644
--- a/content/treestyletab/bookmarksOverlay.js
+++ b/content/treestyletab/bookmarksOverlay.js
@@ -253,7 +253,7 @@ var TreeStyleTabBookmarksService = {
 						'if (item.uri) { $& }'
 					).replace(
 						/(browserWindow\.(?:getBrowser\(\)|gBrowser)\.loadTabs\([^;]+\);)/,
-						'var TSTResult = browserWindow.TreeStyleTabBookmarksService.handleTabsOpenProcess(where, aEvent, browserWindow, ids, urls, typeof replaceCurrentTab == "undefined" ? undefined : replaceCurrentTab, aFolderTitle);\n' +
+						'var TSTResult = browserWindow.TreeStyleTabBookmarksService.handleTabsOpenProcess(where, aEvent, browserWindow, ids, urls, aFolderTitle);\n' +
 						'TSTTreeStructure = TSTResult.treeStructure;\n' +
 						'TSTPreviousTabs = TSTResult.previousTabs;\n' +
 						'TSTOpenGroupBookmarkBehavior = TSTResult.behavior;\n' +
@@ -370,13 +370,12 @@ var TreeStyleTabBookmarksService = {
 			);
 		}
 	},
-	handleTabsOpenProcess : function TSTBMService_handleTabsOpenProcess(aWhere, aEvent, aBrowserWindow, aIDs, aURLs, aReplaceCurrentTab, aFolderTitle)
+	handleTabsOpenProcess : function TSTBMService_handleTabsOpenProcess(aWhere, aEvent, aBrowserWindow, aIDs, aURLs, aFolderTitle)
 	{
 		var result = {
-				behavior          : undefined,
-				treeStructure     : undefined,
-				previousTabs      : undefined,
-				replaceCurrentTab : undefined
+				behavior      : undefined,
+				treeStructure : undefined,
+				previousTabs  : undefined
 			};
 		if (
 			aEvent.type != 'drop' &&
@@ -394,32 +393,41 @@ var TreeStyleTabBookmarksService = {
 			let treeStructure = result.behavior & sv.kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE ?
 						null :
 						sv.getTreeStructureFromItems(aIDs) ;
-			if (
-				treeStructure &&
-				result.behavior & sv.kGROUP_BOOKMARK_USE_DUMMY
-				) {
-				let parentCount = 0;
-				let childCount = 0;
-				for (let i in treeStructure) {
-					if (treeStructure[i] == -1)
-						parentCount++;
-					else
-						childCount++;
+			if (treeStructure) {
+				if (result.behavior & sv.kGROUP_BOOKMARK_USE_DUMMY) {
+					let parentCount = 0;
+					let childCount = 0;
+					for (let i in treeStructure) {
+						if (treeStructure[i] == -1)
+							parentCount++;
+						else
+							childCount++;
+					}
+					if (
+						parentCount > 1 &&
+						(
+							result.behavior & sv.kGROUP_BOOKMARK_USE_DUMMY_FORCE ||
+							// when there is any orphan, then all of parents and orphans should be grouped under a dummy tab.
+							childCount < parentCount
+						)
+						) {
+						aIDs.unshift(-1);
+						treeStructure = sv.getTreeStructureFromItems(aIDs, 0);
+						aURLs.unshift(sv.getGroupTabURI({
+							title:     aFolderTitle,
+							temporary: TreeStyleTabUtils.getTreePref('openGroupBookmark.temporaryGroup')
+						}));
+					}
 				}
-				if (
-					parentCount > 1 &&
-					(
-						result.behavior & sv.kGROUP_BOOKMARK_USE_DUMMY_FORCE ||
-						// when there is any orphan, then all of parents and orphans should be grouped under a dummy tab.
-						childCount < parentCount
-					)
-					) {
-					aIDs.unshift(-1);
-					treeStructure = sv.getTreeStructureFromItems(aIDs, 0);
-					aURLs.unshift(sv.getGroupTabURI({
-						title:     aFolderTitle,
-						temporary: TreeStyleTabUtils.getTreePref('openGroupBookmark.temporaryGroup')
-					}));
+				else {
+					// make the first item parent.
+					treeStructure = treeStructure.map(function(aParent, aIndex) {
+						if (aIndex == 0)
+							return aParent;
+						if (aParent < 0)
+							return 0;
+						return aParent;
+					});
 				}
 			}
 
@@ -432,14 +440,6 @@ var TreeStyleTabBookmarksService = {
 			else {
 				sv.readyToOpenNewTabGroup(null, treeStructure, result.behavior & sv.kGROUP_BOOKMARK_EXPAND_ALL_TREE);
 			}
-			// replaceCurrentTab works only on Firefox 7 or earlier
-			// See: https://bugzilla.mozilla.org/show_bug.cgi?id=440093
-			if (typeof aReplaceCurrentTab !== 'undefined')
-				result.replaceCurrentTab = false;
-		}
-		else {
-			if (typeof aReplaceCurrentTab !== 'undefined')
-				result.replaceCurrentTab = !!(result.behavior & sv.kGROUP_BOOKMARK_REPLACE);
 		}
 		return result;
 	},
diff --git a/content/treestyletab/config.js b/content/treestyletab/config.js
index f7a334c..63bfeb2 100644
--- a/content/treestyletab/config.js
+++ b/content/treestyletab/config.js
@@ -36,8 +36,7 @@ function syncEnabledState(aElement, aEnabled)
 var gGroupBookmarkRadio,
 	gGroupBookmarkUnderParent,
 	gGroupBookmarkType,
-	gGroupBookmarkBehaviorPref,
-	gGroupBookmarkReplacePref;
+	gGroupBookmarkBehaviorPref;
 
 function ensureGroupBookmarkItems()
 {
@@ -47,14 +46,6 @@ function ensureGroupBookmarkItems()
 	gGroupBookmarkUnderParent  = document.getElementById('openGroupBookmark.underParent-check');
 	gGroupBookmarkType         = document.getElementById('openGroupBookmark.subtreeType-menulist');
 	gGroupBookmarkBehaviorPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior');
-	var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace';
-	gGroupBookmarkReplacePref = document.getElementById(bookmarkReplaceKey);
-	try {
-		gGroupBookmarkReplacePref.value = prefs.getPref(bookmarkReplaceKey);
-	}
-	catch(e) {
-		prefs.setPref(bookmarkReplaceKey, gGroupBookmarkReplacePref.value != 'false');
-	}
 }
 
 function init()
@@ -142,12 +133,6 @@ function initTabPane()
 
 	var newTabPref = document.getElementById('extensions.treestyletab.autoAttach.newTabButton-box');
 	newTabPref.removeAttribute('hidden');
-
-	var bookmarkGroupReplacePref = document.getElementById('openGroupBookmark.replace');
-	if (bookmarkGroupReplacePref.selected) {
-		document.getElementById('openGroupBookmark.subtree').selected = true;
-	}
-	bookmarkGroupReplacePref.setAttribute('hidden', true);
 }
 
 function onSyncGroupBookmarkUIToPref()
diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul
index 0d2f6ef..6d45463 100644
--- a/content/treestyletab/config.xul
+++ b/content/treestyletab/config.xul
@@ -339,9 +339,6 @@
 		<preference id="extensions.treestyletab.openGroupBookmark.behavior"
 			name="extensions.treestyletab.openGroupBookmark.behavior"
 			type="int"/>
-		<preference id="browser.tabs.loadFolderAndReplace"
-			name="browser.tabs.loadFolderAndReplace.override"
-			type="bool"/>
 		<preference id="extensions.treestyletab.dropLinksOnTab.behavior"
 			name="extensions.treestyletab.dropLinksOnTab.behavior"
 			type="int"/>
@@ -452,8 +449,6 @@
 					</vbox>
 				</hbox>
 				<radio value="2" label="&config.openGroupBookmark.flat;"/>
-				<radio id="openGroupBookmark.replace"
-					value="4" label="&config.openGroupBookmark.replace;"/>
 			</radiogroup>
 			</vbox>
 		</deck>
diff --git a/content/treestyletab/license.txt b/content/treestyletab/license.txt
index 38bcff5..eeda95c 100644
--- a/content/treestyletab/license.txt
+++ b/content/treestyletab/license.txt
@@ -14,7 +14,7 @@ License.
 The Original Code is the Tree Style Tab.
 
 The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
-Portions created by the Initial Developer are Copyright (C) 2007-2013
+Portions created by the Initial Developer are Copyright (C) 2007-2014
 the Initial Developer. All Rights Reserved.
 
 Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
diff --git a/content/treestyletab/treestyletab.css b/content/treestyletab/treestyletab.css
index 89147c2..68d5f5e 100644
--- a/content/treestyletab/treestyletab.css
+++ b/content/treestyletab/treestyletab.css
@@ -276,6 +276,14 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
  * it includes #TabsToolbar in its subqueries.
  */
 @media all and (-moz-windows-compositor) { /* for winstripe */
+	#navigator-toolbox
+	  > .treestyletab-tabbar-toolbar:not(#toolbar-menubar),
+	#navigator-toolbox
+	  > .treestyletab-tabbar-toolbar:not(#toolbar-menubar):-moz-lwtheme,
+	#navigator-toolbox
+	  > .treestyletab-tabbar-toolbar-ready:not(#toolbar-menubar),
+	#navigator-toolbox
+	  > .treestyletab-tabbar-toolbar-ready:not(#toolbar-menubar):-moz-lwtheme,
 	#navigator-toolbox[tabsontop="true"]
 	  > .treestyletab-tabbar-toolbar:not(#toolbar-menubar),
 	#navigator-toolbox[tabsontop="true"]
@@ -287,6 +295,12 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
 
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + .treestyletab-tabbar-toolbar:last-child,
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + .treestyletab-tabbar-toolbar:not(:last-child),
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
 	  + .treestyletab-tabbar-toolbar[tabsontop="true"]:last-child,
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
@@ -299,6 +313,12 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
 	  + .treestyletab-tabbar-toolbar[tabsontop="false"]:not(:last-child),
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + .treestyletab-tabbar-toolbar-ready:last-child,
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + .treestyletab-tabbar-toolbar-ready:not(:last-child),
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
 	  + .treestyletab-tabbar-toolbar-ready[tabsontop="true"]:last-child,
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
@@ -317,6 +337,12 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
 
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + #TabsToolbar:last-child,
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
+	  + #TabsToolbar:not(:last-child),heme,
+	#navigator-toolbox
+	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
 	  + #TabsToolbar[tabsontop="true"]:last-child,
 	#navigator-toolbox
 	  > #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"]
@@ -334,10 +360,11 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
 	}
 }
 @media not all and (-moz-windows-compositor) { /* for winstripe */
-	#TabsToolbar[tabsontop=true]:not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
-	#navigator-toolbox[tabsontop=false]
+	#TabsToolbar:not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
+	#TabsToolbar[tabsontop="true"]:not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
+	#navigator-toolbox[tabsontop="false"]
 	  > toolbar.treestyletab-tabbar-toolbar:not(#toolbar-menubar):not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
-	#navigator-toolbox[tabsontop=false]
+	#navigator-toolbox[tabsontop="false"]
 	  > toolbar.treestyletab-tabbar-toolbar-ready:not(#toolbar-menubar):not(:-moz-lwtheme):-moz-system-metric(windows-default-theme) {
 		-moz-binding: url(treestyletab.xml#toolbar-drag);
 	}
@@ -345,8 +372,10 @@ tabs.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-sc
 .treestyletab-tabbar-toolbar,
 .treestyletab-tabbar-toolbar-ready,
 /* for gnomestripe */
-#TabsToolbar.treestyletab-tabbar-toolbar[tabsontop="true"]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
-#TabsToolbar.treestyletab-tabbar-toolbar-ready[tabsontop="true"]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
+#TabsToolbar.treestyletab-tabbar-toolbar:not([autohide="true"]):not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
+#TabsToolbar.treestyletab-tabbar-toolbar:not([autohide="true"])[tabsontop="true"]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
+#TabsToolbar.treestyletab-tabbar-toolbar-ready:not([autohide="true"]):not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
+#TabsToolbar.treestyletab-tabbar-toolbar-ready:not([autohide="true"])[tabsontop="true"]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
 /* for pinstripe */
 toolbar.treestyletab-tabbar-toolbar:not([nowindowdrag="true"]),
 toolbar.treestyletab-tabbar-toolbar-ready:not([nowindowdrag="true"]),
diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js
index 6b46eb2..a7a638d 100644
--- a/content/treestyletab/windowHelper.js
+++ b/content/treestyletab/windowHelper.js
@@ -17,17 +17,6 @@ var TreeStyleTabWindowHelper = {
 				) {
 				target = 'gBrowserInit._delayedStartup';
 			}
-			else if ( // legacy code for Firefox 18 and olders
-				'onLoad' in gBrowserInit &&
-				(source = gBrowserInit.onLoad.toSource()) &&
-				source.indexOf('swapBrowsersAndCloseOther') > -1
-				) {
-				target = 'gBrowserInit.onLoad';
-			}
-		}
-		else if ('BrowserStartup' in window) { // legacy code for Firefox 15 and olders
-			source = window.BrowserStartup.toSource();
-			target = 'BrowserStartup';
 		}
 		if (!target)
 			dump('Tree Style Tab: failed to initialize startup function!');
@@ -170,14 +159,23 @@ var TreeStyleTabWindowHelper = {
 			)
 		);
 
-		if ('BrowserSearch' in window &&
-			'loadSearch' in BrowserSearch) {
-			eval('BrowserSearch.loadSearch = '+
-				BrowserSearch.loadSearch.toSource().replace(
-					'openLinkIn(',
-					'TreeStyleTabService.onBeforeBrowserSearch(arguments[0], useNewTab); $&'
-				)
-			);
+		if ('BrowserSearch' in window) {
+			if ('_loadSearch' in BrowserSearch) {
+				eval('BrowserSearch._loadSearch = '+
+					BrowserSearch._loadSearch.toSource().replace(
+						'openLinkIn(',
+						'TreeStyleTabService.onBeforeBrowserSearch(arguments[0], useNewTab); $&'
+					)
+				);
+			}
+			else if ('loadSearch' in BrowserSearch) { // Firefox 24 and olders
+				eval('BrowserSearch.loadSearch = '+
+					BrowserSearch.loadSearch.toSource().replace(
+						'openLinkIn(',
+						'TreeStyleTabService.onBeforeBrowserSearch(arguments[0], useNewTab); $&'
+					)
+				);
+			}
 		}
 
 		let (functions = [
@@ -278,13 +276,6 @@ var TreeStyleTabWindowHelper = {
 				'{ gBrowser.treeStyleTab.onBeforeFullScreenToggle(); '
 			)
 		);
-		// for Firefox 28 (29) and later
-		eval('FullScreen.showXULChrome = '+
-			FullScreen.showXULChrome.toSource().replace(
-				'var ctlsOnTabbar = window.toolbar.visible;',
-				'var ctlsOnTabbar = window.toolbar.visible && gBrowser.treeStyleTab.position == "top" && gBrowser.treeStyleTab.fixed;'
-			)
-		);
 
 		if ('PrintUtils' in window) {
 			eval('PrintUtils.printPreview = '+PrintUtils.printPreview.toSource().replace(
@@ -297,18 +288,12 @@ var TreeStyleTabWindowHelper = {
 			));
 		}
 
-		if ('TabsOnTop' in window && TabsOnTop.syncUI) { // Firefox 12 or later
+		if ('TabsOnTop' in window && TabsOnTop.syncUI) {
 			eval('TabsOnTop.syncUI = '+TabsOnTop.syncUI.toSource().replace(
 				/(\}\)?)$/,
 				'gBrowser.treeStyleTab.onTabsOnTopSyncCommand(enabled); $&'
 			));
 		}
-		if ('TabsOnTop' in window && TabsOnTop.syncCommand) { // Firefox 4-11
-			eval('TabsOnTop.syncCommand = '+TabsOnTop.syncCommand.toSource().replace(
-				/(\}\)?)$/,
-				'gBrowser.treeStyleTab.onTabsOnTopSyncCommand(enabled); $&'
-			));
-		}
 
 		if ('toggleSidebar' in window) {
 			eval('window.toggleSidebar = '+
@@ -364,7 +349,7 @@ var TreeStyleTabWindowHelper = {
 		tabbar.addEventListener('click', this.service, true);
 
 		var newTabButton = document.getElementById('new-tab-button');
-		const nsIDOMNode = Ci.nsIDOM3Node || Ci.nsIDOMNode; // on Firefox 7, nsIDOM3Node was merged to nsIDOMNode.
+		const nsIDOMNode = Ci.nsIDOMNode;
 		if (newTabButton &&
 			!(tabbar.compareDocumentPosition(newTabButton) & nsIDOMNode.DOCUMENT_POSITION_CONTAINED_BY))
 			newTabButton.parentNode.addEventListener('click', this.service, true);
@@ -382,7 +367,7 @@ var TreeStyleTabWindowHelper = {
 		tabbar.removeEventListener('click', this.service, true);
 
 		var newTabButton = document.getElementById('new-tab-button');
-		const nsIDOMNode = Ci.nsIDOM3Node || Ci.nsIDOMNode; // on Firefox 7, nsIDOM3Node was merged to nsIDOMNode.
+		const nsIDOMNode = Ci.nsIDOMNode;
 		if (newTabButton &&
 			!(tabbar.compareDocumentPosition(newTabButton) & Ci.nsIDOMNode.DOCUMENT_POSITION_CONTAINED_BY))
 			newTabButton.parentNode.removeEventListener('click', this.service, true);
@@ -397,18 +382,8 @@ var TreeStyleTabWindowHelper = {
 		var b = aTabBrowser;
 
 		let (source = b.moveTabForward.toSource()) {
-			if (source.indexOf('nextTab.hidden') < 0) { // Firefox 19 or olders
-				source = source.replace(
-					'{', '{ var nextTab;'
-				).replace(
-					'tabPos < this.browsers.length - 1',
-					'nextTab = this.treeStyleTab.getNextSiblingTab(this.mCurrentTab)'
-				).replace(
-					'tabPos + 1', 'nextTab._tPos'
-				);
-			}
-			else {
-				source = source.replace(
+			eval('b.moveTabForward = '+
+				source.replace(
 					'if (nextTab)',
 					'(function() {\n' +
 					'  if (this.treeStyleTab.hasChildTabs(this.mCurrentTab)) {\n' +
@@ -418,10 +393,7 @@ var TreeStyleTabWindowHelper = {
 					'  }\n' +
 					'}).call(this);' +
 					'$&'
-				);
-			}
-			eval('b.moveTabForward = '+
-				source.replace(
+				).replace(
 					/(this.moveTabTo\([^;]+\);)/,
 					'(function() {\n' +
 					'  let descendant = this.treeStyleTab.getDescendantTabs(nextTab);\n' +
@@ -449,16 +421,6 @@ var TreeStyleTabWindowHelper = {
 		}
 
 		let (source = b.moveTabBackward.toSource()) {
-			if (source.indexOf('prevTab.hidden') < 0) { // Firefox 19 or olders
-				source = source.replace(
-					'{', '{ var prevTab;'
-				).replace(
-					'tabPos > 0',
-					'prevTab = this.treeStyleTab.getPreviousSiblingTab(this.mCurrentTab)'
-				).replace(
-					'tabPos - 1', 'prevTab._tPos'
-				);
-			}
 			eval('b.moveTabBackward = '+
 				source.replace(
 					'this.moveTabToEnd();',
diff --git a/content/treestyletab/windowHelperHacks.js b/content/treestyletab/windowHelperHacks.js
index b0e4ed5..ca6510f 100644
--- a/content/treestyletab/windowHelperHacks.js
+++ b/content/treestyletab/windowHelperHacks.js
@@ -1353,6 +1353,32 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
 		}
 	}
 
+	// Tab Control
+	// https://addons.mozilla.org/firefox/addon/tab-control/
+	if (
+		TreeStyleTabUtils.getTreePref('compatibility.TabControl') &&
+		'gTabControl' in window
+		) {
+		let listener = {
+				handleEvent : function(aEvent)
+				{
+					switch (aEvent.type)
+					{
+						case sv.kEVENT_TYPE_FOCUS_NEXT_TAB:
+							if (TreeStyleTabUtils.prefs.getPref('tabcontrol.focusLeftOnClose'))
+								aEvent.preventDefault();
+							break;
+
+						case 'unload':
+							document.removeEventListener(sv.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false);
+							break;
+					}
+				}
+			};
+		document.addEventListener(sv.kEVENT_TYPE_FOCUS_NEXT_TAB, listener, false);
+		document.addEventListener('unload', listener, false);
+	}
+
 	// Firefox Sync (Weave)
 	// http://www.mozilla.com/en-US/firefox/sync/
 	if (
diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js
index 3f76202..73880a8 100644
--- a/defaults/preferences/treestyletab.js
+++ b/defaults/preferences/treestyletab.js
@@ -601,7 +601,6 @@ pref("extensions.treestyletab.restoreTree.level", 1);
  * conflict with TST features. They will be rolled back when TST is uninstalled.
  */
 pref("browser.link.open_newwindow.restriction.override", 0);
-pref("browser.tabs.loadFolderAndReplace.override", false);
 pref("browser.tabs.insertRelatedAfterCurrent.override", false);
 pref("browser.tabs.insertRelatedAfterCurrent.override.force", true);
 
@@ -662,6 +661,7 @@ pref("extensions.treestyletab.compatibility.Locationbar2", true);
 pref("extensions.treestyletab.compatibility.MouseGesturesRedox", true);
 pref("extensions.treestyletab.compatibility.MouselessBrowsing", true);
 pref("extensions.treestyletab.compatibility.MultiLinks", true);
+pref("extensions.treestyletab.compatibility.NavbarOnTitlebar", true);
 pref("extensions.treestyletab.compatibility.OptimozTweaks", true);
 pref("extensions.treestyletab.compatibility.PermaTabs", true);
 pref("extensions.treestyletab.compatibility.PersonalTitlebar", true);
@@ -677,6 +677,7 @@ pref("extensions.treestyletab.compatibility.STM.warnForNewTabPosition", true);
 pref("extensions.treestyletab.compatibility.STM", true); // Super Tab Mode
 pref("extensions.treestyletab.compatibility.SuperDragAndGo", true);
 pref("extensions.treestyletab.compatibility.Tabberwocky", true);
+pref("extensions.treestyletab.compatibility.TabControl", true);
 pref("extensions.treestyletab.compatibility.TabUtilities", true);
 pref("extensions.treestyletab.compatibility.TMP", true); // Tab Mix Plus
 pref("extensions.treestyletab.compatibility.TooManyTabs", true);
diff --git a/install.rdf b/install.rdf
index 301223c..2208bba 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,7 +5,7 @@
   <RDF:Description RDF:about="urn:mozilla:install-manifest"
                    em:id="treestyletab at piro.sakura.ne.jp"
                    em:name="Tree Style Tab"
-                   em:version="0.14.2013112901"
+                   em:version="0.14.2014020901"
                    em:creator="YUKI "Piro" Hiroshi"
                    em:description="Show tabs like a tree."
                    em:homepageURL="http://piro.sakura.ne.jp/xul/_treestyletab.html.en"
@@ -194,7 +194,7 @@
     <em:targetApplication>
       <RDF:Description em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
                        em:minVersion="24.0"
-                       em:maxVersion="28.0a1" />
+                       em:maxVersion="30.0a1" />
     </em:targetApplication>
   </RDF:Description>
 </RDF:RDF>
diff --git a/locale/da-DK/treestyletab/treestyletab.dtd b/locale/da-DK/treestyletab/treestyletab.dtd
index 5e8ca72..fa4f94e 100644
--- a/locale/da-DK/treestyletab/treestyletab.dtd
+++ b/locale/da-DK/treestyletab/treestyletab.dtd
@@ -98,7 +98,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat "Ignorer">
 <!ENTITY config.openGroupBookmark.subtree.type.after "Faners træstruktur gemt i bogmærker">
 <!ENTITY config.openGroupBookmark.flat "Åben som faner (Firefox standard)">
-<!ENTITY config.openGroupBookmark.replace "Erstat aktuel fane med siderne i mappen">
 <!ENTITY config.openGroupBookmark.underParent "Arranger faner under ny gruppefane">
 
 <!ENTITY config.dropLinksOnTab.caption "Droppet link, URL, bogmærke eller fil til eksisterende fane">
diff --git a/locale/de-DE/treestyletab/treestyletab.dtd b/locale/de-DE/treestyletab/treestyletab.dtd
index e08d884..540c49a 100644
--- a/locale/de-DE/treestyletab/treestyletab.dtd
+++ b/locale/de-DE/treestyletab/treestyletab.dtd
@@ -99,7 +99,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignoriere">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "Anordnung der Tabs im Zweig beim Speichern als Lesezeichen">
 <!ENTITY config.openGroupBookmark.flat        "Als eigenständige Tabs öffnen (Firefox Standard)">
-<!ENTITY config.openGroupBookmark.replace     "Aktuelles Tab durch die neuen Tabs ersetzen">
 <!ENTITY config.openGroupBookmark.underParent "Seiten zur Gruppierung einem Dummytab unterordnen">
 
 <!ENTITY config.dropLinksOnTab.caption "Verhalten für Drag & Drop auf Tabs">
diff --git a/locale/en-US/treestyletab/license.txt b/locale/en-US/treestyletab/license.txt
index 690b3e7..9dc284f 100644
--- a/locale/en-US/treestyletab/license.txt
+++ b/locale/en-US/treestyletab/license.txt
@@ -14,7 +14,7 @@ License.
 The Original Code is the Tree Style Tab.
 
 The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
-Portions created by the Initial Developer are Copyright (C) 2007-2012
+Portions created by the Initial Developer are Copyright (C) 2007-2014
 the Initial Developer. All Rights Reserved.
 
 Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd
index 0b147f9..2d67053 100644
--- a/locale/en-US/treestyletab/treestyletab.dtd
+++ b/locale/en-US/treestyletab/treestyletab.dtd
@@ -84,7 +84,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignore">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "tree structure of tabs saved to bookmarks">
 <!ENTITY config.openGroupBookmark.flat        "Open as separate tabs (Firefox default)">
-<!ENTITY config.openGroupBookmark.replace     "Replace the current one tab with the pages in the folder">
 <!ENTITY config.openGroupBookmark.underParent "Put tabs under a dummy tab for grouping">
 
 <!ENTITY config.dropLinksOnTab.caption "Dropped link, URL, bookmark or file to existing tab">
diff --git a/locale/es-ES/treestyletab/treestyletab.dtd b/locale/es-ES/treestyletab/treestyletab.dtd
index dd5cdae..1718a4e 100644
--- a/locale/es-ES/treestyletab/treestyletab.dtd
+++ b/locale/es-ES/treestyletab/treestyletab.dtd
@@ -87,7 +87,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignorar">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "Estructura del árbol guardado en marcadores">
 <!ENTITY config.openGroupBookmark.flat        "Abrir como pestañas separadas (Firefox Predeterminado)">
-<!ENTITY config.openGroupBookmark.replace     "Remplazar la pestaña actual con las páginas de la carpeta">
 <!ENTITY config.openGroupBookmark.underParent "Agrupar las pestañas bajo una carpeta">
 
 <!ENTITY config.dropLinksOnTab.caption "Dropped link, URL, bookmark or file to existing tab">
diff --git a/locale/fr-FR/treestyletab/treestyletab.dtd b/locale/fr-FR/treestyletab/treestyletab.dtd
index 93356fb..c9c4d78 100644
--- a/locale/fr-FR/treestyletab/treestyletab.dtd
+++ b/locale/fr-FR/treestyletab/treestyletab.dtd
@@ -85,7 +85,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignorer">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "l'arborescence des onglets sauvegardée dans les marque-pages">
 <!ENTITY config.openGroupBookmark.flat        "Ouvrir dans des onglets séparés (défaut Firefox)">
-<!ENTITY config.openGroupBookmark.replace     "Remplacer l'onglet actuel par les pages du dossier">
 <!ENTITY config.openGroupBookmark.underParent "Mettre les onglets sous un onglet fictif afin de les grouper">
 
 <!ENTITY config.dropLinksOnTab.caption "Action pour les glisser-déposer de liens, URL, marques-pages ou fichiers sur un onglet existant">
diff --git a/locale/it-IT/treestyletab/treestyletab.dtd b/locale/it-IT/treestyletab/treestyletab.dtd
index ce3047c..73fdcd2 100644
--- a/locale/it-IT/treestyletab/treestyletab.dtd
+++ b/locale/it-IT/treestyletab/treestyletab.dtd
@@ -87,7 +87,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignore">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "tree structure of tabs saved to bookmarks">
 <!ENTITY config.openGroupBookmark.flat        "apre i segnalibri in schede separate (comportamento predefinito di Firefox)">
-<!ENTITY config.openGroupBookmark.replace     "sostituisce la scheda in uso con i segnalibri contenuti nella cartella selezionata">
 <!ENTITY config.openGroupBookmark.underParent "Put tabs under a dummy tab for grouping">
 
 <!ENTITY config.dropLinksOnTab.caption "Dropped link, URL, bookmark or file to existing tab">
diff --git a/locale/ja/treestyletab/license.txt b/locale/ja/treestyletab/license.txt
index 690b3e7..9dc284f 100644
--- a/locale/ja/treestyletab/license.txt
+++ b/locale/ja/treestyletab/license.txt
@@ -14,7 +14,7 @@ License.
 The Original Code is the Tree Style Tab.
 
 The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
-Portions created by the Initial Developer are Copyright (C) 2007-2012
+Portions created by the Initial Developer are Copyright (C) 2007-2014
 the Initial Developer. All Rights Reserved.
 
 Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd
index 1a6416c..106d279 100644
--- a/locale/ja/treestyletab/treestyletab.dtd
+++ b/locale/ja/treestyletab/treestyletab.dtd
@@ -85,7 +85,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "無視する">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "">
 <!ENTITY config.openGroupBookmark.flat        "ばらばらのタブとして開く(Firefox初期状態)">
-<!ENTITY config.openGroupBookmark.replace     "現在のタブ1つだけをブックマークの内容で置き換える">
 <!ENTITY config.openGroupBookmark.underParent "グループ化用のダミーのタブを親にする">
 
 <!ENTITY config.dropLinksOnTab.caption "タブにドラッグ&ドロップされたリンク、URL、ブックマーク、ファイルなど">
diff --git a/locale/pl/treestyletab/treestyletab.dtd b/locale/pl/treestyletab/treestyletab.dtd
index 9823dd2..ec698c6 100644
--- a/locale/pl/treestyletab/treestyletab.dtd
+++ b/locale/pl/treestyletab/treestyletab.dtd
@@ -87,7 +87,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Zignoruj">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "strukturę drzewiastą kart zapisanych jako zakładki">
 <!ENTITY config.openGroupBookmark.flat        "Otwieraj jako osobne karty (domyślnie działanie Firefoksa)">
-<!ENTITY config.openGroupBookmark.replace     "Zastępuj aktywną kartę stronami z folderu">
 <!ENTITY config.openGroupBookmark.underParent "Umieszczaj karty pod pustą kartą dla lepszego grupowania">
 
 <!ENTITY config.dropLinksOnTab.caption "Dropped link, URL, bookmark or file to existing tab">
diff --git a/locale/ru/treestyletab/treestyletab.dtd b/locale/ru/treestyletab/treestyletab.dtd
index 31f5a83..25f301e 100755
--- a/locale/ru/treestyletab/treestyletab.dtd
+++ b/locale/ru/treestyletab/treestyletab.dtd
@@ -85,7 +85,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Игнорировать">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "структуру дерева вкладок, сохраненную в закладках">
 <!ENTITY config.openGroupBookmark.flat        "Открывать как раздельные вкладки (по умолчанию в Firefox)">
-<!ENTITY config.openGroupBookmark.replace     "Открывать с заменой текущей вкладки">
 <!ENTITY config.openGroupBookmark.underParent "Поместить вкладки в «титульную» родительскую вкладку">
 
 <!ENTITY config.dropLinksOnTab.caption "При перетаскивании ссылки, закладки или файла на существующую вкладку">
diff --git a/locale/sv-SE/treestyletab/treestyletab.dtd b/locale/sv-SE/treestyletab/treestyletab.dtd
index 216d973..273572d 100644
--- a/locale/sv-SE/treestyletab/treestyletab.dtd
+++ b/locale/sv-SE/treestyletab/treestyletab.dtd
@@ -97,7 +97,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "Ignorera">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "trädstrukturen för flikar som sparats till bokmärken">
 <!ENTITY config.openGroupBookmark.flat        "Öppna som separata flikar (standard i Firefox)">
-<!ENTITY config.openGroupBookmark.replace     "Ersätt den aktuella fliken med sidorna i mappen">
 <!ENTITY config.openGroupBookmark.underParent "Placera flikar under en tillfällig flik för gruppering">
 
 <!ENTITY config.dropLinksOnTab.caption "När länk, URL, bokmärke eller fil släpps på befintlig flik">
diff --git a/locale/zh-CN/treestyletab/treestyletab.dtd b/locale/zh-CN/treestyletab/treestyletab.dtd
index ee77120..426efe0 100644
--- a/locale/zh-CN/treestyletab/treestyletab.dtd
+++ b/locale/zh-CN/treestyletab/treestyletab.dtd
@@ -97,7 +97,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "忽略">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "保存到书签时的树状结构">
 <!ENTITY config.openGroupBookmark.flat        "在单独标签中平行打开(Firefox 默认)">
-<!ENTITY config.openGroupBookmark.replace     "覆盖当前标签打开">
 <!ENTITY config.openGroupBookmark.underParent "将标签置于一伪标签下以便分组">
 
 <!ENTITY config.dropLinksOnTab.caption "如何打开拖拽到现有标签的链接、网址、书签或文件?">
diff --git a/locale/zh-TW/treestyletab/treestyletab.dtd b/locale/zh-TW/treestyletab/treestyletab.dtd
index 9e3e868..1e3c0a4 100644
--- a/locale/zh-TW/treestyletab/treestyletab.dtd
+++ b/locale/zh-TW/treestyletab/treestyletab.dtd
@@ -85,7 +85,6 @@
 <!ENTITY config.openGroupBookmark.subtree.type.flat    "忽略">
 <!ENTITY config.openGroupBookmark.subtree.type.after   "樹狀結構">
 <!ENTITY config.openGroupBookmark.flat        "以各自的分頁開啟(Firefox 預設)">
-<!ENTITY config.openGroupBookmark.replace     "將目前瀏覽的分頁取代為書籤的內容">
 <!ENTITY config.openGroupBookmark.underParent "開啟於一個分組用的父分頁下">
 
 <!ENTITY config.dropLinksOnTab.caption "拖曳鏈結、URL 或書籤到現存分頁時">
diff --git a/modules/autoHide.js b/modules/autoHide.js
index 695fbff..52bb84d 100644
--- a/modules/autoHide.js
+++ b/modules/autoHide.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2010-2013
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -84,6 +84,7 @@ AutoHideBrowser.prototype = {
 	kSHOWHIDE_BY_END    : 1 << 4,
 	kSHOWHIDE_BY_POSITION_CHANGE : 1 << 5,
 	kSHOWHIDE_BY_RESIZE : 1 << 6,
+	kSHOWHIDE_BY_API    : 1 << 8,
 	kHIDDEN_BY_CLICK    : 1 << 7,
  
 	get mode() /* PUBLIC API */ 
@@ -219,10 +220,11 @@ AutoHideBrowser.prototype = {
 		return this.document.getElementById('treestyletab-tabbar-resizer-splitter');
 	},
  
-	start : function AHB_start() 
+	start : function AHB_start(aReason) 
 	{
 		if (this.enabled) return;
 		this.enabled = true;
+		aReason = aReason || 0;
 
 		var sv = this.treeStyleTab;
 		var b  = this.browser;
@@ -232,22 +234,25 @@ AutoHideBrowser.prototype = {
 
 		sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_EXPANDED);
 
-		b.addEventListener('mousedown', this, true);
-		b.addEventListener('mouseup', this, true);
-		b.addEventListener('dragover', this, true);
-		b.addEventListener('dragleave', this, true);
-		sv.tabStrip.addEventListener('mousedown', this, true);
-		sv.tabStrip.addEventListener('mouseup', this, true);
+		if (!(aReason & this.kSHOWHIDE_BY_API)) {
+			b.addEventListener('mousedown', this, true);
+			b.addEventListener('mouseup', this, true);
+			b.addEventListener('dragover', this, true);
+			b.addEventListener('dragleave', this, true);
+			sv.tabStrip.addEventListener('mousedown', this, true);
+			sv.tabStrip.addEventListener('mouseup', this, true);
+			if (this.shouldListenMouseMove)
+				this.startListenMouseMove();
+			if (b == w.gBrowser && sv.shouldListenKeyEventsForAutoHide)
+				w.TreeStyleTabService.startListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
+			this.userActionListening = true;
+		}
 		w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
 		w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
-		if (this.shouldListenMouseMove)
-			this.startListenMouseMove();
-		if (b == w.gBrowser && sv.shouldListenKeyEventsForAutoHide)
-			w.TreeStyleTabService.startListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
 
 		this.updateTransparency();
 
-		this.showHideInternal(this.kSHOWHIDE_BY_START);
+		this.showHideInternal(this.kSHOWHIDE_BY_START | aReason);
 
 		b.treeStyleTab.fixTooNarrowTabbar();
 	},
@@ -265,17 +270,20 @@ AutoHideBrowser.prototype = {
 
 		this.screen.hidePopup();
 
-		b.removeEventListener('mousedown', this, true);
-		b.removeEventListener('mouseup', this, true);
-		b.removeEventListener('dragover', this, true);
-		b.removeEventListener('dragleave', this, true);
-		sv.tabStrip.removeEventListener('mousedown', this, true);
-		sv.tabStrip.removeEventListener('mouseup', this, true);
+		if (this.userActionListening) {
+			b.removeEventListener('mousedown', this, true);
+			b.removeEventListener('mouseup', this, true);
+			b.removeEventListener('dragover', this, true);
+			b.removeEventListener('dragleave', this, true);
+			sv.tabStrip.removeEventListener('mousedown', this, true);
+			sv.tabStrip.removeEventListener('mouseup', this, true);
+			this.endListenMouseMove();
+			if (b == w.gBrowser)
+				w.TreeStyleTabService.endListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
+			this.userActionListening = false;
+		}
 		w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
 		w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
-		this.endListenMouseMove();
-		if (b == w.gBrowser)
-			w.TreeStyleTabService.endListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
 
 		this.updateTransparency();
 
@@ -660,9 +668,14 @@ AutoHideBrowser.prototype = {
 		var b   = this.browser;
 		var pos = sv.position;
 
+		aReason = aReason || 0;
+
 		if (this.expanded) { // to be hidden or shrunken
+			let reason = this.kSHOWN_BY_UNKNOWN;
+			if (aReason & this.kSHOWHIDE_BY_API)
+				reason = aReason;
 			this.onHiding();
-			this.showHideReason = this.kSHOWN_BY_UNKNOWN;
+			this.showHideReason = reason;
 		}
 		else { // to be shown or expanded
 			this.onShowing();
@@ -680,9 +693,9 @@ AutoHideBrowser.prototype = {
 				(aReason & this.kSHOWHIDE_BY_RESIZE ? 'resize ' : '' ) +
 				(aReason & this.kHIDDEN_BY_CLICK ? 'click ' : '' );
 			if (this.expanded)
-				dump('autoHide: hide by ' + humanReadableReason + '\n');
-			else
 				dump('autoHide: show by ' + humanReadableReason + '\n');
+			else
+				dump('autoHide: hide by ' + humanReadableReason + '\n');
 		}
 
 		this.fireStateChangingEvent();
@@ -732,6 +745,11 @@ AutoHideBrowser.prototype = {
 	
 	show : function AHB_show(aReason) /* PUBLIC API */ 
 	{
+		if (this.showHideReason & this.kSHOWHIDE_BY_API) {
+			this.end();
+			return;
+		}
+
 		if (aReason) {
 			this.showHideReason |= aReason;
 		}
@@ -741,6 +759,11 @@ AutoHideBrowser.prototype = {
  
 	hide : function AHB_hide(aReason) /* PUBLIC API */ 
 	{
+		if (!this.enabled) {
+			this.start(aReason | this.kSHOWHIDE_BY_API);
+			return;
+		}
+
 		if (aReason) {
 			if (aReason == this.kSHOWN_BY_ANY_REASON)
 				this.showHideReason &= ~this.kSHOWN_BY_ANY_REASON;
@@ -802,6 +825,7 @@ AutoHideBrowser.prototype = {
 				break;
 
 			case this.kMODE_HIDE:
+				sv.updateLastScrollPosition();
 				sv.setTabbrowserAttribute(this.kAUTOHIDE, 'hidden');
 				sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_HIDDEN);
 				sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
diff --git a/modules/base.js b/modules/base.js
index 9ee18c6..ae2a7a7 100644
--- a/modules/base.js
+++ b/modules/base.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2010-2013
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -135,7 +135,6 @@ var TreeStyleTabBase = {
 		this.onPrefChange('extensions.treestyletab.indent.vertical');
 		this.onPrefChange('extensions.treestyletab.indent.horizontal');
 		this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
-		this.onPrefChange('browser.tabs.loadFolderAndReplace.override');
 		this.onPrefChange('browser.tabs.insertRelatedAfterCurrent.override');
 		this.onPrefChange('extensions.stm.tabBarMultiRows.override'); // Super Tab Mode
 		this.onPrefChange('extensions.treestyletab.tabbar.scroll.smooth');
@@ -187,7 +186,6 @@ var TreeStyleTabBase = {
 			prefs.removePrefListener(this);
 
 			let restorePrefs = [
-				'browser.tabs.loadFolderAndReplace',
 				'browser.tabs.insertRelatedAfterCurrent',
 				'extensions.stm.tabBarMultiRows' // Super Tab Mode
 			];
@@ -323,8 +321,6 @@ var TreeStyleTabBase = {
 		{
 			let target = targets.getNext()
 							.QueryInterface(Ci.nsIDOMWindow);
-			if ('nsIDOMWindowInternal' in Ci) // for Firefox 7 or olders
-				target = target.QueryInterface(Ci.nsIDOMWindowInternal);
 			windows.push(target);
 		}
 
@@ -396,11 +392,10 @@ var TreeStyleTabBase = {
 				utils.treeBundle.getString('openGroupBookmarkBehavior.title'),
 				utils.treeBundle.getString('openGroupBookmarkBehavior.text'),
 				(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
-				(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1) +
-				(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2),
+				(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1),
 				utils.treeBundle.getString('openGroupBookmarkBehavior.subTree'),
 				utils.treeBundle.getString('openGroupBookmarkBehavior.separate'),
-				utils.treeBundle.getString('openGroupBookmarkBehavior.replace'),
+				null,
 				utils.treeBundle.getString('openGroupBookmarkBehavior.never'),
 				checked
 			);
@@ -409,14 +404,12 @@ var TreeStyleTabBase = {
 			button = 1;
 		var behaviors = [
 				this.kGROUP_BOOKMARK_SUBTREE | dummyTabFlag,
-				this.kGROUP_BOOKMARK_SEPARATE,
-				this.kGROUP_BOOKMARK_REPLACE
+				this.kGROUP_BOOKMARK_SEPARATE
 			];
 		behavior = behaviors[button];
 
 		if (checked.value) {
 			utils.setTreePref('openGroupBookmark.behavior', behavior);
-			prefs.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
 		}
 		return behavior;
 	},
@@ -424,7 +417,6 @@ var TreeStyleTabBase = {
 	kGROUP_BOOKMARK_FIXED     : 1 + 2 + 4,
 	kGROUP_BOOKMARK_SUBTREE   : 1,
 	kGROUP_BOOKMARK_SEPARATE  : 2,
-	kGROUP_BOOKMARK_REPLACE   : 4,
 	kGROUP_BOOKMARK_USE_DUMMY                   : 256,
 	kGROUP_BOOKMARK_USE_DUMMY_FORCE             : 1024,
 	kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE : 512,
@@ -2429,7 +2421,6 @@ var TreeStyleTabBase = {
 	domains : [ 
 		'extensions.treestyletab.',
 		'browser.tabs.animate',
-		'browser.tabs.loadFolderAndReplace',
 		'browser.tabs.insertRelatedAfterCurrent',
 		'extensions.stm.tabBarMultiRows' // Super Tab Mode
 	],
@@ -2463,14 +2454,12 @@ var TreeStyleTabBase = {
 				return this.updateTabWidthPrefs(aPrefName);
 
 			case 'browser.tabs.insertRelatedAfterCurrent':
-			case 'browser.tabs.loadFolderAndReplace':
 			case 'extensions.stm.tabBarMultiRows': // Super Tab Mode
 				if (this.prefOverriding)
 					return;
 				aPrefName += '.override';
 				prefs.setPref(aPrefName, value);
 			case 'browser.tabs.insertRelatedAfterCurrent.override':
-			case 'browser.tabs.loadFolderAndReplace.override':
 			case 'extensions.stm.tabBarMultiRows.override': // Super Tab Mode
 				if (prefs.getPref(aPrefName+'.force')) {
 					let defaultValue = prefs.getDefaultPref(aPrefName);
diff --git a/modules/browser.js b/modules/browser.js
index 06fcf40..980eead 100644
--- a/modules/browser.js
+++ b/modules/browser.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2011-2013
+ * Portions created by the Initial Developer are Copyright (C) 2011-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -317,6 +317,17 @@ TreeStyleTabBrowser.prototype = {
 		return (box.getAttribute('orient') || this.window.getComputedStyle(box, '').getPropertyValue('-moz-box-orient')) == 'vertical';
 	},
  
+	get isVisible()
+	{
+		var bar = this.ownerToolbar;
+		var style = this.window.getComputedStyle(bar, '');
+		if (style.visibility != 'visible' || style.display == 'none')
+			return false;
+
+		var box = bar.boxObject;
+		return !!(box.width || box.height);
+	},
+ 
 	isFloating : true, // for backward compatibility (but this should be removed) 
  
 	get ownerToolbar() 
@@ -740,7 +751,6 @@ TreeStyleTabBrowser.prototype = {
 		Services.obs.addObserver(this, this.kTOPIC_INDENT_MODIFIED, false);
 		Services.obs.addObserver(this, this.kTOPIC_COLLAPSE_EXPAND_ALL, false);
 		Services.obs.addObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY, false);
-		Services.obs.addObserver(this, 'private-browsing-change-granted', false); // only for Firefox 19 and olders
 		Services.obs.addObserver(this, 'lightweight-theme-styling-update', false);
 		prefs.addPrefListener(this);
 
@@ -765,8 +775,8 @@ TreeStyleTabBrowser.prototype = {
 
 		var self = this;
 		(this.deferredTasks['init'] = this.Deferred.next(function() {
-			// On Firefox 12 and later, this command is always enabled
-			// and the TabsOnTop can be enabled by <tabbrowser>.updateVisibility().
+			// This command is always enabled and the TabsOnTop can be enabled
+			// by <tabbrowser>.updateVisibility().
 			// So we have to reset TabsOnTop state on the startup.
 			var toggleTabsOnTop = d.getElementById('cmd_ToggleTabsOnTop');
 			var TabsOnTop = 'TabsOnTop' in w ? w.TabsOnTop : null ;
@@ -1839,8 +1849,7 @@ TreeStyleTabBrowser.prototype = {
 				(aReason & this.kTABBAR_UPDATE_BY_FULLSCREEN ? 'fullscreen ' : '' ) +
 				(aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE ? 'autohide ' : '' ) +
 				(aReason & this.kTABBAR_UPDATE_BY_INITIALIZE ? 'initialize ' : '' ) +
-				(aReason & this.kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR ? 'toggle-sidebar ' : '' ) +
-				(aReason & this.kTABBAR_UPDATE_BY_PRIVATE_BROWSING ? 'private-browsing ' : '' );
+				(aReason & this.kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR ? 'toggle-sidebar ' : '' );
 			dump('TSTBrowser_updateFloatingTabbarInternal: ' + humanReadableReason + '\n');
 		}
 
@@ -1961,6 +1970,13 @@ TreeStyleTabBrowser.prototype = {
 			this.positionPinnedTabs(null, null, aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE);
 		else
 			this.positionPinnedTabsWithDelay(null, null, aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE);
+
+		if (!collapsed && aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE) {
+			let self = this;
+			this.Deferred.next(function() {
+				self.scrollToTab(self.browser.selectedTab);
+			});
+		}
 	},
 	getTabbarPlaceholderSize: function TSTBrowser_getTabbarPlaceholderSize()
 	{
@@ -2157,7 +2173,6 @@ TreeStyleTabBrowser.prototype = {
 		Services.obs.removeObserver(this, this.kTOPIC_INDENT_MODIFIED);
 		Services.obs.removeObserver(this, this.kTOPIC_COLLAPSE_EXPAND_ALL);
 		Services.obs.removeObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY);
-		Services.obs.removeObserver(this, 'private-browsing-change-granted'); // only for Firefox 19 and olders
 		Services.obs.removeObserver(this, 'lightweight-theme-styling-update');
 		prefs.removePrefListener(this);
 
@@ -2404,11 +2419,6 @@ TreeStyleTabBrowser.prototype = {
 				}
 				return;
 
-			case 'private-browsing-change-granted': // only for Firefox 19 and olders
-				this.collapseExpandAllSubtree(false, true);
-				this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PRIVATE_BROWSING);
-				return;
-
 			case 'lightweight-theme-styling-update':
 				return this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_APPEARANCE_CHANGE);
 
@@ -2800,7 +2810,7 @@ TreeStyleTabBrowser.prototype = {
 	
 	restoreLastScrollPosition : function TSTBrowser_restoreLastScrollPosition() 
 	{
-		if (this.lastScrollX < 0 || this.lastScrollY < 0)
+		if (this.lastScrollX < 0 || this.lastScrollY < 0 || !this.isVisible)
 			return;
 		var lastX = this.lastScrollX;
 		var lastY = this.lastScrollY;
@@ -2822,7 +2832,7 @@ TreeStyleTabBrowser.prototype = {
  
 	updateLastScrollPosition : function TSTBrowser_updateLastScrollPosition() 
 	{
-		if (!this.isVertical)
+		if (!this.isVertical || !this.isVisible)
 			return;
 		var x = {}, y = {};
 		var scrollBoxObject = this.scrollBoxObject;
@@ -2886,7 +2896,7 @@ TreeStyleTabBrowser.prototype = {
 			let parent = this.getTabById(this.parentTab);
 			if (parent) {
 				let tabs = [parent].concat(this.getDescendantTabs(parent));
-				parent = pareintIndexInTree < tabs.length ? tabs[pareintIndexInTree] : parent ;
+				parent = pareintIndexInTree > -1 && pareintIndexInTree < tabs.length ? tabs[pareintIndexInTree] : parent ;
 			}
 			if (parent) {
 				this.attachTabTo(tab, parent, {
@@ -6507,18 +6517,34 @@ TreeStyleTabBrowser.prototype = {
 			return;
 
 		var level = utils.getTreePref('restoreTree.level');
+
+		var tabs = this.getAllTabs(this.mTabBrowser);
+		var tabsToRestore = 0;
+		if (utils.SessionStoreInternal &&
+			utils.SessionStoreInternal._browserEpochs) {
+			// for Firefox 29 and later
+			// (after https://bugzilla.mozilla.org/show_bug.cgi?id=942374)
+			var browserEpochs = utils.SessionStoreInternal._browserEpochs;
+			tabsToRestore = tabs.filter(function(aTab) {
+				return browserEpochs.has(aTab.linkedBrowser.permanentKey);
+			}).length;
+		}
+		else {
+			// for Firefox 24 and old versions
+			tabsToRestore = this.window.__SS_tabsToRestore;
+		}
+
 		dump('TSTBrowser::restoreTree\n');
 		dump('  level = '+level+'\n');
-		dump('  tabsToRestore = '+this.window.__SS_tabsToRestore+'\n');
+		dump('  tabsToRestore = '+tabsToRestore+'\n');
 		if (
 			level <= this.kRESTORE_TREE_LEVEL_NONE ||
-			!this.window.__SS_tabsToRestore ||
-			this.window.__SS_tabsToRestore <= 1
+			!tabsToRestore ||
+			tabsToRestore <= 1
 			)
 			return;
 
 		var onlyVisible = level <= this.kRESTORE_TREE_ONLY_VISIBLE;
-		var tabs = this.getAllTabs(this.mTabBrowser);
 		tabs = tabs.filter(function(aTab) {
 			return (
 				utils.isTabNotRestoredYet(aTab) &&
diff --git a/modules/browserUIShowHideObserver.js b/modules/browserUIShowHideObserver.js
index f9dde4b..3ba3cdb 100644
--- a/modules/browserUIShowHideObserver.js
+++ b/modules/browserUIShowHideObserver.js
@@ -124,11 +124,6 @@ BrowserUIShowHideObserver.prototype = {
 		aMutations.forEach(function(aMutation) {
 			if (aMutation.type != 'attributes')
 				return;
-			if (aTargetElement.id == 'toolbar-menubar' &&
-				aMutation.attributeName == 'autohide') {
-				this.owner.updateTabsInTitlebarForMenubar();
-				return;
-			}
 			if (aMutation.attributeName == 'hidden' ||
 				aMutation.attributeName == 'collapsed' ||
 				aMutation.attributeName == 'moz-collapsed' || // Used in full screen mode
diff --git a/modules/constants.js b/modules/constants.js
index ed8e3bf..0adb08b 100644
--- a/modules/constants.js
+++ b/modules/constants.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2010-2013
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -179,12 +179,11 @@ const TreeStyleTabConstants = Object.freeze({
 	kTABBAR_UPDATE_BY_TABBAR_RESIZE     : (1 << 5),
 	kTABBAR_UPDATE_BY_WINDOW_RESIZE     : (1 << 6),
 	kTABBAR_UPDATE_BY_FULLSCREEN        : (1 << 7),
-	kTABBAR_UPDATE_BY_PRIVATE_BROWSING  : (1 << 8),
 	kTABBAR_UPDATE_BY_AUTOHIDE          : (1 << 9),
 	kTABBAR_UPDATE_BY_INITIALIZE        : (1 << 10),
 	kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR    : (1 << 11),
 	kTABBAR_UPDATE_NOW                 : (1 << 5) | (1 << 6) | (1 << 9) | (1 << 10),
-	kTABBAR_UPDATE_SYNC_TO_TABBAR      : (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5) | (1 << 8) | (1 << 9),
+	kTABBAR_UPDATE_SYNC_TO_TABBAR      : (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5) | (1 << 9),
 	kTABBAR_UPDATE_SYNC_TO_PLACEHOLDER : (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 10) | (1 << 11),
 
 	kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD        : 3,
diff --git a/modules/fullscreenObserver.js b/modules/fullscreenObserver.js
new file mode 100644
index 0000000..d272df0
--- /dev/null
+++ b/modules/fullscreenObserver.js
@@ -0,0 +1,106 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Tree Style Tab.
+ *
+ * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
+ * Portions created by the Initial Developer are Copyright (C) 2013
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ******/
+
+const EXPORTED_SYMBOLS = ['FullscreenObserver']; 
+
+function FullscreenObserver(aWindow) {
+	this.window = aWindow;
+	this.init();
+}
+FullscreenObserver.prototype = {
+	get MutationObserver()
+	{
+		var w = this.window;
+		return w.MutationObserver || w.MozMutationObserver;
+	},
+
+	init : function FullscreenObserver_onInit() 
+	{
+		if (!this.MutationObserver)
+			return;
+		this.observer = new this.MutationObserver((function(aMutations, aObserver) {
+			this.onMutation(aMutations, aObserver);
+		}).bind(this));
+		this.observer.observe(this.window.document.documentElement, { attributes : true });
+
+		this.onSizeModeChange();
+	},
+
+	destroy : function FullscreenObserver_destroy()
+	{
+		if (this.observer) {
+			this.observer.disconnect();
+			delete this.observer;
+		}
+		delete this.window;
+	},
+
+	onMutation : function FullscreenObserver_onMutation(aMutations, aObserver) 
+	{
+		aMutations.forEach(function(aMutation) {
+			if (aMutation.type != 'attributes')
+				return;
+			if (aMutation.attributeName == 'sizemode')
+				this.window.setTimeout((function() {
+					this.onSizeModeChange();
+				}).bind(this), 10);
+		}, this);
+	},
+
+	onSizeModeChange : function FullscreenObserver_onSizeModeChange()
+	{
+		var w = this.window;
+		var d = w.document;
+		if (d.documentElement.getAttribute('sizemode') != 'fullscreen')
+			return;
+
+		if (!w.FullScreen.useLionFullScreen) { // see https://github.com/piroor/treestyletab/issues/645
+			let toolbox = w.gNavToolbox;
+			toolbox.style.marginTop = -toolbox.getBoundingClientRect().height + 'px';
+		}
+
+		var windowControls = d.getElementById('window-controls');
+		var navigationToolbar = d.getElementById('nav-bar');
+		if (!windowControls ||
+			!navigationToolbar ||
+			windowControls.parentNode == navigationToolbar ||
+			(w.gBrowser.treeStyleTab.position == 'top' && w.gBrowser.treeStyleTab.fixed))
+			return;
+
+		// the location bar is flex=1, so we should not apply it.
+		// windowControls.setAttribute('flex', '1');
+		navigationToolbar.appendChild(windowControls);
+	}
+};
diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js
index 4008705..4f68b84 100644
--- a/modules/tabbarDNDObserver.js
+++ b/modules/tabbarDNDObserver.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2010-2013
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -91,7 +91,10 @@ TabbarDNDObserver.prototype = {
 
 		if (
 			sv.evaluateXPath(
-				'ancestor-or-self::*[contains(" scrollbar popup menupopup panel tooltip ", concat(" ", local-name(), " "))]',
+				'ancestor-or-self::*[' +
+					'contains(" scrollbar popup menupopup panel tooltip ", concat(" ", local-name(), " ")) or' +
+					'(local-name()="toolbarbutton" and @type="menu")' +
+				']',
 				aEvent.originalTarget,
 				Ci.nsIDOMXPathResult.BOOLEAN_TYPE
 			).booleanValue ||
@@ -649,7 +652,6 @@ catch(e) {
 			if (aTab.hasAttribute(sv.kDROP_POSITION))
 				aTab.removeAttribute(sv.kDROP_POSITION)
 
-			// clear drop position preview on Firefox 17 and later
 			if (aOnFinish) {
 				aTab.style.transform = '';
 				if ('__treestyletab__opacityBeforeDragged' in aTab) {
@@ -1000,7 +1002,7 @@ try{
 			this.clearDropPosition();
 			indicatorTab.setAttribute(sv.kDROP_POSITION, dropPosition);
 			if (b.ownerDocument.defaultView['piro.sakura.ne.jp'].tabsDragUtils
-					.canAnimateDraggedTabs(aEvent)) { // Firefox 17 and later
+					.canAnimateDraggedTabs(aEvent)) {
 				let newOpacity = dropPosition == 'self' ? 0.35 : 0.75 ; // to prevent the dragged tab hides the drop target itself
 				this.window['piro.sakura.ne.jp'].tabsDragUtils.getDraggedTabs(aEvent).forEach(function(aTab) {
 					if (!('__treestyletab__opacityBeforeDragged' in aTab))
@@ -1191,9 +1193,7 @@ catch(e) {
 		let sourceURI = sourceDoc ? sourceDoc.documentURI : 'file:///' ;
 		let principal = sourceDoc ?
 					sourceDoc.nodePrincipal :
-				SecMan.getSimpleCodebasePrincipal ? // this method isn't there on Firefox 16 and olders!
-					SecMan.getSimpleCodebasePrincipal(Services.io.newURI(sourceURI, null, null)) :
-					null ;
+					SecMan.getSimpleCodebasePrincipal(Services.io.newURI(sourceURI, null, null)) ;
 		try {
 			if (principal)
 				SecMan.checkLoadURIStrWithPrincipal(principal, normalizedURI.spec, Ci.nsIScriptSecurityManager.STANDARD);
@@ -1290,13 +1290,13 @@ catch(e) {
 	
 	startListenEvents : function TabbarDND_startListenEvents() 
 	{
-		var strip = this.treeStyleTab.tabStrip;
-		strip.addEventListener('dragstart', this, true);
-		strip.addEventListener('dragover',  this, true);
-		strip.addEventListener('dragenter', this, false);
-		strip.addEventListener('dragleave', this, false);
-		strip.addEventListener('dragend',   this, true);
-		strip.addEventListener('drop',      this, true);
+		var target = this.treeStyleTab.ownerToolbar || this.treeStyleTab.tabStrip;
+		target.addEventListener('dragstart', this, true);
+		target.addEventListener('dragover',  this, true);
+		target.addEventListener('dragenter', this, false);
+		target.addEventListener('dragleave', this, false);
+		target.addEventListener('dragend',   this, true);
+		target.addEventListener('drop',      this, true);
 	},
   
 	destroy : function TabbarDND_destroy() 
@@ -1311,13 +1311,13 @@ catch(e) {
 	
 	endListenEvents : function TabbarDND_endListenEvents() 
 	{
-		var strip = this.treeStyleTab.tabStrip;
-		strip.removeEventListener('dragstart', this, true);
-		strip.removeEventListener('dragover',  this, true);
-		strip.removeEventListener('dragenter', this, false);
-		strip.removeEventListener('dragleave', this, false);
-		strip.removeEventListener('dragend',   this, true);
-		strip.removeEventListener('drop',      this, true);
+		var target = this.treeStyleTab.ownerToolbar || this.treeStyleTab.tabStrip;
+		target.removeEventListener('dragstart', this, true);
+		target.removeEventListener('dragover',  this, true);
+		target.removeEventListener('dragenter', this, false);
+		target.removeEventListener('dragleave', this, false);
+		target.removeEventListener('dragend',   this, true);
+		target.removeEventListener('drop',      this, true);
 	}
   
 }; 
diff --git a/modules/utils.js b/modules/utils.js
index e82b9ea..f6c0de0 100644
--- a/modules/utils.js
+++ b/modules/utils.js
@@ -14,7 +14,7 @@
  * The Original Code is the Tree Style Tab.
  *
  * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
- * Portions created by the Initial Developer are Copyright (C) 2010-2013
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex at gmail.com>
@@ -64,7 +64,7 @@ XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabConstants',
   'resource://treestyletab-modules/constants.js', 'TreeStyleTabConstants');
 
 const TST_PREF_PREFIX = 'extensions.treestyletab.';
-const TST_PREF_VERSION = 9;
+const TST_PREF_VERSION = 10;
 
 
 let TreeStyleTabUtils = {
@@ -133,8 +133,6 @@ let TreeStyleTabUtils = {
 						behavior += (
 							this.getTreePref('openGroupBookmarkAsTabSubTree') ?
 								TreeStyleTabConstants.kGROUP_BOOKMARK_SUBTREE :
-							this.getTreePref('browser.tabs.loadFolderAndReplace') ?
-								TreeStyleTabConstants.kGROUP_BOOKMARK_REPLACE :
 								TreeStyleTabConstants.kGROUP_BOOKMARK_SEPARATE
 						);
 					}
@@ -142,7 +140,6 @@ let TreeStyleTabUtils = {
 					this.clearTreePref('openGroupBookmarkBehavior.confirm');
 					this.clearTreePref('openGroupBookmarkAsTabSubTree');
 					this.clearTreePref('openGroupBookmarkAsTabSubTree.underParent');
-					prefs.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & TreeStyleTabConstants.kGROUP_BOOKMARK_REPLACE));
 				}
 			case 4:
 				let (subTreePrefs = [
@@ -202,6 +199,14 @@ let TreeStyleTabUtils = {
 					'extensions.treestyletab.indent',
 					'extensions.treestyletab.indent.min'
 				]);
+			case 9:
+				let (behavior = this.getTreePref('openGroupBookmark.behavior')) {
+					if (behavior & 4) {
+						behavior ^= 4;
+						behavior |= 1;
+						this.setTreePref('openGroupBookmark.behavior', behavior);
+					}
+				}
 			default:
 				for (let i = 0, maxi = orientalPrefs.length; i < maxi; i++)
 				{
@@ -262,6 +267,9 @@ let TreeStyleTabUtils = {
 
 		return browser.__SS_restoreState == 1;
 	},
+	get SessionStoreInternal() {
+		return this.SessionStoreNS.SessionStoreInternal;
+	},
 	get TabRestoreStates() {
 		return this.SessionStoreNS.TabRestoreStates;
 	},
diff --git a/modules/window.js b/modules/window.js
index 5105d9d..5ffa3e2 100644
--- a/modules/window.js
+++ b/modules/window.js
@@ -61,6 +61,7 @@ XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabBrowser', 'resource://trees
 XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
 XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestyletab-modules/autoHide.js');
 XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabThemeManager', 'resource://treestyletab-modules/themeManager.js');
+XPCOMUtils.defineLazyModuleGetter(this, 'FullscreenObserver', 'resource://treestyletab-modules/fullscreenObserver.js');
 XPCOMUtils.defineLazyModuleGetter(this, 'BrowserUIShowHideObserver', 'resource://treestyletab-modules/browserUIShowHideObserver.js');
 
 function TreeStyleTabWindow(aWindow) 
@@ -179,7 +180,11 @@ TreeStyleTabWindow.prototype = {
  
 	get isPopupWindow() 
 	{
-		return this.document && this.document.documentElement.getAttribute('chromehidden') != '';
+		return (
+			this.document &&
+			this.document.documentElement.getAttribute('chromehidden') != '' &&
+			!this.window.gBrowser.treeStyleTab.isVisible
+		);
 	},
   
 /* backward compatibility */ 
@@ -370,6 +375,7 @@ TreeStyleTabWindow.prototype = {
 		w.addEventListener('beforecustomization', this, true);
 		w.addEventListener('aftercustomization', this, false);
 
+		this.fullscreenObserver = new FullscreenObserver(this.window);
 		this.initUIShowHideObserver();
 
 		var appcontent = d.getElementById('appcontent');
@@ -499,6 +505,9 @@ TreeStyleTabWindow.prototype = {
 				w.removeEventListener('beforecustomization', this, true);
 				w.removeEventListener('aftercustomization', this, false);
 
+				this.fullscreenObserver.destroy();
+				delete this.fullscreenObserver;
+
 				this.rootElementObserver.destroy();
 				delete this.rootElementObserver;
 
@@ -594,6 +603,9 @@ TreeStyleTabWindow.prototype = {
 			case 'keypress':
 				return this.onKeyRelease(aEvent);
 
+			case 'blur':
+				return this.simulateKeyRelease();
+
 			case 'mousedown':
 				return this.onTabbarResizeStart(aEvent);
 
@@ -666,6 +678,7 @@ TreeStyleTabWindow.prototype = {
 			w.addEventListener('keydown',  this, true);
 			w.addEventListener('keyup',    this, true);
 			w.addEventListener('keypress', this, true);
+			w.addEventListener('blur',     this, true);
 			this.keyEventListening = true;
 		}
 		this.keyEventListeningFlags |= aReason;
@@ -681,6 +694,7 @@ TreeStyleTabWindow.prototype = {
 			w.removeEventListener('keydown',  this, true);
 			w.removeEventListener('keyup',    this, true);
 			w.removeEventListener('keypress', this, true);
+			w.removeEventListener('blur',     this, true);
 			this.keyEventListening = false;
 		}
 	},
@@ -810,6 +824,27 @@ TreeStyleTabWindow.prototype = {
 		}
 		this._tabShouldBeExpandedAfterKeyReleased = null;
 	},
+	// When the window lose its focus, we cannot detect any key-release events.
+	// So we have to simulate key-release event manually.
+	// See: https://github.com/piroor/treestyletab/issues/654
+	simulateKeyRelease : function TSTWindow_simulateKeyRelease()
+	{
+		if (!this.accelKeyPressed)
+			return;
+
+		this.accelKeyPressed = false;
+		var data = {
+			scrollDown   : false,
+			scrollUp     : false,
+			standBy      : false,
+			onlyShiftKey : false,
+			sourceEvent  : null
+		};
+		/* PUBLIC API */
+		this.fireDataContainerEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, this.browser, true, false, data);
+		// for backward compatibility
+		this.fireDataContainerEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END.replace(/^nsDOM/, ''), this.browser, true, false, data);
+	},
  
 	get shouldListenKeyEventsForAutoExpandByFocusChange() 
 	{
@@ -1055,6 +1090,8 @@ TreeStyleTabWindow.prototype = {
 			}
 			if (TabsInTitlebar) {
 				let allowed = isTopTabbar && this.browser.treeStyleTab.fixed;
+				if ('navbarontop' in this.window && utils.getTreePref('compatibility.NavbarOnTitlebar'))
+					allowed = true;
 				TabsInTitlebar.allowedBy('TreeStyleTab-tabsOnTop', allowed);
 			}
 		}
diff --git a/skin/classic/treestyletab/Darwin-base.css b/skin/classic/treestyletab/Darwin-base.css
index bddb4d0..cb4f428 100644
--- a/skin/classic/treestyletab/Darwin-base.css
+++ b/skin/classic/treestyletab/Darwin-base.css
@@ -1,21 +1 @@
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
-
-/**
- * Cancel "tabs on top" appearance on Australis.
- */
-:root:not([treestyletab-tabbar-position="top"])
-  #nav-bar:not(:-moz-lwtheme),
-:root:not([treestyletab-tabbar-position="top"])
-  #nav-bar:not(:-moz-lwtheme):-moz-window-inactive {
-	background: transparent;
-	border-top: none;
-	border-left: none;
-	border-right: none;
-	box-shadow: none;
-	/**
-	 * With Australis, the "back" button in the navigation toolbar is
-	 * unexpectedly overwrapped on the border of the expanded titlebar.
-	 * This negative margin solves the overwrapping.
-	 */
-	margin-top: -4px;
-}
diff --git a/skin/classic/treestyletab/WINNT-base.css b/skin/classic/treestyletab/WINNT-base.css
index af97e10..07784b9 100644
--- a/skin/classic/treestyletab/WINNT-base.css
+++ b/skin/classic/treestyletab/WINNT-base.css
@@ -1,42 +1,5 @@
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 
- at media (-moz-windows-compositor) {
-
-/**
- * Cancel "tabs on top" appearance on Australis.
- */
-#main-window:not([treestyletab-tabbar-position="top"])
-  #browser-panel
-  > #navigator-toolbox
-  > #nav-bar:not(:-moz-lwtheme),
-#main-window:not([treestyletab-tabbar-position="top"])
-  #browser-panel
-  > #navigator-toolbox
-  > #nav-bar:not(:-moz-lwtheme):-moz-window-inactive {
-	background: transparent;
-	border-top: none !important;
-	border-left: none;
-	border-right: none;
-	box-shadow: none;
-	padding-top: 0;
-	padding-left: 0;
-	padding-right: 0;
-	-moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-drag");
-}
-#main-window:not([sizemode="fullscreen"]):not([treestyletab-tabbar-position="top"])
-  #browser-panel
-  > #navigator-toolbox
-  > #nav-bar:not(:-moz-lwtheme),
-#main-window:not([sizemode="fullscreen"]):not([treestyletab-tabbar-position="top"])
-  #browser-panel
-  > #navigator-toolbox
-  > #nav-bar:not(:-moz-lwtheme):-moz-window-inactive {
-	position: relative;
-	margin-top: -5px;
-}
-
-}
-
 
 /* indicator for private window on Australis */
 #main-window[privatebrowsingmode="temporary"]:not([treestyletab-tabbar-position="top"])
diff --git a/skin/classic/treestyletab/group.css b/skin/classic/treestyletab/group.css
index 929326c..eb4457d 100644
--- a/skin/classic/treestyletab/group.css
+++ b/skin/classic/treestyletab/group.css
@@ -8,11 +8,7 @@
 
 .label-container {
 	padding: 1em;
-	position: fixed;
-	top: 0;
-	right: 0;
-	bottom: 0;
-	left: 0;
+	position: relative;
 }
 
 .label-container > * {
@@ -61,9 +57,7 @@
 
 
 #tree {
-	height: 80%;
 	margin-top: 1em;
-	max-height: 80%;
 	overflow: auto;
 	box-flex: 1;
 	-moz-box-flex: 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tree-style-tab.git



More information about the Pkg-mozext-commits mailing list