bug 1151402 - proxy most of IAccessibleText and IAccessibleEditableText

r=davidb


--HG--
rename : accessible/windows/msaa/Platform.cpp => accessible/windows/ProxyWrappers.h
This commit is contained in:
Trevor Saunders 2015-04-06 06:04:44 -04:00
Родитель e69f6f626a
Коммит cec589153c
13 изменённых файлов: 282 добавлений и 116 удалений

Просмотреть файл

@ -294,13 +294,14 @@ bool
DocAccessibleChild::RecvTextSubstring(const uint64_t& aID,
const int32_t& aStartOffset,
const int32_t& aEndOffset,
nsString* aText)
nsString* aText, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (!acc) {
return true;
}
*aValid = acc->IsValidRange(aStartOffset, aEndOffset);
acc->TextSubstring(aStartOffset, aEndOffset, *aText);
return true;
}
@ -561,10 +562,11 @@ DocAccessibleChild::RecvReplaceText(const uint64_t& aID,
bool
DocAccessibleChild::RecvInsertText(const uint64_t& aID,
const nsString& aText,
const int32_t& aPosition)
const int32_t& aPosition, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidOffset(aPosition);
acc->InsertText(aText, aPosition);
}
@ -574,7 +576,7 @@ DocAccessibleChild::RecvInsertText(const uint64_t& aID,
bool
DocAccessibleChild::RecvCopyText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos)
const int32_t& aEndPos, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
@ -587,10 +589,11 @@ DocAccessibleChild::RecvCopyText(const uint64_t& aID,
bool
DocAccessibleChild::RecvCutText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos)
const int32_t& aEndPos, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidRange(aStartPos, aEndPos);
acc->CutText(aStartPos, aEndPos);
}
@ -600,10 +603,11 @@ DocAccessibleChild::RecvCutText(const uint64_t& aID,
bool
DocAccessibleChild::RecvDeleteText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos)
const int32_t& aEndPos, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidRange(aStartPos, aEndPos);
acc->DeleteText(aStartPos, aEndPos);
}
@ -612,10 +616,11 @@ DocAccessibleChild::RecvDeleteText(const uint64_t& aID,
bool
DocAccessibleChild::RecvPasteText(const uint64_t& aID,
const int32_t& aPosition)
const int32_t& aPosition, bool* aValid)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidOffset(aPosition);
acc->PasteText(aPosition);
}

Просмотреть файл

@ -75,8 +75,8 @@ public:
virtual bool RecvTextSubstring(const uint64_t& aID,
const int32_t& aStartOffset,
const int32_t& aEndOffset, nsString* aText)
override;
const int32_t& aEndOffset, nsString* aText,
bool* aValid) override;
virtual bool RecvGetTextAfterOffset(const uint64_t& aID,
const int32_t& aOffset,
@ -166,22 +166,22 @@ public:
virtual bool RecvInsertText(const uint64_t& aID,
const nsString& aText,
const int32_t& aPosition) override;
const int32_t& aPosition, bool* aValid) override;
virtual bool RecvCopyText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos) override;
const int32_t& aEndPos, bool* aValid) override;
virtual bool RecvCutText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos) override;
const int32_t& aEndPos, bool* aValid) override;
virtual bool RecvDeleteText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos) override;
const int32_t& aEndPos, bool* aValid) override;
virtual bool RecvPasteText(const uint64_t& aID,
const int32_t& aPosition) override;
const int32_t& aPosition, bool* aValid) override;
virtual bool RecvImagePosition(const uint64_t& aID,
const uint32_t& aCoordType,

Просмотреть файл

@ -82,7 +82,7 @@ child:
prio(high) sync CharacterCount(uint64_t aID) returns(int32_t aCount);
prio(high) sync SelectionCount(uint64_t aID) returns(int32_t aCount);
prio(high) sync TextSubstring(uint64_t aID, int32_t aStartOffset, int32_t
aEndOffset) returns(nsString aText);
aEndOffset) returns(nsString aText, bool aValid);
prio(high) sync GetTextAfterOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType)
returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
prio(high) sync GetTextAtOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType)
@ -124,11 +124,16 @@ child:
int32_t aX, int32_t aY);
prio(high) sync ReplaceText(uint64_t aID, nsString aText);
prio(high) sync InsertText(uint64_t aID, nsString aText, int32_t aPosition);
prio(high) sync CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
prio(high) sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
prio(high) sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
prio(high) sync PasteText(uint64_t aID, int32_t aPosition);
prio(high) sync InsertText(uint64_t aID, nsString aText, int32_t aPosition)
returns(bool aValid);
prio(high) sync CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
prio(high) sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
prio(high) sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
prio(high) sync PasteText(uint64_t aID, int32_t aPosition)
returns(bool aValid);
prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(nsIntPoint aRetVal);
prio(high) sync ImageSize(uint64_t aID) returns(IntSize aRetVal);

