Skip to content

Commit e0a3329

Browse files
committed
[css-align][css-position][css-anchor-position] Define the new 'shift to stay in the original containing block' behavior, and revert the anchor-center 'shrink the available space' behavior. #10316 #10315 #9960
1 parent 95984f6 commit e0a3329

File tree

3 files changed

+118
-27
lines changed

3 files changed

+118
-27
lines changed

css-align-3/Overview.bs

+44-8
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,9 @@ Distributed Alignment: the ''<content-distribution>/stretch'', ''space-between''
771771

772772
These values are represented with the <<content-distribution>> grammar term:
773773

774-
<pre class='prod'><dfn>&lt;content-distribution></dfn> = space-between | space-around | space-evenly | stretch</pre>
774+
<pre class='prod'>
775+
<dfn>&lt;content-distribution></dfn> = space-between | space-around | space-evenly | stretch
776+
</pre>
775777

776778
<h3 id='overflow-values'>
777779
Overflow Alignment: the ''safe'' and ''unsafe'' keywords and scroll safety limits</h3>
@@ -865,13 +867,36 @@ Overflow Alignment: the ''safe'' and ''unsafe'' keywords and scroll safety limit
865867
<dt>(no value specified)
866868
<dd>
867869
If the <a>overflow alignment</a> isn't explicitly specified,
868-
the default <a>overflow alignment</a> is a blend of “safe” and “unsafe”
869-
in that an overflowing <a>alignment subject</a> is allowed to overflow its <a>alignment container</a>,
870-
but if this would cause it to also overflow
871-
the <a>scrollable overflow area</a> of its nearest ancestor <a>scroll container</a>
872-
(thus extending into the “unscrollable” region),
873-
then its overflow in that direction is limited
874-
by biasing any remaining overflow to the opposite side.
870+
the default <a>overflow alignment</a> is a blend of “safe” and “unsafe”,
871+
and also varies slightly depending on layout mode.
872+
873+
For [=absolutely positioned=] [=alignment subjects=]
874+
which are not in [=legacy positioning mode=]
875+
in the given axis:
876+
877+
1. If the [=alignment subject=] overflows its [=inset-modified containing block=]
878+
(its normal [=alignment container=]),
879+
no effect.
880+
2. If the <em>size</em> of the [=alignment subject=]
881+
fits within its [=original containing block=],
882+
but its alignment would cause it to overflow the [=original containing block=],
883+
it is instead shifted the minimum amount
884+
to stay within the [=original containing block=]
885+
(flush with the edge of the [=original containing block=]
886+
it was trying to overflow over).
887+
3. If the size of the [=alignment subject=]
888+
overflows the [=original containing block=],
889+
it is instead start-aligned within the [=original containing block=].
890+
891+
For all other elements:
892+
893+
1. If the [=alignment subject=] overflows its [=alignment container=],
894+
no effect.
895+
2. If the [=alignment subject=] would overflow
896+
the [=scrollable overflow area=] of its nearest ancestor [=scroll container=],
897+
(thus extending into the “unscrollable” region),
898+
then its overflow in that direction is limited
899+
by biasing any remaining overflow to the opposite side.
875900

876901
Issue: It may not be Web-compatible to implement the “smart” default behavior
877902
(though we hope so, and believe it to be likely),
@@ -881,6 +906,17 @@ Overflow Alignment: the ''safe'' and ''unsafe'' keywords and scroll safety limit
881906
and ''unsafe'' otherwise.
882907
</dl>
883908

909+
An [=absolutely-positioned element=]
910+
is in <dfn export>legacy positioning mode</dfn>
911+
in a given axis
912+
if all of the following are true:
913+
914+
* the relevant [=self-alignment property=] is ''justify-self/normal'' on the element.
915+
* the elements's 'inset-area' property does not define an [=inset-area grid=].
916+
917+
Note: A number of newer behaviors across several specifications
918+
can't apply to elements in [=legacy positioning mode=],
919+
due to backwards-compatibility constraints.
884920

885921
<!--
886922
██████ ███████ ██ ██ ████████ ████████ ██ ██ ████████

css-anchor-position-1/Overview.bs

+49-19
Original file line numberDiff line numberDiff line change
@@ -559,25 +559,53 @@ Its syntax is:
559559
or is not an [=absolutely-positioned=] element,
560560
this value has no effect.
561561

562-
Otherwise, the property selects a region of the [=inset-area grid=],
563-
and makes that the element's [=containing block=].
562+
Otherwise, it has the following effects:
564563

