Bug 1906310 - Some some dead SVGPath code. r=longsonr

And do some minor clean-up while at it.

Differential Revision: https://phabricator.services.mozilla.com/D215789
This commit is contained in:
Emilio Cobos Álvarez 2024-07-04 16:59:22 +00:00
Родитель 956f21594f
Коммит 8da9ffec8f
3 изменённых файлов: 5 добавлений и 44 удалений

Просмотреть файл

@ -38,14 +38,6 @@ void SVGPathData::GetValueAsString(nsACString& aValue) const {
Servo_SVGPathData_ToString(&mData, &aValue);
}
float SVGPathData::GetPathLength() const {
SVGPathTraversalState state;
for (const auto& segment : AsSpan()) {
SVGPathSegUtils::TraversePathSegment(segment, state);
}
return state.length;
}
bool SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(
FallibleTArray<double>* aOutput) const {
return GetDistancesFromOriginToEndsOfVisibleSegments(AsSpan(), aOutput);
@ -80,27 +72,6 @@ bool SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(
return true;
}
/* static */
uint32_t SVGPathData::GetPathSegAtLength(Span<const StylePathCommand> aPath,
float aDistance) {
// TODO [SVGWG issue] get specified what happen if 'aDistance' < 0, or
// 'aDistance' > the length of the path, or the seg list is empty.
// Return -1? Throwing would better help authors avoid tricky bugs (DOM
// could do that if we return -1).
uint32_t segIndex = 0;
SVGPathTraversalState state;
for (const auto& cmd : aPath) {
SVGPathSegUtils::TraversePathSegment(cmd, state);
if (state.length >= aDistance) {
return segIndex;
}
segIndex++;
}
return std::max(1U, segIndex) - 1;
}
/**
* The SVG spec says we have to paint stroke caps for zero length subpaths:
*

Просмотреть файл

@ -112,13 +112,6 @@ class SVGPathData {
StyleSVGPathData& RawData() { return mData; }
const StyleSVGPathData& RawData() const { return mData; }
float GetPathLength() const;
uint32_t GetPathSegAtLength(float aDistance) const;
static uint32_t GetPathSegAtLength(Span<const StylePathCommand> aPath,
float aDistance);
void GetMarkerPositioningData(float aZoom, nsTArray<SVGMark>* aMarks) const;
static void GetMarkerPositioningData(Span<const StylePathCommand> aPath,

Просмотреть файл

@ -7,15 +7,14 @@
#ifndef DOM_SVG_SVGPATHSEGUTILS_H_
#define DOM_SVG_SVGPATHSEGUTILS_H_
#include "mozilla/ArrayUtils.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/Span.h"
#include "nsStringFwd.h"
namespace mozilla {
template <typename Angle, typename LP>
struct StyleGenericShapeCommand;
using StylePathCommand = StyleGenericShapeCommand<float, float>;
/**
* Code that works with path segments can use an instance of this class to
@ -76,9 +75,8 @@ class SVGPathSegUtils {
* Traverse the given path segment and update the SVGPathTraversalState
* object. This is identical to the above one but accepts StylePathCommand.
*/
static void TraversePathSegment(
const StyleGenericShapeCommand<float, float>& aCommand,
SVGPathTraversalState& aState);
static void TraversePathSegment(const StylePathCommand&,
SVGPathTraversalState&);
};
/// Detect whether the path represents a rectangle (for both filling AND
@ -86,15 +84,14 @@ class SVGPathSegUtils {
///
/// This is typically useful for google slides which has many of these rectangle
/// shaped paths. It handles the same scenarios as skia's
/// SkPathPriv::IsRectContour which it is inspried from, including zero-length
/// SkPathPriv::IsRectContour which it is inspired from, including zero-length
/// edges and multiple points on edges of the rectangle, and doesn't attempt to
/// detect flat curves (that could easily be added but the expectation is that
/// since skia doesn't fast path it we're not likely to run into it in
/// practice).
///
/// We could implement something similar for polygons.
Maybe<gfx::Rect> SVGPathToAxisAlignedRect(
Span<const StyleGenericShapeCommand<float, float>> aPath);
Maybe<gfx::Rect> SVGPathToAxisAlignedRect(Span<const StylePathCommand>);
} // namespace mozilla