diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 6c21c9c90652..c478402a169b 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -3503,8 +3503,8 @@ StyleClipBasicShapeToCSSArray(const nsStyleClipPath& aClipPath, nsCSSKeyword functionName = shape->GetShapeTypeName(); RefPtr functionArray; switch (shape->GetShapeType()) { - case nsStyleBasicShape::Type::eCircle: - case nsStyleBasicShape::Type::eEllipse: { + case StyleBasicShapeType::Circle: + case StyleBasicShapeType::Ellipse: { const nsTArray& coords = shape->Coordinates(); MOZ_ASSERT(coords.Length() == ShapeArgumentCount(functionName) - 1, "Unexpected radii count"); @@ -3525,7 +3525,7 @@ StyleClipBasicShapeToCSSArray(const nsStyleClipPath& aClipPath, functionArray->Item(functionArray->Count() - 1)); break; } - case nsStyleBasicShape::Type::ePolygon: { + case StyleBasicShapeType::Polygon: { functionArray = aResult->Item(0).InitFunction(functionName, ShapeArgumentCount(functionName)); @@ -3546,7 +3546,7 @@ StyleClipBasicShapeToCSSArray(const nsStyleClipPath& aClipPath, } break; } - case nsStyleBasicShape::Type::eInset: { + case StyleBasicShapeType::Inset: { const nsTArray& coords = shape->Coordinates(); MOZ_ASSERT(coords.Length() == ShapeArgumentCount(functionName) - 1, "Unexpected offset count"); diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 9481aaaa2eac..715f9cdc7705 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -5921,7 +5921,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape( { MOZ_ASSERT(aStyleBasicShape, "Expect a valid basic shape pointer!"); - nsStyleBasicShape::Type type = aStyleBasicShape->GetShapeType(); + StyleBasicShapeType type = aStyleBasicShape->GetShapeType(); // Shape function name and opening parenthesis. nsAutoString shapeFunctionString; AppendASCIItoUTF16(nsCSSKeywords::GetStringValue( @@ -5929,7 +5929,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape( shapeFunctionString); shapeFunctionString.Append('('); switch (type) { - case nsStyleBasicShape::Type::ePolygon: { + case StyleBasicShapeType::Polygon: { bool hasEvenOdd = aStyleBasicShape->GetFillRule() == NS_STYLE_FILL_RULE_EVENODD; if (hasEvenOdd) { @@ -5951,11 +5951,11 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape( } break; } - case nsStyleBasicShape::Type::eCircle: - case nsStyleBasicShape::Type::eEllipse: { + case StyleBasicShapeType::Circle: + case StyleBasicShapeType::Ellipse: { const nsTArray& radii = aStyleBasicShape->Coordinates(); MOZ_ASSERT(radii.Length() == - (type == nsStyleBasicShape::Type::eCircle ? 1 : 2), + (type == StyleBasicShapeType::Circle ? 1 : 2), "wrong number of radii"); for (size_t i = 0; i < radii.Length(); ++i) { nsAutoString radius; @@ -5976,7 +5976,7 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape( shapeFunctionString.Append(positionString); break; } - case nsStyleBasicShape::Type::eInset: { + case StyleBasicShapeType::Inset: { BoxValuesToString(shapeFunctionString, aStyleBasicShape->Coordinates()); if (aStyleBasicShape->HasRadius()) { shapeFunctionString.AppendLiteral(" round "); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 00d3933f63bd..d5be1c160484 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -9595,7 +9595,7 @@ GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue, if (functionName == eCSSKeyword_polygon) { MOZ_ASSERT(!basicShape, "did not expect value"); - basicShape = new nsStyleBasicShape(nsStyleBasicShape::ePolygon); + basicShape = new nsStyleBasicShape(StyleBasicShapeType::Polygon); MOZ_ASSERT(shapeFunction->Count() > 1, "polygon has wrong number of arguments"); size_t j = 1; @@ -9626,17 +9626,17 @@ GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue, } } else if (functionName == eCSSKeyword_circle || functionName == eCSSKeyword_ellipse) { - nsStyleBasicShape::Type type = functionName == eCSSKeyword_circle ? - nsStyleBasicShape::eCircle : - nsStyleBasicShape::eEllipse; + StyleBasicShapeType type = functionName == eCSSKeyword_circle ? + StyleBasicShapeType::Circle : + StyleBasicShapeType::Ellipse; MOZ_ASSERT(!basicShape, "did not expect value"); basicShape = new nsStyleBasicShape(type); const int32_t mask = SETCOORD_PERCENT | SETCOORD_LENGTH | SETCOORD_STORE_CALC | SETCOORD_ENUMERATED; - size_t count = type == nsStyleBasicShape::eCircle ? 2 : 3; + size_t count = type == StyleBasicShapeType::Circle ? 2 : 3; MOZ_ASSERT(shapeFunction->Count() == count + 1, "unexpected arguments count"); - MOZ_ASSERT(type == nsStyleBasicShape::eCircle || + MOZ_ASSERT(type == StyleBasicShapeType::Circle || (shapeFunction->Item(1).GetUnit() == eCSSUnit_Null) == (shapeFunction->Item(2).GetUnit() == eCSSUnit_Null), "ellipse should have two radii or none"); @@ -9666,7 +9666,7 @@ GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue, } } else if (functionName == eCSSKeyword_inset) { MOZ_ASSERT(!basicShape, "did not expect value"); - basicShape = new nsStyleBasicShape(nsStyleBasicShape::eInset); + basicShape = new nsStyleBasicShape(StyleBasicShapeType::Inset); MOZ_ASSERT(shapeFunction->Count() == 6, "inset function has wrong number of arguments"); MOZ_ASSERT(shapeFunction->Item(1).GetUnit() != eCSSUnit_Null, diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 5f88752d46fd..87f1ab6b22bf 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -54,8 +54,8 @@ static inline css::Side operator++(css::Side& side, int) { #define NS_SIDE_TO_HALF_CORNER(side_, second_, parallel_) \ ((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8) -// Basic Shapes (currently unused) -enum class StyleBasicShape : uint8_t{ +// Basic shapes +enum class StyleBasicShapeType : uint8_t { Polygon, Circle, Ellipse, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 2d753c34c9c1..a95939784e36 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -996,13 +996,13 @@ nsCSSKeyword nsStyleBasicShape::GetShapeTypeName() const { switch (mType) { - case nsStyleBasicShape::Type::ePolygon: + case StyleBasicShapeType::Polygon: return eCSSKeyword_polygon; - case nsStyleBasicShape::Type::eCircle: + case StyleBasicShapeType::Circle: return eCSSKeyword_circle; - case nsStyleBasicShape::Type::eEllipse: + case StyleBasicShapeType::Ellipse: return eCSSKeyword_ellipse; - case nsStyleBasicShape::Type::eInset: + case StyleBasicShapeType::Inset: return eCSSKeyword_inset; } NS_NOTREACHED("unexpected type"); diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index a8015e15d19d..f2609786a08f 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -3441,44 +3441,39 @@ namespace mozilla { class nsStyleBasicShape final { public: - enum Type { - eInset, - eCircle, - eEllipse, - ePolygon - }; - - explicit nsStyleBasicShape(Type type) + explicit nsStyleBasicShape(StyleBasicShapeType type) : mType(type), mFillRule(NS_STYLE_FILL_RULE_NONZERO) { mPosition.SetInitialPercentValues(0.5f); } - Type GetShapeType() const { return mType; } + StyleBasicShapeType GetShapeType() const { return mType; } nsCSSKeyword GetShapeTypeName() const; int32_t GetFillRule() const { return mFillRule; } void SetFillRule(int32_t aFillRule) { - NS_ASSERTION(mType == ePolygon, "expected polygon"); + MOZ_ASSERT(mType == StyleBasicShapeType::Polygon, "expected polygon"); mFillRule = aFillRule; } typedef nsStyleImageLayers::Position Position; Position& GetPosition() { - NS_ASSERTION(mType == eCircle || mType == eEllipse, - "expected circle or ellipse"); + MOZ_ASSERT(mType == StyleBasicShapeType::Circle || + mType == StyleBasicShapeType::Ellipse, + "expected circle or ellipse"); return mPosition; } const Position& GetPosition() const { - NS_ASSERTION(mType == eCircle || mType == eEllipse, - "expected circle or ellipse"); + MOZ_ASSERT(mType == StyleBasicShapeType::Circle || + mType == StyleBasicShapeType::Ellipse, + "expected circle or ellipse"); return mPosition; } bool HasRadius() const { - NS_ASSERTION(mType == eInset, "expected inset"); + MOZ_ASSERT(mType == StyleBasicShapeType::Inset, "expected inset"); nsStyleCoord zero; zero.SetCoordValue(0); NS_FOR_CSS_HALF_CORNERS(corner) { @@ -3489,11 +3484,11 @@ public: return false; } nsStyleCorners& GetRadius() { - NS_ASSERTION(mType == eInset, "expected inset"); + MOZ_ASSERT(mType == StyleBasicShapeType::Inset, "expected inset"); return mRadius; } const nsStyleCorners& GetRadius() const { - NS_ASSERTION(mType == eInset, "expected inset"); + MOZ_ASSERT(mType == StyleBasicShapeType::Inset, "expected inset"); return mRadius; } @@ -3526,7 +3521,7 @@ public: private: ~nsStyleBasicShape() {} - Type mType; + StyleBasicShapeType mType; int32_t mFillRule; // mCoordinates has coordinates for polygon or radii for diff --git a/layout/svg/nsCSSClipPathInstance.cpp b/layout/svg/nsCSSClipPathInstance.cpp index 0ce75ee4d3d8..ea1275d0d423 100644 --- a/layout/svg/nsCSSClipPathInstance.cpp +++ b/layout/svg/nsCSSClipPathInstance.cpp @@ -94,13 +94,13 @@ nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget) nsStyleBasicShape* basicShape = mClipPathStyle.GetBasicShape(); switch (basicShape->GetShapeType()) { - case nsStyleBasicShape::Type::eCircle: + case StyleBasicShapeType::Circle: return CreateClipPathCircle(aDrawTarget, r); - case nsStyleBasicShape::Type::eEllipse: + case StyleBasicShapeType::Ellipse: return CreateClipPathEllipse(aDrawTarget, r); - case nsStyleBasicShape::Type::ePolygon: + case StyleBasicShapeType::Polygon: return CreateClipPathPolygon(aDrawTarget, r); - case nsStyleBasicShape::Type::eInset: + case StyleBasicShapeType::Inset: // XXXkrit support all basic shapes break; default: