diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index 4f5eae12863d..6b60920fe054 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -490,16 +490,16 @@ static inline wr::SideOffsets2D_f32 ToSideOffsets2D_f32(float top, float right, return offset; } -static inline wr::RepeatMode ToRepeatMode(uint8_t repeatMode) +static inline wr::RepeatMode ToRepeatMode(mozilla::StyleBorderImageRepeat repeatMode) { switch (repeatMode) { - case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH: + case mozilla::StyleBorderImageRepeat::Stretch: return wr::RepeatMode::Stretch; - case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT: + case mozilla::StyleBorderImageRepeat::Repeat: return wr::RepeatMode::Repeat; - case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND: + case mozilla::StyleBorderImageRepeat::Round: return wr::RepeatMode::Round; - case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE: + case mozilla::StyleBorderImageRepeat::Space: return wr::RepeatMode::Space; default: MOZ_ASSERT(false); diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index dfa5190dc3be..923d645214ec 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -749,10 +749,10 @@ nsCSSRendering::CreateWebRenderCommandsForBorder(nsDisplayItem* aItem, return false; } - if (styleBorder->mBorderImageRepeatH == NS_STYLE_BORDER_IMAGE_REPEAT_ROUND || - styleBorder->mBorderImageRepeatH == NS_STYLE_BORDER_IMAGE_REPEAT_SPACE || - styleBorder->mBorderImageRepeatV == NS_STYLE_BORDER_IMAGE_REPEAT_ROUND || - styleBorder->mBorderImageRepeatV == NS_STYLE_BORDER_IMAGE_REPEAT_SPACE) { + if (styleBorder->mBorderImageRepeatH == StyleBorderImageRepeat::Round || + styleBorder->mBorderImageRepeatH == StyleBorderImageRepeat::Space || + styleBorder->mBorderImageRepeatV == StyleBorderImageRepeat::Round || + styleBorder->mBorderImageRepeatV == StyleBorderImageRepeat::Space) { return false; } diff --git a/layout/painting/nsCSSRenderingBorders.cpp b/layout/painting/nsCSSRenderingBorders.cpp index 466b40656d11..a4eb01d6467d 100644 --- a/layout/painting/nsCSSRenderingBorders.cpp +++ b/layout/painting/nsCSSRenderingBorders.cpp @@ -3754,7 +3754,7 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext, 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) { @@ -3808,7 +3808,7 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext, unitSize.width = sliceWidth[i] * factor; unitSize.height = borderHeight[j]; fillStyleH = mRepeatModeHorizontal; - fillStyleV = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH; + fillStyleV = StyleBorderImageRepeat::Stretch; } else if (j == MIDDLE) { // left, right gfxFloat factor; @@ -3819,15 +3819,15 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext, unitSize.width = borderWidth[i]; unitSize.height = sliceHeight[j] * factor; - fillStyleH = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH; + fillStyleH = StyleBorderImageRepeat::Stretch; fillStyleV = mRepeatModeVertical; } 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]); diff --git a/layout/painting/nsCSSRenderingBorders.h b/layout/painting/nsCSSRenderingBorders.h index a5baf0b19c47..87c6aeae6307 100644 --- a/layout/painting/nsCSSRenderingBorders.h +++ b/layout/painting/nsCSSRenderingBorders.h @@ -336,8 +336,8 @@ private: nsMargin mImageOutset; nsRect mArea; nsRect mClip; - uint8_t mRepeatModeHorizontal; - uint8_t mRepeatModeVertical; + mozilla::StyleBorderImageRepeat mRepeatModeHorizontal; + mozilla::StyleBorderImageRepeat mRepeatModeVertical; uint8_t mFill; friend class nsDisplayBorder; diff --git a/layout/painting/nsImageRenderer.cpp b/layout/painting/nsImageRenderer.cpp index 8fa2511bca56..5478f3295ed5 100644 --- a/layout/painting/nsImageRenderer.cpp +++ b/layout/painting/nsImageRenderer.cpp @@ -745,35 +745,35 @@ nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresCo * 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 + * StyleBorderImageRepeat - 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, + 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 = nsCSSRendering::ComputeRoundedSize(aUnitSize.width, aFill.width); aRepeatSize.width = tile.width; break; - case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE: + case StyleBorderImageRepeat::Space: { nscoord space; aRepeatSize.width = @@ -790,23 +790,23 @@ ComputeTile(nsRect& aFill, } 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 = nsCSSRendering::ComputeRoundedSize(aUnitSize.height, aFill.height); aRepeatSize.height = tile.height; break; - case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE: + case StyleBorderImageRepeat::Space: { nscoord space; aRepeatSize.height = @@ -832,14 +832,14 @@ ComputeTile(nsRect& aFill, */ static bool RequiresScaling(const nsRect& aFill, - uint8_t aHFill, - uint8_t aVFill, + 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); } @@ -850,8 +850,8 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext, const nsRect& aDirtyRect, const nsRect& aFill, const CSSIntRect& aSrc, - uint8_t aHFill, - uint8_t aVFill, + StyleBorderImageRepeat aHFill, + StyleBorderImageRepeat aVFill, const nsSize& aUnitSize, uint8_t aIndex, const Maybe& aSVGViewportSize, diff --git a/layout/painting/nsImageRenderer.h b/layout/painting/nsImageRenderer.h index 9456d5d6216a..91e9c93d5ead 100644 --- a/layout/painting/nsImageRenderer.h +++ b/layout/painting/nsImageRenderer.h @@ -247,8 +247,8 @@ public: const nsRect& aDirtyRect, const nsRect& aFill, const mozilla::CSSIntRect& aSrc, - uint8_t aHFill, - uint8_t aVFill, + mozilla::StyleBorderImageRepeat aHFill, + mozilla::StyleBorderImageRepeat aVFill, const nsSize& aUnitSize, uint8_t aIndex, const mozilla::Maybe& aSVGViewportSize, diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 943f9a9ee84b..c0658dc20ea7 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -168,6 +168,7 @@ rusty-enums = [ "StyleBasicShapeType", "nsStyleImageLayers_Size_DimensionType", "StyleStackSizing", + "StyleBorderImageRepeat", "StyleBoxPack", "StyleBoxOrient", "StyleBoxAlign", diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp index 78c0a055c7c1..aeff6a67a2b8 100644 --- a/layout/style/nsCSSDataBlock.cpp +++ b/layout/style/nsCSSDataBlock.cpp @@ -454,8 +454,7 @@ 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)); } /*****************************************************************************/ diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 43ba06eebcf7..c1d8d5e02ba6 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -13158,8 +13158,7 @@ CSSParserImpl::SetBorderImageInitialValues() // 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); } diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 2f7b054e2aae..673f8c8c249b 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -1004,10 +1004,10 @@ const KTableEntry nsCSSProps::kBorderCollapseKTable[] = { }; 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 } }; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 3f8a59c89270..7abc5559961c 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1425,6 +1425,7 @@ struct SetEnumValueHelper aField = static_cast(value); \ } + DEFINE_ENUM_CLASS_SETTER(StyleBorderImageRepeat, Stretch, Space) DEFINE_ENUM_CLASS_SETTER(StyleBoxAlign, Stretch, End) DEFINE_ENUM_CLASS_SETTER(StyleBoxDecorationBreak, Slice, Clone) DEFINE_ENUM_CLASS_SETTER(StyleBoxDirection, Normal, Reverse) @@ -7602,14 +7603,14 @@ nsRuleNode::ComputeBorderData(void* aStartStruct, 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) } diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 800fd1ed61e1..750928176b6b 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -337,11 +337,13 @@ enum class StyleImageLayerRepeat : uint8_t { #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 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index d81ab65eb3b8..b45013d84e93 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -337,8 +337,8 @@ nsStylePadding::CalcDifference(const nsStylePadding& aNewData) const nsStyleBorder::nsStyleBorder(const nsPresContext* aContext) : 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) diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 126a1dbc1df7..3a80994891f7 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1253,8 +1253,8 @@ public: 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]