[Pkg-mozext-commits] [tabmixplus] 24/44: [e10s] ContentClick.selectExistingTab doesn't work (regressed by changeset b5bf1b1ccc63), use our syncHandlers to access borwser.contentWindow instead of contentWindowAsCPOW

David Prévot taffit at moszumanska.debian.org
Wed Oct 15 02:10:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 0db5c9d61a53be58770761538a59123291d0b696
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sun Oct 12 15:49:21 2014 +0300

    [e10s] ContentClick.selectExistingTab doesn't work (regressed by changeset b5bf1b1ccc63), use our syncHandlers to access borwser.contentWindow instead of contentWindowAsCPOW
---
 chrome/content/content.js            |  7 ++++
 chrome/content/links/contentLinks.js |  2 +-
 modules/ContentClick.jsm             | 67 +++++++++++++++++++++---------------
 modules/LinkNodeUtils.jsm            | 25 ++++++++++++++
 4 files changed, 72 insertions(+), 29 deletions(-)

diff --git a/chrome/content/content.js b/chrome/content/content.js
index d301b51..5319edb 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -11,6 +11,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
 XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
   "resource://tabmixplus/Services.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "LinkNodeUtils",
+  "resource://tabmixplus/LinkNodeUtils.jsm");
+
 XPCOMUtils.defineLazyModuleGetter(this, "ContextMenu",
   "resource://tabmixplus/ContextMenu.jsm");
 
@@ -53,6 +56,10 @@ let TabmixContentHandler = {
 
   getSelectedLinks: function(check) {
     return ContextMenu.getSelectedLinks(content, check);
+  },
+
+  isFrameInContent: function(href, name) {
+    return LinkNodeUtils.isFrameInContent(content, href, name);
   }
 };
 
diff --git a/chrome/content/links/contentLinks.js b/chrome/content/links/contentLinks.js
index e7cfa0a..fbc416d 100644
--- a/chrome/content/links/contentLinks.js
+++ b/chrome/content/links/contentLinks.js
@@ -40,7 +40,7 @@ Tabmix.contentAreaClick = {
       '  event.__suppressTabsOnFileDownload = suppressTabsOnFileDownload;\n' +
       '  var result = $&\n' +
       '  if (targetAttr && !result)\n' +
-      '    setTimeout(function(){Tabmix.ContentClick.selectExistingTab(href, targetAttr);},300);'
+      '    setTimeout(function(){Tabmix.ContentClick.selectExistingTab(window, href, targetAttr);},300);'
     ).toCode();
 
     /* don't change where if it is save, window, or we passed
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index 12364cc..8cf4cbe 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -15,8 +15,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
 XPCOMUtils.defineLazyModuleGetter(this, "ContentClick",
   "resource:///modules/ContentClick.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this,
-  "TabmixSvc", "resource://tabmixplus/Services.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "LinkNodeUtils",
+  "resource://tabmixplus/LinkNodeUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
+  "resource://tabmixplus/Services.jsm");
 
 this.TabmixContentClick = {
   init: function() {
@@ -52,8 +55,8 @@ this.TabmixContentClick = {
     return false;
   },
 
-  selectExistingTab: function(href, targetAttr) {
-    ContentClickInternal.selectExistingTab(href, targetAttr);
+  selectExistingTab: function(window, href, targetAttr) {
+    ContentClickInternal.selectExistingTab(window, href, targetAttr);
   }
 }
 Object.freeze(TabmixContentClick);
@@ -104,12 +107,7 @@ let ContentClickInternal = {
     Tabmix.changeCode(ContentClick, "ContentClick.contentAreaClick")._replace(
       'var where = window.whereToOpenLink(json);',
       'var data = json.tabmix || {where: window.whereToOpenLink(json)};\n' +
-      '    var {where, targetAttr, suppressTabsOnFileDownload} = data;\n' +
-      '    if (where == "default" && targetAttr) {\n' +
-      '      window.setTimeout(function(){\n' +
-      '        window.Tabmix.ContentClick.selectExistingTab(json.href, targetAttr);\n' +
-      '      },300);\n' +
-      '    }\n'
+      '    var {where, suppressTabsOnFileDownload} = data;'
     )._replace(
       'where == "current"',
       '!json.tabmix && where == "current" || where == "default"'
@@ -178,6 +176,17 @@ let ContentClickInternal = {
     if (where == "current")
       browser.tabmix_allowLoad = true;
 
+    if (href && browser.getAttribute("remote") == "true" &&
+        where == "default" && targetAttr) {
+      let win = this._window;
+      win.setTimeout(function() {
+        // don't try to select new tab if the original browser is no longer
+        // the selected browser
+        if (win.gBrowser.selectedBrowser == browser)
+          this.selectExistingTab(win, href, targetAttr);
+      }.bind(this), 300);
+    }
+
     // don't call this._data.hrefFromOnClick
     // if __hrefFromOnClick did not set by now we won't use it
     if (where != "default" && event.__hrefFromOnClick)
@@ -869,38 +878,39 @@ let ContentClickInternal = {
    *        focusing it for link with target. Search in the browser content
    *        and its frames for content with matching name and href
    */
