Bug 1512251 - Remove unused render only selection code r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 06 Dec 2018 19:40:50 +0000
changeset 508793 868ceb8ba4df9df67fefeb60f30c8de9a0a46af7
parent 508792 3c61fb185d513883a3a9c8eb510e102b0e7f5158
child 508794 3347058499c706d9651ad1cfa3aaae3c1d45bbe7
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1512251
milestone65.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 1512251 - Remove unused render only selection code r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D13829
layout/base/PresShell.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsHTMLButtonControlFrame.cpp
layout/forms/nsRangeFrame.cpp
layout/generic/nsBlockFrame.cpp
layout/generic/nsBlockFrame.h
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsPluginFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
layout/generic/nsVideoFrame.cpp
layout/mathml/nsMathMLContainerFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
layout/svg/SVGGeometryFrame.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGOuterSVGFrame.cpp
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableFrame.cpp
layout/xul/nsGroupBoxFrame.cpp
layout/xul/nsImageBoxFrame.cpp
layout/xul/nsLeafBoxFrame.cpp
layout/xul/nsTextBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -4955,17 +4955,17 @@ void PresShell::AddCanvasBackgroundColor
   // If we're only adding an unscrolled item, then pretend that we've
   // already done it.
   bool addedScrollingBackgroundColor = (aFlags & APPEND_UNSCROLLED_ONLY);
   if (!aFrame->GetParent() && !addedScrollingBackgroundColor) {
     nsIScrollableFrame* sf =
         aFrame->PresShell()->GetRootScrollFrameAsScrollable();
     if (sf) {
       nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
-      if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) {
+      if (canvasFrame && canvasFrame->IsVisibleForPainting()) {
         addedScrollingBackgroundColor = AddCanvasBackgroundColor(
             aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
       }
     }
   }
 
   // With async scrolling, we'd like to have two instances of the background
   // color: one that scrolls with the content (for the reasons stated above),
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -212,17 +212,16 @@ nsPresContext::nsPresContext(nsIDocument
       mUnderlineLinks(true),
       mSendAfterPaintToContent(false),
       mUseFocusColors(false),
       mFocusRingOnAnything(false),
       mFocusRingStyle(false),
       mDrawImageBackground(true),  // always draw the background
       mDrawColorBackground(true),
       // mNeverAnimate is initialised below, in constructor body
-      mIsRenderingOnlySelection(false),
       mPaginated(aType != eContext_Galley),
       mCanPaginatedScroll(false),
       mDoScaledTwips(true),
       mIsRootPaginatedDocument(false),
       mPrefBidiDirection(false),
       mPrefScrollbarSide(0),
       mPendingSysColorChanged(false),
       mPendingThemeChanged(false),
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -856,25 +856,16 @@ class nsPresContext : public nsISupports
 
   /**
    * Get the Bidi options for the presentation context
    * Not inline so consumers of nsPresContext are not forced to
    * include nsIDocument.
    */
   uint32_t GetBidi() const;
 
-  /**
-   * Render only Selection
-   */
-  void SetIsRenderingOnlySelection(bool aResult) {
-    mIsRenderingOnlySelection = aResult;
-  }
-
-  bool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; }
-
   bool IsTopLevelWindowInactive();
 
   /*
    * Obtain a native them for rendering our widgets (both form controls and
    * html)
    */
   nsITheme* GetTheme();
 
@@ -1396,17 +1387,16 @@ class nsPresContext : public nsISupports
   unsigned mUnderlineLinks : 1;
   unsigned mSendAfterPaintToContent : 1;
   unsigned mUseFocusColors : 1;
   unsigned mFocusRingOnAnything : 1;
   unsigned mFocusRingStyle : 1;
   unsigned mDrawImageBackground : 1;
   unsigned mDrawColorBackground : 1;
   unsigned mNeverAnimate : 1;
-  unsigned mIsRenderingOnlySelection : 1;
   unsigned mPaginated : 1;
   unsigned mCanPaginatedScroll : 1;
   unsigned mDoScaledTwips : 1;
   unsigned mIsRootPaginatedDocument : 1;
   unsigned mPrefBidiDirection : 1;
   unsigned mPrefScrollbarSide : 2;
   unsigned mPendingSysColorChanged : 1;
   unsigned mPendingThemeChanged : 1;
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1466,17 +1466,17 @@ void nsComboboxControlFrame::BuildDispla
   if (doc) {
     nsPIDOMWindowOuter* window = doc->GetWindow();
     if (window && window->ShouldShowFocusRing()) {
       nsPresContext* presContext = PresContext();
       const nsStyleDisplay* disp = StyleDisplay();
       if ((!IsThemed(disp) ||
            !presContext->GetTheme()->ThemeDrawsFocusForWidget(
                disp->mAppearance)) &&
-          mDisplayFrame && IsVisibleForPainting(aBuilder)) {
+          mDisplayFrame && IsVisibleForPainting()) {
         aLists.Content()->AppendToTop(
             MakeDisplayItem<nsDisplayComboboxFocus>(aBuilder, this));
       }
     }
   }
 
   DisplaySelectionOverlay(aBuilder, aLists.Content());
 }
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -191,17 +191,17 @@ bool nsDisplayFieldSetBorder::CreateWebR
 
 void nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                        const nsDisplayListSet& aLists) {
   // Paint our background and border in a special way.
   // REVIEW: We don't really need to check frame emptiness here; if it's empty,
   // the background/border display item won't do anything, and if it isn't
   // empty, we need to paint the outline
   if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) &&
