[Pkg-mozext-commits] [tabmixplus] 24/34: Refactor duplicateTabToWindow (follow up bug 1181475) to avoid duplicate tab id in WebExtension when the duplicated tab is dragging back to the original window

David Prévot taffit at moszumanska.debian.org
Mon Jun 27 13:57:57 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 93fdde4f8bf45f852e1c0b0152a0c26662ed4be4
Author: onemen <tabmix.onemen at gmail.com>
Date:   Wed Jun 22 22:44:39 2016 +0300

    Refactor duplicateTabToWindow (follow up bug 1181475) to avoid duplicate tab id in WebExtension when the duplicated tab is dragging back to the original window
---
 chrome/content/minit/tablib.js | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index a7e4044..4e17e7e 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1045,10 +1045,26 @@ var tablib = { // eslint-disable-line
       } else if (aMoveTab) {
         this.replaceTabWithWindow(aTab);
       } else {
-        aTab._tabmixCopyToWindow = {data: aTabData};
-        // replaceTabWithWindow not working if there is only one tab in the the window
-        window.openDialog("chrome://browser/content/browser.xul",
-            "_blank", "chrome,dialog=no,all", aTab);
+        let otherWin = OpenBrowserWindow();
+        let delayedStartupFinished = (subject, topic) => {
+          if (topic == "browser-delayed-startup-finished" &&
+              subject == otherWin) {
+            Services.obs.removeObserver(delayedStartupFinished, topic);
+            let otherGBrowser = otherWin.gBrowser;
+            let otherTab = otherGBrowser.selectedTab;
+            if (aTabData) {
+              // restore closed tab to new window
+              TabmixSvc.ss.setTabState(otherTab, aTabData);
+            } else {
+              TabmixSvc.ss.duplicateTab(otherWin, aTab);
+              otherGBrowser.removeTab(otherTab, {animate: false});
+            }
+          }
+        };
+
+        Services.obs.addObserver(delayedStartupFinished,
+                                 "browser-delayed-startup-finished",
+                                 false);
       }
     };
 
@@ -1678,15 +1694,6 @@ var tablib = { // eslint-disable-line
       }
 
       Tabmix.copyTabData(aOurTab, aOtherTab);
-
-      let copy = aOtherTab._tabmixCopyToWindow;
-      delete aOtherTab._tabmixCopyToWindow;
-      if (typeof copy == "object") {
-        let tabData = copy ? copy.data : null;
-        TabmixSvc.ss.setTabState(aOurTab, tabData || TabmixSvc.ss.getTabState(aOtherTab));
-        return;
-      }
-
       Tabmix.originalFunctions.swapBrowsersAndCloseOther.apply(this, arguments);
     };
     Tabmix.setNewFunction(gBrowser, "swapBrowsersAndCloseOther", swapTab);

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