Skip to content

Commit 6c58a23

Browse files
committed
[css-layout-api] Update layout invalidation section.
1 parent 7b44c50 commit 6c58a23

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

css-layout-api/Overview.bs

+44-15
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ spec:dom; type:dfn; text:element
2424
Introduction {#intro}
2525
=====================
2626

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>.
2929

3030
This specification describes an API which allows developers to layout a <a>box</a> in response to
3131
computed style and <a>box</a> tree changes.
@@ -487,21 +487,51 @@ registerLayout('fragmenting', class {
487487
Layout Invalidation {#layout-invalidation}
488488
==========================================
489489

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>.
497527

498528
Layout Engine {#layout-engine}
499529
==============================
500530

501531
<pre class="idl">
502532
interface FragmentRequestToken {
503533
// Has internal slots:
504-
// [[box]] - The box to generate the fragment for.
534+
// [[layoutChild]] - The layout child to generate the fragment for.
505535
// [[constraintSpace]] - The constraint space to perform layout in.
506536
// [[breakToken]] - The break token to resume the layout with.
507537
};
@@ -528,8 +558,8 @@ An example layout engine written in javascript is shown below.
528558

529559
<pre class="lang-javascript">
530560
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
533563
// Fragment.
534564
layoutEntry(rootBox, rootPageConstraintSpace, breakToken) {
535565
return layoutFragment({
@@ -576,8 +606,6 @@ Registering A Layout {#registering-a-layout}
576606
============================================
577607

578608
<pre class='idl'>
579-
callback VoidFunction = void ();
580-
581609
partial interface LayoutWorkletGlobalScope {
582610
void registerLayout(DOMString name, VoidFunction layoutCtor);
583611
};
@@ -612,7 +640,8 @@ Layout Notation {#layout-notation}
612640
<dfn>inline-layout()</dfn> = inline-layout( <<ident>> )
613641
</pre>
614642

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.
616645

617646
Issue: Resolve this with css-display-3 once required.
618647

0 commit comments

Comments
 (0)