Bug 1064790 - Give S/SN/SF/SN meaningful names. r=bz
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 09 Sep 2014 21:08:00 -0400
changeset 229190 134555681bd91b714a6bda43191ef4652c383375
parent 229189 0ff268a723788f0400f4a6ef76c2e6355395c8ae
child 229191 6f3a3126790fccd273095d836bd3b87464d36d34
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1064790, 641426
milestone35.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 1064790 - Give S/SN/SF/SN meaningful names. r=bz Also fix gfxRect usage in "PrintAsString" as Bug 641426 part 2 did.
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -614,17 +614,17 @@ nsCSSRendering::PaintBorderWithStyleBord
                                            nsRenderingContext& aRenderingContext,
                                            nsIFrame* aForFrame,
                                            const nsRect& aDirtyRect,
                                            const nsRect& aBorderArea,
                                            const nsStyleBorder& aStyleBorder,
                                            nsStyleContext* aStyleContext,
                                            Sides aSkipSides)
 {
-  SN("++ PaintBorder");
+  PrintAsStringNewline("++ PaintBorder");
 
   // Check to see if we have an appearance defined.  If so, we let the theme
   // renderer draw the border.  DO not get the data from aForFrame, since the passed in style context
   // may be different!  Always use |aStyleContext|!
   const nsStyleDisplay* displayData = aStyleContext->StyleDisplay();
   if (displayData->mAppearance) {
     nsITheme *theme = aPresContext->GetTheme();
     if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance))
@@ -658,17 +658,17 @@ nsCSSRendering::PaintBorderWithStyleBord
   // Compute the outermost boundary of the area that might be painted.
   // Same coordinate space as aBorderArea & aBGClipRect.
   nsRect joinedBorderArea =
     ::BoxDecorationRectForBorder(aForFrame, aBorderArea, &aStyleBorder);
   gfxCornerSizes bgRadii;
   ::GetRadii(aForFrame, aStyleBorder, aBorderArea, joinedBorderArea, &bgRadii);
 
 
