Skip to content

Commit

Permalink
115a
Browse files Browse the repository at this point in the history
  • Loading branch information
117649 committed Jun 7, 2023
1 parent 61aafa3 commit b364d1d
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 79 deletions.
4 changes: 2 additions & 2 deletions resource/modules/utils/Overlays.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ Modules.LOADMODULE = function() {
Browsers.register(Overlays, 'SidebarUnloaded');
Observers.add(Overlays, 'window-overlayed');

Piggyback.add('Overlays', CUIBackstage.CustomizableUIInternal, 'registerToolbarNode', Overlays.registerToolbarNode);
// Piggyback.add('Overlays', CUIBackstage.CustomizableUIInternal, 'registerToolbarNode', Overlays.registerToolbarNode);
};

Modules.UNLOADMODULE = function() {
Expand All @@ -2093,7 +2093,7 @@ Modules.UNLOADMODULE = function() {
Overlays.unloadAll(aWindow);
});

Piggyback.revert('Overlays', CUIBackstage.CustomizableUIInternal, 'registerToolbarNode');
// Piggyback.revert('Overlays', CUIBackstage.CustomizableUIInternal, 'registerToolbarNode');

delete Globals.widgets;
};
154 changes: 77 additions & 77 deletions resource/modules/utils/Piggyback.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -166,86 +166,86 @@ Modules.LOADMODULE = function() {

// CustomizableUI is a special case, as CustomizableUIInternal is frozen and not exported
self.CUIBackstage = ChromeUtils.import("resource:///modules/CustomizableUI.jsm", self);
CUIBackstage[Piggyback._obj] = {
replaceInternal: function(objs) {
if(!CUIBackstage.__CustomizableUIInternal) {
CUIBackstage.__CustomizableUIInternal = CUIBackstage.CustomizableUIInternal;

var CUIInternalNew = {};
for(var p in CUIBackstage.CustomizableUIInternal) {
if(CUIBackstage.CustomizableUIInternal.hasOwnProperty(p)) {
var propGetter = CUIBackstage.CustomizableUIInternal.__lookupGetter__(p);
if(propGetter) {
CUIInternalNew.__defineGetter__(p, propGetter.bind(CUIBackstage.__CustomizableUIInternal));
} else {
CUIInternalNew[p] = CUIBackstage.CustomizableUIInternal[p].bind(CUIBackstage.__CustomizableUIInternal);
}
}
}
CUIBackstage.CustomizableUIInternal = CUIInternalNew;
CUIBackstage[Piggyback._obj].active = true;

// we have to make sure any other modifications from other add-ons stay in place if we're re-replacing CUIInternal
if(objs) {
for(var id in objs) {
for(var [aName, bName] of objs[id]) {
for(var [aMethod, bMethod] of bName) {
Piggyback.add(aName, CUIBackstage.CustomizableUIInternal, aMethod, bMethod.method, bMethod.mode, bMethod);
}
}
}
}
}
},
active: false
};

CUIBackstage[Piggyback._obj].replaceInternal();

if(!CUIBackstage.__PiggybackIds) {
CUIBackstage.__PiggybackIds = objName;
} else if(CUIBackstage.__PiggybackIds.indexOf(objName) == -1) { // should always be the case if it doesn't exist
var ex = CUIBackstage.__PiggybackIds.split(' ');
ex.push(objName);
CUIBackstage.__PiggybackIds = ex.join(' ');
}
// CUIBackstage[Piggyback._obj] = {
// replaceInternal: function(objs) {
// if(!CUIBackstage.__CustomizableUIInternal) {
// CUIBackstage.__CustomizableUIInternal = CUIBackstage.CustomizableUIInternal;

// var CUIInternalNew = {};
// for(var p in CUIBackstage.CustomizableUIInternal) {
// if(CUIBackstage.CustomizableUIInternal.hasOwnProperty(p)) {
// var propGetter = CUIBackstage.CustomizableUIInternal.__lookupGetter__(p);
// if(propGetter) {
// CUIInternalNew.__defineGetter__(p, propGetter.bind(CUIBackstage.__CustomizableUIInternal));
// } else {
// CUIInternalNew[p] = CUIBackstage.CustomizableUIInternal[p].bind(CUIBackstage.__CustomizableUIInternal);
// }
// }
// }
// CUIBackstage.CustomizableUIInternal = CUIInternalNew;
// CUIBackstage[Piggyback._obj].active = true;

// // we have to make sure any other modifications from other add-ons stay in place if we're re-replacing CUIInternal
// if(objs) {
// for(var id in objs) {
// for(var [aName, bName] of objs[id]) {
// for(var [aMethod, bMethod] of bName) {
// Piggyback.add(aName, CUIBackstage.CustomizableUIInternal, aMethod, bMethod.method, bMethod.mode, bMethod);
// }
// }
// }
// }
// }
// },
// active: false
// };

// CUIBackstage[Piggyback._obj].replaceInternal();

// if(!CUIBackstage.__PiggybackIds) {
// CUIBackstage.__PiggybackIds = objName;
// } else if(CUIBackstage.__PiggybackIds.indexOf(objName) == -1) { // should always be the case if it doesn't exist
// var ex = CUIBackstage.__PiggybackIds.split(' ');
// ex.push(objName);
// CUIBackstage.__PiggybackIds = ex.join(' ');
// }
};

