mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 10:15:41 +00:00
Bug 1345375 - Use the FullZoomChange event instead of browser-fullZoom observers since FullZoomChange works on MediaDocuments. r=dao
MozReview-Commit-ID: 9SYHLc2FluC --HG-- extra : rebase_source : 8ee29ae20c5170b44a06368b46ebb43f2649497d
This commit is contained in:
parent
0539e340b8
commit
9794edea1a
@ -726,9 +726,8 @@ const CustomizableWidgets = [
|
||||
}
|
||||
|
||||
// Register ourselves with the service so we know when the zoom prefs change.
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomChange", false);
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomReset", false);
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:location-change", false);
|
||||
window.addEventListener("FullZoomChange", updateZoomResetButton);
|
||||
|
||||
if (inPanel) {
|
||||
let panel = aDocument.getElementById(kPanelId);
|
||||
@ -805,9 +804,8 @@ const CustomizableWidgets = [
|
||||
return;
|
||||
|
||||
CustomizableUI.removeListener(listener);
|
||||
Services.obs.removeObserver(updateZoomResetButton, "browser-fullZoom:zoomChange");
|
||||
Services.obs.removeObserver(updateZoomResetButton, "browser-fullZoom:zoomReset");
|
||||
Services.obs.removeObserver(updateZoomResetButton, "browser-fullZoom:location-change");
|
||||
window.removeEventListener("FullZoomChange", updateZoomResetButton);
|
||||
let panel = aDoc.getElementById(kPanelId);
|
||||
panel.removeEventListener("popupshowing", updateZoomResetButton);
|
||||
let container = aDoc.defaultView.gBrowser.tabContainer;
|
||||
|
@ -14,11 +14,13 @@ var URLBarZoom = {
|
||||
aWindow.addEventListener("EndSwapDocShells", onEndSwapDocShells, true);
|
||||
aWindow.addEventListener("unload", () => {
|
||||
aWindow.removeEventListener("EndSwapDocShells", onEndSwapDocShells, true);
|
||||
aWindow.removeEventListener("FullZoomChange", onFullZoomChange);
|
||||
}, {once: true});
|
||||
aWindow.addEventListener("FullZoomChange", onFullZoomChange);
|
||||
},
|
||||
}
|
||||
|
||||
function fullZoomObserver(aSubject, aTopic) {
|
||||
function fullZoomLocationChangeObserver(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.
|
||||
@ -26,25 +28,25 @@ function fullZoomObserver(aSubject, aTopic) {
|
||||
return;
|
||||
}
|
||||
|
||||
let animate = (aTopic != "browser-fullZoom:location-change");
|
||||
updateZoomButton(aSubject, animate);
|
||||
updateZoomButton(aSubject, false);
|
||||
}
|
||||
|
||||
function onEndSwapDocShells(event) {
|
||||
updateZoomButton(event.originalTarget);
|
||||
}
|
||||
|
||||
function onFullZoomChange(event) {
|
||||
updateZoomButton(event.originalTarget, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the zoom button in the location bar.
|
||||
*
|
||||
* @param {object} aBrowser The browser that the zoomed content resides in.
|
||||
* @param {boolean} aAnimate Should be True for all cases unless the zoom
|
||||
* change is related to tab switching. Optional
|
||||
* @param {number} aValue The value that should be used for the zoom control.
|
||||
* If not provided then the value will be read from the window. Useful
|
||||
* if the data on the window may be stale.
|
||||
*/
|
||||
function updateZoomButton(aBrowser, aAnimate = false, aValue = undefined) {
|
||||
function updateZoomButton(aBrowser, aAnimate = false) {
|
||||
let win = aBrowser.ownerGlobal;
|
||||
if (aBrowser != win.gBrowser.selectedBrowser) {
|
||||
return;
|
||||
@ -60,12 +62,9 @@ function updateZoomButton(aBrowser, aAnimate = false, aValue = undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let zoomFactor = Math.round((aValue || win.ZoomManager.zoom) * 100);
|
||||
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;
|
||||
}
|
||||
zoomResetButton.hidden = false;
|
||||
if (aAnimate) {
|
||||
zoomResetButton.setAttribute("animate", "true");
|
||||
} else {
|
||||
@ -79,9 +78,4 @@ function updateZoomButton(aBrowser, aAnimate = false, aValue = undefined) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
Services.mm.addMessageListener("SyntheticDocument:ZoomChange", function(aMessage) {
|
||||
updateZoomButton(aMessage.target, true, aMessage.data.value);
|
||||
});
|
||||
Services.obs.addObserver(fullZoomLocationChangeObserver, "browser-fullZoom:location-change", false);
|
||||
|
@ -1777,20 +1777,6 @@ let DateTimePickerListener = {
|
||||
|
||||
DateTimePickerListener.init();
|
||||
|
||||
let URLBarZoom = {
|
||||
init() {
|
||||
addEventListener("FullZoomChange", e => {
|
||||
if (!e.target.mozSyntheticDocument) {
|
||||
return;
|
||||
}
|
||||
sendSyncMessage("SyntheticDocument:ZoomChange",
|
||||
{"value": docShell.contentViewer.fullZoom});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
URLBarZoom.init();
|
||||
|
||||
addEventListener("mozshowdropdown", event => {
|
||||
if (!event.isTrusted)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user