Created attachment 229799 [details]
patch with a test case
Under some circumstances text enclosed directly in <body> does not behave like text. atk_text_set_caret_offset does not allow to position the cursor inside it and caret-moved events are not emitted.
The simple example is as follows:
Divs are accessible, but the text between them is not. If there were no misleading divs, the text alone is accessible. Once a div after or before is added, the problem arises.
I prepared a test case for that. To make such tests easier I prepared a helper testWebkitAtkCaretWalk method. So in this testatk.c diff there is also a test case for bug #130941 included. The name of the test for this bug report is caretInBody.
In Source/WebCore/accessibility/AccessibilityRenderObject.cpp, function AccessibilityRenderObject::textUnderElement, line 664, we have a comment:
// For anonymous blocks, we work around not having a direct node to create a range from
// defining one based in the two external positions defining the boundaries of the subtree.
But when we set cursor position, we rely on visiblePositionForIndex, the same file, line 1859. There it returns empty position for anonymous blocks (!node).