Bug 506206 - ASSERTION: There should always be a DOM node for an event, one more patch, r=davidb

This commit is contained in:
Alexander Surkov 2011-10-12 00:33:06 +09:00
parent 850a8d08cc
commit 00fbb506c0
2 changed files with 12 additions and 15 deletions

View File

@ -316,6 +316,10 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
for (PRUint32 idx = 0; idx < eventCount; idx++) {
AccEvent* accEvent = events[idx];
if (accEvent->mEventRule != AccEvent::eDoNotEmit) {
nsAccessible* target = accEvent->GetAccessible();
if (!target || target->IsDefunct())
continue;
// Dispatch the focus event if target is still focused.
if (accEvent->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
FocusMgr()->ProcessFocusEvent(accEvent);

View File

@ -1730,33 +1730,26 @@ nsDocAccessible::FireDelayedAccessibleEvent(AccEvent* aEvent)
void
nsDocAccessible::ProcessPendingEvent(AccEvent* aEvent)
{
nsAccessible* accessible = aEvent->GetAccessible();
if (!accessible)
return;
PRUint32 eventType = aEvent->GetEventType();
if (eventType == nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED) {
nsCOMPtr<nsIAccessibleText> accessibleText = do_QueryObject(accessible);
nsHyperTextAccessible* hyperText = aEvent->GetAccessible()->AsHyperText();
PRInt32 caretOffset;
if (accessibleText &&
NS_SUCCEEDED(accessibleText->GetCaretOffset(&caretOffset))) {
if (hyperText &&
NS_SUCCEEDED(hyperText->GetCaretOffset(&caretOffset))) {
#ifdef DEBUG_A11Y
PRUnichar chAtOffset;
accessibleText->GetCharacterAtOffset(caretOffset, &chAtOffset);
hyperText->GetCharacterAtOffset(caretOffset, &chAtOffset);
printf("\nCaret moved to %d with char %c", caretOffset, chAtOffset);
#endif
nsRefPtr<AccEvent> caretMoveEvent =
new AccCaretMoveEvent(accessible, caretOffset);
if (!caretMoveEvent)
return;
new AccCaretMoveEvent(hyperText, caretOffset);
nsEventShell::FireEvent(caretMoveEvent);
PRInt32 selectionCount;
accessibleText->GetSelectionCount(&selectionCount);
hyperText->GetSelectionCount(&selectionCount);
if (selectionCount) { // There's a selection so fire selection change as well
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
accessible);
hyperText);
}
}
}
@ -1765,7 +1758,7 @@ nsDocAccessible::ProcessPendingEvent(AccEvent* aEvent)
// Post event processing
if (eventType == nsIAccessibleEvent::EVENT_HIDE)
ShutdownChildrenInSubtree(accessible);
ShutdownChildrenInSubtree(aEvent->GetAccessible());
}
}