@@ -10,6 +10,7 @@ Abstract: Converting CSSOM value strings into meaningfully typed JavaScript repr
10
10
Editor : Shane Stephens, shanestephens@google.com
11
11
Editor : Tab Atkins-Bittner, Google, http://xanthir.com/contact/, w3cid 42199
12
12
Repository : w3c/css-houdini-drafts
13
+ Inline Github Issues : title
13
14
Ignored Vars : type, unit
14
15
Ignored Terms : Drawable, paint image definition, list-valued property, list-valued property iteration, parse a CSSStyleValue, values to iterate over, CSS
15
16
Markup Shorthands : markdown yes
@@ -553,12 +554,19 @@ The following are the arithmetic operations you can perform on dimensions:
553
554
2. If |this| and |value| are both {{CSSUnitValue}} s:
554
555
and have the same {{CSSUnitValue/unit}} ,
555
556
return a new {{CSSUnitValue}}
556
- with the same unit
557
- and a value equal to the sum of |this|’s and |value|’s values.
558
-
559
- 3. Otherwise,
560
- return a {{CSSCalcValue}}
561
- representing the sum of the |this| and |value|.
557
+ whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
558
+ and {{CSSUnitValue/value}} internal slot set to the sum of
559
+ |this|’s and |value|’s {{CSSUnitValue/value}} internal slots.
560
+
561
+ 3. Otherwise:
562
+ 1. Let |newEntries| be a copy of |this|’s [=map entries=] .
563
+ 2. [=map/For each=] |unit| → |val| in |value|’s [=map entries=] :
564
+ 1. If |newEntries|[|unit|] [=map/exists=] ,
565
+ set |newEntries|[|unit|] to |newEntries|[|unit|] plus |val|.
566
+ 2. Otherwise,
567
+ set |newEntries|[|unit|] to |val|.
568
+ 3. Return a new {{CSSCalcValue}}
569
+ whose [=map entries=] are |newEntries|.
562
570
</div>
563
571
564
572
<div algorithm="CSSNumericValue.sub()">
@@ -573,12 +581,19 @@ The following are the arithmetic operations you can perform on dimensions:
573
581
2. If |this| and |value| are both {{CSSUnitValue}} s:
574
582
and have the same {{CSSUnitValue/unit}} ,
575
583
return a new {{CSSUnitValue}}
576
- with the same unit
577
- and a value equal to the difference of |this|’s and |value|’s values.
578
-
579
- 3. Otherwise,
580
- return a {{CSSCalcValue}}
581
- representing the difference of the |this| and |value|.
584
+ whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
585
+ and {{CSSUnitValue/value}} internal slot set to the difference of
586
+ |this|’s and |value|’s {{CSSUnitValue/value}} internal slots.
587
+
588
+ 3. Otherwise:
589
+ 1. Let |newEntries| be a copy of |this|’s [=map entries=] .
590
+ 2. [=map/For each=] |unit| → |val| in |value|’s [=map entries=] :
591
+ 1. If |newEntries|[|unit|] [=map/exists=] ,
592
+ set |newEntries|[|unit|] to |newEntries|[|unit|] minus |val|.
593
+ 2. Otherwise,
594
+ set |newEntries|[|unit|] to -|val|.
595
+ 3. Return a new {{CSSCalcValue}}
596
+ whose [=map entries=] are |newEntries|.
582
597
</div>
583
598
584
599
<div algorithm="CSSNumericValue.mul()">
@@ -588,13 +603,15 @@ The following are the arithmetic operations you can perform on dimensions:
588
603
589
604
1. If |this| is a {{CSSUnitValue}} ,
590
605
return a new {{CSSUnitValue}}
591
- with the same unit
592
- and a value equal to |this|’s value times |value|.
593
-
594
- 2. Otherwise,
595
- return a new {{CSSCalcValue}}
596
- containing the same keys,
597
- but with each value multiplied by |value|.
606
+ whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
607
+ and {{CSSUnitValue/value}} internal slot set to |this|’s {{CSSUnitValue/value}} internal slot times |value|.
608
+
609
+ 2. Otherwise:
610
+ 1. Let |newEntries| be a copy of |this|’s [=map entries=] .
611
+ 2. [=map/For each=] |unit| → |val| in |newEntries|,
612
+ set |newEntries|[|unit|] to |val| times |value|.
613
+ 3. Return a new {{CSSCalcValue}}
614
+ whose [=map entries=] are |newEntries|.
598
615
</div>
599
616
600
617
<div algorithm="CSSNumericValue.div()">
@@ -604,17 +621,19 @@ The following are the arithmetic operations you can perform on dimensions:
604
621
605
622
1. If |this| is a {{CSSUnitValue}} ,
606
623
return a new {{CSSUnitValue}}
607
- with the same unit
608
- and a value equal to |this|’s value divided by |value|.
609
-
610
- 2. Otherwise,
611
- return a new {{CSSCalcValue}}
612
- containing the same keys,
613
- but with each value divided by |value|.
624
+ whose {{CSSUnitValue/unit}} internal slot is set to |this|’s {{CSSUnitValue/unit}} internal slot,
625
+ and {{CSSUnitValue/value}} internal slot set to |this|’s {{CSSUnitValue/value}} internal slot divided by |value|.
626
+
627
+ 2. Otherwise:
628
+ 1. Let |newEntries| be a copy of |this|’s [=map entries=] .
629
+ 2. [=map/For each=] |unit| → |val| in |newEntries|,
630
+ set |newEntries|[|unit|] to |val| divided by |value|.
631
+ 3. Return a new {{CSSCalcValue}}
632
+ whose [=map entries=] are |newEntries|.
614
633
</div>
615
634
616
635
<div algorithm="CSSNumericValue.to()">
617
- The <dfn method for=CSSNumericValue>to(|unit|)</dfn> method converts an existing {{CSSNumericValue}}
636
+ The <dfn method for=CSSNumericValue>to(|unit|)</dfn> method converts an existing {{CSSNumericValue}} |this|
618
637
into another one with the specified |unit|.
619
638
When called, it must perform the following steps:
620
639
@@ -623,24 +642,21 @@ The following are the arithmetic operations you can perform on dimensions:
623
642
and abort this algorithm.
624
643
625
644
2. If |this| is a {{CSSUnitValue}}
626
- and |this|’s unit and |unit| are [=compatible units=] ,
645
+ and |this|’s {{CSSUnitValue/ unit}} internal slot and |unit| are [=compatible units=] ,
627
646
return a new {{CSSUnitValue}}
628
- with its unit set to |unit|
629
- and its value set to |this|’s value
647
+ with its {{CSSUnitValue/ unit}} internal slot set to |unit|
648
+ and its {{CSSUnitValue/ value}} internal slot set to |this|’s {{CSSUnitValue/ value}}
630
649
multiplied by the conversion ratio between the two units.
631
650
632
- 3. If |this| is a {{CSSCalcValue}}
633
- and all of its keys
634
- are [=compatible units=] with |unit|,
635
- return a new {{CSSUnitValue}}
636
- with its unit set to |unit|
637
- and its value to the sum of
638
- each of |this|’s values
639
- multiplied by the corresponding conversion ratios
640
- between their key and |unit|.
641
-
642
- 4. Otherwise,
643
- [=throw=] a {{TypeError}} .
651
+ 3. If |this| is a {{CSSCalcValue}} :
652
+ 1. Let |sum| be 0.
653
+ 2. [=map/For each=] |oldUnit| → |value| in |this|’s [=map entries=] :
654
+ 1. If |oldUnit| and |unit| are not [=compatible units=] ,
655
+ [=throw=] a {{TypeError}} .
656
+ 2. Increment |sum| by |value| times the conversion ratio between |oldUnit| and |unit|.
657
+ 3. Return a new {{CSSUnitValue}}
658
+ with its {{CSSUnitValue/unit}} internal slot set to |unit|
659
+ and its {{CSSUnitValue/value}} internal slot set to |sum|.
644
660
</div>
645
661
646
662
The {{CSSNumericValue/parse()}} method allows a {{CSSNumericValue}}
@@ -667,17 +683,24 @@ rather than on {{CSSNumericValue}} instances.
667
683
668
684
3. If |result| is a <<dimension-token>> , <<number-token>> , or <<percentage-token>> ,
669
685
return a new {{CSSUnitValue}} object
670
- with its value set to the token's value,
671
- and the unit set to the token's unit if it's a <<dimension-token>> ,
672
- or `"number"` if it is a <<number-token>> ,
673
- or `"percentage"` if it is a <<percentage-token>> .
674
-
675
- 4. If |result| is a <<calc()>> ,
676
- normalize the ''calc()'' argument
677
- into a sum of values with unique units,
678
- then return a {{CSSCalcValue}} object,
679
- with keys for each unit in the calc,
680
- and values set to the corresponding numeric values.
686
+ with its {{CSSUnitValue/value}} internal slot set to the token's value,
687
+ and its {{CSSUnitValue/value}} internal slot set to the token's unit if it's a <<dimension-token>> ,
688
+ or `"number"` if it's a <<number-token>> ,
689
+ or `"percentage"` if it's a <<percentage-token>> .
690
+
691
+ 4. If |result| is a <<calc()>> :
692
+ 1. Normalize the ''calc()'' argument
693
+ into a sum of values with unique units |calcEntries|.
694
+ 2. Let |newEntries| be an empty [=ordered map=] .
695
+ 3. If |calcEntries| contains a <<number>> term,
696
+ set |newEntries|["number"] to the value of that term.
697
+ 4. For each <<dimension>> term in |calcEntries|,
698
+ ordered [=ASCII case-insensitive=] alphabetically by their |unit|,
699
+ set |newEntries|[|unit|] to the term's value.
700
+ 5. If |calcEntries| contains a <<percentage>> term,
701
+ set |newEntries|["percentage"] to the value of that term.
702
+ 6. Return a new {{CSSCalcValue}} object
703
+ with its [=map entries=] set to |newEntries|.
681
704
</div>
682
705
683
706
{{CSSNumericValue}} s can be <dfn>strongly typed</dfn>
@@ -744,8 +767,8 @@ are represented as {{CSSUnitValue}}s.
744
767
and abort this algorithm.
745
768
746
769
2. Return a new {{CSSUnitValue}}
747
- with its value set to |value|
748
- and its unit set to |unit|.
770
+ with its {{CSSUnitValue/ value}} internal slot set to |value|
771
+ and its {{CSSUnitValue/ unit}} set to |unit|.
749
772
</div>
750
773
751
774
<div algorithm="CSSUnitValue.unit">
@@ -757,10 +780,10 @@ are represented as {{CSSUnitValue}}s.
757
780
[=throw=] a {{TypeError}} .
758
781
759
782
2. Otherwise,
760
- set |this|’s internal {{CSSUnitValue/unit}} slot to |unit|.
783
+ set |this|’s {{CSSUnitValue/unit}} internal slot to |unit|.
761
784
762
785
On reading,
763
- it must return the value of |this|’s internal {{CSSUnitValue/unit}} slot.
786
+ it must return the value of |this|’s {{CSSUnitValue/unit}} internal slot.
764
787
</div>
765
788
766
789
<div algorithm="CSSUnitValue.type">
@@ -1306,6 +1329,8 @@ is a [=list=] of {{CSSTransformComponent}}s.
1306
1329
Note: ''perspective()'' functions always represent 3D transforms.
1307
1330
</div>
1308
1331
1332
+ Issue(366): Figure out how to define 2d vs 3d matrix.
1333
+
1309
1334
<div class=note>
1310
1335
Each {{CSSTransformComponent}} can correspond to
1311
1336
one of a number of underlying transform functions.
0 commit comments