Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ Also:
- **Selectors that end in a tag do not walk the page** in the DOM layer,
and URL parses are cached: SvelteKit's split build looks for
`meta[property=csp-nonce]` several times a navigation.
- **A list scrolled down no longer takes clicks meant for what is above
it.** Rows scrolled out of the top of a scroll box were still hit where
they would have been, under the buttons drawn there; in the counter
example "start timer" stopped working once the list was scrolled a little.
A box that clips its overflow now clips clicks too (a Blitz patch).
- **A crash when an element came and went within one turn is fixed.** A
form control, `<style>` or `<title>` that was added and garbage-collected
before the turn ended (rare on QuickJS, seen on V8) stopped the app with
Expand Down
19 changes: 11 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,16 @@ at the size when a change adds crates or features.
needs `doc.wait(0.04)` after it settles (the frame comes in the first
step, the timer in the second); the Tracker's and router_dom's `click()`
do that. `goto` does not wait.
- **SvelteKit's route announcer** (`#svelte-announcer`) is a 1px
`overflow: hidden` box at the top left whose text overflows it, and Blitz
hit-tests overflowing content. `sepal/adapter` gives it `pointer-events:
none` in a `<style>` in `index.html`; without that it took clicks at the top left after
the first navigation. The real fix is a Blitz patch that clips hit
testing to `overflow: hidden`, which also changes what the Tracker tests
can click (they click rows far below the window).
- **A box that clips its overflow clips clicks too** (blitz-dom patch 14):
outside an `overflow: scroll`/`hidden`/`auto` box's padding box nothing
inside it is hit, as nothing inside it is drawn there. Upstream hit
content scrolled out of a list under the buttons above it. A test that
clicks something out of view (a row far down a list) has to scroll it in
first, as a user would: `SvelteDocument::scroll_into_view`, which the
Tracker's `click()` calls when its target is not under the pointer.
SvelteKit's route announcer (`#svelte-announcer`, a 1px `overflow:
hidden` box whose text overflows it) took clicks at the top left before
this; `sepal/adapter` still gives it `pointer-events: none`.
- **An unknown address needs a route in a SvelteKit app.** SvelteKit
answers it with a page load from the server; an app has none, so `goto`
rejects (`navigation_route_missing`) and a link changes nothing on
Expand Down Expand Up @@ -461,7 +464,7 @@ at the size when a change adds crates or features.
brings it back; check with `footprint` while frames are drawn. See its
`PATCH.md`. Same rules as below.
- **`crates/blitz-dom` is a patched copy**, wired in with `[patch.crates-io]`.
It differs from crates.io 0.3.0-beta.4 in thirteen places, all marked
It differs from crates.io 0.3.0-beta.4 in fourteen places, all marked
`sepal patch` (as are the changes in the other patched copies) and
described in `crates/blitz-dom/PATCH.md`. Do not
edit anything else there, and do not run `cargo fmt` on it.
Expand Down
12 changes: 7 additions & 5 deletions HANDOVER.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ Left for later, each its own job:
stand-in with no children. `href`, attribute reads and `closest` are
where it can come down (`preload-fix.md`). Without it the Board is still
4.7 ms behind main on a repeat visit: not looked into.
4. **Blitz hit testing clipped to `overflow: hidden`** (below, item 3 of the
SvelteKit list): `sepal/adapter` still gives the route announcer
`pointer-events: none`.
4. ~~**Blitz hit testing clipped to `overflow: hidden`**~~: done, blitz-dom
patch 14, for every box that clips its overflow (a scroll box too: the
counter's buttons stopped taking clicks once its list was scrolled).
`sepal/adapter`'s `pointer-events: none` on the route announcer can go.

## Native layer: backend, OS APIs and per-app host builds (24 Nov 2026)

Expand Down Expand Up @@ -131,7 +132,7 @@ always `crates/host`, so the patches always applied.

With per-app builds, the top level is the app's `native/` crate. Without the
patch lines, it compiles against the stock crates and quietly loses what each
`PATCH.md` lists: the thirteen changes to `blitz-dom`, the eleven to
`PATCH.md` lists: the fourteen changes to `blitz-dom`, the eleven to
`anyrender_vello_hybrid` (the glyph atlas, damage tracking), and the GPU
memory fixes in `vello_gpu` (two) and `wgpu-hal` (three; without them the
first blit costs about 80 MB of driver memory). Step 1 makes that
Expand Down Expand Up @@ -354,7 +355,8 @@ Next, each its own job after this branch:
`raf-frames` (above).
2. **Then a fresh comparison session**, and `compare.md` regenerated from it
(`make_compare_report.py` reads sessions by name).
3. **Blitz hit testing clipped to `overflow: hidden`.** Blitz descends into
3. ~~**Blitz hit testing clipped to `overflow: hidden`.**~~ Done (blitz-dom patch 14, 26 Nov).
Blitz descends into
content that overflows an `overflow: hidden` box, so invisible text can
take clicks. In `Node::hit_inner` (`crates/blitz-dom/src/node/node.rs`), a
point outside the box on an axis whose overflow is `hidden` or `clip`
Expand Down
22 changes: 20 additions & 2 deletions crates/blitz-dom/PATCH.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Patched copy of blitz-dom 0.3.0-beta.4

This is the crates.io source of `blitz-dom` 0.3.0-beta.4 (MIT OR Apache-2.0,
https://github.com/DioxusLabs/blitz) with thirteen changes. `crates/host/Cargo.toml`
https://github.com/DioxusLabs/blitz) with fourteen changes. `crates/host/Cargo.toml`
swaps it in through `[patch.crates-io]`.

## The changes
Expand Down Expand Up @@ -161,8 +161,26 @@ and `src/document.rs` (`laid_out_in`):
tree; subtrees without damage are now skipped, by the same test
`propagate_damage_flags` uses (1.5 ms on that page).

**14. A box that clips its overflow clips clicks too.** `src/node/node.rs`,
`hit_inner`, with `clips_descendants`: an element that clips its overflow
(as blitz-paint decides in `render.rs`, `should_clip`: `overflow` other than
`visible` on either axis, or paint containment; never the root element)
draws nothing of its descendants outside its padding box, and now nothing
there is hit either. Outside the padding box the element itself is hit on
its border, and nothing otherwise.

Upstream tests the descendants anyway, and in the box's scrolled
coordinates, where a point above a list scrolled down by 40 px counts as
inside it. Rows scrolled out of the top of a list took the clicks meant for
the buttons drawn above it (`examples/counter`: scroll the list a little and
"start timer" stops working), and text overflowing an `overflow: hidden` box
took clicks outside the box (SvelteKit's route announcer, which
`sepal/adapter` gives `pointer-events: none` for that reason). Tests that
clicked rows far below the window scroll them into view first now
(`SvelteDocument::scroll_into_view`).

## Updating

Do not edit anything else here. To move to a new blitz-dom version, replace the
directory with that version's source and reapply the thirteen changes (search for
directory with that version's source and reapply the fourteen changes (search for
`sepal patch`).
60 changes: 60 additions & 0 deletions crates/blitz-dom/src/node/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,36 @@ impl Node {
*scrollbar = Some(sb);
}

// sepal patch: an element that clips its overflow (as blitz-paint
// decides, see `clips_descendants`) shows nothing of its descendants
// outside its padding box, so nothing there can be hit either.
// Upstream tests the descendants anyway, in this node's scrolled
// coordinates: rows scrolled out of the top of a list took the
// clicks meant for buttons drawn above it, and text overflowing an
// `overflow: hidden` box took clicks outside the box. On its border,
// the element itself is hit.
if self.clips_descendants() {
let layout = self.final_layout();
let unscrolled_x = x - self.scroll_offset().x as f32;
let unscrolled_y = y - self.scroll_offset().y as f32;
let in_padding_box = unscrolled_x >= layout.border.left
&& unscrolled_x <= layout.size.width - layout.border.right
&& unscrolled_y >= layout.border.top
&& unscrolled_y <= layout.size.height - layout.border.bottom;
if !in_padding_box {
let in_border_box = unscrolled_x >= 0.0
&& unscrolled_x <= layout.size.width
&& unscrolled_y >= 0.0
&& unscrolled_y <= layout.size.height;
return (in_border_box && !pointer_events_none).then_some(HitResult {
node_id: self.id,
x,
y,
is_text: false,
});
}
}

let content_box_offset = taffy::Point {
x: self.final_layout().padding.left + self.final_layout().border.left,
y: self.final_layout().padding.top + self.final_layout().border.top,
Expand Down Expand Up @@ -1569,6 +1599,36 @@ impl Node {
None
}

/// sepal patch: whether this element clips its descendants to its padding
/// box, decided as blitz-paint's `render.rs` decides it (`should_clip`):
/// `overflow` other than `visible` on either axis, or paint containment.
/// Never the root element, whose overflow is the viewport's. (Paint also
/// clips images, sub-documents and text inputs, which have no children to
/// hit.)
fn clips_descendants(&self) -> bool {
use style::values::computed::{Contain, Overflow};
use style::values::specified::box_::{DisplayInside, DisplayOutside};
let Some(style) = self.primary_styles() else {
return false;
};
let is_root_element = self
.parent
.is_some_and(|parent| matches!(self.with(parent).data, NodeData::Document(_)));
if is_root_element {
return false;
}
let box_style = style.get_box();
let contain_paint = box_style.clone_contain().contains(Contain::PAINT) && {
let display = style.clone_display();
let internal_table_box_other_than_cell = display.outside() == DisplayOutside::InternalTable
&& display.inside() != DisplayInside::TableCell;
!display.is_inline_flow() && !internal_table_box_other_than_cell
};
contain_paint
|| !matches!(box_style.overflow_x, Overflow::Visible)
|| !matches!(box_style.overflow_y, Overflow::Visible)
}

/// Find the inline root ancestor of this node (or self if this is an inline root).
/// Returns None if no inline root ancestor exists.
pub fn inline_root_ancestor(&self) -> Option<&Node> {
Expand Down
2 changes: 1 addition & 1 deletion crates/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ path = "src/main.rs"
name = "drive"
required-features = ["screenshot"]

# Thirteen small changes; see crates/blitz-dom/PATCH.md.
# Fourteen small changes; see crates/blitz-dom/PATCH.md.
[patch.crates-io]
blitz-dom = { path = "../blitz-dom" }
# Glyph atlas on with small pages, large images, drawing without a window; see its PATCH.md.
Expand Down
22 changes: 22 additions & 0 deletions crates/host/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,28 @@ impl SvelteDocument {
.map_or(0, |resources| resources.folder().files_read())
}

/// Scroll the boxes around a node until it is in the middle of them, as
/// the app's `scrollIntoView({ block: 'center' })` does, then settle, so
/// the app hears where they went. For tests and `drive`: a scroll box
/// clips clicks as it clips what it draws, so what a user would scroll to
/// before clicking, a test has to as well.
pub fn scroll_into_view(&mut self, node: NodeId) {
{
let mut page = self.page.borrow_mut();
if page.has_size() {
page.layout_if_stale();
}
let Page { doc, scrolled, .. } = &mut *page;
let request = crate::scroll::Request::IntoView(
node,
crate::scroll::Align::Center,
crate::scroll::Align::Nearest,
);
crate::scroll::apply(doc, request, scrolled);
}
self.settle();
}

/// The id JavaScript knows a node by, if it knows it.
pub fn js_id(&self, node: NodeId) -> Option<u32> {
self.page.borrow().nodes.js(node)
Expand Down
22 changes: 22 additions & 0 deletions crates/host/tests/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,25 @@ fn a_fresh_document_can_replace_a_running_one() {
assert_eq!(new.text(inc), "count is 1");
assert_eq!(new.text(new.query("#seconds").unwrap()), "0s");
}

/// A scroll box clips what it holds, for clicks as for pixels. Scrolled a
/// little, the list's first rows sit above its top, under the buttons, and
/// are not drawn there: a click on "start timer" is the button's, not a
/// hidden row's.
#[test]
fn rows_scrolled_out_of_the_list_do_not_take_clicks() {
let mut doc = load();
doc.layout(800, 600);
let (lx, ly, lw, _) = doc.rect(doc.query("#rows").unwrap()).unwrap();
doc.wheel((lx + lw / 2.0) as f32, (ly + 40.0) as f32, 0.0, 60.0);
doc.wait(0.1);
assert_eq!(doc.text(doc.query("#scrolled").unwrap()), "scrolled 60px");

let tick = doc.query("#tick").unwrap();
let (tx, ty, tw, th) = doc.rect(tick).unwrap();
assert!(ty + th / 2.0 > ly - 60.0, "the button's middle is over a scrolled-out row");
doc.click_at((tx + tw / 2.0) as f32, (ty + th / 2.0) as f32);
doc.wait(0.1);
assert_eq!(doc.text(tick).trim(), "stop timer", "the click reached the button");
assert!(doc.query("#rows > li.selected").is_none(), "and no hidden row");
}
26 changes: 26 additions & 0 deletions crates/host/tests/tracker/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,29 @@ fn insights_chart_draws_bars_and_links_weeks() {
click_node(&mut doc, last);
assert_eq!(text(&doc, "[data-testid=page-title]"), "Issues");
}

/// In the narrowest window the app allows (720px), the Board's filters wrap
/// onto another line inside the window, and Insights puts its tiles two by
/// two and stacks its panels: nothing runs out of the window.
#[test]
fn board_and_insights_fit_the_narrowest_window() {
let mut doc = load();
doc.layout(720, 800);
click(&mut doc, "[data-testid=nav-board]");
doc.wait(0.1);
doc.layout(720, 800);
for id in ["search", "filter-status", "filter-priority", "filter-assignee", "filter-project"] {
let node = doc.query(&format!("[data-testid={id}]")).unwrap();
let (x, y, w, h) = doc.rect(node).unwrap();
assert!(x + w <= 720.0, "the Board's {id} runs out of the window at {}", x + w);
assert!(reaches(&doc, x + w / 2.0, y + h / 2.0, node), "the Board's {id} cannot be clicked");
}

click(&mut doc, "[data-testid=nav-insights]");
doc.wait(0.1);
doc.layout(720, 800);
for id in ["tile-open", "tile-created", "tile-closed", "tile-age", "chart", "by-assignee", "by-priority"] {
let (x, _, w, _) = doc.rect(doc.query(&format!("[data-testid={id}]")).unwrap()).unwrap();
assert!(x >= 240.0 && x + w <= 720.0, "Insights' {id} runs out of the window: {x} + {w}");
}
}
Loading
Loading