Skip to content

Commit 5b92c85

Browse files
committed
svgom: introduce the SVGGraphicsElement and SVGGeometryElement interfaces
The interfaces do not have all their SVG2 methods, looking for compatibility with SVG 1.1.
1 parent 4b42aa1 commit 5b92c85

File tree

9 files changed

+99
-20
lines changed

9 files changed

+99
-20
lines changed

svgom-api/src/main/java/org/w3c/dom/svg/SVGCircleElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGCircleElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable,
18-
SVGTransformable, EventTarget {
17+
public interface SVGCircleElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget {
1919
SVGAnimatedLength getCx();
2020

2121
SVGAnimatedLength getCy();

svgom-api/src/main/java/org/w3c/dom/svg/SVGClipPathElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package org.w3c.dom.svg;
1414

15-
public interface SVGClipPathElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired,
16-
SVGStylable, SVGTransformable, SVGUnitTypes {
15+
public interface SVGClipPathElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
16+
SVGUnitTypes {
1717
SVGAnimatedEnumeration getClipPathUnits();
1818
}

svgom-api/src/main/java/org/w3c/dom/svg/SVGEllipseElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGEllipseElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired,
18-
SVGStylable, SVGTransformable, EventTarget {
17+
public interface SVGEllipseElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget {
1919
SVGAnimatedLength getCx();
2020

2121
SVGAnimatedLength getCy();
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright © 2023 W3C®.
3+
*
4+
* This software or document includes material copied from or derived from
5+
* https://svgwg.org/specs/animations/
6+
*
7+
* [1] https://www.w3.org/copyright/software-license-2023/
8+
*/
9+
10+
// SPDX-License-Identifier: W3C-20150513
11+
12+
package org.w3c.dom.svg;
13+
14+
/**
15+
* Represents SVG elements whose rendering is defined by geometry with an
16+
* equivalent path, and which can be filled and stroked.
17+
*/
18+
public interface SVGGeometryElement extends SVGGraphicsElement {
19+
20+
/**
21+
* Gets the read-only {@code pathLength} attribute, which is the author's
22+
* computation of the total length of the path, in user units.
23+
* <p>
24+
* The {@code pathLength} attribute has no effect on percentage
25+
* distance-along-a-path calculations.
26+
* </p>
27+
*
28+
* @return the total length of the path, in user units.
29+
*/
30+
SVGAnimatedNumber getPathLength();
31+
32+
/**
33+
* Get the length of the path.
34+
*
35+
* @return the length of the path, in user units.
36+
*/
37+
float getTotalLength();
38+
39+
/**
40+
* Gets the point at a given distance along the path.
41+
* <p>
42+
* When getPointAtLength(distance) is called, the following steps are run:
43+
* </p>
44+
* <ol>
45+
* <li>If current element is a non-rendered element, and the UA is not able to
46+
* compute the total length of the path, then throw an InvalidStateError.</li>
47+
* <li>Let length be the user agent's computed value for the total length of the
48+
* path, in user units.
49+
* <p>
50+
* As with getTotalLength, this does not take into account the
51+
* {@code pathLength} attribute.
52+
* </p>
53+
* </li>
54+
* <li>Clamp distance to [0, length].</li>
55+
* <li>Let (x, y) be the point on the path at distance distance.</li>
56+
* <li>Return a newly created, detached DOMPoint object representing the point
57+
* (x, y).</li>
58+
* </ol>
59+
* </p>
60+
*
61+
* @param distance the distance.
62+
* @return the point at a given distance along the path.
63+
*/
64+
SVGPoint getPointAtLength(float distance);
65+
66+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright © 2023 W3C®.
3+
*
4+
* This software or document includes material copied from or derived from
5+
* https://svgwg.org/specs/animations/
6+
*
7+
* [1] https://www.w3.org/copyright/software-license-2023/
8+
*/
9+
10+
// SPDX-License-Identifier: W3C-20150513
11+
12+
package org.w3c.dom.svg;
13+
14+
/**
15+
* Represents SVG elements whose primary purpose is to directly render graphics
16+
* into a group.
17+
*/
18+
public interface SVGGraphicsElement extends SVGElement, SVGStylable, SVGTests, SVGTransformable {
19+
}

svgom-api/src/main/java/org/w3c/dom/svg/SVGLineElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGLineElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable,
18-
SVGTransformable, EventTarget {
17+
public interface SVGLineElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget {
1919
SVGAnimatedLength getX1();
2020

2121
SVGAnimatedLength getY1();

svgom-api/src/main/java/org/w3c/dom/svg/SVGPathElement.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGPathElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable,
18-
SVGTransformable, EventTarget, SVGAnimatedPathData {
19-
SVGAnimatedNumber getPathLength();
20-
21-
float getTotalLength();
22-
23-
SVGPoint getPointAtLength(float distance);
24-
17+
public interface SVGPathElement extends SVGGeometryElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget, SVGAnimatedPathData {
2519
int getPathSegAtLength(float distance);
2620

2721
SVGPathSegClosePath createSVGPathSegClosePath();

svgom-api/src/main/java/org/w3c/dom/svg/SVGPolygonElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGPolygonElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired,
18-
SVGStylable, SVGTransformable, EventTarget, SVGAnimatedPoints {
17+
public interface SVGPolygonElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget, SVGAnimatedPoints {
1919
}

svgom-api/src/main/java/org/w3c/dom/svg/SVGRectElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import org.w3c.dom.events.EventTarget;
1616

17-
public interface SVGRectElement extends SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable,
18-
SVGTransformable, EventTarget {
17+
public interface SVGRectElement extends SVGGraphicsElement, SVGLangSpace, SVGExternalResourcesRequired,
18+
EventTarget {
1919
SVGAnimatedLength getX();
2020

2121
SVGAnimatedLength getY();

0 commit comments

Comments
 (0)