Просмотреть файл

@ -181,11 +181,13 @@ ProxyAccessible::SelectionCount()
return count;
}
void
bool
ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const
{
unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOfset, &aText);
bool valid;
unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOfset, &aText, &valid);
return valid;
}
void
@ -333,34 +335,44 @@ ProxyAccessible::ReplaceText(const nsString& aText)
unused << mDoc->SendReplaceText(mID, aText);
}
void
bool
ProxyAccessible::InsertText(const nsString& aText, int32_t aPosition)
{
unused << mDoc->SendInsertText(mID, aText, aPosition);
bool valid;
unused << mDoc->SendInsertText(mID, aText, aPosition, &valid);
return valid;
}
void
bool
ProxyAccessible::CopyText(int32_t aStartPos, int32_t aEndPos)
{
unused << mDoc->SendCopyText(mID, aStartPos, aEndPos);
bool valid;
unused << mDoc->SendCopyText(mID, aStartPos, aEndPos, &valid);
return valid;
}
void
bool
ProxyAccessible::CutText(int32_t aStartPos, int32_t aEndPos)
{
unused << mDoc->SendCutText(mID, aStartPos, aEndPos);
bool valid;
unused << mDoc->SendCutText(mID, aStartPos, aEndPos, &valid);
return valid;
}
void
bool
ProxyAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos)
{
unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos);
bool valid;
unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos, &valid);
return valid;
}
void
bool
ProxyAccessible::PasteText(int32_t aPosition)
{
unused << mDoc->SendPasteText(mID, aPosition);
bool valid;
unused << mDoc->SendPasteText(mID, aPosition, &valid);
return valid;
}
nsIntPoint

Просмотреть файл

@ -114,7 +114,7 @@ public:
/**
* Get the text between the given offsets.
*/
void TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
bool TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const;
void GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
@ -169,15 +169,15 @@ public:
void ReplaceText(const nsString& aText);
void InsertText(const nsString& aText, int32_t aPosition);
bool InsertText(const nsString& aText, int32_t aPosition);
void CopyText(int32_t aStartPos, int32_t aEndPos);
bool CopyText(int32_t aStartPos, int32_t aEndPos);
void CutText(int32_t aStartPos, int32_t aEndPos);
bool CutText(int32_t aStartPos, int32_t aEndPos);
void DeleteText(int32_t aStartPos, int32_t aEndPos);
bool DeleteText(int32_t aStartPos, int32_t aEndPos);
void PasteText(int32_t aPosition);
bool PasteText(int32_t aPosition);
nsIntPoint ImagePosition(uint32_t aCoordType);

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. *
*/
#ifndef MOZILLA_A11Y_ProxyWrappers_h
#define MOZILLA_A11Y_ProxyWrappers_h
#include "HyperTextAccessible.h"
namespace mozilla {
namespace a11y {
class ProxyAccessibleWrap : public AccessibleWrap
{
public:
ProxyAccessibleWrap(ProxyAccessible* aProxy) :
AccessibleWrap(nullptr, nullptr)
{
mType = eProxyType;
mBits.proxy = aProxy;
}
virtual void Shutdown() override
{
mBits.proxy = nullptr;
}
};
class HyperTextProxyAccessibleWrap : public ProxyAccessibleWrap,
public ia2AccessibleEditableText,
public ia2AccessibleHypertext
{
HyperTextProxyAccessibleWrap(ProxyAccessible* aProxy) :
ProxyAccessibleWrap(aProxy) {}
};
template<typename T>
inline ProxyAccessible*
HyperTextProxyFor(T* aWrapper)
{
static_assert(mozilla::IsBaseOf<IUnknown, T>::value, "only IAccessible* should be passed in");
auto wrapper = static_cast<HyperTextProxyAccessibleWrap*>(aWrapper);
return wrapper->IsProxy() ? wrapper->Proxy() : nullptr;
}
}
}
#endif

