Created attachment 446883 [details] [diff] [review] patch Hyper text accessible methods take magic number -2 to start working relative caret offset, for example, get text at offset method. It makes us traverse the children twice: first time to calculate caret offset and the second time to find an accessible at offset. Also current implementation of GetCaretOffset isn't very perfromant. 1) it doesn't ensure the focused node is in the document of hypertext accessible 2) it makes some unnecessary computations 2.1) IsAncestorOf() while hypertext accessible is focused 2.2) It gets selection and transforms it into hypertext offset while focus in in subtree of hypertext accessible which means embedded character is focused and all we need is to its offset 3) it traverses DOM tree, however a11y tree would be more performance since it's shorter. I'm putting wip patch. I'll get back to it when we'll make sure we expose correct accessible tree, otherwise it bothers me if we can trust a11y tree during traversal.
we have now SelectionManager::AccessibleWithCaret() method