Commit 89a15ab9 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Mike Perry
Browse files

Bug #14429, Part 3. Improve behavior of content window resizer

parent c042622c
This diff is collapsed.
......@@ -644,8 +644,6 @@ function torbutton_init() {
createTorCircuitDisplay(m_tb_control_host, m_tb_control_port, m_tb_control_pass,
"extensions.torbutton.display_circuit");
quantizeBrowserSize(window, 200, 100);
torbutton_log(3, 'init completed');
}
......@@ -3000,8 +2998,8 @@ function torbutton_new_tab(event)
// Returns true if the window wind is neither maximized, full screen,
// ratpoisioned/evilwmed, nor minimized.
function torbutton_is_windowed(wind) {
torbutton_log(3, "Window: ("+wind.outerHeight+","+wind.outerWidth+") ?= ("
+wind.screen.availHeight+","+wind.screen.availWidth+")");
torbutton_log(3, "Window: (" + wind.outerWidth + "," + wind.outerHeight + ") ?= ("
+ wind.screen.availWidth + "," + wind.screen.availHeight + ")");
if(wind.windowState == Components.interfaces.nsIDOMChromeWindow.STATE_MINIMIZED
|| wind.windowState == Components.interfaces.nsIDOMChromeWindow.STATE_MAXIMIZED) {
torbutton_log(2, "Window is minimized/maximized");
......@@ -3391,7 +3389,8 @@ var torbutton_resizelistener =
var progress =
Components.classes["@mozilla.org/docloaderservice;1"].
getService(Components.interfaces.nsIWebProgress);
var win = getBrowser().contentWindow;
var win = getBrowser().contentWindow,
container = getBrowser().parentElement;
if (!win || typeof(win) == "undefined") {
torbutton_log(5, "No initial browser content window?");
progress.removeProgressListener(this);
......@@ -3416,8 +3415,8 @@ var torbutton_resizelistener =
" Available: " + availWidth.value + "x" +
availHeight.value);
var diff_height = window.outerHeight - win.innerHeight;
var diff_width = window.outerWidth - win.innerWidth;
var diff_height = window.outerHeight - win.innerHeight;
var delta_fix = 0;
// The following block tries to cope with funny corner cases where the
......@@ -3481,6 +3480,14 @@ var torbutton_resizelistener =
height = Math.floor(maxHeight/100.0)*100;
}
let resizeInnerWindowTo = function (width, height) {
window.resizeBy(width - win.innerWidth,
height - win.innerHeight);
torbutton_log(3, "Resized new window from: " + container.clientWidth + "x" +
container.clientHeight + " to " + width + "x" + height +
" in state " + window.windowState);
}
m_tb_resize_handler = function() {
if (window.windowState === 1) {
if (m_tb_prefs.
......@@ -3537,7 +3544,7 @@ var torbutton_resizelistener =
getBoolPref(k_tb_tor_resize_warn_pref)) {
window.addEventListener("resize",
function() {
win.resizeBy(width - win.innerWidth, height - win.innerHeight);
resizeInnerWindowTo(width, height);
var calling_function = arguments.callee;
setTimeout(function() {
torbutton_log(3, "Removing resize listener..");
......@@ -3575,10 +3582,7 @@ var torbutton_resizelistener =
// This is fun. any attempt to directly set the inner window actually
// resizes the outer width to that value instead. Must use resizeBy()
// instead of assignment or resizeTo()
win.resizeBy(width - win.innerWidth, height - win.innerHeight);
torbutton_log(3, "Resized new window from: " + win.innerWidth + "x" +
win.innerHeight + " to " + width + "x" + height +
" in state " + window.windowState);
resizeInnerWindowTo(width, height);
// Resizing within this progress listener does not always work as overlays
// of other extensions might still influence the height/width of the
......@@ -3592,14 +3596,9 @@ var torbutton_resizelistener =
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);
resizeInnerWindowTo(width, height);
quantizeBrowserSize(window, 100, 100);
}, 0);
mut_observer.disconnect();
}
......
......@@ -7,6 +7,7 @@ torbutton.circuit_display.this_browser = This browser
torbutton.circuit_display.relay = relay
torbutton.circuit_display.tor_bridge = Bridge
torbutton.circuit_display.unknown_country = Unknown country
torbutton.content_sizer.margin_tooltip = Tor Browser adds this margin to make the width and height of your window less distinctive, and thus reduces the ability of people to track you online.
torbutton.panel.tooltip.disabled = Click to enable Tor
torbutton.panel.tooltip.enabled = Click to disable Tor
torbutton.panel.plugins.disabled = Click to enable plugins
......
......@@ -39,5 +39,18 @@ let bindPrefAndInit = function (prefName, prefHandler) {
return () => { prefs.removeObserver(prefName, observer); };
};
// ## Environment variables
// __env__.
// Provides access to process environment variables.
let env = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
// __getEnv(name)__.
// Reads the environment variable of the given name.
let getEnv = function (name) {
return env.exists(name) ? env.get(name) : undefined;
};
// Export utility functions for external use.
let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue"];
let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue", "getEnv"];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment