Hopefully this is possible by invoking a method that gets executed by browser internal code. Given a point x,y in dom coordinates. (that is can get relative to any node) in an element containing text I want effectively
charIndex = characterUnderPoint(textNode,nodex,nodey);
I figure if there is some sort of facilty to do
range = xx.creatRange(node,x,y)
or
selection = xx.createSelection(node,x,y)
or
range.setAnchorToLocation(node,x,y)
etc.
I can't find anything so far that implements effectively what happens when you click to set the caret position. all the methods seem to only take a character offset.
Mainly I want this because searching by incrementing a range through all the chars to test whether the point is in it is very slow (could be a binary search but) it should be done inside the layout engine in native code to be fast.