[Pkg-mozext-commits] [tabmixplus] 18/34: [e10s] Stop using unsafe CPOW by ContentClickInternal.selectExistingTab
David Prévot
taffit at moszumanska.debian.org
Mon Mar 9 23:28:08 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit d9eed34fd01d486f7283e6bea67acf7abd5fb7f0
Author: onemen <tabmix.onemen at gmail.com>
Date: Sun Feb 22 12:05:44 2015 +0200
[e10s] Stop using unsafe CPOW by ContentClickInternal.selectExistingTab
---
chrome/content/content.js | 9 +++--
modules/ContentClick.jsm | 100 +++++++++++++++++++++++++++++-----------------
2 files changed, 69 insertions(+), 40 deletions(-)
diff --git a/chrome/content/content.js b/chrome/content/content.js
index 6b17025..035928e 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -32,6 +32,7 @@ let TabmixContentHandler = {
"Tabmix:collectScrollPosition",
"Tabmix:setScrollPosition",
"Tabmix:collectReloadData",
+ "Tabmix:isFrameInContent",
],
init: function () {
@@ -90,6 +91,10 @@ let TabmixContentHandler = {
}
sendAsyncMessage("Tabmix:reloadTab", json);
break;
+ case "Tabmix:isFrameInContent":
+ let result = LinkNodeUtils.isFrameInContent(content, data.href, data.name);
+ sendAsyncMessage("Tabmix:isFrameInContentResult", {result: result});
+ break;
}
},
@@ -101,10 +106,6 @@ let TabmixContentHandler = {
return ContextMenu.getSelectedLinks(content).join("\n");
},
- isFrameInContent: function(href, name) {
- return LinkNodeUtils.isFrameInContent(content, href, name);
- },
-
wrapNode: function(node) {
let window = TabmixClickEventHandler._focusedWindow;
return LinkNodeUtils.wrap(node, window);
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index 0ca480a..bc9c43e 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -74,6 +74,7 @@ var ContentClickInternal = {
let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
mm.addMessageListener("TabmixContent:Click", this);
+ mm.addMessageListener("Tabmix:isFrameInContentResult", this);
this.initContentAreaClick();
},
@@ -116,6 +117,10 @@ var ContentClickInternal = {
},
receiveMessage: function(message) {
+ if (message.name == "Tabmix:isFrameInContentResult") {
+ this.isFrameInContent.result(message.target, message.data);
+ return;
+ }
if (message.name != "TabmixContent:Click")
return null;
@@ -910,54 +915,77 @@ var ContentClickInternal = {
Services.prefs.getBoolPref("browser.tabs.loadInBackground"))
return;
- let isCurrent = function(browser) {
- if (TabmixSvc.version(320)) {
- try {
- let handler = TabmixSvc.syncHandlers.get(browser.permanentKey);
- return handler.isFrameInContent(href, targetFrame);
- } catch(ex) {
- TabmixSvc.console.log("unable to get syncHandlers for page " +
- browser.currentURI.spec + "\n" + ex);
- // fall back to use CPOW
- }
- }
- return LinkNodeUtils.isFrameInContent(browser[TabmixSvc.contentWindowAsCPOW], href, targetFrame);
- };
-
- let switchIfURIInWindow = function switchIfURIInWindow(aWindow) {
- // Only switch to the tab if both source and desination are
- // private or non-private.
+ let isValidWindow = function(aWindow) {
+ // window is valid only if both source and destination are in the same
+ // privacy state and multiProcess state
if ((TabmixSvc.version(200) &&
- PrivateBrowsingUtils.isWindowPrivate(window) !=
- PrivateBrowsingUtils.isWindowPrivate(aWindow)) ||
+ PrivateBrowsingUtils.isWindowPrivate(window) !=
+ PrivateBrowsingUtils.isWindowPrivate(aWindow)) ||
(TabmixSvc.version(320) &&
- window.gMultiProcessBrowser != aWindow.gMultiProcessBrowser)) {
+ window.gMultiProcessBrowser != aWindow.gMultiProcessBrowser)) {
return false;
}
- let browsers = aWindow.gBrowser.browsers;
- for (let i = 0; i < browsers.length; i++) {
- if (isCurrent(browsers[i])) {
- aWindow.gURLBar.handleRevert();
- // Focus the matching window & tab
- aWindow.focus();
- aWindow.gBrowser.tabContainer.selectedIndex = i;
- return true;
- }
- }
- return false;
+ return true;
};
- let isBrowserWindow = !!window.gBrowser;
- if (isBrowserWindow && switchIfURIInWindow(window))
- return;
+ let windows = [];
+ if (!!window.gBrowser && isValidWindow(window))
+ windows.push(window);
let winEnum = Services.wm.getEnumerator("navigator:browser");
while (winEnum.hasMoreElements()) {
let browserWin = winEnum.getNext();
if (browserWin.closed || browserWin == window)
continue;
- if (switchIfURIInWindow(browserWin))
- return;
+ if (isValidWindow(browserWin))
+ windows.push(browserWin);
+ }
+ this.isFrameInContent.start(windows, {href: href, name: targetFrame});
+ },
+
+ isFrameInContent: {
+ start: function(windows, frameData) {
+ this.frameData = frameData;
+ this.windows = windows;
+ let window = this.windows.shift();
+ this.next(window.gBrowser.tabs[0]);
+ },
+ stop: function() {
+ this.frameData = null;
+ this.windows = null;
+ },
+ result: function(browser, data) {
+ let window = browser.ownerDocument.defaultView;
+ let tab = window.gBrowser.getTabForBrowser(browser);
+ if (data.result) {
+ this.stop();
+ window.gURLBar.handleRevert();
+ // Focus the matching window & tab
+ window.focus();
+ window.gBrowser.selectedTab = tab;
+ }
+ else
+ this.next(tab.nextSibling);
+ },
+ next: function(tab) {
+ if (!tab && this.windows.length) {
+ let window = this.windows.shift();
+ tab = window.gBrowser.tabs[0];
+ }
+ if (tab) {
+ let browser = tab.linkedBrowser;
+ if (tab.getAttribute("remote") == "true") {
+ browser.messageManager
+ .sendAsyncMessage("Tabmix:isFrameInContent", this.frameData);
+ }
+ else {
+ let result = LinkNodeUtils.isFrameInContent(browser.contentWindow,
+ this.frameData.href, this.frameData.name);
+ this.result(browser, {result: result});
+ }
+ }
+ else
+ this.stop();
}
},
--
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