Bug 1320014 Part 3 - Move Corner from namespace mozilla::css into mozilla. draft
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 04 Jan 2017 17:18:49 +0800
changeset 456792 f7f3d14892fde60e9f1e03d4df7590f7edf085fb
parent 456791 61868358194eadaac00480e07ec97b7dfb506d05
child 456793 592e4eda357b7c524dbd8463395bd0a268c220df
push id40602
push userbmo:tlin@mozilla.com
push dateFri, 06 Jan 2017 07:30:30 +0000
bugs1320014
milestone53.0a1
Bug 1320014 Part 3 - Move Corner from namespace mozilla::css into mozilla. For those cpp files, it's sufficient to use Corner to refer to mozilla::Corner. MozReview-Commit-ID: JmDEJ3gGm8K
gfx/2d/BezierUtils.cpp
gfx/2d/BezierUtils.h
gfx/2d/Types.h
gfx/thebes/gfxRect.h
layout/painting/DottedCornerFinder.cpp
layout/painting/DottedCornerFinder.h
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsCSSRenderingBorders.h
--- a/gfx/2d/BezierUtils.cpp
+++ b/gfx/2d/BezierUtils.cpp
@@ -237,17 +237,17 @@ FindBezierNearestPoint(const Bezier& aBe
   if (aT) {
     *aT = t;
   }
 
   return P;
 }
 
 void
