Bug 253889 - part 4: Finally, get rid of nsIPresShell r=emilio
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 01 May 2019 02:28:59 +0000
changeset 531055 d1f9cf74a077fe71234115dafdee9c0723b58e93
parent 531054 cbf6babb97cddfb252b504ef4e39580003f35029
child 531056 5f451bcec20508390823a0a3244ff7301fdafa6e
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs253889
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 253889 - part 4: Finally, get rid of nsIPresShell r=emilio And also this cleans up some legacy comments of PresShell users. Differential Revision: https://phabricator.services.mozilla.com/D29313
dom/base/PopupBlocker.cpp
dom/base/nsGlobalWindowOuter.h
dom/events/EventDispatcher.h
layout/base/PresShell.cpp
layout/base/PresShell.h
layout/base/PresShellForwards.h
layout/base/moz.build
layout/base/nsIPresShell.h
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.cpp
layout/generic/ReflowInput.h
layout/generic/nsFrameSelection.cpp
layout/generic/nsIFrame.h
layout/painting/nsCSSRendering.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/test/test_media_queries_dynamic.html
widget/nsBaseWidget.cpp
--- a/dom/base/PopupBlocker.cpp
+++ b/dom/base/PopupBlocker.cpp
@@ -180,17 +180,17 @@ PopupBlocker::PopupControlState PopupBlo
       return PopupBlocker::openAllowed;
     }
   }
 
   switch (aEvent->mClass) {
     case eBasicEventClass:
       // For these following events only allow popups if they're
       // triggered while handling user input. See
-      // nsPresShell::HandleEventInternal() for details.
+      // PresShell::EventHandler::PrepareToDispatchEvent() for details.
       if (EventStateManager::IsHandlingUserInput()) {
         abuse = PopupBlocker::openBlocked;
         switch (aEvent->mMessage) {
           case eFormSelect:
             if (PopupAllowedForEvent("select")) {
               abuse = PopupBlocker::openControlled;
             }
             break;
@@ -202,34 +202,34 @@ PopupBlocker::PopupControlState PopupBlo
           default:
             break;
         }
       }
       break;
     case eEditorInputEventClass:
       // For this following event only allow popups if it's triggered
       // while handling user input. See
-      // nsPresShell::HandleEventInternal() for details.
+      // PresShell::EventHandler::PrepareToDispatchEvent() for details.
       if (EventStateManager::IsHandlingUserInput()) {
         abuse = PopupBlocker::openBlocked;
         switch (aEvent->mMessage) {
           case eEditorInput:
             if (PopupAllowedForEvent("input")) {
               abuse = PopupBlocker::openControlled;
             }
             break;
           default:
             break;
         }
       }
       break;
     case eInputEventClass:
       // For this following event only allow popups if it's triggered
       // while handling user input. See
-      // nsPresShell::HandleEventInternal() for details.
+      // PresShell::EventHandler::PrepareToDispatchEvent() for details.
       if (EventStateManager::IsHandlingUserInput()) {
         abuse = PopupBlocker::openBlocked;
         switch (aEvent->mMessage) {
           case eFormChange:
             if (PopupAllowedForEvent("change")) {
               abuse = PopupBlocker::openControlled;
             }
             break;
@@ -365,17 +365,17 @@ PopupBlocker::PopupControlState PopupBlo
           default:
             break;
         }
       }
       break;
     case eFormEventClass:
       // For these following events only allow popups if they're
       // triggered while handling user input. See
-      // nsPresShell::HandleEventInternal() for details.
+      // PresShell::EventHandler::PrepareToDispatchEvent() for details.
       if (EventStateManager::IsHandlingUserInput()) {
         abuse = PopupBlocker::openBlocked;
         switch (aEvent->mMessage) {
           case eFormSubmit:
             if (PopupAllowedForEvent("submit")) {
               abuse = PopupBlocker::openControlled;
             }
             break;
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -1135,17 +1135,17 @@ class nsGlobalWindowOuter final : public
   uint32_t mAutoActivateVRDisplayID;
 
   static OuterWindowByIdTable* sOuterWindowsById;
 
   // Members in the mChromeFields member should only be used in chrome windows.
   // All accesses to this field should be guarded by a check of mIsChrome.
   struct ChromeFields {
     nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
-    // A weak pointer to the nsPresShell that we are doing fullscreen for.
+    // A weak pointer to the PresShell that we are doing fullscreen for.
     // The pointer being set indicates we've set the IsInFullscreenChange
     // flag on this pres shell.
     nsWeakPtr mFullscreenPresShell;
   } mChromeFields;
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;
   friend class mozilla::dom::BrowsingContext;
--- a/dom/events/EventDispatcher.h
+++ b/dom/events/EventDispatcher.h
@@ -298,17 +298,17 @@ class EventChainPostVisitor : public moz
       : EventChainVisitor(aOther.mPresContext, aOther.mEvent, aOther.mDOMEvent,
                           aOther.mEventStatus) {}
 };
 
 /**
  * If an EventDispatchingCallback object is passed to Dispatch,
  * its HandleEvent method is called after handling the default event group,
  * before handling the system event group.
- * This is used in nsPresShell.
+ * This is used in PresShell.
  */
 class MOZ_STACK_CLASS EventDispatchingCallback {
  public:
   MOZ_CAN_RUN_SCRIPT
   virtual void HandleEvent(EventChainPostVisitor& aVisitor) = 0;
 };
 
 /**
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -422,28 +422,28 @@ struct nsCallbackEventRequest {
 };
 
 // ----------------------------------------------------------------------------
 //
 // NOTE(emilio): It'd be nice for this to assert that our document isn't in the
 // bfcache, but font pref changes don't care about that, and maybe / probably
 // shouldn't.
 #ifdef DEBUG
-#  define ASSERT_REFLOW_SCHEDULED_STATE()                                    \
-    {                                                                        \
-      if (ObservingLayoutFlushes()) {                                        \
-        MOZ_ASSERT(mDocument->GetBFCacheEntry() ||                           \
-                       mPresContext->RefreshDriver()->IsLayoutFlushObserver( \
-                           static_cast<PresShell*>(this)),                   \
-                   "Unexpected state");                                      \
-      } else {                                                               \
-        MOZ_ASSERT(!mPresContext->RefreshDriver()->IsLayoutFlushObserver(    \
-                       static_cast<PresShell*>(this)),                       \
-                   "Unexpected state");                                      \
-      }                                                                      \
+#  define ASSERT_REFLOW_SCHEDULED_STATE()                                   \
+    {                                                                       \
+      if (ObservingLayoutFlushes()) {                                       \
+        MOZ_ASSERT(                                                         \
+            mDocument->GetBFCacheEntry() ||                                 \
+                mPresContext->RefreshDriver()->IsLayoutFlushObserver(this), \
+            "Unexpected state");                                            \
+      } else {                                                              \
+        MOZ_ASSERT(                                                         \
+            !mPresContext->RefreshDriver()->IsLayoutFlushObserver(this),    \
+            "Unexpected state");                                            \
+      }                                                                     \
     }
 #else
 #  define ASSERT_REFLOW_SCHEDULED_STATE() /* nothing */
 #endif
 
 class nsAutoCauseReflowNotifier {
  public:
   explicit nsAutoCauseReflowNotifier(PresShell* aPresShell)
@@ -853,17 +853,16 @@ PresShell::PresShell()
 }
 
 NS_INTERFACE_TABLE_HEAD(PresShell)
   NS_INTERFACE_TABLE_BEGIN
     // In most cases, PresShell should be treated as concrete class, but need to
     // QI for weak reference.  Therefore, the case needed by do_QueryReferent()
     // should be tested first.
     NS_INTERFACE_TABLE_ENTRY(PresShell, PresShell)
-    NS_INTERFACE_TABLE_ENTRY(PresShell, nsIPresShell)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsIDocumentObserver)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsISelectionController)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsISelectionDisplay)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsIObserver)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsISupportsWeakReference)
     NS_INTERFACE_TABLE_ENTRY(PresShell, nsIMutationObserver)
     NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(PresShell, nsISupports, nsIObserver)
   NS_INTERFACE_TABLE_END
