Skip to content

Commit 67a8eaa

Browse files
saschanazsandersn
authored andcommitted
add SVG Text types (#758)
1 parent 288facf commit 67a8eaa

File tree

6 files changed

+108
-7
lines changed

6 files changed

+108
-7
lines changed

baselines/dom.generated.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@ interface CSSStyleDeclaration {
30623062
tableLayout: string;
30633063
textAlign: string;
30643064
textAlignLast: string;
3065-
textAnchor: string | null;
3065+
textAnchor: string;
30663066
textCombineUpright: string;
30673067
textDecoration: string;
30683068
textDecorationColor: string;
@@ -14694,13 +14694,13 @@ interface SVGTests {
1469414694
interface SVGTextContentElement extends SVGGraphicsElement {
1469514695
readonly lengthAdjust: SVGAnimatedEnumeration;
1469614696
readonly textLength: SVGAnimatedLength;
14697-
getCharNumAtPosition(point: SVGPoint): number;
14697+
getCharNumAtPosition(point?: DOMPointInit): number;
1469814698
getComputedTextLength(): number;
14699-
getEndPositionOfChar(charnum: number): SVGPoint;
14700-
getExtentOfChar(charnum: number): SVGRect;
14699+
getEndPositionOfChar(charnum: number): DOMPoint;
14700+
getExtentOfChar(charnum: number): DOMRect;
1470114701
getNumberOfChars(): number;
1470214702
getRotationOfChar(charnum: number): number;
14703-
getStartPositionOfChar(charnum: number): SVGPoint;
14703+
getStartPositionOfChar(charnum: number): DOMPoint;
1470414704
getSubStringLength(charnum: number, nchars: number): number;
1470514705
selectSubString(charnum: number, nchars: number): void;
1470614706
readonly LENGTHADJUST_SPACING: number;

inputfiles/addedTypes.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,30 @@
21492149
}
21502150
]
21512151
},
2152+
"SVGTextElement": {
2153+
"element": [
2154+
{
2155+
"namespace": "SVG",
2156+
"name": "text"
2157+
}
2158+
]
2159+
},
2160+
"SVGTextPathElement": {
2161+
"element": [
2162+
{
2163+
"namespace": "SVG",
2164+
"name": "textPath"
2165+
}
2166+
]
2167+
},
2168+
"SVGTSpanElement": {
2169+
"element": [
2170+
{
2171+
"namespace": "SVG",
2172+
"name": "tspan"
2173+
}
2174+
]
2175+
},
21522176
"MediaStream": {
21532177
"events": {
21542178
"event": [

inputfiles/idl/SVG - Text.widl

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[Exposed=Window]
2+
interface SVGTextContentElement : SVGGraphicsElement {
3+
4+
// lengthAdjust Types
5+
const unsigned short LENGTHADJUST_UNKNOWN = 0;
6+
const unsigned short LENGTHADJUST_SPACING = 1;
7+
const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2;
8+
9+
[SameObject] readonly attribute SVGAnimatedLength textLength;
10+
[SameObject] readonly attribute SVGAnimatedEnumeration lengthAdjust;
11+
12+
long getNumberOfChars();
13+
float getComputedTextLength();
14+
float getSubStringLength(unsigned long charnum, unsigned long nchars);
15+
DOMPoint getStartPositionOfChar(unsigned long charnum);
16+
DOMPoint getEndPositionOfChar(unsigned long charnum);
17+
DOMRect getExtentOfChar(unsigned long charnum);
18+
float getRotationOfChar(unsigned long charnum);
19+
long getCharNumAtPosition(optional DOMPointInit point);
20+
void selectSubString(unsigned long charnum, unsigned long nchars);
21+
};
22+
23+
[Exposed=Window]
24+
interface SVGTextPositioningElement : SVGTextContentElement {
25+
[SameObject] readonly attribute SVGAnimatedLengthList x;
26+
[SameObject] readonly attribute SVGAnimatedLengthList y;
27+
[SameObject] readonly attribute SVGAnimatedLengthList dx;
28+
[SameObject] readonly attribute SVGAnimatedLengthList dy;
29+
[SameObject] readonly attribute SVGAnimatedNumberList rotate;
30+
};
31+
32+
[Exposed=Window]
33+
interface SVGTextElement : SVGTextPositioningElement {
34+
};
35+
36+
[Exposed=Window]
37+
interface SVGTSpanElement : SVGTextPositioningElement {
38+
};
39+
40+
[Exposed=Window]
41+
interface SVGTextPathElement : SVGTextContentElement {
42+
43+
// textPath Method Types
44+
const unsigned short TEXTPATH_METHODTYPE_UNKNOWN = 0;
45+
const unsigned short TEXTPATH_METHODTYPE_ALIGN = 1;
46+
const unsigned short TEXTPATH_METHODTYPE_STRETCH = 2;
47+
48+
// textPath Spacing Types
49+
const unsigned short TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
50+
const unsigned short TEXTPATH_SPACINGTYPE_AUTO = 1;
51+
const unsigned short TEXTPATH_SPACINGTYPE_EXACT = 2;
52+
53+
[SameObject] readonly attribute SVGAnimatedLength startOffset;
54+
[SameObject] readonly attribute SVGAnimatedEnumeration method;
55+
[SameObject] readonly attribute SVGAnimatedEnumeration spacing;
56+
};
57+
58+
SVGTextPathElement includes SVGURIReference;
59+
60+
partial interface CSSStyleDeclaration {
61+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString inlineSize;
62+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString shapeInside;
63+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString shapeSubtract;
64+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString shapeMargin;
65+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString textAnchor;
66+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString textDecorationFill;
67+
[CEReactions] attribute [TreatNullAs=EmptyString] CSSOMString textDecorationStroke;
68+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@
419419
"url": "https://www.w3.org/TR/SVG2/painting.html",
420420
"title": "SVG - Painting"
421421
},
422+
{
423+
"url": "https://www.w3.org/TR/SVG2/text.html",
424+
"title": "SVG - Text"
425+
},
422426
{
423427
"url": "https://w3c.github.io/touch-events/",
424428
"title": "Touch Events"

inputfiles/removedTypes.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
"overflowInline": null,
132132
"paddingBlock": null,
133133
"paddingInline": null,
134+
"shapeInside": null,
135+
"shapeMargin": null,
136+
"shapeSubtract": null,
134137
"strokeAlign": null,
135138
"strokeBreak": null,
136139
"strokeColor": null,
@@ -141,7 +144,9 @@
141144
"strokePosition": null,
142145
"strokeRepeat": null,
143146
"strokeSize": null,
144-
"textAlignAll": null
147+
"textAlignAll": null,
148+
"textDecorationFill": null,
149+
"textDecorationStroke": null
145150
}
146151
}
147152
},

src/idlfetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const idlSelector = [
2121
].join(",");
2222

2323
const cssPropSelector = [
24-
".propdef dfn", // CSS Fonts
24+
".propdef dfn", // CSS Fonts, SVG
2525
"dfn.css[data-dfn-type=property]"
2626
].join(",");
2727

0 commit comments

Comments
 (0)