render: expose real geometry to JS behind the render feature

getBoundingClientRect, offsetWidth/Height, and offsetTop/Left now read
real box geometry from the obscura-render layout cache when the render
feature is compiled in. elementFromPoint inherits correct hit-testing
because it already delegates to getBoundingClientRect per element.

Adds a render feature on obscura-js (propagated through obscura-browser
and obscura-cli), a lazily-computed layout cache and viewport in
ObscuraState (feature-gated, cleared on navigation), and an
op_layout_geometry op. bootstrap.js probes the op with typeof, so the
default scraping build is unchanged and falls through to the synthetic
rect.

With --features render, block siblings stack and flex children place
horizontally at correct positions, and elementFromPoint resolves the
right element. Default build returns the synthetic rect unchanged.
Obstacle course 33/33; obscura-js unit failures identical to main.
This commit is contained in:
SGavrl committed 2026-06-30 20:36:43 +00:00
1 parent f0f9b048d0
commit 399181b975
7 files changed
+125 -33

No files matched your search

+8 -1
View File
@@ -188,7 +188,14 @@ impl ObscuraJsRuntime {
}
pub fn set_dom(&self, dom: DomTree) {
self.state.borrow_mut().dom = Some(dom);
let mut gs = self.state.borrow_mut();
gs.dom = Some(dom);
// A new document invalidates the layout cache; it is recomputed lazily
// on the next geometry read.
#[cfg(feature = "render")]
{
gs.layout_cache = None;
}
}
pub fn set_url(&self, url: &str) {