Bug 253889 - part 2: Move all methods and public structs of nsIPresShell into mozilla::PresShell r=emilio
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 01 May 2019 02:27:53 +0000
changeset 531053 ad0568bbf0d1f39cef9e798283b48d64c40ec9c0
parent 531052 9ea9cc51a20217f8883546904e1e56ac8b2391a0
child 531054 cbf6babb97cddfb252b504ef4e39580003f35029
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 2: Move all methods and public structs of nsIPresShell into mozilla::PresShell r=emilio Differential Revision: https://phabricator.services.mozilla.com/D29311
dom/interfaces/base/nsIDOMWindowUtils.idl
layout/base/PresShell.cpp
layout/base/PresShell.h
layout/base/RestyleManager.cpp
layout/base/Units.h
layout/base/nsIPresShell.h
layout/base/nsIReflowCallback.h
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.h
layout/generic/nsQueryFrame.h
layout/style/ServoStyleSet.cpp
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -836,17 +836,17 @@ interface nsIDOMWindowUtils : nsISupport
 
   /**
    * Scroll the visual viewport to the given coordinates, relative to the
    * document origin.
    * Only applicable to the window associated with the root content document.
    * Note: this does not take effect right away. Rather, the visual scroll
    *       request is sent to APZ with the next transaction, and will be
    *       reflected in the main thread with the subsequent APZ repaint request.
-   * Please see the caveats mentioned at nsIPresShell::ScrollToVisual(), and
+   * Please see the caveats mentioned at PresShell::ScrollToVisual(), and
    * request APZ review if adding a new call to this.
    */
   const long UPDATE_TYPE_RESTORE = 0;
   const long UPDATE_TYPE_MAIN_THREAD = 1;
   const long SCROLL_MODE_INSTANT = 0;
   const long SCROLL_MODE_SMOOTH = 1;
   void scrollToVisual(in float aOffsetX, in float aOffsetY,
                       in long aUpdateType, in long aScrollMode);
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -564,56 +564,56 @@ class MOZ_STACK_CLASS AutoPointerEventTa
   }
 
  private:
   RefPtr<PresShell> mShell;
   AutoWeakFrame mWeakFrame;
   nsIContent** mTargetContent;
 };
 
