Skip to main content

block_geometry

Function block_geometry 

Source
pub fn block_geometry(
    intrinsic: (u32, u32),
    fit: MediaFit,
    line_height_px: f32,
    pane_width_px: f32,
) -> (u16, f32)
Expand description

How much space a block should take, given what it is and where it goes.

Returns (rows, height_lh):

  • rows โ€” display rows to reserve. Both peers agree on this, which is what keeps scroll (a row index) anchoring the same source line whichever renderer is running.
  • height_lh โ€” the drawn height in line-heights, which the drawing peer spends through RowWeights. Deliberately allowed to be fractional: a 3.4-line-height image reserves 4 rows and draws 3.4 of them. Snapping it to 4 is what ยง3 of the design rejected, because it makes the rendered size a function of the font size.

rows is ceil(height_lh) so the reservation never under-covers the drawing โ€” an image must not paint over the line beneath it.