compute method
Implementation
@override
CSSValue? compute([DOMContext? domContext]) {
if (args.isEmpty) return null;
var values = args.map((a) => CSSValue.from(a)).toList();
var valuesNotNull = values.nonNulls.toList();
if (valuesNotNull.length != values.length) return null;
var computed =
valuesNotNull.map((a) => CSSFunction.computeValue(a)).toList();
var computedNotNull = computed.nonNulls.toList();
if (computedNotNull.length != computed.length) return null;
var computedCSSLength = computedNotNull.whereType<CSSLength>();
if (computedCSSLength.length == computedNotNull.length) {
var firstUnit = computedCSSLength.first.unit;
if (computedCSSLength.every((a) => a.unit == firstUnit)) {
var maxVal = computedCSSLength.map((a) => a.value).max;
return CSSLength(maxVal, firstUnit);
}
}
var computedCSSNumber = computedNotNull.whereType<CSSNumber>();
if (computedCSSNumber.length == computedNotNull.length) {
var maxVal = computedCSSLength.map((a) => a.value).max;
return CSSNumber(maxVal);
}
return null;
}