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 0dddbc6c8a
commit bca7e7be13
6 changed files with 65 additions and 11 deletions

View File

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

View File

@ -207,6 +207,22 @@ DocAccessibleChild::RecvRelations(const uint64_t& aID,
return true; 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 bool
DocAccessibleChild::RecvTextSubstring(const uint64_t& aID, DocAccessibleChild::RecvTextSubstring(const uint64_t& aID,
const int32_t& aStartOffset, const int32_t& aStartOffset,

View File

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

View File

@ -65,6 +65,8 @@ child:
// AccessibleText // AccessibleText
// TextSubstring is getText in IDL. // 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 prio(high) sync TextSubstring(uint64_t aID, int32_t aStartOffset, int32_t
aEndOffset) returns(nsString aText); aEndOffset) returns(nsString aText);
prio(high) sync GetTextAfterOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType) 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 void
ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset, ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const nsString& aText) const

View File

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