Bug 1297982 - Replace NS_STYLE_BOX_DIRECTION_* with enum class; r?xidorn draft
authorRavi Shankar <wafflespeanut@gmail.com>
Fri, 26 Aug 2016 12:47:09 +0530
changeset 405960 b53e1743517341bf063c872af4a5afed4673942e
parent 405959 2cd0c9f87f15069839feb0b90471ff99a6839a0f
child 405961 536f95b6ae72d3196a120ccf7c1507167179deb4
push id27614
push userwafflespeanut@gmail.com
push dateFri, 26 Aug 2016 07:20:49 +0000
reviewersxidorn
bugs1297982
milestone51.0a1
Bug 1297982 - Replace NS_STYLE_BOX_DIRECTION_* with enum class; r?xidorn MozReview-Commit-ID: H6Mr73864O2
layout/generic/nsFlexContainerFrame.cpp
layout/style/nsCSSProps.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/xul/nsBoxFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -3272,17 +3272,17 @@ FlexboxAxisTracker::InitAxesFromLegacyPr
   if (!mWM.IsBidiLTR()) {
     AxisOrientationType& axisToFlip = mIsRowOriented ? mMainAxis : mCrossAxis;
     axisToFlip = GetReverseAxis(axisToFlip);
   }
   // XXXdholbert END CODE TO SET DEPRECATED MEMBER-VARS
 
   // Legacy flexbox can use "-webkit-box-direction: reverse" to reverse the
   // main axis (so it runs in the reverse direction of the inline axis):
-  if (styleXUL->mBoxDirection == NS_STYLE_BOX_DIRECTION_REVERSE) {
+  if (styleXUL->mBoxDirection == StyleBoxDirection::Reverse) {
     mMainAxis = GetReverseAxis(mMainAxis);
     mIsMainAxisReversed = true;
   } else {
     mIsMainAxisReversed = false;
   }
 
   // Legacy flexbox does not support reversing the cross axis -- it has no
   // equivalent of modern flexbox's "flex-wrap: wrap-reverse".
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2246,18 +2246,18 @@ const KTableEntry nsCSSProps::kBoxAlignK
   { eCSSKeyword_start, StyleBoxAlign::Start },
   { eCSSKeyword_center, StyleBoxAlign::Center },
   { eCSSKeyword_baseline, StyleBoxAlign::Baseline },
   { eCSSKeyword_end, StyleBoxAlign::End },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxDirectionKTable[] = {
-  { eCSSKeyword_normal, NS_STYLE_BOX_DIRECTION_NORMAL },
-  { eCSSKeyword_reverse, NS_STYLE_BOX_DIRECTION_REVERSE },
+  { eCSSKeyword_normal, StyleBoxDirection::Normal },
+  { eCSSKeyword_reverse, StyleBoxDirection::Reverse },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxOrientKTable[] = {
   { eCSSKeyword_horizontal, NS_STYLE_BOX_ORIENT_HORIZONTAL },
   { eCSSKeyword_vertical, NS_STYLE_BOX_ORIENT_VERTICAL },
   { eCSSKeyword_inline_axis, NS_STYLE_BOX_ORIENT_HORIZONTAL },
   { eCSSKeyword_block_axis, NS_STYLE_BOX_ORIENT_VERTICAL },
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1331,16 +1331,17 @@ struct SetEnumValueHelper
     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(StyleBoxAlign, Stretch, End)
   DEFINE_ENUM_CLASS_SETTER(StyleBoxDecorationBreak, Slice, Clone)
+  DEFINE_ENUM_CLASS_SETTER(StyleBoxDirection, Normal, Reverse)
   DEFINE_ENUM_CLASS_SETTER(StyleBoxPack, Start, Justify)
   DEFINE_ENUM_CLASS_SETTER(StyleBoxSizing, Content, Border)
   DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
   DEFINE_ENUM_CLASS_SETTER(StyleFloat, None_, InlineEnd)
   DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
   DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None_, SelectMenu)
   DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None_, MozText)
 
@@ -9098,17 +9099,17 @@ nsRuleNode::ComputeXULData(void* aStartS
            parentXUL->mBoxAlign,
            StyleBoxAlign::Stretch);
 
   // box-direction: enum, inherit, initial
   SetValue(*aRuleData->ValueForBoxDirection(),
            xul->mBoxDirection, conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentXUL->mBoxDirection,
-           NS_STYLE_BOX_DIRECTION_NORMAL);
+           StyleBoxDirection::Normal);
 
   // box-flex: factor, inherit
   SetFactor(*aRuleData->ValueForBoxFlex(),
             xul->mBoxFlex, conditions,
             parentXUL->mBoxFlex, 0.0f,
             SETFCT_UNSET_INITIAL);
 
   // box-orient: enum, inherit, initial
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -72,16 +72,22 @@ enum class StyleBoxAlign : uint8_t {
 };
 
 // box-decoration-break
 enum class StyleBoxDecorationBreak : uint8_t {
   Slice,
   Clone,
 };
 
