зеркало из https://github.com/mozilla/gecko-dev.git
bug 1270916 - add a map from accessible and event type to an event r=davidb
This commit is contained in:
Родитель
71e552a505
Коммит
bffaebfaf0
|
@ -449,3 +449,52 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||
mObservingState = eNotObservingRefresh;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent)
|
||||
{
|
||||
EventType type = GetEventType(aEvent);
|
||||
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
||||
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
||||
addr |= type;
|
||||
mTable.Put(addr, aEvent);
|
||||
}
|
||||
|
||||
AccTreeMutationEvent*
|
||||
NotificationController::EventMap::GetEvent(Accessible* aTarget, EventType aType)
|
||||
{
|
||||
uint64_t addr = reinterpret_cast<uintptr_t>(aTarget);
|
||||
MOZ_ASSERT((addr & 0x3) == 0, "target is not 4 byte aligned");
|
||||
|
||||
addr |= aType;
|
||||
return mTable.GetWeak(addr);
|
||||
}
|
||||
|
||||
void
|
||||
NotificationController::EventMap::RemoveEvent(AccTreeMutationEvent* aEvent)
|
||||
{
|
||||
EventType type = GetEventType(aEvent);
|
||||
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
||||
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
||||
addr |= type;
|
||||
|
||||
MOZ_ASSERT(mTable.GetWeak(addr) == aEvent, "mTable has the wrong event");
|
||||
mTable.Remove(addr);
|
||||
}
|
||||
|
||||
NotificationController::EventMap::EventType
|
||||
NotificationController::EventMap::GetEventType(AccTreeMutationEvent* aEvent)
|
||||
{
|
||||
switch(aEvent->GetEventType())
|
||||
{
|
||||
case nsIAccessibleEvent::EVENT_SHOW:
|
||||
return ShowEvent;
|
||||
case nsIAccessibleEvent::EVENT_HIDE:
|
||||
return HideEvent;
|
||||
case nsIAccessibleEvent::EVENT_REORDER:
|
||||
return ReorderEvent;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("event has invalid type");
|
||||
return ShowEvent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,6 +376,32 @@ private:
|
|||
|
||||
friend class MoveGuard;
|
||||
friend class EventTree;
|
||||
|
||||
/**
|
||||
* A class to map an accessible and event type to an event.
|
||||
*/
|
||||
class EventMap
|
||||
{
|
||||
public:
|
||||
enum EventType
|
||||
{
|
||||
ShowEvent = 0x0,
|
||||
HideEvent = 0x1,
|
||||
ReorderEvent = 0x2,
|
||||
};
|
||||
|
||||
void PutEvent(AccTreeMutationEvent* aEvent);
|
||||
AccTreeMutationEvent* GetEvent(Accessible* aTarget, EventType aType);
|
||||
void RemoveEvent(AccTreeMutationEvent* aEvent);
|
||||
void Clear() { mTable.Clear(); }
|
||||
|
||||
private:
|
||||
EventType GetEventType(AccTreeMutationEvent* aEvent);
|
||||
|
||||
nsRefPtrHashtable<nsUint64HashKey, AccTreeMutationEvent> mTable;
|
||||
};
|
||||
|
||||
EventMap mMutationMap;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
|
Загрузка…
Ссылка в новой задаче