@@ -1178,6 +1178,14 @@ tabutils._protectAndLockTab = function() {
1178
1178
}
1179
1179
} ;
1180
1180
1181
+ gBrowser . isProtected = function isProtected ( aTab ) {
1182
+ return aTab . hasAttribute ( "protected" ) || aTab . pinned && this . _autoProtectPinned ;
1183
+ } ;
1184
+
1185
+ gBrowser . isLocked = function isLocked ( aTab ) {
1186
+ return aTab . hasAttribute ( "locked" ) || aTab . pinned && this . _autoLockPinned ;
1187
+ } ;
1188
+
1181
1189
TU_hookCode ( "gBrowser.onTabRestoring" , "}" , function ( ) {
1182
1190
this . protectTab ( aTab , ss . getTabValue ( aTab , "protected" ) == "true" , true ) ;
1183
1191
this . lockTab ( aTab , ss . getTabValue ( aTab , "locked" ) == "true" , true ) ;
@@ -1199,30 +1207,23 @@ tabutils._protectAndLockTab = function() {
1199
1207
TU_hookCode ( "gBrowser.onLocationChange" , "}" , "this.autoProtectTab(aTab, uri, tags);this.autoLockTab(aTab, uri, tags);" ) ;
1200
1208
1201
1209
TU_hookCode ( "gBrowser.removeTab" , "{" , function ( ) {
1202
- if ( aTab . hasAttribute ( "protected" ) ||
1203
- aTab . pinned && TU_getPref ( "extensions.tabutils.pinTab.autoProtect" , false ) )
1210
+ if ( this . isProtected ( aTab ) )
1204
1211
return ;
1205
1212
} ) ;
1206
1213
TU_hookCode ( "gBrowser.createTooltip" , / ( t a b | t n ) .m O v e r C l o s e B u t t o n / , "$& && !$1.hasAttribute('protected')" ) ;
1207
1214
1208
1215
TU_hookCode ( "gBrowser.loadURI" , "{" , function ( ) {
1209
- let locked = this . mCurrentTab . hasAttribute ( "locked" )
1210
- || this . mCurrentTab . pinned && TU_getPref ( "extensions.tabutils.pinTab.autoLock" , false ) ;
1211
- if ( locked && ! aURI . startsWith ( "javascript:" ) )
1216
+ if ( this . isLocked ( this . mCurrentTab ) && ! aURI . startsWith ( "javascript:" ) )
1212
1217
return this . loadOneTab ( aURI , aReferrerURI , aCharset , null , null , false ) ;
1213
1218
} ) ;
1214
1219
1215
1220
TU_hookCode ( "gBrowser.loadURIWithFlags" , "{" , function ( ) {
1216
- let locked = this . mCurrentTab . hasAttribute ( "locked" )
1217
- || this . mCurrentTab . pinned && TU_getPref ( "extensions.tabutils.pinTab.autoLock" , false ) ;
1218
- if ( locked && ! aURI . startsWith ( "javascript:" ) )
1221
+ if ( this . isLocked ( this . mCurrentTab ) && ! aURI . startsWith ( "javascript:" ) )
1219
1222
return this . loadOneTab ( aURI , aReferrerURI , aCharset , aPostData , null , aFlags & Ci . nsIWebNavigation . LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP ) ;
1220
1223
} ) ;
1221
1224
1222
1225
TU_hookCode ( "contentAreaClick" , / i f [ ^ { } ] * e v e n t .b u t t o n = = 0 [ ^ { } ] * { ( [ ^ { } ] | { [ ^ { } ] * } | { ( [ ^ { } ] | { [ ^ { } ] * } ) * } ) * (? = } ) / , "$&" + ( function ( ) {
1223
- let locked = gBrowser . mCurrentTab . hasAttribute ( "locked" )
1224
- || gBrowser . mCurrentTab . pinned && TU_getPref ( "extensions.tabutils.pinTab.autoLock" , false ) ;
1225
- if ( locked && ! href . startsWith ( "javascript:" ) ) {
1226
+ if ( gBrowser . isLocked ( gBrowser . mCurrentTab ) && ! href . startsWith ( "javascript:" ) ) {
1226
1227
openNewTabWith ( href , linkNode . ownerDocument , null , event , false ) ;
1227
1228
event . preventDefault ( ) ;
1228
1229
return ;
@@ -1345,8 +1346,7 @@ tabutils._restartTab = function() {
1345
1346
if ( aTab . hasAttribute ( "pending" ) ) // Bug 817947 [Fx20]
1346
1347
return ;
1347
1348
1348
- if ( aTab . hasAttribute ( "locked" ) ||
1349
- aTab . pinned && TU_getPref ( "extensions.tabutils.pinTab.autoLock" , false ) )
1349
+ if ( this . isLocked ( aTab ) )
1350
1350
return ;
1351
1351
1352
1352
var tabState = tabutils . _ss . getTabState ( aTab ) ;
@@ -1720,6 +1720,8 @@ tabutils._multiTabHandler = function() {
1720
1720
aTabs = aTabs ? "length" in aTabs ? aTabs : [ aTabs ] : [ ] ;
1721
1721
bTabs = bTabs ? "length" in bTabs ? bTabs : [ bTabs ] : [ ] ;
1722
1722
1723
+ aTabs = Array . filter ( aTabs , function ( aTab ) ! this . isProtected ( aTab ) , this ) ;
1724
+
1723
1725
if ( bTabs . length > 0 )
1724
1726
aTabs = Array . filter ( aTabs , function ( aTab ) Array . indexOf ( bTabs , aTab ) == - 1 ) ;
1725
1727
@@ -2464,13 +2466,13 @@ tabutils._tabContextMenu = function() {
2464
2466
}
2465
2467
2466
2468
[
2467
- [ "context_protectTab" , "protected" , "autoProtect " ] ,
2468
- [ "context_lockTab" , "locked" , "autoLock " ] ,
2469
- [ "context_faviconizeTab" , "faviconized" , "autoFaviconize " ]
2470
- ] . forEach ( function ( [ aId , aAttr , aPref ] ) {
2469
+ [ "context_protectTab" , "protected" , "_autoProtectPinned " ] ,
2470
+ [ "context_lockTab" , "locked" , "_autoLockPinned " ] ,
2471
+ [ "context_faviconizeTab" , "faviconized" , "_autoFaviconizePinned " ]
2472
+ ] . forEach ( function ( [ aId , aAttr , aProp ] ) {
2471
2473
let item = $ ( aId ) ;
2472
2474
if ( item && ! item . hidden && ! item . collapsed ) {
2473
- let disabled = TU_getPref ( "extensions.tabutils.pinTab." + aPref , false ) &&
2475
+ let disabled = gBrowser [ aProp ] &&
2474
2476
tabs . every ( function ( aTab ) aTab . pinned && ! aTab . hasAttribute ( aAttr ) ) ;
2475
2477
item . setAttribute ( "disabled" , disabled ) ;
2476
2478
item . setAttribute ( "checked" , disabled || tabs . every ( function ( aTab ) aTab . hasAttribute ( aAttr ) ) ) ;
@@ -3200,8 +3202,17 @@ tabutils._tabPrefObserver = {
3200
3202
tabsToolbar . _dragBindingAlive = TU_getPref ( "extensions.tabutils.dragBindingAlive" , true ) ;
3201
3203
} ,
3202
3204
3205
+ pinTab_autoProtect : function ( ) {
3206
+ gBrowser . _autoProtectPinned = TU_getPref ( "extensions.tabutils.pinTab.autoProtect" ) ;
3207
+ } ,
3208
+
3209
+ pinTab_autoLock : function ( ) {
3210
+ gBrowser . _autoLockPinned = TU_getPref ( "extensions.tabutils.pinTab.autoLock" ) ;
3211
+ } ,
3212
+
3203
3213
pinTab_autoFaviconize : function ( ) {
3204
- gBrowser . mTabContainer . setAttribute ( "autoFaviconizePinned" , TU_getPref ( "extensions.tabutils.pinTab.autoFaviconize" ) ) ;
3214
+ gBrowser . _autoFaviconizePinned = TU_getPref ( "extensions.tabutils.pinTab.autoFaviconize" ) ;
3215
+ gBrowser . mTabContainer . setAttribute ( "autoFaviconizePinned" , gBrowser . _autoFaviconizePinned ) ;
3205
3216
gBrowser . mTabContainer . positionPinnedTabs ( ) ;
3206
3217
gBrowser . mTabContainer . adjustTabstrip ( ) ;
3207
3218
} ,
0 commit comments