Skip to content

Commit

Permalink
Issue 5946: Firebug breaks Firefox UI when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Oct 8, 2012
1 parent f95f305 commit 122d121
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
77 changes: 45 additions & 32 deletions extension/content/firebug/firefox/browserOverlay.js
Expand Up @@ -557,6 +557,51 @@ Firebug.GlobalUI =
}); });


return true; return true;
},

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Page Context Menu Overlay

loadContextMenuOverlay: function(win)
{
if (typeof(win.nsContextMenu) == "undefined")
return;

// https://bugzilla.mozilla.org/show_bug.cgi?id=433168
var setTargetOriginal = this.setTargetOriginal = win.nsContextMenu.prototype.setTarget;
win.nsContextMenu.prototype.setTarget = function(aNode, aRangeParent, aRangeOffset)
{
setTargetOriginal.apply(this, arguments);

if (this.isTargetAFormControl(aNode))
this.shouldDisplay = true;
};

// Hide built-in inspector if the pref says so.
var initItemsOriginal = this.initItemsOriginal = win.nsContextMenu.prototype.initItems;
win.nsContextMenu.prototype.initItems = function()
{
initItemsOriginal.apply(this, arguments);

// Hide built-in inspector menu item if the pref "extensions.firebug.hideDefaultInspector"
// says so. Note that there is also built-in preference "devtools.inspector.enable" that
// can be used for the same purpose.
var hideInspect = PrefLoader.getPref("hideDefaultInspector");
if (hideInspect)
{
this.showItem("inspect-separator", false);
this.showItem("context-inspect", false);
}
}
},

unloadContextMenuOverlay: function(win)
{
if (typeof(win.nsContextMenu) == "undefined")
return;

win.nsContextMenu.prototype.setTarget = this.setTargetOriginal;
win.nsContextMenu.prototype.initItems = this.initItemsOriginal;
} }
} }


Expand Down Expand Up @@ -1268,38 +1313,6 @@ if (checkFirebugVersion(PrefLoader.getPref("currentVersion")) > 0)
} }
} }


// ********************************************************************************************* //
// Firefox Page Context Menu

if (typeof(nsContextMenu) != "undefined")
{
// https://bugzilla.mozilla.org/show_bug.cgi?id=433168
var setTargetOriginal = nsContextMenu.prototype.setTarget;
nsContextMenu.prototype.setTarget = function(aNode, aRangeParent, aRangeOffset)
{
setTargetOriginal.apply(this, arguments);
if (this.isTargetAFormControl(aNode))
this.shouldDisplay = true;
};

// Hide built-in inspector if the pref says so.
var initItemsOriginal = nsContextMenu.prototype.initItems;
nsContextMenu.prototype.initItems = function()
{
initItemsOriginal.apply(this, arguments);

// Hide built-in inspector menu item if the pref "extensions.firebug.hideDefaultInspector"
// says so. Note that there is also built-in preference "devtools.inspector.enable" that
// can be used for the same purpose.
var hideInspect = PrefLoader.getPref("hideDefaultInspector");
if (hideInspect)
{
this.showItem("inspect-separator", false);
this.showItem("context-inspect", false);
}
}
}

// ********************************************************************************************* // // ********************************************************************************************* //
// All Pages Activation" is on // All Pages Activation" is on


Expand Down
4 changes: 4 additions & 0 deletions extension/modules/loader.js
Expand Up @@ -125,6 +125,8 @@ var FirebugLoader =
el.parentNode.removeChild(el); el.parentNode.removeChild(el);
}); });


win.Firebug.GlobalUI.unloadContextMenuOverlay(win);

delete win.Firebug; delete win.Firebug;
delete win.FBTrace; delete win.FBTrace;
delete win.FBL; delete win.FBL;
Expand All @@ -141,6 +143,8 @@ var FirebugLoader =
// Apply all Firefox/SeaMonkey overlays to the browser window. // Apply all Firefox/SeaMonkey overlays to the browser window.
loadSubscript("chrome://firebug/content/firefox/browserOverlay.js", win); loadSubscript("chrome://firebug/content/firefox/browserOverlay.js", win);


win.Firebug.GlobalUI.loadContextMenuOverlay(win);

// Firebug extensions should initialize here. // Firebug extensions should initialize here.
this.dispatchToScopes("topWindowLoad", [win]); this.dispatchToScopes("topWindowLoad", [win]);
}, },
Expand Down

0 comments on commit 122d121

Please sign in to comment.