-  selectExistingTab: function TMP_selectExistingTab(href, targetFrame) {
+  selectExistingTab: function TMP_selectExistingTab(window, href, targetFrame) {
     if (TabmixSvc.prefBranch.getIntPref("opentabforLinks") != 0 ||
         Services.prefs.getBoolPref("browser.tabs.loadInBackground"))
       return;
 
-    let isCurrent = function isCurrent(content) {
-      if (content.location.href == href && content.name == targetFrame)
-        return true;
-      for (let i = 0; i < content.frames.length; i++) {
-        let frame = content.frames[i];
-        if (frame.location.href == href && frame.name == targetFrame)
-          return true;
+    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 false;
+      return LinkNodeUtils.isFrameInContent(browser[TabmixSvc.contentWindowAsCPOW], href, targetFrame);
     }
 
-    let window = this._window;
     let switchIfURIInWindow = function switchIfURIInWindow(aWindow) {
       // Only switch to the tab if both source and desination are
       // private or non-private.
-      if (TabmixSvc.version(200) &&
+      if ((TabmixSvc.version(200) &&
           PrivateBrowsingUtils.isWindowPrivate(window) !=
-          PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
+          PrivateBrowsingUtils.isWindowPrivate(aWindow)) ||
+          (TabmixSvc.version(320) &&
+          window.gMultiProcessBrowser != aWindow.gMultiProcessBrowser)) {
         return false;
       }
-      if (!("gBrowser" in aWindow))
-        return false;
       let browsers = aWindow.gBrowser.browsers;
       for (let i = 0; i < browsers.length; i++) {
-        let browser = browsers[i];
-        if (isCurrent(browser[TabmixSvc.contentWindowAsCPOW])) {
-          gURLBar.handleRevert();
+        if (isCurrent(browsers[i])) {
+          aWindow.gURLBar.handleRevert();
           // Focus the matching window & tab
           aWindow.focus();
           aWindow.gBrowser.tabContainer.selectedIndex = i;
@@ -910,7 +920,8 @@ let ContentClickInternal = {
       return false;
     }
 
-    if (switchIfURIInWindow(window))
+    let isBrowserWindow = !!window.gBrowser;
+    if (isBrowserWindow && switchIfURIInWindow(window))
       return;
 
     let winEnum = Services.wm.getEnumerator("navigator:browser");
diff --git a/modules/LinkNodeUtils.jsm b/modules/LinkNodeUtils.jsm
new file mode 100644
index 0000000..1447394
--- /dev/null
+++ b/modules/LinkNodeUtils.jsm
@@ -0,0 +1,25 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["LinkNodeUtils"];
+
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
+  "resource://tabmixplus/Services.jsm");
+
+this.LinkNodeUtils = {
+  isFrameInContent: function(content, href, name) {
+    if (!content)
+      return false;
+    if (content.location.href == href && content.name == name)
+      return true;
+    for (let i = 0; i < content.frames.length; i++) {
+      let frame = content.frames[i];
+      if (frame.location.href == href && frame.name == name)
+        return true;
+    }
+    return false;
+  }
+}

-- 
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