Bug 1317588 Part 4 - Remove side bits defined in BorderConsts.h r=mats
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 21 Nov 2016 11:56:35 +0800
changeset 324064 88f2c7f0a24a5d7e1f82769ae24aed5c0cf9bed7
parent 324063 1710e2f930dbd5b32aa5f126ab031c8353a73523
child 324065 0c03c2ddda3a4e58295c9f3e1670237cd8b75fb9
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmats
bugs1317588
milestone53.0a1
Bug 1317588 Part 4 - Remove side bits defined in BorderConsts.h r=mats Those bits are already defined as enum in gfx/2d/Types.h. MozReview-Commit-ID: 8E81lW9WnAg
layout/painting/BorderConsts.h
layout/painting/nsCSSRenderingBorders.cpp
--- a/layout/painting/BorderConsts.h
+++ b/layout/painting/BorderConsts.h
@@ -5,23 +5,16 @@
 
 #ifndef mozilla_BorderConsts_h_
 #define mozilla_BorderConsts_h_
 
 // thickness of dashed line relative to dotted line
 #define DOT_LENGTH  1           // square
 #define DASH_LENGTH 3           // 3 times longer than dot
 
-// some shorthand for side bits
-#define SIDE_BIT_TOP (1 << eSideTop)
-#define SIDE_BIT_RIGHT (1 << eSideRight)
-#define SIDE_BIT_BOTTOM (1 << eSideBottom)
-#define SIDE_BIT_LEFT (1 << eSideLeft)
-#define SIDE_BITS_ALL (SIDE_BIT_TOP|SIDE_BIT_RIGHT|SIDE_BIT_BOTTOM|SIDE_BIT_LEFT)
-
 #define C_TL NS_CORNER_TOP_LEFT
 #define C_TR NS_CORNER_TOP_RIGHT
 #define C_BR NS_CORNER_BOTTOM_RIGHT
 #define C_BL NS_CORNER_BOTTOM_LEFT
 
 #define BORDER_SEGMENT_COUNT_MAX 100
 #define BORDER_DOTTED_CORNER_MAX_RADIUS 100000
 
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -136,18 +136,18 @@ static mozilla::css::Corner
 GetCCWCorner(mozilla::Side aSide)
 {
   return mozilla::css::Corner(aSide);
 }
 
 static bool
 IsSingleSide(int aSides)
 {
-  return aSides == SIDE_BIT_TOP || aSides == SIDE_BIT_RIGHT ||
-         aSides == SIDE_BIT_BOTTOM || aSides == SIDE_BIT_LEFT;
+  return aSides == eSideBitsTop || aSides == eSideBitsRight ||
+         aSides == eSideBitsBottom || aSides == eSideBitsLeft;
 }
 
 static bool
 IsHorizontalSide(mozilla::Side aSide)
 {
   return aSide == eSideTop || aSide == eSideBottom;
 }
 
