[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r13539: Try harder to maintain the 50 pixel rounding in the face of (torbutton/trunk/src/chrome/content)



Author: mikeperry
Date: 2008-02-17 04:34:36 -0500 (Sun, 17 Feb 2008)
New Revision: 13539

Modified:
   torbutton/trunk/src/chrome/content/torbutton.js
Log:

Try harder to maintain the 50 pixel rounding in the face of
minimized windows and resizing. This may get annoying..



Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2008-02-17 06:55:35 UTC (rev 13538)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2008-02-17 09:34:36 UTC (rev 13539)
@@ -719,7 +719,7 @@
         while(enumerator.hasMoreElements()) {
             var win = enumerator.getNext();
             if(win.windowState 
-                    == Components.interfaces.nsIDOMChromeWindow.STATE_NORMAL) {
+                == Components.interfaces.nsIDOMChromeWindow.STATE_NORMAL) {
                 var bWin = win.getBrowser().contentWindow;
                 bWin.innerHeight = Math.round(bWin.innerHeight/50.0)*50;
                 bWin.innerWidth = Math.round(bWin.innerWidth/50.0)*50;
@@ -1172,6 +1172,16 @@
     }
 }
 
+function torbutton_do_resize(ev)
+{
+    if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
+            && m_tb_prefs.getBoolPref("extensions.torbutton.resize_on_toggle")) {
+        var bWin = window.getBrowser().contentWindow;
+        bWin.innerHeight = Math.round(bWin.innerHeight/50.0)*50;
+        bWin.innerWidth = Math.round(bWin.innerWidth/50.0)*50;
+    }
+}
+
 function torbutton_new_window(event)
 {
     torbutton_log(3, "New window");
@@ -1189,6 +1199,7 @@
             !m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled"),
             m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins"));
 
+    window.addEventListener("resize", torbutton_do_resize, false);
 }
 
 function torbutton_close_window(event) {
@@ -1325,6 +1336,13 @@
         browser.__tb_tor_fetched = !tor_tag;
         browser.docShell.allowPlugins = tor_tag || !kill_plugins;
         browser.docShell.allowJavascript = js_enabled;
+
+        // We need to do the resize here as well in case the window
+        // was minimized during toggle...
+        if(!tor_tag && m_tb_prefs.getBoolPref("extensions.torbutton.resize_on_toggle")) {
+            win.top.innerHeight = Math.round(win.top.innerHeight/50.0)*50;
+            win.top.innerWidth = Math.round(win.top.innerWidth/50.0)*50;
+        }
     }
 
     torbutton_log(2, "Tags updated.");