Bug 1409114 - Part 7: Pass rects in display list coordinates to AppendBackgroundItemsToTop. r=miko
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 20 May 2019 23:15:54 +0000
changeset 474633 df9a4342bf9750ad45219104bfd25674260f6080
parent 474632 e88eae3b48a71d611ae395582d170548caf9bd28
child 474634 69b049f546226b6bcc288986bbf60d792f01bf8f
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiko
bugs1409114
milestone69.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 1409114 - Part 7: Pass rects in display list coordinates to AppendBackgroundItemsToTop. r=miko This helps for the next patch, since some of the table backgrounds items want to compute this without position:relative taken into account. Differential Revision: https://phabricator.services.mozilla.com/D29279
layout/forms/nsButtonFrameRenderer.cpp
layout/forms/nsFieldSetFrame.cpp
layout/generic/nsFrame.cpp
layout/mathml/nsMathMLChar.cpp
layout/painting/nsDisplayList.cpp
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowGroupFrame.cpp
layout/xul/nsGroupBoxFrame.cpp
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -232,17 +232,17 @@ nsDisplayItemGeometry* nsDisplayButtonBo
 bool nsDisplayButtonBorder::CreateWebRenderCommands(
     mozilla::wr::DisplayListBuilder& aBuilder,
     mozilla::wr::IpcResourceUpdateQueue& aResources,
     const StackingContextHelper& aSc,
     mozilla::layers::RenderRootStateManager* aManager,
     nsDisplayListBuilder* aDisplayListBuilder) {
   // This is really a combination of paint box shadow inner +
   // paint border.
-  nsRect buttonRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
+  const nsRect buttonRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
   bool snap;
   nsRegion visible = GetBounds(aDisplayListBuilder, &snap);
   nsDisplayBoxShadowInner::CreateInsetBoxShadowWebRenderCommands(
       aBuilder, aSc, visible, mFrame, buttonRect);
 
   bool borderIsEmpty = false;
   Maybe<nsCSSBorderRenderer> br = nsCSSRendering::CreateBorderRenderer(
       mFrame->PresContext(), nullptr, mFrame, nsRect(),
@@ -389,17 +389,18 @@ bool nsDisplayButtonForeground::CreateWe
 nsresult nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
                                               nsDisplayList* aBackground,
                                               nsDisplayList* aForeground) {
   if (!mFrame->StyleEffects()->mBoxShadow.IsEmpty()) {
     aBackground->AppendNewToTop<nsDisplayButtonBoxShadowOuter>(aBuilder,
                                                                GetFrame());
   }
 
-  nsRect buttonRect = mFrame->GetRectRelativeToSelf();
+  nsRect buttonRect =
+      mFrame->GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(mFrame);
 
   nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, mFrame,
                                                        buttonRect, aBackground);
 
   aBackground->AppendNewToTop<nsDisplayButtonBorder>(aBuilder, GetFrame(),
                                                      this);
 
   // Only display focus rings if we actually have them. Since at most one
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -219,19 +219,21 @@ void nsFieldSetFrame::BuildDisplayList(n
   // 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()) {
     DisplayOutsetBoxShadowUnconditional(aBuilder, aLists.BorderBackground());
 
+    const nsRect rect =
+        VisualBorderRectRelativeToSelf() + aBuilder->ToReferenceFrame(this);
+
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
-        aBuilder, this, VisualBorderRectRelativeToSelf(),
-        aLists.BorderBackground(),
+        aBuilder, this, rect, aLists.BorderBackground(),
         /* aAllowWillPaintBorderOptimization = */ false);
 
     aLists.BorderBackground()->AppendNewToTop<nsDisplayFieldSetBorder>(aBuilder,
                                                                        this);
 
     DisplayOutlineUnconditional(aBuilder, aLists);
 
     DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame");
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2431,17 +2431,19 @@ bool nsFrame::DisplayBackgroundUnconditi
                                              bool aForceBackground) {
   // Here we don't try to detect background propagation. Frames that might
   // receive a propagated background should just set aForceBackground to
   // true.
   if (aBuilder->IsForEventDelivery() || aForceBackground ||
       !StyleBackground()->IsTransparent(this) ||
       StyleDisplay()->HasAppearance()) {
     return nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
-        aBuilder, this, GetRectRelativeToSelf(), aLists.BorderBackground());
+        aBuilder, this,
+        GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this),
+        aLists.BorderBackground());
   }
   return false;
 }
 
 void nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
                                              const nsDisplayListSet& aLists,
                                              bool aForceBackground) {
   // The visibility check belongs here since child elements have the
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1832,17 +1832,18 @@ void nsMathMLChar::Display(nsDisplayList
   if (aSelectedRect && !aSelectedRect->IsEmpty()) {
     aLists.BorderBackground()->AppendNewToTop<nsDisplayMathMLSelectionRect>(
         aBuilder, aForFrame, *aSelectedRect);
   } else if (mRect.width && mRect.height) {
     if (!usingParentStyle &&
         NS_GET_A(computedStyle->StyleBackground()->BackgroundColor(
             computedStyle)) > 0) {
       nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
-          aBuilder, aForFrame, mRect, aLists.BorderBackground(),
+          aBuilder, aForFrame, mRect + aBuilder->ToReferenceFrame(aForFrame),
+          aLists.BorderBackground(),
           /* aAllowWillPaintBorderOptimization */ true, computedStyle);
     }
     // else
     //  our container frame will take care of painting its background
 
 #if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
     // for visual debug
     aLists.BorderBackground()->AppendNewToTop<nsDisplayMathMLCharDebug>(
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3815,20 +3815,20 @@ static bool SpecialCutoutRegionCase(nsDi
 /*static*/
 bool nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
     nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
     const nsRect& aBackgroundRect, nsDisplayList* aList,
     bool aAllowWillPaintBorderOptimization, ComputedStyle* aComputedStyle,
     const nsRect& aBackgroundOriginRect, nsIFrame* aSecondaryReferenceFrame) {
   ComputedStyle* bgSC = aComputedStyle;
   const nsStyleBackground* bg = nullptr;
-  nsRect bgRect = aBackgroundRect + aBuilder->ToReferenceFrame(aFrame);
+  nsRect bgRect = aBackgroundRect;
   nsRect bgOriginRect = bgRect;
   if (!aBackgroundOriginRect.IsEmpty()) {
-    bgOriginRect = aBackgroundOriginRect + aBuilder->ToReferenceFrame(aFrame);
+    bgOriginRect = aBackgroundOriginRect;
   }
   nsPresContext* presContext = aFrame->PresContext();
   bool isThemed = aFrame->IsThemed();
   nsIFrame* dependentFrame = nullptr;
   if (!isThemed) {
     if (!bgSC) {
       dependentFrame = GetBackgroundComputedStyleFrame(aFrame);
       if (dependentFrame) {
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -445,22 +445,24 @@ void nsTableCellFrame::BuildDisplayList(
   if (ShouldPaintBordersAndBackgrounds()) {
     // display outset box-shadows if we need to.
     bool hasBoxShadow = !StyleEffects()->mBoxShadow.IsEmpty();
     if (hasBoxShadow) {
       aLists.BorderBackground()->AppendNewToTop<nsDisplayBoxShadowOuter>(
           aBuilder, this);
     }
 
+    nsRect bgRect = GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this);
+
     // display background if we need to.
     if (aBuilder->IsForEventDelivery() ||
         !StyleBackground()->IsTransparent(this) ||
         StyleDisplay()->HasAppearance()) {
       nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
-          aBuilder, this, GetRectRelativeToSelf(), aLists.BorderBackground());
+          aBuilder, this, bgRect, aLists.BorderBackground());
     }
 
     // display inset box-shadows if we need to.
     if (hasBoxShadow) {
       aLists.BorderBackground()->AppendNewToTop<nsDisplayBoxShadowInner>(
           aBuilder, this);
     }
 
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -531,30 +531,32 @@ nscoord nsTableRowFrame::CalcBSize(const
   }
   return GetInitialBSize();
 }
 
 void nsTableRowFrame::PaintCellBackgroundsForFrame(
     nsIFrame* aFrame, nsDisplayListBuilder* aBuilder,
     const nsDisplayListSet& aLists, const nsPoint& aOffset) {
   // Compute background rect by iterating all cell frame.
+  const nsPoint toReferenceFrame = aBuilder->ToReferenceFrame(aFrame);
   for (nsTableCellFrame* cell = GetFirstCell(); cell;
        cell = cell->GetNextCell()) {
     if (!cell->ShouldPaintBackground(aBuilder)) {
       continue;
     }
 
     auto cellRect =
         cell->GetRectRelativeToSelf() + cell->GetNormalPosition() + aOffset;
     if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
       continue;
     }
+    cellRect += toReferenceFrame;
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
         aBuilder, aFrame, cellRect, aLists.BorderBackground(), true, nullptr,
-        aFrame->GetRectRelativeToSelf(), cell);
+        aFrame->GetRectRelativeToSelf() + toReferenceFrame, cell);
   }
 }
 
 void nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                        const nsDisplayListSet& aLists) {
   DisplayOutsetBoxShadow(aBuilder, aLists.BorderBackground());
 
   PaintCellBackgroundsForFrame(this, aBuilder, aLists);
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -257,24 +257,26 @@ void nsTableRowGroupFrame::PaintCellBack
         }
         continue;
       }
 
       if (!cell->ShouldPaintBackground(aBuilder)) {
         continue;
       }
 
