@react-x11/components 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html/controls.d.ts +29 -2
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js +70 -2
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +26 -4
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/color.d.ts +18 -0
- package/dist/html/css/color.d.ts.map +1 -1
- package/dist/html/css/color.js +27 -0
- package/dist/html/css/color.js.map +1 -1
- package/dist/html/css/parse.d.ts +18 -4
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +66 -28
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +128 -15
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +561 -144
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/transform.d.ts +85 -0
- package/dist/html/css/transform.d.ts.map +1 -0
- package/dist/html/css/transform.js +425 -0
- package/dist/html/css/transform.js.map +1 -0
- package/dist/html/css/ua.d.ts.map +1 -1
- package/dist/html/css/ua.js +14 -2
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/css/values.d.ts +4 -0
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/fonts.d.ts +55 -5
- package/dist/html/fonts.d.ts.map +1 -1
- package/dist/html/fonts.js +284 -23
- package/dist/html/fonts.js.map +1 -1
- package/dist/html/layout/axes.d.ts +14 -0
- package/dist/html/layout/axes.d.ts.map +1 -0
- package/dist/html/layout/axes.js +28 -0
- package/dist/html/layout/axes.js.map +1 -0
- package/dist/html/layout/block.d.ts +93 -12
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +389 -39
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +59 -1
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +22 -2
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/cache.d.ts +1 -1
- package/dist/html/layout/cache.d.ts.map +1 -1
- package/dist/html/layout/cache.js +6 -0
- package/dist/html/layout/cache.js.map +1 -1
- package/dist/html/layout/css-grid.d.ts.map +1 -1
- package/dist/html/layout/css-grid.js +90 -18
- package/dist/html/layout/css-grid.js.map +1 -1
- package/dist/html/layout/flex.d.ts.map +1 -1
- package/dist/html/layout/flex.js +570 -83
- package/dist/html/layout/flex.js.map +1 -1
- package/dist/html/layout/inline.d.ts +3 -0
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +144 -54
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/layout/multicol.d.ts +42 -0
- package/dist/html/layout/multicol.d.ts.map +1 -0
- package/dist/html/layout/multicol.js +897 -0
- package/dist/html/layout/multicol.js.map +1 -0
- package/dist/html/layout/shaping.d.ts +7 -0
- package/dist/html/layout/shaping.d.ts.map +1 -1
- package/dist/html/layout/shaping.js +25 -20
- package/dist/html/layout/shaping.js.map +1 -1
- package/dist/html/layout/table.d.ts.map +1 -1
- package/dist/html/layout/table.js +62 -18
- package/dist/html/layout/table.js.map +1 -1
- package/dist/html/node.d.ts +3 -0
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +263 -36
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +79 -4
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +1213 -141
- package/dist/html/paint.js.map +1 -1
- package/dist/html/svg.d.ts +15 -2
- package/dist/html/svg.d.ts.map +1 -1
- package/dist/html/svg.js +249 -17
- package/dist/html/svg.js.map +1 -1
- package/dist/html/widgets.js +87 -7
- package/dist/html/widgets.js.map +1 -1
- package/dist/html/woff2.d.ts +14 -0
- package/dist/html/woff2.d.ts.map +1 -0
- package/dist/html/woff2.js +608 -0
- package/dist/html/woff2.js.map +1 -0
- package/dist/maps/controller.d.ts +17 -1
- package/dist/maps/controller.d.ts.map +1 -1
- package/dist/maps/controller.js +27 -7
- package/dist/maps/controller.js.map +1 -1
- package/dist/richtext/node.d.ts +8 -1
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +5 -1
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +25 -6
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +240 -24
- package/dist/richtext/runs.js.map +1 -1
- package/package.json +1 -1
- package/src/html/controls.ts +85 -2
- package/src/html/css/cascade.ts +23 -0
- package/src/html/css/color.ts +29 -0
- package/src/html/css/parse.ts +71 -31
- package/src/html/css/style.ts +664 -147
- package/src/html/css/transform.ts +459 -0
- package/src/html/css/ua.ts +15 -2
- package/src/html/css/values.ts +4 -0
- package/src/html/fonts.ts +312 -29
- package/src/html/layout/axes.ts +62 -0
- package/src/html/layout/block.ts +444 -37
- package/src/html/layout/boxes.ts +65 -3
- package/src/html/layout/cache.ts +6 -0
- package/src/html/layout/css-grid.ts +95 -22
- package/src/html/layout/flex.ts +671 -77
- package/src/html/layout/inline.ts +149 -55
- package/src/html/layout/multicol.ts +977 -0
- package/src/html/layout/shaping.ts +27 -18
- package/src/html/layout/table.ts +62 -19
- package/src/html/node.ts +300 -37
- package/src/html/paint.ts +1406 -206
- package/src/html/svg.ts +277 -19
- package/src/html/widgets.ts +95 -9
- package/src/html/woff2.ts +612 -0
- package/src/maps/controller.ts +28 -7
- package/src/richtext/node.ts +13 -2
- package/src/richtext/runs.ts +313 -35
package/src/html/layout/boxes.ts
CHANGED
|
@@ -202,6 +202,17 @@ export interface LineText {
|
|
|
202
202
|
* the ones before a forced break that fit take room on the line.
|
|
203
203
|
*/
|
|
204
204
|
hung?: { at: number; x: number; width: number }[];
|
|
205
|
+
/**
|
|
206
|
+
* How far the line goes on past this text for the collapsible spaces it
|
|
207
|
+
* ends on, which its engine, laying out a piece of a line as a line,
|
|
208
|
+
* stripped: the room they take where more follows them on the line, and
|
|
209
|
+
* none where the line ends on them, since CSS removes them there (CSS
|
|
210
|
+
* Text 3, 4.1.2). They are the text's, in the elements they are in, and
|
|
211
|
+
* `trailRun` is the run they are the end of: whose underline, line
|
|
212
|
+
* through and highlight go on under them.
|
|
213
|
+
*/
|
|
214
|
+
trail?: number;
|
|
215
|
+
trailRun?: TextRun;
|
|
205
216
|
/** Any offset in the layout's own text as a document index — how a run
|
|
206
217
|
* under the pointer finds the element whose text it is. Per pass: the
|
|
207
218
|
* layout may be one an earlier pass made (`TextLayoutCache`), and the
|
|
@@ -630,12 +641,16 @@ export const CLAMPED = new WeakSet<Box>();
|
|
|
630
641
|
/** A grid's tracks as its layout left them, each column's and each row's
|
|
631
642
|
* start and end from the content box's corner, with the lines of each
|
|
632
643
|
* axis by number and by name: what an absolutely positioned box's grid
|
|
633
|
-
* area is found in (CSS Grid 1, 9.1).
|
|
644
|
+
* area is found in (CSS Grid 1, 9.1). And the first of its items in
|
|
645
|
+
* row-major order, where they were placed and not where they were
|
|
646
|
+
* written, which the grid's own baseline is taken from (10.6): null for a
|
|
647
|
+
* grid with no item. */
|
|
634
648
|
export interface GridTracks {
|
|
635
649
|
cols: [number, number][];
|
|
636
650
|
rows: [number, number][];
|
|
637
651
|
colLines: GridLines;
|
|
638
652
|
rowLines: GridLines;
|
|
653
|
+
first: Box | null;
|
|
639
654
|
}
|
|
640
655
|
export const GRID_TRACKS = new WeakMap<Box, GridTracks>();
|
|
641
656
|
|
|
@@ -656,6 +671,48 @@ export const CUT_BLOCKS = new WeakMap<Box, Box[]>();
|
|
|
656
671
|
* the clearance in (`elementRect`). Only the blocks that had clearance. */
|
|
657
672
|
export const CLEARED_FROM = new WeakMap<Box, number>();
|
|
658
673
|
|
|
674
|
+
/**
|
|
675
|
+
* One piece of a block that a column break falls inside (CSS Multi-column
|
|
676
|
+
* 1): its border box in one column, as far as the box goes in it, and where
|
|
677
|
+
* the whole box would stand there — the box its background and its borders
|
|
678
|
+
* are drawn as, cut to the piece (`box-decoration-break: slice`).
|
|
679
|
+
*/
|
|
680
|
+
export interface ColumnPiece {
|
|
681
|
+
x: number;
|
|
682
|
+
y: number;
|
|
683
|
+
width: number;
|
|
684
|
+
height: number;
|
|
685
|
+
/** The top of the whole box, in this column, and its height. */
|
|
686
|
+
wholeY: number;
|
|
687
|
+
wholeHeight: number;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/** The pieces of each block a column break falls inside, in the order of
|
|
691
|
+
* the columns. The block's own rect is what takes them all in, as a
|
|
692
|
+
* browser's bounding rect of it is. */
|
|
693
|
+
export const COLUMN_PIECES = new WeakMap<Box, ColumnPiece[]>();
|
|
694
|
+
|
|
695
|
+
/** The lines of a box that columns took apart: they are not one under
|
|
696
|
+
* another, and a search that counts on their tops rising reads them all
|
|
697
|
+
* instead. */
|
|
698
|
+
export const COLUMN_LINES = new WeakSet<LineBox[]>();
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* The rows of a text's layout that are in the text's own column, from the
|
|
702
|
+
* layout's origin, where the layout's lines went to more than one: a layout
|
|
703
|
+
* is drawn whole, so it is drawn once for each column, there, and clipped
|
|
704
|
+
* to the rows that are that column's. One object for all the texts of a
|
|
705
|
+
* layout in a column, which is what tells a draw of it from another.
|
|
706
|
+
*/
|
|
707
|
+
export const COLUMN_ROWS = new WeakMap<
|
|
708
|
+
LineText,
|
|
709
|
+
{ top: number; bottom: number }
|
|
710
|
+
>();
|
|
711
|
+
|
|
712
|
+
/** Whether any layout has broken a box between columns: what the walks
|
|
713
|
+
* that would ask the three maps above of every box ask first. */
|
|
714
|
+
export const columned = { any: false };
|
|
715
|
+
|
|
659
716
|
/** The element a pseudo-element's box is generated from, which has no
|
|
660
717
|
* element of its own (`Box.pseudo`): whose the images its styles name are,
|
|
661
718
|
* when the host is asked for them. */
|
|
@@ -733,6 +790,10 @@ export interface BoxTree {
|
|
|
733
790
|
* (`Cascade.rootStyle`), whose background is the canvas's; null where
|
|
734
791
|
* the document has either. */
|
|
735
792
|
impliedHtml: ComputedStyle | null;
|
|
793
|
+
/** The scheme the palette is, which the element the document is drawn
|
|
794
|
+
* in is of: where the root element's is the other, the canvas is that
|
|
795
|
+
* scheme's and opaque (`paintDocument`). */
|
|
796
|
+
paletteScheme: 'light' | 'dark';
|
|
736
797
|
}
|
|
737
798
|
|
|
738
799
|
export interface BuildOptions {
|
|
@@ -882,6 +943,7 @@ class Builder {
|
|
|
882
943
|
movedInline: this._movedInline,
|
|
883
944
|
clipText: this._clipText,
|
|
884
945
|
impliedHtml,
|
|
946
|
+
paletteScheme: cascade.initial.colorScheme,
|
|
885
947
|
};
|
|
886
948
|
}
|
|
887
949
|
|
|
@@ -1043,7 +1105,7 @@ class Builder {
|
|
|
1043
1105
|
}
|
|
1044
1106
|
}
|
|
1045
1107
|
// a translation is moved by the same pass
|
|
1046
|
-
if (style.translate || style.
|
|
1108
|
+
if (style.translate || style.transform) this._relative = true;
|
|
1047
1109
|
if (style.backgroundClipText) this._clipText = true;
|
|
1048
1110
|
if (style.verticalAlign !== 'baseline' && style.display === 'inline') {
|
|
1049
1111
|
this._movedInline = true;
|
|
@@ -1348,7 +1410,7 @@ class Builder {
|
|
|
1348
1410
|
}
|
|
1349
1411
|
}
|
|
1350
1412
|
// a translation is moved by the same pass
|
|
1351
|
-
if (style.translate || style.
|
|
1413
|
+
if (style.translate || style.transform) this._relative = true;
|
|
1352
1414
|
if (style.backgroundClipText) this._clipText = true;
|
|
1353
1415
|
if (style.verticalAlign !== 'baseline' && style.display === 'inline') {
|
|
1354
1416
|
this._movedInline = true;
|
package/src/html/layout/cache.ts
CHANGED
|
@@ -186,6 +186,8 @@ export const RUN_FIELDS = [
|
|
|
186
186
|
'underlineOffset',
|
|
187
187
|
'underlineThickness',
|
|
188
188
|
'strike',
|
|
189
|
+
'strikeStyle',
|
|
190
|
+
'strikeThickness',
|
|
189
191
|
'href',
|
|
190
192
|
'features',
|
|
191
193
|
'nowrap',
|
|
@@ -221,6 +223,8 @@ function sameRun(a: TextRun, b: TextRun): boolean {
|
|
|
221
223
|
a.underlineOffset === b.underlineOffset &&
|
|
222
224
|
a.underlineThickness === b.underlineThickness &&
|
|
223
225
|
a.strike === b.strike &&
|
|
226
|
+
a.strikeStyle === b.strikeStyle &&
|
|
227
|
+
a.strikeThickness === b.strikeThickness &&
|
|
224
228
|
a.href === b.href &&
|
|
225
229
|
a.features === b.features &&
|
|
226
230
|
a.nowrap === b.nowrap &&
|
|
@@ -249,6 +253,8 @@ function sameStyle(
|
|
|
249
253
|
a.underlineOffset === b.underlineOffset &&
|
|
250
254
|
a.underlineThickness === b.underlineThickness &&
|
|
251
255
|
a.strike === b.strike &&
|
|
256
|
+
a.strikeStyle === b.strikeStyle &&
|
|
257
|
+
a.strikeThickness === b.strikeThickness &&
|
|
252
258
|
a.href === b.href &&
|
|
253
259
|
a.features === b.features &&
|
|
254
260
|
a.nowrap === b.nowrap &&
|
|
@@ -31,6 +31,8 @@ import { Box, GRID_TRACKS, isBlank } from './boxes.js';
|
|
|
31
31
|
import {
|
|
32
32
|
FLEXED_HEIGHT,
|
|
33
33
|
MIN_CONTENT_PROBE,
|
|
34
|
+
USED_HEIGHT,
|
|
35
|
+
centreButton,
|
|
34
36
|
clampHeight,
|
|
35
37
|
clampWidth,
|
|
36
38
|
exactMinContent,
|
|
@@ -60,6 +62,25 @@ interface Item {
|
|
|
60
62
|
max: number;
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The first of a grid's items in row-major order: the one furthest to the
|
|
67
|
+
* start of the first row that holds an item, which the grid's baseline is
|
|
68
|
+
* taken from (CSS Grid 1, 10.6).
|
|
69
|
+
*/
|
|
70
|
+
function firstItem(items: Item[]): Box | null {
|
|
71
|
+
let first: Item | null = null;
|
|
72
|
+
for (const item of items) {
|
|
73
|
+
if (
|
|
74
|
+
first === null ||
|
|
75
|
+
item.row < first.row ||
|
|
76
|
+
(item.row === first.row && item.col < first.col)
|
|
77
|
+
) {
|
|
78
|
+
first = item;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return first?.box ?? null;
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
/**
|
|
64
85
|
* Lay out a grid container's children. Returns the content height.
|
|
65
86
|
*/
|
|
@@ -78,7 +99,13 @@ export function layoutGrid(
|
|
|
78
99
|
positionOutOfFlow(child, box, ctx, false);
|
|
79
100
|
continue;
|
|
80
101
|
}
|
|
81
|
-
|
|
102
|
+
// While the columns are sized, the area an item is in has no width for
|
|
103
|
+
// the percentages in its margins and its padding to be of, and they
|
|
104
|
+
// are of nothing (CSS Sizing 3, 5.2.1): a column is as wide as what
|
|
105
|
+
// is in the item. They are of the area once it has a width
|
|
106
|
+
// (`layoutItem`). Taken of the grid's width, an item `margin: 0 25%`
|
|
107
|
+
// made its `min-content` column half the grid wide.
|
|
108
|
+
resolveEdges(child, 0);
|
|
82
109
|
boxes.push(child);
|
|
83
110
|
}
|
|
84
111
|
// the gaps: a percentage of the grid's content size along them, and of
|
|
@@ -240,14 +267,15 @@ export function layoutGrid(
|
|
|
240
267
|
item,
|
|
241
268
|
extent(widths, lefts, item.col, item.cols),
|
|
242
269
|
ctx,
|
|
243
|
-
|
|
270
|
+
spanBefore(item),
|
|
244
271
|
);
|
|
245
272
|
}
|
|
246
273
|
|
|
247
274
|
// a height of the grid's own, or else the least it may be, which the
|
|
248
|
-
// `fr` rows and the `auto` ones fill
|
|
275
|
+
// `fr` rows and the `auto` ones fill: its `min-height`, or the height a
|
|
276
|
+
// column it is an item of flexed it to (`USED_HEIGHT`)
|
|
249
277
|
const own = Number.isFinite(definite);
|
|
250
|
-
const least = own ? 0 : leastHeight(box);
|
|
278
|
+
const least = own ? 0 : Math.max(leastHeight(box), USED_HEIGHT.get(box) ?? 0);
|
|
251
279
|
// the rows against a height: percentages of it, or `auto` without one
|
|
252
280
|
const sizeRows = (base: number, available: number, atLeast: number) => {
|
|
253
281
|
const rowTracks: SizingTrack[] = [];
|
|
@@ -301,18 +329,14 @@ export function layoutGrid(
|
|
|
301
329
|
if (Object.is(child.percentHeightBase, tall) || !percentOwn(child))
|
|
302
330
|
continue;
|
|
303
331
|
child.percentHeightBase = tall;
|
|
304
|
-
layoutItem(
|
|
305
|
-
item,
|
|
306
|
-
extent(widths, lefts, item.col, item.cols),
|
|
307
|
-
ctx,
|
|
308
|
-
heightBeforeRows(child, tall),
|
|
309
|
-
);
|
|
332
|
+
layoutItem(item, extent(widths, lefts, item.col, item.cols), ctx, tall);
|
|
310
333
|
}
|
|
311
334
|
GRID_TRACKS.set(box, {
|
|
312
335
|
cols: tracksOf(widths, lefts, keepCols),
|
|
313
336
|
rows: tracksOf(heights, tops, keepRows),
|
|
314
337
|
colLines,
|
|
315
338
|
rowLines,
|
|
339
|
+
first: firstItem(items),
|
|
316
340
|
});
|
|
317
341
|
|
|
318
342
|
for (const item of items) {
|
|
@@ -371,20 +395,28 @@ export function layoutGrid(
|
|
|
371
395
|
const width =
|
|
372
396
|
wide === null ? child.width : clampWidth(child, wide, area, ctx);
|
|
373
397
|
// what is in it takes its percentages of that height, which a
|
|
374
|
-
// stretch makes definite, as it does a flex item's
|
|
398
|
+
// stretch makes definite, as it does a flex item's — and an item that
|
|
399
|
+
// is a flex or grid container lays its own items out in it (11.1:
|
|
400
|
+
// "the grid area's width and height are considered definite for this
|
|
401
|
+
// purpose"): a card's `margin-top: auto` takes what its row is taller
|
|
402
|
+
// than the card by, its `flex: 1` grows into it (CSS Flexbox 8.1,
|
|
403
|
+
// 9.7). Its content's own height is the same layout, and kept.
|
|
375
404
|
if (
|
|
376
405
|
child.kind !== 'replaced' &&
|
|
377
|
-
(wide !== null ||
|
|
406
|
+
(wide !== null ||
|
|
407
|
+
percentHeightsIn(child) ||
|
|
408
|
+
(child.kind === 'flex' && height !== child.height))
|
|
378
409
|
) {
|
|
379
410
|
FLEXED_HEIGHT.set(child, Math.max(0, height - child.verticalExtra));
|
|
380
411
|
try {
|
|
381
|
-
ctx.layoutSubtree(child, width);
|
|
412
|
+
ctx.layoutSubtree(child, width, area);
|
|
382
413
|
} finally {
|
|
383
414
|
FLEXED_HEIGHT.delete(child);
|
|
384
415
|
}
|
|
385
416
|
}
|
|
386
417
|
child.width = width;
|
|
387
418
|
child.height = height;
|
|
419
|
+
centreButton(child);
|
|
388
420
|
}
|
|
389
421
|
moveTo(
|
|
390
422
|
child,
|
|
@@ -617,15 +649,25 @@ function maxContentOf(box: Box, ctx: LayoutContext): number {
|
|
|
617
649
|
return box.intrinsicMaxContent;
|
|
618
650
|
}
|
|
619
651
|
|
|
620
|
-
/**
|
|
621
|
-
*
|
|
622
|
-
*
|
|
652
|
+
/**
|
|
653
|
+
* Lay an item out in its area: stretched across it where its width is
|
|
654
|
+
* `auto` and it is stretched, or at its content's width, no wider than
|
|
655
|
+
* the area, where it is aligned instead.
|
|
656
|
+
*
|
|
657
|
+
* The area is the item's containing block (CSS Grid 1, 3.3), so it is its
|
|
658
|
+
* width that a percentage in the item's margins, its padding, its
|
|
659
|
+
* `min-width` and its `max-width` is of (6.4, and CSS 2.1 8.3, 8.4 and
|
|
660
|
+
* 10.4), whatever width the item comes to in it. With its own width
|
|
661
|
+
* standing for its area's, an item `width: 50%; max-width: 80%` was four
|
|
662
|
+
* tenths of its column, and one `min-width: 50%` aligned to the start was
|
|
663
|
+
* as wide as its text.
|
|
664
|
+
*/
|
|
623
665
|
function layoutItem(
|
|
624
666
|
item: Item,
|
|
625
667
|
area: number,
|
|
626
668
|
ctx: LayoutContext,
|
|
627
|
-
/**
|
|
628
|
-
|
|
669
|
+
/** The height of the rows it spans, where they have one yet. */
|
|
670
|
+
rows: number,
|
|
629
671
|
): void {
|
|
630
672
|
const child = item.box;
|
|
631
673
|
const style = child.style;
|
|
@@ -634,19 +676,35 @@ function layoutItem(
|
|
|
634
676
|
style.justifySelf === 'auto'
|
|
635
677
|
? (parent?.justifyItems ?? 'normal')
|
|
636
678
|
: style.justifySelf;
|
|
679
|
+
resolveEdges(child, area);
|
|
680
|
+
// its border box's height before the rows are sized, where it has one
|
|
681
|
+
const tall = heightBeforeRows(child, rows);
|
|
637
682
|
const margins = child.marginLeft + child.marginRight;
|
|
638
683
|
const room = Math.max(0, area - margins);
|
|
639
|
-
//
|
|
684
|
+
// Its content's widths, border box: measured once in its life, with the
|
|
685
|
+
// percentages in its padding of nothing, as they are while the columns
|
|
686
|
+
// are sized, and here with what those come to of its area. Measuring
|
|
687
|
+
// resolves its edges against nothing, and they are put back.
|
|
688
|
+
const padded = percentPadding(child);
|
|
640
689
|
const content = (): [number, number] => {
|
|
641
|
-
|
|
690
|
+
let probed = false;
|
|
691
|
+
if (child.intrinsicMaxContent < 0) {
|
|
692
|
+
maxContentOf(child, ctx);
|
|
693
|
+
probed = true;
|
|
694
|
+
}
|
|
642
695
|
if (child.intrinsicMinContent < 0) {
|
|
643
696
|
child.intrinsicMinContent = measureIntrinsicWidth(
|
|
644
697
|
child,
|
|
645
698
|
ctx,
|
|
646
699
|
MIN_CONTENT_PROBE,
|
|
647
700
|
);
|
|
701
|
+
probed = true;
|
|
648
702
|
}
|
|
649
|
-
|
|
703
|
+
if (probed) resolveEdges(child, area);
|
|
704
|
+
return [
|
|
705
|
+
child.intrinsicMinContent + padded,
|
|
706
|
+
child.intrinsicMaxContent + padded,
|
|
707
|
+
];
|
|
650
708
|
};
|
|
651
709
|
const keyword = style.widthKeyword;
|
|
652
710
|
// `stretch` fills its area, and so does `normal` but for a replaced
|
|
@@ -699,7 +757,7 @@ function layoutItem(
|
|
|
699
757
|
width = Math.min(widest, Math.max(narrowest, room));
|
|
700
758
|
}
|
|
701
759
|
if (child.kind !== 'replaced') {
|
|
702
|
-
ctx.layoutSubtree(child, width);
|
|
760
|
+
ctx.layoutSubtree(child, width, area);
|
|
703
761
|
return;
|
|
704
762
|
}
|
|
705
763
|
// a replaced element sizes itself from its style: then it is given the
|
|
@@ -718,6 +776,21 @@ function layoutItem(
|
|
|
718
776
|
}
|
|
719
777
|
}
|
|
720
778
|
|
|
779
|
+
/** What the percentages in a box's padding come to across it, its edges
|
|
780
|
+
* resolved: what a width of its content's, measured with them of nothing,
|
|
781
|
+
* is short of its border box by. */
|
|
782
|
+
function percentPadding(box: Box): number {
|
|
783
|
+
const { paddingLeft, paddingRight } = box.style;
|
|
784
|
+
let out = 0;
|
|
785
|
+
if (isPct(paddingLeft)) {
|
|
786
|
+
out += box.padLeft - Math.max(0, resolve(paddingLeft, 0));
|
|
787
|
+
}
|
|
788
|
+
if (isPct(paddingRight)) {
|
|
789
|
+
out += box.padRight - Math.max(0, resolve(paddingRight, 0));
|
|
790
|
+
}
|
|
791
|
+
return out;
|
|
792
|
+
}
|
|
793
|
+
|
|
721
794
|
/** Whether a box's content is its least size through a ratio, which it is
|
|
722
795
|
* where the box shows what overflows it and its least width is `auto`
|
|
723
796
|
* (CSS Sizing 4, 5.2). */
|