Bug 1135908 - [E10s] Proxy for Character/SelectionCount(), r=tbsaunde

This commit is contained in:
Olli Pettay 2015-02-25 14:18:17 +02:00
parent f7e9e672c5
commit 18cd3edf36
6 changed files with 65 additions and 11 deletions

View File

@ -330,12 +330,17 @@ static gint
getCharacterCountCB(AtkText *aText)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (!accWrap)
return 0;
if (accWrap) {
HyperTextAccessible* textAcc = accWrap->AsHyperText();
return
textAcc->IsDefunct() ? 0 : static_cast<gint>(textAcc->CharacterCount());
}
HyperTextAccessible* textAcc = accWrap->AsHyperText();
return textAcc->IsDefunct() ?
0 : static_cast<gint>(textAcc->CharacterCount());
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return proxy->CharacterCount();
}
return 0;
}
static gint
@ -362,14 +367,20 @@ static gint
getTextSelectionCountCB(AtkText *aText)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (!accWrap)
return 0;
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return 0;
}
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return 0;
return text->SelectionCount();
}
return text->SelectionCount();
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return proxy->SelectionCount();
}
return 0;
}
static gchar*

View File

@ -207,6 +207,22 @@ DocAccessibleChild::RecvRelations(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvCharacterCount(const uint64_t& aID, int32_t* aCount)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
*aCount = acc ? acc->CharacterCount() : 0;
return true;
}
bool
DocAccessibleChild::RecvSelectionCount(const uint64_t& aID, int32_t* aCount)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
*aCount = acc ? acc->SelectionCount() : 0;
return true;
}
bool
DocAccessibleChild::RecvTextSubstring(const uint64_t& aID,
const int32_t& aStartOffset,

View File

@ -63,6 +63,12 @@ public:
virtual bool RecvAttributes(const uint64_t& aID,
nsTArray<Attribute> *aAttributes) MOZ_OVERRIDE;
virtual bool RecvCharacterCount(const uint64_t& aID, int32_t* aCount)
MOZ_OVERRIDE;
virtual bool RecvSelectionCount(const uint64_t& aID, int32_t* aCount)
MOZ_OVERRIDE;
virtual bool RecvTextSubstring(const uint64_t& aID,
const int32_t& aStartOffset,
const int32_t& aEndOffset, nsString* aText)

View File

@ -65,6 +65,8 @@ child:
// AccessibleText
// TextSubstring is getText in IDL.
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);
prio(high) sync GetTextAfterOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType)

View File

@ -149,6 +149,22 @@ ProxyAccessible::Relations(nsTArray<RelationType>* aTypes,
}
}
int32_t
ProxyAccessible::CharacterCount()
{
int32_t count = 0;
unused << mDoc->SendCharacterCount(mID, &count);
return count;
}
int32_t
ProxyAccessible::SelectionCount()
{
int32_t count = 0;
unused << mDoc->SendSelectionCount(mID, &count);
return count;
}
void
ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const

View File

@ -99,6 +99,9 @@ public:
void Relations(nsTArray<RelationType>* aTypes,
nsTArray<nsTArray<ProxyAccessible*>>* aTargetSets) const;
int32_t CharacterCount();
int32_t SelectionCount();
/**
* Get the text between the given offsets.
*/