-      IsVisibleForPainting(aBuilder)) {
+      IsVisibleForPainting()) {
     if (StyleEffects()->mBoxShadow) {
       aLists.BorderBackground()->AppendToTop(
           MakeDisplayItem<nsDisplayBoxShadowOuter>(aBuilder, this));
     }
 
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
         aBuilder, this, VisualBorderRectRelativeToSelf(),
         aLists.BorderBackground(),
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -85,17 +85,17 @@ void nsHTMLButtonControlFrame::BuildDisp
     nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
     nscoord radii[8];
     bool hasRadii = GetBorderRadii(radii);
     eventClipState->ClipContainingBlockDescendants(rect,
                                                    hasRadii ? radii : nullptr);
   }
 
   nsDisplayList onTop;
-  if (IsVisibleForPainting(aBuilder)) {
+  if (IsVisibleForPainting()) {
     mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
   }
 
   nsDisplayListCollection set(aBuilder);
 
   // Do not allow the child subtree to receive events.
   if (!isForEventDelivery || aBuilder->HitTestIsForVisibility()) {
     DisplayListClipState::AutoSaveRestore clipState(aBuilder);
--- a/layout/forms/nsRangeFrame.cpp
+++ b/layout/forms/nsRangeFrame.cpp
@@ -241,17 +241,17 @@ void nsRangeFrame::BuildDisplayList(nsDi
       BuildDisplayListForChild(aBuilder, thumb, set, DISPLAY_CHILD_INLINE);
     }
   } else {
     BuildDisplayListForInline(aBuilder, aLists);
   }
 
   // Draw a focus outline if appropriate:
 
-  if (!aBuilder->IsForPainting() || !IsVisibleForPainting(aBuilder)) {
+  if (!aBuilder->IsForPainting() || !IsVisibleForPainting()) {
     // we don't want the focus ring item for hit-testing or if the item isn't
     // in the area being [re]painted
     return;
   }
 
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED) ||
       !eventStates.HasState(NS_EVENT_STATE_FOCUSRING)) {
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -6343,25 +6343,16 @@ static void ComputeVisualOverflowArea(ns
 
   aResult.x = xa;
   aResult.y = ya;
   aResult.width = xb - xa;
   aResult.height = yb - ya;
 }
 #endif
 
-bool nsBlockFrame::IsVisibleInSelection(Selection* aSelection) {
-  if (mContent->IsAnyOfHTMLElements(nsGkAtoms::html, nsGkAtoms::body))
-    return true;
-
-  IgnoredErrorResult rv;
-  bool visible = aSelection->ContainsNode(*mContent, true, rv);
-  return !rv.Failed() && visible;
-}
-
 #ifdef DEBUG
 static void DebugOutputDrawLine(int32_t aDepth, nsLineBox* aLine, bool aDrawn) {
   if (nsBlockFrame::gNoisyDamageRepair) {
     nsFrame::IndentBy(stdout, aDepth + 1);
     nsRect lineArea = aLine->GetVisualOverflowArea();
     printf("%s line=%p bounds=%d,%d,%d,%d ca=%d,%d,%d,%d\n",
            aDrawn ? "draw" : "skip", static_cast<void*>(aLine), aLine->IStart(),
            aLine->BStart(), aLine->ISize(), aLine->BSize(), lineArea.x,
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -218,17 +218,16 @@ class nsBlockFrame : public nsContainerF
     }
 
    private:
     nsBlockFrame* mFrame;
     nsLineBox* mOrigCursor;
   };
 
   void ChildIsDirty(nsIFrame* aChild) override;
-  bool IsVisibleInSelection(mozilla::dom::Selection* aSelection) override;
 
   bool IsEmpty() override;
   bool CachedIsEmpty() override;
   bool IsSelfEmpty() override;
 
   // Given that we have a bullet, does it actually draw something, i.e.,
   // do we have either a 'list-style-type' or 'list-style-image' that is
   // not 'none'?
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -636,17 +636,17 @@ void nsDisplayBullet::Paint(nsDisplayLis
   ImgDrawResult result = static_cast<nsBulletFrame*>(mFrame)->PaintBullet(
       *aCtx, ToReferenceFrame(), GetPaintRect(), flags, mDisableSubpixelAA);
 
   nsDisplayBulletGeometry::UpdateDrawResult(this, result);
 }
 
 void nsBulletFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                      const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame");
 
   aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplayBullet>(aBuilder, this));
 }
 
 Maybe<BulletRenderer> nsBulletFrame::CreateBulletRenderer(
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -473,17 +473,17 @@ void nsCanvasFrame::BuildDisplayList(nsD
 
   // Force a background to be shown. We may have a background propagated to us,
   // in which case StyleBackground wouldn't have the right background
   // and the code in nsFrame::DisplayBorderBackgroundOutline might not give us
   // a background.
   // We don't have any border or outline, and our background draws over
   // the overflow area, so just add nsDisplayCanvasBackground instead of
   // calling DisplayBorderBackgroundOutline.
-  if (IsVisibleForPainting(aBuilder)) {
+  if (IsVisibleForPainting()) {
     ComputedStyle* bg = nullptr;
     nsIFrame* dependentFrame = nullptr;
     bool isThemed = IsThemed();
     if (!isThemed &&
         nsCSSRendering::FindBackgroundFrame(this, &dependentFrame)) {
       bg = dependentFrame->Style();
       if (dependentFrame == this) {
         dependentFrame = nullptr;
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -1218,17 +1218,17 @@ void nsColumnSetFrame::Reflow(nsPresCont
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
 }
 
 void nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                         const nsDisplayListSet& aLists) {
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
-  if (IsVisibleForPainting(aBuilder)) {
+  if (IsVisibleForPainting()) {
     aLists.BorderBackground()->AppendToTop(
         MakeDisplayItem<nsDisplayColumnRule>(aBuilder, this));
   }
 
   // Our children won't have backgrounds so it doesn't matter where we put them.
   for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
     BuildDisplayListForChild(aBuilder, e.get(), aLists);
   }
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2126,17 +2126,17 @@ already_AddRefed<ComputedStyle> nsIFrame
 
 /********************************************************
  * Refreshes each content's frame
  *********************************************************/
 
 void nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
                                       nsDisplayList* aList,
                                       uint16_t aContentType) {
-  if (!IsSelected() || !IsVisibleForPainting(aBuilder)) {
+  if (!IsSelected() || !IsVisibleForPainting()) {
     return;
   }
 
   int16_t displaySelection = PresShell()->GetSelectionFlags();
   if (!(displaySelection & aContentType)) {
     return;
   }
 
@@ -2184,24 +2184,24 @@ void nsFrame::DisplayOutlineUnconditiona
   }
 
   aLists.Outlines()->AppendToTop(
       MakeDisplayItem<nsDisplayOutline>(aBuilder, this));
 }
 
 void nsFrame::DisplayOutline(nsDisplayListBuilder* aBuilder,
                              const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DisplayOutlineUnconditional(aBuilder, aLists);
 }
 
 void nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder,
                             nsDisplayList* aList) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   aList->AppendToTop(MakeDisplayItem<nsDisplayCaret>(aBuilder, this));
 }
 
 nscolor nsIFrame::GetCaretColorAt(int32_t aOffset) {
   return nsLayoutUtils::GetColor(this, &nsStyleUI::mCaretColor);
 }
 
@@ -2221,17 +2221,17 @@ bool nsFrame::DisplayBackgroundUnconditi
 }
 
 void nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
                                              const nsDisplayListSet& aLists,
                                              bool aForceBackground) {
   // The visibility check belongs here since child elements have the
   // opportunity to override the visibility property and display even if
   // their parent is hidden.
-  if (!IsVisibleForPainting(aBuilder)) {
+  if (!IsVisibleForPainting()) {
     return;
   }
 
   nsCSSShadowArray* shadows = StyleEffects()->mBoxShadow;
   if (shadows && shadows->HasShadowWithInset(false)) {
     aLists.BorderBackground()->AppendToTop(
         MakeDisplayItem<nsDisplayBoxShadowOuter>(aBuilder, this));
   }
@@ -2660,17 +2660,17 @@ static void AddHitTestInfo(nsDisplayList
 void nsIFrame::BuildDisplayListForStackingContext(
     nsDisplayListBuilder* aBuilder, nsDisplayList* aList,
     bool* aCreatedContainerItem) {
   AutoCheckBuilder check(aBuilder);
   if (GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE) return;
 
   // Replaced elements have their visibility handled here, because
   // they're visually atomic
-  if (IsFrameOfType(eReplaced) && !IsVisibleForPainting(aBuilder)) return;
+  if (IsFrameOfType(eReplaced) && !IsVisibleForPainting()) return;
 
   const nsStyleDisplay* disp = StyleDisplay();
   const nsStyleEffects* effects = StyleEffects();
   EffectSet* effectSet = EffectSet::GetEffectSet(this);
   // We can stop right away if this is a zero-opacity stacking context and
   // we're painting, and we're not animating opacity. Don't do this
   // if we're going to compute plugin geometry, since opacity-0 plugins
   // need to have display items built for them.
@@ -7337,58 +7337,22 @@ void nsIFrame::RootFrameList(nsPresConte
     nsIFrame* frame = shell->GetRootFrame();
     if (frame) {
       frame->List(out, aPrefix);
     }
   }
 }
 #endif
 
-bool nsIFrame::IsVisibleForPainting(nsDisplayListBuilder* aBuilder) {
-  if (!StyleVisibility()->IsVisible()) return false;
-  Selection* sel = aBuilder->GetBoundingSelection();
-  return !sel || IsVisibleInSelection(sel);
-}
-
 bool nsIFrame::IsVisibleForPainting() {
-  if (!StyleVisibility()->IsVisible()) return false;
-
-  nsPresContext* pc = PresContext();
-  if (!pc->IsRenderingOnlySelection()) return true;
-
-  nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(pc->PresShell()));
-  if (selcon) {
-    RefPtr<Selection> sel =
-        selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
-    if (sel) {
-      return IsVisibleInSelection(sel);
-    }
-  }
-  return true;
-}
-
-bool nsIFrame::IsVisibleInSelection(nsDisplayListBuilder* aBuilder) {
-  Selection* sel = aBuilder->GetBoundingSelection();
-  return !sel || IsVisibleInSelection(sel);
-}
-
-bool nsIFrame::IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder) {
-  if (!StyleVisibility()->IsVisibleOrCollapsed()) return false;
-  Selection* sel = aBuilder->GetBoundingSelection();
-  return !sel || IsVisibleInSelection(sel);
-}
-
-bool nsIFrame::IsVisibleInSelection(Selection* aSelection) {
-  if (!GetContent() || !GetContent()->IsSelectionDescendant()) {
-    return false;
-  }
-
-  ErrorResult rv;
-  bool vis = aSelection->ContainsNode(*mContent, true, rv);
-  return rv.Failed() || vis;
+  return StyleVisibility()->IsVisible();
+}
+
+bool nsIFrame::IsVisibleOrCollapsedForPainting() {
+  return StyleVisibility()->IsVisibleOrCollapsed();
 }
 
 /* virtual */ bool nsFrame::IsEmpty() { return false; }
 
 bool nsIFrame::CachedIsEmpty() {
   MOZ_ASSERT(!(GetStateBits() & NS_FRAME_IS_DIRTY),
              "Must only be called on reflowed lines");
   return IsEmpty();
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -435,17 +435,17 @@ already_AddRefed<Layer> nsHTMLCanvasFram
 bool nsHTMLCanvasFrame::UpdateWebRenderCanvasData(
     nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
   HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(GetContent());
   return element->UpdateWebRenderCanvasData(aBuilder, aCanvasData);
 }
 
 void nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                          const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
   uint32_t clipFlags =
       nsStyleUtil::ObjectPropsMightCauseOverflow(StylePosition())
           ? 0
           : DisplayListClipState::ASSUME_DRAWING_RESTRICTED_TO_CONTENT_RECT;
 
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3409,38 +3409,22 @@ class nsIFrame : public nsQueryFrame {
    * boxes transitively owned by this frame.
    */
   virtual void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult);
 
   /**
    * Determines whether a frame is visible for painting;
    * taking into account whether it is painting a selection or printing.
    */
-  bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
+  bool IsVisibleForPainting();
   /**
    * Determines whether a frame is visible for painting or collapsed;
    * taking into account whether it is painting a selection or printing,
    */
-  bool IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder);
-  /**
-   * As above, but slower because we have to recompute some stuff that
-   * aBuilder already has.
-   */
-  bool IsVisibleForPainting();
-  /**
-   * Check whether this frame is visible in the current selection. Returns
-   * true if there is no current selection.
-   */
-  bool IsVisibleInSelection(nsDisplayListBuilder* aBuilder);
-
-  /**
-   * Overridable function to determine whether this frame should be considered
-   * "in" the given non-null aSelection for visibility purposes.
-   */
-  virtual bool IsVisibleInSelection(mozilla::dom::Selection* aSelection);
+  bool IsVisibleOrCollapsedForPainting();
 
   /**
    * Determines if this frame is a stacking context.
    *
    * @param aIsPositioned The precomputed result of IsAbsPosContainingBlock
    * on the StyleDisplay().
    */
   bool IsStackingContext(mozilla::EffectSet* aEffectSet,
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1800,17 +1800,17 @@ already_AddRefed<imgIRequest> nsImageFra
   MOZ_ASSERT(imageLoader);
   imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
                           getter_AddRefs(request));
   return request.forget();
 }
 
 void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                     const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
   uint32_t clipFlags =
       nsStyleUtil::ObjectPropsMightCauseOverflow(StylePosition())
           ? 0
           : DisplayListClipState::ASSUME_DRAWING_RESTRICTED_TO_CONTENT_RECT;
 
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -1052,17 +1052,17 @@ bool nsPluginFrame::IsTransparentMode() 
   pi->IsTransparent(&transparent);
   return transparent;
 #endif
 }
 
 void nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                      const nsDisplayListSet& aLists) {
   // XXX why are we painting collapsed object frames?
-  if (!IsVisibleOrCollapsedForPainting(aBuilder)) return;
+  if (!IsVisibleOrCollapsedForPainting()) return;
 
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
   nsPresContext::nsPresContextType type = PresContext()->Type();
 
   // If we are painting in Print Preview do nothing....
   if (type == nsPresContext::eContext_PrintPreview) return;
 
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -291,17 +291,17 @@ static void WrapBackgroundColorInOwnLaye
     }
     tempItems.AppendToTop(item);
   }
   aList->AppendToTop(&tempItems);
 }
 
 void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                           const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   nsFrameLoader* frameLoader = FrameLoader();
   RenderFrame* rf = nullptr;
   if (frameLoader) {
     rf = frameLoader->GetCurrentRenderFrame();
   }
 
   // If we are pointer-events:none then we don't need to HitTest background
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5027,17 +5027,17 @@ void nsDisplayText::RenderToContext(gfxC
 
   if (willClip) {
     aCtx->PopClip();
   }
 }
 
 void nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                    const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame");
 
   const nsStyleText* st = StyleText();
   bool isTextTransparent =
       NS_GET_A(st->mWebkitTextFillColor.CalcColor(this)) == 0 &&
       NS_GET_A(st->mWebkitTextStrokeColor.CalcColor(this)) == 0;
   Maybe<bool> isSelected;
