Bug 1142400 - Separate padding calculation in Get{Min,Pref}ISize and Reflow of nsBulletFrame. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 12 Mar 2015 20:53:54 +1100
changeset 233348 0654036827f727e1868823c4f02161bc56059212
parent 233347 56e97ea0233b07a986f7a52d2de9cdbe84114579
child 233349 328350363afc37e952f3404d29e84ea2d470662a
push id28410
push userryanvm@gmail.com
push dateThu, 12 Mar 2015 22:06:36 +0000
treeherdermozilla-central@42afc7ef5ccb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1142400
milestone39.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 1142400 - Separate padding calculation in Get{Min,Pref}ISize and Reflow of nsBulletFrame. r=dbaron
layout/generic/nsBulletFrame.cpp
layout/generic/nsBulletFrame.h
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -510,30 +510,32 @@ nsBulletFrame::GetListItemText(nsAString
     aResult.Append(mark);
   }
   aResult.Append(suffix);
 }
 
 #define MIN_BULLET_SIZE 1
 
 void
-nsBulletFrame::AppendSpacingToPadding(nsFontMetrics* aFontMetrics)
+nsBulletFrame::AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
+                                      LogicalMargin* aPadding)
 {
-  mPadding.IEnd(GetWritingMode()) += aFontMetrics->EmHeight() / 2;
+  aPadding->IEnd(GetWritingMode()) += aFontMetrics->EmHeight() / 2;
 }
 
 void
 nsBulletFrame::GetDesiredSize(nsPresContext*  aCX,
                               nsRenderingContext *aRenderingContext,
                               nsHTMLReflowMetrics& aMetrics,
-                              float aFontSizeInflation)
+                              float aFontSizeInflation,
+                              LogicalMargin* aPadding)
 {
   // Reset our padding.  If we need it, we'll set it below.
   WritingMode wm = GetWritingMode();
-  mPadding.SizeTo(wm, 0, 0, 0, 0);
+  aPadding->SizeTo(wm, 0, 0, 0, 0);
   LogicalSize finalSize(wm);
 
   const nsStyleList* myList = StyleList();
   nscoord ascent;
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
                                         aFontSizeInflation);
 
@@ -545,17 +547,17 @@ nsBulletFrame::GetDesiredSize(nsPresCont
     if (status & imgIRequest::STATUS_SIZE_AVAILABLE &&
         !(status & imgIRequest::STATUS_ERROR)) {
       // auto size the image
       finalSize.ISize(wm) = mIntrinsicSize.ISize(wm);
       aMetrics.SetBlockStartAscent(finalSize.BSize(wm) =
                                    mIntrinsicSize.BSize(wm));
       aMetrics.SetSize(wm, finalSize);
 
-      AppendSpacingToPadding(fm);
+      AppendSpacingToPadding(fm, aPadding);
 
       AddStateBits(BULLET_FRAME_IMAGE_LOADING);
 
       return;
     }
   }
 
   // If we're getting our desired size and don't have an image, reset
