Bug 894905 - Make AppendBackgroundItemsToTop return a bool instead of an nsDisplayBackgroundImage. r=roc
authorMarkus Stange <mstange@themasta.com>
Thu, 18 Jul 2013 08:34:10 +0200
changeset 151294 9cc2abd1f1a00f22000e90e206d673fc9625eb18
parent 151293 f24b57db17bc611e83e22a95d54fedc9a21a18eb
child 151295 fcc730af1e8b5bfb00a062b8d11902272e52d1b9
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs894905
milestone25.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 894905 - Make AppendBackgroundItemsToTop return a bool instead of an nsDisplayBackgroundImage. r=roc
layout/base/nsDisplayList.cpp
layout/base/nsDisplayList.h
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/tables/nsTableFrame.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1643,18 +1643,22 @@ static nsStyleContext* GetBackgroundStyl
   }
   return sc;
 }
 
 /*static*/ nsresult
 nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuilder,
                                                      nsIFrame* aFrame,
                                                      nsDisplayList* aList,
-                                                     nsDisplayBackgroundImage** aBackground)
+                                                     bool* aAppendedThemedBackground)
 {
+  if (aAppendedThemedBackground) {
+    *aAppendedThemedBackground = false;
+  }
+
   nsStyleContext* bgSC = nullptr;
   const nsStyleBackground* bg = nullptr;
   nsPresContext* presContext = aFrame->PresContext();
   bool isThemed = aFrame->IsThemed();
   if (!isThemed) {
     bgSC = GetBackgroundStyleContext(aFrame);
     if (bgSC) {
       bg = bgSC->StyleBackground();
@@ -1676,42 +1680,37 @@ nsDisplayBackgroundImage::AppendBackgrou
       aBuilder->IsForEventDelivery()) {
     aList->AppendNewToTop(
         new (aBuilder) nsDisplayBackgroundColor(aBuilder, aFrame, bg,
                                                 drawBackgroundColor ? color : NS_RGBA(0, 0, 0, 0)));
   }
 
   if (isThemed) {
     nsDisplayBackgroundImage* bgItem =
-      new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, 0, isThemed, nullptr);
+      new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, 0, true, nullptr);
     aList->AppendNewToTop(bgItem);
-    if (aBackground) {
-      *aBackground = bgItem;
+    if (aAppendedThemedBackground) {
+      *aAppendedThemedBackground = true;
     }
     return NS_OK;
   }
 
   if (!bg) {
     return NS_OK;
   }
  
   // Passing bg == nullptr in this macro will result in one iteration with
   // i = 0.
-  bool backgroundSet = !aBackground;
   NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
     if (bg->mLayers[i].mImage.IsEmpty()) {
       continue;
     }
     nsDisplayBackgroundImage* bgItem =
-      new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, i, isThemed, bg);
+      new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, i, false, bg);
     aList->AppendNewToTop(bgItem);
-    if (!backgroundSet) {
-      *aBackground = bgItem;
-      backgroundSet = true;
-    }
   }
 
   return NS_OK;
 }
 
 // Check that the rounded border of aFrame, added to aToReferenceFrame,
 // intersects aRect.  Assumes that the unrounded border has already
 // been checked for intersection.
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -1953,17 +1953,17 @@ public:
   virtual ~nsDisplayBackgroundImage();
 
   // This will create and append new items for all the layers of the
   // background. If given, aBackground will be set with the address of the
   // bottom-most background item.
   static nsresult AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuilder,
                                              nsIFrame* aFrame,
                                              nsDisplayList* aList,
-                                             nsDisplayBackgroundImage** aBackground = nullptr);
+                                             bool* aAppendedThemedBackground = nullptr);
 
   virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
                                    LayerManager* aManager,
                                    const ContainerParameters& aParameters) MOZ_OVERRIDE;
 
   virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
                                              LayerManager* aManager,
                                              const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1480,28 +1480,30 @@ nsIFrame::GetCaretColorAt(int32_t aOffse
   // Use text color.
   return StyleColor()->mColor;
 }
 
 void
 nsFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder*       aBuilder,
                                         const nsDisplayListSet&     aLists,
                                         bool                        aForceBackground,
