@antv/g 5.0.23-alpha.0 → 5.0.23-alpha.12
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 +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/numeric.d.ts +1 -1
- package/es/css/parser/numeric.js +1 -1
- package/es/css/parser/transform-origin.d.ts +1 -1
- package/es/css/parser/transform-origin.js +1 -1
- package/es/css/parser/transform.d.ts +1 -3
- package/es/css/parser/transform.js +9 -8
- package/es/css/properties/CSSPropertyTransform.js +2 -2
- package/es/plugins/PrepareRendererPlugin.js +2 -2
- package/es/services/RenderingService.js +2 -2
- 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 +1232 -58
- 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/numeric.d.ts +1 -1
- package/lib/css/parser/numeric.js +4 -4
- package/lib/css/parser/transform-origin.d.ts +1 -1
- package/lib/css/parser/transform-origin.js +2 -2
- package/lib/css/parser/transform.d.ts +1 -3
- package/lib/css/parser/transform.js +25 -24
- package/lib/css/properties/CSSPropertyTransform.js +18 -18
- package/lib/plugins/PrepareRendererPlugin.js +2 -2
- package/lib/services/RenderingService.js +2 -2
- package/package.json +3 -3
- 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,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathSum = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _CSSMathVariadic = require("./CSSMathVariadic");
|
|
13
|
-
|
|
14
|
-
var _ = require(".");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents the sum of one or more CSSNumericValues.
|
|
18
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
19
|
-
*/
|
|
20
|
-
var CSSMathSum =
|
|
21
|
-
/** @class */
|
|
22
|
-
function (_super) {
|
|
23
|
-
(0, _tslib.__extends)(CSSMathSum, _super);
|
|
24
|
-
|
|
25
|
-
function CSSMathSum() {
|
|
26
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
|
|
28
|
-
_this.operator = 'sum';
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
CSSMathSum.create = function (values) {
|
|
33
|
-
var error = false;
|
|
34
|
-
var finalType = (0, _.typeCheck)(values, _.CSSNumericValueType.add, error);
|
|
35
|
-
return error ? null : new CSSMathSum(values, finalType);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
CSSMathSum.numericTypeFromUnitMap = function (units) {
|
|
39
|
-
var type = new _.CSSNumericValueType();
|
|
40
|
-
Object.keys(units).forEach(function (key) {
|
|
41
|
-
var exp = units[key];
|
|
42
|
-
var error = false;
|
|
43
|
-
type = _.CSSNumericValueType.multiply(type, new _.CSSNumericValueType(Number(key), exp), error);
|
|
44
|
-
(0, _utils.DCHECK)(!error);
|
|
45
|
-
});
|
|
46
|
-
return type;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
CSSMathSum.canCreateNumericTypeFromSumValue = function (sum) {
|
|
50
|
-
var _this = this;
|
|
51
|
-
|
|
52
|
-
(0, _utils.DCHECK)(!!sum.length);
|
|
53
|
-
var first_type = this.numericTypeFromUnitMap(sum[0].units);
|
|
54
|
-
return sum.every(function (term) {
|
|
55
|
-
var error = false;
|
|
56
|
-
|
|
57
|
-
_.CSSNumericValueType.add(first_type, _this.numericTypeFromUnitMap(term.units), error);
|
|
58
|
-
|
|
59
|
-
return !error;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
CSSMathSum.prototype.clone = function () {
|
|
64
|
-
return new CSSMathSum(this.values, this.type_);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
CSSMathSum.prototype.getType = function () {
|
|
68
|
-
return _.CSSStyleValueType.kSumType;
|
|
69
|
-
}; // toCalcExpressionNode() {
|
|
70
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
CSSMathSum.prototype.sumValue = function () {
|
|
75
|
-
var sum = [];
|
|
76
|
-
this.numericValues().forEach(function (value) {
|
|
77
|
-
var child_sum = value.sumValue();
|
|
78
|
-
|
|
79
|
-
if (!child_sum.length) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
child_sum.forEach(function (term) {
|
|
84
|
-
var index = sum.findIndex(function (s) {
|
|
85
|
-
return JSON.stringify(s.units) === JSON.stringify(term.units);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (index === -1) {
|
|
89
|
-
sum.push((0, _tslib.__assign)({}, term));
|
|
90
|
-
} else {
|
|
91
|
-
sum[index].value += term.value;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
if (!CSSMathSum.canCreateNumericTypeFromSumValue(sum)) return null;
|
|
96
|
-
return sum;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
CSSMathSum.prototype.buildCSSText = function (nested, paren_less, result) {
|
|
100
|
-
if (paren_less == _.ParenLess.kNo) {
|
|
101
|
-
result += nested === _.Nested.kYes ? '(' : 'calc(';
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var values = this.numericValues();
|
|
105
|
-
result = values[0].buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
106
|
-
|
|
107
|
-
for (var i = 1; i < values.length; i++) {
|
|
108
|
-
var arg = values[i];
|
|
109
|
-
|
|
110
|
-
if (arg.getType() === _.CSSStyleValueType.kNegateType) {
|
|
111
|
-
result += ' - ';
|
|
112
|
-
result = arg.value.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
113
|
-
} else {
|
|
114
|
-
result += ' + ';
|
|
115
|
-
result = arg.buildCSSText(_.Nested.kYes, _.ParenLess.kNo, result);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (paren_less === _.ParenLess.kNo) {
|
|
120
|
-
result += ')';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return result;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return CSSMathSum;
|
|
127
|
-
}(_CSSMathVariadic.CSSMathVariadic);
|
|
128
|
-
|
|
129
|
-
exports.CSSMathSum = CSSMathSum;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CSSNumericValue } from './CSSNumericValue';
|
|
2
|
-
/**
|
|
3
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
4
|
-
*
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
6
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class CSSMathValue extends CSSNumericValue {
|
|
9
|
-
abstract operator: string;
|
|
10
|
-
isUnitValue(): boolean;
|
|
11
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathValue = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _CSSNumericValue = require("./CSSNumericValue");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
14
|
-
*
|
|
15
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
16
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
17
|
-
*/
|
|
18
|
-
var CSSMathValue =
|
|
19
|
-
/** @class */
|
|
20
|
-
function (_super) {
|
|
21
|
-
(0, _tslib.__extends)(CSSMathValue, _super);
|
|
22
|
-
|
|
23
|
-
function CSSMathValue() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
} // From CSSNumericValue
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
CSSMathValue.prototype.isUnitValue = function () {
|
|
29
|
-
return false;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return CSSMathValue;
|
|
33
|
-
}(_CSSNumericValue.CSSNumericValue);
|
|
34
|
-
|
|
35
|
-
exports.CSSMathValue = CSSMathValue;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CSSMathValue } from './CSSMathValue';
|
|
2
|
-
import type { CSSNumericValue, CSSNumericValueType } from '.';
|
|
3
|
-
export declare function typeCheck(values: CSSNumericValue[], op: Function, error: boolean): CSSNumericValueType;
|
|
4
|
-
export declare abstract class CSSMathVariadic extends CSSMathValue {
|
|
5
|
-
values: CSSNumericValue[];
|
|
6
|
-
constructor(values: CSSNumericValue[], type: CSSNumericValueType);
|
|
7
|
-
numericValues(): CSSNumericValue[];
|
|
8
|
-
equals(other: CSSNumericValue): any;
|
|
9
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSMathVariadic = void 0;
|
|
7
|
-
exports.typeCheck = typeCheck;
|
|
8
|
-
|
|
9
|
-
var _tslib = require("tslib");
|
|
10
|
-
|
|
11
|
-
var _CSSMathValue = require("./CSSMathValue");
|
|
12
|
-
|
|
13
|
-
function typeCheck(values, op, error) {
|
|
14
|
-
error = false;
|
|
15
|
-
var final_type = values[0].type_;
|
|
16
|
-
|
|
17
|
-
for (var i = 1; i < values.length; i++) {
|
|
18
|
-
final_type = op(final_type, values[i].type_, error);
|
|
19
|
-
if (error) return final_type;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return final_type;
|
|
23
|
-
} // Represents an arithmetic operation with one or more CSSNumericValues.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var CSSMathVariadic =
|
|
27
|
-
/** @class */
|
|
28
|
-
function (_super) {
|
|
29
|
-
(0, _tslib.__extends)(CSSMathVariadic, _super);
|
|
30
|
-
|
|
31
|
-
function CSSMathVariadic(values, type) {
|
|
32
|
-
var _this = _super.call(this, type) || this;
|
|
33
|
-
|
|
34
|
-
_this.values = values;
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
CSSMathVariadic.prototype.numericValues = function () {
|
|
39
|
-
return this.values;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
CSSMathVariadic.prototype.equals = function (other) {
|
|
43
|
-
if (this.getType() !== other.getType()) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this.values.every(function (value, i) {
|
|
48
|
-
return value.equals(other.values[i]);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return CSSMathVariadic;
|
|
53
|
-
}(_CSSMathValue.CSSMathValue);
|
|
54
|
-
|
|
55
|
-
exports.CSSMathVariadic = CSSMathVariadic;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { UnitType } from '.';
|
|
2
|
-
export declare enum BaseType {
|
|
3
|
-
kLength = 0,
|
|
4
|
-
kAngle = 1,
|
|
5
|
-
kTime = 2,
|
|
6
|
-
kFrequency = 3,
|
|
7
|
-
kResolution = 4,
|
|
8
|
-
kFlex = 5,
|
|
9
|
-
kPercent = 6,
|
|
10
|
-
kNumBaseTypes = 7
|
|
11
|
-
}
|
|
12
|
-
export declare function unitTypeToBaseType(unit: UnitType): BaseType.kLength | BaseType.kAngle | BaseType.kTime | BaseType.kFrequency | BaseType.kResolution | BaseType.kFlex | BaseType.kPercent;
|
|
13
|
-
export declare function baseTypeToString(baseType: BaseType): "" | "percent" | "length" | "angle" | "time" | "frequency" | "resolution" | "flex";
|
|
14
|
-
export declare class CSSNumericValueType {
|
|
15
|
-
private exponents;
|
|
16
|
-
private numNonZeroEntries;
|
|
17
|
-
percentHint: BaseType;
|
|
18
|
-
hasPercentHint: boolean;
|
|
19
|
-
constructor(unit?: UnitType, exponent?: number);
|
|
20
|
-
applyPercentHint(hint: BaseType): void;
|
|
21
|
-
hasNonZeroEntries(): boolean;
|
|
22
|
-
isOnlyNonZeroEntry(baseType: BaseType, value: number): boolean;
|
|
23
|
-
exponent(type: BaseType): number;
|
|
24
|
-
setExponent(type: BaseType, newValue: number): void;
|
|
25
|
-
static negateExponents(type: CSSNumericValueType): CSSNumericValueType;
|
|
26
|
-
matchesBaseType(baseType: BaseType): boolean;
|
|
27
|
-
matchesPercentage(): boolean;
|
|
28
|
-
matchesBaseTypePercentage(baseType: BaseType): boolean;
|
|
29
|
-
matchesNumber(): boolean;
|
|
30
|
-
matchesNumberPercentage(): boolean;
|
|
31
|
-
static add(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
|
32
|
-
static multiply(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
|
33
|
-
}
|
|
@@ -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
|
-
}
|