Skip to main content

content_step

Function content_step 

Source
pub fn content_step(content: Option<f64>, visible: Option<f64>) -> Step
Expand description

The per-line scroll step computed from the document content’s size along the scroll axis and the visible viewport’s size along the same axis.

content is the size of the scroll area’s document child — the first AXChildren element that is not an AXScrollBar (typically AXTextArea, AXTable, AXOutline, or AXGroup). visible is the scroll area’s own AXSize along the axis, minus the orthogonal scroll bar’s height (or width) when both bars are present.

One wheel notch is LINE_POINTS points (≈ three text lines), so one wheel line moves LINE_POINTS / (content - visible) of the bar, clamped to 0..=1. The unit tests pin every branch:

  • Some(2400), Some(400) → 0.02 so ten wheel lines move 0.2 of the bar.
  • content <= visible → 0.0 with CONTENT_FITS_WARNING (nothing to scroll).
  • missing or non-finite sizes → DEFAULT_STEP with APPROXIMATED_WARNING (we did not measure, so the step is a guess).