@@ -1792,12 +1792,20 @@ The <dfn export for=CSSNumericValue lt="base type">base types</dfn> are
1792
1792
and "percent".
1793
1793
The ordering of a [=type=] ’s entries always matches this [=base type=] ordering.
1794
1794
The <dfn export for=CSSNumericValue>percent hint</dfn>
1795
- is either null or a [=base type=] other than "percent" .
1795
+ is either null or a [=base type=] .
1796
1796
1797
1797
Note: As new unit types are added to CSS,
1798
1798
they'll be added to this list of [=base types=] ,
1799
1799
and to the CSS [=math functions=] .
1800
1800
1801
+ Note: A [=percent hint=] can be "percent",
1802
+ indicating the percentage is used as itself
1803
+ (or, equivalently, evaluated against a plain number),
1804
+ but this is not produced by the Typed OM methods;
1805
+ it only occurs when the type machinery
1806
+ is used directly by CSS,
1807
+ where a value's context is actually known.
1808
+
1801
1809
<div algorithm>
1802
1810
To <dfn export for="CSSNumericValue" lt="create a type|creating a type">create a type</dfn> from a string |unit|,
1803
1811
follow the appropriate branch of the following:
@@ -1898,13 +1906,17 @@ and to the CSS [=math functions=].
1898
1906
</div>
1899
1907
1900
1908
<div algorithm>
1901
- To <dfn export>apply the percent hint</dfn> |hint| to a |type|,
1909
+ To <dfn export>apply the percent hint</dfn> |hint|
1910
+ to a |type| without a [=percent hint=] ,
1902
1911
perform the following steps:
1903
1912
1904
- 1. If |type| doesn't [=map/contain=] |hint|, set |type|[|hint|] to 0.
1905
- 2. If |type| [=map/contains=] "percent", add |type|["percent"] to |type|[|hint|] ,
1913
+ 1. Set |type|’s [=percent hint=] to |hint|,
1914
+ 2. If |type| doesn't [=map/contain=] |hint|, set |type|[|hint|] to 0.
1915
+ 3. If |hint| is anything other than "percent",
1916
+ and |type| [=map/contains=] "percent",
1917
+ add |type|["percent"] to |type|[|hint|] ,
1906
1918
then set |type|["percent"] to 0.
1907
- 4. Set |type|’s [=percent hint=] to |hint |.
1919
+ 4. Return |type|.
1908
1920
</div>
1909
1921
1910
1922
<div algorithm>
@@ -1974,24 +1986,29 @@ and to the CSS [=math functions=].
1974
1986
1975
1987
* A [=type=] matches <<percentage>>
1976
1988
if its only non-zero [=map/entry=] is «[ "percent" → 1 ] »,
1977
- and it has a null [=percent hint=] .
1989
+ and its [=percent hint=] is either null or "percent".
1990
+
1978
1991
* A [=type=] matches <<length-percentage>>
1979
1992
if it matches <<length>> or matches <<percentage>> .
1980
1993
Same for <<angle-percentage>> , <<time-percentage>> , etc.
1994
+
1981
1995
* A [=type=] matches <<number>>
1982
1996
if it has no non-zero [=map/entries=] .
1983
1997
1984
1998
If the context in which the value is used
1985
1999
allows <<percentage>> values,
1986
- and those percentages are resolved against another type,
2000
+ and those percentages are resolved against a type other than <<number>> ,
1987
2001
then for the [=type=] to be considered [=CSSNumericValue/matching=]
1988
- it must either have a null [=percent hint=] ,
1989
- or the [=percent hint=] must match the other type.
2002
+ the [=percent hint=] must either be null
2003
+ or match the other type.
2004
+
2005
+ If the context allows <<percentage>> values,
2006
+ but either doesn't resolve them against another type
2007
+ or resolves them against a <<number>> ,
2008
+ then for the [=type=] to be considered [=CSSNumericValue/matching=]
2009
+ the [=percent hint=] must either be null or "percent".
1990
2010
1991
2011
If the context does <em> not</em> allow <<percentage>> values,
1992
- or allows them but does not resolve them against another type
1993
- (or treats them equivalent to a <<number>> ,
1994
- such as in 'opacity' ),
1995
2012
then for the [=type=] to be considered [=CSSNumericValue/matching=]
1996
2013
the [=percent hint=] must be null.
1997
2014
</div>
0 commit comments