xbintsc 0.6.9 → 0.6.10
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/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/driver/config.js +1 -0
- package/dist/src/driver/config.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/tests/driver/config.test.js +15 -2
- package/dist/tests/driver/config.test.js.map +1 -1
- 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-unsupported.test.d.ts +6 -0
- package/dist/tests/e2e/gui-unsupported.test.js +123 -0
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
- package/doc/ai/extensions.md +7 -4
- package/doc/ai/zh-CN/extensions.md +6 -3
- package/doc/gui/dom.md +69 -1
- package/doc/gui/known-issues.md +12 -5
- package/doc/gui/layout.md +19 -6
- package/doc/gui/rendering.md +16 -9
- package/doc/zh-CN/gui/dom.md +61 -1
- 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/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_selector.cpp +23 -0
- package/runtime/ext_gui/css_sheet.cpp +7 -0
- package/runtime/ext_gui/document.cpp +3 -0
- package/runtime/ext_gui/document_animation.cpp +4 -1
- package/runtime/ext_gui/dom_api.cpp +3 -0
- package/runtime/ext_gui/dom_parse.cpp +4 -0
- package/runtime/ext_gui/effect_values.cpp +28 -7
- package/runtime/ext_gui/gradient_values.cpp +25 -5
- package/runtime/ext_gui/inline_svg.cpp +3 -0
- package/runtime/ext_gui/layout_flow.cpp +12 -2
- package/runtime/ext_gui/layout_inline.cpp +80 -7
- package/runtime/ext_gui/media_query.cpp +7 -1
- package/runtime/ext_gui/paint.cpp +58 -23
- package/runtime/ext_gui/paint.h +7 -4
- package/runtime/ext_gui/paint_clip.cpp +74 -19
- package/runtime/ext_gui/paint_internal.h +7 -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 +3 -0
- package/runtime/ext_gui/style_text.cpp +11 -0
- package/runtime/ext_gui/style_values.cpp +89 -90
- package/runtime/ext_gui/transform.cpp +2 -0
- package/runtime/ext_gui/warnings.cpp +300 -0
- package/runtime/ext_gui/warnings.h +59 -0
- package/src/cli/main.ts +1 -0
- package/src/driver/config.ts +1 -0
- package/src/driver/version.ts +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-end tests for the `gui` extension — the warnings that make an
|
|
3
|
+
* unsupported HTML element or CSS property visible instead of silently
|
|
4
|
+
* dropping it.
|
|
5
|
+
*/
|
|
6
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
7
|
+
import { createGuiHarness, guiAvailable } from "./gui-helpers.js";
|
|
8
|
+
const harness = createGuiHarness();
|
|
9
|
+
const PAGE = `
|
|
10
|
+
<html>
|
|
11
|
+
<head>
|
|
12
|
+
<style>
|
|
13
|
+
body { color: #111111; }
|
|
14
|
+
.one { unsupported-one: 1px; color: #222222; }
|
|
15
|
+
.two { unsupported-one: 2px; display: flex; }
|
|
16
|
+
@supports (display: grid) { .supports { color: red; } }
|
|
17
|
+
@layer base { .layer { color: blue; } }
|
|
18
|
+
@import url("https://example.com/x.css");
|
|
19
|
+
@font-face { font-family: "Unused"; font-display: swap; }
|
|
20
|
+
.has:has(.one) { color: green; }
|
|
21
|
+
.selection::selection { color: green; }
|
|
22
|
+
.bad[data-x="y" i] { color: red; }
|
|
23
|
+
@media (min-resolution: 2dppx) { .media { color: green; } }
|
|
24
|
+
.features {
|
|
25
|
+
color: hsl(0 100% 50%);
|
|
26
|
+
width: 10vmin;
|
|
27
|
+
transform: perspective(10px);
|
|
28
|
+
filter: url(#somefilter);
|
|
29
|
+
clip-path: path("M0 0 L10 10 Z");
|
|
30
|
+
background-image: conic-gradient(red, blue);
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<table><tr><td>cell</td></tr></table>
|
|
36
|
+
<input value="x">
|
|
37
|
+
<iframe src="about:blank"></iframe>
|
|
38
|
+
<svg width="20" height="20"><text x="0" y="10">x</text></svg>
|
|
39
|
+
<div class="one">one</div>
|
|
40
|
+
<div class="two">two</div>
|
|
41
|
+
<div class="features has">features</div>
|
|
42
|
+
<div class="layer">layer</div>
|
|
43
|
+
<div class="media">media</div>
|
|
44
|
+
<a href="#top">top</a>
|
|
45
|
+
<div srcset="a.png 1x" sizes="100px" controls contenteditable="true" hidden tabindex="0">attrs</div>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
48
|
+
`;
|
|
49
|
+
const PROGRAM = `
|
|
50
|
+
import { createWindow, run } from "gui";
|
|
51
|
+
|
|
52
|
+
const HTML = ${JSON.stringify(PAGE)};
|
|
53
|
+
|
|
54
|
+
const win = createWindow({ title: "unsupported", width: 320, height: 240 });
|
|
55
|
+
win.on("ready", () => {
|
|
56
|
+
/* A run-time created element is reported too, not just markup from the page. */
|
|
57
|
+
win.document.createElement("select");
|
|
58
|
+
win.document.querySelector(".one").style.setProperty("unsupported-two", "3px");
|
|
59
|
+
win.computedStyle(".one", "color");
|
|
60
|
+
console.log("done=1");
|
|
61
|
+
});
|
|
62
|
+
win.loadHTML(HTML);
|
|
63
|
+
run();
|
|
64
|
+
`;
|
|
65
|
+
function occurrences(text, needle) {
|
|
66
|
+
return text.split(needle).length - 1;
|
|
67
|
+
}
|
|
68
|
+
describe.skipIf(!guiAvailable)("gui extension — unsupported features", () => {
|
|
69
|
+
beforeAll(() => harness.setup());
|
|
70
|
+
afterAll(() => harness.cleanup());
|
|
71
|
+
it("reports each unsupported element and CSS property once", () => {
|
|
72
|
+
const { value, stderr } = harness.compileAndRun("unsupported", PROGRAM, {
|
|
73
|
+
console: true,
|
|
74
|
+
});
|
|
75
|
+
expect(value("done")).toBe("1");
|
|
76
|
+
expect(stderr).toContain("unsupported element <table>");
|
|
77
|
+
expect(stderr).toContain("unsupported element <input>");
|
|
78
|
+
expect(stderr).toContain("unsupported element <iframe>");
|
|
79
|
+
/* Created through `document.createElement`, after the page was parsed. */
|
|
80
|
+
expect(stderr).toContain("unsupported element <select>");
|
|
81
|
+
/* Declared by two rules, but reported as one property name. */
|
|
82
|
+
expect(stderr).toContain("unsupported CSS property 'unsupported-one'");
|
|
83
|
+
/* Set through the CSSOM after the page was parsed. */
|
|
84
|
+
expect(stderr).toContain("unsupported CSS property 'unsupported-two'");
|
|
85
|
+
/* At-rules, selectors, media queries and value functions. */
|
|
86
|
+
expect(stderr).toContain("unsupported at-rule '@supports'");
|
|
87
|
+
expect(stderr).toContain("unsupported at-rule '@layer'");
|
|
88
|
+
expect(stderr).toContain("unsupported at-rule '@import'");
|
|
89
|
+
expect(stderr).toContain("unsupported @font-face descriptor 'font-display'");
|
|
90
|
+
expect(stderr).toContain("unsupported pseudo-class ':has'");
|
|
91
|
+
expect(stderr).toContain("unsupported pseudo-element '::selection'");
|
|
92
|
+
expect(stderr).toContain(`unsupported selector '.bad[data-x="y" i]'`);
|
|
93
|
+
expect(stderr).toContain("unsupported media feature 'min-resolution'");
|
|
94
|
+
expect(stderr).toContain("unsupported function 'hsl()' in 'color'");
|
|
95
|
+
expect(stderr).toContain("unsupported CSS unit 'vmin'");
|
|
96
|
+
expect(stderr).toContain("unsupported function 'perspective()' in 'transform'");
|
|
97
|
+
expect(stderr).toContain("unsupported function 'url()' in 'filter'");
|
|
98
|
+
expect(stderr).toContain("unsupported function 'path()' in 'clip-path'");
|
|
99
|
+
expect(stderr).toContain("unsupported function 'conic-gradient()' in 'background-image'");
|
|
100
|
+
/* SVG children and HTML attributes the engine has no behaviour for. */
|
|
101
|
+
expect(stderr).toContain("unsupported SVG element <text>");
|
|
102
|
+
expect(stderr).toContain("unsupported attribute 'srcset' on <div>");
|
|
103
|
+
expect(stderr).toContain("unsupported attribute 'controls' on <div>");
|
|
104
|
+
expect(stderr).toContain("unsupported attribute 'href' on <a>");
|
|
105
|
+
expect(occurrences(stderr, "unsupported CSS property 'unsupported-one'")).toBe(1);
|
|
106
|
+
expect(occurrences(stderr, "unsupported element <table>")).toBe(1);
|
|
107
|
+
expect(occurrences(stderr, "unsupported element <td>")).toBe(1);
|
|
108
|
+
expect(occurrences(stderr, "unsupported attribute 'srcset' on <div>")).toBe(1);
|
|
109
|
+
/* A property the engine implements is never reported. */
|
|
110
|
+
expect(stderr).not.toContain("unsupported CSS property 'color'");
|
|
111
|
+
expect(stderr).not.toContain("unsupported CSS property 'display'");
|
|
112
|
+
});
|
|
113
|
+
it("can silence the reports with XT_GUI_NO_WARNINGS", () => {
|
|
114
|
+
const { value, stderr } = harness.compileAndRun("unsupported-quiet", PROGRAM, {
|
|
115
|
+
console: true,
|
|
116
|
+
env: { XT_GUI_NO_WARNINGS: "1" },
|
|
117
|
+
});
|
|
118
|
+
expect(value("done")).toBe("1");
|
|
119
|
+
expect(stderr).not.toContain("unsupported element");
|
|
120
|
+
expect(stderr).not.toContain("unsupported CSS property");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=gui-unsupported.test.js.map
|
|
@@ -0,0 +1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C;QACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACpD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/doc/ai/extensions.md
CHANGED
|
@@ -89,10 +89,13 @@ reflowing anything — animate it per frame from `requestAnimationFrame` or with
|
|
|
89
89
|
`transition: transform` (see `examples/gui/pelican-svg`). The CSS subset also
|
|
90
90
|
covers `@media`, `::before`/`::after` generated content, multi-layer linear/radial
|
|
91
91
|
backgrounds, `calc()`, `text-shadow`/`box-shadow` with a true Gaussian blur,
|
|
92
|
-
`clip-path`, `
|
|
93
|
-
|
|
94
|
-
`
|
|
95
|
-
|
|
92
|
+
`clip-path`, rounded `border-radius` clipping (including `overflow: hidden`
|
|
93
|
+
frames and replaced content), `filter` colour effects, `backdrop-filter`
|
|
94
|
+
compositing, `@keyframes` and `transition`/`animation` timing functions,
|
|
95
|
+
`letter-spacing`, `text-transform`, `white-space: nowrap`,
|
|
96
|
+
`text-overflow: ellipsis`, inline-level `flex`/`grid`, `grid-area`,
|
|
97
|
+
`aspect-ratio`, auto margins, percentage heights inside a definite frame,
|
|
98
|
+
percentage `border-radius`, `outline`, tiled `background-size` for
|
|
96
99
|
`url()` layers, document CSS on SVG children and text-only vertical writing
|
|
97
100
|
mode. `filter: blur()` is still a documented approximation. If the archive is
|
|
98
101
|
missing for your platform, the build fails with an actionable message; design
|
|
@@ -82,10 +82,13 @@ import { createWindow, run } from "gui";
|
|
|
82
82
|
`requestAnimationFrame` 逐帧驱动,或写成 `transition: transform`(见
|
|
83
83
|
`examples/gui/pelican-svg`)。CSS 子集还覆盖 `@media`、`::before`/`::after`
|
|
84
84
|
生成内容、线性/径向多层背景、`calc()`、真正的 `text-shadow`/`box-shadow`
|
|
85
|
-
高斯模糊、`clip-path
|
|
85
|
+
高斯模糊、`clip-path`、圆角 `border-radius` 裁剪(含 `overflow: hidden` 框架
|
|
86
|
+
与替换内容)、`filter` 颜色效果、`backdrop-filter` 合成、
|
|
86
87
|
`@keyframes` 与 `transition`/`animation` 时间函数、`letter-spacing`、
|
|
87
|
-
`text-transform
|
|
88
|
-
|
|
88
|
+
`text-transform`、`white-space: nowrap`、`text-overflow: ellipsis`、行内级
|
|
89
|
+
`flex`/`grid`、`grid-area`、`aspect-ratio`、自动
|
|
90
|
+
外边距、确定高度框架内的百分比高度、百分比 `border-radius`、`outline`、
|
|
91
|
+
`url()` 图层的平铺
|
|
89
92
|
`background-size`、SVG 子元素上的文档 CSS,以及仅文本的竖排书写模式。`filter: blur()`
|
|
90
93
|
仍是有文档说明的近似。
|
|
91
94
|
因为主体是 C++,它以各平台预编译的 `gui.a`/`gui.lib` 形式分发。如果该
|
package/doc/gui/dom.md
CHANGED
|
@@ -29,7 +29,9 @@ combinators (descendant, child, adjacent and general sibling), the pseudo-classe
|
|
|
29
29
|
subset), numbers, keywords and shorthands (`margin`/`padding`/`border`/`flex`/
|
|
30
30
|
`font`/`outline`). `display: inline-flex`/`inline-grid` make a flex/grid
|
|
31
31
|
container inline-level; `grid-area`, `aspect-ratio`, `letter-spacing`,
|
|
32
|
-
`text-transform`, `
|
|
32
|
+
`text-transform`, `text-overflow` (`clip`/`ellipsis`), `white-space`
|
|
33
|
+
(`normal`/`nowrap`/`pre`/`pre-wrap`/`pre-line`), `writing-mode`
|
|
34
|
+
(`vertical-rl`/`vertical-lr` text),
|
|
33
35
|
`vertical-align` (length form), percentage `border-radius`, `background-size`
|
|
34
36
|
(size + default repeat for `url()` layers) and `currentColor` are parsed too.
|
|
35
37
|
`font-variant-numeric`, `text-wrap`, `text-rendering`, `touch-action`,
|
|
@@ -68,6 +70,72 @@ per-restyle arena. Layout inserts its box before/after the real children;
|
|
|
68
70
|
traversal, queries, `innerHTML` and `elementIndex()` never see it, and hit
|
|
69
71
|
testing targets the origin element.
|
|
70
72
|
|
|
73
|
+
### Unsupported features are reported
|
|
74
|
+
|
|
75
|
+
The subset above is a limit, not a silent one. The rest of the document still
|
|
76
|
+
renders — an unsupported element becomes an ordinary box (or stays hidden, for a
|
|
77
|
+
tag such as `<template>`), an unsupported declaration is dropped — but the first
|
|
78
|
+
use of each name is reported on stderr:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
xt_gui: warning: unsupported element <table>; the engine has no browser behaviour for it
|
|
82
|
+
xt_gui: warning: unsupported CSS property 'gap'; it is ignored
|
|
83
|
+
xt_gui: warning: unsupported at-rule '@supports'; its rule is ignored
|
|
84
|
+
xt_gui: warning: unsupported pseudo-class ':has'; it never matches
|
|
85
|
+
xt_gui: warning: unsupported CSS unit 'vmin'; the value is ignored
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Reporting is per name for the whole process, so one property used by many rules
|
|
89
|
+
or a cell repeated on every row appears once. The parser/cascade path reports:
|
|
90
|
+
|
|
91
|
+
- **HTML elements** with browser behaviour the engine lacks: `applet`, `area`,
|
|
92
|
+
`basefont`, `bgsound`, `blink`, `caption`, `col`, `colgroup`, `datalist`,
|
|
93
|
+
`details`, `dialog`, `embed`, `frame`, `frameset`, `iframe`, `input`,
|
|
94
|
+
`isindex`, `keygen`, `map`, `marquee`, `math`, `meter`, `noembed`, `noframes`,
|
|
95
|
+
`object`, `optgroup`, `option`, `output`, `param`, `plaintext`, `progress`,
|
|
96
|
+
`select`, `summary`, `table`, `tbody`, `td`, `template`, `textarea`, `tfoot`,
|
|
97
|
+
`th`, `thead`, `tr`, `track` and `xmp`. Every other tag — including `button`,
|
|
98
|
+
`label`, custom elements and a typo such as `<dvi>` — is rendered as a plain
|
|
99
|
+
box, which is the intended fallback rather than a dropped feature, so it is
|
|
100
|
+
not reported.
|
|
101
|
+
- **HTML attributes** that request unsupported behaviour: `href` (links do not
|
|
102
|
+
navigate), `srcset`, `sizes`, `poster`, `controls`, `contenteditable`,
|
|
103
|
+
`draggable`, `autofocus`, `tabindex`, `hidden`, and the SVG
|
|
104
|
+
`filter`/`mask`/`clip-path`/`marker-*` attributes.
|
|
105
|
+
- **CSS properties** outside the subset, and **length units** the parser does
|
|
106
|
+
not implement (`ch`, `ex`, `vmin`, `dvh`, …). A recognised property with an
|
|
107
|
+
unparsable value is not reported as unsupported; only the property name is
|
|
108
|
+
checked.
|
|
109
|
+
- **CSS at-rules** other than `@media`, `@font-face` and `@keyframes` (including
|
|
110
|
+
its vendor-prefixed spelling): `@supports`, `@layer`, `@container`,
|
|
111
|
+
`@import`, …
|
|
112
|
+
- **`@font-face` descriptors** other than `font-family`, `src`, `font-weight`
|
|
113
|
+
and `font-style` (`font-display`, `unicode-range`, …).
|
|
114
|
+
- **Selectors**: unsupported pseudo-classes (`:has`, `:is`, `:where`,
|
|
115
|
+
`:nth-of-type`, …), unsupported pseudo-elements (`::selection`, `::marker`, …),
|
|
116
|
+
and a selector the parser has to drop.
|
|
117
|
+
- **Media queries**: an unknown feature (`min-resolution`, `aspect-ratio`, …)
|
|
118
|
+
evaluates to false and is reported.
|
|
119
|
+
- **CSS functions** in a supported property when the engine does not implement
|
|
120
|
+
them: `hsl()`/`oklch()`/… colours, `perspective()`/`rotateX()` transforms,
|
|
121
|
+
`url()` filters, `path()` clip shapes, `conic-gradient()` backgrounds and
|
|
122
|
+
`counter()` generated content. An unsupported function invalidates the
|
|
123
|
+
declaration that uses it.
|
|
124
|
+
- **SVG elements** NanoSVG does not render: `<text>`, `<use>`, `<filter>` and the
|
|
125
|
+
`fe*` primitives, `<mask>`, `<clipPath>`, `<pattern>`, `<marker>`, `<image>`,
|
|
126
|
+
`<foreignObject>` and animation elements. They are reported when an inline
|
|
127
|
+
`<svg>` is serialized for painting (an `<img src="…svg">` file goes through
|
|
128
|
+
NanoSVG directly and is outside this check).
|
|
129
|
+
|
|
130
|
+
`XT_GUI_NO_WARNINGS=1` silences the reports. On Windows a GUI program is a
|
|
131
|
+
Windows-subsystem executable, so stderr is visible only with `app.console: true`
|
|
132
|
+
(see [API](./api.md)). The warnings do not affect the exit status.
|
|
133
|
+
|
|
134
|
+
This is a parser/cascade audit, not a complete API audit: an unsupported *value*
|
|
135
|
+
of a supported property (`display: contents`, for example), a DOM method that is
|
|
136
|
+
a deliberate no-op and a WebGL entry point the backend does not implement remain
|
|
137
|
+
silent (the Canvas and WebGL pages document their subsets).
|
|
138
|
+
|
|
71
139
|
## Interactive DOM (M8)
|
|
72
140
|
|
|
73
141
|
`win.document` returns the document handle; element handles have stable identity
|
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
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -27,7 +27,9 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
27
27
|
颜色(十六进制、`rgb()`/`rgba()`、一个命名子集)、数字、关键字与简写
|
|
28
28
|
(`margin`/`padding`/`border`/`flex`/`font`/`outline`)。
|
|
29
29
|
`display: inline-flex`/`inline-grid` 生成行内级 flex/grid 容器;`grid-area`、
|
|
30
|
-
`aspect-ratio`、`letter-spacing`、`text-transform`、`
|
|
30
|
+
`aspect-ratio`、`letter-spacing`、`text-transform`、`text-overflow`
|
|
31
|
+
(`clip`/`ellipsis`)、`white-space`
|
|
32
|
+
(`normal`/`nowrap`/`pre`/`pre-wrap`/`pre-line`)、`writing-mode`
|
|
31
33
|
(`vertical-rl`/`vertical-lr` 文本)、`vertical-align`(长度形式)、百分比
|
|
32
34
|
`border-radius`、`background-size`(`url()` 图层按尺寸与默认 repeat 平铺)与
|
|
33
35
|
`currentColor` 都已支持。`font-variant-numeric`、`text-wrap`、`text-rendering`、
|
|
@@ -61,6 +63,64 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
61
63
|
之前/之后;遍历、查询、`innerHTML` 与 `elementIndex()` 永远看不到它,命中测试
|
|
62
64
|
则指向原始元素。
|
|
63
65
|
|
|
66
|
+
### 不支持的特性会给出提示
|
|
67
|
+
|
|
68
|
+
上面的子集是一条边界,但不是一条静默的边界。文档其余部分仍然会渲染——不支持的
|
|
69
|
+
元素会变成普通盒子(`<template>` 这类标签则保持隐藏),不支持的声明会被丢弃——
|
|
70
|
+
但每个名字的第一次使用会输出到 stderr:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
xt_gui: warning: unsupported element <table>; the engine has no browser behaviour for it
|
|
74
|
+
xt_gui: warning: unsupported CSS property 'gap'; it is ignored
|
|
75
|
+
xt_gui: warning: unsupported at-rule '@supports'; its rule is ignored
|
|
76
|
+
xt_gui: warning: unsupported pseudo-class ':has'; it never matches
|
|
77
|
+
xt_gui: warning: unsupported CSS unit 'vmin'; the value is ignored
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
报告按名字在整个进程内去重:一个被多条规则使用的属性,或每行重复出现的表格
|
|
81
|
+
单元格,只会出现一次。解析/层叠路径会报告:
|
|
82
|
+
|
|
83
|
+
- **HTML 元素**:引擎缺少其浏览器行为的标签——`applet`、`area`、`basefont`、
|
|
84
|
+
`bgsound`、`blink`、`caption`、`col`、`colgroup`、`datalist`、`details`、
|
|
85
|
+
`dialog`、`embed`、`frame`、`frameset`、`iframe`、`input`、`isindex`、
|
|
86
|
+
`keygen`、`map`、`marquee`、`math`、`meter`、`noembed`、`noframes`、
|
|
87
|
+
`object`、`optgroup`、`option`、`output`、`param`、`plaintext`、`progress`、
|
|
88
|
+
`select`、`summary`、`table`、`tbody`、`td`、`template`、`textarea`、`tfoot`、
|
|
89
|
+
`th`、`thead`、`tr`、`track` 与 `xmp`。其余标签——包括 `button`、`label`、
|
|
90
|
+
自定义元素以及 `<dvi>` 这类拼写错误——都会渲染成普通盒子,这是预期的回退而
|
|
91
|
+
不是被丢弃的特性,因此不会报告。
|
|
92
|
+
- **HTML 特性(attribute)**:请求了不支持行为的 `href`(链接不会导航)、
|
|
93
|
+
`srcset`、`sizes`、`poster`、`controls`、`contenteditable`、`draggable`、
|
|
94
|
+
`autofocus`、`tabindex`、`hidden`,以及 SVG 的
|
|
95
|
+
`filter`/`mask`/`clip-path`/`marker-*` 特性。
|
|
96
|
+
- **CSS 属性**:子集之外的属性名;以及解析器未实现的长度单位(`ch`、`ex`、
|
|
97
|
+
`vmin`、`dvh` 等)。已支持属性上的非法值不会按“不支持”报告——只检查属性的
|
|
98
|
+
*名字*。
|
|
99
|
+
- **CSS at-rule**:`@media`、`@font-face`、`@keyframes`(含厂商前缀拼写)之外的
|
|
100
|
+
at-rule,例如 `@supports`、`@layer`、`@container`、`@import`。
|
|
101
|
+
- **`@font-face` 描述符**:`font-family`、`src`、`font-weight`、`font-style`
|
|
102
|
+
之外的描述符(`font-display`、`unicode-range` 等)。
|
|
103
|
+
- **选择器**:不支持的伪类(`:has`、`:is`、`:where`、`:nth-of-type` 等)、
|
|
104
|
+
不支持的伪元素(`::selection`、`::marker` 等),以及解析器不得不丢弃的
|
|
105
|
+
选择器。
|
|
106
|
+
- **媒体查询**:未知特性(`min-resolution`、`aspect-ratio` 等)会按不匹配处理并
|
|
107
|
+
报告。
|
|
108
|
+
- **CSS 函数**:已支持属性里出现引擎未实现的函数——`hsl()`/`oklch()` 等颜色、
|
|
109
|
+
`perspective()`/`rotateX()` 等变换、`url()` 滤镜、`path()` 裁剪形状、
|
|
110
|
+
`conic-gradient()` 背景、`counter()` 生成内容。不支持的函数会使整条声明失效。
|
|
111
|
+
- **SVG 元素**:NanoSVG 不渲染的 `<text>`、`<use>`、`<filter>` 及其 `fe*`
|
|
112
|
+
原语、`<mask>`、`<clipPath>`、`<pattern>`、`<marker>`、`<image>`、
|
|
113
|
+
`<foreignObject>` 与动画元素。内联 `<svg>` 在序列化用于绘制时报告;
|
|
114
|
+
`<img src="…svg">` 文件直接交给 NanoSVG,不经过这项检查。
|
|
115
|
+
|
|
116
|
+
`XT_GUI_NO_WARNINGS=1` 可以关闭这些报告。在 Windows 上,GUI 程序是
|
|
117
|
+
Windows 子系统可执行文件,只有设置 `app.console: true` 时才能看到 stderr
|
|
118
|
+
(见 [API](./api.md))。这些警告不影响退出状态。
|
|
119
|
+
|
|
120
|
+
这是解析/层叠路径的审计,不是完整 API 审计:已支持属性上的不支持*值*
|
|
121
|
+
(例如 `display: contents`)、有意空实现的 DOM 方法和后端未实现的 WebGL 入口
|
|
122
|
+
仍然保持静默(Canvas 与 WebGL 页面记录了各自的子集)。
|
|
123
|
+
|
|
64
124
|
## 交互式 DOM(M8)
|
|
65
125
|
|
|
66
126
|
`win.document` 返回文档句柄;元素句柄具有稳定标识,并提供可读写的属性、
|
|
@@ -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` 对块级子元素的影响(只有行内内容会绕排,
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
`DisplayList`:一个按画家顺序排列的 `ops` 列表,包含**矩形**(背景与四条实心
|
|
11
11
|
边框,带 `border-radius`)、**文本 run**(每个携带其文本、颜色与已解析的
|
|
12
12
|
`FontSpec`)与**图像**,背后由并列的负载数组支撑。每个 op 还携带当前生效的裁剪
|
|
13
|
-
矩形(最近的 `overflow: hidden` 祖先的 padding box
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
矩形(最近的 `overflow: hidden` 祖先的 padding box)以及最多四个指向显示列表
|
|
14
|
+
裁剪多边形的下标——CSS `clip-path` 形状,加上带 `border-radius` 的 `overflow`
|
|
15
|
+
祖先的圆角 padding box——因此 `overflow`/`clip-path` 裁剪与 `z-index`
|
|
16
|
+
顺序都能保留到渲染器,圆形头像框也真的是圆的。`DisplayList::dump()` 为
|
|
17
|
+
`paintList()`/`paintCount()` 提供数据。
|
|
17
18
|
|
|
18
19
|
`opacity` 会乘到该盒子及其后代绘制的每个颜色 alpha 上(沿绘制链逐层相乘),
|
|
19
20
|
因此小数 opacity 以及 CSS 解析器接受的 `opacity` 过渡都能看到效果。这是按图形
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
`runtime/ext_gui/renderer.{h,cpp}` 把该列表转换为每个窗口的批处理顶点缓冲
|
|
25
26
|
(图形、字形四边形与图像),并把管线、裁剪与纹理都相同的连续 op 合并为
|
|
26
27
|
**绘制 run**。每个 run 用各自的 GPU scissor 矩形(按设备像素缩放)绘制,因此
|
|
27
|
-
画家顺序与 `overflow` 裁剪按 op 生效,并通过 SDL_GPU
|
|
28
|
+
画家顺序与 `overflow` 裁剪按 op 生效,并通过 SDL_GPU 图形管线完成;scissor 只是
|
|
29
|
+
包围矩形,圆角 `overflow` 裁剪与 `clip-path` 形状会切进下面描述的顶点几何:
|
|
28
30
|
|
|
29
31
|
- 共享管线会依据设备支持的着色器格式延迟创建。SDL_GPU 的三个后端各自只接受一种
|
|
30
32
|
二进制格式,且都不会在运行时编译 GLSL/HLSL,因此引擎三种都随包提供,由
|
|
@@ -122,11 +124,12 @@ rgba(…) calc(100% - 1px)` 这样的 1px 分割线要么落在两次采样之
|
|
|
122
124
|
显示为 `backdrop …` op。
|
|
123
125
|
|
|
124
126
|
**`clip-path`** 在 `paint_clip.cpp` 中解析为设备空间多边形(每个点都应用盒子的
|
|
125
|
-
transform),用耳切法三角化,并存入 `DisplayList::clip_paths
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
transform),用耳切法三角化,并存入 `DisplayList::clip_paths`。圆角 `overflow`
|
|
128
|
+
裁剪使用同一表示:每个角用短弦近似,因此多边形是凸的,scissor 矩形只是它的
|
|
129
|
+
包围盒。每个 op 的 `PaintClip` 最多携带四个路径下标;`renderer_clip.cpp` 在上传
|
|
130
|
+
时把每个凸的图形/字形/图像四边形与这些三角形求交(先按一条路径裁剪,再把得到的
|
|
131
|
+
每块交给下一条)。即使 `polygon()` 是凹多边形也正确,无需模板或 shader 改动,
|
|
132
|
+
但边缘是硬边(没有解析抗锯齿)。嵌套超过四层时保留最外四层。
|
|
130
133
|
|
|
131
134
|
**`filter`** 的颜色函数(`brightness`、`contrast`、`grayscale`、`sepia`、
|
|
132
135
|
`invert`、`saturate`、`hue-rotate`、`opacity`)会折进每个绘制颜色,因此盒子与
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xbintsc",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "xbintsc - a TypeScript binary compiler (TypeScript -> LLVM IR -> native binary)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"vitest": "^2.1.8"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"@xbintsc/linux-x64": "0.6.
|
|
76
|
-
"@xbintsc/linux-arm64": "0.6.
|
|
77
|
-
"@xbintsc/darwin-x64": "0.6.
|
|
78
|
-
"@xbintsc/darwin-arm64": "0.6.
|
|
79
|
-
"@xbintsc/win32-x64": "0.6.
|
|
80
|
-
"@xbintsc/win32-arm64": "0.6.
|
|
75
|
+
"@xbintsc/linux-x64": "0.6.10",
|
|
76
|
+
"@xbintsc/linux-arm64": "0.6.10",
|
|
77
|
+
"@xbintsc/darwin-x64": "0.6.10",
|
|
78
|
+
"@xbintsc/darwin-arm64": "0.6.10",
|
|
79
|
+
"@xbintsc/win32-x64": "0.6.10",
|
|
80
|
+
"@xbintsc/win32-arm64": "0.6.10"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=22"
|