Browse Source

update patch

Frank-Rainer Grahl 6 days ago
parent
commit
5d639f8e3c

+ 10 - 64
comm-release/patches/1925037-switchToTabHavingURI-25320.patch → comm-release/patches/1925037-switchToTabHavingURI-1_1-25320.patch

@@ -1,7 +1,7 @@
 # HG changeset patch
 # User Frank-Rainer Grahl <frgrahl@gmx.net>
 # Date 1729077928 -7200
-# Parent  f7d4d44c38a4243fe43c572c2203446239bc637a
+# Parent  e39a9a79b3b463b098bc3fd717b48782f276835c
 Bug 1925037 - Pass optional parameters to switchToTabHavingURI as an array. r=IanN a=IanN
 
 Aligns the call syntax with Firefox and toolkit usage.
@@ -106,7 +106,7 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
      w.loadURI(urlArray[0], null, null, allowThirdPartyFixup);
      w.content.focus();
      break;
-@@ -1728,76 +1728,177 @@ function openUILinkArrayIn(urlArray, whe
+@@ -1728,76 +1728,125 @@ function openUILinkArrayIn(urlArray, whe
    var relatedToCurrent = where == "current";
    for (var i = 1; i < urlArray.length; i++)
      browser.addTab(urlArray[i], {allowThirdPartyFixup: allowThirdPartyFixup, relatedToCurrent: relatedToCurrent});
@@ -120,7 +120,7 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
 - * windows will be searched.
 + * Switch to a tab that has a given URI, and focuses its browser window.
 + * If a matching tab is in this window, it will be switched to. Otherwise,
-+ *  other windows will be searched.
++ * other windows will be searched.
   *
   * @param aURI
   *        URI to search for
@@ -137,15 +137,6 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
 + *        see the documentation for openUILinkIn to see what parameters can be
 + *        passed via this object.
 + *        This object also allows:
-+ *        - 'ignoreFragment' property to be set to true to exclude
-+ *        fragment-portion matching when comparing URIs.
-+ *          If set to "whenComparing", the fragment will be unmodified.
-+ *          If set to "whenComparingAndReplace", the fragment will be replaced.
-+ *        - 'ignoreQueryString' boolean property to be set to true to exclude
-+ *         query string matching when comparing URIs.
-+ *        - 'replaceQueryString' boolean property to be set to true to exclude
-+ *        query string matching when comparing URIs and overwrite the initial
-+ *         query string with the one from the new URI.
 + *        - 'browserCallback' a callback to call when the tab is open, the
 + *        tab's browser will be passed as an argument
 +
@@ -159,77 +150,38 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
 +    "about:addons",
 +  ]);
 +
-+  let ignoreFragment = aOpenParams.ignoreFragment;
-+  let ignoreQueryString = aOpenParams.ignoreQueryString;
-+  let replaceQueryString = aOpenParams.replaceQueryString;
 +  let browserCallback = aOpenParams.browserCallback;
 +
 +  // These properties are only used by switchToTabHavingURI and should
 +  // not be used as a parameter for the new load.