-      auto cellPos = cell->GetNormalPosition() + rowPos;
+      auto cellPos = cell->GetNormalPosition() + rowPos +
+                     aBuilder->ToReferenceFrame(aFrame);
       auto cellRect = nsRect(cellPos, cell->GetSize());
       if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
         continue;
       }
       nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
           aBuilder, aFrame, cellRect, aList, false, nullptr,
-          aFrame->GetRectRelativeToSelf(), cell);
+          aFrame->GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(aFrame),
+          cell);
     }
   }
 }
 
 void nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                             const nsDisplayListSet& aLists) {
   DisplayOutsetBoxShadow(aBuilder, aLists.BorderBackground());
 
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -148,17 +148,18 @@ void nsDisplayXULGroupBorder::Paint(nsDi
   nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
 }
 
 void nsGroupBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                        const nsDisplayListSet& aLists) {
   // Paint our background and border
   if (IsVisibleForPainting()) {
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
-        aBuilder, this, GetBackgroundRectRelativeToSelf(),
+        aBuilder, this,
+        GetBackgroundRectRelativeToSelf() + aBuilder->ToReferenceFrame(this),
         aLists.BorderBackground());
     aLists.BorderBackground()->AppendNewToTop<nsDisplayXULGroupBorder>(aBuilder,
                                                                        this);
 
     DisplayOutline(aBuilder, aLists);
   }
 
   BuildDisplayListForChildren(aBuilder, aLists);