Просмотреть файл

@ -619,22 +619,7 @@ ia2Accessible::get_attributes(BSTR* aAttributes)
nsTArray<Attribute> attrs;
acc->Proxy()->Attributes(&attrs);
nsString attrStr;
size_t attrCount = attrs.Length();
for (size_t i = 0; i < attrCount; i++) {
EscapeAttributeChars(attrs[i].Name());
EscapeAttributeChars(attrs[i].Value());
AppendUTF8toUTF16(attrs[i].Name(), attrStr);
attrStr.Append(':');
attrStr.Append(attrs[i].Value());
attrStr.Append(';');
}
if (attrStr.IsEmpty())
return S_FALSE;
*aAttributes = ::SysAllocStringLen(attrStr.get(), attrStr.Length());
return *aAttributes ? S_OK : E_OUTOFMEMORY;
return ConvertToIA2Attributes(&attrs, aAttributes);
A11Y_TRYBLOCK_END
}
@ -747,6 +732,28 @@ EscapeAttributeChars(String& aStr)
}
}
HRESULT
ia2Accessible::ConvertToIA2Attributes(nsTArray<Attribute>* aAttributes,
BSTR* aIA2Attributes)
{
nsString attrStr;
size_t attrCount = aAttributes->Length();
for (size_t i = 0; i < attrCount; i++) {
EscapeAttributeChars(aAttributes->ElementAt(i).Name());
EscapeAttributeChars(aAttributes->ElementAt(i).Value());
AppendUTF8toUTF16(aAttributes->ElementAt(i).Name(), attrStr);
attrStr.Append(':');
attrStr.Append(aAttributes->ElementAt(i).Value());
attrStr.Append(';');
}
if (attrStr.IsEmpty())
return S_FALSE;
*aIA2Attributes = ::SysAllocStringLen(attrStr.get(), attrStr.Length());
return *aIA2Attributes ? S_OK : E_OUTOFMEMORY;
}
HRESULT
ia2Accessible::ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
BSTR* aIA2Attributes)

Просмотреть файл

@ -13,6 +13,7 @@
namespace mozilla {
namespace a11y {
class Attribute;
class ia2Accessible : public IAccessible2_2
{
@ -106,6 +107,8 @@ public:
// Helper method
static HRESULT ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
BSTR* aIA2Attributes);
static HRESULT ConvertToIA2Attributes(nsTArray<Attribute>* aAttributes,
BSTR* aIA2Attributes);
};
} // namespace a11y

Просмотреть файл

