Issue #1781 - Part 1: support calc() in stroke-dashoffset CSS

This adds basic calc() support to stroke-dashoffset. It does not provide
CSS animation (yet, todo for part 2)
This commit is contained in:
Moonchild 2021-06-12 01:12:39 +00:00 committed by roytam1
commit 15a322effa
3 changed files with 120 additions and 1 deletions

View file

@ -833,6 +833,14 @@ SVGContentUtils::CoordToFloat(nsSVGElement *aContent,
SVGSVGElement* ctx = aContent->GetCtx();
return ctx ? aCoord.GetPercentValue() * ctx->GetLength(SVGContentUtils::XY) : 0.0f;
}
case eStyleUnit_Calc: {
MOZ_ASSERT(aCoord.GetCalcValue(), "Invalid calc value");
nsStyleCoord::Calc* calc = aCoord.GetCalcValue();
SVGSVGElement* ctx = aContent->GetCtx();
float len = nsPresContext::AppUnitsToFloatCSSPixels(calc->mLength);
return ctx ? len + calc->mPercent * ctx->GetLength(SVGContentUtils::XY)
: len;
}
default:
return 0.0f;
}