From be6805c7922e7c9a692032837bda4bb3d3ae13a3 Mon Sep 17 00:00:00 2001 From: Savo Date: Fri, 4 Oct 2019 12:34:28 +0200 Subject: [PATCH] Bug 1586068 - Replace #define NS_STYLE_FLEX_WRAP with enum class. r=emilio MANUAL PUSH: Rebasing contributor patch. Differential Revision: https://phabricator.services.mozilla.com/D48166 --- layout/generic/nsFlexContainerFrame.cpp | 12 ++++++------ layout/style/ServoBindings.toml | 1 + layout/style/nsStyleConsts.h | 8 +++++--- layout/style/nsStyleStruct.cpp | 2 +- layout/style/nsStyleStruct.h | 2 +- .../style/properties/longhands/position.mako.rs | 1 + 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 9ccbdb3980e1..eca58a434936 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1220,7 +1220,7 @@ uint16_t nsFlexContainerFrame::CSSAlignmentForAbsPosChild( const uint8_t alignContent = SimplifyAlignOrJustifyContentForOneItem( containerStylePos->mAlignContent, /*aIsAlign = */ true); - if (NS_STYLE_FLEX_WRAP_NOWRAP != containerStylePos->mFlexWrap && + if (StyleFlexWrap::Nowrap != containerStylePos->mFlexWrap && alignContent != NS_STYLE_ALIGN_STRETCH) { // Multi-line, align-content isn't stretch --> align-content determines // this child's alignment in the cross axis. @@ -1600,7 +1600,7 @@ void nsFlexContainerFrame::ResolveAutoFlexBasisAndMinSize( const ReflowInput* flexContainerRI = aItemReflowInput.mParentReflowInput; MOZ_ASSERT(flexContainerRI, "flex item's reflow input should have ptr to container's state"); - if (NS_STYLE_FLEX_WRAP_NOWRAP == flexContainerRI->mStylePosition->mFlexWrap) { + if (StyleFlexWrap::Nowrap == flexContainerRI->mStylePosition->mFlexWrap) { // XXXdholbert Maybe this should share logic with ComputeCrossSize()... // Alternately, maybe tentative container cross size should be passed down. nscoord containerCrossSize = GET_CROSS_COMPONENT_LOGICAL( @@ -3150,7 +3150,7 @@ CrossAxisPositionTracker::CrossAxisPositionTracker( } const bool isSingleLine = - NS_STYLE_FLEX_WRAP_NOWRAP == aReflowInput.mStylePosition->mFlexWrap; + StyleFlexWrap::Nowrap == aReflowInput.mStylePosition->mFlexWrap; if (isSingleLine) { MOZ_ASSERT(!aFirstLine->getNext(), "If we're styled as single-line, we should only have 1 line"); @@ -3782,7 +3782,7 @@ void FlexboxAxisTracker::InitAxesFromModernProps( } // "flex-wrap: wrap-reverse" reverses our cross axis. - if (stylePos->mFlexWrap == NS_STYLE_FLEX_WRAP_WRAP_REVERSE) { + if (stylePos->mFlexWrap == StyleFlexWrap::WrapReverse) { mCrossAxis = GetReverseAxis(mCrossAxis); mIsCrossAxisReversed = true; } else { @@ -3845,7 +3845,7 @@ void nsFlexContainerFrame::GenerateFlexLines( MOZ_ASSERT(aLines.isEmpty(), "Expecting outparam to start out empty"); const bool isSingleLine = - NS_STYLE_FLEX_WRAP_NOWRAP == aReflowInput.mStylePosition->mFlexWrap; + StyleFlexWrap::Nowrap == aReflowInput.mStylePosition->mFlexWrap; // If we're transparently reversing axes, then we'll need to link up our // FlexItems and FlexLines in the reverse order, so that the rest of flex @@ -5364,7 +5364,7 @@ nscoord nsFlexContainerFrame::IntrinsicISize(gfxContext* aRenderingContext, // is the max of its items' min isizes. // * For a row-oriented multi-line flex container, the intrinsic // pref isize is former (sum), and its min isize is the latter (max). - bool isSingleLine = (NS_STYLE_FLEX_WRAP_NOWRAP == stylePos->mFlexWrap); + bool isSingleLine = (StyleFlexWrap::Nowrap == stylePos->mFlexWrap); if (axisTracker.IsRowOriented() && (isSingleLine || aType == nsLayoutUtils::PREF_ISIZE)) { containerISize += childISize; diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 5167f5596dda..1d168fb5ec8a 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -127,6 +127,7 @@ rusty-enums = [ "mozilla::StyleTextRendering", "mozilla::StyleColorAdjust", "mozilla::StyleFlexDirection", + "mozilla::StyleFlexWrap", "mozilla::StyleTextDecorationSkipInk", "mozilla::StyleTextDecorationLength", "nsStyleImageType", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 0c518bc0821d..329172fea2ff 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -453,9 +453,11 @@ enum class StyleFlexDirection : uint8_t { }; // See nsStylePosition -#define NS_STYLE_FLEX_WRAP_NOWRAP 0 -#define NS_STYLE_FLEX_WRAP_WRAP 1 -#define NS_STYLE_FLEX_WRAP_WRAP_REVERSE 2 +enum class StyleFlexWrap : uint8_t { + Nowrap, + Wrap, + WrapReverse, +}; // See nsStylePosition // NOTE: This is the initial value of the integer-valued 'order' property diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index f854c8f1e49c..9096b90161d7 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1176,7 +1176,7 @@ nsStylePosition::nsStylePosition(const Document& aDocument) mJustifyItems(NS_STYLE_JUSTIFY_NORMAL), mJustifySelf(NS_STYLE_JUSTIFY_AUTO), mFlexDirection(StyleFlexDirection::Row), - mFlexWrap(NS_STYLE_FLEX_WRAP_NOWRAP), + mFlexWrap(StyleFlexWrap::Nowrap), mObjectFit(NS_STYLE_OBJECT_FIT_FILL), mOrder(NS_STYLE_ORDER_INITIAL), mFlexGrow(0.0f), diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 425917bb2625..2113ad74f48d 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1033,7 +1033,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition { uint8_t mJustifyItems; uint8_t mJustifySelf; mozilla::StyleFlexDirection mFlexDirection; - uint8_t mFlexWrap; // NS_STYLE_FLEX_WRAP_* + mozilla::StyleFlexWrap mFlexWrap; uint8_t mObjectFit; // NS_STYLE_OBJECT_FIT_* int32_t mOrder; float mFlexGrow; diff --git a/servo/components/style/properties/longhands/position.mako.rs b/servo/components/style/properties/longhands/position.mako.rs index a63f7637db4c..680b6117c426 100644 --- a/servo/components/style/properties/longhands/position.mako.rs +++ b/servo/components/style/properties/longhands/position.mako.rs @@ -91,6 +91,7 @@ ${helpers.single_keyword( extra_prefixes="webkit", animation_value_type="discrete", servo_restyle_damage = "reflow", + gecko_enum_prefix = "StyleFlexWrap", )} % if engine == "servo-2013":