Skip to content

Commit 1124efb

Browse files
committed
[css-typed-om] Reifying computed numeric values uses the canonical unit. Fixes w3c#725.
1 parent 0000e8f commit 1124efb

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

css-typed-om/Overview.bs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,16 +2890,22 @@ has the same behavior as in normal CSS.
28902890
This section describes how Typed OM objects are constructed from [=underlying values=],
28912891
a process called <dfn export for=CSS lt="reify | reification">reification</dfn>.
28922892

2893-
The following list defines the [=reification=] behavior for every single property in CSS,
2894-
for both specified and computed values.
2893+
Some general principles apply to all [=reification=],
2894+
and so aren't stated in each individual instance:
2895+
2896+
* If an [=underlying value=] is from a [=list-valued=] property,
2897+
this list defines how to reify a single iteration of the property;
2898+
multiple iterations are reflected by returning multiple values from {{StylePropertyMap}}.{{getAll()}}.
28952899

2896-
If an [=underlying value=] is from a [=list-valued=] property,
2897-
this list defines how to reify a single iteration of the property;
2898-
multiple iterations are reflected by returning multiple values from {{StylePropertyMap}}.{{getAll()}}.
2900+
* If an [=underlying value=] contains a ''var()'' reference,
2901+
then it is reified by [=reify a list of component values|reifying a list of component values=],
2902+
regardless of what property it is for.
28992903

2900-
If an [=underlying value=] contains a ''var()'' reference,
2901-
then it is reified by [=reify a list of component values|reifying a list of component values=],
2902-
regardless of what property it is for.
2904+
Property-specific Rules {#reify-property}
2905+
-----------------------------------------
2906+
2907+
The following list defines the [=reification=] behavior for every single property in CSS,
2908+
for both specified and computed values.
29032909

29042910
<dl link-type=property>
29052911
: unregistered [=custom properties=]
@@ -4754,7 +4760,7 @@ CSS <<number>>, <<percentage>>, and <<dimension>> values become {{CSSNumericValu
47544760
<div algorithm>
47554761
To <dfn export>reify a numeric value</dfn> |num|:
47564762

4757-
1. If |num| is a ''calc()'', ''min()'', or ''max()'' expression,
4763+
1. If |num| is a [=math function=],
47584764
[=reify a math expression=] from |num|
47594765
and return the result.
47604766

@@ -4772,6 +4778,17 @@ CSS <<number>>, <<percentage>>, and <<dimension>> values become {{CSSNumericValu
47724778
set to "number" if |num| is a <<number>>,
47734779
"percent" if |num| is a <<percentage>>,
47744780
and |num|’s unit if |num| is a <<dimension>>.
4781+
4782+
If the value being [=reified=] is a computed value,
4783+
the unit used must be the appropriate [=canonical unit=] for the value's type,
4784+
with the numeric value scaled accordingly.
4785+
4786+
<div class=example highlight=js>
4787+
For example, if an element has `style="width: 1in;"`,
4788+
`el.attributeStyleMap.get('width')` will return `CSS.in(1)`,
4789+
but `el.computedStyleMap.get('width')` will return `CSS.px(96)`,
4790+
as ''px'' is the [=canonical unit=] for absolute lengths.
4791+
</div>
47754792
</div>
47764793

47774794
<div algorithm>

0 commit comments

Comments
 (0)