Modules.UNLOADMODULE = function() {
if(self.isContent) { return; }

var ids = CUIBackstage.__PiggybackIds ? CUIBackstage.__PiggybackIds.split(' ') : [];

// we really need to put everything back as it was!
if(ids.indexOf(objName) > -1) {
var active = CUIBackstage[Piggyback._obj].active;

delete CUIBackstage[Piggyback._obj];
ids.splice(ids.indexOf(objName), 1);
if(ids.length > 0) {
CUIBackstage.__PiggybackIds = ids.join(' ');
} else {
delete CUIBackstage.__PiggybackIds;
}

var internalObjs = null;
if(active) {
// we have to make sure any other modifications from other add-ons stay in place
if(CUIBackstage.CustomizableUIInternal.__PiggybackIds) {
var internalIds = CUIBackstage.CustomizableUIInternal.__PiggybackIds.split(' ');
internalObjs = {};
for(var id of internalIds) {
internalObjs[id] = CUIBackstage.CustomizableUIInternal['_Piggyback_'+id];
}
}

CUIBackstage.CustomizableUIInternal = CUIBackstage.__CustomizableUIInternal;
delete CUIBackstage.__CustomizableUIInternal;

// if another add-on is still initialized, make sure it redoes this
for(var id of ids) {
CUIBackstage['_Piggyback_'+id].replaceInternal(internalObjs);
}
}
}
// var ids = CUIBackstage.__PiggybackIds ? CUIBackstage.__PiggybackIds.split(' ') : [];

// // we really need to put everything back as it was!
// if(ids.indexOf(objName) > -1) {
// var active = CUIBackstage[Piggyback._obj].active;

// delete CUIBackstage[Piggyback._obj];
// ids.splice(ids.indexOf(objName), 1);
// if(ids.length > 0) {
// CUIBackstage.__PiggybackIds = ids.join(' ');
// } else {
// delete CUIBackstage.__PiggybackIds;
// }

// var internalObjs = null;
// if(active) {
// // we have to make sure any other modifications from other add-ons stay in place
// if(CUIBackstage.CustomizableUIInternal.__PiggybackIds) {
// var internalIds = CUIBackstage.CustomizableUIInternal.__PiggybackIds.split(' ');
// internalObjs = {};
// for(var id of internalIds) {
// internalObjs[id] = CUIBackstage.CustomizableUIInternal['_Piggyback_'+id];
// }
// }

// CUIBackstage.CustomizableUIInternal = CUIBackstage.__CustomizableUIInternal;
// delete CUIBackstage.__CustomizableUIInternal;

// // if another add-on is still initialized, make sure it redoes this
// for(var id of ids) {
// CUIBackstage['_Piggyback_'+id].replaceInternal(internalObjs);
// }
// }
// }
};

0 comments on commit b364d1d

Please sign in to comment.