-void nsIPresShell::DirtyRootsList::Add(nsIFrame* aFrame) {
+void PresShell::DirtyRootsList::Add(nsIFrame* aFrame) {
   // Is this root already scheduled for reflow?
   // FIXME: This could possibly be changed to a uniqueness assertion, with some
   // work in ResizeReflowIgnoreOverride (and maybe others?)
   if (mList.Contains(aFrame)) {
     // We don't expect frame to change depths.
     MOZ_ASSERT(aFrame->GetDepthInFrameTree() ==
                mList[mList.IndexOf(aFrame)].mDepth);
     return;
   }
 
   mList.InsertElementSorted(
       FrameAndDepth{aFrame, aFrame->GetDepthInFrameTree()},
       FrameAndDepth::CompareByReverseDepth{});
 }
 
-void nsIPresShell::DirtyRootsList::Remove(nsIFrame* aFrame) {
+void PresShell::DirtyRootsList::Remove(nsIFrame* aFrame) {
   mList.RemoveElement(aFrame);
 }
 
-nsIFrame* nsIPresShell::DirtyRootsList::PopShallowestRoot() {
+nsIFrame* PresShell::DirtyRootsList::PopShallowestRoot() {
   // List is sorted in order of decreasing depth, so there are no deeper
   // frames than the last one.
   const FrameAndDepth& lastFAD = mList.LastElement();
   nsIFrame* frame = lastFAD.mFrame;
   // We don't expect frame to change depths.
   MOZ_ASSERT(frame->GetDepthInFrameTree() == lastFAD.mDepth);
   mList.RemoveLastElement();
   return frame;
 }
 
-void nsIPresShell::DirtyRootsList::Clear() { mList.Clear(); }
-
-bool nsIPresShell::DirtyRootsList::Contains(nsIFrame* aFrame) const {
+void PresShell::DirtyRootsList::Clear() { mList.Clear(); }
+
+bool PresShell::DirtyRootsList::Contains(nsIFrame* aFrame) const {
   return mList.Contains(aFrame);
 }
 
-bool nsIPresShell::DirtyRootsList::IsEmpty() const { return mList.IsEmpty(); }
-
-bool nsIPresShell::DirtyRootsList::FrameIsAncestorOfDirtyRoot(
+bool PresShell::DirtyRootsList::IsEmpty() const { return mList.IsEmpty(); }
+
+bool PresShell::DirtyRootsList::FrameIsAncestorOfDirtyRoot(
     nsIFrame* aFrame) const {
   MOZ_ASSERT(aFrame);
 
   // Look for a path from any dirty roots to aFrame, following GetParent().
   // This check mirrors what FrameNeedsReflow() would have done if the reflow
   // root didn't get in the way.
   for (nsIFrame* dirtyFrame : mList) {
     do {
@@ -624,27 +624,27 @@ bool nsIPresShell::DirtyRootsList::Frame
     } while (dirtyFrame);
   }
 
   return false;
 }
 
 bool PresShell::sDisableNonTestMouseEvents = false;
 
-mozilla::LazyLogModule nsIPresShell::gLog("PresShell");
-
-mozilla::TimeStamp PresShell::EventHandler::sLastInputCreated;
-mozilla::TimeStamp PresShell::EventHandler::sLastInputProcessed;
+LazyLogModule PresShell::gLog("PresShell");
+
+TimeStamp PresShell::EventHandler::sLastInputCreated;
+TimeStamp PresShell::EventHandler::sLastInputProcessed;
 StaticRefPtr<Element> PresShell::EventHandler::sLastKeyDownEventTargetElement;
 
 bool PresShell::sProcessInteractable = false;
 
 static bool gVerifyReflowEnabled;
 
-bool nsIPresShell::GetVerifyReflowEnable() {
+bool PresShell::GetVerifyReflowEnable() {
 #ifdef DEBUG
   static bool firstTime = true;
   if (firstTime) {
     firstTime = false;
     char* flags = PR_GetEnv("GECKO_VERIFY_REFLOW_FLAGS");
     if (flags) {
       bool error = false;
 
@@ -696,56 +696,56 @@ bool nsIPresShell::GetVerifyReflowEnable
       }
       printf("\n");
     }
   }
 #endif
   return gVerifyReflowEnabled;
 }
 
-void nsIPresShell::SetVerifyReflowEnable(bool aEnabled) {
+void PresShell::SetVerifyReflowEnable(bool aEnabled) {
   gVerifyReflowEnabled = aEnabled;
 }
 
-void nsIPresShell::AddAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
+void PresShell::AddAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
   if (aWeakFrame->GetFrame()) {
     aWeakFrame->GetFrame()->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
   }
   aWeakFrame->SetPreviousWeakFrame(mAutoWeakFrames);
   mAutoWeakFrames = aWeakFrame;
 }
 
-void nsIPresShell::AddWeakFrame(WeakFrame* aWeakFrame) {
+void PresShell::AddWeakFrame(WeakFrame* aWeakFrame) {
   if (aWeakFrame->GetFrame()) {
     aWeakFrame->GetFrame()->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
   }
   MOZ_ASSERT(!mWeakFrames.GetEntry(aWeakFrame));
   mWeakFrames.PutEntry(aWeakFrame);
 }
 
-void nsIPresShell::RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
+void PresShell::RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
   if (mAutoWeakFrames == aWeakFrame) {
     mAutoWeakFrames = aWeakFrame->GetPreviousWeakFrame();
     return;
   }
   AutoWeakFrame* nextWeak = mAutoWeakFrames;
   while (nextWeak && nextWeak->GetPreviousWeakFrame() != aWeakFrame) {
     nextWeak = nextWeak->GetPreviousWeakFrame();
   }
   if (nextWeak) {
     nextWeak->SetPreviousWeakFrame(aWeakFrame->GetPreviousWeakFrame());
   }
 }
 
-void nsIPresShell::RemoveWeakFrame(WeakFrame* aWeakFrame) {
+void PresShell::RemoveWeakFrame(WeakFrame* aWeakFrame) {
   MOZ_ASSERT(mWeakFrames.GetEntry(aWeakFrame));
   mWeakFrames.RemoveEntry(aWeakFrame);
 }
 
-already_AddRefed<nsFrameSelection> nsIPresShell::FrameSelection() {
+already_AddRefed<nsFrameSelection> PresShell::FrameSelection() {
   RefPtr<nsFrameSelection> ret = mSelection;
   return ret.forget();
 }
 
 //----------------------------------------------------------------------
 
 static bool sSynthMouseMove = true;
 static uint32_t sNextPresShellId;
@@ -890,17 +890,17 @@ NS_IMPL_RELEASE(PresShell)
 
 PresShell::~PresShell() {
   MOZ_RELEASE_ASSERT(!mForbiddenToFlush,
                      "Flag should only be set temporarily, while doing things "
                      "that shouldn't cause destruction");
   MOZ_LOG(gLog, LogLevel::Debug, ("PresShell::~PresShell this=%p", this));
 
   if (!mHaveShutDown) {
-    MOZ_ASSERT_UNREACHABLE("Someone did not call nsIPresShell::destroy");
+    MOZ_ASSERT_UNREACHABLE("Someone did not call PresShell::Destroy()");
     Destroy();
   }
 
   NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
                "Huh, event content left on the stack in pres shell dtor!");
   NS_ASSERTION(mFirstCallbackEventRequest == nullptr &&
                    mLastCallbackEventRequest == nullptr,
                "post-reflow queues not empty.  This means we're leaking");
@@ -1376,43 +1376,43 @@ void PresShell::Destroy() {
     mPresContext->SetLinkHandler(nullptr);
   }
 
   mHaveShutDown = true;
 
   mTouchManager.Destroy();
 }
 
-void nsIPresShell::StopObservingRefreshDriver() {
+void PresShell::StopObservingRefreshDriver() {
   nsRefreshDriver* rd = mPresContext->RefreshDriver();
   if (mResizeEventPending) {
     rd->RemoveResizeEventFlushObserver(static_cast<PresShell*>(this));
   }
   if (mObservingLayoutFlushes) {
     rd->RemoveLayoutFlushObserver(static_cast<PresShell*>(this));
   }
   if (mObservingStyleFlushes) {
     rd->RemoveStyleFlushObserver(static_cast<PresShell*>(this));
   }
 }
 
-void nsIPresShell::StartObservingRefreshDriver() {
+void PresShell::StartObservingRefreshDriver() {
   nsRefreshDriver* rd = mPresContext->RefreshDriver();
   if (mResizeEventPending) {
     rd->AddResizeEventFlushObserver(static_cast<PresShell*>(this));
   }
   if (mObservingLayoutFlushes) {
     rd->AddLayoutFlushObserver(static_cast<PresShell*>(this));
   }
   if (mObservingStyleFlushes) {
     rd->AddStyleFlushObserver(static_cast<PresShell*>(this));
   }
 }
 
-nsRefreshDriver* nsIPresShell::GetRefreshDriver() const {
+nsRefreshDriver* PresShell::GetRefreshDriver() const {
   return mPresContext ? mPresContext->RefreshDriver() : nullptr;
 }
 
 void PresShell::SetAuthorStyleDisabled(bool aStyleDisabled) {
   if (aStyleDisabled != StyleSet()->GetAuthorStyleDisabled()) {
     StyleSet()->SetAuthorStyleDisabled(aStyleDisabled);
     mDocument->ApplicableStylesChanged();
 
@@ -1635,30 +1635,30 @@ PresShell::RepaintSelection(RawSelection
     return NS_OK;
   }
 
   RefPtr<nsFrameSelection> frameSelection = mSelection;
   return frameSelection->RepaintSelection(ToSelectionType(aRawSelectionType));
 }
 
 // Make shell be a document observer
-void nsIPresShell::BeginObservingDocument() {
+void PresShell::BeginObservingDocument() {
   if (mDocument && !mIsDestroying) {
     mIsObservingDocument = true;
     if (mIsDocumentGone) {
       NS_WARNING(
           "Adding a presshell that was disconnected from the document "
           "as a document observer?  Sounds wrong...");
       mIsDocumentGone = false;
     }
   }
 }
 
 // Make shell stop being a document observer
-void nsIPresShell::EndObservingDocument() {
+void PresShell::EndObservingDocument() {
   // XXXbz do we need to tell the frame constructor that the document
   // is gone, perhaps?  Except for printing it's NOT gone, sometimes.
   mIsDocumentGone = true;
   mIsObservingDocument = false;
 }
 
 #ifdef DEBUG_kipp
 char* nsPresShell_ReflowStackPointerTop;
@@ -2047,17 +2047,17 @@ static nsIContent* GetNativeAnonymousSub
   // from the current event content stack from ContentRemoved, so it can
   // actually happen, see bug 1510208.
   while (current && !current->IsRootOfNativeAnonymousSubtree()) {
     current = current->GetFlattenedTreeParent();
   }
   return current;
 }
 
-void nsIPresShell::NativeAnonymousContentRemoved(nsIContent* aAnonContent) {
+void PresShell::NativeAnonymousContentRemoved(nsIContent* aAnonContent) {
   MOZ_ASSERT(aAnonContent->IsRootOfNativeAnonymousSubtree());
   if (nsIContent* root = GetNativeAnonymousSubtreeRoot(mCurrentEventContent)) {
     if (aAnonContent == root) {
       mCurrentEventContent = aAnonContent->GetFlattenedTreeParent();
       mCurrentEventFrame = nullptr;
     }
   }
 
@@ -2067,17 +2067,17 @@ void nsIPresShell::NativeAnonymousConten
     if (aAnonContent == anon) {
       mCurrentEventContentStack.ReplaceObjectAt(
           aAnonContent->GetFlattenedTreeParent(), i);
       mCurrentEventFrameStack[i] = nullptr;
     }
   }
 }
 
-void nsIPresShell::SetIgnoreFrameDestruction(bool aIgnore) {
+void PresShell::SetIgnoreFrameDestruction(bool aIgnore) {
   if (mDocument) {
     // We need to tell the ImageLoader to drop all its references to frames
     // because they're about to go away and it won't get notifications of that.
     mDocument->StyleImageLoader()->ClearFrames(mPresContext);
   }
   mIgnoreFrameDestruction = aIgnore;
 }
 
@@ -2125,30 +2125,30 @@ void PresShell::NotifyDestroyingFrame(ns
     nsIScrollableFrame* scrollableFrame = do_QueryFrame(aFrame);
     if (scrollableFrame) {
       mPendingScrollAnchorSelection.RemoveEntry(scrollableFrame);
       mPendingScrollAnchorAdjustment.RemoveEntry(scrollableFrame);
     }
   }
 }
 
-already_AddRefed<nsCaret> nsIPresShell::GetCaret() const {
+already_AddRefed<nsCaret> PresShell::GetCaret() const {
   RefPtr<nsCaret> caret = mCaret;
   return caret.forget();
 }
 
 already_AddRefed<AccessibleCaretEventHub>
-nsIPresShell::GetAccessibleCaretEventHub() const {
+PresShell::GetAccessibleCaretEventHub() const {
   RefPtr<AccessibleCaretEventHub> eventHub = mAccessibleCaretEventHub;
   return eventHub.forget();
 }
 
-void nsIPresShell::SetCaret(nsCaret* aNewCaret) { mCaret = aNewCaret; }
-
-void nsIPresShell::RestoreCaret() { mCaret = mOriginalCaret; }
+void PresShell::SetCaret(nsCaret* aNewCaret) { mCaret = aNewCaret; }
+
+void PresShell::RestoreCaret() { mCaret = mOriginalCaret; }
 
 NS_IMETHODIMP PresShell::SetCaretEnabled(bool aInEnable) {
   bool oldEnabled = mCaretEnabled;
 
   mCaretEnabled = aInEnable;
 
   if (mCaretEnabled != oldEnabled) {
     MOZ_ASSERT(mCaret);
@@ -2410,40 +2410,40 @@ nsresult PresShell::CheckVisibilityConte
 
   *aRetval = false;
   DoCheckVisibility(mPresContext, aNode, aStartOffset, aEndOffset, aRetval);
   return NS_OK;
 }
 
 // end implementations nsISelectionController
 
-nsIFrame* nsIPresShell::GetRootScrollFrame() const {
+nsIFrame* PresShell::GetRootScrollFrame() const {
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   // Ensure root frame is a viewport frame
   if (!rootFrame || !rootFrame->IsViewportFrame()) return nullptr;
   nsIFrame* theFrame = rootFrame->PrincipalChildList().FirstChild();
   if (!theFrame || !theFrame->IsScrollFrame()) return nullptr;
   return theFrame;
 }
 
-nsIScrollableFrame* nsIPresShell::GetRootScrollFrameAsScrollable() const {
+nsIScrollableFrame* PresShell::GetRootScrollFrameAsScrollable() const {
   nsIFrame* frame = GetRootScrollFrame();
   if (!frame) return nullptr;
   nsIScrollableFrame* scrollableFrame = do_QueryFrame(frame);
   NS_ASSERTION(scrollableFrame,
                "All scroll frames must implement nsIScrollableFrame");
   return scrollableFrame;
 }
 
-nsIPageSequenceFrame* nsIPresShell::GetPageSequenceFrame() const {
+nsIPageSequenceFrame* PresShell::GetPageSequenceFrame() const {
   nsIFrame* frame = mFrameConstructor->GetPageSequenceFrame();
   return do_QueryFrame(frame);
 }
 
-nsCanvasFrame* nsIPresShell::GetCanvasFrame() const {
+nsCanvasFrame* PresShell::GetCanvasFrame() const {
   nsIFrame* frame = mFrameConstructor->GetDocElementContainingBlock();
   return do_QueryFrame(frame);
 }
 
 void PresShell::RestoreRootScrollPosition() {
   nsIScrollableFrame* scrollableFrame = GetRootScrollFrameAsScrollable();
   if (scrollableFrame) {
     scrollableFrame->ScrollToRestoredPosition();
@@ -2545,36 +2545,36 @@ void PresShell::VerifyHasDirtyRootAncest
   }
 
   MOZ_ASSERT_UNREACHABLE(
       "Frame has dirty bits set but isn't scheduled to be "
       "reflowed?");
 }
 #endif
 
-void nsIPresShell::PostPendingScrollAnchorSelection(
+void PresShell::PostPendingScrollAnchorSelection(
     mozilla::layout::ScrollAnchorContainer* aContainer) {
   mPendingScrollAnchorSelection.PutEntry(aContainer->ScrollableFrame());
 }
 
-void nsIPresShell::FlushPendingScrollAnchorSelections() {
+void PresShell::FlushPendingScrollAnchorSelections() {
   for (auto iter = mPendingScrollAnchorSelection.Iter(); !iter.Done();
        iter.Next()) {
     nsIScrollableFrame* scroll = iter.Get()->GetKey();
     scroll->Anchor()->SelectAnchor();
   }
   mPendingScrollAnchorSelection.Clear();
 }
 
-void nsIPresShell::PostPendingScrollAnchorAdjustment(
+void PresShell::PostPendingScrollAnchorAdjustment(
     ScrollAnchorContainer* aContainer) {
   mPendingScrollAnchorAdjustment.PutEntry(aContainer->ScrollableFrame());
 }
 
-void nsIPresShell::FlushPendingScrollAnchorAdjustments() {
+void PresShell::FlushPendingScrollAnchorAdjustments() {
   for (auto iter = mPendingScrollAnchorAdjustment.Iter(); !iter.Done();
        iter.Next()) {
     nsIScrollableFrame* scroll = iter.Get()->GetKey();
     scroll->Anchor()->ApplyAdjustments();
   }
   mPendingScrollAnchorAdjustment.Clear();
 }
 
@@ -2751,49 +2751,48 @@ void PresShell::FrameNeedsToContinueRefl
           nsLayoutUtils::IsProperAncestorFrame(mCurrentReflowRoot, aFrame),
       "Frame passed in is not the descendant of mCurrentReflowRoot");
   NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW,
                "Frame passed in not in reflow?");
 
   mFramesToDirty.PutEntry(aFrame);
 }
 
-already_AddRefed<nsIContent> nsIPresShell::GetContentForScrolling() const {
+already_AddRefed<nsIContent> PresShell::GetContentForScrolling() const {
   if (nsCOMPtr<nsIContent> focused = GetFocusedContentInOurWindow()) {
     return focused.forget();
   }
   return GetSelectedContentForScrolling();
 }
 
-already_AddRefed<nsIContent> nsIPresShell::GetSelectedContentForScrolling()
-    const {
+already_AddRefed<nsIContent> PresShell::GetSelectedContentForScrolling() const {
   nsCOMPtr<nsIContent> selectedContent;
   if (mSelection) {
     Selection* domSelection = mSelection->GetSelection(SelectionType::eNormal);
     if (domSelection) {
       selectedContent =
           nsIContent::FromNodeOrNull(domSelection->GetFocusNode());
     }
   }
   return selectedContent.forget();
 }
 
-nsIScrollableFrame* nsIPresShell::GetNearestScrollableFrame(
+nsIScrollableFrame* PresShell::GetNearestScrollableFrame(
     nsIFrame* aFrame, ScrollableDirection aDirection) {
   if (aDirection == ScrollableDirection::Either) {
     return nsLayoutUtils::GetNearestScrollableFrame(aFrame);
   }
 
   return nsLayoutUtils::GetNearestScrollableFrameForDirection(
       aFrame, aDirection == ScrollableDirection::Vertical
                   ? nsLayoutUtils::eVertical
                   : nsLayoutUtils::eHorizontal);
 }
 
-nsIScrollableFrame* nsIPresShell::GetScrollableFrameToScrollForContent(
+nsIScrollableFrame* PresShell::GetScrollableFrameToScrollForContent(
     nsIContent* aContent, ScrollableDirection aDirection) {
   nsIScrollableFrame* scrollFrame = nullptr;
   if (aContent) {
     nsIFrame* startFrame = aContent->GetPrimaryFrame();
     if (startFrame) {
       scrollFrame = startFrame->GetScrollTargetFrame();
       if (scrollFrame) {
         startFrame = scrollFrame->GetScrolledFrame();
@@ -2807,23 +2806,23 @@ nsIScrollableFrame* nsIPresShell::GetScr
       return nullptr;
     }
     scrollFrame =
         GetNearestScrollableFrame(scrollFrame->GetScrolledFrame(), aDirection);
   }
   return scrollFrame;
 }
 
-nsIScrollableFrame* nsIPresShell::GetScrollableFrameToScroll(
+nsIScrollableFrame* PresShell::GetScrollableFrameToScroll(
     ScrollableDirection aDirection) {
   nsCOMPtr<nsIContent> content = GetContentForScrolling();
   return GetScrollableFrameToScrollForContent(content.get(), aDirection);
 }
 
-void nsIPresShell::CancelAllPendingReflows() {
+void PresShell::CancelAllPendingReflows() {
   mDirtyRoots.Clear();
 
   if (mObservingLayoutFlushes) {
     GetPresContext()->RefreshDriver()->RemoveLayoutFlushObserver(
         static_cast<PresShell*>(this));
     mObservingLayoutFlushes = false;
   }
 
@@ -2834,19 +2833,19 @@ static bool DestroyFramesAndStyleDataFor
     Element* aElement, nsPresContext& aPresContext,
     RestyleManager::IncludeRoot aIncludeRoot) {
   bool didReconstruct =
       aPresContext.FrameConstructor()->DestroyFramesFor(aElement);
   RestyleManager::ClearServoDataFromSubtree(aElement, aIncludeRoot);
   return didReconstruct;
 }
 
-void nsIPresShell::SlotAssignmentWillChange(Element& aElement,
-                                            HTMLSlotElement* aOldSlot,
-                                            HTMLSlotElement* aNewSlot) {
+void PresShell::SlotAssignmentWillChange(Element& aElement,
+                                         HTMLSlotElement* aOldSlot,
+                                         HTMLSlotElement* aNewSlot) {
   MOZ_ASSERT(aOldSlot != aNewSlot);
 
   if (MOZ_UNLIKELY(!mDidInitialize)) {
     return;
   }
 
   // If the old slot is about to become empty, let layout know that it needs to
   // do work.
@@ -2897,17 +2896,17 @@ static void AssertNoFramesInSubtree(nsIC
           AssertNoFramesInSubtree(child);
         }
       }
     }
   }
 }
 #endif
 
-void nsIPresShell::DestroyFramesForAndRestyle(Element* aElement) {
+void PresShell::DestroyFramesForAndRestyle(Element* aElement) {
 #ifdef DEBUG
   auto postCondition =
       mozilla::MakeScopeExit([&]() { AssertNoFramesInSubtree(aElement); });
 #endif
 
   MOZ_ASSERT(aElement);
   if (MOZ_UNLIKELY(!mDidInitialize)) {
     return;
@@ -2934,42 +2933,41 @@ void nsIPresShell::DestroyFramesForAndRe
       didReconstruct ? nsChangeHint(0) : nsChangeHint_ReconstructFrame;
 
   mPresContext->RestyleManager()->PostRestyleEvent(
       aElement, RestyleHint::RestyleSubtree(), changeHint);
 
   --mChangeNestCount;
 }
 
-void nsIPresShell::PostRecreateFramesFor(Element* aElement) {
+void PresShell::PostRecreateFramesFor(Element* aElement) {
   if (MOZ_UNLIKELY(!mDidInitialize)) {
     // Nothing to do here. In fact, if we proceed and aElement is the root, we
     // will crash.
     return;
   }
 
   mPresContext->RestyleManager()->PostRestyleEvent(
       aElement, RestyleHint{0}, nsChangeHint_ReconstructFrame);
 }
 
-void nsIPresShell::RestyleForAnimation(Element* aElement, RestyleHint aHint) {
+void PresShell::RestyleForAnimation(Element* aElement, RestyleHint aHint) {
   // Now that we no longer have separate non-animation and animation
   // restyles, this method having a distinct identity is less important,
   // but it still seems useful to offer as a "more public" API and as a
   // chokepoint for these restyles to go through.
   mPresContext->RestyleManager()->PostRestyleEvent(aElement, aHint,
                                                    nsChangeHint(0));
 }
 
-void nsIPresShell::SetForwardingContainer(
-    const WeakPtr<nsDocShell>& aContainer) {
+void PresShell::SetForwardingContainer(const WeakPtr<nsDocShell>& aContainer) {
   mForwardingContainer = aContainer;
 }
 
-void nsIPresShell::ClearFrameRefs(nsIFrame* aFrame) {
+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));
@@ -2984,17 +2982,17 @@ void nsIPresShell::ClearFrameRefs(nsIFra
       toRemove.AppendElement(weakFrame);
     }
   }
   for (WeakFrame* weakFrame : toRemove) {
     weakFrame->Clear(static_cast<PresShell*>(this));
   }
 }
 
-already_AddRefed<gfxContext> nsIPresShell::CreateReferenceRenderingContext() {
+already_AddRefed<gfxContext> PresShell::CreateReferenceRenderingContext() {
   nsDeviceContext* devCtx = mPresContext->DeviceContext();
   RefPtr<gfxContext> rc;
   if (mPresContext->IsScreen()) {
     rc = gfxContext::CreateOrNull(
         gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget().get());
   } else {
     // We assume the devCtx has positive width and height for this call.
     // However, width and height, may be outside of the reasonable range
@@ -3513,21 +3511,20 @@ void PresShell::DoScrollContentIntoView(
 
   frameBounds.Inflate(scrollMargin);
 
   ScrollFrameRectIntoView(container, frameBounds, data->mContentScrollVAxis,
                           data->mContentScrollHAxis,
                           data->mContentToScrollToFlags);
 }
 
-bool nsIPresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
-                                           const nsRect& aRect,
-                                           ScrollAxis aVertical,
-                                           ScrollAxis aHorizontal,
-                                           ScrollFlags aScrollFlags) {
+bool PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
+                                        ScrollAxis aVertical,
+                                        ScrollAxis aHorizontal,
+                                        ScrollFlags aScrollFlags) {
   bool didScroll = false;
   // This function needs to work even if rect has a width or height of 0.
   nsRect rect = aRect;
   nsIFrame* container = aFrame;
   // Walk up the frame hierarchy scrolling the rect into view and
   // keeping rect relative to container
   do {
     nsIScrollableFrame* sf = do_QueryFrame(container);
@@ -3698,17 +3695,17 @@ void PresShell::ScheduleViewManagerFlush
 
   nsPresContext* presContext = GetPresContext();
   if (presContext) {
     presContext->RefreshDriver()->ScheduleViewManagerFlush();
   }
   SetNeedLayoutFlush();
 }
 
-void nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) {
+void PresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) {
   AUTO_PROFILER_TRACING_DOCSHELL("Paint", "DispatchSynthMouseMove", GRAPHICS,
                                  mPresContext->GetDocShell());
   nsEventStatus status = nsEventStatus_eIgnore;
   nsView* targetView = nsView::GetViewFor(aEvent->mWidget);
   if (!targetView) return;
   RefPtr<nsViewManager> viewManager = targetView->GetViewManager();
   viewManager->DispatchEvent(aEvent, targetView, &status);
 }
@@ -3803,30 +3800,30 @@ nsresult PresShell::CaptureHistoryState(
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   if (!rootFrame) return NS_OK;
 
   mFrameConstructor->CaptureFrameState(rootFrame, historyState);
 
   return NS_OK;
 }
 
-void nsIPresShell::ScheduleBeforeFirstPaint() {
+void PresShell::ScheduleBeforeFirstPaint() {
   if (!mDocument->IsResourceDoc()) {
     // Notify observers that a new page is about to be drawn. Execute this
     // as soon as it is safe to run JS, which is guaranteed to be before we
     // go back to the event loop and actually draw the page.
     MOZ_LOG(gLog, LogLevel::Debug,
             ("PresShell::ScheduleBeforeFirstPaint this=%p", this));
 
     nsContentUtils::AddScriptRunner(
         new nsBeforeFirstPaintDispatcher(mDocument));
   }
 }
 
-void nsIPresShell::UnsuppressAndInvalidate() {
+void PresShell::UnsuppressAndInvalidate() {
   // Note: We ignore the EnsureVisible check for resource documents, because
   // they won't have a docshell, so they'll always fail EnsureVisible.
   if ((!mDocument->IsResourceDoc() && !mPresContext->EnsureVisible()) ||
       mHaveShutDown) {
     // No point; we're about to be torn down anyway.
     return;
   }
 
@@ -3862,17 +3859,17 @@ void PresShell::UnsuppressPainting() {
   // go ahead and unlock now.
   if (!mDirtyRoots.IsEmpty())
     mShouldUnsuppressPainting = true;
   else
     UnsuppressAndInvalidate();
 }
 
 // Post a request to handle an arbitrary callback after reflow has finished.
-nsresult nsIPresShell::PostReflowCallback(nsIReflowCallback* aCallback) {
+nsresult PresShell::PostReflowCallback(nsIReflowCallback* aCallback) {
   void* result = AllocateByObjectID(eArenaObjectID_nsCallbackEventRequest,
                                     sizeof(nsCallbackEventRequest));
   nsCallbackEventRequest* request = (nsCallbackEventRequest*)result;
 
   request->callback = aCallback;
   request->next = nullptr;
 
   if (mLastCallbackEventRequest) {
@@ -3880,17 +3877,17 @@ nsresult nsIPresShell::PostReflowCallbac
   } else {
     mFirstCallbackEventRequest = request;
     mLastCallbackEventRequest = request;
   }
 
   return NS_OK;
 }
 
-void nsIPresShell::CancelReflowCallback(nsIReflowCallback* aCallback) {
+void PresShell::CancelReflowCallback(nsIReflowCallback* aCallback) {
   nsCallbackEventRequest* before = nullptr;
   nsCallbackEventRequest* node = mFirstCallbackEventRequest;
   while (node) {
     nsIReflowCallback* callback = node->callback;
 
     if (callback == aCallback) {
       nsCallbackEventRequest* toFree = node;
       if (node == mFirstCallbackEventRequest) {
@@ -3909,17 +3906,17 @@ void nsIPresShell::CancelReflowCallback(
       FreeByObjectID(eArenaObjectID_nsCallbackEventRequest, toFree);
     } else {
       before = node;
       node = node->next;
     }
   }
 }
 
-void nsIPresShell::CancelPostedReflowCallbacks() {
+void PresShell::CancelPostedReflowCallbacks() {
   while (mFirstCallbackEventRequest) {
     nsCallbackEventRequest* node = mFirstCallbackEventRequest;
     mFirstCallbackEventRequest = node->next;
     if (!mFirstCallbackEventRequest) {
       mLastCallbackEventRequest = nullptr;
     }
     nsIReflowCallback* callback = node->callback;
     FreeByObjectID(eArenaObjectID_nsCallbackEventRequest, node);
@@ -3949,17 +3946,17 @@ void PresShell::HandlePostedReflowCallba
 
   FlushType flushType =
       aInterruptible ? FlushType::InterruptibleLayout : FlushType::Layout;
   if (shouldFlush && !mIsDestroying) {
     FlushPendingNotifications(flushType);
   }
 }
 
-bool nsIPresShell::IsSafeToFlush() const {
+bool PresShell::IsSafeToFlush() const {
   // Not safe if we are getting torn down, reflowing, or in the middle of frame
   // construction.
   if (mIsReflowing || mChangeNestCount || mIsDestroying) {
     return false;
   }
 
   // Not safe if we are painting
   if (nsViewManager* viewManager = GetViewManager()) {
@@ -3968,17 +3965,17 @@ bool nsIPresShell::IsSafeToFlush() const
     if (isPainting) {
       return false;
     }
   }
 
   return true;
 }
 
-void nsIPresShell::NotifyFontFaceSetOnRefresh() {
+void PresShell::NotifyFontFaceSetOnRefresh() {
   if (FontFaceSet* set = mDocument->GetFonts()) {
     set->DidRefresh();
   }
 }
 
 void PresShell::DoFlushPendingNotifications(FlushType aType) {
   // by default, flush animations if aType >= FlushType::Style
   mozilla::ChangesToFlush flush(aType, aType >= FlushType::Style);
@@ -4390,22 +4387,22 @@ 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 nsIPresShell::NotifyCounterStylesAreDirty() {
+void PresShell::NotifyCounterStylesAreDirty() {
   nsAutoCauseReflowNotifier reflowNotifier(static_cast<PresShell*>(this));
   mFrameConstructor->NotifyCounterStylesAreDirty();
 }
 
-bool nsIPresShell::FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const {
+bool PresShell::FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const {
   return mDirtyRoots.FrameIsAncestorOfDirtyRoot(aFrame);
 }
 
 void PresShell::ReconstructFrames() {
   MOZ_ASSERT(!mFrameConstructor->GetRootFrame() || mDidInitialize,
              "Must not have root frame before initial reflow");
   if (!mDidInitialize || mIsDestroying) {
     // Nothing to do here
@@ -6157,26 +6154,26 @@ void PresShell::SetCapturingContent(nsIC
         !!(aFlags & CaptureFlags::RetargetToElement) ||
         !!(aFlags & CaptureFlags::PointerLock);
     sCapturingContentInfo.mPreventDrag =
         !!(aFlags & CaptureFlags::PreventDragStart);
     sCapturingContentInfo.mPointerLock = !!(aFlags & CaptureFlags::PointerLock);
   }
 }
 
-nsIContent* nsIPresShell::GetCurrentEventContent() {
+nsIContent* PresShell::GetCurrentEventContent() {
   if (mCurrentEventContent &&
       mCurrentEventContent->GetComposedDoc() != mDocument) {
     mCurrentEventContent = nullptr;
     mCurrentEventFrame = nullptr;
   }
   return mCurrentEventContent;
 }
 
-nsIFrame* nsIPresShell::GetCurrentEventFrame() {
+nsIFrame* PresShell::GetCurrentEventFrame() {
   if (MOZ_UNLIKELY(mIsDestroying)) {
     return nullptr;
   }
 
   // GetCurrentEventContent() makes sure the content is still in the
   // same document that this pres shell belongs to. If not, then the
   // frame shouldn't get an event, nor should we even assume its safe
   // to try and find the frame.
@@ -6184,41 +6181,40 @@ nsIFrame* nsIPresShell::GetCurrentEventF
   if (!mCurrentEventFrame && content) {
     mCurrentEventFrame = content->GetPrimaryFrame();
     MOZ_ASSERT(!mCurrentEventFrame ||
                mCurrentEventFrame->PresContext()->GetPresShell() == this);
   }
   return mCurrentEventFrame;
 }
 
-already_AddRefed<nsIContent> nsIPresShell::GetEventTargetContent(
+already_AddRefed<nsIContent> PresShell::GetEventTargetContent(
     WidgetEvent* aEvent) {
   nsCOMPtr<nsIContent> content = GetCurrentEventContent();
   if (!content) {
     nsIFrame* currentEventFrame = GetCurrentEventFrame();
     if (currentEventFrame) {
       currentEventFrame->GetContentForEvent(aEvent, getter_AddRefs(content));
       NS_ASSERTION(!content || content->GetComposedDoc() == mDocument,
                    "handing out content from a different doc");
     }
   }
   return content.forget();
 }
 
-void nsIPresShell::PushCurrentEventInfo(nsIFrame* aFrame,
-                                        nsIContent* aContent) {
+void PresShell::PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent) {
   if (mCurrentEventFrame || mCurrentEventContent) {
     mCurrentEventFrameStack.InsertElementAt(0, mCurrentEventFrame);
     mCurrentEventContentStack.InsertObjectAt(mCurrentEventContent, 0);
   }
   mCurrentEventFrame = aFrame;
   mCurrentEventContent = aContent;
 }
 
-void nsIPresShell::PopCurrentEventInfo() {
+void PresShell::PopCurrentEventInfo() {
   mCurrentEventFrame = nullptr;
   mCurrentEventContent = nullptr;
 
   if (0 != mCurrentEventFrameStack.Length()) {
     mCurrentEventFrame = mCurrentEventFrameStack.ElementAt(0);
     mCurrentEventFrameStack.RemoveElementAt(0);
     mCurrentEventContent = mCurrentEventContentStack.ObjectAt(0);
     mCurrentEventContentStack.RemoveObjectAt(0);
@@ -6265,18 +6261,17 @@ PresShell::GetFocusedDOMWindowInOurWindo
   NS_ENSURE_TRUE(rootWindow, nullptr);
   nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
   nsFocusManager::GetFocusedDescendant(rootWindow,
                                        nsFocusManager::eIncludeAllDescendants,
                                        getter_AddRefs(focusedWindow));
   return focusedWindow.forget();
 }
 
-already_AddRefed<nsIContent> nsIPresShell::GetFocusedContentInOurWindow()
-    const {
+already_AddRefed<nsIContent> PresShell::GetFocusedContentInOurWindow() const {
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm && mDocument) {
     RefPtr<Element> focusedElement;
     fm->GetFocusedElementForWindow(mDocument->GetWindow(), false, nullptr,
                                    getter_AddRefs(focusedElement));
     return focusedElement.forget();
   }
   return nullptr;
@@ -8945,47 +8940,47 @@ void PresShell::Thaw() {
 
   UnsuppressPainting();
 }
 
 //--------------------------------------------------------
 // Start of protected and private methods on the PresShell
 //--------------------------------------------------------
 
-void nsIPresShell::MaybeScheduleReflow() {
+void PresShell::MaybeScheduleReflow() {
   ASSERT_REFLOW_SCHEDULED_STATE();
   if (mObservingLayoutFlushes || mIsDestroying || mIsReflowing ||
       mDirtyRoots.IsEmpty())
     return;
 
   if (!mPresContext->HasPendingInterrupt() || !ScheduleReflowOffTimer()) {
     ScheduleReflow();
   }
 
   ASSERT_REFLOW_SCHEDULED_STATE();
 }
 
-void nsIPresShell::ScheduleReflow() {
+void PresShell::ScheduleReflow() {
   ASSERT_REFLOW_SCHEDULED_STATE();
   DoObserveLayoutFlushes();
   ASSERT_REFLOW_SCHEDULED_STATE();
 }
 
-void nsIPresShell::WillCauseReflow() {
+void PresShell::WillCauseReflow() {
   nsContentUtils::AddScriptBlocker();
   ++mChangeNestCount;
 }
 
-void nsIPresShell::DidCauseReflow() {
+void PresShell::DidCauseReflow() {
   NS_ASSERTION(mChangeNestCount != 0, "Unexpected call to DidCauseReflow()");
   --mChangeNestCount;
   nsContentUtils::RemoveScriptBlocker();
 }
 
-void nsIPresShell::WillDoReflow() {
+void PresShell::WillDoReflow() {
   mDocument->FlushUserFontSet();
 
   mPresContext->FlushCounterStyles();
 
   mPresContext->FlushFontFeatureValues();
 
   mLastReflowStart = GetPerformanceNowUnclamped();
 }
@@ -9005,39 +9000,39 @@ void PresShell::DidDoReflow(bool aInterr
 
   if (sSynthMouseMove) {
     SynthesizeMouseMove(false);
   }
 
   mPresContext->NotifyMissingFonts();
 }
 
-DOMHighResTimeStamp nsIPresShell::GetPerformanceNowUnclamped() {
+DOMHighResTimeStamp PresShell::GetPerformanceNowUnclamped() {
   DOMHighResTimeStamp now = 0;
 
   if (nsPIDOMWindowInner* window = mDocument->GetInnerWindow()) {
     Performance* perf = window->GetPerformance();
 
     if (perf) {
       now = perf->NowUnclamped();
     }
   }
 
   return now;
 }
 
-void nsIPresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell) {
+void PresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell) {
   RefPtr<PresShell> self = static_cast<PresShell*>(aPresShell);
 
   MOZ_ASSERT(aTimer == self->mReflowContinueTimer, "Unexpected timer");
   self->mReflowContinueTimer = nullptr;
   self->ScheduleReflow();
 }
 
-bool nsIPresShell::ScheduleReflowOffTimer() {
+bool PresShell::ScheduleReflowOffTimer() {
   MOZ_ASSERT(!mObservingLayoutFlushes, "Shouldn't get here");
   ASSERT_REFLOW_SCHEDULED_STATE();
 
   if (!mReflowContinueTimer) {
     nsresult rv = NS_NewTimerWithFuncCallback(
         getter_AddRefs(mReflowContinueTimer), sReflowContinueCallback, this, 30,
         nsITimer::TYPE_ONE_SHOT, "sReflowContinueCallback",
         mDocument->EventTargetFor(TaskCategory::Other));
@@ -9455,65 +9450,62 @@ PresShell::Observe(nsISupports* aSubject
     mPresContext->ForceReflowForFontInfoUpdate();
     return NS_OK;
   }
 
   NS_WARNING("unrecognized topic in PresShell::Observe");
   return NS_ERROR_FAILURE;
 }
 
-bool nsIPresShell::AddRefreshObserver(nsARefreshObserver* aObserver,
-                                      FlushType aFlushType) {
+bool PresShell::AddRefreshObserver(nsARefreshObserver* aObserver,
+                                   FlushType aFlushType) {
   nsPresContext* presContext = GetPresContext();
   if (MOZ_UNLIKELY(!presContext)) {
     return false;
   }
   presContext->RefreshDriver()->AddRefreshObserver(aObserver, aFlushType);
   return true;
 }
 
-bool nsIPresShell::RemoveRefreshObserver(nsARefreshObserver* aObserver,
-                                         FlushType aFlushType) {
+bool PresShell::RemoveRefreshObserver(nsARefreshObserver* aObserver,
+                                      FlushType aFlushType) {
   nsPresContext* presContext = GetPresContext();
   return presContext && presContext->RefreshDriver()->RemoveRefreshObserver(
                             aObserver, aFlushType);
 }
 
-/* virtual */
-bool nsIPresShell::AddPostRefreshObserver(nsAPostRefreshObserver* aObserver) {
+bool PresShell::AddPostRefreshObserver(nsAPostRefreshObserver* aObserver) {
   nsPresContext* presContext = GetPresContext();
   if (!presContext) {
     return false;
   }
   presContext->RefreshDriver()->AddPostRefreshObserver(aObserver);
   return true;
 }
 
-/* virtual */
-bool nsIPresShell::RemovePostRefreshObserver(
-    nsAPostRefreshObserver* aObserver) {
+bool PresShell::RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver) {
   nsPresContext* presContext = GetPresContext();
   if (!presContext) {
     return false;
   }
   presContext->RefreshDriver()->RemovePostRefreshObserver(aObserver);
   return true;
 }
 
-void nsIPresShell::DoObserveStyleFlushes() {
+void PresShell::DoObserveStyleFlushes() {
   MOZ_ASSERT(!ObservingStyleFlushes());
   mObservingStyleFlushes = true;
 
   if (MOZ_LIKELY(!mDocument->GetBFCacheEntry())) {
     mPresContext->RefreshDriver()->AddStyleFlushObserver(
         static_cast<PresShell*>(this));
   }
 }
 
-void nsIPresShell::DoObserveLayoutFlushes() {
+void PresShell::DoObserveLayoutFlushes() {
   MOZ_ASSERT(!ObservingLayoutFlushes());
   mObservingLayoutFlushes = true;
 
   if (MOZ_LIKELY(!mDocument->GetBFCacheEntry())) {
     mPresContext->RefreshDriver()->AddLayoutFlushObserver(
         static_cast<PresShell*>(this));
   }
 }
@@ -10335,17 +10327,17 @@ void ReflowCountMgr::DisplayDiffsInTotal
     iter.Data()->SetTotalsCache();
   }
 
   mCycledOnce = true;
 }
 
 #endif  // MOZ_REFLOW_PERF
 
-nsIFrame* nsIPresShell::GetAbsoluteContainingBlock(nsIFrame* aFrame) {
+nsIFrame* PresShell::GetAbsoluteContainingBlock(nsIFrame* aFrame) {
   return FrameConstructor()->GetAbsoluteContainingBlock(
       aFrame, nsCSSFrameConstructor::ABS_POS);
 }
 
 #ifdef ACCESSIBILITY
 
 // static
 bool PresShell::IsAccessibilityActive() { return GetAccService() != nullptr; }
@@ -10632,96 +10624,96 @@ bool PresShell::SetVisualViewportOffset(
             GetRootScrollFrameAsScrollable()) {
       ScrollAnchorContainer* container = rootScrollFrame->Anchor();
       container->UserScrolled();
     }
   }
   return didChange;
 }
 
-void nsIPresShell::ScrollToVisual(
-    const nsPoint& aVisualViewportOffset,
-    FrameMetrics::ScrollOffsetUpdateType aUpdateType, ScrollMode aMode) {
+void PresShell::ScrollToVisual(const nsPoint& aVisualViewportOffset,
+                               FrameMetrics::ScrollOffsetUpdateType aUpdateType,
+                               ScrollMode aMode) {
   MOZ_ASSERT(aMode == ScrollMode::Instant || aMode == ScrollMode::SmoothMsd);
 
   if (aMode == ScrollMode::SmoothMsd) {
     if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) {
       if (sf->SmoothScrollVisual(aVisualViewportOffset, aUpdateType)) {
         return;
       }
     }
   }
 
   // If the caller asked for instant scroll, or if we failed
   // to do a smooth scroll, do an instant scroll.
   SetPendingVisualScrollUpdate(aVisualViewportOffset, aUpdateType);
 }
 
-void nsIPresShell::SetPendingVisualScrollUpdate(
+void PresShell::SetPendingVisualScrollUpdate(
     const nsPoint& aVisualViewportOffset,
     FrameMetrics::ScrollOffsetUpdateType aUpdateType) {
   mPendingVisualScrollUpdate =
-      mozilla::Some(VisualScrollUpdate{aVisualViewportOffset, aUpdateType});
+      Some(VisualScrollUpdate{aVisualViewportOffset, aUpdateType});
 
   // The pending update is picked up during the next paint.
   // Schedule a paint to make sure one will happen.
   if (nsIFrame* rootFrame = GetRootFrame()) {
     rootFrame->SchedulePaint();
   }
 }
 
-void nsIPresShell::ClearPendingVisualScrollUpdate() {
+void PresShell::ClearPendingVisualScrollUpdate() {
   if (mPendingVisualScrollUpdate && mPendingVisualScrollUpdate->mAcknowledged) {
     mPendingVisualScrollUpdate = mozilla::Nothing();
   }
 }
 
-void nsIPresShell::AcknowledgePendingVisualScrollUpdate() {
+void PresShell::AcknowledgePendingVisualScrollUpdate() {
   MOZ_ASSERT(mPendingVisualScrollUpdate);
   mPendingVisualScrollUpdate->mAcknowledged = true;
 }
 
 nsPoint PresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const {
   return GetVisualViewportOffset() - GetLayoutViewportOffset();
 }
 
-nsPoint nsIPresShell::GetLayoutViewportOffset() const {
+nsPoint PresShell::GetLayoutViewportOffset() const {
   nsPoint result;
   if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) {
     result = sf->GetScrollPosition();
   }
   return result;
 }
 
-nsSize nsIPresShell::GetLayoutViewportSize() const {
+nsSize PresShell::GetLayoutViewportSize() const {
   nsSize result;
   if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) {
     result = sf->GetScrollPortRect().Size();
   }
   return result;
 }
 
-void nsIPresShell::RecomputeFontSizeInflationEnabled() {
+void PresShell::RecomputeFontSizeInflationEnabled() {
   mFontSizeInflationEnabled = DetermineFontSizeInflationState();
 
   float fontScale = nsLayoutUtils::SystemFontScale();
   if (fontScale == 0.0f) {
     return;
   }
 
   MOZ_ASSERT(mDocument);
   MOZ_ASSERT(mPresContext);
   if (mFontSizeInflationEnabled || mDocument->IsSyntheticDocument()) {
     mPresContext->SetSystemFontScale(1.0f);
   } else {
     mPresContext->SetSystemFontScale(fontScale);
   }
 }
 
-bool nsIPresShell::DetermineFontSizeInflationState() {
+bool PresShell::DetermineFontSizeInflationState() {
   MOZ_ASSERT(mPresContext, "our pres context should not be null");
   if (mPresContext->IsChrome()) {
     return false;
   }
 
   if (FontSizeInflationEmPerLine() == 0 && FontSizeInflationMinTwips() == 0) {
     return false;
   }
@@ -10796,17 +10788,17 @@ void PresShell::PausePainting() {
 void PresShell::ResumePainting() {
   if (GetPresContext()->RefreshDriver()->GetPresContext() != GetPresContext())
     return;
 
   mPaintingIsFrozen = false;
   GetPresContext()->RefreshDriver()->Thaw();
 }
 
-void nsIPresShell::SyncWindowProperties(nsView* aView) {
+void PresShell::SyncWindowProperties(nsView* aView) {
   nsIFrame* frame = aView->GetFrame();
   if (frame && mPresContext) {
     // CreateReferenceRenderingContext can return nullptr
     RefPtr<gfxContext> rcx(CreateReferenceRenderingContext());
     nsContainerFrame::SyncWindowProperties(mPresContext, frame, aView, rcx, 0);
   }
 }
 
@@ -10820,18 +10812,18 @@ static StyleOrigin ToOrigin(uint32_t aSe
       break;
     default:
       MOZ_FALLTHROUGH_ASSERT("unexpected aSheetType value");
     case nsIStyleSheetService::AUTHOR_SHEET:
       return StyleOrigin::Author;
   }
 }
 
-nsresult nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(
-    uint32_t aSheetType, bool* aRetVal) {
+nsresult PresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
+                                                            bool* aRetVal) {
   *aRetVal = false;
   return NS_OK;
 }
 
 void PresShell::NotifyStyleSheetServiceSheetAdded(StyleSheet* aSheet,
                                                   uint32_t aSheetType) {
   switch (aSheetType) {
     case nsIStyleSheetService::AGENT_SHEET:
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -131,98 +131,1032 @@ class PresShell final : public nsIPresSh
 
   /**
    * Return accessibility service if accessibility is active.
    */
   static nsAccessibilityService* GetAccessibilityService();
 #endif  // #ifdef ACCESSIBILITY
 
   void Init(Document*, nsPresContext*, nsViewManager*);
-  void Destroy() override;
+
+  /**
+   * All callers are responsible for calling |Destroy| after calling
+   * |EndObservingDocument|.  It needs to be separate only because form
+   * controls incorrectly store their data in the frames rather than the
+   * content model and printing calls |EndObservingDocument| multiple
+   * times to make form controls behave nicely when printed.
+   */
+  void Destroy();
+
+  bool IsDestroying() { return mIsDestroying; }
+
+  /**
+   * All frames owned by the shell are allocated from an arena.  They
+   * are also recycled using free lists.  Separate free lists are
+   * maintained for each frame type (aID), which must always correspond
+   * to the same aSize value.  AllocateFrame is infallible and will abort
+   * on out-of-memory.
+   */
+  void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
+    void* result = mFrameArena.AllocateByFrameID(aID, aSize);
+    RecordAlloc(result);
+    return result;
+  }
+
+  void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) {
+    RecordFree(aPtr);
+    if (!mIsDestroying) {
+      mFrameArena.FreeByFrameID(aID, aPtr);
+    }
+  }
+
+  /**
+   * This is for allocating other types of objects (not frames).  Separate free
+   * lists are maintained for each type (aID), which must always correspond to
+   * the same aSize value.  AllocateByObjectID is infallible and will abort on
+   * out-of-memory.
+   */
+  void* AllocateByObjectID(ArenaObjectID aID, size_t aSize) {
+    void* result = mFrameArena.AllocateByObjectID(aID, aSize);
+    RecordAlloc(result);
+    return result;
+  }
+
+  void FreeByObjectID(ArenaObjectID aID, void* aPtr) {
+    RecordFree(aPtr);
+    if (!mIsDestroying) {
+      mFrameArena.FreeByObjectID(aID, aPtr);
+    }
+  }
+
+  Document* GetDocument() const { return mDocument; }
+
+  nsPresContext* GetPresContext() const { return mPresContext; }
+
+  nsViewManager* GetViewManager() const { return mViewManager; }
+
+  nsRefreshDriver* GetRefreshDriver() const;
+
+  nsCSSFrameConstructor* FrameConstructor() const {
+    return mFrameConstructor.get();
+  }
+
+  /**
+   * FrameSelection will return the Frame based selection API.
+   * You cannot go back and forth anymore with QI between nsIDOM sel and
+   * nsIFrame sel.
+   */
+  already_AddRefed<nsFrameSelection> FrameSelection();
+
+  /**
+   * ConstFrameSelection returns an object which methods are safe to use for
+   * example in nsIFrame code.
+   */
+  const nsFrameSelection* ConstFrameSelection() const { return mSelection; }
+
+  // Start receiving notifications from our document. If called after Destroy,
+  // this will be ignored.
+  void BeginObservingDocument();
+
+  // Stop receiving notifications from our document. If called after Destroy,
+  // this will be ignored.
+  void EndObservingDocument();
+
+  bool IsObservingDocument() const { return mIsObservingDocument; }
+
+  /**
+   * Return whether Initialize() was previously called.
+   */
+  bool DidInitialize() const { return mDidInitialize; }
+
+  /**
+   * Perform initialization. Constructs the frame for the root content
+   * object and then enqueues a reflow of the frame model.
+   *
+   * Callers of this method must hold a reference to this shell that
+   * is guaranteed to survive through arbitrary script execution.
+   * Calling Initialize can execute arbitrary script.
+   */
+  nsresult Initialize();
+
+  /**
+   * Reflow the frame model into a new width and height.  The
+   * coordinates for aWidth and aHeight must be in standard nscoord's.
+   */
+  MOZ_CAN_RUN_SCRIPT nsresult
+  ResizeReflow(nscoord aWidth, nscoord aHeight, nscoord aOldWidth = 0,
+               nscoord aOldHeight = 0,
+               ResizeReflowOptions aOptions = ResizeReflowOptions::NoOption);
+  MOZ_CAN_RUN_SCRIPT nsresult ResizeReflowIgnoreOverride(
+      nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight,
+      ResizeReflowOptions aOptions = ResizeReflowOptions::NoOption);
+
+  /**
+   * Returns true if the platform/pref or docshell require a meta viewport.
+   */
+  bool GetIsViewportOverridden() { return (mMobileViewportManager != nullptr); }
+
+  /**
+   * Note that the assumptions that determine the need for a meta viewport
+   * may have changed.
+   */
+  void UpdateViewportOverridden(bool aAfterInitialization);
+
+  /**
+   * Get the MobileViewportManager used to manage the document's mobile
+   * viewport. Will return null in situations where we don't have a mobile
+   * viewport, and for documents that are not the root content document.
+   */
+  RefPtr<MobileViewportManager> GetMobileViewportManager() const;
+
+  /**
+   * Return true if the presshell expects layout flush.
+   */
+  bool IsLayoutFlushObserver() {
+    return GetPresContext()->RefreshDriver()->IsLayoutFlushObserver(this);
+  }
+
+  /**
+   * Called when document load completes.
+   */
+  void LoadComplete();
+  /**
+   * This calls through to the frame manager to get the root frame.
+   */
+  nsIFrame* GetRootFrame() const { return mFrameManager->GetRootFrame(); }
+
+  /*
+   * Get root scroll frame from FrameManager()->GetRootFrame().
+   */
+  nsIFrame* GetRootScrollFrame() const;
+
+  /*
+   * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
+   */
+  nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
+
+  /**
+   * Get the current focused content or DOM selection that should be the
+   * target for scrolling.
+   */
+  already_AddRefed<nsIContent> GetContentForScrolling() const;
+
+  /**
+   * Get the DOM selection that should be the target for scrolling, if there
+   * is no focused content.
+   */
+  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.
+   */
+  nsIScrollableFrame* GetScrollableFrameToScrollForContent(
+      nsIContent* aContent, 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(
+      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,
+                                                ScrollableDirection aDirection);
+
+  /**
+   * Returns the page sequence frame associated with the frame hierarchy.
+   * Returns nullptr if not a paginated view.
+   */
+  nsIPageSequenceFrame* GetPageSequenceFrame() const;
+
+  /**
+   * Returns the canvas frame associated with the frame hierarchy.
+   * Returns nullptr if is XUL document.
+   */
+  nsCanvasFrame* GetCanvasFrame() const;
+
+  void PostPendingScrollAnchorSelection(
+      layout::ScrollAnchorContainer* aContainer);
+  void FlushPendingScrollAnchorSelections();
+  void PostPendingScrollAnchorAdjustment(
+      layout::ScrollAnchorContainer* aContainer);
+
+  void CancelAllPendingReflows();
+
+  void NotifyCounterStylesAreDirty();
+
+  bool FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const;
+
+  /**
+   * Destroy the frames for aElement, and reconstruct them asynchronously if
+   * needed.
+   *
+   * Note that this may destroy frames for an ancestor instead.
+   */
+  void DestroyFramesForAndRestyle(Element* aElement);
+
+  /**
+   * Handles all the layout stuff needed when the slot assignment for an element
+   * is about to change.
+   *
+   * Only called when the slot attribute of the element changes, the rest of
+   * the changes should be handled in ShadowRoot.
+   */
+  void SlotAssignmentWillChange(Element& aElement,
+                                dom::HTMLSlotElement* aOldSlot,
+                                dom::HTMLSlotElement* aNewSlot);
+
+  void PostRecreateFramesFor(Element*);
+  void RestyleForAnimation(Element*, RestyleHint);
+
+  /**
+   * Determine if it is safe to flush all pending notifications.
+   */
+  bool IsSafeToFlush() const;
+
+  /**
+   * Informs the document's FontFaceSet that the refresh driver ticked,
+   * flushing style and layout.
+   */
+  void NotifyFontFaceSetOnRefresh();
+
+  // Removes ourself from the list of layout / style / and resize refresh driver
+  // observers.
+  //
+  // Right now this is only used for documents in the BFCache, so if you want to
+  // use this for anything else you need to ensure we don't end up in those
+  // lists after calling this, but before calling StartObservingRefreshDriver
+  // again.
+  //
+  // That is handled by the mDocument->GetBFCacheEntry checks in
+  // DoObserve*Flushes functions, though that could conceivably become a boolean
+  // member in the shell if needed.
+  //
+  // Callers are responsible of manually calling StartObservingRefreshDriver
+  // again.
+  void StopObservingRefreshDriver();
+  void StartObservingRefreshDriver();
+
+  bool ObservingStyleFlushes() const { return mObservingStyleFlushes; }
+  bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes; }
+
+  void ObserveStyleFlushes() {
+    if (!ObservingStyleFlushes()) {
+      DoObserveStyleFlushes();
+    }
+  }
+
+  /**
+   * Callbacks will be called even if reflow itself fails for
+   * some reason.
+   */
+  nsresult PostReflowCallback(nsIReflowCallback* aCallback);
+  void CancelReflowCallback(nsIReflowCallback* aCallback);
+
+  void ScheduleBeforeFirstPaint();
+  void UnsuppressAndInvalidate();
+
+  void ClearFrameRefs(nsIFrame* aFrame);
+
+  /**
+   * Get a reference rendering context. This is a context that should not
+   * be rendered to, but is suitable for measuring text and performing
+   * other non-rendering operations. Guaranteed to return non-null.
+   */
+  already_AddRefed<gfxContext> CreateReferenceRenderingContext();
+
+  /**
+   * Scrolls the view of the document so that the given area of a frame
+   * is visible, if possible. Layout is not flushed before scrolling.
+   *
+   * @param aRect relative to aFrame
+   * @param aVertical see ScrollContentIntoView and ScrollAxis
+   * @param aHorizontal see ScrollContentIntoView and ScrollAxis
+   * @param aScrollFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
+   * nearest scrollable ancestor is scrolled, otherwise all
+   * scrollable ancestors may be scrolled if necessary
+   * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
+   * even if overflow:hidden is specified in that direction; otherwise
+   * we will not scroll in that direction when overflow:hidden is
+   * set for that direction
+   * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
+   * nodes in this document, not in any parent documents which
+   * contain this document in a iframe or the like.
+   * If SCROLL_IGNORE_SCROLL_MARGIN_AND_PADDING is set we ignore scroll-margin
+   * value specified for |aFrame| and scroll-padding value for the scroll
+   * container. This option is typically used to locate poped-up frames into
+   * view.
+   * @return true if any scrolling happened, false if no scrolling happened
+   */
+  bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
+                               ScrollAxis aVertical, ScrollAxis aHorizontal,
+                               ScrollFlags aScrollFlags);
+
+  /**
+   * Determine if a rectangle specified in the frame's coordinate system
+   * intersects "enough" with the viewport to be considered visible. This
+   * is not a strict test against the viewport -- it's a test against
+   * the intersection of the viewport and the frame's ancestor scrollable
+   * frames. If it doesn't intersect enough, return a value indicating
+   * which direction the frame's topmost ancestor scrollable frame would
+   * need to be scrolled to bring the frame into view.
+   * @param aFrame frame that aRect coordinates are specified relative to
+   * @param aRect rectangle in twips to test for visibility
+   * @param aMinTwips is the minimum distance in from the edge of the
+   *                  visible area that an object must be to be counted
+   *                  visible
+   * @return RectVisibility::Visible if the rect is visible
+   *         RectVisibility::AboveViewport
+   *         RectVisibility::BelowViewport
+   *         RectVisibility::LeftOfViewport
+   *         RectVisibility::RightOfViewport rectangle is outside the
+   *         topmost ancestor scrollable frame in the specified direction
+   */
+  RectVisibility GetRectVisibility(nsIFrame* aFrame, const nsRect& aRect,
+                                   nscoord aMinTwips) const;
+
+  /**
+   * Suppress notification of the frame manager that frames are
+   * being destroyed.
+   */
+  void SetIgnoreFrameDestruction(bool aIgnore);
+
+  /**
+   * Get the AccessibleCaretEventHub, if it exists. AddRefs it.
+   */
+  already_AddRefed<AccessibleCaretEventHub> GetAccessibleCaretEventHub() const;
+
+  /**
+   * Get the caret, if it exists. AddRefs it.
+   */
+  already_AddRefed<nsCaret> GetCaret() const;
+
+  /**
+   * Set the current caret to a new caret. To undo this, call RestoreCaret.
+   */
+  void SetCaret(nsCaret* aNewCaret);
+
+  /**
+   * Restore the caret to the original caret that this pres shell was created
+   * with.
+   */
+  void RestoreCaret();
+
+  dom::Selection* GetCurrentSelection(SelectionType aSelectionType);
+
+  /**
+   * Gets a selection controller for the focused content in the DOM window
+   * for mDocument.
+   *
+   * @param aFocusedContent     If there is focused content in the DOM window,
+   *                            the focused content will be returned.  This may
+   *                            be nullptr if it's not necessary.
+   * @return                    A selection controller for focused content.
+   *                            E.g., if an <input> element has focus, returns
+   *                            the independent selection controller of it.
+   *                            If the DOM window does not have focused content
+   *                            (similar to Document.activeElement), returns
+   *                            nullptr.
+   */
+  already_AddRefed<nsISelectionController>
+  GetSelectionControllerForFocusedContent(
+      nsIContent** aFocusedContent = nullptr);
+
+  /**
+   * Interface to dispatch events via the presshell
+   * @note The caller must have a strong reference to the PresShell.
+   */
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  nsresult HandleEventWithTarget(WidgetEvent* aEvent, nsIFrame* aFrame,
+                                 nsIContent* aContent,
+                                 nsEventStatus* aEventStatus,
+                                 bool aIsHandlingNativeEvent = false,
+                                 nsIContent** aTargetContent = nullptr,
+                                 nsIContent* aOverrideClickTarget = nullptr) {
+    MOZ_ASSERT(aEvent);
+    EventHandler eventHandler(*this);
+    return eventHandler.HandleEventWithTarget(
+        aEvent, aFrame, aContent, aEventStatus, aIsHandlingNativeEvent,
+        aTargetContent, aOverrideClickTarget);
+  }
+
+  /**
+   * Dispatch event to content only (NOT full processing)
+   * @note The caller must have a strong reference to the PresShell.
+   */
+  nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
+                                    WidgetEvent* aEvent,
+                                    nsEventStatus* aStatus);
+
+  /**
+   * Dispatch event to content only (NOT full processing)
+   * @note The caller must have a strong reference to the PresShell.
+   */
+  nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
+                                    dom::Event* aEvent, nsEventStatus* aStatus);
+
+  /**
+   * Return whether or not the event is valid to be dispatched
+   */
+  bool CanDispatchEvent(const WidgetGUIEvent* aEvent = nullptr) const;
+
+  /**
+   * Gets the current target event frame from the PresShell
+   */
+  nsIFrame* GetCurrentEventFrame();
+
+  /**
+   * Gets the current target event frame from the PresShell
+   */
+  already_AddRefed<nsIContent> GetEventTargetContent(WidgetEvent* aEvent);
+
+  /**
+   * Get and set the history state for the current document
+   */
+  nsresult CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState);
+
+  /**
+   * Determine if reflow is currently locked
+   * returns true if reflow is locked, false otherwise
+   */
+  bool IsReflowLocked() const { return mIsReflowing; }
+
+  /**
+   * Called to find out if painting is suppressed for this presshell.  If it is
+   * suppressd, we don't allow the painting of any layer but the background, and
+   * we don't recur into our children.
+   */
+  bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
+
+  /**
+   * Pause painting by freezing the refresh driver of this and all parent
+   * presentations. This may not have the desired effect if this pres shell
+   * has its own refresh driver.
+   */
+  void PausePainting();
+
+  /**
+   * Resume painting by thawing the refresh driver of this and all parent
+   * presentations. This may not have the desired effect if this pres shell
+   * has its own refresh driver.
+   */
+  void ResumePainting();
+
+  /**
+   * Unsuppress painting.
+   */
+  void UnsuppressPainting();
+
+  /**
+   * Add an override style sheet for this presentation
+   */
+  nsresult AddOverrideStyleSheet(StyleSheet* aSheet);
+
+  /**
+   * Remove an override style sheet
+   */
+  nsresult RemoveOverrideStyleSheet(StyleSheet* aSheet);
+
+  /**
+   * Reconstruct frames for all elements in the document
+   */
+  void ReconstructFrames();
+
+  /**
+   * See if reflow verification is enabled. To enable reflow verification add
+   * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
+   * debug level will work). Or, call SetVerifyReflowEnable with true.
+   */
+  static bool GetVerifyReflowEnable();
+
+  /**
+   * Set the verify-reflow enable flag.
+   */
+  static void SetVerifyReflowEnable(bool aEnabled);
+
+  nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
+
+#ifdef MOZ_REFLOW_PERF
+  void DumpReflows();
+  void CountReflows(const char* aName, nsIFrame* aFrame);
+  void PaintCount(const char* aName, gfxContext* aRenderingContext,
+                  nsPresContext* aPresContext, nsIFrame* aFrame,
+                  const nsPoint& aOffset, uint32_t aColor);
+  void SetPaintFrameCount(bool aOn);
+  bool IsPaintingFrameCounts();
+#endif  // #ifdef MOZ_REFLOW_PERF
+
+#ifdef DEBUG
+  // Debugging hooks
+  void ListComputedStyles(FILE* out, int32_t aIndent = 0);
+
+  void ListStyleSheets(FILE* out, int32_t aIndent = 0);
+#endif  // #ifdef DEBUG
+
+  /**
+   * Stop all active elements (plugins and the caret) in this presentation and
+   * in the presentations of subdocuments.  Resets painting to a suppressed
+   * state.
+   * XXX this should include image animations
+   */
+  void Freeze();
+  bool IsFrozen() { return mFrozen; }
+
+  /**
+   * Restarts active elements (plugins) in this presentation and in the
+   * presentations of subdocuments, then do a full invalidate of the content
+   * area.
+   */
+  void Thaw();
+
+  void FireOrClearDelayedEvents(bool aFireEvents);
+
+  /**
+   * When this shell is disconnected from its containing docshell, we
+   * lose our container pointer.  However, we'd still like to be able to target
+   * user events at the docshell's parent.  This pointer allows us to do that.
+   * It should not be used for any other purpose.
+   */
+  void SetForwardingContainer(const WeakPtr<nsDocShell>& aContainer);
+
+  /**
+   * Render the document into an arbitrary gfxContext
+   * 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 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 RenderDocumentFlags::AsyncDecodeImages to avoid having images
+   * synchronously decoded during rendering.
+   * (by default images decode synchronously with RenderDocument)
+   *   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
+   * (PresShell::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.
+   */
+  nsresult RenderDocument(const nsRect& aRect, RenderDocumentFlags aFlags,
+                          nscolor aBackgroundColor,
+                          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);
+
+  /**
+   * 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 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.
+   */
+  already_AddRefed<gfx::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);
+
+  /**
+   * Stop or restart non synthetic test mouse event handling on *all*
+   * presShells.
+   *
+   * @param aDisable If true, disable all non synthetic test mouse
+   * events on all presShells.  Otherwise, enable them.
+   */
+  void DisableNonTestMouseEvents(bool aDisable);
+
+  /**
+   * Record the background color of the most recently drawn canvas. This color
+   * is composited on top of the user's default background color and then used
+   * to draw the background color of the canvas. See PresShell::Paint,
+   * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
+   * bug 488242, bug 476557 and other bugs mentioned there.
+   */
+  void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
+  nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
+
+  /**
+   * Use the current frame tree (if it exists) to update the background
+   * color of the most recently drawn canvas.
+   */
+  void UpdateCanvasBackground();
+
+  /**
+   * 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.
+   */
+  void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
+                                     nsDisplayList& aList, nsIFrame* aFrame,
+                                     const nsRect& aBounds);
+
+  /**
+   * Computes the backstop color for the view: transparent if in a transparent
+   * widget, otherwise the PresContext default background color. This color is
+   * only visible if the contents of the view as a whole are translucent.
+   */
+  nscolor ComputeBackstopColor(nsView* aDisplayRoot);
+
+  void ObserveNativeAnonMutationsForPrint(bool aObserve) {
+    mObservesMutationsForPrint = aObserve;
+  }
+  bool ObservesNativeAnonMutationsForPrint() {
+    return mObservesMutationsForPrint;
+  }
+
+  nsresult SetIsActive(bool aIsActive);
+
+  bool IsActive() { return mIsActive; }
+
+  /**
+   * Keep track of how many times this presshell has been rendered to
+   * a window.
+   */
+  uint64_t GetPaintCount() { return mPaintCount; }
+  void IncrementPaintCount() { ++mPaintCount; }
+
+  /**
+   * Get the root DOM window of this presShell.
+   */
+  already_AddRefed<nsPIDOMWindowOuter> GetRootWindow();
+
+  /**
+   * This returns the focused DOM window under our top level window.
+   * I.e., when we are deactive, this returns the *last* focused DOM window.
+   */
+  already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow();
+
+  /**
+   * Get the focused content under this window.
+   */
+  already_AddRefed<nsIContent> GetFocusedContentInOurWindow() const;
+
+  /**
+   * Get the layer manager for the widget of the root view, if it has
+   * one.
+   */
+  LayerManager* GetLayerManager();
+
+  /**
+   * Return true iff there is a widget rendering this presShell and that
+   * widget is APZ-enabled.
+   */
+  bool AsyncPanZoomEnabled();
+
+  /**
+   * Track whether we're ignoring viewport scrolling for the purposes
+   * of painting.  If we are ignoring, then layers aren't clipped to
+   * the CSS viewport and scrollbars aren't drawn.
+   */
+  void SetIgnoreViewportScrolling(bool aIgnore);
+  bool IgnoringViewportScrolling() const {
+    return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING;
+  }
+
+  float GetResolution() const { return mResolution.valueOr(1.0); }
+  float GetCumulativeResolution();
+
+  /**
+   * 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; }
+  void SetResolutionUpdated(bool aUpdated) { mResolutionUpdated = aUpdated; }
+
+  /**
+   * Returns true if the resolution has ever been changed by APZ.
+   */
+  bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz; }
+
+  /**
+   * Calculate the cumulative scale resolution from this document up to
+   * but not including the root document.
+   */
+  float GetCumulativeNonRootScaleResolution();
+
+  /**
+   * Used by session restore code to restore a resolution before the first
+   * paint.
+   */
+  void SetRestoreResolution(float aResolution,
+                            LayoutDeviceIntSize aDisplaySize);
+
+  /**
+   * Returns whether we are in a DrawWindow() call that used the
+   * DRAWWINDOW_DO_NOT_FLUSH flag.
+   */
+  bool InDrawWindowNotFlushing() const {
+    return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING;
+  }
+
+  /**
+   * Set the isFirstPaint flag.
+   */
+  void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }
+
+  /**
+   * Get the isFirstPaint flag.
+   */
+  bool GetIsFirstPaint() const { return mIsFirstPaint; }
+
+  uint32_t GetPresShellId() { return mPresShellId; }
+
+  /**
+   * 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).
+   */
+  void SynthesizeMouseMove(bool aFromScroll);
+
+  MOZ_CAN_RUN_SCRIPT
+  nsresult HandleEvent(nsIFrame* aFrame, WidgetGUIEvent* aEvent,
+                       bool aDontRetargetEvents, nsEventStatus* aEventStatus);
+  bool ShouldIgnoreInvalidation();
+  /**
+   * 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.
+   */
+  void WillPaintWindow();
+  /**
+   * 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.
+   */
+  void DidPaintWindow();
+
+  bool IsVisible();
+  MOZ_CAN_RUN_SCRIPT
+  void DispatchSynthMouseMove(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
+   * period of time and result in unnecessary checkerboarding (see bug
+   * 1255054). */
+  void SuppressDisplayport(bool aEnabled);
+
+  /* Whether or not displayport suppression should be turned on. Note that
+   * this only affects the return value of |IsDisplayportSuppressed()|, and
+   * doesn't change the value of the internal counter.
+   */
+  void RespectDisplayportSuppression(bool aEnabled);
+
+  /* Whether or not the displayport is currently suppressed. */
+  bool IsDisplayportSuppressed();
+
+  void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
+
+  /**
+   * Methods that retrieve the cached font inflation preferences.
+   */
+  uint32_t FontSizeInflationEmPerLine() const {
+    return mFontSizeInflationEmPerLine;
+  }
+
+  uint32_t FontSizeInflationMinTwips() const {
+    return mFontSizeInflationMinTwips;
+  }
+
+  uint32_t FontSizeInflationLineThreshold() const {
+    return mFontSizeInflationLineThreshold;
+  }
+
+  bool FontSizeInflationForceEnabled() const {
+    return mFontSizeInflationForceEnabled;
+  }
+
+  bool FontSizeInflationDisabledInMasterProcess() const {
+    return mFontSizeInflationDisabledInMasterProcess;
+  }
+
+  bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled; }
+
+  /**
+   * Recomputes whether font-size inflation is enabled.
+   */
+  void RecomputeFontSizeInflationEnabled();
+
+  /**
+   * Return true if the most recent interruptible reflow was interrupted.
+   */
+  bool IsReflowInterrupted() const { return mWasLastReflowInterrupted; }
+
+  /**
+   * Return true if the the interruptible reflows have to be suppressed.
+   * This may happen only if if the most recent reflow was interrupted.
+   */
+  bool SuppressInterruptibleReflows() const {
+    return mWasLastReflowInterrupted;
+  }
+
+  //////////////////////////////////////////////////////////////////////////////
+  // Approximate frame visibility tracking public API.
+  //////////////////////////////////////////////////////////////////////////////
+
+  /**
+   * Schedule an update of the list of approximately visible frames "soon".
+   * This lets the refresh driver know that we want a visibility update in the
+   * near future. The refresh driver applies its own heuristics and throttling
+   * to decide when to actually perform the visibility update.
+   */
+  void ScheduleApproximateFrameVisibilityUpdateSoon();
+
+  /**
+   * Schedule an update of the list of approximately visible frames "now". The
+   * update runs asynchronously, but it will be posted to the event loop
+   * immediately. Prefer the "soon" variation of this method when possible, as
+   * this variation ignores the refresh driver's heuristics.
+   */
+  void ScheduleApproximateFrameVisibilityUpdateNow();
+
+  /**
+   * Clears the current list of approximately visible frames on this pres shell
+   * and replaces it with frames that are in the display list @aList.
+   */
+  void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList& aList);
+  void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
+                                         bool aRemoveOnly = false);
+
+  /**
+   * Ensures @aFrame is in the list of approximately visible frames.
+   */
+  void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame);
+
+  /// Removes @aFrame from the list of approximately visible frames if present.
+  void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame);
+
+  /// Whether we should assume all frames are visible.
+  bool AssumeAllFramesVisible();
+
+  /**
+   * Returns whether the document's style set's rule processor for the
+   * specified level of the cascade is shared by multiple style sets.
+   *
+   * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
+   */
+  nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
+                                                   bool* aRetVal);
+
+  /**
+   * Returns whether or not the document has ever handled user input
+   */
+  bool HasHandledUserInput() const { return mHasHandledUserInput; }
+
+  void FireResizeEvent();
+
+  void NativeAnonymousContentRemoved(nsIContent* aAnonContent);
+
+  /**
+   * See HTMLDocument.setKeyPressEventModel() in HTMLDocument.webidl for the
+   * detail.
+   */
+  void SetKeyPressEventModel(uint16_t aKeyPressEventModel) {
+    mForceUseLegacyKeyCodeAndCharCodeValues |=
+        aKeyPressEventModel ==
+        dom::HTMLDocument_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
+  }
+
+  bool AddRefreshObserver(nsARefreshObserver* aObserver, FlushType aFlushType);
+  bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
+                             FlushType aFlushType);
+
+  bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
+  bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);
+
+  // Represents an update to the visual scroll offset that will be sent to APZ.
+  // The update type is used to determine priority compared to other scroll
+  // updates.
+  struct VisualScrollUpdate {
+    nsPoint mVisualScrollOffset;
+    FrameMetrics::ScrollOffsetUpdateType mUpdateType;
+    bool mAcknowledged = false;
+  };
+
+  // Ask APZ in the next transaction to scroll to the given visual viewport
+  // offset (relative to the document).
+  // Use this sparingly, as it will clobber JS-driven scrolling that happens
+  // in the same frame. This is mostly intended to be used in special
+  // situations like "first paint" or session restore.
+  // If scrolling "far away", i.e. not just within the existing layout
+  // viewport, it's recommended to use both nsIScrollableFrame.ScrollTo*()
+  // (via window.scrollTo if calling from JS) *and* this function; otherwise,
+  // temporary checkerboarding may result.
+  // Please request APZ review if adding a new call site.
+  void ScrollToVisual(const nsPoint& aVisualViewportOffset,
+                      FrameMetrics::ScrollOffsetUpdateType aUpdateType,
+                      ScrollMode aMode);
+  void AcknowledgePendingVisualScrollUpdate();
+  void ClearPendingVisualScrollUpdate();
+  const Maybe<VisualScrollUpdate>& GetPendingVisualScrollUpdate() const {
+    return mPendingVisualScrollUpdate;
+  }
+
+  nsPoint GetLayoutViewportOffset() const;
+  nsSize GetLayoutViewportSize() const;
+
+  /**
+   * Documents belonging to an invisible DocShell must not be painted ever.
+   */
+  bool IsNeverPainting() { return mIsNeverPainting; }
+
+  void SetNeverPainting(bool aNeverPainting) {
+    mIsNeverPainting = aNeverPainting;
+  }
+
+  /**
+   * True if a reflow event has been scheduled, or is going to be scheduled
+   * to run in the future.
+   */
+  bool HasPendingReflow() const {
+    return mObservingLayoutFlushes || mReflowContinueTimer;
+  }
+
+  void SyncWindowProperties(nsView* aView);
+
+  Document* GetPrimaryContentDocument();
+
+  struct MOZ_RAII AutoAssertNoFlush {
+    explicit AutoAssertNoFlush(PresShell& aPresShell)
+        : mPresShell(aPresShell), mOldForbidden(mPresShell.mForbiddenToFlush) {
+      mPresShell.mForbiddenToFlush = true;
+    }
+
+    ~AutoAssertNoFlush() { mPresShell.mForbiddenToFlush = mOldForbidden; }
+
+    PresShell& mPresShell;
+    const bool mOldForbidden;
+  };
 
   NS_IMETHOD GetSelectionFromScript(RawSelectionType aRawSelectionType,
                                     dom::Selection** aSelection) override;
   dom::Selection* GetSelection(RawSelectionType aRawSelectionType) override;
 
-  dom::Selection* GetCurrentSelection(SelectionType aSelectionType) override;
-
-  already_AddRefed<nsISelectionController>
-  GetSelectionControllerForFocusedContent(
-      nsIContent** aFocusedContent = nullptr) override;
-
   NS_IMETHOD SetDisplaySelection(int16_t aToggle) override;
   NS_IMETHOD GetDisplaySelection(int16_t* aToggle) override;
   NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
                                      SelectionRegion aRegion,
                                      int16_t aFlags) override;
   NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
 
-  nsresult Initialize() override;
-  MOZ_CAN_RUN_SCRIPT nsresult ResizeReflow(
-      nscoord aWidth, nscoord aHeight, nscoord aOldWidth = 0,
-      nscoord aOldHeight = 0,
-      ResizeReflowOptions aOptions = ResizeReflowOptions::NoOption) override;
-  MOZ_CAN_RUN_SCRIPT nsresult ResizeReflowIgnoreOverride(
-      nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight,
-      ResizeReflowOptions aOptions = ResizeReflowOptions::NoOption) override;
-
-  RectVisibility GetRectVisibility(nsIFrame* aFrame, const nsRect& aRect,
-                                   nscoord aMinTwips) const override;
-
-  nsresult CaptureHistoryState(
-      nsILayoutHistoryState** aLayoutHistoryState) override;
-
-  void UnsuppressPainting() override;
-
-  nsresult AddOverrideStyleSheet(StyleSheet*) override;
-  nsresult RemoveOverrideStyleSheet(StyleSheet*) override;
-
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
-  nsresult HandleEventWithTarget(
-      WidgetEvent* aEvent, nsIFrame* aFrame, nsIContent* aContent,
-      nsEventStatus* aEventStatus, bool aIsHandlingNativeEvent = false,
-      nsIContent** aTargetContent = nullptr,
-      nsIContent* aOverrideClickTarget = nullptr) override {
-    MOZ_ASSERT(aEvent);
-    EventHandler eventHandler(*this);
-    return eventHandler.HandleEventWithTarget(
-        aEvent, aFrame, aContent, aEventStatus, aIsHandlingNativeEvent,
-        aTargetContent, aOverrideClickTarget);
-  }
-
-  void ReconstructFrames(void) override;
-  void Freeze() override;
-  void Thaw() override;
-  void FireOrClearDelayedEvents(bool aFireEvents) override;
-
-  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,
-                                             RenderImageFlags aFlags) override;
-
-  already_AddRefed<SourceSurface> RenderSelection(
-      dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
-      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
@@ -233,87 +1167,70 @@ class PresShell final : public nsIPresSh
    * |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,
                                    ResolutionChangeOrigin aOrigin);
 
-  float GetCumulativeResolution() override;
-  float GetCumulativeNonRootScaleResolution() override;
-  void SetRestoreResolution(float aResolution,
-                            LayoutDeviceIntSize aDisplaySize) override;
-
   // Widget notificiations
   void WindowSizeMoveDone();
   void SysColorChanged() { mPresContext->SysColorChanged(); }
   void ThemeChanged() { mPresContext->ThemeChanged(); }
   void BackingScaleFactorChanged() { mPresContext->UIResolutionChangedSync(); }
 
-  void SynthesizeMouseMove(bool aFromScroll) override;
-
-  Document* GetPrimaryContentDocument() override;
-
-  void PausePainting() override;
-  void ResumePainting() override;
-
   // nsIViewObserver interface
 
   void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
              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 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;
 
   /**
    * 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);
 
-  bool IsVisible() override;
-  void SuppressDisplayport(bool aEnabled) override;
-  void RespectDisplayportSuppression(bool aEnabled) override;
-  bool IsDisplayportSuppressed() override;
-
   // caret handling
   NS_IMETHOD SetCaretEnabled(bool aInEnable) override;
   NS_IMETHOD SetCaretReadOnly(bool aReadOnly) override;
   NS_IMETHOD GetCaretEnabled(bool* aOutEnabled) override;
   NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) override;
   NS_IMETHOD GetCaretVisible(bool* _retval) override;
 
+  /**
+   * Should the images have borders etc.  Actual visual effects are determined
+   * by the frames.  Visual effects may not effect layout, only display.
+   * Takes effect on next repaint, does not force a repaint itself.
+   *
+   * @param aInEnable  if true, visual selection effects are enabled
+   *                   if false visual selection effects are disabled
+   */
   NS_IMETHOD SetSelectionFlags(int16_t aInEnable) override;
   NS_IMETHOD GetSelectionFlags(int16_t* aOutEnable) override;
 
-  using nsIPresShell::GetSelectionFlags;
+  /**
+   * Gets the current state of non text selection effects
+   * @return   current state of non text selection,
+   *           as set by SetDisplayNonTextSelection
+   */
+  int16_t GetSelectionFlags() const { return mSelectionFlags; }
 
   // nsISelectionController
 
   NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
                           bool aExtend) override;
   NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
   NS_IMETHOD CharacterExtendForDelete() override;
   NS_IMETHOD CharacterExtendForBackspace() override;
@@ -490,36 +1407,16 @@ class PresShell final : public nsIPresSh
                                            uint32_t aSheetType);
 
   // DoReflow returns whether the reflow finished without interruption
   // If aFrame is not the root frame, the caller must pass a non-null
   // aOverflowTracker.
   bool DoReflow(nsIFrame* aFrame, bool aInterruptible,
                 OverflowChangedTracker* aOverflowTracker);
 
-#ifdef MOZ_REFLOW_PERF
-  void DumpReflows() override;
-  void CountReflows(const char* aName, nsIFrame* aFrame) override;
-  void PaintCount(const char* aName, gfxContext* aRenderingContext,
-                  nsPresContext* aPresContext, nsIFrame* aFrame,
-                  const nsPoint& aOffset, uint32_t aColor) override;
-  void SetPaintFrameCount(bool aOn) override;
-  bool IsPaintingFrameCounts() override;
-#endif
-
-#ifdef DEBUG
-  void ListComputedStyles(FILE* out, int32_t aIndent = 0) override;
-
-  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
@@ -537,72 +1434,20 @@ class PresShell final : public nsIPresSh
    * 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),
       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;
-
-  bool GetIsViewportOverridden() override {
-    return (mMobileViewportManager != nullptr);
-  }
-
-  RefPtr<MobileViewportManager> GetMobileViewportManager() const override;
-
-  void UpdateViewportOverridden(bool aAfterInitialization) override;
-
-  bool IsLayoutFlushObserver() override {
-    return GetPresContext()->RefreshDriver()->IsLayoutFlushObserver(this);
-  }
-
-  void LoadComplete() override;
-
-  void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const override;
   size_t SizeOfTextRuns(MallocSizeOf aMallocSizeOf) const;
 
-  //////////////////////////////////////////////////////////////////////////////
-  // Approximate frame visibility tracking public API.
-  //////////////////////////////////////////////////////////////////////////////
-
-  void ScheduleApproximateFrameVisibilityUpdateSoon() override;
-  void ScheduleApproximateFrameVisibilityUpdateNow() override;
-
-  void RebuildApproximateFrameVisibilityDisplayList(
-      const nsDisplayList& aList) override;
-  void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
-                                         bool aRemoveOnly = false) override;
-
-  void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) override;
-  void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) override;
-
-  bool AssumeAllFramesVisible() override;
-
-  bool CanDispatchEvent(const WidgetGUIEvent* aEvent = nullptr) const override;
-
   void SetNextPaintCompressed() { mNextPaintCompressed = true; }
 
-  bool HasHandledUserInput() const override { return mHasHandledUserInput; }
-
-  void FireResizeEvent() override;
-
-  void SetKeyPressEventModel(uint16_t aKeyPressEventModel) override {
-    mForceUseLegacyKeyCodeAndCharCodeValues |=
-        aKeyPressEventModel ==
-        dom::HTMLDocument_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
-  }
-
   static PresShell* GetShellForEventTarget(nsIFrame* aFrame,
                                            nsIContent* aContent);
   static PresShell* GetShellForTouchEvent(WidgetGUIEvent* aEvent);
 
   /**
    * Informs the pres shell that the document is now at the anchor with
    * the given name.  If |aScroll| is true, scrolls the view of the
    * document so that the anchor with the specified name is displayed at
@@ -723,16 +1568,89 @@ class PresShell final : public nsIPresSh
 
 #ifdef DEBUG
   nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
 #endif
 
  private:
   ~PresShell();
 
+  /**
+   * Refresh observer management.
+   */
+  void DoObserveStyleFlushes();
+  void DoObserveLayoutFlushes();
+
+  /**
+   * Does the actual work of figuring out the current state of font size
+   * inflation.
+   */
+  bool DetermineFontSizeInflationState();
+
+  void RecordAlloc(void* aPtr) {
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+    MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
+    mAllocatedPointers.PutEntry(aPtr);
+#endif
+  }
+
+  void RecordFree(void* aPtr) {
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+    MOZ_DIAGNOSTIC_ASSERT(mAllocatedPointers.Contains(aPtr));
+    mAllocatedPointers.RemoveEntry(aPtr);
+#endif
+  }
+
+  void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
+  void PopCurrentEventInfo();
+  nsIContent* GetCurrentEventContent();
+
+  friend class ::nsRefreshDriver;
+  friend class ::nsAutoCauseReflowNotifier;
+
+  void WillCauseReflow();
+  void DidCauseReflow();
+
+  void CancelPostedReflowCallbacks();
+  void FlushPendingScrollAnchorAdjustments();
+
+  void SetPendingVisualScrollUpdate(
+      const nsPoint& aVisualViewportOffset,
+      FrameMetrics::ScrollOffsetUpdateType aUpdateType);
+
+#ifdef MOZ_REFLOW_PERF
+  UniquePtr<ReflowCountMgr> mReflowCountMgr;
+#endif
+
+  void WillDoReflow();
+
+  // This data is stored as a content property (nsGkAtoms::scrolling) on
+  // mContentToScrollTo when we have a pending ScrollIntoView.
+  struct ScrollIntoViewData {
+    ScrollAxis mContentScrollVAxis;
+    ScrollAxis mContentScrollHAxis;
+    ScrollFlags mContentToScrollToFlags;
+  };
+
+  static LazyLogModule gLog;
+
+  DOMHighResTimeStamp GetPerformanceNowUnclamped();
+
+  // The callback for the mReflowContinueTimer timer.
+  static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
+  bool ScheduleReflowOffTimer();
+  // MaybeScheduleReflow checks if posting a reflow is needed, then checks if
+  // the last reflow was interrupted. In the interrupted case ScheduleReflow is
+  // called off a timer, otherwise it is called directly.
+  void MaybeScheduleReflow();
+  // Actually schedules a reflow.  This should only be called by
+  // MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer
+  // sets up.
+  void ScheduleReflow();
+
   friend class ::AutoPointerEventTargetUpdater;
 
   // ProcessReflowCommands returns whether we processed all our dirty roots
   // without interruptions.
   MOZ_CAN_RUN_SCRIPT bool ProcessReflowCommands(bool aInterruptible);
 
   /**
    * Callback handler for whether reflow happened.
@@ -912,17 +1830,17 @@ class PresShell final : public nsIPresSh
   MOZ_CAN_RUN_SCRIPT void ProcessSynthMouseMoveEvent(bool aFromScroll);
 
   void QueryIsActive();
   nsresult UpdateImageLockingState();
 
   already_AddRefed<PresShell> GetParentPresShellForEventHandling();
 
   /**
-   * EventHandler is implementation of nsIPresShell::HandleEvent().
+   * EventHandler is implementation of PresShell::HandleEvent().
    */
   class MOZ_STACK_CLASS EventHandler final {
    public:
     EventHandler() = delete;
     EventHandler(const EventHandler& aOther) = delete;
     explicit EventHandler(PresShell& aPresShell)
         : mPresShell(aPresShell), mCurrentEventInfoSetter(nullptr) {}
     explicit EventHandler(RefPtr<PresShell>&& aPresShell)
@@ -1802,17 +2720,22 @@ class PresShell final : public nsIPresSh
   nsCOMPtr<nsIContent> mContentToScrollTo;
 
 #ifdef ACCESSIBILITY
   a11y::DocAccessible* mDocAccessible;
 #endif  // #ifdef ACCESSIBILITY
 
   nsSize mVisualViewportSize;
 
-  mozilla::Maybe<nsPoint> mVisualViewportOffset;
+  Maybe<nsPoint> mVisualViewportOffset;
+
+  // A pending visual scroll offset that we will ask APZ to scroll to
+  // during the next transaction. Cleared when we send the transaction.
+  // Only applicable to the RCD pres shell.
+  Maybe<VisualScrollUpdate> mPendingVisualScrollUpdate;
 
   TimeStamp mLastOSWake;
 
   // The focus sequence number of the last processed input event
   uint64_t mAPZFocusSequenceNumber;
   // The focus information needed for async keyboard scrolling
   FocusTarget mAPZFocusTarget;
 
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -3039,17 +3039,17 @@ void RestyleManager::DoProcessPendingRes
     // where the PresShell hasn't yet been initialized (and therefore we haven't
     // yet done the initial style traversal of the DOM tree). We should arguably
     // fix up the callers and assert against this case, but we just detect and
     // handle it for now.
     return;
   }
 
   // It'd be bad!
-  nsIPresShell::AutoAssertNoFlush noReentrantFlush(*presShell);
+  PresShell::AutoAssertNoFlush noReentrantFlush(*presShell);
 
   // Create a AnimationsWithDestroyedFrame during restyling process to
   // stop animations and transitions on elements that have no frame at the end
   // of the restyling process.
   AnimationsWithDestroyedFrame animationsWithDestroyedFrame(this);
 
   ServoStyleSet* styleSet = StyleSet();
   Document* doc = presContext->Document();
--- a/layout/base/Units.h
+++ b/layout/base/Units.h
@@ -476,17 +476,17 @@ struct LayoutDevicePixel {
                     aMargin.left * aAppUnitsPerDevPixel);
   }
 };
 
 /*
  * The pixels that layout rasterizes and delivers to the graphics code.
  * These also are generally referred to as "device pixels" in layout code.
  * Conversion between CSS pixels and LayerPixels is affected by:
- * 1) the "display resolution" (see nsIPresShell::SetResolution)
+ * 1) the "display resolution" (see PresShell::SetResolution)
  * 2) the "full zoom" (see nsPresContext::SetFullZoom)
  * 3) the "widget scale" (see nsIWidget::GetDefaultScale)
  * 4) rasterizing at a different scale in the presence of some CSS transforms
  */
 struct LayerPixel {};
 
 /*
  * This is Layer coordinates with the Layer's CSS transform applied.
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -163,1118 +163,17 @@ class nsIPresShell : public nsStubDocume
     STATE_IGNORING_VIEWPORT_SCROLLING = 0x1,
     STATE_DRAWWINDOW_NOT_FLUSHING = 0x2
   };
   typedef uint8_t RenderFlags;  // for storing the above flags
 
  public:
   nsIPresShell();
 
-  /**
-   * All callers are responsible for calling |Destroy| after calling
-   * |EndObservingDocument|.  It needs to be separate only because form
-   * controls incorrectly store their data in the frames rather than the
-   * content model and printing calls |EndObservingDocument| multiple
-   * times to make form controls behave nicely when printed.
-   */
-  virtual void Destroy() = 0;
-
-  bool IsDestroying() { return mIsDestroying; }
-
-  /**
-   * All frames owned by the shell are allocated from an arena.  They
-   * are also recycled using free lists.  Separate free lists are
-   * maintained for each frame type (aID), which must always correspond
-   * to the same aSize value.  AllocateFrame is infallible and will abort
-   * on out-of-memory.
-   */
-  void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
-    void* result = mFrameArena.AllocateByFrameID(aID, aSize);
-    RecordAlloc(result);
-    return result;
-  }
-
-  void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) {
-    RecordFree(aPtr);
-    if (!mIsDestroying) mFrameArena.FreeByFrameID(aID, aPtr);
-  }
-
-  /**
-   * This is for allocating other types of objects (not frames).  Separate free
-   * lists are maintained for each type (aID), which must always correspond to
-   * the same aSize value.  AllocateByObjectID is infallible and will abort on
-   * out-of-memory.
-   */
-  void* AllocateByObjectID(mozilla::ArenaObjectID aID, size_t aSize) {
-    void* result = mFrameArena.AllocateByObjectID(aID, aSize);
-    RecordAlloc(result);
-    return result;
-  }
-
-  void FreeByObjectID(mozilla::ArenaObjectID aID, void* aPtr) {
-    RecordFree(aPtr);
-    if (!mIsDestroying) mFrameArena.FreeByObjectID(aID, aPtr);
-  }
-
-  Document* GetDocument() const { return mDocument; }
-
-  nsPresContext* GetPresContext() const { return mPresContext; }
-
-  nsViewManager* GetViewManager() const { return mViewManager; }
-
-  nsRefreshDriver* GetRefreshDriver() const;
-
-  nsCSSFrameConstructor* FrameConstructor() const {
-    return mFrameConstructor.get();
-  }
-
-  /**
-   * FrameSelection will return the Frame based selection API.
-   * You cannot go back and forth anymore with QI between nsIDOM sel and
-   * nsIFrame sel.
-   */
-  already_AddRefed<nsFrameSelection> FrameSelection();
-
-  /**
-   * ConstFrameSelection returns an object which methods are safe to use for
-   * example in nsIFrame code.
-   */
-  const nsFrameSelection* ConstFrameSelection() const { return mSelection; }
-
-  // Start receiving notifications from our document. If called after Destroy,
-  // this will be ignored.
-  void BeginObservingDocument();
-
-  // Stop receiving notifications from our document. If called after Destroy,
-  // this will be ignored.
-  void EndObservingDocument();
-
-  bool IsObservingDocument() const { return mIsObservingDocument; }
-
-  /**
-   * Return whether Initialize() was previously called.
-   */
-  bool DidInitialize() const { return mDidInitialize; }
-
-  /**
-   * Perform initialization. Constructs the frame for the root content
-   * object and then enqueues a reflow of the frame model.
-   *
-   * Callers of this method must hold a reference to this shell that
-   * is guaranteed to survive through arbitrary script execution.
-   * Calling Initialize can execute arbitrary script.
-   */
-  virtual nsresult Initialize() = 0;
-
-  /**
-   * Reflow the frame model into a new width and height.  The
-   * coordinates for aWidth and aHeight must be in standard nscoord's.
-   */
-  MOZ_CAN_RUN_SCRIPT virtual nsresult ResizeReflow(
-      nscoord aWidth, nscoord aHeight, nscoord aOldWidth = 0,
-      nscoord aOldHeight = 0,
-      mozilla::ResizeReflowOptions aOptions =
-          mozilla::ResizeReflowOptions::NoOption) = 0;
-  /**
-   * Do the same thing as ResizeReflow but even if ResizeReflowOverride was
-   * called previously.
-   */
-  MOZ_CAN_RUN_SCRIPT virtual nsresult ResizeReflowIgnoreOverride(
-      nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight,
-      mozilla::ResizeReflowOptions aOptions =
-          mozilla::ResizeReflowOptions::NoOption) = 0;
-
-  /**
-   * Returns true if the platform/pref or docshell require a meta viewport.
-   */
-  virtual bool GetIsViewportOverridden() = 0;
-
-  /**
-   * Note that the assumptions that determine the need for a meta viewport
-   * may have changed.
-   */
-  virtual void UpdateViewportOverridden(bool aAfterInitialization) = 0;
-
-  /**
-   * Get the MobileViewportManager used to manage the document's mobile
-   * viewport. Will return null in situations where we don't have a mobile
-   * viewport, and for documents that are not the root content document.
-   */
-  virtual RefPtr<MobileViewportManager> GetMobileViewportManager() const = 0;
-
-  /**
-   * Return true if the presshell expects layout flush.
-   */
-  virtual bool IsLayoutFlushObserver() = 0;
-
-  /**
-   * Called when document load completes.
-   */
-  virtual void LoadComplete() = 0;
-
-  /**
-   * This calls through to the frame manager to get the root frame.
-   */
-  nsIFrame* GetRootFrame() const { return mFrameManager->GetRootFrame(); }
-
-  /*
-   * Get root scroll frame from FrameManager()->GetRootFrame().
-   */
-  nsIFrame* GetRootScrollFrame() const;
-
-  /*
-   * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
-   */
-  nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
-
-  /**
-   * Get the current focused content or DOM selection that should be the
-   * target for scrolling.
-   */
-  already_AddRefed<nsIContent> GetContentForScrolling() const;
-
-  /**
-   * Get the DOM selection that should be the target for scrolling, if there
-   * is no focused content.
-   */
-  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.
-   */
-  nsIScrollableFrame* GetScrollableFrameToScrollForContent(
-      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(
-      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, mozilla::ScrollableDirection aDirection);
-
-  /**
-   * Returns the page sequence frame associated with the frame hierarchy.
-   * Returns nullptr if not a paginated view.
-   */
-  nsIPageSequenceFrame* GetPageSequenceFrame() const;
-
-  /**
-   * Returns the canvas frame associated with the frame hierarchy.
-   * Returns nullptr if is XUL document.
-   */
-  nsCanvasFrame* GetCanvasFrame() const;
-
-  void PostPendingScrollAnchorSelection(
-      mozilla::layout::ScrollAnchorContainer* aContainer);
-  void FlushPendingScrollAnchorSelections();
-  void PostPendingScrollAnchorAdjustment(
-      mozilla::layout::ScrollAnchorContainer* aContainer);
-
-  void CancelAllPendingReflows();
-
-  void NotifyCounterStylesAreDirty();
-
-  bool FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const;
-
-  /**
-   * Destroy the frames for aElement, and reconstruct them asynchronously if
-   * needed.
-   *
-   * Note that this may destroy frames for an ancestor instead.
-   */
-  void DestroyFramesForAndRestyle(mozilla::dom::Element* aElement);
-
-  /**
-   * Handles all the layout stuff needed when the slot assignment for an element
-   * is about to change.
-   *
-   * Only called when the slot attribute of the element changes, the rest of
-   * the changes should be handled in ShadowRoot.
-   */
-  void SlotAssignmentWillChange(mozilla::dom::Element& aElement,
-                                mozilla::dom::HTMLSlotElement* aOldSlot,
-                                mozilla::dom::HTMLSlotElement* aNewSlot);
-
-  void PostRecreateFramesFor(mozilla::dom::Element*);
-  void RestyleForAnimation(mozilla::dom::Element*, mozilla::RestyleHint);
-
-  /**
-   * Determine if it is safe to flush all pending notifications.
-   */
-  bool IsSafeToFlush() const;
-
-  /**
-   * Informs the document's FontFaceSet that the refresh driver ticked,
-   * flushing style and layout.
-   */
-  void NotifyFontFaceSetOnRefresh();
-
-  // Removes ourself from the list of layout / style / and resize refresh driver
-  // observers.
-  //
-  // Right now this is only used for documents in the BFCache, so if you want to
-  // use this for anything else you need to ensure we don't end up in those
-  // lists after calling this, but before calling StartObservingRefreshDriver
-  // again.
-  //
-  // That is handled by the mDocument->GetBFCacheEntry checks in
-  // DoObserve*Flushes functions, though that could conceivably become a boolean
-  // member in the shell if needed.
-  //
-  // Callers are responsible of manually calling StartObservingRefreshDriver
-  // again.
-  void StopObservingRefreshDriver();
-  void StartObservingRefreshDriver();
-
-  bool ObservingStyleFlushes() const { return mObservingStyleFlushes; }
-  bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes; }
-
-  void ObserveStyleFlushes() {
-    if (!ObservingStyleFlushes()) DoObserveStyleFlushes();
-  }
-
-  /**
-   * Callbacks will be called even if reflow itself fails for
-   * some reason.
-   */
-  nsresult PostReflowCallback(nsIReflowCallback* aCallback);
-  void CancelReflowCallback(nsIReflowCallback* aCallback);
-
-  void ScheduleBeforeFirstPaint();
-  void UnsuppressAndInvalidate();
-
-  void ClearFrameRefs(nsIFrame* aFrame);
-
-  /**
-   * Get a reference rendering context. This is a context that should not
-   * be rendered to, but is suitable for measuring text and performing
-   * other non-rendering operations. Guaranteed to return non-null.
-   */
-  already_AddRefed<gfxContext> CreateReferenceRenderingContext();
-
-  /**
-   * Scrolls the view of the document so that the given area of a frame
-   * is visible, if possible. Layout is not flushed before scrolling.
-   *
-   * @param aRect relative to aFrame
-   * @param aVertical see ScrollContentIntoView and ScrollAxis
-   * @param aHorizontal see ScrollContentIntoView and ScrollAxis
-   * @param aScrollFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
-   * nearest scrollable ancestor is scrolled, otherwise all
-   * scrollable ancestors may be scrolled if necessary
-   * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
-   * even if overflow:hidden is specified in that direction; otherwise
-   * we will not scroll in that direction when overflow:hidden is
-   * set for that direction
-   * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
-   * nodes in this document, not in any parent documents which
-   * contain this document in a iframe or the like.
-   * If SCROLL_IGNORE_SCROLL_MARGIN_AND_PADDING is set we ignore scroll-margin
-   * value specified for |aFrame| and scroll-padding value for the scroll
-   * container. This option is typically used to locate poped-up frames into
-   * view.
-   * @return true if any scrolling happened, false if no scrolling happened
-   */
-  bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
-                               mozilla::ScrollAxis aVertical,
-                               mozilla::ScrollAxis aHorizontal,
-                               mozilla::ScrollFlags aScrollFlags);
-
-  /**
-   * Determine if a rectangle specified in the frame's coordinate system
-   * intersects "enough" with the viewport to be considered visible. This
-   * is not a strict test against the viewport -- it's a test against
-   * the intersection of the viewport and the frame's ancestor scrollable
-   * frames. If it doesn't intersect enough, return a value indicating
-   * which direction the frame's topmost ancestor scrollable frame would
-   * need to be scrolled to bring the frame into view.
-   * @param aFrame frame that aRect coordinates are specified relative to
-   * @param aRect rectangle in twips to test for visibility
-   * @param aMinTwips is the minimum distance in from the edge of the
-   *                  visible area that an object must be to be counted
-   *                  visible
-   * @return RectVisibility::Visible if the rect is visible
-   *         RectVisibility::AboveViewport
-   *         RectVisibility::BelowViewport
-   *         RectVisibility::LeftOfViewport
-   *         RectVisibility::RightOfViewport rectangle is outside the
-   *         topmost ancestor scrollable frame in the specified direction
-   */
-  virtual mozilla::RectVisibility GetRectVisibility(
-      nsIFrame* aFrame, const nsRect& aRect, nscoord aMinTwips) const = 0;
-
-  /**
-   * Suppress notification of the frame manager that frames are
-   * being destroyed.
-   */
-  void SetIgnoreFrameDestruction(bool aIgnore);
-
-  /**
-   * Get the AccessibleCaretEventHub, if it exists. AddRefs it.
-   */
-  already_AddRefed<mozilla::AccessibleCaretEventHub>
-  GetAccessibleCaretEventHub() const;
-
-  /**
-   * Get the caret, if it exists. AddRefs it.
-   */
-  already_AddRefed<nsCaret> GetCaret() const;
-
-  /**
-   * Set the current caret to a new caret. To undo this, call RestoreCaret.
-   */
-  void SetCaret(nsCaret* aNewCaret);
-
-  /**
-   * Restore the caret to the original caret that this pres shell was created
-   * with.
-   */
-  void RestoreCaret();
-
-  /**
-   * Should the images have borders etc.  Actual visual effects are determined
-   * by the frames.  Visual effects may not effect layout, only display.
-   * Takes effect on next repaint, does not force a repaint itself.
-   *
-   * @param aInEnable  if true, visual selection effects are enabled
-   *                   if false visual selection effects are disabled
-   */
-  NS_IMETHOD SetSelectionFlags(int16_t aInEnable) = 0;
-
-  /**
-   * Gets the current state of non text selection effects
-   * @return   current state of non text selection,
-   *           as set by SetDisplayNonTextSelection
-   */
-  int16_t GetSelectionFlags() const { return mSelectionFlags; }
-
-  virtual mozilla::dom::Selection* GetCurrentSelection(
-      mozilla::SelectionType aSelectionType) = 0;
-
-  /**
-   * Gets a selection controller for the focused content in the DOM window
-   * for mDocument.
-   *
-   * @param aFocusedContent     If there is focused content in the DOM window,
-   *                            the focused content will be returned.  This may
-   *                            be nullptr if it's not necessary.
-   * @return                    A selection controller for focused content.
-   *                            E.g., if an <input> element has focus, returns
-   *                            the independent selection controller of it.
-   *                            If the DOM window does not have focused content
-   *                            (similar to Document.activeElement), returns
-   *                            nullptr.
-   */
-  virtual already_AddRefed<nsISelectionController>
-  GetSelectionControllerForFocusedContent(
-      nsIContent** aFocusedContent = nullptr) = 0;
-
-  /**
-   * Interface to dispatch events via the presshell
-   * @note The caller must have a strong reference to the PresShell.
-   */
-  virtual nsresult HandleEventWithTarget(
-      mozilla::WidgetEvent* aEvent, nsIFrame* aFrame, nsIContent* aContent,
-      nsEventStatus* aStatus, bool aIsHandlingNativeEvent = false,
-      nsIContent** aTargetContent = nullptr,
-      nsIContent* aOverrideClickTarget = nullptr) = 0;
-
-  /**
-   * Dispatch event to content only (NOT full processing)
-   * @note The caller must have a strong reference to the PresShell.
-   */
-  virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
-                                            mozilla::WidgetEvent* aEvent,
-                                            nsEventStatus* aStatus) = 0;
-
-  /**
-   * Dispatch event to content only (NOT full processing)
-   * @note The caller must have a strong reference to the PresShell.
-   */
-  virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
-                                            mozilla::dom::Event* aEvent,
-                                            nsEventStatus* aStatus) = 0;
-
-  /**
-   * Return whether or not the event is valid to be dispatched
-   */
-  virtual bool CanDispatchEvent(
-      const mozilla::WidgetGUIEvent* aEvent = nullptr) const = 0;
-
-  /**
-   * Gets the current target event frame from the PresShell
-   */
-  nsIFrame* GetCurrentEventFrame();
-
-  /**
-   * Gets the current target event frame from the PresShell
-   */
-  already_AddRefed<nsIContent> GetEventTargetContent(
-      mozilla::WidgetEvent* aEvent);
-
-  /**
-   * Get and set the history state for the current document
-   */
-
-  virtual nsresult CaptureHistoryState(
-      nsILayoutHistoryState** aLayoutHistoryState) = 0;
-
-  /**
-   * Determine if reflow is currently locked
-   * returns true if reflow is locked, false otherwise
-   */
-  bool IsReflowLocked() const { return mIsReflowing; }
-
-  /**
-   * Called to find out if painting is suppressed for this presshell.  If it is
-   * suppressd, we don't allow the painting of any layer but the background, and
-   * we don't recur into our children.
-   */
-  bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
-
-  /**
-   * Pause painting by freezing the refresh driver of this and all parent
-   * presentations. This may not have the desired effect if this pres shell
-   * has its own refresh driver.
-   */
-  virtual void PausePainting() = 0;
-
-  /**
-   * Resume painting by thawing the refresh driver of this and all parent
-   * presentations. This may not have the desired effect if this pres shell
-   * has its own refresh driver.
-   */
-  virtual void ResumePainting() = 0;
-
-  /**
-   * Unsuppress painting.
-   */
-  virtual void UnsuppressPainting() = 0;
-
-  /**
-   * Add an override style sheet for this presentation
-   */
-  virtual nsresult AddOverrideStyleSheet(mozilla::StyleSheet* aSheet) = 0;
-
-  /**
-   * Remove an override style sheet
-   */
-  virtual nsresult RemoveOverrideStyleSheet(mozilla::StyleSheet* aSheet) = 0;
-
-  /**
-   * Reconstruct frames for all elements in the document
-   */
-  virtual void ReconstructFrames() = 0;
-
-  /**
-   * Notify that a content node's state has changed
-   */
-  virtual void ContentStateChanged(
-      Document* aDocument, nsIContent* aContent,
-      mozilla::EventStates aStateMask) override = 0;
-
-  /**
-   * See if reflow verification is enabled. To enable reflow verification add
-   * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
-   * debug level will work). Or, call SetVerifyReflowEnable with true.
-   */
-  static bool GetVerifyReflowEnable();
-
-  /**
-   * Set the verify-reflow enable flag.
-   */
-  static void SetVerifyReflowEnable(bool aEnabled);
-
-  nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
-
-#ifdef MOZ_REFLOW_PERF
-  virtual void DumpReflows() = 0;
-  virtual void CountReflows(const char* aName, nsIFrame* aFrame) = 0;
-  virtual void PaintCount(const char* aName, gfxContext* aRenderingContext,
-                          nsPresContext* aPresContext, nsIFrame* aFrame,
-                          const nsPoint& aOffset, uint32_t aColor) = 0;
-  virtual void SetPaintFrameCount(bool aOn) = 0;
-  virtual bool IsPaintingFrameCounts() = 0;
-#endif
-
-#ifdef DEBUG
-  // Debugging hooks
-  virtual void ListComputedStyles(FILE* out, int32_t aIndent = 0) = 0;
-
-  virtual void ListStyleSheets(FILE* out, int32_t aIndent = 0) = 0;
-#endif
-
-  /**
-   * Stop all active elements (plugins and the caret) in this presentation and
-   * in the presentations of subdocuments.  Resets painting to a suppressed
-   * state.
-   * XXX this should include image animations
-   */
-  virtual void Freeze() = 0;
-  bool IsFrozen() { return mFrozen; }
-
-  /**
-   * Restarts active elements (plugins) in this presentation and in the
-   * presentations of subdocuments, then do a full invalidate of the content
-   * area.
-   */
-  virtual void Thaw() = 0;
-
-  virtual void FireOrClearDelayedEvents(bool aFireEvents) = 0;
-
-  /**
-   * When this shell is disconnected from its containing docshell, we
-   * lose our container pointer.  However, we'd still like to be able to target
-   * user events at the docshell's parent.  This pointer allows us to do that.
-   * It should not be used for any other purpose.
-   */
-  void SetForwardingContainer(const mozilla::WeakPtr<nsDocShell>& aContainer);
-
-  /**
-   * Render the document into an arbitrary gfxContext
-   * 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 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 RenderDocumentFlags::AsyncDecodeImages to avoid having images
-   * synchronously decoded during rendering.
-   * (by default images decode synchronously with RenderDocument)
-   *   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.
-   */
-  virtual nsresult RenderDocument(const nsRect& aRect,
-                                  mozilla::RenderDocumentFlags aFlags,
-                                  nscolor aBackgroundColor,
-                                  gfxContext* aRenderedContext) = 0;
-
-  /**
-   * 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,
-      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 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,
-      mozilla::RenderImageFlags aFlags) = 0;
-
-  void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame);
-  void AddWeakFrame(WeakFrame* aWeakFrame);
-
-  void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
-  void RemoveWeakFrame(WeakFrame* aWeakFrame);
-
-  /**
-   * Stop or restart non synthetic test mouse event handling on *all*
-   * presShells.
-   *
-   * @param aDisable If true, disable all non synthetic test mouse
-   * events on all presShells.  Otherwise, enable them.
-   */
-  virtual void DisableNonTestMouseEvents(bool aDisable) = 0;
-
-  /**
-   * Record the background color of the most recently drawn canvas. This color
-   * is composited on top of the user's default background color and then used
-   * to draw the background color of the canvas. See PresShell::Paint,
-   * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
-   * bug 488242, bug 476557 and other bugs mentioned there.
-   */
-  void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
-  nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
-
-  /**
-   * 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 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;
-
-  /**
-   * Computes the backstop color for the view: transparent if in a transparent
-   * widget, otherwise the PresContext default background color. This color is
-   * only visible if the contents of the view as a whole are translucent.
-   */
-  virtual nscolor ComputeBackstopColor(nsView* aDisplayRoot) = 0;
-
-  void ObserveNativeAnonMutationsForPrint(bool aObserve) {
-    mObservesMutationsForPrint = aObserve;
-  }
-  bool ObservesNativeAnonMutationsForPrint() {
-    return mObservesMutationsForPrint;
-  }
-
-  virtual nsresult SetIsActive(bool aIsActive) = 0;
-
-  bool IsActive() { return mIsActive; }
-
-  /**
-   * Keep track of how many times this presshell has been rendered to
-   * a window.
-   */
-  uint64_t GetPaintCount() { return mPaintCount; }
-  void IncrementPaintCount() { ++mPaintCount; }
-
-  /**
-   * Get the root DOM window of this presShell.
-   */
-  virtual already_AddRefed<nsPIDOMWindowOuter> GetRootWindow() = 0;
-
-  /**
-   * This returns the focused DOM window under our top level window.
-   * I.e., when we are deactive, this returns the *last* focused DOM window.
-   */
-  virtual already_AddRefed<nsPIDOMWindowOuter>
-  GetFocusedDOMWindowInOurWindow() = 0;
-
-  /**
-   * Get the focused content under this window.
-   */
-  already_AddRefed<nsIContent> GetFocusedContentInOurWindow() const;
-
-  /**
-   * Get the layer manager for the widget of the root view, if it has
-   * one.
-   */
-  virtual LayerManager* GetLayerManager() = 0;
-
-  /**
-   * Return true iff there is a widget rendering this presShell and that
-   * widget is APZ-enabled.
-   */
-  virtual bool AsyncPanZoomEnabled() = 0;
-
-  /**
-   * Track whether we're ignoring viewport scrolling for the purposes
-   * 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;
-  }
-
-  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; }
-  void SetResolutionUpdated(bool aUpdated) { mResolutionUpdated = aUpdated; }
-
-  /**
-   * Returns true if the resolution has ever been changed by APZ.
-   */
-  bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz; }
-
-  /**
-   * Calculate the cumulative scale resolution from this document up to
-   * but not including the root document.
-   */
-  virtual float GetCumulativeNonRootScaleResolution() = 0;
-
-  /**
-   * Used by session restore code to restore a resolution before the first
-   * paint.
-   */
-  virtual void SetRestoreResolution(
-      float aResolution, mozilla::LayoutDeviceIntSize aDisplaySize) = 0;
-
-  /**
-   * Returns whether we are in a DrawWindow() call that used the
-   * DRAWWINDOW_DO_NOT_FLUSH flag.
-   */
-  bool InDrawWindowNotFlushing() const {
-    return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING;
-  }
-
-  /**
-   * Set the isFirstPaint flag.
-   */
-  void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }
-
-  /**
-   * Get the isFirstPaint flag.
-   */
-  bool GetIsFirstPaint() const { return mIsFirstPaint; }
-
-  uint32_t GetPresShellId() { return mPresShellId; }
-
-  /**
-   * 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;
-
-  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 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 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;
-
-  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
-   * period of time and result in unnecessary checkerboarding (see bug
-   * 1255054). */
-  virtual void SuppressDisplayport(bool aEnabled) = 0;
-
-  /* Whether or not displayport suppression should be turned on. Note that
-   * this only affects the return value of |IsDisplayportSuppressed()|, and
-   * doesn't change the value of the internal counter.
-   */
-  virtual void RespectDisplayportSuppression(bool aEnabled) = 0;
-
-  /* Whether or not the displayport is currently suppressed. */
-  virtual bool IsDisplayportSuppressed() = 0;
-
-  virtual void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const = 0;
-
-  /**
-   * Methods that retrieve the cached font inflation preferences.
-   */
-  uint32_t FontSizeInflationEmPerLine() const {
-    return mFontSizeInflationEmPerLine;
-  }
-
-  uint32_t FontSizeInflationMinTwips() const {
-    return mFontSizeInflationMinTwips;
-  }
-
-  uint32_t FontSizeInflationLineThreshold() const {
-    return mFontSizeInflationLineThreshold;
-  }
-
-  bool FontSizeInflationForceEnabled() const {
-    return mFontSizeInflationForceEnabled;
-  }
-
-  bool FontSizeInflationDisabledInMasterProcess() const {
-    return mFontSizeInflationDisabledInMasterProcess;
-  }
-
-  bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled; }
-
-  /**
-   * Recomputes whether font-size inflation is enabled.
-   */
-  void RecomputeFontSizeInflationEnabled();
-
-  /**
-   * Return true if the most recent interruptible reflow was interrupted.
-   */
-  bool IsReflowInterrupted() const { return mWasLastReflowInterrupted; }
-
-  /**
-   * Return true if the the interruptible reflows have to be suppressed.
-   * This may happen only if if the most recent reflow was interrupted.
-   */
-  bool SuppressInterruptibleReflows() const {
-    return mWasLastReflowInterrupted;
-  }
-
-  //////////////////////////////////////////////////////////////////////////////
-  // Approximate frame visibility tracking public API.
-  //////////////////////////////////////////////////////////////////////////////
-
-  /// Schedule an update of the list of approximately visible frames "soon".
-  /// This lets the refresh driver know that we want a visibility update in the
-  /// near future. The refresh driver applies its own heuristics and throttling
-  /// to decide when to actually perform the visibility update.
-  virtual void ScheduleApproximateFrameVisibilityUpdateSoon() = 0;
-
-  /// Schedule an update of the list of approximately visible frames "now". The
-  /// update runs asynchronously, but it will be posted to the event loop
-  /// immediately. Prefer the "soon" variation of this method when possible, as
-  /// this variation ignores the refresh driver's heuristics.
-  virtual void ScheduleApproximateFrameVisibilityUpdateNow() = 0;
-
-  /// Clears the current list of approximately visible frames on this pres shell
-  /// and replaces it with frames that are in the display list @aList.
-  virtual void RebuildApproximateFrameVisibilityDisplayList(
-      const nsDisplayList& aList) = 0;
-  virtual void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
-                                                 bool aRemoveOnly = false) = 0;
-
-  /// Ensures @aFrame is in the list of approximately visible frames.
-  virtual void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) = 0;
-
-  /// Removes @aFrame from the list of approximately visible frames if present.
-  virtual void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) = 0;
-
-  /// Whether we should assume all frames are visible.
-  virtual bool AssumeAllFramesVisible() = 0;
-
-  /**
-   * Returns whether the document's style set's rule processor for the
-   * specified level of the cascade is shared by multiple style sets.
-   *
-   * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
-   */
-  nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
-                                                   bool* aRetVal);
-
-  /**
-   * Returns whether or not the document has ever handled user input
-   */
-  virtual bool HasHandledUserInput() const = 0;
-
-  virtual void FireResizeEvent() = 0;
-
-  void NativeAnonymousContentRemoved(nsIContent* aAnonContent);
-
-  /**
-   * See HTMLDocument.setKeyPressEventModel() in HTMLDocument.webidl for the
-   * detail.
-   */
-  virtual void SetKeyPressEventModel(uint16_t aKeyPressEventModel) = 0;
-
  protected:
-  /**
-   * Refresh observer management.
-   */
-  void DoObserveStyleFlushes();
-  void DoObserveLayoutFlushes();
-
-  /**
-   * Does the actual work of figuring out the current state of font size
-   * inflation.
-   */
-  bool DetermineFontSizeInflationState();
-
-  void RecordAlloc(void* aPtr) {
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
-    MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
-    mAllocatedPointers.PutEntry(aPtr);
-#endif
-  }
-
-  void RecordFree(void* aPtr) {
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
-    MOZ_DIAGNOSTIC_ASSERT(mAllocatedPointers.Contains(aPtr));
-    mAllocatedPointers.RemoveEntry(aPtr);
-#endif
-  }
-
-  void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
-  void PopCurrentEventInfo();
-  nsIContent* GetCurrentEventContent();
-
- public:
-  bool AddRefreshObserver(nsARefreshObserver* aObserver,
-                          mozilla::FlushType aFlushType);
-  bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
-                             mozilla::FlushType aFlushType);
-
-  bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
-  bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);
-
-  // Represents an update to the visual scroll offset that will be sent to APZ.
-  // The update type is used to determine priority compared to other scroll
-  // updates.
-  struct VisualScrollUpdate {
-    nsPoint mVisualScrollOffset;
-    FrameMetrics::ScrollOffsetUpdateType mUpdateType;
-    bool mAcknowledged = false;
-  };
-
-  // Ask APZ in the next transaction to scroll to the given visual viewport
-  // offset (relative to the document).
-  // Use this sparingly, as it will clobber JS-driven scrolling that happens
-  // in the same frame. This is mostly intended to be used in special
-  // situations like "first paint" or session restore.
-  // If scrolling "far away", i.e. not just within the existing layout
-  // viewport, it's recommended to use both nsIScrollableFrame.ScrollTo*()
-  // (via window.scrollTo if calling from JS) *and* this function; otherwise,
-  // temporary checkerboarding may result.
-  // Please request APZ review if adding a new call site.
-  void ScrollToVisual(const nsPoint& aVisualViewportOffset,
-                      FrameMetrics::ScrollOffsetUpdateType aUpdateType,
-                      mozilla::ScrollMode aMode);
-  void AcknowledgePendingVisualScrollUpdate();
-  void ClearPendingVisualScrollUpdate();
-  const mozilla::Maybe<VisualScrollUpdate>& GetPendingVisualScrollUpdate()
-      const {
-    return mPendingVisualScrollUpdate;
-  }
-
-  nsPoint GetLayoutViewportOffset() const;
-  nsSize GetLayoutViewportSize() const;
-
-  /**
-   * Documents belonging to an invisible DocShell must not be painted ever.
-   */
-  bool IsNeverPainting() { return mIsNeverPainting; }
-
-  void SetNeverPainting(bool aNeverPainting) {
-    mIsNeverPainting = aNeverPainting;
-  }
-
-  /**
-   * True if a reflow event has been scheduled, or is going to be scheduled
-   * to run in the future.
-   */
-  bool HasPendingReflow() const {
-    return mObservingLayoutFlushes || mReflowContinueTimer;
-  }
-
-  void SyncWindowProperties(nsView* aView);
-
-  virtual Document* GetPrimaryContentDocument() = 0;
-
-  struct MOZ_RAII AutoAssertNoFlush {
-    explicit AutoAssertNoFlush(nsIPresShell& aShell)
-        : mShell(aShell), mOldForbidden(mShell.mForbiddenToFlush) {
-      mShell.mForbiddenToFlush = true;
-    }
-
-    ~AutoAssertNoFlush() { mShell.mForbiddenToFlush = mOldForbidden; }
-
-    nsIPresShell& mShell;
-    const bool mOldForbidden;
-  };
-
- protected:
-  friend class nsRefreshDriver;
-  friend class ::nsAutoCauseReflowNotifier;
-
-  void WillCauseReflow();
-  void DidCauseReflow();
-
-  void CancelPostedReflowCallbacks();
-  void FlushPendingScrollAnchorAdjustments();
-
-  void SetPendingVisualScrollUpdate(
-      const nsPoint& aVisualViewportOffset,
-      FrameMetrics::ScrollOffsetUpdateType aUpdateType);
-
-#ifdef MOZ_REFLOW_PERF
-  mozilla::UniquePtr<ReflowCountMgr> mReflowCountMgr;
-#endif
-
-  void WillDoReflow();
-
-  // This data is stored as a content property (nsGkAtoms::scrolling) on
-  // mContentToScrollTo when we have a pending ScrollIntoView.
-  struct ScrollIntoViewData {
-    mozilla::ScrollAxis mContentScrollVAxis;
-    mozilla::ScrollAxis mContentScrollHAxis;
-    mozilla::ScrollFlags mContentToScrollToFlags;
-  };
-
-  static mozilla::LazyLogModule gLog;
-
-  DOMHighResTimeStamp GetPerformanceNowUnclamped();
-
-  // The callback for the mReflowContinueTimer timer.
-  static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
-  bool ScheduleReflowOffTimer();
-  // MaybeScheduleReflow checks if posting a reflow is needed, then checks if
-  // the last reflow was interrupted. In the interrupted case ScheduleReflow is
-  // called off a timer, otherwise it is called directly.
-  void MaybeScheduleReflow();
-  // Actually schedules a reflow.  This should only be called by
-  // MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer
-  // sets up.
-  void ScheduleReflow();
-
   // IMPORTANT: The ownership implicit in the following member variables
   // has been explicitly checked.  If you add any members to this class,
   // please make the ownership explicit (pinkerton, scc).
 
   // These are the same Document and PresContext owned by the DocViewer.
   // we must share ownership.
   RefPtr<Document> mDocument;
   RefPtr<nsPresContext> mPresContext;
@@ -1305,21 +204,16 @@ class nsIPresShell : public nsStubDocume
   // We track allocated pointers in a debug-only hashtable to assert against
   // missing/double frees.
   nsTHashtable<nsPtrHashKey<void>> mAllocatedPointers;
 #endif
 
   // Count of the number of times this presshell has been painted to a window.
   uint64_t mPaintCount;
 
-  // A pending visual scroll offset that we will ask APZ to scroll to
-  // during the next transaction. Cleared when we send the transaction.
-  // Only applicable to the RCD pres shell.
-  mozilla::Maybe<VisualScrollUpdate> mPendingVisualScrollUpdate;
-
   // A list of stack weak frames. This is a pointer to the last item in the
   // list.
   AutoWeakFrame* mAutoWeakFrames;
 
   // A hash table of heap allocated weak frames.
   nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames;
 
   class DirtyRootsList {
--- a/layout/base/nsIReflowCallback.h
+++ b/layout/base/nsIReflowCallback.h
@@ -8,17 +8,17 @@
 
 /**
  * Reflow callback interface.
  * These are not refcounted. Objects must be removed from the presshell
  * callback list before they die.
  * Protocol: objects will either get a ReflowFinished() call when a reflow
  * has finished or a ReflowCallbackCanceled() call if the shell is destroyed,
  * whichever happens first. If the object is explicitly removed from the shell
- * (using nsIPresShell::CancelReflowCallback()) before that occurs then neither
+ * (using PresShell::CancelReflowCallback()) before that occurs then neither
  * of the callback methods are called.
  */
 class nsIReflowCallback {
  public:
   /**
    * The presshell calls this when reflow has finished. Return true if
    * you need a FlushType::Layout to happen after this.
    */
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8930,17 +8930,17 @@ ScrollMetadata nsLayoutUtils::ComputeScr
       if (aLayerManager->GetIsFirstPaint() &&
           presShell->IsVisualViewportOffsetSet()) {
         // Restore the visual viewport offset to the copy stored on the
         // main thread.
         presShell->ScrollToVisual(presShell->GetVisualViewportOffset(),
                                   FrameMetrics::eRestore, ScrollMode::Instant);
       }
 
-      if (const Maybe<nsIPresShell::VisualScrollUpdate>& visualUpdate =
+      if (const Maybe<PresShell::VisualScrollUpdate>& visualUpdate =
               presShell->GetPendingVisualScrollUpdate()) {
         metrics.SetVisualViewportOffset(
             CSSPoint::FromAppUnits(visualUpdate->mVisualScrollOffset));
         metrics.SetVisualScrollUpdateType(visualUpdate->mUpdateType);
         presShell->AcknowledgePendingVisualScrollUpdate();
       }
     }
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -916,17 +916,17 @@ class nsPresContext : public nsISupports
   };
 
   /**
    * Check for interrupts. This may return true if a pending event is
    * detected. Once it has returned true, it will keep returning true
    * until ReflowStarted is called. In all cases where this returns true,
    * the passed-in frame (which should be the frame whose reflow will be
    * interrupted if true is returned) will be passed to
-   * nsIPresShell::FrameNeedsToContinueReflow.
+   * PresShell::FrameNeedsToContinueReflow.
    */
   bool CheckForInterrupt(nsIFrame* aFrame);
   /**
    * Returns true if CheckForInterrupt has returned true since the last
    * ReflowStarted call. Cannot itself trigger an interrupt check.
    */
   bool HasPendingInterrupt() { return mHasPendingInterrupt; }
   /**
--- a/layout/generic/nsQueryFrame.h
+++ b/layout/generic/nsQueryFrame.h
@@ -67,17 +67,17 @@ class nsQueryFrame {
 #define FRAME_ID(classname, ...) classname##_id,
 #define ABSTRACT_FRAME_ID(classname) classname##_id,
 #include "nsFrameIdList.h"
 #undef FRAME_ID
 #undef ABSTRACT_FRAME_ID
 
     // This marker allows mozilla::ArenaObjectID to "extend" this enum
     // with additional sequential values for use in nsPresArena and
-    // nsIPresShell::{Allocate,Free}ByObjectId
+    // PresShell::{Allocate,Free}ByObjectId
     NON_FRAME_MARKER
   };
 
   // A strict subset of FrameIID above for frame classes that we instantiate.
   enum class ClassID : uint8_t {
 #define FRAME_ID(classname, ...) classname##_id,
 #define ABSTRACT_FRAME_ID(classname)
 #include "nsFrameIdList.h"
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -284,21 +284,17 @@ void ServoStyleSet::SetAuthorStyleDisabl
   mAuthorStyleDisabled = aStyleDisabled;
   if (Element* root = mDocument->GetRootElement()) {
     if (nsPresContext* pc = GetPresContext()) {
       pc->RestyleManager()->PostRestyleEvent(
           root, RestyleHint::RestyleSubtree(), nsChangeHint(0));
     }
   }
   Servo_StyleSet_SetAuthorStyleDisabled(mRawSet.get(), mAuthorStyleDisabled);
-  // XXX Workaround for the assertion in InvalidateStyleForDocumentStateChanges
-  // which is called by nsIPresShell::SetAuthorStyleDisabled via nsIPresShell::
-  // RestyleForCSSRuleChanges. It is not really necessary because we don't need
-  // to rebuild stylist for this change. But we have bug around this, and we
-  // may want to rethink how things should work. See bug 1437785.
+  // XXX Workaround for bug 1437785.
   SetStylistStyleSheetsDirty();
 }
 
 const ServoElementSnapshotTable& ServoStyleSet::Snapshots() {
   MOZ_ASSERT(GetPresContext(), "Styling a document without a shell?");
   return GetPresContext()->RestyleManager()->Snapshots();
 }