зеркало из https://github.com/mozilla/gecko-dev.git
Bug 909731 - Disable zoom on start tab r=mbrubeck
This commit is contained in:
Родитель
5d43d99088
Коммит
d87d1fe50b
|
@ -432,7 +432,7 @@ let Content = {
|
|||
aRect.height,
|
||||
presShellId.value,
|
||||
viewId].join(",");
|
||||
Services.obs.notifyObservers(null, "Metro:ZoomToRect", zoomData);
|
||||
Services.obs.notifyObservers(null, "apzc-zoom-to-rect", zoomData);
|
||||
},
|
||||
|
||||
_shouldZoomToElement: function(aElement) {
|
||||
|
|
|
@ -35,6 +35,9 @@ var StartUI = {
|
|||
|
||||
this.chromeWin.addEventListener("MozPrecisePointer", this, true);
|
||||
this.chromeWin.addEventListener("MozImprecisePointer", this, true);
|
||||
this.chromeWin.addEventListener("MozAfterPaint", this, true);
|
||||
this.chromeWin.Elements.panelUI.addEventListener("ToolPanelHidden", this, false);
|
||||
|
||||
Services.obs.addObserver(this, "metro_viewstate_changed", false);
|
||||
},
|
||||
|
||||
|
@ -107,6 +110,15 @@ var StartUI = {
|
|||
aEvent.preventDefault();
|
||||
aEvent.stopPropagation();
|
||||
break;
|
||||
case "ToolPanelHidden":
|
||||
// After opening panel UI (console) set disableZoom again.
|
||||
this.chromeWin.addEventListener("MozAfterPaint", this, true);
|
||||
break;
|
||||
|
||||
case "MozAfterPaint":
|
||||
this._disableZoom();
|
||||
this.chromeWin.removeEventListener("MozAfterPaint", this, true);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -116,5 +128,24 @@ var StartUI = {
|
|||
this._adjustDOMforViewState(aData);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_disableZoom: function() {
|
||||
let utils = Util.getWindowUtils(window);
|
||||
let viewId;
|
||||
try {
|
||||
viewId = utils.getViewId(document.documentElement);
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
let presShellId = {};
|
||||
utils.getPresShellId(presShellId);
|
||||
|
||||
let notificationData = [
|
||||
presShellId.value,
|
||||
viewId].join(",");
|
||||
|
||||
Services.obs.notifyObservers(null, "apzc-disable-zoom", notificationData);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -280,7 +280,8 @@ MetroWidget::Destroy()
|
|||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
observerService->RemoveObserver(this, "apzc-scroll-offset-changed");
|
||||
observerService->RemoveObserver(this, "Metro:ZoomToRect");
|
||||
observerService->RemoveObserver(this, "apzc-zoom-to-rect");
|
||||
observerService->RemoveObserver(this, "apzc-disable-zoom");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -991,7 +992,8 @@ CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfa
|
|||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
observerService->AddObserver(this, "apzc-scroll-offset-changed", false);
|
||||
observerService->AddObserver(this, "Metro:ZoomToRect", false);
|
||||
observerService->AddObserver(this, "apzc-zoom-to-rect", false);
|
||||
observerService->AddObserver(this, "apzc-disable-zoom", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1601,7 +1603,7 @@ MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *d
|
|||
mController->UpdateScrollOffset(ScrollableLayerGuid(mRootLayerTreeId, presShellId, scrollId),
|
||||
scrollOffset);
|
||||
}
|
||||
else if (!strcmp(topic, "Metro:ZoomToRect")) {
|
||||
else if (!strcmp(topic, "apzc-zoom-to-rect")) {
|
||||
CSSRect rect = CSSRect();
|
||||
uint64_t viewId = 0;
|
||||
int32_t presShellId = 0;
|
||||
|
@ -1610,12 +1612,25 @@ MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *d
|
|||
&rect.x, &rect.y, &rect.width, &rect.height,
|
||||
&presShellId, &viewId);
|
||||
if(reScan != 6) {
|
||||
NS_WARNING("Malformed Metro:ZoomToRect message");
|
||||
NS_WARNING("Malformed apzc-zoom-to-rect message");
|
||||
}
|
||||
|
||||
ScrollableLayerGuid guid = ScrollableLayerGuid(mRootLayerTreeId, presShellId, viewId);
|
||||
APZController::sAPZC->ZoomToRect(guid, rect);
|
||||
}
|
||||
else if (!strcmp(topic, "apzc-disable-zoom")) {
|
||||
uint64_t viewId = 0;
|
||||
int32_t presShellId = 0;
|
||||
|
||||
int reScan = swscanf(data, L"%d,%llu",
|
||||
&presShellId, &viewId);
|
||||
if (reScan != 2) {
|
||||
NS_WARNING("Malformed apzc-disable-zoom message");
|
||||
}
|
||||
|
||||
ScrollableLayerGuid guid = ScrollableLayerGuid(mRootLayerTreeId, presShellId, viewId);
|
||||
APZController::sAPZC->UpdateZoomConstraints(guid, false, CSSToScreenScale(1.0f), CSSToScreenScale(1.0f));
|
||||
}
|
||||
else {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче