Bug 673958 - rework accessible focus handling, r=enndeaking, marcoz, tbsaunde, matspal, f=marcoz

This commit is contained in:
Alexander Surkov
2011-09-28 10:46:11 +09:00
parent ca1125e839
commit 6aff769f3a
92 changed files with 4701 additions and 1628 deletions

View File

@@ -44,9 +44,12 @@
#include "nsDocAccessible.h"
#include "nsEventShell.h"
#include "nsTextAccessible.h"
#include "FocusManager.h"
#include "TextUpdater.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// NotificationCollector
@@ -182,7 +185,8 @@ NotificationController::IsUpdatePending()
return mPresShell->IsLayoutFlushObserver() ||
mObservingState == eRefreshProcessingForUpdate ||
mContentInsertions.Length() != 0 || mNotifications.Length() != 0 ||
mTextHash.Count() != 0;
mTextHash.Count() != 0 ||
!mDocument->HasLoadState(nsDocAccessible::eTreeConstructed);
}
////////////////////////////////////////////////////////////////////////////////
@@ -312,8 +316,15 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
for (PRUint32 idx = 0; idx < eventCount; idx++) {
AccEvent* accEvent = events[idx];
if (accEvent->mEventRule != AccEvent::eDoNotEmit) {
// Dispatch the focus event if target is still focused.
if (accEvent->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
FocusMgr()->ProcessFocusEvent(accEvent);
continue;
}
mDocument->ProcessPendingEvent(accEvent);
// Fire text change event caused by tree mutation.
AccMutationEvent* showOrHideEvent = downcast_accEvent(accEvent);
if (showOrHideEvent) {
if (showOrHideEvent->mTextChangeEvent)
@@ -345,14 +356,14 @@ NotificationController::CoalesceEvents()
PRInt32 tail = numQueuedEvents - 1;
AccEvent* tailEvent = mEvents[tail];
// No node means this is application accessible (which can be a subject
// of reorder events), we do not coalesce events for it currently.
if (!tailEvent->mNode)
return;
switch(tailEvent->mEventRule) {
case AccEvent::eCoalesceFromSameSubtree:
{
// No node means this is application accessible (which is a subject of
// reorder events), we do not coalesce events for it currently.
if (!tailEvent->mNode)
return;
for (PRInt32 index = tail - 1; index >= 0; index--) {
AccEvent* thisEvent = mEvents[index];
@@ -446,21 +457,18 @@ NotificationController::CoalesceEvents()
} break; // case eCoalesceFromSameSubtree
case AccEvent::eCoalesceFromSameDocument:
case AccEvent::eCoalesceOfSameType:
{
// Used for focus event, coalesce more older event since focus event
// for accessible can be duplicated by event for its document, we are
// interested in focus event for accessible.
// Coalesce old events by newer event.
for (PRInt32 index = tail - 1; index >= 0; index--) {
AccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventType == tailEvent->mEventType &&
thisEvent->mEventRule == tailEvent->mEventRule &&
thisEvent->GetDocAccessible() == tailEvent->GetDocAccessible()) {
thisEvent->mEventRule = AccEvent::eDoNotEmit;
AccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule) {
accEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
}
} break; // case eCoalesceFromSameDocument
} break; // case eCoalesceOfSameType
case AccEvent::eRemoveDupes:
{