Calculate the visual bounding rect for an element, balancing two
heuristics:
Shrink-to-fit — when the focused element is a link/card whose
dominant visible content is a single media child (img / picture /
svg / video / canvas), use the child's rect. Outlines what the
user perceives as "the focused thing" instead of the larger
wrapper card. The "single media child" + "no significant text
siblings" gates prevent shrinking icon-plus-label links to their
icon.
Expand-to-fit — when the focused element has an image-like
child that overflows the hit area (logos, image-buttons), use
the larger child rect so the visual outline matches the visual
asset, not the smaller tap target.
Shrink is tried first; if no qualifying single visible media child
exists, the expand path falls through. Both paths preserve the
original behaviour for elements whose own rect already matches their
visible content (the common case — buttons, inputs, plain links).
Calculate the visual bounding rect for an element, balancing two heuristics:
Shrink-to-fit — when the focused element is a link/card whose dominant visible content is a single media child (img / picture / svg / video / canvas), use the child's rect. Outlines what the user perceives as "the focused thing" instead of the larger wrapper card. The "single media child" + "no significant text siblings" gates prevent shrinking icon-plus-label links to their icon.
Expand-to-fit — when the focused element has an image-like child that overflows the hit area (logos, image-buttons), use the larger child rect so the visual outline matches the visual asset, not the smaller tap target.
Shrink is tried first; if no qualifying single visible media child exists, the expand path falls through. Both paths preserve the original behaviour for elements whose own rect already matches their visible content (the common case — buttons, inputs, plain links).