Bug 1325940 part 2 - Converted NS_STYLE_BORDER_IMAGE_REPEAT_* to an enum class. r=xidorn
☠☠ backed out by a26629278490 ☠ ☠
authorGajanan <grhegde09@gmail.com>
Mon, 13 Mar 2017 21:19:19 +1100
changeset 395383 a035c2b6ae72b394debf576a29a97a1274232597
parent 395382 be602e750e399e19e32a6a06ea22ce090495b4b2
child 395384 a266292784906fc4d18640b7e653d606b4825147
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1325940
milestone55.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 1325940 part 2 - Converted NS_STYLE_BORDER_IMAGE_REPEAT_* to an enum class. r=xidorn MozReview-Commit-ID: 4Y30dMHsFgj
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/style/nsCSSDataBlock.cpp
layout/style/nsCSSParser.cpp
layout/style/nsCSSProps.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -4317,17 +4317,17 @@ DrawBorderImage(nsPresContext*       aPr
   // default sizing algorithm) to renderer as the viewport size.
   Maybe<nsSize> svgViewportSize = intrinsicSize.CanComputeConcreteSize() ?
     Nothing() : Some(imageSize);
   bool hasIntrinsicRatio = intrinsicSize.HasRatio();
   renderer.PurgeCacheForViewportChange(svgViewportSize, hasIntrinsicRatio);
 
   for (int i = LEFT; i <= RIGHT; i++) {
     for (int j = TOP; j <= BOTTOM; j++) {
-      uint8_t fillStyleH, fillStyleV;
+      StyleBorderImageRepeat fillStyleH, fillStyleV;
       nsSize unitSize;
 
       if (i == MIDDLE && j == MIDDLE) {
         // Discard the middle portion unless set to fill.
         if (NS_STYLE_BORDER_IMAGE_SLICE_NOFILL ==
             aStyleBorder.mBorderImageFill) {
           continue;
         }
@@ -4373,36 +4373,36 @@ DrawBorderImage(nsPresContext*       aPr
         if (0 < borderHeight[j] && 0 < sliceHeight[j])
           factor = gfxFloat(borderHeight[j])/sliceHeight[j];
         else
           factor = 1;
 
         unitSize.width = sliceWidth[i]*factor;
         unitSize.height = borderHeight[j];
         fillStyleH = aStyleBorder.mBorderImageRepeatH;
-        fillStyleV = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
+        fillStyleV = StyleBorderImageRepeat::Stretch;
 
       } else if (j == MIDDLE) { // left, right
         gfxFloat factor;
         if (0 < borderWidth[i] && 0 < sliceWidth[i])
           factor = gfxFloat(borderWidth[i])/sliceWidth[i];
         else
           factor = 1;
 
         unitSize.width = borderWidth[i];
         unitSize.height = sliceHeight[j]*factor;
-        fillStyleH = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
+        fillStyleH = StyleBorderImageRepeat::Stretch;
         fillStyleV = aStyleBorder.mBorderImageRepeatV;
 
       } else {
         // Corners are always stretched to fit the corner.
         unitSize.width = borderWidth[i];
         unitSize.height = borderHeight[j];
-        fillStyleH = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
-        fillStyleV = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
+        fillStyleH = StyleBorderImageRepeat::Stretch;
+        fillStyleV = StyleBorderImageRepeat::Stretch;
       }
 
       nsRect destArea(borderX[i], borderY[j], borderWidth[i], borderHeight[j]);
       nsRect subArea(sliceX[i], sliceY[j], sliceWidth[i], sliceHeight[j]);
       if (subArea.IsEmpty())
         continue;
 
       nsIntRect intSubArea = subArea.ToOutsidePixels(nsPresContext::AppUnitsPerCSSPixel());
@@ -5965,71 +5965,71 @@ nsImageRenderer::DrawLayer(nsPresContext
  * Compute the size and position of the master copy of the image. I.e., a single
  * tile used to fill the dest rect.
  * aFill The destination rect to be filled
  * aHFill and aVFill are the repeat patterns for the component -
  * NS_STYLE_BORDER_IMAGE_REPEAT_* - i.e., how a tiling unit is used to fill aFill
  * aUnitSize The size of the source rect in dest coords.
  */
 static nsRect
-ComputeTile(nsRect&              aFill,
-            uint8_t              aHFill,
-            uint8_t              aVFill,
-            const nsSize&        aUnitSize,
-            nsSize&              aRepeatSize)
+ComputeTile(nsRect&                 aFill,
+            StyleBorderImageRepeat  aHFill,
+            StyleBorderImageRepeat  aVFill,
+            const nsSize&           aUnitSize,
+            nsSize&                 aRepeatSize)
 {
   nsRect tile;
   switch (aHFill) {
-  case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
+  case StyleBorderImageRepeat::Stretch:
     tile.x = aFill.x;
     tile.width = aFill.width;
     aRepeatSize.width = tile.width;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
+  case StyleBorderImageRepeat::Repeat:
     tile.x = aFill.x + aFill.width/2 - aUnitSize.width/2;
     tile.width = aUnitSize.width;
     aRepeatSize.width = tile.width;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
+  case StyleBorderImageRepeat::Round:
     tile.x = aFill.x;
     tile.width = ComputeRoundedSize(aUnitSize.width, aFill.width);
     aRepeatSize.width = tile.width;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
+  case StyleBorderImageRepeat::Space:
     {
       nscoord space;
       aRepeatSize.width =
         ComputeBorderSpacedRepeatSize(aUnitSize.width, aFill.width, space);
       tile.x = aFill.x + space;
       tile.width = aUnitSize.width;
       aFill.x = tile.x;
       aFill.width = aFill.width - space * 2;
     }
     break;
   default:
     NS_NOTREACHED("unrecognized border-image fill style");
   }
 
   switch (aVFill) {
-  case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
+  case StyleBorderImageRepeat::Stretch:
     tile.y = aFill.y;
     tile.height = aFill.height;
     aRepeatSize.height = tile.height;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
+  case StyleBorderImageRepeat::Repeat:
     tile.y = aFill.y + aFill.height/2 - aUnitSize.height/2;
     tile.height = aUnitSize.height;
     aRepeatSize.height = tile.height;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
+  case StyleBorderImageRepeat::Round:
     tile.y = aFill.y;
     tile.height = ComputeRoundedSize(aUnitSize.height, aFill.height);
     aRepeatSize.height = tile.height;
     break;
-  case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
+  case StyleBorderImageRepeat::Space:
     {
       nscoord space;
       aRepeatSize.height =
         ComputeBorderSpacedRepeatSize(aUnitSize.height, aFill.height, space);
       tile.y = aFill.y + space;
       tile.height = aUnitSize.height;
       aFill.y = tile.y;
       aFill.height = aFill.height - space * 2;
@@ -6043,41 +6043,41 @@ ComputeTile(nsRect&              aFill,
 }
 
 /**
  * Returns true if the given set of arguments will require the tiles which fill
  * the dest rect to be scaled from the source tile. See comment on ComputeTile
  * for argument descriptions.
  */
 static bool
-RequiresScaling(const nsRect&        aFill,
-                uint8_t              aHFill,
-                uint8_t              aVFill,
-                const nsSize&        aUnitSize)
+RequiresScaling(const nsRect&           aFill,
+                StyleBorderImageRepeat  aHFill,
+                StyleBorderImageRepeat  aVFill,
+                const nsSize&           aUnitSize)
 {
   // If we have no tiling in either direction, we can skip the intermediate
   // scaling step.
-  return (aHFill != NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH ||
-          aVFill != NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH) &&
+  return (aHFill != StyleBorderImageRepeat::Stretch ||
+          aVFill != StyleBorderImageRepeat::Stretch) &&
          (aUnitSize.width != aFill.width ||
           aUnitSize.height != aFill.height);
 }
 
 DrawResult
-nsImageRenderer::DrawBorderImageComponent(nsPresContext*       aPresContext,
-                                          nsRenderingContext&  aRenderingContext,
-                                          const nsRect&        aDirtyRect,
-                                          const nsRect&        aFill,
-                                          const CSSIntRect&    aSrc,
-                                          uint8_t              aHFill,
-                                          uint8_t              aVFill,
-                                          const nsSize&        aUnitSize,
-                                          uint8_t              aIndex,
+nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext,
+                                          nsRenderingContext& aRenderingContext,
+                                          const nsRect& aDirtyRect,
+                                          const nsRect& aFill,
+                                          const CSSIntRect& aSrc,
+                                          StyleBorderImageRepeat aHFill,
+                                          StyleBorderImageRepeat aVFill,
+                                          const nsSize& aUnitSize,
+                                          uint8_t aIndex,
                                           const Maybe<nsSize>& aSVGViewportSize,
-                                          const bool           aHasIntrinsicRatio)
+                                          const bool aHasIntrinsicRatio)
 {
   if (!IsReady()) {
     NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
     return DrawResult::BAD_ARGS;
   }
   if (aFill.IsEmpty() || aSrc.IsEmpty()) {
     return DrawResult::SUCCESS;
   }
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -237,27 +237,27 @@ public:
    * aSVGViewportSize The image size evaluated by default sizing algorithm.
    * Pass Nothing() if we can read a valid viewport size or aspect-ratio from
    * the drawing image directly, otherwise, pass Some() with viewport size
    * evaluated from default sizing algorithm.
    * aHasIntrinsicRatio is used to record if the source image has fixed
    * intrinsic ratio.
    */
   DrawResult
-  DrawBorderImageComponent(nsPresContext*       aPresContext,
-                           nsRenderingContext&  aRenderingContext,
-                           const nsRect&        aDirtyRect,
-                           const nsRect&        aFill,
-                           const mozilla::CSSIntRect& aSrc,
-                           uint8_t              aHFill,
-                           uint8_t              aVFill,
-                           const nsSize&        aUnitSize,
-                           uint8_t              aIndex,
-                           const mozilla::Maybe<nsSize>& aSVGViewportSize,
-                           const bool           aHasIntrinsicRatio);
+  DrawBorderImageComponent(nsPresContext*                   aPresContext,
+                           nsRenderingContext&              aRenderingContext,
+                           const nsRect&                    aDirtyRect,
+                           const nsRect&                    aFill,
+                           const mozilla::CSSIntRect&       aSrc,
+                           mozilla::StyleBorderImageRepeat  aHFill,
+                           mozilla::StyleBorderImageRepeat  aVFill,
+                           const nsSize&                    aUnitSize,
+                           uint8_t                          aIndex,
+                           const mozilla::Maybe<nsSize>&    aSVGViewportSize,
+                           const bool                       aHasIntrinsicRatio);
 
   bool IsRasterImage();
   bool IsAnimatedImage();
 
   /// Retrieves the image associated with this nsImageRenderer, if there is one.
   already_AddRefed<imgIContainer> GetImage();
 
   bool IsReady() const { return mPrepareResult == DrawResult::SUCCESS; }
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -450,18 +450,17 @@ nsCSSCompressedDataBlock::HasDefaultBord
   return outset.AllSidesEqualTo(nsCSSValue(0.0f, eCSSUnit_Number));
 }
 
 bool
 nsCSSCompressedDataBlock::HasDefaultBorderImageRepeat() const
 {
   const nsCSSValuePair &repeat =
     ValueFor(eCSSProperty_border_image_repeat)->GetPairValue();
-  return repeat.BothValuesEqualTo(
-    nsCSSValue(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH, eCSSUnit_Enumerated));
+  return repeat.BothValuesEqualTo(nsCSSValue(StyleBorderImageRepeat::Stretch));
 }
 
 /*****************************************************************************/
 
 nsCSSExpandedDataBlock::nsCSSExpandedDataBlock()
 {
   AssertInitialState();
 }
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -13141,18 +13141,17 @@ CSSParserImpl::SetBorderImageInitialValu
   nsCSSValue outset;
   nsCSSRect& outsetBox = outset.SetRectValue();
   outsetBox.SetAllSidesTo(nsCSSValue(0.0f, eCSSUnit_Number));
   AppendValue(eCSSProperty_border_image_outset, outset);
 
   // border-image-repeat: repeat
   nsCSSValue repeat;
   nsCSSValuePair repeatPair;
-  repeatPair.SetBothValuesTo(nsCSSValue(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH,
-                                        eCSSUnit_Enumerated));
+  repeatPair.SetBothValuesTo(nsCSSValue(StyleBorderImageRepeat::Stretch));
   repeat.SetPairValue(&repeatPair);
   AppendValue(eCSSProperty_border_image_repeat, repeat);
 }
 
 bool
 CSSParserImpl::ParseBorderImageSlice(bool aAcceptsInherit,
                                      bool* aConsumedTokens)
 {
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1000,20 +1000,20 @@ const KTableEntry nsCSSProps::kBlendMode
 
 const KTableEntry nsCSSProps::kBorderCollapseKTable[] = {
   { eCSSKeyword_collapse,  NS_STYLE_BORDER_COLLAPSE },
   { eCSSKeyword_separate,  NS_STYLE_BORDER_SEPARATE },
   { eCSSKeyword_UNKNOWN,   -1 }
 };
 
 const KTableEntry nsCSSProps::kBorderImageRepeatKTable[] = {
-  { eCSSKeyword_stretch, NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH },
-  { eCSSKeyword_repeat, NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT },
-  { eCSSKeyword_round, NS_STYLE_BORDER_IMAGE_REPEAT_ROUND },
-  { eCSSKeyword_space, NS_STYLE_BORDER_IMAGE_REPEAT_SPACE },
+  { eCSSKeyword_stretch, StyleBorderImageRepeat::Stretch },
+  { eCSSKeyword_repeat, StyleBorderImageRepeat::Repeat },
+  { eCSSKeyword_round, StyleBorderImageRepeat::Round },
+  { eCSSKeyword_space, StyleBorderImageRepeat::Space },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBorderImageSliceKTable[] = {
   { eCSSKeyword_fill, NS_STYLE_BORDER_IMAGE_SLICE_FILL },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1451,16 +1451,17 @@ struct SetEnumValueHelper
   DEFINE_ENUM_CLASS_SETTER(StyleHyphens, None, Auto)
   DEFINE_ENUM_CLASS_SETTER(StyleTextJustify, None, InterCharacter)
   DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
   DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
   DEFINE_ENUM_CLASS_SETTER(StyleUserInput, None, Auto)
   DEFINE_ENUM_CLASS_SETTER(StyleUserModify, ReadOnly, WriteOnly)
   DEFINE_ENUM_CLASS_SETTER(StyleWindowDragging, Default, NoDrag)
   DEFINE_ENUM_CLASS_SETTER(StyleOrient, Inline, Vertical)
+  DEFINE_ENUM_CLASS_SETTER(StyleBorderImageRepeat, Stretch, Space)
 #ifdef MOZ_XUL
   DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, MozPopup)
 #else
   DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, InlineBox)
 #endif
 
 #undef DEF_SET_ENUMERATED_VALUE
 };
@@ -7878,24 +7879,24 @@ nsRuleNode::ComputeBorderData(void* aSta
   SetBorderImagePair(*aRuleData->ValueForBorderImageRepeat(),
                      borderImageRepeat);
 
   SetValue(borderImageRepeat.mXValue,
            border->mBorderImageRepeatH,
            conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentBorder->mBorderImageRepeatH,
-           NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
+           StyleBorderImageRepeat::Stretch);
 
   SetValue(borderImageRepeat.mYValue,
            border->mBorderImageRepeatV,
            conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentBorder->mBorderImageRepeatV,
-           NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
+           StyleBorderImageRepeat::Stretch);
 
   COMPUTE_END_RESET(Border, border)
 }
 
 const void*
 nsRuleNode::ComputePaddingData(void* aStartStruct,
                                const nsRuleData* aRuleData,
                                nsStyleContext* aContext,
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -384,21 +384,23 @@ enum class FillMode : uint8_t;
 #define NS_STYLE_BORDER_STYLE_DASHED            4
 #define NS_STYLE_BORDER_STYLE_SOLID             5
 #define NS_STYLE_BORDER_STYLE_DOUBLE            6
 #define NS_STYLE_BORDER_STYLE_INSET             7
 #define NS_STYLE_BORDER_STYLE_OUTSET            8
 #define NS_STYLE_BORDER_STYLE_HIDDEN            9
 #define NS_STYLE_BORDER_STYLE_AUTO              10 // for outline-style only
 
-// See nsStyleBorder mBorderImage
-#define NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH    0
-#define NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT     1
-#define NS_STYLE_BORDER_IMAGE_REPEAT_ROUND      2
-#define NS_STYLE_BORDER_IMAGE_REPEAT_SPACE      3
+// border-image-repeat
+enum class StyleBorderImageRepeat : uint8_t {
+  Stretch,
+  Repeat,
+  Round,
+  Space
+};
 
 #define NS_STYLE_BORDER_IMAGE_SLICE_NOFILL      0
 #define NS_STYLE_BORDER_IMAGE_SLICE_FILL        1
 
 // See nsStyleContent
 #define NS_STYLE_CONTENT_OPEN_QUOTE             0
 #define NS_STYLE_CONTENT_CLOSE_QUOTE            1
 #define NS_STYLE_CONTENT_NO_OPEN_QUOTE          2
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -297,18 +297,18 @@ nsStylePadding::CalcDifference(const nsS
   // reflow of the frame's children (see how
   // ReflowInput::InitResizeFlags initializes the inline-resize flag).
   return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
 }
 
 nsStyleBorder::nsStyleBorder(const nsPresContext* aContext)
   : mBorderColors(nullptr)
   , mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL)
-  , mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
-  , mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
+  , mBorderImageRepeatH(StyleBorderImageRepeat::Stretch)
+  , mBorderImageRepeatV(StyleBorderImageRepeat::Stretch)
   , mFloatEdge(StyleFloatEdge::ContentBox)
   , mBoxDecorationBreak(StyleBoxDecorationBreak::Slice)
   , mComputedBorder(0, 0, 0, 0)
 {
   MOZ_COUNT_CTOR(nsStyleBorder);
 
   NS_FOR_CSS_HALF_CORNERS (corner) {
     mBorderRadius.Set(corner, nsStyleCoord(0, nsStyleCoord::CoordConstructor));
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1332,18 +1332,18 @@ public:
   nsBorderColors** mBorderColors;     // [reset] composite (stripe) colors
   nsStyleCorners mBorderRadius;       // [reset] coord, percent
   nsStyleImage   mBorderImageSource;  // [reset]
   nsStyleSides   mBorderImageSlice;   // [reset] factor, percent
   nsStyleSides   mBorderImageWidth;   // [reset] length, factor, percent, auto
   nsStyleSides   mBorderImageOutset;  // [reset] length, factor
 
   uint8_t        mBorderImageFill;    // [reset]
-  uint8_t        mBorderImageRepeatH; // [reset] see nsStyleConsts.h
-  uint8_t        mBorderImageRepeatV; // [reset]
+  mozilla::StyleBorderImageRepeat mBorderImageRepeatH; // [reset]
+  mozilla::StyleBorderImageRepeat mBorderImageRepeatV; // [reset]
   mozilla::StyleFloatEdge mFloatEdge; // [reset]
   mozilla::StyleBoxDecorationBreak mBoxDecorationBreak; // [reset]
 
 protected:
   uint8_t       mBorderStyle[4];  // [reset] See nsStyleConsts.h
 
 public:
   // [reset] the colors to use for a simple border.