From 2de6c8c636000ee628a7bda0cdb51514d1fcbe5f Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 06:32:37 +0000 Subject: [PATCH] Remove diagnostic prints --- crates/imaging/src/ui/fill/mod.rs | 11 ---- crates/ui-canvas/src/canvas/mod.rs | 4 -- crates/ui-contract/src/primitives/sensing.rs | 11 ---- crates/ui-contract/src/runtime/keys/route.rs | 12 ---- crates/ui-contract/src/runtime/pointer.rs | 63 +------------------- crates/ui-widgets/src/notices/notice.rs | 6 -- 6 files changed, 2 insertions(+), 105 deletions(-) diff --git a/crates/imaging/src/ui/fill/mod.rs b/crates/imaging/src/ui/fill/mod.rs index 3311ebfed..878cf50f3 100644 --- a/crates/imaging/src/ui/fill/mod.rs +++ b/crates/imaging/src/ui/fill/mod.rs @@ -651,17 +651,6 @@ impl ContentAwareFillWorkspace { self.apply_reset(FillReset::FillArea); } - { - let test = std::thread::current().name().unwrap_or("?").rsplit("::").next().unwrap_or("?").to_owned(); - if test.starts_with("an_erased_sampling") || test.starts_with("brush_strokes_change") { - eprintln!( - "DIAG {test}: fill body max_rect {:?} available {:?} measuring {}", - ui.max_rect(), - ui.available_size(), - craft_ui::runtime::measure::active(ui.ctx()) - ); - } - } Row::new().fill().show(ui, |ui, _| { let rail = ToolRail::new(words.tools.clone(), slots, &self.tool, &self.last_used).show_rail(ui, |_, _| {}); if let Some(next) = rail.last_used { diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index 3bfe9b39e..5aa243703 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -388,10 +388,6 @@ impl<'a> Canvas<'a> { // As its body's scroll owner the canvas shows a control focus arrives at, and applies the page keys a focused // control leaves as its own. if let Some(by) = cx.take_reveal(area) { - eprintln!( - "DIAG command_drag_over_a_guide_moves_the_guide_with_any_tool: canvas {id:?} reveal by {by:?} in {area:?} egui focus {:?}", - ctx.memory(|memory| memory.focused()) - ); pan(&mut view, -by); jumped = true; } diff --git a/crates/ui-contract/src/primitives/sensing.rs b/crates/ui-contract/src/primitives/sensing.rs index 73fe9656d..98d191ec0 100644 --- a/crates/ui-contract/src/primitives/sensing.rs +++ b/crates/ui-contract/src/primitives/sensing.rs @@ -804,17 +804,6 @@ fn outcome_in(ctx: &Context, read: &PassRead, arena: ArenaId, layer: Layer, enab }; let won_kinds = root.map_or(Sense::empty(), |own| pointer::press_winners(ctx, at, targets).senses_of(own)); let allowed = crate::runtime::sampler::root_takes_press(ctx, root, layer, at, untargeted) && !won_kinds.is_empty(); - if let Some(test) = pointer::diag_test() - && state.root.is_some_and(|own| own.rect.contains(at)) - { - eprintln!( - "DIAG {test}: start root {:?} enabled {enabled} allowed {allowed} won {won_kinds:?} untargeted {untargeted} takes {} layer {layer:?} rect {:?} clip {:?}", - root.map(pointer::diag_id), - crate::runtime::sampler::root_takes_press(ctx, root, layer, at, untargeted), - state.root.map(|own| own.rect), - state.root.map(|own| own.clip), - ); - } if !enabled || !allowed { return None; } diff --git a/crates/ui-contract/src/runtime/keys/route.rs b/crates/ui-contract/src/runtime/keys/route.rs index 4c690f714..afd8cc49d 100644 --- a/crates/ui-contract/src/runtime/keys/route.rs +++ b/crates/ui-contract/src/runtime/keys/route.rs @@ -609,18 +609,6 @@ fn nudge_of(key: Key, mods: Mods) -> Option<(Vec2, Mods)> { /// Routes an AccessKit action request to the owner of its target node, whatever the focus (9.2 rule 2). fn route_access(ctx: &Context, request: &Action, nodes: &HashMap, routed: &mut HashMap, Routed>, activated: &mut IdMap) { - if matches!(request.kind(), ActionKind::Focus) { - let found = nodes.get(&request.node()); - eprintln!( - "DIAG every_displayed_shortcut_dispatches_from_where_focus_usually_is: access focus node {} found {} owner {:?} part {:?} focusable {:?} nodes {}", - request.node(), - found.is_some(), - found.map(|node| node.owner), - found.and_then(|node| node.part), - found.map(|node| node.focusable), - nodes.len() - ); - } let Some(node) = nodes.get(&request.node()).copied() else { return }; let owner = Some(node.owner); // A request that only scrolls (a screen reader's Scroll Into View) shows the node and leaves focus where it is. diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index e8b04f19f..535faea26 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -580,16 +580,13 @@ pub(crate) fn press_winner(ctx: &Context, at: Pos2, targets: PressTargets) -> Op fn find_press_winners(ctx: &Context, viewport: ViewportId, at: Pos2, targets: PressTargets) -> PressWinners { let Some(layer) = areas::layer_at(ctx, at) else { - if let Some(test) = diag_test() { - eprintln!("DIAG {test}: press_winner at {at:?}: no layer"); - } return PressWinners::default(); }; let to_layer = |layer: Layer| areas::layer_map(ctx, layer).map_or(at, |map| map.to_layer(at)); let body = PerViewport::::with(ctx, viewport, |record| record.last_bodies.get(&layer).copied()); let beneath = body.map(|(root, parent)| (root, parent, to_layer(parent))); let on_layer = to_layer(layer); - let found = PerViewport::::with(ctx, viewport, |record| { + PerViewport::::with(ctx, viewport, |record| { // Bottom to top: the body layer's root on its own layer, then the roots on the layer in paint order. let mut stack: Vec<(u8, Id, &RootRecord, Pos2)> = Vec::new(); if let Some((root, parent, point)) = beneath @@ -601,33 +598,6 @@ fn find_press_winners(ctx: &Context, viewport: ViewportId, at: Pos2, targets: Pr stack.extend(roots.iter().map(|(root, entry)| (1, *root, entry, on_layer))); } let shown = stack.iter().any(|(_, _, entry, point)| entry.placed.iter().any(|placed| placed.clip.contains(*point))); - if let Some(test) = diag_test() { - let hits: Vec = stack - .iter() - .flat_map(|(tier, root, entry, point)| { - entry.shapes.iter().zip(&entry.placed).filter(|(shape, _)| shape.hits(*point)).map(move |(shape, placed)| { - format!( - "[tier {tier} root {} owner {} part {:?} sense {:?} level {:?} pos {} order {} clip_in {}]", - diag_id(*root), - diag_id(shape.owner), - shape.part, - shape.sense, - shape.priority.level, - shape.position, - placed.order, - placed.clip.contains(*point) - ) - }) - }) - .collect(); - let foreign = |widget: Option| widget.map(|widget| (diag_id(widget), !registered_in(&record.last, widget))); - eprintln!( - "DIAG {test}: press_winner at {at:?} layer {layer:?} body {:?} click {:?} drag {:?} shown {shown} hits {hits:?}", - beneath.map(|(root, parent, _)| (diag_id(root), parent)), - foreign(targets.click), - foreign(targets.drag) - ); - } if targets.click.is_some_and(|widget| !registered_in(&record.last, widget)) { return PressWinners::default(); } @@ -682,36 +652,7 @@ fn find_press_winners(ctx: &Context, viewport: ViewportId, at: Pos2, targets: Pr } } winners - }); - if let Some(test) = diag_test() { - let show = |found: Option<(Winner, Id)>| found.map(|(winner, root)| (diag_id(root), diag_id(winner.owner), winner.part, winner.sense)); - eprintln!("DIAG {test}: press_winner at {at:?} -> click {:?} drag {:?}", show(found.click), show(found.drag)); - } - found -} - -/// DIAG: the test under study this thread runs, if any. -pub(crate) fn diag_test() -> Option<&'static str> { - const TESTS: [&str; 8] = [ - "delete_removes_the_plane_and_escape_drops_a_half_plane_first", - "a_window_mounts_edges_resize_the_window_and_the_childs_press_keeps_its_click", - "gradient_map_stop_picker_closed_without_a_colour_changes_nothing", - "photo_filter_colour_picker_previews_live_cancel_restores_and_ok_is_one_step", - "every_paragraph_box_handle_resizes_the_box_with_snapping_on", - "click_inside_the_paragraph_box_off_the_glyphs_moves_the_caret", - "a_crop_drag_begun_before_the_dialog_still_ends_under_it", - "move_pointer_still_reaches_the_liquify_workspace", - ]; - // Trials run on unnamed pool threads: there the run names its trial in `CRAFT_DIAG_TEST`. - let thread = std::thread::current(); - let name = std::env::var("CRAFT_DIAG_TEST").ok().or_else(|| thread.name().map(str::to_owned))?; - TESTS.into_iter().find(|test| name.ends_with(test)) -} - -/// DIAG: the tail of an id's path. -pub(crate) fn diag_id(id: Id) -> String { - let text = format!("{id:?}"); - text.char_indices().rev().nth(90).map_or(text.clone(), |(at, _)| text[at..].to_owned()) + }) } /// Whether some root registered the egui widget `widget` in `layers`. diff --git a/crates/ui-widgets/src/notices/notice.rs b/crates/ui-widgets/src/notices/notice.rs index 77ff16043..0cfb90755 100644 --- a/crates/ui-widgets/src/notices/notice.rs +++ b/crates/ui-widgets/src/notices/notice.rs @@ -563,12 +563,6 @@ impl Component for Notice<'_> { // the column's room: in a container that sets a line length, its paragraphs' wrap width. (_, None) => cx.column_room().map_or(natural, |column| natural.min(column)), }; - { - let test = std::thread::current().name().unwrap_or("?").rsplit("::").next().unwrap_or("?").to_owned(); - if test.starts_with("an_erased_sampling") || test.starts_with("brush_strokes_change") { - eprintln!("DIAG {test}: notice measure room {:?} column {:?} natural {natural} width {width}", cx.room, cx.column_room()); - } - } Vec2::new(width, self.plan(cx, &texts, self.wrap_width(cx, width)).height) }