2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-01-01 16:49:19 -08:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
#include "AccEvent.h"
|
2010-03-17 00:10:52 -07:00
|
|
|
|
2012-04-25 04:29:40 -07:00
|
|
|
#include "ApplicationAccessibleWrap.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2012-05-27 02:01:40 -07:00
|
|
|
#include "DocAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsIAccessibleText.h"
|
2010-08-24 19:08:28 -07:00
|
|
|
#include "nsAccEvent.h"
|
2012-03-22 05:28:25 -07:00
|
|
|
#include "States.h"
|
2010-03-17 00:10:52 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
#include "nsEventStateManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIServiceManager.h"
|
2007-07-05 23:53:18 -07:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-22 05:28:25 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccEvent
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-08-10 18:44:44 -07:00
|
|
|
|
2008-08-06 05:19:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccEvent constructors
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
AccEvent::AccEvent(uint32_t aEventType, Accessible* aAccessible,
|
2010-10-20 21:16:10 -07:00
|
|
|
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule) :
|
|
|
|
mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-11-20 21:25:20 -08:00
|
|
|
if (aIsFromUserInput == eAutoDetect)
|
|
|
|
mIsFromUserInput = nsEventStateManager::IsHandlingUserInput();
|
|
|
|
else
|
|
|
|
mIsFromUserInput = aIsFromUserInput == eFromUserInput ? true : false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccEvent public methods
|
2007-04-16 21:45:42 -07:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccEvent::CreateXPCOMObject()
|
|
|
|
{
|
|
|
|
nsAccEvent* event = new nsAccEvent(this);
|
|
|
|
NS_IF_ADDREF(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AccEvent cycle collection
|
|
|
|
|
2013-01-16 20:36:02 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_1(AccEvent, mAccessible)
|
2010-08-24 19:08:28 -07:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AccEvent, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
|
|
|
|
|
2009-02-04 22:23:18 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccStateChangeEvent
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-02-04 22:23:18 -08:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccStateChangeEvent::CreateXPCOMObject()
|
2007-04-12 23:03:30 -07:00
|
|
|
{
|
2010-08-24 19:08:28 -07:00
|
|
|
nsAccEvent* event = new nsAccStateChangeEvent(this);
|
|
|
|
NS_IF_ADDREF(event);
|
|
|
|
return event;
|
2007-04-12 23:03:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccTextChangeEvent
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-06-02 05:30:13 -07:00
|
|
|
// Note: we pass in eAllowDupes to the base class because we don't support text
|
2012-05-27 02:01:40 -07:00
|
|
|
// events coalescence. We fire delayed text change events in DocAccessible but
|
2010-06-02 05:30:13 -07:00
|
|
|
// we continue to base the event off the accessible object rather than just the
|
|
|
|
// node. This means we won't try to create an accessible based on the node when
|
|
|
|
// we are ready to fire the event and so we will no longer assert at that point
|
|
|
|
// if the node was removed from the document. Either way, the AT won't work with
|
|
|
|
// a defunct accessible so the behaviour should be equivalent.
|
2010-08-24 19:08:28 -07:00
|
|
|
AccTextChangeEvent::
|
2012-08-22 08:56:38 -07:00
|
|
|
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsAString& aModifiedText, bool aIsInserted,
|
2010-10-20 21:16:10 -07:00
|
|
|
EIsFromUserInput aIsFromUserInput)
|
2010-08-24 19:08:28 -07:00
|
|
|
: AccEvent(aIsInserted ?
|
2012-08-22 08:56:38 -07:00
|
|
|
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_INSERTED) :
|
|
|
|
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
|
2010-10-20 21:16:10 -07:00
|
|
|
aAccessible, aIsFromUserInput, eAllowDupes)
|
2010-08-18 19:14:50 -07:00
|
|
|
, mStart(aStart)
|
|
|
|
, mIsInserted(aIsInserted)
|
|
|
|
, mModifiedText(aModifiedText)
|
2007-04-16 23:52:52 -07:00
|
|
|
{
|
2012-03-22 05:28:25 -07:00
|
|
|
// XXX We should use IsFromUserInput here, but that isn't always correct
|
|
|
|
// when the text change isn't related to content insertion or removal.
|
|
|
|
mIsFromUserInput = mAccessible->State() &
|
|
|
|
(states::FOCUSED | states::EDITABLE);
|
2007-04-16 23:52:52 -07:00
|
|
|
}
|
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccTextChangeEvent::CreateXPCOMObject()
|
2007-08-28 14:57:53 -07:00
|
|
|
{
|
2010-08-24 19:08:28 -07:00
|
|
|
nsAccEvent* event = new nsAccTextChangeEvent(this);
|
|
|
|
NS_IF_ADDREF(event);
|
|
|
|
return event;
|
2007-08-28 14:57:53 -07:00
|
|
|
}
|
|
|
|
|
2010-07-01 18:49:42 -07:00
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-11-12 22:29:22 -08:00
|
|
|
// AccReorderEvent
|
2010-10-20 21:16:10 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-11-12 22:29:22 -08:00
|
|
|
uint32_t
|
|
|
|
AccReorderEvent::IsShowHideEventTarget(const Accessible* aTarget) const
|
2010-10-20 21:16:10 -07:00
|
|
|
{
|
2012-11-12 22:29:22 -08:00
|
|
|
uint32_t count = mDependentEvents.Length();
|
|
|
|
for (uint32_t index = count - 1; index < count; index--) {
|
2013-01-01 16:49:19 -08:00
|
|
|
if (mDependentEvents[index]->mAccessible == aTarget) {
|
|
|
|
uint32_t eventType = mDependentEvents[index]->mEventType;
|
|
|
|
if (eventType == nsIAccessibleEvent::EVENT_SHOW ||
|
|
|
|
eventType == nsIAccessibleEvent::EVENT_HIDE) {
|
|
|
|
return mDependentEvents[index]->mEventType;
|
|
|
|
}
|
2012-11-12 22:29:22 -08:00
|
|
|
}
|
|
|
|
}
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2012-11-12 22:29:22 -08:00
|
|
|
return 0;
|
|
|
|
}
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2010-07-01 18:49:42 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AccHideEvent
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
AccHideEvent::
|
2012-05-28 18:18:45 -07:00
|
|
|
AccHideEvent(Accessible* aTarget, nsINode* aTargetNode) :
|
2011-01-18 00:03:38 -08:00
|
|
|
AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget, aTargetNode)
|
2010-07-01 18:49:42 -07:00
|
|
|
{
|
2011-06-06 19:23:13 -07:00
|
|
|
mNextSibling = mAccessible->NextSibling();
|
|
|
|
mPrevSibling = mAccessible->PrevSibling();
|
2010-07-01 18:49:42 -07:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:02:41 -08:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccHideEvent::CreateXPCOMObject()
|
|
|
|
{
|
|
|
|
nsAccEvent* event = new nsAccHideEvent(this);
|
|
|
|
NS_ADDREF(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2010-07-01 18:49:42 -07:00
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AccShowEvent
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
AccShowEvent::
|
2012-05-28 18:18:45 -07:00
|
|
|
AccShowEvent(Accessible* aTarget, nsINode* aTargetNode) :
|
2011-01-18 00:03:38 -08:00
|
|
|
AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget, aTargetNode)
|
2010-10-20 21:16:10 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccCaretMoveEvent
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccCaretMoveEvent::CreateXPCOMObject()
|
2007-06-22 02:27:22 -07:00
|
|
|
{
|
2010-08-24 19:08:28 -07:00
|
|
|
nsAccEvent* event = new nsAccCaretMoveEvent(this);
|
|
|
|
NS_IF_ADDREF(event);
|
|
|
|
return event;
|
2007-06-22 02:27:22 -07:00
|
|
|
}
|
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
|
2011-10-31 17:52:27 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AccSelChangeEvent
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
AccSelChangeEvent::
|
2012-05-28 18:18:45 -07:00
|
|
|
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
|
2011-10-31 17:52:27 -07:00
|
|
|
SelChangeType aSelChangeType) :
|
|
|
|
AccEvent(0, aItem, eAutoDetect, eCoalesceSelectionChange),
|
|
|
|
mWidget(aWidget), mItem(aItem), mSelChangeType(aSelChangeType),
|
2012-07-30 07:20:58 -07:00
|
|
|
mPreceedingCount(0), mPackedEvent(nullptr)
|
2011-10-31 17:52:27 -07:00
|
|
|
{
|
|
|
|
if (aSelChangeType == eSelectionAdd) {
|
|
|
|
if (mWidget->GetSelectedItem(1))
|
|
|
|
mEventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
|
|
|
|
else
|
|
|
|
mEventType = nsIAccessibleEvent::EVENT_SELECTION;
|
|
|
|
} else {
|
|
|
|
mEventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-08-24 19:08:28 -07:00
|
|
|
// AccTableChangeEvent
|
2010-01-20 03:16:32 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
AccTableChangeEvent::
|
2012-08-22 08:56:38 -07:00
|
|
|
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
|
|
|
|
int32_t aRowOrColIndex, int32_t aNumRowsOrCols) :
|
2010-10-20 21:16:10 -07:00
|
|
|
AccEvent(aEventType, aAccessible),
|
2008-01-17 18:56:38 -08:00
|
|
|
mRowOrColIndex(aRowOrColIndex), mNumRowsOrCols(aNumRowsOrCols)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccTableChangeEvent::CreateXPCOMObject()
|
2008-01-17 18:56:38 -08:00
|
|
|
{
|
2010-08-24 19:08:28 -07:00
|
|
|
nsAccEvent* event = new nsAccTableChangeEvent(this);
|
|
|
|
NS_IF_ADDREF(event);
|
|
|
|
return event;
|
2008-01-17 18:56:38 -08:00
|
|
|
}
|
|
|
|
|
2012-03-09 17:52:13 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AccVCChangeEvent
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
AccVCChangeEvent::
|
2012-05-28 18:18:45 -07:00
|
|
|
AccVCChangeEvent(Accessible* aAccessible,
|
2012-03-09 17:52:13 -08:00
|
|
|
nsIAccessible* aOldAccessible,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aOldStart, int32_t aOldEnd,
|
|
|
|
int16_t aReason) :
|
2012-03-09 17:52:13 -08:00
|
|
|
AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible),
|
2012-06-20 14:07:51 -07:00
|
|
|
mOldAccessible(aOldAccessible), mOldStart(aOldStart), mOldEnd(aOldEnd),
|
|
|
|
mReason(aReason)
|
2012-03-09 17:52:13 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsAccEvent>
|
|
|
|
AccVCChangeEvent::CreateXPCOMObject()
|
|
|
|
{
|
|
|
|
nsAccEvent* event = new nsAccVirtualCursorChangeEvent(this);
|
|
|
|
NS_ADDREF(event);
|
|
|
|
return event;
|
|
|
|
}
|