-  SF(" joinedBorderArea: %d %d %d %d\n", joinedBorderArea.x, joinedBorderArea.y,
+  PrintAsFormatString(" joinedBorderArea: %d %d %d %d\n", joinedBorderArea.x, joinedBorderArea.y,
      joinedBorderArea.width, joinedBorderArea.height);
 
   // start drawing
   gfxContext* ctx = aRenderingContext.ThebesContext();
   ctx->Save();
 
   if (::IsBoxDecorationSlice(aStyleBorder)) {
     if (aSkipSides.IsEmpty()) {
@@ -711,18 +711,18 @@ nsCSSRendering::PaintBorderWithStyleBord
     borderStyles[i] = aStyleBorder.GetBorderStyle(i);
     aStyleBorder.GetBorderColor(i, borderColors[i], foreground);
     aStyleBorder.GetCompositeColors(i, &compositeColors[i]);
 
     if (foreground)
       borderColors[i] = ourColor->mColor;
   }
 
-  SF(" borderStyles: %d %d %d %d\n", borderStyles[0], borderStyles[1], borderStyles[2], borderStyles[3]);
-  //SF ("bgRadii: %f %f %f %f\n", bgRadii[0], bgRadii[1], bgRadii[2], bgRadii[3]);
+  PrintAsFormatString(" borderStyles: %d %d %d %d\n", borderStyles[0], borderStyles[1], borderStyles[2], borderStyles[3]);
+  //PrintAsFormatString ("bgRadii: %f %f %f %f\n", bgRadii[0], bgRadii[1], bgRadii[2], bgRadii[3]);
 
 #if 0
   // this will draw a transparent red backround underneath the border area
   ctx->Save();
   ctx->Rectangle(joinedBorderAreaPx);
   ctx->SetColor(gfxRGBA(1.0, 0.0, 0.0, 0.5));
   ctx->Fill();
   ctx->Restore();
@@ -736,17 +736,17 @@ nsCSSRendering::PaintBorderWithStyleBord
                          bgRadii,
                          borderColors,
                          compositeColors,
                          bgColor);
   br.DrawBorders();
 
   ctx->Restore();
 
-  SN();
+  PrintAsStringNewline();
 }
 
 static nsRect
 GetOutlineInnerRect(nsIFrame* aFrame)
 {
   nsRect* savedOutlineInnerRect = static_cast<nsRect*>
     (aFrame->Properties().Get(nsIFrame::OutlineInnerRectProperty()));
   if (savedOutlineInnerRect)
@@ -874,17 +874,17 @@ nsCSSRendering::PaintOutline(nsPresConte
                          outlineRadii,
                          outlineColors,
                          nullptr,
                          bgColor);
   br.DrawBorders();
 
   ctx->Restore();
 
-  SN();
+  PrintAsStringNewline();
 }
 
 void
 nsCSSRendering::PaintFocus(nsPresContext* aPresContext,
                            nsRenderingContext& aRenderingContext,
                            const nsRect& aFocusRect,
                            nscolor aColor)
 {
@@ -927,17 +927,17 @@ nsCSSRendering::PaintFocus(nsPresContext
                          focusRadii,
                          focusColors,
                          nullptr,
                          NS_RGB(255, 0, 0));
   br.DrawBorders();
 
   ctx->Restore();
 
-  SN();
+  PrintAsStringNewline();
 }
 
 // Thebes Border Rendering Code End
 //----------------------------------------------------------------------
 
 
 //----------------------------------------------------------------------
 
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -938,22 +938,22 @@ nsCSSBorderRenderer::DrawDashedSide(mozi
       dash[1] = dashWidth * 2.0;
 
       mContext->SetLineCap(gfxContext::LINE_CAP_ROUND);
     } else {
       dash[0] = dashWidth;
       dash[1] = dashWidth;
     }
   } else {
-    SF("DrawDashedSide: style: %d!!\n", style);
+    PrintAsFormatString("DrawDashedSide: style: %d!!\n", style);
     NS_ERROR("DrawDashedSide called with style other than DASHED or DOTTED; someone's not playing nice");
     return;
   }
 
-  SF("dash: %f %f\n", dash[0], dash[1]);
+  PrintAsFormatString("dash: %f %f\n", dash[0], dash[1]);
 
   mContext->SetDash(dash, 2, 0.0);
 
   gfxPoint start = mOuterRect.CCWCorner(aSide);
   gfxPoint end = mOuterRect.CWCorner(aSide);
 
   if (aSide == NS_SIDE_TOP) {
     start.x += mBorderCornerDimensions[C_TL].width;
@@ -1088,17 +1088,17 @@ nsCSSBorderRenderer::CreateCornerGradien
                                           Point &aPoint2)
 {
   typedef struct { gfxFloat a, b; } twoFloats;
 
   const twoFloats gradientCoeff[4] = { { -1, +1 },
                                        { -1, -1 },
                                        { +1, -1 },
                                        { +1, +1 } };
-  
+
   // Sides which form the 'width' and 'height' for the calculation of the angle
   // for our gradient.
   const int cornerWidth[4] = { 3, 1, 1, 3 };
   const int cornerHeight[4] = { 0, 0, 2, 2 };
 
   gfxPoint cornerOrigin = mOuterRect.AtCorner(aCorner);
 
   gfxPoint pat1, pat2;
@@ -1152,25 +1152,25 @@ nsCSSBorderRenderer::DrawSingleWidthSoli
   gfxRect rect = mOuterRect;
   rect.Deflate(0.5);
 
   const twoFloats cornerAdjusts[4] = { { +0.5,  0   },
                                        {    0, +0.5 },
                                        { -0.5,  0   },
                                        {    0, -0.5 } };
 
-    
+
   NS_FOR_CSS_SIDES(side) {
     gfxPoint firstCorner = rect.CCWCorner(side);
     firstCorner.x += cornerAdjusts[side].a;
     firstCorner.y += cornerAdjusts[side].b;
     gfxPoint secondCorner = rect.CWCorner(side);
     secondCorner.x += cornerAdjusts[side].a;
     secondCorner.y += cornerAdjusts[side].b;
-        
+
     mContext->SetColor(gfxRGBA(mBorderColors[side]));
     mContext->NewPath();
     mContext->MoveTo(firstCorner);
     mContext->LineTo(secondCorner);
     mContext->Stroke();
   }
 }
 
