1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
"use strict";
const DOMException = require("../generated/DOMException");
class SVGRectImplRecord {
constructor() {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
}
}
class SVGRectImplReflection {
constructor(privateData) {
this._reflectedElement = privateData.reflectedElement;
this._reflectedAttribute = privateData.reflectedAttribute;
this._parser = privateData.parser;
}
// https://svgwg.org/svg2-draft/types.html#TermReserialize
_reserialize({ x, y, width, height }) {
this._reflectedElement.setAttributeNS(null, this._reflectedAttribute, `${x} ${y} ${width} ${height}`);
}
get x() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).x;
}
set x(newX) {
const { y, width, height } = this;
this._reserialize({
x: newX,
y,
width,
height
});
}
get y() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).y;
}
set y(newY) {
const { x, width, height } = this;
this._reserialize({
x,
y: newY,
width,
height
});
}
get width() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).width;
}
set width(newWidth) {
const { x, y, height } = this;
this._reserialize({
x,
y,
width: newWidth,
height
});
}
get height() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).height;
}
set height(newHeight) {
const { x, y, width } = this;
this._reserialize({
x,
y,
width,
height: newHeight
});
}
}
class SVGRectImpl {
constructor(globalObject, args, { readOnly = false, ...privateData } = {}) {
this._globalObject = globalObject;
this._readOnly = readOnly;
if (privateData.reflectedElement) {
this._impl = new SVGRectImplReflection(privateData);
} else {
this._impl = new SVGRectImplRecord();
}
}
get x() {
return this._impl.x;
}
set x(newX) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.x = newX;
}
get y() {
return this._impl.y;
}
set y(newY) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.y = newY;
}
get width() {
return this._impl.width;
}
set width(newWidth) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.width = newWidth;
}
get height() {
return this._impl.height;
}
set height(newHeight) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.height = newHeight;
}
}
exports.implementation = SVGRectImpl;
|