565-
Note: This means that the [=inset properties=] specify offsets from the inset-area,
566-
and some property values,
567-
like ''max-height: 100%'',
568-
will be relative to the inset-area as well.
564+
* The property selects a region of the [=inset-area grid=],
565+
and makes that the element's [=containing block=].
566+
See [[#resolving-spans]] for details.
569567

570-
Additionally, the ''align-self/normal'' value for the [=self-alignment properties=]
571-
behaves as either ''align-self/start'', ''align-self/end'',
572-
or ''align-self/anchor-center'',
573-
depending on the positioning of the region,
574-
to give a good default alignment for the positioned element.
568+
Note: This means that the [=inset properties=] specify offsets from the inset-area,
569+
and some property values,
570+
like ''max-height: 100%'',
571+
will be relative to the inset-area as well.
575572

576-
See [[#resolving-spans]] for details on both of these effects.
573+
* The ''align-self/normal'' value for the [=self-alignment properties=]
574+
behaves as either ''align-self/start'', ''align-self/end'',
575+
or ''align-self/anchor-center'',
576+
depending on the positioning of the region,
577+
to give a good default alignment for the positioned element.
578+
Again, see [[#resolving-spans]] for details.
577579

578-
Also, any ''top/auto'' [=inset properties=] resolve to ''0''.
580+
* Any ''top/auto'' [=inset properties=] resolve to ''0''.
581+
582+
* The element is not considered to be in a [=legacy alignment mode=]
583+
in either axis.
579584
</dl>
580585

586+
<div class=note>
587+
If the element overflows its 'inset-area' (and 'inset') -modified [=containing block=],
588+
but would still fit within its [=original containing block=],
589+
by default it will "shift" to stay within its [=original containing block=],
590+
even if that violates its normal alignment.
591+
See [[css-align-3#overflow-values]] for details.
592+
593+
This behavior makes it more likely
594+
that positioned elements remain visible
595+
and within their intended bounds,
596+
even when their [=containing block=]
597+
ends up smaller than anticipated.
598+
599+
For example, an ''inset-area: bottom span-right'' value
600+
lets the positioned element stretch
601+
from its anchors left edge
602+
to its containing block's right edge,
603+
and left-aligns it in that space by default.
604+
But if the positioned element is larger than that space
605+
(such as if the anchor is very close to the right edge of the screen),
606+
it will shift leftwards to stay visible.
607+
</di>
608+
581609

582610
<h4 id=resolving-spans>
583611
Resolving <<inset-area>>s</h4>
@@ -918,18 +946,20 @@ in the relevant axis.
918946

919947
Additionally,
920948
any ''top/auto'' [=inset properties=] resolve to ''0''.
921-
However, the [=available space=] for the positioned element in the relevant axis
922-
is reduced to the size of the largest rectangle
923-
that is centered on the [=default anchor element=]
924-
and doesn't overflow the [=inset-modified containing block=].
925-
(Possibly being zero-sized,
926-
if the anchor's center is not within the [=inset-modified containing block=].)
927949

928950
If the element is not [=absolutely positioned=],
929951
or does not have a [=default anchor element=],
930952
this value behaves as ''<self-position>/center''
931953
and has no additional effect on how [=inset properties=] resolve.
932954

955+
Note: Similar to 'inset-area',
956+
when using ''anchor-center'',
957+
if the anchor is too close to the edge of the element's
958+
[=original containing block=],
959+
by default it will "shift" from being purely centered,
960+
to instead remain within the [=original containing block=].
961+
See [[css-align-3#overflow-values]] for more details.
962+
933963

934964
<!-- Big Text: scroll
935965

css-position-3/Overview.bs

+25
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,31 @@ Containing Blocks of Positioned Boxes</h3>
373373
(i.e., that generated by "div1").
374374
</div>
375375

376+
<h4 id="original-cb">
377+
Further Shrinking the Containing Block</h4>
378+
379+
Some features can additionally change the [=containing block=]
380+
of [=absolutely positioned=] boxes.
381+
These are applied in the following order,
382+
with earlier steps modifying the containing block
383+
that later steps see:
384+
385+
1. If the [=containing block=] is generated by a [=grid container=],
386+
the [=grid positioning properties=]
387+
on the positioned element
388+
change the [=containing block=]
389+
to the corresponding [=grid area=]
390+
of that [=grid container=].
391+
See [[css-grid-1#abspos-items]].
392+
393+
2. If 'inset-area' has an effect on the positioned element,
394+
the [=containing block=] is the specified area of the [=inset-area grid=].
395+
See [[css-anchor-position-1#inset-area]].
396+
397+
The element's <dfn export>original containing block</dfn>
398+
is its [=containing block=]
399+
before applying any of these effects.
400+
376401
<h3 id="stacking">
377402
Painting Order and Stacking Contexts</h3>
378403

0 commit comments

Comments
 (0)