[Pkg-mozext-commits] [tabmixplus] 19/34: In Single window mode we should not close windows that was probably opened by extension

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 18644294f60623dff71bd5e264c38cb4203229c7
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sun Jun 19 19:21:12 2016 +0300

    In Single window mode we should not close windows that was probably opened by extension
---
 modules/SingleWindowModeUtils.jsm | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/modules/SingleWindowModeUtils.jsm b/modules/SingleWindowModeUtils.jsm
index 71c938b..5eded9f 100644
--- a/modules/SingleWindowModeUtils.jsm
+++ b/modules/SingleWindowModeUtils.jsm
@@ -83,6 +83,23 @@ this.SingleWindowModeUtils = {
     return true;
   },
 
+  restoreDimensionsAndPosition: function(newWindow, restorePosition) {
+    const rect = newWindow.__winRect;
+    if (typeof rect != "object") {
+      return;
+    }
+    const doc = newWindow.document.documentElement;
+    for (let attr of Object.keys(rect)) {
+      doc.setAttribute(attr, rect[attr]);
+    }
+    if (restorePosition) {
+      const {width, height, screenX, screenY} = rect;
+      newWindow.resizeTo(width, height);
+      newWindow.moveTo(screenX, screenY);
+    }
+    delete newWindow.__winRect;
+  },
+
   onLoad: function(newWindow) {
     var existingWindow = this.getBrowserWindow(newWindow);
     // no navigator:browser window open yet?
@@ -93,6 +110,12 @@ this.SingleWindowModeUtils = {
       return;
     var args = newWindow.arguments;
 
+    // don't close windows that was probably opened by extension
+    if (args.length == 1 && args[0] === null) {
+      this.restoreDimensionsAndPosition(newWindow, true);
+      return;
+    }
+
     var existingBrowser = existingWindow.gBrowser;
     existingWindow.tablib.init(); // just in case tablib isn't init yet
     var uriToLoad = args[0];
@@ -187,15 +210,10 @@ this.SingleWindowModeUtils = {
     } catch (ex) {
       existingWindow.Tabmix.obj(ex);
     }
-    existingWindow.setTimeout(function() {
+    existingWindow.setTimeout(() => {
       try {
         // restore window dimensions, to prevent flickering in the next restart
-        var win = newWindow.document.documentElement;
-        if (typeof newWindow.__winRect == "object") {
-          for (let attr of Object.keys(newWindow.__winRect)) {
-            win.setAttribute(attr, newWindow.__winRect[attr]);
-          }
-        }
+        this.restoreDimensionsAndPosition(newWindow);
         newWindow.close();
         if (firstTabAdded) {
           existingBrowser.selectedTab = firstTabAdded;

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