Skip to content

Commit 04736d2

Browse files
committed
[css-anchor-position] Specify how flipping exactly works. w3c#10049
1 parent e0805b7 commit 04736d2

File tree

1 file changed

+111
-11
lines changed

1 file changed

+111
-11
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 111 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,12 +1293,10 @@ Values have the following meanings:
12931293
::
12941294
Automatically creates a [=position option=]
12951295
from the element's computed style,
1296-
by swapping the
1297-
[=margin property|margin=],
1298-
[=sizing property|sizing=],
1299-
[=inset property|inset=],
1300-
and [=self-alignment property|self-alignment=] property values
1301-
among the element's sides,
1296+
by [=swapping due to a try-tactic=]
1297+
according to the specified keyword,
1298+
and adding the constructed [=position option=]
1299+
to the element's [=position options list=].
13021300
and adds it to the [=position options list=].
13031301

13041302
<pre class=prod>
@@ -1330,11 +1328,6 @@ Values have the following meanings:
13301328
the transformations are composed in order
13311329
to produce a single [=position option=].
13321330

1333-
Issue: Define how the values themselves are changed upon flipping:
1334-
anchor(top) becomes anchor(bottom);
1335-
start becomes end;
1336-
etc.
1337-
13381331
: <dfn><<dashed-ident>> || <<try-tactic>></dfn>
13391332
::
13401333
Combines the effects of the previous two options:
@@ -1354,6 +1347,113 @@ Values have the following meanings:
13541347
with the given value.
13551348
</dl>
13561349

1350+
<div algorithm>
1351+
To <dfn>swap due to a try-tactic</dfn>
1352+
the styles of an element |el|
1353+
between two directions |directions|,
1354+
returning a set of styles:
1355+
1356+
0. If |directions| are opposites along the same axis,
1357+
they are "opposing".
1358+
Otherwise (when they are specifying different axises),
1359+
they are "perpendicular".
1360+
1361+
1. Determine the specified values of the [=accepted @position-try properties=]
1362+
on |el|,
1363+
and let |styles| be the result.
1364+
1365+
2. [=substitute a var()|Substitute variables=],
1366+
''env()'' functions,
1367+
and similar substitution functions
1368+
in |styles|.
1369+
1370+
Issue: Need to define a term to hook for substitution functions,
1371+
to make sure we can hit var(), env(), random(), etc...
1372+
1373+
3. Swap the values of the |styles| between
1374+
the associated properties
1375+
corresponding to |directions|.
1376+
1377+
<div class=example>
1378+
For example, if "top" and "left" are being swapped,
1379+
then the values of 'margin-top' and 'margin-left' are swapped,
1380+
'width' and 'height' are swapped,
1381+
etc.
1382+
</div>
1383+
1384+
Note: If the directions are opposites along the same axis,
1385+
some properties (like 'width' or 'align-self')
1386+
wont' swap,
1387+
since they're associated with themselves across the two directions,
1388+
but their values might be changed by the next step.
1389+
1390+
4. Modify the values of the properties
1391+
as they swap to match the new directions,
1392+
as follows:
1393+
1394+
* For [=inset properties=],
1395+
change the specified side in ''anchor()'' functions
1396+
to maintain the same relative relationship to the new direction
1397+
that they had to the old.
1398+
1399+
If a <<percentage>> is used,
1400+
and |directions| are opposing,
1401+
change it to ''100%'' minus the original percentage.
1402+
1403+
<div class=example>
1404+
For example, if "top" and "left" are being swapped,
1405+
then ''margin-top: anchor(bottom)''
1406+
will become ''margin-left: anchor(right)''.
1407+
1408+
If "top" and "bottom" are being swapped,
1409+
then ''margin-top: anchor(20%)''
1410+
will become ''margin-bottom: anchor(80%)''.
1411+
</div>
1412+
* For [=sizing properties=],
1413+
change the specified axis in ''anchor-size()'' functions
1414+
to maintain the same relative relationship to the new direction
1415+
that they had to the old.
1416+
1417+
<div class=example>
1418+
For example, if "top" and "left" are being swapped,
1419+
then ''width: anchor-size(width)''
1420+
will become ''height: anchor-size(height)''.
1421+
</div>
1422+
* For the [=self-alignment properties=],
1423+
if |directions| are opposing,
1424+
change the specified <<self-position>>
1425+
(or ''align-self/left''/''align-self/right'' keywords),
1426+
if any,
1427+
to maintain the same relative relationship to the new direction
1428+
that they had to the old.
1429+
1430+
<div class=example>
1431+
For example, if "top" and "bottom" are being swapped,
1432+
then ''align-self: start''
1433+
will become ''align-self: end''.
1434+
1435+
However, ''align-self: center'' will remain unchanged,
1436+
as it has the same relationship to both directions.
1437+
1438+
Similarly, ''align-self: first baseline'' will remain unchanged,
1439+
as it's a <<baseline-position>>
1440+
rather than a <<self-position>>.
1441+
</div>
1442+
* For 'inset-area',
1443+
change the value
1444+
so that the selected rows/columns of the [=inset-area grid=]
1445+
maintain the same relative relationship to the new direction
1446+
that they had to the old.
1447+
1448+
<div class=example>
1449+
For example, if "top" and "left" are being swapped,
1450+
then ''inset-area: left span-bottom''
1451+
will become ''inset-area: top span-right''.
1452+
</div>
1453+
1454+
5. Return |styles|.
1455+
</div>
1456+
13571457
<!-- Big Text: -order
13581458

13591459
███▌ ████▌ ████▌ █████▌ ████▌

0 commit comments

Comments
 (0)