@@ -1364,36 +1363,36 @@ void PresShell::Destroy() {
   mHaveShutDown = true;
 
   mTouchManager.Destroy();
 }
 
 void PresShell::StopObservingRefreshDriver() {
   nsRefreshDriver* rd = mPresContext->RefreshDriver();
   if (mResizeEventPending) {
-    rd->RemoveResizeEventFlushObserver(static_cast<PresShell*>(this));
+    rd->RemoveResizeEventFlushObserver(this);
   }
   if (mObservingLayoutFlushes) {
-    rd->RemoveLayoutFlushObserver(static_cast<PresShell*>(this));
+    rd->RemoveLayoutFlushObserver(this);
   }
   if (mObservingStyleFlushes) {
-    rd->RemoveStyleFlushObserver(static_cast<PresShell*>(this));
+    rd->RemoveStyleFlushObserver(this);
   }
 }
 
 void PresShell::StartObservingRefreshDriver() {
   nsRefreshDriver* rd = mPresContext->RefreshDriver();
   if (mResizeEventPending) {
-    rd->AddResizeEventFlushObserver(static_cast<PresShell*>(this));
+    rd->AddResizeEventFlushObserver(this);
   }
   if (mObservingLayoutFlushes) {
-    rd->AddLayoutFlushObserver(static_cast<PresShell*>(this));
+    rd->AddLayoutFlushObserver(this);
   }
   if (mObservingStyleFlushes) {
-    rd->AddStyleFlushObserver(static_cast<PresShell*>(this));
+    rd->AddStyleFlushObserver(this);
   }
 }
 
 nsRefreshDriver* PresShell::GetRefreshDriver() const {
   return mPresContext ? mPresContext->RefreshDriver() : nullptr;
 }
 
 void PresShell::SetAuthorStyleDisabled(bool aStyleDisabled) {
@@ -2801,18 +2800,17 @@ nsIScrollableFrame* PresShell::GetScroll
   nsCOMPtr<nsIContent> content = GetContentForScrolling();
   return GetScrollableFrameToScrollForContent(content.get(), aDirection);
 }
 
 void PresShell::CancelAllPendingReflows() {
   mDirtyRoots.Clear();
 
   if (mObservingLayoutFlushes) {
-    GetPresContext()->RefreshDriver()->RemoveLayoutFlushObserver(
-        static_cast<PresShell*>(this));
+    GetPresContext()->RefreshDriver()->RemoveLayoutFlushObserver(this);
     mObservingLayoutFlushes = false;
   }
 
   ASSERT_REFLOW_SCHEDULED_STATE();
 }
 
 static bool DestroyFramesAndStyleDataFor(
     Element* aElement, nsPresContext& aPresContext,
@@ -2950,30 +2948,30 @@ void PresShell::SetForwardingContainer(c
 void PresShell::ClearFrameRefs(nsIFrame* aFrame) {
   mPresContext->EventStateManager()->ClearFrameRefs(aFrame);
 
   AutoWeakFrame* weakFrame = mAutoWeakFrames;
   while (weakFrame) {
     AutoWeakFrame* prev = weakFrame->GetPreviousWeakFrame();
     if (weakFrame->GetFrame() == aFrame) {
       // This removes weakFrame from mAutoWeakFrames.
-      weakFrame->Clear(static_cast<PresShell*>(this));
+      weakFrame->Clear(this);
     }
     weakFrame = prev;
   }
 
   AutoTArray<WeakFrame*, 4> toRemove;
   for (auto iter = mWeakFrames.Iter(); !iter.Done(); iter.Next()) {
     WeakFrame* weakFrame = iter.Get()->GetKey();
     if (weakFrame->GetFrame() == aFrame) {
       toRemove.AppendElement(weakFrame);
     }
   }
   for (WeakFrame* weakFrame : toRemove) {
-    weakFrame->Clear(static_cast<PresShell*>(this));
+    weakFrame->Clear(this);
   }
 }
 
 already_AddRefed<gfxContext> PresShell::CreateReferenceRenderingContext() {
   nsDeviceContext* devCtx = mPresContext->DeviceContext();
   RefPtr<gfxContext> rc;
   if (mPresContext->IsScreen()) {
     rc = gfxContext::CreateOrNull(
@@ -4373,17 +4371,17 @@ void PresShell::ContentRemoved(nsIConten
   // NOTE(emilio): It's important that this goes after the frame constructor
   // stuff, otherwise the frame constructor can't see elements which are
   // display: contents / display: none, because we'd have cleared all the style
   // data from there.
   mPresContext->RestyleManager()->ContentRemoved(aChild, oldNextSibling);
 }
 
 void PresShell::NotifyCounterStylesAreDirty() {
-  nsAutoCauseReflowNotifier reflowNotifier(static_cast<PresShell*>(this));
+  nsAutoCauseReflowNotifier reflowNotifier(this);
   mFrameConstructor->NotifyCounterStylesAreDirty();
 }
 
 bool PresShell::FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const {
   return mDirtyRoots.FrameIsAncestorOfDirtyRoot(aFrame);
 }
 
 void PresShell::ReconstructFrames() {
@@ -9247,18 +9245,18 @@ bool PresShell::DoReflow(nsIFrame* targe
     mWasLastReflowInterrupted = true;
     MaybeScheduleReflow();
   }
 
   // dump text perf metrics for reflows with significant text processing
   if (tp) {
     if (tp->current.numChars > 100) {
       TimeDuration reflowTime = TimeStamp::Now() - timeStart;
-      LogTextPerfStats(tp, static_cast<PresShell*>(this), tp->current,
-                       reflowTime.ToMilliseconds(), eLog_reflow, nullptr);
+      LogTextPerfStats(tp, this, tp->current, reflowTime.ToMilliseconds(),
+                       eLog_reflow, nullptr);
     }
     tp->Accumulate();
   }
 
   if (isTimelineRecording) {
     timelines->AddMarkerForDocShell(docShell, "Reflow", MarkerTracingType::END);
   }
 
@@ -9478,28 +9476,26 @@ bool PresShell::RemovePostRefreshObserve
   return true;
 }
 
 void PresShell::DoObserveStyleFlushes() {
   MOZ_ASSERT(!ObservingStyleFlushes());
   mObservingStyleFlushes = true;
 
   if (MOZ_LIKELY(!mDocument->GetBFCacheEntry())) {
-    mPresContext->RefreshDriver()->AddStyleFlushObserver(
-        static_cast<PresShell*>(this));
+    mPresContext->RefreshDriver()->AddStyleFlushObserver(this);
   }
 }
 
 void PresShell::DoObserveLayoutFlushes() {
   MOZ_ASSERT(!ObservingLayoutFlushes());
   mObservingLayoutFlushes = true;
 
   if (MOZ_LIKELY(!mDocument->GetBFCacheEntry())) {
-    mPresContext->RefreshDriver()->AddLayoutFlushObserver(
-        static_cast<PresShell*>(this));
+    mPresContext->RefreshDriver()->AddLayoutFlushObserver(this);
   }
 }
 
 //------------------------------------------------------
 // End of protected and private methods on the PresShell
 //------------------------------------------------------
 
 //------------------------------------------------------------------
@@ -9809,17 +9805,17 @@ bool PresShell::VerifyIncrementalReflow(
   NS_ENSURE_TRUE(presShell, false);
 
   // Note that after we create the shell, we must make sure to destroy it
   presShell->SetVerifyReflowEnable(
       false);  // turn off verify reflow while we're
                // reflowing the test frame tree
   vm->SetPresShell(presShell);
   {
-    nsAutoCauseReflowNotifier crNotifier(static_cast<PresShell*>(this));
+    nsAutoCauseReflowNotifier crNotifier(this);
     presShell->Initialize();
   }
   mDocument->BindingManager()->ProcessAttachedQueue();
   presShell->FlushPendingNotifications(FlushType::Layout);
   presShell->SetVerifyReflowEnable(
       true);  // turn on verify reflow again now that
               // we're done reflowing the test frame tree
   // Force the non-primary presshell to unsuppress; it doesn't want to normally
@@ -10703,18 +10699,17 @@ bool PresShell::DetermineFontSizeInflati
   }
 
   if (FontSizeInflationEmPerLine() == 0 && FontSizeInflationMinTwips() == 0) {
     return false;
   }
 
   // Force-enabling font inflation always trumps the heuristics here.
   if (!FontSizeInflationForceEnabled()) {
-    if (BrowserChild* tab =
-            BrowserChild::GetFrom(static_cast<PresShell*>(this))) {
+    if (BrowserChild* tab = BrowserChild::GetFrom(this)) {
       // We're in a child process.  Cancel inflation if we're not
       // async-pan zoomed.
       if (!tab->AsyncPanZoomEnabled()) {
         return false;
       }
     } else if (XRE_IsParentProcess()) {
       // We're in the master process.  Cancel inflation if it's been
       // explicitly disabled.
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -5,69 +5,166 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* a presentation of a document, part 2 */
 
 #ifndef mozilla_PresShell_h
 #define mozilla_PresShell_h
 
 #include "mozilla/PresShellForwards.h"
-#include "nsIPresShell.h"
-
+
+#include <stdio.h>  // for FILE definition
+#include "FrameMetrics.h"
+#include "GeckoProfiler.h"
+#include "TouchManager.h"
+#include "Units.h"
+#include "ZoomConstraintsClient.h"
+#include "gfxPoint.h"
+#include "mozilla/ArenaObjectID.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/dom/HTMLDocumentBinding.h"
-#include "mozilla/layers/FocusTarget.h"
+#include "mozilla/FlushType.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ScrollTypes.h"
 #include "mozilla/ServoStyleSet.h"
+#include "mozilla/ServoStyleConsts.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/StyleSheet.h"
 #include "mozilla/UniquePtr.h"
-#include "nsContentUtils.h"  // For AddScriptBlocker().
-#include "nsCRT.h"
+#include "mozilla/WeakPtr.h"
+#include "mozilla/dom/HTMLDocumentBinding.h"
+#include "mozilla/layers/FocusTarget.h"
+#include "nsChangeHint.h"
+#include "nsClassHashtable.h"
+#include "nsColor.h"
+#include "nsCOMArray.h"
+#include "nsCoord.h"
+#include "nsDOMNavigationTiming.h"
+#include "nsFrameManager.h"
+#include "nsFrameState.h"
+#include "nsHashKeys.h"
+#include "nsIContent.h"
+#include "nsIImageLoadingContent.h"
 #include "nsIObserver.h"
 #include "nsISelectionController.h"
 #include "nsIWidget.h"
+#include "nsQueryFrame.h"
+#include "nsMargin.h"
+#include "nsPresArena.h"
 #include "nsPresContext.h"
+#include "nsRect.h"
+#include "nsRefPtrHashtable.h"
 #include "nsRefreshDriver.h"
+#include "nsRegionFwd.h"
+#include "nsStringFwd.h"
 #include "nsStubDocumentObserver.h"
+#include "nsTHashtable.h"
 #include "nsThreadUtils.h"
 #include "nsWeakReference.h"
-#include "TouchManager.h"
-#include "ZoomConstraintsClient.h"
-
+
+class AutoPointerEventTargetUpdater;
+class AutoWeakFrame;
+class gfxContext;
+class MobileViewportManager;
+#ifdef ACCESSIBILITY
+class nsAccessibilityService;
+#endif
+class nsARefreshObserver;
+class nsAutoCauseReflowNotifier;
+class nsCanvasFrame;
+class nsCaret;
+class nsCSSFrameConstructor;
+class nsDisplayList;
+class nsDisplayListBuilder;
+class nsDocShell;
+class nsFrameSelection;
 class nsIDocShell;
+class nsIFrame;
+class nsILayoutHistoryState;
+class nsINode;
+class nsIPageSequenceFrame;
+class nsIReflowCallback;
+class nsIScrollableFrame;
+class nsITimer;
+class nsPIDOMWindowOuter;
+class nsAPostRefreshObserver;
+class nsPresShellEventCB;
 class nsRange;
-
+class nsRefreshDriver;
+class nsRegion;
+class nsView;
+class nsViewManager;
+class nsWindowSizes;
 struct RangePaintInfo;
-
-class nsPresShellEventCB;
-class AutoPointerEventTargetUpdater;
-class MobileViewportManager;
+#ifdef MOZ_REFLOW_PERF
+class ReflowCountMgr;
+#endif
+class WeakFrame;
+
+template <class E>
+class nsCOMArray;
+
+struct nsCallbackEventRequest;
+struct nsPoint;
+struct nsRect;
 
 namespace mozilla {
+class AccessibleCaretEventHub;
+class EventStates;
+class GeckoMVMContext;
+class OverflowChangedTracker;
+class StyleSheet;
+
+#ifdef ACCESSIBILITY
+namespace a11y {
+class DocAccessible;
+}  // namespace a11y
+#endif
 
 namespace dom {
+class Document;
 class Element;
+class Event;
+class HTMLSlotElement;
 class Selection;
 }  // namespace dom
 
-class EventDispatchingCallback;
-class GeckoMVMContext;
-class OverflowChangedTracker;
+namespace gfx {
+class SourceSurface;
+}  // namespace gfx
+
+namespace layers {
+class LayerManager;
+}  // namespace layers
+
+namespace layout {
+class ScrollAnchorContainer;
+}  // namespace layout
 
 // 039d8ffc-fa55-42d7-a53a-388cb129b052
 #define NS_PRESSHELL_IID                             \
   {                                                  \
     0x039d8ffc, 0xfa55, 0x42d7, {                    \
       0xa5, 0x3a, 0x38, 0x8c, 0xb1, 0x29, 0xb0, 0x52 \
     }                                                \
   }
 
-class PresShell final : public nsIPresShell,
+#undef NOISY_INTERRUPTIBLE_REFLOW
+
+/**
+ * Presentation shell. Presentation shells are the controlling point for
+ * managing the presentation of a document.  The presentation shell holds a
+ * live reference to the document, the presentation context, the style
+ * manager, the style set and the root frame.
+ *
+ * When this object is Release'd, it will release the document, the
+ * presentation context, the style manager, the style set and the root frame.
+ */
+
+class PresShell final : public nsStubDocumentObserver,
                         public nsISelectionController,
                         public nsIObserver,
                         public nsSupportsWeakReference {
   typedef dom::Document Document;
   typedef dom::Element Element;
   typedef gfx::SourceSurface SourceSurface;
   typedef layers::FocusTarget FocusTarget;
   typedef layers::FrameMetrics FrameMetrics;
@@ -737,20 +834,21 @@ class PresShell final : public nsIPresSh
                           gfxContext* aRenderedContext);
 
   /**
    * 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.
    */
-  already_AddRefed<gfx::SourceSurface> RenderNode(
-      nsINode* aNode, const Maybe<CSSIntRegion>& aRegion,
-      const LayoutDeviceIntPoint aPoint, LayoutDeviceIntRect* aScreenRect,
-      RenderImageFlags aFlags);
+  already_AddRefed<SourceSurface> RenderNode(nsINode* aNode,
+                                             const Maybe<CSSIntRegion>& aRegion,
+                                             const LayoutDeviceIntPoint aPoint,
+                                             LayoutDeviceIntRect* aScreenRect,
+                                             RenderImageFlags aFlags);
 
   /**
    * 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.
    *
@@ -758,17 +856,17 @@ class PresShell final : public nsIPresSh
    * 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.
    */
-  already_AddRefed<gfx::SourceSurface> RenderSelection(
+  already_AddRefed<SourceSurface> RenderSelection(
       dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
       LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);
 
   void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame);
   void AddWeakFrame(WeakFrame* aWeakFrame);
 
   void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
   void RemoveWeakFrame(WeakFrame* aWeakFrame);
--- a/layout/base/PresShellForwards.h
+++ b/layout/base/PresShellForwards.h
@@ -4,18 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_PresShellForwards_h
 #define mozilla_PresShellForwards_h
 
 #include "mozilla/TypedEnumBits.h"
 
-class nsIPresShell;
-
 struct CapturingContentInfo;
 
 namespace mozilla {
 
 class PresShell;
 
 // Flags to pass to PresShell::SetCapturingContent().
 enum class CaptureFlags {
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -47,17 +47,16 @@ EXPORTS += [
     'nsCounterManager.h',
     'nsCSSFrameConstructor.h',
     'nsFrameManager.h',
     'nsFrameTraversal.h',
     'nsGenConList.h',
     'nsIFrameTraversal.h',
     'nsILayoutDebugger.h',
     'nsIPercentBSizeObserver.h',
-    'nsIPresShell.h',
     'nsIReflowCallback.h',
     'nsLayoutUtils.h',
     'nsPresArena.h',
     'nsPresArenaObjectList.h',
     'nsPresContext.h',
     'nsPresContextInlines.h',
     'nsQuoteList.h',
     'nsRefreshDriver.h',
deleted file mode 100644
--- a/layout/base/nsIPresShell.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* a presentation of a document, part 2 */
-
-#ifndef nsIPresShell_h___
-#define nsIPresShell_h___
-
-#include "mozilla/PresShellForwards.h"
-
-#include "mozilla/ArenaObjectID.h"
-#include "mozilla/EventForwards.h"
-#include "mozilla/FlushType.h"
-#include "mozilla/MemoryReporting.h"
-#include "mozilla/ScrollTypes.h"
-#include "mozilla/ServoStyleSet.h"
-#include "mozilla/ServoStyleConsts.h"
-#include "mozilla/StyleSheet.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/WeakPtr.h"
-#include "FrameMetrics.h"
-#include "GeckoProfiler.h"
-#include "gfxPoint.h"
-#include "nsDOMNavigationTiming.h"
-#include "nsTHashtable.h"
-#include "nsHashKeys.h"
-#include "nsISupports.h"
-#include "nsIContent.h"
-#include "nsISelectionController.h"
-#include "nsQueryFrame.h"
-#include "nsStringFwd.h"
-#include "nsCoord.h"
-#include "nsColor.h"
-#include "nsFrameManager.h"
-#include "nsRect.h"
-#include "nsRegionFwd.h"
-#include <stdio.h>  // for FILE definition
-#include "nsChangeHint.h"
-#include "nsRefPtrHashtable.h"
-#include "nsClassHashtable.h"
-#include "nsPresArena.h"
-#include "nsIImageLoadingContent.h"
-#include "nsMargin.h"
-#include "nsFrameState.h"
-#include "nsStubDocumentObserver.h"
-#include "nsCOMArray.h"
-#include "Units.h"
-
-#ifdef MOZ_REFLOW_PERF
-class ReflowCountMgr;
-#endif
-
-class gfxContext;
-struct nsCallbackEventRequest;
-class nsDocShell;
-class nsIFrame;
-class nsPresContext;
-class nsWindowSizes;
-class nsViewManager;
-class nsView;
-class nsIPageSequenceFrame;
-class nsCanvasFrame;
-class nsCaret;
-namespace mozilla {
-class AccessibleCaretEventHub;
-class OverflowChangedTracker;
-class StyleSheet;
-}  // namespace mozilla
-class nsFrameSelection;
-class nsFrameManager;
-class nsILayoutHistoryState;
-class nsIReflowCallback;
-class nsCSSFrameConstructor;
-template <class E>
-class nsCOMArray;
-class AutoWeakFrame;
-class MobileViewportManager;
-class WeakFrame;
-class nsIScrollableFrame;
-class nsDisplayList;
-class nsDisplayListBuilder;
-class nsPIDOMWindowOuter;
-struct nsPoint;
-class nsINode;
-struct nsRect;
-class nsRegion;
-class nsRefreshDriver;
-class nsAutoCauseReflowNotifier;
-class nsARefreshObserver;
-class nsAPostRefreshObserver;
-#ifdef ACCESSIBILITY
-class nsAccessibilityService;
-namespace mozilla {
-namespace a11y {
-class DocAccessible;
-}  // namespace a11y
-}  // namespace mozilla
-#endif
-class nsITimer;
-
-namespace mozilla {
-class EventStates;
-
-namespace dom {
-class Element;
-class Event;
-class Document;
-class HTMLSlotElement;
-class Touch;
-class Selection;
-class ShadowRoot;
-}  // namespace dom
-
-namespace layout {
-class ScrollAnchorContainer;
-}  // namespace layout
-
-namespace layers {
-class LayerManager;
-}  // namespace layers
-
-namespace gfx {
-class SourceSurface;
-}  // namespace gfx
-}  // namespace mozilla
-
-// b7b89561-4f03-44b3-9afa-b47e7f313ffb
-#define NS_IPRESSHELL_IID                            \
-  {                                                  \
-    0xb7b89561, 0x4f03, 0x44b3, {                    \
-      0x9a, 0xfa, 0xb4, 0x7e, 0x7f, 0x31, 0x3f, 0xfb \
-    }                                                \
-  }
-
-#undef NOISY_INTERRUPTIBLE_REFLOW
-
-/**
- * Presentation shell interface. Presentation shells are the
- * controlling point for managing the presentation of a document. The
- * presentation shell holds a live reference to the document, the
- * presentation context, the style manager, the style set and the root
- * frame. <p>
- *
- * When this object is Release'd, it will release the document, the
- * presentation context, the style manager, the style set and the root
- * frame.
- */
-
-class nsIPresShell : public nsStubDocumentObserver {
- public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
-
-  nsIPresShell() = default;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID)
-
-#endif /* nsIPresShell_h___ */
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2233,17 +2233,17 @@ nsPoint nsLayoutUtils::GetEventCoordinat
   // Convert from root document app units to app units of the document aFrame
   // is in.
   int32_t rootAPD = rootFrame->PresContext()->AppUnitsPerDevPixel();
   int32_t localAPD = aFrame->PresContext()->AppUnitsPerDevPixel();
   widgetToView = widgetToView.ScaleToOtherAppUnits(rootAPD, localAPD);
   PresShell* presShell = aFrame->PresShell();
 
   // XXX Bug 1224748 - Update nsLayoutUtils functions to correctly handle
-  // nsPresShell resolution
+  // PresShell resolution
   widgetToView =
       widgetToView.RemoveResolution(GetCurrentAPZResolutionScale(presShell));
 
   /* If we encountered a transform, we can't do simple arithmetic to figure
    * out how to convert back to aFrame's coordinates and must use the CTM.
    */
   if (transformFound || nsSVGUtils::IsInSVGTextSubtree(aFrame)) {
     return TransformRootPointToFrame(aFrame, widgetToView);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2540,18 +2540,18 @@ static void ApplyPluginGeometryUpdatesCa
 }
 
 void nsRootPresContext::InitApplyPluginGeometryTimer() {
   if (mApplyPluginGeometryTimer) {
     return;
   }
 
   // We'll apply the plugin geometry updates during the next compositing paint
-  // in this presContext (either from nsPresShell::WillPaintWindow or from
-  // nsPresShell::DidPaintWindow, depending on the platform).  But paints might
+  // in this presContext (either from PresShell::WillPaintWindow() or from
+  // PresShell::DidPaintWindow(), depending on the platform).  But paints might
   // get optimized away if the old plugin geometry covers the invalid region,
   // so set a backup timer to do this too.  We want to make sure this
   // won't fire before our normal paint notifications, if those would
   // update the geometry, so set it for double the refresh driver interval.
   mApplyPluginGeometryTimer = CreateTimer(
       ApplyPluginGeometryUpdatesCallback, "ApplyPluginGeometryUpdatesCallback",
       nsRefreshDriver::DefaultInterval() * 2);
 }
--- a/layout/generic/ReflowInput.h
+++ b/layout/generic/ReflowInput.h
@@ -382,17 +382,17 @@ struct ReflowInput : public SizeComputat
   nscoord mBlockDelta = 0;
 
   // If a ReflowInput finds itself initialized with an unconstrained
   // inline-size, it will look up its parentReflowInput chain for a reflow input
   // with an orthogonal writing mode and a non-NS_UNCONSTRAINEDSIZE value for
   // orthogonal limit; when it finds such a reflow input, it will use its
   // orthogonal-limit value to constrain inline-size.
   // This is initialized to NS_UNCONSTRAINEDSIZE (so it will be ignored),
-  // but reset to a suitable value for the reflow root by nsPresShell.
+  // but reset to a suitable value for the reflow root by PresShell.
   nscoord mOrthogonalLimit = NS_UNCONSTRAINEDSIZE;
 
   // Accessors for the private fields below. Forcing all callers to use these
   // will allow us to introduce logical-coordinate versions and gradually
   // change clients from physical to logical as needed; and potentially switch
   // the internal fields from physical to logical coordinates in due course,
   // while maintaining compatibility with not-yet-updated code.
   nscoord AvailableWidth() const { return mAvailableWidth; }
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -2756,18 +2756,18 @@ nsresult nsFrameSelection::UpdateSelecti
 // mozilla::AutoCopyListener
 
 int16_t AutoCopyListener::sClipboardID = -1;
 
 /*
  * What we do now:
  * On every selection change, we copy to the clipboard anew, creating a
  * HTML buffer, a transferable, an nsISupportsString and
- * a huge mess every time.  This is basically what nsPresShell::DoCopy does
- * to move the selection into the clipboard for Edit->Copy.
+ * a huge mess every time.  This is basically what nsCopySupport::HTMLCopy()
+ * does to move the selection into the clipboard for Edit->Copy.
  *
  * What we should do, to make our end of the deal faster:
  * Create a singleton transferable with our own magic converter.  When selection
  * changes (use a quick cache to detect ``real'' changes), we put the new
  * Selection in the transferable.  Our magic converter will take care of
  * transferable->whatever-other-format when the time comes to actually
  * hand over the clipboard contents.
  *
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2148,17 +2148,17 @@ class nsIFrame : public nsQueryFrame {
   /**
    * Note: "width" in the names and comments on the following methods
    * means inline-size, which could be height in vertical layout
    */
 
   /**
    * Mark any stored intrinsic width information as dirty (requiring
    * re-calculation).  Note that this should generally not be called
-   * directly; nsPresShell::FrameNeedsReflow will call it instead.
+   * directly; PresShell::FrameNeedsReflow() will call it instead.
    */
   virtual void MarkIntrinsicISizesDirty() = 0;
 
   /**
    * Get the min-content intrinsic inline size of the frame.  This must be
    * less than or equal to the max-content intrinsic inline size.
    *
    * This is *not* affected by the CSS 'min-width', 'width', and
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -2437,17 +2437,17 @@ ImgDrawResult nsCSSRendering::PaintStyle
       return ImgDrawResult::SUCCESS;
     }
   }
 
   // For canvas frames (in the CSS sense) we draw the background color using
   // a solid color item that gets added in nsLayoutUtils::PaintFrame,
   // or nsSubDocumentFrame::BuildDisplayList (bug 488242). (The solid
   // color may be moved into nsDisplayCanvasBackground by
-  // nsPresShell::AddCanvasBackgroundColorItem, and painted by
+  // PresShell::AddCanvasBackgroundColorItem(), and painted by
   // nsDisplayCanvasBackground directly.) Either way we don't need to
   // paint the background color here.
   bool isCanvasFrame = IsCanvasFrame(aParams.frame);
 
   // Determine whether we are drawing background images and/or
   // background colors.
   bool drawBackgroundImage;
   bool drawBackgroundColor;
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -503,18 +503,17 @@ already_AddRefed<ComputedStyle> nsComput
     StyleType aStyleType) {
   MOZ_ASSERT(aElement, "NULL element");
 
   // If the content has a pres shell, we must use it.  Otherwise we'd
   // potentially mix rule trees by using the wrong pres shell's style
   // set.  Using the pres shell from the content also means that any
   // content that's actually *in* a document will get the style from the
   // correct document.
-  PresShell* presShell =
-      static_cast<PresShell*>(nsContentUtils::GetPresShellForContent(aElement));
+  PresShell* presShell = nsContentUtils::GetPresShellForContent(aElement);
   bool inDocWithShell = true;
   if (!presShell) {
     inDocWithShell = false;
     presShell = aPresShell;
     if (!presShell) {
       return nullptr;
     }
   }
--- a/layout/style/test/test_media_queries_dynamic.html
+++ b/layout/style/test/test_media_queries_dynamic.html
@@ -163,17 +163,17 @@ function run() {
 
   iframe_style.height = "123px";
   flush_and_assert_change_counters("change height with no media queries",
     { restyle: false, construct: false, reflow: true });
 
   sheet.insertRule("@media (min-width: 150px) { div { display:flex } }", 0);
   flush_and_assert_change_counters("add non-matching media query",
     // FIXME: We restyle here because
-    // nsIPresShell::RestyleForCSSRuleChanges posts a restyle, but it's
+    // PresShell::NextRestyleIsForCSSRuleChanges() posts a restyle, but it's
     // probably avoidable if we wanted to avoid it.
     { restyle: true, construct: false, reflow: false });
 
   iframe_style.width = "177px";
   flush_and_assert_change_counters("resize width across media query with 'display'",
     { restyle: true, construct: true, reflow: true });
 
   iframe_style.width = "162px";
@@ -194,17 +194,17 @@ function run() {
 
   iframe_style.height = "184px";
   flush_and_assert_change_counters("resize height across media query with 'display'",
     { restyle: true, construct: true, reflow: true });
 
   sheet.deleteRule(0);
   flush_and_assert_change_counters("remove non-matching media query",
     // FIXME: We restyle here because
-    // nsIPresShell::RestyleForCSSRuleChanges posts a restyle, but it's
+    // PresShell::NextRestyleIsForCSSRuleChanges() posts a restyle, but it's
     // probably avoidable if we wanted to avoid it.
     { restyle: true, construct: false, reflow: false });
 
   SimpleTest.finish();
 }
 
 </script>
 </pre>
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1795,18 +1795,17 @@ void nsBaseWidget::ZoomToRect(const uint
           aRect, aFlags));
 }
 
 #ifdef ACCESSIBILITY
 
 a11y::Accessible* nsBaseWidget::GetRootAccessible() {
   NS_ENSURE_TRUE(mWidgetListener, nullptr);
 
-  PresShell* presShell =
-      static_cast<PresShell*>(mWidgetListener->GetPresShell());
+  PresShell* presShell = mWidgetListener->GetPresShell();
   NS_ENSURE_TRUE(presShell, nullptr);
 
   // If container is null then the presshell is not active. This often happens
   // when a preshell is being held onto for fastback.
   nsPresContext* presContext = presShell->GetPresContext();
   NS_ENSURE_TRUE(presContext->GetContainerWeak(), nullptr);
 
   // Accessible creation might be not safe so use IsSafeToRunScript to