@@ -785,8 +785,8 @@ registerLayout('example-layout-fragment', class {
785
785
786
786
// You can set the position of the fragment, e.g. this will set it to the
787
787
// top-left corner:
788
- fragment.inlineOffset = edges.all. inlineStart;
789
- fragment.blockOffset = edges.all. blockStart;
788
+ fragment.inlineOffset = edges.inlineStart;
789
+ fragment.blockOffset = edges.blockStart;
790
790
791
791
// Data may be passed from the child layout:
792
792
console.log(fragment.data);
@@ -938,9 +938,9 @@ registerLayout('layout-constraints-example', class {
938
938
async layout(children, edges, constraints, styleMap) {
939
939
940
940
// Calculate the available size.
941
- const availableInlineSize = constraints.fixedInlineSize - edges.all. inline;
941
+ const availableInlineSize = constraints.fixedInlineSize - edges.inline;
942
942
const availableBlockSize = constraints.fixedBlockSize ?
943
- constraints.fixedBlockSize - edges.all. inline : null;
943
+ constraints.fixedBlockSize - edges.inline : null;
944
944
945
945
// Web developers should resolve any percentages against the percentage sizes.
946
946
const value = constraints.percentageInlineSize * 0.5;
@@ -1093,7 +1093,7 @@ Edges {#edges}
1093
1093
1094
1094
<pre class='idl'>
1095
1095
[Exposed=LayoutWorklet]
1096
- interface LayoutEdgeSizes {
1096
+ interface LayoutEdges {
1097
1097
readonly attribute double inlineStart;
1098
1098
readonly attribute double inlineEnd;
1099
1099
@@ -1104,33 +1104,17 @@ interface LayoutEdgeSizes {
1104
1104
readonly attribute double inline;
1105
1105
readonly attribute double block;
1106
1106
};
1107
-
1108
- [Exposed=LayoutWorklet]
1109
- interface LayoutEdges {
1110
- readonly attribute LayoutEdgeSizes border;
1111
- readonly attribute LayoutEdgeSizes scrollbar;
1112
- readonly attribute LayoutEdgeSizes padding;
1113
-
1114
- readonly attribute LayoutEdgeSizes all;
1115
- };
1116
1107
</pre>
1117
1108
1118
- A {{LayoutEdges}} object is passed into the layout method. This represents the size of the [=box
1119
- model edges=] for the current box which is being laid out.
1120
-
1121
- The {{LayoutEdges}} has {{LayoutEdges/border}} , {{LayoutEdges/scrollbar}} , and
1122
- {{LayoutEdges/padding}} attributes. Each of these represent the width of their respective edge.
1123
-
1124
- The {{LayoutEdges}} has the {{LayoutEdges/all}} attribute. This is a convenience attribute which
1125
- represents the sum of the {{LayoutEdges/border}} , {{LayoutEdges/scrollbar}} , {{LayoutEdges/padding}}
1126
- edges.
1109
+ A {{LayoutEdges}} object is passed into the layout method. This represents the sum of all the [=box
1110
+ model edges=] (border, scrollbar, padding), for the current box which is being laid out.
1127
1111
1128
- The {{LayoutEdgeSizes}} object represents the width in CSS pixels of an edge in each of the
1129
- [=abstract dimensions=] ({{LayoutEdgeSizes /inlineStart}} , {{LayoutEdgeSizes /inlineEnd}} ,
1130
- {{LayoutEdgeSizes/blockStart}} , {{LayoutEdgeSizes /blockEnd}} ).
1112
+ Each of the accessors represents the width in CSS pixels of an edge in each of the [=abstract
1113
+ dimensions=] ({{LayoutEdges /inlineStart}} , {{LayoutEdges /inlineEnd}} , {{LayoutEdges/blockStart }} ,
1114
+ {{LayoutEdges /blockEnd}} ).
1131
1115
1132
- The {{LayoutEdgeSizes /inline}} , and {{LayoutEdgeSizes /block}} on the {{LayoutEdgeSizes }} object are
1133
- convenience attributes which represent the sum in that direction.
1116
+ The {{LayoutEdges /inline}} , and {{LayoutEdges /block}} on the {{LayoutEdges }} object are convenience
1117
+ attributes which represent the sum in that direction.
1134
1118
1135
1119
<div class="example">
1136
1120
This example shows an node styled by CSS, and what its respective {{LayoutEdges}} could contain.
@@ -1159,10 +1143,11 @@ This example shows an node styled by CSS, and what its respective {{LayoutEdges}
1159
1143
<pre class="lang-javascript">
1160
1144
registerLayout('box-edges' , class {
1161
1145
async layout(children, edges, constraints, styleMap, breakToken) {
1162
- edges.padding.inlineStart; // 5 (as 10% * 50px = 5px).
1163
- edges.border.blockEnd; // 2
1164
- edges.scrollbar.inlineEnd; // UA-dependent, may be 0 or >0 (e.g. 16).
1165
- edges.all.block; // 14 (2 + 5 + 5 + 2).
1146
+ edges.inlineStart; // 2 + 5 (as 10% * 50px = 5px).
1147
+ edges.blockEnd; // 7 (2 + 5)
1148
+ edges.inlineEnd; // UA-dependent, due to scrollbar.
1149
+ // Could be 2 + 5 + 0 or 2 + 5 + 16 for example.
1150
+ edges.block; // 14 (2 + 5 + 5 + 2).
1166
1151
}
1167
1152
}
1168
1153
</pre>
@@ -1527,8 +1512,8 @@ When the user agent wants to <dfn>invoke a intrinsic sizes callback</dfn> given
1527
1512
1528
1513
2. [=list/Append=] |layoutChild| to |children|.
1529
1514
1530
- 6. Let |edges| be a new {{LayoutEdgeSizes }} populated with the [=computed value=] for all the
1531
- [=box model edges=] for |box|.
1515
+ 6. Let |edges| be a new {{LayoutEdges }} populated with the [=computed value=] for all the [=box
1516
+ model edges=] for |box|.
1532
1517
1533
1518
7. Let |styleMap| be the result of [=get a style map=] given |box|, and |inputProperties|.
1534
1519
@@ -1644,8 +1629,8 @@ following steps:
1644
1629
1645
1630
2. <a for=list>Append</a> |layoutChild| to |children|.
1646
1631
1647
- 8. Let |edges| be a new {{LayoutEdgeSizes }} populated with the [=computed value=] for all the
1648
- [=box model edges=] for |box|.
1632
+ 8. Let |edges| be a new {{LayoutEdges }} populated with the [=computed value=] for all the [=box
1633
+ model edges=] for |box|.
1649
1634
1650
1635
9. Let |layoutConstraints| be the result of [=create a layout constraints object=] given
1651
1636
|internalLayoutConstraints|, |box|, and |sizingMode|.
@@ -1900,20 +1885,20 @@ registerLayout('block-like', class {
1900
1885
1901
1886
const maxContentSize = childrenSizes.reduce((max, childSizes) => {
1902
1887
return Math.max(max, childSizes.maxContentSize);
1903
- }, 0) + edges.all. inline;
1888
+ }, 0) + edges.inline;
1904
1889
1905
1890
const minContentSize = childrenSizes.reduce((max, childSizes) => {
1906
1891
return Math.max(max, childSizes.minContentSize);
1907
- }, 0) + edges.all. inline;
1892
+ }, 0) + edges.inline;
1908
1893
1909
1894
return {maxContentSize, minContentSize};
1910
1895
}
1911
1896
1912
1897
async layout(children, edges, constraints, styleMap) {
1913
1898
// Determine our (inner) available size.
1914
- const availableInlineSize = constraints.fixedInlineSize - edges.all. inline;
1899
+ const availableInlineSize = constraints.fixedInlineSize - edges.inline;
1915
1900
const availableBlockSize = constraints.fixedBlockSize ?
1916
- constraints.fixedBlockSize - edges.all. block : null;
1901
+ constraints.fixedBlockSize - edges.block : null;
1917
1902
1918
1903
const childFragments = [];
1919
1904
const childConstraints = { availableInlineSize, availableBlockSize };
@@ -1922,19 +1907,19 @@ registerLayout('block-like', class {
1922
1907
return child.layoutNextFragment(childConstraints);
1923
1908
}));
1924
1909
1925
- let blockOffset = edges.all. blockStart;
1910
+ let blockOffset = edges.blockStart;
1926
1911
for (let fragment of childFragments) {
1927
1912
// Position the fragment in a block like manner, centering it in the
1928
1913
// inline direction.
1929
1914
fragment.blockOffset = blockOffset;
1930
1915
fragment.inlineOffset = Math.max(
1931
- edges.all. inlineStart,
1916
+ edges.inlineStart,
1932
1917
(availableInlineSize - fragment.inlineSize) / 2);
1933
1918
1934
1919
blockOffset += fragment.blockSize;
1935
1920
}
1936
1921
1937
- const autoBlockSize = blockOffset + edges.all. blockEnd;
1922
+ const autoBlockSize = blockOffset + edges.blockEnd;
1938
1923
1939
1924
return {
1940
1925
autoBlockSize,
@@ -1958,21 +1943,21 @@ registerLayout('flex-distribution-like', class {
1958
1943
1959
1944
const maxContentSize = childrenSizes.reduce((sum, childSizes) => {
1960
1945
return sum + childSizes.maxContentSize;
1961
- }, 0) + edges.all. inline;
1946
+ }, 0) + edges.inline;
1962
1947
1963
1948
const minContentSize = childrenSizes.reduce((max, childSizes) => {
1964
1949
return sum + childSizes.minContentSize;
1965
- }, 0) + edges.all. inline;
1950
+ }, 0) + edges.inline;
1966
1951
1967
1952
return {maxContentSize, minContentSize};
1968
1953
}
1969
1954
1970
1955
async layout(children, edges, constraints, styleMap) {
1971
1956
// Determine our (inner) available size.
1972
1957
const availableInlineSize =
1973
- constraints.fixedInlineSize - edges.all. inline;
1958
+ constraints.fixedInlineSize - edges.inline;
1974
1959
const availableBlockSize = constraints.fixedBlockSize ?
1975
- constraints.fixedBlockSize - edges.all. block : null;
1960
+ constraints.fixedBlockSize - edges.block : null;
1976
1961
1977
1962
const childConstraints = { availableInlineSize, availableBlockSize };
1978
1963
@@ -2002,14 +1987,14 @@ registerLayout('flex-distribution-like', class {
2002
1987
let maxChildBlockSize = 0;
2003
1988
for (let fragment of childFragments) {
2004
1989
fragment.inlineOffset = inlineOffset;
2005
- fragment.blockOffset = edges.all. blockStart;
1990
+ fragment.blockOffset = edges.blockStart;
2006
1991
2007
1992
inlineOffset += fragment.inlineSize;
2008
1993
maxChildBlockSize = Math.max(maxChildBlockSize, fragment.blockSize);
2009
1994
}
2010
1995
2011
1996
return {
2012
- autoBlockSize: maxChildBlockSize + edges.all. block,
1997
+ autoBlockSize: maxChildBlockSize + edges.block,
2013
1998
childFragments,
2014
1999
};
2015
2000
}
@@ -2037,9 +2022,9 @@ registerLayout('indent-lines', class {
2037
2022
async layout(children, edges, constraints, styleMap, breakToken) {
2038
2023
// Determine our (inner) available size.
2039
2024
const availableInlineSize =
2040
- constraints.fixedInlineSize - edges.all. inline;
2025
+ constraints.fixedInlineSize - edges.inline;
2041
2026
const availableBlockSize = constraints.fixedBlockSize ?
2042
- constraints.fixedBlockSize - edges.all. block : null;
2027
+ constraints.fixedBlockSize - edges.block : null;
2043
2028
2044
2029
// Detrermine the number of lines to indent, and the indent amount.
2045
2030
const indent = resolveLength(constraints, styleMap.get('--indent' ));
@@ -2055,7 +2040,7 @@ registerLayout('indent-lines', class {
2055
2040
children.splice(0, children.indexOf(childBreakToken.child));
2056
2041
}
2057
2042
2058
- let blockOffset = edges.all. blockStart;
2043
+ let blockOffset = edges.blockStart;
2059
2044
let child = children.shift();
2060
2045
while (child) {
2061
2046
const shouldIndent = lines-- > 0;
@@ -2077,7 +2062,7 @@ registerLayout('indent-lines', class {
2077
2062
2078
2063
// Position the fragment.
2079
2064
fragment.inlineOffset = shouldIndent ?
2080
- edges.all. inlineStart + indent : edges.all .inlineStart;
2065
+ edges.inlineStart + indent : edges.inlineStart;
2081
2066
fragment.blockOffset = blockOffset;
2082
2067
blockOffset += fragment.blockSize;
2083
2068
@@ -2097,7 +2082,7 @@ registerLayout('indent-lines', class {
2097
2082
}
2098
2083
}
2099
2084
2100
- const autoBlockSize = blockOffset + edges.all. blockEnd;
2085
+ const autoBlockSize = blockOffset + edges.blockEnd;
2101
2086
2102
2087
// Return our fragment.
2103
2088
const result = {
0 commit comments