Bypass walk: the stop every focusable egui widget gets by itself (Stop::automatic) is no registration, so a raw egui widget beside a component is a finding again

This commit is contained in:
aiongg
2026-11-25 02:00:59 +00:00
parent e46f5180a0
commit bb4c826819
3 changed files with 13 additions and 7 deletions
+2 -3
View File
@@ -231,11 +231,10 @@ impl State {
/// Whether `id`, holding egui focus, is an app's own widget: as `made` says, no widget a component made
/// (`pointer::made_by_component`), and the root of no stop but the one every focusable egui widget of the app has
/// (`Stop::host` with default keys). The app's canvas (`host_canvas`, `KeyUse::chrome_key`) is none: its declared
/// (`Stop::automatic`). The app's canvas (`host_canvas`, `KeyUse::chrome_key`) is none: its declared
/// keys route as a framework stop's do, so egui's arrows and Tab never move focus off it.
pub(super) fn app_widget(&self, id: Id, made: bool) -> bool {
let automatic = |rec: &StopRec| rec.stop.host && !rec.stop.keys.chrome_key;
!made && !self.stops.iter().chain(&self.last_stops).any(|rec| !automatic(rec) && (rec.stop.root == id || rec.stop.key() == (id, None)))
!made && !self.stops.iter().chain(&self.last_stops).any(|rec| !rec.stop.automatic() && (rec.stop.root == id || rec.stop.key() == (id, None)))
}
/// Moves focus to `rec` and asks the enclosing scroll owner to reveal it: the egui widget is its root, and the stop
@@ -37,8 +37,8 @@ pub struct Stop {
/// The arena root the stop is shown in (a canvas whose body holds it), whether or not it joined the arena: a text
/// stop keeps its own egui widget. A removed stop hands focus back to it.
pub arena: Option<Id>,
/// The app's own egui widget (`focus::host_canvas`), which reads its keys from egui's input: the key stage leaves
/// the presses it routes to the stop there.
/// The app's own egui widget (`focus::host_canvas`, or any focusable egui widget the app draws), which reads its
/// keys from egui's input: the key stage leaves the presses it routes to the stop there.
pub host: bool,
}
@@ -128,6 +128,12 @@ impl Stop {
self
}
/// Whether this is the stop every focusable egui widget the app draws gets by itself (`focus::take_app_widgets`):
/// the app's own widget, not declared as its canvas (`KeyUse::chrome_key`). No component or app call registered it.
pub fn automatic(&self) -> bool {
self.host && !self.keys.chrome_key
}
pub(crate) fn key(&self) -> StopKey {
(self.id, self.part)
}
+3 -2
View File
@@ -1,7 +1,8 @@
//! Bypass detection (24.2): the pass-end walk that finds what a component made without the runtime.
//!
//! Every interactive egui widget of the latest pass must be one a component registered (a root or one of its
//! widgets, a focus stop's root) or one the runtime noted. Every AccessKit node that declares an action must
//! widgets, the root of a focus stop that something registered: not the stop every focusable egui widget gets by
//! itself, `Stop::automatic`) or one the runtime noted. Every AccessKit node that declares an action must
//! come from the runtime's node writer. A raw `ui.interact`, `ui.button` or `ui.add(Slider)` in a component
//! fails here, with the id of the offender.
@@ -24,7 +25,7 @@ pub fn findings(fixture: &Fixture) -> Vec<String> {
let mut registered: HashSet<Id> = pointer::registered_widgets(ctx);
registered.extend(noted_widgets);
focus::with_viewport(ctx, egui::ViewportId::ROOT, |state| {
registered.extend(state.stops.iter().chain(&state.last_stops).map(|rec| rec.stop.root));
registered.extend(state.stops.iter().chain(&state.last_stops).filter(|rec| !rec.stop.automatic()).map(|rec| rec.stop.root));
});
let mut found: Vec<String> = widgets::interactive(ctx)
.into_iter()