@@ -1351,17 +1351,17 @@ nsCSSBorderRenderer::DrawRectangularComp
       int sideNext = (side + 1) % 4;
 
       gfxPoint firstCorner = rect.CCWCorner(side);
       firstCorner.x += cornerAdjusts[side].a;
       firstCorner.y += cornerAdjusts[side].b;
       gfxPoint secondCorner = rect.CWCorner(side);
       secondCorner.x -= cornerAdjusts[side].a;
       secondCorner.y -= cornerAdjusts[side].b;
-        
+
       gfxRGBA currentColor =
         currentColors[side] ? gfxRGBA(currentColors[side]->mColor)
                             : gfxRGBA(mBorderColors[side]);
 
       mContext->SetColor(currentColor);
       mContext->NewPath();
       mContext->MoveTo(firstCorner);
       mContext->LineTo(secondCorner);
@@ -1486,29 +1486,29 @@ nsCSSBorderRenderer::DrawBorders()
       mBorderStyles[0] == NS_STYLE_BORDER_STYLE_DOTTED &&
       mBorderWidths[0] < 3 &&
       mNoBorderRadius &&
       !mAvoidStroke)
   {
     // Very simple case. We draw this rectangular dotted borner without
     // antialiasing. The dots should be pixel aligned.
     SetupStrokeStyle(NS_SIDE_TOP);
-    
+
     gfxFloat dash = mBorderWidths[0];
     mContext->SetDash(&dash, 1, 0.5);
     mContext->SetAntialiasMode(gfxContext::MODE_ALIASED);
     gfxRect rect = mOuterRect;
     rect.Deflate(mBorderWidths[0] / 2.0);
     mContext->NewPath();
     mContext->Rectangle(rect);
     mContext->Stroke();
     return;
   }
 
-  
+
   if (allBordersSame &&
       mCompositeColors[0] == nullptr &&
       mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID &&
       !mAvoidStroke &&
       !mNoBorderRadius)
   {
     // Relatively simple case.
     SetupStrokeStyle(NS_SIDE_TOP);
@@ -1569,19 +1569,19 @@ nsCSSBorderRenderer::DrawBorders()
   }
 
   // If we have composite colors -and- border radius,
   // then use separate corners so we get OPERATOR_ADD for the corners.
   // Otherwise, we'll get artifacts as we draw stacked 1px-wide curves.
   if (allBordersSame && mCompositeColors[0] != nullptr && !mNoBorderRadius)
     forceSeparateCorners = true;
 
-  S(" mOuterRect: "), S(mOuterRect), SN();
-  S(" mInnerRect: "), S(mInnerRect), SN();
-  SF(" mBorderColors: 0x%08x 0x%08x 0x%08x 0x%08x\n", mBorderColors[0], mBorderColors[1], mBorderColors[2], mBorderColors[3]);
+  PrintAsString(" mOuterRect: "), PrintAsString(mOuterRect), PrintAsStringNewline();
+  PrintAsString(" mInnerRect: "), PrintAsString(mInnerRect), PrintAsStringNewline();
+  PrintAsFormatString(" mBorderColors: 0x%08x 0x%08x 0x%08x 0x%08x\n", mBorderColors[0], mBorderColors[1], mBorderColors[2], mBorderColors[3]);
 
   // if conditioning the outside rect failed, then bail -- the outside
   // rect is supposed to enclose the entire border
   mOuterRect.Condition();
   if (mOuterRect.IsEmpty())
     return;
 
   mInnerRect.Condition();