-                                        nsDisplayBackgroundImage** aBackground)
-{
-  *aBackground = nullptr;
+                                        bool*                       aAppendedThemedBackground)
+{
+  if (aAppendedThemedBackground) {
+    *aAppendedThemedBackground = false;
+  }
 
   // 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() || StyleDisplay()->mAppearance) {
     nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, this,
                                                          aLists.BorderBackground(),
-                                                         aBackground);
+                                                         aAppendedThemedBackground);
   }
 }
 
 void
 nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder*   aBuilder,
                                         const nsDisplayListSet& aLists,
                                         bool                    aForceBackground)
 {
@@ -1512,27 +1514,28 @@ nsFrame::DisplayBorderBackgroundOutline(
     return;
 
   nsCSSShadowArray* shadows = StyleBorder()->mBoxShadow;
   if (shadows && shadows->HasShadowWithInset(false)) {
     aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
       nsDisplayBoxShadowOuter(aBuilder, this));
   }
 
-  nsDisplayBackgroundImage* bg;
-  DisplayBackgroundUnconditional(aBuilder, aLists, aForceBackground, &bg);
+  bool bgIsThemed;
+  DisplayBackgroundUnconditional(aBuilder, aLists, aForceBackground,
+                                 &bgIsThemed);
 
   if (shadows && shadows->HasShadowWithInset(true)) {
     aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
       nsDisplayBoxShadowInner(aBuilder, this));
   }
 
   // If there's a themed background, we should not create a border item.
   // It won't be rendered.
-  if ((!bg || !bg->IsThemed()) && StyleBorder()->HasBorder()) {
+  if (!bgIsThemed && StyleBorder()->HasBorder()) {
     aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
       nsDisplayBorder(aBuilder, this));
   }
 
   DisplayOutlineUnconditional(aBuilder, aLists);
 }
 
 inline static bool IsSVGContentWithCSSClip(const nsIFrame *aFrame)
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -489,23 +489,24 @@ public:
 
   /**
    * Adds display items for standard CSS background if necessary.
    * Does not check IsVisibleForPainting.
    * @param aForceBackground draw the background even if the frame
    * background style appears to have no background --- this is useful
    * for frames that might receive a propagated background via
    * nsCSSRendering::FindBackground
-   * @param aBackground *aBackground is set to the bottom-most
-   * nsDisplayBackground item, if any are created, otherwise null.
+   * @param aAppendedThemedBackground if non-null,
+   * *aAppendedThemedBackground will indicate whether a themed background
+   * item was created.
    */
   void DisplayBackgroundUnconditional(nsDisplayListBuilder*   aBuilder,
                                       const nsDisplayListSet& aLists,
                                       bool aForceBackground,
-                                      nsDisplayBackgroundImage** aBackground);
+                                      bool* aAppendedThemedBackground = nullptr);
   /**
    * Adds display items for standard CSS borders, background and outline for
    * for this frame, as necessary. Checks IsVisibleForPainting and won't
    * display anything if the frame is not visible.
    * @param aForceBackground draw the background even if the frame
    * background style appears to have no background --- this is useful
    * for frames that might receive a propagated background via
    * nsCSSRendering::FindBackground
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1263,18 +1263,17 @@ nsTableFrame::BuildDisplayList(nsDisplay
   nsDisplayTableItem* item = nullptr;
   if (IsVisibleInSelection(aBuilder)) {
     if (StyleVisibility()->IsVisible()) {
       nsMargin deflate = GetDeflationForBackground(PresContext());
       // If 'deflate' is (0,0,0,0) then we can paint the table background
       // in its own display item, so do that to take advantage of
       // opacity and visibility optimizations
       if (deflate == nsMargin(0, 0, 0, 0)) {
-        nsDisplayBackgroundImage* bg;
-        DisplayBackgroundUnconditional(aBuilder, aLists, false, &bg);
+        DisplayBackgroundUnconditional(aBuilder, aLists, false);
       }
     }
     
     // This background is created if any of the table parts are visible,
     // or if we're doing event handling (since DisplayGenericTablePart
     // needs the item for the |sortEventBackgrounds|-dependent code).
     // Specific visibility decisions are delegated to the table background
     // painter, which handles borders and backgrounds for the table.