@react-x11/components 0.10.0 → 0.12.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/flow/node.d.ts +14 -6
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +82 -64
- package/dist/flow/node.js.map +1 -1
- package/dist/html/controls.d.ts +26 -7
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js +28 -3
- package/dist/html/controls.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 +89 -31
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/color.d.ts +19 -0
- package/dist/html/css/color.d.ts.map +1 -1
- package/dist/html/css/color.js +86 -0
- package/dist/html/css/color.js.map +1 -1
- package/dist/html/css/parse.d.ts +11 -0
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +114 -4
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +45 -5
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +363 -14
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.js +22 -5
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/css/values.d.ts +10 -1
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +27 -2
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/css/vars.d.ts +5 -0
- package/dist/html/css/vars.d.ts.map +1 -1
- package/dist/html/css/vars.js +2 -2
- package/dist/html/css/vars.js.map +1 -1
- package/dist/html/dom.d.ts.map +1 -1
- package/dist/html/dom.js +35 -2
- package/dist/html/dom.js.map +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +38 -1
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/block.d.ts +11 -2
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +306 -25
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +61 -6
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +65 -16
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/cache.d.ts +2 -2
- package/dist/html/layout/cache.d.ts.map +1 -1
- package/dist/html/layout/cache.js +8 -3
- package/dist/html/layout/cache.js.map +1 -1
- package/dist/html/layout/floats.d.ts +4 -0
- package/dist/html/layout/floats.d.ts.map +1 -1
- package/dist/html/layout/floats.js +26 -0
- package/dist/html/layout/floats.js.map +1 -1
- package/dist/html/layout/inline.d.ts +29 -2
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +1454 -125
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts +33 -0
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +608 -86
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +53 -1
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +746 -214
- package/dist/html/paint.js.map +1 -1
- package/dist/html/surfaces.d.ts +7 -2
- package/dist/html/surfaces.d.ts.map +1 -1
- package/dist/html/surfaces.js +16 -0
- package/dist/html/surfaces.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/internal/window.d.ts +22 -0
- package/dist/internal/window.d.ts.map +1 -1
- package/dist/internal/window.js +35 -8
- package/dist/internal/window.js.map +1 -1
- 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/richtext/node.d.ts +7 -0
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js.map +1 -1
- 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 +5 -3
- 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/flow/node.ts +80 -64
- package/src/html/controls.ts +50 -9
- package/src/html/css/cascade.ts +134 -43
- package/src/html/css/color.ts +87 -0
- package/src/html/css/parse.ts +107 -4
- package/src/html/css/style.ts +386 -23
- package/src/html/css/ua.ts +22 -5
- package/src/html/css/values.ts +31 -3
- package/src/html/css/vars.ts +2 -2
- package/src/html/dom.ts +38 -2
- package/src/html/index.ts +39 -1
- package/src/html/layout/block.ts +360 -22
- package/src/html/layout/boxes.ts +98 -23
- package/src/html/layout/cache.ts +8 -3
- package/src/html/layout/floats.ts +24 -0
- package/src/html/layout/inline.ts +1690 -119
- package/src/html/node.ts +648 -101
- package/src/html/paint.ts +883 -283
- package/src/html/surfaces.ts +21 -1
- package/src/html/svg.ts +30 -19
- package/src/internal/codelines.ts +200 -0
- package/src/internal/window.ts +36 -8
- 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/richtext/node.ts +7 -0
- package/src/terminal-output/index.ts +127 -34
- package/src/terminal-output/runs.ts +16 -2
package/dist/html/controls.d.ts
CHANGED
|
@@ -22,14 +22,23 @@ export interface ControlRect {
|
|
|
22
22
|
width: number;
|
|
23
23
|
height: number;
|
|
24
24
|
/**
|
|
25
|
-
* Set on a text field whose own box the author styled —
|
|
26
|
-
* or a background (`styledField`). The document draws
|
|
27
|
-
* widget goes bare inside its content box, here, with
|
|
28
|
-
* of its own and its text in the element's colour and
|
|
25
|
+
* Set on a text field or a `<select>` whose own box the author styled —
|
|
26
|
+
* gave it a border or a background (`styledField`). The document draws
|
|
27
|
+
* that box, and the widget goes bare inside its content box, here, with
|
|
28
|
+
* no frame or fill of its own and its text in the element's colour and
|
|
29
|
+
* font.
|
|
29
30
|
*/
|
|
30
31
|
bare?: BareField;
|
|
32
|
+
/**
|
|
33
|
+
* How opaque the widget is drawn, where it is less than 1: the element's
|
|
34
|
+
* own `opacity` times every ancestor's, since each fades what is in it as
|
|
35
|
+
* a group. At 0 the widget is not seen and still takes a press, as the
|
|
36
|
+
* element does in a browser — the checkbox a CSS-only dropdown lays,
|
|
37
|
+
* invisible, over its label.
|
|
38
|
+
*/
|
|
39
|
+
opacity?: number;
|
|
31
40
|
}
|
|
32
|
-
/** Where a styled
|
|
41
|
+
/** Where a styled field's widget goes, and how its text looks. */
|
|
33
42
|
export interface BareField {
|
|
34
43
|
x: number;
|
|
35
44
|
y: number;
|
|
@@ -38,18 +47,28 @@ export interface BareField {
|
|
|
38
47
|
color: string;
|
|
39
48
|
fontFamily: string;
|
|
40
49
|
fontSize: number;
|
|
50
|
+
/**
|
|
51
|
+
* A `<select>`'s: whether it draws its arrow. It does unless the page set
|
|
52
|
+
* `appearance: none`, which is how a page that draws its own arrow — as a
|
|
53
|
+
* background image, most often — says so.
|
|
54
|
+
*/
|
|
55
|
+
chevron?: boolean;
|
|
41
56
|
}
|
|
42
57
|
/** The rectangles every control in a laid-out document landed on. */
|
|
43
58
|
export declare function controlRectsOf(tree: BoxTree): ControlRect[];
|
|
44
59
|
/**
|
|
45
|
-
* Whether a
|
|
46
|
-
*
|
|
60
|
+
* Whether a field's box is the author's to draw: one given a border or a
|
|
61
|
+
* background of its own, which the UA sheet gives no control, or set to
|
|
47
62
|
* `appearance: none`, which says so outright. A browser drops a field's
|
|
48
63
|
* native look for the author's then (CSS UI 4 7.1, `appearance`), and so
|
|
49
64
|
* does this: the widget's frame and fill would hide the author's, and what
|
|
50
65
|
* they would draw is the theme's rather than the page's. `appearance: none`
|
|
51
66
|
* is how a design system writes every field it has — meetup.com's search
|
|
52
67
|
* pill holds two with no background, only one of them with a border.
|
|
68
|
+
*
|
|
69
|
+
* A `<select>` is one too. A browser keeps its arrow when the page gave it a
|
|
70
|
+
* border or a background (Blink's `menulist-button`), and leaves that out
|
|
71
|
+
* as well at `appearance: none` — `BareField.chevron`.
|
|
53
72
|
*/
|
|
54
73
|
export declare function styledField(kind: ReplacedKind, style: ComputedStyle): boolean;
|
|
55
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../src/html/controls.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB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G,WAAW,EAAE,CAqC3D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAe7E;AAMD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE,aAAa,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA6EnC;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAe/C;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAoBzE;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkBzD;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAQjD"}
|
package/dist/html/controls.js
CHANGED
|
@@ -8,6 +8,9 @@ export function controlRectsOf(tree) {
|
|
|
8
8
|
continue;
|
|
9
9
|
if (box.width <= 0 || box.height <= 0)
|
|
10
10
|
continue;
|
|
11
|
+
// a hidden element draws nothing and takes no press (CSS 2.1 11.2)
|
|
12
|
+
if (box.style.visibility !== 'visible')
|
|
13
|
+
continue;
|
|
11
14
|
const rect = {
|
|
12
15
|
element: box.el,
|
|
13
16
|
kind: box.replaced,
|
|
@@ -16,6 +19,12 @@ export function controlRectsOf(tree) {
|
|
|
16
19
|
width: box.width,
|
|
17
20
|
height: box.height,
|
|
18
21
|
};
|
|
22
|
+
let opacity = 1;
|
|
23
|
+
for (let at = box; at; at = at.parent) {
|
|
24
|
+
opacity *= at.style.opacity;
|
|
25
|
+
}
|
|
26
|
+
if (opacity < 1)
|
|
27
|
+
rect.opacity = Math.max(0, opacity);
|
|
19
28
|
if (styledField(box.replaced, box.style)) {
|
|
20
29
|
rect.bare = {
|
|
21
30
|
x: box.contentX,
|
|
@@ -25,6 +34,9 @@ export function controlRectsOf(tree) {
|
|
|
25
34
|
color: box.style.color,
|
|
26
35
|
fontFamily: box.style.fontFamily,
|
|
27
36
|
fontSize: box.style.fontSize,
|
|
37
|
+
...(box.replaced === 'select' && {
|
|
38
|
+
chevron: box.style.appearance !== 'none',
|
|
39
|
+
}),
|
|
28
40
|
};
|
|
29
41
|
}
|
|
30
42
|
out.push(rect);
|
|
@@ -32,18 +44,23 @@ export function controlRectsOf(tree) {
|
|
|
32
44
|
return out;
|
|
33
45
|
}
|
|
34
46
|
/**
|
|
35
|
-
* Whether a
|
|
36
|
-
*
|
|
47
|
+
* Whether a field's box is the author's to draw: one given a border or a
|
|
48
|
+
* background of its own, which the UA sheet gives no control, or set to
|
|
37
49
|
* `appearance: none`, which says so outright. A browser drops a field's
|
|
38
50
|
* native look for the author's then (CSS UI 4 7.1, `appearance`), and so
|
|
39
51
|
* does this: the widget's frame and fill would hide the author's, and what
|
|
40
52
|
* they would draw is the theme's rather than the page's. `appearance: none`
|
|
41
53
|
* is how a design system writes every field it has — meetup.com's search
|
|
42
54
|
* pill holds two with no background, only one of them with a border.
|
|
55
|
+
*
|
|
56
|
+
* A `<select>` is one too. A browser keeps its arrow when the page gave it a
|
|
57
|
+
* border or a background (Blink's `menulist-button`), and leaves that out
|
|
58
|
+
* as well at `appearance: none` — `BareField.chevron`.
|
|
43
59
|
*/
|
|
44
60
|
export function styledField(kind, style) {
|
|
45
|
-
if (kind !== 'input' && kind !== 'textarea')
|
|
61
|
+
if (kind !== 'input' && kind !== 'textarea' && kind !== 'select') {
|
|
46
62
|
return false;
|
|
63
|
+
}
|
|
47
64
|
return (style.appearance === 'none' ||
|
|
48
65
|
!isTransparent(style.backgroundColor) ||
|
|
49
66
|
!!style.backgroundImage ||
|
|
@@ -89,6 +106,14 @@ export function measureControl(el, kind, style, fonts, look) {
|
|
|
89
106
|
}
|
|
90
107
|
case 'select': {
|
|
91
108
|
const widest = optionWidths(el);
|
|
109
|
+
// a select the page styled is its widest option and its arrow, and
|
|
110
|
+
// the room around them is the page's
|
|
111
|
+
if (styledField(kind, style)) {
|
|
112
|
+
return {
|
|
113
|
+
width: Math.round(ch * widest + (style.appearance === 'none' ? 0 : em)),
|
|
114
|
+
height: lineHeight,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
92
117
|
// The room for the chevron is the widget's, not the document's, but
|
|
93
118
|
// the document has to reserve it or the last letter of the widest
|
|
94
119
|
// option sits under it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/html/controls.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/html/controls.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2DhD,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,SAAS;QACtB,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC;YAAE,SAAS;QAChD,mEAAmE;QACnE,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS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MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,MAAM,IAAI,SAAS,CAAC,EAAE,CAAC;QAChC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;+CAE+C;AAC/C,SAAS,SAAS,CAAC,KAAoB,EAAE,KAAuB;IAC9D,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE;YACzC,IAAI,EAAE,KAAK,CAAC,QAAQ;YACpB,MAAM,EAAE,KAAK,CAAC,UAAU;YACxB,KAAK,EAAE,KAAK,CAAC,SAAS;SACvB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,uEAAuE;QACvE,gCAAgC;QAChC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -47,6 +47,20 @@ export interface PointerState {
|
|
|
47
47
|
hovered: ReadonlySet<Element>;
|
|
48
48
|
active: ReadonlySet<Element>;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The face a style's font-relative units are measured in: its family list,
|
|
52
|
+
* size, weight and slant, the four that pick one. A family's faces can be
|
|
53
|
+
* different fonts altogether — a page's `@font-face` rules may set its
|
|
54
|
+
* bold in another file — so an `ex` in bold text is the bold face's.
|
|
55
|
+
*/
|
|
56
|
+
export interface MetricFace {
|
|
57
|
+
family: string;
|
|
58
|
+
size: number;
|
|
59
|
+
weight: number;
|
|
60
|
+
style: ComputedStyle['fontStyle'];
|
|
61
|
+
}
|
|
62
|
+
/** What a face measures, where the fonts can say. */
|
|
63
|
+
export type FaceMetric = (face: MetricFace) => number | null;
|
|
50
64
|
/**
|
|
51
65
|
* A cascade over a fixed set of stylesheets. Rebuilt when the sheets change;
|
|
52
66
|
* re-run when the DOM, the viewport band or the pointer state does.
|
|
@@ -89,14 +103,14 @@ export declare class Cascade {
|
|
|
89
103
|
readonly breakpoints: number[];
|
|
90
104
|
/** The counter styles the sheets define, over the predefined ones. */
|
|
91
105
|
readonly counterStyles: CounterStyles;
|
|
92
|
-
/** A
|
|
106
|
+
/** A face's x-height, for `ex`, where the fonts can say. */
|
|
93
107
|
private _xHeightOf;
|
|
94
108
|
private _xHeights;
|
|
95
|
-
/** The advance of a
|
|
109
|
+
/** The advance of a face's "0", for `ch`, likewise. */
|
|
96
110
|
private _zeroWidthOf;
|
|
97
111
|
private _zeroWidths;
|
|
98
|
-
/** A
|
|
99
|
-
*
|
|
112
|
+
/** A face's own line height, for `lh` where `line-height` is `normal`,
|
|
113
|
+
* likewise. */
|
|
100
114
|
private _normalLineOf;
|
|
101
115
|
private _normalLines;
|
|
102
116
|
/** Whether any declaration sets a custom property or reads one: without
|
|
@@ -115,7 +129,7 @@ export declare class Cascade {
|
|
|
115
129
|
/** Whether any declaration has a length in `lh` or `rlh`: only then is
|
|
116
130
|
* the line height settled ahead of the declarations that read it. */
|
|
117
131
|
private _lh;
|
|
118
|
-
constructor(sheets: Stylesheet[], look: RootLook, viewportWidth: number, viewportHeight: number, scale?: number, xHeight?:
|
|
132
|
+
constructor(sheets: Stylesheet[], look: RootLook, viewportWidth: number, viewportHeight: number, scale?: number, xHeight?: FaceMetric | null, zeroWidth?: FaceMetric | null, normalLine?: FaceMetric | null, families?: FontFamilies | null);
|
|
119
133
|
/** Whether declarations read the viewport's width or height (`vw`,
|
|
120
134
|
* `vh`, `vmin`, `vmax`), noted on the cascade. */
|
|
121
135
|
private _noteViewportUnits;
|
|
@@ -246,14 +260,14 @@ export declare class Cascade {
|
|
|
246
260
|
* `display` or its `position` (CSS 2.1 5.12.2).
|
|
247
261
|
*/
|
|
248
262
|
firstLetterStyle(rules: FirstLetterRules, parentStyle: ComputedStyle): ComputedStyle;
|
|
249
|
-
/** The x-height of a style's font: the font's own, asked once per face
|
|
250
|
-
*
|
|
263
|
+
/** The x-height of a style's font: the font's own, asked once per face,
|
|
264
|
+
* or half an em. */
|
|
251
265
|
private _exOf;
|
|
252
266
|
/** The advance of a style's font's "0": the font's own, asked once per
|
|
253
|
-
* face
|
|
267
|
+
* face, or half an em. */
|
|
254
268
|
private _chOf;
|
|
255
269
|
/** A style's computed line height as a length, for `lh`: `normal` as
|
|
256
|
-
* its font's own, asked once per face
|
|
270
|
+
* its font's own, asked once per face, or 1.2em. */
|
|
257
271
|
private _lineHeightOf;
|
|
258
272
|
/** `styleFor`, from the rules and hints already gathered for `el`. */
|
|
259
273
|
private _computeStyle;
|
|
@@ -278,8 +292,16 @@ export declare class Cascade {
|
|
|
278
292
|
* that implied `<html>` instead, so an `html { font-size }` still reaches
|
|
279
293
|
* the body. Taken as the initial style, the rule matched nothing and the
|
|
280
294
|
* whole page came out at the theme's size.
|
|
295
|
+
*
|
|
296
|
+
* `html` is the implied `<html>`'s own style where the root box stands in
|
|
297
|
+
* for the body inside it, and null otherwise: what an `html { … }` or a
|
|
298
|
+
* `:root { … }` rule gives it that is not inherited has no box to be
|
|
299
|
+
* drawn on, and its background is the canvas's (`paintDocument`).
|
|
281
300
|
*/
|
|
282
|
-
rootStyle(hasBody: boolean, hasHtml?: boolean):
|
|
301
|
+
rootStyle(hasBody: boolean, hasHtml?: boolean): {
|
|
302
|
+
style: ComputedStyle;
|
|
303
|
+
html: ComputedStyle | null;
|
|
304
|
+
};
|
|
283
305
|
/** The rules of `index` that match `el`, pushed onto `out` as candidates,
|
|
284
306
|
* and their ids onto `matched` in the order they were tried. */
|
|
285
307
|
private _matchInto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascade.d.ts","sourceRoot":"","sources":["../../../src/html/css/cascade.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAW1C,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,YAAY,CAAC;AAcrE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cascade.d.ts","sourceRoot":"","sources":["../../../src/html/css/cascade.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAW1C,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,YAAY,CAAC;AAcrE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAC;AAwCtE;sEACsE;AACtE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AA4ID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAClD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC9C,CA8GA;AAwID,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,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B,WAAW,EAAE,aAAa,GACzB,aAAa,CAUf;IAED;yBACqB;IACrB,OAAO,CAAC,KAAK;IAWb;+BAC2B;IAC3B,OAAO,CAAC,KAAK;IAWb;yDACqD;IACrD,OAAO,CAAC,aAAa;IAerB,sEAAsE;IACtE,OAAO,CAAC,aAAa;IAkJrB;;sEAEkE;IAClE,OAAO,CAAC,MAAM;IAuBd;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CACP,OAAO,EAAE,OAAO,EAChB,OAAO,UAAO,GACb;QAAE,KAAK,EAAE,aAAa,CAAC;QAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAiBtD;IAED;qEACiE;IACjE,OAAO,CAAC,UAAU;IA4ClB;;sBAEkB;IAClB,OAAO,CAAC,WAAW;CAiDpB"}
|
package/dist/html/css/cascade.js
CHANGED
|
@@ -24,6 +24,7 @@ import { asciiLower, escapeEnd, mediaMatches, readIdent, startsIdent, } from './
|
|
|
24
24
|
import { applyDeclaration, blockify, settleContentVisibility, settleOverflow, settleClamp, copyStyle, decorate, inherit, initialOne, initialStyle, isInherited, } from './style.js';
|
|
25
25
|
import { parseDeclarations } from './parse.js';
|
|
26
26
|
import { CounterStyles, counterStyleRule } from './counter-styles.js';
|
|
27
|
+
import { viewportUnit } from './values.js';
|
|
27
28
|
import { customProperties, substituteIn } from './vars.js';
|
|
28
29
|
/** Where a declaration came from. Higher wins before specificity is asked. */
|
|
29
30
|
var Origin;
|
|
@@ -430,6 +431,17 @@ function balancedEnd(text, from, open, close) {
|
|
|
430
431
|
return text.length;
|
|
431
432
|
}
|
|
432
433
|
const NO_POINTER = { hovered: new Set(), active: new Set() };
|
|
434
|
+
function faceOf(style) {
|
|
435
|
+
return {
|
|
436
|
+
family: style.fontFamily,
|
|
437
|
+
size: style.fontSize,
|
|
438
|
+
weight: style.fontWeight,
|
|
439
|
+
style: style.fontStyle,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function faceKey(style) {
|
|
443
|
+
return `${style.fontFamily}\u0001${style.fontSize}\u0001${style.fontWeight}\u0001${style.fontStyle}`;
|
|
444
|
+
}
|
|
433
445
|
/**
|
|
434
446
|
* A cascade over a fixed set of stylesheets. Rebuilt when the sheets change;
|
|
435
447
|
* re-run when the DOM, the viewport band or the pointer state does.
|
|
@@ -478,14 +490,14 @@ export class Cascade {
|
|
|
478
490
|
breakpoints;
|
|
479
491
|
/** The counter styles the sheets define, over the predefined ones. */
|
|
480
492
|
counterStyles;
|
|
481
|
-
/** A
|
|
493
|
+
/** A face's x-height, for `ex`, where the fonts can say. */
|
|
482
494
|
_xHeightOf;
|
|
483
495
|
_xHeights = new Map();
|
|
484
|
-
/** The advance of a
|
|
496
|
+
/** The advance of a face's "0", for `ch`, likewise. */
|
|
485
497
|
_zeroWidthOf;
|
|
486
498
|
_zeroWidths = new Map();
|
|
487
|
-
/** A
|
|
488
|
-
*
|
|
499
|
+
/** A face's own line height, for `lh` where `line-height` is `normal`,
|
|
500
|
+
* likewise. */
|
|
489
501
|
_normalLineOf;
|
|
490
502
|
_normalLines = new Map();
|
|
491
503
|
/** Whether any declaration sets a custom property or reads one: without
|
|
@@ -572,7 +584,7 @@ export class Cascade {
|
|
|
572
584
|
if (!VIEWPORT_UNIT.test(d.value))
|
|
573
585
|
continue;
|
|
574
586
|
for (const m of d.value.matchAll(VIEWPORT_UNITS)) {
|
|
575
|
-
const unit = m[1]
|
|
587
|
+
const unit = viewportUnit(m[1]);
|
|
576
588
|
if (unit !== 'vh')
|
|
577
589
|
this.readsViewportWidth = true;
|
|
578
590
|
if (unit !== 'vw')
|
|
@@ -953,13 +965,13 @@ export class Cascade {
|
|
|
953
965
|
style.position = 'static';
|
|
954
966
|
return style;
|
|
955
967
|
}
|
|
956
|
-
/** The x-height of a style's font: the font's own, asked once per face
|
|
957
|
-
*
|
|
968
|
+
/** The x-height of a style's font: the font's own, asked once per face,
|
|
969
|
+
* or half an em. */
|
|
958
970
|
_exOf(style) {
|
|
959
|
-
const key =
|
|
971
|
+
const key = faceKey(style);
|
|
960
972
|
let ex = this._xHeights.get(key);
|
|
961
973
|
if (ex === undefined) {
|
|
962
|
-
ex = this._xHeightOf?.(style
|
|
974
|
+
ex = this._xHeightOf?.(faceOf(style)) ?? NaN;
|
|
963
975
|
if (!(ex > 0))
|
|
964
976
|
ex = style.fontSize * 0.5;
|
|
965
977
|
this._xHeights.set(key, ex);
|
|
@@ -967,12 +979,12 @@ export class Cascade {
|
|
|
967
979
|
return ex;
|
|
968
980
|
}
|
|
969
981
|
/** The advance of a style's font's "0": the font's own, asked once per
|
|
970
|
-
* face
|
|
982
|
+
* face, or half an em. */
|
|
971
983
|
_chOf(style) {
|
|
972
|
-
const key =
|
|
984
|
+
const key = faceKey(style);
|
|
973
985
|
let ch = this._zeroWidths.get(key);
|
|
974
986
|
if (ch === undefined) {
|
|
975
|
-
ch = this._zeroWidthOf?.(style
|
|
987
|
+
ch = this._zeroWidthOf?.(faceOf(style)) ?? NaN;
|
|
976
988
|
if (!(ch > 0))
|
|
977
989
|
ch = style.fontSize * 0.5;
|
|
978
990
|
this._zeroWidths.set(key, ch);
|
|
@@ -980,16 +992,16 @@ export class Cascade {
|
|
|
980
992
|
return ch;
|
|
981
993
|
}
|
|
982
994
|
/** A style's computed line height as a length, for `lh`: `normal` as
|
|
983
|
-
* its font's own, asked once per face
|
|
995
|
+
* its font's own, asked once per face, or 1.2em. */
|
|
984
996
|
_lineHeightOf(style) {
|
|
985
997
|
const set = style.lineHeight;
|
|
986
998
|
if (set !== 'normal') {
|
|
987
999
|
return style.lineHeightIsLength ? set : set * style.fontSize;
|
|
988
1000
|
}
|
|
989
|
-
const key =
|
|
1001
|
+
const key = faceKey(style);
|
|
990
1002
|
let line = this._normalLines.get(key);
|
|
991
1003
|
if (line === undefined) {
|
|
992
|
-
line = this._normalLineOf?.(style
|
|
1004
|
+
line = this._normalLineOf?.(faceOf(style)) ?? NaN;
|
|
993
1005
|
if (!(line > 0))
|
|
994
1006
|
line = style.fontSize * 1.2;
|
|
995
1007
|
this._normalLines.set(key, line);
|
|
@@ -1020,12 +1032,20 @@ export class Cascade {
|
|
|
1020
1032
|
lh: () => this._lineHeightOf(parentStyle),
|
|
1021
1033
|
rlh: () => this._lineHeightOf(this.initial),
|
|
1022
1034
|
};
|
|
1023
|
-
//
|
|
1035
|
+
// The family, the weight and the slant go with the size: together they
|
|
1036
|
+
// pick the face an `ex`, a `ch` or an `lh` in any declaration is
|
|
1037
|
+
// measured in, however the declarations are ordered. A `width: 10ex`
|
|
1038
|
+
// in a sheet under an inline `font-weight: 900` was measured in the
|
|
1039
|
+
// family's regular face. The colour scheme goes ahead of the rest for
|
|
1040
|
+
// the same reason: every `light-dark()` among them is read by it.
|
|
1024
1041
|
let sized = false;
|
|
1025
1042
|
let keyword = false;
|
|
1026
1043
|
for (const c of candidates) {
|
|
1027
1044
|
for (const d of pick(c)) {
|
|
1028
|
-
if (d.prop === 'font-family'
|
|
1045
|
+
if (d.prop === 'font-family' ||
|
|
1046
|
+
d.prop === 'font-weight' ||
|
|
1047
|
+
d.prop === 'font-style' ||
|
|
1048
|
+
d.prop === 'color-scheme') {
|
|
1029
1049
|
this._apply(style, parentStyle, d, ctxParent);
|
|
1030
1050
|
}
|
|
1031
1051
|
else if (d.prop === 'font-size' || d.prop === 'font') {
|
|
@@ -1054,22 +1074,43 @@ export class Cascade {
|
|
|
1054
1074
|
if (sized ? keyword && mono : mono !== monospaceOnly(parentStyle.fontFamily)) {
|
|
1055
1075
|
style.fontSize *= mono ? FIXED_SIZE : 1 / FIXED_SIZE;
|
|
1056
1076
|
}
|
|
1077
|
+
// The face as the first pass settled it. The second applies every
|
|
1078
|
+
// declaration again in cascade order, the font's among them, so the
|
|
1079
|
+
// style passes through the fonts of every rule on the way: read from
|
|
1080
|
+
// it, the `10ex` in `div { font-family: foo; width: 10ex }` was `foo`'s
|
|
1081
|
+
// under an inline `font-family: Ahem` that came after it.
|
|
1082
|
+
const face = {
|
|
1083
|
+
fontFamily: style.fontFamily,
|
|
1084
|
+
fontSize: style.fontSize,
|
|
1085
|
+
fontWeight: style.fontWeight,
|
|
1086
|
+
fontStyle: style.fontStyle,
|
|
1087
|
+
};
|
|
1088
|
+
let line = null;
|
|
1057
1089
|
const ctx = {
|
|
1058
1090
|
...ctxParent,
|
|
1059
1091
|
em: style.fontSize,
|
|
1060
|
-
ex: () => this._exOf(
|
|
1061
|
-
ch: () => this._chOf(
|
|
1062
|
-
lh: () => this._lineHeightOf(style),
|
|
1092
|
+
ex: () => this._exOf(face),
|
|
1093
|
+
ch: () => this._chOf(face),
|
|
1094
|
+
lh: () => this._lineHeightOf(line ?? style),
|
|
1063
1095
|
};
|
|
1064
1096
|
// the line height, which an `lh` in any other declaration reads, ahead
|
|
1065
|
-
// of them
|
|
1097
|
+
// of them — a `font` sets one too — and read as it is then, for the
|
|
1098
|
+
// same reason as the face: set again with the rest, in its place among
|
|
1099
|
+
// them. A `font` sets the size as well, which the first pass settled.
|
|
1066
1100
|
if (this._lh) {
|
|
1067
1101
|
for (const c of candidates) {
|
|
1068
1102
|
for (const d of pick(c)) {
|
|
1069
|
-
if (d.prop === 'line-height')
|
|
1103
|
+
if (d.prop === 'line-height' || d.prop === 'font') {
|
|
1070
1104
|
this._apply(style, parentStyle, d, ctx);
|
|
1105
|
+
}
|
|
1071
1106
|
}
|
|
1072
1107
|
}
|
|
1108
|
+
style.fontSize = face.fontSize;
|
|
1109
|
+
line = {
|
|
1110
|
+
...face,
|
|
1111
|
+
lineHeight: style.lineHeight,
|
|
1112
|
+
lineHeightIsLength: style.lineHeightIsLength,
|
|
1113
|
+
};
|
|
1073
1114
|
}
|
|
1074
1115
|
const settled = style.fontSize;
|
|
1075
1116
|
for (const c of candidates) {
|
|
@@ -1144,24 +1185,31 @@ export class Cascade {
|
|
|
1144
1185
|
* that implied `<html>` instead, so an `html { font-size }` still reaches
|
|
1145
1186
|
* the body. Taken as the initial style, the rule matched nothing and the
|
|
1146
1187
|
* whole page came out at the theme's size.
|
|
1188
|
+
*
|
|
1189
|
+
* `html` is the implied `<html>`'s own style where the root box stands in
|
|
1190
|
+
* for the body inside it, and null otherwise: what an `html { … }` or a
|
|
1191
|
+
* `:root { … }` rule gives it that is not inherited has no box to be
|
|
1192
|
+
* drawn on, and its background is the canvas's (`paintDocument`).
|
|
1147
1193
|
*/
|
|
1148
1194
|
rootStyle(hasBody, hasHtml = true) {
|
|
1149
1195
|
const style = copyStyle(this.initial);
|
|
1150
1196
|
style.display = 'block';
|
|
1151
1197
|
if (hasBody && hasHtml)
|
|
1152
|
-
return style;
|
|
1198
|
+
return { style, html: null };
|
|
1153
1199
|
const synthetic = new DomElement('body', {}, []);
|
|
1154
1200
|
let parent = style;
|
|
1201
|
+
let html = null;
|
|
1155
1202
|
if (!hasHtml) {
|
|
1156
|
-
const
|
|
1157
|
-
synthetic.parent =
|
|
1158
|
-
parent = this.styleFor(
|
|
1203
|
+
const element = new DomElement('html', {}, hasBody ? [] : [synthetic]);
|
|
1204
|
+
synthetic.parent = element;
|
|
1205
|
+
parent = this.styleFor(element, style, false);
|
|
1159
1206
|
if (hasBody)
|
|
1160
|
-
return asRoot(parent);
|
|
1207
|
+
return { style: asRoot(parent), html: null };
|
|
1208
|
+
html = parent;
|
|
1161
1209
|
}
|
|
1162
1210
|
// Only the box the body would have drawn is taken, not its layout role:
|
|
1163
1211
|
// the root is still the initial containing block.
|
|
1164
|
-
return asRoot(this.styleFor(synthetic, parent, false));
|
|
1212
|
+
return { style: asRoot(this.styleFor(synthetic, parent, false)), html };
|
|
1165
1213
|
}
|
|
1166
1214
|
/** The rules of `index` that match `el`, pushed onto `out` as candidates,
|
|
1167
1215
|
* and their ids onto `matched` in the order they were tried. */
|
|
@@ -1269,9 +1317,19 @@ function asRoot(style) {
|
|
|
1269
1317
|
}
|
|
1270
1318
|
/** `:root` is the `<html>` element: the one a browser implies around a
|
|
1271
1319
|
* fragment, whose style the root box takes (`rootStyle`), and never a
|
|
1272
|
-
* fragment's top-level elements, which css-select would take for it.
|
|
1320
|
+
* fragment's top-level elements, which css-select would take for it.
|
|
1321
|
+
*
|
|
1322
|
+
* `:focus` and its two kin match nothing: no element of the document takes
|
|
1323
|
+
* the focus — a control's widget does, beside it. css-select has none of
|
|
1324
|
+
* the three and throws on them, which dropped every rule that named one,
|
|
1325
|
+
* `:not(:focus)` among them: Wikipedia's skip link hides with
|
|
1326
|
+
* `.mw-jump-link:not(:focus)`, and without it stood in the flow at the top
|
|
1327
|
+
* of every page. */
|
|
1273
1328
|
const PSEUDOS = {
|
|
1274
1329
|
root: (el) => el.name === 'html' && !(el.parent && isTag(el.parent)),
|
|
1330
|
+
focus: () => false,
|
|
1331
|
+
'focus-visible': () => false,
|
|
1332
|
+
'focus-within': () => false,
|
|
1275
1333
|
// css-select's, but its ranges and tags lower-cased as ASCII has it, and
|
|
1276
1334
|
// no other script (CSS 2.1 4.1.3): Unicode's took `:lang(\u212Al)`, a
|
|
1277
1335
|
// Kelvin sign for the K, for `:lang(kl)`
|
|
@@ -1306,8 +1364,8 @@ const PSEUDOS = {
|
|
|
1306
1364
|
};
|
|
1307
1365
|
/** A length in a unit of the viewport: a number, then the unit, and no
|
|
1308
1366
|
* more of a name after it. */
|
|
1309
|
-
const VIEWPORT_UNIT = /\d(?:
|
|
1310
|
-
const VIEWPORT_UNITS = /\d(
|
|
1367
|
+
const VIEWPORT_UNIT = /\d[sld]?v(?:w|h|i|b|min|max)(?![\w-])/i;
|
|
1368
|
+
const VIEWPORT_UNITS = /\d([sld]?v(?:w|h|i|b|min|max))(?![\w-])/gi;
|
|
1311
1369
|
/**
|
|
1312
1370
|
* A selector with its `[attr~=""]` made one that matches nothing: an empty
|
|
1313
1371
|
* string is no word of a list, and such a selector represents nothing
|