Bug 1288383 - Replace NS_STYLE_FLOAT_EDGE_* with an enum class; r=heycam draft
authorManish Goregaokar <manishearth@gmail.com>
Mon, 25 Jul 2016 11:56:05 +0530
changeset 392236 73c3446ba07f31f3fbfb6eca304ebe88cccf359a
parent 392235 8bd51a9bd776c02979093a0ec76cfc42bcee8ffd
child 392237 b893331b173a306143e546f0d403ae25f827fae2
child 392257 96c7c219f0a45c05feb48b1309afe89a3dd884cb
push id23970
push usermanishearth@gmail.com
push dateMon, 25 Jul 2016 06:25:05 +0000
reviewersheycam
bugs1288383
milestone50.0a1
Bug 1288383 - Replace NS_STYLE_FLOAT_EDGE_* with an enum class; r=heycam MozReview-Commit-ID: FrH5kGWeXkL
layout/generic/BlockReflowInput.cpp
layout/style/nsCSSProps.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/generic/BlockReflowInput.cpp
+++ b/layout/generic/BlockReflowInput.cpp
@@ -259,23 +259,23 @@ BlockReflowInput::ComputeBlockAvailSpace
                "unexpected replaced width");
   if (!aBlockAvoidsFloats) {
     if (aFloatAvailableSpace.mHasFloats) {
       // Use the float-edge property to determine how the child block
       // will interact with the float.
       const nsStyleBorder* borderStyle = aFrame->StyleBorder();
       switch (borderStyle->mFloatEdge) {
         default:
-        case NS_STYLE_FLOAT_EDGE_CONTENT_BOX:  // content and only content does runaround of floats
+        case StyleFloatEdge::ContentBox:  // content and only content does runaround of floats
           // The child block will flow around the float. Therefore
           // give it all of the available space.
           aResult.IStart(wm) = mContentArea.IStart(wm);
           aResult.ISize(wm) = mContentArea.ISize(wm);
           break;
-        case NS_STYLE_FLOAT_EDGE_MARGIN_BOX:
+        case StyleFloatEdge::MarginBox:
           {
             // The child block's margins should be placed adjacent to,
             // but not overlap the float.
             aResult.IStart(wm) = aFloatAvailableSpace.mRect.IStart(wm);
             aResult.ISize(wm) = aFloatAvailableSpace.mRect.ISize(wm);
           }
           break;
       }
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1486,18 +1486,18 @@ KTableEntry nsCSSProps::kFloatKTable[] =
   { eCSSKeyword_left,         NS_STYLE_FLOAT_LEFT },
   { eCSSKeyword_right,        NS_STYLE_FLOAT_RIGHT },
   { eCSSKeyword_inline_start, NS_STYLE_FLOAT_INLINE_START },
   { eCSSKeyword_inline_end,   NS_STYLE_FLOAT_INLINE_END },
   { eCSSKeyword_UNKNOWN,      -1 }
 };
 
 const KTableEntry nsCSSProps::kFloatEdgeKTable[] = {
-  { eCSSKeyword_content_box, NS_STYLE_FLOAT_EDGE_CONTENT_BOX },
-  { eCSSKeyword_margin_box, NS_STYLE_FLOAT_EDGE_MARGIN_BOX },
+  { eCSSKeyword_content_box, uint8_t(StyleFloatEdge::ContentBox) },
+  { eCSSKeyword_margin_box, uint8_t(StyleFloatEdge::MarginBox) },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kFontDisplayKTable[] = {
   { eCSSKeyword_auto, NS_FONT_DISPLAY_AUTO },
   { eCSSKeyword_block, NS_FONT_DISPLAY_BLOCK },
   { eCSSKeyword_swap, NS_FONT_DISPLAY_SWAP },
   { eCSSKeyword_fallback, NS_FONT_DISPLAY_FALLBACK },
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4399,17 +4399,17 @@ nsComputedDOMStyle::DoGetJustifySelf()
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetFloatEdge()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(
-    nsCSSProps::ValueToKeywordEnum(StyleBorder()->mFloatEdge,
+    nsCSSProps::ValueToKeywordEnum(uint8_t(StyleBorder()->mFloatEdge),
                                    nsCSSProps::kFloatEdgeKTable));
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetForceBrokenImageIcon()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1296,16 +1296,17 @@ struct SetEnumValueHelper
     auto value = aValue.GetIntValue(); \
     MOZ_ASSERT(value >= static_cast<decltype(value)>(type_::min_) && \
                value <= static_cast<decltype(value)>(type_::max_), \
                "inappropriate value"); \
     aField = static_cast<type_>(value); \
   }
 
   DEFINE_ENUM_CLASS_SETTER(StyleBoxSizing, Content, Border)
+  DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
 
 #undef DEF_SET_ENUMERATED_VALUE
 };
 
 template<typename FieldT>
 struct SetIntegerValueHelper
 {
   static void SetIntegerValue(FieldT& aField, const nsCSSValue& aValue)
@@ -7573,17 +7574,17 @@ nsRuleNode::ComputeBorderData(void* aSta
     }
   }
 
   // float-edge: enum, inherit, initial
   SetValue(*aRuleData->ValueForFloatEdge(),
            border->mFloatEdge, conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentBorder->mFloatEdge,
-           NS_STYLE_FLOAT_EDGE_CONTENT_BOX);
+           StyleFloatEdge::ContentBox);
 
   // border-image-source
   const nsCSSValue* borderImageSource = aRuleData->ValueForBorderImageSource();
   if (borderImageSource->GetUnit() == eCSSUnit_Inherit) {
     conditions.SetUncacheable();
     border->mBorderImageSource = parentBorder->mBorderImageSource;
   } else {
     SetStyleImage(aContext,
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -90,18 +90,20 @@ enum class StyleClipShapeSizing : uint8_
   Border,
   Margin,
   Fill,
   Stroke,
   View,
 };
 
 // float-edge
-#define NS_STYLE_FLOAT_EDGE_CONTENT_BOX    0
-#define NS_STYLE_FLOAT_EDGE_MARGIN_BOX     1
+enum class StyleFloatEdge : uint8_t {
+  ContentBox,
+  MarginBox,
+};
 
 // user-focus
 #define NS_STYLE_USER_FOCUS_NONE            0
 #define NS_STYLE_USER_FOCUS_IGNORE          1
 #define NS_STYLE_USER_FOCUS_NORMAL          2
 #define NS_STYLE_USER_FOCUS_SELECT_ALL      3
 #define NS_STYLE_USER_FOCUS_SELECT_BEFORE   4
 #define NS_STYLE_USER_FOCUS_SELECT_AFTER    5
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -327,17 +327,17 @@ nsStylePadding::CalcDifference(const nsS
   return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
 }
 
 nsStyleBorder::nsStyleBorder(StyleStructContext aContext)
   : mBorderColors(nullptr)
   , mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL)
   , mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
   , mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
-  , mFloatEdge(NS_STYLE_FLOAT_EDGE_CONTENT_BOX)
+  , mFloatEdge(StyleFloatEdge::ContentBox)
   , mBoxDecorationBreak(NS_STYLE_BOX_DECORATION_BREAK_SLICE)
   , mComputedBorder(0, 0, 0, 0)
 {
   MOZ_COUNT_CTOR(nsStyleBorder);
 
   NS_FOR_CSS_HALF_CORNERS (corner) {
     mBorderRadius.Set(corner, nsStyleCoord(0, nsStyleCoord::CoordConstructor));
   }
@@ -2850,27 +2850,27 @@ StyleTransition::SetUnknownProperty(nsCS
   MOZ_ASSERT(aProperty == eCSSProperty_UNKNOWN ||
              aProperty == eCSSPropertyExtra_variable,
              "should be either unknown or custom property");
   mProperty = aProperty;
   mUnknownProperty = NS_Atomize(aPropertyString);
 }
 
 bool
-StyleTransition::operator==(const mozilla::StyleTransition& aOther) const
+StyleTransition::operator==(const StyleTransition& aOther) const
 {
   return mTimingFunction == aOther.mTimingFunction &&
          mDuration == aOther.mDuration &&
          mDelay == aOther.mDelay &&
          mProperty == aOther.mProperty &&
          (mProperty != eCSSProperty_UNKNOWN ||
           mUnknownProperty == aOther.mUnknownProperty);
 }
 
-StyleAnimation::StyleAnimation(const mozilla::StyleAnimation& aCopy)
+StyleAnimation::StyleAnimation(const StyleAnimation& aCopy)
   : mTimingFunction(aCopy.mTimingFunction)
   , mDuration(aCopy.mDuration)
   , mDelay(aCopy.mDelay)
   , mName(aCopy.mName)
   , mDirection(aCopy.mDirection)
   , mFillMode(aCopy.mFillMode)
   , mPlayState(aCopy.mPlayState)
   , mIterationCount(aCopy.mIterationCount)
@@ -2886,17 +2886,17 @@ StyleAnimation::SetInitialValues()
   mName = EmptyString();
   mDirection = dom::PlaybackDirection::Normal;
   mFillMode = dom::FillMode::None;
   mPlayState = NS_STYLE_ANIMATION_PLAY_STATE_RUNNING;
   mIterationCount = 1.0f;
 }
 
 bool
-StyleAnimation::operator==(const mozilla::StyleAnimation& aOther) const
+StyleAnimation::operator==(const StyleAnimation& aOther) const
 {
   return mTimingFunction == aOther.mTimingFunction &&
          mDuration == aOther.mDuration &&
          mDelay == aOther.mDelay &&
          mName == aOther.mName &&
          mDirection == aOther.mDirection &&
          mFillMode == aOther.mFillMode &&
          mPlayState == aOther.mPlayState &&
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1255,27 +1255,27 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   {
     if (mBorderImageSource.GetType() == eStyleImageType_Image) {
       return mBorderImageSource.GetImageData();
     }
     return nullptr;
   }
 
 public:
-  nsBorderColors** mBorderColors;        // [reset] composite (stripe) colors
+  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]
-  uint8_t        mFloatEdge;          // [reset]
+  mozilla::StyleFloatEdge mFloatEdge; // [reset]
   uint8_t        mBoxDecorationBreak; // [reset] see nsStyleConsts.h
 
 protected:
   // mComputedBorder holds the CSS2.1 computed border-width values.
   // In particular, these widths take into account the border-style
   // for the relevant side, and the values are rounded to the nearest
   // device pixel (which is not part of the definition of computed
   // values). The presence or absence of a border-image does not