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

[tor-commits] [torbutton/master] Bug 10095: Make inner window a multiple of 200x100



commit d5822f67f694fd3cc23f1564da825250ca61217f
Author: Georg Koppen <gk@xxxxxxxxxxxxxx>
Date:   Fri Jan 10 15:01:59 2014 +0100

    Bug 10095: Make inner window a multiple of 200x100
    
    In order to be sure that no other extension is resizing the inner window
    due to merging its overlay into the chrome we resize the window (again)
    via a mutation observer and a setTimeout(0) call. The mutation observer
    helps us as DevTools code is modifying the DOM during start-up.
    
    This approach minimizes the possible usability issues as well as the
    window just gets larger by some pixels while being visible (if it gets
    larger at all, i.e. if proper resizing did not succeed before the window
    got visible). Provided it gets visible in the first place before the
    final resizing gets applied.
---
 src/chrome/content/torbutton.js |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 07f5e19..c9e03e9 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2823,6 +2823,39 @@ var torbutton_resizelistener =
         win.innerHeight + " to " + width + "x" + height + " in state " +
         window.windowState);
 
+      // Resizing within this progress listener does not always work as overlays
+      // of other extensions might still influence the height/width of the
+      // chrome and therefore the height/width of the content window. Doing a
+      // fallback resize with setTimeout(0) from this progess listener does not
+      // work on some machines (probably due to race conditions which are all
+      // over the place). Thus we need a point later in the start-up process
+      // where we can do this... Please welcome the mutation observer.
+      let mut_target = document.getElementById("main-window");
+      let mut_observer = new MutationObserver(
+        function(mutations) {
+          mutations.forEach(
+            function(mutation) {
+              torbutton_log(3, "Mutation observer: Window dimensions are: " +
+                win.innerWidth + " x " + win.innerHeight);
+              setTimeout(function() {
+                           win.resizeBy(width - win.innerWidth,
+                             height - win.innerHeight);
+                           torbutton_log(3, "Mutation observer: Window " +
+                             "dimensions are (after resizing again): " + win.
+                             innerWidth + " x " + win.innerHeight);
+                         }, 0);
+              mut_observer.disconnect();
+            }
+          );
+        }
+      );
+      // Configuration of the observer. Looking at added nodes is enough as
+      // DevTools related code is manipulating the DOM which we can capture.
+      // From that on we can start our fallback resizing.
+      let mut_config = { attributes: false, childList: true,
+        characterData: false };
+      mut_observer.observe(mut_target, mut_config);
+
       progress.removeProgressListener(this);
     }
   },



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits