@@ -681,6 +681,27 @@ All numeric CSS values
681681are represented by subclasses of the {{CSSNumericValue}} interface.
682682
683683<xmp class=idl>
684+ enum CSSNumericBaseType {
685+ "length",
686+ "angle",
687+ "time",
688+ "frequency",
689+ "resolution",
690+ "flex",
691+ "percent",
692+ };
693+
694+ dictionary CSSNumericType {
695+ long length;
696+ long angle;
697+ long time;
698+ long frequency;
699+ long resolution;
700+ long flex;
701+ long percent;
702+ CSSNumericBaseType percentHint;
703+ };
704+
684705 interface CSSNumericValue : CSSStyleValue {
685706 CSSNumericValue add(CSSNumberish... values);
686707 CSSNumericValue sub(CSSNumberish... values);
@@ -693,15 +714,12 @@ are represented by subclasses of the {{CSSNumericValue}} interface.
693714
694715 CSSUnitValue to(DOMString unit);
695716 CSSMathSum toSum(DOMString... units);
696- // ??? type();
717+ CSSNumericType type();
697718
698719 static CSSNumericValue parse(DOMString cssText);
699720 };
700721</xmp>
701722
702- Issue(482): Figure out how we want to represent the type of an expression in JS,
703- and define the type() method accordingly.
704-
705723The methods on the {{CSSNumericValue}} superclass
706724represent operations that all numeric values can perform.
707725
@@ -1035,6 +1053,24 @@ The following are the arithmetic operations you can perform on dimensions:
10351053 is set to |result|.
10361054</div>
10371055
1056+ <div algorithm="CSSNumericValue.type()">
1057+ The <dfn method for=CSSNumericValue>type()</dfn> method
1058+ returns a representation of the [=type=] of |this|.
1059+
1060+ When called, it must perform the following steps:
1061+
1062+ 1. Let |result| be a new {{CSSNumericType}} .
1063+
1064+ 2. For each |baseType| → |power| in the [=type=] of |this|,
1065+ 1. If |power| is not 0,
1066+ set |result|[|baseType|] to |power|.
1067+
1068+ 3. If the [=percent hint=] of |this| is not null,
1069+ 1. Set {{CSSNumericType/percentHint}} to the [=percent hint=] of |this|.
1070+
1071+ 4. Return |result|.
1072+ </div>
1073+
10381074<div algorithm="sum value">
10391075 A <dfn>sum value</dfn>
10401076 is an abstract representation of a {{CSSNumericValue}}
0 commit comments