@antv/g 5.0.22 → 5.0.23-alpha.11
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/index.umd.min.js +3 -3
- package/es/AbstractRenderer.js +5 -0
- package/es/camera/Camera.js +2 -2
- package/es/css/StyleValueRegistry.d.ts +2 -0
- package/es/css/StyleValueRegistry.js +7 -3
- package/es/css/cssom/CSSKeywordValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericValue.d.ts +141 -4
- package/es/css/cssom/CSSNumericValue.js +1166 -5
- package/es/css/cssom/CSSTransformValue.d.ts +1 -1
- package/es/css/cssom/index.d.ts +0 -10
- package/es/css/cssom/index.js +1 -11
- package/es/css/parser/color.js +1 -1
- package/es/css/parser/dimension.js +1 -2
- package/es/css/parser/numeric.d.ts +1 -1
- package/es/css/parser/numeric.js +2 -2
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +1 -1
- package/es/css/parser/points.js +1 -1
- package/es/css/parser/transform-origin.d.ts +1 -1
- package/es/css/parser/transform-origin.js +2 -2
- package/es/css/parser/transform.d.ts +1 -3
- package/es/css/parser/transform.js +9 -8
- package/es/css/properties/CSSPropertyPath.d.ts +14 -2
- package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/es/css/properties/CSSPropertyTransform.js +3 -4
- package/es/display-objects/DisplayObject.js +4 -5
- package/es/display-objects/Path.d.ts +15 -15
- package/es/display-objects/Path.js +1 -1
- package/es/display-objects/Polygon.d.ts +8 -1
- package/es/display-objects/Polyline.d.ts +7 -5
- package/es/dom/Document.js +2 -2
- package/es/dom/Element.js +1 -2
- package/es/dom/EventTarget.js +1 -1
- package/es/dom/FederatedTouchEvent.d.ts +5 -3
- package/es/plugins/CullingPlugin.d.ts +0 -1
- package/es/plugins/CullingPlugin.js +3 -8
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +9 -8
- package/es/plugins/EventPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.js +163 -148
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +17 -18
- package/es/services/EventService.d.ts +8 -0
- package/es/services/EventService.js +274 -20
- package/es/services/RenderingService.d.ts +17 -16
- package/es/services/RenderingService.js +20 -19
- package/es/services/SceneGraphService.js +1 -1
- package/es/services/aabb/PathUpdater.d.ts +3 -3
- package/es/services/aabb/PolylineUpdater.d.ts +3 -3
- package/es/services/aabb/RectUpdater.js +1 -1
- package/es/types.d.ts +5 -3
- package/es/utils/assert.d.ts +6 -0
- package/es/utils/assert.js +18 -0
- package/es/utils/event.d.ts +18 -16
- package/es/utils/hooks.d.ts +280 -0
- package/es/utils/hooks.js +753 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/math.d.ts +1 -0
- package/es/utils/math.js +13 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +8 -0
- package/es/utils/text.js +2 -1
- package/lib/AbstractRenderer.js +5 -0
- package/lib/camera/Camera.js +4 -4
- package/lib/css/StyleValueRegistry.d.ts +2 -0
- package/lib/css/StyleValueRegistry.js +13 -5
- package/lib/css/cssom/CSSKeywordValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValue.d.ts +141 -4
- package/lib/css/cssom/CSSNumericValue.js +1226 -52
- package/lib/css/cssom/CSSTransformValue.d.ts +1 -1
- package/lib/css/cssom/index.d.ts +0 -10
- package/lib/css/cssom/index.js +0 -130
- package/lib/css/parser/color.js +5 -5
- package/lib/css/parser/dimension.js +1 -3
- package/lib/css/parser/numeric.d.ts +1 -1
- package/lib/css/parser/numeric.js +7 -7
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +4 -4
- package/lib/css/parser/points.js +2 -2
- package/lib/css/parser/transform-origin.d.ts +1 -1
- package/lib/css/parser/transform-origin.js +4 -4
- package/lib/css/parser/transform.d.ts +1 -3
- package/lib/css/parser/transform.js +25 -24
- package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/lib/css/properties/CSSPropertyTransform.js +18 -20
- package/lib/display-objects/DisplayObject.js +7 -9
- package/lib/display-objects/Path.d.ts +15 -15
- package/lib/display-objects/Path.js +3 -3
- package/lib/display-objects/Polygon.d.ts +8 -1
- package/lib/display-objects/Polyline.d.ts +7 -5
- package/lib/dom/Document.js +2 -2
- package/lib/dom/Element.js +1 -3
- package/lib/dom/EventTarget.js +9 -9
- package/lib/dom/FederatedTouchEvent.d.ts +5 -3
- package/lib/plugins/CullingPlugin.d.ts +0 -1
- package/lib/plugins/CullingPlugin.js +3 -7
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +10 -8
- package/lib/plugins/EventPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.js +172 -156
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +16 -16
- package/lib/services/EventService.d.ts +8 -0
- package/lib/services/EventService.js +274 -19
- package/lib/services/RenderingService.d.ts +17 -16
- package/lib/services/RenderingService.js +21 -20
- package/lib/services/SceneGraphService.js +3 -3
- package/lib/services/aabb/PathUpdater.d.ts +3 -3
- package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/types.d.ts +5 -3
- package/lib/utils/assert.d.ts +6 -0
- package/lib/utils/assert.js +30 -0
- package/lib/utils/event.d.ts +18 -16
- package/lib/utils/hooks.d.ts +280 -0
- package/lib/utils/hooks.js +759 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/math.d.ts +1 -0
- package/lib/utils/math.js +17 -4
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +11 -0
- package/lib/utils/text.js +5 -3
- package/package.json +4 -7
- package/es/css/cssom/CSSMathInvert.d.ts +0 -14
- package/es/css/cssom/CSSMathInvert.js +0 -84
- package/es/css/cssom/CSSMathMax.d.ts +0 -17
- package/es/css/cssom/CSSMathMax.js +0 -118
- package/es/css/cssom/CSSMathMin.d.ts +0 -17
- package/es/css/cssom/CSSMathMin.js +0 -119
- package/es/css/cssom/CSSMathNegate.d.ts +0 -14
- package/es/css/cssom/CSSMathNegate.js +0 -80
- package/es/css/cssom/CSSMathProduct.d.ts +0 -16
- package/es/css/cssom/CSSMathProduct.js +0 -109
- package/es/css/cssom/CSSMathSum.d.ts +0 -17
- package/es/css/cssom/CSSMathSum.js +0 -117
- package/es/css/cssom/CSSMathValue.d.ts +0 -11
- package/es/css/cssom/CSSMathValue.js +0 -27
- package/es/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/es/css/cssom/CSSMathVariadic.js +0 -44
- package/es/css/cssom/CSSNumericValueType.d.ts +0 -33
- package/es/css/cssom/CSSNumericValueType.js +0 -259
- package/es/css/cssom/CSSUnitValue.d.ts +0 -33
- package/es/css/cssom/CSSUnitValue.js +0 -252
- package/lib/css/cssom/CSSMathInvert.d.ts +0 -14
- package/lib/css/cssom/CSSMathInvert.js +0 -94
- package/lib/css/cssom/CSSMathMax.d.ts +0 -17
- package/lib/css/cssom/CSSMathMax.js +0 -128
- package/lib/css/cssom/CSSMathMin.d.ts +0 -17
- package/lib/css/cssom/CSSMathMin.js +0 -128
- package/lib/css/cssom/CSSMathNegate.d.ts +0 -14
- package/lib/css/cssom/CSSMathNegate.js +0 -89
- package/lib/css/cssom/CSSMathProduct.d.ts +0 -16
- package/lib/css/cssom/CSSMathProduct.js +0 -119
- package/lib/css/cssom/CSSMathSum.d.ts +0 -17
- package/lib/css/cssom/CSSMathSum.js +0 -129
- package/lib/css/cssom/CSSMathValue.d.ts +0 -11
- package/lib/css/cssom/CSSMathValue.js +0 -35
- package/lib/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/lib/css/cssom/CSSMathVariadic.js +0 -55
- package/lib/css/cssom/CSSNumericValueType.d.ts +0 -33
- package/lib/css/cssom/CSSNumericValueType.js +0 -272
- package/lib/css/cssom/CSSUnitValue.d.ts +0 -33
- package/lib/css/cssom/CSSUnitValue.js +0 -267
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSNumericValueType = exports.BaseType = void 0;
|
|
7
|
-
exports.baseTypeToString = baseTypeToString;
|
|
8
|
-
exports.unitTypeToBaseType = unitTypeToBaseType;
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _ = require(".");
|
|
13
|
-
|
|
14
|
-
// https://drafts.css-houdini.org/css-typed-om/#enumdef-cssnumericbasetype
|
|
15
|
-
var BaseType;
|
|
16
|
-
exports.BaseType = BaseType;
|
|
17
|
-
|
|
18
|
-
(function (BaseType) {
|
|
19
|
-
BaseType[BaseType["kLength"] = 0] = "kLength";
|
|
20
|
-
BaseType[BaseType["kAngle"] = 1] = "kAngle";
|
|
21
|
-
BaseType[BaseType["kTime"] = 2] = "kTime";
|
|
22
|
-
BaseType[BaseType["kFrequency"] = 3] = "kFrequency";
|
|
23
|
-
BaseType[BaseType["kResolution"] = 4] = "kResolution";
|
|
24
|
-
BaseType[BaseType["kFlex"] = 5] = "kFlex";
|
|
25
|
-
BaseType[BaseType["kPercent"] = 6] = "kPercent";
|
|
26
|
-
BaseType[BaseType["kNumBaseTypes"] = 7] = "kNumBaseTypes";
|
|
27
|
-
})(BaseType || (exports.BaseType = BaseType = {}));
|
|
28
|
-
|
|
29
|
-
function unitTypeToBaseType(unit) {
|
|
30
|
-
(0, _utils.DCHECK_NE)(unit, _.UnitType.kNumber);
|
|
31
|
-
|
|
32
|
-
switch (unit) {
|
|
33
|
-
case _.UnitType.kEms:
|
|
34
|
-
case _.UnitType.kExs:
|
|
35
|
-
case _.UnitType.kPixels:
|
|
36
|
-
case _.UnitType.kCentimeters:
|
|
37
|
-
case _.UnitType.kMillimeters:
|
|
38
|
-
case _.UnitType.kQuarterMillimeters:
|
|
39
|
-
case _.UnitType.kInches:
|
|
40
|
-
case _.UnitType.kPoints:
|
|
41
|
-
case _.UnitType.kPicas:
|
|
42
|
-
case _.UnitType.kUserUnits:
|
|
43
|
-
case _.UnitType.kViewportWidth:
|
|
44
|
-
case _.UnitType.kViewportHeight:
|
|
45
|
-
case _.UnitType.kViewportInlineSize:
|
|
46
|
-
case _.UnitType.kViewportBlockSize:
|
|
47
|
-
case _.UnitType.kViewportMin:
|
|
48
|
-
case _.UnitType.kViewportMax:
|
|
49
|
-
case _.UnitType.kSmallViewportWidth:
|
|
50
|
-
case _.UnitType.kSmallViewportHeight:
|
|
51
|
-
case _.UnitType.kSmallViewportInlineSize:
|
|
52
|
-
case _.UnitType.kSmallViewportBlockSize:
|
|
53
|
-
case _.UnitType.kSmallViewportMin:
|
|
54
|
-
case _.UnitType.kSmallViewportMax:
|
|
55
|
-
case _.UnitType.kLargeViewportWidth:
|
|
56
|
-
case _.UnitType.kLargeViewportHeight:
|
|
57
|
-
case _.UnitType.kLargeViewportInlineSize:
|
|
58
|
-
case _.UnitType.kLargeViewportBlockSize:
|
|
59
|
-
case _.UnitType.kLargeViewportMin:
|
|
60
|
-
case _.UnitType.kLargeViewportMax:
|
|
61
|
-
case _.UnitType.kDynamicViewportWidth:
|
|
62
|
-
case _.UnitType.kDynamicViewportHeight:
|
|
63
|
-
case _.UnitType.kDynamicViewportInlineSize:
|
|
64
|
-
case _.UnitType.kDynamicViewportBlockSize:
|
|
65
|
-
case _.UnitType.kDynamicViewportMin:
|
|
66
|
-
case _.UnitType.kDynamicViewportMax:
|
|
67
|
-
case _.UnitType.kContainerWidth:
|
|
68
|
-
case _.UnitType.kContainerHeight:
|
|
69
|
-
case _.UnitType.kContainerInlineSize:
|
|
70
|
-
case _.UnitType.kContainerBlockSize:
|
|
71
|
-
case _.UnitType.kContainerMin:
|
|
72
|
-
case _.UnitType.kContainerMax:
|
|
73
|
-
case _.UnitType.kRems:
|
|
74
|
-
case _.UnitType.kChs:
|
|
75
|
-
return BaseType.kLength;
|
|
76
|
-
|
|
77
|
-
case _.UnitType.kMilliseconds:
|
|
78
|
-
case _.UnitType.kSeconds:
|
|
79
|
-
return BaseType.kTime;
|
|
80
|
-
|
|
81
|
-
case _.UnitType.kDegrees:
|
|
82
|
-
case _.UnitType.kRadians:
|
|
83
|
-
case _.UnitType.kGradians:
|
|
84
|
-
case _.UnitType.kTurns:
|
|
85
|
-
return BaseType.kAngle;
|
|
86
|
-
|
|
87
|
-
case _.UnitType.kHertz:
|
|
88
|
-
case _.UnitType.kKilohertz:
|
|
89
|
-
return BaseType.kFrequency;
|
|
90
|
-
|
|
91
|
-
case _.UnitType.kDotsPerPixel:
|
|
92
|
-
case _.UnitType.kDotsPerInch:
|
|
93
|
-
case _.UnitType.kDotsPerCentimeter:
|
|
94
|
-
return BaseType.kResolution;
|
|
95
|
-
|
|
96
|
-
case _.UnitType.kFraction:
|
|
97
|
-
return BaseType.kFlex;
|
|
98
|
-
|
|
99
|
-
case _.UnitType.kPercentage:
|
|
100
|
-
return BaseType.kPercent;
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
return BaseType.kLength;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function baseTypeToString(baseType) {
|
|
108
|
-
switch (baseType) {
|
|
109
|
-
case BaseType.kLength:
|
|
110
|
-
return 'length';
|
|
111
|
-
|
|
112
|
-
case BaseType.kAngle:
|
|
113
|
-
return 'angle';
|
|
114
|
-
|
|
115
|
-
case BaseType.kTime:
|
|
116
|
-
return 'time';
|
|
117
|
-
|
|
118
|
-
case BaseType.kFrequency:
|
|
119
|
-
return 'frequency';
|
|
120
|
-
|
|
121
|
-
case BaseType.kResolution:
|
|
122
|
-
return 'resolution';
|
|
123
|
-
|
|
124
|
-
case BaseType.kFlex:
|
|
125
|
-
return 'flex';
|
|
126
|
-
|
|
127
|
-
case BaseType.kPercent:
|
|
128
|
-
return 'percent';
|
|
129
|
-
|
|
130
|
-
default:
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return '';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var CSSNumericValueType =
|
|
138
|
-
/** @class */
|
|
139
|
-
function () {
|
|
140
|
-
function CSSNumericValueType(unit, exponent) {
|
|
141
|
-
if (unit === void 0) {
|
|
142
|
-
unit = _.UnitType.kNumber;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (exponent === void 0) {
|
|
146
|
-
exponent = 1;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.exponents = [];
|
|
150
|
-
this.numNonZeroEntries = 0;
|
|
151
|
-
this.percentHint = BaseType.kPercent;
|
|
152
|
-
this.hasPercentHint = false;
|
|
153
|
-
this.exponents = new Array(BaseType.kNumBaseTypes).fill(0);
|
|
154
|
-
|
|
155
|
-
if (unit !== _.UnitType.kNumber) {
|
|
156
|
-
this.setExponent(unitTypeToBaseType(unit), exponent);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
CSSNumericValueType.prototype.applyPercentHint = function (hint) {
|
|
161
|
-
(0, _utils.DCHECK_NE)(hint, BaseType.kPercent);
|
|
162
|
-
this.setExponent(hint, this.exponent(hint) + this.exponent(BaseType.kPercent));
|
|
163
|
-
this.setExponent(BaseType.kPercent, 0);
|
|
164
|
-
this.percentHint = hint;
|
|
165
|
-
this.hasPercentHint = true;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
CSSNumericValueType.prototype.hasNonZeroEntries = function () {
|
|
169
|
-
return this.numNonZeroEntries > 0;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
CSSNumericValueType.prototype.isOnlyNonZeroEntry = function (baseType, value) {
|
|
173
|
-
(0, _utils.DCHECK_NE)(value, 0);
|
|
174
|
-
return this.numNonZeroEntries === 1 && this.exponent(baseType) === value;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
CSSNumericValueType.prototype.exponent = function (type) {
|
|
178
|
-
return this.exponents[type];
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
CSSNumericValueType.prototype.setExponent = function (type, newValue) {
|
|
182
|
-
var oldValue = this.exponents[type];
|
|
183
|
-
|
|
184
|
-
if (oldValue == 0 && newValue !== 0) {
|
|
185
|
-
this.numNonZeroEntries++;
|
|
186
|
-
} else if (oldValue !== 0 && newValue == 0) {
|
|
187
|
-
this.numNonZeroEntries--;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
this.exponents[type] = newValue;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
CSSNumericValueType.negateExponents = function (type) {
|
|
194
|
-
type.exponents.forEach(function (v) {
|
|
195
|
-
return v *= -1;
|
|
196
|
-
});
|
|
197
|
-
return type;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
CSSNumericValueType.prototype.matchesBaseType = function (baseType) {
|
|
201
|
-
(0, _utils.DCHECK_NE)(baseType, BaseType.kPercent);
|
|
202
|
-
return this.isOnlyNonZeroEntry(baseType, 1) && !this.hasPercentHint;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
CSSNumericValueType.prototype.matchesPercentage = function () {
|
|
206
|
-
return this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
CSSNumericValueType.prototype.matchesBaseTypePercentage = function (baseType) {
|
|
210
|
-
(0, _utils.DCHECK_NE)(baseType, BaseType.kPercent);
|
|
211
|
-
return this.isOnlyNonZeroEntry(baseType, 1) || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
CSSNumericValueType.prototype.matchesNumber = function () {
|
|
215
|
-
return !this.hasNonZeroEntries() && !this.hasPercentHint;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
CSSNumericValueType.prototype.matchesNumberPercentage = function () {
|
|
219
|
-
return !this.hasNonZeroEntries() || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
CSSNumericValueType.add = function (type1, type2, error) {
|
|
223
|
-
if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
|
|
224
|
-
error = true;
|
|
225
|
-
return type1;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
|
|
229
|
-
(0, _utils.DCHECK_EQ)(type1.percentHint, type2.percentHint); // Match up base types. Try to use the percent hint to match up any
|
|
230
|
-
// differences.
|
|
231
|
-
|
|
232
|
-
for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
|
|
233
|
-
var base_type = i;
|
|
234
|
-
|
|
235
|
-
if (type1.exponents[i] !== type2.exponents[i]) {
|
|
236
|
-
if (base_type !== BaseType.kPercent) {
|
|
237
|
-
type1.applyPercentHint(base_type);
|
|
238
|
-
type2.applyPercentHint(base_type);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (type1.exponents[i] !== type2.exponents[i]) {
|
|
242
|
-
error = true;
|
|
243
|
-
return type1;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
error = false;
|
|
249
|
-
return type1;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
CSSNumericValueType.multiply = function (type1, type2, error) {
|
|
253
|
-
if (type1.hasPercentHint && type2.hasPercentHint && type1.percentHint != type2.percentHint) {
|
|
254
|
-
error = true;
|
|
255
|
-
return type1;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
|
|
259
|
-
|
|
260
|
-
for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
|
|
261
|
-
var base_type = i;
|
|
262
|
-
type1.setExponent(base_type, type1.exponent(base_type) + type2.exponent(base_type));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
error = false;
|
|
266
|
-
return type1;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
return CSSNumericValueType;
|
|
270
|
-
}();
|
|
271
|
-
|
|
272
|
-
exports.CSSNumericValueType = CSSNumericValueType;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The CSSUnitValue interface of the CSS_Object_Model represents values that contain a single unit type.
|
|
3
|
-
* For example, "42px" would be represented by a CSSNumericValue.
|
|
4
|
-
*
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue
|
|
6
|
-
*/
|
|
7
|
-
import { CSSMathInvert } from './CSSMathInvert';
|
|
8
|
-
import type { CSSNumericSumValue } from './CSSNumericSumValue';
|
|
9
|
-
import type { Nested, ParenLess } from '.';
|
|
10
|
-
import { CSSNumericValue } from './CSSNumericValue';
|
|
11
|
-
import { CSSStyleValueType, UnitType } from '.';
|
|
12
|
-
/**
|
|
13
|
-
* Represents numeric values that can be expressed as a single number plus a
|
|
14
|
-
* unit (or a naked number or percentage).
|
|
15
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
|
16
|
-
*/
|
|
17
|
-
export declare class CSSUnitValue extends CSSNumericValue {
|
|
18
|
-
static toCanonicalUnit(unit: UnitType): UnitType.kUnknown | UnitType.kNumber | UnitType.kPixels | UnitType.kDegrees | UnitType.kSeconds | UnitType.kHertz | UnitType.kDotsPerPixel;
|
|
19
|
-
static toCanonicalUnitIfPossible(unit: UnitType): UnitType;
|
|
20
|
-
static formatInfinityOrNaN(number: number, suffix?: string): string;
|
|
21
|
-
static formatNumber(number: number, suffix?: string): string;
|
|
22
|
-
unit: UnitType;
|
|
23
|
-
value: number;
|
|
24
|
-
constructor(value: number, unitOrName?: UnitType | string);
|
|
25
|
-
clone(): CSSUnitValue;
|
|
26
|
-
convertTo(target_unit: UnitType): CSSUnitValue;
|
|
27
|
-
equals(other: CSSNumericValue): boolean;
|
|
28
|
-
getType(): CSSStyleValueType;
|
|
29
|
-
sumValue(): CSSNumericSumValue;
|
|
30
|
-
negate(): CSSUnitValue;
|
|
31
|
-
invert(): CSSUnitValue | CSSMathInvert;
|
|
32
|
-
buildCSSText(n: Nested, p: ParenLess, result: string): string;
|
|
33
|
-
}
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSUnitValue = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _CSSMathInvert = require("./CSSMathInvert");
|
|
13
|
-
|
|
14
|
-
var _CSSNumericValue = require("./CSSNumericValue");
|
|
15
|
-
|
|
16
|
-
var _CSSNumericValueType = require("./CSSNumericValueType");
|
|
17
|
-
|
|
18
|
-
var _ = require(".");
|
|
19
|
-
|
|
20
|
-
var _CSSStyleValue = require("./CSSStyleValue");
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The CSSUnitValue interface of the CSS_Object_Model represents values that contain a single unit type.
|
|
24
|
-
* For example, "42px" would be represented by a CSSNumericValue.
|
|
25
|
-
*
|
|
26
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Represents numeric values that can be expressed as a single number plus a
|
|
31
|
-
* unit (or a naked number or percentage).
|
|
32
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
|
33
|
-
*/
|
|
34
|
-
var CSSUnitValue =
|
|
35
|
-
/** @class */
|
|
36
|
-
function (_super) {
|
|
37
|
-
(0, _tslib.__extends)(CSSUnitValue, _super);
|
|
38
|
-
|
|
39
|
-
function CSSUnitValue(value, unitOrName) {
|
|
40
|
-
if (unitOrName === void 0) {
|
|
41
|
-
unitOrName = _.UnitType.kNumber;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var _this = this;
|
|
45
|
-
|
|
46
|
-
var unit;
|
|
47
|
-
|
|
48
|
-
if (typeof unitOrName === 'string') {
|
|
49
|
-
unit = CSSUnitValue.unitFromName(unitOrName);
|
|
50
|
-
} else {
|
|
51
|
-
unit = unitOrName;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
(0, _utils.DCHECK)(CSSUnitValue.isValidUnit(unit));
|
|
55
|
-
_this = _super.call(this, new _CSSNumericValueType.CSSNumericValueType(unit)) || this;
|
|
56
|
-
_this.unit = unit;
|
|
57
|
-
_this.value = value;
|
|
58
|
-
return _this;
|
|
59
|
-
} // static fromCSSValue(value: CSSNumericLiteralValue) {
|
|
60
|
-
// let unit = value.type;
|
|
61
|
-
// if (unit === UnitType.kInteger) unit = UnitType.kNumber;
|
|
62
|
-
// if (!this.isValidUnit(unit)) return null;
|
|
63
|
-
// return new CSSUnitValue(value.getDoubleValue(), unit);
|
|
64
|
-
// }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
CSSUnitValue.toCanonicalUnit = function (unit) {
|
|
68
|
-
return this.canonicalUnitTypeForCategory(this.unitTypeToUnitCategory(unit));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
CSSUnitValue.toCanonicalUnitIfPossible = function (unit) {
|
|
72
|
-
var canonical_unit = this.toCanonicalUnit(unit);
|
|
73
|
-
if (canonical_unit === _.UnitType.kUnknown) return unit;
|
|
74
|
-
return canonical_unit;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
CSSUnitValue.formatInfinityOrNaN = function (number, suffix) {
|
|
78
|
-
if (suffix === void 0) {
|
|
79
|
-
suffix = '';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var result = '';
|
|
83
|
-
|
|
84
|
-
if (!Number.isFinite(number)) {
|
|
85
|
-
if (number > 0) result = 'infinity';else result = '-infinity';
|
|
86
|
-
} else {
|
|
87
|
-
(0, _utils.DCHECK)(Number.isNaN(number));
|
|
88
|
-
result = 'NaN';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return result += suffix;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
CSSUnitValue.formatNumber = function (number, suffix) {
|
|
95
|
-
if (suffix === void 0) {
|
|
96
|
-
suffix = '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return number + suffix;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
CSSUnitValue.prototype.clone = function () {
|
|
103
|
-
return new CSSUnitValue(this.value, this.unit);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
CSSUnitValue.prototype.convertTo = function (target_unit) {
|
|
107
|
-
if (this.unit === target_unit) {
|
|
108
|
-
return new CSSUnitValue(this.value, this.unit);
|
|
109
|
-
} // Instead of defining the scale factors for every unit to every other unit,
|
|
110
|
-
// we simply convert to the canonical unit and back since we already have
|
|
111
|
-
// the scale factors for canonical units.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var canonical_unit = CSSUnitValue.toCanonicalUnit(this.unit);
|
|
115
|
-
|
|
116
|
-
if (canonical_unit !== CSSUnitValue.toCanonicalUnit(target_unit) || canonical_unit === _.UnitType.kUnknown) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var scale_factor = _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit) / _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(target_unit);
|
|
121
|
-
|
|
122
|
-
return new CSSUnitValue(this.value * scale_factor, target_unit);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
CSSUnitValue.prototype.equals = function (other) {
|
|
126
|
-
var other_unit_value = other;
|
|
127
|
-
return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
CSSUnitValue.prototype.getType = function () {
|
|
131
|
-
return _.CSSStyleValueType.kUnitType;
|
|
132
|
-
}; // toCSSValue() {
|
|
133
|
-
// return new CSSNumericLiteralValue(this.value, this.unit);
|
|
134
|
-
// }
|
|
135
|
-
// // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
|
|
136
|
-
// toCalcExpressionNode() {
|
|
137
|
-
// return CSSMathExpressionNumericLiteral.create(
|
|
138
|
-
// new CSSNumericLiteralValue(this.value, this.unit),
|
|
139
|
-
// );
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
CSSUnitValue.prototype.sumValue = function () {
|
|
144
|
-
var sum = [];
|
|
145
|
-
var unit_map = {};
|
|
146
|
-
|
|
147
|
-
if (this.unit !== _.UnitType.kNumber) {
|
|
148
|
-
unit_map[CSSUnitValue.toCanonicalUnitIfPossible(this.unit)] = 1;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
sum.push({
|
|
152
|
-
value: this.value * _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit),
|
|
153
|
-
units: unit_map
|
|
154
|
-
});
|
|
155
|
-
return sum;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
CSSUnitValue.prototype.negate = function () {
|
|
159
|
-
return new CSSUnitValue(-this.value, this.unit);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
CSSUnitValue.prototype.invert = function () {
|
|
163
|
-
if (this.unit === _.UnitType.kNumber) {
|
|
164
|
-
if (this.value === 0) return null;
|
|
165
|
-
return new CSSUnitValue(1.0 / this.value, this.unit);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return _CSSMathInvert.CSSMathInvert.create(this);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
CSSUnitValue.prototype.buildCSSText = function (n, p, result) {
|
|
172
|
-
var text;
|
|
173
|
-
|
|
174
|
-
switch (this.unit) {
|
|
175
|
-
case _.UnitType.kUnknown:
|
|
176
|
-
// FIXME
|
|
177
|
-
break;
|
|
178
|
-
|
|
179
|
-
case _.UnitType.kInteger:
|
|
180
|
-
text = Number(this.value).toFixed(0);
|
|
181
|
-
break;
|
|
182
|
-
|
|
183
|
-
case _.UnitType.kNumber:
|
|
184
|
-
case _.UnitType.kPercentage:
|
|
185
|
-
case _.UnitType.kEms:
|
|
186
|
-
case _.UnitType.kQuirkyEms:
|
|
187
|
-
case _.UnitType.kExs:
|
|
188
|
-
case _.UnitType.kRems:
|
|
189
|
-
case _.UnitType.kChs:
|
|
190
|
-
case _.UnitType.kPixels:
|
|
191
|
-
case _.UnitType.kCentimeters:
|
|
192
|
-
case _.UnitType.kDotsPerPixel:
|
|
193
|
-
case _.UnitType.kDotsPerInch:
|
|
194
|
-
case _.UnitType.kDotsPerCentimeter:
|
|
195
|
-
case _.UnitType.kMillimeters:
|
|
196
|
-
case _.UnitType.kQuarterMillimeters:
|
|
197
|
-
case _.UnitType.kInches:
|
|
198
|
-
case _.UnitType.kPoints:
|
|
199
|
-
case _.UnitType.kPicas:
|
|
200
|
-
case _.UnitType.kUserUnits:
|
|
201
|
-
case _.UnitType.kDegrees:
|
|
202
|
-
case _.UnitType.kRadians:
|
|
203
|
-
case _.UnitType.kGradians:
|
|
204
|
-
case _.UnitType.kMilliseconds:
|
|
205
|
-
case _.UnitType.kSeconds:
|
|
206
|
-
case _.UnitType.kHertz:
|
|
207
|
-
case _.UnitType.kKilohertz:
|
|
208
|
-
case _.UnitType.kTurns:
|
|
209
|
-
case _.UnitType.kFraction:
|
|
210
|
-
case _.UnitType.kViewportWidth:
|
|
211
|
-
case _.UnitType.kViewportHeight:
|
|
212
|
-
case _.UnitType.kViewportInlineSize:
|
|
213
|
-
case _.UnitType.kViewportBlockSize:
|
|
214
|
-
case _.UnitType.kViewportMin:
|
|
215
|
-
case _.UnitType.kViewportMax:
|
|
216
|
-
case _.UnitType.kSmallViewportWidth:
|
|
217
|
-
case _.UnitType.kSmallViewportHeight:
|
|
218
|
-
case _.UnitType.kSmallViewportInlineSize:
|
|
219
|
-
case _.UnitType.kSmallViewportBlockSize:
|
|
220
|
-
case _.UnitType.kSmallViewportMin:
|
|
221
|
-
case _.UnitType.kSmallViewportMax:
|
|
222
|
-
case _.UnitType.kLargeViewportWidth:
|
|
223
|
-
case _.UnitType.kLargeViewportHeight:
|
|
224
|
-
case _.UnitType.kLargeViewportInlineSize:
|
|
225
|
-
case _.UnitType.kLargeViewportBlockSize:
|
|
226
|
-
case _.UnitType.kLargeViewportMin:
|
|
227
|
-
case _.UnitType.kLargeViewportMax:
|
|
228
|
-
case _.UnitType.kDynamicViewportWidth:
|
|
229
|
-
case _.UnitType.kDynamicViewportHeight:
|
|
230
|
-
case _.UnitType.kDynamicViewportInlineSize:
|
|
231
|
-
case _.UnitType.kDynamicViewportBlockSize:
|
|
232
|
-
case _.UnitType.kDynamicViewportMin:
|
|
233
|
-
case _.UnitType.kDynamicViewportMax:
|
|
234
|
-
case _.UnitType.kContainerWidth:
|
|
235
|
-
case _.UnitType.kContainerHeight:
|
|
236
|
-
case _.UnitType.kContainerInlineSize:
|
|
237
|
-
case _.UnitType.kContainerBlockSize:
|
|
238
|
-
case _.UnitType.kContainerMin:
|
|
239
|
-
case _.UnitType.kContainerMax:
|
|
240
|
-
{
|
|
241
|
-
var kMinInteger = -999999;
|
|
242
|
-
var kMaxInteger = 999999;
|
|
243
|
-
var value = this.value;
|
|
244
|
-
var unit = CSSUnitValue.unitTypeToString(this.unit);
|
|
245
|
-
|
|
246
|
-
if (value < kMinInteger || value > kMaxInteger) {
|
|
247
|
-
var unit_1 = CSSUnitValue.unitTypeToString(this.unit);
|
|
248
|
-
|
|
249
|
-
if (!Number.isFinite(value) || Number.isNaN(value)) {
|
|
250
|
-
text = CSSUnitValue.formatInfinityOrNaN(value, unit_1);
|
|
251
|
-
} else {
|
|
252
|
-
text = CSSUnitValue.formatNumber(value, unit_1);
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
text = "".concat(value).concat(unit);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
result += text;
|
|
261
|
-
return result;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
return CSSUnitValue;
|
|
265
|
-
}(_CSSNumericValue.CSSNumericValue);
|
|
266
|
-
|
|
267
|
-
exports.CSSUnitValue = CSSUnitValue;
|