xbintsc 0.6.9 → 0.6.12
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/src/checker/globals.js +2 -1
- package/dist/src/checker/globals.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +1 -0
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/state.js +3 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +3 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/compiler.js +1 -1
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/config.js +1 -0
- package/dist/src/driver/config.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +2 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/driver/version.js.map +1 -1
- package/dist/src/extensions/node/crypto/index.js +12 -1
- package/dist/src/extensions/node/crypto/index.js.map +1 -1
- package/dist/tests/driver/config.test.js +15 -2
- package/dist/tests/driver/config.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +26 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-node.test.js +37 -1
- package/dist/tests/e2e/compile-node.test.js.map +1 -1
- package/dist/tests/e2e/crypto-random.test.d.ts +9 -0
- package/dist/tests/e2e/crypto-random.test.js +63 -0
- package/dist/tests/e2e/crypto-random.test.js.map +1 -0
- package/dist/tests/e2e/date-parse.test.js +27 -1
- package/dist/tests/e2e/date-parse.test.js.map +1 -1
- package/dist/tests/e2e/gui-css-coverage.test.js +1 -1
- package/dist/tests/e2e/gui-dom.test.js +29 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-form.test.d.ts +9 -0
- package/dist/tests/e2e/gui-form.test.js +359 -0
- package/dist/tests/e2e/gui-form.test.js.map +1 -0
- package/dist/tests/e2e/gui-helpers.d.ts +2 -0
- package/dist/tests/e2e/gui-helpers.js +1 -0
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +47 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-paint.test.js +108 -0
- package/dist/tests/e2e/gui-paint.test.js.map +1 -1
- package/dist/tests/e2e/gui-script-import-order.test.js +6 -1
- package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
- package/dist/tests/e2e/gui-style.test.js +82 -0
- package/dist/tests/e2e/gui-style.test.js.map +1 -1
- package/dist/tests/e2e/gui-unsupported.test.d.ts +6 -0
- package/dist/tests/e2e/gui-unsupported.test.js +124 -0
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
- package/dist/tests/e2e/json-parse-errors.test.d.ts +9 -0
- package/dist/tests/e2e/json-parse-errors.test.js +48 -0
- package/dist/tests/e2e/json-parse-errors.test.js.map +1 -0
- package/doc/ai/extensions.md +7 -4
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/zh-CN/extensions.md +6 -3
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/gui/api.md +8 -2
- package/doc/gui/dom.md +81 -4
- package/doc/gui/input.md +74 -3
- package/doc/gui/known-issues.md +12 -5
- package/doc/gui/layout.md +19 -6
- package/doc/gui/rendering.md +16 -9
- package/doc/implemented/node/crypto.md +8 -0
- package/doc/implemented/node/fs.md +1 -1
- package/doc/implemented/stdlib.md +10 -2
- package/doc/zh-CN/gui/api.md +8 -2
- package/doc/zh-CN/gui/dom.md +70 -4
- package/doc/zh-CN/gui/input.md +65 -4
- package/doc/zh-CN/gui/known-issues.md +11 -4
- package/doc/zh-CN/gui/layout.md +14 -4
- package/doc/zh-CN/gui/rendering.md +13 -10
- package/doc/zh-CN/implemented/node/crypto.md +6 -0
- package/doc/zh-CN/implemented/node/fs.md +1 -1
- package/doc/zh-CN/implemented/stdlib.md +10 -2
- package/package.json +7 -7
- package/runtime/ext_gui/clip_values.cpp +11 -0
- package/runtime/ext_gui/css.cpp +27 -2
- package/runtime/ext_gui/css_match.cpp +21 -1
- package/runtime/ext_gui/css_selector.cpp +23 -0
- package/runtime/ext_gui/css_sheet.cpp +7 -0
- package/runtime/ext_gui/document.cpp +15 -0
- package/runtime/ext_gui/document_animation.cpp +4 -1
- package/runtime/ext_gui/dom.h +41 -2
- package/runtime/ext_gui/dom_api.cpp +3 -0
- package/runtime/ext_gui/dom_api_document.cpp +28 -0
- package/runtime/ext_gui/dom_api_events.cpp +17 -14
- package/runtime/ext_gui/dom_api_form.cpp +567 -0
- package/runtime/ext_gui/dom_api_internal.h +46 -214
- package/runtime/ext_gui/dom_api_mutation.cpp +1 -1
- package/runtime/ext_gui/dom_api_node.cpp +10 -3
- package/runtime/ext_gui/dom_api_node_read.cpp +1 -1
- package/runtime/ext_gui/dom_api_proto.cpp +45 -0
- package/runtime/ext_gui/dom_api_webgl_methods.h +217 -0
- package/runtime/ext_gui/dom_parse.cpp +118 -1
- package/runtime/ext_gui/effect_values.cpp +28 -7
- package/runtime/ext_gui/form_focus.cpp +293 -0
- package/runtime/ext_gui/form_input.cpp +448 -0
- package/runtime/ext_gui/form_internal.h +30 -0
- package/runtime/ext_gui/form_shared.cpp +126 -0
- package/runtime/ext_gui/form_state.cpp +536 -0
- package/runtime/ext_gui/form_state.h +97 -0
- package/runtime/ext_gui/gradient_values.cpp +25 -5
- package/runtime/ext_gui/gui_engine.h +40 -4
- package/runtime/ext_gui/gui_events.cpp +63 -48
- package/runtime/ext_gui/inline_svg.cpp +3 -0
- package/runtime/ext_gui/layout.cpp +6 -0
- package/runtime/ext_gui/layout.h +4 -0
- package/runtime/ext_gui/layout_flow.cpp +35 -3
- package/runtime/ext_gui/layout_inline.cpp +80 -7
- package/runtime/ext_gui/media_query.cpp +7 -1
- package/runtime/ext_gui/paint.cpp +62 -24
- package/runtime/ext_gui/paint.h +7 -4
- package/runtime/ext_gui/paint_clip.cpp +74 -19
- package/runtime/ext_gui/paint_form.cpp +389 -0
- package/runtime/ext_gui/paint_internal.h +13 -1
- package/runtime/ext_gui/renderer_clip.cpp +19 -17
- package/runtime/ext_gui/style.cpp +5 -1
- package/runtime/ext_gui/style.h +5 -0
- package/runtime/ext_gui/style_cascade.cpp +2 -0
- package/runtime/ext_gui/style_internal.h +7 -2
- package/runtime/ext_gui/style_print.cpp +33 -0
- package/runtime/ext_gui/style_text.cpp +11 -0
- package/runtime/ext_gui/style_ua.cpp +42 -0
- package/runtime/ext_gui/style_values.cpp +89 -90
- package/runtime/ext_gui/transform.cpp +2 -0
- package/runtime/ext_gui/warnings.cpp +298 -0
- package/runtime/ext_gui/warnings.h +59 -0
- package/runtime/ext_gui/window.cpp +31 -55
- package/runtime/ext_gui/window_diagnostics.cpp +58 -0
- package/runtime/ext_gui/window_emit.cpp +51 -0
- package/runtime/ext_node/crypto/crypto.c +3 -2
- package/runtime/ext_node/crypto/crypto_hash.h +13 -0
- package/runtime/ext_node/crypto/crypto_random.c +339 -0
- package/runtime/ext_node/fs/async_worker.c +1 -1
- package/runtime/ext_node/fs/fs_ops.c +1 -1
- package/runtime/ext_node/fs/parts/platform.inc +65 -0
- package/runtime/rt.h +27 -0
- package/runtime/xt_crypto.c +132 -0
- package/runtime/xt_random.c +143 -0
- package/runtime/xt_regex/matcher.inc +9 -28
- package/runtime/xt_regex/parser.inc +65 -2
- package/runtime/xt_regex/types.inc +11 -1
- package/runtime/xt_regex.h +6 -2
- package/runtime/xt_stdlib/dispatch.inc +2 -0
- package/runtime/xt_stdlib/math.inc +1 -1
- package/runtime/xt_stdlib2/date.inc +204 -4
- package/runtime/xt_stdlib2/json.inc +4 -546
- package/runtime/xt_stdlib2/json_parse.inc +347 -0
- package/runtime/xt_stdlib2/json_stringify.inc +368 -0
- package/runtime/xt_stdlib2/regexp-match.inc +6 -11
- package/runtime/xt_stdlib2.c +0 -4
- package/runtime/xt_typed_array/elements.inc +6 -1
- package/src/checker/globals.ts +2 -0
- package/src/cli/main.ts +1 -0
- package/src/codegen/generator/state.ts +3 -0
- package/src/codegen/generator/tables.ts +3 -0
- package/src/driver/compiler.ts +1 -1
- package/src/driver/config.ts +1 -0
- package/src/driver/runtime-objects.ts +2 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/node/crypto/index.ts +12 -1
package/doc/gui/input.md
CHANGED
|
@@ -12,7 +12,8 @@ scaled or translated element is hit exactly where it is drawn — and `:hover`
|
|
|
12
12
|
follows the artwork, not the box flow left behind.
|
|
13
13
|
|
|
14
14
|
- SDL pointer/wheel/key events are routed to the owning window, hit tested, and
|
|
15
|
-
delivered to the handlers registered with `on`. `mousedown` also moves focus
|
|
15
|
+
delivered to the handlers registered with `on`. `mousedown` also moves focus
|
|
16
|
+
and places the caret in a text field.
|
|
16
17
|
- Keyboard events also follow the DOM path: the target is the focused element (or
|
|
17
18
|
`<body>` when nothing is focused), the event bubbles through its ancestors to
|
|
18
19
|
`document`, and finally reaches `window` listeners. This is what lets a page
|
|
@@ -21,12 +22,82 @@ delivered to the handlers registered with `on`. `mousedown` also moves focus.
|
|
|
21
22
|
(`"KeyW"`, `"ArrowUp"`, `"Space"`) and `key` the produced value (`"w"`, `"W"`,
|
|
22
23
|
`" "`) — not SDL's scancode/key names.
|
|
23
24
|
- `:hover` matches the hovered element **and its ancestors** (so hovering a child
|
|
24
|
-
lights up its parents); `:focus` matches the focused element
|
|
25
|
+
lights up its parents); `:focus` matches the focused element and
|
|
26
|
+
`:focus-within` its ancestors too. When either
|
|
25
27
|
changes, `XtDocument::setHover`/`setFocus` recompute styles and layout and mark
|
|
26
28
|
the window's geometry dirty, so the change is painted on the next frame.
|
|
27
29
|
- `win.hitTest(x, y)` and `win.sendEvent(type, options)` expose hit testing and
|
|
28
30
|
synthetic input so the whole path is testable headlessly (the e2e suite drives
|
|
29
31
|
clicks, wheels and keys without a real mouse).
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## Form controls (M23)
|
|
32
34
|
|
|
35
|
+
`<input>`, `<textarea>` and `<select>` are native leaf boxes: their value,
|
|
36
|
+
selection and checked state live in `Node::form` (`FormState`) and are painted
|
|
37
|
+
by the engine, so no browser/DOM layer is involved.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const user = document.getElementById("user"); // <input id="user" value="abc">
|
|
41
|
+
user.focus();
|
|
42
|
+
user.value; // "abc"
|
|
43
|
+
user.selectionStart; // 3
|
|
44
|
+
user.setSelectionRange(1, 3);
|
|
45
|
+
user.placeholder = "name";
|
|
46
|
+
user.disabled = true;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **`<input>` types**: `text`, `search`, `tel`, `url`, `email`, `password`,
|
|
50
|
+
`number`, `date`, `month`, `week`, `time`, `datetime-local`, `range`, `color`,
|
|
51
|
+
`checkbox`, `radio`, `file`, `submit`, `reset`, `button`, `image` and
|
|
52
|
+
`hidden`. Text-like types are editable; checkbox/radio paint their box and
|
|
53
|
+
toggle on click (radios uncheck the rest of their `name` group); range paints a
|
|
54
|
+
track and thumb and updates from a drag; color paints a swatch; submit/reset/
|
|
55
|
+
button paint their label. `hidden` has no box.
|
|
56
|
+
- **`<textarea>`** is multi-line (`\n` breaks a line), **`<select>`** paints the
|
|
57
|
+
selected `<option>`'s label and cycles the selection on click (there is no
|
|
58
|
+
popup menu). `date`/`time`/`month`/`week` inputs are editable text fields with
|
|
59
|
+
the browser's value shape, and `color`/`file` expose their value/state without
|
|
60
|
+
opening a native picker or file dialog.
|
|
61
|
+
- **`value`** is the live value, separate from the `value` attribute (the
|
|
62
|
+
default). `<textarea>` reads its default from its text content and `<select>`
|
|
63
|
+
from the selected/first `<option>`. Assigning `value` moves the caret to the
|
|
64
|
+
end, as browsers do.
|
|
65
|
+
- **`selectionStart` / `selectionEnd` / `selectionDirection`**,
|
|
66
|
+
`setSelectionRange(start, end, direction)` and `select()` use UTF-16 code-unit
|
|
67
|
+
offsets (the DOM convention), backed by UTF-8 storage.
|
|
68
|
+
- **`checked`**, `type`, `name`, `disabled`, `readOnly`, `required`,
|
|
69
|
+
`placeholder`, `min`, `max`, `step`, `maxLength`, `tabIndex`, `form`,
|
|
70
|
+
`options` and `selectedIndex` are live DOM properties.
|
|
71
|
+
- **`document.activeElement`** is the focused element, or `<body>` when nothing
|
|
72
|
+
is focused. `tabindex` establishes the Tab order (`tabindex="1"` before the
|
|
73
|
+
implicit `0` stops; `-1` is click-focusable but skipped by Tab); Tab and
|
|
74
|
+
Shift+Tab move focus even when no text field is focused. A disabled or hidden
|
|
75
|
+
control cannot be focused, is skipped by Tab and paints dimmed.
|
|
76
|
+
- **Text input** comes from `SDL_EVENT_TEXT_INPUT`, which carries the text the
|
|
77
|
+
keyboard layout or IME actually produced. `keydown` handles the editing
|
|
78
|
+
commands (Backspace/Delete/arrows/Home/End/Ctrl+A/C/X/V, with Shift extending
|
|
79
|
+
the selection) and `keypress` + `input` are dispatched after an edit.
|
|
80
|
+
- **IME** uses `SDL_EVENT_TEXT_EDITING`: the pre-edit text is displayed at the
|
|
81
|
+
caret and `compositionstart` / `compositionupdate` / `compositionend` fire;
|
|
82
|
+
the commit is inserted into the value on `compositionend`.
|
|
83
|
+
- **Clipboard** is the system clipboard through SDL: Ctrl+C/X/V.
|
|
84
|
+
- **Events** fire automatically: `beforeinput` (cancelable) before a text edit,
|
|
85
|
+
`input` after every value change (typing, deletion, checkbox/radio toggle,
|
|
86
|
+
range drag, select), and `change` when the value is committed (a text field
|
|
87
|
+
losing focus after a change, Enter in a single-line field, a checkbox/radio
|
|
88
|
+
click, a range release or a select change). `input`/`change` payloads carry
|
|
89
|
+
`value`; `change` also carries `checked`.
|
|
90
|
+
- **Forms**: a submit button (or Enter in a single-line field) fires a
|
|
91
|
+
cancelable `submit` on the enclosing `<form>` with the `submitter` when one
|
|
92
|
+
was clicked; there is no navigation, so preventing the event or not has the
|
|
93
|
+
same visible result. A reset button or `form.reset()` fires `reset` and
|
|
94
|
+
restores every control's default value/checked state. `form.submit()` and
|
|
95
|
+
`form.requestSubmit(submitter?)` dispatch the same event.
|
|
96
|
+
|
|
97
|
+
`win.sendEvent` also accepts `{ type: "textInput", text }` (as if SDL delivered
|
|
98
|
+
that text), `{ type: "compositionstart" | "compositionupdate" | "compositionend",
|
|
99
|
+
data }` and printable `keydown` events. A real physical `keydown` never inserts
|
|
100
|
+
its US-layout `key`: the matching text-input event does, so an IME or a non-US
|
|
101
|
+
layout cannot double a character.
|
|
102
|
+
|
|
103
|
+
Still to do for full input: drag-selection across several lines and undo/redo.
|
package/doc/gui/known-issues.md
CHANGED
|
@@ -64,7 +64,11 @@
|
|
|
64
64
|
*class change* on a flex container has also been observed to crash the same
|
|
65
65
|
way; `examples/gui/pelican-bike` reveals its game-over overlay with `opacity`
|
|
66
66
|
instead.
|
|
67
|
-
- **CSS coverage is a deliberate subset.**
|
|
67
|
+
- **CSS coverage is a deliberate subset.** Unsupported property names, at-rules,
|
|
68
|
+
selectors, functions, units, attributes and elements (see
|
|
69
|
+
[DOM](./dom.md#unsupported-features-are-reported)) are reported once on stderr
|
|
70
|
+
rather than silently dropped, so a ported page shows what fell back. Grid,
|
|
71
|
+
`calc()` (including
|
|
68
72
|
nested arithmetic and `calc()` inside `min()`/`max()`/`clamp()`),
|
|
69
73
|
`clamp()`/`min()`/`max()`/`env()`, `var()` custom properties, the `inset`
|
|
70
74
|
shorthand, `box-sizing`, `visibility` and `pointer-events`, `@media` queries,
|
|
@@ -72,9 +76,11 @@
|
|
|
72
76
|
backgrounds, `text-shadow` (true Gaussian), `box-shadow` (outer/inset, spread,
|
|
73
77
|
multiple layers), `clip-path` (`inset`/`circle`/`ellipse`/`polygon`),
|
|
74
78
|
`filter` colour functions, `@keyframes` animations, the full `transition`
|
|
75
|
-
timing-function set, `letter-spacing`, `text-transform`,
|
|
79
|
+
timing-function set, `letter-spacing`, `text-transform`,
|
|
80
|
+
`white-space: nowrap`, `text-overflow: ellipsis`, inline-level
|
|
76
81
|
`flex`/`grid`, `grid-area`, `aspect-ratio`, auto margins, percentage
|
|
77
|
-
`border-radius
|
|
82
|
+
`border-radius` (including rounded `overflow` clipping of children and
|
|
83
|
+
replaced content), `outline`, `background-size` tiling for `url()` layers and
|
|
78
84
|
document CSS on SVG children (`fill`/`stroke`/…) are implemented. Known
|
|
79
85
|
limits: `background-clip`, `background-position` and `background-repeat`
|
|
80
86
|
remain unimplemented (`background-size` covers the tiled default);
|
|
@@ -87,8 +93,9 @@
|
|
|
87
93
|
groups fall back to normal source-over painting and the backdrop filter is
|
|
88
94
|
skipped. `filter: blur()` is still a nine-tap per-shape spread rather than a
|
|
89
95
|
true group blur, so overlapping descendants can darken; `drop-shadow` is
|
|
90
|
-
approximated from box silhouettes; at most
|
|
91
|
-
|
|
96
|
+
approximated from box silhouettes; at most four nested clip shapes (CSS
|
|
97
|
+
`clip-path` and rounded `overflow` boxes together) are intersected (deeper
|
|
98
|
+
nesting keeps the outer four); and images/canvases are not
|
|
92
99
|
colour-filtered except for the brightness/opacity tint the image shader can
|
|
93
100
|
carry. Canvas textures are sampled nearest-neighbour. Background gradients
|
|
94
101
|
(linear and radial) are rasterised per pixel into a texture and then stretched
|
package/doc/gui/layout.md
CHANGED
|
@@ -10,11 +10,14 @@ with absolute (viewport-relative) geometry:
|
|
|
10
10
|
|
|
11
11
|
- **Block flow** — block-level children stack vertically; `display: none`
|
|
12
12
|
generates no box; `width: auto` fills the containing block, `height: auto`
|
|
13
|
-
wraps the content.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
wraps the content. A percentage `height` resolves against the containing
|
|
14
|
+
block's **definite** content height (a frame sized by `height`/`clamp()` hands
|
|
15
|
+
its used height down to its children); when no definite height is known along
|
|
16
|
+
that chain, it is treated as `auto`. The box
|
|
17
|
+
model (margin/padding/border) is resolved, including percentages against the
|
|
18
|
+
containing block width. Adjoining vertical margins between siblings collapse
|
|
19
|
+
to `max(positive) + min(negative)`; a parent's bottom margin does not collapse
|
|
20
|
+
with its last child's (see the limitations below).
|
|
18
21
|
- **Inline flow** — consecutive inline-level children form an anonymous inline
|
|
19
22
|
formatting context with greedy, word-based line breaking, `text-align` and
|
|
20
23
|
`line-height`. Inline elements get the union of their descendants' geometry;
|
|
@@ -23,6 +26,10 @@ with absolute (viewport-relative) geometry:
|
|
|
23
26
|
that overlap it, so later lines wrap around them.
|
|
24
27
|
Each text fragment remembers the run it covers, so paint can shape it. Text is
|
|
25
28
|
measured with the stb_truetype stack (see [Text stack](./rendering.md#text-stack-m4b)).
|
|
29
|
+
`white-space: nowrap` stops a run from wrapping at spaces (a source newline
|
|
30
|
+
collapses to a space); `text-overflow: ellipsis` on a box whose `overflow` is
|
|
31
|
+
not `visible` replaces the part of an overflowing line that does not fit with
|
|
32
|
+
a single U+2026 ellipsis and drops the rest.
|
|
26
33
|
- **Flexbox** — `row`/`column` (and the `-reverse` variants) with `gap`,
|
|
27
34
|
`flex-basis`/`flex-grow`/`flex-shrink`, `justify-content` and `align-items`
|
|
28
35
|
(including `stretch` when the cross size is definite). On both axes the main
|
|
@@ -99,7 +106,13 @@ with absolute (viewport-relative) geometry:
|
|
|
99
106
|
enclose them.
|
|
100
107
|
- **`overflow` clipping** — a box with `overflow: hidden` (or `scroll`/`auto`)
|
|
101
108
|
clips its subtree to its padding box, intersected with any ancestor clip; the
|
|
102
|
-
renderer applies the result with a GPU scissor rectangle.
|
|
109
|
+
renderer applies the result with a GPU scissor rectangle. A `border-radius`
|
|
110
|
+
rounds that clip: the padding box becomes a triangulated polygon that joins
|
|
111
|
+
the `clip-path` intersection, so a circular avatar frame trims the square
|
|
112
|
+
artwork inside it instead of only cutting the corners off its bounding box.
|
|
113
|
+
The same radius clips the box's own background images/gradients and replaced
|
|
114
|
+
content (`<img>`, `<canvas>`, `<video>`, inline `<svg>`), so a bare
|
|
115
|
+
`border-radius: 50%` rounds an image even without `overflow`. There is no
|
|
103
116
|
scrolling yet, so `scroll`/`auto` clip like `hidden`.
|
|
104
117
|
|
|
105
118
|
Not yet implemented: parent/child and empty-block margin collapsing, anonymous
|
package/doc/gui/rendering.md
CHANGED
|
@@ -11,8 +11,10 @@ emits a backend-agnostic `DisplayList`: a painter-order `ops` list of
|
|
|
11
11
|
**text runs** (each carrying its text, colour and resolved `FontSpec`) and
|
|
12
12
|
**images**, backed by parallel payload arrays. Each op also carries the active
|
|
13
13
|
clip rectangle (the padding box of the nearest `overflow: hidden` ancestor) and
|
|
14
|
-
up to
|
|
15
|
-
`
|
|
14
|
+
up to four indices into the display list's triangulated clip polygons — CSS
|
|
15
|
+
`clip-path` shapes plus the rounded padding boxes of `overflow` ancestors with a
|
|
16
|
+
`border-radius` — so `overflow`/`clip-path` clipping and `z-index` ordering
|
|
17
|
+
survive into the renderer, and a circular avatar frame really is a circle.
|
|
16
18
|
`DisplayList::dump()` feeds `paintList()`/`paintCount()`.
|
|
17
19
|
|
|
18
20
|
`opacity` multiplies the alpha of every colour painted by the box and its
|
|
@@ -28,7 +30,9 @@ Hiding and revealing a layer with `opacity: 0` on the hidden state is what
|
|
|
28
30
|
per window (shapes, glyph quads and images) and merges consecutive ops that
|
|
29
31
|
share a pipeline, clip and texture into **draw runs**. Each run is drawn with
|
|
30
32
|
its own GPU scissor rectangle (scaled to device pixels), so painter order and
|
|
31
|
-
`overflow` clipping are applied per op through the SDL_GPU graphics pipelines
|
|
33
|
+
`overflow` clipping are applied per op through the SDL_GPU graphics pipelines;
|
|
34
|
+
the scissor is only the bounding rectangle, while rounded `overflow` clips and
|
|
35
|
+
`clip-path` shapes are cut into the vertex geometry described below:
|
|
32
36
|
|
|
33
37
|
- The shared pipelines are created lazily from the device's supported shader
|
|
34
38
|
format. Each of SDL_GPU's three backends consumes a different binary and none
|
|
@@ -154,12 +158,15 @@ therefore shows as a `backdrop …` op in `paintList()`.
|
|
|
154
158
|
|
|
155
159
|
**`clip-path`** is resolved in `paint_clip.cpp` to a device-space polygon (the
|
|
156
160
|
box transform is applied to every point), triangulated with ear clipping, and
|
|
157
|
-
stored on `DisplayList::clip_paths`.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
stored on `DisplayList::clip_paths`. A rounded `overflow` clip uses the same
|
|
162
|
+
representation: each corner is a short chord approximation, so the polygon is
|
|
163
|
+
convex and the scissor rectangle is only its bounding box. Ops carry up to four
|
|
164
|
+
path indices on their `PaintClip`; `renderer_clip.cpp` intersects each convex
|
|
165
|
+
shape/glyph/image quad with those triangles at upload time (the quad is clipped
|
|
166
|
+
by one path, and each resulting piece by the next). The result is exact even
|
|
167
|
+
for concave `polygon()` shapes, needs no stencil or shader change, and the edges
|
|
168
|
+
are hard (no analytic antialiasing). Nesting deeper than four shapes keeps the
|
|
169
|
+
outermost four.
|
|
163
170
|
|
|
164
171
|
**`filter`** colour functions (`brightness`, `contrast`, `grayscale`, `sepia`,
|
|
165
172
|
`invert`, `saturate`, `hue-rotate`, `opacity`) are folded into each painted
|
|
@@ -7,3 +7,11 @@ Location: `src/extensions/node/crypto/index.ts`, `runtime/ext_node/crypto/crypto
|
|
|
7
7
|
- `createHash(algorithm)` returns a hash object with `update(...)` and `digest([encoding])`.
|
|
8
8
|
- The streaming form (`setEncoding` / `write` / `end` / `read`) is supported.
|
|
9
9
|
- SHA-1 and SHA-256 are available.
|
|
10
|
+
- `randomBytes(size[, callback])`, `randomUUID()`, `randomInt([min, ]max[, callback])`,
|
|
11
|
+
`randomFillSync(buffer[, offset[, size]])` and `randomFill(...)` read the OS
|
|
12
|
+
CSPRNG (`BCryptGenRandom` on Windows, `/dev/urandom` elsewhere). `webcrypto`
|
|
13
|
+
exposes the same `getRandomValues` / `randomUUID` object as the global
|
|
14
|
+
`crypto`.
|
|
15
|
+
- `pbkdf2Sync(password, salt, iterations, keylen[, digest])` and
|
|
16
|
+
`pbkdf2(...)` implement PBKDF2-HMAC-SHA1/SHA-256 (the async form invokes the
|
|
17
|
+
callback immediately; the work is synchronous).
|
|
@@ -18,7 +18,7 @@ Location: `src/extensions/node/fs/*.ts`, `runtime/ext_node/fs/*.c`
|
|
|
18
18
|
| `rmSync(path[, options])` | `xt_node_rm` | delete a file/directory; `{ recursive: true }` deletes recursively |
|
|
19
19
|
| `rmdirSync(path[, options])` | `xt_node_rmdir` | delete an empty directory |
|
|
20
20
|
| `unlinkSync(path)` | `xt_node_unlink` | delete a file |
|
|
21
|
-
| `renameSync(oldPath, newPath)` | `xt_node_rename` | rename / move |
|
|
21
|
+
| `renameSync(oldPath, newPath)` | `xt_node_rename` | rename / move; atomically replaces an existing target (`MoveFileExW` + `MOVEFILE_REPLACE_EXISTING` on Windows) |
|
|
22
22
|
| `copyFileSync(src, dest[, flags])` | `xt_node_copy_file` | copy a file; honours `COPYFILE_EXCL` |
|
|
23
23
|
| `cpSync(src, dest[, options])` | `xt_node_cp` | recursive copy; `recursive`, `force`, `errorOnExist`, `dereference`, `preserveTimestamps` |
|
|
24
24
|
| `realpathSync(path)` | `xt_node_realpath` | resolve to an absolute path |
|
|
@@ -37,17 +37,19 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
37
37
|
|
|
38
38
|
## JSON
|
|
39
39
|
|
|
40
|
-
- `JSON.parse` with a `reviver`.
|
|
40
|
+
- `JSON.parse` with a `reviver`; malformed input (bad numbers/strings, trailing text, missing separators) throws a catchable `SyntaxError` instead of returning `undefined`.
|
|
41
41
|
- `JSON.stringify` with a function or array `replacer`, `toJSON`, and `space` (number or string, clamped to 10). `undefined` / function / symbol values follow the standard omission rules.
|
|
42
42
|
- Object keys are emitted in insertion order, with integer keys ordered numerically; circular references throw.
|
|
43
43
|
|
|
44
44
|
## Date
|
|
45
45
|
|
|
46
46
|
- `Date` backed by `gmtime_r`; ISO 8601 parsing through `Date.parse` / `new Date(string)`.
|
|
47
|
+
- `toLocaleDateString` / `toLocaleTimeString` / `toLocaleString` format the local time (`M/D/YYYY`, `h:mm:ss AM`); a small options subset (`weekday`/`year`/`month`/`day`/`hour`/`minute`/`second`/`hour12`) is honoured. `toDateString` / `toTimeString` / `toUTCString` are available too, and an invalid date formats as `Invalid Date`.
|
|
47
48
|
|
|
48
49
|
## RegExp
|
|
49
50
|
|
|
50
|
-
- `RegExp` uses POSIX
|
|
51
|
+
- `RegExp` uses the runtime's self-contained POSIX-ERE-compatible matcher (`regcomp` / `regexec` style) on every host, so results do not depend on the platform's libc. Capture groups are exposed through `exec` / `match` / `replace` / `split` / `search`.
|
|
52
|
+
- Quantifiers include `*`, `+`, `?` and the counted forms `{n}`, `{n,}` and `{n,m}` (with a lazy `?` suffix). Malformed brace groups such as `{x}` and `{,2}` stay literal, as in JavaScript; an inverted range such as `{2,1}` is also treated as literal instead of being rejected.
|
|
51
53
|
- Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
|
|
52
54
|
|
|
53
55
|
## Symbol
|
|
@@ -94,3 +96,9 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
94
96
|
- `btoa` / `atob` base64 encoding and decoding (core globals; not Node-extension-only).
|
|
95
97
|
- `structuredClone`: arrays, objects, `Map`, `Set`, `Date`, `RegExp` and typed arrays, preserving cycles and shared references; functions, symbols, promises and generators are rejected.
|
|
96
98
|
- Timers, `queueMicrotask` and `performance.now` are described in [Async, promises and generators](./async.md); `fetch` in [fetch](./fetch.md).
|
|
99
|
+
|
|
100
|
+
## Global crypto
|
|
101
|
+
|
|
102
|
+
- `crypto.getRandomValues(typedArray)` fills an integer typed array (up to 65 536 bytes) from the OS CSPRNG and returns it; `crypto.randomUUID()` returns a v4 UUID string. `crypto` is also a first-class object and the methods can be detached (`const uuid = crypto.randomUUID`).
|
|
103
|
+
- `Math.random` draws from a xoshiro256** stream seeded from the OS CSPRNG (53 random bits), not from the C `rand()`.
|
|
104
|
+
- Node's `crypto.randomBytes` / `randomInt` / `randomFillSync` / `pbkdf2Sync` surface is documented in [node/crypto](../implemented/node/crypto.md).
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -43,7 +43,9 @@ API 编写的文档可以原样运行。
|
|
|
43
43
|
提升操作系统窗口并置位 `document.hasFocus()`,`blur()` 清除它。事件:
|
|
44
44
|
`ready`(首帧呈现后)、`load`、`close`、`resize`、`scroll`、`focus`、`blur`,
|
|
45
45
|
以及输入事件 `mousemove`、`mousedown`、`mouseup`、`click`、`wheel`、
|
|
46
|
-
`keydown`、`keyup
|
|
46
|
+
`keydown`、`keyup`、`keypress`、`textInput`、
|
|
47
|
+
`compositionstart` / `compositionupdate` / `compositionend`、`beforeinput`、
|
|
48
|
+
`input`、`change`、`submit` 与 `reset`。
|
|
47
49
|
|
|
48
50
|
`createWindow(options)` 除标题与尺寸外还支持:`{ title, width, height,
|
|
49
51
|
highDensity, resizable, borderless, alwaysOnTop, hidden, fullscreen, x, y,
|
|
@@ -171,6 +173,8 @@ win.on("keydown", (e) => console.log(e.key, e.code, e.ctrlKey, e.shiftKey));
|
|
|
171
173
|
| `key`、`code` | keyboard | 浏览器 `KeyboardEvent` 写法:产生的值与物理键 |
|
|
172
174
|
| `repeat`、`ctrl`、`shift`、`alt`、`meta` | keyboard | 修饰键(旧版 DOM 写法) |
|
|
173
175
|
| `ctrlKey`、`shiftKey`、`altKey`、`metaKey` | keyboard | 修饰键(现行 DOM 写法) |
|
|
176
|
+
| `data` | composition | 预编辑文本(`compositionstart`/`update`/`end`) |
|
|
177
|
+
| `text` | `textInput` | IME/键盘布局实际产生的文本 |
|
|
174
178
|
| `target` | pointer、wheel | 该点下最深的元素,表示为类 CSS 描述符(`div#main.card`),可能缺省 |
|
|
175
179
|
|
|
176
180
|
## 诊断
|
|
@@ -189,7 +193,9 @@ win.inlineSvg(selector) // 序列化的内联 <svg>:{ markup, w
|
|
|
189
193
|
win.measureText(text, fontSize?, family?) // 整形后的推进宽度(像素)
|
|
190
194
|
win.fontMetrics(fontSize?, family?) // { ascent, descent, lineHeight, ready }
|
|
191
195
|
win.hitTest(x, y) // 最深的元素描述符,或 ""
|
|
192
|
-
win.sendEvent(type, options?) //
|
|
196
|
+
win.sendEvent(type, options?) // 合成输入(测试用);也支持
|
|
197
|
+
// "textInput" + { text } 与
|
|
198
|
+
// "composition*" 事件 + { data }
|
|
193
199
|
win.advance(ms) // 推进 CSS transition 时钟(测试用)
|
|
194
200
|
win.stats() // 引擎/运行时计数器(内存排查用)
|
|
195
201
|
```
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
**HTML 解析器**(`runtime/ext_gui/dom.{h,cpp}`):标签/属性/文本,注释与
|
|
11
11
|
doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素,原始文本元素
|
|
12
12
|
(`<style>`/`<script>`),以及常见的隐式闭合规则(`li`、`dt`/`dd`、`option`、
|
|
13
|
-
`p
|
|
13
|
+
`p`、标题、表格单元格/行)。解析片段时会补上隐式的 `<html>`/`<head>`/`<body>`
|
|
14
|
+
(顶层 `<style>`/`<title>` 等进入 `<head>`,其余进入 `<body>`),因此即使源文件
|
|
15
|
+
只有一个 `<div>`,`document.body`、`document.head` 与 `body { … }` 也能工作。
|
|
16
|
+
`innerHTML`/`insertAdjacentHTML` 按片段解析,**不会**再合成一层文档包装。
|
|
14
17
|
|
|
15
18
|
**CSS 解析器**(`runtime/ext_gui/css.{h,cpp}`):会剥离注释;`@media` 块递归解析
|
|
16
19
|
(嵌套查询用 `and` 合并,逗号列表会分配到内层查询),其他 at-rule 跳过。规则支持
|
|
@@ -20,14 +23,17 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
20
23
|
(`=`、`~=`、`|=`、`^=`、`$=`、`*=`)、四种组合器(后代、子、相邻兄弟与
|
|
21
24
|
通用兄弟)、伪类 `:first-child`、`:last-child`、`:only-child`、`:empty`、
|
|
22
25
|
`:root`、`:not(...)`、`:nth-child(an+b)`、`:disabled`、`:checked`、有状态的
|
|
23
|
-
`:hover`、`:focus`、`:focus-visible`(目前等同 `:focus
|
|
26
|
+
`:hover`、`:focus`、`:focus-visible`(目前等同 `:focus`)、`:focus-within`
|
|
27
|
+
(聚焦元素及其祖先)与 `:active`
|
|
24
28
|
(见[输入](./input.md)),以及伪元素
|
|
25
29
|
`::before`/`::after`(也接受旧式 `:before`/`:after`)。值:长度
|
|
26
30
|
(`px`、`%`、`em`、`rem`、`vw`、`vh`、`pt`、`pc`、`in`、`cm`、`mm`、`q`)、
|
|
27
31
|
颜色(十六进制、`rgb()`/`rgba()`、一个命名子集)、数字、关键字与简写
|
|
28
32
|
(`margin`/`padding`/`border`/`flex`/`font`/`outline`)。
|
|
29
33
|
`display: inline-flex`/`inline-grid` 生成行内级 flex/grid 容器;`grid-area`、
|
|
30
|
-
`aspect-ratio`、`letter-spacing`、`text-transform`、`
|
|
34
|
+
`aspect-ratio`、`letter-spacing`、`text-transform`、`text-overflow`
|
|
35
|
+
(`clip`/`ellipsis`)、`white-space`
|
|
36
|
+
(`normal`/`nowrap`/`pre`/`pre-wrap`/`pre-line`)、`writing-mode`
|
|
31
37
|
(`vertical-rl`/`vertical-lr` 文本)、`vertical-align`(长度形式)、百分比
|
|
32
38
|
`border-radius`、`background-size`(`url()` 图层按尺寸与默认 repeat 平铺)与
|
|
33
39
|
`currentColor` 都已支持。`font-variant-numeric`、`text-wrap`、`text-rendering`、
|
|
@@ -61,6 +67,63 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
61
67
|
之前/之后;遍历、查询、`innerHTML` 与 `elementIndex()` 永远看不到它,命中测试
|
|
62
68
|
则指向原始元素。
|
|
63
69
|
|
|
70
|
+
### 不支持的特性会给出提示
|
|
71
|
+
|
|
72
|
+
上面的子集是一条边界,但不是一条静默的边界。文档其余部分仍然会渲染——不支持的
|
|
73
|
+
元素会变成普通盒子(`<template>` 这类标签则保持隐藏),不支持的声明会被丢弃——
|
|
74
|
+
但每个名字的第一次使用会输出到 stderr:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
xt_gui: warning: unsupported element <table>; the engine has no browser behaviour for it
|
|
78
|
+
xt_gui: warning: unsupported CSS property 'gap'; it is ignored
|
|
79
|
+
xt_gui: warning: unsupported at-rule '@supports'; its rule is ignored
|
|
80
|
+
xt_gui: warning: unsupported pseudo-class ':has'; it never matches
|
|
81
|
+
xt_gui: warning: unsupported CSS unit 'vmin'; the value is ignored
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
报告按名字在整个进程内去重:一个被多条规则使用的属性,或每行重复出现的表格
|
|
85
|
+
单元格,只会出现一次。解析/层叠路径会报告:
|
|
86
|
+
|
|
87
|
+
- **HTML 元素**:引擎缺少其浏览器行为的标签——`applet`、`area`、`basefont`、
|
|
88
|
+
`bgsound`、`blink`、`caption`、`col`、`colgroup`、`datalist`、`details`、
|
|
89
|
+
`dialog`、`embed`、`frame`、`frameset`、`iframe`、`isindex`、`keygen`、`map`、
|
|
90
|
+
`marquee`、`math`、`meter`、`noembed`、`noframes`、`object`、`output`、`param`、
|
|
91
|
+
`plaintext`、`progress`、`summary`、`table`、`tbody`、`td`、`template`、`tfoot`、
|
|
92
|
+
`th`、`thead`、`tr`、`track` 与 `xmp`。其余标签——包括 `button`、`input`、
|
|
93
|
+
`label`、`select`、`textarea`、自定义元素以及 `<dvi>` 这类拼写错误——都会渲染
|
|
94
|
+
成盒子,这是预期的回退而不是被丢弃的特性,因此不会报告。
|
|
95
|
+
- **HTML 特性(attribute)**:请求了不支持行为的 `href`(链接不会导航)、
|
|
96
|
+
`srcset`、`sizes`、`poster`、`controls`、`contenteditable`、`draggable`、
|
|
97
|
+
`autofocus`、`hidden`,以及 SVG 的
|
|
98
|
+
`filter`/`mask`/`clip-path`/`marker-*` 特性。
|
|
99
|
+
- **CSS 属性**:子集之外的属性名;以及解析器未实现的长度单位(`ch`、`ex`、
|
|
100
|
+
`vmin`、`dvh` 等)。已支持属性上的非法值不会按“不支持”报告——只检查属性的
|
|
101
|
+
*名字*。
|
|
102
|
+
- **CSS at-rule**:`@media`、`@font-face`、`@keyframes`(含厂商前缀拼写)之外的
|
|
103
|
+
at-rule,例如 `@supports`、`@layer`、`@container`、`@import`。
|
|
104
|
+
- **`@font-face` 描述符**:`font-family`、`src`、`font-weight`、`font-style`
|
|
105
|
+
之外的描述符(`font-display`、`unicode-range` 等)。
|
|
106
|
+
- **选择器**:不支持的伪类(`:has`、`:is`、`:where`、`:nth-of-type` 等)、
|
|
107
|
+
不支持的伪元素(`::selection`、`::marker` 等),以及解析器不得不丢弃的
|
|
108
|
+
选择器。
|
|
109
|
+
- **媒体查询**:未知特性(`min-resolution`、`aspect-ratio` 等)会按不匹配处理并
|
|
110
|
+
报告。
|
|
111
|
+
- **CSS 函数**:已支持属性里出现引擎未实现的函数——`hsl()`/`oklch()` 等颜色、
|
|
112
|
+
`perspective()`/`rotateX()` 等变换、`url()` 滤镜、`path()` 裁剪形状、
|
|
113
|
+
`conic-gradient()` 背景、`counter()` 生成内容。不支持的函数会使整条声明失效。
|
|
114
|
+
- **SVG 元素**:NanoSVG 不渲染的 `<text>`、`<use>`、`<filter>` 及其 `fe*`
|
|
115
|
+
原语、`<mask>`、`<clipPath>`、`<pattern>`、`<marker>`、`<image>`、
|
|
116
|
+
`<foreignObject>` 与动画元素。内联 `<svg>` 在序列化用于绘制时报告;
|
|
117
|
+
`<img src="…svg">` 文件直接交给 NanoSVG,不经过这项检查。
|
|
118
|
+
|
|
119
|
+
`XT_GUI_NO_WARNINGS=1` 可以关闭这些报告。在 Windows 上,GUI 程序是
|
|
120
|
+
Windows 子系统可执行文件,只有设置 `app.console: true` 时才能看到 stderr
|
|
121
|
+
(见 [API](./api.md))。这些警告不影响退出状态。
|
|
122
|
+
|
|
123
|
+
这是解析/层叠路径的审计,不是完整 API 审计:已支持属性上的不支持*值*
|
|
124
|
+
(例如 `display: contents`)、有意空实现的 DOM 方法和后端未实现的 WebGL 入口
|
|
125
|
+
仍然保持静默(Canvas 与 WebGL 页面记录了各自的子集)。
|
|
126
|
+
|
|
64
127
|
## 交互式 DOM(M8)
|
|
65
128
|
|
|
66
129
|
`win.document` 返回文档句柄;元素句柄具有稳定标识,并提供可读写的属性、
|
|
@@ -115,7 +178,10 @@ console.log(box.contains(inner)); // 后代判断
|
|
|
115
178
|
`getComputedStyle(el, pseudoElt)` 从**层叠结果**读取——UA 样式表、作者规则、
|
|
116
179
|
继承和内联声明——而不是回显内联块,因此写在样式表里的规则同样可见。它支持
|
|
117
180
|
`getPropertyValue`、`getPropertyPriority` 与命名属性(`cs.width`、
|
|
118
|
-
`cs.backgroundColor`、`cs["--accent"]
|
|
181
|
+
`cs.backgroundColor`、`cs["--accent"]`)。边框属性也按边序列化:
|
|
182
|
+
`border-top-color` / `border-right-color` / … 会把 `currentColor` 解析为元素
|
|
183
|
+
计算颜色,`border-*-width` 对 `none` 边框报告实际使用的 `0px`,
|
|
184
|
+
`border-*-style` 报告计算后的样式关键字。传入 `"::before"` 或 `"::after"`
|
|
119
185
|
可读取生成内容盒;其他伪元素返回空值。每次读取都会先结算待处理的重新样式,
|
|
120
186
|
因此早先创建的句柄在后续变更后仍然有效。
|
|
121
187
|
|
package/doc/zh-CN/gui/input.md
CHANGED
|
@@ -11,18 +11,79 @@
|
|
|
11
11
|
出来**的位置被命中——`:hover` 跟着画面走,而不是跟着流式布局留下的盒子走。
|
|
12
12
|
|
|
13
13
|
- SDL 指针/滚轮/键盘事件会被路由到所属窗口,进行命中测试,并投递给用 `on`
|
|
14
|
-
注册的处理器。`mousedown`
|
|
14
|
+
注册的处理器。`mousedown` 还会移动焦点,并在文本框中放置光标。
|
|
15
15
|
- 键盘事件同时走 DOM 路径:目标为聚焦元素(没有焦点时为 `<body>`),事件沿祖先
|
|
16
16
|
冒泡到 `document`,最后到达 `window` 监听器。因此按浏览器写的
|
|
17
17
|
`document.addEventListener("keydown", …)` 可以直接工作。负载使用浏览器
|
|
18
18
|
`KeyboardEvent` 的写法:`code` 是物理键(`"KeyW"`、`"ArrowUp"`、`"Space"`),
|
|
19
19
|
`key` 是产生的值(`"w"`、`"W"`、`" "`),而不是 SDL 的扫描码/键名。
|
|
20
20
|
- `:hover` 匹配悬停元素**及其祖先**(因此悬停子元素会点亮其父元素);
|
|
21
|
-
`:focus`
|
|
22
|
-
|
|
21
|
+
`:focus` 匹配聚焦元素,`:focus-within` 同时匹配其祖先。当任一改变时,
|
|
22
|
+
`XtDocument::setHover`/`setFocus` 重新计算样式与布局,并把窗口几何标记为
|
|
23
|
+
脏,因此改动会在下一帧绘制。
|
|
23
24
|
- `win.hitTest(x, y)` 与 `win.sendEvent(type, options)` 暴露命中测试与合成
|
|
24
25
|
输入,使整条路径可无头测试(e2e 套件在没有真实鼠标的情况下驱动点击、滚轮
|
|
25
26
|
与按键)。
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
## 表单控件(M23)
|
|
28
29
|
|
|
30
|
+
`<input>`、`<textarea>` 与 `<select>` 是引擎原生的叶子盒:值、选区与勾选状态
|
|
31
|
+
保存在 `Node::form`(`FormState`)中,由引擎绘制,不涉及浏览器/DOM 层。
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const user = document.getElementById("user"); // <input id="user" value="abc">
|
|
35
|
+
user.focus();
|
|
36
|
+
user.value; // "abc"
|
|
37
|
+
user.selectionStart; // 3
|
|
38
|
+
user.setSelectionRange(1, 3);
|
|
39
|
+
user.placeholder = "name";
|
|
40
|
+
user.disabled = true;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **`<input>` 类型**:`text`、`search`、`tel`、`url`、`email`、`password`、
|
|
44
|
+
`number`、`date`、`month`、`week`、`time`、`datetime-local`、`range`、`color`、
|
|
45
|
+
`checkbox`、`radio`、`file`、`submit`、`reset`、`button`、`image` 与 `hidden`。
|
|
46
|
+
文本类可编辑;checkbox/radio 绘制方框并在点击时切换(radio 会取消同 `name`
|
|
47
|
+
组的其它项);range 绘制轨道与滑块并支持拖动;color 绘制色块;
|
|
48
|
+
submit/reset/button 绘制标签;`hidden` 不产生盒。
|
|
49
|
+
- **`<textarea>`** 支持多行(`\n` 换行),**`<select>`** 绘制当前 `<option>`
|
|
50
|
+
的标签,点击切换选项(没有弹出菜单)。`date`/`time`/`month`/`week` 输入框
|
|
51
|
+
是按浏览器值格式编辑的文本框;`color`/`file` 暴露值/状态,但不会打开原生
|
|
52
|
+
取色器或文件对话框。
|
|
53
|
+
- **`value`** 是活动值,与 `value` 属性(默认值)分离。`<textarea>` 的默认值
|
|
54
|
+
来自其文本内容,`<select>` 来自被选中/第一个 `<option>`。给 `value` 赋值会
|
|
55
|
+
把光标移到末尾,与浏览器一致。
|
|
56
|
+
- **`selectionStart` / `selectionEnd` / `selectionDirection`**、
|
|
57
|
+
`setSelectionRange(start, end, direction)` 与 `select()` 使用 UTF-16 码元
|
|
58
|
+
偏移(DOM 约定),底层存储为 UTF-8。
|
|
59
|
+
- **`checked`**、`type`、`name`、`disabled`、`readOnly`、`required`、
|
|
60
|
+
`placeholder`、`min`、`max`、`step`、`maxLength`、`tabIndex`、`form`、
|
|
61
|
+
`options` 与 `selectedIndex` 均为活动 DOM 属性。
|
|
62
|
+
- **`document.activeElement`** 是聚焦元素;没有焦点时为 `<body>`。`tabindex`
|
|
63
|
+
决定 Tab 顺序(`tabindex="1"` 排在隐式 `0` 之前;`-1` 可点击聚焦但被 Tab
|
|
64
|
+
跳过);即使没有文本框聚焦,Tab 与 Shift+Tab 也能移动焦点。禁用或隐藏的控件
|
|
65
|
+
不能聚焦、会被 Tab 跳过,并以灰色绘制。
|
|
66
|
+
- **文本输入**来自 `SDL_EVENT_TEXT_INPUT`,它携带键盘布局或 IME 实际产生的
|
|
67
|
+
文本。`keydown` 处理编辑命令(Backspace/Delete/方向键/Home/End/Ctrl+A/C/X/V,
|
|
68
|
+
Shift 扩展选区),编辑后派发 `keypress` 与 `input`。
|
|
69
|
+
- **IME** 使用 `SDL_EVENT_TEXT_EDITING`:预编辑文本显示在光标处,并触发
|
|
70
|
+
`compositionstart` / `compositionupdate` / `compositionend`;提交内容在
|
|
71
|
+
`compositionend` 时插入值中。
|
|
72
|
+
- **剪贴板**通过 SDL 使用系统剪贴板:Ctrl+C/X/V。
|
|
73
|
+
- **事件**自动派发:文本编辑前触发可取消的 `beforeinput`,每次值变化后触发
|
|
74
|
+
`input`(输入、删除、checkbox/radio 切换、range 拖动、select 切换),值提交时
|
|
75
|
+
触发 `change`(有改动的文本框失焦、单行输入框回车、checkbox/radio 点击、
|
|
76
|
+
range 释放或 select 切换)。`input`/`change` 负载携带 `value`;`change` 还
|
|
77
|
+
携带 `checked`。
|
|
78
|
+
- **表单**:提交按钮(或单行输入框回车)在所属 `<form>` 上触发可取消的
|
|
79
|
+
`submit`,被点击时携带 `submitter`;引擎不会导航,因此是否阻止事件在视觉上
|
|
80
|
+
没有区别。重置按钮或 `form.reset()` 触发 `reset`,并把每个控件恢复到默认
|
|
81
|
+
值/勾选状态。`form.submit()` 与 `form.requestSubmit(submitter?)` 派发同一个
|
|
82
|
+
事件。
|
|
83
|
+
|
|
84
|
+
`win.sendEvent` 也接受 `{ type: "textInput", text }`(等同于 SDL 投递该文本)、
|
|
85
|
+
`{ type: "compositionstart" | "compositionupdate" | "compositionend", data }` 与
|
|
86
|
+
可打印的 `keydown`。真实的物理 `keydown` 不会插入其 US 布局的 `key`:对应的
|
|
87
|
+
文本输入事件才会插入,因此 IME 或非 US 布局不会重复字符。
|
|
88
|
+
|
|
89
|
+
完整输入仍需完成:跨多行的拖动选择与撤销/重做。
|
|
@@ -48,15 +48,21 @@
|
|
|
48
48
|
`tests/e2e/gui-example-browser.test.ts` 中。
|
|
49
49
|
- **`display: none -> flex` 的重排。** 通过类名切换让隐藏元素显示在 flex 容器上时,也曾观察
|
|
50
50
|
到同样的崩溃;`examples/gui/pelican-bike` 改用 `opacity` 显示游戏结束遮罩。
|
|
51
|
-
- **CSS 覆盖范围是有意为之的子集。**
|
|
51
|
+
- **CSS 覆盖范围是有意为之的子集。** 不支持的属性名、at-rule、选择器、函数、
|
|
52
|
+
单位、特性(attribute)以及
|
|
53
|
+
[DOM](./dom.md#不支持的特性会给出提示) 中列出的元素,会在 stderr 上报告一次,
|
|
54
|
+
而不是被静默丢弃,因此从 Web 移植的页面能看出回退掉了什么。已实现
|
|
55
|
+
Grid、`calc()`(含嵌套算术及
|
|
52
56
|
`min()`/`max()`/`clamp()` 内的 `calc()`)、`clamp()`/`min()`/`max()`/`env()`、
|
|
53
57
|
`var()` 自定义属性、`inset` 简写、`box-sizing`、`visibility`/`pointer-events`、
|
|
54
58
|
`@media` 查询、生成内容(`::before`/`::after`)、线性/径向多层背景、
|
|
55
59
|
`text-shadow`(真正的高斯)、`box-shadow`(外阴影/内阴影、spread、多层)、
|
|
56
60
|
`clip-path`(`inset`/`circle`/`ellipse`/`polygon`)、`filter` 颜色函数、
|
|
57
61
|
`@keyframes` 动画、完整的 `transition` 时间函数、`letter-spacing`、
|
|
58
|
-
`text-transform
|
|
59
|
-
|
|
62
|
+
`text-transform`、`white-space: nowrap`、`text-overflow: ellipsis`、行内级
|
|
63
|
+
`flex`/`grid`、`grid-area`、`aspect-ratio`、自动
|
|
64
|
+
外边距、百分比 `border-radius`(含对子元素与替换内容的圆角 `overflow` 裁剪)、
|
|
65
|
+
`outline`、`url()` 图层的 `background-size`
|
|
60
66
|
平铺,以及 SVG 子元素上的文档 CSS(`fill`/`stroke`/…)均已实现。仍有限制:
|
|
61
67
|
`background-clip`、`background-position`、`background-repeat` 未实现
|
|
62
68
|
(`background-size` 只覆盖默认平铺场景);`font-variant-numeric`、
|
|
@@ -67,7 +73,8 @@
|
|
|
67
73
|
近似而非真正的组合成;D3D12/DXIL 后端没有混合与 `backdrop-filter` 合成器,
|
|
68
74
|
那里会退回普通 source-over 绘制并跳过背景滤镜。`filter: blur()` 仍是按图形做
|
|
69
75
|
九次偏移的近似,而不是真正的组模糊,重叠的子元素会加深;`drop-shadow` 用盒子
|
|
70
|
-
|
|
76
|
+
轮廓近似;最多只交叉四层裁剪形状(CSS `clip-path` 与圆角 `overflow` 盒一起
|
|
77
|
+
计算;更深时保留外侧四层);
|
|
71
78
|
图像/画布除图像着色器能携带的亮度与透明度染色外不做颜色滤镜。Canvas 纹理使用
|
|
72
79
|
最近邻采样。背景渐变(线性与径向)都逐像素光栅化成纹理,盒子大于纹理时再拉伸
|
|
73
80
|
(径向每边最大 1024 px;线性沿渐变线最大 4096 px,且沿渐变线之外只有一像素厚),
|
package/doc/zh-CN/gui/layout.md
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
几何信息的 `LayoutBox` 树:
|
|
11
11
|
|
|
12
12
|
- **块级流** —— 块级子元素垂直堆叠;`display: none`
|
|
13
|
-
不生成盒;`width: auto` 填满包含块,`height: auto`
|
|
13
|
+
不生成盒;`width: auto` 填满包含块,`height: auto` 包裹内容。百分比
|
|
14
|
+
`height` 相对包含块**确定**的内容高度解析(由 `height`/`clamp()` 定尺的
|
|
15
|
+
框架会把已用高度传给子元素);当整条链上都没有确定高度时,百分比按 `auto`
|
|
16
|
+
处理。盒模型
|
|
14
17
|
(margin/padding/border)会被解析,包括相对包含块宽度的百分比。相邻兄弟的
|
|
15
18
|
垂直外边距会折叠为 `max(正值) + min(负值)`;父元素的下外边距不会与其最后一个
|
|
16
19
|
子元素折叠(见下方限制)。
|
|
@@ -19,7 +22,10 @@
|
|
|
19
22
|
的并集;`display: inline-block` 以 shrink-to-fit 宽度原子化布局。每一行会收缩到
|
|
20
23
|
与之重叠的浮动(`float: left|right`)所留出的空白带,因此后续行会绕开它们。
|
|
21
24
|
每个文本片段会记住它覆盖的 run,以便绘制时对它整形。文本使用 stb_truetype
|
|
22
|
-
技术栈测量(见[文本技术栈](./rendering.md)
|
|
25
|
+
技术栈测量(见[文本技术栈](./rendering.md))。`white-space: nowrap`
|
|
26
|
+
让一段文本不在空格处换行(源码换行会折叠为空格);在 `overflow` 不是
|
|
27
|
+
`visible` 的盒子上,`text-overflow: ellipsis` 会把溢出线放不下的部分替换为
|
|
28
|
+
单个 U+2026 省略号并丢弃其余内容。
|
|
23
29
|
- **Flexbox** —— `row`/`column`(以及 `-reverse` 变体),支持 `gap`、
|
|
24
30
|
`flex-basis`/`flex-grow`/`flex-shrink`、`justify-content` 与 `align-items`
|
|
25
31
|
(当交叉轴尺寸确定时包括 `stretch`)。两个方向的主轴尺寸都先取
|
|
@@ -78,8 +84,12 @@
|
|
|
78
84
|
会把后续块推到相关浮动的下方,而只包含浮动的块会增高以包裹它们。
|
|
79
85
|
- **`overflow` 裁剪** —— `overflow: hidden`(或 `scroll`/`auto`)的盒子会将其
|
|
80
86
|
子树裁剪到自身的 padding box,并与任一祖先裁剪区域取交集;渲染器用 GPU
|
|
81
|
-
scissor
|
|
82
|
-
|
|
87
|
+
scissor 矩形实现该结果。`border-radius` 会让该裁剪变成圆角:padding box
|
|
88
|
+
成为三角化多边形,加入 `clip-path` 的交集,因此圆形头像框会真正裁掉其中
|
|
89
|
+
的方形图像,而不只是裁掉其包围盒的四角。同一半径也会裁剪盒子自身的
|
|
90
|
+
background 图像/渐变与替换内容(`<img>`、`<canvas>`、`<video>`、内联
|
|
91
|
+
`<svg>`),所以单独的 `border-radius: 50%` 即使没有 `overflow` 也能把图片
|
|
92
|
+
变圆。目前还没有滚动,因此 `scroll`/`auto` 与 `hidden` 一样只做裁剪。
|
|
83
93
|
|
|
84
94
|
尚未实现:父/子与空块的外边距折叠、由非空白文本产生的匿名 flex 项、完整的
|
|
85
95
|
`z-index` 层叠上下文,以及 `float` 对块级子元素的影响(只有行内内容会绕排,
|