Name every silent input rejection with WebSurfaceInputOutcome

bool returns on the five record_* surface inputs collapsed nine real
outcomes into one bit. The cascade we found in this round — silent
click drop because viewport_bounds wasn't measured yet, then
keyboard_focus stays None, then typing also "fails" — looked like
three independent symptoms but was one root cause hiding inside
that bit. Replace the bool with a #[must_use] WebSurfaceInputOutcome
enum so each rejection names itself at the call site.

Variants map 1:1 to real return points in web_surface.rs:
  Applied / NoChange / Buffered — three distinct success-ish states
  the controller already needed to disambiguate (only Applied notifies)
  DroppedInvalidBounds — geometry rejected zero/NaN viewport
  DroppedNoViewportBounds — input arrived before the viewport tracker
  DroppedOutOfBounds — window position outside the viewport rect
  DroppedZeroDelta — wheel rounded to zero device px
  DroppedEmptyText — empty record_typed_text
  DroppedNoKeyboardFocus — type without a prior click
  DroppedFocusMismatch — focus belongs to another tab/url

Behavior preserved: Applied is the only notify trigger, matching the
old `true` semantics. Three new negative-path tests (no_viewport_bounds,
zero_delta, no_keyboard_focus) lock the named drops so a future
regression surfaces as a wrong variant in tests instead of a missing
repaint. cargo test ely_app --bin ely_app web_surface: 17 passed.
This commit is contained in:
2026-05-10 02:00:52 -04:00
parent c20daf36b9
commit b8795bf903
5 changed files with 159 additions and 54 deletions
@@ -7,7 +7,7 @@ use crate::services::ProfileDataMode;
use super::{
ElyShell,
web_surface_permissions::web_surface_site_permissions_for_tab,
web_surface_state::WebSurfaceState,
web_surface_state::{WebSurfaceInputOutcome, WebSurfaceState},
web_surface_view::{
render_failed_web_surface, render_loading_web_surface, render_ready_web_surface,
},
@@ -55,7 +55,9 @@ impl ElyShell {
scale_factor: f32,
cx: &mut Context<Self>,
) {
if self.web_surfaces.record_viewport_size(&tab_id, bounds, scale_factor) {
if self.web_surfaces.record_viewport_size(&tab_id, bounds, scale_factor)
== WebSurfaceInputOutcome::Applied
{
cx.notify();
}
}
@@ -73,7 +75,8 @@ impl ElyShell {
requested_url.as_str(),
delta,
scale_factor,
) {
) == WebSurfaceInputOutcome::Applied
{
cx.notify();
}
}
@@ -85,7 +88,9 @@ impl ElyShell {
scale_factor: f32,
cx: &mut Context<Self>,
) {
if self.web_surfaces.record_hover_point(&tab_id, position, scale_factor) {
if self.web_surfaces.record_hover_point(&tab_id, position, scale_factor)
== WebSurfaceInputOutcome::Applied
{
cx.notify();
}
}
@@ -105,7 +110,8 @@ impl ElyShell {
requested_url.as_str(),
position,
scale_factor,
) {
) == WebSurfaceInputOutcome::Applied
{
cx.notify();
}
}
@@ -125,7 +131,9 @@ impl ElyShell {
text: &str,
cx: &mut Context<Self>,
) -> bool {
if self.web_surfaces.record_typed_text(&tab_id, requested_url.as_str(), text) {
if self.web_surfaces.record_typed_text(&tab_id, requested_url.as_str(), text)
== WebSurfaceInputOutcome::Applied
{
cx.notify();
return true;
}