[Pkg-mozext-commits] [tabmixplus] 14/23: Open tabs from address bar doesn't work. Follow up bug 1180944 - Implement one-off searches from Awesomebar

David Prévot taffit at moszumanska.debian.org
Fri Sep 23 03:31:05 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 4c688b79f44940d890859213cdf9380be2896e0e
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sat Sep 3 19:01:33 2016 +0300

    Open tabs from address bar doesn't work. Follow up bug 1180944 - Implement one-off searches from Awesomebar
---
 chrome/content/links/setup.js | 41 ++++++++++++++++--------------
 chrome/content/minit/minit.js | 58 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/chrome/content/links/setup.js b/chrome/content/links/setup.js
index a9f8851..d0e4dc6 100644
--- a/chrome/content/links/setup.js
+++ b/chrome/content/links/setup.js
@@ -15,25 +15,28 @@
  * @returns   Nothing.
  */
 Tabmix.linkHandling_init = function TMP_TBP_init() {
-  // for normal click this function calls urlbar.handleCommand
-  // for middle click or click with modifiers whereToOpenLink can't be "current"
-  // so we don't need to check for locked tabs only for blanks tabs
-  var autoComplete = document.getElementById("PopupAutoCompleteRichResult");
-  if (autoComplete) {
-    // https://addons.mozilla.org/en-US/firefox/addon/quieturl/
-    let fn = typeof autoComplete._QuietUrlPopupClickOld == "function" ?
-        "_QuietUrlPopupClickOld" : "PopupAutoCompleteRichResult.onPopupClick";
-    let n = '\n            ';
-    this.changeCode(autoComplete, fn)._replace(
-      /openUILink\(url, aEvent.*\);/,
-      'var tabmixOptions = typeof options == "object" ? options : {};' + n +
-      'var isBlankTab = gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab);' + n +
-      'var where = isBlankTab ? "current" : whereToOpenLink(aEvent);' + n +
-      'var pref = "extensions.tabmix.loadUrlInBackground";' + n +
-      'tabmixOptions.inBackground = Services.prefs.getBoolPref(pref);' + n +
-      'tabmixOptions.initiatingDoc = aEvent ? aEvent.target.ownerDocument : null;' + n +
-      'openUILinkIn(url, where, tabmixOptions);'
-    ).toCode();
+  // Since bug 1180944 onPopupClick always call urlbar.handleCommand
+  if (!Tabmix.isVersion(510)) {
+    // for normal click this function calls urlbar.handleCommand
+    // for middle click or click with modifiers whereToOpenLink can't be "current"
+    // so we don't need to check for locked tabs only for blanks tabs
+    var autoComplete = document.getElementById("PopupAutoCompleteRichResult");
+    if (autoComplete) {
+      // https://addons.mozilla.org/en-US/firefox/addon/quieturl/
+      let fn = typeof autoComplete._QuietUrlPopupClickOld == "function" ?
+               "_QuietUrlPopupClickOld" : "PopupAutoCompleteRichResult.onPopupClick";
+      let n = '\n            ';
+      this.changeCode(autoComplete, fn)._replace(
+          /openUILink\(url, aEvent.*\);/,
+          'var tabmixOptions = typeof options == "object" ? options : {};' + n +
+          'var isBlankTab = gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab);' + n +
+          'var where = isBlankTab ? "current" : whereToOpenLink(aEvent);' + n +
+          'var pref = "extensions.tabmix.loadUrlInBackground";' + n +
+          'tabmixOptions.inBackground = Services.prefs.getBoolPref(pref);' + n +
+          'tabmixOptions.initiatingDoc = aEvent ? aEvent.target.ownerDocument : null;' + n +
+          'openUILinkIn(url, where, tabmixOptions);'
+      ).toCode();
+    }
   }
 
   window.BrowserOpenTab = TMP_BrowserOpenTab;
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 0145662..47b0fda 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -1191,6 +1191,56 @@ Tabmix.navToolbox = {
     if (blur.indexOf("Tabmix.urlBarOnBlur") == -1)
       Tabmix.setItem(gURLBar, "onblur", blur + "Tabmix.urlBarOnBlur();");
 
+    if (Tabmix.isVersion(510)) {
+      if (!this.urlBarInitialized) {
+        Tabmix.originalFunctions.gURLBar_handleCommand = gURLBar.handleCommand;
+        gURLBar.handleCommand = this.handleCommand.bind(gURLBar);
+        this.urlBarInitialized = true;
+      }
+    } else {
+      this.handleCommand_beforeV51();
+    }
+  },
+
+  handleCommand: function(event, openUILinkWhere, openUILinkParams) {
+    let prevTab, prevTabPos;
+    let action = this._parseActionUrl(this.value);
+    if (action && action.type == "switchtab" && this.hasAttribute("actiontype")) {
+      prevTab = gBrowser.selectedTab;
+      prevTabPos = prevTab._tPos;
+    }
+
+    if (!openUILinkWhere) {
+      let isMouseEvent = event instanceof MouseEvent;
+      let altEnter = !isMouseEvent && event &&
+          event.altKey && !isTabEmpty(gBrowser.selectedTab);
+      let where = "current";
+      let loadNewTab = Tabmix.whereToOpen("extensions.tabmix.opentabfor.urlbar",
+              altEnter).inNew && !(/^ *javascript:/.test(this.value));
+      if (isMouseEvent || altEnter || loadNewTab) {
+        // Use the standard UI link behaviors for clicks or Alt+Enter
+        where = "tab";
+        if (isMouseEvent || event && !altEnter)
+          where = whereToOpenLink(event, false, false);
+        if (loadNewTab && where == "current" || !isMouseEvent && where == "window")
+          where = "tab";
+        else if (!isMouseEvent && !loadNewTab && /^tab/.test(where))
+          where = "current";
+      }
+      openUILinkWhere = where;
+    }
+
+    Tabmix.originalFunctions.gURLBar_handleCommand.call(gURLBar, event, openUILinkWhere, openUILinkParams);
+
+    // move the tab that was switched to after the previously selected tab
+    if (prevTabPos) {
+      let pos = prevTabPos + Number(gBrowser.selectedTab._tPos > prevTabPos) -
+          Number(!prevTab || !prevTab.parentNode);
+      gBrowser.moveTabTo(gBrowser.selectedTab, pos);
+    }
+  },
+
+  handleCommand_beforeV51: function() {
     let obj = gURLBar, fn;
     // Fix incompatibility with Omnibar (O is not defined)
     // URL Dot 0.4.x extension
@@ -1339,11 +1389,15 @@ Tabmix.navToolbox = {
       'inBackground: aWhere == "tab-background"',
       '$& ||' + $LF +
       '                Tabmix.prefs.getBoolPref("loadSearchInBackground")',
-      {check: Tabmix.isVersion(350)}
+      {check: Tabmix.isVersion(350) && !Tabmix.isVersion(510)}
     )._replace(
       'var loadInBackground = prefs.getBoolPref("loadBookmarksInBackground");',
       'var loadInBackground = aWhere == "tab-background" || Tabmix.prefs.getBoolPref("loadSearchInBackground");',
-      {check: !searchLoadExt && organizeSE}
+      {check: !searchLoadExt && organizeSE && !Tabmix.isVersion(510)}
+    )._replace(
+      'openUILinkIn',
+      'params.inBackground = params.inBackground || Tabmix.prefs.getBoolPref("loadSearchInBackground");' + $LF +
+      '$&', {check: Tabmix.isVersion(510)}
     )._replace(
       /searchbar\.currentEngine/g,
       'this.currentEngine', {check: pIte}

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