@@ -7153,36 +7153,16 @@ int16_t nsTextFrame::GetSelectionStatus(
   selectionController->GetSelectionFlags(aSelectionFlags);
 
   int16_t selectionValue;
   selectionController->GetDisplaySelection(&selectionValue);
 
   return selectionValue;
 }
 
-bool nsTextFrame::IsVisibleInSelection(Selection* aSelection) {
-  // Check the quick way first
-  if (!GetContent()->IsSelectionDescendant()) return false;
-
-  UniquePtr<SelectionDetails> details = GetSelectionDetails();
-  bool found = false;
-
-  // where are the selection points "really"
-  for (SelectionDetails* sdptr = details.get(); sdptr;
-       sdptr = sdptr->mNext.get()) {
-    if (sdptr->mEnd > GetContentOffset() && sdptr->mStart < GetContentEnd() &&
-        sdptr->mSelectionType == SelectionType::eNormal) {
-      found = true;
-      break;
-    }
-  }
-
-  return found;
-}
-
 /**
  * Compute the longest prefix of text whose width is <= aWidth. Return
  * the length of the prefix. Also returns the width of the prefix in aFitWidth.
  */
 static uint32_t CountCharsFit(const gfxTextRun* aTextRun,
                               gfxTextRun::Range aRange, gfxFloat aWidth,
                               PropertyProvider* aProvider,
                               gfxFloat* aFitWidth) {
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -202,18 +202,16 @@ class nsTextFrame : public nsFrame {
   nsresult GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) final;
   nsresult GetCharacterRectsInRange(int32_t aInOffset, int32_t aLength,
                                     nsTArray<nsRect>& aRects) final;
 
   nsresult GetChildFrameContainingOffset(int32_t inContentOffset, bool inHint,
                                          int32_t* outFrameContentOffset,
                                          nsIFrame** outChildFrame) final;
 
-  bool IsVisibleInSelection(mozilla::dom::Selection* aSelection) final;
-
   bool IsEmpty() final;
   bool IsSelfEmpty() final { return IsEmpty(); }
   nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const final;
 
   bool HasSignificantTerminalNewline() const final;
 
   /**
    * Returns true if this text frame is logically adjacent to the end of the
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -540,17 +540,17 @@ class nsDisplayVideo : public nsDisplayI
     HTMLMediaElement* elem =
         static_cast<HTMLMediaElement*>(mFrame->GetContent());
     return elem->IsPotentiallyPlaying() ? LAYER_ACTIVE_FORCE : LAYER_INACTIVE;
   }
 };
 
 void nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                     const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   DO_GLOBAL_REFLOW_COUNT_DSP("nsVideoFrame");
 
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
   const bool shouldDisplayPoster = ShouldDisplayPoster();
 
   // NOTE: If we're displaying a poster image (instead of video data), we can
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -589,17 +589,17 @@ nsresult nsMathMLContainerFrame::Finaliz
  * Frame construction
  * =============================================================================
  */
 
 void nsMathMLContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                               const nsDisplayListSet& aLists) {
   // report an error if something wrong was found in this frame
   if (NS_MATHML_HAS_ERROR(mPresentationData.flags)) {
-    if (!IsVisibleForPainting(aBuilder)) return;
+    if (!IsVisibleForPainting()) return;
 
     aLists.Content()->AppendToTop(
         MakeDisplayItem<nsDisplayMathMLError>(aBuilder, this));
     return;
   }
 
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -1064,26 +1064,16 @@ nsDisplayListBuilder::nsDisplayListBuild
       mPartialBuildFailed(false),
       mIsInActiveDocShell(false),
       mHitTestArea(),
       mHitTestInfo(CompositorHitTestInvisibleToHit) {
   MOZ_COUNT_CTOR(nsDisplayListBuilder);
 
   mBuildCompositorHitTestInfo = mAsyncPanZoomEnabled && IsForPainting();
 
-  nsPresContext* pc = aReferenceFrame->PresContext();
-  nsIPresShell* shell = pc->PresShell();
-  if (pc->IsRenderingOnlySelection()) {
-    nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
-    if (selcon) {
-      mBoundingSelection =
-          selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
-    }
-  }
-
   static_assert(
       static_cast<uint32_t>(DisplayItemType::TYPE_MAX) < (1 << TYPE_BITS),
       "Check TYPE_MAX should not overflow");
 }
 
 void nsDisplayListBuilder::BeginFrame() {
   nsCSSRendering::BeginFrameTreesLocked();
   mCurrentAGR = mRootAGR;
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -551,22 +551,16 @@ class nsDisplayListBuilder {
    * CSS2.1 appendix E refers to with "treat the element as if it created
    * a new stacking context
    */
   bool IsAtRootOfPseudoStackingContext() const {
     return mIsAtRootOfPseudoStackingContext;
   }
 
   /**
-   * @return the selection that painting should be restricted to (or nullptr
-   * in the normal unrestricted case)
-   */
-  mozilla::dom::Selection* GetBoundingSelection() { return mBoundingSelection; }
-
-  /**
    * @return the root of given frame's (sub)tree, whose origin
    * establishes the coordinate system for the child display items.
    */
   const nsIFrame* FindReferenceFrameFor(const nsIFrame* aFrame,
                                         nsPoint* aOffset = nullptr) const;
 
   /**
    * @return the root of the display list's frame (sub)tree, whose origin
@@ -1862,17 +1856,16 @@ class nsDisplayListBuilder {
     nsPresContext* mPresContext;
     uint32_t mUsage;
   };
 
   nsIFrame* const mReferenceFrame;
   nsIFrame* mIgnoreScrollFrame;
   nsPresArena mPool;
 
-  RefPtr<mozilla::dom::Selection> mBoundingSelection;
   AutoTArray<PresShellState, 8> mPresShellStates;
   AutoTArray<nsIFrame*, 400> mFramesMarkedForDisplay;
   AutoTArray<nsIFrame*, 40> mFramesMarkedForDisplayIfVisible;
   AutoTArray<nsIFrame*, 20> mFramesWithOOFData;
   nsClassHashtable<nsPtrHashKey<nsDisplayItem>, nsTArray<ThemeGeometry>>
       mThemeGeometries;
   nsDisplayTableItem* mCurrentTableItem;
   DisplayListClipState mClipState;
--- a/layout/svg/SVGGeometryFrame.cpp
+++ b/layout/svg/SVGGeometryFrame.cpp
@@ -226,17 +226,17 @@ bool SVGGeometryFrame::IsSVGTransformed(
     foundTransform = true;
   }
   return foundTransform;
 }
 
 void SVGGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                         const nsDisplayListSet& aLists) {
   if (!static_cast<const nsSVGElement*>(GetContent())->HasValidDimensions() ||
-      (!IsVisibleForPainting(aBuilder) && aBuilder->IsForPainting())) {
+      (!IsVisibleForPainting() && aBuilder->IsForPainting())) {
     return;
   }
   DisplayOutline(aBuilder, aLists);
   aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplaySVGGeometry>(aBuilder, this));
 }
 
 //----------------------------------------------------------------------
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -2934,17 +2934,17 @@ void SVGTextFrame::Init(nsIContent* aCon
 void SVGTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                     const nsDisplayListSet& aLists) {
   if (NS_SUBTREE_DIRTY(this)) {
     // We can sometimes be asked to paint before reflow happens and we
     // have updated mPositions, etc.  In this case, we just avoid
     // painting.
     return;
   }
-  if (!IsVisibleForPainting(aBuilder) && aBuilder->IsForPainting()) {
+  if (!IsVisibleForPainting() && aBuilder->IsForPainting()) {
     return;
   }
   DisplayOutline(aBuilder, aLists);
   aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplaySVGText>(aBuilder, this));
 }
 
 nsresult SVGTextFrame::AttributeChanged(int32_t aNameSpaceID,
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -748,17 +748,17 @@ void nsSVGOuterSVGFrame::BuildDisplayLis
 
   if ((aBuilder->IsForEventDelivery() &&
        NS_SVGDisplayListHitTestingEnabled()) ||
       (!aBuilder->IsForEventDelivery() && NS_SVGDisplayListPaintingEnabled())) {
     nsDisplayList* contentList = aLists.Content();
     nsDisplayListSet set(contentList, contentList, contentList, contentList,
                          contentList, contentList);
     BuildDisplayListForNonBlockChildren(aBuilder, set);
-  } else if (IsVisibleForPainting(aBuilder) || !aBuilder->IsForPainting()) {
+  } else if (IsVisibleForPainting() || !aBuilder->IsForPainting()) {
     aLists.Content()->AppendToTop(
         MakeDisplayItem<nsDisplayOuterSVG>(aBuilder, this));
   }
 }
 
 //----------------------------------------------------------------------
 // nsISVGSVGFrame methods:
 
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -431,17 +431,17 @@ bool nsTableCellFrame::ShouldPaintBorder
   if (tableFrame->IsBorderCollapse()) {
     return true;
   }
 
   return StyleTableBorder()->mEmptyCells == NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
 }
 
 bool nsTableCellFrame::ShouldPaintBackground(nsDisplayListBuilder* aBuilder) {
-  return ShouldPaintBordersAndBackgrounds() && IsVisibleInSelection(aBuilder);
+  return ShouldPaintBordersAndBackgrounds();
 }
 
 void nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                         const nsDisplayListSet& aLists) {
   DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame");
   if (ShouldPaintBordersAndBackgrounds()) {
     // display outset box-shadows if we need to.
     bool hasBoxShadow = !!StyleEffects()->mBoxShadow;
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1371,17 +1371,17 @@ void nsTableFrame::CalcHasBCBorders() {
 
   SetHasBCBorders(false);
 }
 
 /* static */ void nsTableFrame::DisplayGenericTablePart(
     nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
     const nsDisplayListSet& aLists,
     DisplayGenericTablePartTraversal aTraversal) {
-  bool isVisible = aFrame->IsVisibleForPainting(aBuilder);
+  bool isVisible = aFrame->IsVisibleForPainting();
   bool isTable = aFrame->IsTableFrame();
 
   // Note that we UpdateForFrameBackground() even if we're not visible, unless
   // we're a table frame, because our backgrounds may paint anyway if the _cell_
   // is visible.
   if (isVisible || !isTable) {
     nsDisplayTableItem* currentItem = aBuilder->GetCurrentTableItem();
     // currentItem may be null, when none of the table parts have a
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -145,17 +145,17 @@ void nsDisplayXULGroupBorder::Paint(nsDi
       *aCtx, ToReferenceFrame(), GetPaintRect());
 
   nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
 }
 
 void nsGroupBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                        const nsDisplayListSet& aLists) {
   // Paint our background and border
-  if (IsVisibleForPainting(aBuilder)) {
+  if (IsVisibleForPainting()) {
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
         aBuilder, this, GetBackgroundRectRelativeToSelf(),
         aLists.BorderBackground());
     aLists.BorderBackground()->AppendToTop(
         MakeDisplayItem<nsDisplayXULGroupBorder>(aBuilder, this));
 
     DisplayOutline(aBuilder, aLists);
   }
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -289,17 +289,17 @@ void nsImageBoxFrame::BuildDisplayList(n
 
   if ((0 == mRect.width) || (0 == mRect.height)) {
     // Do not render when given a zero area. This avoids some useless
     // scaling work while we wait for our image dimensions to arrive
     // asynchronously.
     return;
   }
 
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   uint32_t clipFlags =
       nsStyleUtil::ObjectPropsMightCauseOverflow(StylePosition())
           ? 0
           : DisplayListClipState::ASSUME_DRAWING_RESTRICTED_TO_CONTENT_RECT;
 
   DisplayListClipState::AutoClipContainingBlockDescendantsToContentBox clip(
       aBuilder, this, clipFlags);
--- a/layout/xul/nsLeafBoxFrame.cpp
+++ b/layout/xul/nsLeafBoxFrame.cpp
@@ -87,17 +87,17 @@ void nsLeafBoxFrame::BuildDisplayList(ns
                                       const nsDisplayListSet& aLists) {
   // REVIEW: GetFrameForPoint used to not report events for the background
   // layer, whereas this code will put an event receiver for this frame in the
   // BlockBorderBackground() list. But I don't see any need to preserve
   // that anomalous behaviour. The important thing I'm preserving is that
   // leaf boxes continue to receive events in the foreground layer.
   DisplayBorderBackgroundOutline(aBuilder, aLists);
 
-  if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting(aBuilder))
+  if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting())
     return;
 
   aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplayEventReceiver>(aBuilder, this));
 }
 
 /* virtual */ nscoord nsLeafBoxFrame::GetMinISize(
     gfxContext* aRenderingContext) {
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -333,17 +333,17 @@ nsRect nsDisplayXULTextBox::GetBounds(ns
 nsRect nsDisplayXULTextBox::GetComponentAlphaBounds(
     nsDisplayListBuilder* aBuilder) const {
   return static_cast<nsTextBoxFrame*>(mFrame)->GetComponentAlphaBounds() +
          ToReferenceFrame();
 }
 
 void nsTextBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                       const nsDisplayListSet& aLists) {
-  if (!IsVisibleForPainting(aBuilder)) return;
+  if (!IsVisibleForPainting()) return;
 
   nsLeafBoxFrame::BuildDisplayList(aBuilder, aLists);
 
   aLists.Content()->AppendToTop(
       MakeDisplayItem<nsDisplayXULTextBox>(aBuilder, this));
 }
 
 void nsTextBoxFrame::PaintTitle(gfxContext& aRenderingContext,
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -2559,17 +2559,17 @@ class nsDisplayTreeBody final : public n
     return GetBounds(aBuilder, &snap);
   }
 };
 
 // Painting routines
 void nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                        const nsDisplayListSet& aLists) {
   // REVIEW: why did we paint if we were collapsed? that makes no sense!
-  if (!IsVisibleForPainting(aBuilder))
+  if (!IsVisibleForPainting())
     return;  // We're invisible.  Don't paint.
 
   // Handles painting our background, border, and outline.
   nsLeafBoxFrame::BuildDisplayList(aBuilder, aLists);
 
   // Bail out now if there's no view or we can't run script because the
   // document is a zombie
   if (!mView || !GetContent()->GetComposedDoc()->GetWindow()) return;