Skip to content

Commit a4d277f

Browse files
darrnshntabatkins
authored andcommitted
Add shortcuts for other arithmetic operations (w3c#559)
1 parent 4047650 commit a4d277f

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

css-typed-om/Overview.bs

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ The following are the arithmetic operations you can perform on dimensions:
717717
with the same {{CSSUnitValue/unit}} internal slot as |this|,
718718
and a {{CSSUnitValue/value}} internal slot set to the negation of |this|’s.
719719

720-
2. Otherwise,
720+
3. Otherwise,
721721
return a new {{CSSMathNegate}} object
722722
whose {{CSSMathNegate/value}} internal slot
723723
is set to |this|.
@@ -737,11 +737,28 @@ The following are the arithmetic operations you can perform on dimensions:
737737
Otherwise,
738738
prepend |this| to |values|.
739739

740-
3. Let |type| be the result of [=multiplying=] the [=types=] of every [=list/item=] in |values|.
740+
3. If all of the [=list/items=] in |values| are {{CSSUnitValue}}s
741+
with {{CSSUnitValue/unit}} internal slot set to "number",
742+
return a new {{CSSUnitValue}}
743+
whose {{CSSUnitValue/unit}} internal slot is set to "number",
744+
and {{CSSUnitValue/value}} internal slot is set to the product of
745+
the {{CSSUnitValue/value}} internal slots
746+
of the [=list/items=] in |values|.
747+
748+
4. If all of the [=list/items=] in |values| are {{CSSUnitValue}}s
749+
with {{CSSUnitValue/unit}} internal slot set to "number"
750+
except one which is set to |unit|,
751+
return a new {{CSSUnitValue}}
752+
whose {{CSSUnitValue/unit}} internal slot is set to |unit|,
753+
and {{CSSUnitValue/value}} internal slot is set to the product of
754+
the {{CSSUnitValue/value}} internal slots
755+
of the [=list/items=] in |values|.
756+
757+
5. Let |type| be the result of [=multiplying=] the [=types=] of every [=list/item=] in |values|.
741758
If |type| is failure,
742759
[=throw=] a {{TypeError}}.
743760

744-
5. Return a new {{CSSMathProduct}} object
761+
6. Return a new {{CSSMathProduct}} object
745762
whose {{CSSMathProduct/values}} internal slot
746763
is set to |values|.
747764
</div>
@@ -765,7 +782,12 @@ The following are the arithmetic operations you can perform on dimensions:
765782
1. If |this| is a {{CSSMathInvert}} object,
766783
return |this|’s {{CSSMathInvert/value}} internal slot.
767784

768-
2. Otherwise,
785+
2. If |this| is a {{CSSUnitValue}} object with {{CSSUnitValue/unit}} internal slot set to "number",
786+
return a new {{CSSUnitValue}}
787+
with the {{CSSUnitValue/unit}} internal slot set to "number",
788+
and a {{CSSUnitValue/value}} internal slot set to the inverse of |this|’s.
789+
790+
3. Otherwise,
769791
return a new {{CSSMathInvert}} object
770792
whose {{CSSMathInvert/value}} internal slot
771793
is set to |this|.
@@ -785,11 +807,19 @@ The following are the arithmetic operations you can perform on dimensions:
785807
Otherwise,
786808
prepend |this| to |values|.
787809

788-
3. Let |type| be the result of [=adding=] the [=types=] of every [=list/item=] in |values|.
810+
3. If all of the [=list/items=] in |values| are {{CSSUnitValue}}s
811+
and have the same {{CSSUnitValue/unit}},
812+
return a new {{CSSUnitValue}}
813+
whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
814+
and {{CSSUnitValue/value}} internal slot is set to the minimum of
815+
the {{CSSUnitValue/value}} internal slots
816+
of the [=list/items=] in |values|.
817+
818+
4. Let |type| be the result of [=adding=] the [=types=] of every [=list/item=] in |values|.
789819
If |type| is failure,
790820
[=throw=] a {{TypeError}}.
791821

792-
4. Return a new {{CSSMathMin}} object
822+
5. Return a new {{CSSMathMin}} object
793823
whose {{CSSMathMin/values}} internal slot
794824
is set to |values|.
795825
</div>
@@ -808,11 +838,19 @@ The following are the arithmetic operations you can perform on dimensions:
808838
Otherwise,
809839
prepend |this| to |values|.
810840

811-
3. Let |type| be the result of [=adding=] the [=types=] of every [=list/item=] in |values|.
841+
3. If all of the [=list/items=] in |values| are {{CSSUnitValue}}s
842+
and have the same {{CSSUnitValue/unit}},
843+
return a new {{CSSUnitValue}}
844+
whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
845+
and {{CSSUnitValue/value}} internal slot is set to the maximum of
846+
the {{CSSUnitValue/value}} internal slots
847+
of the [=list/items=] in |values|.
848+
849+
4. Let |type| be the result of [=adding=] the [=types=] of every [=list/item=] in |values|.
812850
If |type| is failure,
813851
[=throw=] a {{TypeError}}.
814852

815-
4. Return a new {{CSSMathMax}} object
853+
5. Return a new {{CSSMathMax}} object
816854
whose {{CSSMathMax/values}} internal slot
817855
is set to |values|.
818856
</div>

0 commit comments

Comments
 (0)