mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1516368 - Change SetResolutionAndScaleTo to take an enum instead of an nsAtoms*. r=botond
There is no reason to use nsAtoms*, it's error prone, i.e. the function can take arbitrary nsAtoms*. Depends on D15339 Differential Revision: https://phabricator.services.mozilla.com/D15340 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
1cee88971a
commit
529616ef3a
@ -548,7 +548,8 @@ nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
presShell->SetResolutionAndScaleTo(aResolution, nsGkAtoms::other);
|
||||
presShell->SetResolutionAndScaleTo(aResolution,
|
||||
nsIPresShell::ChangeOrigin::eOther);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -10148,7 +10148,8 @@ void nsIDocument::CleanupFullscreenState() {
|
||||
// Restore the zoom level that was in place prior to entering fullscreen.
|
||||
if (nsIPresShell* shell = GetShell()) {
|
||||
if (shell->GetMobileViewportManager()) {
|
||||
shell->SetResolutionAndScaleTo(mSavedResolution, nsGkAtoms::restore);
|
||||
shell->SetResolutionAndScaleTo(mSavedResolution,
|
||||
nsIPresShell::ChangeOrigin::eRestore);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10546,7 +10547,7 @@ bool nsIDocument::ApplyFullscreen(UniquePtr<FullscreenRequest> aRequest) {
|
||||
// Save the previous resolution so it can be restored.
|
||||
child->mSavedResolution = shell->GetResolution();
|
||||
shell->SetResolutionAndScaleTo(manager->ComputeIntrinsicResolution(),
|
||||
nsGkAtoms::other);
|
||||
nsIPresShell::ChangeOrigin::eOther);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,8 @@ void APZCCallbackHelper::UpdateRootFrame(const RepaintRequest& aRequest) {
|
||||
// last paint.
|
||||
presShellResolution =
|
||||
aRequest.GetPresShellResolution() * aRequest.GetAsyncZoom().scale;
|
||||
shell->SetResolutionAndScaleTo(presShellResolution, nsGkAtoms::apz);
|
||||
shell->SetResolutionAndScaleTo(presShellResolution,
|
||||
nsIPresShell::ChangeOrigin::eApz);
|
||||
}
|
||||
|
||||
// Do this as late as possible since scrolling can flush layout. It also
|
||||
|
@ -329,7 +329,8 @@ void MobileViewportManager::UpdateResolution(
|
||||
if (newZoom) {
|
||||
LayoutDeviceToLayerScale resolution = ZoomToResolution(*newZoom, cssToDev);
|
||||
MVM_LOG("%p: setting resolution %f\n", this, resolution.scale);
|
||||
mPresShell->SetResolutionAndScaleTo(resolution.scale, nsGkAtoms::other);
|
||||
mPresShell->SetResolutionAndScaleTo(resolution.scale,
|
||||
nsIPresShell::ChangeOrigin::eOther);
|
||||
|
||||
MVM_LOG("%p: New zoom is %f\n", this, newZoom->scale);
|
||||
}
|
||||
|
@ -5157,7 +5157,7 @@ void PresShell::SetIgnoreViewportScrolling(bool aIgnore) {
|
||||
}
|
||||
|
||||
nsresult PresShell::SetResolutionAndScaleTo(float aResolution,
|
||||
nsAtom* aOrigin) {
|
||||
ChangeOrigin aOrigin) {
|
||||
if (!(aResolution > 0.0)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
@ -5171,7 +5171,7 @@ nsresult PresShell::SetResolutionAndScaleTo(float aResolution,
|
||||
if (mMobileViewportManager) {
|
||||
mMobileViewportManager->ResolutionUpdated();
|
||||
}
|
||||
if (aOrigin != nsGkAtoms::apz) {
|
||||
if (aOrigin != ChangeOrigin::eApz) {
|
||||
mResolutionUpdated = true;
|
||||
}
|
||||
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
|
||||
|
@ -195,7 +195,8 @@ class PresShell final : public nsIPresShell,
|
||||
|
||||
void SetIgnoreViewportScrolling(bool aIgnore) override;
|
||||
|
||||
nsresult SetResolutionAndScaleTo(float aResolution, nsAtom* aOrigin) override;
|
||||
nsresult SetResolutionAndScaleTo(float aResolution,
|
||||
ChangeOrigin aOrigin) override;
|
||||
bool IsResolutionUpdated() const override { return mResolutionUpdated; }
|
||||
void SetResolutionUpdated(bool aUpdated) override {
|
||||
mResolutionUpdated = aUpdated;
|
||||
|
@ -1371,12 +1371,17 @@ class nsIPresShell : public nsStubDocumentObserver {
|
||||
* The resolution defaults to 1.0.
|
||||
*
|
||||
* |aOrigin| specifies who originated the resolution change. For changes
|
||||
* sent by APZ, pass nsGkAtoms::apz. For changes sent by the main thread,
|
||||
* use pass nsGkAtoms::other or nsGkAtoms::restore (similar to the |aOrigin|
|
||||
* parameter of nsIScrollableFrame::ScrollToCSSPixels()).
|
||||
* sent by APZ, pass ChangeOrigin::eApz. For changes sent by the main thread,
|
||||
* use pass ChangeOrigin::Other or ChangeOrigin::Restore (similar to the
|
||||
* |aOrigin| parameter of nsIScrollableFrame::ScrollToCSSPixels()).
|
||||
*/
|
||||
enum class ChangeOrigin : uint8_t {
|
||||
eApz,
|
||||
eRestore,
|
||||
eOther,
|
||||
};
|
||||
virtual nsresult SetResolutionAndScaleTo(float aResolution,
|
||||
nsAtom* aOrigin) = 0;
|
||||
ChangeOrigin aOrigin) = 0;
|
||||
float GetResolution() const { return mResolution.valueOr(1.0); }
|
||||
virtual float GetCumulativeResolution() = 0;
|
||||
|
||||
|
@ -6162,7 +6162,7 @@ void ScrollFrameHelper::RestoreState(PresState* aState) {
|
||||
if (mIsRoot) {
|
||||
nsIPresShell* presShell = mOuter->PresShell();
|
||||
presShell->SetResolutionAndScaleTo(aState->resolution(),
|
||||
nsGkAtoms::restore);
|
||||
nsIPresShell::ChangeOrigin::eRestore);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user