-+  delete aOpenParams.ignoreFragment;
-+  delete aOpenParams.ignoreQueryString;
-+  delete aOpenParams.replaceQueryString;
 +  delete aOpenParams.browserCallback;
 +
 +  // This will switch to the tab in aWindow having aURI, if present.
    function switchIfURIInWindow(aWindow) {
 -    if (!aWindow.gBrowser)
++    if (!aWindow.gBrowser) {
+       return false;
++    }
++
 +    // Only switch to the tab if neither the source nor the destination window
 +    // are private and they are not in permanent private browsing mode
 +    if (!kPrivateBrowsingWhitelist.has(aURI.spec) &&
 +        (PrivateBrowsingUtils.isWindowPrivate(window) ||
 +         PrivateBrowsingUtils.isWindowPrivate(aWindow)) &&
 +        !PrivateBrowsingUtils.permanentPrivateBrowsing) {
-       return false;
-+    }
-+
-+    // Remove the query string, fragment, both, or neither from a given url.
-+    function cleanURL(url, removeQuery, removeFragment) {
-+      let ret = url;
-+      if (removeFragment) {
-+        ret = ret.split("#")[0];
-+        if (removeQuery) {
-+          // This removes a query, if present before the fragment.
-+          ret = ret.split("?")[0];
-+        }
-+      } else if (removeQuery) {
-+        // This is needed in case there is a fragment after the query.
-+        let fragment = ret.split("#")[1];
-+        ret = ret.split("?")[0].concat(
-+          (fragment != undefined) ? "#".concat(fragment) : "");
-+      }
-+      return ret;
++      return false;
 +    }
 +
-+    // Need to handle nsSimpleURIs here too (e.g. about:...), which don't
-+    // work correctly with URL objects - so treat them as strings
-+    let ignoreFragmentWhenComparing =
-+      typeof ignoreFragment == "string" &&
-+      ignoreFragment.startsWith("whenComparing");
-+    let requestedCompare = cleanURL(
-+          aURI.displaySpec, ignoreQueryString || replaceQueryString,
-+          ignoreFragmentWhenComparing);
      let browsers = aWindow.gBrowser.browsers;
      for (let i = 0; i < browsers.length; i++) {
        let browser = browsers[i];
--      if (browser.currentURI.equals(aURI)) {
--        // Focus the matching window & tab
-+      let browserCompare = cleanURL(
-+          browser.currentURI.displaySpec,
-+          ignoreQueryString || replaceQueryString,
-+          ignoreFragmentWhenComparing);
-+      if (requestedCompare == browserCompare) {
+       if (browser.currentURI.equals(aURI)) {
+         // Focus the matching window & tab
          aWindow.focus();
-+        if (ignoreFragment == "whenComparingAndReplace" ||
-+            replaceQueryString) {
-+          browser.loadURI(aURI.spec);
-+        }
          aWindow.gBrowser.tabContainer.selectedIndex = i;
 -        if (aCallback)
 -          aCallback(browser);
 +        if (browserCallback) {
-+          // Services.console
-+          //         .logStringMessage("switchToTabHavingURI browsercallb 1");
 +          browserCallback(browser);
 +        }
 +
@@ -245,8 +197,6 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
      aURI = Services.io.newURI(aURI);
 +  }
 +
-+  // Services.console.logStringMessage("switchToTabHavingURI " + aURI.spec);
-+
 +  let isBrowserWindow = !!window.gBrowser;
  
    // Prioritise this window.
@@ -287,8 +237,6 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
 +      browserWinNew = openUILinkIn(aURI.spec, "tab", aOpenParams);
 +    }
 +    if (browserCallback) {
-+      // Services.console
-+      //         .logStringMessage("switchToTabHavingURI browsercallb pre");
 +      browserWinNew.addEventListener("pageshow",
 +        function browserWinPageShow(event) {
 +          if (event.target.location.href != aURI.spec) {
@@ -296,8 +244,6 @@ diff --git a/suite/base/content/utilityOverlay.js b/suite/base/content/utilityOv
 +          }
 +          browserWinNew.removeEventListener("pageshow", browserWinPageShow,
 +                                            true);
-+          // Services.console
-+          //         .logStringMessage("switchToTabHavingURI browsercallb 2");
 +          browserCallback(browserWinNew.getBrowser().selectedBrowser);
 +        },
 +      true);

+ 1 - 1
comm-release/patches/series

@@ -2217,4 +2217,4 @@ TOP-1378089-4-WIP-bookmarks-25320.patch
 TOP-1872623-cancelbookmark-25319.patch
 1925025-specificsearch-25320.patch
 1925033-focus-25320.patch
-1925037-switchToTabHavingURI-25320.patch
+1925037-switchToTabHavingURI-1_1-25320.patch