@@ -641,7 +641,6 @@ probably in an appendix.
641
641
(such as ''Auto'' matching the keyword ''auto'' specified in the grammar for 'width' ),
642
642
they apply to this comparison as well.
643
643
* A {{CSSTransformValue}} matches <<transform-list>> .
644
- * A {{CSSPositionValue}} matches <<position>> .
645
644
* A {{CSSNumericValue}} matches what its type [=CSSNumericValue/matches=] .
646
645
* A {{CSSURLImageValue}} matches <<url>> .
647
646
* Any subclass of {{CSSImageValue}} matches <<image>> .
@@ -2302,21 +2301,6 @@ partial namespace CSS {
2302
2301
to avoid defining the unit individually for all ~20 functions.
2303
2302
</div>
2304
2303
2305
- <div class=example>
2306
- For example, rather than creating a new {{CSSPositionValue}} with code like:
2307
-
2308
- <pre class=lang-js>
2309
- let pos = new CSSPositionValue(
2310
- new CSSUnitValue(5, "px"),
2311
- new CSSUnitValue(10, "px"));
2312
- </pre>
2313
-
2314
- One can instead write:
2315
-
2316
- <pre class=lang-js>
2317
- let pos = new CSSPositionValue(CSS.px(5), CSS.px(10));
2318
- </pre>
2319
- </div>
2320
2304
2321
2305
<!--
2322
2306
████████ ████████ ███ ██ ██ ██████ ████████ ███████ ████████ ██ ██
@@ -2787,86 +2771,6 @@ This list is the object's [=values to iterate over=].
2787
2771
respectively.
2788
2772
</div>
2789
2773
2790
- <!--
2791
- ████████ ███████ ██████ ████ ████████ ████ ███████ ██ ██
2792
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
2793
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██
2794
- ████████ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██
2795
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████
2796
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███
2797
- ██ ███████ ██████ ████ ██ ████ ███████ ██ ██
2798
- -->
2799
-
2800
- {{CSSPositionValue}} objects {#positionvalue-objects}
2801
- --------------------------------------------------
2802
-
2803
- {{CSSPositionValue}} objects represent <<position>> values,
2804
- used by properties such as 'object-position' .
2805
-
2806
- <pre class='idl'>
2807
- [Exposed=(Window, Worker, PaintWorklet, LayoutWorklet),
2808
- Constructor(CSSNumericValue x, CSSNumericValue y)]
2809
- interface CSSPositionValue : CSSStyleValue {
2810
- attribute CSSNumericValue x;
2811
- attribute CSSNumericValue y;
2812
- };
2813
- </pre>
2814
-
2815
- The {{CSSPositionValue/x}} attribute expresses the offset from the left edge of the container;
2816
- {{CSSPositionValue/y}} expresses the offset from the top edge of the container.
2817
-
2818
- <div algorithm>
2819
- The <dfn constructor for=CSSPositionValue>CSSPositionValue(|x|, |y|)</dfn> constructor must,
2820
- when called,
2821
- perform the following steps:
2822
-
2823
- 1. If |x| or |y| doesn't [=CSSNumericValue/match=] <<length-percentage>> ,
2824
- [=throw=] a {{TypeError}} .
2825
-
2826
- 2. Otherwise, return a new {{CSSPositionValue}}
2827
- whose {{CSSPositionValue/x}} internal slot is set to |x|,
2828
- and whose {{CSSPositionValue/y}} internal slot is set to |y|.
2829
- </div>
2830
-
2831
- <div algorithm="CSSPositionValue.x">
2832
- The <dfn attribute for=CSSPositionValue>x</dfn> and <dfn attribute for=CSSPositionValue>y</dfn> attribute of a {{CSSPositionValue}} |this| must,
2833
- on setting a value |value|,
2834
- perform the following steps:
2835
-
2836
- 1. If |value| doesn't [=CSSNumericValue/match=] <<length-percentage>> ,
2837
- [=throw=] a {{TypeError}} .
2838
-
2839
- 2. Otherwise, set |this|’s {{CSSPositionValue/x}} or {{CSSPositionValue/y}} internal slot,
2840
- as appropriate,
2841
- to |value|.
2842
-
2843
- On reading, the attributes must return the value of the {{CSSPositionValue/x}} or {{CSSPositionValue/y}} internal slot,
2844
- as appropriate.
2845
- </div>
2846
-
2847
- <div class='example'>
2848
- <<position>> values accept a complicated combination of keywords and values,
2849
- but Typed OM always simplifies to just two offsets as per the [[#reify-position]] algorithm.
2850
- For example, the following style sheet:
2851
-
2852
- <pre class='lang-css'>
2853
- .example {
2854
- object-position: center bottom 10px;
2855
- }
2856
- </pre>
2857
-
2858
- Will produce the following behavior:
2859
-
2860
- <pre class='lang-javascript'>
2861
- let map = document.querySelector('.example' ).computedStyleMap();
2862
-
2863
- map.get('object-position' ).x;
2864
- // CSS.percent(50)
2865
-
2866
- map.get('object-position' ).y;
2867
- // CSSMathSum(CSS.percent(100), CSS.px(-10))
2868
- </pre>
2869
- </div>
2870
2774
2871
2775
<!--
2872
2776
████ ██ ██ ███ ██████ ████████
@@ -5064,79 +4968,6 @@ while CSS <<transform-function>> values become {{CSSTransformComponent}}s.
5064
4968
</dl>
5065
4969
</div>
5066
4970
5067
- <<position>> Values {#reify-position}
5068
- -----------------------------------------------
5069
-
5070
- CSS <<position>> values become {{CSSPositionValue}} s in the Typed OM, with <var> x</var> and <var> y</var>
5071
- components determined via the following process. If this process, or any sub-process referenced by this
5072
- process fails, then reification as a whole fails.
5073
-
5074
- 1. Initialize both <var> x</var> and <var> y</var> to a {{CSSNumericValue}} value representing 50%.
5075
- 1. If the provided value is a single keyword, length, percentage, or calc expression, then follow
5076
- the procedure outlined in [[#from-single-keyword]] with <var> value</var> given
5077
- by the provided value and an auto <var> bias</var> .
5078
- 1. Otherwise, if the provided value consists of a combination of two keywords, then:
5079
-
5080
- 1. follow the procedure outlined in [[#from-single-keyword]] with <var> value</var> given by the
5081
- first keyword and an auto <var> bias</var> .
5082
- 1. if <var> bias</var> is horizontal, set it to vertical. Otherwise, set it to horizontal.
5083
- 1. follow the procedure again with <var> value</var> given by the second keyword, using the existing <var> bias</var> .
5084
-
5085
- 1. Otherwise, if the provided value consists of a combination of two keywords, lengths, percentages, and
5086
- calc expressions, then follow the procedure outlined in [[#from-single-keyword]] with
5087
- <var> value</var> given by the first part of the provided value and a horizontal <var> bias</var> , then follow the
5088
- procedure again with <var> value</var> given by the second part of the provided value and a vertical <var> bias</var> .
5089
- 1. Otherwise:
5090
-
5091
- 1. if the provided value starts with a keyword followed by a length, percentage, or calc expression, then follow
5092
- the procedure outlined in [[#from-keyword-and-length]] with <var> keyword</var> set to the
5093
- keyword, <var> length</var> set to the length, percentage, or calc expression, and auto <var> bias</var> .
5094
- 1. otherwise, follow the procedure outlined in [[#from-single-keyword]] with <var> value</var>
5095
- set to the first component of the provided value and an auto <var> bias</var> .
5096
- 1. if <var> bias</var> is horizontal, set it to vertical. Otherwise, set it to horizontal.
5097
- 1. if the remainder of the provided value is a single keyword, length, percentage or calc expression, follow
5098
- the procedure outlined in
5099
- [[#from-single-keyword]] with <var> value</var> set to the keyword and the existing
5100
- <var> bias</var> .
5101
- 1. otherwise, if the remainder of the provided value consists of a keyword followed by a length, percentage or
5102
- calc expression, follow the procedure outlined in [[#from-keyword-and-length]] with
5103
- <var> keyword</var> set to the keyword, <var> length</var> set to the length, percentage, or calc expression, and
5104
- the existing <var> bias</var> .
5105
- 1. Otherwise, the process fails.
5106
-
5107
- <h4 id='from-single-keyword'>Determining <var>x</var> or <var>y</var> from a single value</h4>
5108
-
5109
- The following process sets a value for either <var> x</var> or <var> y</var> , depending on an input <var> value</var>
5110
- and <var> bias</var> . The process also updates <var> bias</var> based on the <var> value</var> .
5111
-
5112
- 1. If <var> value</var> is the keyword "left" and <var> bias</var> is not vertical, then set <var> x</var> to a
5113
- {{CSSNumericValue}} value representing 0% and <var> bias</var> to horizontal and exit this process.
5114
- 1. If <var> value</var> is the keyword "right" and <var> bias</var> is not vertical, then set <var> x</var> to a
5115
- {{CSSNumericValue}} value representing 100% and <var> bias</var> to horizontal and exit this process.
5116
- 1. If <var> value</var> is the keyword "top" and <var> bias</var> is not horizontal, then set <var> y</var> to a
5117
- {{CSSNumericValue}} value representing 0% and <var> bias</var> to vertical and exit this process.
5118
- 1. If <var> value</var> is the keyword "bottom" and <var> bias</var> is not horizontal, then set <var> y</var> to a
5119
- {{CSSNumericValue}} value representing 100% and <var> bias</var> to vertical and exit this process.
5120
- 1. If <var> value</var> [=CSSNumericValue/matches=] the <<length-percentage>> production, then set <var> norm</var> to the result of
5121
- [=reify a numeric value|reifying |value| as a numeric value=] . If <var> bias</var> is vertical,
5122
- set <var> y</var> to <var> norm</var> , otherwise set <var> x</var> to <var> norm</var> and <var> bias</var> to
5123
- horizontal. Exit this process.
5124
- 1. If <var> value</var> is not the keyword "center", then this process fails.
5125
-
5126
- <h4 id='from-keyword-and-length'>Determining <var>x</var> or <var>y</var> from a keyword and a length</h4>
5127
-
5128
- The following process sets a value for either <var> x</var> or<var> y</var> , depending on an input <var> keyword</var> ,
5129
- <var> length</var> , and <var> bias</var> . The process also updates <var> bias</var> based on the <var> keyword</var> and
5130
- <var> length</var> .
5131
-
5132
- 1. Follow the procedure outlined in [[#from-single-keyword]] with <var> value</var> given by
5133
- <var> keyword</var> , using the provided <var> bias</var>
5134
- 1. Let <var> adjustment</var> be the result of
5135
- [=reify a numeric value|reifying |length| as a numeric value=] .
5136
- 1. If the keyword is "right" or "bottom", let <var> adjustment</var> be the result of subtracting
5137
- <var> adjustment</var> from a zero length.
5138
- 1. Amend <var> x</var> (if <var> bias</var> is horizontal) or <var> y</var> (if <var> bias</var> is vertical) by
5139
- adding <var> adjustment</var> to it.
5140
4971
5141
4972
<<url>> (and subtype) Values {#reify-url}
5142
4973
--------------------------------------------------------------
@@ -5580,17 +5411,6 @@ length3.toString(); // "42px";
5580
5411
</div>
5581
5412
5582
5413
5583
- {{CSSPositionValue}} Serialization {#positionvalue-serialization}
5584
- -----------------------------------------------------------------
5585
-
5586
- {{CSSPositionValue}} objects are serialized by:
5587
- * serializing the {{CSSPositionValue/x}} attribute according to
5588
- the rules for {{CSSNumericValue}} objects above.
5589
- * serializing the {{CSSPositionValue/y}} attribute according to
5590
- the rules for {{CSSNumericValue}} objects above.
5591
- * returning the concatenation of the two serializations (x before y), separated
5592
- by a space.
5593
-
5594
5414
{{CSSURLImageValue}} Serialization {#urlimagevalue-serialization}
5595
5415
-----------------------------------------------------------
5596
5416
0 commit comments