@@ -1360,9 +1360,8 @@ Applying Position Fallback {#fallback-apply}
13601360
13611361When a positioned element overflows its [=inset-modified containing block=] ,
13621362and has a non-empty [=position options list=] ,
1363- it iterates the [=position options list=] ,
1364- applying each [=position option's=] styles over the element's base styles,
1365- and attempts to find an option that avoids overflow.
1363+ it [=determines the position fallback styles=] for the element
1364+ to attempt to find an option that avoids overflow.
13661365
13671366These modified styles are applied to the element via [=interleaving=] ,
13681367so they affect [=computed values=]
@@ -1419,50 +1418,36 @@ as part of a theoretical UA-controlled final cascade layer.
14191418 only |el|'s own [=margin box=] .
14201419</div>
14211420
1421+ During a full layout pass,
1422+ once an element has determined its fallback styles
1423+ (or determined it's not using any),
1424+ laying out later elements cannot change this decision.
1425+
1426+ <div class=example>
1427+ For example, say you have two positioned elements,
1428+ A and B,
1429+ with A laid out before B.
1430+ If B overflows and causes A's containing block to gain scrollbars,
1431+ this <em> does not</em> cause A
1432+ to go back and re-determine its fallback styles
1433+ in an attempt to avoid overflowing.
1434+ (At best, this can result in exponential layout costs;
1435+ at worst, it's cyclic and will never settle.)
1436+
1437+ Layout does not "go backward", in other words.
1438+ </div>
1439+
14221440Issue: Make sure the snapshotted scroll offset stuff is correct now,
14231441given interleaving.
14241442
14251443Issue: Add conditions for forgetting the [=last successful position option=] ,
14261444similar to the [=last remembered size=]
14271445
1428- The styles returned by [=determining the position fallback styles=]
1429- are taken as the final values for the specified properties.
1430-
14311446Implementations may choose to impose an implementation-defined limit
14321447on the length of [=position options lists=] ,
14331448to limit the amount of excess layout work that may be required.
14341449This limit must be <em> at least</em> five.
14351450
1436- <div class=issue>
1437- Nested anchors
1438- (an anchored element inside of another anchored element)
1439- present the potential for exponential blow-up of layouts
1440- when doing fallback,
1441- since the grandchild anchored element can cause scrollbars on an ancestor,
1442- changing the IMCB for the child anchored element,
1443- thus possibly causing the fallback choice to change for it.
1444-
1445- There are strategies to avoid this,
1446- but they're not without costs of their own.
1447- We should <em> probably</em> impose a <strong> maximum</strong> limit as well,
1448- to avoid this.
1449-
1450- However, since *most* usages won't be problematic in the first place,
1451- we don't want to restrict them unduly
1452- just to prevent weird situations from exploding.
1453- Perhaps a complexity budget based on the branching factor at each level?
1454- Like, accumulate the product of the fallback list lengths from ancestors,
1455- and your fallback list gets limited to not exceed a total product
1456- of, say, 1k.
1457- Get too deep and you're stuck with your first choice only!
1458- But this would allow large, complex fallback lists for top-level stuff,
1459- and even some reasonable nesting.
1460- (Length-five lists could be nested to depth of 4, for example,
1461- if we did go with 1k.)
1462-
1463- More thought is needed.
1464- </div>
1465-
14661451<div class=example>
14671452 For example,
14681453 the following CSS will first attempt to position a "popover"
@@ -1474,47 +1459,16 @@ This limit must be <em>at least</em> five.
14741459 <pre highlight=css>
14751460 #myPopover {
14761461 position: fixed;
1477- position-fallback: --button-popover;
1478- overflow: auto;
1462+ top: anchor(--button bottom);
1463+ left: anchor(--button left);
1464+ position-try-options: flip-inline, flip-block, flip-block flip-inline;
14791465
14801466 /* The popover is at least as wide as the button */
14811467 min-width: anchor-size(--button width);
14821468
14831469 /* The popover is at least as tall as 2 menu items */
14841470 min-height: 6em;
14851471 }
1486-
1487- @position-fallback --button-popover {
1488- /* First try to align the top, left edge of the popover
1489- with the bottom, left edge of the button. */
1490- @try {
1491- top: anchor(--button bottom);
1492- left: anchor(--button left);
1493- }
1494-
1495- /* Next try to align the bottom, left edge of the popover
1496- with the top, left edge of the button. */
1497- @try {
1498- bottom: anchor(--button top);
1499- left: anchor(--button left);
1500- }
1501-
1502- /* Next try to align the top, right edge of the popover
1503- with the bottom, right edge of the button. */
1504- @try {
1505- top: anchor(--button bottom);
1506- right: anchor(--button right);
1507- }
1508-
1509- /* Finally, try to align the bottom, right edge of the popover
1510- with the top, right edge of the button. Other positions are possible,
1511- but this is the final option the author would like the rendering
1512- engine to try. */
1513- @try {
1514- bottom: anchor(--button top);
1515- right: anchor(--button right);
1516- }
1517- }
15181472 </pre>
15191473</div>
15201474
0 commit comments