@@ -24,8 +24,8 @@ spec:dom; type:dfn; text:element
24
24
Introduction {#intro}
25
25
=====================
26
26
27
- The layout stage of CSS is responsible for generating and positioning <a>fragments</a> from a tree
28
- of <a>boxes </a> .
27
+ The layout stage of CSS is responsible for generating and positioning <a>fragments</a> from the
28
+ <a>box tree </a> .
29
29
30
30
This specification describes an API which allows developers to layout a <a>box</a> in response to
31
31
computed style and <a>box</a> tree changes.
@@ -487,21 +487,51 @@ registerLayout('fragmenting', class {
487
487
Layout Invalidation {#layout-invalidation}
488
488
==========================================
489
489
490
- <div class='issue'>
491
- TODO, list all the ways that layout can be invalidated, namely:
492
- - Computed style change.
493
- - Child computed style change.
494
- - Child add/remove change.
495
- - etc.
496
- </div>
490
+ A <a>document</a> has an associated <dfn>layout name to input properties map</dfn> and a <dfn>layout
491
+ name to child input properties map</dfn> . Initialy these maps are empty and are populated when
492
+ {{registerLayout(name, layoutCtor)}} is called.
493
+
494
+ Each <a>box</a> has an associated <dfn>layout valid flag</dfn> . It may be either
495
+ <dfn>layout-valid</dfn> or <dfn>layout-invalid</dfn> . It is initially set to <a>layout-invalid</a> .
496
+
497
+ When the computed style for a |box| changes, the user agent must run the following steps:
498
+ 1. Let |layoutFunction| be the <<layout()>> or <<inline-layout()>> function of the 'display'
499
+ property on the computed style if it exists. If it is a different type of value (e.g.
500
+ ''grid'' ) then abort all these steps.
501
+
502
+ 2. Let |name| be the first argument of the |layoutFunction|.
503
+
504
+ 3. Let |inputProperties| be the result of looking up |name| on <a>layout name to input
505
+ properties map</a> .
506
+
507
+ 4. Let |childInputProperties| be the result of looking up |name| on <a>layout name to child
508
+ input properties map<a>.
509
+
510
+ 5. For each |property| in |inputProperties|, if the |property|'s <a>computed value</a> has
511
+ changed, set the <a>layout valid flag</a> on the <a>box</a> to <a>layout-invalid</a> .
512
+
513
+ 6. For each |property| in |childInputProperties|, if the |property|'s <a>computed value</a> has
514
+ changed, set the <a>layout valid flag</a> on the <a>box</a> to <a>layout-invalid</a> .
515
+
516
+ When a child <a>box</a> represented by a {{BoxLayoutChild}} is added or removed from the <a>box
517
+ tree</a> or has its layout invalidated (from a computed style change). Set the <a>layout valid
518
+ flag</a> on the current <a>box</a> to <a>layout-invalid</a> .
519
+
520
+ When a child non-<a>atomic inline</a> represented by a {{InlineLayoutChild}} is added or removed
521
+ from the <a>box tree</a> or has its layout invalidated (from a computed style change, or if its text
522
+ has changed). Set the <a>layout valid flag</a> on the current <a>box</a> to <a>layout-invalid</a> .
523
+
524
+ NOTE: This only describes layout invalidatation as it relates to the CSS Layout API. All
525
+ <a>boxes</a> conceptually have a <a>layout valid flag</a> and these changes are propogated
526
+ through the <a>box tree</a> .
497
527
498
528
Layout Engine {#layout-engine}
499
529
==============================
500
530
501
531
<pre class="idl">
502
532
interface FragmentRequestToken {
503
533
// Has internal slots:
504
- // [[box ]] - The box to generate the fragment for.
534
+ // [[layoutChild ]] - The layout child to generate the fragment for.
505
535
// [[constraintSpace]] - The constraint space to perform layout in.
506
536
// [[breakToken]] - The break token to resume the layout with.
507
537
};
@@ -528,8 +558,8 @@ An example layout engine written in javascript is shown below.
528
558
529
559
<pre class="lang-javascript">
530
560
class LayoutEngine {
531
- // This function takes the root of the Box -tree, a ConstraintSpace, and a
532
- // BreakToken to (if paginating for printing for example) and generates a
561
+ // This function takes the root of the box -tree, a ConstraintSpace, and a
562
+ // BreakToken to (if paginating for printing for example) and generates a
533
563
// Fragment.
534
564
layoutEntry(rootBox, rootPageConstraintSpace, breakToken) {
535
565
return layoutFragment({
@@ -576,8 +606,6 @@ Registering A Layout {#registering-a-layout}
576
606
============================================
577
607
578
608
<pre class='idl'>
579
- callback VoidFunction = void ();
580
-
581
609
partial interface LayoutWorkletGlobalScope {
582
610
void registerLayout(DOMString name, VoidFunction layoutCtor);
583
611
};
@@ -612,7 +640,8 @@ Layout Notation {#layout-notation}
612
640
<dfn>inline-layout()</dfn> = inline-layout( <<ident>> )
613
641
</pre>
614
642
615
- The <<layout()>> and <<inline-layout()>> function is an additional notation to be supported by the ''display'' property.
643
+ The <<layout()>> and <<inline-layout()>> function is an additional notation to be supported by the
644
+ 'display' property.
616
645
617
646
Issue: Resolve this with css-display-3 once required.
618
647
0 commit comments