Skip to content

Commit dc3358e

Browse files
committed
Fix the type handling of mul(), and similarly reduce div() to just reusing mul()'s algo.
1 parent b6e66d6 commit dc3358e

File tree

1 file changed

+14
-64
lines changed

1 file changed

+14
-64
lines changed

css-typed-om/Overview.bs

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -674,37 +674,19 @@ The following are the arithmetic operations you can perform on dimensions:
674674
1. Replace each [=list/item=] of |values|
675675
with the result of [=rectifying a numberish value=] for the [=list/item=].
676676

677-
2. Let |thisAndValues| be |this| prepended to |values|.
678-
679-
3. Let |mainValue| initially be null.
680-
681-
4. [=list/For each=] |item| of |thisAndValues|:
682-
1. If |item| has a [=strong type=],
683-
or a [=weak type=] other than "number":
684-
685-
1. If |mainValue| is null,
686-
set |mainValue| to |item|.
687-
2. Otherwise,
688-
[=throw=] a {{TypeError}}.
689-
690-
5. If |mainValue| is still null,
691-
set |mainValue| to |this|.
692-
693-
6. If all of the [=list/items=] in |values| are {{CSSUnitValue}}s,
694-
return a new {{CSSUnitValue}}
695-
whose {{CSSUnitValue/unit}} internal slot is set to |mainValue|’s {{CSSUnitValue/unit}} internal slot,
696-
and {{CSSUnitValue/value}} internal slot is set to
697-
the product of the {{CSSUnitValue/value}} internal slots
698-
of the [=list/items=] in |thisAndValues|.
677+
2. If |this| is a {{CSSMathProduct}} object,
678+
[=list/prepend=] the [=list/items=] in |this|’s {{CSSMathProduct/values}} internal slot
679+
to |values|.
680+
Otherwise,
681+
prepend |this| to |values|.
699682

700-
7. If |this| is a {{CSSMathProduct}} object,
701-
[=list/append=] the [=list/items=] of |values|
702-
to |this|’s {{CSSMathProduct/values}} internal slot.
683+
3. Let |type| be the result of [=multiplying=] the [=types=] of every [=list/item=] in |values|.
684+
If |type| is failure,
685+
[=throw=] a {{TypeError}}.
703686

704-
8. Otherwise,
705-
and return a new {{CSSMathProduct}}
687+
5. Return a new {{CSSMathProduct}} object
706688
whose {{CSSMathProduct/values}} internal slot
707-
is set to |thisAndValues|.
689+
is set to |values|.
708690
</div>
709691

710692
<div algorithm="CSSNumericValue.div()">
@@ -713,43 +695,11 @@ The following are the arithmetic operations you can perform on dimensions:
713695
must perform the following steps:
714696

715697
1. Replace each [=list/item=] of |values|
716-
with the result of [=rectifying a numberish value=] for the [=list/item=].
717-
718-
2. Let |thisAndValues| be |this| prepended to |values|.
719-
720-
3. Let |mainValue| initially be null.
721-
722-
4. [=list/For each=] |item| of |thisAndValues|:
723-
1. If |item| has a [=strong type=],
724-
or a [=weak type=] other than "number":
725-
726-
1. If |mainValue| is null,
727-
set |mainValue| to |item|.
728-
2. Otherwise,
729-
[=throw=] a {{TypeError}}.
730-
731-
5. If |mainValue| is still null,
732-
set |mainValue| to |this|.
733-
734-
6. If all of the [=list/items=] in |thisAndValues| are {{CSSUnitValue}}s,
735-
return a new {{CSSUnitValue}}
736-
whose {{CSSUnitValue/unit}} internal slot is set to |mainValue|’s {{CSSUnitValue/unit}} internal slot,
737-
and {{CSSUnitValue/value}} internal slot is set to
738-
the {{CSSUnitValue/value}} internal slot of |this|
739-
divided by the product of the {{CSSUnitValue/value}} internal slots
740-
of the [=list/items=] in |values|.
741-
742-
7. [=CSSMath/Invert=] all of the [=list/items=] in |values|.
743-
744-
8. If |this| is a {{CSSMathProduct}} object,
745-
[=list/append=] the [=list/items=] of |values|
746-
to |this|’s {{CSSMathProduct/values}} internal slot.
698+
with the result of [=rectifying a numberish value=] for the [=list/item=],
699+
then [=CSSMath/inverting=] the value.
747700

748-
9. Otherwise,
749-
prepend |this| to |values|,
750-
then return a new {{CSSMathProduct}} object
751-
whose {{CSSMathProduct/values}} internal slot
752-
is set to |values|.
701+
2. Return the result of calling the {{CSSNumericValue/mul()}} internal algorithm
702+
with |this| and |values|.
753703
</div>
754704

755705
<div algorithm>

0 commit comments

Comments
 (0)