[Pkg-mozext-commits] [tabmixplus] 10/73: Remove TabmixSvc.syncHandlers
David Prévot
taffit at moszumanska.debian.org
Mon May 9 02:30:50 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 34a11c5964f4693728cbee87495ad8dd76476af7
Author: onemen <tabmix.onemen at gmail.com>
Date: Sun Mar 27 14:46:30 2016 +0300
Remove TabmixSvc.syncHandlers
---
.eslintrc | 1 +
chrome/content/click/click.js | 25 +++++--------------------
chrome/content/content.js | 35 ++++++++++++++++++++++-------------
chrome/content/minit/tablib.js | 4 +++-
chrome/content/tabmix.js | 3 ---
modules/ContentClick.jsm | 5 -----
modules/ContextMenu.jsm | 10 +++-------
modules/DocShellCapabilities.jsm | 7 ++-----
modules/Services.jsm | 2 --
modules/Utils.jsm | 11 +++++++----
10 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index 6140171..30cb06c 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -340,6 +340,7 @@
"Scratchpad": false,
"sendAsyncMessage": false,
"sendSyncMessage": false,
+ "sendRpcMessage": false,
"Services": false,
"SidebarUtils": false,
"SessionStore": false,
diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index 8e56036..204b191 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -608,6 +608,9 @@ var TabmixContext = {
if (!gContextMenu || event.originalTarget != document.getElementById("contentAreaContextMenu"))
return true;
+ gContextMenu.tabmixLinks = Tabmix.contextMenuLinks;
+ Tabmix.contextMenuLinks = null;
+
var tab = gBrowser.selectedTab;
try {
var contentClick = gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage;
@@ -730,26 +733,8 @@ var TabmixContext = {
},
openMultipleLinks: function TMP_openMultipleLinks(check) {
- let urls = [];
- let browser = window.gBrowser.selectedBrowser;
-
- function getLinks() {
- try {
- let handler = TabmixSvc.syncHandlers.get(browser.permanentKey);
- let result = handler.getSelectedLinks();
- gContextMenu.tabmixLinks = result && result.split('\n');
- } catch (ex) {
- Tabmix.log("unable to get syncHandlers for page " +
- browser.currentURI.spec + "\n" + ex);
- }
- return gContextMenu.tabmixLinks || [];
- }
-
- if (Tabmix.isVersion(320))
- urls = gContextMenu.tabmixLinks || getLinks();
- // getSelectedLinks was not implemented for remote tabs before Firefox 32
- else if (browser.getAttribute("remote") != "true")
- urls = Tabmix.ContextMenu.getSelectedLinks(content, check);
+ let urls = Tabmix.isVersion(420) ? gContextMenu.tabmixLinks :
+ Tabmix.ContextMenu.getSelectedLinks(content, check);
if (!check && urls.length) {
Tabmix.loadTabs(urls, false);
diff --git a/chrome/content/content.js b/chrome/content/content.js
index b72fd44..492b3dc 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -50,10 +50,6 @@ var TabmixContentHandler = {
init: function() {
this.MESSAGES.forEach(m => addMessageListener(m, this));
- // Send a CPOW to the parent so that it can synchronously request
- // docShell capabilities.
- sendSyncMessage("Tabmix:SetSyncHandler", {}, {syncHandler: this});
-
if (PROCESS_TYPE_CONTENT) {
addEventListener("drop", this.onDrop);
}
@@ -145,15 +141,6 @@ var TabmixContentHandler = {
return DocShellCapabilities.collect(docShell).join(",") || "";
},
- getSelectedLinks: function() {
- return ContextMenu.getSelectedLinks(content).join("\n");
- },
-
- wrapNode: function(node) {
- let window = TabmixClickEventHandler._focusedWindow;
- return LinkNodeUtils.wrap(node, window);
- },
-
onDrop: function(event) {
let uri, name = { };
let linkHandler = Cc["@mozilla.org/content/dropped-link-handler;1"].
@@ -382,6 +369,28 @@ var AboutNewTabHandler = {
}
};
+var ContextMenuHandler = {
+ init: function(global) {
+ Cc["@mozilla.org/eventlistenerservice;1"]
+ .getService(Ci.nsIEventListenerService)
+ .addSystemEventListener(global, "contextmenu", this.prepareContextMenu, true);
+ },
+
+ prepareContextMenu: function(event) {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ let links;
+ if (TabmixSvc.prefBranch.getBoolPref("openAllLinks")) {
+ links = ContextMenu.getSelectedLinks(content).join("\n");
+ }
+
+ sendRpcMessage("Tabmix:contextmenu", {links: links});
+ }
+};
+
TabmixContentHandler.init();
TabmixClickEventHandler.init(this);
AboutNewTabHandler.init(this);
+ContextMenuHandler.init(this);
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 7492066..0d8d357 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1117,8 +1117,10 @@ var tablib = { // eslint-disable-line
let json = {button: 0, shiftKey: false, ctrlKey: false, metaKey: false,
altKey: false, target: {},
tabmix_openLinkWithHistory: true};
+ // we only get here when it is safe to use contentWindowAsCPOW
+ // see TabmixContext.updateMainContextMenu
let result = Tabmix.ContentClick.getParamsForLink(json,
- target, url, browser, document.commandDispatcher.focusedWindow);
+ target, url, browser, gBrowser.selectedBrowser._contentWindow);
return result._href && isValid(result._href) ? result._href : null;
}
return url;
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index c11f0cb..e84b8fd 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -833,9 +833,6 @@ var TMP_eventListener = {
}
// clean WeakMap
- let browser = tab.linkedBrowser;
- if (Tabmix.isVersion(320) && browser && TabmixSvc.syncHandlers.has(browser.permanentKey))
- TabmixSvc.syncHandlers.delete(browser.permanentKey);
if (this.tabWidthCache.has(tab))
this.tabWidthCache.delete(tab);
},
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index d15b236..68ee9e4 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -180,11 +180,6 @@ ContentClickInternal = {
},
getParamsForLink: function(event, linkNode, href, browser, focusedWindow) {
- if (browser.getAttribute("remote") == "true" &&
- TabmixSvc.syncHandlers.has(browser.permanentKey)) {
- let handler = TabmixSvc.syncHandlers.get(browser.permanentKey);
- linkNode = handler.wrapNode(linkNode);
- }
let wrappedNode = this.getWrappedNode(linkNode, focusedWindow, event.button === 0);
return this._getParamsForLink(event, wrappedNode, href, browser);
},
diff --git a/modules/ContextMenu.jsm b/modules/ContextMenu.jsm
index a8c75cf..d4a675f 100644
--- a/modules/ContextMenu.jsm
+++ b/modules/ContextMenu.jsm
@@ -2,7 +2,7 @@
this.EXPORTED_SYMBOLS = ["ContextMenu"];
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+const {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/Services.jsm");
@@ -12,11 +12,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
this.ContextMenu = {
getSelectedLinks: function(content, check) {
- // get focused window selection
- let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
- let focusedWindow = {};
- fm.getFocusedElementForWindow(content, true, focusedWindow);
- let selectionObject = focusedWindow.value.getSelection();
+ let doc = content.document;
+ let selectionObject = doc.getSelection();
if (selectionObject.isCollapsed) // nothing selected
return [];
@@ -31,7 +28,6 @@ this.ContextMenu = {
};
// do urlSecurityCheck for each link in the treeWalker....
- let doc = content.document;
let secMan = Services.scriptSecurityManager;
let securityCheck = function(url) {
if (!url)
diff --git a/modules/DocShellCapabilities.jsm b/modules/DocShellCapabilities.jsm
index 795efc1..e6e1d51 100644
--- a/modules/DocShellCapabilities.jsm
+++ b/modules/DocShellCapabilities.jsm
@@ -36,15 +36,12 @@ this.DocShellCapabilities = {
return this.caps.filter(cap => !browser.docShell["allow" + cap]);
}
- if (tab.ownerDocument.defaultView.__SSi) {
+ let window = tab.ownerDocument.defaultView;
+ if (window && window.__SSi) {
let tabState = TabState.collect(tab);
return tabState.disallow || "";
}
- try {
- let handler = TabmixSvc.syncHandlers.get(browser.permanentKey);
- return handler.getCapabilities();
- } catch (ex) { }
return "";
},
diff --git a/modules/Services.jsm b/modules/Services.jsm
index c567c70..b5481b8 100644
--- a/modules/Services.jsm
+++ b/modules/Services.jsm
@@ -155,8 +155,6 @@ this.TabmixSvc = {
}
},
- syncHandlers: new WeakMap(),
-
windowStartup: {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
diff --git a/modules/Utils.jsm b/modules/Utils.jsm
index 92ce1f4..be8167a 100644
--- a/modules/Utils.jsm
+++ b/modules/Utils.jsm
@@ -6,12 +6,12 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
// Messages that will be received via the Frame Message Manager.
const FMM_MESSAGES = [
- "Tabmix:SetSyncHandler",
"Tabmix:restorePermissionsComplete",
"Tabmix:updateScrollPosition",
"Tabmix:reloadTab",
"Tabmix:getOpener",
"Tabmix:contentDrop",
+ "Tabmix:contextmenu",
];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -59,9 +59,6 @@ this.TabmixUtils = {
let browser = message.target;
let win, tab;
switch (message.name) {
- case "Tabmix:SetSyncHandler":
- TabmixSvc.syncHandlers.set(browser.permanentKey, message.objects.syncHandler);
- break;
case "Tabmix:restorePermissionsComplete":
DocShellCapabilities.update(browser, message.data);
break;
@@ -96,6 +93,12 @@ this.TabmixUtils = {
}
return false;
}
+ case "Tabmix:contextmenu": {
+ win = browser.ownerDocument.defaultView;
+ let links = message.data.links;
+ win.Tabmix.contextMenuLinks = links && links.split("\n") || [];
+ break;
+ }
}
return null;
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list