@@ -576,35 +578,35 @@ nsBulletFrame::GetDesiredSize(nsPresCont
       break;
 
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE: {
       ascent = fm->MaxAscent();
       bulletSize = std::max(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
                           NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
-      mPadding.BEnd(wm) = NSToCoordRound(float(ascent) / 8.0f);
+      aPadding->BEnd(wm) = NSToCoordRound(float(ascent) / 8.0f);
       finalSize.ISize(wm) = finalSize.BSize(wm) = bulletSize;
-      aMetrics.SetBlockStartAscent(bulletSize + mPadding.BEnd(wm));
-      AppendSpacingToPadding(fm);
+      aMetrics.SetBlockStartAscent(bulletSize + aPadding->BEnd(wm));
+      AppendSpacingToPadding(fm, aPadding);
       break;
     }
 
     case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
     case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
       ascent = fm->EmAscent();
       bulletSize = std::max(
           nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
           NSToCoordRound(0.75f * ascent));
-      mPadding.BEnd(wm) = NSToCoordRound(0.125f * ascent);
+      aPadding->BEnd(wm) = NSToCoordRound(0.125f * ascent);
       finalSize.ISize(wm) = finalSize.BSize(wm) = bulletSize;
       if (!wm.IsVertical()) {
-        aMetrics.SetBlockStartAscent(bulletSize + mPadding.BEnd(wm));
+        aMetrics.SetBlockStartAscent(bulletSize + aPadding->BEnd(wm));
       }
-      AppendSpacingToPadding(fm);
+      AppendSpacingToPadding(fm, aPadding);
       break;
 
     default:
       GetListItemText(text);
       finalSize.BSize(wm) = fm->MaxHeight();
       finalSize.ISize(wm) =
         nsLayoutUtils::AppUnitWidthOfStringBidi(text, this, *fm,
                                                 *aRenderingContext);
@@ -623,17 +625,18 @@ nsBulletFrame::Reflow(nsPresContext* aPr
 {
   DO_GLOBAL_REFLOW_COUNT("nsBulletFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
 
   float inflation = nsLayoutUtils::FontSizeInflationFor(this);
   SetFontSizeInflation(inflation);
 
   // Get the base size
-  GetDesiredSize(aPresContext, aReflowState.rendContext, aMetrics, inflation);
+  GetDesiredSize(aPresContext, aReflowState.rendContext,
+                 aMetrics, inflation, &mPadding);
 
   // Add in the border and padding; split the top/bottom between the
   // ascent and descent to make things look nice
   WritingMode wm = aReflowState.GetWritingMode();
   const LogicalMargin& bp = aReflowState.ComputedLogicalBorderPadding();
   mPadding.BStart(wm) += NSToCoordRound(bp.BStart(wm) * inflation);
   mPadding.IEnd(wm) += NSToCoordRound(bp.IEnd(wm) * inflation);
   mPadding.BEnd(wm) += NSToCoordRound(bp.BEnd(wm) * inflation);
@@ -657,29 +660,31 @@ nsBulletFrame::Reflow(nsPresContext* aPr
 }
 
 /* virtual */ nscoord
 nsBulletFrame::GetMinISize(nsRenderingContext *aRenderingContext)
 {
   WritingMode wm = GetWritingMode();
   nsHTMLReflowMetrics metrics(wm);
   DISPLAY_MIN_WIDTH(this, metrics.ISize(wm));
-  GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
-  metrics.ISize(wm) += mPadding.IStartEnd(wm);
+  LogicalMargin padding(wm);
+  GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f, &padding);
+  metrics.ISize(wm) += padding.IStartEnd(wm);
   return metrics.ISize(wm);
 }
 
 /* virtual */ nscoord
 nsBulletFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
 {
   WritingMode wm = GetWritingMode();
   nsHTMLReflowMetrics metrics(wm);
   DISPLAY_PREF_WIDTH(this, metrics.ISize(wm));
-  GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
-  metrics.ISize(wm) += mPadding.IStartEnd(wm);
+  LogicalMargin padding(wm);
+  GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f, &padding);
+  metrics.ISize(wm) += padding.IStartEnd(wm);
   return metrics.ISize(wm);
 }
 
 NS_IMETHODIMP
 nsBulletFrame::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData)
 {
   if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
     nsCOMPtr<imgIContainer> image;
--- a/layout/generic/nsBulletFrame.h
+++ b/layout/generic/nsBulletFrame.h
@@ -108,21 +108,23 @@ public:
 
   int32_t GetOrdinal() { return mOrdinal; }
 
   already_AddRefed<imgIContainer> GetImage() const;
 
 protected:
   nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
 
-  void AppendSpacingToPadding(nsFontMetrics* aFontMetrics);
+  void AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
+                              mozilla::LogicalMargin* aPadding);
   void GetDesiredSize(nsPresContext* aPresContext,
                       nsRenderingContext *aRenderingContext,
                       nsHTMLReflowMetrics& aMetrics,
-                      float aFontSizeInflation);
+                      float aFontSizeInflation,
+                      mozilla::LogicalMargin* aPadding);
 
   void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
   nsIDocument* GetOurCurrentDoc() const;
 
   mozilla::LogicalMargin mPadding;
   nsRefPtr<imgRequestProxy> mImageRequest;
   nsRefPtr<nsBulletListener> mListener;