@react-x11/components 0.10.0 → 0.11.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/code/index.d.ts.map +1 -1
- package/dist/code/index.js +25 -24
- package/dist/code/index.js.map +1 -1
- package/dist/code-language/index.d.ts +1 -1
- package/dist/code-language/index.d.ts.map +1 -1
- package/dist/code-language/index.js +1 -1
- package/dist/code-language/index.js.map +1 -1
- package/dist/code-language/runs.d.ts +31 -0
- package/dist/code-language/runs.d.ts.map +1 -1
- package/dist/code-language/runs.js +105 -0
- package/dist/code-language/runs.js.map +1 -1
- package/dist/codeblock/index.d.ts +13 -0
- package/dist/codeblock/index.d.ts.map +1 -1
- package/dist/codeblock/index.js +37 -1
- package/dist/codeblock/index.js.map +1 -1
- package/dist/html/css/cascade.d.ts +32 -10
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +72 -27
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/style.d.ts +7 -4
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +37 -6
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.js +8 -5
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +127 -9
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +27 -0
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +30 -2
- package/dist/html/layout/boxes.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 +236 -14
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +118 -57
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +203 -37
- package/dist/html/paint.js.map +1 -1
- package/dist/html/svg.d.ts.map +1 -1
- package/dist/html/svg.js +27 -20
- package/dist/html/svg.js.map +1 -1
- package/dist/internal/codelines.d.ts +42 -0
- package/dist/internal/codelines.d.ts.map +1 -0
- package/dist/internal/codelines.js +170 -0
- package/dist/internal/codelines.js.map +1 -0
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +98 -26
- package/dist/markdown/index.js.map +1 -1
- package/dist/rich-text-editor/index.d.ts.map +1 -1
- package/dist/rich-text-editor/index.js +3 -8
- package/dist/rich-text-editor/index.js.map +1 -1
- package/dist/rich-text-editor/markdown.d.ts.map +1 -1
- package/dist/rich-text-editor/markdown.js +30 -1
- package/dist/rich-text-editor/markdown.js.map +1 -1
- package/dist/rich-text-editor/replace.d.ts +13 -0
- package/dist/rich-text-editor/replace.d.ts.map +1 -0
- package/dist/rich-text-editor/replace.js +64 -0
- package/dist/rich-text-editor/replace.js.map +1 -0
- package/dist/terminal-output/index.d.ts.map +1 -1
- package/dist/terminal-output/index.js +100 -25
- package/dist/terminal-output/index.js.map +1 -1
- package/dist/terminal-output/runs.d.ts +4 -1
- package/dist/terminal-output/runs.d.ts.map +1 -1
- package/dist/terminal-output/runs.js +5 -1
- package/dist/terminal-output/runs.js.map +1 -1
- package/package.json +1 -1
- package/src/code/index.ts +34 -32
- package/src/code-language/index.ts +1 -1
- package/src/code-language/runs.ts +111 -1
- package/src/codeblock/index.ts +48 -1
- package/src/html/css/cascade.ts +117 -39
- package/src/html/css/style.ts +43 -15
- package/src/html/css/ua.ts +8 -5
- package/src/html/layout/block.ts +134 -8
- package/src/html/layout/boxes.ts +43 -2
- package/src/html/layout/inline.ts +257 -13
- package/src/html/node.ts +145 -79
- package/src/html/paint.ts +236 -45
- package/src/html/svg.ts +30 -19
- package/src/internal/codelines.ts +200 -0
- package/src/markdown/index.ts +145 -26
- package/src/rich-text-editor/index.ts +3 -11
- package/src/rich-text-editor/markdown.ts +36 -1
- package/src/rich-text-editor/replace.ts +85 -0
- package/src/terminal-output/index.ts +127 -34
- package/src/terminal-output/runs.ts +16 -2
package/dist/html/css/ua.js
CHANGED
|
@@ -40,8 +40,11 @@ export function uaStylesheet(look) {
|
|
|
40
40
|
return sheet;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Margins are in `em
|
|
44
|
-
* `body` scales its whitespace with its text the way a browser's does.
|
|
43
|
+
* Margins above and below are in `em`, so a document that sets `font-size`
|
|
44
|
+
* on `body` scales its whitespace with its text the way a browser's does.
|
|
45
|
+
* The indents of lists, definitions and figures are the HTML standard's
|
|
46
|
+
* 40px (15.3.3, 15.3.8), whatever the size: a list in a 10px sidebar is
|
|
47
|
+
* indented as far as one in the body.
|
|
45
48
|
*/
|
|
46
49
|
function uaText(look) {
|
|
47
50
|
const mono = look.monoFamily;
|
|
@@ -77,7 +80,7 @@ h4 { font-size: 1em; font-weight: bold; margin: 1.33em 0; }
|
|
|
77
80
|
h5 { font-size: 0.83em; font-weight: bold; margin: 1.67em 0; }
|
|
78
81
|
h6 { font-size: 0.67em; font-weight: bold; margin: 2.33em 0; }
|
|
79
82
|
|
|
80
|
-
ul, ol { margin: 1em 0; padding-left:
|
|
83
|
+
ul, ol { margin: 1em 0; padding-left: 40px; }
|
|
81
84
|
ul { list-style-type: disc; }
|
|
82
85
|
ol { list-style-type: decimal; }
|
|
83
86
|
ol, ul, menu, dir { counter-reset: list-item; }
|
|
@@ -88,7 +91,7 @@ ul ul ul, ol ol ul, ul ol ul, ol ul ul { list-style-type: square; }
|
|
|
88
91
|
ul ul, ul ol, ol ul, ol ol { margin: 0; }
|
|
89
92
|
|
|
90
93
|
dl { margin: 1em 0; }
|
|
91
|
-
dd { margin-left:
|
|
94
|
+
dd { margin-left: 40px; }
|
|
92
95
|
dt { font-weight: bold; }
|
|
93
96
|
|
|
94
97
|
blockquote {
|
|
@@ -146,7 +149,7 @@ img { display: inline-block; }
|
|
|
146
149
|
iframe { border: 2px inset; }
|
|
147
150
|
/* a poster is drawn within the video's box at its own ratio (HTML 15.4.1) */
|
|
148
151
|
video { object-fit: contain; }
|
|
149
|
-
figure { margin: 1em
|
|
152
|
+
figure { margin: 1em 40px; }
|
|
150
153
|
|
|
151
154
|
table { display: table; border-collapse: separate; border-spacing: 2px; box-sizing: border-box; }
|
|
152
155
|
caption { display: table-caption; text-align: center; }
|
package/dist/html/css/ua.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ua.js","sourceRoot":"","sources":["../../../src/html/css/ua.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,yEAAyE;AACzE,2EAA2E;AAC3E,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7C;mEACmE;AACnE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAE5C,MAAM,UAAU,OAAO,CAAC,IAAc;IACpC,OAAO;QACL,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,aAAa;KACnB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAA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IAAI,GAAG,CAAC;QAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAClC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,IAAc;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;gBAsBO,IAAI,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA2BC,IAAI,CAAC,WAAW;WAChC,IAAI,CAAC,UAAU;;;;;iBAKT,IAAI;;;;;;;qCAOgB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;mBAyBtB,IAAI,CAAC,SAAS;;;;;0BAKP,IAAI,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCzB,IAAI,CAAC,UAAU;;;;;;;;;;;;;;;;;aAiBnB,IAAI,CAAC,WAAW;YACjB,IAAI,CAAC,aAAa,YAAY,IAAI,CAAC,WAAW;mBACvC,IAAI,CAAC,aAAa;sBACf,IAAI,CAAC,OAAO;WACvB,IAAI,CAAC,KAAK;;;;4BAIO,IAAI,CAAC,UAAU;;4EAEiC,IAAI,CAAC,WAAW;;;;;;;;;;;CAW3F,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/html/layout/block.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAEV,aAAa,EACb,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAEL,GAAG,
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/html/layout/block.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAEV,aAAa,EACb,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAEL,GAAG,EAWJ,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GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAIzE;AA6GD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAwG/C;AAg0BD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,OAAO,GACZ,IAAI,CA0BN;AAmED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAazD;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAO3D;AAED;4EAC4E;AAC5E,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGtD;AA6BD;;iEAEiE;AACjE,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,CAiDpE;AAyCD;+DAC+D;AAC/D,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CA8BhD;AAED;;uEAEuE;AACvE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAuBnD;AAED;sEACsE;AACtE,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEzD"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { AUTO, gapOf, isPct, isTransparent, resolve, resolveOrNull, } from '../css/values.js';
|
|
14
14
|
import { CONTAIN_INLINE_SIZE, CONTAIN_LAYOUT, CONTAIN_PAINT, CONTAIN_SIZE, scrolls, } from '../css/style.js';
|
|
15
15
|
import { lineOf, spanToName } from './grid-lines.js';
|
|
16
|
-
import { BOX_RAISES, Box, CLAMPED, CUT_BLOCKS, GRID_TRACKS, FIRST_LINE, INLINE_OFFSETS, LINE_BOX_RAISES, SHIFTED_LINES, TEXT_SHIFTS, isBlank, } from './boxes.js';
|
|
16
|
+
import { BOX_RAISES, Box, CLAMPED, CUT_BLOCKS, GRID_TRACKS, FIRST_LINE, INLINE_OFFSETS, MOVED_OFF_LINES, LINE_BOX_RAISES, SHIFTED_LINES, TEXT_SHIFTS, isBlank, } from './boxes.js';
|
|
17
17
|
import { FloatContext } from './floats.js';
|
|
18
18
|
import { faceExtentOf, layoutInline, lineHeightMultiplier, spaceBreaksOnly, strutOf, widestWord, } from './inline.js';
|
|
19
19
|
import { layoutFlex } from './flex.js';
|
|
@@ -47,7 +47,9 @@ export function layoutDocument(tree, fonts, viewportWidth, viewportHeight) {
|
|
|
47
47
|
// there — or `<p>hi</p>` would stand 8px lower than the same paragraph in
|
|
48
48
|
// `<body>`.
|
|
49
49
|
resolveEdges(root, viewportWidth);
|
|
50
|
+
const body = fragmentBodyHeight(tree, viewportHeight);
|
|
50
51
|
const leading = root.marginTop;
|
|
52
|
+
const trailing = root.marginBottom;
|
|
51
53
|
root.padRight += root.marginRight;
|
|
52
54
|
root.padBottom += root.marginBottom;
|
|
53
55
|
root.padLeft += root.marginLeft;
|
|
@@ -55,13 +57,15 @@ export function layoutDocument(tree, fonts, viewportWidth, viewportHeight) {
|
|
|
55
57
|
root.marginRight = 0;
|
|
56
58
|
root.marginBottom = 0;
|
|
57
59
|
root.marginLeft = 0;
|
|
60
|
+
if (body)
|
|
61
|
+
handPercentBase(root, body.inner);
|
|
58
62
|
const contentWidth = Math.max(0, viewportWidth - root.horizontalExtra);
|
|
59
63
|
const floats = new FloatContext(root.contentX, root.contentX + contentWidth);
|
|
60
64
|
// the initial containing block is the viewport's size, which a percentage
|
|
61
65
|
// height on the root element resolves against (CSS 2.1 10.1, 10.5); a
|
|
62
66
|
// fragment has no root element, and the box standing in for its body has
|
|
63
67
|
// the body's `auto` height to give
|
|
64
|
-
let readsViewportHeight =
|
|
68
|
+
let readsViewportHeight = body?.viewport === true;
|
|
65
69
|
for (const child of root.children) {
|
|
66
70
|
if (child.el?.name !== 'html')
|
|
67
71
|
continue;
|
|
@@ -75,7 +79,9 @@ export function layoutDocument(tree, fonts, viewportWidth, viewportHeight) {
|
|
|
75
79
|
}
|
|
76
80
|
const flow = layoutChildren(root, ctx, floats, root.contentY, contentWidth, leading);
|
|
77
81
|
const floatBottom = floats.bottom === -Infinity ? 0 : floats.bottom - root.contentY;
|
|
78
|
-
root.height =
|
|
82
|
+
root.height = body
|
|
83
|
+
? leading + body.outer + trailing
|
|
84
|
+
: Math.max(flow.height, floatBottom) + root.verticalExtra;
|
|
79
85
|
// Positioned boxes last, and in the order they were found, so a later one
|
|
80
86
|
// can be positioned against an earlier one's resolved rectangle.
|
|
81
87
|
for (let i = 0; i < ctx.positioned.length; i += 1) {
|
|
@@ -106,6 +112,37 @@ export function layoutDocument(tree, fonts, viewportWidth, viewportHeight) {
|
|
|
106
112
|
readsViewportHeight: readsViewportHeight || ctx.readViewportHeight === true,
|
|
107
113
|
};
|
|
108
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* How tall the body a fragment's root box stands in for says it is, where
|
|
117
|
+
* that is definite (CSS 2.1 10.5): a length, `100vh` among them, or a
|
|
118
|
+
* percentage of the `<html>` implied around it where that has a height of
|
|
119
|
+
* its own — a length, or a percentage of the viewport, as `html, body {
|
|
120
|
+
* height: 100% }` fills a window. Its border box, and its content box,
|
|
121
|
+
* which what it holds takes its percentages of; `viewport` where the
|
|
122
|
+
* answer read the viewport's height. Null where the document has an
|
|
123
|
+
* `<html>` or a `<body>`, and where the body's height is `auto`, and the
|
|
124
|
+
* box is as tall as what is in it. Measured before its margins are folded
|
|
125
|
+
* into its padding.
|
|
126
|
+
*/
|
|
127
|
+
function fragmentBodyHeight(tree, viewportHeight) {
|
|
128
|
+
const html = tree.impliedHtml;
|
|
129
|
+
if (!html)
|
|
130
|
+
return null;
|
|
131
|
+
const root = tree.root;
|
|
132
|
+
const style = root.style;
|
|
133
|
+
const base = resolveOrNull(html.height, viewportHeight);
|
|
134
|
+
const set = resolveOrNull(style.height, base ?? NaN);
|
|
135
|
+
if (set === null)
|
|
136
|
+
return null;
|
|
137
|
+
root.percentHeightBase = base ?? NaN;
|
|
138
|
+
const extra = root.verticalExtra;
|
|
139
|
+
const outer = clampHeight(root, style.boxSizing === 'border-box' ? Math.max(set, extra) : set + extra);
|
|
140
|
+
return {
|
|
141
|
+
outer,
|
|
142
|
+
inner: Math.max(0, outer - extra),
|
|
143
|
+
viewport: isPct(style.height) && isPct(html.height),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
109
146
|
/** No margin at all, shared: most joins leave a strut as it was. */
|
|
110
147
|
const NO_MARGIN = Object.freeze({ pos: 0, neg: 0 });
|
|
111
148
|
/** One margin, as a strut to collapse others with. */
|
|
@@ -533,6 +570,8 @@ function layoutChildren(box, ctx, floats, contentTop, contentWidth, leading = 0)
|
|
|
533
570
|
// this box's first formatted line is its first child's in flow (CSS 2.1
|
|
534
571
|
// 5.12.1), which its `::first-line` is handed to
|
|
535
572
|
let firstLine = ctx.firstLine ? firstLineOf(box) : null;
|
|
573
|
+
// and the room a list item's marker takes on it (`MARKER_ROOM`)
|
|
574
|
+
let marked = MARKER_ROOM.get(box) ?? null;
|
|
536
575
|
const clamp = ctx.clamp ?? null;
|
|
537
576
|
for (const child of box.children) {
|
|
538
577
|
if (child.kind === 'text' && isBlank(child.text))
|
|
@@ -552,6 +591,10 @@ function layoutChildren(box, ctx, floats, contentTop, contentWidth, leading = 0)
|
|
|
552
591
|
HANDED.set(child, firstLine);
|
|
553
592
|
firstLine = null;
|
|
554
593
|
}
|
|
594
|
+
if (marked && !child.outOfFlow && !child.isFloat) {
|
|
595
|
+
MARKER_ROOM.set(child, marked);
|
|
596
|
+
marked = null;
|
|
597
|
+
}
|
|
555
598
|
if (child.outOfFlow) {
|
|
556
599
|
placeStatic(child, box, contentLeft, contentWidth, y + marginOf(pendingMargin));
|
|
557
600
|
ctx.positioned.push({
|
|
@@ -663,11 +706,14 @@ function layoutChildren(box, ctx, floats, contentTop, contentWidth, leading = 0)
|
|
|
663
706
|
// escapes, and the caller merges it into the box's own bottom margin so
|
|
664
707
|
// the next sibling still sees it. Dropping it here was the bug that made
|
|
665
708
|
// `<div><p>…</p></div><p>…</p>` set the two paragraphs solid.
|
|
709
|
+
// A percentage of a height that depends on content computes to `auto`
|
|
710
|
+
// (CSS 2.1 10.5), and lets it through as `auto` does: a `height: 100%`
|
|
711
|
+
// wrapper in an `auto` body kept its last child's margin inside it
|
|
666
712
|
if (!first &&
|
|
667
713
|
!cleared &&
|
|
668
714
|
!box.borderBottom &&
|
|
669
715
|
!box.padBottom &&
|
|
670
|
-
box
|
|
716
|
+
specifiedHeight(box) === null &&
|
|
671
717
|
!establishesBFC(box)) {
|
|
672
718
|
const height = y - contentTop;
|
|
673
719
|
// A minimum height that makes the box taller parts the margin from its
|
|
@@ -812,6 +858,7 @@ function layoutInlineContent(box, ctx, floats, contentTop, contentWidth, content
|
|
|
812
858
|
floats,
|
|
813
859
|
originX: contentLeft,
|
|
814
860
|
clipText: ctx.clipText,
|
|
861
|
+
firstStrut: MARKER_ROOM.get(box),
|
|
815
862
|
floatBoxes: floated
|
|
816
863
|
? {
|
|
817
864
|
size: (child) => sizeFloat(child, ctx, contentWidth),
|
|
@@ -997,7 +1044,8 @@ function makesNothing(box) {
|
|
|
997
1044
|
return true;
|
|
998
1045
|
}
|
|
999
1046
|
/** Whether a `::first-line` style sets its line's text otherwise than its
|
|
1000
|
-
* block's: in another face, size or line height,
|
|
1047
|
+
* block's: in another face, size or line height, spaced apart, or in
|
|
1048
|
+
* capitals. */
|
|
1001
1049
|
function setsFonts(line, block) {
|
|
1002
1050
|
return (line.fontFamily !== block.fontFamily ||
|
|
1003
1051
|
line.fontSize !== block.fontSize ||
|
|
@@ -1011,7 +1059,8 @@ function setsFonts(line, block) {
|
|
|
1011
1059
|
line.fontVariantLigatures !== block.fontVariantLigatures ||
|
|
1012
1060
|
line.fontVariantPosition !== block.fontVariantPosition ||
|
|
1013
1061
|
line.fontKerning !== block.fontKerning ||
|
|
1014
|
-
line.fontFeatureSettings !== block.fontFeatureSettings
|
|
1062
|
+
line.fontFeatureSettings !== block.fontFeatureSettings ||
|
|
1063
|
+
line.textTransform !== block.textTransform);
|
|
1015
1064
|
}
|
|
1016
1065
|
/** `::first-line` styles handed down to the first child in flow of a box
|
|
1017
1066
|
* that has one, whose first line is the box's (`layoutChildren`). */
|
|
@@ -1342,13 +1391,28 @@ function layoutBox(box, ctx, borderBoxWidth, x, y, outerFloats) {
|
|
|
1342
1391
|
// the line a pass before gave a marker, which this one may not
|
|
1343
1392
|
if (box.marker)
|
|
1344
1393
|
box.lines = null;
|
|
1394
|
+
if (box.marker && ctx.fonts) {
|
|
1395
|
+
const room = markerRoom(box, box.marker, ctx.fonts);
|
|
1396
|
+
if (room)
|
|
1397
|
+
MARKER_ROOM.set(box, room);
|
|
1398
|
+
else
|
|
1399
|
+
MARKER_ROOM.delete(box);
|
|
1400
|
+
}
|
|
1345
1401
|
const flow = layoutChildren(box, ctx, floats, box.contentY, contentWidth);
|
|
1346
1402
|
// A list item with a marker and no line holds one, the marker's, a line
|
|
1347
1403
|
// of its own face tall: an empty `<li>` is a line tall in a browser, and
|
|
1348
1404
|
// an inline-block around one sits on its marker's baseline.
|
|
1349
1405
|
let height = flow.height;
|
|
1350
1406
|
if (box.marker && ctx.fonts && !firstLineIn(box)) {
|
|
1351
|
-
const
|
|
1407
|
+
const own = strutOf(ctx.fonts, box.style);
|
|
1408
|
+
// as tall as the marker on it, as a first line with text is
|
|
1409
|
+
const room = MARKER_ROOM.get(box);
|
|
1410
|
+
const strut = room
|
|
1411
|
+
? {
|
|
1412
|
+
ascent: Math.max(own.ascent, room.ascent),
|
|
1413
|
+
descent: Math.max(own.descent, room.descent),
|
|
1414
|
+
}
|
|
1415
|
+
: own;
|
|
1352
1416
|
const line = strut.ascent + strut.descent;
|
|
1353
1417
|
box.lines = [
|
|
1354
1418
|
{
|
|
@@ -1390,6 +1454,27 @@ function layoutBox(box, ctx, borderBoxWidth, x, y, outerFloats) {
|
|
|
1390
1454
|
if (box.marker)
|
|
1391
1455
|
layoutMarker(box, box.marker, ctx);
|
|
1392
1456
|
}
|
|
1457
|
+
/**
|
|
1458
|
+
* The room a list item's marker takes about its first line's baseline,
|
|
1459
|
+
* handed to the box that line is in: an image's height above it, its
|
|
1460
|
+
* bottom on the baseline as an inline image's is, and a marker in a face
|
|
1461
|
+
* of its own — a `::marker` rule's — its face at its line height. CSS 2.1
|
|
1462
|
+
* (12.5.1) leaves where an outside marker goes to the user agent; Blink
|
|
1463
|
+
* and Gecko both set it on the item's first line and make the line as tall
|
|
1464
|
+
* as it, and design 032's bullets, images taller than its 10px text, set
|
|
1465
|
+
* every item's first line lower than ours did.
|
|
1466
|
+
*/
|
|
1467
|
+
const MARKER_ROOM = new WeakMap();
|
|
1468
|
+
function markerRoom(box, marker, fonts) {
|
|
1469
|
+
if (marker.image) {
|
|
1470
|
+
return marker.image.height > 0
|
|
1471
|
+
? { ascent: marker.image.height, descent: 0 }
|
|
1472
|
+
: null;
|
|
1473
|
+
}
|
|
1474
|
+
return marker.style && marker.style !== box.style
|
|
1475
|
+
? strutOf(fonts, marker.style)
|
|
1476
|
+
: null;
|
|
1477
|
+
}
|
|
1393
1478
|
/** The first line box anywhere under a box, in layout order. */
|
|
1394
1479
|
function firstLineIn(box) {
|
|
1395
1480
|
if (box.lines?.length)
|
|
@@ -3371,15 +3456,21 @@ export function applyRelativeOffsets(box) {
|
|
|
3371
3456
|
if (transformed(style) && box.kind !== 'inline') {
|
|
3372
3457
|
// a transform moves the box it is on, and an inline box is none
|
|
3373
3458
|
const [dx, dy] = translationOf(box);
|
|
3374
|
-
if (dx || dy)
|
|
3459
|
+
if (dx || dy) {
|
|
3375
3460
|
translate(box, dx, dy);
|
|
3461
|
+
movedOffLine(box);
|
|
3462
|
+
}
|
|
3376
3463
|
}
|
|
3377
3464
|
if (style.position !== 'relative' && style.position !== 'sticky')
|
|
3378
3465
|
return;
|
|
3379
3466
|
const [dx, dy] = relativeOffset(box);
|
|
3467
|
+
if (!(dx || dy))
|
|
3468
|
+
return;
|
|
3380
3469
|
translate(box, dx, dy);
|
|
3381
|
-
if (box.kind !== 'inline'
|
|
3470
|
+
if (box.kind !== 'inline') {
|
|
3471
|
+
movedOffLine(box);
|
|
3382
3472
|
return;
|
|
3473
|
+
}
|
|
3383
3474
|
offsetInline(box, dx, dy);
|
|
3384
3475
|
// the blocks it was broken around move with it (9.2.1.1)
|
|
3385
3476
|
const blocks = box.cut ? CUT_BLOCKS.get(box) : undefined;
|
|
@@ -3450,9 +3541,36 @@ function offsetInline(box, dx, dy) {
|
|
|
3450
3541
|
y: (was?.y ?? 0) + dy,
|
|
3451
3542
|
});
|
|
3452
3543
|
SHIFTED_LINES.add(line);
|
|
3544
|
+
markMovedOff(lines, line);
|
|
3453
3545
|
}
|
|
3454
3546
|
}
|
|
3455
3547
|
}
|
|
3548
|
+
/** Mark the line an inline-block or an image a box moved off was placed
|
|
3549
|
+
* on, where it was on one: the line stays, and the box is drawn where it
|
|
3550
|
+
* went (`MOVED_OFF_LINES`). */
|
|
3551
|
+
function movedOffLine(box) {
|
|
3552
|
+
let block = box.parent;
|
|
3553
|
+
while (block && block.kind === 'inline')
|
|
3554
|
+
block = block.parent;
|
|
3555
|
+
const lines = block?.lines;
|
|
3556
|
+
if (!lines)
|
|
3557
|
+
return;
|
|
3558
|
+
for (const line of lines) {
|
|
3559
|
+
for (const placed of line.atomics) {
|
|
3560
|
+
if (placed.box !== box)
|
|
3561
|
+
continue;
|
|
3562
|
+
markMovedOff(lines, line);
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
function markMovedOff(lines, line) {
|
|
3568
|
+
const moved = MOVED_OFF_LINES.get(lines);
|
|
3569
|
+
if (moved)
|
|
3570
|
+
moved.add(line);
|
|
3571
|
+
else
|
|
3572
|
+
MOVED_OFF_LINES.set(lines, new Set([line]));
|
|
3573
|
+
}
|
|
3456
3574
|
/** Whether `inner` is `outer` or inside it. */
|
|
3457
3575
|
function holds(outer, inner) {
|
|
3458
3576
|
for (let at = inner; at; at = at.parent) {
|