STDMETHODIMP ia2Accessible::get_accessibleWithCaret(IUnknown** aAccessible, long* aCaretOffset) { if (!aAccessible || !aCaretOffset) return E_INVALIDARG; *aAccessible = nullptr; *aCaretOffset = -1; AccessibleWrap* acc = static_cast<AccessibleWrap*>(this); if (acc->IsDefunct()) return CO_E_OBJNOTCONNECTED; int32_t caretOffset = -1; Accessible* accWithCaret = SelectionMgr()->AccessibleWithCaret(&caretOffset); if (!accWithCaret || acc->Document() != accWithCaret->Document()) return S_FALSE; Accessible* child = accWithCaret; while (!child->IsDoc() && child != acc) child = child->Parent(); if (child != acc) return S_FALSE; *aAccessible = static_cast<IAccessible2*>( static_cast<AccessibleWrap*>(accWithCaret)); (*aAccessible)->AddRef(); *aCaretOffset = caretOffset; return S_OK; }
// XXX Use MOZ_CAN_RUN_SCRIPT_BOUNDARY for now due to bug 1543294. MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP ia2Accessible::scrollTo(enum IA2ScrollType aScrollType) { AccessibleWrap* acc = static_cast<AccessibleWrap*>(this); if (acc->IsDefunct()) return CO_E_OBJNOTCONNECTED; MOZ_ASSERT(!acc->IsProxy()); RefPtr<PresShell> presShell = acc->Document()->PresShellPtr(); nsCOMPtr<nsIContent> content = acc->GetContent(); nsCoreUtils::ScrollTo(presShell, content, aScrollType); return S_OK; }
STDMETHODIMP ia2Accessible::scrollTo(enum IA2ScrollType aScrollType) { AccessibleWrap* acc = static_cast<AccessibleWrap*>(this); if (acc->IsDefunct()) return CO_E_OBJNOTCONNECTED; MOZ_ASSERT(!acc->IsProxy()); nsCoreUtils::ScrollTo(acc->Document()->PresShell(), acc->GetContent(), aScrollType); return S_OK; }
STDMETHODIMP ia2Accessible::get_selectionRanges(IA2Range** aRanges, long *aNRanges) { if (!aRanges || !aNRanges) return E_INVALIDARG; *aNRanges = 0; AccessibleWrap* acc = static_cast<AccessibleWrap*>(this); if (acc->IsDefunct()) return CO_E_OBJNOTCONNECTED; AutoTArray<TextRange, 1> ranges; acc->Document()->SelectionRanges(&ranges); uint32_t len = ranges.Length(); for (uint32_t idx = 0; idx < len; idx++) { if (!ranges[idx].Crop(acc)) { ranges.RemoveElementAt(idx); } } *aNRanges = ranges.Length(); *aRanges = static_cast<IA2Range*>( ::CoTaskMemAlloc(sizeof(IA2Range) * *aNRanges)); if (!*aRanges) return E_OUTOFMEMORY; for (uint32_t idx = 0; idx < static_cast<uint32_t>(*aNRanges); idx++) { AccessibleWrap* anchor = static_cast<AccessibleWrap*>(ranges[idx].StartContainer()); (*aRanges)[idx].anchor = static_cast<IAccessible2*>(anchor); anchor->AddRef(); (*aRanges)[idx].anchorOffset = ranges[idx].StartOffset(); AccessibleWrap* active = static_cast<AccessibleWrap*>(ranges[idx].EndContainer()); (*aRanges)[idx].active = static_cast<IAccessible2*>(active); active->AddRef(); (*aRanges)[idx].activeOffset = ranges[idx].EndOffset(); } return S_OK; }
void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) { mFocusPath.Clear(); if (IPCAccessibilityActive()) { DocAccessibleChild* ipcDoc = IPCDoc(); nsTArray<BatchData> cacheData; for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent(); acc = static_cast<AccessibleWrap*>(acc->Parent())) { auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc() ? 0 : reinterpret_cast<uint64_t>(acc->UniqueID()); nsAutoString name; acc->Name(name); nsAutoString textValue; acc->Value(textValue); nsAutoString nodeID; acc->WrapperDOMNodeID(nodeID); nsCOMPtr<nsIPersistentProperties> props = acc->Attributes(); nsTArray<Attribute> attributes; nsAccUtils::PersistentPropertiesToArray(props, &attributes); cacheData.AppendElement(BatchData( acc->Document()->IPCDoc(), uid, acc->State(), acc->Bounds(), acc->ActionCount(), name, textValue, nodeID, acc->CurValue(), acc->MinValue(), acc->MaxValue(), acc->Step(), attributes)); mFocusPath.Put(acc->UniqueID(), acc); } ipcDoc->SendBatch(eBatch_FocusPath, cacheData); } else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(this)) { nsTArray<AccessibleWrap*> accessibles; for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent(); acc = static_cast<AccessibleWrap*>(acc->Parent())) { accessibles.AppendElement(acc); } sessionAcc->ReplaceFocusPathCache(accessibles); } }