зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1300376 - Update zoom indicator when moving a browser to another window. r=jaws
MozReview-Commit-ID: 3iWBQBM9jC3 --HG-- extra : rebase_source : 60675f06a4c68d429f8f7a9ffac6334b22f47804
This commit is contained in:
Родитель
7cb03e9252
Коммит
233f3a1a90
|
@ -27,7 +27,8 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
|
|||
ShortcutUtils:false, SimpleServiceDiscovery:false, SitePermissions:false,
|
||||
Social:false, TabCrashHandler:false, Task:false, TelemetryStopwatch:false,
|
||||
Translation:false, UITour:false, UpdateUtils:false, Weave:false,
|
||||
fxAccounts:false, gDevTools:false, gDevToolsBrowser:false, webrtcUI:false
|
||||
fxAccounts:false, gDevTools:false, gDevToolsBrowser:false, webrtcUI:false,
|
||||
URLBarZoom:false
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -74,11 +75,12 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
|
|||
["Translation", "resource:///modules/translation/Translation.jsm"],
|
||||
["UITour", "resource:///modules/UITour.jsm"],
|
||||
["UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"],
|
||||
["URLBarZoom", "resource:///modules/URLBarZoom.jsm"],
|
||||
["Weave", "resource://services-sync/main.js"],
|
||||
["fxAccounts", "resource://gre/modules/FxAccounts.jsm"],
|
||||
["gDevTools", "resource://devtools/client/framework/gDevTools.jsm"],
|
||||
["gDevToolsBrowser", "resource://devtools/client/framework/gDevTools.jsm"],
|
||||
["webrtcUI", "resource:///modules/webrtcUI.jsm", ]
|
||||
["webrtcUI", "resource:///modules/webrtcUI.jsm"],
|
||||
].forEach(([name, resource]) => XPCOMUtils.defineLazyModuleGetter(this, name, resource));
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
|
||||
|
@ -1132,6 +1134,7 @@ var gBrowserInit = {
|
|||
TrackingProtection.init();
|
||||
RefreshBlocker.init();
|
||||
CaptivePortalWatcher.init();
|
||||
URLBarZoom.init(window);
|
||||
|
||||
let mm = window.getGroupMessageManager("browsers");
|
||||
mm.loadFrameScript("chrome://browser/content/tab-content.js", true);
|
||||
|
|
|
@ -32,7 +32,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "AlertsService", "@mozilla.org/alerts-s
|
|||
ProcessHangMonitor:false, ReaderParent:false, RecentWindow:false,
|
||||
RemotePrompt:false, SelfSupportBackend:false, SessionStore:false,
|
||||
ShellService:false, SimpleServiceDiscovery:false, TabCrashHandler:false,
|
||||
Task:false, UITour:false, URLBarZoom:false, WebChannel:false,
|
||||
Task:false, UITour:false, WebChannel:false,
|
||||
WindowsRegistry:false, webrtcUI:false */
|
||||
|
||||
/**
|
||||
|
@ -86,7 +86,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "AlertsService", "@mozilla.org/alerts-s
|
|||
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
|
||||
["Task", "resource://gre/modules/Task.jsm"],
|
||||
["UITour", "resource:///modules/UITour.jsm"],
|
||||
["URLBarZoom", "resource:///modules/URLBarZoom.jsm"],
|
||||
["WebChannel", "resource://gre/modules/WebChannel.jsm"],
|
||||
["WindowsRegistry", "resource://gre/modules/WindowsRegistry.jsm"],
|
||||
["webrtcUI", "resource:///modules/webrtcUI.jsm"],
|
||||
|
@ -631,7 +630,6 @@ BrowserGlue.prototype = {
|
|||
|
||||
LoginManagerParent.init();
|
||||
ReaderParent.init();
|
||||
URLBarZoom.init();
|
||||
|
||||
SelfSupportBackend.init();
|
||||
|
||||
|
|
|
@ -10,20 +10,39 @@ this.EXPORTED_SYMBOLS = [ "URLBarZoom" ];
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var URLBarZoom = {
|
||||
|
||||
init(aWindow) {
|
||||
// Register ourselves with the service so we know when the zoom prefs change.
|
||||
Services.obs.addObserver(updateZoomButton, "browser-fullZoom:zoomChange", false);
|
||||
Services.obs.addObserver(updateZoomButton, "browser-fullZoom:zoomReset", false);
|
||||
Services.obs.addObserver(updateZoomButton, "browser-fullZoom:location-change", false);
|
||||
aWindow.addEventListener("EndSwapDocShells", onEndSwapDocShells, true);
|
||||
aWindow.addEventListener("unload", () => {
|
||||
aWindow.removeEventListener("EndSwapDocShells", onEndSwapDocShells, true);
|
||||
}, {once: true});
|
||||
},
|
||||
}
|
||||
|
||||
function updateZoomButton(aSubject, aTopic) {
|
||||
let win = aSubject.ownerGlobal;
|
||||
function fullZoomObserver(aSubject, aTopic) {
|
||||
// If the tab was the last one in its window and has been dragged to another
|
||||
// window, the original browser's window will be unavailable here. Since that
|
||||
// window is closing, we can just ignore this notification.
|
||||
if (!aSubject.ownerGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only allow pulse animation for zoom changes, not tab switching.
|
||||
let animate = (aTopic != "browser-fullZoom:location-change");
|
||||
updateZoomButton(aSubject, animate);
|
||||
}
|
||||
|
||||
function onEndSwapDocShells(event) {
|
||||
updateZoomButton(event.originalTarget);
|
||||
}
|
||||
|
||||
function updateZoomButton(aBrowser, aAnimate = false) {
|
||||
let win = aBrowser.ownerGlobal;
|
||||
if (aBrowser != win.gBrowser.selectedBrowser) {
|
||||
return;
|
||||
}
|
||||
|
||||
let customizableZoomControls = win.document.getElementById("zoom-controls");
|
||||
let zoomResetButton = win.document.getElementById("urlbar-zoom-button");
|
||||
let zoomFactor = Math.round(win.ZoomManager.zoom * 100);
|
||||
|
||||
// Ensure that zoom controls haven't already been added to browser in Customize Mode
|
||||
if (customizableZoomControls &&
|
||||
|
@ -31,21 +50,26 @@ function updateZoomButton(aSubject, aTopic) {
|
|||
zoomResetButton.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let zoomFactor = Math.round(win.ZoomManager.zoom * 100);
|
||||
if (zoomFactor != 100) {
|
||||
// Check if zoom button is visible and update label if it is
|
||||
if (zoomResetButton.hidden) {
|
||||
zoomResetButton.hidden = false;
|
||||
}
|
||||
// Only allow pulse animation for zoom changes, not tab switching
|
||||
if (aTopic != "browser-fullZoom:location-change") {
|
||||
if (aAnimate) {
|
||||
zoomResetButton.setAttribute("animate", "true");
|
||||
} else {
|
||||
zoomResetButton.removeAttribute("animate");
|
||||
}
|
||||
zoomResetButton.setAttribute("label",
|
||||
win.gNavigatorBundle.getFormattedString("urlbar-zoom-button.label", [zoomFactor]));
|
||||
// Hide button if zoom is at 100%
|
||||
} else {
|
||||
zoomResetButton.hidden = true;
|
||||
// Hide button if zoom is at 100%
|
||||
zoomResetButton.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(fullZoomObserver, "browser-fullZoom:zoomChange", false);
|
||||
Services.obs.addObserver(fullZoomObserver, "browser-fullZoom:zoomReset", false);
|
||||
Services.obs.addObserver(fullZoomObserver, "browser-fullZoom:location-change", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче