From 37fb58b7f9116680c9b63fcf3f40dc27109c398d Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 23 Feb 2014 18:48:57 +0100 Subject: heuristic to avoid exporting Firefox Places menubar --- chrome/content/topmenuservice.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'chrome') diff --git a/chrome/content/topmenuservice.js b/chrome/content/topmenuservice.js index 96d0e6c..30b66eb 100644 --- a/chrome/content/topmenuservice.js +++ b/chrome/content/topmenuservice.js @@ -62,11 +62,20 @@ function WindowProxy(window) { } this.srcWindow = window; - this.srcMenuBar = null; - this.observer = null; - this.appMenuBar = null; + this.srcMenuBar = menubars[0]; + + // A hack to heuristically detect if we must export this menubar. + var srcMenuBarParent = this.srcMenuBar.parentNode; + if (srcMenuBarParent.firstChild !== this.srcMenuBar) { + // This menu is not the first child on the parent item. + // Do not export this menubar. + this.srcWindow = null; + this.srcMenuBar = null; + return; + } + + this.gdkWindow = getTopLevelGdkWindow(window); - this.accelGroup = null; this.flags = {}; this.updateFlags(); @@ -780,11 +789,15 @@ WindowProxy.prototype.fakeCommandEvent = function(item) { WindowProxy.prototype.unload = function() { this.setMenuBarVisibility(true); - topmenu_client.topmenu_client_disconnect_window(this.gdkWindow); + if (this.gdkWindow) { + topmenu_client.topmenu_client_disconnect_window(this.gdkWindow); + } } WindowProxy.prototype.dispose = function() { - window.document.removeEventListener("keypress", this.callbacks.keypress); + if (this.srcWindow) { + this.srcWindow.document.removeEventListener("keypress", this.callbacks.keypress); + } if (this.monitor) { if (this.monitorConnectionId) { gobject.g_signal_handler_disconnect(this.monitor, this.monitorConnectionId); @@ -810,6 +823,7 @@ WindowProxy.prototype.dispose = function() { } this.gdkWindow = null; + this.srcMenuBar = null; this.srcWindow = null; this.menus = null; this.items = null; -- cgit v1.2.3