Skip to main content

Crate sk_tree

Crate sk_tree 

Source
Expand description

sk-tree — the retained node tree that Vue’s custom renderer mutates through __sk_* host functions, and the per-frame lowering of that tree into gpui elements.

JS holds dense u32 node ids (0 = none); tags, style keys and event names are interned once via __sk_intern so the hot path carries no strings. Structural ops apply synchronously; insert is also move (implicit detach), remove destroys the whole subtree. Mutations mark the tree dirty and the frame pump notifies the root view after the JS wave.

Re-exports§

pub use windows::WinKey;

Modules§

devtools
The read/drive surface sk-devtools sits on: selector queries against the REAL cascade matcher, node dumps off the retained tree, and synthesized input through the ordinary dispatch path.
iframe
<iframe>: a document in a platform webview, drawn into the element’s box.
log
A bounded in-process log ring so the devtools logs command can read back what the host printed. Off unless enable is called, so record is one relaxed atomic load. Output is teed here, not moved: the terminal keeps showing exactly what it did. The ring is thread-local because every recorder lives on the VM/gpui main thread.
perf
Phase counters for the SK_PERF probe: the restyle and build phases that run deep inside sk-tree, accumulated into a one-second window that sk-app drains next to its own frame report. With the probe off a phase costs one relaxed atomic load.
surface
<sk-surface name="…">: a picture native code produces and a Skathi element shows, composited like any other content (object-fit, clipping, radii, transforms, z-order).
windows
Per-window state: one process, one JsRuntime and one Tree, but N gpui windows each painting one node of it. State the windows disagree about (focus, bounds, drag regions, @media) lives in one WindowState per gpui::WindowId; single-slot thread-locals would alias across windows. “Here” is passed, never guessed.

Structs§

EventPayload
The numeric payload a native input event carries into JS. Mouse: a=x b=y c=button, d=modifier bits | click count << 4. Wheel: a=deltaX b=deltaY. Input: key = the new value. Scroll: a=scrollLeft b=scrollTop. Modifier bits: 1 ctrl, 2 shift, 4 alt, 8 meta.

Enums§

Flush

Constants§

EVENT_NAMES
Every host event code with the name JS knows it by; devtools lists from here.
EV_AUXCLICK
Middle or right button pressed and released over one element; the target is the nearest common ancestor.
EV_BEFOREINPUT
Before each edit, cancelable (except the IME’s): a cancelled one makes no edit and no input.
EV_BLUR
EV_CANPLAY
EV_CANPLAYTHROUGH
EV_CLICK
EV_COMPLETE
EV_COMPOSITIONEND
EV_COMPOSITIONSTART
The IME composition’s stages (CompositionEvents, data as above): start, each pre-edit, and the end, which follows the commit’s input.
EV_COMPOSITIONUPDATE
EV_CONTEXTMENU
A MouseEvent; also from the Menu key / Shift+F10 at the focused element.
EV_COPY
EV_CUT
EV_DURATIONCHANGE
EV_EMPTIED
EV_ENDED
EV_ENTERFRAME
EV_ERROR
Carries MediaError.code in a and the advisory text in key.
EV_FOCUS
EV_INPUT
EV_KEYDOWN
EV_KEYUP
EV_LOAD
a/b = naturalWidth/naturalHeight, key = the src. A failure is EV_ERROR with the same key.
EV_LOADEDDATA
EV_LOADEDMETADATA
EV_LOADSTART
EV_LOOPCOMPLETE
EV_MESSAGE
An <iframe>’s document posted to its parent (crate::iframe): at the iframe’s node, key = {"o": origin, "d": wire}. The runtime fires it at window.
EV_MOUSEDOWN
EV_MOUSEENTER
Non-bubbling, per the UI Events spec: fires only on the element entered.
EV_MOUSELEAVE
EV_MOUSEMOVE
EV_MOUSEUP
EV_PASTE
EV_PAUSE
EV_PLAY
EV_PLAYING
EV_POINTERCANCEL
The window lost activation mid-press: only the press’s mousedown target hears it.
EV_POINTERLOCKCHANGE
The document’s pointer lock changed (a = the request it settles, 0: none) or a request failed (key = “Name: message”). Delivered at node 0; the runtime fires both at document.
EV_POINTERLOCKERROR
EV_RATECHANGE
EV_SCROLL
EV_SEEKED
EV_SEEKING
EV_TIMEUPDATE
Throttled to the spec’s 250 ms.
EV_VOLUMECHANGE
EV_WAITING
EV_WHEEL

Functions§