@ -10,6 +10,7 @@
#include "AccessibleEditableText_i.c"
#include "HyperTextAccessible-inl.h"
#include "HyperTextAccessibleWrap.h"
#include "ProxyWrappers.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -23,6 +24,10 @@ ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->CopyText(aStartOffset, aEndOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -41,6 +46,10 @@ ia2AccessibleEditableText::deleteText(long aStartOffset, long aEndOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->DeleteText(aStartOffset, aEndOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -59,6 +68,12 @@ ia2AccessibleEditableText::insertText(long aOffset, BSTR *aText)
{
A11Y_TRYBLOCK_BEGIN
uint32_t length = ::SysStringLen(*aText);
nsAutoString text(*aText, length);
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->InsertText(text, aOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -66,9 +81,6 @@ ia2AccessibleEditableText::insertText(long aOffset, BSTR *aText)
if (!textAcc->IsValidOffset(aOffset))
return E_INVALIDARG;
uint32_t length = ::SysStringLen(*aText);
nsAutoString text(*aText, length);
textAcc->InsertText(text, aOffset);
return S_OK;
@ -80,6 +92,10 @@ ia2AccessibleEditableText::cutText(long aStartOffset, long aEndOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->CutText(aStartOffset, aEndOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -98,6 +114,10 @@ ia2AccessibleEditableText::pasteText(long aOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->PasteText(aOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;

Просмотреть файл

@ -12,6 +12,7 @@
#include "HyperTextAccessibleWrap.h"
#include "HyperTextAccessible-inl.h"
#include "ProxyWrappers.h"
using namespace mozilla::a11y;
@ -22,6 +23,11 @@ ia2AccessibleText::addSelection(long aStartOffset, long aEndOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->AddToSelection(aStartOffset, aEndOffset) ?
S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -45,16 +51,23 @@ ia2AccessibleText::get_attributes(long aOffset, long *aStartOffset,
*aEndOffset = 0;
*aTextAttributes = nullptr;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
int32_t startOffset = 0, endOffset = 0;
nsCOMPtr<nsIPersistentProperties> attributes =
textAcc->TextAttributes(true, aOffset, &startOffset, &endOffset);
HRESULT hr;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
nsAutoTArray<Attribute, 10> attrs;
proxy->TextAttributes(true, aOffset, &attrs, &startOffset, &endOffset);
hr = AccessibleWrap::ConvertToIA2Attributes(&attrs, aTextAttributes);
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIPersistentProperties> attributes =
textAcc->TextAttributes(true, aOffset, &startOffset, &endOffset);
hr = AccessibleWrap::ConvertToIA2Attributes(attributes, aTextAttributes);
}
HRESULT hr = AccessibleWrap::ConvertToIA2Attributes(attributes,
aTextAttributes);
if (FAILED(hr))
return hr;
@ -76,11 +89,16 @@ ia2AccessibleText::get_caretOffset(long *aOffset)
*aOffset = -1;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
*aOffset = proxy->CaretOffset();
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
*aOffset = textAcc->CaretOffset();
}
*aOffset = textAcc->CaretOffset();
return *aOffset != -1 ? S_OK : S_FALSE;
A11Y_TRYBLOCK_END
@ -98,15 +116,19 @@ ia2AccessibleText::get_characterExtents(long aOffset,
return E_INVALIDARG;
*aX = *aY = *aWidth = *aHeight = 0;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
nsIntRect rect;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
rect = proxy->CharBounds(aOffset, geckoCoordType);
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsIntRect rect = textAcc->CharBounds(aOffset, geckoCoordType);
rect = textAcc->CharBounds(aOffset, geckoCoordType);
}
*aX = rect.x;
*aY = rect.y;
@ -126,11 +148,16 @@ ia2AccessibleText::get_nSelections(long* aNSelections)
return E_INVALIDARG;
*aNSelections = 0;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
*aNSelections = proxy->SelectionCount();
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
*aNSelections = textAcc->SelectionCount();
}
*aNSelections = textAcc->SelectionCount();
return S_OK;
A11Y_TRYBLOCK_END
@ -147,15 +174,20 @@ ia2AccessibleText::get_offsetAtPoint(long aX, long aY,
return E_INVALIDARG;
*aOffset = 0;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
*aOffset = textAcc->OffsetAtPoint(aX, aY, geckoCoordType);
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
*aOffset = proxy->OffsetAtPoint(aX, aY, geckoCoordType);
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
*aOffset = textAcc->OffsetAtPoint(aX, aY, geckoCoordType);
}
return *aOffset == -1 ? S_FALSE : S_OK;
A11Y_TRYBLOCK_END
@ -171,13 +203,20 @@ ia2AccessibleText::get_selection(long aSelectionIndex, long* aStartOffset,
return E_INVALIDARG;
*aStartOffset = *aEndOffset = 0;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
int32_t startOffset = 0, endOffset = 0;
if (!textAcc->SelectionBoundsAt(aSelectionIndex, &startOffset, &endOffset))
return E_INVALIDARG;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
nsString unused;
if (!proxy->SelectionBoundsAt(aSelectionIndex, unused, &startOffset,
&endOffset))
return E_INVALIDARG;
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (!textAcc->SelectionBoundsAt(aSelectionIndex, &startOffset, &endOffset))
return E_INVALIDARG;
}
*aStartOffset = startOffset;
*aEndOffset = endOffset;
@ -196,15 +235,22 @@ ia2AccessibleText::get_text(long aStartOffset, long aEndOffset, BSTR* aText)
*aText = nullptr;
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset))
return E_INVALIDARG;
nsAutoString text;
textAcc->TextSubstring(aStartOffset, aEndOffset, text);
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
if (!proxy->TextSubstring(aStartOffset, aEndOffset, text)) {
return E_INVALIDARG;
}
} else {
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset))
return E_INVALIDARG;
textAcc->TextSubstring(aStartOffset, aEndOffset, text);
}
if (text.IsEmpty())
return S_FALSE;
@ -361,6 +407,10 @@ ia2AccessibleText::removeSelection(long aSelectionIndex)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->RemoveFromSelection(aSelectionIndex) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -376,6 +426,10 @@ ia2AccessibleText::setCaretOffset(long aOffset)
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->SetCaretOffset(aOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -395,6 +449,11 @@ ia2AccessibleText::setSelection(long aSelectionIndex, long aStartOffset,
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
return proxy->SetSelectionBoundsAt(aSelectionIndex, aStartOffset,
aEndOffset) ? S_OK : E_INVALIDARG;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -414,6 +473,11 @@ ia2AccessibleText::get_nCharacters(long* aNCharacters)
return E_INVALIDARG;
*aNCharacters = 0;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
*aNCharacters = proxy->CharacterCount();
return S_OK;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -430,6 +494,11 @@ ia2AccessibleText::scrollSubstringTo(long aStartIndex, long aEndIndex,
{
A11Y_TRYBLOCK_BEGIN
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
proxy->ScrollSubstringTo(aStartIndex, aEndIndex, aScrollType);
return S_OK;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -450,6 +519,16 @@ ia2AccessibleText::scrollSubstringToPoint(long aStartIndex, long aEndIndex,
{
A11Y_TRYBLOCK_BEGIN
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
proxy->ScrollSubstringToPoint(aStartIndex, aEndIndex, geckoCoordType, aX,
aY);
return S_OK;
}
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
if (textAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -457,10 +536,6 @@ ia2AccessibleText::scrollSubstringToPoint(long aStartIndex, long aEndIndex,
if (!textAcc->IsValidRange(aStartIndex, aEndIndex))
return E_INVALIDARG;
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
textAcc->ScrollSubstringToPoint(aStartIndex, aEndIndex,
geckoCoordType, aX, aY);
return S_OK;

Просмотреть файл

@ -39,6 +39,7 @@ LOCAL_INCLUDES += [
'/accessible/base',
'/accessible/generic',
'/accessible/html',
'/accessible/windows',
'/accessible/windows/msaa',
'/accessible/xpcom',
'/accessible/xul',

Просмотреть файл

@ -11,6 +11,7 @@
#include "HyperTextAccessibleWrap.h"
#include "nsWinUtils.h"
#include "mozilla/a11y/ProxyAccessible.h"
#include "ProxyWrappers.h"
#include "mozilla/ClearOnShutdown.h"
@ -35,22 +36,6 @@ a11y::PlatformShutdown()
nsWinUtils::ShutdownWindowEmulation();
}
class ProxyAccessibleWrap : public AccessibleWrap
{
public:
ProxyAccessibleWrap(ProxyAccessible* aProxy) :
AccessibleWrap(nullptr, nullptr)
{
mType = eProxyType;
mBits.proxy = aProxy;
}
virtual void Shutdown() override
{
mBits.proxy = nullptr;
}
};
void
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t)
{

Просмотреть файл

@ -48,6 +48,7 @@ LOCAL_INCLUDES += [
'/accessible/base',
'/accessible/generic',
'/accessible/html',
'/accessible/windows',
'/accessible/windows/ia2',
'/accessible/windows/sdn',
'/accessible/windows/uia',