bug 1172053 - don't malloc the signal name in FireAtkTextChangedEvent r=lsocks

This commit is contained in:
Trevor Saunders 2015-06-05 13:52:36 -04:00
parent fddc9128ab
commit 03bc59adfb

View File

@ -1451,6 +1451,21 @@ MaiAtkObject::FireStateChangeEvent(uint64_t aState, bool aEnabled)
} }
} }
#define OLD_TEXT_INSERTED "text_changed::insert"
#define OLD_TEXT_REMOVED "text_changed::delete"
static const char* oldTextChangeStrings[2][2] = {
{ OLD_TEXT_REMOVED NON_USER_EVENT, OLD_TEXT_INSERTED NON_USER_EVENT },
{ OLD_TEXT_REMOVED, OLD_TEXT_INSERTED }
};
#define TEXT_INSERTED "text-insert"
#define TEXT_REMOVED "text-remove"
#define NON_USER_DETAIL "::system"
static const char* textChangedStrings[2][2] = {
{ TEXT_REMOVED NON_USER_DETAIL, TEXT_INSERTED NON_USER_DETAIL },
{ TEXT_REMOVED, TEXT_INSERTED}
};
nsresult nsresult
AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent, AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
AtkObject* aObject) AtkObject* aObject)
@ -1462,7 +1477,6 @@ AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
uint32_t length = event->GetLength(); uint32_t length = event->GetLength();
bool isInserted = event->IsTextInserted(); bool isInserted = event->IsTextInserted();
bool isFromUserInput = aEvent->IsFromUserInput(); bool isFromUserInput = aEvent->IsFromUserInput();
char* signal_name = nullptr;
if (gAvailableAtkSignals == eUnknown) if (gAvailableAtkSignals == eUnknown)
gAvailableAtkSignals = gAvailableAtkSignals =
@ -1473,20 +1487,18 @@ AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
// XXX remove this code and the gHaveNewTextSignals check when we can // XXX remove this code and the gHaveNewTextSignals check when we can
// stop supporting old atk since it doesn't really work anyway // stop supporting old atk since it doesn't really work anyway
// see bug 619002 // see bug 619002
signal_name = g_strconcat(isInserted ? "text_changed::insert" : const char* signal_name =
"text_changed::delete", oldTextChangeStrings[isFromUserInput][isInserted];
isFromUserInput ? "" : NON_USER_EVENT, nullptr);
g_signal_emit_by_name(aObject, signal_name, start, length); g_signal_emit_by_name(aObject, signal_name, start, length);
} else { } else {
nsAutoString text; nsAutoString text;
event->GetModifiedText(text); event->GetModifiedText(text);
signal_name = g_strconcat(isInserted ? "text-insert" : "text-remove", const char* signal_name =
isFromUserInput ? "" : "::system", nullptr); textChangedStrings[isFromUserInput][isInserted];
g_signal_emit_by_name(aObject, signal_name, start, length, g_signal_emit_by_name(aObject, signal_name, start, length,
NS_ConvertUTF16toUTF8(text).get()); NS_ConvertUTF16toUTF8(text).get());
} }
g_free(signal_name);
return NS_OK; return NS_OK;
} }