+// box-direction
+enum class StyleBoxDirection : uint8_t {
+  Normal,
+  Reverse,
+};
+
 // box-pack
 enum class StyleBoxPack : uint8_t {
   Start,
   Center,
   End,
   Justify,
 };
 
@@ -186,20 +192,16 @@ enum class StyleUserSelect : uint8_t {
 #define NS_STYLE_USER_MODIFY_READ_WRITE  1
 #define NS_STYLE_USER_MODIFY_WRITE_ONLY  2
 
 // -moz-window-dragging
 #define NS_STYLE_WINDOW_DRAGGING_DEFAULT 0
 #define NS_STYLE_WINDOW_DRAGGING_DRAG    1
 #define NS_STYLE_WINDOW_DRAGGING_NO_DRAG 2
 
-// box-direction
-#define NS_STYLE_BOX_DIRECTION_NORMAL    0
-#define NS_STYLE_BOX_DIRECTION_REVERSE   1
-
 // box-orient
 #define NS_STYLE_BOX_ORIENT_HORIZONTAL 0
 #define NS_STYLE_BOX_ORIENT_VERTICAL   1
 
 // orient
 #define NS_STYLE_ORIENT_INLINE     0
 #define NS_STYLE_ORIENT_BLOCK      1
 #define NS_STYLE_ORIENT_HORIZONTAL 2
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -824,17 +824,17 @@ nsStyleList::sNoneQuotes;
 
 // --------------------
 // nsStyleXUL
 //
 nsStyleXUL::nsStyleXUL(StyleStructContext aContext)
   : mBoxFlex(0.0f)
   , mBoxOrdinal(1)
   , mBoxAlign(StyleBoxAlign::Stretch)
-  , mBoxDirection(NS_STYLE_BOX_DIRECTION_NORMAL)
+  , mBoxDirection(StyleBoxDirection::Normal)
   , mBoxOrient(NS_STYLE_BOX_ORIENT_HORIZONTAL)
   , mBoxPack(StyleBoxPack::Start)
   , mStretchStack(true)
 {
   MOZ_COUNT_CTOR(nsStyleXUL);
 }
 
 nsStyleXUL::~nsStyleXUL()
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3432,17 +3432,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
     return nsChangeHint_NeedReflow |
            nsChangeHint_ReflowChangesSizeOrPosition |
            nsChangeHint_ClearAncestorIntrinsics;
   }
 
   float         mBoxFlex;               // [reset] see nsStyleConsts.h
   uint32_t      mBoxOrdinal;            // [reset] see nsStyleConsts.h
   mozilla::StyleBoxAlign mBoxAlign;         // [reset]
-  uint8_t       mBoxDirection;          // [reset] see nsStyleConsts.h
+  mozilla::StyleBoxDirection mBoxDirection; // [reset]
   uint8_t       mBoxOrient;             // [reset] see nsStyleConsts.h
   mozilla::StyleBoxPack mBoxPack;           // [reset]
   bool          mStretchStack;          // [reset] see nsStyleConsts.h
 };
 
 struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
 {
   explicit nsStyleColumn(StyleStructContext aContext);
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -484,19 +484,20 @@ nsBoxFrame::GetInitialDirection(bool& aI
     // This means that BiDI users will end up with horizontally inverted chrome.
     aIsNormal = (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR); // If text runs RTL then so do we.
   }
   else
     aIsNormal = true; // Assume a normal direction in the vertical case.
 
   // Now check the style system to see if we should invert aIsNormal.
   const nsStyleXUL* boxInfo = StyleXUL();
-  if (boxInfo->mBoxDirection == NS_STYLE_BOX_DIRECTION_REVERSE)
+  if (boxInfo->mBoxDirection == StyleBoxDirection::Reverse) {
     aIsNormal = !aIsNormal; // Invert our direction.
-  
+  }
+
   // Now see if we have an attribute.  The attribute overrides
   // the style system value.
   if (IsXULHorizontal()) {
     static nsIContent::AttrValuesArray strings[] =
       {&nsGkAtoms::reverse, &nsGkAtoms::ltr, &nsGkAtoms::rtl, nullptr};
     int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::dir,
         strings, eCaseMatters);
     if (index >= 0) {