Bug 1516368 - Change SetResolutionAndScaleTo to take an enum instead of an nsAtoms*. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sun, 30 Dec 2018 02:16:42 +0000
changeset 509234 f11eea40912a16a004d9e71f2ec2d3faffd5d8c8
parent 509233 bb9b55fa11612bc7a6e70c3eda132d04b7f22167
child 509235 a17c856e81b5ab876db8bc26bc89ebcf78dfaf30
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1516368
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDocument.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
layout/base/MobileViewportManager.cpp
layout/base/PresShell.cpp
layout/base/PresShell.h
layout/base/nsIPresShell.h
layout/generic/nsGfxScrollFrame.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -543,17 +543,18 @@ nsDOMWindowUtils::SetDisplayPortBaseForE
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution) {
   nsIPresShell* presShell = GetPresShell();
   if (!presShell) {
     return NS_ERROR_FAILURE;
   }
 
-  presShell->SetResolutionAndScaleTo(aResolution, nsGkAtoms::other);
+  presShell->SetResolutionAndScaleTo(aResolution,
+                                     nsIPresShell::ChangeOrigin::eOther);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SetRestoreResolution(float aResolution,
                                        uint32_t aDisplayWidth,
                                        uint32_t aDisplayHeight) {
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -10143,17 +10143,18 @@ void nsIDocument::CleanupFullscreenState
     }
   }
   mFullscreenStack.Clear();
   mFullscreenRoot = nullptr;
 
   // 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);
     }
   }
 
   UpdateViewportScrollbarOverrideForFullscreen(this);
 }
 
 bool nsIDocument::FullscreenStackPush(Element* aElement) {
   NS_ASSERTION(aElement, "Must pass non-null to FullscreenStackPush()");
@@ -10541,17 +10542,17 @@ bool nsIDocument::ApplyFullscreen(Unique
     // This also ensures that things like video controls aren't zoomed in
     // when in fullscreen mode.
     if (nsIPresShell* shell = child->GetShell()) {
       if (RefPtr<MobileViewportManager> manager =
               shell->GetMobileViewportManager()) {
         // Save the previous resolution so it can be restored.
         child->mSavedResolution = shell->GetResolution();
         shell->SetResolutionAndScaleTo(manager->ComputeIntrinsicResolution(),
-                                       nsGkAtoms::other);
+                                       nsIPresShell::ChangeOrigin::eOther);
       }
     }
 
     NS_ASSERTION(child->GetFullscreenRoot() == fullScreenRootDoc,
                  "Fullscreen root should be set!");
     if (child == fullScreenRootDoc) {
       break;
     }
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -313,17 +313,18 @@ void APZCCallbackHelper::UpdateRootFrame
                                    aRequest.GetPresShellResolution())) {
       return;
     }
 
     // The pres shell resolution is updated by the the async zoom since the
     // 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
   // adjusts the display port margins, so do it before we set those.
   ScreenMargin displayPortMargins = ScrollFrame(content, aRequest);
 
   SetDisplayPortMargins(shell, content, displayPortMargins,
                         aRequest.CalculateCompositedSizeInCssPixels());
--- a/layout/base/MobileViewportManager.cpp
+++ b/layout/base/MobileViewportManager.cpp
@@ -324,17 +324,18 @@ void MobileViewportManager::UpdateResolu
       }
     }
   }
 
   // If the zoom has changed, update the pres shell resolution accordingly.
   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);
   }
 
   // The visual viewport size depends on both the zoom and the display size,
   // and needs to be updated if either might have changed.
   if (newZoom || aType == UpdateType::ViewportSize) {
     UpdateVisualViewportSize(aDisplaySize, newZoom ? *newZoom : zoom);
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -5152,31 +5152,31 @@ void PresShell::SetIgnoreViewportScrolli
   }
   RenderingState state(this);
   state.mRenderFlags = ChangeFlag(state.mRenderFlags, aIgnore,
                                   STATE_IGNORING_VIEWPORT_SCROLLING);
   SetRenderingState(state);
 }
 
 nsresult PresShell::SetResolutionAndScaleTo(float aResolution,
-                                            nsAtom* aOrigin) {
+                                            ChangeOrigin aOrigin) {
   if (!(aResolution > 0.0)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
   if (aResolution == mResolution.valueOr(0.0)) {
     MOZ_ASSERT(mResolution.isSome());
     return NS_OK;
   }
   RenderingState state(this);
   state.mResolution = Some(aResolution);
   SetRenderingState(state);
   if (mMobileViewportManager) {
     mMobileViewportManager->ResolutionUpdated();
   }
-  if (aOrigin != nsGkAtoms::apz) {
+  if (aOrigin != ChangeOrigin::eApz) {
     mResolutionUpdated = true;
   }
   if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
     window->VisualViewport()->PostResizeEvent();
   }
 
   return NS_OK;
 }
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -190,17 +190,18 @@ class PresShell final : public nsIPresSh
       override;
 
   LayerManager* GetLayerManager() override;
 
   bool AsyncPanZoomEnabled() override;
 
   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;
   }
   float GetCumulativeResolution() override;
   float GetCumulativeNonRootScaleResolution() override;
   void SetRestoreResolution(float aResolution,
                             LayoutDeviceIntSize aDisplaySize) override;
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1366,22 +1366,27 @@ class nsIPresShell : public nsStubDocume
    * actually updated.
    *
    * Also increase the scale of the content by the same amount
    * (that's the "AndScaleTo" part).
    *
    * 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;
 
   /**
    * Accessors for a flag that tracks whether the most recent change to
    * the pres shell's resolution was originated by the main thread.
    */
   virtual bool IsResolutionUpdated() const = 0;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -6157,17 +6157,17 @@ void ScrollFrameHelper::RestoreState(Pre
   mLastPos = mScrolledFrame ? GetLogicalScrollPosition() : nsPoint(0, 0);
 
   // Resolution properties should only exist on root scroll frames.
   MOZ_ASSERT(mIsRoot || aState->resolution() == 1.0);
 
   if (mIsRoot) {
     nsIPresShell* presShell = mOuter->PresShell();
     presShell->SetResolutionAndScaleTo(aState->resolution(),
-                                       nsGkAtoms::restore);
+                                       nsIPresShell::ChangeOrigin::eRestore);
   }
 }
 
 void ScrollFrameHelper::PostScrolledAreaEvent() {
   if (mScrolledAreaEvent.IsPending()) {
     return;
   }
   mScrolledAreaEvent = new ScrolledAreaEvent(this);