Bug 1545342 - part 3: Move remaining public enum of nsIPresShell to mozilla namespace in mozilla/PresShellForwards.h and make them enum class r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 25 Apr 2019 05:04:23 +0000
changeset 471241 e73708ef8ebaa3215f8575fede5979d01fa8df10
parent 471240 ac28f88b0c677487f673867a9fa5a0a79b96407f
child 471242 cd4bab29d164a5db77da35c8e803075c7ab52b47
push id35912
push userbtara@mozilla.com
push dateThu, 25 Apr 2019 09:46:25 +0000
treeherdermozilla-central@0ec836eceb96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1545342
milestone68.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 1545342 - part 3: Move remaining public enum of nsIPresShell to mozilla namespace in mozilla/PresShellForwards.h and make them enum class r=smaug This patch moves remaining public `enum` of `nsIPresShell` to `mozilla` namespace in `mozilla/PresShellForwards.h` and make them `enum class`es. Additionally, some methods which use the moving `enum`s from `nsIPresShell` to `PresShell`. Differential Revision: https://phabricator.services.mozilla.com/D28607
dom/base/Document.cpp
dom/base/nsDOMWindowUtils.cpp
dom/canvas/CanvasRenderingContext2D.cpp
dom/events/EventStateManager.cpp
dom/ipc/BrowserChild.cpp
dom/media/webrtc/MediaEngineTabVideoSource.cpp
gfx/ipc/CrossProcessPaint.cpp
gfx/layers/apz/src/FocusTarget.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/thebes/gfxUtils.cpp
image/VectorImage.cpp
layout/base/GeckoMVMContext.cpp
layout/base/PresShell.cpp
layout/base/PresShell.h
layout/base/PresShellForwards.h
layout/base/nsIPresShell.h
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
view/nsViewManager.cpp
widget/android/fennec/ThumbnailHelper.h
widget/nsBaseDragService.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -10506,18 +10506,18 @@ void Document::CleanupFullscreenState() 
     }
   }
   mFullscreenStack.Clear();
   mFullscreenRoot = nullptr;
 
   // Restore the zoom level that was in place prior to entering fullscreen.
   if (PresShell* presShell = GetPresShell()) {
     if (presShell->GetMobileViewportManager()) {
-      presShell->SetResolutionAndScaleTo(
-          mSavedResolution, nsIPresShell::ChangeOrigin::eMainThread);
+      presShell->SetResolutionAndScaleTo(mSavedResolution,
+                                         ResolutionChangeOrigin::MainThread);
     }
   }
 
   UpdateViewportScrollbarOverrideForFullscreen(this);
 }
 
 bool Document::FullscreenStackPush(Element* aElement) {
   NS_ASSERTION(aElement, "Must pass non-null to FullscreenStackPush()");
@@ -10905,17 +10905,17 @@ bool Document::ApplyFullscreen(UniquePtr
     // when in fullscreen mode.
     if (PresShell* presShell = child->GetPresShell()) {
       if (RefPtr<MobileViewportManager> manager =
               presShell->GetMobileViewportManager()) {
         // Save the previous resolution so it can be restored.
         child->mSavedResolution = presShell->GetResolution();
         presShell->SetResolutionAndScaleTo(
             manager->ComputeIntrinsicResolution(),
-            nsIPresShell::ChangeOrigin::eMainThread);
+            ResolutionChangeOrigin::MainThread);
       }
     }
 
     NS_ASSERTION(child->GetFullscreenRoot() == fullScreenRootDoc,
                  "Fullscreen root should be set!");
     if (child == fullScreenRootDoc) {
       break;
     }
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -378,17 +378,17 @@ nsDOMWindowUtils::UpdateLayerTree() {
     presShell->FlushPendingNotifications(
         ChangesToFlush(FlushType::Display, false /* flush animations */));
     RefPtr<nsViewManager> vm = presShell->GetViewManager();
     nsView* view = vm->GetRootView();
     if (view) {
       nsAutoScriptBlocker scriptBlocker;
       presShell->Paint(
           view, view->GetBounds(),
-          nsIPresShell::PAINT_LAYERS | nsIPresShell::PAINT_SYNC_DECODE_IMAGES);
+          PaintFlags::PaintLayers | PaintFlags::PaintSyncDecodeImages);
       presShell->GetLayerManager()->WaitOnTransactionProcessed();
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetContentViewerSize(uint32_t* aDisplayWidth,
@@ -563,17 +563,17 @@ nsDOMWindowUtils::SetDisplayPortBaseForE
 NS_IMETHODIMP
 nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution) {
   PresShell* presShell = GetPresShell();
   if (!presShell) {
     return NS_ERROR_FAILURE;
   }
 
   presShell->SetResolutionAndScaleTo(aResolution,
-                                     nsIPresShell::ChangeOrigin::eMainThread);
+                                     ResolutionChangeOrigin::MainThread);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SetRestoreResolution(float aResolution,
                                        uint32_t aDisplayWidth,
                                        uint32_t aDisplayHeight) {
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4661,34 +4661,35 @@ void CanvasRenderingContext2D::DrawWindo
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   nsRect r(nsPresContext::CSSPixelsToAppUnits((float)aX),
            nsPresContext::CSSPixelsToAppUnits((float)aY),
            nsPresContext::CSSPixelsToAppUnits((float)aW),
            nsPresContext::CSSPixelsToAppUnits((float)aH));
-  uint32_t renderDocFlags = (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
-                             nsIPresShell::RENDER_DOCUMENT_RELATIVE);
+  RenderDocumentFlags renderDocFlags =
+      (RenderDocumentFlags::IgnoreViewportScrolling |
+       RenderDocumentFlags::DocumentRelative);
   if (aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_DRAW_CARET) {
-    renderDocFlags |= nsIPresShell::RENDER_CARET;
+    renderDocFlags |= RenderDocumentFlags::DrawCaret;
   }
   if (aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_DRAW_VIEW) {
-    renderDocFlags &= ~(nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
-                        nsIPresShell::RENDER_DOCUMENT_RELATIVE);
+    renderDocFlags &= ~(RenderDocumentFlags::IgnoreViewportScrolling |
+                        RenderDocumentFlags::DocumentRelative);
   }
   if (aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_USE_WIDGET_LAYERS) {
-    renderDocFlags |= nsIPresShell::RENDER_USE_WIDGET_LAYERS;
+    renderDocFlags |= RenderDocumentFlags::UseWidgetLayers;
   }
   if (aFlags &
       CanvasRenderingContext2D_Binding::DRAWWINDOW_ASYNC_DECODE_IMAGES) {
-    renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
+    renderDocFlags |= RenderDocumentFlags::AsyncDecodeImages;
   }
   if (aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_DO_NOT_FLUSH) {
-    renderDocFlags |= nsIPresShell::RENDER_DRAWWINDOW_NOT_FLUSHING;
+    renderDocFlags |= RenderDocumentFlags::DrawWindowNotFlushing;
   }
 
   // gfxContext-over-Azure may modify the DrawTarget's transform, so
   // save and restore it
   Matrix matrix = mTarget->GetTransform();
   double sw = matrix._11 * aW;
   double sh = matrix._22 * aH;
   if (!sw || !sh) {
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -5685,17 +5685,17 @@ nsresult EventStateManager::DoContentCom
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
 
   aEvent->mSucceeded = true;
 
   nsIScrollableFrame* sf =
-      presShell->GetScrollableFrameToScroll(nsIPresShell::eEither);
+      presShell->GetScrollableFrameToScroll(ScrollableDirection::Either);
   aEvent->mIsEnabled =
       sf ? (aEvent->mScroll.mIsHorizontal ? WheelHandlingUtils::CanScrollOn(
                                                 sf, aEvent->mScroll.mAmount, 0)
                                           : WheelHandlingUtils::CanScrollOn(
                                                 sf, 0, aEvent->mScroll.mAmount))
          : false;
 
   if (!aEvent->mIsEnabled || aEvent->mOnlyEnabledCheck) {
--- a/dom/ipc/BrowserChild.cpp
+++ b/dom/ipc/BrowserChild.cpp
@@ -2491,17 +2491,17 @@ mozilla::ipc::IPCResult BrowserChild::Re
       // that we only paint what's visible. This ensures that the tab we're
       // switching to paints as quickly as possible.
       presShell->SuppressDisplayport(true);
       if (nsContentUtils::IsSafeToRunScript()) {
         WebWidget()->PaintNowIfNeeded();
       } else {
         RefPtr<nsViewManager> vm = presShell->GetViewManager();
         if (nsView* view = vm->GetRootView()) {
-          presShell->Paint(view, view->GetBounds(), nsIPresShell::PAINT_LAYERS);
+          presShell->Paint(view, view->GetBounds(), PaintFlags::PaintLayers);
         }
       }
       presShell->SuppressDisplayport(false);
     }
   } else {
     if (sVisibleTabs) {
       sVisibleTabs->RemoveEntry(this);
       // We don't delete sVisibleTabs here when it's empty since that
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -347,20 +347,20 @@ void MediaEngineTabVideoSource::Draw() {
     if (mWindow) {
       RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
       MOZ_ASSERT(context);  // already checked the draw target above
       context->SetMatrix(context->CurrentMatrix().PreScale(
           (((float)size.width) / mViewportWidth),
           (((float)size.height) / mViewportHeight)));
 
       nscolor bgColor = NS_RGB(255, 255, 255);
-      uint32_t renderDocFlags =
-          mScrollWithPage ? 0
-                          : (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
-                             nsIPresShell::RENDER_DOCUMENT_RELATIVE);
+      RenderDocumentFlags renderDocFlags =
+          mScrollWithPage ? RenderDocumentFlags::None
+                          : (RenderDocumentFlags::IgnoreViewportScrolling |
+                             RenderDocumentFlags::DocumentRelative);
       nsRect r(nsPresContext::CSSPixelsToAppUnits((float)mViewportOffsetX),
                nsPresContext::CSSPixelsToAppUnits((float)mViewportOffsetY),
                nsPresContext::CSSPixelsToAppUnits((float)mViewportWidth),
                nsPresContext::CSSPixelsToAppUnits((float)mViewportHeight));
       NS_ENSURE_SUCCESS_VOID(
           presShell->RenderDocument(r, renderDocFlags, bgColor, context));
     } else {
       dt->ClearRect(Rect(0, 0, size.width, size.height));
--- a/gfx/ipc/CrossProcessPaint.cpp
+++ b/gfx/ipc/CrossProcessPaint.cpp
@@ -94,17 +94,18 @@ PaintFragment PaintFragment::Record(nsID
     nsRect r(nsPresContext::CSSPixelsToAppUnits(aRect.x),
              nsPresContext::CSSPixelsToAppUnits(aRect.y),
              nsPresContext::CSSPixelsToAppUnits(aRect.width),
              nsPresContext::CSSPixelsToAppUnits(aRect.height));
 
     RefPtr<gfxContext> thebes = gfxContext::CreateOrNull(dt);
     thebes->SetMatrix(Matrix::Scaling(aScale, aScale));
     RefPtr<PresShell> presShell = presContext->PresShell();
-    Unused << presShell->RenderDocument(r, 0, aBackgroundColor, thebes);
+    Unused << presShell->RenderDocument(r, RenderDocumentFlags::None,
+                                        aBackgroundColor, thebes);
   }
 
   ByteBuf recording = ByteBuf((uint8_t*)recorder->mOutputStream.mData,
                               recorder->mOutputStream.mLength,
                               recorder->mOutputStream.mCapacity);
   recorder->mOutputStream.mData = nullptr;
   recorder->mOutputStream.mLength = 0;
   recorder->mOutputStream.mCapacity = 0;
--- a/gfx/layers/apz/src/FocusTarget.cpp
+++ b/gfx/layers/apz/src/FocusTarget.cpp
@@ -204,20 +204,20 @@ FocusTarget::FocusTarget(PresShell* aRoo
 
   nsCOMPtr<nsIContent> selectedContent =
       presShell->GetSelectedContentForScrolling();
 
   // Gather the scrollable frames that would be scrolled in each direction
   // for this scroll target
   nsIScrollableFrame* horizontal =
       presShell->GetScrollableFrameToScrollForContent(
-          selectedContent.get(), nsIPresShell::eHorizontal);
+          selectedContent.get(), ScrollableDirection::Horizontal);
   nsIScrollableFrame* vertical =
-      presShell->GetScrollableFrameToScrollForContent(selectedContent.get(),
-                                                      nsIPresShell::eVertical);
+      presShell->GetScrollableFrameToScrollForContent(
+          selectedContent.get(), ScrollableDirection::Vertical);
 
   // We might have the globally focused element for scrolling. Gather a ViewID
   // for the horizontal and vertical scroll targets of this element.
   ScrollTargets target;
   target.mHorizontal = nsLayoutUtils::FindIDForScrollableFrame(horizontal);
   target.mVertical = nsLayoutUtils::FindIDForScrollableFrame(vertical);
   if (XRE_IsContentProcess()) {
     target.mHorizontalRenderRoot = gfxUtils::GetContentRenderRoot();
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -332,17 +332,17 @@ void APZCCallbackHelper::UpdateRootFrame
       return;
     }
 
     // The pres shell resolution is updated by the the async zoom since the
     // last paint.
     presShellResolution =
         aRequest.GetPresShellResolution() * aRequest.GetAsyncZoom().scale;
     presShell->SetResolutionAndScaleTo(presShellResolution,
-                                       nsIPresShell::ChangeOrigin::eApz);
+                                       ResolutionChangeOrigin::Apz);
   }
 
   // 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(presShell, content, displayPortMargins,
                         aRequest.CalculateCompositedSizeInCssPixels());
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1236,17 +1236,18 @@ void gfxUtils::WriteAsPNG(nsIPresShell* 
 
   RefPtr<mozilla::gfx::DrawTarget> dt =
       gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
           IntSize(width, height), SurfaceFormat::B8G8R8A8);
   NS_ENSURE_TRUE(dt && dt->IsValid(), /*void*/);
 
   RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
   MOZ_ASSERT(context);  // already checked the draw target above
-  aShell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context);
+  aShell->RenderDocument(r, RenderDocumentFlags::None, NS_RGB(255, 255, 0),
+                         context);
   WriteAsPNG(dt.get(), aFile);
 }
 
 /* static */
 void gfxUtils::DumpAsDataURI(SourceSurface* aSurface, FILE* aFile) {
   EncodeSourceSurface(aSurface, ImageType::PNG, EmptyString(), eDataURIEncode,
                       aFile);
 }
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -292,19 +292,20 @@ bool SVGDrawingCallback::operator()(gfxC
           double(mSize.height) / mViewportSize.height));
 
   nsPresContext* presContext = presShell->GetPresContext();
   MOZ_ASSERT(presContext, "pres shell w/out pres context");
 
   nsRect svgRect(0, 0, presContext->DevPixelsToAppUnits(mViewportSize.width),
                  presContext->DevPixelsToAppUnits(mViewportSize.height));
 
-  uint32_t renderDocFlags = nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING;
+  RenderDocumentFlags renderDocFlags =
+      RenderDocumentFlags::IgnoreViewportScrolling;
   if (!(mImageFlags & imgIContainer::FLAG_SYNC_DECODE)) {
-    renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
+    renderDocFlags |= RenderDocumentFlags::AsyncDecodeImages;
   }
 
   presShell->RenderDocument(svgRect, renderDocFlags,
                             NS_RGBA(0, 0, 0, 0),  // transparent
                             aContext);
 
   return true;
 }
