resolveCaretX method
Caret coordinate resolver for vertical navigation.
Optimized to O(1) by looking up the paragraph render directly via the fragment's logical container, instead of scanning every registered render.
Implementation
double resolveCaretX(CaretStop stop) {
final containerId = findLogicalContainerId(stop.fragmentId);
if (containerId != null) {
final render = _paragraphRegistry.renderFor(containerId);
final x = render?.getCaretX(stop.fragmentId, stop.offset);
if (x != null) return x;
}
final box = _findBlockImageBox(stop.fragmentId);
if (box == null) return 0.0;
final origin = box.localToGlobal(Offset.zero);
return origin.dx + (stop.offset == 0 ? 0 : box.size.width);
}