Proposal: HostOps.nodeRect — node geometry readback (root-space border box)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, rust, typescript
Hướng nghiên cứu
Read contracts/spec/ui-ops.ts and inspect the generated bindings and engine/runtime-cabi/src/compat/ui/mod.rs; the issue says the prototype targeted the removed engine/wasm crate. First settle the result shape and auxiliary-surface semantics with maintainers, then port the core method, C ABI export, and framework/web binding. Done means tests cover nested geometry, missing or stale IDs, and agreement with the drawn position.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Proposal: HostOps.nodeRect — node geometry readback
Summary
Add a read-only op that returns a node's border box in root space, so renderers can anchor UI (popovers, menus, tooltips, floating buttons) without probing the framebuffer.
Problem
The core computes layout, but the host-visible op surface has no way to read a node's rectangle:
ui_node_layoutreturns parent-relative values and is not part ofHostOps, so every caller has to re-walk the ancestor chain.- There is no op that returns a node's box in root space.
A renderer that wants to place a popover next to its trigger therefore has to reconstruct the box from hit tests.
Measured cost in a real renderer
Our React renderer for PocketJS (compat layer over this core) anchors Menu/Select/tooltip panels to their triggers today by scanning for a seed point with hitTestBounds, then four binary searches for the edges:
| Scene | Hit-test queries per measure | Queries per popover open (8 frames) |
|---|---|---|
| bare node | 1,839 | — |
| labelled node | 3,040 | — |
| clipped node | 449 | — |
| popover open | — | 22,322 |
That is per interaction, on a 480×272 viewport, with two frames of latency before the panel can be placed.
Proposal
interface NodeRect {
readonly x: number;
readonly y: number;
readonly w: number;
readonly h: number;
}
interface HostOps {
nodeRect?(id: number): NodeRect | null;
}
Semantics:
- Root-space border box in logical pixels: the node's parent-relative layout rect summed up the parent chain.
- Untransformed (transforms are not applied) and unclipped (overflow clips and occlusion are not applied); a painted/clipped rect can be a later op.
- Margin excluded.
nullfor id 0, a stale id or a destroyed node.- Optional member: hosts without the op omit it, and callers feature-detect. Old hosts keep working.
A working implementation exists in a local branch (see below): a core method that sums the parent chain, a C ABI export writing four f32s to an output buffer, and the framework/web binding. Tests: a hand-computed nested rect, the none/stale cases, and a pixel-free assertion that the box matches the drawn position.
Feedback we would like before opening a ported PR:
- Result shape. The op needs to return four numbers. Options we see: (a) a new
rectresult kind incontracts/spec/ui-ops.tswith the generated bindings extended for it, (b) an out-buffer call with the existingintegersuccess result — cheaper to wire, less ergonomic. We are happy to do either; (a) touches the generator chain and the guests, so we would rather ask first. - Untransformed/unclipped as stated, or should it intersect with clipping ancestors?
- Should the same op serve auxiliary surfaces (rect in that surface's space, as hit tests do)?
Status of the local implementation
The prototype predates the runtime-drivers refactor (#603): it added ui_node_rect to the old engine/wasm crate, which no longer exists. The core method and the C ABI export port cleanly to engine/runtime-cabi/src/compat/ui/mod.rs; what needs deciding is the descriptor/result-kind shape above. We have not opened that PR yet because we would rather agree on the API than hand you a PR that needs reworking in all the generators.
Happy to post the prototype diff on request, and to rebase the ported version the moment the shape is settled.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.6k
- Fork
- 88
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pocket-stack/pocketjs
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
pocket-stack/pocketjs#729 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pocket-stack/pocketjs#725 ·
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
pocket-stack/pocketjs#724 ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
pocket-stack/pocketjs#728 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
pocket-stack/pocketjs#727 ·
Tất cả issue của pocket-stack/pocketjs
Issue tương tự
-
kind:defect
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
mux-labs/mux-frontend#1240 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: agents-mcp priority: normal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Wait for the IDS correction dialog to settle in the stale-audit testCó thể đã có người làm @louistrue đã nhận hôm nay. Đang mởready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI pathCó thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cloudflare/chanfana#400 ·
Maintainer thường phản hồi trong vòng 1 ngày