@@ -1594,22 +1594,22 @@ nsCSSBorderRenderer::DrawBorders()
     {
       // pretend that all borders aren't the same; we need to draw
       // things separately for dashed/dotting
       allBordersSame = false;
       dashedSides |= (1 << i);
     }
   }
 
-  SF(" allBordersSame: %d dashedSides: 0x%02x\n", allBordersSame, dashedSides);
+  PrintAsFormatString(" allBordersSame: %d dashedSides: 0x%02x\n", allBordersSame, dashedSides);
 
   if (allBordersSame && !forceSeparateCorners) {
     /* Draw everything in one go */
     DrawBorderSides(SIDE_BITS_ALL);
-    SN("---------------- (1)");
+    PrintAsStringNewline("---------------- (1)");
   } else {
     PROFILER_LABEL("nsCSSBorderRenderer", "DrawBorders::multipass",
       js::ProfileEntry::Category::GRAPHICS);
 
     /* We have more than one pass to go.  Draw the corners separately from the sides. */
 
     /*
      * If we have a 1px-wide border, the corners are going to be
@@ -1685,33 +1685,33 @@ nsCSSBorderRenderer::DrawBorders()
         // that often in practice (we double buffer to no-alpha
         // surfaces). We choose just to seam though, as the performance
         // advantages outway the modest easthetic improvement.
 
         for (int cornerSide = 0; cornerSide < 2; cornerSide++) {
           mozilla::css::Side side = mozilla::css::Side(sides[cornerSide]);
           uint8_t style = mBorderStyles[side];
 
-          SF("corner: %d cornerSide: %d side: %d style: %d\n", corner, cornerSide, side, style);
+          PrintAsFormatString("corner: %d cornerSide: %d side: %d style: %d\n", corner, cornerSide, side, style);
 
           mContext->Save();
 
           mContext->NewPath();
           DoSideClipSubPath(side);
           mContext->Clip();
 
           DrawBorderSides(1 << side);
 
           mContext->Restore();
         }
       }
 
       mContext->Restore();
 
-      SN();
+      PrintAsStringNewline();
     }
 
     // in the case of a single-unit border, we already munged the
     // corners up above; so we can just draw the top left and bottom
     // right sides separately, if they're the same.
     //
     // We need to check for mNoBorderRadius, because when there is
     // one, FillSolidBorder always draws the full rounded rectangle
@@ -1745,17 +1745,17 @@ nsCSSBorderRenderer::DrawBorders()
         continue;
 
 
       if (dashedSides & (1 << side)) {
         // Dashed sides will always draw just the part ignoring the
         // corners for the side, so no need to clip.
         DrawDashedSide (side);
 
-        SN("---------------- (d)");
+        PrintAsStringNewline("---------------- (d)");
         continue;
       }
 
       // Undashed sides will currently draw the entire side,
       // including parts that would normally be covered by a corner,
       // so we need to clip.
       //
       // XXX Optimization -- it would be good to make this work like
@@ -1766,12 +1766,12 @@ nsCSSBorderRenderer::DrawBorders()
       mContext->NewPath();
       DoSideClipWithoutCornersSubPath(side);
       mContext->Clip();
 
       DrawBorderSides(1 << side);
 
       mContext->Restore();
 
-      SN("---------------- (*)");
+      PrintAsStringNewline("---------------- (*)");
     }
   }
 }
--- a/layout/base/nsCSSRenderingBorders.h
+++ b/layout/base/nsCSSRenderingBorders.h
@@ -168,17 +168,17 @@ struct nsCSSBorderRenderer {
   // present in the bitmask
   void DrawBorderSides (int aSides);
 
   // function used by the above to handle -moz-border-colors
   void DrawBorderSidesCompositeColors(int aSides, const nsBorderColors *compositeColors);
 
   // draw the given dashed side
   void DrawDashedSide (mozilla::css::Side aSide);
-  
+
   // Setup the stroke style for a given side
   void SetupStrokeStyle(mozilla::css::Side aSize);
 
   // Analyze if all border sides have the same width.
   bool AllBordersSameWidth();
 
   // Analyze if all borders are 'solid' this also considers hidden or 'none'
   // borders because they can be considered 'solid' borders of 0 width and
@@ -221,70 +221,69 @@ struct nsCSSBorderRenderer {
   // by increasing the radii, except keeping sharp corners sharp.
   // Used for spread box-shadows
   static void ComputeOuterRadii(const gfxCornerSizes& aRadii,
                                 const gfxFloat *aBorderSizes,
                                 gfxCornerSizes *aOuterRadiiRet);
 };
 
 namespace mozilla {
-
 #ifdef DEBUG_NEW_BORDERS
 #include <stdarg.h>
 
-static inline void S(const gfxPoint& p) {
+static inline void PrintAsString(const gfxPoint& p) {
   fprintf (stderr, "[%f,%f]", p.x, p.y);
 }
 
-static inline void S(const gfxSize& s) {
+static inline void PrintAsString(const gfxSize& s) {
   fprintf (stderr, "[%f %f]", s.width, s.height);
 }
 
-static inline void S(const gfxRect& r) {
-  fprintf (stderr, "[%f %f %f %f]", r.pos.x, r.pos.y, r.size.width, r.size.height);
+static inline void PrintAsString(const gfxRect& r) {
+  fprintf (stderr, "[%f %f %f %f]", r.X(), r.Y(), r.Width(), r.Height());
 }
 
-static inline void S(const gfxFloat f) {
+static inline void PrintAsString(const gfxFloat f) {
   fprintf (stderr, "%f", f);
 }
 
-static inline void S(const char *s) {
+static inline void PrintAsString(const char *s) {
   fprintf (stderr, "%s", s);
 }
 
-static inline void SN(const char *s = nullptr) {
+static inline void PrintAsStringNewline(const char *s = nullptr) {
   if (s)
     fprintf (stderr, "%s", s);
   fprintf (stderr, "\n");
   fflush (stderr);
 }
 
-static inline void SF(const char *fmt, ...) {
+static inline void PrintAsFormatString(const char *fmt, ...) {
   va_list vl;
   va_start(vl, fmt);
   vfprintf (stderr, fmt, vl);
   va_end(vl);
 }
 
-static inline void SX(gfxContext *ctx) {
+static inline void PrintGfxContext(gfxContext *ctx) {
   gfxPoint p = ctx->CurrentPoint();
   fprintf (stderr, "p: %f %f\n", p.x, p.y);
   return;
   ctx->MoveTo(p + gfxPoint(-2, -2)); ctx->LineTo(p + gfxPoint(2, 2));
   ctx->MoveTo(p + gfxPoint(-2, 2)); ctx->LineTo(p + gfxPoint(2, -2));
   ctx->MoveTo(p);
 }
 
 
 #else
-static inline void S(const gfxPoint& p) {}
-static inline void S(const gfxSize& s) {}
-static inline void S(const gfxRect& r) {}
-static inline void S(const gfxFloat f) {}
-static inline void S(const char *s) {}
-static inline void SN(const char *s = nullptr) {}
-static inline void SF(const char *fmt, ...) {}
-static inline void SX(gfxContext *ctx) {}
+static inline void PrintAsString(const gfxPoint& p) {}
+static inline void PrintAsString(const gfxSize& s) {}
+static inline void PrintAsString(const gfxRect& r) {}
+static inline void PrintAsString(const gfxFloat f) {}
+static inline void PrintAsString(const char *s) {}
+static inline void PrintAsStringNewline(const char *s = nullptr) {}
+static inline void PrintAsFormatString(const char *fmt, ...) {}
+static inline void PrintGfxContext(gfxContext *ctx) {}
 #endif
 
 }
 
 #endif /* NS_CSS_RENDERING_BORDERS_H */