Bug 873438 - Implement IAccessible2_2::accessibleWithCaret, r=yzen

This commit is contained in:
Alexander Surkov 2015-10-06 12:36:47 -04:00
parent 2764b0443c
commit a94a922597

View File

@ -18,6 +18,7 @@
#include "nsIAccessibleTypes.h"
#include "mozilla/a11y/PDocAccessible.h"
#include "Relation.h"
#include "nsAccessibilityService.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
@ -651,7 +652,27 @@ ia2Accessible::get_accessibleWithCaret(IUnknown** aAccessible,
*aAccessible = nullptr;
*aCaretOffset = -1;
return E_NOTIMPL;
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
if (acc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
int32_t caretOffset = -1;
Accessible* accWithCaret = SelectionMgr()->AccessibleWithCaret(&caretOffset);
if (acc->Document() != accWithCaret->Document())
return S_FALSE;
Accessible* child = accWithCaret;
while (child != acc)
child = child->Parent();
if (!child)
return S_FALSE;
*aAccessible = static_cast<IAccessible2*>(
static_cast<AccessibleWrap*>(accWithCaret));
*aCaretOffset = caretOffset;
return S_OK;
A11Y_TRYBLOCK_END
}