-GetBezierPointsForCorner(Bezier* aBezier, mozilla::css::Corner aCorner,
+GetBezierPointsForCorner(Bezier* aBezier, Corner aCorner,
                          const Point& aCornerPoint, const Size& aCornerSize)
 {
   // Calculate bezier control points for elliptic arc.
 
   const Float signsList[4][2] = {
     { +1.0f, +1.0f },
     { -1.0f, +1.0f },
     { -1.0f, -1.0f },
--- a/gfx/2d/BezierUtils.h
+++ b/gfx/2d/BezierUtils.h
@@ -122,17 +122,17 @@ Point FindBezierNearestPoint(const Bezie
 //                    |            | |
 //                    |            ||
 //                    |            ||
 //                    |            |
 //                    |            |
 //                    |            |
 //                    v mPoints[0] |
 //                    -------------+
-void GetBezierPointsForCorner(Bezier* aBezier, mozilla::css::Corner aCorner,
+void GetBezierPointsForCorner(Bezier* aBezier, mozilla::Corner aCorner,
                               const Point& aCornerPoint,
                               const Size& aCornerSize);
 
 // Calculate the approximate length of a quarter elliptic arc formed by radii
 // (a, b).
 //
 //                a
 //      |<----------------->|
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -411,40 +411,38 @@ enum SideBits {
 
 static inline Side& operator++(Side& side) {
   MOZ_ASSERT(side >= eSideTop && side <= eSideLeft,
              "Out of range side");
   side = Side(side + 1);
   return side;
 }
 
-namespace css {
 enum Corner {
   // This order is important!
   eCornerTopLeft = 0,
   eCornerTopRight = 1,
   eCornerBottomRight = 2,
   eCornerBottomLeft = 3,
   eNumCorners = 4
 };
-} // namespace css
 
-#define NS_CORNER_TOP_LEFT mozilla::css::eCornerTopLeft
-#define NS_CORNER_TOP_RIGHT mozilla::css::eCornerTopRight
-#define NS_CORNER_BOTTOM_RIGHT mozilla::css::eCornerBottomRight
-#define NS_CORNER_BOTTOM_LEFT mozilla::css::eCornerBottomLeft
-#define NS_NUM_CORNERS mozilla::css::eNumCorners
+#define NS_CORNER_TOP_LEFT mozilla::eCornerTopLeft
+#define NS_CORNER_TOP_RIGHT mozilla::eCornerTopRight
+#define NS_CORNER_BOTTOM_RIGHT mozilla::eCornerBottomRight
+#define NS_CORNER_BOTTOM_LEFT mozilla::eCornerBottomLeft
+#define NS_NUM_CORNERS mozilla::eNumCorners
 
 #define NS_FOR_CSS_CORNERS(var_)                       \
-  for (mozilla::css::Corner var_ = NS_CORNER_TOP_LEFT; \
+  for (mozilla::Corner var_ = NS_CORNER_TOP_LEFT;      \
        var_ <= NS_CORNER_BOTTOM_LEFT;                  \
        var_++)
 
-static inline mozilla::css::Corner operator++(mozilla::css::Corner& corner, int) {
+static inline Corner operator++(Corner& corner, int) {
   MOZ_ASSERT(corner >= NS_CORNER_TOP_LEFT &&
              corner < NS_NUM_CORNERS, "Out of range corner");
-  corner = mozilla::css::Corner(corner + 1);
+  corner = Corner(corner + 1);
   return corner;
 }
 
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_TYPES_H_ */
--- a/gfx/thebes/gfxRect.h
+++ b/gfx/thebes/gfxRect.h
@@ -40,17 +40,17 @@ struct gfxRect :
     /**
      * Return true if all components of this rect are within
      * aEpsilon of integer coordinates, defined as
      *   |round(coord) - coord| <= |aEpsilon|
      * for x,y,width,height.
      */
     bool WithinEpsilonOfIntegerPixels(gfxFloat aEpsilon) const;
 
-    gfxPoint AtCorner(mozilla::css::Corner corner) const {
+    gfxPoint AtCorner(mozilla::Corner corner) const {
         switch (corner) {
             case NS_CORNER_TOP_LEFT: return TopLeft();
             case NS_CORNER_TOP_RIGHT: return TopRight();
             case NS_CORNER_BOTTOM_RIGHT: return BottomRight();
             case NS_CORNER_BOTTOM_LEFT: return BottomLeft();
             default:
                 NS_ERROR("Invalid corner!");
                 break;
--- a/layout/painting/DottedCornerFinder.cpp
+++ b/layout/painting/DottedCornerFinder.cpp
@@ -40,17 +40,17 @@ struct BestOverlap
   {}
 };
 
 static const size_t DottedCornerCacheSize = 256;
 nsDataHashtable<FourFloatsHashKey, BestOverlap> DottedCornerCache;
 
 DottedCornerFinder::DottedCornerFinder(const Bezier& aOuterBezier,
                                        const Bezier& aInnerBezier,
-                                       mozilla::css::Corner aCorner,
+                                       Corner aCorner,
                                        Float aBorderRadiusX,
                                        Float aBorderRadiusY,
                                        const Point& aC0, Float aR0,
                                        const Point& aCn, Float aRn,
                                        const Size& aCornerDim)
  : mOuterBezier(aOuterBezier),
    mInnerBezier(aInnerBezier),
    mCorner(aCorner),
--- a/layout/painting/DottedCornerFinder.h
+++ b/layout/painting/DottedCornerFinder.h
@@ -111,17 +111,17 @@ public:
   //                   |                  |                   |
   //                   |                  |                   |
   //                   v                  |        aCn        |
   //                   -------------------+---------+---------+
   //                                      |         |
   //                                      |<------->|
   //                                          aRn
   DottedCornerFinder(const Bezier& aOuterBezier, const Bezier& aInnerBezier,
-                     mozilla::css::Corner aCorner,
+                     mozilla::Corner aCorner,
                      Float aBorderRadiusX, Float aBorderRadiusY,
                      const Point& aC0, Float aR0, const Point& aCn, Float aRn,
                      const Size& aCornerDim);
 
   bool HasMore(void) const;
   Result Next(void);
 
 private:
@@ -145,17 +145,17 @@ private:
   // |    |    |
   // |    |    |
   // |    |    |
   // +----+----+
   Bezier mOuterBezier;
   Bezier mInnerBezier;
   Bezier mCenterBezier;
 
-  mozilla::css::Corner mCorner;
+  mozilla::Corner mCorner;
 
   // Sign of the normal vector used in radius calculation, flipped depends on
   // corner and start and end radii.
   Float mNormalSign;
 
   // Center points and raii for start and end circles, mR0 >= mRn.
   // mMaxR = max(mR0, mRn)
   //
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -63,18 +63,18 @@ static void ComputeBorderCornerDimension
                                           const RectCornerRadii& aRadii,
                                           RectCornerRadii *aDimsResult);
 
 // given a side index, get the previous and next side index
 #define NEXT_SIDE(_s) mozilla::Side(((_s) + 1) & 3)
 #define PREV_SIDE(_s) mozilla::Side(((_s) + 3) & 3)
 
 // given a corner index, get the previous and next corner index
-#define NEXT_CORNER(_s) mozilla::css::Corner(((_s) + 1) & 3)
-#define PREV_CORNER(_s) mozilla::css::Corner(((_s) + 3) & 3)
+#define NEXT_CORNER(_s) Corner(((_s) + 1) & 3)
+#define PREV_CORNER(_s) Corner(((_s) + 3) & 3)
 
 // from the given base color and the background color, turn
 // color into a color for the given border pattern style
 static Color MakeBorderColor(nscolor aColor,
                              nscolor aBackgroundColor,
                              BorderColorStyle aBorderColorStyle);
 
 
@@ -110,37 +110,37 @@ IsZeroSize(const Size& sz) {
 nsCSSBorderRenderer::AllCornersZeroSize(const RectCornerRadii& corners) {
   return IsZeroSize(corners[NS_CORNER_TOP_LEFT]) &&
     IsZeroSize(corners[NS_CORNER_TOP_RIGHT]) &&
     IsZeroSize(corners[NS_CORNER_BOTTOM_RIGHT]) &&
     IsZeroSize(corners[NS_CORNER_BOTTOM_LEFT]);
 }
 
 static mozilla::Side
-GetHorizontalSide(mozilla::css::Corner aCorner)
+GetHorizontalSide(Corner aCorner)
 {
   return (aCorner == C_TL || aCorner == C_TR) ? eSideTop : eSideBottom;
 }
 
 static mozilla::Side
-GetVerticalSide(mozilla::css::Corner aCorner)
+GetVerticalSide(Corner aCorner)
 {
   return (aCorner == C_TL || aCorner == C_BL) ? eSideLeft : eSideRight;
 }
 
-static mozilla::css::Corner
+static Corner
 GetCWCorner(mozilla::Side aSide)
 {
-  return mozilla::css::Corner(NEXT_SIDE(aSide));
+  return Corner(NEXT_SIDE(aSide));
 }
 
-static mozilla::css::Corner
+static Corner
 GetCCWCorner(mozilla::Side aSide)
 {
-  return mozilla::css::Corner(aSide);
+  return Corner(aSide);
 }
 
 static bool
 IsSingleSide(int aSides)
 {
   return aSides == eSideBitsTop || aSides == eSideBitsRight ||
          aSides == eSideBitsBottom || aSides == eSideBitsLeft;
 }
@@ -329,17 +329,17 @@ nsCSSBorderRenderer::AreBorderSideFinalS
       return ((aSides & ~(eSideBitsTop | eSideBitsLeft)) == 0 ||
               (aSides & ~(eSideBitsBottom | eSideBitsRight)) == 0);
   }
 
   return true;
 }
 
 bool
-nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, mozilla::css::Corner aCorner)
+nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, Corner aCorner)
 {
   switch (aStyle) {
     case NS_STYLE_BORDER_STYLE_SOLID:
       return true;
 
     case NS_STYLE_BORDER_STYLE_INSET:
     case NS_STYLE_BORDER_STYLE_OUTSET:
       return (aCorner == NS_CORNER_TOP_LEFT || aCorner == NS_CORNER_BOTTOM_RIGHT);
@@ -352,17 +352,17 @@ nsCSSBorderRenderer::IsSolidCornerStyle(
       return mOneUnitBorder;
 
     default:
       return false;
   }
 }
 
 bool
-nsCSSBorderRenderer::IsCornerMergeable(mozilla::css::Corner aCorner)
+nsCSSBorderRenderer::IsCornerMergeable(Corner aCorner)
 {
   // Corner between dotted borders with same width and small radii is
   // merged into single dot.
   //
   //  widthH / 2.0
   // |<---------->|
   // |            |
   // |radius.width|
@@ -402,17 +402,17 @@ nsCSSBorderRenderer::IsCornerMergeable(m
   }
 
   Size radius = mBorderRadii[aCorner];
   return IsZeroSize(radius) ||
          (radius.width < widthH / 2.0f && radius.height < widthH / 2.0f);
 }
 
 BorderColorStyle
-nsCSSBorderRenderer::BorderColorStyleForSolidCorner(uint8_t aStyle, mozilla::css::Corner aCorner)
+nsCSSBorderRenderer::BorderColorStyleForSolidCorner(uint8_t aStyle, Corner aCorner)
 {
   // note that this function assumes that the corner is already solid,
   // as per the earlier function
   switch (aStyle) {
     case NS_STYLE_BORDER_STYLE_SOLID:
     case NS_STYLE_BORDER_STYLE_DOUBLE:
       return BorderColorStyleSolid;
 
@@ -432,17 +432,17 @@ nsCSSBorderRenderer::BorderColorStyleFor
         return BorderColorStyleDark;
       break;
   }
 
   return BorderColorStyleNone;
 }
 
 Rect
-nsCSSBorderRenderer::GetCornerRect(mozilla::css::Corner aCorner)
+nsCSSBorderRenderer::GetCornerRect(Corner aCorner)
 {
   Point offset(0.f, 0.f);
 
   if (aCorner == C_TR || aCorner == C_BR)
     offset.x = mOuterRect.Width() - mBorderCornerDimensions[aCorner].width;
   if (aCorner == C_BR || aCorner == C_BL)
     offset.y = mOuterRect.Height() - mBorderCornerDimensions[aCorner].height;
 
@@ -671,17 +671,17 @@ nsCSSBorderRenderer::GetSideClipSubPath(
   builder->LineTo(end[1]);
   builder->LineTo(start[1]);
   builder->Close();
   return builder->Finish();
 }
 
 Point
 nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
-                                            mozilla::css::Corner aCorner,
+                                            Corner aCorner,
                                             bool* aIsUnfilled)
 {
   // Calculate the end point of the side for dashed/dotted border, that is also
   // the end point of the corner curve.  The point is specified by aSide and
   // aCorner. (e.g. eSideTop and C_TL means the left end of border-top)
   //
   //
   //  aCorner        aSide
@@ -1056,17 +1056,17 @@ nsCSSBorderRenderer::GetStraightBorderPo
   }
 
   return P;
 }
 
 void
 nsCSSBorderRenderer::GetOuterAndInnerBezier(Bezier* aOuterBezier,
                                             Bezier* aInnerBezier,
-                                            mozilla::css::Corner aCorner)
+                                            Corner aCorner)
 {
   // Return bezier control points for outer and inner curve for given corner.
   //
   //               ___---+ outer curve
   //           __--      |
   //         _-          |
   //       /             |
   //     /               |
@@ -2255,17 +2255,17 @@ nsCSSBorderRenderer::DrawDottedSideSlow(
 
   if (mergeStart == MERGE_HALF || mergeEnd == MERGE_HALF) {
     mDrawTarget->PopClip();
   }
 }
 
 void
 nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide,
-                                              mozilla::css::Corner aCorner)
+                                              Corner aCorner)
 {
   // Draw dashed/dotted corner with following approach.
   //
   // dashed corner
   //   If both side has same border-width and border-width <= 2.0, draw dashed
   //   line along the corner, with appropriate dash length and gap to make the
   //   corner symmetric as far as possible.  Dash length equals to the gap, and
   //   the ratio of the dash length to border-width is the maximum value in in
@@ -2361,17 +2361,17 @@ nsCSSBorderRenderer::DrawDashedOrDottedC
   builder->BezierTo(points[1], points[2], points[3]);
   RefPtr<Path> path = builder->Finish();
   mDrawTarget->Stroke(path, ColorPattern(ToDeviceColor(borderColor)),
                       strokeOptions);
 }
 
 void
 nsCSSBorderRenderer::DrawDottedCornerSlow(mozilla::Side aSide,
-                                          mozilla::css::Corner aCorner)
+                                          Corner aCorner)
 {
   NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
                "Style should be dotted.");
 
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
   Float R0 = mBorderWidths[sideH] / 2.0f;
   Float Rn = mBorderWidths[sideV] / 2.0f;
@@ -2438,17 +2438,17 @@ DashedPathOverlapsRect(Rect& pathRect,
   pathRect.ExpandToEnclose(result.innerSectionBezier.mPoints[2]);
   pathRect.ExpandToEnclose(result.innerSectionBezier.mPoints[3]);
 
   return pathRect.Intersects(marginedDirtyRect);
 }
 
 void
 nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::Side aSide,
-                                          mozilla::css::Corner aCorner)
+                                          Corner aCorner)
 {
   NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED,
                "Style should be dashed.");
 
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
   Float borderWidthH = mBorderWidths[sideH];
   Float borderWidthV = mBorderWidths[sideV];
@@ -2554,17 +2554,17 @@ nsCSSBorderRenderer::DrawDashedCornerSlo
   }
 
   RefPtr<Path> path = builder->Finish();
   mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor)));
 }
 
 void
 nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide,
