bug 1192330 - add ia2AccessibleText::UpdateTextChangeData r=surkov

Soon we will need to be able to update the text change event data from both
 HandleAccEvent() and ProxyTextChangeEvent(), so separate out the logic to do
 that into a function.
This commit is contained in:
Trevor Saunders 2015-08-06 16:57:31 -04:00
parent e43b77bce9
commit 2b5f6116ed
3 changed files with 24 additions and 9 deletions

View File

@ -622,3 +622,18 @@ ia2AccessibleText::InitTextChangeData()
ClearOnShutdown(&sLastTextChangeAcc);
ClearOnShutdown(&sLastTextChangeString);
}
void
ia2AccessibleText::UpdateTextChangeData(HyperTextAccessibleWrap* aAcc,
bool aInsert, const nsString& aStr,
int32_t aStart, uint32_t aLen)
{
if (!sLastTextChangeString)
sLastTextChangeString = new nsString();
sLastTextChangeAcc = aAcc;
sLastTextChangeStart = aStart;
sLastTextChangeEnd = aStart + aLen;
sLastTextChangeWasInsert = aInsert;
*sLastTextChangeString = aStr;
}

View File

@ -115,6 +115,9 @@ public:
/* [retval][out] */ IA2TextSegment *oldText);
static void InitTextChangeData();
static void UpdateTextChangeData(HyperTextAccessibleWrap* aAcc, bool aInsert,
const nsString& aStr, int32_t aStart,
uint32_t aLen);
protected:
static StaticRefPtr<HyperTextAccessibleWrap> sLastTextChangeAcc;

View File

@ -53,16 +53,13 @@ HyperTextAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
eventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
Accessible* accessible = aEvent->GetAccessible();
if (accessible && accessible->IsHyperText()) {
sLastTextChangeAcc =
static_cast<HyperTextAccessibleWrap*>(accessible->AsHyperText());
if (!sLastTextChangeString)
sLastTextChangeString = new nsString();
AccTextChangeEvent* event = downcast_accEvent(aEvent);
event->GetModifiedText(*sLastTextChangeString);
sLastTextChangeStart = event->GetStartOffset();
sLastTextChangeEnd = sLastTextChangeStart + event->GetLength();
sLastTextChangeWasInsert = event->IsTextInserted();
HyperTextAccessibleWrap* text =
static_cast<HyperTextAccessibleWrap*>(accessible->AsHyperText());
ia2AccessibleText::UpdateTextChangeData(text, event->IsTextInserted(),
event->ModifiedText(),
event->GetStartOffset(),
event->GetLength());
}
}