Bug 1139972 - IPC Proxy for charAt, r=tbsaunde

This commit is contained in:
Olli Pettay 2015-03-06 19:37:37 +02:00
parent da2f7bc6c1
commit af5f6aae1a
6 changed files with 39 additions and 7 deletions

View File

@ -183,15 +183,21 @@ static gunichar
getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
{
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;
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
return static_cast<gunichar>(text->CharAt(aOffset));
}
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
return static_cast<gunichar>(text->CharAt(aOffset));
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return static_cast<gunichar>(proxy->CharAt(aOffset));
}
return 0;
}
static gchar*

View File

@ -292,5 +292,16 @@ DocAccessibleChild::RecvGetTextBeforeOffset(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvCharAt(const uint64_t& aID,
const int32_t& aOffset,
uint16_t* aChar)
{
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
*aChar = acc && acc->IsTextRole() ?
static_cast<uint16_t>(acc->CharAt(aOffset)) : 0;
return true;
}
}
}

View File

@ -90,6 +90,10 @@ public:
nsString* aText, int32_t* aStartOffset,
int32_t* aEndOffset) MOZ_OVERRIDE;
virtual bool RecvCharAt(const uint64_t& aID,
const int32_t& aOffset,
uint16_t* aChar) MOZ_OVERRIDE;
private:
DocAccessible* mDoc;
};

View File

@ -75,6 +75,7 @@ child:
returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
prio(high) sync GetTextBeforeOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType)
returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
prio(high) sync CharAt(uint64_t aID, int32_t aOffset) returns(uint16_t aChar);
};
}

View File

@ -202,5 +202,13 @@ ProxyAccessible::GetTextBeforeOffset(int32_t aOffset,
&aText, aStartOffset, aEndOffset);
}
char16_t
ProxyAccessible::CharAt(int32_t aOffset)
{
uint16_t retval = 0;
unused << mDoc->SendCharAt(mID, aOffset, &retval);
return static_cast<char16_t>(retval);
}
}
}

View File

@ -120,6 +120,8 @@ public:
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
char16_t CharAt(int32_t aOffset);
/**
* Allow the platform to store a pointers worth of data on us.
*/