@antv/g-lite 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/CSSProperty.d.ts +1 -1
- package/dist/css/CSSProperty.d.ts.map +1 -1
- package/dist/css/CSSStyleValuePool.d.ts +2 -5
- package/dist/css/CSSStyleValuePool.d.ts.map +1 -1
- package/dist/css/StyleValueRegistry.d.ts +1 -1
- package/dist/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/css/cssom/CSSNumericValue.d.ts +5 -185
- package/dist/css/cssom/CSSNumericValue.d.ts.map +1 -1
- package/dist/css/parser/dimension.d.ts +1 -4
- package/dist/css/parser/dimension.d.ts.map +1 -1
- package/dist/css/parser/transform-origin.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -7
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyLocalPosition.d.ts +1 -1
- package/dist/css/properties/CSSPropertyLocalPosition.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/display-objects/HTML.d.ts.map +1 -1
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/global-runtime.d.ts +1 -0
- package/dist/global-runtime.d.ts.map +1 -1
- package/dist/index.esm.js +835 -1727
- package/dist/index.js +883 -1775
- package/dist/index.umd.js +791 -1719
- package/dist/index.umd.min.js +1 -1
- package/dist/plugins/FrustumCullingStrategy.d.ts.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/dist/services/OffscreenCanvasCreator.d.ts +2 -2
- package/dist/services/OffscreenCanvasCreator.d.ts.map +1 -1
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/shapes/AABB.d.ts +12 -13
- package/dist/shapes/AABB.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/math.d.ts +7 -0
- package/dist/utils/math.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import RBush from 'rbush/rbush.js';
|
|
2
2
|
export { default as RBush } from 'rbush/rbush.js';
|
|
3
3
|
import { isString, isNil, isObject, clamp, isNumber, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isBoolean, isUndefined, getPointAtLength, distanceSquareRoot, getTotalLength, min, max, isNumberEqual, mod } from '@antv/util';
|
|
4
|
-
import { vec3, quat as quat$1, mat4, vec2, mat3, vec4 } from 'gl-matrix';
|
|
5
4
|
import { color } from 'd3-color';
|
|
6
5
|
import { Polyline as Polyline$1, Line as Line$1, Arc, Cubic, Quad } from '@antv/g-math';
|
|
6
|
+
import { mat4, vec3, quat as quat$1, mat3, vec4, vec2 } from 'gl-matrix';
|
|
7
7
|
import EventEmitter from 'eventemitter3';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -73,383 +73,6 @@ var PropertySyntax;
|
|
|
73
73
|
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
74
74
|
})(PropertySyntax || (PropertySyntax = {}));
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Axis-Aligned Bounding Box
|
|
78
|
-
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
79
|
-
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
80
|
-
*/
|
|
81
|
-
var AABB = /*#__PURE__*/function () {
|
|
82
|
-
AABB.isEmpty = function isEmpty(aabb) {
|
|
83
|
-
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
84
|
-
};
|
|
85
|
-
function AABB(center, halfExtents) {
|
|
86
|
-
if (center === void 0) {
|
|
87
|
-
center = [0, 0, 0];
|
|
88
|
-
}
|
|
89
|
-
if (halfExtents === void 0) {
|
|
90
|
-
halfExtents = [0, 0, 0];
|
|
91
|
-
}
|
|
92
|
-
this.center = vec3.create();
|
|
93
|
-
this.halfExtents = vec3.create();
|
|
94
|
-
this.min = vec3.create();
|
|
95
|
-
this.max = vec3.create();
|
|
96
|
-
this.update(center, halfExtents);
|
|
97
|
-
}
|
|
98
|
-
var _proto = AABB.prototype;
|
|
99
|
-
_proto.update = function update(center, halfExtents) {
|
|
100
|
-
vec3.copy(this.center, center);
|
|
101
|
-
vec3.copy(this.halfExtents, halfExtents);
|
|
102
|
-
vec3.sub(this.min, this.center, this.halfExtents);
|
|
103
|
-
vec3.add(this.max, this.center, this.halfExtents);
|
|
104
|
-
};
|
|
105
|
-
_proto.setMinMax = function setMinMax(min, max) {
|
|
106
|
-
vec3.add(this.center, max, min);
|
|
107
|
-
vec3.scale(this.center, this.center, 0.5);
|
|
108
|
-
vec3.sub(this.halfExtents, max, min);
|
|
109
|
-
vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
110
|
-
vec3.copy(this.min, min);
|
|
111
|
-
vec3.copy(this.max, max);
|
|
112
|
-
};
|
|
113
|
-
_proto.getMin = function getMin() {
|
|
114
|
-
return this.min;
|
|
115
|
-
};
|
|
116
|
-
_proto.getMax = function getMax() {
|
|
117
|
-
return this.max;
|
|
118
|
-
};
|
|
119
|
-
_proto.add = function add(aabb) {
|
|
120
|
-
if (AABB.isEmpty(aabb)) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (AABB.isEmpty(this)) {
|
|
124
|
-
this.setMinMax(aabb.getMin(), aabb.getMax());
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
var tc = this.center;
|
|
128
|
-
var tcx = tc[0];
|
|
129
|
-
var tcy = tc[1];
|
|
130
|
-
var tcz = tc[2];
|
|
131
|
-
var th = this.halfExtents;
|
|
132
|
-
var thx = th[0];
|
|
133
|
-
var thy = th[1];
|
|
134
|
-
var thz = th[2];
|
|
135
|
-
var tminx = tcx - thx;
|
|
136
|
-
var tmaxx = tcx + thx;
|
|
137
|
-
var tminy = tcy - thy;
|
|
138
|
-
var tmaxy = tcy + thy;
|
|
139
|
-
var tminz = tcz - thz;
|
|
140
|
-
var tmaxz = tcz + thz;
|
|
141
|
-
var oc = aabb.center;
|
|
142
|
-
var ocx = oc[0];
|
|
143
|
-
var ocy = oc[1];
|
|
144
|
-
var ocz = oc[2];
|
|
145
|
-
var oh = aabb.halfExtents;
|
|
146
|
-
var ohx = oh[0];
|
|
147
|
-
var ohy = oh[1];
|
|
148
|
-
var ohz = oh[2];
|
|
149
|
-
var ominx = ocx - ohx;
|
|
150
|
-
var omaxx = ocx + ohx;
|
|
151
|
-
var ominy = ocy - ohy;
|
|
152
|
-
var omaxy = ocy + ohy;
|
|
153
|
-
var ominz = ocz - ohz;
|
|
154
|
-
var omaxz = ocz + ohz;
|
|
155
|
-
if (ominx < tminx) {
|
|
156
|
-
tminx = ominx;
|
|
157
|
-
}
|
|
158
|
-
if (omaxx > tmaxx) {
|
|
159
|
-
tmaxx = omaxx;
|
|
160
|
-
}
|
|
161
|
-
if (ominy < tminy) {
|
|
162
|
-
tminy = ominy;
|
|
163
|
-
}
|
|
164
|
-
if (omaxy > tmaxy) {
|
|
165
|
-
tmaxy = omaxy;
|
|
166
|
-
}
|
|
167
|
-
if (ominz < tminz) {
|
|
168
|
-
tminz = ominz;
|
|
169
|
-
}
|
|
170
|
-
if (omaxz > tmaxz) {
|
|
171
|
-
tmaxz = omaxz;
|
|
172
|
-
}
|
|
173
|
-
tc[0] = (tminx + tmaxx) * 0.5;
|
|
174
|
-
tc[1] = (tminy + tmaxy) * 0.5;
|
|
175
|
-
tc[2] = (tminz + tmaxz) * 0.5;
|
|
176
|
-
th[0] = (tmaxx - tminx) * 0.5;
|
|
177
|
-
th[1] = (tmaxy - tminy) * 0.5;
|
|
178
|
-
th[2] = (tmaxz - tminz) * 0.5;
|
|
179
|
-
this.min[0] = tminx;
|
|
180
|
-
this.min[1] = tminy;
|
|
181
|
-
this.min[2] = tminz;
|
|
182
|
-
this.max[0] = tmaxx;
|
|
183
|
-
this.max[1] = tmaxy;
|
|
184
|
-
this.max[2] = tmaxz;
|
|
185
|
-
};
|
|
186
|
-
_proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
|
|
187
|
-
var bc = this.center;
|
|
188
|
-
var br = this.halfExtents;
|
|
189
|
-
var ac = aabb.center;
|
|
190
|
-
var ar = aabb.halfExtents;
|
|
191
|
-
var mx0 = m[0];
|
|
192
|
-
var mx1 = m[4];
|
|
193
|
-
var mx2 = m[8];
|
|
194
|
-
var my0 = m[1];
|
|
195
|
-
var my1 = m[5];
|
|
196
|
-
var my2 = m[9];
|
|
197
|
-
var mz0 = m[2];
|
|
198
|
-
var mz1 = m[6];
|
|
199
|
-
var mz2 = m[10];
|
|
200
|
-
var mx0a = Math.abs(mx0);
|
|
201
|
-
var mx1a = Math.abs(mx1);
|
|
202
|
-
var mx2a = Math.abs(mx2);
|
|
203
|
-
var my0a = Math.abs(my0);
|
|
204
|
-
var my1a = Math.abs(my1);
|
|
205
|
-
var my2a = Math.abs(my2);
|
|
206
|
-
var mz0a = Math.abs(mz0);
|
|
207
|
-
var mz1a = Math.abs(mz1);
|
|
208
|
-
var mz2a = Math.abs(mz2);
|
|
209
|
-
vec3.set(bc, m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2], m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2], m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2]);
|
|
210
|
-
vec3.set(br, mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2], my0a * ar[0] + my1a * ar[1] + my2a * ar[2], mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2]);
|
|
211
|
-
this.min = vec3.sub(this.min, bc, br);
|
|
212
|
-
this.max = vec3.add(this.max, bc, br);
|
|
213
|
-
};
|
|
214
|
-
_proto.intersects = function intersects(aabb) {
|
|
215
|
-
var aMax = this.getMax();
|
|
216
|
-
var aMin = this.getMin();
|
|
217
|
-
var bMax = aabb.getMax();
|
|
218
|
-
var bMin = aabb.getMin();
|
|
219
|
-
return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
|
|
220
|
-
};
|
|
221
|
-
_proto.intersection = function intersection(aabb) {
|
|
222
|
-
if (!this.intersects(aabb)) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
var intersection = new AABB();
|
|
226
|
-
var min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
227
|
-
var max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
228
|
-
intersection.setMinMax(min, max);
|
|
229
|
-
return intersection;
|
|
230
|
-
};
|
|
231
|
-
_proto.containsPoint = function containsPoint(point) {
|
|
232
|
-
var min = this.getMin();
|
|
233
|
-
var max = this.getMax();
|
|
234
|
-
return !(point[0] < min[0] || point[0] > max[0] || point[1] < min[1] || point[1] > max[1] || point[2] < min[2] || point[2] > max[2]);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* get n-vertex
|
|
238
|
-
* @param plane plane of CullingVolume
|
|
239
|
-
*/;
|
|
240
|
-
_proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
|
|
241
|
-
if (plane.pnVertexFlag === 0x111) {
|
|
242
|
-
return vec3.copy(vec3.create(), this.min);
|
|
243
|
-
} else if (plane.pnVertexFlag === 0x110) {
|
|
244
|
-
return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
245
|
-
} else if (plane.pnVertexFlag === 0x101) {
|
|
246
|
-
return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
247
|
-
} else if (plane.pnVertexFlag === 0x100) {
|
|
248
|
-
return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
249
|
-
} else if (plane.pnVertexFlag === 0x011) {
|
|
250
|
-
return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
251
|
-
} else if (plane.pnVertexFlag === 0x010) {
|
|
252
|
-
return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
253
|
-
} else if (plane.pnVertexFlag === 0x001) {
|
|
254
|
-
return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
255
|
-
} else {
|
|
256
|
-
return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* get p-vertex
|
|
261
|
-
* @param plane plane of CullingVolume
|
|
262
|
-
*/;
|
|
263
|
-
_proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
|
|
264
|
-
if (plane.pnVertexFlag === 0x111) {
|
|
265
|
-
return vec3.copy(vec3.create(), this.max);
|
|
266
|
-
} else if (plane.pnVertexFlag === 0x110) {
|
|
267
|
-
return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
268
|
-
} else if (plane.pnVertexFlag === 0x101) {
|
|
269
|
-
return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
270
|
-
} else if (plane.pnVertexFlag === 0x100) {
|
|
271
|
-
return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
272
|
-
} else if (plane.pnVertexFlag === 0x011) {
|
|
273
|
-
return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
274
|
-
} else if (plane.pnVertexFlag === 0x010) {
|
|
275
|
-
return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
276
|
-
} else if (plane.pnVertexFlag === 0x001) {
|
|
277
|
-
return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
278
|
-
} else {
|
|
279
|
-
return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
return AABB;
|
|
283
|
-
}();
|
|
284
|
-
|
|
285
|
-
var Plane = /*#__PURE__*/function () {
|
|
286
|
-
/**
|
|
287
|
-
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
288
|
-
*/
|
|
289
|
-
|
|
290
|
-
function Plane(distance, normal) {
|
|
291
|
-
this.distance = void 0;
|
|
292
|
-
this.normal = void 0;
|
|
293
|
-
this.pnVertexFlag = void 0;
|
|
294
|
-
this.distance = distance || 0;
|
|
295
|
-
this.normal = normal || vec3.fromValues(0, 1, 0);
|
|
296
|
-
this.updatePNVertexFlag();
|
|
297
|
-
}
|
|
298
|
-
var _proto = Plane.prototype;
|
|
299
|
-
_proto.updatePNVertexFlag = function updatePNVertexFlag() {
|
|
300
|
-
this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
|
|
301
|
-
};
|
|
302
|
-
_proto.distanceToPoint = function distanceToPoint(point) {
|
|
303
|
-
return vec3.dot(point, this.normal) - this.distance;
|
|
304
|
-
};
|
|
305
|
-
_proto.normalize = function normalize() {
|
|
306
|
-
var invLen = 1 / vec3.len(this.normal);
|
|
307
|
-
vec3.scale(this.normal, this.normal, invLen);
|
|
308
|
-
this.distance *= invLen;
|
|
309
|
-
};
|
|
310
|
-
_proto.intersectsLine = function intersectsLine(start, end, point) {
|
|
311
|
-
var d0 = this.distanceToPoint(start);
|
|
312
|
-
var d1 = this.distanceToPoint(end);
|
|
313
|
-
var t = d0 / (d0 - d1);
|
|
314
|
-
var intersects = t >= 0 && t <= 1;
|
|
315
|
-
if (intersects && point) {
|
|
316
|
-
vec3.lerp(point, start, end, t);
|
|
317
|
-
}
|
|
318
|
-
return intersects;
|
|
319
|
-
};
|
|
320
|
-
return Plane;
|
|
321
|
-
}();
|
|
322
|
-
|
|
323
|
-
var Mask;
|
|
324
|
-
(function (Mask) {
|
|
325
|
-
Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
|
|
326
|
-
Mask[Mask["INSIDE"] = 0] = "INSIDE";
|
|
327
|
-
Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
|
|
328
|
-
})(Mask || (Mask = {}));
|
|
329
|
-
var Frustum = /*#__PURE__*/function () {
|
|
330
|
-
function Frustum(planes) {
|
|
331
|
-
this.planes = [];
|
|
332
|
-
if (planes) {
|
|
333
|
-
this.planes = planes;
|
|
334
|
-
} else {
|
|
335
|
-
for (var i = 0; i < 6; i++) {
|
|
336
|
-
this.planes.push(new Plane());
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* extract 6 planes from projectionMatrix
|
|
342
|
-
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
343
|
-
*/
|
|
344
|
-
var _proto = Frustum.prototype;
|
|
345
|
-
_proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
|
|
346
|
-
// @ts-ignore
|
|
347
|
-
var m0 = projectionMatrix[0],
|
|
348
|
-
m1 = projectionMatrix[1],
|
|
349
|
-
m2 = projectionMatrix[2],
|
|
350
|
-
m3 = projectionMatrix[3],
|
|
351
|
-
m4 = projectionMatrix[4],
|
|
352
|
-
m5 = projectionMatrix[5],
|
|
353
|
-
m6 = projectionMatrix[6],
|
|
354
|
-
m7 = projectionMatrix[7],
|
|
355
|
-
m8 = projectionMatrix[8],
|
|
356
|
-
m9 = projectionMatrix[9],
|
|
357
|
-
m10 = projectionMatrix[10],
|
|
358
|
-
m11 = projectionMatrix[11],
|
|
359
|
-
m12 = projectionMatrix[12],
|
|
360
|
-
m13 = projectionMatrix[13],
|
|
361
|
-
m14 = projectionMatrix[14],
|
|
362
|
-
m15 = projectionMatrix[15];
|
|
363
|
-
// right
|
|
364
|
-
vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
|
|
365
|
-
this.planes[0].distance = m15 - m12;
|
|
366
|
-
// left
|
|
367
|
-
vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
|
|
368
|
-
this.planes[1].distance = m15 + m12;
|
|
369
|
-
// bottom
|
|
370
|
-
vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
|
|
371
|
-
this.planes[2].distance = m15 + m13;
|
|
372
|
-
// top
|
|
373
|
-
vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
|
|
374
|
-
this.planes[3].distance = m15 - m13;
|
|
375
|
-
// far
|
|
376
|
-
vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
|
|
377
|
-
this.planes[4].distance = m15 - m14;
|
|
378
|
-
// near
|
|
379
|
-
vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
|
|
380
|
-
this.planes[5].distance = m15 + m14;
|
|
381
|
-
this.planes.forEach(function (plane) {
|
|
382
|
-
plane.normalize();
|
|
383
|
-
plane.updatePNVertexFlag();
|
|
384
|
-
});
|
|
385
|
-
};
|
|
386
|
-
return Frustum;
|
|
387
|
-
}();
|
|
388
|
-
|
|
389
|
-
var Point = /*#__PURE__*/function () {
|
|
390
|
-
function Point(x, y) {
|
|
391
|
-
if (x === void 0) {
|
|
392
|
-
x = 0;
|
|
393
|
-
}
|
|
394
|
-
if (y === void 0) {
|
|
395
|
-
y = 0;
|
|
396
|
-
}
|
|
397
|
-
this.x = 0;
|
|
398
|
-
this.y = 0;
|
|
399
|
-
this.x = x;
|
|
400
|
-
this.y = y;
|
|
401
|
-
}
|
|
402
|
-
var _proto = Point.prototype;
|
|
403
|
-
_proto.clone = function clone() {
|
|
404
|
-
return new Point(this.x, this.y);
|
|
405
|
-
};
|
|
406
|
-
_proto.copyFrom = function copyFrom(p) {
|
|
407
|
-
this.x = p.x;
|
|
408
|
-
this.y = p.y;
|
|
409
|
-
};
|
|
410
|
-
return Point;
|
|
411
|
-
}();
|
|
412
|
-
|
|
413
|
-
var Rectangle = /*#__PURE__*/function () {
|
|
414
|
-
function Rectangle(x, y, width, height) {
|
|
415
|
-
this.x = void 0;
|
|
416
|
-
this.y = void 0;
|
|
417
|
-
this.width = void 0;
|
|
418
|
-
this.height = void 0;
|
|
419
|
-
this.left = void 0;
|
|
420
|
-
this.right = void 0;
|
|
421
|
-
this.top = void 0;
|
|
422
|
-
this.bottom = void 0;
|
|
423
|
-
this.x = x;
|
|
424
|
-
this.y = y;
|
|
425
|
-
this.width = width;
|
|
426
|
-
this.height = height;
|
|
427
|
-
this.left = x;
|
|
428
|
-
this.right = x + width;
|
|
429
|
-
this.top = y;
|
|
430
|
-
this.bottom = y + height;
|
|
431
|
-
}
|
|
432
|
-
var _proto = Rectangle.prototype;
|
|
433
|
-
_proto.toJSON = function toJSON() {};
|
|
434
|
-
return Rectangle;
|
|
435
|
-
}();
|
|
436
|
-
|
|
437
|
-
var Shape;
|
|
438
|
-
(function (Shape) {
|
|
439
|
-
Shape["GROUP"] = "g";
|
|
440
|
-
Shape["CIRCLE"] = "circle";
|
|
441
|
-
Shape["ELLIPSE"] = "ellipse";
|
|
442
|
-
Shape["IMAGE"] = "image";
|
|
443
|
-
Shape["RECT"] = "rect";
|
|
444
|
-
Shape["LINE"] = "line";
|
|
445
|
-
Shape["POLYLINE"] = "polyline";
|
|
446
|
-
Shape["POLYGON"] = "polygon";
|
|
447
|
-
Shape["TEXT"] = "text";
|
|
448
|
-
Shape["PATH"] = "path";
|
|
449
|
-
Shape["HTML"] = "html";
|
|
450
|
-
Shape["MESH"] = "mesh";
|
|
451
|
-
})(Shape || (Shape = {}));
|
|
452
|
-
|
|
453
76
|
function memoize(func, resolver) {
|
|
454
77
|
if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
|
|
455
78
|
throw new TypeError('Expected a function');
|
|
@@ -486,16 +109,6 @@ function DCHECK(bool) {
|
|
|
486
109
|
throw new Error();
|
|
487
110
|
}
|
|
488
111
|
}
|
|
489
|
-
function DCHECK_EQ(a, b) {
|
|
490
|
-
if (a !== b) {
|
|
491
|
-
throw new Error();
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
function DCHECK_NE(a, b) {
|
|
495
|
-
if (a === b) {
|
|
496
|
-
throw new Error();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
112
|
function isFunction(func) {
|
|
500
113
|
return typeof func === 'function';
|
|
501
114
|
}
|
|
@@ -1663,646 +1276,103 @@ var CSSColorValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
|
1663
1276
|
_this.colorSpace = colorSpace;
|
|
1664
1277
|
return _this;
|
|
1665
1278
|
}
|
|
1666
|
-
var _proto = CSSColorValue.prototype;
|
|
1667
|
-
_proto.getType = function getType() {
|
|
1668
|
-
return CSSStyleValueType.kColorType;
|
|
1669
|
-
}
|
|
1670
|
-
// buildCSSText(n: Nested, p: ParenLess, result: string): string {
|
|
1671
|
-
// let text = '';
|
|
1672
|
-
// if (this.colorSpace === 'rgb') {
|
|
1673
|
-
// text = `rgba(${this.channels.join(',')},${this.alpha})`;
|
|
1674
|
-
// }
|
|
1675
|
-
// return (result += text);
|
|
1676
|
-
// }
|
|
1677
|
-
/**
|
|
1678
|
-
* @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
|
|
1679
|
-
*/;
|
|
1680
|
-
_proto.to = function to(colorSpace) {
|
|
1681
|
-
return this;
|
|
1682
|
-
};
|
|
1683
|
-
return CSSColorValue;
|
|
1684
|
-
}(CSSStyleValue);
|
|
1685
|
-
|
|
1686
|
-
var GradientType;
|
|
1687
|
-
(function (GradientType) {
|
|
1688
|
-
GradientType[GradientType["Constant"] = 0] = "Constant";
|
|
1689
|
-
GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient";
|
|
1690
|
-
GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient";
|
|
1691
|
-
})(GradientType || (GradientType = {}));
|
|
1692
|
-
var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1693
|
-
_inheritsLoose(CSSGradientValue, _CSSStyleValue);
|
|
1694
|
-
function CSSGradientValue(type, value) {
|
|
1695
|
-
var _this;
|
|
1696
|
-
_this = _CSSStyleValue.call(this) || this;
|
|
1697
|
-
_this.type = void 0;
|
|
1698
|
-
_this.value = void 0;
|
|
1699
|
-
_this.type = type;
|
|
1700
|
-
_this.value = value;
|
|
1701
|
-
return _this;
|
|
1702
|
-
}
|
|
1703
|
-
var _proto = CSSGradientValue.prototype;
|
|
1704
|
-
_proto.clone = function clone() {
|
|
1705
|
-
return new CSSGradientValue(this.type, this.value);
|
|
1706
|
-
};
|
|
1707
|
-
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
1708
|
-
return result;
|
|
1709
|
-
};
|
|
1710
|
-
_proto.getType = function getType() {
|
|
1711
|
-
return CSSStyleValueType.kColorType;
|
|
1712
|
-
};
|
|
1713
|
-
return CSSGradientValue;
|
|
1714
|
-
}(CSSStyleValue);
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* CSSKeywordValue represents CSS Values that are specified as keywords
|
|
1718
|
-
* eg. 'initial'
|
|
1719
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
|
|
1720
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
|
|
1721
|
-
*/
|
|
1722
|
-
var CSSKeywordValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1723
|
-
_inheritsLoose(CSSKeywordValue, _CSSStyleValue);
|
|
1724
|
-
function CSSKeywordValue(value) {
|
|
1725
|
-
var _this;
|
|
1726
|
-
_this = _CSSStyleValue.call(this) || this;
|
|
1727
|
-
_this.value = void 0;
|
|
1728
|
-
_this.value = value;
|
|
1729
|
-
return _this;
|
|
1730
|
-
}
|
|
1731
|
-
var _proto = CSSKeywordValue.prototype;
|
|
1732
|
-
_proto.clone = function clone() {
|
|
1733
|
-
return new CSSKeywordValue(this.value);
|
|
1734
|
-
};
|
|
1735
|
-
_proto.getType = function getType() {
|
|
1736
|
-
return CSSStyleValueType.kKeywordType;
|
|
1737
|
-
};
|
|
1738
|
-
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
1739
|
-
return result + this.value;
|
|
1740
|
-
};
|
|
1741
|
-
return CSSKeywordValue;
|
|
1742
|
-
}(CSSStyleValue);
|
|
1743
|
-
|
|
1744
|
-
var CSSMathOperator;
|
|
1745
|
-
(function (CSSMathOperator) {
|
|
1746
|
-
CSSMathOperator["kAdd"] = "+";
|
|
1747
|
-
CSSMathOperator["kSubtract"] = "-";
|
|
1748
|
-
CSSMathOperator["kMultiply"] = "*";
|
|
1749
|
-
CSSMathOperator["kDivide"] = "/";
|
|
1750
|
-
CSSMathOperator["kMin"] = "min";
|
|
1751
|
-
CSSMathOperator["kMax"] = "max";
|
|
1752
|
-
CSSMathOperator["kClamp"] = "clamp";
|
|
1753
|
-
CSSMathOperator["kInvalid"] = "";
|
|
1754
|
-
})(CSSMathOperator || (CSSMathOperator = {}));
|
|
1755
|
-
|
|
1756
|
-
// https://drafts.css-houdini.org/css-typed-om/#enumdef-cssnumericbasetype
|
|
1757
|
-
var BaseType;
|
|
1758
|
-
(function (BaseType) {
|
|
1759
|
-
BaseType[BaseType["kLength"] = 0] = "kLength";
|
|
1760
|
-
BaseType[BaseType["kAngle"] = 1] = "kAngle";
|
|
1761
|
-
BaseType[BaseType["kTime"] = 2] = "kTime";
|
|
1762
|
-
BaseType[BaseType["kFrequency"] = 3] = "kFrequency";
|
|
1763
|
-
BaseType[BaseType["kResolution"] = 4] = "kResolution";
|
|
1764
|
-
BaseType[BaseType["kFlex"] = 5] = "kFlex";
|
|
1765
|
-
BaseType[BaseType["kPercent"] = 6] = "kPercent";
|
|
1766
|
-
BaseType[BaseType["kNumBaseTypes"] = 7] = "kNumBaseTypes";
|
|
1767
|
-
})(BaseType || (BaseType = {}));
|
|
1768
|
-
function unitTypeToBaseType(unit) {
|
|
1769
|
-
DCHECK_NE(unit, UnitType.kNumber);
|
|
1770
|
-
switch (unit) {
|
|
1771
|
-
case UnitType.kEms:
|
|
1772
|
-
// case UnitType.kExs:
|
|
1773
|
-
case UnitType.kPixels:
|
|
1774
|
-
// case UnitType.kCentimeters:
|
|
1775
|
-
// case UnitType.kMillimeters:
|
|
1776
|
-
// case UnitType.kQuarterMillimeters:
|
|
1777
|
-
// case UnitType.kInches:
|
|
1778
|
-
// case UnitType.kPoints:
|
|
1779
|
-
// case UnitType.kPicas:
|
|
1780
|
-
// case UnitType.kUserUnits:
|
|
1781
|
-
// case UnitType.kViewportWidth:
|
|
1782
|
-
// case UnitType.kViewportHeight:
|
|
1783
|
-
// case UnitType.kViewportInlineSize:
|
|
1784
|
-
// case UnitType.kViewportBlockSize:
|
|
1785
|
-
// case UnitType.kViewportMin:
|
|
1786
|
-
// case UnitType.kViewportMax:
|
|
1787
|
-
// case UnitType.kSmallViewportWidth:
|
|
1788
|
-
// case UnitType.kSmallViewportHeight:
|
|
1789
|
-
// case UnitType.kSmallViewportInlineSize:
|
|
1790
|
-
// case UnitType.kSmallViewportBlockSize:
|
|
1791
|
-
// case UnitType.kSmallViewportMin:
|
|
1792
|
-
// case UnitType.kSmallViewportMax:
|
|
1793
|
-
// case UnitType.kLargeViewportWidth:
|
|
1794
|
-
// case UnitType.kLargeViewportHeight:
|
|
1795
|
-
// case UnitType.kLargeViewportInlineSize:
|
|
1796
|
-
// case UnitType.kLargeViewportBlockSize:
|
|
1797
|
-
// case UnitType.kLargeViewportMin:
|
|
1798
|
-
// case UnitType.kLargeViewportMax:
|
|
1799
|
-
// case UnitType.kDynamicViewportWidth:
|
|
1800
|
-
// case UnitType.kDynamicViewportHeight:
|
|
1801
|
-
// case UnitType.kDynamicViewportInlineSize:
|
|
1802
|
-
// case UnitType.kDynamicViewportBlockSize:
|
|
1803
|
-
// case UnitType.kDynamicViewportMin:
|
|
1804
|
-
// case UnitType.kDynamicViewportMax:
|
|
1805
|
-
// case UnitType.kContainerWidth:
|
|
1806
|
-
// case UnitType.kContainerHeight:
|
|
1807
|
-
// case UnitType.kContainerInlineSize:
|
|
1808
|
-
// case UnitType.kContainerBlockSize:
|
|
1809
|
-
// case UnitType.kContainerMin:
|
|
1810
|
-
// case UnitType.kContainerMax:
|
|
1811
|
-
case UnitType.kRems:
|
|
1812
|
-
// case UnitType.kChs:
|
|
1813
|
-
return BaseType.kLength;
|
|
1814
|
-
case UnitType.kMilliseconds:
|
|
1815
|
-
case UnitType.kSeconds:
|
|
1816
|
-
return BaseType.kTime;
|
|
1817
|
-
case UnitType.kDegrees:
|
|
1818
|
-
case UnitType.kRadians:
|
|
1819
|
-
case UnitType.kGradians:
|
|
1820
|
-
case UnitType.kTurns:
|
|
1821
|
-
return BaseType.kAngle;
|
|
1822
|
-
// case UnitType.kHertz:
|
|
1823
|
-
// case UnitType.kKilohertz:
|
|
1824
|
-
// return BaseType.kFrequency;
|
|
1825
|
-
// case UnitType.kDotsPerPixel:
|
|
1826
|
-
// case UnitType.kDotsPerInch:
|
|
1827
|
-
// case UnitType.kDotsPerCentimeter:
|
|
1828
|
-
// return BaseType.kResolution;
|
|
1829
|
-
// case UnitType.kFraction:
|
|
1830
|
-
// return BaseType.kFlex;
|
|
1831
|
-
case UnitType.kPercentage:
|
|
1832
|
-
return BaseType.kPercent;
|
|
1833
|
-
default:
|
|
1834
|
-
return BaseType.kLength;
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
|
-
function baseTypeToString(baseType) {
|
|
1838
|
-
switch (baseType) {
|
|
1839
|
-
case BaseType.kLength:
|
|
1840
|
-
return 'length';
|
|
1841
|
-
case BaseType.kAngle:
|
|
1842
|
-
return 'angle';
|
|
1843
|
-
case BaseType.kTime:
|
|
1844
|
-
return 'time';
|
|
1845
|
-
case BaseType.kFrequency:
|
|
1846
|
-
return 'frequency';
|
|
1847
|
-
case BaseType.kResolution:
|
|
1848
|
-
return 'resolution';
|
|
1849
|
-
case BaseType.kFlex:
|
|
1850
|
-
return 'flex';
|
|
1851
|
-
case BaseType.kPercent:
|
|
1852
|
-
return 'percent';
|
|
1853
|
-
}
|
|
1854
|
-
return '';
|
|
1855
|
-
}
|
|
1856
|
-
var CSSNumericValueType = /*#__PURE__*/function () {
|
|
1857
|
-
function CSSNumericValueType(unit, exponent) {
|
|
1858
|
-
if (unit === void 0) {
|
|
1859
|
-
unit = UnitType.kNumber;
|
|
1860
|
-
}
|
|
1861
|
-
if (exponent === void 0) {
|
|
1862
|
-
exponent = 1;
|
|
1863
|
-
}
|
|
1864
|
-
this.exponents = [];
|
|
1865
|
-
this.numNonZeroEntries = 0;
|
|
1866
|
-
this.percentHint = BaseType.kPercent;
|
|
1867
|
-
this.hasPercentHint = false;
|
|
1868
|
-
this.exponents = new Array(BaseType.kNumBaseTypes).fill(0);
|
|
1869
|
-
if (unit !== UnitType.kNumber) {
|
|
1870
|
-
this.setExponent(unitTypeToBaseType(unit), exponent);
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
var _proto = CSSNumericValueType.prototype;
|
|
1874
|
-
_proto.applyPercentHint = function applyPercentHint(hint) {
|
|
1875
|
-
DCHECK_NE(hint, BaseType.kPercent);
|
|
1876
|
-
this.setExponent(hint, this.exponent(hint) + this.exponent(BaseType.kPercent));
|
|
1877
|
-
this.setExponent(BaseType.kPercent, 0);
|
|
1878
|
-
this.percentHint = hint;
|
|
1879
|
-
this.hasPercentHint = true;
|
|
1880
|
-
};
|
|
1881
|
-
_proto.hasNonZeroEntries = function hasNonZeroEntries() {
|
|
1882
|
-
return this.numNonZeroEntries > 0;
|
|
1883
|
-
};
|
|
1884
|
-
_proto.isOnlyNonZeroEntry = function isOnlyNonZeroEntry(baseType, value) {
|
|
1885
|
-
DCHECK_NE(value, 0);
|
|
1886
|
-
return this.numNonZeroEntries === 1 && this.exponent(baseType) === value;
|
|
1887
|
-
};
|
|
1888
|
-
_proto.exponent = function exponent(type) {
|
|
1889
|
-
return this.exponents[type];
|
|
1890
|
-
};
|
|
1891
|
-
_proto.setExponent = function setExponent(type, newValue) {
|
|
1892
|
-
var oldValue = this.exponents[type];
|
|
1893
|
-
if (oldValue == 0 && newValue !== 0) {
|
|
1894
|
-
this.numNonZeroEntries++;
|
|
1895
|
-
} else if (oldValue !== 0 && newValue == 0) {
|
|
1896
|
-
this.numNonZeroEntries--;
|
|
1897
|
-
}
|
|
1898
|
-
this.exponents[type] = newValue;
|
|
1899
|
-
};
|
|
1900
|
-
CSSNumericValueType.negateExponents = function negateExponents(type) {
|
|
1901
|
-
type.exponents.forEach(function (v) {
|
|
1902
|
-
return v *= -1;
|
|
1903
|
-
});
|
|
1904
|
-
return type;
|
|
1905
|
-
};
|
|
1906
|
-
_proto.matchesBaseType = function matchesBaseType(baseType) {
|
|
1907
|
-
DCHECK_NE(baseType, BaseType.kPercent);
|
|
1908
|
-
return this.isOnlyNonZeroEntry(baseType, 1) && !this.hasPercentHint;
|
|
1909
|
-
};
|
|
1910
|
-
_proto.matchesPercentage = function matchesPercentage() {
|
|
1911
|
-
return this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
1912
|
-
};
|
|
1913
|
-
_proto.matchesBaseTypePercentage = function matchesBaseTypePercentage(baseType) {
|
|
1914
|
-
DCHECK_NE(baseType, BaseType.kPercent);
|
|
1915
|
-
return this.isOnlyNonZeroEntry(baseType, 1) || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
1916
|
-
};
|
|
1917
|
-
_proto.matchesNumber = function matchesNumber() {
|
|
1918
|
-
return !this.hasNonZeroEntries() && !this.hasPercentHint;
|
|
1919
|
-
};
|
|
1920
|
-
_proto.matchesNumberPercentage = function matchesNumberPercentage() {
|
|
1921
|
-
return !this.hasNonZeroEntries() || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
1922
|
-
};
|
|
1923
|
-
CSSNumericValueType.add = function add(type1, type2, error) {
|
|
1924
|
-
if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
|
|
1925
|
-
return type1;
|
|
1926
|
-
}
|
|
1927
|
-
if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
|
|
1928
|
-
DCHECK_EQ(type1.percentHint, type2.percentHint);
|
|
1929
|
-
// Match up base types. Try to use the percent hint to match up any
|
|
1930
|
-
// differences.
|
|
1931
|
-
for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
|
|
1932
|
-
var base_type = i;
|
|
1933
|
-
if (type1.exponents[i] !== type2.exponents[i]) {
|
|
1934
|
-
if (base_type !== BaseType.kPercent) {
|
|
1935
|
-
type1.applyPercentHint(base_type);
|
|
1936
|
-
type2.applyPercentHint(base_type);
|
|
1937
|
-
}
|
|
1938
|
-
if (type1.exponents[i] !== type2.exponents[i]) {
|
|
1939
|
-
return type1;
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
return type1;
|
|
1944
|
-
};
|
|
1945
|
-
CSSNumericValueType.multiply = function multiply(type1, type2, error) {
|
|
1946
|
-
if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
|
|
1947
|
-
return type1;
|
|
1948
|
-
}
|
|
1949
|
-
if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
|
|
1950
|
-
for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
|
|
1951
|
-
var base_type = i;
|
|
1952
|
-
type1.setExponent(base_type, type1.exponent(base_type) + type2.exponent(base_type));
|
|
1953
|
-
}
|
|
1954
|
-
return type1;
|
|
1955
|
-
};
|
|
1956
|
-
return CSSNumericValueType;
|
|
1957
|
-
}();
|
|
1958
|
-
var fromNumberish = function fromNumberish(value) {
|
|
1959
|
-
if (typeof value === 'number') {
|
|
1960
|
-
return new CSSUnitValue(value, UnitType.kNumber);
|
|
1961
|
-
}
|
|
1962
|
-
return value;
|
|
1963
|
-
};
|
|
1964
|
-
/**
|
|
1965
|
-
* CSSNumericValue is the base class for numeric and length typed CSS Values.
|
|
1966
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
|
|
1967
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
|
|
1968
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
|
|
1969
|
-
*/
|
|
1970
|
-
var CSSNumericValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1971
|
-
_inheritsLoose(CSSNumericValue, _CSSStyleValue);
|
|
1972
|
-
/**
|
|
1973
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#296
|
|
1974
|
-
*/
|
|
1975
|
-
// static fromPercentish(value: CSSNumberish): CSSNumericValue {
|
|
1976
|
-
// if (typeof value === 'number') {
|
|
1977
|
-
// return new CSSUnitValue(value * 100, UnitType.kPercentage);
|
|
1978
|
-
// }
|
|
1979
|
-
// return value;
|
|
1980
|
-
// }
|
|
1981
|
-
function CSSNumericValue(type_) {
|
|
1982
|
-
var _this;
|
|
1983
|
-
_this = _CSSStyleValue.call(this) || this;
|
|
1984
|
-
_this.type_ = void 0;
|
|
1985
|
-
_this.type_ = type_;
|
|
1986
|
-
return _this;
|
|
1987
|
-
}
|
|
1988
|
-
var _proto2 = CSSNumericValue.prototype;
|
|
1989
|
-
_proto2.getType = function getType() {
|
|
1990
|
-
return CSSStyleValueType.kUnknownType;
|
|
1991
|
-
}
|
|
1992
|
-
// toCSSValue() {
|
|
1993
|
-
// return null;
|
|
1994
|
-
// }
|
|
1995
|
-
/**
|
|
1996
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/equals
|
|
1997
|
-
*/;
|
|
1998
|
-
_proto2.equals = function equals() {
|
|
1999
|
-
var _this2 = this;
|
|
2000
|
-
for (var _len = arguments.length, numberishes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2001
|
-
numberishes[_key] = arguments[_key];
|
|
2002
|
-
}
|
|
2003
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2004
|
-
return values.every(function (value) {
|
|
2005
|
-
return _this2.equals(value);
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#439
|
|
2010
|
-
*/;
|
|
2011
|
-
_proto2.add = function add() {
|
|
2012
|
-
for (var _len2 = arguments.length, numberishes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2013
|
-
numberishes[_key2] = arguments[_key2];
|
|
2014
|
-
}
|
|
2015
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2016
|
-
prependValueForArithmetic(CSSStyleValueType.kSumType, values, this);
|
|
2017
|
-
// eg. 1px + 2px = 3px
|
|
2018
|
-
var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kAdd);
|
|
2019
|
-
if (unitValue) {
|
|
2020
|
-
return unitValue;
|
|
2021
|
-
}
|
|
2022
|
-
return CSSMathSum.create(values);
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#452
|
|
2026
|
-
*/;
|
|
2027
|
-
_proto2.sub = function sub() {
|
|
2028
|
-
for (var _len3 = arguments.length, numberishes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2029
|
-
numberishes[_key3] = arguments[_key3];
|
|
2030
|
-
}
|
|
2031
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2032
|
-
values = values.map(function (value) {
|
|
2033
|
-
return value.negate();
|
|
2034
|
-
});
|
|
2035
|
-
prependValueForArithmetic(CSSStyleValueType.kSumType, values, this);
|
|
2036
|
-
// eg. 3px - 2px = 1px
|
|
2037
|
-
var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kAdd);
|
|
2038
|
-
if (unitValue) {
|
|
2039
|
-
return unitValue;
|
|
2040
|
-
}
|
|
2041
|
-
return CSSMathSum.create(values);
|
|
2042
|
-
}
|
|
2043
|
-
/**
|
|
2044
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/mul
|
|
2045
|
-
*/;
|
|
2046
|
-
_proto2.mul = function mul() {
|
|
2047
|
-
for (var _len4 = arguments.length, numberishes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2048
|
-
numberishes[_key4] = arguments[_key4];
|
|
2049
|
-
}
|
|
2050
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2051
|
-
prependValueForArithmetic(CSSStyleValueType.kProductType, values, this);
|
|
2052
|
-
var unitValue = maybeMultiplyAsUnitValue(values);
|
|
2053
|
-
if (unitValue) {
|
|
2054
|
-
return unitValue;
|
|
2055
|
-
}
|
|
2056
|
-
return CSSMathProduct.create(values);
|
|
2057
|
-
}
|
|
2058
|
-
/**
|
|
2059
|
-
* eg. calc(24px / 4%)
|
|
2060
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/div
|
|
2061
|
-
*/;
|
|
2062
|
-
_proto2.div = function div() {
|
|
2063
|
-
for (var _len5 = arguments.length, numberishes = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
2064
|
-
numberishes[_key5] = arguments[_key5];
|
|
2065
|
-
}
|
|
2066
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2067
|
-
values = values.map(function (value) {
|
|
2068
|
-
return value.invert();
|
|
2069
|
-
});
|
|
2070
|
-
prependValueForArithmetic(CSSStyleValueType.kProductType, values, this);
|
|
2071
|
-
var unitValue = maybeMultiplyAsUnitValue(values);
|
|
2072
|
-
if (unitValue) {
|
|
2073
|
-
return unitValue;
|
|
2074
|
-
}
|
|
2075
|
-
return CSSMathProduct.create(values);
|
|
2076
|
-
};
|
|
2077
|
-
_proto2.min = function min() {
|
|
2078
|
-
for (var _len6 = arguments.length, numberishes = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
2079
|
-
numberishes[_key6] = arguments[_key6];
|
|
2080
|
-
}
|
|
2081
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2082
|
-
prependValueForArithmetic(CSSStyleValueType.kMinType, values, this);
|
|
2083
|
-
var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kMin);
|
|
2084
|
-
if (unitValue) {
|
|
2085
|
-
return unitValue;
|
|
2086
|
-
}
|
|
2087
|
-
return CSSMathMin.create(values);
|
|
2088
|
-
};
|
|
2089
|
-
_proto2.max = function max() {
|
|
2090
|
-
for (var _len7 = arguments.length, numberishes = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
2091
|
-
numberishes[_key7] = arguments[_key7];
|
|
2092
|
-
}
|
|
2093
|
-
var values = cssNumberishesToNumericValues(numberishes);
|
|
2094
|
-
prependValueForArithmetic(CSSStyleValueType.kMaxType, values, this);
|
|
2095
|
-
var unitValue = maybeSimplifyAsUnitValue(values, CSSMathOperator.kMax);
|
|
2096
|
-
if (unitValue) {
|
|
2097
|
-
return unitValue;
|
|
2098
|
-
}
|
|
2099
|
-
return CSSMathMax.create(values);
|
|
2100
|
-
}
|
|
2101
|
-
/**
|
|
2102
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/to
|
|
2103
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#331
|
|
2104
|
-
*/;
|
|
2105
|
-
_proto2.to = function to(unitOrName) {
|
|
2106
|
-
var sum = this.sumValue();
|
|
2107
|
-
if (sum.length === 0 || sum.length !== 1) return null;
|
|
2108
|
-
var value = cssNumericSumValueEntryToUnitValue(sum[0]);
|
|
2109
|
-
if (!value) return null;
|
|
2110
|
-
var unit;
|
|
2111
|
-
if (typeof unitOrName === 'string') {
|
|
2112
|
-
unit = unitFromName(unitOrName);
|
|
2113
|
-
} else {
|
|
2114
|
-
unit = unitOrName;
|
|
2115
|
-
}
|
|
2116
|
-
return value.convertTo(unit);
|
|
2117
|
-
}
|
|
2118
|
-
/**
|
|
2119
|
-
* converts the object's value to a CSSMathSum object to values of the specified unit.
|
|
2120
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/toSum
|
|
2121
|
-
*/;
|
|
2122
|
-
_proto2.toSum = function toSum() {
|
|
2123
|
-
for (var _len8 = arguments.length, unit_strings = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
2124
|
-
unit_strings[_key8] = arguments[_key8];
|
|
2125
|
-
}
|
|
2126
|
-
for (var _i = 0, _unit_strings = unit_strings; _i < _unit_strings.length; _i++) {
|
|
2127
|
-
var unit_string = _unit_strings[_i];
|
|
2128
|
-
if (!CSSNumericValue.isValidUnit(unitFromName(unit_string))) {
|
|
2129
|
-
return null;
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
var sum = this.sumValue();
|
|
2133
|
-
if (!sum.length) {
|
|
2134
|
-
return null;
|
|
2135
|
-
}
|
|
2136
|
-
var values = [];
|
|
2137
|
-
for (var _iterator = _createForOfIteratorHelperLoose(sum), _step; !(_step = _iterator()).done;) {
|
|
2138
|
-
var term = _step.value;
|
|
2139
|
-
var value = cssNumericSumValueEntryToUnitValue(term);
|
|
2140
|
-
if (!value) {
|
|
2141
|
-
return null;
|
|
2142
|
-
}
|
|
2143
|
-
values.push(value);
|
|
2144
|
-
}
|
|
2145
|
-
if (unit_strings.length === 0) {
|
|
2146
|
-
values.sort(function (a, b) {
|
|
2147
|
-
return a.unit - b.unit;
|
|
2148
|
-
});
|
|
2149
|
-
// We got 'values' from a sum value, so it must be a valid CSSMathSum.
|
|
2150
|
-
var _result = CSSMathSum.create(values);
|
|
2151
|
-
DCHECK(!!_result);
|
|
2152
|
-
return _result;
|
|
2153
|
-
}
|
|
2154
|
-
var result = [];
|
|
2155
|
-
var _loop = function _loop() {
|
|
2156
|
-
var unit_string = _unit_strings2[_i2];
|
|
2157
|
-
var target_unit = unitFromName(unit_string);
|
|
2158
|
-
DCHECK(CSSNumericValue.isValidUnit(target_unit));
|
|
2159
|
-
// Collect all the terms that are compatible with this unit.
|
|
2160
|
-
// We mark used terms as null so we don't use them again.
|
|
2161
|
-
var total_value = values.reduce(function (cur_sum, value, i) {
|
|
2162
|
-
if (value) {
|
|
2163
|
-
var unit_value = value;
|
|
2164
|
-
var converted_value = unit_value.convertTo(target_unit);
|
|
2165
|
-
if (converted_value) {
|
|
2166
|
-
cur_sum += converted_value.value;
|
|
2167
|
-
values[i] = null;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
return cur_sum;
|
|
2171
|
-
}, 0);
|
|
2172
|
-
result.push(new CSSUnitValue(total_value, target_unit));
|
|
2173
|
-
};
|
|
2174
|
-
for (var _i2 = 0, _unit_strings2 = unit_strings; _i2 < _unit_strings2.length; _i2++) {
|
|
2175
|
-
_loop();
|
|
2176
|
-
}
|
|
2177
|
-
if (values.some(function (v) {
|
|
2178
|
-
return !!v;
|
|
2179
|
-
})) {
|
|
2180
|
-
throw new Error('There were leftover terms that were not converted');
|
|
2181
|
-
}
|
|
2182
|
-
return CSSMathSum.create(result);
|
|
2183
|
-
}
|
|
1279
|
+
var _proto = CSSColorValue.prototype;
|
|
1280
|
+
_proto.getType = function getType() {
|
|
1281
|
+
return CSSStyleValueType.kColorType;
|
|
1282
|
+
}
|
|
1283
|
+
// buildCSSText(n: Nested, p: ParenLess, result: string): string {
|
|
1284
|
+
// let text = '';
|
|
1285
|
+
// if (this.colorSpace === 'rgb') {
|
|
1286
|
+
// text = `rgba(${this.channels.join(',')},${this.alpha})`;
|
|
1287
|
+
// }
|
|
1288
|
+
// return (result += text);
|
|
1289
|
+
// }
|
|
2184
1290
|
/**
|
|
2185
|
-
* @see https://
|
|
2186
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#414
|
|
1291
|
+
* @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
|
|
2187
1292
|
*/;
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
}
|
|
2215
|
-
exponent = this.type_.exponent(BaseType.kResolution);
|
|
2216
|
-
if (exponent) {
|
|
2217
|
-
type.resolution = exponent;
|
|
2218
|
-
}
|
|
2219
|
-
exponent = this.type_.exponent(BaseType.kFlex);
|
|
2220
|
-
if (exponent) {
|
|
2221
|
-
type.flex = exponent;
|
|
2222
|
-
}
|
|
2223
|
-
exponent = this.type_.exponent(BaseType.kPercent);
|
|
2224
|
-
if (exponent) {
|
|
2225
|
-
type.percent = exponent;
|
|
2226
|
-
}
|
|
2227
|
-
if (this.type_.hasPercentHint) {
|
|
2228
|
-
type.percentHint = baseTypeToString(this.type_.percentHint);
|
|
2229
|
-
}
|
|
2230
|
-
return type;
|
|
2231
|
-
};
|
|
2232
|
-
CSSNumericValue.isValidUnit = function isValidUnit(unit) {
|
|
2233
|
-
// if (unit === UnitType.kUserUnits) return false;
|
|
2234
|
-
if (unit === UnitType.kNumber || unit == UnitType.kPercentage || this.isLength(unit) || this.isAngle(unit) || this.isTime(unit)
|
|
2235
|
-
// this.isFrequency(unit) ||
|
|
2236
|
-
// this.isResolution(unit) ||
|
|
2237
|
-
// this.isFlex(unit)
|
|
2238
|
-
) return true;
|
|
2239
|
-
return false;
|
|
1293
|
+
_proto.to = function to(colorSpace) {
|
|
1294
|
+
return this;
|
|
1295
|
+
};
|
|
1296
|
+
return CSSColorValue;
|
|
1297
|
+
}(CSSStyleValue);
|
|
1298
|
+
|
|
1299
|
+
var GradientType;
|
|
1300
|
+
(function (GradientType) {
|
|
1301
|
+
GradientType[GradientType["Constant"] = 0] = "Constant";
|
|
1302
|
+
GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient";
|
|
1303
|
+
GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient";
|
|
1304
|
+
})(GradientType || (GradientType = {}));
|
|
1305
|
+
var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1306
|
+
_inheritsLoose(CSSGradientValue, _CSSStyleValue);
|
|
1307
|
+
function CSSGradientValue(type, value) {
|
|
1308
|
+
var _this;
|
|
1309
|
+
_this = _CSSStyleValue.call(this) || this;
|
|
1310
|
+
_this.type = void 0;
|
|
1311
|
+
_this.value = void 0;
|
|
1312
|
+
_this.type = type;
|
|
1313
|
+
_this.value = value;
|
|
1314
|
+
return _this;
|
|
1315
|
+
}
|
|
1316
|
+
var _proto = CSSGradientValue.prototype;
|
|
1317
|
+
_proto.clone = function clone() {
|
|
1318
|
+
return new CSSGradientValue(this.type, this.value);
|
|
2240
1319
|
};
|
|
2241
|
-
|
|
2242
|
-
return
|
|
1320
|
+
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
1321
|
+
return result;
|
|
2243
1322
|
};
|
|
2244
|
-
|
|
2245
|
-
return
|
|
1323
|
+
_proto.getType = function getType() {
|
|
1324
|
+
return CSSStyleValueType.kColorType;
|
|
2246
1325
|
};
|
|
2247
|
-
return
|
|
1326
|
+
return CSSGradientValue;
|
|
2248
1327
|
}(CSSStyleValue);
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
if (Object.keys(term.units).length === 1 && term.units[Object.keys(term.units)[0]] === 1) {
|
|
2265
|
-
return new CSSUnitValue(term.value, Number(Object.keys(term.units)[0]));
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* CSSKeywordValue represents CSS Values that are specified as keywords
|
|
1331
|
+
* eg. 'initial'
|
|
1332
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
|
|
1333
|
+
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
|
|
1334
|
+
*/
|
|
1335
|
+
var CSSKeywordValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1336
|
+
_inheritsLoose(CSSKeywordValue, _CSSStyleValue);
|
|
1337
|
+
function CSSKeywordValue(value) {
|
|
1338
|
+
var _this;
|
|
1339
|
+
_this = _CSSStyleValue.call(this) || this;
|
|
1340
|
+
_this.value = void 0;
|
|
1341
|
+
_this.value = value;
|
|
1342
|
+
return _this;
|
|
2266
1343
|
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
final_value *= unit_value.value;
|
|
2300
|
-
}
|
|
2301
|
-
return new CSSUnitValue(final_value, unit_other_than_number);
|
|
2302
|
-
}
|
|
2303
|
-
var toCanonicalUnit = function toCanonicalUnit(unit) {
|
|
2304
|
-
return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));
|
|
2305
|
-
};
|
|
1344
|
+
var _proto = CSSKeywordValue.prototype;
|
|
1345
|
+
_proto.clone = function clone() {
|
|
1346
|
+
return new CSSKeywordValue(this.value);
|
|
1347
|
+
};
|
|
1348
|
+
_proto.getType = function getType() {
|
|
1349
|
+
return CSSStyleValueType.kKeywordType;
|
|
1350
|
+
};
|
|
1351
|
+
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
1352
|
+
return result + this.value;
|
|
1353
|
+
};
|
|
1354
|
+
return CSSKeywordValue;
|
|
1355
|
+
}(CSSStyleValue);
|
|
1356
|
+
|
|
1357
|
+
// type CSSNumericBaseType =
|
|
1358
|
+
// | 'length'
|
|
1359
|
+
// | 'angle'
|
|
1360
|
+
// | 'time'
|
|
1361
|
+
// | 'frequency'
|
|
1362
|
+
// | 'resolution'
|
|
1363
|
+
// | 'flex'
|
|
1364
|
+
// | 'percent';
|
|
1365
|
+
// https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
|
|
1366
|
+
// interface CSSNumericType {
|
|
1367
|
+
// length: number;
|
|
1368
|
+
// angle: number;
|
|
1369
|
+
// time: number;
|
|
1370
|
+
// frequency: number;
|
|
1371
|
+
// resolution: number;
|
|
1372
|
+
// flex: number;
|
|
1373
|
+
// percent: number;
|
|
1374
|
+
// percentHint: CSSNumericBaseType;
|
|
1375
|
+
// }
|
|
2306
1376
|
var formatInfinityOrNaN = function formatInfinityOrNaN(number, suffix) {
|
|
2307
1377
|
if (suffix === void 0) {
|
|
2308
1378
|
suffix = '';
|
|
@@ -2316,49 +1386,52 @@ var formatInfinityOrNaN = function formatInfinityOrNaN(number, suffix) {
|
|
|
2316
1386
|
}
|
|
2317
1387
|
return result += suffix;
|
|
2318
1388
|
};
|
|
2319
|
-
var
|
|
2320
|
-
|
|
2321
|
-
if (canonical_unit === UnitType.kUnknown) return unit;
|
|
2322
|
-
return canonical_unit;
|
|
1389
|
+
var toCanonicalUnit = function toCanonicalUnit(unit) {
|
|
1390
|
+
return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));
|
|
2323
1391
|
};
|
|
1392
|
+
/**
|
|
1393
|
+
* CSSNumericValue is the base class for numeric and length typed CSS Values.
|
|
1394
|
+
* @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
|
|
1395
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
|
|
1396
|
+
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
|
|
1397
|
+
*/
|
|
2324
1398
|
/**
|
|
2325
1399
|
* Represents numeric values that can be expressed as a single number plus a
|
|
2326
1400
|
* unit (or a naked number or percentage).
|
|
2327
1401
|
* @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
|
2328
1402
|
*/
|
|
2329
|
-
var CSSUnitValue = /*#__PURE__*/function (
|
|
2330
|
-
_inheritsLoose(CSSUnitValue,
|
|
2331
|
-
// static fromCSSValue(value: CSSNumericLiteralValue) {
|
|
2332
|
-
// let unit = value.type;
|
|
2333
|
-
// if (unit === UnitType.kInteger) unit = UnitType.kNumber;
|
|
2334
|
-
// if (!this.isValidUnit(unit)) return null;
|
|
2335
|
-
// return new CSSUnitValue(value.getDoubleValue(), unit);
|
|
2336
|
-
// }
|
|
2337
|
-
|
|
1403
|
+
var CSSUnitValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
1404
|
+
_inheritsLoose(CSSUnitValue, _CSSStyleValue);
|
|
2338
1405
|
function CSSUnitValue(value, unitOrName) {
|
|
2339
|
-
var
|
|
1406
|
+
var _this;
|
|
2340
1407
|
if (unitOrName === void 0) {
|
|
2341
1408
|
unitOrName = UnitType.kNumber;
|
|
2342
1409
|
}
|
|
1410
|
+
_this = _CSSStyleValue.call(this) || this;
|
|
1411
|
+
_this.unit = void 0;
|
|
1412
|
+
_this.value = void 0;
|
|
2343
1413
|
var unit;
|
|
2344
1414
|
if (typeof unitOrName === 'string') {
|
|
2345
1415
|
unit = unitFromName(unitOrName);
|
|
2346
1416
|
} else {
|
|
2347
1417
|
unit = unitOrName;
|
|
2348
1418
|
}
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
_this3.value = void 0;
|
|
2353
|
-
_this3.unit = unit;
|
|
2354
|
-
_this3.value = value;
|
|
2355
|
-
return _this3;
|
|
1419
|
+
_this.unit = unit;
|
|
1420
|
+
_this.value = value;
|
|
1421
|
+
return _this;
|
|
2356
1422
|
}
|
|
2357
|
-
var
|
|
2358
|
-
|
|
1423
|
+
var _proto = CSSUnitValue.prototype;
|
|
1424
|
+
_proto.clone = function clone() {
|
|
2359
1425
|
return new CSSUnitValue(this.value, this.unit);
|
|
2360
1426
|
};
|
|
2361
|
-
|
|
1427
|
+
_proto.equals = function equals(other) {
|
|
1428
|
+
var other_unit_value = other;
|
|
1429
|
+
return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
|
|
1430
|
+
};
|
|
1431
|
+
_proto.getType = function getType() {
|
|
1432
|
+
return CSSStyleValueType.kUnitType;
|
|
1433
|
+
};
|
|
1434
|
+
_proto.convertTo = function convertTo(target_unit) {
|
|
2362
1435
|
if (this.unit === target_unit) {
|
|
2363
1436
|
return new CSSUnitValue(this.value, this.unit);
|
|
2364
1437
|
}
|
|
@@ -2372,46 +1445,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
|
|
|
2372
1445
|
var scale_factor = conversionToCanonicalUnitsScaleFactor(this.unit) / conversionToCanonicalUnitsScaleFactor(target_unit);
|
|
2373
1446
|
return new CSSUnitValue(this.value * scale_factor, target_unit);
|
|
2374
1447
|
};
|
|
2375
|
-
|
|
2376
|
-
var other_unit_value = other;
|
|
2377
|
-
return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
|
|
2378
|
-
};
|
|
2379
|
-
_proto3.getType = function getType() {
|
|
2380
|
-
return CSSStyleValueType.kUnitType;
|
|
2381
|
-
}
|
|
2382
|
-
// toCSSValue() {
|
|
2383
|
-
// return new CSSNumericLiteralValue(this.value, this.unit);
|
|
2384
|
-
// }
|
|
2385
|
-
// // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
|
|
2386
|
-
// toCalcExpressionNode() {
|
|
2387
|
-
// return CSSMathExpressionNumericLiteral.create(
|
|
2388
|
-
// new CSSNumericLiteralValue(this.value, this.unit),
|
|
2389
|
-
// );
|
|
2390
|
-
// }
|
|
2391
|
-
;
|
|
2392
|
-
_proto3.sumValue = function sumValue() {
|
|
2393
|
-
var sum = [];
|
|
2394
|
-
var unit_map = {};
|
|
2395
|
-
if (this.unit !== UnitType.kNumber) {
|
|
2396
|
-
unit_map[toCanonicalUnitIfPossible(this.unit)] = 1;
|
|
2397
|
-
}
|
|
2398
|
-
sum.push({
|
|
2399
|
-
value: this.value * conversionToCanonicalUnitsScaleFactor(this.unit),
|
|
2400
|
-
units: unit_map
|
|
2401
|
-
});
|
|
2402
|
-
return sum;
|
|
2403
|
-
};
|
|
2404
|
-
_proto3.negate = function negate() {
|
|
2405
|
-
return new CSSUnitValue(-this.value, this.unit);
|
|
2406
|
-
};
|
|
2407
|
-
_proto3.invert = function invert() {
|
|
2408
|
-
if (this.unit === UnitType.kNumber) {
|
|
2409
|
-
if (this.value === 0) return null;
|
|
2410
|
-
return new CSSUnitValue(1.0 / this.value, this.unit);
|
|
2411
|
-
}
|
|
2412
|
-
return CSSMathInvert.create(this);
|
|
2413
|
-
};
|
|
2414
|
-
_proto3.buildCSSText = function buildCSSText(n, p, result) {
|
|
1448
|
+
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
2415
1449
|
var text;
|
|
2416
1450
|
switch (this.unit) {
|
|
2417
1451
|
case UnitType.kUnknown:
|
|
@@ -2446,12 +1480,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
|
|
|
2446
1480
|
// case UnitType.kHertz:
|
|
2447
1481
|
// case UnitType.kKilohertz:
|
|
2448
1482
|
case UnitType.kTurns:
|
|
2449
|
-
// case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
2450
|
-
// case UnitType.kContainerWidth:
|
|
2451
|
-
// case UnitType.kContainerHeight:
|
|
2452
|
-
// case UnitType.kContainerInlineSize:
|
|
2453
|
-
// case UnitType.kContainerBlockSize:
|
|
2454
|
-
// case UnitType.kContainerMin:
|
|
1483
|
+
// case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
2455
1484
|
// case UnitType.kContainerMax: {
|
|
2456
1485
|
{
|
|
2457
1486
|
var kMinInteger = -999999;
|
|
@@ -2474,504 +1503,7 @@ var CSSUnitValue = /*#__PURE__*/function (_CSSNumericValue) {
|
|
|
2474
1503
|
return result;
|
|
2475
1504
|
};
|
|
2476
1505
|
return CSSUnitValue;
|
|
2477
|
-
}(
|
|
2478
|
-
/**
|
|
2479
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
2480
|
-
*
|
|
2481
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
2482
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
2483
|
-
*/
|
|
2484
|
-
var CSSMathValue = /*#__PURE__*/function (_CSSNumericValue2) {
|
|
2485
|
-
_inheritsLoose(CSSMathValue, _CSSNumericValue2);
|
|
2486
|
-
function CSSMathValue() {
|
|
2487
|
-
return _CSSNumericValue2.apply(this, arguments) || this;
|
|
2488
|
-
}
|
|
2489
|
-
var _proto4 = CSSMathValue.prototype;
|
|
2490
|
-
// From CSSNumericValue
|
|
2491
|
-
_proto4.isUnitValue = function isUnitValue() {
|
|
2492
|
-
return false;
|
|
2493
|
-
};
|
|
2494
|
-
return CSSMathValue;
|
|
2495
|
-
}(CSSNumericValue);
|
|
2496
|
-
var CSSMathInvert = /*#__PURE__*/function (_CSSMathValue) {
|
|
2497
|
-
_inheritsLoose(CSSMathInvert, _CSSMathValue);
|
|
2498
|
-
CSSMathInvert.create = function create(value) {
|
|
2499
|
-
var type = CSSNumericValueType.negateExponents(value.type_);
|
|
2500
|
-
return new CSSMathInvert(value, type);
|
|
2501
|
-
};
|
|
2502
|
-
function CSSMathInvert(value, type) {
|
|
2503
|
-
var _this4;
|
|
2504
|
-
_this4 = _CSSMathValue.call(this, type) || this;
|
|
2505
|
-
_this4.value = void 0;
|
|
2506
|
-
_this4.operator = 'invert';
|
|
2507
|
-
_this4.value = value;
|
|
2508
|
-
return _this4;
|
|
2509
|
-
}
|
|
2510
|
-
var _proto5 = CSSMathInvert.prototype;
|
|
2511
|
-
_proto5.clone = function clone() {
|
|
2512
|
-
return new CSSMathInvert(this.value, this.type_);
|
|
2513
|
-
};
|
|
2514
|
-
_proto5.getType = function getType() {
|
|
2515
|
-
return CSSStyleValueType.kInvertType;
|
|
2516
|
-
};
|
|
2517
|
-
_proto5.equals = function equals(other) {
|
|
2518
|
-
if (other.getType() !== CSSStyleValueType.kInvertType) {
|
|
2519
|
-
return false;
|
|
2520
|
-
}
|
|
2521
|
-
// We can safely cast here as we know 'other' has the same type as us.
|
|
2522
|
-
var other_invert = other;
|
|
2523
|
-
return this.value.equals(other_invert.value);
|
|
2524
|
-
};
|
|
2525
|
-
_proto5.sumValue = function sumValue() {
|
|
2526
|
-
var sum = this.value.sumValue();
|
|
2527
|
-
if (sum.length === 0 || sum.length !== 1 || sum[0].value === 0) {
|
|
2528
|
-
return null;
|
|
2529
|
-
}
|
|
2530
|
-
Object.keys(sum[0].units).forEach(function (key) {
|
|
2531
|
-
sum[0].units[key] *= -1;
|
|
2532
|
-
});
|
|
2533
|
-
sum[0].value = 1.0 / sum[0].value;
|
|
2534
|
-
return sum;
|
|
2535
|
-
}
|
|
2536
|
-
// toCalcExpressionNode(): CSSMathExpressionNode {
|
|
2537
|
-
// const right_side = this.value.toCalcExpressionNode();
|
|
2538
|
-
// if (!right_side) {
|
|
2539
|
-
// return null;
|
|
2540
|
-
// }
|
|
2541
|
-
// // return CSSMathExpressionOperation::CreateArithmeticOperation(
|
|
2542
|
-
// // CSSMathExpressionNumericLiteral::Create(
|
|
2543
|
-
// // 1, UnitType.kNumber),
|
|
2544
|
-
// // right_side, CSSMathOperator.kDivide);
|
|
2545
|
-
// return null;
|
|
2546
|
-
// }
|
|
2547
|
-
;
|
|
2548
|
-
_proto5.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2549
|
-
if (paren_less == ParenLess.kNo) {
|
|
2550
|
-
result += nested === Nested.kYes ? '(' : 'calc(';
|
|
2551
|
-
}
|
|
2552
|
-
result += '1 / ';
|
|
2553
|
-
result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2554
|
-
if (paren_less === ParenLess.kNo) {
|
|
2555
|
-
result += ')';
|
|
2556
|
-
}
|
|
2557
|
-
return result;
|
|
2558
|
-
};
|
|
2559
|
-
return CSSMathInvert;
|
|
2560
|
-
}(CSSMathValue);
|
|
2561
|
-
var CSSMathNegate = /*#__PURE__*/function (_CSSMathValue2) {
|
|
2562
|
-
_inheritsLoose(CSSMathNegate, _CSSMathValue2);
|
|
2563
|
-
CSSMathNegate.create = function create(value) {
|
|
2564
|
-
return new CSSMathNegate(value, value.type_);
|
|
2565
|
-
};
|
|
2566
|
-
function CSSMathNegate(value, type) {
|
|
2567
|
-
var _this5;
|
|
2568
|
-
_this5 = _CSSMathValue2.call(this, type) || this;
|
|
2569
|
-
_this5.value = void 0;
|
|
2570
|
-
_this5.operator = 'negate';
|
|
2571
|
-
_this5.value = value;
|
|
2572
|
-
return _this5;
|
|
2573
|
-
}
|
|
2574
|
-
var _proto6 = CSSMathNegate.prototype;
|
|
2575
|
-
_proto6.clone = function clone() {
|
|
2576
|
-
return new CSSMathNegate(this.value, this.type_);
|
|
2577
|
-
};
|
|
2578
|
-
_proto6.getType = function getType() {
|
|
2579
|
-
return CSSStyleValueType.kNegateType;
|
|
2580
|
-
};
|
|
2581
|
-
_proto6.equals = function equals(other) {
|
|
2582
|
-
if (other.getType() !== CSSStyleValueType.kNegateType) {
|
|
2583
|
-
return false;
|
|
2584
|
-
}
|
|
2585
|
-
var other_invert = other;
|
|
2586
|
-
return this.value.equals(other_invert.value);
|
|
2587
|
-
};
|
|
2588
|
-
_proto6.sumValue = function sumValue() {
|
|
2589
|
-
var sum = this.value.sumValue();
|
|
2590
|
-
if (sum.length === 0) {
|
|
2591
|
-
return null;
|
|
2592
|
-
}
|
|
2593
|
-
sum.forEach(function (term) {
|
|
2594
|
-
term.value *= -1;
|
|
2595
|
-
});
|
|
2596
|
-
return sum;
|
|
2597
|
-
}
|
|
2598
|
-
// toCalcExpressionNode(): CSSMathExpressionNode {
|
|
2599
|
-
// const right_side = this.value.toCalcExpressionNode();
|
|
2600
|
-
// if (!right_side) {
|
|
2601
|
-
// return null;
|
|
2602
|
-
// }
|
|
2603
|
-
// // return CSSMathExpressionOperation::CreateArithmeticOperationSimplified(
|
|
2604
|
-
// // CSSMathExpressionNumericLiteral::Create(
|
|
2605
|
-
// // -1, CSSPrimitiveValue::UnitType::kNumber),
|
|
2606
|
-
// // right_side, CSSMathOperator::kMultiply);
|
|
2607
|
-
// }
|
|
2608
|
-
;
|
|
2609
|
-
_proto6.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2610
|
-
if (paren_less == ParenLess.kNo) {
|
|
2611
|
-
result += nested === Nested.kYes ? '(' : 'calc(';
|
|
2612
|
-
}
|
|
2613
|
-
result += '-';
|
|
2614
|
-
result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2615
|
-
if (paren_less === ParenLess.kNo) {
|
|
2616
|
-
result += ')';
|
|
2617
|
-
}
|
|
2618
|
-
return result;
|
|
2619
|
-
};
|
|
2620
|
-
return CSSMathNegate;
|
|
2621
|
-
}(CSSMathValue);
|
|
2622
|
-
function typeCheck(values, op, error) {
|
|
2623
|
-
error = false;
|
|
2624
|
-
var final_type = values[0].type_;
|
|
2625
|
-
for (var i = 1; i < values.length; i++) {
|
|
2626
|
-
final_type = op(final_type, values[i].type_, error);
|
|
2627
|
-
if (error) return final_type;
|
|
2628
|
-
}
|
|
2629
|
-
return final_type;
|
|
2630
|
-
}
|
|
2631
|
-
// Represents an arithmetic operation with one or more CSSNumericValues.
|
|
2632
|
-
var CSSMathVariadic = /*#__PURE__*/function (_CSSMathValue3) {
|
|
2633
|
-
_inheritsLoose(CSSMathVariadic, _CSSMathValue3);
|
|
2634
|
-
function CSSMathVariadic(values, type) {
|
|
2635
|
-
var _this6;
|
|
2636
|
-
_this6 = _CSSMathValue3.call(this, type) || this;
|
|
2637
|
-
_this6.values = void 0;
|
|
2638
|
-
_this6.values = values;
|
|
2639
|
-
return _this6;
|
|
2640
|
-
}
|
|
2641
|
-
var _proto7 = CSSMathVariadic.prototype;
|
|
2642
|
-
_proto7.numericValues = function numericValues() {
|
|
2643
|
-
return this.values;
|
|
2644
|
-
};
|
|
2645
|
-
_proto7.equals = function equals(other) {
|
|
2646
|
-
if (this.getType() !== other.getType()) {
|
|
2647
|
-
return false;
|
|
2648
|
-
}
|
|
2649
|
-
return this.values.every(function (value, i) {
|
|
2650
|
-
return value.equals(other.values[i]);
|
|
2651
|
-
});
|
|
2652
|
-
};
|
|
2653
|
-
return CSSMathVariadic;
|
|
2654
|
-
}(CSSMathValue);
|
|
2655
|
-
// Represents the minimum of one or more CSSNumericValues.
|
|
2656
|
-
// @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
2657
|
-
var CSSMathMin = /*#__PURE__*/function (_CSSMathVariadic) {
|
|
2658
|
-
_inheritsLoose(CSSMathMin, _CSSMathVariadic);
|
|
2659
|
-
function CSSMathMin() {
|
|
2660
|
-
var _this7;
|
|
2661
|
-
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
2662
|
-
args[_key9] = arguments[_key9];
|
|
2663
|
-
}
|
|
2664
|
-
_this7 = _CSSMathVariadic.call.apply(_CSSMathVariadic, [this].concat(args)) || this;
|
|
2665
|
-
_this7.operator = 'min';
|
|
2666
|
-
return _this7;
|
|
2667
|
-
}
|
|
2668
|
-
CSSMathMin.create = function create(values) {
|
|
2669
|
-
var error = false;
|
|
2670
|
-
var final_type = typeCheck(values, CSSNumericValueType.add, error);
|
|
2671
|
-
return new CSSMathMin(values, final_type);
|
|
2672
|
-
};
|
|
2673
|
-
var _proto8 = CSSMathMin.prototype;
|
|
2674
|
-
_proto8.clone = function clone() {
|
|
2675
|
-
return new CSSMathMin(this.values, this.type_);
|
|
2676
|
-
};
|
|
2677
|
-
_proto8.getType = function getType() {
|
|
2678
|
-
return CSSStyleValueType.kMinType;
|
|
2679
|
-
};
|
|
2680
|
-
_proto8.sumValue = function sumValue() {
|
|
2681
|
-
var cur_min = this.numericValues()[0].sumValue();
|
|
2682
|
-
if (!cur_min.length) {
|
|
2683
|
-
return null;
|
|
2684
|
-
}
|
|
2685
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(this.numericValues()), _step2; !(_step2 = _iterator2()).done;) {
|
|
2686
|
-
var value = _step2.value;
|
|
2687
|
-
var child_sum = value.sumValue();
|
|
2688
|
-
if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_min[0].units)) {
|
|
2689
|
-
return null;
|
|
2690
|
-
}
|
|
2691
|
-
if (child_sum[0].value < cur_min[0].value) {
|
|
2692
|
-
cur_min = child_sum;
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
return cur_min;
|
|
2696
|
-
}
|
|
2697
|
-
// toCalcExpressionNode() {
|
|
2698
|
-
// const operands: CSSMathExpressionOperation[] = [];
|
|
2699
|
-
// for (const value of this.numericValues()) {
|
|
2700
|
-
// const operand = value.toCalcExpressionNode();
|
|
2701
|
-
// if (!operand) {
|
|
2702
|
-
// continue;
|
|
2703
|
-
// }
|
|
2704
|
-
// operands.push(operand as CSSMathExpressionOperation);
|
|
2705
|
-
// }
|
|
2706
|
-
// return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMin);
|
|
2707
|
-
// }
|
|
2708
|
-
;
|
|
2709
|
-
_proto8.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2710
|
-
result += 'min(';
|
|
2711
|
-
var first_iteration = true;
|
|
2712
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(this.numericValues()), _step3; !(_step3 = _iterator3()).done;) {
|
|
2713
|
-
var value = _step3.value;
|
|
2714
|
-
if (!first_iteration) result += ', ';
|
|
2715
|
-
first_iteration = false;
|
|
2716
|
-
result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
|
|
2717
|
-
}
|
|
2718
|
-
result += ')';
|
|
2719
|
-
return result;
|
|
2720
|
-
};
|
|
2721
|
-
return CSSMathMin;
|
|
2722
|
-
}(CSSMathVariadic);
|
|
2723
|
-
// Represents the maximum of one or more CSSNumericValues.
|
|
2724
|
-
// @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
2725
|
-
var CSSMathMax = /*#__PURE__*/function (_CSSMathVariadic2) {
|
|
2726
|
-
_inheritsLoose(CSSMathMax, _CSSMathVariadic2);
|
|
2727
|
-
function CSSMathMax() {
|
|
2728
|
-
var _this8;
|
|
2729
|
-
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
2730
|
-
args[_key10] = arguments[_key10];
|
|
2731
|
-
}
|
|
2732
|
-
_this8 = _CSSMathVariadic2.call.apply(_CSSMathVariadic2, [this].concat(args)) || this;
|
|
2733
|
-
_this8.operator = 'max';
|
|
2734
|
-
return _this8;
|
|
2735
|
-
}
|
|
2736
|
-
CSSMathMax.create = function create(values) {
|
|
2737
|
-
var error = false;
|
|
2738
|
-
var final_type = typeCheck(values, CSSNumericValueType.add, error);
|
|
2739
|
-
return new CSSMathMax(values, final_type);
|
|
2740
|
-
};
|
|
2741
|
-
var _proto9 = CSSMathMax.prototype;
|
|
2742
|
-
_proto9.clone = function clone() {
|
|
2743
|
-
return new CSSMathMax(this.values, this.type_);
|
|
2744
|
-
};
|
|
2745
|
-
_proto9.getType = function getType() {
|
|
2746
|
-
return CSSStyleValueType.kMaxType;
|
|
2747
|
-
};
|
|
2748
|
-
_proto9.sumValue = function sumValue() {
|
|
2749
|
-
var cur_max = this.numericValues()[0].sumValue();
|
|
2750
|
-
if (!cur_max.length) {
|
|
2751
|
-
return null;
|
|
2752
|
-
}
|
|
2753
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(this.numericValues()), _step4; !(_step4 = _iterator4()).done;) {
|
|
2754
|
-
var value = _step4.value;
|
|
2755
|
-
var child_sum = value.sumValue();
|
|
2756
|
-
if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_max[0].units)) {
|
|
2757
|
-
return null;
|
|
2758
|
-
}
|
|
2759
|
-
if (child_sum[0].value < cur_max[0].value) {
|
|
2760
|
-
cur_max = child_sum;
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
return cur_max;
|
|
2764
|
-
}
|
|
2765
|
-
// toCalcExpressionNode() {
|
|
2766
|
-
// const operands: CSSMathExpressionOperation[] = [];
|
|
2767
|
-
// for (const value of this.numericValues()) {
|
|
2768
|
-
// const operand = value.toCalcExpressionNode();
|
|
2769
|
-
// if (!operand) {
|
|
2770
|
-
// continue;
|
|
2771
|
-
// }
|
|
2772
|
-
// operands.push(operand as CSSMathExpressionOperation);
|
|
2773
|
-
// }
|
|
2774
|
-
// return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMax);
|
|
2775
|
-
// }
|
|
2776
|
-
;
|
|
2777
|
-
_proto9.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2778
|
-
result += 'max(';
|
|
2779
|
-
var first_iteration = true;
|
|
2780
|
-
for (var _iterator5 = _createForOfIteratorHelperLoose(this.numericValues()), _step5; !(_step5 = _iterator5()).done;) {
|
|
2781
|
-
var value = _step5.value;
|
|
2782
|
-
if (!first_iteration) result += ', ';
|
|
2783
|
-
first_iteration = false;
|
|
2784
|
-
result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
|
|
2785
|
-
}
|
|
2786
|
-
result += ')';
|
|
2787
|
-
return result;
|
|
2788
|
-
};
|
|
2789
|
-
return CSSMathMax;
|
|
2790
|
-
}(CSSMathVariadic);
|
|
2791
|
-
/**
|
|
2792
|
-
* Represents the sum of one or more CSSNumericValues.
|
|
2793
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
2794
|
-
*/
|
|
2795
|
-
var CSSMathSum = /*#__PURE__*/function (_CSSMathVariadic3) {
|
|
2796
|
-
_inheritsLoose(CSSMathSum, _CSSMathVariadic3);
|
|
2797
|
-
function CSSMathSum() {
|
|
2798
|
-
var _this9;
|
|
2799
|
-
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
2800
|
-
args[_key11] = arguments[_key11];
|
|
2801
|
-
}
|
|
2802
|
-
_this9 = _CSSMathVariadic3.call.apply(_CSSMathVariadic3, [this].concat(args)) || this;
|
|
2803
|
-
_this9.operator = 'sum';
|
|
2804
|
-
return _this9;
|
|
2805
|
-
}
|
|
2806
|
-
CSSMathSum.create = function create(values) {
|
|
2807
|
-
var error = false;
|
|
2808
|
-
var finalType = typeCheck(values, CSSNumericValueType.add, error);
|
|
2809
|
-
return new CSSMathSum(values, finalType);
|
|
2810
|
-
};
|
|
2811
|
-
CSSMathSum.numericTypeFromUnitMap = function numericTypeFromUnitMap(units) {
|
|
2812
|
-
var type = new CSSNumericValueType();
|
|
2813
|
-
Object.keys(units).forEach(function (key) {
|
|
2814
|
-
var exp = units[key];
|
|
2815
|
-
var error = false;
|
|
2816
|
-
type = CSSNumericValueType.multiply(type, new CSSNumericValueType(Number(key), exp), error);
|
|
2817
|
-
DCHECK(!error);
|
|
2818
|
-
});
|
|
2819
|
-
return type;
|
|
2820
|
-
};
|
|
2821
|
-
CSSMathSum.canCreateNumericTypeFromSumValue = function canCreateNumericTypeFromSumValue(sum) {
|
|
2822
|
-
var _this10 = this;
|
|
2823
|
-
DCHECK(!!sum.length);
|
|
2824
|
-
var first_type = this.numericTypeFromUnitMap(sum[0].units);
|
|
2825
|
-
return sum.every(function (term) {
|
|
2826
|
-
var error = false;
|
|
2827
|
-
CSSNumericValueType.add(first_type, _this10.numericTypeFromUnitMap(term.units), error);
|
|
2828
|
-
return !error;
|
|
2829
|
-
});
|
|
2830
|
-
};
|
|
2831
|
-
var _proto10 = CSSMathSum.prototype;
|
|
2832
|
-
_proto10.clone = function clone() {
|
|
2833
|
-
return new CSSMathSum(this.values, this.type_);
|
|
2834
|
-
};
|
|
2835
|
-
_proto10.getType = function getType() {
|
|
2836
|
-
return CSSStyleValueType.kSumType;
|
|
2837
|
-
}
|
|
2838
|
-
// toCalcExpressionNode() {
|
|
2839
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
|
|
2840
|
-
// }
|
|
2841
|
-
;
|
|
2842
|
-
_proto10.sumValue = function sumValue() {
|
|
2843
|
-
var sum = [];
|
|
2844
|
-
this.numericValues().forEach(function (value) {
|
|
2845
|
-
var child_sum = value.sumValue();
|
|
2846
|
-
if (!child_sum.length) {
|
|
2847
|
-
return null;
|
|
2848
|
-
}
|
|
2849
|
-
child_sum.forEach(function (term) {
|
|
2850
|
-
var index = sum.findIndex(function (s) {
|
|
2851
|
-
return JSON.stringify(s.units) === JSON.stringify(term.units);
|
|
2852
|
-
});
|
|
2853
|
-
if (index === -1) {
|
|
2854
|
-
sum.push(_extends({}, term));
|
|
2855
|
-
} else {
|
|
2856
|
-
sum[index].value += term.value;
|
|
2857
|
-
}
|
|
2858
|
-
});
|
|
2859
|
-
});
|
|
2860
|
-
if (!CSSMathSum.canCreateNumericTypeFromSumValue(sum)) return null;
|
|
2861
|
-
return sum;
|
|
2862
|
-
};
|
|
2863
|
-
_proto10.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2864
|
-
if (paren_less == ParenLess.kNo) {
|
|
2865
|
-
result += nested === Nested.kYes ? '(' : 'calc(';
|
|
2866
|
-
}
|
|
2867
|
-
var values = this.numericValues();
|
|
2868
|
-
result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2869
|
-
for (var i = 1; i < values.length; i++) {
|
|
2870
|
-
var arg = values[i];
|
|
2871
|
-
if (arg.getType() === CSSStyleValueType.kNegateType) {
|
|
2872
|
-
result += ' - ';
|
|
2873
|
-
result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2874
|
-
} else {
|
|
2875
|
-
result += ' + ';
|
|
2876
|
-
result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2877
|
-
}
|
|
2878
|
-
}
|
|
2879
|
-
if (paren_less === ParenLess.kNo) {
|
|
2880
|
-
result += ')';
|
|
2881
|
-
}
|
|
2882
|
-
return result;
|
|
2883
|
-
};
|
|
2884
|
-
return CSSMathSum;
|
|
2885
|
-
}(CSSMathVariadic);
|
|
2886
|
-
/**
|
|
2887
|
-
* Represents the product of one or more CSSNumericValues.
|
|
2888
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
|
|
2889
|
-
*/
|
|
2890
|
-
var CSSMathProduct = /*#__PURE__*/function (_CSSMathVariadic4) {
|
|
2891
|
-
_inheritsLoose(CSSMathProduct, _CSSMathVariadic4);
|
|
2892
|
-
function CSSMathProduct() {
|
|
2893
|
-
var _this11;
|
|
2894
|
-
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
2895
|
-
args[_key12] = arguments[_key12];
|
|
2896
|
-
}
|
|
2897
|
-
_this11 = _CSSMathVariadic4.call.apply(_CSSMathVariadic4, [this].concat(args)) || this;
|
|
2898
|
-
_this11.operator = 'product';
|
|
2899
|
-
return _this11;
|
|
2900
|
-
}
|
|
2901
|
-
CSSMathProduct.create = function create(values) {
|
|
2902
|
-
var error = false;
|
|
2903
|
-
var finalType = typeCheck(values, CSSNumericValueType.multiply, error);
|
|
2904
|
-
return new CSSMathProduct(values, finalType);
|
|
2905
|
-
};
|
|
2906
|
-
CSSMathProduct.multiplyUnitMaps = function multiplyUnitMaps(a, b) {
|
|
2907
|
-
Object.keys(b).forEach(function (key) {
|
|
2908
|
-
DCHECK_NE(b[key].value, 0);
|
|
2909
|
-
var old_value = key in a ? a[key].value : 0;
|
|
2910
|
-
if (old_value + b[key].value === 0) {
|
|
2911
|
-
delete a[key];
|
|
2912
|
-
} else {
|
|
2913
|
-
a[key] = old_value + b[key].value;
|
|
2914
|
-
}
|
|
2915
|
-
});
|
|
2916
|
-
return a;
|
|
2917
|
-
};
|
|
2918
|
-
var _proto11 = CSSMathProduct.prototype;
|
|
2919
|
-
_proto11.clone = function clone() {
|
|
2920
|
-
return new CSSMathProduct(this.values, this.type_);
|
|
2921
|
-
};
|
|
2922
|
-
_proto11.getType = function getType() {
|
|
2923
|
-
return CSSStyleValueType.kProductType;
|
|
2924
|
-
}
|
|
2925
|
-
// toCalcExpressionNode() {
|
|
2926
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kMultiply);
|
|
2927
|
-
// }
|
|
2928
|
-
;
|
|
2929
|
-
_proto11.sumValue = function sumValue() {
|
|
2930
|
-
var sum = [{
|
|
2931
|
-
value: 1,
|
|
2932
|
-
units: {}
|
|
2933
|
-
}];
|
|
2934
|
-
this.numericValues().forEach(function (value) {
|
|
2935
|
-
var child_sum = value.sumValue();
|
|
2936
|
-
if (!child_sum.length) {
|
|
2937
|
-
return null;
|
|
2938
|
-
}
|
|
2939
|
-
var new_sum = [];
|
|
2940
|
-
sum.forEach(function (a) {
|
|
2941
|
-
child_sum.forEach(function (b) {
|
|
2942
|
-
new_sum.push({
|
|
2943
|
-
value: a.value * b.value,
|
|
2944
|
-
units: CSSMathProduct.multiplyUnitMaps(a.units, b.units)
|
|
2945
|
-
});
|
|
2946
|
-
});
|
|
2947
|
-
});
|
|
2948
|
-
sum = new_sum;
|
|
2949
|
-
});
|
|
2950
|
-
return sum;
|
|
2951
|
-
};
|
|
2952
|
-
_proto11.buildCSSText = function buildCSSText(nested, paren_less, result) {
|
|
2953
|
-
if (paren_less == ParenLess.kNo) {
|
|
2954
|
-
result += nested === Nested.kYes ? '(' : 'calc(';
|
|
2955
|
-
}
|
|
2956
|
-
var values = this.numericValues();
|
|
2957
|
-
result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2958
|
-
for (var i = 1; i < values.length; i++) {
|
|
2959
|
-
var arg = values[i];
|
|
2960
|
-
if (arg.getType() === CSSStyleValueType.kInvertType) {
|
|
2961
|
-
result += ' / ';
|
|
2962
|
-
result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2963
|
-
} else {
|
|
2964
|
-
result += ' * ';
|
|
2965
|
-
result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
if (paren_less === ParenLess.kNo) {
|
|
2969
|
-
result += ')';
|
|
2970
|
-
}
|
|
2971
|
-
return result;
|
|
2972
|
-
};
|
|
2973
|
-
return CSSMathProduct;
|
|
2974
|
-
}(CSSMathVariadic);
|
|
1506
|
+
}(CSSStyleValue);
|
|
2975
1507
|
var Opx = new CSSUnitValue(0, 'px');
|
|
2976
1508
|
var Lpx = new CSSUnitValue(1, 'px');
|
|
2977
1509
|
var Odeg = new CSSUnitValue(0, 'deg');
|
|
@@ -3153,17 +1685,20 @@ var getOrCreateRGBA = memoize(function (r, g, b, a) {
|
|
|
3153
1685
|
}, function (r, g, b, a) {
|
|
3154
1686
|
return "rgba(" + r + "," + g + "," + b + "," + a + ")";
|
|
3155
1687
|
});
|
|
3156
|
-
|
|
1688
|
+
// export const getOrCreateUnitValue = memoize(
|
|
1689
|
+
// (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
|
|
1690
|
+
// return new CSSUnitValue(value, unitOrName);
|
|
1691
|
+
// },
|
|
1692
|
+
// (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
|
|
1693
|
+
// return `${value}${unitOrName}`;
|
|
1694
|
+
// },
|
|
1695
|
+
// );
|
|
1696
|
+
var getOrCreateUnitValue = function getOrCreateUnitValue(value, unitOrName) {
|
|
3157
1697
|
if (unitOrName === void 0) {
|
|
3158
1698
|
unitOrName = UnitType.kNumber;
|
|
3159
1699
|
}
|
|
3160
1700
|
return new CSSUnitValue(value, unitOrName);
|
|
3161
|
-
}
|
|
3162
|
-
if (unitOrName === void 0) {
|
|
3163
|
-
unitOrName = UnitType.kNumber;
|
|
3164
|
-
}
|
|
3165
|
-
return "" + value + unitOrName;
|
|
3166
|
-
});
|
|
1701
|
+
};
|
|
3167
1702
|
|
|
3168
1703
|
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
3169
1704
|
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
@@ -3286,7 +1821,7 @@ var parseGradient = memoize(function (colorStr) {
|
|
|
3286
1821
|
var steps = colorStops.map(function (colorStop) {
|
|
3287
1822
|
// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
3288
1823
|
return {
|
|
3289
|
-
offset: getOrCreateUnitValue(colorStop.length.value, '%'),
|
|
1824
|
+
offset: getOrCreateUnitValue(Number(colorStop.length.value), '%'),
|
|
3290
1825
|
color: colorStopToString(colorStop)
|
|
3291
1826
|
};
|
|
3292
1827
|
});
|
|
@@ -3481,6 +2016,22 @@ function mergeColors(left, right) {
|
|
|
3481
2016
|
}];
|
|
3482
2017
|
}
|
|
3483
2018
|
|
|
2019
|
+
var Shape;
|
|
2020
|
+
(function (Shape) {
|
|
2021
|
+
Shape["GROUP"] = "g";
|
|
2022
|
+
Shape["CIRCLE"] = "circle";
|
|
2023
|
+
Shape["ELLIPSE"] = "ellipse";
|
|
2024
|
+
Shape["IMAGE"] = "image";
|
|
2025
|
+
Shape["RECT"] = "rect";
|
|
2026
|
+
Shape["LINE"] = "line";
|
|
2027
|
+
Shape["POLYLINE"] = "polyline";
|
|
2028
|
+
Shape["POLYGON"] = "polygon";
|
|
2029
|
+
Shape["TEXT"] = "text";
|
|
2030
|
+
Shape["PATH"] = "path";
|
|
2031
|
+
Shape["HTML"] = "html";
|
|
2032
|
+
Shape["MESH"] = "mesh";
|
|
2033
|
+
})(Shape || (Shape = {}));
|
|
2034
|
+
|
|
3484
2035
|
function parseDimension(unitRegExp, string) {
|
|
3485
2036
|
if (isNil(string)) {
|
|
3486
2037
|
return getOrCreateUnitValue(0, 'px');
|
|
@@ -3524,12 +2075,20 @@ var parserPercentage = memoize(function (css) {
|
|
|
3524
2075
|
*
|
|
3525
2076
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
|
|
3526
2077
|
*/
|
|
3527
|
-
|
|
2078
|
+
// export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
|
|
2079
|
+
// if (isNumber(css) || isFinite(Number(css))) {
|
|
2080
|
+
// return getOrCreateUnitValue(Number(css), 'px');
|
|
2081
|
+
// }
|
|
2082
|
+
// return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
|
|
2083
|
+
// });
|
|
2084
|
+
var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
|
|
3528
2085
|
if (isNumber(css) || isFinite(Number(css))) {
|
|
3529
2086
|
return getOrCreateUnitValue(Number(css), 'px');
|
|
2087
|
+
// return Number(css);
|
|
3530
2088
|
}
|
|
2089
|
+
|
|
3531
2090
|
return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
|
|
3532
|
-
}
|
|
2091
|
+
};
|
|
3533
2092
|
var parseAngle = memoize(function (css) {
|
|
3534
2093
|
return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
|
|
3535
2094
|
});
|
|
@@ -4460,6 +3019,9 @@ var CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
|
|
|
4460
3019
|
* CSS.percent(50) -> CSS.px(0.5 * parent.width)
|
|
4461
3020
|
*/
|
|
4462
3021
|
_proto.calculator = function calculator(name, oldParsed, computed, object, registry) {
|
|
3022
|
+
if (isNumber(computed)) {
|
|
3023
|
+
return computed;
|
|
3024
|
+
}
|
|
4463
3025
|
if (CSSUnitValue.isRelativeUnit(computed.unit)) {
|
|
4464
3026
|
if (computed.unit === UnitType.kPercentage) {
|
|
4465
3027
|
// TODO: merge dimensions
|
|
@@ -4581,7 +3143,7 @@ var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
|
|
|
4581
3143
|
/**
|
|
4582
3144
|
* update local position
|
|
4583
3145
|
*/
|
|
4584
|
-
_proto.postProcessor = function postProcessor(object) {
|
|
3146
|
+
_proto.postProcessor = function postProcessor(object, attributes) {
|
|
4585
3147
|
var x;
|
|
4586
3148
|
var y;
|
|
4587
3149
|
var z;
|
|
@@ -4629,12 +3191,19 @@ var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
|
|
|
4629
3191
|
object.parsedStyle.defY = y || 0;
|
|
4630
3192
|
}
|
|
4631
3193
|
var needResetLocalPosition = !isNil(x) || !isNil(y) || !isNil(z);
|
|
4632
|
-
if
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
3194
|
+
// only if `transform` won't be processed later
|
|
3195
|
+
if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
|
|
3196
|
+
// account for current transform if needed
|
|
3197
|
+
var transform = object.parsedStyle.transform;
|
|
3198
|
+
if (transform && transform.length) {
|
|
3199
|
+
parsedTransformToMat4(transform, object);
|
|
3200
|
+
} else {
|
|
3201
|
+
var _object$getLocalPosit = object.getLocalPosition(),
|
|
3202
|
+
ox = _object$getLocalPosit[0],
|
|
3203
|
+
oy = _object$getLocalPosit[1],
|
|
3204
|
+
oz = _object$getLocalPosit[2];
|
|
3205
|
+
object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
|
|
3206
|
+
}
|
|
4638
3207
|
}
|
|
4639
3208
|
};
|
|
4640
3209
|
return CSSPropertyLocalPosition;
|
|
@@ -4949,6 +3518,30 @@ var CustomElementRegistry = /*#__PURE__*/function () {
|
|
|
4949
3518
|
return CustomElementRegistry;
|
|
4950
3519
|
}();
|
|
4951
3520
|
|
|
3521
|
+
var Point = /*#__PURE__*/function () {
|
|
3522
|
+
function Point(x, y) {
|
|
3523
|
+
if (x === void 0) {
|
|
3524
|
+
x = 0;
|
|
3525
|
+
}
|
|
3526
|
+
if (y === void 0) {
|
|
3527
|
+
y = 0;
|
|
3528
|
+
}
|
|
3529
|
+
this.x = 0;
|
|
3530
|
+
this.y = 0;
|
|
3531
|
+
this.x = x;
|
|
3532
|
+
this.y = y;
|
|
3533
|
+
}
|
|
3534
|
+
var _proto = Point.prototype;
|
|
3535
|
+
_proto.clone = function clone() {
|
|
3536
|
+
return new Point(this.x, this.y);
|
|
3537
|
+
};
|
|
3538
|
+
_proto.copyFrom = function copyFrom(p) {
|
|
3539
|
+
this.x = p.x;
|
|
3540
|
+
this.y = p.y;
|
|
3541
|
+
};
|
|
3542
|
+
return Point;
|
|
3543
|
+
}();
|
|
3544
|
+
|
|
4952
3545
|
function isFederatedEvent(value) {
|
|
4953
3546
|
return !!value.type;
|
|
4954
3547
|
}
|
|
@@ -6046,16 +4639,26 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
6046
4639
|
dirtyFlag: false,
|
|
6047
4640
|
localDirtyFlag: false,
|
|
6048
4641
|
frozen: false,
|
|
6049
|
-
localPosition: vec3.fromValues(0, 0, 0),
|
|
6050
|
-
localRotation: quat
|
|
6051
|
-
localScale: vec3.fromValues(1, 1, 1),
|
|
4642
|
+
// localPosition: vec3.fromValues(0, 0, 0),
|
|
4643
|
+
// localRotation: quat.fromValues(0, 0, 0, 1),
|
|
4644
|
+
// localScale: vec3.fromValues(1, 1, 1),
|
|
4645
|
+
// localTransform: mat4.create(),
|
|
4646
|
+
// localSkew: vec2.fromValues(0, 0),
|
|
4647
|
+
// position: vec3.fromValues(0, 0, 0),
|
|
4648
|
+
// rotation: quat.fromValues(0, 0, 0, 1),
|
|
4649
|
+
// scaling: vec3.fromValues(1, 1, 1),
|
|
4650
|
+
// worldTransform: mat4.create(),
|
|
4651
|
+
// origin: vec3.fromValues(0, 0, 0),
|
|
4652
|
+
localPosition: [0, 0, 0],
|
|
4653
|
+
localRotation: [0, 0, 0, 1],
|
|
4654
|
+
localScale: [1, 1, 1],
|
|
6052
4655
|
localTransform: mat4.create(),
|
|
6053
|
-
localSkew:
|
|
6054
|
-
position:
|
|
6055
|
-
rotation:
|
|
6056
|
-
scaling:
|
|
4656
|
+
localSkew: [0, 0],
|
|
4657
|
+
position: [0, 0, 0],
|
|
4658
|
+
rotation: [0, 0, 0, 1],
|
|
4659
|
+
scaling: [1, 1, 1],
|
|
6057
4660
|
worldTransform: mat4.create(),
|
|
6058
|
-
origin:
|
|
4661
|
+
origin: [0, 0, 0]
|
|
6059
4662
|
};
|
|
6060
4663
|
_this.sortable = {
|
|
6061
4664
|
dirty: false,
|
|
@@ -6772,6 +5375,20 @@ var DEFAULT_PARSED_STYLE_PROPS = {
|
|
|
6772
5375
|
filter: [],
|
|
6773
5376
|
shadowType: 'outer'
|
|
6774
5377
|
};
|
|
5378
|
+
var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = _extends({}, DEFAULT_PARSED_STYLE_PROPS, {
|
|
5379
|
+
opacity: 1,
|
|
5380
|
+
fillOpacity: 1,
|
|
5381
|
+
strokeOpacity: 1,
|
|
5382
|
+
visibility: 'visible',
|
|
5383
|
+
pointerEvents: 'auto',
|
|
5384
|
+
lineWidth: 1,
|
|
5385
|
+
lineCap: 'butt',
|
|
5386
|
+
lineJoin: 'miter',
|
|
5387
|
+
increasedLineWidthForHitTesting: 0,
|
|
5388
|
+
fillRule: 'nonzero'
|
|
5389
|
+
// TODO: transformOrigin
|
|
5390
|
+
});
|
|
5391
|
+
|
|
6775
5392
|
var INHERITABLE_BASE_STYLE_PROPS = ['opacity', 'fillOpacity', 'strokeOpacity', 'transformOrigin', 'visibility', 'pointerEvents', 'lineWidth', 'lineCap', 'lineJoin', 'increasedLineWidthForHitTesting'];
|
|
6776
5393
|
var INHERITABLE_STYLE_PROPS = [].concat(INHERITABLE_BASE_STYLE_PROPS, ['fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'textAlign', 'textBaseline', 'textTransform']);
|
|
6777
5394
|
/**
|
|
@@ -6826,7 +5443,13 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
6826
5443
|
}
|
|
6827
5444
|
_this.nodeName = _this.config.type || Shape.GROUP;
|
|
6828
5445
|
// compatible with G 3.0
|
|
6829
|
-
_this.config.style =
|
|
5446
|
+
_this.config.style = _this.config.style || _this.config.attrs || {};
|
|
5447
|
+
Object.assign(_this.config.style, _this.config.attrs);
|
|
5448
|
+
// this.config.style = {
|
|
5449
|
+
// // ...DEFAULT_STYLE_PROPS,
|
|
5450
|
+
// ...this.config.style,
|
|
5451
|
+
// ...this.config.attrs,
|
|
5452
|
+
// };
|
|
6830
5453
|
if (_this.config.visible != null) {
|
|
6831
5454
|
_this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
|
|
6832
5455
|
}
|
|
@@ -6834,8 +5457,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
6834
5457
|
_this.config.style.pointerEvents = _this.config.interactive === false ? 'none' : 'auto';
|
|
6835
5458
|
}
|
|
6836
5459
|
// merge parsed value
|
|
6837
|
-
Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
|
|
6838
|
-
|
|
5460
|
+
Object.assign(_this.parsedStyle, runtime.enableCSSParsing ? DEFAULT_PARSED_STYLE_PROPS : DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED, _this.config.initialParsedStyle);
|
|
5461
|
+
if (runtime.enableCSSParsing) {
|
|
5462
|
+
Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
|
|
5463
|
+
}
|
|
6839
5464
|
// start to process attributes
|
|
6840
5465
|
_this.initAttributes(_this.config.style);
|
|
6841
5466
|
_this.style = new Proxy(
|
|
@@ -6930,16 +5555,21 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
6930
5555
|
attributes = {};
|
|
6931
5556
|
}
|
|
6932
5557
|
var renderable = this.renderable;
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
forceUpdateGeometry: true,
|
|
6936
|
-
usedAttributes: INHERITABLE_STYLE_PROPS
|
|
5558
|
+
var options = {
|
|
5559
|
+
forceUpdateGeometry: true
|
|
6937
5560
|
// usedAttributes:
|
|
6938
5561
|
// // only Group / Text should account for text relative props
|
|
6939
5562
|
// this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
|
|
6940
5563
|
// ? INHERITABLE_STYLE_PROPS
|
|
6941
5564
|
// : INHERITABLE_BASE_STYLE_PROPS,
|
|
6942
|
-
}
|
|
5565
|
+
};
|
|
5566
|
+
|
|
5567
|
+
if (runtime.enableCSSParsing) {
|
|
5568
|
+
// @ts-ignore
|
|
5569
|
+
options.usedAttributes = INHERITABLE_STYLE_PROPS;
|
|
5570
|
+
}
|
|
5571
|
+
// account for FCP, process properties as less as possible
|
|
5572
|
+
runtime.styleValueRegistry.processProperties(this, attributes, options);
|
|
6943
5573
|
// redraw at next frame
|
|
6944
5574
|
renderable.dirty = true;
|
|
6945
5575
|
};
|
|
@@ -7674,7 +6304,11 @@ var HTML = /*#__PURE__*/function (_DisplayObject) {
|
|
|
7674
6304
|
var minX = clientRect.left - canvasRect.left;
|
|
7675
6305
|
var minY = clientRect.top - canvasRect.top;
|
|
7676
6306
|
var aabb = new AABB();
|
|
7677
|
-
aabb.setMinMax(
|
|
6307
|
+
// aabb.setMinMax(
|
|
6308
|
+
// vec3.fromValues(minX, minY, 0),
|
|
6309
|
+
// vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
|
|
6310
|
+
// );
|
|
6311
|
+
aabb.setMinMax([minX, minY, 0], [minX + clientRect.width, minY + clientRect.height, 0]);
|
|
7678
6312
|
return aabb;
|
|
7679
6313
|
}
|
|
7680
6314
|
return null;
|
|
@@ -8419,6 +7053,42 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
8419
7053
|
return Text;
|
|
8420
7054
|
}(DisplayObject);
|
|
8421
7055
|
|
|
7056
|
+
function copyVec3(a, b) {
|
|
7057
|
+
a[0] = b[0];
|
|
7058
|
+
a[1] = b[1];
|
|
7059
|
+
a[2] = b[2];
|
|
7060
|
+
return a;
|
|
7061
|
+
}
|
|
7062
|
+
function subVec3(o, a, b) {
|
|
7063
|
+
o[0] = a[0] - b[0];
|
|
7064
|
+
o[1] = a[1] - b[1];
|
|
7065
|
+
o[2] = a[2] - b[2];
|
|
7066
|
+
return o;
|
|
7067
|
+
}
|
|
7068
|
+
function addVec3(o, a, b) {
|
|
7069
|
+
o[0] = a[0] + b[0];
|
|
7070
|
+
o[1] = a[1] + b[1];
|
|
7071
|
+
o[2] = a[2] + b[2];
|
|
7072
|
+
return o;
|
|
7073
|
+
}
|
|
7074
|
+
function scaleVec3(o, a, b) {
|
|
7075
|
+
o[0] = a[0] * b;
|
|
7076
|
+
o[1] = a[1] * b;
|
|
7077
|
+
o[2] = a[2] * b;
|
|
7078
|
+
return o;
|
|
7079
|
+
}
|
|
7080
|
+
function maxVec3(o, a, b) {
|
|
7081
|
+
o[0] = Math.max(a[0], b[0]);
|
|
7082
|
+
o[1] = Math.max(a[1], b[1]);
|
|
7083
|
+
o[2] = Math.max(a[2], b[2]);
|
|
7084
|
+
return o;
|
|
7085
|
+
}
|
|
7086
|
+
function minVec3(o, a, b) {
|
|
7087
|
+
o[0] = Math.min(a[0], b[0]);
|
|
7088
|
+
o[1] = Math.min(a[1], b[1]);
|
|
7089
|
+
o[2] = Math.min(a[2], b[2]);
|
|
7090
|
+
return o;
|
|
7091
|
+
}
|
|
8422
7092
|
function getAngle(angle) {
|
|
8423
7093
|
if (angle === undefined) {
|
|
8424
7094
|
return 0;
|
|
@@ -8788,16 +7458,16 @@ function parsedTransformToMat4(transform, object) {
|
|
|
8788
7458
|
object.translateLocal(_newTranslation4[0].value, _newTranslation4[1].value, _newTranslation4[2].value);
|
|
8789
7459
|
} else if (t === 'rotate') {
|
|
8790
7460
|
var newAngles = d || [Odeg];
|
|
8791
|
-
object.rotateLocal(0, 0, newAngles[0]
|
|
7461
|
+
object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
|
|
8792
7462
|
} else if (t === 'rotatex') {
|
|
8793
7463
|
var _newAngles = d || [Odeg];
|
|
8794
|
-
object.rotateLocal(_newAngles[0]
|
|
7464
|
+
object.rotateLocal(convertAngleUnit(_newAngles[0]), 0, 0);
|
|
8795
7465
|
} else if (t === 'rotatey') {
|
|
8796
7466
|
var _newAngles2 = d || [Odeg];
|
|
8797
|
-
object.rotateLocal(0, _newAngles2[0]
|
|
7467
|
+
object.rotateLocal(0, convertAngleUnit(_newAngles2[0]), 0);
|
|
8798
7468
|
} else if (t === 'rotatez') {
|
|
8799
7469
|
var _newAngles3 = d || [Odeg];
|
|
8800
|
-
object.rotateLocal(0, 0, _newAngles3[0]
|
|
7470
|
+
object.rotateLocal(0, 0, convertAngleUnit(_newAngles3[0]));
|
|
8801
7471
|
} else if (t === 'rotate3d') ; else if (t === 'skew') {
|
|
8802
7472
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
8803
7473
|
return s.value;
|
|
@@ -10836,90 +9506,484 @@ function toFontString(attributes) {
|
|
|
10836
9506
|
if (!stringRegExp.test(_fontFamily) && genericFontFamilies.indexOf(_fontFamily) < 0) {
|
|
10837
9507
|
_fontFamily = "\"" + _fontFamily + "\"";
|
|
10838
9508
|
}
|
|
10839
|
-
fontFamilies[i] = _fontFamily;
|
|
9509
|
+
fontFamilies[i] = _fontFamily;
|
|
9510
|
+
}
|
|
9511
|
+
return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
|
|
9512
|
+
}
|
|
9513
|
+
|
|
9514
|
+
/**
|
|
9515
|
+
* Thanks for following contributor of codes
|
|
9516
|
+
* https://gist.github.com/1866474
|
|
9517
|
+
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
|
9518
|
+
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
|
9519
|
+
* https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
|
|
9520
|
+
**/
|
|
9521
|
+
var uId = 1;
|
|
9522
|
+
var uniqueId = function uniqueId() {
|
|
9523
|
+
return uId++;
|
|
9524
|
+
};
|
|
9525
|
+
// We use `self` instead of `window` for `WebWorker` support.
|
|
9526
|
+
var root = typeof self === 'object' && self.self == self ? self :
|
|
9527
|
+
// @ts-ignore
|
|
9528
|
+
typeof global === 'object' && global.global == global ?
|
|
9529
|
+
// @ts-ignore
|
|
9530
|
+
global : {};
|
|
9531
|
+
var nowOffset = Date.now();
|
|
9532
|
+
// use performance api if exist, otherwise use Date.now.
|
|
9533
|
+
// Date.now polyfill required.
|
|
9534
|
+
var pnow = function pnow() {
|
|
9535
|
+
if (root.performance && typeof root.performance.now === 'function') {
|
|
9536
|
+
return root.performance.now();
|
|
9537
|
+
}
|
|
9538
|
+
// fallback
|
|
9539
|
+
return Date.now() - nowOffset;
|
|
9540
|
+
};
|
|
9541
|
+
var reservedCBs = {};
|
|
9542
|
+
var lastTime = Date.now();
|
|
9543
|
+
var polyfillRaf = function polyfillRaf(callback) {
|
|
9544
|
+
if (typeof callback !== 'function') {
|
|
9545
|
+
throw new TypeError(callback + ' is not a function');
|
|
9546
|
+
}
|
|
9547
|
+
var currentTime = Date.now();
|
|
9548
|
+
var gap = currentTime - lastTime;
|
|
9549
|
+
var delay = gap > 16 ? 0 : 16 - gap;
|
|
9550
|
+
var id = uniqueId();
|
|
9551
|
+
reservedCBs[id] = callback;
|
|
9552
|
+
// keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
|
|
9553
|
+
// 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
|
|
9554
|
+
if (Object.keys(reservedCBs).length > 1) return id;
|
|
9555
|
+
setTimeout(function () {
|
|
9556
|
+
lastTime = currentTime;
|
|
9557
|
+
var copied = reservedCBs;
|
|
9558
|
+
reservedCBs = {};
|
|
9559
|
+
Object.keys(copied).forEach(function (key) {
|
|
9560
|
+
return copied[key](pnow());
|
|
9561
|
+
});
|
|
9562
|
+
}, delay);
|
|
9563
|
+
return id;
|
|
9564
|
+
};
|
|
9565
|
+
var polyfillCaf = function polyfillCaf(id) {
|
|
9566
|
+
delete reservedCBs[id];
|
|
9567
|
+
};
|
|
9568
|
+
var vendorPrefixes = ['', 'webkit', 'moz', 'ms', 'o'];
|
|
9569
|
+
var getRequestAnimationFrame = function getRequestAnimationFrame(vp) {
|
|
9570
|
+
if (typeof vp !== 'string') return polyfillRaf;
|
|
9571
|
+
if (vp === '') return root['requestAnimationFrame'];
|
|
9572
|
+
return root[vp + 'RequestAnimationFrame'];
|
|
9573
|
+
};
|
|
9574
|
+
var getCancelAnimationFrame = function getCancelAnimationFrame(vp) {
|
|
9575
|
+
if (typeof vp !== 'string') return polyfillCaf;
|
|
9576
|
+
if (vp === '') return root['cancelAnimationFrame'];
|
|
9577
|
+
return root[vp + 'CancelAnimationFrame'] || root[vp + 'CancelRequestAnimationFrame'];
|
|
9578
|
+
};
|
|
9579
|
+
var find = function find(arr, predicate) {
|
|
9580
|
+
var i = 0;
|
|
9581
|
+
while (arr[i] !== void 0) {
|
|
9582
|
+
if (predicate(arr[i])) return arr[i];
|
|
9583
|
+
i = i + 1;
|
|
9584
|
+
}
|
|
9585
|
+
};
|
|
9586
|
+
var vp = find(vendorPrefixes, function (vp) {
|
|
9587
|
+
return !!getRequestAnimationFrame(vp);
|
|
9588
|
+
});
|
|
9589
|
+
var raf = getRequestAnimationFrame(vp);
|
|
9590
|
+
var caf = getCancelAnimationFrame(vp);
|
|
9591
|
+
root.requestAnimationFrame = raf;
|
|
9592
|
+
root.cancelAnimationFrame = caf;
|
|
9593
|
+
|
|
9594
|
+
/**
|
|
9595
|
+
* Axis-Aligned Bounding Box
|
|
9596
|
+
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
9597
|
+
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
9598
|
+
*/
|
|
9599
|
+
var AABB = /*#__PURE__*/function () {
|
|
9600
|
+
AABB.isEmpty = function isEmpty(aabb) {
|
|
9601
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
9602
|
+
};
|
|
9603
|
+
// center: vec3 = vec3.create();
|
|
9604
|
+
// halfExtents: vec3 = vec3.create();
|
|
9605
|
+
// min: vec3 = vec3.create();
|
|
9606
|
+
// max: vec3 = vec3.create();
|
|
9607
|
+
function AABB(center, halfExtents) {
|
|
9608
|
+
if (center === void 0) {
|
|
9609
|
+
center = [0, 0, 0];
|
|
9610
|
+
}
|
|
9611
|
+
if (halfExtents === void 0) {
|
|
9612
|
+
halfExtents = [0, 0, 0];
|
|
9613
|
+
}
|
|
9614
|
+
this.center = [0, 0, 0];
|
|
9615
|
+
this.halfExtents = [0, 0, 0];
|
|
9616
|
+
this.min = [0, 0, 0];
|
|
9617
|
+
this.max = [0, 0, 0];
|
|
9618
|
+
this.update(center, halfExtents);
|
|
9619
|
+
}
|
|
9620
|
+
var _proto = AABB.prototype;
|
|
9621
|
+
_proto.update = function update(center, halfExtents) {
|
|
9622
|
+
copyVec3(this.center, center);
|
|
9623
|
+
copyVec3(this.halfExtents, halfExtents);
|
|
9624
|
+
subVec3(this.min, this.center, this.halfExtents);
|
|
9625
|
+
addVec3(this.max, this.center, this.halfExtents);
|
|
9626
|
+
// vec3.copy(this.center, center);
|
|
9627
|
+
// vec3.copy(this.halfExtents, halfExtents);
|
|
9628
|
+
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
9629
|
+
// vec3.add(this.max, this.center, this.halfExtents);
|
|
9630
|
+
};
|
|
9631
|
+
_proto.setMinMax = function setMinMax(min, max) {
|
|
9632
|
+
// vec3.add(this.center, max, min);
|
|
9633
|
+
// vec3.scale(this.center, this.center, 0.5);
|
|
9634
|
+
// vec3.sub(this.halfExtents, max, min);
|
|
9635
|
+
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
9636
|
+
// vec3.copy(this.min, min);
|
|
9637
|
+
// vec3.copy(this.max, max);
|
|
9638
|
+
addVec3(this.center, max, min);
|
|
9639
|
+
scaleVec3(this.center, this.center, 0.5);
|
|
9640
|
+
subVec3(this.halfExtents, max, min);
|
|
9641
|
+
scaleVec3(this.halfExtents, this.halfExtents, 0.5);
|
|
9642
|
+
copyVec3(this.min, min);
|
|
9643
|
+
copyVec3(this.max, max);
|
|
9644
|
+
};
|
|
9645
|
+
_proto.getMin = function getMin() {
|
|
9646
|
+
return this.min;
|
|
9647
|
+
};
|
|
9648
|
+
_proto.getMax = function getMax() {
|
|
9649
|
+
return this.max;
|
|
9650
|
+
};
|
|
9651
|
+
_proto.add = function add(aabb) {
|
|
9652
|
+
if (AABB.isEmpty(aabb)) {
|
|
9653
|
+
return;
|
|
9654
|
+
}
|
|
9655
|
+
if (AABB.isEmpty(this)) {
|
|
9656
|
+
this.setMinMax(aabb.getMin(), aabb.getMax());
|
|
9657
|
+
return;
|
|
9658
|
+
}
|
|
9659
|
+
var tc = this.center;
|
|
9660
|
+
var tcx = tc[0];
|
|
9661
|
+
var tcy = tc[1];
|
|
9662
|
+
var tcz = tc[2];
|
|
9663
|
+
var th = this.halfExtents;
|
|
9664
|
+
var thx = th[0];
|
|
9665
|
+
var thy = th[1];
|
|
9666
|
+
var thz = th[2];
|
|
9667
|
+
var tminx = tcx - thx;
|
|
9668
|
+
var tmaxx = tcx + thx;
|
|
9669
|
+
var tminy = tcy - thy;
|
|
9670
|
+
var tmaxy = tcy + thy;
|
|
9671
|
+
var tminz = tcz - thz;
|
|
9672
|
+
var tmaxz = tcz + thz;
|
|
9673
|
+
var oc = aabb.center;
|
|
9674
|
+
var ocx = oc[0];
|
|
9675
|
+
var ocy = oc[1];
|
|
9676
|
+
var ocz = oc[2];
|
|
9677
|
+
var oh = aabb.halfExtents;
|
|
9678
|
+
var ohx = oh[0];
|
|
9679
|
+
var ohy = oh[1];
|
|
9680
|
+
var ohz = oh[2];
|
|
9681
|
+
var ominx = ocx - ohx;
|
|
9682
|
+
var omaxx = ocx + ohx;
|
|
9683
|
+
var ominy = ocy - ohy;
|
|
9684
|
+
var omaxy = ocy + ohy;
|
|
9685
|
+
var ominz = ocz - ohz;
|
|
9686
|
+
var omaxz = ocz + ohz;
|
|
9687
|
+
if (ominx < tminx) {
|
|
9688
|
+
tminx = ominx;
|
|
9689
|
+
}
|
|
9690
|
+
if (omaxx > tmaxx) {
|
|
9691
|
+
tmaxx = omaxx;
|
|
9692
|
+
}
|
|
9693
|
+
if (ominy < tminy) {
|
|
9694
|
+
tminy = ominy;
|
|
9695
|
+
}
|
|
9696
|
+
if (omaxy > tmaxy) {
|
|
9697
|
+
tmaxy = omaxy;
|
|
9698
|
+
}
|
|
9699
|
+
if (ominz < tminz) {
|
|
9700
|
+
tminz = ominz;
|
|
9701
|
+
}
|
|
9702
|
+
if (omaxz > tmaxz) {
|
|
9703
|
+
tmaxz = omaxz;
|
|
9704
|
+
}
|
|
9705
|
+
tc[0] = (tminx + tmaxx) * 0.5;
|
|
9706
|
+
tc[1] = (tminy + tmaxy) * 0.5;
|
|
9707
|
+
tc[2] = (tminz + tmaxz) * 0.5;
|
|
9708
|
+
th[0] = (tmaxx - tminx) * 0.5;
|
|
9709
|
+
th[1] = (tmaxy - tminy) * 0.5;
|
|
9710
|
+
th[2] = (tmaxz - tminz) * 0.5;
|
|
9711
|
+
this.min[0] = tminx;
|
|
9712
|
+
this.min[1] = tminy;
|
|
9713
|
+
this.min[2] = tminz;
|
|
9714
|
+
this.max[0] = tmaxx;
|
|
9715
|
+
this.max[1] = tmaxy;
|
|
9716
|
+
this.max[2] = tmaxz;
|
|
9717
|
+
};
|
|
9718
|
+
_proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
|
|
9719
|
+
var bc = this.center;
|
|
9720
|
+
var br = this.halfExtents;
|
|
9721
|
+
var ac = aabb.center;
|
|
9722
|
+
var ar = aabb.halfExtents;
|
|
9723
|
+
var mx0 = m[0];
|
|
9724
|
+
var mx1 = m[4];
|
|
9725
|
+
var mx2 = m[8];
|
|
9726
|
+
var my0 = m[1];
|
|
9727
|
+
var my1 = m[5];
|
|
9728
|
+
var my2 = m[9];
|
|
9729
|
+
var mz0 = m[2];
|
|
9730
|
+
var mz1 = m[6];
|
|
9731
|
+
var mz2 = m[10];
|
|
9732
|
+
var mx0a = Math.abs(mx0);
|
|
9733
|
+
var mx1a = Math.abs(mx1);
|
|
9734
|
+
var mx2a = Math.abs(mx2);
|
|
9735
|
+
var my0a = Math.abs(my0);
|
|
9736
|
+
var my1a = Math.abs(my1);
|
|
9737
|
+
var my2a = Math.abs(my2);
|
|
9738
|
+
var mz0a = Math.abs(mz0);
|
|
9739
|
+
var mz1a = Math.abs(mz1);
|
|
9740
|
+
var mz2a = Math.abs(mz2);
|
|
9741
|
+
bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
|
|
9742
|
+
bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
|
|
9743
|
+
bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
|
|
9744
|
+
// vec3.set(
|
|
9745
|
+
// bc,
|
|
9746
|
+
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
9747
|
+
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
9748
|
+
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
9749
|
+
// );
|
|
9750
|
+
br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
|
|
9751
|
+
br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
|
|
9752
|
+
br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
|
|
9753
|
+
// vec3.set(
|
|
9754
|
+
// br,
|
|
9755
|
+
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
9756
|
+
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
9757
|
+
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
9758
|
+
// );
|
|
9759
|
+
// this.min = vec3.sub(this.min, bc, br);
|
|
9760
|
+
// this.max = vec3.add(this.max, bc, br);
|
|
9761
|
+
subVec3(this.min, bc, br);
|
|
9762
|
+
addVec3(this.max, bc, br);
|
|
9763
|
+
};
|
|
9764
|
+
_proto.intersects = function intersects(aabb) {
|
|
9765
|
+
var aMax = this.getMax();
|
|
9766
|
+
var aMin = this.getMin();
|
|
9767
|
+
var bMax = aabb.getMax();
|
|
9768
|
+
var bMin = aabb.getMin();
|
|
9769
|
+
return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
|
|
9770
|
+
};
|
|
9771
|
+
_proto.intersection = function intersection(aabb) {
|
|
9772
|
+
if (!this.intersects(aabb)) {
|
|
9773
|
+
return null;
|
|
9774
|
+
}
|
|
9775
|
+
var intersection = new AABB();
|
|
9776
|
+
// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
9777
|
+
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
9778
|
+
var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
|
|
9779
|
+
var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
|
|
9780
|
+
intersection.setMinMax(min, max);
|
|
9781
|
+
return intersection;
|
|
10840
9782
|
}
|
|
10841
|
-
|
|
10842
|
-
|
|
9783
|
+
// containsPoint(point: vec3) {
|
|
9784
|
+
// const min = this.getMin();
|
|
9785
|
+
// const max = this.getMax();
|
|
9786
|
+
// return !(
|
|
9787
|
+
// point[0] < min[0] ||
|
|
9788
|
+
// point[0] > max[0] ||
|
|
9789
|
+
// point[1] < min[1] ||
|
|
9790
|
+
// point[1] > max[1] ||
|
|
9791
|
+
// point[2] < min[2] ||
|
|
9792
|
+
// point[2] > max[2]
|
|
9793
|
+
// );
|
|
9794
|
+
// }
|
|
9795
|
+
/**
|
|
9796
|
+
* get n-vertex
|
|
9797
|
+
* @param plane plane of CullingVolume
|
|
9798
|
+
*/;
|
|
9799
|
+
_proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
|
|
9800
|
+
if (plane.pnVertexFlag === 0x111) {
|
|
9801
|
+
return copyVec3([0, 0, 0], this.min);
|
|
9802
|
+
// return vec3.copy(vec3.create(), this.min);
|
|
9803
|
+
} else if (plane.pnVertexFlag === 0x110) {
|
|
9804
|
+
return [this.min[0], this.min[1], this.max[2]];
|
|
9805
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
9806
|
+
} else if (plane.pnVertexFlag === 0x101) {
|
|
9807
|
+
return [this.min[0], this.max[1], this.min[2]];
|
|
9808
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
9809
|
+
} else if (plane.pnVertexFlag === 0x100) {
|
|
9810
|
+
return [this.min[0], this.max[1], this.max[2]];
|
|
9811
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
9812
|
+
} else if (plane.pnVertexFlag === 0x011) {
|
|
9813
|
+
return [this.max[0], this.min[1], this.min[2]];
|
|
9814
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
9815
|
+
} else if (plane.pnVertexFlag === 0x010) {
|
|
9816
|
+
return [this.max[0], this.min[1], this.max[2]];
|
|
9817
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
9818
|
+
} else if (plane.pnVertexFlag === 0x001) {
|
|
9819
|
+
return [this.max[0], this.max[1], this.min[2]];
|
|
9820
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
9821
|
+
} else {
|
|
9822
|
+
return [this.max[0], this.max[1], this.max[2]];
|
|
9823
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9826
|
+
/**
|
|
9827
|
+
* get p-vertex
|
|
9828
|
+
* @param plane plane of CullingVolume
|
|
9829
|
+
*/;
|
|
9830
|
+
_proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
|
|
9831
|
+
if (plane.pnVertexFlag === 0x111) {
|
|
9832
|
+
return copyVec3([0, 0, 0], this.max);
|
|
9833
|
+
// return vec3.copy(vec3.create(), this.max);
|
|
9834
|
+
} else if (plane.pnVertexFlag === 0x110) {
|
|
9835
|
+
return [this.max[0], this.max[1], this.min[2]];
|
|
9836
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
9837
|
+
} else if (plane.pnVertexFlag === 0x101) {
|
|
9838
|
+
return [this.max[0], this.min[1], this.max[2]];
|
|
9839
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
9840
|
+
} else if (plane.pnVertexFlag === 0x100) {
|
|
9841
|
+
return [this.max[0], this.min[1], this.min[2]];
|
|
9842
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
9843
|
+
} else if (plane.pnVertexFlag === 0x011) {
|
|
9844
|
+
return [this.min[0], this.max[1], this.max[2]];
|
|
9845
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
9846
|
+
} else if (plane.pnVertexFlag === 0x010) {
|
|
9847
|
+
return [this.min[0], this.max[1], this.min[2]];
|
|
9848
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
9849
|
+
} else if (plane.pnVertexFlag === 0x001) {
|
|
9850
|
+
return [this.min[0], this.min[1], this.max[2]];
|
|
9851
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
9852
|
+
} else {
|
|
9853
|
+
return [this.min[0], this.min[1], this.min[2]];
|
|
9854
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
9855
|
+
}
|
|
9856
|
+
};
|
|
9857
|
+
return AABB;
|
|
9858
|
+
}();
|
|
10843
9859
|
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
var root = typeof self === 'object' && self.self == self ? self :
|
|
10857
|
-
// @ts-ignore
|
|
10858
|
-
typeof global === 'object' && global.global == global ?
|
|
10859
|
-
// @ts-ignore
|
|
10860
|
-
global : {};
|
|
10861
|
-
var nowOffset = Date.now();
|
|
10862
|
-
// use performance api if exist, otherwise use Date.now.
|
|
10863
|
-
// Date.now polyfill required.
|
|
10864
|
-
var pnow = function pnow() {
|
|
10865
|
-
if (root.performance && typeof root.performance.now === 'function') {
|
|
10866
|
-
return root.performance.now();
|
|
9860
|
+
var Plane = /*#__PURE__*/function () {
|
|
9861
|
+
/**
|
|
9862
|
+
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
9863
|
+
*/
|
|
9864
|
+
|
|
9865
|
+
function Plane(distance, normal) {
|
|
9866
|
+
this.distance = void 0;
|
|
9867
|
+
this.normal = void 0;
|
|
9868
|
+
this.pnVertexFlag = void 0;
|
|
9869
|
+
this.distance = distance || 0;
|
|
9870
|
+
this.normal = normal || vec3.fromValues(0, 1, 0);
|
|
9871
|
+
this.updatePNVertexFlag();
|
|
10867
9872
|
}
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
9873
|
+
var _proto = Plane.prototype;
|
|
9874
|
+
_proto.updatePNVertexFlag = function updatePNVertexFlag() {
|
|
9875
|
+
this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
|
|
9876
|
+
};
|
|
9877
|
+
_proto.distanceToPoint = function distanceToPoint(point) {
|
|
9878
|
+
return vec3.dot(point, this.normal) - this.distance;
|
|
9879
|
+
};
|
|
9880
|
+
_proto.normalize = function normalize() {
|
|
9881
|
+
var invLen = 1 / vec3.len(this.normal);
|
|
9882
|
+
vec3.scale(this.normal, this.normal, invLen);
|
|
9883
|
+
this.distance *= invLen;
|
|
9884
|
+
};
|
|
9885
|
+
_proto.intersectsLine = function intersectsLine(start, end, point) {
|
|
9886
|
+
var d0 = this.distanceToPoint(start);
|
|
9887
|
+
var d1 = this.distanceToPoint(end);
|
|
9888
|
+
var t = d0 / (d0 - d1);
|
|
9889
|
+
var intersects = t >= 0 && t <= 1;
|
|
9890
|
+
if (intersects && point) {
|
|
9891
|
+
vec3.lerp(point, start, end, t);
|
|
9892
|
+
}
|
|
9893
|
+
return intersects;
|
|
9894
|
+
};
|
|
9895
|
+
return Plane;
|
|
9896
|
+
}();
|
|
9897
|
+
|
|
9898
|
+
var Mask;
|
|
9899
|
+
(function (Mask) {
|
|
9900
|
+
Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
|
|
9901
|
+
Mask[Mask["INSIDE"] = 0] = "INSIDE";
|
|
9902
|
+
Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
|
|
9903
|
+
})(Mask || (Mask = {}));
|
|
9904
|
+
var Frustum = /*#__PURE__*/function () {
|
|
9905
|
+
function Frustum(planes) {
|
|
9906
|
+
this.planes = [];
|
|
9907
|
+
if (planes) {
|
|
9908
|
+
this.planes = planes;
|
|
9909
|
+
} else {
|
|
9910
|
+
for (var i = 0; i < 6; i++) {
|
|
9911
|
+
this.planes.push(new Plane());
|
|
9912
|
+
}
|
|
9913
|
+
}
|
|
10876
9914
|
}
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
9915
|
+
/**
|
|
9916
|
+
* extract 6 planes from projectionMatrix
|
|
9917
|
+
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
9918
|
+
*/
|
|
9919
|
+
var _proto = Frustum.prototype;
|
|
9920
|
+
_proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
|
|
9921
|
+
// @ts-ignore
|
|
9922
|
+
var m0 = projectionMatrix[0],
|
|
9923
|
+
m1 = projectionMatrix[1],
|
|
9924
|
+
m2 = projectionMatrix[2],
|
|
9925
|
+
m3 = projectionMatrix[3],
|
|
9926
|
+
m4 = projectionMatrix[4],
|
|
9927
|
+
m5 = projectionMatrix[5],
|
|
9928
|
+
m6 = projectionMatrix[6],
|
|
9929
|
+
m7 = projectionMatrix[7],
|
|
9930
|
+
m8 = projectionMatrix[8],
|
|
9931
|
+
m9 = projectionMatrix[9],
|
|
9932
|
+
m10 = projectionMatrix[10],
|
|
9933
|
+
m11 = projectionMatrix[11],
|
|
9934
|
+
m12 = projectionMatrix[12],
|
|
9935
|
+
m13 = projectionMatrix[13],
|
|
9936
|
+
m14 = projectionMatrix[14],
|
|
9937
|
+
m15 = projectionMatrix[15];
|
|
9938
|
+
// right
|
|
9939
|
+
vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
|
|
9940
|
+
this.planes[0].distance = m15 - m12;
|
|
9941
|
+
// left
|
|
9942
|
+
vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
|
|
9943
|
+
this.planes[1].distance = m15 + m12;
|
|
9944
|
+
// bottom
|
|
9945
|
+
vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
|
|
9946
|
+
this.planes[2].distance = m15 + m13;
|
|
9947
|
+
// top
|
|
9948
|
+
vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
|
|
9949
|
+
this.planes[3].distance = m15 - m13;
|
|
9950
|
+
// far
|
|
9951
|
+
vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
|
|
9952
|
+
this.planes[4].distance = m15 - m14;
|
|
9953
|
+
// near
|
|
9954
|
+
vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
|
|
9955
|
+
this.planes[5].distance = m15 + m14;
|
|
9956
|
+
this.planes.forEach(function (plane) {
|
|
9957
|
+
plane.normalize();
|
|
9958
|
+
plane.updatePNVertexFlag();
|
|
10891
9959
|
});
|
|
10892
|
-
}
|
|
10893
|
-
return
|
|
10894
|
-
};
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
9960
|
+
};
|
|
9961
|
+
return Frustum;
|
|
9962
|
+
}();
|
|
9963
|
+
|
|
9964
|
+
var Rectangle = /*#__PURE__*/function () {
|
|
9965
|
+
function Rectangle(x, y, width, height) {
|
|
9966
|
+
this.x = void 0;
|
|
9967
|
+
this.y = void 0;
|
|
9968
|
+
this.width = void 0;
|
|
9969
|
+
this.height = void 0;
|
|
9970
|
+
this.left = void 0;
|
|
9971
|
+
this.right = void 0;
|
|
9972
|
+
this.top = void 0;
|
|
9973
|
+
this.bottom = void 0;
|
|
9974
|
+
this.x = x;
|
|
9975
|
+
this.y = y;
|
|
9976
|
+
this.width = width;
|
|
9977
|
+
this.height = height;
|
|
9978
|
+
this.left = x;
|
|
9979
|
+
this.right = x + width;
|
|
9980
|
+
this.top = y;
|
|
9981
|
+
this.bottom = y + height;
|
|
10914
9982
|
}
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
return
|
|
10918
|
-
});
|
|
10919
|
-
var raf = getRequestAnimationFrame(vp);
|
|
10920
|
-
var caf = getCancelAnimationFrame(vp);
|
|
10921
|
-
root.requestAnimationFrame = raf;
|
|
10922
|
-
root.cancelAnimationFrame = caf;
|
|
9983
|
+
var _proto = Rectangle.prototype;
|
|
9984
|
+
_proto.toJSON = function toJSON() {};
|
|
9985
|
+
return Rectangle;
|
|
9986
|
+
}();
|
|
10923
9987
|
|
|
10924
9988
|
/**
|
|
10925
9989
|
* Blink used them in code generation(css_properties.json5)
|
|
@@ -11416,9 +10480,9 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
11416
10480
|
var propertyMetadataCache = {};
|
|
11417
10481
|
var unresolvedProperties = new WeakMap();
|
|
11418
10482
|
// const uniqueAttributeSet = new Set<string>();
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
10483
|
+
// const tmpVec3a = vec3.create();
|
|
10484
|
+
// const tmpVec3b = vec3.create();
|
|
10485
|
+
// const tmpVec3c = vec3.create();
|
|
11422
10486
|
var isPropertyResolved = function isPropertyResolved(object, name) {
|
|
11423
10487
|
var properties = unresolvedProperties.get(object);
|
|
11424
10488
|
if (!properties || properties.length === 0) {
|
|
@@ -11468,6 +10532,25 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11468
10532
|
usedAttributes: []
|
|
11469
10533
|
};
|
|
11470
10534
|
}
|
|
10535
|
+
if (!runtime.enableCSSParsing) {
|
|
10536
|
+
Object.assign(object.attributes, attributes);
|
|
10537
|
+
object.parsedStyle = Object.assign(object.parsedStyle, attributes);
|
|
10538
|
+
if (attributes.fill) {
|
|
10539
|
+
object.parsedStyle.fill = parseColor(attributes.fill);
|
|
10540
|
+
}
|
|
10541
|
+
if (attributes.stroke) {
|
|
10542
|
+
object.parsedStyle.stroke = parseColor(attributes.stroke);
|
|
10543
|
+
}
|
|
10544
|
+
// @ts-ignore
|
|
10545
|
+
if (attributes.cx || attributes.cy) {
|
|
10546
|
+
// @ts-ignore
|
|
10547
|
+
runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object);
|
|
10548
|
+
}
|
|
10549
|
+
// console.log(object.parsedStyle);
|
|
10550
|
+
// console.log(attributes);
|
|
10551
|
+
this.updateGeometry(object);
|
|
10552
|
+
return;
|
|
10553
|
+
}
|
|
11471
10554
|
var _options = options,
|
|
11472
10555
|
skipUpdateAttribute = _options.skipUpdateAttribute,
|
|
11473
10556
|
skipParse = _options.skipParse,
|
|
@@ -11526,10 +10609,10 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11526
10609
|
}
|
|
11527
10610
|
attributeNames.forEach(function (name) {
|
|
11528
10611
|
if (name in object.parsedStyle) {
|
|
11529
|
-
_this2.postProcessProperty(name, object);
|
|
10612
|
+
_this2.postProcessProperty(name, object, attributeNames);
|
|
11530
10613
|
}
|
|
11531
10614
|
});
|
|
11532
|
-
if (object.children.length) {
|
|
10615
|
+
if (runtime.enableCSSParsing && object.children.length) {
|
|
11533
10616
|
attributeNames.forEach(function (name) {
|
|
11534
10617
|
if (name in object.parsedStyle && _this2.isPropertyInheritable(name)) {
|
|
11535
10618
|
// update children's inheritable
|
|
@@ -11632,13 +10715,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11632
10715
|
// return false;
|
|
11633
10716
|
return used;
|
|
11634
10717
|
};
|
|
11635
|
-
_proto.postProcessProperty = function postProcessProperty(name, object) {
|
|
10718
|
+
_proto.postProcessProperty = function postProcessProperty(name, object, attributes) {
|
|
11636
10719
|
var metadata = propertyMetadataCache[name];
|
|
11637
10720
|
if (metadata && metadata.syntax) {
|
|
11638
10721
|
var handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
|
|
11639
10722
|
var propertyHandler = handler;
|
|
11640
10723
|
if (propertyHandler && propertyHandler.postProcessor) {
|
|
11641
|
-
propertyHandler.postProcessor(object);
|
|
10724
|
+
propertyHandler.postProcessor(object, attributes);
|
|
11642
10725
|
}
|
|
11643
10726
|
}
|
|
11644
10727
|
}
|
|
@@ -11723,7 +10806,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11723
10806
|
var flipY = width < 0;
|
|
11724
10807
|
var flipX = height < 0;
|
|
11725
10808
|
// init with content box
|
|
11726
|
-
var halfExtents =
|
|
10809
|
+
var halfExtents = [Math.abs(width) / 2, Math.abs(height) / 2, depth / 2];
|
|
10810
|
+
// const halfExtents = vec3.set(
|
|
10811
|
+
// tmpVec3a,
|
|
10812
|
+
// Math.abs(width) / 2,
|
|
10813
|
+
// Math.abs(height) / 2,
|
|
10814
|
+
// depth / 2,
|
|
10815
|
+
// );
|
|
11727
10816
|
// anchor is center by default, don't account for lineWidth here
|
|
11728
10817
|
var stroke = parsedStyle.stroke,
|
|
11729
10818
|
lineWidth = parsedStyle.lineWidth,
|
|
@@ -11738,7 +10827,13 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11738
10827
|
if (object.nodeName === Shape.TEXT) {
|
|
11739
10828
|
delete parsedStyle.anchor;
|
|
11740
10829
|
}
|
|
11741
|
-
var center =
|
|
10830
|
+
var center = [(1 - (anchor && anchor[0] || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1] || 0) * 2) * height / 2 + offsetY, (1 - (anchor && anchor[2] || 0) * 2) * halfExtents[2] + offsetZ];
|
|
10831
|
+
// const center = vec3.set(
|
|
10832
|
+
// tmpVec3b,
|
|
10833
|
+
// ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
|
|
10834
|
+
// ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
|
|
10835
|
+
// (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
|
|
10836
|
+
// );
|
|
11742
10837
|
// update geometry's AABB
|
|
11743
10838
|
geometry.contentBounds.update(center, halfExtents);
|
|
11744
10839
|
// @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
|
|
@@ -11755,8 +10850,15 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11755
10850
|
var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) * expansion;
|
|
11756
10851
|
// halfExtents[0] += halfLineWidth[0];
|
|
11757
10852
|
// halfExtents[1] += halfLineWidth[1];
|
|
11758
|
-
|
|
10853
|
+
halfExtents[0] += halfLineWidth;
|
|
10854
|
+
halfExtents[1] += halfLineWidth;
|
|
10855
|
+
// vec3.add(
|
|
10856
|
+
// halfExtents,
|
|
10857
|
+
// halfExtents,
|
|
10858
|
+
// vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
|
|
10859
|
+
// );
|
|
11759
10860
|
}
|
|
10861
|
+
|
|
11760
10862
|
geometry.renderBounds.update(center, halfExtents);
|
|
11761
10863
|
// account for shadow, only support constant value now
|
|
11762
10864
|
if (shadowColor && shadowType && shadowType !== 'inner') {
|
|
@@ -11785,7 +10887,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11785
10887
|
params = _ref.params;
|
|
11786
10888
|
if (name === 'blur') {
|
|
11787
10889
|
var blurRadius = params[0].value;
|
|
11788
|
-
geometry.renderBounds.update(geometry.renderBounds.center,
|
|
10890
|
+
geometry.renderBounds.update(geometry.renderBounds.center, addVec3(geometry.renderBounds.halfExtents, geometry.renderBounds.halfExtents, [blurRadius, blurRadius, 0]));
|
|
11789
10891
|
} else if (name === 'drop-shadow') {
|
|
11790
10892
|
var _shadowOffsetX = params[0].value;
|
|
11791
10893
|
var _shadowOffsetY = params[1].value;
|
|
@@ -11806,8 +10908,8 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11806
10908
|
});
|
|
11807
10909
|
anchor = parsedStyle.anchor;
|
|
11808
10910
|
// set transform origin
|
|
11809
|
-
var usedOriginXValue = (flipY ? -1 : 1) * convertPercentUnit(transformOrigin[0], 0, object);
|
|
11810
|
-
var usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
|
|
10911
|
+
var usedOriginXValue = (flipY ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[0], 0, object) : 0);
|
|
10912
|
+
var usedOriginYValue = (flipX ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[1], 1, object) : 0);
|
|
11811
10913
|
usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
|
|
11812
10914
|
usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
|
|
11813
10915
|
object.setOrigin(usedOriginXValue, usedOriginYValue);
|
|
@@ -13700,37 +12802,37 @@ var OffscreenCanvasCreator = /*#__PURE__*/function () {
|
|
|
13700
12802
|
this.context = void 0;
|
|
13701
12803
|
}
|
|
13702
12804
|
var _proto = OffscreenCanvasCreator.prototype;
|
|
13703
|
-
_proto.getOrCreateCanvas = function getOrCreateCanvas(offscreenCanvas) {
|
|
12805
|
+
_proto.getOrCreateCanvas = function getOrCreateCanvas(offscreenCanvas, contextAttributes) {
|
|
13704
12806
|
if (this.canvas) {
|
|
13705
12807
|
return this.canvas;
|
|
13706
12808
|
}
|
|
13707
12809
|
// user-defined offscreen canvas
|
|
13708
12810
|
if (offscreenCanvas) {
|
|
13709
12811
|
this.canvas = offscreenCanvas;
|
|
13710
|
-
this.context = this.canvas.getContext('2d');
|
|
12812
|
+
this.context = this.canvas.getContext('2d', contextAttributes);
|
|
13711
12813
|
} else {
|
|
13712
12814
|
try {
|
|
13713
12815
|
// OffscreenCanvas2D measureText can be up to 40% faster.
|
|
13714
12816
|
this.canvas = new window.OffscreenCanvas(0, 0);
|
|
13715
|
-
this.context = this.canvas.getContext('2d');
|
|
12817
|
+
this.context = this.canvas.getContext('2d', contextAttributes);
|
|
13716
12818
|
if (!this.context || !this.context.measureText) {
|
|
13717
12819
|
this.canvas = document.createElement('canvas');
|
|
13718
12820
|
this.context = this.canvas.getContext('2d');
|
|
13719
12821
|
}
|
|
13720
12822
|
} catch (ex) {
|
|
13721
12823
|
this.canvas = document.createElement('canvas');
|
|
13722
|
-
this.context = this.canvas.getContext('2d');
|
|
12824
|
+
this.context = this.canvas.getContext('2d', contextAttributes);
|
|
13723
12825
|
}
|
|
13724
12826
|
}
|
|
13725
12827
|
this.canvas.width = 10;
|
|
13726
12828
|
this.canvas.height = 10;
|
|
13727
12829
|
return this.canvas;
|
|
13728
12830
|
};
|
|
13729
|
-
_proto.getOrCreateContext = function getOrCreateContext(offscreenCanvas) {
|
|
12831
|
+
_proto.getOrCreateContext = function getOrCreateContext(offscreenCanvas, contextAttributes) {
|
|
13730
12832
|
if (this.context) {
|
|
13731
12833
|
return this.context;
|
|
13732
12834
|
}
|
|
13733
|
-
this.getOrCreateCanvas(offscreenCanvas);
|
|
12835
|
+
this.getOrCreateCanvas(offscreenCanvas, contextAttributes);
|
|
13734
12836
|
return this.context;
|
|
13735
12837
|
};
|
|
13736
12838
|
return OffscreenCanvasCreator;
|
|
@@ -13897,7 +12999,9 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
13897
12999
|
enableDirtyCheck = _canvasConfig$rendere.enableDirtyCheck,
|
|
13898
13000
|
enableCulling = _canvasConfig$rendere.enableCulling;
|
|
13899
13001
|
// recalc style values
|
|
13900
|
-
this.globalRuntime.
|
|
13002
|
+
if (this.globalRuntime.enableCSSParsing) {
|
|
13003
|
+
this.globalRuntime.styleValueRegistry.recalc(displayObject);
|
|
13004
|
+
}
|
|
13901
13005
|
// TODO: relayout
|
|
13902
13006
|
// dirtycheck first
|
|
13903
13007
|
var objectChanged = enableDirtyCheck ? this.hooks.dirtycheck.call(displayObject) : displayObject;
|
|
@@ -15233,6 +14337,7 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
|
|
|
15233
14337
|
runtime.styleValueRegistry = new DefaultStyleValueRegistry();
|
|
15234
14338
|
runtime.layoutRegistry = null;
|
|
15235
14339
|
runtime.globalThis = getGlobalThis();
|
|
14340
|
+
runtime.enableCSSParsing = true;
|
|
15236
14341
|
|
|
15237
14342
|
var AbstractRendererPlugin = /*#__PURE__*/function () {
|
|
15238
14343
|
function AbstractRendererPlugin() {
|
|
@@ -15775,8 +14880,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15775
14880
|
};
|
|
15776
14881
|
var handleMounted = function handleMounted(e) {
|
|
15777
14882
|
var object = e.target;
|
|
15778
|
-
|
|
15779
|
-
|
|
14883
|
+
if (runtime.enableCSSParsing) {
|
|
14884
|
+
// recalc style values
|
|
14885
|
+
runtime.styleValueRegistry.recalc(object);
|
|
14886
|
+
}
|
|
15780
14887
|
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
15781
14888
|
renderingService.dirtify();
|
|
15782
14889
|
};
|
|
@@ -15811,6 +14918,7 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15811
14918
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15812
14919
|
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
15813
14920
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14921
|
+
_this.toSync.clear();
|
|
15814
14922
|
});
|
|
15815
14923
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
15816
14924
|
// if (this.isFirstTimeRendering) {
|