Skip to content

Commit b90e037

Browse files
committed
[css-layout-api] Add section on how sizing works.
1 parent b31962f commit b90e037

File tree

1 file changed

+98
-9
lines changed

1 file changed

+98
-9
lines changed

css-layout-api/Overview.bs

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ values other than ''z-index/auto'' create a stacking context even if 'position'
146146
Box Tree Transformations {#layout-api-box-tree}
147147
-----------------------------------------------
148148

149-
The children of a <a>layout API container</a> can act in different ways depending on the value of <a
150-
for="document layout definition">child display</a> (set by <code>childDisplay</code> on the class).
149+
The <a>layout API children</a> can act in different ways depending on the value of <a for="document
150+
layout definition">child display</a> (set by <code>childDisplay</code> on the class).
151151

152152
If the value of <a for="document layout definition">child display</a> is <code>"block"</code> the
153153
'display' value of that child is <a>blockified</a>. This is similar to children of <a>flex
@@ -349,7 +349,8 @@ registerLayout('block-like', class {
349349
const inlineSize = resolveInlineSize(space, styleMap);
350350

351351
const availableInlineSize = inlineSize - edges.all.inline;
352-
const availableBlockSize = resolveBlockSize(constraintSpace, styleMap) - edges.all.block;
352+
const availableBlockSize =
353+
resolveBlockSize(constraintSpace, styleMap) - edges.all.block;
353354

354355
const childFragments = [];
355356
const childConstraintSpace = new ConstraintSpace({
@@ -373,9 +374,9 @@ registerLayout('block-like', class {
373374
blockOffset += fragment.blockSize;
374375
}
375376

376-
const contentSize = blockOffset + edges.all.blockEnd;
377+
const autoBlockSize = blockOffset + edges.all.blockEnd;
377378
const blockSize = resolveBlockSize(
378-
constraintSpace, styleMap, contentSize);
379+
constraintSpace, styleMap, autoBlockSize);
379380

380381
return {
381382
inlineSize: inlineSize,
@@ -417,6 +418,7 @@ interface ConstraintSpace {
417418
readonly attribute double percentageInlineSize;
418419
readonly attribute double percentageBlockSize;
419420

421+
readonly attribute double? blockFragmentationOffset;
420422
readonly attribute BlockFragmentationType blockFragmentationType;
421423

422424
readonly attribute any data;
@@ -432,6 +434,7 @@ dictionary ConstraintSpaceOptions {
432434
double? percentageInlineSize = null;
433435
double? percentageBlockSize = null;
434436

437+
double? blockFragmentationOffset = null;
435438
BlockFragmentationType blockFragmentationType = "none";
436439

437440
any data = null;
@@ -665,10 +668,10 @@ registerLayout('indent-lines', class {
665668
}
666669
}
667670

668-
const contentSize = blockOffset + edges.all.blockEnd;
671+
const autoBlockSize = blockOffset + edges.all.blockEnd;
669672
const blockSize = resolveBlockSize(space,
670673
styleMap,
671-
contentSize);
674+
autoBlockSize);
672675

673676
// Return our fragment.
674677
const result = {
@@ -780,13 +783,27 @@ partial interface LayoutWorkletGlobalScope {
780783

781784
double resolveBlockSize(ConstraintSpace constraintSpace,
782785
StylePropertyMapReadOnly styleMap,
783-
optional double contentSize);
786+
optional double autoBlockSize);
784787

785788
double resolveLength(ConstraintSpace constraintSpace, CSSStyleValue value);
786789
};
787790
</pre>
788791

789-
Issue: Specify the behaviour of these functions.
792+
<div algorithm>
793+
When the <dfn method for=LayoutWorkletGlobalScope>resolveBlockSize(|constraintSpace|, |styleMap|,
794+
|autoBlockSize|)</dfn> method is called, the user agent <em>must</em> run the following steps:
795+
796+
Issue: Define that this algorithm should do exactly what CSS does for block sizes.
797+
|constraintSpace|, |styleMap|, |autoBlockSize|.
798+
</div>
799+
800+
<div algorithm>
801+
When the <dfn method for=LayoutWorkletGlobalScope>resolveLength(|constraintSpace|, |value|)</dfn>
802+
method is called, the user agent <em>must</em> run the following steps:
803+
804+
Issue: Define that this algorithm should do exactly what CSS does for generic lengths.
805+
|constraintSpace|, |value|.
806+
</div>
790807

791808
Interactions with other Modules {#interactions-with-other-modules}
792809
==================================================================
@@ -796,7 +813,79 @@ This section describes how other CSS modules interact with the CSS Layout API.
796813
Sizing {#interaction-sizing}
797814
----------------------------
798815

816+
User agents must use the {{ConstraintSpace}} to communicate to the <a>current layout</a> the size
817+
they would like the fragment to be.
818+
819+
If the user agent wishes to force a size on the box, it can use the
820+
{{ConstraintSpace/inlineSizeFixed}} and {{ConstraintSpace/blockSizeFixed}} attributes to do so.
821+
822+
Issue: Do we want the inlineSize to always be fixed? This would remove the resolveInlineSize call,
823+
and just rely on the pre-defined behaviour by the user agent.
824+
825+
The downside to this is that we won't be able to things like MathML in the initial version of
826+
the specifcation, which is able to "bubble" up inline sizes to its parent.
827+
828+
We can't do a similar thing for the blockSize due to fragmentation. E.g. the size of the
829+
fragment which is undergoing fragmentation, isn't able to be automatically resolved.
830+
831+
If the <a>layout API container</a> is within a <a>block formatting context</a>, is inflow, and has
832+
an ''width/auto'' inline size, the user agent <em>must</em> set the {{ConstraintSpace/inlineSize}}
833+
to the <a>stretch-fit inline size</a>.
834+
835+
<div class="note">
836+
Note: In the example below the <a>layout API container</a> has its inline size set to 50.
837+
838+
<pre class="lang-html">
839+
&lt;style>
840+
#container {
841+
width: 100px;
842+
height: 100px;
843+
box-sizing: border-box;
844+
padding: 5px;
845+
}
846+
#layout-api {
847+
display: layout(foo);
848+
margin: 0 20px;
849+
}
850+
&lt;/style>
851+
&lt;div id="container">
852+
&lt;div id="layout-api">&lt;/div>
853+
&lt;/div>
854+
</pre>
855+
</div>
856+
857+
### Positioned layout sizing ### {#interaction-sizing-positiong-layout}
799858

859+
If a <a>layout API container</a> is out-of-flow positioned the user agent <em>must</em> solve the
860+
positioned size equations ([[css-position-3#abs-non-replaced-width]],
861+
[[css-position-3#abs-non-replaced-height]]), and set the appropriate fixed
862+
{{ConstraintSpace/inlineSize}} and {{ConstraintSpace/blockSize}}.
863+
864+
<div class="note">
865+
Note: In the example below the <a>layout API container</a> has its inline and block size fixed
866+
to 80.
867+
868+
<pre class="lang-html">
869+
&lt;style>
870+
#container {
871+
position: relative;
872+
width: 100px;
873+
height: 100px;
874+
}
875+
#layout-api {
876+
display: layout(foo);
877+
top: 10px;
878+
bottom: 10px;
879+
left: 10px;
880+
right: 10px;
881+
position: absolute;
882+
}
883+
&lt;/style>
884+
&lt;div id="container">
885+
&lt;div id="layout-api">&lt;/div>
886+
&lt;/div>
887+
</pre>
888+
</div>
800889

801890
Positioning {#interaction-positioning}
802891
--------------------------------------

0 commit comments

Comments
 (0)