зеркало из https://github.com/mozilla/pjs.git
Bug 386835: Page loaded in background doesn't get zoom applied until it is switched to. r=gavin
This commit is contained in:
Родитель
98e0da9c51
Коммит
e86e640838
|
@ -226,10 +226,10 @@ var FullZoom = {
|
|||
|
||||
// location change observer
|
||||
|
||||
onLocationChange: function FullZoom_onLocationChange(aURI) {
|
||||
onLocationChange: function FullZoom_onLocationChange(aURI, aBrowser) {
|
||||
if (!aURI)
|
||||
return;
|
||||
this._applyPrefToSetting(this._cps.getPref(aURI, this.name));
|
||||
this._applyPrefToSetting(this._cps.getPref(aURI, this.name), aBrowser);
|
||||
},
|
||||
|
||||
// update state of zoom type menu item
|
||||
|
@ -286,18 +286,18 @@ var FullZoom = {
|
|||
* We don't check first to see if the new value is the same as the current
|
||||
* one.
|
||||
**/
|
||||
_applyPrefToSetting: function FullZoom__applyPrefToSetting(aValue) {
|
||||
_applyPrefToSetting: function FullZoom__applyPrefToSetting(aValue, aBrowser) {
|
||||
if (!this.siteSpecific || gInPrintPreviewMode ||
|
||||
content.document instanceof Ci.nsIImageDocument)
|
||||
return;
|
||||
|
||||
try {
|
||||
if (typeof aValue != "undefined")
|
||||
ZoomManager.zoom = this._ensureValid(aValue);
|
||||
ZoomManager.setZoomForBrowser(aBrowser || gBrowser, this._ensureValid(aValue));
|
||||
else if (typeof this.globalValue != "undefined")
|
||||
ZoomManager.zoom = this.globalValue;
|
||||
ZoomManager.setZoomForBrowser(aBrowser || gBrowser, this.globalValue);
|
||||
else
|
||||
ZoomManager.zoom = 1;
|
||||
ZoomManager.setZoomForBrowser(aBrowser || gBrowser, 1);
|
||||
}
|
||||
catch(ex) {}
|
||||
},
|
||||
|
|
|
@ -4035,8 +4035,6 @@ var XULBrowserWindow = {
|
|||
// Update starring UI
|
||||
PlacesStarButton.updateState();
|
||||
}
|
||||
|
||||
FullZoom.onLocationChange(aLocationURI);
|
||||
}
|
||||
UpdateBackForwardCommands(gBrowser.webNavigation);
|
||||
|
||||
|
@ -4172,6 +4170,7 @@ var XULBrowserWindow = {
|
|||
|
||||
// simulate all change notifications after switching tabs
|
||||
onUpdateCurrentBrowser: function (aStateFlags, aStatus, aMessage, aTotalProgress) {
|
||||
FullZoom.onLocationChange(gBrowser.currentURI);
|
||||
var nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
var loadingDone = aStateFlags & nsIWebProgressListener.STATE_STOP;
|
||||
// use a pseudo-object instead of a (potentially non-existing) channel for getting
|
||||
|
@ -4236,6 +4235,9 @@ var TabsProgressListener = {
|
|||
},
|
||||
|
||||
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI) {
|
||||
// Filter out any sub-frame loads
|
||||
if (aBrowser.contentWindow == aWebProgress.DOMWindow)
|
||||
FullZoom.onLocationChange(aLocationURI, aBrowser);
|
||||
},
|
||||
|
||||
onStatusChange: function (aBrowser, aWebProgress, aRequest, aStatus, aMessage) {
|
||||
|
|
|
@ -83,6 +83,8 @@ _BROWSER_FILES = browser_bug321000.js \
|
|||
alltabslistener.html \
|
||||
zoom_test.html \
|
||||
browser_bug416661.js \
|
||||
browser_bug386835.js \
|
||||
bug386835.html \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
var gTestPage = "http://example.org/browser/browser/base/content/test/bug386835.html";
|
||||
var gTab1, gTab2, gTab3;
|
||||
var gLevel;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gTab1 = gBrowser.addTab(gTestPage);
|
||||
gTab2 = gBrowser.addTab();
|
||||
gTab3 = gBrowser.addTab();
|
||||
gBrowser.selectedTab = gTab1;
|
||||
|
||||
gBrowser.getBrowserForTab(gTab1).addEventListener("load", tab1Loaded, true);
|
||||
}
|
||||
|
||||
function tab1Loaded() {
|
||||
gBrowser.getBrowserForTab(gTab1).removeEventListener("load", tab1Loaded, true);
|
||||
|
||||
gBrowser.getBrowserForTab(gTab2).addEventListener("load", tab2Loaded, true);
|
||||
gBrowser.getBrowserForTab(gTab2).loadURI(gTestPage);
|
||||
}
|
||||
|
||||
function tab2Loaded() {
|
||||
gBrowser.getBrowserForTab(gTab2).removeEventListener("load", tab2Loaded, true);
|
||||
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)), 1, "Initial zoom of tab 1 should be 1");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)), 1, "Initial zoom of tab 2 should be 1");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab3)), 1, "Initial zoom of tab 3 should be 1");
|
||||
|
||||
// Now have three tabs, two with the test page, one blank. Tab 1 is selected
|
||||
// Zoom tab 1
|
||||
FullZoom.enlarge();
|
||||
gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
|
||||
|
||||
ok(gLevel != 1, "New zoom for tab 1 should not be 1");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)), 1, "Zooming tab 1 should not affect tab 2");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab3)), 1, "Zooming tab 1 should not affect tab 3");
|
||||
|
||||
gBrowser.getBrowserForTab(gTab3).addEventListener("load", tab3Loaded, true);
|
||||
gBrowser.getBrowserForTab(gTab3).loadURI(gTestPage);
|
||||
}
|
||||
|
||||
function tab3Loaded() {
|
||||
gBrowser.getBrowserForTab(gTab3).removeEventListener("load", tab3Loaded, true);
|
||||
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)), gLevel, "Tab 1 should still be zoomed");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)), 1, "Tab 2 should still not be affected");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab3)), gLevel, "Tab 3 should have zoomed as it was loading in the background");
|
||||
|
||||
// Switching to tab 2 should update its zoom setting.
|
||||
gBrowser.selectedTab = gTab2;
|
||||
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)), gLevel, "Tab 1 should still be zoomed");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)), gLevel, "Tab 2 should be zoomed now");
|
||||
is(ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab3)), gLevel, "Tab 3 should still be zoomed");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
FullZoom.reset();
|
||||
gBrowser.removeTab(gTab1);
|
||||
gBrowser.removeTab(gTab2);
|
||||
gBrowser.removeTab(gTab3);
|
||||
finish();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Test page for bug 386835</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Test page for bug 386835</p>
|
||||
</body>
|
||||
</html>
|
|
@ -42,7 +42,8 @@
|
|||
|
||||
/** Document Zoom Management Code
|
||||
*
|
||||
* To use this, you'll need to have a getBrowser() function.
|
||||
* To use this, you'll need to have a getBrowser() function or use the methods
|
||||
* that accept a browser to be modified.
|
||||
**/
|
||||
|
||||
var ZoomManager = {
|
||||
|
@ -72,17 +73,26 @@ var ZoomManager = {
|
|||
},
|
||||
|
||||
get zoom ZoomManager_get_zoom() {
|
||||
var markupDocumentViewer = getBrowser().markupDocumentViewer;
|
||||
return this.getZoomForBrowser(getBrowser());
|
||||
},
|
||||
|
||||
getZoomForBrowser: function ZoomManager_getZoomForBrowser(aBrowser) {
|
||||
var markupDocumentViewer = aBrowser.markupDocumentViewer;
|
||||
|
||||
return this.useFullZoom ? markupDocumentViewer.fullZoom
|
||||
: markupDocumentViewer.textZoom;
|
||||
},
|
||||
|
||||
set zoom ZoomManager_set_zoom(aVal) {
|
||||
this.setZoomForBrowser(getBrowser(), aVal);
|
||||
return aVal;
|
||||
},
|
||||
|
||||
setZoomForBrowser: function ZoomManager_setZoomForBrowser(aBrowser, aVal) {
|
||||
if (aVal < this.MIN || aVal > this.MAX)
|
||||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
|
||||
var markupDocumentViewer = getBrowser().markupDocumentViewer;
|
||||
var markupDocumentViewer = aBrowser.markupDocumentViewer;
|
||||
|
||||
if (this.useFullZoom) {
|
||||
markupDocumentViewer.textZoom = 1;
|
||||
|
@ -91,8 +101,6 @@ var ZoomManager = {
|
|||
markupDocumentViewer.textZoom = aVal;
|
||||
markupDocumentViewer.fullZoom = 1;
|
||||
}
|
||||
|
||||
return aVal;
|
||||
},
|
||||
|
||||
get zoomValues ZoomManager_get_zoomValues() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче