diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 9f35896d6682..69a239e984b2 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -3573,7 +3573,8 @@ StyleClipBasicShapeToCSSArray(const nsStyleClipPath& aClipPath, MOZ_ASSERT_UNREACHABLE("Unknown shape type"); return false; } - aResult->Item(1).SetIntValue(aClipPath.GetSizingBox(), eCSSUnit_Enumerated); + aResult->Item(1).SetIntValue(uint8_t(aClipPath.GetSizingBox()), + eCSSUnit_Enumerated); return true; } @@ -3963,7 +3964,8 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, result->SetURLValue(url); aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL); } else if (type == NS_STYLE_CLIP_PATH_BOX) { - aComputedValue.SetIntValue(clipPath.GetSizingBox(), eUnit_Enumerated); + aComputedValue.SetIntValue(uint8_t(clipPath.GetSizingBox()), + eUnit_Enumerated); } else if (type == NS_STYLE_CLIP_PATH_SHAPE) { RefPtr result = nsCSSValue::Array::Create(2); if (!StyleClipBasicShapeToCSSArray(clipPath, result)) { diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index ee5a29cbb91a..8a249681244c 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -2300,13 +2300,13 @@ const KTableEntry nsCSSProps::kFillRuleKTable[] = { }; const KTableEntry nsCSSProps::kClipShapeSizingKTable[] = { - { eCSSKeyword_content_box, NS_STYLE_CLIP_SHAPE_SIZING_CONTENT }, - { eCSSKeyword_padding_box, NS_STYLE_CLIP_SHAPE_SIZING_PADDING }, - { eCSSKeyword_border_box, NS_STYLE_CLIP_SHAPE_SIZING_BORDER }, - { eCSSKeyword_margin_box, NS_STYLE_CLIP_SHAPE_SIZING_MARGIN }, - { eCSSKeyword_fill_box, NS_STYLE_CLIP_SHAPE_SIZING_FILL }, - { eCSSKeyword_stroke_box, NS_STYLE_CLIP_SHAPE_SIZING_STROKE }, - { eCSSKeyword_view_box, NS_STYLE_CLIP_SHAPE_SIZING_VIEW }, + { eCSSKeyword_content_box, uint8_t(StyleClipShapeSizing::Content) }, + { eCSSKeyword_padding_box, uint8_t(StyleClipShapeSizing::Padding) }, + { eCSSKeyword_border_box, uint8_t(StyleClipShapeSizing::Border) }, + { eCSSKeyword_margin_box, uint8_t(StyleClipShapeSizing::Margin) }, + { eCSSKeyword_fill_box, uint8_t(StyleClipShapeSizing::Fill) }, + { eCSSKeyword_stroke_box, uint8_t(StyleClipShapeSizing::Stroke) }, + { eCSSKeyword_view_box, uint8_t(StyleClipShapeSizing::View) }, { eCSSKeyword_UNKNOWN, -1 } }; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index c5477e581d03..ef38b09b9f04 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -5975,7 +5975,8 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape( already_AddRefed nsComputedDOMStyle::CreatePrimitiveValueForClipPath( - const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox) + const nsStyleBasicShape* aStyleBasicShape, + mozilla::StyleClipShapeSizing aSizingBox) { RefPtr valueList = GetROCSSValueList(false); if (aStyleBasicShape) { @@ -5983,13 +5984,13 @@ nsComputedDOMStyle::CreatePrimitiveValueForClipPath( CreatePrimitiveValueForBasicShape(aStyleBasicShape)); } - if (aSizingBox == NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) { + if (aSizingBox == StyleClipShapeSizing::NoBox) { return valueList.forget(); } nsAutoString boxString; AppendASCIItoUTF16( - nsCSSProps::ValueToKeyword(aSizingBox, + nsCSSProps::ValueToKeyword(uint8_t(aSizingBox), nsCSSProps::kClipShapeSizingKTable), boxString); RefPtr val = new nsROCSSPrimitiveValue; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index a664ee757960..c60413372ad5 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -643,7 +643,8 @@ private: const nsStyleFilter& aStyleFilter); already_AddRefed CreatePrimitiveValueForClipPath( - const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox); + const nsStyleBasicShape* aStyleBasicShape, + mozilla::StyleClipShapeSizing aSizingBox); // Helper function for computing basic shape styles. already_AddRefed CreatePrimitiveValueForBasicShape( diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index e02737ecc485..1e28ba302ff8 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -9701,17 +9701,17 @@ nsRuleNode::SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath, MOZ_ASSERT(array->Count() == 1 || array->Count() == 2, "Expect one or both of a shape function and geometry-box"); - uint8_t sizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX; + StyleClipShapeSizing sizingBox = StyleClipShapeSizing::NoBox; RefPtr basicShape; for (size_t i = 0; i < array->Count(); ++i) { if (array->Item(i).GetUnit() == eCSSUnit_Enumerated) { int32_t type = array->Item(i).GetIntValue(); - if (type > NS_STYLE_CLIP_SHAPE_SIZING_VIEW || - type < NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) { + if (type > uint8_t(StyleClipShapeSizing::View) || + type < uint8_t(StyleClipShapeSizing::NoBox)) { NS_NOTREACHED("unexpected reference box"); return; } - sizingBox = (uint8_t)type; + sizingBox = static_cast(type); } else if (array->Item(i).GetUnit() == eCSSUnit_Function) { basicShape = GetStyleBasicShapeFromCSSValue(array->Item(i), aStyleContext, aPresContext, aConditions); diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 1505826361da..49c6de879482 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -61,14 +61,16 @@ enum class StyleBoxSizing : uint8_t { }; // clip-path sizing -#define NS_STYLE_CLIP_SHAPE_SIZING_NOBOX 0 -#define NS_STYLE_CLIP_SHAPE_SIZING_CONTENT 1 -#define NS_STYLE_CLIP_SHAPE_SIZING_PADDING 2 -#define NS_STYLE_CLIP_SHAPE_SIZING_BORDER 3 -#define NS_STYLE_CLIP_SHAPE_SIZING_MARGIN 4 -#define NS_STYLE_CLIP_SHAPE_SIZING_FILL 5 -#define NS_STYLE_CLIP_SHAPE_SIZING_STROKE 6 -#define NS_STYLE_CLIP_SHAPE_SIZING_VIEW 7 +enum class StyleClipShapeSizing : uint8_t { + NoBox, + Content, + Padding, + Border, + Margin, + Fill, + Stroke, + View, +}; // Basic Shapes #define NS_STYLE_BASIC_SHAPE_POLYGON 0 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 020ca58420fe..742be0a21f47 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1007,14 +1007,14 @@ nsStyleBasicShape::GetShapeTypeName() const nsStyleClipPath::nsStyleClipPath() : mType(NS_STYLE_CLIP_PATH_NONE) , mURL(nullptr) - , mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) + , mSizingBox(mozilla::StyleClipShapeSizing::NoBox) { } nsStyleClipPath::nsStyleClipPath(const nsStyleClipPath& aSource) : mType(NS_STYLE_CLIP_PATH_NONE) , mURL(nullptr) - , mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) + , mSizingBox(mozilla::StyleClipShapeSizing::NoBox) { if (aSource.mType == NS_STYLE_CLIP_PATH_URL) { SetURL(aSource.mURL); @@ -1045,7 +1045,7 @@ nsStyleClipPath::operator=(const nsStyleClipPath& aOther) SetSizingBox(aOther.mSizingBox); } else { ReleaseRef(); - mSizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX; + mSizingBox = mozilla::StyleClipShapeSizing::NoBox; mType = NS_STYLE_CLIP_PATH_NONE; } return *this; @@ -1096,7 +1096,8 @@ nsStyleClipPath::SetURL(nsIURI* aURL) } void -nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, uint8_t aSizingBox) +nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, + mozilla::StyleClipShapeSizing aSizingBox) { NS_ASSERTION(aBasicShape, "expected pointer"); ReleaseRef(); @@ -1107,7 +1108,7 @@ nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, uint8_t aSizingBo } void -nsStyleClipPath::SetSizingBox(uint8_t aSizingBox) +nsStyleClipPath::SetSizingBox(mozilla::StyleClipShapeSizing aSizingBox) { ReleaseRef(); mSizingBox = aSizingBox; diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index ffff64af5cbd..ea5e4155e2b1 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -3522,10 +3522,11 @@ struct nsStyleClipPath } void SetBasicShape(nsStyleBasicShape* mBasicShape, - uint8_t aSizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX); + mozilla::StyleClipShapeSizing aSizingBox = + mozilla::StyleClipShapeSizing::NoBox); - uint8_t GetSizingBox() const { return mSizingBox; } - void SetSizingBox(uint8_t aSizingBox); + mozilla::StyleClipShapeSizing GetSizingBox() const { return mSizingBox; } + void SetSizingBox(mozilla::StyleClipShapeSizing aSizingBox); private: void ReleaseRef(); @@ -3536,7 +3537,7 @@ private: nsStyleBasicShape* mBasicShape; nsIURI* mURL; }; - uint8_t mSizingBox; // see NS_STYLE_CLIP_SHAPE_SIZING_* constants in nsStyleConsts.h + mozilla::StyleClipShapeSizing mSizingBox; }; struct nsStyleFilter diff --git a/layout/svg/nsCSSClipPathInstance.cpp b/layout/svg/nsCSSClipPathInstance.cpp index 591cb282a7f7..e49d471c5df5 100644 --- a/layout/svg/nsCSSClipPathInstance.cpp +++ b/layout/svg/nsCSSClipPathInstance.cpp @@ -68,13 +68,13 @@ nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget) nsRect r; // XXXkrit SVG needs to use different boxes. switch (mClipPathStyle.GetSizingBox()) { - case NS_STYLE_CLIP_SHAPE_SIZING_CONTENT: + case StyleClipShapeSizing::Content: r = mTargetFrame->GetContentRectRelativeToSelf(); break; - case NS_STYLE_CLIP_SHAPE_SIZING_PADDING: + case StyleClipShapeSizing::Padding: r = mTargetFrame->GetPaddingRectRelativeToSelf(); break; - case NS_STYLE_CLIP_SHAPE_SIZING_MARGIN: + case StyleClipShapeSizing::Margin: r = mTargetFrame->GetMarginRectRelativeToSelf(); break; default: // Use the border box