Change Iea6656882293e8e3cc78df87c31afe58ff59c7e8 fixed T110378 , which was caused by getNodeAndOffset crashing on
slugless branch nodes with zero DM length. The fix was to re-rendering the nodes from inside getNodeAndOffset, thereby adding slugs to zero-length branch nodes.
However re-rendering can close IME candidate windows and prematurely commit
text, so we should avoid such a call inside an apparently pure function.
Slugless branch nodes with zero DM length can happen when all the content is deleted by a browser native action (without a re-render). At first I thought perhaps we could move the re-render calls to IME-safe places in the code, such that getNodeAndOffset could never be called on such a node. Unfortunately, it turns out to be impossible because of IME restrictions:
1. An IME can remove all the text out of the node at a time when it is unsafe to re-render.
2. For SurfaceObserver to poll changes, getNodeAndOffset must be called at this time.
Therefore, slugless branch nodes with zero DM length cannot be avoided, and getNodeAndOffset must support them directly.