Ticket #9268: tb.kludge3.diff
File tb.kludge3.diff, 5.0 KB (added by , 6 years ago) 


torbutton.js
old new 2869 2869 { /*torbutton_eclog(1, 'called linkIcon'); */ return 0; } 2870 2870 } 2871 2871 2872 /* Call it to resize window. Later is better, then it counts 2873 all appeared bars to proper round inner sizes */ 2874 function torbutton_resize_window(win) { 2875 2876 var diff_height = window.outerHeight  win.innerHeight; 2877 var diff_width = window.outerWidth  win.innerWidth; 2878 2879 2880 /* kludge kludge kludge 2881 What about screenPixelsPerCSSPixel? */ 2882 var delta_fix = 0; 2883 if (window.outerHeight == window.innerHeight) { 2884 delta_fix = Math.floor(window.mozInnerScreenY)  window.screenY; 2885 if (delta_fix == 0) // zero? adds more kludge 2886 delta_fix = Math.floor(diff_height / 2); 2887 else 2888 delta_fix++; 2889 } 2890 2891 /* window.screen.avail* returns maximum outer size available. 2892 We no need screen resolution for desktop here, 2893 which can't to count DPI settings, taskbar or something else */ 2894 2895 var maxHeight = window.screen.availHeight  (diff_height + delta_fix); 2896 var maxWidth = window.screen.availWidth  diff_width ; 2897 2898 var width = 0; 2899 var height = 0; 2900 2901 torbutton_log(5, "About to resize window: " + 2902 window.outerWidth + "x" + window.outerHeight + 2903 " inner: " + win.innerWidth + "x" + win.innerHeight + 2904 " in state " + window.windowState + 2905 " Available: " + window.screen.availWidth + "x" + 2906 window.screen.availHeight); 2907 2908 2909 if (maxWidth > 1000) { 2910 width = 1000; 2911 } else { 2912 width = Math.floor(maxWidth/200.0)*200; 2913 } 2914 2915 height = Math.floor(maxHeight/100.0)*100; 2916 2917 torbutton_log(5, "Max dimensions for resize: " + maxWidth + "x" + 2918 maxHeight + " Requested: " + width + "x" + height); 2919 2920 win.resizeBy(width  win.innerWidth, height  win.innerHeight); 2921 } 2872 2922 // Bug 1506 P1/P3: Setting a fixed window size is important, but 2873 2923 // probably not for android. 2874 2924 var torbutton_resizelistener = … … 2894 2944 progress.removeProgressListener(this); 2895 2945 return; 2896 2946 } 2897 var screenMan = Components.classes["@mozilla.org/gfx/screenmanager;1"].2898 getService(Components.interfaces.nsIScreenManager);2899 var junk = {}, availWidth = {}, availHeight = {};2900 screenMan.primaryScreen.GetRect(junk, junk, availWidth, availHeight);2901 2947 2902 2948 // We need to set the inner width to an initial value because it has none 2903 2949 // at this point... Choosing "300" as this works even on Windows … … 2905 2951 win.innerWidth = 300; 2906 2952 win.innerHeight = 300; 2907 2953 2908 torbutton_log(3, "About to resize new window: " + window.outerWidth +2909 "x" + window.outerHeight + " inner: " + win.innerWidth + "x" + win.2910 innerHeight + " in state " + window.windowState + " Have " +2911 availWidth.value + "x" + availHeight.value);2912 2913 var maxHeight = availHeight.value 2914 (window.outerHeight  win.innerHeight)  51;2915 var maxWidth = availWidth.value  (window.outerWidth  win.innerWidth);2916 torbutton_log(3, "Got max dimensions: " + maxWidth + "x" + maxHeight);2917 2918 var width;2919 var height;2920 2921 if (maxWidth > 1000) {2922 width = 1000;2923 } else {2924 width = Math.floor(maxWidth/200.0)*200;2925 }2926 2927 height = Math.floor(maxHeight/100.0)*100;2928 2954 2929 2955 var handler = function() { 2930 2956 if (window.windowState === 1) { 2931 2957 window.addEventListener("resize", 2932 2958 function() { 2933 win.resizeBy(width  win.innerWidth, height  win.innerHeight);2959 torbutton_resize_window(win); 2934 2960 var calling_function = arguments.callee; 2935 2961 setTimeout(function() { 2936 2962 torbutton_log(3, "Removing resize listener.."); … … 2969 2995 // This is fun. any attempt to directly set the inner window actually 2970 2996 // resizes the outer width to that value instead. Must use resizeBy() 2971 2997 // instead of assignment or resizeTo() 2972 win.resizeBy(width  win.innerWidth, height  win.innerHeight); 2973 torbutton_log(3, "Resized new window from: " + win.innerWidth + "x" + 2974 win.innerHeight + " to " + width + "x" + height + " in state " + 2975 window.windowState); 2998 torbutton_resize_window(win); 2976 2999 2977 3000 // Resizing within this progress listener does not always work as overlays 2978 3001 // of other extensions might still influence the height/width of the … … 2989 3012 torbutton_log(3, "Mutation observer: Window dimensions are: " + 2990 3013 win.innerWidth + " x " + win.innerHeight); 2991 3014 setTimeout(function() { 2992 win.resizeBy(width  win.innerWidth, 2993 height  win.innerHeight); 3015 torbutton_resize_window(win); 2994 3016 torbutton_log(3, "Mutation observer: Window " + 2995 3017 "dimensions are (after resizing again): " + win. 2996 3018 innerWidth + " x " + win.innerHeight);