mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1597881 : convert NS_STYLE_STROKE_LINECAP_* to an enum class in nsStyleConsts.h r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D53908 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3c08b72ace
commit
aa897e8496
@ -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<gfx::Path> SVGContentUtils::GetPath(
|
||||
RefPtr<PathBuilder> 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) {
|
||||
|
@ -280,13 +280,13 @@ static void ApproximateZeroLengthSubpathSquareCaps(PathBuilder* aPB,
|
||||
} while (0)
|
||||
|
||||
already_AddRefed<Path> 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<Path> SVGPathData::BuildPathForMeasuring() const {
|
||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||
RefPtr<PathBuilder> 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<Path> SVGPathData::BuildPathForMeasuring() const {
|
||||
/* static */
|
||||
already_AddRefed<Path> SVGPathData::BuildPath(
|
||||
Span<const StylePathCommand> 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<Path> 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;
|
||||
|
||||
|
@ -163,7 +163,7 @@ class SVGPathData {
|
||||
already_AddRefed<Path> BuildPathForMeasuring() const;
|
||||
|
||||
already_AddRefed<Path> 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<Path> BuildPath(Span<const StylePathCommand> aPath,
|
||||
PathBuilder* aBuilder,
|
||||
uint8_t aStrokeLineCap,
|
||||
StyleStrokeLinecap aStrokeLineCap,
|
||||
Float aStrokeWidth,
|
||||
float aZoomFactor = 1.0);
|
||||
|
||||
|
@ -258,7 +258,7 @@ already_AddRefed<Path> 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<Path> 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);
|
||||
}
|
||||
|
@ -620,8 +620,8 @@ already_AddRefed<gfx::Path> MotionPathUtils::BuildPath(
|
||||
}
|
||||
|
||||
const Span<const StylePathCommand>& 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 */
|
||||
|
@ -125,6 +125,7 @@ rusty-enums = [
|
||||
"mozilla::StyleTextRendering",
|
||||
"mozilla::StyleColorAdjust",
|
||||
"mozilla::StyleFlexDirection",
|
||||
"mozilla::StyleStrokeLinecap",
|
||||
"mozilla::StyleFlexWrap",
|
||||
"mozilla::StyleTextDecorationSkipInk",
|
||||
"mozilla::StyleTextDecorationLength",
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -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_*
|
||||
|
@ -229,6 +229,6 @@ already_AddRefed<Path> 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);
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user