mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
bug 1172523 - Move AccessibleWrap::FireAtkTextChangedEvent to MaiAtkObject::FireTextChangeEvent r=lsocks
This commit is contained in:
parent
ba749f52dd
commit
54e3f50bb2
@ -34,7 +34,7 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
AccessibleWrap::EAvailableAtkSignals AccessibleWrap::gAvailableAtkSignals =
|
||||
MaiAtkObject::EAvailableAtkSignals MaiAtkObject::gAvailableAtkSignals =
|
||||
eUnknown;
|
||||
|
||||
//defined in ApplicationAccessibleWrap.cpp
|
||||
@ -1169,7 +1169,18 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
||||
|
||||
case nsIAccessibleEvent::EVENT_TEXT_REMOVED:
|
||||
case nsIAccessibleEvent::EVENT_TEXT_INSERTED:
|
||||
return FireAtkTextChangedEvent(aEvent, atkObj);
|
||||
{
|
||||
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
|
||||
|
||||
MAI_ATK_OBJECT(atkObj)-> FireTextChangeEvent(event->ModifiedText(),
|
||||
event->GetStartOffset(),
|
||||
event->GetLength(),
|
||||
event->IsTextInserted(),
|
||||
event->IsFromUserInput());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
case nsIAccessibleEvent::EVENT_FOCUS:
|
||||
{
|
||||
@ -1470,21 +1481,14 @@ static const char* textChangedStrings[2][2] = {
|
||||
{ TEXT_REMOVED, TEXT_INSERTED}
|
||||
};
|
||||
|
||||
nsresult
|
||||
AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
|
||||
AtkObject* aObject)
|
||||
void
|
||||
MaiAtkObject::FireTextChangeEvent(const nsString& aStr, int32_t aStart,
|
||||
uint32_t aLen, bool aIsInsert,
|
||||
bool aFromUser)
|
||||
{
|
||||
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
|
||||
|
||||
int32_t start = event->GetStartOffset();
|
||||
uint32_t length = event->GetLength();
|
||||
bool isInserted = event->IsTextInserted();
|
||||
bool isFromUserInput = aEvent->IsFromUserInput();
|
||||
|
||||
if (gAvailableAtkSignals == eUnknown)
|
||||
gAvailableAtkSignals =
|
||||
g_signal_lookup("text-insert", G_OBJECT_TYPE(aObject)) ?
|
||||
g_signal_lookup("text-insert", G_OBJECT_TYPE(this)) ?
|
||||
eHaveNewAtkTextSignals : eNoNewAtkSignals;
|
||||
|
||||
if (gAvailableAtkSignals == eNoNewAtkSignals) {
|
||||
@ -1492,18 +1496,14 @@ AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
|
||||
// stop supporting old atk since it doesn't really work anyway
|
||||
// see bug 619002
|
||||
const char* signal_name =
|
||||
oldTextChangeStrings[isFromUserInput][isInserted];
|
||||
g_signal_emit_by_name(aObject, signal_name, start, length);
|
||||
oldTextChangeStrings[aFromUser][aIsInsert];
|
||||
g_signal_emit_by_name(this, signal_name, aStart, aLen);
|
||||
} else {
|
||||
nsAutoString text;
|
||||
event->GetModifiedText(text);
|
||||
const char* signal_name =
|
||||
textChangedStrings[isFromUserInput][isInserted];
|
||||
g_signal_emit_by_name(aObject, signal_name, start, length,
|
||||
NS_ConvertUTF16toUTF8(text).get());
|
||||
textChangedStrings[aFromUser][aIsInsert];
|
||||
g_signal_emit_by_name(this, signal_name, aStart, aLen,
|
||||
NS_ConvertUTF16toUTF8(aStr).get());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define ADD_EVENT "children_changed::add"
|
||||
|
@ -79,20 +79,6 @@ protected:
|
||||
AtkObject *mAtkObject;
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
* do we have text-remove and text-insert signals if not we need to use
|
||||
* text-changed see AccessibleWrap::FireAtkTextChangedEvent() and
|
||||
* bug 619002
|
||||
*/
|
||||
enum EAvailableAtkSignals {
|
||||
eUnknown,
|
||||
eHaveNewAtkTextSignals,
|
||||
eNoNewAtkSignals
|
||||
};
|
||||
|
||||
static EAvailableAtkSignals gAvailableAtkSignals;
|
||||
|
||||
uint16_t CreateMaiInterfaces();
|
||||
};
|
||||
|
||||
|
@ -81,6 +81,26 @@ struct MaiAtkObject
|
||||
* Notify atk of a state change on this AtkObject.
|
||||
*/
|
||||
void FireStateChangeEvent(uint64_t aState, bool aEnabled);
|
||||
|
||||
/*
|
||||
* Notify ATK of a text change within this ATK object.
|
||||
*/
|
||||
void FireTextChangeEvent(const nsString& aStr, int32_t aStart, uint32_t aLen,
|
||||
bool aIsInsert, bool aIsFromUser);
|
||||
|
||||
private:
|
||||
/*
|
||||
* do we have text-remove and text-insert signals if not we need to use
|
||||
* text-changed see AccessibleWrap::FireAtkTextChangedEvent() and
|
||||
* bug 619002
|
||||
*/
|
||||
enum EAvailableAtkSignals {
|
||||
eUnknown,
|
||||
eHaveNewAtkTextSignals,
|
||||
eNoNewAtkSignals
|
||||
};
|
||||
|
||||
static EAvailableAtkSignals gAvailableAtkSignals;
|
||||
};
|
||||
|
||||
#endif /* __NS_MAI_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user