bug 1173876 - make getText{At,After,Before}OffsetCB work with proxies r=lsocks

This commit is contained in:
Trevor Saunders 2015-06-08 16:28:06 -04:00
parent f036df8e47
commit 6fb3a347e0

View File

@ -163,22 +163,24 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType, AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset) gint *aStartOffset, gint *aEndOffset)
{ {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); nsAutoString autoStr;
if (!accWrap)
return nullptr;
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
nsAutoString autoStr;
int32_t startOffset = 0, endOffset = 0; int32_t startOffset = 0, endOffset = 0;
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr); AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
ConvertTexttoAsterisks(accWrap, autoStr);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->GetTextAfterOffset(aOffset, aBoundaryType, autoStr, &startOffset,
&endOffset);
}
*aStartOffset = startOffset; *aStartOffset = startOffset;
*aEndOffset = endOffset; *aEndOffset = endOffset;
ConvertTexttoAsterisks(accWrap, autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr); NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr; return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
} }
@ -188,23 +190,26 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType, AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset) gint *aStartOffset, gint *aEndOffset)
{ {
nsAutoString autoStr;
int32_t startOffset = 0, endOffset = 0;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (!accWrap) if (accWrap) {
return nullptr; HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
nsAutoString autoStr;
int32_t startOffset = 0, endOffset = 0;
text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr); text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
*aStartOffset = startOffset;
*aEndOffset = endOffset;
ConvertTexttoAsterisks(accWrap, autoStr); ConvertTexttoAsterisks(accWrap, autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr); } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr; proxy->GetTextAtOffset(aOffset, aBoundaryType, autoStr, &startOffset,
&endOffset);
}
*aStartOffset = startOffset;
*aEndOffset = endOffset;
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
} }
static gunichar static gunichar
@ -233,22 +238,25 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType, AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset) gint *aStartOffset, gint *aEndOffset)
{ {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (!accWrap)
return nullptr;
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
nsAutoString autoStr; nsAutoString autoStr;
int32_t startOffset = 0, endOffset = 0; int32_t startOffset = 0, endOffset = 0;
text->TextBeforeOffset(aOffset, aBoundaryType, AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
&startOffset, &endOffset, autoStr); if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
text->TextBeforeOffset(aOffset, aBoundaryType,
&startOffset, &endOffset, autoStr);
ConvertTexttoAsterisks(accWrap, autoStr);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->GetTextBeforeOffset(aOffset, aBoundaryType, autoStr, &startOffset,
&endOffset);
}
*aStartOffset = startOffset; *aStartOffset = startOffset;
*aEndOffset = endOffset; *aEndOffset = endOffset;
ConvertTexttoAsterisks(accWrap, autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr); NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr; return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
} }