2009-12-25 11:51:24 -05:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2009-12-25 11:38:14 -05:00
|
|
|
* 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.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
|
2012-01-13 11:15:12 -05:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010-2012
|
2009-12-25 11:38:14 -05:00
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
|
2009-12-25 11:38:14 -05:00
|
|
|
*
|
|
|
|
* 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 ******/
|
2009-12-25 11:51:24 -05:00
|
|
|
|
2012-09-27 02:40:14 -04:00
|
|
|
const EXPORTED_SYMBOLS = ['TreeStyleTabBase'];
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2010-07-06 23:13:33 -04:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
2009-12-25 11:51:24 -05:00
|
|
|
|
2012-08-13 01:58:40 -04:00
|
|
|
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm');
|
2009-12-25 13:23:18 -05:00
|
|
|
|
2011-05-25 23:11:08 -04:00
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/prefs.js');
|
2010-12-06 07:04:52 -05:00
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/namespace.jsm');
|
2010-06-22 05:38:42 -04:00
|
|
|
var window = getNamespaceFor('piro.sakura.ne.jp');
|
2011-05-25 23:11:08 -04:00
|
|
|
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Deferred', 'resource://treestyletab-modules/lib/jsdeferred.js');
|
2011-05-25 23:11:08 -04:00
|
|
|
XPCOMUtils.defineLazyGetter(this, 'jstimer', function() {
|
|
|
|
var jstimer = {};
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/jstimer.jsm', jstimer);
|
|
|
|
return jstimer;
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'boxObject', function() {
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/boxObject.js', {});
|
|
|
|
return window['piro.sakura.ne.jp'].boxObject;
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'stringBundle', function() {
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/stringBundle.js', {});
|
|
|
|
return window['piro.sakura.ne.jp'].stringBundle;
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'extensions', function() {
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/extensions.js', {});
|
|
|
|
return window['piro.sakura.ne.jp'].extensions;
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'animationManager', function() {
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/animationManager.js', {});
|
|
|
|
return window['piro.sakura.ne.jp'].animationManager;
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'autoScroll', function() {
|
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/autoScroll.js', {});
|
|
|
|
return window['piro.sakura.ne.jp'].autoScroll;
|
|
|
|
});
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'confirmWithPopup', 'resource://treestyletab-modules/lib/confirmWithPopup.js');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
2012-10-19 08:38:35 -04:00
|
|
|
|
|
|
|
|
2012-09-27 02:40:14 -04:00
|
|
|
var TreeStyleTabBase = {
|
2011-05-25 23:11:08 -04:00
|
|
|
__proto__ : window['piro.sakura.ne.jp'].prefs,
|
2010-03-24 11:38:08 -04:00
|
|
|
tabsHash : null,
|
2010-05-08 04:30:39 -04:00
|
|
|
inWindowDestoructionProcess : false,
|
2009-12-25 11:51:24 -05:00
|
|
|
|
2009-12-25 13:13:33 -05:00
|
|
|
/* attributes */
|
2009-12-25 12:55:55 -05:00
|
|
|
kID : 'treestyletab-id',
|
|
|
|
kCHILDREN : 'treestyletab-children',
|
|
|
|
kPARENT : 'treestyletab-parent',
|
|
|
|
kANCESTOR : 'treestyletab-ancestors',
|
|
|
|
kNEST : 'treestyletab-nest',
|
|
|
|
kINSERT_BEFORE : 'treestyletab-insert-before',
|
|
|
|
kINSERT_AFTER : 'treestyletab-insert-after',
|
2009-12-25 15:07:00 -05:00
|
|
|
kCLOSED_SET_ID : 'treestyletab-closed-set-id',
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2012-09-23 04:19:09 -04:00
|
|
|
kID_NEW : 'treestyletab-id-new',
|
2009-12-25 12:55:55 -05:00
|
|
|
kID_RESTORING : 'treestyletab-id-restoring',
|
|
|
|
kCHILDREN_RESTORING : 'treestyletab-children-restoring',
|
|
|
|
|
|
|
|
kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed',
|
2011-12-26 23:21:23 -05:00
|
|
|
kSUBTREE_EXPANDED_MANUALLY : 'treestyletab-subtree-expanded-manually',
|
2009-12-25 12:55:55 -05:00
|
|
|
kCOLLAPSED : 'treestyletab-collapsed',
|
|
|
|
kCOLLAPSED_DONE : 'treestyletab-collapsed-done',
|
2010-05-02 00:30:51 -04:00
|
|
|
kCOLLAPSING_PHASE : 'treestyletab-collapsing-phase',
|
|
|
|
kCOLLAPSING_PHASE_TO_BE_COLLAPSED : 'collapse',
|
|
|
|
kCOLLAPSING_PHASE_TO_BE_EXPANDED : 'expand',
|
2009-12-25 12:55:55 -05:00
|
|
|
kALLOW_COLLAPSE : 'treestyletab-allow-subtree-collapse',
|
2010-11-24 11:14:36 -05:00
|
|
|
kALLOW_STACK : 'treestyletab-stack-collapsed-tabs',
|
2010-08-07 11:46:16 -04:00
|
|
|
kREMOVED : 'treestyletab-removed',
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
kX_OFFSET : 'treestyletab-x-offset',
|
|
|
|
kY_OFFSET : 'treestyletab-y-offset',
|
|
|
|
|
|
|
|
kTABBAR_POSITION : 'treestyletab-tabbar-position',
|
|
|
|
kMODE : 'treestyletab-mode',
|
|
|
|
|
2010-03-31 06:37:41 -04:00
|
|
|
kHIDE_NEWTAB : 'treestyletab-hide-newtab-button',
|
2009-12-25 12:55:55 -05:00
|
|
|
kSTYLE : 'treestyletab-style',
|
|
|
|
kFIRSTTAB_BORDER : 'treestyletab-firsttab-border',
|
|
|
|
kFIXED : 'treestyletab-tabbar-fixed',
|
|
|
|
kRESIZING : 'treestyletab-tabbar-resizing',
|
|
|
|
kINDENTED : 'treestyletab-tabs-indented',
|
2010-11-29 05:35:47 -05:00
|
|
|
kMAX_LEVEL : 'treestyletab-max-tree-level',
|
2010-03-28 14:22:15 -04:00
|
|
|
kPRINT_PREVIEW : 'treestyletab-print-preview',
|
2010-05-02 00:30:51 -04:00
|
|
|
kANIMATION_ENABLED : 'treestyletab-animation-enabled',
|
2011-03-24 23:12:33 -04:00
|
|
|
kINVERT_SCROLLBAR : 'treestyletab-invert-scrollbar',
|
2011-03-24 22:42:50 -04:00
|
|
|
kNARROW_SCROLLBAR : 'treestyletab-narrow-scrollbar',
|
2011-07-29 01:44:31 -04:00
|
|
|
kFAVICONIZED : 'treestyletab-faviconized',
|
2012-01-29 05:54:02 -05:00
|
|
|
kBG_NOTIFY_PHASE : 'treestyletab-notifybgtab-phase',
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
kTAB_INVERTED : 'treestyletab-tab-inverted',
|
|
|
|
kTAB_CONTENTS_INVERTED : 'treestyletab-tab-contents-inverted',
|
|
|
|
kCLOSEBOX_INVERTED : 'treestyletab-closebox-inverted',
|
|
|
|
|
|
|
|
kTWISTY_HOVER : 'treestyletab-twisty-hover',
|
|
|
|
kTWISTY_STYLE : 'treestyletab-twisty-style',
|
|
|
|
|
|
|
|
kDROP_POSITION : 'treestyletab-drop-position',
|
|
|
|
kDRAG_TYPE_TABBAR : 'application/x-moz-treestyletab-tabbrowser-tabbar',
|
|
|
|
kDROP_POSITION_UNKNOWN : 'unknown',
|
|
|
|
kTABBAR_MOVE_FORCE : 'force',
|
|
|
|
kTABBAR_MOVE_NORMAL : 'normal',
|
2010-11-30 19:40:27 -05:00
|
|
|
|
|
|
|
/* classes */
|
2011-01-23 02:01:26 -05:00
|
|
|
kTWISTY : 'treestyletab-twisty',
|
|
|
|
kCOUNTER : 'treestyletab-counter',
|
|
|
|
kCOUNTER_CONTAINER : 'treestyletab-counter-container',
|
|
|
|
kCOUNTER_PAREN : 'treestyletab-counter-paren',
|
|
|
|
kSPLITTER : 'treestyletab-splitter',
|
|
|
|
kTABBAR_TOGGLER : 'treestyletab-tabbar-toggler',
|
|
|
|
kTABBAR_PLACEHOLDER : 'treestyletab-tabbar-placeholder',
|
|
|
|
kTABBAR_TOOLBAR : 'treestyletab-tabbar-toolbar',
|
|
|
|
kTABBAR_TOOLBAR_READY : 'treestyletab-tabbar-toolbar-ready',
|
|
|
|
kTABBAR_TOOLBAR_READY_POPUP : 'treestyletab-tabbar-toolbar-ready-popup',
|
2010-11-30 19:40:27 -05:00
|
|
|
|
2010-12-01 19:02:27 -05:00
|
|
|
/* event types, topics */
|
2010-12-20 06:54:42 -05:00
|
|
|
kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN : 'nsDOMTreeStyleTabFocusSwitchingKeyDown',
|
|
|
|
kEVENT_TYPE_TAB_FOCUS_SWITCHING_START : 'nsDOMTreeStyleTabFocusSwitchingStart',
|
|
|
|
kEVENT_TYPE_TAB_FOCUS_SWITCHING_END : 'nsDOMTreeStyleTabFocusSwitchingEnd',
|
2011-01-09 11:40:24 -05:00
|
|
|
kTAB_FOCUS_SWITCHING_SCROLL_DOWN : (1 << 0),
|
|
|
|
kTAB_FOCUS_SWITCHING_SCROLL_UP : (1 << 1),
|
|
|
|
kTAB_FOCUS_SWITCHING_STAND_BY : (1 << 2),
|
|
|
|
kTAB_FOCUS_SWITCHING_ONLY_SHIFT_KEY : (1 << 3),
|
2010-12-20 06:54:42 -05:00
|
|
|
kEVENT_TYPE_SUBTREE_CLOSING : 'nsDOMTreeStyleTabSubtreeClosing',
|
|
|
|
kEVENT_TYPE_SUBTREE_CLOSED : 'nsDOMTreeStyleTabSubtreeClosed',
|
|
|
|
kEVENT_TYPE_TAB_COLLAPSED_STATE_CHANGED : 'nsDOMTreeStyleTabCollapsedStateChange',
|
2011-01-21 12:15:04 -05:00
|
|
|
kEVENT_TYPE_TABBAR_INITIALIZED : 'nsDOMTreeStyleTabTabbarInitialized',
|
2010-12-20 06:54:42 -05:00
|
|
|
kEVENT_TYPE_TABBAR_POSITION_CHANGING : 'nsDOMTreeStyleTabTabbarPositionChanging',
|
|
|
|
kEVENT_TYPE_TABBAR_POSITION_CHANGED : 'nsDOMTreeStyleTabTabbarPositionChanged',
|
|
|
|
kEVENT_TYPE_TABBAR_STATE_CHANGING : 'nsDOMTreeStyleTabTabbarStateChanging',
|
|
|
|
kEVENT_TYPE_TABBAR_STATE_CHANGED : 'nsDOMTreeStyleTabTabbarStateChanged',
|
|
|
|
kEVENT_TYPE_FOCUS_NEXT_TAB : 'nsDOMTreeStyleTabFocusNextTab',
|
|
|
|
kEVENT_TYPE_ATTACHED : 'nsDOMTreeStyleTabAttached',
|
|
|
|
kEVENT_TYPE_DETACHED : 'nsDOMTreeStyleTabParted',
|
2010-11-30 19:40:27 -05:00
|
|
|
|
2010-12-20 06:54:42 -05:00
|
|
|
kEVENT_TYPE_PRINT_PREVIEW_ENTERED : 'nsDOMTreeStyleTabPrintPreviewEntered',
|
|
|
|
kEVENT_TYPE_PRINT_PREVIEW_EXITED : 'nsDOMTreeStyleTabPrintPreviewExited',
|
|
|
|
kEVENT_TYPE_AUTO_HIDE_STATE_CHANGING : 'nsDOMTreeStyleTabAutoHideStateChanging',
|
|
|
|
kEVENT_TYPE_AUTO_HIDE_STATE_CHANGE : 'nsDOMTreeStyleTabAutoHideStateChange',
|
2011-02-19 08:07:08 -05:00
|
|
|
kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION : 'nsDOMTreeStyleTabBeforeToolbarCustomization',
|
|
|
|
kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION : 'nsDOMTreeStyleTabAfterToolbarCustomization',
|
2010-11-30 19:33:07 -05:00
|
|
|
|
|
|
|
kTOPIC_INDENT_MODIFIED : 'TreeStyleTab:indentModified',
|
|
|
|
kTOPIC_COLLAPSE_EXPAND_ALL : 'TreeStyleTab:collapseExpandAllSubtree',
|
|
|
|
kTOPIC_CHANGE_TREEVIEW_AVAILABILITY : 'TreeStyleTab:changeTreeViewAvailability',
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2009-12-25 13:13:33 -05:00
|
|
|
/* other constant values */
|
|
|
|
kFOCUS_ALL : 0,
|
|
|
|
kFOCUS_VISIBLE : 1,
|
|
|
|
|
|
|
|
kDROP_BEFORE : -1,
|
|
|
|
kDROP_ON : 0,
|
|
|
|
kDROP_AFTER : 1,
|
|
|
|
|
|
|
|
kACTION_MOVE : 1 << 0,
|
|
|
|
kACTION_STAY : 1 << 1,
|
|
|
|
kACTION_DUPLICATE : 1 << 2,
|
|
|
|
kACTION_IMPORT : 1 << 3,
|
|
|
|
kACTION_NEWTAB : 1 << 4,
|
|
|
|
kACTION_ATTACH : 1 << 10,
|
|
|
|
kACTION_PART : 1 << 11,
|
|
|
|
kACTIONS_FOR_SOURCE : (1 << 0) | (1 << 1),
|
|
|
|
kACTIONS_FOR_DESTINATION : (1 << 2) | (1 << 3),
|
|
|
|
|
|
|
|
kTABBAR_TOP : 1 << 0,
|
|
|
|
kTABBAR_BOTTOM : 1 << 1,
|
|
|
|
kTABBAR_LEFT : 1 << 2,
|
|
|
|
kTABBAR_RIGHT : 1 << 3,
|
|
|
|
|
|
|
|
kTABBAR_HORIZONTAL : (1 << 0) | (1 << 1),
|
|
|
|
kTABBAR_VERTICAL : (1 << 2) | (1 << 3),
|
2010-02-03 08:43:39 -05:00
|
|
|
kTABBAR_REGULAR : (1 << 0) | (1 << 2),
|
|
|
|
kTABBAR_INVERTED : (1 << 3) | (1 << 4),
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
kINSERT_FISRT : 0,
|
|
|
|
kINSERT_LAST : 1,
|
2010-04-22 05:24:21 -04:00
|
|
|
|
2010-12-03 09:50:42 -05:00
|
|
|
kTABBAR_UPDATE_BY_UNKNOWN_REASON : (1 << 0),
|
|
|
|
kTABBAR_UPDATE_BY_RESET : (1 << 1),
|
|
|
|
kTABBAR_UPDATE_BY_PREF_CHANGE : (1 << 2),
|
|
|
|
kTABBAR_UPDATE_BY_APPEARANCE_CHANGE : (1 << 3),
|
|
|
|
kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR : (1 << 4),
|
|
|
|
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),
|
2011-01-07 08:08:22 -05:00
|
|
|
kTABBAR_UPDATE_BY_INITIALIZE : (1 << 10),
|
2011-05-26 13:50:36 -04:00
|
|
|
kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR : (1 << 11),
|
2011-01-09 22:27:02 -05:00
|
|
|
kTABBAR_UPDATE_NOW : (1 << 5) | (1 << 6) | (1 << 9) | (1 << 10),
|
2010-12-03 09:50:42 -05:00
|
|
|
kTABBAR_UPDATE_SYNC_TO_TABBAR : (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5) | (1 << 8) | (1 << 9),
|
2011-05-26 13:50:36 -04:00
|
|
|
kTABBAR_UPDATE_SYNC_TO_PLACEHOLDER : (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 10) | (1 << 11),
|
2010-12-03 09:50:42 -05:00
|
|
|
|
2011-03-18 13:56:00 -04:00
|
|
|
kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD : 3,
|
|
|
|
kCLOSE_PARENT_BEHAVIOR_PROMOTE_ALL_CHILDREN : 0,
|
|
|
|
kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN : 1,
|
|
|
|
kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN : 4,
|
|
|
|
kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN : 2, // onTabRemoved only
|
|
|
|
|
2011-12-13 23:30:29 -05:00
|
|
|
kRESTORE_TREE_LEVEL_NONE : 0,
|
|
|
|
kRESTORE_TREE_ONLY_VISIBLE : 1,
|
|
|
|
kRESTORE_TREE_ALL : 2,
|
|
|
|
|
2012-01-13 11:45:51 -05:00
|
|
|
kCOUNTER_ROLE_ALL_TABS : 1,
|
|
|
|
kCOUNTER_ROLE_CONTAINED_TABS : 2,
|
|
|
|
|
2010-04-22 05:24:21 -04:00
|
|
|
MAX_TABBAR_SIZE_RATIO : 0.8,
|
|
|
|
DEFAULT_SHRUNKEN_WIDTH_RATIO : 0.67,
|
2012-12-03 07:41:12 -05:00
|
|
|
MIN_TABBAR_WIDTH : 24,
|
|
|
|
MIN_TABBAR_HEIGHT : 24,
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
/* base variables */
|
2012-08-30 13:46:50 -04:00
|
|
|
baseIndentVertical : 12,
|
|
|
|
baseIndentHorizontal : 4,
|
2009-12-25 13:13:33 -05:00
|
|
|
shouldDetectClickOnIndentSpaces : true,
|
|
|
|
|
|
|
|
smoothScrollEnabled : true,
|
|
|
|
smoothScrollDuration : 150,
|
|
|
|
|
|
|
|
animationEnabled : true,
|
|
|
|
indentDuration : 200,
|
|
|
|
collapseDuration : 150,
|
|
|
|
|
2009-12-25 13:45:52 -05:00
|
|
|
shouldExpandTwistyArea : true,
|
2010-07-25 12:13:19 -04:00
|
|
|
|
|
|
|
scrollToNewTabMode : false,
|
2012-01-13 11:45:51 -05:00
|
|
|
|
|
|
|
counterRoleHorizontal : -1,
|
|
|
|
counterRoleVertical : -1,
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
get SessionStore() {
|
|
|
|
if (!this._SessionStore) {
|
|
|
|
this._SessionStore = Cc['@mozilla.org/browser/sessionstore;1'].getService(Ci.nsISessionStore);
|
|
|
|
}
|
|
|
|
return this._SessionStore;
|
|
|
|
},
|
|
|
|
_SessionStore : null,
|
|
|
|
|
2011-12-02 15:01:38 -05:00
|
|
|
get FocusManager()
|
|
|
|
{
|
2012-01-13 03:38:12 -05:00
|
|
|
if (!this._FocusManager) {
|
|
|
|
this._FocusManager = Cc['@mozilla.org/focus-manager;1'].getService(Ci.nsIFocusManager);
|
2011-12-02 15:01:38 -05:00
|
|
|
}
|
|
|
|
return this._FocusManager;
|
|
|
|
},
|
2012-01-13 03:38:12 -05:00
|
|
|
_FocusManager : null,
|
2011-12-02 15:01:38 -05:00
|
|
|
|
2011-10-24 06:54:16 -04:00
|
|
|
get isGecko10OrLater()
|
|
|
|
{
|
2012-09-17 22:59:48 -04:00
|
|
|
return Services.vc.compare(Services.appinfo.version, '10.0a') > 0;
|
2011-10-24 06:54:16 -04:00
|
|
|
},
|
|
|
|
|
2009-12-25 13:45:52 -05:00
|
|
|
get treeBundle() {
|
2011-05-25 23:11:08 -04:00
|
|
|
return stringBundle.get('chrome://treestyletab/locale/treestyletab.properties');
|
2009-12-25 13:45:52 -05:00
|
|
|
},
|
|
|
|
get tabbrowserBundle() {
|
2011-05-25 23:11:08 -04:00
|
|
|
return stringBundle.get('chrome://browser/locale/tabbrowser.properties');
|
2009-12-25 13:45:52 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 23:11:08 -04:00
|
|
|
get extensions() { return extensions; },
|
|
|
|
get animationManager() { return animationManager; },
|
|
|
|
get autoScroll() { return autoScroll; },
|
2011-05-25 23:15:47 -04:00
|
|
|
get Deferred() { return Deferred; },
|
2010-06-22 14:00:16 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
init : function utils_init()
|
2009-12-25 11:38:14 -05:00
|
|
|
{
|
|
|
|
if (this._initialized) return;
|
|
|
|
|
2012-09-17 13:15:08 -04:00
|
|
|
this.isMac = Services.appinfo.OS == 'Darwin';
|
2010-10-24 23:06:02 -04:00
|
|
|
|
|
|
|
this.applyPlatformDefaultPrefs();
|
2012-02-09 14:01:13 -05:00
|
|
|
this.migratePrefs();
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2009-12-25 11:38:14 -05:00
|
|
|
this.addPrefListener(this);
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2012-08-30 14:48:00 -04:00
|
|
|
this.onPrefChange('extensions.treestyletab.indent.vertical');
|
2012-08-30 13:46:50 -04:00
|
|
|
this.onPrefChange('extensions.treestyletab.indent.horizontal');
|
2009-12-25 13:13:33 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
|
|
|
|
this.onPrefChange('browser.tabs.loadFolderAndReplace.override');
|
|
|
|
this.onPrefChange('browser.tabs.insertRelatedAfterCurrent.override');
|
2010-03-31 06:34:30 -04:00
|
|
|
this.onPrefChange('extensions.stm.tabBarMultiRows.override'); // Super Tab Mode
|
2009-12-25 13:13:33 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.scroll.smooth');
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.scroll.duration');
|
2010-07-25 12:13:19 -04:00
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.scrollToNewTab.mode');
|
2011-03-24 22:42:50 -04:00
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.narrowScrollbar.size');
|
2012-11-27 13:34:57 -05:00
|
|
|
this.onPrefChange('browser.tabs.animate');
|
2009-12-25 13:13:33 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.animation.indent.duration');
|
|
|
|
this.onPrefChange('extensions.treestyletab.animation.collapse.duration');
|
|
|
|
this.onPrefChange('extensions.treestyletab.twisty.expandSensitiveArea');
|
2012-01-13 11:45:51 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.counter.role.horizontal');
|
|
|
|
this.onPrefChange('extensions.treestyletab.counter.role.vertical');
|
2010-04-06 09:38:05 -04:00
|
|
|
|
|
|
|
try {
|
2012-09-17 13:15:08 -04:00
|
|
|
if (Services.appinfo.OS == 'WINNT')
|
2010-08-26 11:51:06 -04:00
|
|
|
this.updateAeroPeek();
|
2010-04-06 09:38:05 -04:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
dump(e+'\n');
|
|
|
|
}
|
2011-10-27 15:17:22 -04:00
|
|
|
|
|
|
|
try {
|
|
|
|
this.overrideExtensions();
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
dump(e+'\n');
|
|
|
|
}
|
2009-12-25 11:38:14 -05:00
|
|
|
},
|
|
|
|
_initialized : false,
|
2012-10-23 12:43:56 -04:00
|
|
|
applyPlatformDefaultPrefs : function utils_applyPlatformDefaultPrefs()
|
2010-10-24 23:06:02 -04:00
|
|
|
{
|
2012-09-17 13:15:08 -04:00
|
|
|
var OS = Services.appinfo.OS;
|
2010-11-18 02:04:31 -05:00
|
|
|
var processed = {};
|
2012-02-04 16:31:03 -05:00
|
|
|
var originalKeys = this.getDescendant('extensions.treestyletab.platform.'+OS);
|
|
|
|
for (let i = 0, maxi = originalKeys.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let originalKey = originalKeys[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
let key = originalKey.replace('platform.'+OS+'.', '');
|
|
|
|
this.setDefaultPref(key, this.getPref(originalKey));
|
2010-11-18 02:04:31 -05:00
|
|
|
processed[key] = true;
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2012-02-04 16:31:03 -05:00
|
|
|
originalKeys = this.getDescendant('extensions.treestyletab.platform.default');
|
|
|
|
for (let i = 0, maxi = originalKeys.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let originalKey = originalKeys[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
let key = originalKey.replace('platform.default.', '');
|
2010-11-18 02:04:31 -05:00
|
|
|
if (!(key in processed))
|
2012-02-04 13:15:38 -05:00
|
|
|
this.setDefaultPref(key, this.getPref(originalKey));
|
|
|
|
}
|
2010-10-24 23:06:02 -04:00
|
|
|
},
|
2012-08-30 14:48:00 -04:00
|
|
|
kPREF_VERSION : 9,
|
2012-10-23 12:43:56 -04:00
|
|
|
migratePrefs : function utils_migratePrefs()
|
2012-02-09 14:01:13 -05:00
|
|
|
{
|
|
|
|
// migrate old prefs
|
|
|
|
var orientalPrefs = [];
|
2012-10-23 12:43:56 -04:00
|
|
|
switch (utils.getTreePref('prefsVersion'))
|
2012-02-09 14:01:13 -05:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
orientalPrefs = orientalPrefs.concat([
|
|
|
|
'extensions.treestyletab.tabbar.fixed',
|
|
|
|
'extensions.treestyletab.enableSubtreeIndent',
|
|
|
|
'extensions.treestyletab.allowSubtreeCollapseExpand'
|
|
|
|
]);
|
2012-02-10 13:09:24 -05:00
|
|
|
case 1:
|
2012-02-09 14:01:13 -05:00
|
|
|
case 2:
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref('urlbar.loadSameDomainToNewChildTab') !== null) {
|
|
|
|
let value = utils.getTreePref('urlbar.loadSameDomainToNewChildTab');
|
|
|
|
utils.setTreePref('urlbar.loadSameDomainToNewTab', value);
|
|
|
|
utils.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value);
|
|
|
|
if (value) utils.setTreePref('urlbar.loadDifferentDomainToNewTab', value);
|
|
|
|
utils.clearTreePref('urlbar.loadSameDomainToNewChildTab');
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
|
|
|
case 3:
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref('loadDroppedLinkToNewChildTab') !== null) {
|
|
|
|
utils.setTreePref('dropLinksOnTab.behavior',
|
|
|
|
utils.getTreePref('loadDroppedLinkToNewChildTab.confirm') ?
|
2012-02-09 14:01:13 -05:00
|
|
|
this.kDROPLINK_ASK :
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('loadDroppedLinkToNewChildTab') ?
|
2012-02-09 14:01:13 -05:00
|
|
|
this.kDROPLINK_NEWTAB :
|
|
|
|
this.kDROPLINK_LOAD
|
|
|
|
);
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.clearTreePref('loadDroppedLinkToNewChildTab.confirm');
|
|
|
|
utils.clearTreePref('loadDroppedLinkToNewChildTab');
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref('openGroupBookmarkAsTabSubTree') !== null) {
|
2012-02-09 14:01:13 -05:00
|
|
|
let behavior = 0;
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref('openGroupBookmarkAsTabSubTree.underParent'))
|
2012-02-09 14:01:13 -05:00
|
|
|
behavior += this.kGROUP_BOOKMARK_USE_DUMMY;
|
2012-10-23 12:43:56 -04:00
|
|
|
if (!utils.getTreePref('openGroupBookmarkBehavior.confirm')) {
|
2012-02-09 14:01:13 -05:00
|
|
|
behavior += (
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('openGroupBookmarkAsTabSubTree') ?
|
2012-02-09 14:01:13 -05:00
|
|
|
this.kGROUP_BOOKMARK_SUBTREE :
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('browser.tabs.loadFolderAndReplace') ?
|
2012-02-09 14:01:13 -05:00
|
|
|
this.kGROUP_BOOKMARK_REPLACE :
|
|
|
|
this.kGROUP_BOOKMARK_SEPARATE
|
|
|
|
);
|
|
|
|
}
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('openGroupBookmark.behavior', behavior);
|
|
|
|
utils.clearTreePref('openGroupBookmarkBehavior.confirm');
|
|
|
|
utils.clearTreePref('openGroupBookmarkAsTabSubTree');
|
|
|
|
utils.clearTreePref('openGroupBookmarkAsTabSubTree.underParent');
|
2012-02-09 14:01:13 -05:00
|
|
|
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
let (prefs = [
|
|
|
|
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect',
|
|
|
|
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove',
|
|
|
|
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut',
|
|
|
|
'extensions.treestyletab.autoExpandSubTreeOnAppendChild',
|
|
|
|
'extensions.treestyletab.autoExpandSubTreeOnCollapsedChildFocused',
|
|
|
|
'extensions.treestyletab.collapseExpandSubTree.dblclick',
|
|
|
|
'extensions.treestyletab.createSubTree.underParent',
|
|
|
|
'extensions.treestyletab.show.context-item-reloadTabSubTree',
|
|
|
|
'extensions.treestyletab.show.context-item-removeTabSubTree',
|
|
|
|
'extensions.treestyletab.show.context-item-bookmarkTabSubTree',
|
|
|
|
'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree',
|
|
|
|
'extensions.multipletab.show.multipletab-selection-item-createSubTree'
|
|
|
|
]) {
|
2012-02-10 12:20:24 -05:00
|
|
|
for (let i = 0, maxi = prefs.length; i < maxi; i++)
|
2012-02-09 14:01:13 -05:00
|
|
|
{
|
|
|
|
let pref = prefs[i];
|
|
|
|
let value = this.getPref(pref);
|
|
|
|
if (value === null) continue;
|
|
|
|
this.setPref(pref.replace('SubTree', 'Subtree'), value);
|
|
|
|
this.clearPref(pref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 5:
|
2012-10-23 12:43:56 -04:00
|
|
|
let (behavior = utils.getTreePref('openGroupBookmark.behavior')) {
|
2012-02-09 14:01:13 -05:00
|
|
|
behavior = behavior | 2048;
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('openGroupBookmark.behavior', behavior);
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
let (
|
2012-10-23 12:43:56 -04:00
|
|
|
general = utils.getTreePref('autoAttachNewTabsAsChildren'),
|
|
|
|
search = utils.getTreePref('autoAttachSearchResultAsChildren')
|
2012-02-09 14:01:13 -05:00
|
|
|
) {
|
|
|
|
if (general !== null)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('autoAttach', general);
|
2012-02-09 14:01:13 -05:00
|
|
|
if (search !== null)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('autoAttach.searchResult', search);
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
let (
|
2012-10-23 12:43:56 -04:00
|
|
|
enabled = utils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'),
|
|
|
|
delay = utils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay')
|
2012-02-09 14:01:13 -05:00
|
|
|
) {
|
|
|
|
if (enabled !== null) {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut', enabled);
|
|
|
|
utils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers', enabled);
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
|
|
|
if (delay !== null)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay', delay);
|
2012-02-09 14:01:13 -05:00
|
|
|
}
|
2012-08-30 14:48:00 -04:00
|
|
|
case 8:
|
|
|
|
orientalPrefs = orientalPrefs.concat([
|
|
|
|
'extensions.treestyletab.indent',
|
|
|
|
'extensions.treestyletab.indent.min'
|
|
|
|
]);
|
2012-02-09 14:01:13 -05:00
|
|
|
default:
|
|
|
|
for (let i = 0, maxi = orientalPrefs.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
let pref = orientalPrefs[i];
|
|
|
|
let value = this.getPref(pref);
|
|
|
|
if (value === null) continue;
|
|
|
|
this.setPref(pref+'.horizontal', value);
|
|
|
|
this.setPref(pref+'.vertical', value);
|
|
|
|
this.clearPref(pref);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('prefsVersion', this.kPREF_VERSION);
|
2012-02-09 14:01:13 -05:00
|
|
|
},
|
2010-04-06 09:38:05 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
updateAeroPeek : function utils_updateAeroPeek()
|
2010-04-06 09:38:05 -04:00
|
|
|
{
|
|
|
|
var ns = {};
|
|
|
|
Components.utils.import('resource://gre/modules/WindowsPreviewPerTab.jsm', ns);
|
|
|
|
this.AeroPeek = ns.AeroPeek;
|
|
|
|
},
|
2011-03-24 22:42:50 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
overrideExtensions : function utils_overrideExtensions()
|
2011-10-27 15:17:22 -04:00
|
|
|
{
|
2012-05-01 15:56:45 -04:00
|
|
|
// Scriptish
|
|
|
|
// https://addons.mozilla.org/firefox/addon/scriptish/
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref('compatibility.Scriptish')) {
|
2012-05-01 15:56:45 -04:00
|
|
|
try {
|
|
|
|
let tabModule = Components.utils.import('resource://scriptish/utils/Scriptish_openInTab.js', {});
|
|
|
|
let Scriptish_openInTab = tabModule.Scriptish_openInTab;
|
|
|
|
tabModule.Scriptish_openInTab = function(aURL, aLoadInBackground, aReuse, aChromeWin) {
|
|
|
|
aChromeWin.TreeStyleTabService.readyToOpenChildTabNow(aChromeWin.gBrowser);
|
|
|
|
return Scriptish_openInTab.apply(this, arguments);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
}
|
2011-10-27 15:17:22 -04:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
updateNarrowScrollbarStyle : function utils_updateNarrowScrollbarStyle()
|
2011-03-24 22:42:50 -04:00
|
|
|
{
|
|
|
|
const SSS = Cc['@mozilla.org/content/style-sheet-service;1']
|
|
|
|
.getService(Ci.nsIStyleSheetService);
|
|
|
|
|
|
|
|
if (this.lastAgentSheet &&
|
|
|
|
SSS.sheetRegistered(this.lastAgentSheet, SSS.AGENT_SHEET))
|
|
|
|
SSS.unregisterSheet(this.lastAgentSheet, SSS.AGENT_SHEET);
|
|
|
|
|
|
|
|
const style = 'data:text/css,'+encodeURIComponent(
|
2012-10-12 03:46:37 -04:00
|
|
|
('@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");' +
|
|
|
|
|
|
|
|
'tabs.tabbrowser-tabs[%MODE%="vertical"][%NARROW%="true"]' +
|
|
|
|
' .tabbrowser-arrowscrollbox' +
|
|
|
|
' > scrollbox' +
|
|
|
|
' > scrollbar[orient="vertical"],' +
|
|
|
|
'tabs.tabbrowser-tabs[%MODE%="vertical"][%NARROW%="true"]' +
|
|
|
|
' .tabbrowser-arrowscrollbox' +
|
|
|
|
' > scrollbox' +
|
|
|
|
' > scrollbar[orient="vertical"] * {' +
|
|
|
|
' max-width: %SIZE%;' +
|
|
|
|
' min-width: %SIZE%;' +
|
|
|
|
'}' +
|
|
|
|
|
|
|
|
'tabs.tabbrowser-tabs[%MODE%="vertical"][%NARROW%="true"]' +
|
|
|
|
' .tabbrowser-arrowscrollbox' +
|
|
|
|
' > scrollbox' +
|
|
|
|
' > scrollbar[orient="vertical"] {' +
|
|
|
|
' font-size: %SIZE%;' +
|
|
|
|
'}' +
|
|
|
|
|
|
|
|
'tabs.tabbrowser-tabs[%MODE%="vertical"][%NARROW%="true"]' +
|
|
|
|
' .tabbrowser-arrowscrollbox' +
|
|
|
|
' > scrollbox' +
|
|
|
|
' > scrollbar[orient="vertical"] * {' +
|
|
|
|
' padding-left: 0;' +
|
|
|
|
' padding-right: 0;' +
|
|
|
|
' margin-left: 0;' +
|
|
|
|
' margin-right: 0;' +
|
|
|
|
'}' +
|
|
|
|
|
|
|
|
'%FORCE_NARROW_SCROLLBAR%')
|
2011-12-09 03:55:15 -05:00
|
|
|
.replace(/%FORCE_NARROW_SCROLLBAR%/g,
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.narrowScrollbar.overrideSystemAppearance') ?
|
2011-12-09 03:55:15 -05:00
|
|
|
this.kOVERRIDE_SYSTEM_SCROLLBAR_APPEARANCE : '' )
|
2011-03-24 22:42:50 -04:00
|
|
|
.replace(/%MODE%/g, this.kMODE)
|
|
|
|
.replace(/%NARROW%/g, this.kNARROW_SCROLLBAR)
|
2012-10-23 12:43:56 -04:00
|
|
|
.replace(/%SIZE%/g, utils.getTreePref('tabbar.narrowScrollbar.size'))
|
2011-03-24 22:42:50 -04:00
|
|
|
);
|
|
|
|
this.lastAgentSheet = this.makeURIFromSpec(style);
|
|
|
|
SSS.loadAndRegisterSheet(this.lastAgentSheet, SSS.AGENT_SHEET);
|
|
|
|
},
|
2012-10-12 03:46:37 -04:00
|
|
|
kOVERRIDE_SYSTEM_SCROLLBAR_APPEARANCE :
|
|
|
|
'tabs.tabbrowser-tabs[%MODE%="vertical"][%NARROW%="true"]' +
|
|
|
|
' .tabbrowser-arrowscrollbox' +
|
|
|
|
' > scrollbox' +
|
|
|
|
' > scrollbar[orient="vertical"] {' +
|
|
|
|
' appearance: none;' +
|
|
|
|
' -moz-appearance: none;' +
|
|
|
|
' background: ThreeDFace;' +
|
|
|
|
' border: 1px solid ThreeDShadow;' +
|
|
|
|
'}',
|
2011-03-24 22:42:50 -04:00
|
|
|
lastAgentSheet : null,
|
2010-04-06 09:38:05 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
observe : function utils_observe(aSubject, aTopic, aData)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
|
|
|
switch (aTopic)
|
|
|
|
{
|
|
|
|
case 'nsPref:changed':
|
|
|
|
this.onPrefChange(aData);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/* utilities */
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getBoxObjectFor : function utils_getBoxObjectFor(aNode)
|
2009-12-25 13:23:18 -05:00
|
|
|
{
|
2011-05-25 23:11:08 -04:00
|
|
|
return boxObject.getBoxObjectFor(aNode);
|
2009-12-25 13:23:18 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
evalInSandbox : function utils_evalInSandbox(aCode, aOwner)
|
2009-12-25 15:48:14 -05:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
var sandbox = new Components.utils.Sandbox(aOwner || 'about:blank');
|
|
|
|
return Components.utils.evalInSandbox(aCode, sandbox);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
return void(0);
|
|
|
|
},
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
get browserWindow()
|
2010-05-08 01:37:41 -04:00
|
|
|
{
|
|
|
|
return this.topBrowserWindow;
|
|
|
|
},
|
|
|
|
get topBrowserWindow()
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-09-17 23:01:39 -04:00
|
|
|
return Services.wm.getMostRecentWindow('navigator:browser');
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-05-08 01:37:41 -04:00
|
|
|
get browserWindows()
|
|
|
|
{
|
|
|
|
var windows = [];
|
|
|
|
|
2012-09-17 23:01:39 -04:00
|
|
|
var targets = Services.wm.getZOrderDOMWindowEnumerator('navigator:browser', true);
|
2010-05-08 01:37:41 -04:00
|
|
|
// By the bug 156333, we cannot find windows by their Z order on Linux.
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=156333
|
|
|
|
if (!targets.hasMoreElements())
|
2012-09-17 23:01:39 -04:00
|
|
|
targets = Services.wm.getEnumerator('navigator:browser');
|
2010-05-08 01:37:41 -04:00
|
|
|
|
|
|
|
while (targets.hasMoreElements())
|
|
|
|
{
|
|
|
|
let target = targets.getNext()
|
2011-07-20 06:59:59 -04:00
|
|
|
.QueryInterface(Ci.nsIDOMWindow);
|
|
|
|
if ('nsIDOMWindowInternal' in Ci) // for Firefox 7 or olders
|
|
|
|
target = target.QueryInterface(Ci.nsIDOMWindowInternal);
|
2010-05-08 01:37:41 -04:00
|
|
|
windows.push(target);
|
|
|
|
}
|
|
|
|
|
|
|
|
return windows;
|
|
|
|
},
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
get browser()
|
|
|
|
{
|
|
|
|
var w = this.browserWindow;
|
|
|
|
return !w ? null :
|
|
|
|
'SplitBrowser' in w ? w.SplitBrowser.activeBrowser :
|
|
|
|
w.gBrowser ;
|
|
|
|
},
|
|
|
|
|
2011-05-04 04:10:02 -04:00
|
|
|
get window()
|
2011-04-06 08:05:59 -04:00
|
|
|
{
|
|
|
|
return this.browser.ownerDocument.defaultView;
|
|
|
|
},
|
|
|
|
|
2010-12-01 19:02:27 -05:00
|
|
|
get currentDragSession()
|
|
|
|
{
|
|
|
|
return Cc['@mozilla.org/widget/dragservice;1']
|
|
|
|
.getService(Ci.nsIDragService)
|
|
|
|
.getCurrentSession();
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
dropLinksOnTabBehavior : function utils_dropLinksOnTabBehavior()
|
2009-12-25 13:45:52 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
var behavior = utils.getTreePref('dropLinksOnTab.behavior');
|
2009-12-25 13:45:52 -05:00
|
|
|
if (behavior & this.kDROPLINK_FIXED) return behavior;
|
|
|
|
|
|
|
|
var checked = { value : false };
|
2012-09-17 23:10:11 -04:00
|
|
|
var newChildTab = Services.prompt.confirmEx(this.browserWindow,
|
2009-12-25 13:45:52 -05:00
|
|
|
this.treeBundle.getString('dropLinkOnTab.title'),
|
|
|
|
this.treeBundle.getString('dropLinkOnTab.text'),
|
2012-09-17 23:10:11 -04:00
|
|
|
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
|
|
|
|
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1),
|
2009-12-25 13:45:52 -05:00
|
|
|
this.treeBundle.getString('dropLinkOnTab.openNewChildTab'),
|
|
|
|
this.treeBundle.getString('dropLinkOnTab.loadInTheTab'),
|
|
|
|
null,
|
|
|
|
this.treeBundle.getString('dropLinkOnTab.never'),
|
|
|
|
checked
|
|
|
|
) == 0;
|
|
|
|
|
|
|
|
behavior = newChildTab ? this.kDROPLINK_NEWTAB : this.kDROPLINK_LOAD ;
|
|
|
|
if (checked.value)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('dropLinksOnTab.behavior', behavior);
|
2009-12-25 13:45:52 -05:00
|
|
|
|
|
|
|
return behavior
|
|
|
|
},
|
|
|
|
kDROPLINK_ASK : 0,
|
|
|
|
kDROPLINK_FIXED : 1 + 2,
|
|
|
|
kDROPLINK_LOAD : 1,
|
|
|
|
kDROPLINK_NEWTAB : 2,
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
openGroupBookmarkBehavior : function utils_openGroupBookmarkBehavior()
|
2009-12-25 13:45:52 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
var behavior = utils.getTreePref('openGroupBookmark.behavior');
|
2009-12-25 13:45:52 -05:00
|
|
|
if (behavior & this.kGROUP_BOOKMARK_FIXED) return behavior;
|
|
|
|
|
|
|
|
var dummyTabFlag = behavior & this.kGROUP_BOOKMARK_USE_DUMMY;
|
|
|
|
|
|
|
|
var checked = { value : false };
|
2012-09-17 23:10:11 -04:00
|
|
|
var button = Services.prompt.confirmEx(this.browserWindow,
|
2009-12-25 13:45:52 -05:00
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.title'),
|
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.text'),
|
2012-09-17 23:10:11 -04:00
|
|
|
(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),
|
2009-12-25 13:45:52 -05:00
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.subTree'),
|
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.separate'),
|
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.replace'),
|
|
|
|
this.treeBundle.getString('openGroupBookmarkBehavior.never'),
|
|
|
|
checked
|
|
|
|
);
|
|
|
|
|
|
|
|
if (button < 0) button = 1;
|
|
|
|
var behaviors = [
|
|
|
|
this.kGROUP_BOOKMARK_SUBTREE | dummyTabFlag,
|
|
|
|
this.kGROUP_BOOKMARK_SEPARATE,
|
|
|
|
this.kGROUP_BOOKMARK_REPLACE
|
|
|
|
];
|
|
|
|
behavior = behaviors[button];
|
|
|
|
|
|
|
|
if (checked.value) {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('openGroupBookmark.behavior', behavior);
|
2011-01-22 13:32:04 -05:00
|
|
|
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
|
2009-12-25 13:45:52 -05:00
|
|
|
}
|
|
|
|
return behavior;
|
|
|
|
},
|
|
|
|
kGROUP_BOOKMARK_ASK : 0,
|
|
|
|
kGROUP_BOOKMARK_FIXED : 1 + 2 + 4,
|
|
|
|
kGROUP_BOOKMARK_SUBTREE : 1,
|
|
|
|
kGROUP_BOOKMARK_SEPARATE : 2,
|
|
|
|
kGROUP_BOOKMARK_REPLACE : 4,
|
2010-07-29 22:39:51 -04:00
|
|
|
kGROUP_BOOKMARK_USE_DUMMY : 256,
|
|
|
|
kGROUP_BOOKMARK_USE_DUMMY_FORCE : 1024,
|
2009-12-25 13:45:52 -05:00
|
|
|
kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE : 512,
|
2010-07-29 22:39:51 -04:00
|
|
|
kGROUP_BOOKMARK_EXPAND_ALL_TREE : 2048,
|
2009-12-25 13:45:52 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
bookmarkDroppedTabsBehavior : function utils_bookmarkDroppedTabsBehavior()
|
2010-12-20 06:41:22 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
var behavior = utils.getTreePref('bookmarkDroppedTabs.behavior');
|
2010-12-20 06:41:22 -05:00
|
|
|
if (behavior & this.kBOOKMARK_DROPPED_TABS_FIXED) return behavior;
|
|
|
|
|
|
|
|
var checked = { value : false };
|
2012-09-17 23:10:11 -04:00
|
|
|
var button = Services.prompt.confirmEx(this.browserWindow,
|
2010-12-20 06:41:22 -05:00
|
|
|
this.treeBundle.getString('bookmarkDroppedTabs.title'),
|
|
|
|
this.treeBundle.getString('bookmarkDroppedTabs.text'),
|
2012-09-17 23:10:11 -04:00
|
|
|
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
|
|
|
|
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1),
|
2010-12-20 06:41:22 -05:00
|
|
|
this.treeBundle.getString('bookmarkDroppedTabs.bookmarkAll'),
|
|
|
|
this.treeBundle.getString('bookmarkDroppedTabs.bookmarkOnlyParent'),
|
|
|
|
null,
|
|
|
|
this.treeBundle.getString('bookmarkDroppedTabs.never'),
|
|
|
|
checked
|
|
|
|
);
|
|
|
|
|
|
|
|
if (button < 0) button = 1;
|
|
|
|
var behaviors = [
|
|
|
|
this.kBOOKMARK_DROPPED_TABS_ALL,
|
|
|
|
this.kBOOKMARK_DROPPED_TABS_ONLY_PARENT
|
|
|
|
];
|
|
|
|
behavior = behaviors[button];
|
|
|
|
|
|
|
|
if (checked.value)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('bookmarkDroppedTabs.behavior', behavior);
|
2010-12-20 06:41:22 -05:00
|
|
|
|
|
|
|
return behavior;
|
|
|
|
},
|
|
|
|
kBOOKMARK_DROPPED_TABS_ASK : 0,
|
2011-04-07 14:38:31 -04:00
|
|
|
kBOOKMARK_DROPPED_TABS_FIXED : 1 | 2,
|
2010-12-20 06:41:22 -05:00
|
|
|
kBOOKMARK_DROPPED_TABS_ALL : 1,
|
|
|
|
kBOOKMARK_DROPPED_TABS_ONLY_PARENT : 2,
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
askUndoCloseTabSetBehavior : function utils_askUndoCloseTabSetBehavior(aRestoredTab, aCount)
|
2009-12-26 23:56:16 -05:00
|
|
|
{
|
2010-11-10 11:14:04 -05:00
|
|
|
var behavior = this.undoCloseTabSetBehavior;
|
|
|
|
if (behavior & this.kUNDO_CLOSE_SET) behavior ^= this.kUNDO_CLOSE_SET;
|
|
|
|
|
|
|
|
var self = this;
|
2012-01-17 23:56:50 -05:00
|
|
|
return confirmWithPopup({
|
|
|
|
browser : aRestoredTab.linkedBrowser,
|
2010-11-10 12:13:18 -05:00
|
|
|
label : this.treeBundle.getFormattedString('undoCloseTabSetBehavior.label', [aCount]),
|
|
|
|
value : 'treestyletab-undo-close-tree',
|
2012-01-17 23:56:50 -05:00
|
|
|
image : 'chrome://treestyletab/content/res/icon.png',
|
2010-11-10 12:13:18 -05:00
|
|
|
buttons : [
|
2012-01-17 23:56:50 -05:00
|
|
|
this.treeBundle.getString('undoCloseTabSetBehavior.restoreOnce'),
|
|
|
|
this.treeBundle.getString('undoCloseTabSetBehavior.restoreForever'),
|
|
|
|
this.treeBundle.getString('undoCloseTabSetBehavior.ignoreForever')
|
2012-01-20 10:35:53 -05:00
|
|
|
],
|
|
|
|
persistence : -1 // don't hide even if the tab is restored after the panel is shown.
|
2010-11-10 11:14:04 -05:00
|
|
|
})
|
|
|
|
.next(function(aButtonIndex) {
|
2012-01-17 23:56:50 -05:00
|
|
|
if (aButtonIndex < 2) {
|
2010-11-10 11:14:04 -05:00
|
|
|
behavior |= self.kUNDO_CLOSE_SET;
|
2010-11-10 12:05:02 -05:00
|
|
|
}
|
2012-01-17 23:56:50 -05:00
|
|
|
if (aButtonIndex > 0) {
|
2010-11-10 12:05:02 -05:00
|
|
|
behavior ^= self.kUNDO_ASK;
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('undoCloseTabSet.behavior', behavior);
|
2010-11-10 12:05:02 -05:00
|
|
|
}
|
2010-11-10 11:14:04 -05:00
|
|
|
return behavior;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
get undoCloseTabSetBehavior()
|
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
return utils.getTreePref('undoCloseTabSet.behavior');
|
2009-12-26 23:56:16 -05:00
|
|
|
},
|
|
|
|
kUNDO_ASK : 1,
|
|
|
|
kUNDO_CLOSE_SET : 2,
|
|
|
|
kUNDO_CLOSE_FULL_SET : 256,
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
doAndWaitDOMEvent : function utils_doAndWaitDOMEvent()
|
2011-01-21 12:15:04 -05:00
|
|
|
{
|
|
|
|
var type, target, delay, task;
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = arguments.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let arg = arguments[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
switch(typeof arg)
|
2011-01-21 12:15:04 -05:00
|
|
|
{
|
|
|
|
case 'string':
|
2012-02-04 13:15:38 -05:00
|
|
|
type = arg;
|
|
|
|
continue;
|
2011-01-21 12:15:04 -05:00
|
|
|
|
|
|
|
case 'number':
|
2012-02-04 13:15:38 -05:00
|
|
|
delay = arg;
|
|
|
|
continue;
|
2011-01-21 12:15:04 -05:00
|
|
|
|
|
|
|
case 'function':
|
2012-02-04 13:15:38 -05:00
|
|
|
task = arg;
|
|
|
|
continue;
|
2011-01-21 12:15:04 -05:00
|
|
|
|
|
|
|
default:
|
2012-02-04 13:15:38 -05:00
|
|
|
target = arg;
|
|
|
|
continue;
|
2011-01-21 12:15:04 -05:00
|
|
|
}
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2011-01-21 12:15:04 -05:00
|
|
|
|
|
|
|
if (!target || !type) {
|
|
|
|
if (task) task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var done = false;
|
|
|
|
var listener = function(aEvent) {
|
2011-05-25 23:11:08 -04:00
|
|
|
jstimer.setTimeout(function() {
|
2011-01-21 12:15:04 -05:00
|
|
|
done = true;
|
|
|
|
}, delay || 0);
|
|
|
|
target.removeEventListener(type, listener, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (task)
|
2011-03-18 16:00:12 -04:00
|
|
|
Deferred.next(function() {
|
2011-01-21 12:15:04 -05:00
|
|
|
try {
|
|
|
|
task();
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
dump(e+'\n');
|
|
|
|
target.removeEventListener(type, listener, false);
|
|
|
|
done = true;
|
|
|
|
}
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2011-01-21 12:15:04 -05:00
|
|
|
|
|
|
|
target.addEventListener(type, listener, false);
|
|
|
|
|
|
|
|
var thread = Components
|
|
|
|
.classes['@mozilla.org/thread-manager;1']
|
|
|
|
.getService()
|
|
|
|
.mainThread;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
//dump('WAIT '+type+' '+Date.now()+'\n');
|
|
|
|
thread.processNextEvent(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
findOffsetParent : function utils_findOffsetParent(aNode)
|
2011-05-04 04:10:02 -04:00
|
|
|
{
|
|
|
|
var parent = aNode.parentNode;
|
|
|
|
var doc = aNode.ownerDocument || aNode;
|
|
|
|
var view = doc.defaultView;
|
|
|
|
while (parent && parent instanceof Ci.nsIDOMElement)
|
|
|
|
{
|
|
|
|
let position = view.getComputedStyle(parent, null).getPropertyValue('position');
|
|
|
|
if (position != 'static')
|
|
|
|
return parent;
|
|
|
|
parent = parent.parentNode;
|
|
|
|
}
|
|
|
|
return doc.documentElement;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
assertBeforeDestruction : function utils_assertBeforeDestruction(aNotDestructed)
|
2012-01-23 14:07:56 -05:00
|
|
|
{
|
|
|
|
if (aNotDestructed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var message = 'ERROR: accessed after destruction!';
|
|
|
|
var error = new Error(message);
|
|
|
|
dump(message+'\n'+error.stack+'\n');
|
|
|
|
throw error;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
defaultDeferredErrorHandler : function utils_defaultDeferredErrorHandler(aError)
|
2012-02-06 12:13:46 -05:00
|
|
|
{
|
|
|
|
if (aError.stack)
|
|
|
|
Components.utils.reportError(aError.message+'\n'+aError.stack);
|
|
|
|
else
|
|
|
|
Components.utils.reportError(aError);
|
|
|
|
},
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
// event
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isNewTabAction : function utils_isNewTabAction(aEvent)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return aEvent.button == 1 || (aEvent.button == 0 && this.isAccelKeyPressed(aEvent));
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isAccelKeyPressed : function utils_isAccelKeyPressed(aEvent)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if ( // this is releasing of the accel key!
|
|
|
|
(aEvent.type == 'keyup') &&
|
|
|
|
(aEvent.keyCode == (this.isMac ? Ci.nsIDOMKeyEvent.DOM_VK_META : Ci.nsIDOMKeyEvent.DOM_VK_CONTROL ))
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this.isMac ?
|
|
|
|
(aEvent.metaKey || (aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_META)) :
|
|
|
|
(aEvent.ctrlKey || (aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL)) ;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isCopyAction : function utils_isCopyAction(aEvent)
|
2010-04-06 22:13:58 -04:00
|
|
|
{
|
|
|
|
return this.isAccelKeyPressed(aEvent) ||
|
|
|
|
(aEvent.dataTransfer && aEvent.dataTransfer.dropEffect == 'copy');
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isEventFiredOnClosebox : function utils_isEventFiredOnClosebox(aEvent)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::*[contains(concat(" ", normalize-space(@class), " "), " tab-close-button ")]',
|
|
|
|
aEvent.originalTarget || aEvent.target,
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
|
|
|
).booleanValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isEventFiredOnClickable : function utils_isEventFiredOnClickable(aEvent)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
2012-01-06 05:38:38 -05:00
|
|
|
'ancestor-or-self::*[contains(" button toolbarbutton scrollbar nativescrollbar popup menupopup panel tooltip splitter textbox ", concat(" ", local-name(), " "))]',
|
|
|
|
aEvent.originalTarget,
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
|
|
|
).booleanValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isEventFiredOnScrollbar : function utils_isEventFiredOnScrollbar(aEvent)
|
2012-01-06 05:38:38 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::*[local-name()="scrollbar" or local-name()="nativescrollbar"]',
|
2009-12-25 12:55:55 -05:00
|
|
|
aEvent.originalTarget,
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
|
|
|
).booleanValue;
|
|
|
|
},
|
2009-12-25 13:45:52 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isEventFiredOnTwisty : function utils_isEventFiredOnTwisty(aEvent)
|
2009-12-25 13:45:52 -05:00
|
|
|
{
|
|
|
|
var tab = this.getTabFromEvent(aEvent);
|
2010-02-04 03:56:21 -05:00
|
|
|
if (!tab ||
|
|
|
|
!this.hasChildTabs(tab) ||
|
|
|
|
!this.canCollapseSubtree(tab))
|
|
|
|
return false;
|
2009-12-25 13:45:52 -05:00
|
|
|
|
2010-12-27 04:58:02 -05:00
|
|
|
var twisty = tab.ownerDocument.getAnonymousElementByAttribute(tab, 'class', this.kTWISTY);
|
|
|
|
if (!twisty)
|
|
|
|
return false;
|
2009-12-25 13:45:52 -05:00
|
|
|
|
2010-12-27 04:58:02 -05:00
|
|
|
var box = twisty.boxObject;
|
2012-02-04 13:15:38 -05:00
|
|
|
var left = box.screenX;
|
|
|
|
var top = box.screenY;
|
|
|
|
var right = left + box.width;
|
|
|
|
var bottom = top + box.height;
|
|
|
|
var favicon = this.getFaviconRect(tab);
|
2011-01-15 23:46:18 -05:00
|
|
|
if (!box.width || !box.height) {
|
2012-02-04 13:15:38 -05:00
|
|
|
left = favicon.left;
|
|
|
|
top = favicon.top;
|
|
|
|
right = favicon.right;
|
|
|
|
bottom = favicon.bottom;
|
2011-01-15 23:46:18 -05:00
|
|
|
}
|
2012-02-02 15:27:57 -05:00
|
|
|
else if (
|
2011-01-22 14:03:39 -05:00
|
|
|
this.shouldExpandTwistyArea &&
|
2011-01-15 22:01:59 -05:00
|
|
|
!this._expandTwistyAreaBlockers.length
|
|
|
|
) {
|
2012-02-04 13:15:38 -05:00
|
|
|
left = Math.min(left, favicon.left);
|
|
|
|
top = Math.min(top, favicon.top);
|
|
|
|
right = Math.max(right, favicon.right);
|
|
|
|
bottom = Math.max(bottom, favicon.bottom);
|
2010-12-27 04:58:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var x = aEvent.screenX;
|
|
|
|
var y = aEvent.screenY;
|
2012-02-04 13:15:38 -05:00
|
|
|
return (x >= left && x <= right && y >= top && y <= bottom);
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getFaviconRect : function utils_getFaviconRect(aTab)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
|
|
|
var icon = aTab.ownerDocument.getAnonymousElementByAttribute(aTab, 'class', 'tab-icon-image');
|
|
|
|
var iconBox = icon.boxObject;
|
|
|
|
var iconRect = {
|
|
|
|
left : iconBox.screenX,
|
|
|
|
top : iconBox.screenY,
|
|
|
|
right : iconBox.screenX + iconBox.width,
|
|
|
|
bottom : iconBox.screenY + iconBox.height
|
|
|
|
};
|
|
|
|
|
|
|
|
var throbber = aTab.ownerDocument.getAnonymousElementByAttribute(aTab, 'class', 'tab-throbber');
|
|
|
|
var throbberBox = throbber.boxObject;
|
|
|
|
var throbberRect = {
|
|
|
|
left : throbberBox.screenX,
|
|
|
|
top : throbberBox.screenY,
|
|
|
|
right : throbberBox.screenX + throbberBox.width,
|
|
|
|
bottom : throbberBox.screenY + throbberBox.height
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!iconBox.width && !iconBox.height)
|
|
|
|
return throbberRect;
|
|
|
|
|
|
|
|
if (!throbberBox.width && !throbberBox.height)
|
|
|
|
return iconRect;
|
|
|
|
|
|
|
|
return {
|
|
|
|
left : Math.min(throbberRect.left, iconRect.left),
|
|
|
|
right : Math.max(throbberRect.right, iconRect.right),
|
|
|
|
top : Math.min(throbberRect.top, iconRect.top),
|
|
|
|
bottom : Math.max(throbberRect.bottom, iconRect.bottom)
|
|
|
|
};
|
2009-12-25 13:45:52 -05:00
|
|
|
},
|
|
|
|
|
2011-01-21 12:15:04 -05:00
|
|
|
// called with target(nsIDOMEventTarget), document(nsIDOMDocument), type(string) and data(object)
|
2012-10-23 12:43:56 -04:00
|
|
|
fireDataContainerEvent : function utils_fireDataContainerEvent()
|
2011-01-11 05:29:14 -05:00
|
|
|
{
|
|
|
|
var target, document, type, data, canBubble, cancellable;
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = arguments.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let arg = arguments[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
if (typeof arg == 'boolean') {
|
2011-01-11 05:29:14 -05:00
|
|
|
if (canBubble === void(0))
|
2012-02-04 13:15:38 -05:00
|
|
|
canBubble = arg;
|
2011-01-11 05:29:14 -05:00
|
|
|
else
|
2012-02-04 13:15:38 -05:00
|
|
|
cancellable = arg;
|
2011-01-11 05:29:14 -05:00
|
|
|
}
|
2012-02-04 13:15:38 -05:00
|
|
|
else if (typeof arg == 'string')
|
|
|
|
type = arg;
|
|
|
|
else if (arg instanceof Ci.nsIDOMDocument)
|
|
|
|
document = arg;
|
|
|
|
else if (arg instanceof Ci.nsIDOMEventTarget)
|
|
|
|
target = arg;
|
2011-01-11 05:29:14 -05:00
|
|
|
else
|
2012-02-04 13:15:38 -05:00
|
|
|
data = arg;
|
|
|
|
}
|
2011-01-11 05:29:14 -05:00
|
|
|
if (!target)
|
|
|
|
target = document;
|
|
|
|
if (!document)
|
|
|
|
document = target.ownerDocument || target;
|
|
|
|
|
|
|
|
var event = document.createEvent('DataContainerEvent');
|
|
|
|
event.initEvent(type, canBubble, cancellable);
|
2012-02-04 16:31:03 -05:00
|
|
|
var properties = Object.keys(data);
|
|
|
|
for (let i = 0, maxi = properties.length; i < maxi; i++)
|
2011-01-11 05:29:14 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let property = properties[i];
|
|
|
|
let value = data[property];
|
2012-02-04 14:03:28 -05:00
|
|
|
event.setData(property, value);
|
|
|
|
event[property] = value; // for backward compatibility
|
2011-01-11 05:29:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return target.dispatchEvent(event);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
registerExpandTwistyAreaBlocker : function utils_registerExpandTwistyAreaBlocker(aBlocker) /* PUBLIC API */
|
2009-12-25 13:45:52 -05:00
|
|
|
{
|
2009-12-25 13:48:07 -05:00
|
|
|
if (this._expandTwistyAreaBlockers.indexOf(aBlocker) < 0)
|
|
|
|
this._expandTwistyAreaBlockers.push(aBlocker);
|
2009-12-25 13:45:52 -05:00
|
|
|
},
|
2009-12-25 13:48:07 -05:00
|
|
|
_expandTwistyAreaBlockers : [],
|
2009-12-25 13:45:52 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
registerExpandTwistyAreaAllowance : function utils_registerExpandTwistyAreaAllowance(aAllowance) /* PUBLIC API, obsolete, for backward compatibility */
|
2009-12-25 13:45:52 -05:00
|
|
|
{
|
|
|
|
this.registerExpandTwistyAreaBlocker(aAllowance.toSource());
|
|
|
|
},
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
// string
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
makeNewId : function utils_makeNewId()
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return 'tab-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>';
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
makeNewClosedSetId : function utils_makeNewId()
|
2009-12-25 15:07:00 -05:00
|
|
|
{
|
|
|
|
return 'tabs-closed-set-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>';
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
makeURIFromSpec : function utils_makeURIFromSpec(aURI)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var newURI;
|
|
|
|
aURI = aURI || '';
|
|
|
|
if (aURI && String(aURI).indexOf('file:') == 0) {
|
2012-09-17 11:44:51 -04:00
|
|
|
var fileHandler = Services.io.getProtocolHandler('file').QueryInterface(Ci.nsIFileProtocolHandler);
|
2009-12-25 12:55:55 -05:00
|
|
|
var tempLocalFile = fileHandler.getFileFromURLSpec(aURI);
|
2012-09-17 11:44:51 -04:00
|
|
|
newURI = Services.io.newFileURI(tempLocalFile);
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!/^\w+\:/.test(aURI)) aURI = 'http://'+aURI;
|
2012-09-17 11:44:51 -04:00
|
|
|
newURI = Services.io.newURI(aURI, null, null);
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
|
|
|
return newURI;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getGroupTabURI : function utils_getGroupTabURI(aTitle)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return 'about:treestyletab-group'+(aTitle === void(0) ? '' : '?'+encodeURIComponent(aTitle) );
|
|
|
|
},
|
|
|
|
|
|
|
|
// xpath
|
|
|
|
|
|
|
|
NSResolver : {
|
|
|
|
lookupNamespaceURI : function(aPrefix)
|
|
|
|
{
|
|
|
|
switch (aPrefix)
|
|
|
|
{
|
|
|
|
case 'xul':
|
|
|
|
return 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
|
|
|
|
case 'html':
|
|
|
|
case 'xhtml':
|
|
|
|
return 'http://www.w3.org/1999/xhtml';
|
|
|
|
case 'xlink':
|
|
|
|
return 'http://www.w3.org/1999/xlink';
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
evaluateXPath : function utils_evaluateXPath(aExpression, aContext, aType)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aType) aType = Ci.nsIDOMXPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
|
|
|
|
try {
|
|
|
|
var XPathResult = (aContext.ownerDocument || aContext).evaluate(
|
|
|
|
aExpression,
|
|
|
|
(aContext || document),
|
|
|
|
this.NSResolver,
|
|
|
|
aType,
|
|
|
|
null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
return {
|
|
|
|
singleNodeValue : null,
|
|
|
|
snapshotLength : 0,
|
|
|
|
snapshotItem : function() {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return XPathResult;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getArrayFromXPathResult : function utils_getArrayFromXPathResult(aXPathResult)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var max = aXPathResult.snapshotLength;
|
|
|
|
var array = new Array(max);
|
|
|
|
if (!max) return array;
|
|
|
|
|
|
|
|
for (var i = 0; i < max; i++)
|
|
|
|
{
|
|
|
|
array[i] = aXPathResult.snapshotItem(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return array;
|
|
|
|
},
|
|
|
|
|
2009-12-25 13:13:33 -05:00
|
|
|
/* Session Store API */
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabValue : function utils_getTabValue(aTab, aKey)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
|
|
|
var value = '';
|
|
|
|
try {
|
|
|
|
value = this.SessionStore.getTabValue(aTab, aKey);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.useTMPSessionAPI) {
|
|
|
|
let TMPValue = aTab.getAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey);
|
|
|
|
if (TMPValue) value = TMPValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
setTabValue : function utils_setTabValue(aTab, aKey, aValue)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
|
|
|
if (!aValue) return this.deleteTabValue(aTab, aKey);
|
|
|
|
|
|
|
|
aTab.setAttribute(aKey, aValue);
|
|
|
|
try {
|
|
|
|
this.checkCachedSessionDataExpiration(aTab);
|
|
|
|
this.SessionStore.setTabValue(aTab, aKey, aValue);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.useTMPSessionAPI)
|
|
|
|
aTab.setAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey, aValue);
|
|
|
|
|
|
|
|
return aValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
deleteTabValue : function utils_deleteTabValue(aTab, aKey)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
|
|
|
aTab.removeAttribute(aKey);
|
|
|
|
try {
|
|
|
|
this.checkCachedSessionDataExpiration(aTab);
|
|
|
|
this.SessionStore.setTabValue(aTab, aKey, '');
|
|
|
|
this.SessionStore.deleteTabValue(aTab, aKey);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.useTMPSessionAPI)
|
|
|
|
aTab.removeAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey);
|
|
|
|
},
|
|
|
|
|
|
|
|
// workaround for http://piro.sakura.ne.jp/latest/blosxom/mozilla/extension/treestyletab/2009-09-29_debug.htm
|
2012-10-23 12:43:56 -04:00
|
|
|
checkCachedSessionDataExpiration : function utils_checkCachedSessionDataExpiration(aTab)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2012-01-13 03:38:12 -05:00
|
|
|
var data = aTab.linkedBrowser.__SS_data;
|
2010-01-28 11:33:00 -05:00
|
|
|
if (data &&
|
|
|
|
data._tabStillLoading &&
|
2010-09-26 11:32:44 -04:00
|
|
|
aTab.getAttribute('busy') != 'true' &&
|
2010-10-24 14:29:49 -04:00
|
|
|
aTab.linkedBrowser.__SS_restoreState != 1)
|
2010-01-28 11:33:00 -05:00
|
|
|
data._tabStillLoading = false;
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
markAsClosedSet : function utils_markAsClosedSet(aTabs) /* PUBLIC API */
|
2009-12-25 22:25:29 -05:00
|
|
|
{
|
|
|
|
if (!aTabs || aTabs.length <= 1) return;
|
|
|
|
var id = this.makeNewClosedSetId() + '::' + aTabs.length;
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
this.setTabValue(aTabs[i], this.kCLOSED_SET_ID, id);
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2009-12-25 22:25:29 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
unmarkAsClosedSet : function utils_unmarkAsClosedSet(aTabs) /* PUBLIC API */
|
2009-12-25 22:25:29 -05:00
|
|
|
{
|
|
|
|
if (!aTabs || !aTabs.length) return;
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
this.deleteTabValue(aTabs[i], this.kCLOSED_SET_ID);
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2009-12-25 22:25:29 -05:00
|
|
|
},
|
|
|
|
|
2011-12-15 00:28:40 -05:00
|
|
|
useTMPSessionAPI : false,
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
kTMP_SESSION_DATA_PREFIX : 'tmp-session-data-',
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
// tab
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabStrip : function utils_getTabStrip(aTabBrowser)
|
2010-04-06 09:38:05 -04:00
|
|
|
{
|
|
|
|
if (!(aTabBrowser instanceof Ci.nsIDOMElement))
|
2010-03-27 10:52:25 -04:00
|
|
|
return null;
|
2010-04-06 09:38:05 -04:00
|
|
|
|
2010-03-25 20:20:51 -04:00
|
|
|
var strip = aTabBrowser.mStrip;
|
2010-04-08 19:50:08 -04:00
|
|
|
return (strip && strip instanceof Ci.nsIDOMElement) ?
|
2010-03-25 20:20:51 -04:00
|
|
|
strip :
|
2011-01-21 12:15:04 -05:00
|
|
|
this.evaluateXPath(
|
|
|
|
'ancestor::xul:toolbar[1]',
|
2012-09-23 08:04:20 -04:00
|
|
|
aTabBrowser.tabContainer,
|
2011-01-21 12:15:04 -05:00
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue || aTabBrowser.tabContainer.parentNode;
|
2010-03-23 09:33:00 -04:00
|
|
|
},
|
2010-04-06 09:38:05 -04:00
|
|
|
get tabStrip()
|
2010-03-23 09:33:00 -04:00
|
|
|
{
|
|
|
|
return this.getTabStrip(this.browser);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabContainerBox : function utils_getTabContainerBox(aTabBrowser)
|
2010-04-29 23:20:18 -04:00
|
|
|
{
|
|
|
|
if (!(aTabBrowser instanceof Ci.nsIDOMElement))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var strip = this.getTabStrip(aTabBrowser);
|
2011-01-21 12:15:04 -05:00
|
|
|
return strip.treeStyleTabToolbarInnerBox || aTabBrowser.tabContainer;
|
2010-04-29 23:20:18 -04:00
|
|
|
},
|
|
|
|
get tabContainerBox()
|
|
|
|
{
|
|
|
|
return this.getTabContainerBox(this.browser);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
setTabbrowserAttribute : function utils_setTabbrowserAttribute(aName, aValue, aTabBrowser)
|
2010-03-23 12:12:49 -04:00
|
|
|
{
|
2010-03-28 14:22:15 -04:00
|
|
|
aTabBrowser = aTabBrowser || this.mTabBrowser || this.browser;
|
2010-03-23 12:12:49 -04:00
|
|
|
if (aValue) {
|
|
|
|
aTabBrowser.setAttribute(aName, aValue);
|
|
|
|
aTabBrowser.mTabContainer.setAttribute(aName, aValue);
|
2010-03-25 23:17:16 -04:00
|
|
|
aTabBrowser.treeStyleTab.setTabStripAttribute(aName, aValue);
|
2010-03-23 12:12:49 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aTabBrowser.removeAttribute(aName);
|
|
|
|
aTabBrowser.mTabContainer.removeAttribute(aName);
|
2010-03-25 23:17:16 -04:00
|
|
|
aTabBrowser.treeStyleTab.removeTabStripAttribute(aName);
|
2010-03-23 12:12:49 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
removeTabbrowserAttribute : function utils_removeTabbrowserAttribute(aName, aTabBrowser)
|
2010-03-28 14:22:15 -04:00
|
|
|
{
|
|
|
|
this.setTabbrowserAttribute(aName, null, aTabBrowser);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
setTabStripAttribute : function utils_setTabStripAttribute(aAttr, aValue)
|
2010-04-29 23:20:18 -04:00
|
|
|
{
|
|
|
|
var strip = this.tabStrip;
|
|
|
|
if (!strip) return;
|
2010-09-13 21:04:00 -04:00
|
|
|
var isFeatureAttribute = aAttr.indexOf('treestyletab-') == 0;
|
2010-04-29 23:20:18 -04:00
|
|
|
if (aValue) {
|
2011-05-17 11:27:46 -04:00
|
|
|
if (this._tabStripPlaceHolder)
|
|
|
|
this._tabStripPlaceHolder.setAttribute(aAttr, aValue);
|
|
|
|
if (!this._tabStripPlaceHolder || aAttr != 'ordinal')
|
|
|
|
strip.setAttribute(aAttr, aValue);
|
|
|
|
if (strip.treeStyleTabToolbarInnerBox)
|
|
|
|
strip.treeStyleTabToolbarInnerBox.setAttribute(aAttr, aValue);
|
2010-09-13 21:04:00 -04:00
|
|
|
if (isFeatureAttribute) {
|
|
|
|
// Only attributes for TST's feature are applied to the root element.
|
|
|
|
// (width, height, and other general attributes have to be ignored!)
|
|
|
|
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
|
|
|
|
strip.ownerDocument.documentElement.setAttribute(aAttr, aValue);
|
|
|
|
}, 10, this);
|
|
|
|
}
|
2010-04-29 23:20:18 -04:00
|
|
|
}
|
|
|
|
else {
|
2011-05-17 11:27:46 -04:00
|
|
|
if (this._tabStripPlaceHolder)
|
|
|
|
this._tabStripPlaceHolder.removeAttribute(aAttr);
|
|
|
|
if (!this._tabStripPlaceHolder || aAttr != 'ordinal')
|
|
|
|
strip.removeAttribute(aAttr);
|
|
|
|
if (strip.treeStyleTabToolbarInnerBox)
|
|
|
|
strip.treeStyleTabToolbarInnerBox.removeAttribute(aAttr);
|
2010-09-13 21:04:00 -04:00
|
|
|
if (isFeatureAttribute) {
|
|
|
|
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
|
|
|
|
strip.ownerDocument.documentElement.removeAttribute(aAttr);
|
|
|
|
}, 10, this);
|
|
|
|
}
|
2010-04-29 23:20:18 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
removeTabStripAttribute : function utils_removeTabStripAttribute(aAttr)
|
2010-04-29 23:20:18 -04:00
|
|
|
{
|
|
|
|
this.setTabStripAttribute(aAttr, null);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabFromChild : function utils_getTabFromChild(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
2010-03-23 11:12:43 -04:00
|
|
|
'ancestor-or-self::xul:tab',
|
2009-12-25 12:55:55 -05:00
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabFromEvent : function utils_getTabFromEvent(aEvent)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return this.getTabFromChild(aEvent.originalTarget || aEvent.target);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getNewTabButtonFromEvent : function utils_getNewTabButtonFromEvent(aEvent)
|
2012-02-28 12:28:05 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::*['
|
|
|
|
+'@id="new-tab-button" or '
|
|
|
|
+'contains(concat(" ", normalize-space(@class), " "), " tabs-newtab-button ")'
|
|
|
|
+'][1]',
|
|
|
|
aEvent.originalTarget,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getSplitterFromEvent : function utils_getSplitterFromEvent(aEvent)
|
2010-03-02 09:40:12 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::xul:splitter[contains(concat(" ", normalize-space(@class), " "), " '+this.kSPLITTER+' ")]',
|
|
|
|
aEvent.originalTarget,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isEventFiredOnGrippy : function utils_isEventFiredOnGrippy(aEvent)
|
2010-09-13 13:52:07 -04:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::xul:grippy',
|
|
|
|
aEvent.originalTarget,
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
|
|
|
).booleanValue;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabFromFrame : function utils_getTabFromFrame(aFrame, aTabBrowser)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var b = aTabBrowser || this.browser;
|
2010-11-11 20:42:06 -05:00
|
|
|
var top = aFrame.top;
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getAllTabs(b);
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = tabs[i];
|
2010-11-11 20:42:06 -05:00
|
|
|
if (tab.linkedBrowser.contentWindow == top)
|
2009-12-25 12:55:55 -05:00
|
|
|
return tab;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabbarFromChild : function utils_getTabbarFromChild(aNode)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
2012-10-12 13:24:02 -04:00
|
|
|
'ancestor-or-self::*[contains(concat(" ", normalize-space(@class), " "), " tabbrowser-strip ")] | ' +
|
2010-04-30 00:00:09 -04:00
|
|
|
'ancestor-or-self::xul:tabs[@tabbrowser] | ' +
|
2011-01-21 10:01:19 -05:00
|
|
|
'ancestor-or-self::xul:toolbar/child::xul:tabs[@tabbrowser]',
|
2010-03-24 13:20:30 -04:00
|
|
|
aNode,
|
2009-12-25 12:55:55 -05:00
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getAncestorTabbarFromChild : function utils_getAncestorTabbarFromChild(aNode)
|
2011-03-14 12:25:46 -04:00
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
2012-10-12 13:24:02 -04:00
|
|
|
'ancestor-or-self::*[contains(concat(" ", normalize-space(@class), " "), " tabbrowser-strip ")] | ' +
|
2011-03-14 12:25:46 -04:00
|
|
|
'ancestor-or-self::xul:tabs[@tabbrowser]',
|
|
|
|
aNode,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabbarFromEvent : function utils_getTabbarFromEvent(aEvent)
|
2010-03-24 13:20:30 -04:00
|
|
|
{
|
|
|
|
return this.getTabbarFromChild(aEvent.originalTarget || aEvent.target);
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getAncestorTabbarFromEvent : function utils_getAncestorTabbarFromEvent(aEvent)
|
2011-03-14 12:25:46 -04:00
|
|
|
{
|
|
|
|
return this.getAncestorTabbarFromChild(aEvent.originalTarget || aEvent.target);
|
|
|
|
},
|
2010-03-24 13:20:30 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
cleanUpTabsArray : function utils_cleanUpTabsArray(aTabs)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var newTabs = [];
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = aTabs[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
if (!tab || !tab.parentNode) continue; // ignore removed tabs
|
|
|
|
if (newTabs.indexOf(tab) < 0) newTabs.push(tab);
|
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
newTabs.sort(this.sortTabsByOrder);
|
|
|
|
return newTabs;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
sortTabsByOrder : function utils_sortTabsByOrder(aA, aB)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return aA._tPos - aB._tPos;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
gatherSubtreeMemberTabs : function utils_gatherSubtreeMemberTabs(aTabOrTabs, aOnlyChildren)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var tabs = aTabOrTabs;
|
|
|
|
if (!(tabs instanceof Array)) {
|
|
|
|
tabs = [aTabOrTabs];
|
|
|
|
}
|
|
|
|
|
|
|
|
var b = this.getTabBrowserFromChild(tabs[0]);
|
|
|
|
var descendant = [];
|
|
|
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
descendant = descendant.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
|
|
|
|
}
|
|
|
|
|
2010-09-18 11:12:14 -04:00
|
|
|
return this.cleanUpTabsArray(aOnlyChildren ? descendant : tabs.concat(descendant));
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
2009-12-27 06:22:44 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
splitTabsToSubtrees : function utils_splitTabsToSubtrees(aTabs) /* PUBLIC API */
|
2009-12-27 06:22:44 -05:00
|
|
|
{
|
|
|
|
var groups = [];
|
2011-05-25 23:11:08 -04:00
|
|
|
|
2009-12-27 06:22:44 -05:00
|
|
|
var group = [];
|
2012-02-04 16:31:03 -05:00
|
|
|
aTabs = this.cleanUpTabsArray(aTabs);
|
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = aTabs[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
let parent = this.getParentTab(tab);
|
|
|
|
if (!parent || group.indexOf(parent) < 0) {
|
|
|
|
if (group.length) groups.push(group);
|
|
|
|
group = [tab];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
group.push(tab);
|
|
|
|
}
|
|
|
|
}
|
2009-12-27 06:22:44 -05:00
|
|
|
if (group.length) groups.push(group);
|
|
|
|
return groups;
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
// tabbrowser
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabBrowserFromChild : function utils_getTabBrowserFromChild(aTabBrowserChild)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2010-03-23 13:58:23 -04:00
|
|
|
if (!aTabBrowserChild)
|
|
|
|
return null;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2010-03-23 13:58:23 -04:00
|
|
|
if (aTabBrowserChild.__treestyletab__linkedTabBrowser) // tab
|
2009-12-25 12:55:55 -05:00
|
|
|
return aTabBrowserChild.__treestyletab__linkedTabBrowser;
|
|
|
|
|
2010-03-23 13:58:23 -04:00
|
|
|
if (aTabBrowserChild.localName == 'tabbrowser') // itself
|
2009-12-25 12:55:55 -05:00
|
|
|
return aTabBrowserChild;
|
|
|
|
|
2012-01-13 11:30:06 -05:00
|
|
|
if (aTabBrowserChild.tabbrowser) // tabs
|
2010-03-23 13:58:23 -04:00
|
|
|
return aTabBrowserChild.tabbrowser;
|
|
|
|
|
2012-01-13 11:30:06 -05:00
|
|
|
if (aTabBrowserChild.localName == 'toolbar') // tabs toolbar
|
2010-03-27 10:52:25 -04:00
|
|
|
return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser;
|
|
|
|
|
2012-01-13 11:30:06 -05:00
|
|
|
// tab context menu
|
2010-04-01 13:37:30 -04:00
|
|
|
var popup = this.evaluateXPath(
|
|
|
|
'ancestor-or-self::xul:menupopup[@id="tabContextMenu"]',
|
|
|
|
aTabBrowserChild,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2010-04-22 04:24:36 -04:00
|
|
|
if (popup && 'TabContextMenu' in aTabBrowserChild.ownerDocument.defaultView)
|
2010-04-22 04:29:18 -04:00
|
|
|
return this.getTabBrowserFromChild(aTabBrowserChild.ownerDocument.defaultView.TabContextMenu.contextTab);
|
2010-04-01 13:37:30 -04:00
|
|
|
|
2010-03-23 10:21:13 -04:00
|
|
|
var b = this.evaluateXPath(
|
|
|
|
'ancestor::xul:tabbrowser | '+
|
2010-04-29 23:51:31 -04:00
|
|
|
'ancestor::xul:tabs[@tabbrowser] |'+
|
2011-01-21 10:01:19 -05:00
|
|
|
'ancestor::xul:toolbar/descendant::xul:tabs',
|
2009-12-25 12:55:55 -05:00
|
|
|
aTabBrowserChild,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2010-03-23 10:21:13 -04:00
|
|
|
return (b && b.tabbrowser) || b;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabBrowserFromFrame : function utils_getTabBrowserFromFrame(aFrame)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var w = this.browserWindow;
|
|
|
|
return !w ? null :
|
|
|
|
('SplitBrowser' in w) ? this.getTabBrowserFromChild(w.SplitBrowser.getSubBrowserAndBrowserFromFrame(aFrame.top).browser) :
|
|
|
|
this.browser ;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getFrameFromTabBrowserElements : function utils_getFrameFromTabBrowserElements(aFrameOrTabBrowser)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var frame = aFrameOrTabBrowser;
|
|
|
|
if (frame == '[object XULElement]') {
|
|
|
|
if (frame.localName == 'tab') {
|
|
|
|
frame = frame.linkedBrowser.contentWindow;
|
|
|
|
}
|
|
|
|
else if (frame.localName == 'browser') {
|
|
|
|
frame = frame.contentWindow;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
frame = this.getTabBrowserFromChild(frame);
|
|
|
|
if (!frame) return null;
|
|
|
|
frame = frame.contentWindow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!frame)
|
|
|
|
frame = this.browser.contentWindow;
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
},
|
|
|
|
|
|
|
|
/* get tab(s) */
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabById : function utils_getTabById(aId, aTabBrowserChildren)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aId) return null;
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
if (aTabBrowserChildren && !(aTabBrowserChildren instanceof Ci.nsIDOMNode))
|
|
|
|
aTabBrowserChildren = null;
|
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChildren) || this.browser;
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
if (this.tabsHash) // XPath-less implementation
|
|
|
|
return this.tabsHash[aId] || null;
|
|
|
|
|
2012-09-23 02:43:49 -04:00
|
|
|
return b.mTabContainer.querySelector('tab['+this.kID+'="'+aId+'"]');
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isTabDuplicated : function utils_isTabDuplicated(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return false;
|
|
|
|
var id = this.getTabValue(aTab, this.kID);
|
|
|
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
2012-09-23 02:51:11 -04:00
|
|
|
var tabs = b.mTabContainer.querySelectorAll('tab['+this.kID+'="'+id+'"], tab['+this.kID_RESTORING+'="'+id+'"]');
|
|
|
|
return tabs.length > 1;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
2012-09-23 02:43:49 -04:00
|
|
|
* Returns all tabs in the current group as an array.
|
2010-09-14 03:39:17 -04:00
|
|
|
* It includes tabs hidden by Tab Panorama.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getAllTabs : function utils_getTabs(aTabBrowserChild)
|
2010-09-14 03:39:17 -04:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2012-09-23 02:43:49 -04:00
|
|
|
return Array.slice(b.mTabContainer.querySelectorAll('tab'));
|
2010-09-14 03:39:17 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-09-23 02:43:49 -04:00
|
|
|
* Returns all tabs in the current group as an array.
|
2010-09-14 03:39:17 -04:00
|
|
|
* It excludes tabs hidden by Tab Panorama.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabs : function utils_getTabs(aTabBrowserChild)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2012-09-23 02:43:49 -04:00
|
|
|
return Array.slice(b.mTabContainer.querySelectorAll('tab:not([hidden="true"])'));
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getAllTabsArray : function utils_getAllTabsArray(aTabBrowserChild) /* for backward compatibility */
|
2010-09-14 03:39:17 -04:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getAllTabs(aTabBrowserChild);
|
2010-09-14 03:39:17 -04:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabsArray : function utils_getTabsArray(aTabBrowserChild) /* for backward compatibility */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getTabs(aTabBrowserChild);
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the first tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getFirstTab : function utils_getFirstTab(aTabBrowserChild)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2010-09-14 03:05:27 -04:00
|
|
|
var tabs = b.visibleTabs;
|
|
|
|
return tabs ? tabs[0] : b.mTabContainer.firstChild;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the first visible, not collapsed, and not pinned tab.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getFirstNormalTab : function utils_getFirstNormalTab(aTabBrowserChild)
|
2010-06-25 11:59:59 -04:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2012-09-23 02:51:11 -04:00
|
|
|
return b.mTabContainer.querySelector('tab:not([pinned="true"]):not([hidden="true"])');
|
2010-06-25 11:59:59 -04:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the last tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getLastTab : function utils_getLastTab(aTabBrowserChild)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2010-09-14 03:05:27 -04:00
|
|
|
var tabs = b.visibleTabs;
|
|
|
|
return tabs ? tabs[tabs.length-1] : b.mTabContainer.lastChild ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the next tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getNextTab : function utils_getNextTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
2010-09-14 03:05:27 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2010-09-14 03:05:27 -04:00
|
|
|
var tabs = b.visibleTabs;
|
|
|
|
if (tabs) {
|
|
|
|
let index = tabs.indexOf(aTab);
|
|
|
|
if (index > -1)
|
2010-11-17 12:50:54 -05:00
|
|
|
return tabs.length > index ? tabs[index+1] : null
|
2010-09-14 03:05:27 -04:00
|
|
|
}
|
2010-03-03 10:38:35 -05:00
|
|
|
var tab = aTab.nextSibling;
|
|
|
|
return (tab && tab.localName == 'tab') ? tab : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the previous tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getPreviousTab : function utils_getPreviousTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
2010-09-14 03:05:27 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
2012-01-23 14:07:56 -05:00
|
|
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
2010-09-14 03:05:27 -04:00
|
|
|
var tabs = b.visibleTabs;
|
|
|
|
if (tabs) {
|
|
|
|
let index = tabs.indexOf(aTab);
|
|
|
|
if (index > -1)
|
2010-11-17 12:50:54 -05:00
|
|
|
return 0 < index ? tabs[index-1] : null
|
2010-09-14 03:05:27 -04:00
|
|
|
}
|
2010-03-03 10:38:35 -05:00
|
|
|
var tab = aTab.previousSibling;
|
|
|
|
return (tab && tab.localName == 'tab') ? tab : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the index of the specified tab, in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabIndex : function utils_getTabIndex(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return -1;
|
2010-03-03 10:38:35 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getTabs(b).indexOf(aTab);
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the next not collapsed tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getNextVisibleTab : function utils_getNextVisibleTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-03 10:38:35 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
|
|
|
if (!this.canCollapseSubtree(b))
|
2009-12-25 12:55:55 -05:00
|
|
|
return this.getNextTab(aTab);
|
|
|
|
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getVisibleTabs(b);
|
2010-03-03 10:38:35 -05:00
|
|
|
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
|
|
|
tabs.sort(this.sortTabsByOrder);
|
|
|
|
|
|
|
|
var index = tabs.indexOf(aTab);
|
|
|
|
return (index < tabs.length-1) ? tabs[index+1] : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the previous not collapsed tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getPreviousVisibleTab : function utils_getPreviousVisibleTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-03 10:38:35 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
|
|
|
if (!this.canCollapseSubtree(b))
|
2009-12-25 12:55:55 -05:00
|
|
|
return this.getPreviousTab(aTab);
|
|
|
|
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getVisibleTabs(b);
|
2010-03-03 10:38:35 -05:00
|
|
|
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
|
|
|
tabs.sort(this.sortTabsByOrder);
|
|
|
|
|
|
|
|
var index = tabs.indexOf(aTab);
|
|
|
|
return (index > 0) ? tabs[index-1] : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the last not collapsed tab in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getLastVisibleTab : function utils_getLastVisibleTab(aTabBrowserChild)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2009-12-25 12:55:55 -05:00
|
|
|
if (!b) return null;
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getVisibleTabs(b);
|
2010-03-03 10:38:35 -05:00
|
|
|
return tabs.length ? tabs[tabs.length-1] : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns a XPathResult of not collapsed tabs in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getVisibleTabs : function utils_getVisibleTabs(aTabBrowserChild) /* OBSOLETE */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-08-04 18:06:32 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
2009-12-25 12:55:55 -05:00
|
|
|
if (!this.canCollapseSubtree(b))
|
|
|
|
return this.getTabs(b);
|
2012-09-23 02:43:49 -04:00
|
|
|
return Array.slice(b.mTabContainer.querySelectorAll('tab:not(['+this.kCOLLAPSED+'="true"]):not([hidden="true"])'));
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getVisibleTabsArray : function utils_getVisibleTabsArray(aTabBrowserChild) /* for backward compatibility */
|
2010-03-03 10:38:35 -05:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getVisibleTabs(aTabBrowserChild);
|
2010-03-03 10:38:35 -05:00
|
|
|
},
|
|
|
|
|
2010-09-14 03:39:17 -04:00
|
|
|
/**
|
|
|
|
* Returns the index of the specified tab, in the array of not collapsed
|
|
|
|
* tabs in the current group.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getVisibleIndex : function utils_getVisibleIndex(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return -1;
|
2010-03-03 10:38:35 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getVisibleTabs(b).indexOf(aTab);
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
2012-07-28 22:11:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns tabs which are newly opened in the given operation.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getNewTabsWithOperation : function utils_getNewTabsWithOperation(aOperation, aTabBrowser)
|
2012-07-28 22:11:41 -04:00
|
|
|
{
|
|
|
|
var previousTabs = this.getTabsInfo(aTabBrowser);
|
|
|
|
aOperation.call(this);
|
|
|
|
return this.getNewTabsFromPreviousTabsInfo(aTabBrowser, previousTabs);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns tabs which are newly opened. This requires the "previous state".
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
getNewTabsFromPreviousTabsInfo : function utils_getNewTabsFromPreviousTabsInfo(aTabBrowser, aTabsInfo)
|
2012-07-28 22:11:41 -04:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getTabs(aTabBrowser);
|
2012-07-28 22:11:41 -04:00
|
|
|
var currentTabsInfo = this.getTabsInfo(aTabBrowser);
|
|
|
|
return tabs.filter(function(aTab, aIndex) {
|
|
|
|
return aTabsInfo.indexOf(currentTabsInfo[aIndex]) < 0;
|
|
|
|
});
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabsInfo : function utils_getTabsInfo(aTabBrowser)
|
2012-07-28 22:11:41 -04:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getTabs(aTabBrowser);
|
2012-07-28 22:11:41 -04:00
|
|
|
return tabs.map(function(aTab) {
|
|
|
|
return aTab.getAttribute(this.kID)+'\n'+
|
|
|
|
aTab.getAttribute('busy')+'\n'+
|
|
|
|
aTab.linkedBrowser.currentURI.spec;
|
|
|
|
}, this);
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
/* notify "ready to open child tab(s)" */
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
readyToOpenChildTab : function utils_readyToOpenChildTab(aFrameOrTabBrowser, aMultiple, aInsertBefore) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
if (!utils.getTreePref('autoAttach')) return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
2010-09-13 09:58:30 -04:00
|
|
|
if (!frame)
|
2011-05-25 00:58:25 -04:00
|
|
|
return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
|
|
|
|
|
|
|
var parentTab = this.getTabFromFrame(frame, ownerBrowser);
|
2010-09-13 09:58:30 -04:00
|
|
|
if (!parentTab || parentTab.getAttribute('pinned') == 'true')
|
2011-05-25 00:58:25 -04:00
|
|
|
return false;
|
2010-06-26 13:41:20 -04:00
|
|
|
|
2009-12-25 12:55:55 -05:00
|
|
|
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
|
|
|
var parentId = parentTab.getAttribute(this.kID);
|
|
|
|
|
|
|
|
var refId = null;
|
|
|
|
if (aInsertBefore) {
|
|
|
|
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
|
|
|
refId = aInsertBefore.getAttribute(this.kID);
|
|
|
|
}
|
|
|
|
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachNewTab = true;
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachMultiple = aMultiple || false ;
|
2010-12-07 11:28:23 -05:00
|
|
|
ownerBrowser.treeStyleTab.multipleCount = aMultiple ? 0 : -1 ;
|
2009-12-25 12:55:55 -05:00
|
|
|
ownerBrowser.treeStyleTab.parentTab = parentId;
|
|
|
|
ownerBrowser.treeStyleTab.insertBefore = refId;
|
2011-05-25 00:58:25 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Extended version. If you don't know whether a new tab will be actually
|
|
|
|
* opened or not (by the command called after TST's API), then use this.
|
|
|
|
* This version automatically cancels the "ready" state with delay.
|
|
|
|
*/
|
2012-11-25 12:18:23 -05:00
|
|
|
readyToOpenChildTabNow : function utils_readyToOpenChildTabNow(aFrameOrTabBrowser, aMultiple) /* PUBLIC API */
|
2011-05-25 00:58:25 -04:00
|
|
|
{
|
|
|
|
if (this.readyToOpenChildTab.apply(this, arguments)) {
|
|
|
|
let self = this;
|
|
|
|
this.Deferred.next(function() {
|
|
|
|
self.stopToOpenChildTab(aFrameOrTabBrowser);
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2011-05-25 00:58:25 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
readyToOpenNextSiblingTab : function utils_readyToOpenNextSiblingTab(aFrameOrTabBrowser) /* PUBLIC API */
|
2011-05-04 15:14:38 -04:00
|
|
|
{
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
if (!frame)
|
2011-05-25 00:58:25 -04:00
|
|
|
return false;
|
2011-05-04 15:14:38 -04:00
|
|
|
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
|
|
|
|
|
|
|
var tab = this.getTabFromFrame(frame, ownerBrowser);
|
|
|
|
if (!tab || tab.getAttribute('pinned') == 'true')
|
2011-05-25 00:58:25 -04:00
|
|
|
return false;
|
2011-05-04 15:14:38 -04:00
|
|
|
|
|
|
|
var parentTab = this.getParentTab(tab);
|
|
|
|
var nextTab = this.getNextSiblingTab(tab);
|
|
|
|
if (parentTab) {
|
|
|
|
/**
|
|
|
|
* If the base tab has a parent, open the new tab as a child of
|
|
|
|
* the parent tab.
|
|
|
|
*/
|
2011-05-25 00:58:25 -04:00
|
|
|
return this.readyToOpenChildTab(parentTab, false, nextTab);
|
2011-05-04 15:14:38 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/**
|
|
|
|
* Otherwise, open the tab as a new root tab. If there is no
|
|
|
|
* tab next to the base tab (in other words, if the tab is the
|
|
|
|
* last tab), then do nothing.
|
|
|
|
*/
|
|
|
|
if (!nextTab) return;
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachNewTab = true;
|
|
|
|
ownerBrowser.treeStyleTab.parentTab = null;
|
|
|
|
ownerBrowser.treeStyleTab.insertBefore = nextTab.getAttribute(this.kID);
|
2011-05-25 00:58:25 -04:00
|
|
|
return true;
|
2011-05-04 15:14:38 -04:00
|
|
|
}
|
|
|
|
},
|
2011-05-25 00:58:25 -04:00
|
|
|
/**
|
|
|
|
* Extended version. If you don't know whether a new tab will be actually
|
|
|
|
* opened or not (by the command called after TST's API), then use this.
|
|
|
|
* This version automatically cancels the "ready" state with delay.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
readyToOpenNextSiblingTabNow : function utils_readyToOpenNextSiblingTabNow(aFrameOrTabBrowser) /* PUBLIC API */
|
2011-05-25 00:58:25 -04:00
|
|
|
{
|
|
|
|
if (this.readyToOpenNextSiblingTab.apply(this, arguments)) {
|
|
|
|
let self = this;
|
|
|
|
this.Deferred.next(function() {
|
|
|
|
self.stopToOpenChildTab(aFrameOrTabBrowser);
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2011-05-25 00:58:25 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2011-05-04 15:14:38 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
readyToOpenNewTabGroup : function utils_readyToOpenNewTabGroup(aFrameOrTabBrowser, aTreeStructure, aExpandAllTree) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
if (!utils.getTreePref('autoAttach')) return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
2011-05-25 00:58:25 -04:00
|
|
|
if (!frame) return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
this.stopToOpenChildTab(frame);
|
|
|
|
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachNewTabGroup = true;
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachMultiple = true;
|
|
|
|
ownerBrowser.treeStyleTab.multipleCount = 0;
|
|
|
|
ownerBrowser.treeStyleTab.treeStructure = aTreeStructure;
|
2011-01-22 13:32:04 -05:00
|
|
|
ownerBrowser.treeStyleTab.shouldExpandAllTree = !!aExpandAllTree;
|
2011-05-25 00:58:25 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Extended version. If you don't know whether new tabs will be actually
|
|
|
|
* opened or not (by the command called after TST's API), then use this.
|
|
|
|
* This version automatically cancels the "ready" state with delay.
|
|
|
|
*/
|
2012-10-23 12:43:56 -04:00
|
|
|
readyToOpenNewTabGroupNow : function utils_readyToOpenNewTabGroupNow(aFrameOrTabBrowser) /* PUBLIC API */
|
2011-05-25 00:58:25 -04:00
|
|
|
{
|
2011-12-05 03:21:19 -05:00
|
|
|
|
2011-05-25 00:58:25 -04:00
|
|
|
if (this.readyToOpenNewTabGroup.apply(this, arguments)) {
|
|
|
|
let self = this;
|
|
|
|
this.Deferred.next(function() {
|
|
|
|
self.stopToOpenChildTab(aFrameOrTabBrowser);
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2011-05-25 00:58:25 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
stopToOpenChildTab : function utils_stopToOpenChildTab(aFrameOrTabBrowser) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
2011-05-25 00:58:25 -04:00
|
|
|
if (!frame) return false;
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachNewTab = false;
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachNewTabGroup = false;
|
|
|
|
ownerBrowser.treeStyleTab.readiedToAttachMultiple = false;
|
2010-12-07 11:28:23 -05:00
|
|
|
ownerBrowser.treeStyleTab.multipleCount = -1;
|
2009-12-25 12:55:55 -05:00
|
|
|
ownerBrowser.treeStyleTab.parentTab = null;
|
|
|
|
ownerBrowser.treeStyleTab.insertBefore = null;
|
|
|
|
ownerBrowser.treeStyleTab.treeStructure = null;
|
2010-07-29 22:39:51 -04:00
|
|
|
ownerBrowser.treeStyleTab.shouldExpandAllTree = false;
|
2011-05-25 00:58:25 -04:00
|
|
|
|
|
|
|
return true;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
checkToOpenChildTab : function utils_checkToOpenChildTab(aFrameOrTabBrowser) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
if (!frame) return false;
|
|
|
|
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
2011-01-22 13:32:04 -05:00
|
|
|
return !!(ownerBrowser.treeStyleTab.readiedToAttachNewTab || ownerBrowser.treeStyleTab.readiedToAttachNewTabGroup);
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
/* tree manipulations */
|
|
|
|
|
|
|
|
get treeViewEnabled() /* PUBLIC API */
|
|
|
|
{
|
|
|
|
return this._treeViewEnabled;
|
|
|
|
},
|
|
|
|
set treeViewEnabled(aValue)
|
|
|
|
{
|
2011-01-22 13:32:04 -05:00
|
|
|
this._treeViewEnabled = !!aValue;
|
2012-09-17 11:31:48 -04:00
|
|
|
Services.obs.notifyObservers(
|
2009-12-25 12:55:55 -05:00
|
|
|
window,
|
2010-11-30 19:33:07 -05:00
|
|
|
this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY,
|
2009-12-25 12:55:55 -05:00
|
|
|
this._treeViewEnabled
|
|
|
|
);
|
|
|
|
return aValue;
|
|
|
|
},
|
|
|
|
_treeViewEnabled : true,
|
|
|
|
|
|
|
|
get rootTabs() /* PUBLIC API */
|
|
|
|
{
|
2012-09-23 10:44:06 -04:00
|
|
|
return Array.slice(this.browser.mTabContainer.querySelectorAll('tab:not(['+this.kNEST+']), tab['+this.kNEST+'=""], tab['+this.kNEST+'="0"]'));
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2010-12-08 06:34:42 -05:00
|
|
|
get allRootTabs() /* PUBLIC API */
|
|
|
|
{
|
|
|
|
return this.rootTabs;
|
|
|
|
},
|
|
|
|
|
|
|
|
get visibleRootTabs() /* PUBLIC API */
|
|
|
|
{
|
|
|
|
return this.rootTabs.filter(function(aTab) {
|
|
|
|
return !aTab.hidden;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
canCollapseSubtree : function utils_canCollapseSubtree(aTabOrTabBrowser) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2010-11-29 03:24:45 -05:00
|
|
|
if (aTabOrTabBrowser &&
|
|
|
|
aTabOrTabBrowser.localName == 'tab' &&
|
|
|
|
aTabOrTabBrowser.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var b = this.getTabBrowserFromChild(aTabOrTabBrowser) || this.browser;
|
2011-06-15 22:54:13 -04:00
|
|
|
return b && b.getAttribute(this.kALLOW_COLLAPSE) == 'true';
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isCollapsed : function utils_isCollapsed(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2011-03-28 13:14:27 -04:00
|
|
|
if (!aTab ||
|
|
|
|
!this.canCollapseSubtree(this.getRootTab(aTab)))
|
2009-12-25 12:55:55 -05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return aTab.getAttribute(this.kCOLLAPSED) == 'true';
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isSubtreeCollapsed : function utils_isSubtreeCollapsed(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab || !this.canCollapseSubtree(aTab) || !this.hasChildTabs(aTab))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
shouldCloseTabSubtreeOf : function utils_shouldCloseTabSubtreeOf(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
this.hasChildTabs(aTab) &&
|
|
|
|
(
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
2009-12-25 12:55:55 -05:00
|
|
|
this.isSubtreeCollapsed(aTab)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
shouldCloseTabSubTreeOf : function() { return this.shouldCloseTabSubtreeOf.apply(this, arguments); }, // obsolete, for backward compatibility
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
shouldCloseLastTabSubtreeOf : function utils_shouldCloseLastTabSubtreeOf(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
|
|
|
return (
|
2011-06-15 22:54:13 -04:00
|
|
|
b &&
|
2009-12-25 12:55:55 -05:00
|
|
|
this.shouldCloseTabSubtreeOf(aTab) &&
|
2012-09-23 02:43:49 -04:00
|
|
|
this.getDescendantTabs(aTab).length + 1 == this.getAllTabs(b).length
|
2009-12-25 12:55:55 -05:00
|
|
|
);
|
|
|
|
},
|
|
|
|
shouldCloseLastTabSubTreeOf : function() { return this.shouldCloseLastTabSubtreeOf.apply(this, arguments); }, // obsolete, for backward compatibility
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getParentTab : function utils_getParentTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
2010-03-24 11:38:08 -04:00
|
|
|
|
2011-12-12 13:54:43 -05:00
|
|
|
var parent;
|
2012-08-04 16:04:26 -04:00
|
|
|
var id = aTab.getAttribute(this.kPARENT);
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
2012-08-04 16:04:26 -04:00
|
|
|
parent = this.getTabById(id);
|
|
|
|
if (parent && !parent.parentNode && this.tabsHash) {
|
|
|
|
delete this.tabsHash[id];
|
|
|
|
parent = null;
|
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
}
|
2011-12-12 13:54:43 -05:00
|
|
|
else {
|
|
|
|
parent = this.evaluateXPath(
|
2012-08-04 16:04:26 -04:00
|
|
|
'preceding-sibling::xul:tab[@'+this.kID+'="'+id+'"][1]',
|
2011-12-12 13:54:43 -05:00
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
}
|
|
|
|
return (parent && parent != aTab) ? parent : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getAncestorTabs : function utils_getAncestorTabs(aTab) /* PUBLIC API */
|
2010-12-01 03:40:18 -05:00
|
|
|
{
|
2011-12-12 13:54:43 -05:00
|
|
|
var tabs = [aTab];
|
2010-12-01 03:40:18 -05:00
|
|
|
var parentTab = aTab;
|
|
|
|
while (parentTab = this.getParentTab(parentTab))
|
|
|
|
{
|
2011-12-12 13:54:43 -05:00
|
|
|
if (tabs.indexOf(parentTab) > -1) {
|
|
|
|
let message = 'recursive tree detected!\n'+
|
|
|
|
tabs.concat([parentTab])
|
|
|
|
.reverse().map(function(aTab) {
|
|
|
|
return ' '+aTab._tPos+' : '+
|
|
|
|
aTab.label+'\n '+
|
|
|
|
aTab.getAttribute(this.kID);
|
|
|
|
}, this).join('\n');
|
|
|
|
dump(message+'\n');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTab._tPos < parentTab._tPos) {
|
|
|
|
let message = 'broken tree detected!\n'+
|
|
|
|
tabs.concat([parentTab])
|
|
|
|
.reverse().map(function(aTab) {
|
|
|
|
return ' '+aTab._tPos+' : '+
|
|
|
|
aTab.label+'\n '+
|
|
|
|
aTab.getAttribute(this.kID);
|
|
|
|
}, this).join('\n');
|
|
|
|
dump(message+'\n');
|
|
|
|
}
|
|
|
|
|
2010-12-01 03:40:18 -05:00
|
|
|
tabs.push(parentTab);
|
2011-12-12 13:54:43 -05:00
|
|
|
aTab = parentTab;
|
2010-12-01 03:40:18 -05:00
|
|
|
}
|
2011-12-12 13:54:43 -05:00
|
|
|
return tabs.slice(1);
|
2010-12-01 03:40:18 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getRootTab : function utils_getRootTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2010-03-24 11:38:08 -04:00
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
2011-12-12 13:54:43 -05:00
|
|
|
let ancestors = this.getAncestorTabs(aTab);
|
|
|
|
return ancestors.length ? ancestors[ancestors.length-1] : aTab ;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'(self::*[not(@'+this.kPARENT+')] | preceding-sibling::xul:tab[not(@'+this.kPARENT+')])[last()]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getNextSiblingTab : function utils_getNextSiblingTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
|
|
|
let parentTab = this.getParentTab(aTab);
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (!parentTab) {
|
|
|
|
let next = aTab;
|
|
|
|
do {
|
|
|
|
next = next.nextSibling;
|
|
|
|
}
|
|
|
|
while (next &&
|
|
|
|
next.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
|
|
|
|
this.getParentTab(next));
|
|
|
|
return next;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
let children = parentTab.getAttribute(this.kCHILDREN);
|
|
|
|
if (children) {
|
2011-12-05 03:21:19 -05:00
|
|
|
let list = ('|'+children).split('|'+aTab.getAttribute(this.kID));
|
|
|
|
list = list.length > 1 ? list[1].split('|') : [] ;
|
2010-03-24 11:38:08 -04:00
|
|
|
for (let i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
let firstChild = this.getTabById(list[i], aTab);
|
|
|
|
if (firstChild) return firstChild;
|
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
return null;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
var parent = aTab.getAttribute(this.kPARENT);
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'following-sibling::xul:tab['+
|
|
|
|
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
|
|
|
|
'][1]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getPreviousSiblingTab : function utils_getPreviousSiblingTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
|
|
|
let parentTab = this.getParentTab(aTab);
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (!parentTab) {
|
|
|
|
let prev = aTab;
|
|
|
|
do {
|
|
|
|
prev = prev.previousSibling;
|
|
|
|
}
|
|
|
|
while (prev &&
|
|
|
|
prev.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
|
|
|
|
this.getParentTab(prev));
|
|
|
|
return prev;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
let children = parentTab.getAttribute(this.kCHILDREN);
|
|
|
|
if (children) {
|
|
|
|
let list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[0].split('|');
|
|
|
|
for (let i = list.length-1; i > -1; i--)
|
|
|
|
{
|
|
|
|
let lastChild = this.getTabById(list[i], aTab);
|
|
|
|
if (lastChild) return lastChild;
|
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
return null;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
var parent = aTab.getAttribute(this.kPARENT);
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'preceding-sibling::xul:tab['+
|
|
|
|
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
|
|
|
|
'][1]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getSiblingTabs : function utils_getSiblingTabs(aTab) /* PUBLIC API */
|
2011-07-29 14:07:37 -04:00
|
|
|
{
|
|
|
|
var parent = this.getParentTab(aTab);
|
|
|
|
|
|
|
|
var siblings = parent && parent.parentNode ? this.getChildTabs(parent) : this.visibleRootTabs ;
|
|
|
|
return siblings.filter(function(aSiblingTab) {
|
|
|
|
return aSiblingTab != aTab;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getChildTabs : function utils_getChildTabs(aTab, aAllTabsArray) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var tabs = [];
|
|
|
|
if (!aTab) return tabs;
|
|
|
|
|
|
|
|
var children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
if (!children) return tabs;
|
|
|
|
|
|
|
|
if (aAllTabsArray) tabs = aAllTabsArray;
|
|
|
|
|
|
|
|
var list = children.split('|');
|
|
|
|
for (let i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
let tab = this.getTabById(list[i], aTab);
|
2010-03-25 10:49:22 -04:00
|
|
|
if (!tab || tab == aTab) continue;
|
2012-08-08 16:02:24 -04:00
|
|
|
if (tabs.indexOf(tab) > -1) {
|
|
|
|
let message = 'broken (possible recursive) tree detected!\n'+
|
|
|
|
tabs.map(function(aTab) {
|
|
|
|
return ' '+aTab._tPos+' : '+
|
|
|
|
aTab.label+'\n '+
|
|
|
|
aTab.getAttribute(this.kID);
|
|
|
|
}, this).join('\n');
|
|
|
|
dump(message+'\n');
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
tabs.push(tab);
|
|
|
|
if (aAllTabsArray)
|
|
|
|
this.getChildTabs(tab, tabs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tabs;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
hasChildTabs : function utils_hasChildTabs(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return false;
|
|
|
|
return aTab.hasAttribute(this.kCHILDREN);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getDescendantTabs : function utils_getDescendantTabs(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var tabs = [];
|
|
|
|
this.getChildTabs(aTab, tabs);
|
|
|
|
return tabs;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getFirstChildTab : function utils_getFirstChildTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
|
|
|
let children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
let firstChild = null;
|
|
|
|
if (children) {
|
|
|
|
let list = children.split('|');
|
|
|
|
for (let i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
firstChild = this.getTabById(list[i], aTab);
|
2010-03-25 10:49:22 -04:00
|
|
|
if (firstChild && firstChild != aTab) break;
|
2010-03-24 11:38:08 -04:00
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
return firstChild;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'following-sibling::xul:tab[@'+this.kPARENT+'="'+aTab.getAttribute(this.kID)+'"][1]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getLastChildTab : function utils_getLastChildTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
|
|
|
let children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
let lastChild = null;
|
|
|
|
if (children) {
|
|
|
|
let list = children.split('|');
|
|
|
|
for (let i = list.length-1; i > -1; i--)
|
|
|
|
{
|
|
|
|
lastChild = this.getTabById(list[i], aTab);
|
2010-03-25 11:52:11 -04:00
|
|
|
if (lastChild && lastChild != aTab) break;
|
2010-03-24 11:38:08 -04:00
|
|
|
}
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
return lastChild;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'following-sibling::xul:tab[@'+this.kPARENT+'="'+aTab.getAttribute(this.kID)+'"][last()]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getLastDescendantTab : function utils_getLastDescendantTab(aTab) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
2010-03-24 11:38:08 -04:00
|
|
|
if (this.tabsHash) { // XPath-less implementation
|
|
|
|
let tabs = this.getDescendantTabs(aTab);
|
|
|
|
return tabs.length ? tabs[tabs.length-1] : null ;
|
|
|
|
}
|
|
|
|
|
|
|
|
var parent = aTab.getAttribute(this.kPARENT);
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'following-sibling::xul:tab['+
|
|
|
|
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
|
|
|
|
'][1]/preceding-sibling::xul:tab[1][not(@'+this.kID+'="'+aTab.getAttribute(this.kID)+'")]',
|
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
collectRootTabs : function utils_collectRootTabs(aTabs) /* PUBLIC API */
|
2011-06-15 00:32:39 -04:00
|
|
|
{
|
2011-06-15 04:38:14 -04:00
|
|
|
aTabs = Array.slice(aTabs);
|
|
|
|
return aTabs.filter(function(aTab) {
|
|
|
|
var parent = this.getParentTab(aTab);
|
|
|
|
return !parent || aTabs.indexOf(parent) < 0;
|
2011-06-15 00:32:39 -04:00
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getChildIndex : function utils_getChildIndex(aTab, aParent) /* PUBLIC API */
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
2011-12-14 23:32:17 -05:00
|
|
|
var parent = this.getParentTab(aTab);
|
|
|
|
if (!aParent || !parent || aParent != parent) {
|
|
|
|
let tabs = [aTab].concat(this.getAncestorTabs(aTab));
|
|
|
|
parent = aTab;
|
|
|
|
for (let i = 0, maxi = tabs.length; i < maxi && parent != aParent; i++)
|
|
|
|
{
|
|
|
|
aTab = parent;
|
|
|
|
parent = i < maxi ? tabs[i+1] : null ;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2011-12-14 23:32:17 -05:00
|
|
|
if (parent != aParent)
|
2010-03-24 11:38:08 -04:00
|
|
|
return -1;
|
2011-12-14 23:32:17 -05:00
|
|
|
aParent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
let children = aParent.getAttribute(this.kCHILDREN);
|
|
|
|
let list = children.split('|');
|
|
|
|
let id = aTab.getAttribute(this.kID);
|
|
|
|
for (let i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
if (list[i] == id) return i;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2010-03-24 11:38:08 -04:00
|
|
|
return -1;
|
2009-12-25 12:55:55 -05:00
|
|
|
}
|
2011-12-14 23:32:17 -05:00
|
|
|
else {
|
|
|
|
let tabs = this.rootTabs;
|
|
|
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
if (tabs[i] == aTab) return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getXOffsetOfTab : function utils_getXOffsetOfTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var extraCondition = this.canCollapseSubtree(aTab) ?
|
|
|
|
'[not(@'+this.kCOLLAPSED+'="true")]' :
|
|
|
|
'' ;
|
|
|
|
|
|
|
|
return this.evaluateXPath(
|
2010-08-13 13:14:46 -04:00
|
|
|
'sum((self::* | preceding-sibling::xul:tab[not(@hidden="true")]'+extraCondition+')'+
|
|
|
|
'/attribute::'+this.kX_OFFSET+')',
|
2009-12-25 12:55:55 -05:00
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.NUMBER_TYPE
|
|
|
|
).numberValue;
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getYOffsetOfTab : function utils_getYOffsetOfTab(aTab)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
var extraCondition = this.canCollapseSubtree(aTab) ?
|
|
|
|
'[not(@'+this.kCOLLAPSED+'="true")]' :
|
|
|
|
'';
|
|
|
|
|
|
|
|
return this.evaluateXPath(
|
2010-08-13 13:14:46 -04:00
|
|
|
'sum((self::* | preceding-sibling::xul:tab[not(@hidden="true")]'+extraCondition+')'+
|
|
|
|
'/attribute::'+this.kY_OFFSET+')',
|
2009-12-25 12:55:55 -05:00
|
|
|
aTab,
|
|
|
|
Ci.nsIDOMXPathResult.NUMBER_TYPE
|
|
|
|
).numberValue;
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getFutureBoxObject : function utils_getFutureBoxObject(aTab)
|
2012-01-28 16:43:43 -05:00
|
|
|
{
|
|
|
|
var tabBox = aTab.boxObject;
|
|
|
|
var xOffset = this.getXOffsetOfTab(aTab);
|
|
|
|
var yOffset = this.getYOffsetOfTab(aTab);
|
|
|
|
return {
|
|
|
|
width : tabBox.width,
|
|
|
|
height : tabBox.height,
|
|
|
|
x : tabBox.x + xOffset,
|
|
|
|
y : tabBox.y + yOffset,
|
|
|
|
screenX : tabBox.screenX + xOffset,
|
|
|
|
screenY : tabBox.screenY + yOffset
|
|
|
|
};
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabActualScreenPosition : function utils_getTabActualScreenPosition(aTab)
|
2012-10-12 11:37:03 -04:00
|
|
|
{
|
|
|
|
return aTab.parentNode.orient == 'vertical' ?
|
|
|
|
this.getTabActualScreenY(aTab) :
|
|
|
|
this.getTabActualScreenX(aTab) ;
|
|
|
|
},
|
|
|
|
MATRIX_PATTERN : /matrix\((-?\d+),\s*(-?\d+),\s*(-?\d+),\s*(-?\d+),\s*(-?\d+),\s*(-?\d+)\)/,
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabActualScreenX : function utils_getTabActualScreenX(aTab)
|
2012-10-12 11:37:03 -04:00
|
|
|
{
|
|
|
|
var x = aTab.boxObject.screenX;
|
|
|
|
|
|
|
|
var w = aTab.ownerDocument.defaultView;
|
|
|
|
var transform = w.getComputedStyle(aTab, null).transform;
|
2012-10-12 11:41:03 -04:00
|
|
|
var offset = transform && transform.match(this.MATRIX_PATTERN);
|
2012-10-12 11:37:03 -04:00
|
|
|
offset = offset ? parseFloat(offset[5]) : 0 ;
|
|
|
|
|
|
|
|
return x + offset;
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
getTabActualScreenY : function utils_getTabActualScreenY(aTab)
|
2012-10-12 11:37:03 -04:00
|
|
|
{
|
|
|
|
var y = aTab.boxObject.screenY;
|
|
|
|
|
|
|
|
var w = aTab.ownerDocument.defaultView;
|
|
|
|
var transform = w.getComputedStyle(aTab, null).transform;
|
2012-10-12 11:41:03 -04:00
|
|
|
var offset = transform && transform.match(this.MATRIX_PATTERN);
|
2012-10-12 11:37:03 -04:00
|
|
|
offset = offset ? parseFloat(offset[6]) : 0 ;
|
|
|
|
|
|
|
|
return y + offset;
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
isGroupTab : function utils_isGroupTab(aTab, aLazyCheck)
|
2009-12-25 12:55:55 -05:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
(aLazyCheck || aTab.linkedBrowser.sessionHistory.count == 1) &&
|
|
|
|
aTab.linkedBrowser.currentURI.spec.indexOf('about:treestyletab-group') > -1
|
|
|
|
);
|
|
|
|
},
|
2010-09-09 06:03:03 -04:00
|
|
|
|
|
|
|
get pinnedTabsCount()
|
|
|
|
{
|
2012-09-23 02:51:11 -04:00
|
|
|
return this.browser.mTabContainer.querySelectorAll('tab[pinned="true"]').length;
|
2010-09-09 06:03:03 -04:00
|
|
|
},
|
2011-01-19 21:55:49 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
forceExpandTabs : function utils_forceExpandTabs(aTabs)
|
2011-06-15 04:38:14 -04:00
|
|
|
{
|
|
|
|
var collapsedStates = aTabs.map(function(aTab) {
|
|
|
|
return this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
|
|
|
|
}, this);
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = aTabs[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
this.collapseExpandSubtree(tab, false, true);
|
|
|
|
this.collapseExpandTab(tab, false, true);
|
|
|
|
}
|
2011-06-15 04:38:14 -04:00
|
|
|
return collapsedStates;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTreeStructureFromTabs : function utils_getTreeStructureFromTabs(aTabs)
|
2011-01-19 21:55:49 -05:00
|
|
|
{
|
|
|
|
/* this returns...
|
|
|
|
[A] => -1 (parent is not in this tree)
|
|
|
|
[B] => 0 (parent is 1st item in this tree)
|
|
|
|
[C] => 0 (parent is 1st item in this tree)
|
|
|
|
[D] => 2 (parent is 2nd in this tree)
|
|
|
|
[E] => -1 (parent is not in this tree, and this creates another tree)
|
|
|
|
[F] => 0 (parent is 1st item in this another tree)
|
|
|
|
*/
|
|
|
|
return this.cleanUpTreeStructureArray(
|
|
|
|
aTabs.map(function(aTab, aIndex) {
|
|
|
|
let tab = this.getParentTab(aTab);
|
|
|
|
let index = tab ? aTabs.indexOf(tab) : -1 ;
|
|
|
|
return index >= aIndex ? -1 : index ;
|
|
|
|
}, this),
|
|
|
|
-1
|
|
|
|
);
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
cleanUpTreeStructureArray : function utils_cleanUpTreeStructureArray(aTreeStructure, aDefaultParent)
|
2011-01-19 21:55:49 -05:00
|
|
|
{
|
|
|
|
var offset = 0;
|
|
|
|
aTreeStructure = aTreeStructure
|
|
|
|
.map(function(aPosition, aIndex) {
|
|
|
|
return (aPosition == aIndex) ? -1 : aPosition ;
|
|
|
|
})
|
|
|
|
.map(function(aPosition, aIndex) {
|
|
|
|
if (aPosition == -1) {
|
|
|
|
offset = aIndex;
|
|
|
|
return aPosition;
|
|
|
|
}
|
|
|
|
return aPosition - offset;
|
|
|
|
});
|
|
|
|
|
|
|
|
/* The final step, this validates all of values.
|
|
|
|
Smaller than -1 is invalid, so it becomes to -1. */
|
|
|
|
aTreeStructure = aTreeStructure.map(function(aIndex) {
|
|
|
|
return aIndex < -1 ? aDefaultParent : aIndex ;
|
|
|
|
}, this);
|
|
|
|
return aTreeStructure;
|
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
applyTreeStructureToTabs : function utils_applyTreeStructureToTabs(aTabs, aTreeStructure, aExpandStates)
|
2011-01-19 21:55:49 -05:00
|
|
|
{
|
|
|
|
var b = this.getTabBrowserFromChild(aTabs[0]);
|
|
|
|
if (!b) return;
|
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
|
|
aTabs = aTabs.slice(0, aTreeStructure.length);
|
|
|
|
aTreeStructure = aTreeStructure.slice(0, aTabs.length);
|
|
|
|
|
2011-06-15 04:38:14 -04:00
|
|
|
aExpandStates = (aExpandStates && typeof aExpandStates == 'object') ?
|
|
|
|
aExpandStates :
|
|
|
|
aTabs.map(function(aTab) {
|
|
|
|
return !!aExpandStates;
|
|
|
|
});
|
|
|
|
aExpandStates = aExpandStates.slice(0, aTabs.length);
|
|
|
|
while (aExpandStates.length < aTabs.length) aExpandStates.push(-1);
|
|
|
|
|
2011-01-19 21:55:49 -05:00
|
|
|
var parentTab = null;
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = aTabs[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
if (sv.isCollapsed(tab)) sv.collapseExpandTab(tab, false, true);
|
|
|
|
sv.detachTab(tab);
|
2011-01-19 21:55:49 -05:00
|
|
|
|
2012-02-04 13:15:38 -05:00
|
|
|
let parentIndexInTree = aTreeStructure[i];
|
2011-06-15 04:38:14 -04:00
|
|
|
if (parentIndexInTree < 0) // there is no parent, so this is a new parent!
|
2012-02-04 13:15:38 -05:00
|
|
|
parentTab = tab.getAttribute(sv.kID);
|
2011-01-19 21:55:49 -05:00
|
|
|
|
2012-02-04 13:15:38 -05:00
|
|
|
let parent = sv.getTabById(parentTab);
|
2011-01-19 21:55:49 -05:00
|
|
|
if (parent) {
|
|
|
|
let tabs = [parent].concat(sv.getDescendantTabs(parent));
|
2011-06-15 04:38:14 -04:00
|
|
|
parent = parentIndexInTree < tabs.length ? tabs[parentIndexInTree] : parent ;
|
2011-01-19 21:55:49 -05:00
|
|
|
}
|
|
|
|
if (parent) {
|
2012-02-04 13:15:38 -05:00
|
|
|
sv.attachTabTo(tab, parent, {
|
2011-12-06 22:06:05 -05:00
|
|
|
forceExpand : true,
|
|
|
|
dontMove : true
|
2011-01-19 21:55:49 -05:00
|
|
|
});
|
|
|
|
}
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2011-06-15 04:38:14 -04:00
|
|
|
|
|
|
|
for (let i = aTabs.length-1; i > -1; i--)
|
|
|
|
{
|
2011-12-06 22:06:05 -05:00
|
|
|
sv.collapseExpandSubtree(aTabs[i], !sv.hasChildTabs(aTabs[i]) || !aExpandStates[i], true);
|
2011-06-15 04:38:14 -04:00
|
|
|
}
|
2011-01-19 21:55:49 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getTreeStructureFromTabBrowser : function utils_getTreeStructureFromTabBrowser(aTabBrowser)
|
2011-01-19 21:55:49 -05:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
return this.getTreeStructureFromTabs(this.getAllTabs(aTabBrowser));
|
2011-01-19 21:55:49 -05:00
|
|
|
},
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
applyTreeStructureToTabBrowser : function utils_applyTreeStructureToTabBrowser(aTabBrowser, aTreeStructure, aExpandAllTree)
|
2011-01-19 21:55:49 -05:00
|
|
|
{
|
2012-09-23 02:43:49 -04:00
|
|
|
var tabs = this.getAllTabs(aTabBrowser);
|
2011-01-19 21:55:49 -05:00
|
|
|
return this.applyTreeStructureToTabs(tabs, aTreeStructure, aExpandAllTree);
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2009-12-25 13:13:33 -05:00
|
|
|
/* tabbar position */
|
2009-12-25 11:51:24 -05:00
|
|
|
|
2011-01-22 10:46:29 -05:00
|
|
|
get position() /* PUBLIC API */
|
2009-12-25 11:38:14 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
return utils.getTreePref('tabbar.position') || 'top';
|
2009-12-25 11:38:14 -05:00
|
|
|
},
|
2011-01-22 10:46:29 -05:00
|
|
|
set position(aValue)
|
2009-12-25 11:38:14 -05:00
|
|
|
{
|
2010-05-08 04:30:39 -04:00
|
|
|
var position = String(aValue).toLowerCase();
|
|
|
|
if (!position || !/^(top|bottom|left|right)$/.test(position))
|
2009-12-25 11:38:14 -05:00
|
|
|
position = 'top';
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
if (position != utils.getTreePref('tabbar.position'))
|
|
|
|
utils.setTreePref('tabbar.position', position);
|
2009-12-25 11:38:14 -05:00
|
|
|
|
|
|
|
return aValue;
|
|
|
|
},
|
2011-01-22 10:46:29 -05:00
|
|
|
get currentTabbarPosition() /* for backward compatibility */
|
|
|
|
{
|
|
|
|
return this.position;
|
|
|
|
},
|
|
|
|
set currentTabbarPosition(aValue)
|
|
|
|
{
|
|
|
|
return this.position = aValue;
|
|
|
|
},
|
2010-02-03 08:43:39 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
getPositionFlag : function utils_getPositionFlag(aPosition)
|
2010-02-03 08:43:39 -05:00
|
|
|
{
|
|
|
|
aPosition = String(aPosition).toLowerCase();
|
|
|
|
return (aPosition == 'left') ? this.kTABBAR_LEFT :
|
|
|
|
(aPosition == 'right') ? this.kTABBAR_RIGHT :
|
|
|
|
(aPosition == 'bottom') ? this.kTABBAR_BOTTOM :
|
|
|
|
this.kTABBAR_TOP;
|
|
|
|
},
|
2009-12-25 11:51:24 -05:00
|
|
|
|
2009-12-25 13:13:33 -05:00
|
|
|
/* Pref Listener */
|
2009-12-25 11:56:45 -05:00
|
|
|
|
|
|
|
domains : [
|
2009-12-25 13:13:33 -05:00
|
|
|
'extensions.treestyletab.',
|
2012-11-27 13:34:57 -05:00
|
|
|
'browser.tabs.animate',
|
2009-12-25 13:13:33 -05:00
|
|
|
'browser.tabs.loadFolderAndReplace',
|
2010-03-31 06:34:30 -04:00
|
|
|
'browser.tabs.insertRelatedAfterCurrent',
|
|
|
|
'extensions.stm.tabBarMultiRows' // Super Tab Mode
|
2009-12-25 11:56:45 -05:00
|
|
|
],
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
onPrefChange : function utils_onPrefChange(aPrefName)
|
2009-12-25 11:56:45 -05:00
|
|
|
{
|
|
|
|
var value = this.getPref(aPrefName);
|
|
|
|
switch (aPrefName)
|
|
|
|
{
|
2012-08-30 14:48:00 -04:00
|
|
|
case 'extensions.treestyletab.indent.vertical':
|
2012-08-30 13:46:50 -04:00
|
|
|
this.baseIndentVertical = value;
|
2012-09-17 11:31:48 -04:00
|
|
|
Services.obs.notifyObservers(null, this.kTOPIC_INDENT_MODIFIED, value);
|
2012-08-30 13:46:50 -04:00
|
|
|
return;
|
|
|
|
case 'extensions.treestyletab.indent.horizontal':
|
|
|
|
this.baseIndentHorizontal = value;
|
2012-09-17 11:31:48 -04:00
|
|
|
Services.obs.notifyObservers(null, this.kTOPIC_INDENT_MODIFIED, value);
|
2011-03-24 22:42:50 -04:00
|
|
|
return;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
case 'extensions.treestyletab.tabbar.width':
|
|
|
|
case 'extensions.treestyletab.tabbar.shrunkenWidth':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.updateTabWidthPrefs(aPrefName);
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2010-05-02 00:32:08 -04:00
|
|
|
case 'browser.tabs.insertRelatedAfterCurrent':
|
2009-12-25 13:13:33 -05:00
|
|
|
case 'browser.tabs.loadFolderAndReplace':
|
2010-03-31 06:34:30 -04:00
|
|
|
case 'extensions.stm.tabBarMultiRows': // Super Tab Mode
|
2009-12-25 13:13:33 -05:00
|
|
|
if (this.prefOverriding) return;
|
|
|
|
aPrefName += '.override';
|
|
|
|
this.setPref(aPrefName, value);
|
2010-05-02 00:32:08 -04:00
|
|
|
case 'browser.tabs.insertRelatedAfterCurrent.override':
|
2009-12-25 13:13:33 -05:00
|
|
|
case 'browser.tabs.loadFolderAndReplace.override':
|
2010-03-31 06:34:30 -04:00
|
|
|
case 'extensions.stm.tabBarMultiRows.override': // Super Tab Mode
|
2010-05-02 00:51:19 -04:00
|
|
|
if (this.getPref(aPrefName+'.force')) {
|
|
|
|
let defaultValue = this.getDefaultPref(aPrefName);
|
|
|
|
if (value != defaultValue) {
|
|
|
|
this.setPref(aPrefName, defaultValue);
|
|
|
|
return;
|
|
|
|
}
|
2010-05-02 00:32:08 -04:00
|
|
|
}
|
2009-12-25 13:13:33 -05:00
|
|
|
this.prefOverriding = true;
|
2010-05-02 00:51:19 -04:00
|
|
|
let (target = aPrefName.replace('.override', '')) {
|
|
|
|
let originalValue = this.getPref(target);
|
|
|
|
if (originalValue !== null && originalValue != value)
|
|
|
|
this.setPref(target+'.backup', originalValue);
|
|
|
|
this.setPref(target, this.getPref(aPrefName));
|
|
|
|
}
|
2009-12-25 13:13:33 -05:00
|
|
|
this.prefOverriding = false;
|
2011-03-24 22:42:50 -04:00
|
|
|
return;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
case 'extensions.treestyletab.clickOnIndentSpaces.enabled':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.shouldDetectClickOnIndentSpaces = this.getPref(aPrefName);
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
case 'extensions.treestyletab.tabbar.scroll.smooth':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.smoothScrollEnabled = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
case 'extensions.treestyletab.tabbar.scroll.duration':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.smoothScrollDuration = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2010-07-25 12:13:19 -04:00
|
|
|
case 'extensions.treestyletab.tabbar.scrollToNewTab.mode':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.scrollToNewTabMode = value;
|
|
|
|
|
|
|
|
case 'extensions.treestyletab.tabbar.narrowScrollbar.size':
|
|
|
|
return this.updateNarrowScrollbarStyle();
|
2010-07-25 12:13:19 -04:00
|
|
|
|
2012-11-27 13:34:57 -05:00
|
|
|
case 'browser.tabs.animate':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.animationEnabled = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
case 'extensions.treestyletab.animation.indent.duration':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.indentDuration = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
case 'extensions.treestyletab.animation.collapse.duration':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.collapseDuration = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
case 'extensions.treestyletab.twisty.expandSensitiveArea':
|
2011-03-24 22:42:50 -04:00
|
|
|
return this.shouldExpandTwistyArea = value;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2012-01-13 11:45:51 -05:00
|
|
|
case 'extensions.treestyletab.counter.role.horizontal':
|
|
|
|
return this.counterRoleHorizontal = value;
|
|
|
|
|
|
|
|
case 'extensions.treestyletab.counter.role.vertical':
|
|
|
|
return this.counterRoleVertical = value;
|
|
|
|
|
2009-12-25 11:56:45 -05:00
|
|
|
default:
|
2011-03-24 22:42:50 -04:00
|
|
|
return;
|
2009-12-25 11:56:45 -05:00
|
|
|
}
|
|
|
|
},
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
updateTabWidthPrefs : function utils_updateTabWidthPrefs(aPrefName)
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
var expanded = utils.getTreePref('tabbar.width');
|
|
|
|
var shrunken = utils.getTreePref('tabbar.shrunkenWidth');
|
2010-04-22 05:24:21 -04:00
|
|
|
var originalExpanded = expanded;
|
|
|
|
var originalShrunken = shrunken;
|
|
|
|
if (aPrefName == 'extensions.treestyletab.tabbar.shrunkenWidth') {
|
|
|
|
if (expanded <= shrunken)
|
|
|
|
expanded = parseInt(shrunken / this.DEFAULT_SHRUNKEN_WIDTH_RATIO)
|
|
|
|
let w = this.browserWindow;
|
|
|
|
if (w && expanded > w.gBrowser.boxObject.width) {
|
|
|
|
expanded = w.gBrowser.boxObject.width * this.MAX_TABBAR_SIZE_RATIO;
|
|
|
|
if (expanded <= shrunken)
|
|
|
|
shrunken = parseInt(expanded * this.DEFAULT_SHRUNKEN_WIDTH_RATIO)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (expanded <= shrunken)
|
|
|
|
shrunken = parseInt(expanded * this.DEFAULT_SHRUNKEN_WIDTH_RATIO);
|
|
|
|
}
|
|
|
|
if (expanded != originalExpanded ||
|
|
|
|
shrunken != originalShrunken) {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.width', Math.max(0, expanded));
|
|
|
|
utils.setTreePref('tabbar.shrunkenWidth', Math.max(0, shrunken));
|
2009-12-25 13:13:33 -05:00
|
|
|
}
|
|
|
|
},
|
2012-10-19 08:38:35 -04:00
|
|
|
|
2011-04-06 08:05:59 -04:00
|
|
|
get shouldApplyNewPref()
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
!this.applyOnlyForActiveWindow ||
|
|
|
|
this.window == this.topBrowserWindow
|
|
|
|
) &&
|
|
|
|
!this.inWindowDestoructionProcess;
|
|
|
|
},
|
|
|
|
|
2011-05-04 04:10:02 -04:00
|
|
|
applyOnlyForActiveWindow : false,
|
2011-04-06 08:05:59 -04:00
|
|
|
setPrefForActiveWindow : function(aTask) {
|
2012-09-27 02:40:14 -04:00
|
|
|
TreeStyleTabBase.applyOnlyForActiveWindow = true;
|
2011-04-06 08:05:59 -04:00
|
|
|
try {
|
|
|
|
aTask.call(this);
|
|
|
|
}
|
|
|
|
finally {
|
2012-09-27 02:40:14 -04:00
|
|
|
TreeStyleTabBase.applyOnlyForActiveWindow = false;
|
2011-04-06 08:05:59 -04:00
|
|
|
}
|
2009-12-25 11:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-09-27 02:40:14 -04:00
|
|
|
TreeStyleTabBase.init();
|
2009-12-25 11:51:24 -05:00
|
|
|
|