@@ -290,17 +290,17 @@ ComputeBorderCornerDimensions(const Floa
     (*aDimsRet)[C_BL] = Size(ceil(std::max(leftWidth, aRadii[C_BL].width)),
                              ceil(std::max(bottomWidth, aRadii[C_BL].height)));
   }
 }
 
 bool
 nsCSSBorderRenderer::AreBorderSideFinalStylesSame(uint8_t aSides)
 {
-  NS_ASSERTION(aSides != 0 && (aSides & ~SIDE_BITS_ALL) == 0,
+  NS_ASSERTION(aSides != 0 && (aSides & ~eSideBitsAll) == 0,
                "AreBorderSidesSame: invalid whichSides!");
 
   /* First check if the specified styles and colors are the same for all sides */
   int firstStyle = 0;
   NS_FOR_CSS_SIDES (i) {
     if (firstStyle == i) {
       if (((1 << i) & aSides) == 0)
         firstStyle++;
@@ -320,18 +320,18 @@ nsCSSBorderRenderer::AreBorderSideFinalS
 
   /* Then if it's one of the two-tone styles and we're not
    * just comparing the TL or BR sides */
   switch (mBorderStyles[firstStyle]) {
     case NS_STYLE_BORDER_STYLE_GROOVE:
     case NS_STYLE_BORDER_STYLE_RIDGE:
     case NS_STYLE_BORDER_STYLE_INSET:
     case NS_STYLE_BORDER_STYLE_OUTSET:
-      return ((aSides & ~(SIDE_BIT_TOP | SIDE_BIT_LEFT)) == 0 ||
-              (aSides & ~(SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT)) == 0);
+      return ((aSides & ~(eSideBitsTop | eSideBitsLeft)) == 0 ||
+              (aSides & ~(eSideBitsBottom | eSideBitsRight)) == 0);
   }
 
   return true;
 }
 
 bool
 nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, mozilla::css::Corner aCorner)
 {
@@ -1129,17 +1129,17 @@ nsCSSBorderRenderer::FillSolidBorder(con
     return;
   }
 
   // If we're asked to draw all sides of an equal-sized border,
   // stroking is fastest.  This is a fairly common path, but partial
   // sides is probably second in the list -- there are a bunch of
   // common border styles, such as inset and outset, that are
   // top-left/bottom-right split.
-  if (aSides == SIDE_BITS_ALL &&
+  if (aSides == eSideBitsAll &&
       CheckFourFloatsEqual(aBorderSizes, aBorderSizes[0]) &&
       !mAvoidStroke)
   {
     Float strokeWidth = aBorderSizes[0];
     Rect r(aOuterRect);
     r.Deflate(strokeWidth / 2.f);
     mDrawTarget->StrokeRect(r, aColor, StrokeOptions(strokeWidth));
     return;
@@ -1147,62 +1147,62 @@ nsCSSBorderRenderer::FillSolidBorder(con
 
   // Otherwise, we have unequal sized borders or we're only
   // drawing some sides; create rectangles for each side
   // and fill them.
 
   Rect r[4];
 
   // compute base rects for each side
-  if (aSides & SIDE_BIT_TOP) {
+  if (aSides & eSideBitsTop) {
     r[eSideTop] =
         Rect(aOuterRect.X(), aOuterRect.Y(),
              aOuterRect.Width(), aBorderSizes[eSideTop]);
   }
 
-  if (aSides & SIDE_BIT_BOTTOM) {
+  if (aSides & eSideBitsBottom) {
     r[eSideBottom] =
         Rect(aOuterRect.X(), aOuterRect.YMost() - aBorderSizes[eSideBottom],
              aOuterRect.Width(), aBorderSizes[eSideBottom]);
   }
 
-  if (aSides & SIDE_BIT_LEFT) {
+  if (aSides & eSideBitsLeft) {
     r[eSideLeft] =
         Rect(aOuterRect.X(), aOuterRect.Y(),
              aBorderSizes[eSideLeft], aOuterRect.Height());
   }
 
-  if (aSides & SIDE_BIT_RIGHT) {
+  if (aSides & eSideBitsRight) {
     r[eSideRight] =
         Rect(aOuterRect.XMost() - aBorderSizes[eSideRight], aOuterRect.Y(),
              aBorderSizes[eSideRight], aOuterRect.Height());
   }
 
   // If two sides meet at a corner that we're rendering, then
   // make sure that we adjust one of the sides to avoid overlap.
   // This is especially important in the case of colors with
   // an alpha channel.
 
-  if ((aSides & (SIDE_BIT_TOP | SIDE_BIT_LEFT)) == (SIDE_BIT_TOP | SIDE_BIT_LEFT)) {
+  if ((aSides & (eSideBitsTop | eSideBitsLeft)) == (eSideBitsTop | eSideBitsLeft)) {
     // adjust the left's top down a bit
     r[eSideLeft].y += aBorderSizes[eSideTop];
     r[eSideLeft].height -= aBorderSizes[eSideTop];
   }
 
-  if ((aSides & (SIDE_BIT_TOP | SIDE_BIT_RIGHT)) == (SIDE_BIT_TOP | SIDE_BIT_RIGHT)) {
+  if ((aSides & (eSideBitsTop | eSideBitsRight)) == (eSideBitsTop | eSideBitsRight)) {
     // adjust the top's left a bit
     r[eSideTop].width -= aBorderSizes[eSideRight];
   }
 
-  if ((aSides & (SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT)) == (SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT)) {
+  if ((aSides & (eSideBitsBottom | eSideBitsRight)) == (eSideBitsBottom | eSideBitsRight)) {
     // adjust the right's bottom a bit
     r[eSideRight].height -= aBorderSizes[eSideBottom];
   }
 
-  if ((aSides & (SIDE_BIT_BOTTOM | SIDE_BIT_LEFT)) == (SIDE_BIT_BOTTOM | SIDE_BIT_LEFT)) {
+  if ((aSides & (eSideBitsBottom | eSideBitsLeft)) == (eSideBitsBottom | eSideBitsLeft)) {
     // adjust the bottom's left a bit
     r[eSideBottom].x += aBorderSizes[eSideLeft];
     r[eSideBottom].width -= aBorderSizes[eSideLeft];
   }
 
   // Filling these one by one is faster than filling them all at once.
   for (uint32_t i = 0; i < 4; i++) {
     if (aSides & (1 << i)) {
@@ -1306,17 +1306,17 @@ nsCSSBorderRenderer::DrawBorderSidesComp
 
     ComputeInnerRadii(radii, fakeBorderSizes, &radii);
   }
 }
 
 void
 nsCSSBorderRenderer::DrawBorderSides(int aSides)
 {
-  if (aSides == 0 || (aSides & ~SIDE_BITS_ALL) != 0) {
+  if (aSides == 0 || (aSides & ~eSideBitsAll) != 0) {
     NS_WARNING("DrawBorderSides: invalid sides!");
     return;
   }
 
   uint8_t borderRenderStyle = NS_STYLE_BORDER_STYLE_NONE;
   nscolor borderRenderColor;
   const nsBorderColors *compositeColors = nullptr;
 
@@ -1335,37 +1335,37 @@ nsCSSBorderRenderer::DrawBorderSides(int
 
   if (borderRenderStyle == NS_STYLE_BORDER_STYLE_NONE ||
       borderRenderStyle == NS_STYLE_BORDER_STYLE_HIDDEN)
     return;
 
   if (borderRenderStyle == NS_STYLE_BORDER_STYLE_DASHED ||
       borderRenderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
     // Draw each corner separately, with the given side's color.
-    if (aSides & SIDE_BIT_TOP) {
+    if (aSides & eSideBitsTop) {
       DrawDashedOrDottedCorner(eSideTop, C_TL);
-    } else if (aSides & SIDE_BIT_LEFT) {
+    } else if (aSides & eSideBitsLeft) {
       DrawDashedOrDottedCorner(eSideLeft, C_TL);
     }
 
-    if (aSides & SIDE_BIT_TOP) {
+    if (aSides & eSideBitsTop) {
       DrawDashedOrDottedCorner(eSideTop, C_TR);
-    } else if (aSides & SIDE_BIT_RIGHT) {
+    } else if (aSides & eSideBitsRight) {
       DrawDashedOrDottedCorner(eSideRight, C_TR);
     }
 
-    if (aSides & SIDE_BIT_BOTTOM) {
+    if (aSides & eSideBitsBottom) {
       DrawDashedOrDottedCorner(eSideBottom, C_BL);
-    } else if (aSides & SIDE_BIT_LEFT) {
+    } else if (aSides & eSideBitsLeft) {
       DrawDashedOrDottedCorner(eSideLeft, C_BL);
     }
 
-    if (aSides & SIDE_BIT_BOTTOM) {
+    if (aSides & eSideBitsBottom) {
       DrawDashedOrDottedCorner(eSideBottom, C_BR);
-    } else if (aSides & SIDE_BIT_RIGHT) {
+    } else if (aSides & eSideBitsRight) {
       DrawDashedOrDottedCorner(eSideRight, C_BR);
     }
     return;
   }
 
   // -moz-border-colors is a hack; if we have it for a border, then
   // it's always drawn solid, and each color is given 1px.  The last
   // color is used for the remainder of the border's size.  Just
@@ -1459,17 +1459,17 @@ nsCSSBorderRenderer::DrawBorderSides(int
   // borderColorStyleCount < 1 or > 3; this should never happen,
   // since -moz-border-colors doesn't get handled here.
   NS_ASSERTION(borderColorStyleCount > 0 && borderColorStyleCount < 4,
                "Non-border-colors case with borderColorStyleCount < 1 or > 3; what happened?");
 
   // The caller should never give us anything with a mix
   // of TL/BR if the border style would require a
   // TL/BR split.
-  if (aSides & (SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT))
+  if (aSides & (eSideBitsBottom | eSideBitsRight))
     borderColorStyle = borderColorStyleBottomRight;
   else
     borderColorStyle = borderColorStyleTopLeft;
 
   // Distribute the border across the available space.
   Float borderWidths[3][4];
 
   if (borderColorStyleCount == 1) {
@@ -1529,35 +1529,35 @@ nsCSSBorderRenderer::DrawBorderSides(int
   // |     |
   bool noMarginTop = false;
   bool noMarginRight = false;
   bool noMarginBottom = false;
   bool noMarginLeft = false;
 
   // If there is at least one dotted side, every side is rendered separately.
   if (IsSingleSide(aSides)) {
-    if (aSides == SIDE_BIT_TOP) {
+    if (aSides == eSideBitsTop) {
       if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_TR])) {
         noMarginRight = true;
       }
       if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_TL])) {
         noMarginLeft = true;
       }
-    } else if (aSides == SIDE_BIT_RIGHT) {
+    } else if (aSides == eSideBitsRight) {
       if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_TR])) {
         noMarginTop = true;
       }
       if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_BR])) {
         noMarginBottom = true;
       }
-    } else if (aSides == SIDE_BIT_BOTTOM) {
+    } else if (aSides == eSideBitsBottom) {
       if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_BR])) {
         noMarginRight = true;
       }
       if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
           IsZeroSize(mBorderRadii[C_BL])) {
         noMarginLeft = true;
       }
@@ -3127,19 +3127,19 @@ nsCSSBorderRenderer::DrawRectangularComp
 
 void
 nsCSSBorderRenderer::DrawBorders()
 {
   bool forceSeparateCorners = false;
 
   // Examine the border style to figure out if we can draw it in one
   // go or not.
-  bool tlBordersSame = AreBorderSideFinalStylesSame(SIDE_BIT_TOP | SIDE_BIT_LEFT);
-  bool brBordersSame = AreBorderSideFinalStylesSame(SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT);
-  bool allBordersSame = AreBorderSideFinalStylesSame(SIDE_BITS_ALL);
+  bool tlBordersSame = AreBorderSideFinalStylesSame(eSideBitsTop | eSideBitsLeft);
+  bool brBordersSame = AreBorderSideFinalStylesSame(eSideBitsBottom | eSideBitsRight);
+  bool allBordersSame = AreBorderSideFinalStylesSame(eSideBitsAll);
   if (allBordersSame &&
       ((mCompositeColors[0] == nullptr &&
        (mBorderStyles[0] == NS_STYLE_BORDER_STYLE_NONE ||
         mBorderStyles[0] == NS_STYLE_BORDER_STYLE_HIDDEN ||
         mBorderColors[0] == NS_RGBA(0,0,0,0))) ||
        (mCompositeColors[0] &&
         (mCompositeColors[0]->mColor == NS_RGBA(0,0,0,0) &&
          !mCompositeColors[0]->mNext))))
@@ -3334,17 +3334,17 @@ nsCSSBorderRenderer::DrawBorders()
       dashedSides |= (1 << i);
     }
   }
 
   PrintAsFormatString(" allBordersSame: %d dashedSides: 0x%02x\n", allBordersSame, dashedSides);
 
   if (allBordersSame && !forceSeparateCorners) {
     /* Draw everything in one go */
-    DrawBorderSides(SIDE_BITS_ALL);
+    DrawBorderSides(eSideBitsAll);
     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. */
 
     /*
@@ -3442,26 +3442,26 @@ nsCSSBorderRenderer::DrawBorders()
     // 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
     // and expects there to be a clip in place.
     int alreadyDrawnSides = 0;
     if (mOneUnitBorder &&
         mNoBorderRadius &&
-        (dashedSides & (SIDE_BIT_TOP | SIDE_BIT_LEFT)) == 0)
+        (dashedSides & (eSideBitsTop | eSideBitsLeft)) == 0)
     {
       if (tlBordersSame) {
-        DrawBorderSides(SIDE_BIT_TOP | SIDE_BIT_LEFT);
-        alreadyDrawnSides |= (SIDE_BIT_TOP | SIDE_BIT_LEFT);
+        DrawBorderSides(eSideBitsTop | eSideBitsLeft);
+        alreadyDrawnSides |= (eSideBitsTop | eSideBitsLeft);
       }
 
-      if (brBordersSame && (dashedSides & (SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT)) == 0) {
-        DrawBorderSides(SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT);
-        alreadyDrawnSides |= (SIDE_BIT_BOTTOM | SIDE_BIT_RIGHT);
+      if (brBordersSame && (dashedSides & (eSideBitsBottom | eSideBitsRight)) == 0) {
+        DrawBorderSides(eSideBitsBottom | eSideBitsRight);
+        alreadyDrawnSides |= (eSideBitsBottom | eSideBitsRight);
       }
     }
 
     // We're done with the corners, now draw the sides.
     NS_FOR_CSS_SIDES (side) {
       // if we drew it above, skip it
       if (alreadyDrawnSides & (1 << side))
         continue;