diff --git a/dom/svg/SVGContentUtils.cpp b/dom/svg/SVGContentUtils.cpp index f98e2471d2c4..c09b444e2344 100644 --- a/dom/svg/SVGContentUtils.cpp +++ b/dom/svg/SVGContentUtils.cpp @@ -239,7 +239,7 @@ static DashState GetStrokeDashData( // We can only return eNoStroke if the value of stroke-linecap isn't // adding caps to zero length dashes. if (totalLengthOfDashes <= 0 && - aStyleSVG->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_BUTT) { + aStyleSVG->mStrokeLinecap == StyleStrokeLinecap::Butt) { return eNoStroke; } @@ -304,13 +304,13 @@ void SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions, aStrokeOptions->mLineCap = CapStyle::BUTT; } else { switch (styleSVG->mStrokeLinecap) { - case NS_STYLE_STROKE_LINECAP_BUTT: + case StyleStrokeLinecap::Butt: aStrokeOptions->mLineCap = CapStyle::BUTT; break; - case NS_STYLE_STROKE_LINECAP_ROUND: + case StyleStrokeLinecap::Round: aStrokeOptions->mLineCap = CapStyle::ROUND; break; - case NS_STYLE_STROKE_LINECAP_SQUARE: + case StyleStrokeLinecap::Square: aStrokeOptions->mLineCap = CapStyle::SQUARE; break; } @@ -830,7 +830,7 @@ already_AddRefed SVGContentUtils::GetPath( RefPtr builder = drawTarget->CreatePathBuilder(FillRule::FILL_WINDING); - return pathData.BuildPath(builder, NS_STYLE_STROKE_LINECAP_BUTT, 1); + return pathData.BuildPath(builder, StyleStrokeLinecap::Butt, 1); } bool SVGContentUtils::ShapeTypeHasNoCorners(const nsIContent* aContent) { diff --git a/dom/svg/SVGPathData.cpp b/dom/svg/SVGPathData.cpp index 41ac5c143e51..2cba669e2741 100644 --- a/dom/svg/SVGPathData.cpp +++ b/dom/svg/SVGPathData.cpp @@ -280,13 +280,13 @@ static void ApproximateZeroLengthSubpathSquareCaps(PathBuilder* aPB, } while (0) already_AddRefed SVGPathData::BuildPath(PathBuilder* aBuilder, - uint8_t aStrokeLineCap, + StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth) const { if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) { return nullptr; // paths without an initial moveto are invalid } - bool hasLineCaps = aStrokeLineCap != NS_STYLE_STROKE_LINECAP_BUTT; + bool hasLineCaps = aStrokeLineCap != StyleStrokeLinecap::Butt; bool subpathHasLength = false; // visual length bool subpathContainsNonMoveTo = false; @@ -529,7 +529,7 @@ already_AddRefed SVGPathData::BuildPathForMeasuring() const { gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); RefPtr builder = drawTarget->CreatePathBuilder(FillRule::FILL_WINDING); - return BuildPath(builder, NS_STYLE_STROKE_LINECAP_BUTT, 0); + return BuildPath(builder, StyleStrokeLinecap::Butt, 0); } // We could simplify this function because this is only used by CSS motion path @@ -538,7 +538,7 @@ already_AddRefed SVGPathData::BuildPathForMeasuring() const { /* static */ already_AddRefed SVGPathData::BuildPath( Span aPath, PathBuilder* aBuilder, - uint8_t aStrokeLineCap, Float aStrokeWidth, float aZoomFactor) { + StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth, float aZoomFactor) { if (aPath.IsEmpty() || !aPath[0].IsMoveTo()) { return nullptr; // paths without an initial moveto are invalid } @@ -557,7 +557,7 @@ already_AddRefed SVGPathData::BuildPath( aType == StylePathCommand::Tag::SmoothQuadBezierCurveTo; }; - bool hasLineCaps = aStrokeLineCap != NS_STYLE_STROKE_LINECAP_BUTT; + bool hasLineCaps = aStrokeLineCap != StyleStrokeLinecap::Butt; bool subpathHasLength = false; // visual length bool subpathContainsNonMoveTo = false; diff --git a/dom/svg/SVGPathData.h b/dom/svg/SVGPathData.h index 10ead10fb073..e4aa4a448c6d 100644 --- a/dom/svg/SVGPathData.h +++ b/dom/svg/SVGPathData.h @@ -163,7 +163,7 @@ class SVGPathData { already_AddRefed BuildPathForMeasuring() const; already_AddRefed BuildPath(PathBuilder* aBuilder, - uint8_t aStrokeLineCap, + StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth) const; /** * This function tries to build the path from an array of StylePathCommand, @@ -172,7 +172,7 @@ class SVGPathData { */ static already_AddRefed BuildPath(Span aPath, PathBuilder* aBuilder, - uint8_t aStrokeLineCap, + StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth, float aZoomFactor = 1.0); diff --git a/dom/svg/SVGPathElement.cpp b/dom/svg/SVGPathElement.cpp index 4919913e811c..ec90ffcf4961 100644 --- a/dom/svg/SVGPathElement.cpp +++ b/dom/svg/SVGPathElement.cpp @@ -258,7 +258,7 @@ already_AddRefed SVGPathElement::BuildPath(PathBuilder* aBuilder) { // also our stroke width. See the comment for // ApproximateZeroLengthSubpathSquareCaps for more info. - uint8_t strokeLineCap = NS_STYLE_STROKE_LINECAP_BUTT; + auto strokeLineCap = StyleStrokeLinecap::Butt; Float strokeWidth = 0; SVGGeometryProperty::DoForComputedStyle(this, [&](const ComputedStyle* s) { @@ -267,7 +267,7 @@ already_AddRefed SVGPathElement::BuildPath(PathBuilder* aBuilder) { // exposes hit-testing of strokes that are not actually painted. For that // reason we do not check for eStyleSVGPaintType_None or check the stroke // opacity here. - if (style->mStrokeLinecap != NS_STYLE_STROKE_LINECAP_BUTT) { + if (style->mStrokeLinecap != StyleStrokeLinecap::Butt) { strokeLineCap = style->mStrokeLinecap; strokeWidth = SVGContentUtils::GetStrokeWidth(this, s, nullptr); } diff --git a/layout/base/MotionPathUtils.cpp b/layout/base/MotionPathUtils.cpp index 5ea659d77b79..1eeb52d16ec5 100644 --- a/layout/base/MotionPathUtils.cpp +++ b/layout/base/MotionPathUtils.cpp @@ -620,8 +620,8 @@ already_AddRefed MotionPathUtils::BuildPath( } const Span& path = aPath._0.AsSpan(); - return SVGPathData::BuildPath(path, aPathBuilder, - NS_STYLE_STROKE_LINECAP_BUTT, 0.0); + return SVGPathData::BuildPath(path, aPathBuilder, StyleStrokeLinecap::Butt, + 0.0); } /* static */ diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index a6c141ed7870..110c99309e49 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -125,6 +125,7 @@ rusty-enums = [ "mozilla::StyleTextRendering", "mozilla::StyleColorAdjust", "mozilla::StyleFlexDirection", + "mozilla::StyleStrokeLinecap", "mozilla::StyleFlexWrap", "mozilla::StyleTextDecorationSkipInk", "mozilla::StyleTextDecorationLength", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 9e99cba11b73..4374bd58fe25 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -771,9 +771,11 @@ enum class StyleShapeRendering : uint8_t { }; // stroke-linecap -#define NS_STYLE_STROKE_LINECAP_BUTT 0 -#define NS_STYLE_STROKE_LINECAP_ROUND 1 -#define NS_STYLE_STROKE_LINECAP_SQUARE 2 +enum class StyleStrokeLinecap : uint8_t { + Butt, + Round, + Square, +}; // stroke-linejoin #define NS_STYLE_STROKE_LINEJOIN_MITER 0 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 64b362dbdde1..68a794a9ad7d 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -743,7 +743,7 @@ nsStyleSVG::nsStyleSVG(const Document& aDocument) mFillRule(StyleFillRule::Nonzero), mPaintOrder(0), mShapeRendering(StyleShapeRendering::Auto), - mStrokeLinecap(NS_STYLE_STROKE_LINECAP_BUTT), + mStrokeLinecap(StyleStrokeLinecap::Butt), mStrokeLinejoin(NS_STYLE_STROKE_LINEJOIN_MITER), mDominantBaseline(NS_STYLE_DOMINANT_BASELINE_AUTO), mTextAnchor(NS_STYLE_TEXT_ANCHOR_START), diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 5268e46513b2..21c278280ced 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2220,7 +2220,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG { mozilla::StyleFillRule mFillRule; mozilla::StyleSVGPaintOrder mPaintOrder; mozilla::StyleShapeRendering mShapeRendering; - uint8_t mStrokeLinecap; // NS_STYLE_STROKE_LINECAP_* + mozilla::StyleStrokeLinecap mStrokeLinecap; uint8_t mStrokeLinejoin; // NS_STYLE_STROKE_LINEJOIN_* uint8_t mDominantBaseline; // NS_STYLE_DOMINANT_BASELINE_* uint8_t mTextAnchor; // NS_STYLE_TEXT_ANCHOR_* diff --git a/layout/svg/nsCSSClipPathInstance.cpp b/layout/svg/nsCSSClipPathInstance.cpp index 465606a1b8a8..01e6e424b745 100644 --- a/layout/svg/nsCSSClipPathInstance.cpp +++ b/layout/svg/nsCSSClipPathInstance.cpp @@ -229,6 +229,6 @@ already_AddRefed nsCSSClipPathInstance::CreateClipPathPath( : FillRule::FILL_EVEN_ODD); float scale = float(AppUnitsPerCSSPixel()) / mTargetFrame->PresContext()->AppUnitsPerDevPixel(); - return SVGPathData::BuildPath(path.Path(), builder, - NS_STYLE_STROKE_LINECAP_BUTT, 0.0, scale); + return SVGPathData::BuildPath(path.Path(), builder, StyleStrokeLinecap::Butt, + 0.0, scale); } diff --git a/servo/components/style/properties/longhands/inherited_svg.mako.rs b/servo/components/style/properties/longhands/inherited_svg.mako.rs index 487456cbe124..4ad94b6fb63a 100644 --- a/servo/components/style/properties/longhands/inherited_svg.mako.rs +++ b/servo/components/style/properties/longhands/inherited_svg.mako.rs @@ -108,6 +108,7 @@ ${helpers.single_keyword( engines="gecko", animation_value_type="discrete", spec="https://www.w3.org/TR/SVG11/painting.html#StrokeLinecapProperty", + gecko_enum_prefix = "StyleStrokeLinecap", )} ${helpers.single_keyword(