animating
asset_base
asset_store
bounds_in
The rectangle one window painted this node at; a rectangle is meaningful only in its window’s client space, so a point query must name the window.
build_root
build_subtree
Builds one node’s subtree as the root of a second window’s element tree, with the same per-window bookkeeping as build_root and the root treatment (100% size, Overflow::Scroll, track_focus).
build_view_transition
What the window shows over the document while a transition runs: the old state frozen until the pseudo-elements exist, then those. It takes every pointer event.
content_key
control_hitboxes
control_hitboxes_in
dev_asset_file
Resolves one explicitly mapped dev URL with the same normalization as image/font/video URLs and fetch. Unknown keys never escape the app root.
dispatch_event
Dispatches an input event into JS and runs its microtask checkpoint so Vue’s flush lands in the same frame. Needs Phase::Commit published; false means a handler called preventDefault(). Under a gpui listener the checkpoint is owed and run after gpui’s dispatch (render::settle_owed_later), where an onMounted that measures can lay out.
dispatch_event_with
dispatch_event with an object for the event to carry, passed as the dispatcher’s eighth argument: a ClipboardEvent’s clipboardData (crate::clipboard).
dynamic_range_limit
The computed dynamic-range-limit of an element: how bright the HDR content it shows (an <sk-surface>, <video> or image) may be. An HDR window paints a half-float surface up to it; a producer reads it as crate::surface::SurfaceInfo::dynamic_range_limit.
effects_changed
The app’s --shading effects were replaced (gpui::reload_app_effects): sk-css resolves an effect’s name and arguments when a sheet compiles or an inline style parses, so recompile, re-parse inline --shading and restyle. A renamed or removed effect then degrades as an unknown one does.
enable_pick_hitboxes
env
The last set_env value, the source matchMedia evaluates against (the primary window’s).
flush_changes
flush_changes_kind
flush_pending_mouse_move
The one mousemove a frame may deliver (UAs align mousemove to the frame clock and drop the rest). Also the per-move dedup: gpui runs bubble handlers topmost-first, so the first (innermost) claim wins; otherwise k nested listeners ran k dispatch walks per move. The frame’s hover resolves first so mouseleave/mouseenter precede mousemove.
forget_window
Forgets everything a window held, because it has closed. Its atlas went with it, so tiles it still owed are dropped: another window’s drop_image could remove keys that window re-inserted.
frame_tick
Per-frame work that needs a Window; call once per frame from the pump, before the draw. Returns true when the window must repaint.
in_input_dispatch
True while a gpui listener (or gpui’s own draw) has called into JS. The forced layout must not draw then: gpui took the frame’s listeners out, and focus listeners run inside Window::draw.
install
lotties_animating
match_media
Evaluates one media query against [env], as the cascade would. Err is the compile failure.
media_polls
Whether frame_tick polls something that is loading or playing (video, Lottie, stickers, image loads), which tells nobody when it has a new frame.
painted_bounds_in
painted_drag_region
painted_drag_region_in
pointer_lock_intercept_escape
Escape releases the lock before anything else hears the key, and nothing on the page does. Every other key press counts as a gesture.
pointer_lock_navigated
The document went away: its requests are never answered.
popped_out
read_app_asset
The bytes of one of the app’s own files by URL path (/games/pong/index.html): from the package, or off disk under the app root (or its public/) in a dev host.
root_bounds
Where the app root was painted in the window’s client area, CSS px; None before the first frame. Host-drawn chrome is excluded, as in innerWidth.
root_bounds_in
root_bounds for one window: the source of a per-window @media viewport and a SkWindow’s @resize payload.
set_asset_base
set_asset_store
Makes relative srcs resolve out of lookup instead of the disk; set once at boot, on the render thread, by a packaged exe.
set_dev_asset_files
Replaces the dev manifest’s imported-file map, also visible to fetch’s background threads. Only canonical generated keys and absolute paths pass.
set_env
Publishes the window environment @media is evaluated against (viewport, colour scheme, reduced motion, DPI, display mode). Call every frame; a change dirties the tree and returns true.
set_env_for
set_os_chrome
set_os_chrome_in
set_page_hidden
A paint-only frame is not presented while the page is hidden (crate::live); the draw that shows the window again paints the newest one.
set_popped_out
Marks (or unmarks) a node as painted by another window. Returns true when the flag moved.
set_reduce_motion
set_repaint_all
set_sync_layout
Installs the host’s “draw one frame now” callback (sk-tree cannot depend on sk-app).
settle_container_queries
The frame’s container step, after the pump and before gpui draws: lays the window out now when it will draw anyway, then settles. Nothing runs while no container is watched.
surface_app_closed
The app is quitting: <sk-surface> frames still waiting to be shown are dropped as closed.
surface_device_changed
The renderer recreated its D3D11 device: every <sk-surface> drops its GPU frame and producers hear surface::SurfaceEvent::DeviceLost.
sync_layout
Folds pending changes and draws one frame so a layout read answers from real rectangles. Re-entrant calls are dropped; a no-op with no hook installed.
tree_revision
Advances on every flush that found the tree changed, whichever path flushed it: a frame, an input dispatch, a forced layout or a devtools command.
update_layout_observers
video_device_changed
The renderer recreated its D3D11 device; rebuild every <video> on the new one, keeping position and transport state.
videos_playing
window_control_at
The caption button a click on node lands on, as the hit test resolves it: the nearest ancestor-or-self declaring --window-control, with the window painting it. None where the OS draws the caption.
window_frame_tick
Per-frame work a SECONDARY window does from its own render(): its atlas resources and focus. The JS-facing half stays in frame_tick (one JS realm, once per frame group).
with_tree
Runs f with the tree. Panics (caught by host_fn!, poisons) if it is already borrowed, i.e. JS mutating during a draw walk.

Type Aliases§

AssetLookup
A packaged app’s asset store: app-root-relative key → bytes (mapped in the exe for the process’s life).