--- a/layout/base/GeckoMVMContext.cpp
+++ b/layout/base/GeckoMVMContext.cpp
@@ -122,17 +122,17 @@ Maybe<LayoutDeviceIntSize> GeckoMVMConte
 bool GeckoMVMContext::AllowZoomingForDocument() const {
   MOZ_ASSERT(mDocument);
   return nsLayoutUtils::AllowZoomingForDocument(mDocument);
 }
 
 void GeckoMVMContext::SetResolutionAndScaleTo(float aResolution) {
   MOZ_ASSERT(mPresShell);
   mPresShell->SetResolutionAndScaleTo(aResolution,
-                                      nsIPresShell::ChangeOrigin::eMainThread);
+                                      ResolutionChangeOrigin::MainThread);
 }
 
 void GeckoMVMContext::SetVisualViewportSize(const CSSSize& aSize) {
   MOZ_ASSERT(mPresShell);
   nsLayoutUtils::SetVisualViewportSize(mPresShell, aSize);
 }
 
 void GeckoMVMContext::UpdateDisplayPortMargins() {
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -2245,17 +2245,18 @@ PresShell::IntraLineMove(bool aForward, 
   RefPtr<nsFrameSelection> frameSelection = mSelection;
   return frameSelection->IntraLineMove(aForward, aExtend);
 }
 
 NS_IMETHODIMP
 PresShell::PageMove(bool aForward, bool aExtend) {
   nsIFrame* frame = nullptr;
   if (!aExtend) {
-    frame = do_QueryFrame(GetScrollableFrameToScroll(nsIPresShell::eVertical));
+    frame = do_QueryFrame(
+        GetScrollableFrameToScroll(ScrollableDirection::Vertical));
     // If there is no scrollable frame, get the frame to move caret instead.
   }
   if (!frame) {
     frame = mSelection->GetFrameToPageSelect();
     if (!frame) {
       return NS_OK;
     }
   }
@@ -2268,62 +2269,62 @@ PresShell::PageMove(bool aForward, bool 
       nsISelectionController::SELECTION_FOCUS_REGION,
       nsISelectionController::SCROLL_SYNCHRONOUS |
           nsISelectionController::SCROLL_FOR_CARET_MOVE);
 }
 
 NS_IMETHODIMP
 PresShell::ScrollPage(bool aForward) {
   nsIScrollableFrame* scrollFrame =
-      GetScrollableFrameToScroll(nsIPresShell::eVertical);
+      GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
     scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
                           nsIScrollableFrame::PAGES, ScrollMode::eSmooth,
                           nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::ScrollLine(bool aForward) {
   nsIScrollableFrame* scrollFrame =
-      GetScrollableFrameToScroll(nsIPresShell::eVertical);
+      GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
     int32_t lineCount =
         Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
                             NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
     scrollFrame->ScrollBy(nsIntPoint(0, aForward ? lineCount : -lineCount),
                           nsIScrollableFrame::LINES, ScrollMode::eSmooth,
                           nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::ScrollCharacter(bool aRight) {
   nsIScrollableFrame* scrollFrame =
-      GetScrollableFrameToScroll(nsIPresShell::eHorizontal);
+      GetScrollableFrameToScroll(ScrollableDirection::Horizontal);
   if (scrollFrame) {
     int32_t h =
         Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
                             NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
     scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0),
                           nsIScrollableFrame::LINES, ScrollMode::eSmooth,
                           nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::CompleteScroll(bool aForward) {
   nsIScrollableFrame* scrollFrame =
-      GetScrollableFrameToScroll(nsIPresShell::eVertical);
+      GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
     scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
                           nsIScrollableFrame::WHOLE, ScrollMode::eSmooth,
                           nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
@@ -2763,28 +2764,29 @@ already_AddRefed<nsIContent> nsIPresShel
       selectedContent =
           nsIContent::FromNodeOrNull(domSelection->GetFocusNode());
     }
   }
   return selectedContent.forget();
 }
 
 nsIScrollableFrame* nsIPresShell::GetNearestScrollableFrame(
-    nsIFrame* aFrame, nsIPresShell::ScrollDirection aDirection) {
-  if (aDirection == nsIPresShell::eEither) {
+    nsIFrame* aFrame, ScrollableDirection aDirection) {
+  if (aDirection == ScrollableDirection::Either) {
     return nsLayoutUtils::GetNearestScrollableFrame(aFrame);
   }
 
   return nsLayoutUtils::GetNearestScrollableFrameForDirection(
-      aFrame, aDirection == eVertical ? nsLayoutUtils::eVertical
-                                      : nsLayoutUtils::eHorizontal);
+      aFrame, aDirection == ScrollableDirection::Vertical
+                  ? nsLayoutUtils::eVertical
+                  : nsLayoutUtils::eHorizontal);
 }
 
 nsIScrollableFrame* nsIPresShell::GetScrollableFrameToScrollForContent(
-    nsIContent* aContent, nsIPresShell::ScrollDirection aDirection) {
+    nsIContent* aContent, ScrollableDirection aDirection) {
   nsIScrollableFrame* scrollFrame = nullptr;
   if (aContent) {
     nsIFrame* startFrame = aContent->GetPrimaryFrame();
     if (startFrame) {
       scrollFrame = startFrame->GetScrollTargetFrame();
       if (scrollFrame) {
         startFrame = scrollFrame->GetScrolledFrame();
       }
@@ -2798,17 +2800,17 @@ nsIScrollableFrame* nsIPresShell::GetScr
     }
     scrollFrame =
         GetNearestScrollableFrame(scrollFrame->GetScrolledFrame(), aDirection);
   }
   return scrollFrame;
 }
 
 nsIScrollableFrame* nsIPresShell::GetScrollableFrameToScroll(
-    nsIPresShell::ScrollDirection aDirection) {
+    ScrollableDirection aDirection) {
   nsCOMPtr<nsIContent> content = GetContentForScrolling();
   return GetScrollableFrameToScrollForContent(content.get(), aDirection);
 }
 
 void nsIPresShell::CancelAllPendingReflows() {
   mDirtyRoots.Clear();
 
   if (mObservingLayoutFlushes) {
@@ -3660,17 +3662,17 @@ RectVisibility PresShell::GetRectVisibil
   return RectVisibility::Visible;
 }
 
 void PresShell::ScheduleViewManagerFlush(PaintType aType) {
   if (MOZ_UNLIKELY(mIsDestroying)) {
     return;
   }
 
-  if (aType == PAINT_DELAYED_COMPRESS) {
+  if (aType == PaintType::DelayedCompress) {
     // Delay paint for 1 second.
     static const uint32_t kPaintDelayPeriod = 1000;
     if (!mDelayedPaintTimer) {
       nsTimerCallbackFunc PaintTimerCallBack = [](nsITimer* aTimer,
                                                   void* aClosure) {
         // The passed-in PresShell is always alive here. Because if PresShell
         // died, mDelayedPaintTimer->Cancel() would be called during the
         // destruction and this callback would never be invoked.
@@ -4416,20 +4418,22 @@ void PresShell::ReconstructFrames() {
     return;
   }
 
   nsAutoCauseReflowNotifier crNotifier(this);
   mFrameConstructor->ReconstructDocElementHierarchy(
       nsCSSFrameConstructor::InsertionKind::Sync);
 }
 
-nsresult PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
+nsresult PresShell::RenderDocument(const nsRect& aRect,
+                                   RenderDocumentFlags aFlags,
                                    nscolor aBackgroundColor,
                                    gfxContext* aThebesContext) {
-  NS_ENSURE_TRUE(!(aFlags & RENDER_IS_UNTRUSTED), NS_ERROR_NOT_IMPLEMENTED);
+  NS_ENSURE_TRUE(!(aFlags & RenderDocumentFlags::IsUntrusted),
+                 NS_ERROR_NOT_IMPLEMENTED);
 
   nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext();
   if (rootPresContext) {
     rootPresContext->FlushWillPaintObservers();
     if (mIsDestroying) return NS_OK;
   }
 
   nsAutoScriptBlocker blockScripts;
@@ -4477,47 +4481,47 @@ nsresult PresShell::RenderDocument(const
 
   AutoSaveRestoreRenderingState _(this);
 
   bool wouldFlushRetainedLayers = false;
   PaintFrameFlags flags = PaintFrameFlags::PAINT_IGNORE_SUPPRESSION;
   if (aThebesContext->CurrentMatrix().HasNonIntegerTranslation()) {
     flags |= PaintFrameFlags::PAINT_IN_TRANSFORM;
   }
-  if (!(aFlags & RENDER_ASYNC_DECODE_IMAGES)) {
+  if (!(aFlags & RenderDocumentFlags::AsyncDecodeImages)) {
     flags |= PaintFrameFlags::PAINT_SYNC_DECODE_IMAGES;
   }
-  if (aFlags & RENDER_USE_WIDGET_LAYERS) {
+  if (aFlags & RenderDocumentFlags::UseWidgetLayers) {
     // We only support using widget layers on display root's with widgets.
     nsView* view = rootFrame->GetView();
     if (view && view->GetWidget() &&
         nsLayoutUtils::GetDisplayRootFrame(rootFrame) == rootFrame) {
       LayerManager* layerManager = view->GetWidget()->GetLayerManager();
       // ClientLayerManagers or WebRenderLayerManagers in content processes
       // don't support taking snapshots.
       if (layerManager &&
           (!layerManager->AsKnowsCompositor() || XRE_IsParentProcess())) {
         flags |= PaintFrameFlags::PAINT_WIDGET_LAYERS;
       }
     }
   }
-  if (!(aFlags & RENDER_CARET)) {
+  if (!(aFlags & RenderDocumentFlags::DrawCaret)) {
     wouldFlushRetainedLayers = true;
     flags |= PaintFrameFlags::PAINT_HIDE_CARET;
   }
-  if (aFlags & RENDER_IGNORE_VIEWPORT_SCROLLING) {
+  if (aFlags & RenderDocumentFlags::IgnoreViewportScrolling) {
     wouldFlushRetainedLayers = !IgnoringViewportScrolling();
     mRenderFlags =
         ChangeFlag(mRenderFlags, true, STATE_IGNORING_VIEWPORT_SCROLLING);
   }
-  if (aFlags & RENDER_DRAWWINDOW_NOT_FLUSHING) {
+  if (aFlags & RenderDocumentFlags::DrawWindowNotFlushing) {
     mRenderFlags =
         ChangeFlag(mRenderFlags, true, STATE_DRAWWINDOW_NOT_FLUSHING);
   }
-  if (aFlags & RENDER_DOCUMENT_RELATIVE) {
+  if (aFlags & RenderDocumentFlags::DocumentRelative) {
     // XXX be smarter about this ... drawWindow might want a rect
     // that's "pretty close" to what our retained layer tree covers.
     // In that case, it wouldn't disturb normal rendering too much,
     // and we should allow it.
     wouldFlushRetainedLayers = true;
     flags |= PaintFrameFlags::PAINT_DOCUMENT_RELATIVE;
   }
 
@@ -4757,38 +4761,38 @@ UniquePtr<RangePaintInfo> PresShell::Cre
 
   return info;
 }
 
 already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
     const nsTArray<UniquePtr<RangePaintInfo>>& aItems, Selection* aSelection,
     const Maybe<CSSIntRegion>& aRegion, nsRect aArea,
     const LayoutDeviceIntPoint aPoint, LayoutDeviceIntRect* aScreenRect,
-    uint32_t aFlags) {
+    RenderImageFlags aFlags) {
   nsPresContext* pc = GetPresContext();
   if (!pc || aArea.width == 0 || aArea.height == 0) return nullptr;
 
   // use the rectangle to create the surface
   nsIntRect pixelArea = aArea.ToOutsidePixels(pc->AppUnitsPerDevPixel());
 
   // if the image should not be resized, scale must be 1
   float scale = 1.0;
   nsIntRect rootScreenRect =
       GetRootFrame()->GetScreenRectInAppUnits().ToNearestPixels(
           pc->AppUnitsPerDevPixel());
 
   nsRect maxSize;
   pc->DeviceContext()->GetClientRect(maxSize);
 
   // check if the image should be resized
-  bool resize = aFlags & RENDER_AUTO_SCALE;
+  bool resize = !!(aFlags & RenderImageFlags::AutoScale);
 
   if (resize) {
     // check if image-resizing-algorithm should be used
-    if (aFlags & RENDER_IS_IMAGE) {
+    if (aFlags & RenderImageFlags::IsImage) {
       // get max screensize
       nscoord maxWidth = pc->AppUnitsToDevPixels(maxSize.width);
       nscoord maxHeight = pc->AppUnitsToDevPixels(maxSize.height);
       // resize image relative to the screensize
       // get best height/width relative to screensize
       float bestHeight = float(maxHeight) * RELATIVE_SCALEFACTOR;
       float bestWidth = float(maxWidth) * RELATIVE_SCALEFACTOR;
       // calculate scale for bestWidth
@@ -4904,17 +4908,17 @@ already_AddRefed<SourceSurface> PresShel
   frameSelection->SetDisplaySelection(oldDisplaySelection);
 
   return dt->Snapshot();
 }
 
 already_AddRefed<SourceSurface> PresShell::RenderNode(
     nsINode* aNode, const Maybe<CSSIntRegion>& aRegion,
     const LayoutDeviceIntPoint aPoint, LayoutDeviceIntRect* aScreenRect,
-    uint32_t aFlags) {
+    RenderImageFlags aFlags) {
   // area will hold the size of the surface needed to draw the node, measured
   // from the root frame.
   nsRect area;
   nsTArray<UniquePtr<RangePaintInfo>> rangeItems;
 
   // nothing to draw if the node isn't in a document
   if (!aNode->IsInComposedDoc()) {
     return nullptr;
@@ -4950,17 +4954,17 @@ already_AddRefed<SourceSurface> PresShel
   }
 
   return PaintRangePaintInfo(rangeItems, nullptr, region, area, aPoint,
                              aScreenRect, aFlags);
 }
 
 already_AddRefed<SourceSurface> PresShell::RenderSelection(
     Selection* aSelection, const LayoutDeviceIntPoint aPoint,
-    LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) {
+    LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags) {
   // area will hold the size of the surface needed to draw the selection,
   // measured from the root frame.
   nsRect area;
   nsTArray<UniquePtr<RangePaintInfo>> rangeItems;
 
   // iterate over each range and collect them into the rangeItems array.
   // This is done so that the size of selection can be determined so as
   // to allocate a surface area
@@ -5012,41 +5016,43 @@ static bool AddCanvasBackgroundColor(con
                                  aCSSBackgroundColor))
       return true;
   }
   return false;
 }
 
 void PresShell::AddCanvasBackgroundColorItem(
     nsDisplayListBuilder& aBuilder, nsDisplayList& aList, nsIFrame* aFrame,
-    const nsRect& aBounds, nscolor aBackstopColor, uint32_t aFlags) {
+    const nsRect& aBounds, nscolor aBackstopColor,
+    AddCanvasBackgroundColorFlags aFlags) {
   if (aBounds.IsEmpty()) {
     return;
   }
   // We don't want to add an item for the canvas background color if the frame
   // (sub)tree we are painting doesn't include any canvas frames. There isn't
   // an easy way to check this directly, but if we check if the root of the
   // (sub)tree we are painting is a canvas frame that should cover us in all
   // cases (it will usually be a viewport frame when we have a canvas frame in
   // the (sub)tree).
-  if (!(aFlags & nsIPresShell::FORCE_DRAW) &&
+  if (!(aFlags & AddCanvasBackgroundColorFlags::ForceDraw) &&
       !nsCSSRendering::IsCanvasFrame(aFrame)) {
     return;
   }
 
   nscolor bgcolor = NS_ComposeColors(aBackstopColor, mCanvasBackgroundColor);
   if (NS_GET_A(bgcolor) == 0) return;
 
   // To make layers work better, we want to avoid having a big non-scrolled
   // color background behind a scrolled transparent background. Instead,
   // we'll try to move the color background into the scrolled content
   // by making nsDisplayCanvasBackground paint it.
   // If we're only adding an unscrolled item, then pretend that we've
   // already done it.
-  bool addedScrollingBackgroundColor = (aFlags & APPEND_UNSCROLLED_ONLY);
+  bool addedScrollingBackgroundColor =
+      !!(aFlags & AddCanvasBackgroundColorFlags::AppendUnscrolledOnly);
   if (!aFrame->GetParent() && !addedScrollingBackgroundColor) {
     nsIScrollableFrame* sf =
         aFrame->PresShell()->GetRootScrollFrameAsScrollable();
     if (sf) {
       nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
       if (canvasFrame && canvasFrame->IsVisibleForPainting()) {
         addedScrollingBackgroundColor = AddCanvasBackgroundColor(
             aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
@@ -5056,17 +5062,17 @@ void PresShell::AddCanvasBackgroundColor
 
   // With async scrolling, we'd like to have two instances of the background
   // color: one that scrolls with the content (for the reasons stated above),
   // and one underneath which does not scroll with the content, but which can
   // be shown during checkerboarding and overscroll.
   // We can only do that if the color is opaque.
   bool forceUnscrolledItem =
       nsLayoutUtils::UsesAsyncScrolling(aFrame) && NS_GET_A(bgcolor) == 255;
-  if ((aFlags & ADD_FOR_SUBDOC) &&
+  if ((aFlags & AddCanvasBackgroundColorFlags::AddForSubDocument) &&
       gfxPrefs::LayoutUseContainersForRootFrames()) {
     // If we're using ContainerLayers for a subdoc, then any items we add here
     // will still be scrolled (since we're inside the container at this point),
     // so don't bother and we will do it manually later.
     forceUnscrolledItem = false;
   }
 
   if (!addedScrollingBackgroundColor || forceUnscrolledItem) {
@@ -5186,31 +5192,31 @@ void PresShell::SetIgnoreViewportScrolli
   }
   RenderingState state(this);
   state.mRenderFlags = ChangeFlag(state.mRenderFlags, aIgnore,
                                   STATE_IGNORING_VIEWPORT_SCROLLING);
   SetRenderingState(state);
 }
 
 nsresult PresShell::SetResolutionAndScaleTo(float aResolution,
-                                            ChangeOrigin aOrigin) {
+                                            ResolutionChangeOrigin 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 == ChangeOrigin::eApz) {
+  if (aOrigin == ResolutionChangeOrigin::Apz) {
     mResolutionUpdatedByApz = true;
   } else {
     mResolutionUpdated = true;
   }
 
   if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
     window->VisualViewport()->PostResizeEvent();
   }
@@ -5890,31 +5896,31 @@ void PresShell::RemoveFrameFromApproxima
     // aFrame was in the hashtable, and we're still tracking its visibility,
     // so we need to decrement its visible count.
     aFrame->DecApproximateVisibleCount();
   }
 }
 
 class nsAutoNotifyDidPaint {
  public:
-  nsAutoNotifyDidPaint(PresShell* aShell, uint32_t aFlags)
+  nsAutoNotifyDidPaint(PresShell* aShell, PaintFlags aFlags)
       : mShell(aShell), mFlags(aFlags) {}
   ~nsAutoNotifyDidPaint() {
-    if (mFlags & nsIPresShell::PAINT_COMPOSITE) {
+    if (!!(mFlags & PaintFlags::PaintComposite)) {
       mShell->GetPresContext()->NotifyDidPaintForSubtree();
     }
   }
 
  private:
   PresShell* mShell;
-  uint32_t mFlags;
+  PaintFlags mFlags;
 };
 
 void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
-                      uint32_t aFlags) {
+                      PaintFlags aFlags) {
   nsCString url;
   nsIURI* uri = mDocument->GetDocumentURI();
   Document* contentRoot = GetPrimaryContentDocument();
   if (contentRoot) {
     uri = contentRoot->GetDocumentURI();
   }
   url = uri ? uri->GetSpecOrDefault() : NS_LITERAL_CSTRING("N/A");
 #ifdef MOZ_GECKO_PROFILER
@@ -5922,17 +5928,17 @@ void PresShell::Paint(nsView* aViewToPai
 #endif
 
   Maybe<js::AutoAssertNoContentJS> nojs;
 
   // On Android, Flash can call into content JS during painting, so we can't
   // assert there. However, we don't rely on this assertion on Android because
   // we don't paint while JS is running.
 #if !defined(MOZ_WIDGET_ANDROID)
-  if (!(aFlags & nsIPresShell::PAINT_COMPOSITE)) {
+  if (!(aFlags & PaintFlags::PaintComposite)) {
     // We need to allow content JS when the flag is set since we may trigger
     // MozAfterPaint events in content in those cases.
     nojs.emplace(dom::danger::GetJSContext());
   }
 #endif
 
   NS_ASSERTION(!mIsDestroying, "painting a destroyed PresShell");
   NS_ASSERTION(aViewToPaint, "null view");
@@ -5982,24 +5988,24 @@ void PresShell::Paint(nsView* aViewToPai
   if (frame) {
     // Try to do an empty transaction, if the frame tree does not
     // need to be updated. Do not try to do an empty transaction on
     // a non-retained layer manager (like the BasicLayerManager that
     // draws the window title bar on Mac), because a) it won't work
     // and b) below we don't want to clear NS_FRAME_UPDATE_LAYER_TREE,
     // that will cause us to forget to update the real layer manager!
 
-    if (!(aFlags & PAINT_LAYERS)) {
+    if (!(aFlags & PaintFlags::PaintLayers)) {
       if (layerManager->EndEmptyTransaction()) {
         return;
       }
       NS_WARNING("Must complete empty transaction when compositing!");
     }
 
-    if (!(aFlags & PAINT_SYNC_DECODE_IMAGES) &&
+    if (!(aFlags & PaintFlags::PaintSyncDecodeImages) &&
         !(frame->GetStateBits() & NS_FRAME_UPDATE_LAYER_TREE) &&
         !mNextPaintCompressed) {
       NotifySubDocInvalidationFunc computeInvalidFunc =
           presContext->MayHavePaintEventListenerInSubDocument()
               ? nsPresContext::NotifySubDocInvalidation
               : 0;
       bool computeInvalidRect =
           computeInvalidFunc ||
@@ -6011,18 +6017,19 @@ void PresShell::Paint(nsView* aViewToPai
       // and crashes.
       if (computeInvalidRect && layerManager->GetRoot()) {
         props = LayerProperties::CloneFrom(layerManager->GetRoot());
       }
 
       MaybeSetupTransactionIdAllocator(layerManager, presContext);
 
       if (layerManager->EndEmptyTransaction(
-              (aFlags & PAINT_COMPOSITE) ? LayerManager::END_DEFAULT
-                                         : LayerManager::END_NO_COMPOSITE)) {
+              (aFlags & PaintFlags::PaintComposite)
+                  ? LayerManager::END_DEFAULT
+                  : LayerManager::END_NO_COMPOSITE)) {
         nsIntRegion invalid;
         bool areaOverflowed = false;
         if (props) {
           if (!props->ComputeDifferences(layerManager->GetRoot(), invalid,
                                          computeInvalidFunc)) {
             areaOverflowed = true;
           }
         } else {
@@ -6054,20 +6061,20 @@ void PresShell::Paint(nsView* aViewToPai
   }
   if (frame) {
     frame->ClearPresShellsFromLastPaint();
   }
 
   nscolor bgcolor = ComputeBackstopColor(aViewToPaint);
   PaintFrameFlags flags = PaintFrameFlags::PAINT_WIDGET_LAYERS |
                           PaintFrameFlags::PAINT_EXISTING_TRANSACTION;
-  if (!(aFlags & PAINT_COMPOSITE)) {
+  if (!(aFlags & PaintFlags::PaintComposite)) {
     flags |= PaintFrameFlags::PAINT_NO_COMPOSITE;
   }
-  if (aFlags & PAINT_SYNC_DECODE_IMAGES) {
+  if (aFlags & PaintFlags::PaintSyncDecodeImages) {
     flags |= PaintFrameFlags::PAINT_SYNC_DECODE_IMAGES;
   }
   if (mNextPaintCompressed) {
     flags |= PaintFrameFlags::PAINT_COMPRESSED;
     mNextPaintCompressed = false;
   }
   if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
     flags |= PaintFrameFlags::PAINT_FOR_WEBRENDER;
@@ -6110,17 +6117,17 @@ void PresShell::Paint(nsView* aViewToPai
         pc->GetVisibleArea().ToOutsidePixels(pc->AppUnitsPerDevPixel());
     bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
     root->SetColor(Color::FromABGR(bgcolor));
     root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(bounds));
     layerManager->SetRoot(root);
   }
   MaybeSetupTransactionIdAllocator(layerManager, presContext);
   layerManager->EndTransaction(nullptr, nullptr,
-                               (aFlags & PAINT_COMPOSITE)
+                               (aFlags & PaintFlags::PaintComposite)
                                    ? LayerManager::END_DEFAULT
                                    : LayerManager::END_NO_COMPOSITE);
 }
 
 // static
 void PresShell::SetCapturingContent(nsIContent* aContent, CaptureFlags aFlags) {
   // If capture was set for pointer lock, don't unlock unless we are coming
   // out of pointer lock explicitly.
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -135,43 +135,61 @@ class PresShell final : public nsIPresSh
         aTargetContent, aOverrideClickTarget);
   }
 
   void ReconstructFrames(void) override;
   void Freeze() override;
   void Thaw() override;
   void FireOrClearDelayedEvents(bool aFireEvents) override;
 
-  nsresult RenderDocument(const nsRect& aRect, uint32_t aFlags,
+  nsresult RenderDocument(const nsRect& aRect, RenderDocumentFlags aFlags,
                           nscolor aBackgroundColor,
                           gfxContext* aThebesContext) override;
 
   already_AddRefed<SourceSurface> RenderNode(nsINode* aNode,
                                              const Maybe<CSSIntRegion>& aRegion,
                                              const LayoutDeviceIntPoint aPoint,
                                              LayoutDeviceIntRect* aScreenRect,
-                                             uint32_t aFlags) override;
+                                             RenderImageFlags aFlags) override;
 
   already_AddRefed<SourceSurface> RenderSelection(
       dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
-      LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) override;
+      LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags) override;
 
   already_AddRefed<nsPIDOMWindowOuter> GetRootWindow() override;
 
   already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow()
       override;
 
   LayerManager* GetLayerManager() override;
 
   bool AsyncPanZoomEnabled() override;
 
   void SetIgnoreViewportScrolling(bool aIgnore) override;
 
+  /**
+   * Set a "resolution" for the document, which if not 1.0 will
+   * allocate more or fewer pixels for rescalable content by a factor
+   * of |resolution| in both dimensions.  Return NS_OK iff the
+   * resolution bounds are sane, and the resolution of this was
+   * 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 ResolutionChangeOrigin::Apz. For changes sent by
+   * the main thread, use pass ResolutionChangeOrigin::MainThread (similar
+   * to the |aOrigin| parameter of nsIScrollableFrame::ScrollToCSSPixels()).
+   */
   nsresult SetResolutionAndScaleTo(float aResolution,
-                                   ChangeOrigin aOrigin) override;
+                                   ResolutionChangeOrigin aOrigin);
+
   float GetCumulativeResolution() override;
   float GetCumulativeNonRootScaleResolution() override;
   void SetRestoreResolution(float aResolution,
                             LayoutDeviceIntSize aDisplaySize) override;
 
   // Widget notificiations
   void WindowSizeMoveDone() override;
   void SysColorChanged() override { mPresContext->SysColorChanged(); }
@@ -185,39 +203,50 @@ class PresShell final : public nsIPresSh
   Document* GetPrimaryContentDocument() override;
 
   void PausePainting() override;
   void ResumePainting() override;
 
   // nsIViewObserver interface
 
   void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
-             uint32_t aFlags) override;
+             PaintFlags aFlags);
+
   MOZ_CAN_RUN_SCRIPT nsresult HandleEvent(nsIFrame* aFrameForPresShell,
                                           WidgetGUIEvent* aEvent,
                                           bool aDontRetargetEvents,
                                           nsEventStatus* aEventStatus) override;
   nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                     WidgetEvent* aEvent,
                                     nsEventStatus* aStatus) override;
   nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                     dom::Event* aEvent,
                                     nsEventStatus* aStatus) override;
   bool ShouldIgnoreInvalidation() override;
   /**
-   * Notify that we're going to call Paint with PAINT_LAYERS
+   * Notify that we're going to call Paint with PaintFlags::PaintLayers
    * on the pres shell for a widget (which might not be this one, since
    * WillPaint is called on all presshells in the same toplevel window as the
    * painted widget). This is issued at a time when it's safe to modify
    * widget geometry.
    */
   MOZ_CAN_RUN_SCRIPT void WillPaint();
   void WillPaintWindow() override;
   void DidPaintWindow() override;
-  void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) override;
+
+  /**
+   * Ensures that the refresh driver is running, and schedules a view
+   * manager flush on the next tick.
+   *
+   * @param aType PaintType::DelayedCompress : Schedule a paint to be executed
+   * after a delay, and put FrameLayerBuilder in 'compressed' mode that avoids
+   * short cut optimizations.
+   */
+  void ScheduleViewManagerFlush(PaintType aType = PaintType::Default);
+
   void ClearMouseCaptureOnView(nsView* aView) override;
   bool IsVisible() override;
   void SuppressDisplayport(bool aEnabled) override;
   void RespectDisplayportSuppression(bool aEnabled) override;
   bool IsDisplayportSuppressed() override;
 
   // caret handling
   NS_IMETHOD SetCaretEnabled(bool aInEnable) override;
@@ -288,20 +317,42 @@ class PresShell final : public nsIPresSh
 
   void ListStyleSheets(FILE* out, int32_t aIndent = 0) override;
 #endif
 
   void DisableNonTestMouseEvents(bool aDisable) override;
 
   void UpdateCanvasBackground() override;
 
+  /**
+   * Add a solid color item to the bottom of aList with frame aFrame and bounds
+   * aBounds. Checks first if this needs to be done by checking if aFrame is a
+   * canvas frame (if the AddCanvasBackgroundColorFlags::ForceDraw is passed
+   * then this check is skipped). aBackstopColor is composed behind the
+   * background color of the canvas, it is transparent by default.
+   *
+   * We attempt to make the background color part of the scrolled canvas (to
+   * reduce transparent layers), and if async scrolling is enabled (and the
+   * background is opaque) then we add a second, unscrolled item to handle the
+   * checkerboarding case.
+   *
+   * AddCanvasBackgroundColorFlags::AddSubDocument should be specified when
+   * calling this for a subdocument, and LayoutUseContainersForRootFrame might
+   * cause the whole list to be scrolled. In that case the second unscrolled
+   * item will be elided.
+   *
+   * AddCanvasBackgroundColorFlags::AppendUnscrolledOnly only attempts to add
+   * the unscrolled item, so that we can add it manually after
+   * LayoutUseContainersForRootFrame has built the scrolling ContainerLayer.
+   */
   void AddCanvasBackgroundColorItem(
       nsDisplayListBuilder& aBuilder, nsDisplayList& aList, nsIFrame* aFrame,
       const nsRect& aBounds, nscolor aBackstopColor = NS_RGBA(0, 0, 0, 0),
-      uint32_t aFlags = 0) override;
+      AddCanvasBackgroundColorFlags aFlags =
+          AddCanvasBackgroundColorFlags::None);
 
   void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
                                      nsDisplayList& aList, nsIFrame* aFrame,
                                      const nsRect& aBounds) override;
 
   nscolor ComputeBackstopColor(nsView* aDisplayRoot) override;
 
   nsresult SetIsActive(bool aIsActive) override;
@@ -533,24 +584,24 @@ class PresShell final : public nsIPresSh
    * Paint the items to a new surface and return it.
    *
    * aSelection - selection being painted, if any
    * aRegion - clip region, if any
    * aArea - area that the surface occupies, relative to the root frame
    * aPoint - reference point, typically the mouse position
    * aScreenRect - [out] set to the area of the screen the painted area should
    *               be displayed at
-   * aFlags - set RENDER_AUTO_SCALE to scale down large images, but it must not
-   *          be set if a custom image was specified
+   * aFlags - set RenderImageFlags::AutoScale to scale down large images, but
+   * it must not be set if a custom image was specified
    */
   already_AddRefed<SourceSurface> PaintRangePaintInfo(
       const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
       dom::Selection* aSelection, const Maybe<CSSIntRegion>& aRegion,
       nsRect aArea, const LayoutDeviceIntPoint aPoint,
-      LayoutDeviceIntRect* aScreenRect, uint32_t aFlags);
+      LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);
 
   // Hide a view if it is a popup
   void HideViewIfPopup(nsView* aView);
 
   // Utility method to restore the root scrollframe state
   void RestoreRootScrollPosition();
 
   void MaybeReleaseCapturingContent();
--- a/layout/base/PresShellForwards.h
+++ b/layout/base/PresShellForwards.h
@@ -102,16 +102,73 @@ enum class ScrollFlags {
   ScrollSnap = 1 << 5,
   IgnoreMarginAndPadding = 1 << 6,
   // ScrollOverflowHidden | ScrollNoParentFrames
   AnchorScrollFlags = (1 << 1) | (1 << 2),
 };
 
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollFlags)
 
+enum class ScrollableDirection { Horizontal, Vertical, Either };
+
+// See comment at declaration of RenderDocument() for the detail.
+enum class RenderDocumentFlags {
+  None = 0,
+  IsUntrusted = 1 << 0,
+  IgnoreViewportScrolling = 1 << 1,
+  DrawCaret = 1 << 2,
+  UseWidgetLayers = 1 << 3,
+  AsyncDecodeImages = 1 << 4,
+  DocumentRelative = 1 << 5,
+  DrawWindowNotFlushing = 1 << 6,
+};
+
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderDocumentFlags)
+
+// See comment at declaration of RenderSelection() for the detail.
+enum class RenderImageFlags {
+  None = 0,
+  IsImage = 1 << 0,
+  AutoScale = 1 << 1,
+};
+
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags)
+
+enum class ResolutionChangeOrigin : uint8_t {
+  Apz,
+  MainThread,
+};
+
+// See comment at declaration of AddCanvasBackgroundColorItem() for the detail.
+enum class AddCanvasBackgroundColorFlags {
+  None = 0,
+  ForceDraw = 1 << 0,
+  AddForSubDocument = 1 << 1,
+  AppendUnscrolledOnly = 1 << 2,
+};
+
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AddCanvasBackgroundColorFlags)
+
+enum class PaintFlags {
+  None = 0,
+  /* Update the layer tree and paint PaintedLayers. If this is not specified,
+   * we may still have to do it if the layer tree lost PaintedLayer contents
+   * we need for compositing. */
+  PaintLayers = 1 << 0,
+  /* Composite layers to the window. */
+  PaintComposite = 1 << 1,
+  /* Sync-decode images. */
+  PaintSyncDecodeImages = 1 << 2,
+};
+
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintFlags)
+
+// See comment at declaration of ScheduleViewManagerFlush() for the detail.
+enum class PaintType { Default, DelayedCompress };
+
 #ifdef DEBUG
 
 enum class VerifyReflowFlags {
   None = 0,
   On = 1 << 0,
   Noisy = 1 << 1,
   All = 1 << 2,
   DumpCommands = 1 << 3,
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -380,37 +380,37 @@ class nsIPresShell : public nsStubDocume
   already_AddRefed<nsIContent> GetSelectedContentForScrolling() const;
 
   /**
    * Gets nearest scrollable frame from the specified content node. The frame
    * is scrollable with overflow:scroll or overflow:auto in some direction when
    * aDirection is eEither.  Otherwise, this returns a nearest frame that is
    * scrollable in the specified direction.
    */
-  enum ScrollDirection { eHorizontal, eVertical, eEither };
   nsIScrollableFrame* GetScrollableFrameToScrollForContent(
-      nsIContent* aContent, ScrollDirection aDirection);
+      nsIContent* aContent, mozilla::ScrollableDirection aDirection);
 
   /**
    * Gets nearest scrollable frame from current focused content or DOM
    * selection if there is no focused content. The frame is scrollable with
    * overflow:scroll or overflow:auto in some direction when aDirection is
    * eEither.  Otherwise, this returns a nearest frame that is scrollable in
    * the specified direction.
    */
-  nsIScrollableFrame* GetScrollableFrameToScroll(ScrollDirection aDirection);
+  nsIScrollableFrame* GetScrollableFrameToScroll(
+      mozilla::ScrollableDirection aDirection);
 
   /**
    * Gets nearest ancestor scrollable frame from aFrame.  The frame is
    * scrollable with overflow:scroll or overflow:auto in some direction when
    * aDirection is eEither.  Otherwise, this returns a nearest frame that is
    * scrollable in the specified direction.
    */
-  nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame,
-                                                ScrollDirection aDirection);
+  nsIScrollableFrame* GetNearestScrollableFrame(
+      nsIFrame* aFrame, mozilla::ScrollableDirection aDirection);
 
   /**
    * Returns the page sequence frame associated with the frame hierarchy.
    * Returns nullptr if not a paginated view.
    */
   nsIPageSequenceFrame* GetPageSequenceFrame() const;
 
   /**
@@ -979,90 +979,83 @@ class nsIPresShell : public nsStubDocume
    * Designed for getting a picture of a document or a piece of a document
    * Note that callers will generally want to call FlushPendingNotifications
    * to get an up-to-date view of the document
    * @param aRect is the region to capture into the offscreen buffer, in the
    * root frame's coordinate system (if aIgnoreViewportScrolling is false)
    * or in the root scrolled frame's coordinate system
    * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
    * @param aFlags see below;
-   *   set RENDER_IS_UNTRUSTED if the contents may be passed to malicious
-   * agents. E.g. we might choose not to paint the contents of sensitive widgets
-   * such as the file name in a file upload widget, and we might choose not
-   * to paint themes.
-   *   set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore
-   * clipping and scrollbar painting due to scrolling in the viewport
-   *   set RENDER_CARET to draw the caret if one would be visible
-   * (by default the caret is never drawn)
-   *   set RENDER_USE_LAYER_MANAGER to force rendering to go through
-   * the layer manager for the window. This may be unexpectedly slow
+   *   set RenderDocumentFlags::IsUntrusted if the contents may be passed to
+   * malicious agents. E.g. we might choose not to paint the contents of
+   * sensitive widgets such as the file name in a file upload widget, and we
+   * might choose not to paint themes.
+   *   set RenderDocumentFlags::IgnoreViewportScrolling to ignore clipping and
+   *  scrollbar painting due to scrolling in the viewport
+   *   set RenderDocumentFlags::DrawCaret to draw the caret if one would be
+   *  visible (by default the caret is never drawn)
+   *   set RenderDocumentFlags::UseWidgetLayers to force rendering to go
+   *  through the layer manager for the window. This may be unexpectedly slow
    * (if the layer manager must read back data from the GPU) or low-quality
    * (if the layer manager reads back pixel data and scales it
    * instead of rendering using the appropriate scaling). It may also
    * slow everything down if the area rendered does not correspond to the
    * normal visible area of the window.
-   *   set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously
-   * decoded during rendering.
+   *   set RenderDocumentFlags::AsyncDecodeImages to avoid having images
+   * synchronously decoded during rendering.
    * (by default images decode synchronously with RenderDocument)
-   *   set RENDER_DOCUMENT_RELATIVE to render the document as if there has been
-   * no scrolling and interpret |aRect| relative to the document instead of the
-   * CSS viewport. Only considered if RENDER_IGNORE_VIEWPORT_SCROLLING is set
-   * or the document is in ignore viewport scrolling mode
+   *   set RenderDocumentFlags::DocumentRelative to render the document as if
+   * there has been no scrolling and interpret |aRect| relative to the document
+   * instead of the CSS viewport. Only considered if
+   * RenderDocumentFlags::IgnoreViewportScrolling is set or the document is in
+   * ignore viewport scrolling mode
    * (nsIPresShell::SetIgnoreViewportScrolling/IgnoringViewportScrolling).
    * @param aBackgroundColor a background color to render onto
    * @param aRenderedContext the gfxContext to render to. We render so that
    * one CSS pixel in the source document is rendered to one unit in the current
    * transform.
    */
-  enum {
-    RENDER_IS_UNTRUSTED = 0x01,
-    RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02,
-    RENDER_CARET = 0x04,
-    RENDER_USE_WIDGET_LAYERS = 0x08,
-    RENDER_ASYNC_DECODE_IMAGES = 0x10,
-    RENDER_DOCUMENT_RELATIVE = 0x20,
-    RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40
-  };
-  virtual nsresult RenderDocument(const nsRect& aRect, uint32_t aFlags,
+  virtual nsresult RenderDocument(const nsRect& aRect,
+                                  mozilla::RenderDocumentFlags aFlags,
                                   nscolor aBackgroundColor,
                                   gfxContext* aRenderedContext) = 0;
 
-  enum { RENDER_IS_IMAGE = 0x100, RENDER_AUTO_SCALE = 0x80 };
-
   /**
    * Renders a node aNode to a surface and returns it. The aRegion may be used
    * to clip the rendering. This region is measured in CSS pixels from the
    * edge of the presshell area. The aPoint, aScreenRect and aFlags arguments
    * function in a similar manner as RenderSelection.
    */
   virtual already_AddRefed<mozilla::gfx::SourceSurface> RenderNode(
       nsINode* aNode, const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
       const mozilla::LayoutDeviceIntPoint aPoint,
-      mozilla::LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) = 0;
+      mozilla::LayoutDeviceIntRect* aScreenRect,
+      mozilla::RenderImageFlags aFlags) = 0;
 
   /**
    * Renders a selection to a surface and returns it. This method is primarily
    * intended to create the drag feedback when dragging a selection.
    *
    * aScreenRect will be filled in with the bounding rectangle of the
    * selection area on screen.
    *
-   * If the area of the selection is large and the RENDER_AUTO_SCALE flag is
-   * set, the image will be scaled down. The argument aPoint is used in this
+   * If the area of the selection is large and the RenderImageFlags::AutoScale
+   * is set, the image will be scaled down. The argument aPoint is used in this
    * case as a reference point when determining the new screen rectangle after
    * scaling. Typically, this will be the mouse position, so that the screen
    * rectangle is positioned such that the mouse is over the same point in the
    * scaled image as in the original. When scaling does not occur, the mouse
    * point isn't used because the position can be determined from the displayed
    * frames.
    */
   virtual already_AddRefed<mozilla::gfx::SourceSurface> RenderSelection(
       mozilla::dom::Selection* aSelection,
       const mozilla::LayoutDeviceIntPoint aPoint,
-      mozilla::LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) = 0;
+      mozilla::LayoutDeviceIntRect* aScreenRect,
+      mozilla::RenderImageFlags aFlags) = 0;
 
   void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame);
   void AddWeakFrame(WeakFrame* aWeakFrame);
 
   void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
   void RemoveWeakFrame(WeakFrame* aWeakFrame);
 
 #ifdef DEBUG
@@ -1090,46 +1083,16 @@ class nsIPresShell : public nsStubDocume
 
   /**
    * Use the current frame tree (if it exists) to update the background
    * color of the most recently drawn canvas.
    */
   virtual void UpdateCanvasBackground() = 0;
 
   /**
-   * Add a solid color item to the bottom of aList with frame aFrame and bounds
-   * aBounds. Checks first if this needs to be done by checking if aFrame is a
-   * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped).
-   * aBackstopColor is composed behind the background color of the canvas, it is
-   * transparent by default.
-   *
-   * We attempt to make the background color part of the scrolled canvas (to
-   * reduce transparent layers), and if async scrolling is enabled (and the
-   * background is opaque) then we add a second, unscrolled item to handle the
-   * checkerboarding case.
-   *
-   * ADD_FOR_SUBDOC should be specified when calling this for a subdocument, and
-   * LayoutUseContainersForRootFrame might cause the whole list to be scrolled.
-   * In that case the second unscrolled item will be elided.
-   *
-   * APPEND_UNSCROLLED_ONLY only attempts to add the unscrolled item, so that
-   * we can add it manually after LayoutUseContainersForRootFrame has built the
-   * scrolling ContainerLayer.
-   */
-  enum {
-    FORCE_DRAW = 0x01,
-    ADD_FOR_SUBDOC = 0x02,
-    APPEND_UNSCROLLED_ONLY = 0x04,
-  };
-  virtual void AddCanvasBackgroundColorItem(
-      nsDisplayListBuilder& aBuilder, nsDisplayList& aList, nsIFrame* aFrame,
-      const nsRect& aBounds, nscolor aBackstopColor = NS_RGBA(0, 0, 0, 0),
-      uint32_t aFlags = 0) = 0;
-
-  /**
    * Add a solid color item to the bottom of aList with frame aFrame and
    * bounds aBounds representing the dark grey background behind the page of a
    * print preview presentation.
    */
   virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
                                              nsDisplayList& aList,
                                              nsIFrame* aFrame,
                                              const nsRect& aBounds) = 0;
@@ -1216,39 +1179,16 @@ class nsIPresShell : public nsStubDocume
    * of painting.  If we are ignoring, then layers aren't clipped to
    * the CSS viewport and scrollbars aren't drawn.
    */
   virtual void SetIgnoreViewportScrolling(bool aIgnore) = 0;
   bool IgnoringViewportScrolling() const {
     return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING;
   }
 
-  /**
-   * Set a "resolution" for the document, which if not 1.0 will
-   * allocate more or fewer pixels for rescalable content by a factor
-   * of |resolution| in both dimensions.  Return NS_OK iff the
-   * resolution bounds are sane, and the resolution of this was
-   * 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 ChangeOrigin::eApz. For changes sent by the main thread,
-   * use pass ChangeOrigin::eMainThread (similar to the |aOrigin| parameter of
-   * nsIScrollableFrame::ScrollToCSSPixels()).
-   */
-  enum class ChangeOrigin : uint8_t {
-    eApz,
-    eMainThread,
-  };
-  virtual nsresult SetResolutionAndScaleTo(float aResolution,
-                                           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.
    */
   bool IsResolutionUpdated() const { return mResolutionUpdated; }
@@ -1294,57 +1234,35 @@ class nsIPresShell : public nsStubDocume
 
   /**
    * Dispatch a mouse move event based on the most recent mouse position if
    * this PresShell is visible. This is used when the contents of the page
    * moved (aFromScroll is false) or scrolled (aFromScroll is true).
    */
   virtual void SynthesizeMouseMove(bool aFromScroll) = 0;
 
-  enum PaintFlags {
-    /* Update the layer tree and paint PaintedLayers. If this is not specified,
-     * we may still have to do it if the layer tree lost PaintedLayer contents
-     * we need for compositing. */
-    PAINT_LAYERS = 0x01,
-    /* Composite layers to the window. */
-    PAINT_COMPOSITE = 0x02,
-    /* Sync-decode images. */
-    PAINT_SYNC_DECODE_IMAGES = 0x04
-  };
-  virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
-                     uint32_t aFlags) = 0;
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult HandleEvent(nsIFrame* aFrame,
                                mozilla::WidgetGUIEvent* aEvent,
                                bool aDontRetargetEvents,
                                nsEventStatus* aEventStatus) = 0;
   virtual bool ShouldIgnoreInvalidation() = 0;
   /**
-   * Notify that we're going to call Paint with PAINT_COMPOSITE.
+   * Notify that we're going to call Paint with PaintFlags::PaintComposite.
    * Fires on the presshell for the painted widget.
    * This is issued at a time when it's safe to modify widget geometry.
    */
   virtual void WillPaintWindow() = 0;
   /**
-   * Notify that we called Paint with PAINT_COMPOSITE.
+   * Notify that we called Paint with PaintFlags::PaintComposite.
    * Fires on the presshell for the painted widget.
    * This is issued at a time when it's safe to modify widget geometry.
    */
   virtual void DidPaintWindow() = 0;
 
-  /**
-   * Ensures that the refresh driver is running, and schedules a view
-   * manager flush on the next tick.
-   *
-   * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after
-   * a delay, and put FrameLayerBuilder in 'compressed' mode that avoids short
-   * cut optimizations.
-   */
-  enum PaintType { PAINT_DEFAULT, PAINT_DELAYED_COMPRESS };
-  virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) = 0;
   virtual void ClearMouseCaptureOnView(nsView* aView) = 0;
   virtual bool IsVisible() = 0;
   MOZ_CAN_RUN_SCRIPT
   void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent);
 
   /* Temporarily ignore the Displayport for better paint performance. We
    * trigger a repaint once suppression is disabled. Without that
    * the displayport may get left at the suppressed size for an extended
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -6858,19 +6858,18 @@ static void SchedulePaintInternal(
     return;
   }
   if (!pres->GetContainerWeak()) {
     NS_WARNING("Shouldn't call SchedulePaint in a detached pres context");
     return;
   }
 
   pres->PresShell()->ScheduleViewManagerFlush(
-      aType == nsIFrame::PAINT_DELAYED_COMPRESS
-          ? nsIPresShell::PAINT_DELAYED_COMPRESS
-          : nsIPresShell::PAINT_DEFAULT);
+      aType == nsIFrame::PAINT_DELAYED_COMPRESS ? PaintType::DelayedCompress
+                                                : PaintType::Default);
 
   if (aType == nsIFrame::PAINT_DELAYED_COMPRESS) {
     return;
   }
 
   if (aType == nsIFrame::PAINT_DEFAULT) {
     aDisplayRoot->AddStateBits(NS_FRAME_UPDATE_LAYER_TREE);
   }
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -6484,17 +6484,17 @@ void ScrollFrameHelper::RestoreState(Pre
   mDidHistoryRestore = true;
   mLastPos = mScrolledFrame ? GetLogicalVisualViewportOffset() : nsPoint(0, 0);
 
   // Resolution properties should only exist on root scroll frames.
   MOZ_ASSERT(mIsRoot || aState->resolution() == 1.0);
 
   if (mIsRoot) {
     mOuter->PresShell()->SetResolutionAndScaleTo(
-        aState->resolution(), nsIPresShell::ChangeOrigin::eMainThread);
+        aState->resolution(), ResolutionChangeOrigin::MainThread);
   }
 }
 
 void ScrollFrameHelper::PostScrolledAreaEvent() {
   if (mScrolledAreaEvent.IsPending()) {
     return;
   }
   mScrolledAreaEvent = new ScrolledAreaEvent(this);
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -514,18 +514,19 @@ void nsSubDocumentFrame::BuildDisplayLis
       if (nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) {
         presShell->AddPrintPreviewBackgroundItem(*aBuilder, childItems, frame,
                                                  bounds);
       } else {
         // Add the canvas background color to the bottom of the list. This
         // happens after we've built the list so that
         // AddCanvasBackgroundColorItem can monkey with the contents if
         // necessary.
-        uint32_t flags =
-            nsIPresShell::FORCE_DRAW | nsIPresShell::ADD_FOR_SUBDOC;
+        AddCanvasBackgroundColorFlags flags =
+            AddCanvasBackgroundColorFlags::ForceDraw |
+            AddCanvasBackgroundColorFlags::AddForSubDocument;
         presShell->AddCanvasBackgroundColorItem(
             *aBuilder, childItems, frame, bounds, NS_RGBA(0, 0, 0, 0), flags);
       }
     }
   }
 
   if (subdocRootFrame) {
     aBuilder->LeavePresShell(subdocRootFrame, &childItems);
@@ -590,18 +591,19 @@ void nsSubDocumentFrame::BuildDisplayLis
     // Invoke AutoBuildingDisplayList to ensure that the correct dirty rect
     // is used to compute the visible rect if AddCanvasBackgroundColorItem
     // creates a display item.
     nsDisplayListBuilder::AutoBuildingDisplayList building(aBuilder, this,
                                                            visible, dirty);
     // Add the canvas background color to the bottom of the list. This
     // happens after we've built the list so that AddCanvasBackgroundColorItem
     // can monkey with the contents if necessary.
-    uint32_t flags =
-        nsIPresShell::FORCE_DRAW | nsIPresShell::APPEND_UNSCROLLED_ONLY;
+    AddCanvasBackgroundColorFlags flags =
+        AddCanvasBackgroundColorFlags::ForceDraw |
+        AddCanvasBackgroundColorFlags::AppendUnscrolledOnly;
     presShell->AddCanvasBackgroundColorItem(*aBuilder, childItems, this, bounds,
                                             NS_RGBA(0, 0, 0, 0), flags);
   }
 
   if (aBuilder->IsForFrameVisibility()) {
     // We don't add the childItems to the return list as we're dealing with them
     // here.
     presShell->RebuildApproximateFrameVisibilityDisplayList(childItems);
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -327,17 +327,17 @@ void nsViewManager::Refresh(nsView* aVie
                  "Widgets that we paint must all be display roots");
 
     if (mPresShell) {
 #ifdef MOZ_DUMP_PAINTING
       if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
         printf_stderr("--COMPOSITE-- %p\n", mPresShell);
       }
 #endif
-      uint32_t paintFlags = nsIPresShell::PAINT_COMPOSITE;
+      PaintFlags paintFlags = PaintFlags::PaintComposite;
       LayerManager* manager = widget->GetLayerManager();
       if (!manager->NeedsWidgetInvalidation()) {
         manager->FlushRendering();
       } else {
         mPresShell->Paint(aView, damageRegion, paintFlags);
       }
 #ifdef MOZ_DUMP_PAINTING
       if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@@ -454,17 +454,17 @@ void nsViewManager::ProcessPendingUpdate
 #ifdef MOZ_DUMP_PAINTING
       if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
         printf_stderr(
             "---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n",
             mPresShell, view, aWidget);
       }
 #endif
 
-      mPresShell->Paint(view, nsRegion(), nsIPresShell::PAINT_LAYERS);
+      mPresShell->Paint(view, nsRegion(), PaintFlags::PaintLayers);
       view->SetForcedRepaint(false);
 
 #ifdef MOZ_DUMP_PAINTING
       if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
         printf_stderr("---- PAINT END ----\n");
       }
 #endif
     }
--- a/widget/android/fennec/ThumbnailHelper.h
+++ b/widget/android/fennec/ThumbnailHelper.h
@@ -154,20 +154,20 @@ class ThumbnailHelper final
     context->SetMatrix(context->CurrentMatrix().PreScale(
         aZoomFactor * float(aThumbWidth) / aPageRect.width,
         aZoomFactor * float(aThumbHeight) / aPageRect.height));
 
     const nsRect drawRect(nsPresContext::CSSPixelsToAppUnits(aPageRect.x),
                           nsPresContext::CSSPixelsToAppUnits(aPageRect.y),
                           nsPresContext::CSSPixelsToAppUnits(aPageRect.width),
                           nsPresContext::CSSPixelsToAppUnits(aPageRect.height));
-    const uint32_t renderDocFlags =
-        nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
-        nsIPresShell::RENDER_DOCUMENT_RELATIVE |
-        nsIPresShell::RENDER_DRAWWINDOW_NOT_FLUSHING;
+    const RenderDocumentFlags renderDocFlags =
+        RenderDocumentFlags::IgnoreViewportScrolling |
+        RenderDocumentFlags::DocumentRelative |
+        RenderDocumentFlags::DrawWindowNotFlushing;
     const nscolor bgColor = NS_RGB(255, 255, 255);
 
     if (NS_FAILED(presShell->RenderDocument(drawRect, renderDocFlags, bgColor,
                                             context))) {
       return nullptr;
     }
 
     if (is24bit) {
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -615,17 +615,17 @@ nsresult nsBaseDragService::DrawDrag(nsI
     return NS_OK;
   }
 
   // draw the image for selections
   if (mSelection) {
     LayoutDeviceIntPoint pnt(aScreenDragRect->TopLeft());
     *aSurface = presShell->RenderSelection(
         mSelection, pnt, aScreenDragRect,
-        mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
+        mImage ? RenderImageFlags::None : RenderImageFlags::AutoScale);
     return NS_OK;
   }
 
   // if a custom image was specified, check if it is an image node and draw
   // using the source rather than the displayed image. But if mImage isn't
   // an image or canvas, fall through to RenderNode below.
   if (mImage) {
     nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
@@ -650,31 +650,33 @@ nsresult nsBaseDragService::DrawDrag(nsI
     nsIFrame* frame = content->GetPrimaryFrame();
     if (frame && frame->IsMenuPopupFrame()) {
       mDragPopup = content;
     }
   }
 
   if (!mDragPopup) {
     // otherwise, just draw the node
-    uint32_t renderFlags = mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE;
-    if (renderFlags) {
+    RenderImageFlags renderFlags =
+        mImage ? RenderImageFlags::None : RenderImageFlags::AutoScale;
+    if (renderFlags != RenderImageFlags::None) {
       // check if the dragged node itself is an img element
       if (dragNode->NodeName().LowerCaseEqualsLiteral("img")) {
-        renderFlags = renderFlags | nsIPresShell::RENDER_IS_IMAGE;
+        renderFlags = renderFlags | RenderImageFlags::IsImage;
       } else {
         nsINodeList* childList = dragNode->ChildNodes();
         uint32_t length = childList->Length();
         // check every childnode for being an img element
         // XXXbz why don't we need to check descendants recursively?
         for (uint32_t count = 0; count < length; ++count) {
           if (childList->Item(count)->NodeName().LowerCaseEqualsLiteral(
                   "img")) {
-            // if the dragnode contains an image, set RENDER_IS_IMAGE flag
-            renderFlags = renderFlags | nsIPresShell::RENDER_IS_IMAGE;
+            // if the dragnode contains an image, set RenderImageFlags::IsImage
+            // flag
+            renderFlags = renderFlags | RenderImageFlags::IsImage;
             break;
           }
         }
       }
     }
     LayoutDeviceIntPoint pnt(aScreenDragRect->TopLeft());
     *aSurface = presShell->RenderNode(dragNode, aRegion, pnt, aScreenDragRect,
                                       renderFlags);