mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1667018 - minor improvements to path code r=emilio
- Use IsMoveto method where appropriate - Avoid referencing path in animation so we can move to supporting shapes later Differential Revision: https://phabricator.services.mozilla.com/D91242
This commit is contained in:
parent
b703d14d66
commit
213122103c
@ -211,16 +211,13 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromMpathElem(
|
||||
|
||||
// Use the path that's the target of our chosen <mpath> child.
|
||||
SVGPathElement* pathElem = aMpathElem->GetReferencedPath();
|
||||
if (pathElem) {
|
||||
const SVGPathData& path = pathElem->GetAnimPathSegList()->GetAnimValue();
|
||||
// Path data must contain of at least one path segment (if the path data
|
||||
// doesn't begin with a valid "M", then it's invalid).
|
||||
if (path.Length()) {
|
||||
bool ok =
|
||||
path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
|
||||
if (ok && mPathVertices.Length()) {
|
||||
mPath = pathElem->GetOrBuildPathForMeasuring();
|
||||
}
|
||||
// Path data must contain of at least one path segment (if the path data
|
||||
// doesn't begin with a valid "M", then it's invalid).
|
||||
if (pathElem && pathElem->HasValidDimensions()) {
|
||||
bool ok =
|
||||
pathElem->GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
|
||||
if (ok && mPathVertices.Length()) {
|
||||
mPath = pathElem->GetOrBuildPathForMeasuring();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +162,7 @@ bool SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(
|
||||
// this case an equal amount of time is spent on each path segment,
|
||||
// except on moveto segments which are jumped over immediately.
|
||||
|
||||
if (i == 0 ||
|
||||
(segType != PATHSEG_MOVETO_ABS && segType != PATHSEG_MOVETO_REL)) {
|
||||
if (i == 0 || !IsMoveto(segType)) {
|
||||
if (!aOutput->AppendElement(state.length, fallible)) {
|
||||
return false;
|
||||
}
|
||||
@ -480,8 +479,7 @@ already_AddRefed<Path> SVGPathData::BuildPath(PathBuilder* aBuilder,
|
||||
// seg anyway
|
||||
}
|
||||
|
||||
subpathContainsNonMoveTo =
|
||||
segType != PATHSEG_MOVETO_ABS && segType != PATHSEG_MOVETO_REL;
|
||||
subpathContainsNonMoveTo = !IsMoveto(segType);
|
||||
i += argCount;
|
||||
prevSegType = segType;
|
||||
segStart = segEnd;
|
||||
|
@ -55,6 +55,12 @@ class SVGPathElement final : public SVGPathElementBase {
|
||||
*/
|
||||
virtual already_AddRefed<Path> GetOrBuildPathForMeasuring() override;
|
||||
|
||||
bool GetDistancesFromOriginToEndsOfVisibleSegments(
|
||||
FallibleTArray<double>* aOutput) const {
|
||||
return mD.GetAnimValue().GetDistancesFromOriginToEndsOfVisibleSegments(
|
||||
aOutput);
|
||||
}
|
||||
|
||||
// nsIContent interface
|
||||
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user