-                                             mozilla::css::Corner aCorner)
+                                             Corner aCorner)
 {
   // Render too large dashed or dotted corner with solid style, to avoid hangup
   // inside DashedCornerFinder and DottedCornerFinder.
 
   NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
                mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
                "Style should be dashed or dotted.");
 
@@ -2783,17 +2783,17 @@ ComputeCornerSkirtSize(Float aAlpha1, Fl
   }
 }
 
 // Draws a border radius with possibly different sides.
 // A skirt is drawn underneath the corner intersection to hide possible
 // seams when anti-aliased drawing is used.
 static void
 DrawBorderRadius(DrawTarget* aDrawTarget,
-                 mozilla::css::Corner c,
+                 Corner c,
                  const Point& aOuterCorner, const Point& aInnerCorner,
                  const twoFloats& aCornerMultPrev, const twoFloats& aCornerMultNext,
                  const Size& aCornerDims,
                  const Size& aOuterRadius, const Size& aInnerRadius,
                  const Color& aFirstColor, const Color& aSecondColor,
                  Float aSkirtSize, Float aSkirtSlope)
 {
   // Connect edge to outer arc start point
@@ -2990,18 +2990,18 @@ nsCSSBorderRenderer::DrawNoCompositeColo
     // The CCW corner of this side was already drawn in the previous iteration.
     // The side will be drawn as an explicit stroke, and the CW corner will be
     // filled separately.
     // If the next side does not have a matching color, then we split the
     // corner into two halves, one of each side's color and draw both.
     // Thus, the CCW corner of the next side will end up drawn here.
 
     // the corner index -- either 1 2 3 0 (cw) or 0 3 2 1 (ccw)
-    mozilla::css::Corner c = mozilla::css::Corner((i+1) % 4);
-    mozilla::css::Corner prevCorner = mozilla::css::Corner(i);
+    Corner c = Corner((i+1) % 4);
+    Corner prevCorner = Corner(i);
 
     // i+2 and i+3 respectively.  These are used to index into the corner
     // multiplier table, and were deduced by calculating out the long form
     // of each corner and finding a pattern in the signs and values.
     int i1 = (i+1) % 4;
     int i2 = (i+2) % 4;
     int i3 = (i+3) % 4;
 
--- a/layout/painting/nsCSSRenderingBorders.h
+++ b/layout/painting/nsCSSRenderingBorders.h
@@ -144,53 +144,53 @@ private:
   bool mNoBorderRadius;
   bool mAvoidStroke;
 
   // For all the sides in the bitmask, would they be rendered
   // in an identical color and style?
   bool AreBorderSideFinalStylesSame(uint8_t aSides);
 
   // For the given style, is the given corner a solid color?
-  bool IsSolidCornerStyle(uint8_t aStyle, mozilla::css::Corner aCorner);
+  bool IsSolidCornerStyle(uint8_t aStyle, mozilla::Corner aCorner);
 
   // For the given corner, is the given corner mergeable into one dot?
-  bool IsCornerMergeable(mozilla::css::Corner aCorner);
+  bool IsCornerMergeable(mozilla::Corner aCorner);
 
   // For the given solid corner, what color style should be used?
-  BorderColorStyle BorderColorStyleForSolidCorner(uint8_t aStyle, mozilla::css::Corner aCorner);
+  BorderColorStyle BorderColorStyleForSolidCorner(uint8_t aStyle, mozilla::Corner aCorner);
 
   //
   // Path generation functions
   //
 
   // Get the Rect for drawing the given corner
-  Rect GetCornerRect(mozilla::css::Corner aCorner);
+  Rect GetCornerRect(mozilla::Corner aCorner);
   // add the path for drawing the given side without any adjacent corners to the context
   Rect GetSideClipWithoutCornersRect(mozilla::Side aSide);
 
   // Create a clip path for the wedge that this side of
   // the border should take up.  This is only called
   // when we're drawing separate border sides, so we know
   // that ADD compositing is taking place.
   //
   // This code needs to make sure that the individual pieces
   // don't ever (mathematically) overlap; the pixel overlap
   // is taken care of by the ADD compositing.
   already_AddRefed<Path> GetSideClipSubPath(mozilla::Side aSide);
 
   // Return start or end point for dashed/dotted side
   Point GetStraightBorderPoint(mozilla::Side aSide,
-                               mozilla::css::Corner aCorner,
+                               mozilla::Corner aCorner,
                                bool* aIsUnfilled);
 
   // Return bezier control points for the outer and the inner curve for given
   // corner
   void GetOuterAndInnerBezier(Bezier* aOuterBezier,
                               Bezier* aInnerBezier,
-                              mozilla::css::Corner aCorner);
+                              mozilla::Corner aCorner);
 
   // Given a set of sides to fill and a color, do so in the fastest way.
   //
   // Stroke tends to be faster for smaller borders because it doesn't go
   // through the tessellator, which has initialization overhead.  If
   // we're rendering all sides, we can use stroke at any thickness; we
   // also do TL/BR pairs at 1px thickness using stroke.
   //
@@ -225,29 +225,29 @@ private:
   // Draw the given dashed/dotte side
   void DrawDashedOrDottedSide(mozilla::Side aSide);
 
   // Draw the given dotted side, each dot separately
   void DrawDottedSideSlow(mozilla::Side aSide);
 
   // Draw the given dashed/dotted corner
   void DrawDashedOrDottedCorner(mozilla::Side aSide,
-                                mozilla::css::Corner aCorner);
+                                mozilla::Corner aCorner);
 
   // Draw the given dotted corner, each segment separately
   void DrawDottedCornerSlow(mozilla::Side aSide,
-                            mozilla::css::Corner aCorner);
+                            mozilla::Corner aCorner);
 
   // Draw the given dashed corner, each dot separately
   void DrawDashedCornerSlow(mozilla::Side aSide,
-                            mozilla::css::Corner aCorner);
+                            mozilla::Corner aCorner);
 
   // Draw the given dashed/dotted corner with solid style
   void DrawFallbackSolidCorner(mozilla::Side aSide,
-                               mozilla::css::Corner aCorner);
+                               mozilla::Corner aCorner);
 
   // 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
   // with no color effect.
   bool AllBordersSolid(bool *aHasCompositeColors);