about:startup - update to trunk

This commit is contained in:
Daniel Brooks 2010-09-03 15:52:52 -04:00
commit 691fc5f06d
7190 changed files with 217544 additions and 85512 deletions

View File

@ -9,7 +9,7 @@
# User files that may appear at the root
^\.mozconfig
^mozconfig
^mozconfig$
^configure$
^config\.cache$
^config\.log$

View File

@ -52,3 +52,4 @@ dba2abb7db57078c5a4810884834d3056a5d56c2 last-mozilla-central
0327e126ea245112c0aa7283fee154e084866fb5 bsmedberg-static-xpcom-registration-base
0327e126ea245112c0aa7283fee154e084866fb5 bsmedberg-static-xpcom-registration-base
2f83edbbeef0de7dd901411d270da61106c8afae bsmedberg-static-xpcom-registration-base
138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R12

View File

@ -59,6 +59,7 @@ LOCAL_INCLUDES = -I$(srcdir)/../src
SHARED_LIBRARY_LIBS = \
../src/base/$(LIB_PREFIX)accessibility_base_s.$(LIB_SUFFIX) \
../src/html/$(LIB_PREFIX)accessibility_html_s.$(LIB_SUFFIX) \
../src/xpcom/$(LIB_PREFIX)accessibility_xpcom_s.$(LIB_SUFFIX) \
../src/$(LIB_PREFIX)accessibility_toolkit_s.$(LIB_SUFFIX) \
$(NULL)

View File

@ -59,7 +59,7 @@ interface nsIDOMNode;
* if (NS_SUCCEEDED(rv))
* rv = observerService->AddObserver(this, "accessible-event", PR_TRUE);
*/
[scriptable, uuid(c68b4386-dca7-4b88-8988-7a95ce7be92f)]
[scriptable, uuid(fd1378c5-c606-4a5e-a321-8e7fc107e5cf)]
interface nsIAccessibleEvent : nsISupports
{
/**
@ -476,7 +476,7 @@ interface nsIAccessibleEvent : nsISupports
* Returns true if the event was caused by explicit user input,
* as opposed to purely originating from a timer or mouse movement
*/
attribute boolean isFromUserInput;
readonly attribute boolean isFromUserInput;
};

View File

@ -62,6 +62,7 @@ DIRS += $(PLATFORM_DIR)
DIRS += \
base \
html \
xpcom \
$(null)
ifdef MOZ_XUL
@ -75,4 +76,4 @@ endif
include $(topsrcdir)/config/rules.mk
libs::
$(INSTALL) $(PLATFORM_DIR)/$(LIB_PREFIX)accessibility_toolkit_s.$(LIB_SUFFIX) .
$(INSTALL) $(PLATFORM_DIR)/$(LIB_PREFIX)accessibility_toolkit_s.$(LIB_SUFFIX) $(wildcard $(PLATFORM_DIR)/$(LIB_PREFIX)accessibility_toolkit_s.$(LIB_SUFFIX).fake) .

View File

@ -452,11 +452,8 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
}
//nsIAccessibleHyperLink
nsCOMPtr<nsIAccessibleHyperLink> accessInterfaceHyperlink;
QueryInterface(NS_GET_IID(nsIAccessibleHyperLink),
getter_AddRefs(accessInterfaceHyperlink));
if (accessInterfaceHyperlink) {
// HyperLinkAccessible
if (IsHyperLink()) {
interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
}
@ -478,10 +475,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
}
//nsIAccessibleSelection
nsCOMPtr<nsIAccessibleSelectable> accessInterfaceSelection;
QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accessInterfaceSelection));
if (accessInterfaceSelection) {
if (IsSelect()) {
interfacesBits |= 1 << MAI_INTERFACE_SELECTION;
}
}
@ -848,9 +842,8 @@ getParentCB(AtkObject *aAtkObj)
return nsnull;
}
nsCOMPtr<nsIAccessible> accParent;
nsresult rv = accWrap->GetParent(getter_AddRefs(accParent));
if (NS_FAILED(rv) || !accParent)
nsAccessible* accParent = accWrap->GetParent();
if (!accParent)
return nsnull;
AtkObject *parent = nsAccessibleWrap::GetAtkObject(accParent);
@ -868,11 +861,7 @@ getChildCountCB(AtkObject *aAtkObj)
return 0;
}
// Links within hypertext accessible play role of accessible children in
// ATK since every embedded object is a link and text accessibles are
// ignored.
nsRefPtr<nsHyperTextAccessible> hyperText = do_QueryObject(accWrap);
return hyperText ? hyperText->GetLinkCount() : accWrap->GetChildCount();
return accWrap->GetEmbeddedChildCount();
}
AtkObject *
@ -888,12 +877,7 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
return nsnull;
}
// Links within hypertext accessible play role of accessible children in
// ATK since every embedded object is a link and text accessibles are
// ignored.
nsRefPtr<nsHyperTextAccessible> hyperText = do_QueryObject(accWrap);
nsAccessible* accChild = hyperText ? hyperText->GetLinkAt(aChildIndex) :
accWrap->GetChildAt(aChildIndex);
nsAccessible* accChild = accWrap->GetEmbeddedChildAt(aChildIndex);
if (!accChild)
return nsnull;
@ -924,12 +908,7 @@ getIndexInParentCB(AtkObject *aAtkObj)
return -1; // No parent
}
// Links within hypertext accessible play role of accessible children in
// ATK since every embedded object is a link and text accessibles are
// ignored.
nsRefPtr<nsHyperTextAccessible> hyperTextParent(do_QueryObject(parent));
return hyperTextParent ?
hyperTextParent->GetLinkIndex(accWrap) : accWrap->GetIndexInParent();
return parent->GetIndexOfEmbeddedChild(accWrap);
}
static void TranslateStates(PRUint32 aState, const AtkStateMap *aStateMap,
@ -1065,7 +1044,7 @@ nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj)
}
nsresult
nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
nsAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
nsresult rv = nsAccessible::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
@ -1074,7 +1053,7 @@ nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
}
nsresult
nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
nsAccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
{
nsAccessible *accessible = aEvent->GetAccessible();
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
@ -1112,10 +1091,10 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
if (rootAccWrap && rootAccWrap->mActivated) {
atk_focus_tracker_notify(atkObj);
// Fire state change event for focus
nsRefPtr<nsAccEvent> stateChangeEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_FOCUSED,
PR_FALSE, PR_TRUE);
nsRefPtr<AccEvent> stateChangeEvent =
new AccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_FOCUSED,
PR_FALSE, PR_TRUE);
return FireAtkStateChangeEvent(stateChangeEvent, atkObj);
}
} break;
@ -1145,7 +1124,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_CARET_MOVED\n"));
nsAccCaretMoveEvent *caretMoveEvent = downcast_accEvent(aEvent);
AccCaretMoveEvent* caretMoveEvent = downcast_accEvent(aEvent);
NS_ASSERTION(caretMoveEvent, "Event needs event data");
if (!caretMoveEvent)
break;
@ -1174,7 +1153,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_ROW_INSERT:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_INSERT\n"));
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 rowIndex = tableEvent->GetIndex();
@ -1191,7 +1170,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_ROW_DELETE:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_DELETE\n"));
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 rowIndex = tableEvent->GetIndex();
@ -1215,7 +1194,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_INSERT:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_INSERT\n"));
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 colIndex = tableEvent->GetIndex();
@ -1232,7 +1211,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_DELETE:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_DELETE\n"));
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 colIndex = tableEvent->GetIndex();
@ -1335,12 +1314,12 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
}
nsresult
nsAccessibleWrap::FireAtkStateChangeEvent(nsAccEvent *aEvent,
nsAccessibleWrap::FireAtkStateChangeEvent(AccEvent* aEvent,
AtkObject *aObject)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_STATE_CHANGE\n"));
nsAccStateChangeEvent *event = downcast_accEvent(aEvent);
AccStateChangeEvent* event = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
PRUint32 state = event->GetState();
@ -1371,12 +1350,12 @@ nsAccessibleWrap::FireAtkStateChangeEvent(nsAccEvent *aEvent,
}
nsresult
nsAccessibleWrap::FireAtkTextChangedEvent(nsAccEvent *aEvent,
nsAccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
AtkObject *aObject)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_REMOVED/INSERTED\n"));
nsAccTextChangeEvent *event = downcast_accEvent(aEvent);
AccTextChangeEvent* event = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
PRInt32 start = event->GetStartOffset();
@ -1394,7 +1373,7 @@ nsAccessibleWrap::FireAtkTextChangedEvent(nsAccEvent *aEvent,
}
nsresult
nsAccessibleWrap::FireAtkShowHideEvent(nsAccEvent *aEvent,
nsAccessibleWrap::FireAtkShowHideEvent(AccEvent* aEvent,
AtkObject *aObject, PRBool aIsAdded)
{
if (aIsAdded)

View File

@ -100,7 +100,7 @@ public:
// return the atk object for this nsAccessibleWrap
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);
virtual nsresult HandleAccEvent(AccEvent* aEvent);
AtkObject * GetAtkObject(void);
static AtkObject * GetAtkObject(nsIAccessible * acc);
@ -118,11 +118,11 @@ public:
}
protected:
virtual nsresult FirePlatformEvent(nsAccEvent *aEvent);
virtual nsresult FirePlatformEvent(AccEvent* aEvent);
nsresult FireAtkStateChangeEvent(nsAccEvent *aEvent, AtkObject *aObject);
nsresult FireAtkTextChangedEvent(nsAccEvent *aEvent, AtkObject *aObject);
nsresult FireAtkShowHideEvent(nsAccEvent *aEvent, AtkObject *aObject,
nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject *aObject);
nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject *aObject);
nsresult FireAtkShowHideEvent(AccEvent* aEvent, AtkObject *aObject,
PRBool aIsAdded);
AtkObject *mAtkObject;

View File

@ -93,7 +93,7 @@ static gint getAnchorCountCB(AtkHyperlink *aLink);
G_END_DECLS
static gpointer parent_class = NULL;
static nsIAccessibleHyperLink *
static nsAccessible*
get_accessible_hyperlink(AtkHyperlink *aHyperlink);
GType
@ -122,8 +122,8 @@ mai_atk_hyperlink_get_type(void)
return type;
}
MaiHyperlink::MaiHyperlink(nsIAccessibleHyperLink *aAcc):
mHyperlink(aAcc),
MaiHyperlink::MaiHyperlink(nsAccessible* aHyperLink) :
mHyperlink(aHyperLink),
mMaiAtkHyperlink(nsnull)
{
}
@ -144,8 +144,7 @@ MaiHyperlink::GetAtkHyperlink(void)
if (mMaiAtkHyperlink)
return mMaiAtkHyperlink;
nsCOMPtr<nsIAccessibleHyperLink> accessIf(do_QueryInterface(mHyperlink));
if (!accessIf)
if (!mHyperlink->IsHyperLink())
return nsnull;
mMaiAtkHyperlink =
@ -214,17 +213,18 @@ finalizeCB(GObject *aObj)
gchar *
getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, nsnull);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, nsnull);
MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aLink);
nsCOMPtr<nsIURI> uri;
nsresult rv = accHyperlink->GetURI(aLinkIndex,getter_AddRefs(uri));
if (NS_FAILED(rv) || !uri)
nsCOMPtr<nsIURI> uri = hyperlink->GetAnchorURI(aLinkIndex);
if (!uri)
return nsnull;
nsCAutoString cautoStr;
rv = uri->GetSpec(cautoStr);
nsresult rv = uri->GetSpec(cautoStr);
NS_ENSURE_SUCCESS(rv, nsnull);
return g_strdup(cautoStr.get());
}
@ -232,14 +232,13 @@ getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
AtkObject *
getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, nsnull);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, nsnull);
nsCOMPtr<nsIAccessible> accObj;
accHyperlink->GetAnchor(aLinkIndex, getter_AddRefs(accObj));
NS_ENSURE_TRUE(accObj, nsnull);
nsAccessible* anchor = hyperlink->GetAnchor(aLinkIndex);
NS_ENSURE_TRUE(anchor, nsnull);
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accObj);
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(anchor);
//no need to add ref it, because it is "get" not "ref"
return atkObj;
}
@ -247,52 +246,42 @@ getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
gint
getEndIndexCB(AtkHyperlink *aLink)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, -1);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, -1);
PRInt32 endIndex = -1;
nsresult rv = accHyperlink->GetEndIndex(&endIndex);
return (NS_FAILED(rv)) ? -1 : static_cast<gint>(endIndex);
return static_cast<gint>(hyperlink->EndOffset());
}
gint
getStartIndexCB(AtkHyperlink *aLink)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, -1);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, -1);
PRInt32 startIndex = -1;
nsresult rv = accHyperlink->GetStartIndex(&startIndex);
return (NS_FAILED(rv)) ? -1 : static_cast<gint>(startIndex);
return static_cast<gint>(hyperlink->StartOffset());
}
gboolean
isValidCB(AtkHyperlink *aLink)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, FALSE);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, FALSE);
PRBool isValid = PR_FALSE;
nsresult rv = accHyperlink->GetValid(&isValid);
return (NS_FAILED(rv)) ? FALSE : static_cast<gboolean>(isValid);
return static_cast<gboolean>(hyperlink->IsValid());
}
gint
getAnchorCountCB(AtkHyperlink *aLink)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, -1);
nsAccessible* hyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(hyperlink, -1);
PRInt32 count = -1;
nsresult rv = accHyperlink->GetAnchorCount(&count);
return (NS_FAILED(rv)) ? -1 : static_cast<gint>(count);
return static_cast<gint>(hyperlink->AnchorCount());
}
// Check if aHyperlink is a valid MaiHyperlink, and return the
// nsIAccessibleHyperLink related.
nsIAccessibleHyperLink *
// HyperLinkAccessible related.
nsAccessible*
get_accessible_hyperlink(AtkHyperlink *aHyperlink)
{
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nsnull);

View File

@ -42,7 +42,7 @@
#define __MAI_HYPERLINK_H__
#include "nsMai.h"
#include "nsIAccessibleHyperLink.h"
#include "nsAccessible.h"
struct _AtkHyperlink;
typedef struct _AtkHyperlink AtkHyperlink;
@ -54,17 +54,17 @@ typedef struct _AtkHyperlink AtkHyperlink;
class MaiHyperlink
{
public:
MaiHyperlink(nsIAccessibleHyperLink *aAcc);
MaiHyperlink(nsAccessible* aHyperLink);
~MaiHyperlink();
public:
AtkHyperlink *GetAtkHyperlink(void);
nsIAccessibleHyperLink *GetAccHyperlink(void) {
return mHyperlink;
nsAccessible* GetAccHyperlink(void) {
return mHyperlink && mHyperlink->IsHyperLink() ? mHyperlink : nsnull;
}
protected:
nsIAccessibleHyperLink *mHyperlink;
nsAccessible* mHyperlink;
AtkHyperlink *mMaiAtkHyperlink;
public:
static nsresult Initialize(AtkHyperlink *aObj, MaiHyperlink *aClass);

View File

@ -56,11 +56,8 @@ getHyperlinkCB(AtkHyperlinkImpl *aImpl)
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleHyperLink> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperLink),
getter_AddRefs(accHyperlink));
NS_ENSURE_TRUE(accHyperlink, nsnull);
NS_ENSURE_TRUE(accWrap->IsHyperLink(), nsnull);
MaiHyperlink *maiHyperlink = accWrap->GetMaiHyperlink();
NS_ENSURE_TRUE(maiHyperlink, nsnull);
return maiHyperlink->GetAtkHyperlink();

View File

@ -60,51 +60,34 @@ gboolean
addSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
return NS_SUCCEEDED(accSelection->AddChildToSelection(i));
return accWrap->AddItemToSelection(i);
}
gboolean
clearSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
return NS_SUCCEEDED(accSelection->ClearSelection());
return accWrap->UnselectAll();
}
AtkObject *
refSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return nsnull;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, nsnull);
nsCOMPtr<nsIAccessible> accSelect;
accSelection->RefSelection(i, getter_AddRefs(accSelect));
if (!accSelect) {
nsAccessible* selectedItem = accWrap->GetSelectedItem(i);
if (!selectedItem)
return nsnull;
}
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accSelect);
AtkObject* atkObj = nsAccessibleWrap::GetAtkObject(selectedItem);
if (atkObj) {
g_object_ref(atkObj);
}
@ -115,65 +98,38 @@ gint
getSelectionCountCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return -1;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, -1);
PRInt32 num = 0;
nsresult rv = accSelection->GetSelectionCount(&num);
return (NS_FAILED(rv)) ? -1 : num;
return accWrap->SelectedItemCount();
}
gboolean
isChildSelectedCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
PRBool result = FALSE;
nsresult rv = accSelection->IsChildSelected(i, &result);
return (NS_FAILED(rv)) ? FALSE : result;
return accWrap->IsItemSelected(i);
}
gboolean
removeSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
nsresult rv = accSelection->RemoveChildFromSelection(i);
return (NS_FAILED(rv)) ? FALSE : TRUE;
return accWrap->RemoveItemFromSelection(i);
}
gboolean
selectAllSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (!accWrap)
if (!accWrap || !accWrap->IsSelect())
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
PRBool result = FALSE;
nsresult rv = accSelection->SelectAllSelection(&result);
return (NS_FAILED(rv)) ? FALSE : result;
return accWrap->SelectAll();
}

View File

@ -42,7 +42,6 @@
#define __MAI_INTERFACE_SELECTION_H__
#include "nsMai.h"
#include "nsIAccessibleSelectable.h"
G_BEGIN_DECLS

View File

@ -319,9 +319,12 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset,
else
geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
nsresult rv = accText->GetCharacterExtents(aOffset, &extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
#ifdef DEBUG
nsresult rv =
#endif
accText->GetCharacterExtents(aOffset, &extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
*aX = extX;
*aY = extY;
*aWidth = extWidth;
@ -353,10 +356,13 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
else
geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
nsresult rv = accText->GetRangeExtents(aStartOffset, aEndOffset,
&extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
#ifdef DEBUG
nsresult rv =
#endif
accText->GetRangeExtents(aStartOffset, aEndOffset,
&extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
aRect->x = extX;
aRect->y = extY;
aRect->width = extWidth;

View File

@ -92,7 +92,7 @@ AccCollector::EnsureNGetObject(PRUint32 aIndex)
if (!mFilterFunc(child))
continue;
mObjects.AppendElement(child);
AppendObject(child);
if (mObjects.Length() - 1 == aIndex)
return mObjects[aIndex];
}
@ -109,10 +109,39 @@ AccCollector::EnsureNGetIndex(nsAccessible* aAccessible)
if (!mFilterFunc(child))
continue;
mObjects.AppendElement(child);
AppendObject(child);
if (child == aAccessible)
return mObjects.Length() - 1;
}
return -1;
}
void
AccCollector::AppendObject(nsAccessible* aAccessible)
{
mObjects.AppendElement(aAccessible);
}
////////////////////////////////////////////////////////////////////////////////
// EmbeddedObjCollector
////////////////////////////////////////////////////////////////////////////////
PRInt32
EmbeddedObjCollector::GetIndexAt(nsAccessible *aAccessible)
{
if (aAccessible->mParent != mRoot)
return -1;
if (aAccessible->mIndexOfEmbeddedChild != -1)
return aAccessible->mIndexOfEmbeddedChild;
return mFilterFunc(aAccessible) ? EnsureNGetIndex(aAccessible) : -1;
}
void
EmbeddedObjCollector::AppendObject(nsAccessible* aAccessible)
{
aAccessible->mIndexOfEmbeddedChild = mObjects.Length();
mObjects.AppendElement(aAccessible);
}

View File

@ -66,7 +66,7 @@ public:
/**
* Return index of the given accessible within the collection.
*/
PRInt32 GetIndexAt(nsAccessible* aAccessible);
virtual PRInt32 GetIndexAt(nsAccessible* aAccessible);
protected:
/**
@ -79,6 +79,11 @@ protected:
*/
PRInt32 EnsureNGetIndex(nsAccessible* aAccessible);
/**
* Append the object to collection.
*/
virtual void AppendObject(nsAccessible* aAccessible);
filters::FilterFuncPtr mFilterFunc;
nsAccessible* mRoot;
PRInt32 mRootChildIdx;
@ -91,4 +96,26 @@ private:
AccCollector& operator =(const AccCollector&);
};
/**
* Collect embedded objects. Provide quick access to accessible by index and
* vice versa.
*/
class EmbeddedObjCollector : public AccCollector
{
public:
virtual ~EmbeddedObjCollector() { };
public:
virtual PRInt32 GetIndexAt(nsAccessible* aAccessible);
protected:
// Make sure it's used by nsAccessible class only.
EmbeddedObjCollector(nsAccessible* aRoot) :
AccCollector(aRoot, filters::GetEmbeddedObject) { }
virtual void AppendObject(nsAccessible* aAccessible);
friend class nsAccessible;
};
#endif

View File

@ -20,7 +20,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Aaron Leventhal <aaronl@netscape.com> <original author>
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -36,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccEvent.h"
#include "AccEvent.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
@ -46,6 +47,7 @@
#ifdef MOZ_XUL
#include "nsXULTreeAccessible.h"
#endif
#include "nsAccEvent.h"
#include "nsIDOMDocument.h"
#include "nsIEventStateManager.h"
@ -55,44 +57,24 @@
#endif
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent
// AccEvent
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent. nsISupports
// AccEvent constructors
NS_IMPL_CYCLE_COLLECTION_CLASS(nsAccEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsAccEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mAccessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsAccEvent)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mAccessible");
cb.NoteXPCOMChild(static_cast<nsIAccessible*>(tmp->mAccessible));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAccEvent)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEvent)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAccEvent)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAccEvent)
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent. Constructors
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
AccEvent::AccEvent(PRUint32 aEventType, nsAccessible* aAccessible,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
mAccessible(aAccessible)
{
CaptureIsFromUserInput(aIsFromUserInput);
}
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsINode *aNode,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
AccEvent::AccEvent(PRUint32 aEventType, nsINode* aNode,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
mNode(aNode)
{
@ -100,68 +82,10 @@ nsAccEvent::nsAccEvent(PRUint32 aEventType, nsINode *aNode,
}
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent: nsIAccessibleEvent
NS_IMETHODIMP
nsAccEvent::GetIsFromUserInput(PRBool *aIsFromUserInput)
{
*aIsFromUserInput = mIsFromUserInput;
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::SetIsFromUserInput(PRBool aIsFromUserInput)
{
mIsFromUserInput = aIsFromUserInput;
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetEventType(PRUint32 *aEventType)
{
*aEventType = mEventType;
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetAccessible(nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
NS_IF_ADDREF(*aAccessible = GetAccessible());
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
if (!mNode)
mNode = GetNode();
if (mNode)
CallQueryInterface(mNode, aDOMNode);
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetAccessibleDocument(nsIAccessibleDocument **aDocAccessible)
{
NS_ENSURE_ARG_POINTER(aDocAccessible);
NS_IF_ADDREF(*aDocAccessible = GetDocAccessible());
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent: public methods
// AccEvent public methods
nsAccessible *
nsAccEvent::GetAccessible()
AccEvent::GetAccessible()
{
if (!mAccessible)
mAccessible = GetAccessibleForNode();
@ -170,7 +94,7 @@ nsAccEvent::GetAccessible()
}
nsINode*
nsAccEvent::GetNode()
AccEvent::GetNode()
{
if (!mNode && mAccessible)
mNode = mAccessible->GetNode();
@ -179,7 +103,7 @@ nsAccEvent::GetNode()
}
nsDocAccessible*
nsAccEvent::GetDocAccessible()
AccEvent::GetDocAccessible()
{
nsINode *node = GetNode();
if (node)
@ -188,11 +112,36 @@ nsAccEvent::GetDocAccessible()
return nsnull;
}
already_AddRefed<nsAccEvent>
AccEvent::CreateXPCOMObject()
{
nsAccEvent* event = new nsAccEvent(this);
NS_IF_ADDREF(event);
return event;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent: protected methods
// AccEvent cycle collection
NS_IMPL_CYCLE_COLLECTION_CLASS(AccEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(AccEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mAccessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(AccEvent)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mAccessible");
cb.NoteXPCOMChild(static_cast<nsIAccessible*>(tmp->mAccessible));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AccEvent, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
////////////////////////////////////////////////////////////////////////////////
// AccEvent protected methods
nsAccessible *
nsAccEvent::GetAccessibleForNode() const
AccEvent::GetAccessibleForNode() const
{
if (!mNode)
return nsnull;
@ -227,7 +176,7 @@ nsAccEvent::GetAccessibleForNode() const
}
void
nsAccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
AccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
{
nsINode *targetNode = GetNode();
@ -269,29 +218,26 @@ nsAccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
////////////////////////////////////////////////////////////////////////////////
// nsAccReorderEvent
// AccReorderEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsAccReorderEvent, nsAccEvent)
nsAccReorderEvent::nsAccReorderEvent(nsAccessible *aAccTarget,
PRBool aIsAsynch,
PRBool aIsUnconditional,
nsINode *aReasonNode) :
nsAccEvent(::nsIAccessibleEvent::EVENT_REORDER, aAccTarget,
aIsAsynch, eAutoDetect, nsAccEvent::eCoalesceFromSameSubtree),
AccReorderEvent::
AccReorderEvent(nsAccessible* aAccTarget, PRBool aIsAsynch,
PRBool aIsUnconditional, nsINode* aReasonNode) :
AccEvent(::nsIAccessibleEvent::EVENT_REORDER, aAccTarget,
aIsAsynch, eAutoDetect, AccEvent::eCoalesceFromSameSubtree),
mUnconditionalEvent(aIsUnconditional), mReasonNode(aReasonNode)
{
}
PRBool
nsAccReorderEvent::IsUnconditionalEvent()
AccReorderEvent::IsUnconditionalEvent()
{
return mUnconditionalEvent;
}
PRBool
nsAccReorderEvent::HasAccessibleInReasonSubtree()
AccReorderEvent::HasAccessibleInReasonSubtree()
{
if (!mReasonNode)
return PR_FALSE;
@ -302,37 +248,34 @@ nsAccReorderEvent::HasAccessibleInReasonSubtree()
////////////////////////////////////////////////////////////////////////////////
// nsAccStateChangeEvent
// AccStateChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccStateChangeEvent, nsAccEvent,
nsIAccessibleStateChangeEvent)
// Note: we pass in eAllowDupes to the base class because we don't currently
// support correct state change coalescence (XXX Bug 569356). Also we need to
// decide how to coalesce events created via accessible (instead of node).
nsAccStateChangeEvent::
nsAccStateChangeEvent(nsAccessible *aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch,
EIsFromUserInput aIsFromUserInput):
nsAccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible, aIsAsynch,
aIsFromUserInput, eAllowDupes),
AccStateChangeEvent::
AccStateChangeEvent(nsAccessible* aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch,
EIsFromUserInput aIsFromUserInput):
AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible, aIsAsynch,
aIsFromUserInput, eAllowDupes),
mState(aState), mIsExtraState(aIsExtraState), mIsEnabled(aIsEnabled)
{
}
nsAccStateChangeEvent::
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled):
nsAccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
AccStateChangeEvent::
AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled):
AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
mState(aState), mIsExtraState(aIsExtraState), mIsEnabled(aIsEnabled)
{
}
nsAccStateChangeEvent::
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState) :
nsAccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
AccStateChangeEvent::
AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState) :
AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
mState(aState), mIsExtraState(aIsExtraState)
{
// Use GetAccessibleForNode() because we do not want to store an accessible
@ -348,37 +291,19 @@ nsAccStateChangeEvent::
}
}
NS_IMETHODIMP
nsAccStateChangeEvent::GetState(PRUint32 *aState)
already_AddRefed<nsAccEvent>
AccStateChangeEvent::CreateXPCOMObject()
{
NS_ENSURE_ARG_POINTER(aState);
*aState = mState;
return NS_OK;
nsAccEvent* event = new nsAccStateChangeEvent(this);
NS_IF_ADDREF(event);
return event;
}
NS_IMETHODIMP
nsAccStateChangeEvent::IsExtraState(PRBool *aIsExtraState)
{
NS_ENSURE_ARG_POINTER(aIsExtraState);
*aIsExtraState = mIsExtraState;
return NS_OK;
}
NS_IMETHODIMP
nsAccStateChangeEvent::IsEnabled(PRBool *aIsEnabled)
{
NS_ENSURE_ARG_POINTER(aIsEnabled);
*aIsEnabled = mIsEnabled;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccTextChangeEvent
// AccTextChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccTextChangeEvent, nsAccEvent,
nsIAccessibleTextChangeEvent)
// Note: we pass in eAllowDupes to the base class because we don't support text
// events coalescence. We fire delayed text change events in nsDocAccessible but
// we continue to base the event off the accessible object rather than just the
@ -387,45 +312,26 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccTextChangeEvent, nsAccEvent,
// 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.
// XXX revisit this when coalescence is faster (eCoalesceFromSameSubtree)
nsAccTextChangeEvent::
nsAccTextChangeEvent(nsAccessible *aAccessible, PRInt32 aStart,
nsAString& aModifiedText, PRBool aIsInserted,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput) :
nsAccEvent(aIsInserted ? nsIAccessibleEvent::EVENT_TEXT_INSERTED : nsIAccessibleEvent::EVENT_TEXT_REMOVED,
aAccessible, aIsAsynch, aIsFromUserInput, eAllowDupes),
mStart(aStart), mIsInserted(aIsInserted), mModifiedText(aModifiedText)
AccTextChangeEvent::
AccTextChangeEvent(nsAccessible* aAccessible, PRInt32 aStart,
nsAString& aModifiedText, PRBool aIsInserted,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput)
: AccEvent(aIsInserted ?
static_cast<PRUint32>(nsIAccessibleEvent::EVENT_TEXT_INSERTED) :
static_cast<PRUint32>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
aAccessible, aIsAsynch, aIsFromUserInput, eAllowDupes)
, mStart(aStart)
, mIsInserted(aIsInserted)
, mModifiedText(aModifiedText)
{
}
NS_IMETHODIMP
nsAccTextChangeEvent::GetStart(PRInt32 *aStart)
already_AddRefed<nsAccEvent>
AccTextChangeEvent::CreateXPCOMObject()
{
NS_ENSURE_ARG_POINTER(aStart);
*aStart = mStart;
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::GetLength(PRUint32 *aLength)
{
NS_ENSURE_ARG_POINTER(aLength);
*aLength = GetLength();
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::IsInserted(PRBool *aIsInserted)
{
NS_ENSURE_ARG_POINTER(aIsInserted);
*aIsInserted = mIsInserted;
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::GetModifiedText(nsAString& aModifiedText)
{
aModifiedText = mModifiedText;
return NS_OK;
nsAccEvent* event = new nsAccTextChangeEvent(this);
NS_IF_ADDREF(event);
return event;
}
@ -436,8 +342,8 @@ nsAccTextChangeEvent::GetModifiedText(nsAString& aModifiedText)
AccHideEvent::
AccHideEvent(nsAccessible* aTarget, nsINode* aTargetNode,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput) :
nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, aTarget, aIsAsynch,
aIsFromUserInput, eCoalesceFromSameSubtree)
AccEvent(nsIAccessibleEvent::EVENT_HIDE, aTarget, aIsAsynch,
aIsFromUserInput, eCoalesceFromSameSubtree)
{
mNode = aTargetNode;
mParent = mAccessible->GetCachedParent();
@ -447,65 +353,50 @@ AccHideEvent::
////////////////////////////////////////////////////////////////////////////////
// nsAccCaretMoveEvent
// AccCaretMoveEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccCaretMoveEvent, nsAccEvent,
nsIAccessibleCaretMoveEvent)
nsAccCaretMoveEvent::
nsAccCaretMoveEvent(nsAccessible *aAccessible, PRInt32 aCaretOffset) :
nsAccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible, PR_TRUE), // Currently always asynch
AccCaretMoveEvent::
AccCaretMoveEvent(nsAccessible* aAccessible, PRInt32 aCaretOffset) :
AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible, PR_TRUE), // Currently always asynch
mCaretOffset(aCaretOffset)
{
}
nsAccCaretMoveEvent::
nsAccCaretMoveEvent(nsINode *aNode) :
nsAccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aNode, PR_TRUE), // Currently always asynch
AccCaretMoveEvent::
AccCaretMoveEvent(nsINode* aNode) :
AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aNode, PR_TRUE), // Currently always asynch
mCaretOffset(-1)
{
}
NS_IMETHODIMP
nsAccCaretMoveEvent::GetCaretOffset(PRInt32* aCaretOffset)
already_AddRefed<nsAccEvent>
AccCaretMoveEvent::CreateXPCOMObject()
{
NS_ENSURE_ARG_POINTER(aCaretOffset);
*aCaretOffset = mCaretOffset;
return NS_OK;
nsAccEvent* event = new nsAccCaretMoveEvent(this);
NS_IF_ADDREF(event);
return event;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccTableChangeEvent
// AccTableChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccTableChangeEvent, nsAccEvent,
nsIAccessibleTableChangeEvent)
nsAccTableChangeEvent::
nsAccTableChangeEvent(nsAccessible *aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols, PRBool aIsAsynch):
nsAccEvent(aEventType, aAccessible, aIsAsynch),
AccTableChangeEvent::
AccTableChangeEvent(nsAccessible* aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols,
PRBool aIsAsynch) :
AccEvent(aEventType, aAccessible, aIsAsynch),
mRowOrColIndex(aRowOrColIndex), mNumRowsOrCols(aNumRowsOrCols)
{
}
NS_IMETHODIMP
nsAccTableChangeEvent::GetRowOrColIndex(PRInt32* aRowOrColIndex)
already_AddRefed<nsAccEvent>
AccTableChangeEvent::CreateXPCOMObject()
{
NS_ENSURE_ARG_POINTER(aRowOrColIndex);
*aRowOrColIndex = mRowOrColIndex;
return NS_OK;
}
NS_IMETHODIMP
nsAccTableChangeEvent::GetNumRowsOrCols(PRInt32* aNumRowsOrCols)
{
NS_ENSURE_ARG_POINTER(aNumRowsOrCols);
*aNumRowsOrCols = mNumRowsOrCols;
return NS_OK;
nsAccEvent* event = new nsAccTableChangeEvent(this);
NS_IF_ADDREF(event);
return event;
}

View File

@ -38,13 +38,12 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsAccEvent_H_
#define _nsAccEvent_H_
#include "nsIAccessibleEvent.h"
#ifndef _AccEvent_H_
#define _AccEvent_H_
#include "nsAccessible.h"
class nsAccEvent;
class nsDocAccessible;
// Constants used to point whether the event is from user input.
@ -61,7 +60,7 @@ enum EIsFromUserInput
/**
* Generic accessible event.
*/
class nsAccEvent: public nsIAccessibleEvent
class AccEvent
{
public:
@ -90,22 +89,17 @@ public:
};
// Initialize with an nsIAccessible
nsAccEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
AccEvent(PRUint32 aEventType, nsAccessible* aAccessible,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
// Initialize with an nsIDOMNode
nsAccEvent(PRUint32 aEventType, nsINode *aNode, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
virtual ~nsAccEvent() {}
AccEvent(PRUint32 aEventType, nsINode* aNode, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
virtual ~AccEvent() {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsAccEvent)
NS_DECL_NSIACCESSIBLEEVENT
// nsAccEvent
// AccEvent
PRUint32 GetEventType() const { return mEventType; }
EEventRule GetEventRule() const { return mEventRule; }
PRBool IsAsync() const { return mIsAsync; }
@ -115,6 +109,14 @@ public:
nsDocAccessible* GetDocAccessible();
nsINode* GetNode();
/**
* Create and return an XPCOM object for accessible event object.
*/
virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
/**
* Down casting.
*/
enum EventGroup {
eGenericEvent,
eReorderEvent,
@ -131,6 +133,12 @@ public:
return 1U << eGenericEvent;
}
/**
* Reference counting and cycle collection.
*/
NS_INLINE_DECL_REFCOUNTING(AccEvent)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
protected:
/**
* Get an accessible from event target node.
@ -144,7 +152,6 @@ protected:
void CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput);
PRBool mIsFromUserInput;
PRUint32 mEventType;
EEventRule mEventRule;
PRPackedBool mIsAsync;
@ -158,22 +165,20 @@ protected:
/**
* Accessible reorder event.
*/
class nsAccReorderEvent : public nsAccEvent
class AccReorderEvent : public AccEvent
{
public:
nsAccReorderEvent(nsAccessible *aAccTarget, PRBool aIsAsynch,
PRBool aIsUnconditional, nsINode *aReasonNode);
AccReorderEvent(nsAccessible* aAccTarget, PRBool aIsAsynch,
PRBool aIsUnconditional, nsINode* aReasonNode);
NS_DECL_ISUPPORTS_INHERITED
// nsAccEvent
// AccEvent
static const EventGroup kEventGroup = eReorderEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eReorderEvent);
return AccEvent::GetEventGroups() | (1U << eReorderEvent);
}
// nsAccReorderEvent
// AccReorderEvent
/**
* Return true if event is unconditional, i.e. must be fired.
*/
@ -193,31 +198,29 @@ private:
/**
* Accessible state change event.
*/
class nsAccStateChangeEvent: public nsAccEvent,
public nsIAccessibleStateChangeEvent
class AccStateChangeEvent: public AccEvent
{
public:
nsAccStateChangeEvent(nsAccessible *aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
AccStateChangeEvent(nsAccessible* aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled);
AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled);
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState);
AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESTATECHANGEEVENT
// AccEvent
virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
// nsAccEvent
static const EventGroup kEventGroup = eStateChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eStateChangeEvent);
return AccEvent::GetEventGroups() | (1U << eStateChangeEvent);
}
// nsAccStateChangeEvent
// AccStateChangeEvent
PRUint32 GetState() const { return mState; }
PRBool IsExtraState() const { return mIsExtraState; }
PRBool IsStateEnabled() const { return mIsEnabled; }
@ -232,29 +235,29 @@ private:
/**
* Accessible text change event.
*/
class nsAccTextChangeEvent: public nsAccEvent,
public nsIAccessibleTextChangeEvent
class AccTextChangeEvent: public AccEvent
{
public:
nsAccTextChangeEvent(nsAccessible *aAccessible, PRInt32 aStart,
nsAString& aModifiedText,
PRBool aIsInserted, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
AccTextChangeEvent(nsAccessible* aAccessible, PRInt32 aStart,
nsAString& aModifiedText,
PRBool aIsInserted, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXTCHANGEEVENT
// AccEvent
virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
// nsAccEvent
static const EventGroup kEventGroup = eTextChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eTextChangeEvent);
return AccEvent::GetEventGroups() | (1U << eTextChangeEvent);
}
// nsAccTextChangeEvent
// AccTextChangeEvent
PRInt32 GetStartOffset() const { return mStart; }
PRUint32 GetLength() const { return mModifiedText.Length(); }
PRBool IsTextInserted() const { return mIsInserted; }
void GetModifiedText(nsAString& aModifiedText)
{ aModifiedText = mModifiedText; }
private:
PRInt32 mStart;
@ -268,24 +271,24 @@ private:
/**
* Accessible hide events.
*/
class AccHideEvent : public nsAccEvent
class AccHideEvent : public AccEvent
{
public:
AccHideEvent(nsAccessible* aTarget, nsINode* aTargetNode,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput);
// nsAccEvent
// Event
static const EventGroup kEventGroup = eHideEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eHideEvent);
return AccEvent::GetEventGroups() | (1U << eHideEvent);
}
protected:
nsRefPtr<nsAccessible> mParent;
nsRefPtr<nsAccessible> mNextSibling;
nsRefPtr<nsAccessible> mPrevSibling;
nsRefPtr<nsAccTextChangeEvent> mTextChangeEvent;
nsRefPtr<AccTextChangeEvent> mTextChangeEvent;
friend class nsAccEventQueue;
};
@ -294,24 +297,22 @@ protected:
/**
* Accessible caret move event.
*/
class nsAccCaretMoveEvent: public nsAccEvent,
public nsIAccessibleCaretMoveEvent
class AccCaretMoveEvent: public AccEvent
{
public:
nsAccCaretMoveEvent(nsAccessible *aAccessible, PRInt32 aCaretOffset);
nsAccCaretMoveEvent(nsINode *aNode);
AccCaretMoveEvent(nsAccessible* aAccessible, PRInt32 aCaretOffset);
AccCaretMoveEvent(nsINode* aNode);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLECARETMOVEEVENT
// AccEvent
virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
// nsAccEvent
static const EventGroup kEventGroup = eCaretMoveEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
return AccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
}
// nsAccCaretMoveEvent
// AccCaretMoveEvent
PRInt32 GetCaretOffset() const { return mCaretOffset; }
private:
@ -322,25 +323,23 @@ private:
/**
* Accessible table change event.
*/
class nsAccTableChangeEvent : public nsAccEvent,
public nsIAccessibleTableChangeEvent
class AccTableChangeEvent : public AccEvent
{
public:
nsAccTableChangeEvent(nsAccessible *aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols,
PRBool aIsAsynch);
AccTableChangeEvent(nsAccessible* aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols,
PRBool aIsAsynch);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETABLECHANGEEVENT
// AccEvent
virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
// nsAccEvent
static const EventGroup kEventGroup = eTableChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eTableChangeEvent);
return AccEvent::GetEventGroups() | (1U << eTableChangeEvent);
}
// nsAccTableChangeEvent
// AccTableChangeEvent
PRUint32 GetIndex() const { return mRowOrColIndex; }
PRUint32 GetCount() const { return mNumRowsOrCols; }
@ -356,7 +355,7 @@ private:
class downcast_accEvent
{
public:
downcast_accEvent(nsAccEvent *e) : mRawPtr(e) { }
downcast_accEvent(AccEvent* e) : mRawPtr(e) { }
template<class Destination>
operator Destination*() {
@ -368,7 +367,7 @@ public:
}
private:
nsAccEvent *mRawPtr;
AccEvent* mRawPtr;
};
#endif

View File

@ -49,12 +49,12 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
AccCollector.cpp \
AccEvent.cpp \
AccGroupInfo.cpp \
AccIterator.cpp \
filters.cpp \
nsAccDocManager.cpp \
nsAccessNode.cpp \
nsAccEvent.cpp \
nsARIAGridAccessible.cpp \
nsARIAMap.cpp \
nsDocAccessible.cpp \
@ -91,6 +91,7 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir) \
-I$(srcdir)/../xpcom \
-I$(srcdir)/../html \
-I$(srcdir)/../xul \
-I$(srcdir)/../../../layout/generic \

View File

@ -713,6 +713,7 @@ nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
{&nsAccessibilityAtoms::aria_grabbed, ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_haspopup, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_invalid, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_label, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_labelledby, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_level, ATTR_BYPASSOBJ }, /* handled via groupPosition */
{&nsAccessibilityAtoms::aria_live, ATTR_VALTOKEN },

View File

@ -69,6 +69,9 @@ nsAccDocManager::GetDocAccessible(nsIDocument *aDocument)
if (!aDocument)
return nsnull;
// Ensure CacheChildren is called before we query cache.
nsAccessNode::GetApplicationAccessible()->EnsureChildren();
nsDocAccessible *docAcc =
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument));
if (docAcc)
@ -232,16 +235,16 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress,
loadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE) {
// Fire reload event.
nsRefPtr<nsAccEvent> reloadEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD, docAcc);
nsRefPtr<AccEvent> reloadEvent =
new AccEvent(nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD, docAcc);
nsEventShell::FireEvent(reloadEvent);
}
// Fire state busy change event. Use delayed event since we don't care
// actually if event isn't delivered when the document goes away like a shot.
nsRefPtr<nsAccEvent> stateEvent =
new nsAccStateChangeEvent(document, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_TRUE);
nsRefPtr<AccEvent> stateEvent =
new AccStateChangeEvent(document, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_TRUE);
docAcc->FireDelayedAccessibleEvent(stateEvent);
return NS_OK;
@ -375,14 +378,14 @@ nsAccDocManager::HandleDOMDocumentLoad(nsIDocument *aDocument,
// Fire complete/load stopped if the load event type is given.
if (aLoadEventType) {
nsRefPtr<nsAccEvent> loadEvent = new nsAccEvent(aLoadEventType, aDocument);
nsRefPtr<AccEvent> loadEvent = new AccEvent(aLoadEventType, aDocument);
docAcc->FireDelayedAccessibleEvent(loadEvent);
}
// Fire busy state change event.
nsRefPtr<nsAccEvent> stateEvent =
new nsAccStateChangeEvent(aDocument, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_FALSE);
nsRefPtr<AccEvent> stateEvent =
new AccStateChangeEvent(aDocument, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_FALSE);
docAcc->FireDelayedAccessibleEvent(stateEvent);
}

View File

@ -386,7 +386,7 @@ private:
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD) { \
strEventType.AssignLiteral("reload"); \
} else if (type == nsIAccessibleEvent::EVENT_STATE_CHANGE) { \
nsAccStateChangeEvent *event = downcast_accEvent(aEvent); \
AccStateChangeEvent* event = downcast_accEvent(aEvent); \
if (event->GetState() == nsIAccessibleStates::STATE_BUSY) { \
strEventType.AssignLiteral("busy "); \
if (event->IsStateEnabled()) \

View File

@ -376,16 +376,11 @@ nsAccUtils::GetSelectableContainer(nsAccessible *aAccessible, PRUint32 aState)
if (!(aState & nsIAccessibleStates::STATE_SELECTABLE))
return nsnull;
nsCOMPtr<nsIAccessibleSelectable> container;
nsAccessible *parent = aAccessible;
while (!container) {
parent = parent->GetParent();
if (!parent || Role(parent) == nsIAccessibleRole::ROLE_PANE)
nsAccessible* parent = aAccessible;
while ((parent = parent->GetParent()) && !parent->IsSelect()) {
if (Role(parent) == nsIAccessibleRole::ROLE_PANE)
return nsnull;
container = do_QueryObject(parent);
}
return parent;
}
@ -745,6 +740,9 @@ nsAccUtils::GetHeaderCellsFor(nsIAccessibleTable *aTable,
nsCOMPtr<nsIAccessibleTableCell> tableCellAcc =
do_QueryInterface(cell);
// GetCellAt should always return an nsIAccessibleTableCell (XXX Bug 587529)
NS_ENSURE_STATE(tableCellAcc);
PRInt32 origIdx = 1;
if (moveToLeft)
rv = tableCellAcc->GetColumnIndex(&origIdx);

View File

@ -48,6 +48,7 @@
#include "nsDocAccessible.h"
#include "nsEventShell.h"
#include "nsAccEvent.h"
#include "nsAccessibilityService.h"
#include "nsAccTreeWalker.h"
#include "nsRelUtils.h"
@ -103,6 +104,8 @@
#include "nsIDOMCharacterData.h"
#endif
#include "mozilla/unused.h"
////////////////////////////////////////////////////////////////////////////////
// nsAccessible. nsISupports
@ -152,20 +155,12 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleSelectable))) {
if (mRoleMapEntry &&
(mRoleMapEntry->attributeMap1 == eARIAMultiSelectable ||
mRoleMapEntry->attributeMap2 == eARIAMultiSelectable ||
mRoleMapEntry->attributeMap3 == eARIAMultiSelectable)) {
// If we have an ARIA role attribute present and the role allows multi
// selectable state, then we need to support nsIAccessibleSelectable.
// If either attribute (role or multiselectable) change, then we'll
// destroy this accessible so that we can follow COM identity rules.
if (IsSelect()) {
*aInstancePtr = static_cast<nsIAccessibleSelectable*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_ERROR_NO_INTERFACE;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleValue))) {
@ -177,10 +172,7 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) {
// Every embedded accessible within hypertext accessible implements
// hyperlink interface.
nsCOMPtr<nsIAccessibleHyperText> hyperTextParent = do_QueryObject(GetParent());
if (hyperTextParent && nsAccUtils::IsEmbeddedObject(this)) {
if (IsHyperLink()) {
*aInstancePtr = static_cast<nsIAccessibleHyperLink*>(this);
NS_ADDREF_THIS();
return NS_OK;
@ -193,8 +185,8 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
nsAccessible::nsAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessNodeWrap(aContent, aShell),
mParent(nsnull), mAreChildrenInitialized(PR_FALSE), mIndexInParent(-1),
mRoleMapEntry(nsnull)
mParent(nsnull), mIndexInParent(-1), mChildrenFlags(eChildrenUninitialized),
mIndexOfEmbeddedChild(-1), mRoleMapEntry(nsnull)
{
#ifdef NS_DEBUG_X
{
@ -1100,7 +1092,7 @@ nsAccessible::TakeFocus()
nsIContent* focusContent = mContent;
// If the current element can't take real DOM focus and if it has an ID and
// ancestor with a the aria-activedescendant attribute present, then set DOM
// an ancestor with an aria-activedescendant attribute present, then set DOM
// focus to that ancestor and set aria-activedescendant on the ancestor to
// the ID of the desired element.
if (!frame->IsFocusable()) {
@ -1238,7 +1230,7 @@ nsAccessible::GetXULName(nsAString& aLabel)
}
nsresult
nsAccessible::HandleAccEvent(nsAccEvent *aEvent)
nsAccessible::HandleAccEvent(AccEvent* aEvent)
{
NS_ENSURE_ARG_POINTER(aEvent);
@ -1246,7 +1238,20 @@ nsAccessible::HandleAccEvent(nsAccEvent *aEvent)
mozilla::services::GetObserverService();
NS_ENSURE_TRUE(obsService, NS_ERROR_FAILURE);
return obsService->NotifyObservers(aEvent, NS_ACCESSIBLE_EVENT_TOPIC, nsnull);
nsCOMPtr<nsISimpleEnumerator> observers;
obsService->EnumerateObservers(NS_ACCESSIBLE_EVENT_TOPIC,
getter_AddRefs(observers));
NS_ENSURE_STATE(observers);
PRBool hasObservers = PR_FALSE;
observers->HasMoreElements(&hasObservers);
if (hasObservers) {
nsRefPtr<nsAccEvent> evnt(aEvent->CreateXPCOMObject());
return obsService->NotifyObservers(evnt, NS_ACCESSIBLE_EVENT_TOPIC, nsnull);
}
return NS_OK;
}
NS_IMETHODIMP
@ -2368,22 +2373,18 @@ nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
// nsIAccessibleSelectable
NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
{
NS_ENSURE_ARG_POINTER(aSelectedAccessibles);
*aSelectedAccessibles = nsnull;
nsCOMPtr<nsIMutableArray> selectedAccessibles =
do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_STATE(selectedAccessibles);
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsIAccessible *selected = nsnull;
while ((selected = iter.GetNext()))
selectedAccessibles->AppendElement(selected, PR_FALSE);
PRUint32 length = 0;
selectedAccessibles->GetLength(&length);
if (length) { // length of nsIArray containing selected options
*aSelectedAccessibles = selectedAccessibles;
NS_ADDREF(*aSelectedAccessibles);
nsCOMPtr<nsIArray> items = SelectedItems();
if (items) {
PRUint32 length = 0;
items->GetLength(&length);
if (length)
items.swap(*aSelectedAccessibles);
}
return NS_OK;
@ -2395,23 +2396,20 @@ NS_IMETHODIMP nsAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aSelect
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = nsnull;
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
if (aIndex < 0) {
return NS_ERROR_INVALID_ARG;
}
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsAccessible *selected = nsnull;
PRInt32 count = 0;
while (count ++ <= aIndex) {
selected = iter.GetNext();
if (!selected) {
// The index is out of range.
return NS_ERROR_INVALID_ARG;
}
*aSelected = GetSelectedItem(aIndex);
if (*aSelected) {
NS_ADDREF(*aSelected);
return NS_OK;
}
NS_IF_ADDREF(*aSelected = selected);
return NS_OK;
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP nsAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
@ -2419,83 +2417,65 @@ NS_IMETHODIMP nsAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
NS_ENSURE_ARG_POINTER(aSelectionCount);
*aSelectionCount = 0;
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsAccessible *selected = nsnull;
while ((selected = iter.GetNext()))
++(*aSelectionCount);
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
*aSelectionCount = SelectedItemCount();
return NS_OK;
}
NS_IMETHODIMP nsAccessible::AddChildToSelection(PRInt32 aIndex)
{
// Tree views and other container widgets which may have grandchildren should
// implement a selection methods for their specific interfaces, because being
// able to deal with selection on a per-child basis would not be enough.
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (!(state & nsIAccessibleStates::STATE_SELECTABLE)) {
return NS_OK;
}
return child->SetSelected(PR_TRUE);
return aIndex >= 0 && AddItemToSelection(aIndex) ?
NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP nsAccessible::RemoveChildFromSelection(PRInt32 aIndex)
{
// Tree views and other container widgets which may have grandchildren should
// implement a selection methods for their specific interfaces, because being
// able to deal with selection on a per-child basis would not be enough.
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (!(state & nsIAccessibleStates::STATE_SELECTED)) {
return NS_OK;
}
return child->SetSelected(PR_FALSE);
return aIndex >=0 && RemoveItemFromSelection(aIndex) ?
NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP nsAccessible::IsChildSelected(PRInt32 aIndex, PRBool *aIsSelected)
{
// Tree views and other container widgets which may have grandchildren should
// implement a selection methods for their specific interfaces, because being
// able to deal with selection on a per-child basis would not be enough.
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = PR_FALSE;
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (state & nsIAccessibleStates::STATE_SELECTED) {
*aIsSelected = PR_TRUE;
}
*aIsSelected = IsItemSelected(aIndex);
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::ClearSelection()
{
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsAccessible *selected = nsnull;
while ((selected = iter.GetNext()))
selected->SetSelected(PR_FALSE);
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
UnselectAll();
return NS_OK;
}
NS_IMETHODIMP nsAccessible::SelectAllSelection(PRBool *_retval)
NS_IMETHODIMP
nsAccessible::SelectAllSelection(PRBool* aIsMultiSelect)
{
AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
nsAccessible *selectable = nsnull;
while((selectable = iter.GetNext()))
selectable->SetSelected(PR_TRUE);
NS_ENSURE_ARG_POINTER(aIsMultiSelect);
*aIsMultiSelect = PR_FALSE;
if (IsDefunct() || !IsSelect())
return NS_ERROR_FAILURE;
*aIsMultiSelect = SelectAll();
return NS_OK;
}
@ -2509,7 +2489,12 @@ NS_IMETHODIMP
nsAccessible::GetAnchorCount(PRInt32 *aAnchorCount)
{
NS_ENSURE_ARG_POINTER(aAnchorCount);
*aAnchorCount = 1;
*aAnchorCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aAnchorCount = AnchorCount();
return NS_OK;
}
@ -2523,8 +2508,8 @@ nsAccessible::GetStartIndex(PRInt32 *aStartIndex)
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 endIndex;
return GetLinkOffset(aStartIndex, &endIndex);
*aStartIndex = StartOffset();
return NS_OK;
}
// readonly attribute long nsIAccessibleHyperLink::endIndex
@ -2537,47 +2522,39 @@ nsAccessible::GetEndIndex(PRInt32 *aEndIndex)
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 startIndex;
return GetLinkOffset(&startIndex, aEndIndex);
*aEndIndex = EndOffset();
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
*aURI = nsnull;
if (aIndex != 0)
if (IsDefunct())
return NS_ERROR_FAILURE;
if (aIndex < 0 || aIndex >= static_cast<PRInt32>(AnchorCount()))
return NS_ERROR_INVALID_ARG;
// Check if it's a simple xlink.
if (nsCoreUtils::IsXLink(mContent)) {
nsAutoString href;
mContent->GetAttr(kNameSpaceID_XLink, nsAccessibilityAtoms::href, href);
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
nsCOMPtr<nsIDocument> document = mContent->GetOwnerDoc();
return NS_NewURI(aURI, href,
document ? document->GetDocumentCharacterSet().get() : nsnull,
baseURI);
}
*aURI = GetAnchorURI(aIndex).get();
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GetAnchor(PRInt32 aIndex,
nsIAccessible **aAccessible)
nsAccessible::GetAnchor(PRInt32 aIndex, nsIAccessible** aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
if (aIndex != 0)
if (IsDefunct())
return NS_ERROR_FAILURE;
if (aIndex < 0 || aIndex >= static_cast<PRInt32>(AnchorCount()))
return NS_ERROR_INVALID_ARG;
*aAccessible = this;
NS_ADDREF_THIS();
NS_IF_ADDREF(*aAccessible = GetAnchor(aIndex));
return NS_OK;
}
@ -2586,12 +2563,12 @@ NS_IMETHODIMP
nsAccessible::GetValid(PRBool *aValid)
{
NS_ENSURE_ARG_POINTER(aValid);
PRUint32 state = nsAccUtils::State(this);
*aValid = (0 == (state & nsIAccessibleStates::STATE_INVALID));
// XXX In order to implement this we would need to follow every link
// Perhaps we can get information about invalid links from the cache
// In the mean time authors can use role="link" aria-invalid="true"
// to force it for links they internally know to be invalid
*aValid = PR_FALSE;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aValid = IsValid();
return NS_OK;
}
@ -2600,33 +2577,14 @@ NS_IMETHODIMP
nsAccessible::GetSelected(PRBool *aSelected)
{
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = PR_FALSE;
*aSelected = (gLastFocusedNode == GetNode());
if (IsDefunct())
return NS_ERROR_FAILURE;
*aSelected = IsSelected();
return NS_OK;
}
nsresult
nsAccessible::GetLinkOffset(PRInt32 *aStartOffset, PRInt32 *aEndOffset)
{
nsAccessible *parent = GetParent();
NS_ENSURE_STATE(parent);
PRUint32 characterCount = 0;
PRInt32 childCount = parent->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *sibling = parent->GetChildAt(childIdx);
if (sibling == this) {
*aStartOffset = characterCount;
*aEndOffset = characterCount + 1;
return NS_OK;
}
characterCount += nsAccUtils::TextLength(sibling);
}
return NS_ERROR_FAILURE;
}
nsresult
@ -2694,16 +2652,9 @@ nsAccessible::Shutdown()
nsresult
nsAccessible::GetARIAName(nsAString& aName)
{
// First check for label override via aria-label property
nsAutoString label;
if (mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_label,
label)) {
label.CompressWhitespace();
aName = label;
return NS_OK;
}
// Second check for label override via aria-labelledby relationship
// aria-labelledby now takes precedence over aria-label
nsresult rv = nsTextEquivUtils::
GetTextEquivFromIDRefs(this, nsAccessibilityAtoms::aria_labelledby, label);
if (NS_SUCCEEDED(rv)) {
@ -2711,7 +2662,14 @@ nsAccessible::GetARIAName(nsAString& aName)
aName = label;
}
return rv;
if (label.IsEmpty() &&
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_label,
label)) {
label.CompressWhitespace();
aName = label;
}
return NS_OK;
}
nsresult
@ -2751,6 +2709,7 @@ nsAccessible::UnbindFromParent()
{
mParent = nsnull;
mIndexInParent = -1;
mIndexOfEmbeddedChild = -1;
mGroupInfo = nsnull;
}
@ -2763,8 +2722,9 @@ nsAccessible::InvalidateChildren()
child->UnbindFromParent();
}
mEmbeddedObjCollector = nsnull;
mChildren.Clear();
mAreChildrenInitialized = PR_FALSE;
mChildrenFlags = eChildrenUninitialized;
}
PRBool
@ -2773,6 +2733,9 @@ nsAccessible::AppendChild(nsAccessible* aChild)
if (!mChildren.AppendElement(aChild))
return PR_FALSE;
if (nsAccUtils::IsText(aChild))
mChildrenFlags = eMixedChildren;
aChild->BindToParent(this, mChildren.Length() - 1);
return PR_TRUE;
}
@ -2786,6 +2749,11 @@ nsAccessible::InsertChildAt(PRUint32 aIndex, nsAccessible* aChild)
for (PRUint32 idx = aIndex + 1; idx < mChildren.Length(); idx++)
mChildren[idx]->mIndexInParent++;
if (nsAccUtils::IsText(aChild))
mChildrenFlags = eMixedChildren;
mEmbeddedObjCollector = nsnull;
aChild->BindToParent(this, aIndex);
return PR_TRUE;
}
@ -2800,6 +2768,8 @@ nsAccessible::RemoveChild(nsAccessible* aChild)
mChildren[idx]->mIndexInParent--;
mChildren.RemoveElementAt(aChild->mIndexInParent);
mEmbeddedObjCollector = nsnull;
aChild->UnbindFromParent();
return PR_TRUE;
}
@ -2873,10 +2843,57 @@ PRInt32
nsAccessible::GetIndexInParent()
{
// XXX: call GetParent() to repair the tree if it's broken.
nsAccessible* parent = GetParent();
GetParent();
return mIndexInParent;
}
PRInt32
nsAccessible::GetEmbeddedChildCount()
{
if (EnsureChildren())
return -1;
if (mChildrenFlags == eMixedChildren) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);
return mEmbeddedObjCollector ? mEmbeddedObjCollector->Count() : -1;
}
return GetChildCount();
}
nsAccessible*
nsAccessible::GetEmbeddedChildAt(PRUint32 aIndex)
{
if (EnsureChildren())
return nsnull;
if (mChildrenFlags == eMixedChildren) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);
return mEmbeddedObjCollector ?
mEmbeddedObjCollector->GetAccessibleAt(aIndex) : nsnull;
}
return GetChildAt(aIndex);
}
PRInt32
nsAccessible::GetIndexOfEmbeddedChild(nsAccessible* aChild)
{
if (EnsureChildren())
return -1;
if (mChildrenFlags == eMixedChildren) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);
return mEmbeddedObjCollector ?
mEmbeddedObjCollector->GetIndexAt(aChild) : -1;
}
return GetIndexOf(aChild);
}
#ifdef DEBUG
PRBool
nsAccessible::IsInCache()
@ -2894,6 +2911,227 @@ nsAccessible::IsInCache()
#endif
////////////////////////////////////////////////////////////////////////////////
// HyperLinkAccessible methods
bool
nsAccessible::IsHyperLink()
{
// Every embedded accessible within hypertext accessible implements
// hyperlink interface.
nsRefPtr<nsHyperTextAccessible> hyperText = do_QueryObject(GetParent());
return hyperText && nsAccUtils::IsEmbeddedObject(this);
}
PRUint32
nsAccessible::StartOffset()
{
NS_PRECONDITION(IsHyperLink(), "StartOffset is called not on hyper link!");
nsRefPtr<nsHyperTextAccessible> hyperText(do_QueryObject(GetParent()));
return hyperText ? hyperText->GetChildOffset(this) : 0;
}
PRUint32
nsAccessible::EndOffset()
{
NS_PRECONDITION(IsHyperLink(), "EndOffset is called on not hyper link!");
nsRefPtr<nsHyperTextAccessible> hyperText(do_QueryObject(GetParent()));
return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0;
}
bool
nsAccessible::IsValid()
{
NS_PRECONDITION(IsHyperLink(), "IsValid is called on not hyper link!");
PRUint32 state = nsAccUtils::State(this);
return (0 == (state & nsIAccessibleStates::STATE_INVALID));
// XXX In order to implement this we would need to follow every link
// Perhaps we can get information about invalid links from the cache
// In the mean time authors can use role="link" aria-invalid="true"
// to force it for links they internally know to be invalid
}
bool
nsAccessible::IsSelected()
{
NS_PRECONDITION(IsHyperLink(), "IsSelected is called on not hyper link!");
return (gLastFocusedNode == GetNode());
}
PRUint32
nsAccessible::AnchorCount()
{
NS_PRECONDITION(IsHyperLink(), "AnchorCount is called on not hyper link!");
return 1;
}
nsAccessible*
nsAccessible::GetAnchor(PRUint32 aAnchorIndex)
{
NS_PRECONDITION(IsHyperLink(), "GetAnchor is called on not hyper link!");
return aAnchorIndex == 0 ? this : nsnull;
}
already_AddRefed<nsIURI>
nsAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
{
NS_PRECONDITION(IsHyperLink(), "GetAnchorURI is called on not hyper link!");
if (aAnchorIndex != 0)
return nsnull;
// Check if it's a simple xlink.
if (nsCoreUtils::IsXLink(mContent)) {
nsAutoString href;
mContent->GetAttr(kNameSpaceID_XLink, nsAccessibilityAtoms::href, href);
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
nsCOMPtr<nsIDocument> document = mContent->GetOwnerDoc();
nsIURI* anchorURI = nsnull;
NS_NewURI(&anchorURI, href,
document ? document->GetDocumentCharacterSet().get() : nsnull,
baseURI);
return anchorURI;
}
return nsnull;
}
////////////////////////////////////////////////////////////////////////////////
// SelectAccessible
bool
nsAccessible::IsSelect()
{
// If we have an ARIA role attribute present and the role allows multi
// selectable state, then we need to support SelectAccessible interface. If
// either attribute (role or multiselectable) change, then we'll destroy this
// accessible so that we can follow COM identity rules.
return mRoleMapEntry &&
(mRoleMapEntry->attributeMap1 == eARIAMultiSelectable ||
mRoleMapEntry->attributeMap2 == eARIAMultiSelectable ||
mRoleMapEntry->attributeMap3 == eARIAMultiSelectable);
}
already_AddRefed<nsIArray>
nsAccessible::SelectedItems()
{
nsCOMPtr<nsIMutableArray> selectedItems = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (!selectedItems)
return nsnull;
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsIAccessible* selected = nsnull;
while ((selected = iter.GetNext()))
selectedItems->AppendElement(selected, PR_FALSE);
nsIMutableArray* items = nsnull;
selectedItems.forget(&items);
return items;
}
PRUint32
nsAccessible::SelectedItemCount()
{
PRUint32 count = 0;
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsAccessible* selected = nsnull;
while ((selected = iter.GetNext()))
++count;
return count;
}
nsAccessible*
nsAccessible::GetSelectedItem(PRUint32 aIndex)
{
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
nsAccessible* selected = nsnull;
PRUint32 index = 0;
while ((selected = iter.GetNext()) && index < aIndex)
index++;
return selected;
}
bool
nsAccessible::IsItemSelected(PRUint32 aIndex)
{
PRUint32 index = 0;
AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
nsAccessible* selected = nsnull;
while ((selected = iter.GetNext()) && index < aIndex)
index++;
return selected &&
nsAccUtils::State(selected) & nsIAccessibleStates::STATE_SELECTED;
}
bool
nsAccessible::AddItemToSelection(PRUint32 aIndex)
{
PRUint32 index = 0;
AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
nsAccessible* selected = nsnull;
while ((selected = iter.GetNext()) && index < aIndex)
index++;
if (selected)
selected->SetSelected(PR_TRUE);
return static_cast<bool>(selected);
}
bool
nsAccessible::RemoveItemFromSelection(PRUint32 aIndex)
{
PRUint32 index = 0;
AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
nsAccessible* selected = nsnull;
while ((selected = iter.GetNext()) && index < aIndex)
index++;
if (selected)
selected->SetSelected(PR_FALSE);
return static_cast<bool>(selected);
}
bool
nsAccessible::SelectAll()
{
bool success = false;
nsAccessible* selectable = nsnull;
AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
while((selectable = iter.GetNext())) {
success = true;
selectable->SetSelected(PR_TRUE);
}
return success;
}
bool
nsAccessible::UnselectAll()
{
bool success = false;
nsAccessible* selected = nsnull;
AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
while ((selected = iter.GetNext())) {
success = true;
selected->SetSelected(PR_FALSE);
}
return success;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessible protected methods
@ -2912,7 +3150,8 @@ nsAccessible::TestChildCache(nsAccessible *aCachedChild)
#ifdef DEBUG
PRInt32 childCount = mChildren.Length();
if (childCount == 0) {
NS_ASSERTION(!mAreChildrenInitialized, "No children but initialized!");
NS_ASSERTION(mChildrenFlags == eChildrenUninitialized,
"No children but initialized!");
return;
}
@ -2933,14 +3172,15 @@ PRBool
nsAccessible::EnsureChildren()
{
if (IsDefunct()) {
mAreChildrenInitialized = PR_FALSE;
mChildrenFlags = eChildrenUninitialized;
return PR_TRUE;
}
if (mAreChildrenInitialized)
if (mChildrenFlags != eChildrenUninitialized)
return PR_FALSE;
mAreChildrenInitialized = PR_TRUE; // Prevent reentry
// State is embedded children until text leaf accessible is appended.
mChildrenFlags = eEmbeddedChildren; // Prevent reentry
CacheChildren();
return PR_FALSE;

View File

@ -53,8 +53,9 @@
#include "nsRefPtrHashtable.h"
class AccGroupInfo;
class EmbeddedObjCollector;
class nsAccessible;
class nsAccEvent;
class AccEvent;
struct nsRoleMapEntry;
struct nsRect;
@ -256,6 +257,21 @@ public:
*/
PRBool HasChildren() { return !!GetChildAt(0); }
/**
* Return embedded accessible children count.
*/
PRInt32 GetEmbeddedChildCount();
/**
* Return embedded accessible child at the given index.
*/
nsAccessible* GetEmbeddedChildAt(PRUint32 aIndex);
/**
* Return index of the given embedded accessible child.
*/
PRInt32 GetIndexOfEmbeddedChild(nsAccessible* aChild);
/**
* Return cached accessible of parent-child relatives.
*/
@ -271,7 +287,7 @@ public:
mParent->mChildren.SafeElementAt(mIndexInParent - 1, nsnull).get() : nsnull;
}
PRUint32 GetCachedChildCount() const { return mChildren.Length(); }
PRBool AreChildrenCached() const { return mAreChildrenInitialized; }
PRBool AreChildrenCached() const { return mChildrenFlags != eChildrenUninitialized; }
#ifdef DEBUG
/**
@ -287,7 +303,7 @@ public:
* Handle accessible event, i.e. process it, notifies observers and fires
* platform specific event.
*/
virtual nsresult HandleAccEvent(nsAccEvent *aAccEvent);
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
/**
* Return true if there are accessible children in anonymous content
@ -311,6 +327,98 @@ public:
*/
void TestChildCache(nsAccessible *aCachedChild);
//////////////////////////////////////////////////////////////////////////////
// HyperLinkAccessible
/**
* Return true if the accessible is hyper link accessible.
*/
virtual bool IsHyperLink();
/**
* Return the start offset of the link within the parent accessible.
*/
virtual PRUint32 StartOffset();
/**
* Return the end offset of the link within the parent accessible.
*/
virtual PRUint32 EndOffset();
/**
* Return true if the link is valid (e. g. points to a valid URL).
*/
virtual bool IsValid();
/**
* Return true if the link currently has the focus.
*/
virtual bool IsSelected();
/**
* Return the number of anchors within the link.
*/
virtual PRUint32 AnchorCount();
/**
* Returns an anchor accessible at the given index.
*/
virtual nsAccessible* GetAnchor(PRUint32 aAnchorIndex);
/**
* Returns an anchor URI at the given index.
*/
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
//////////////////////////////////////////////////////////////////////////////
// SelectAccessible
/**
* Return true if the accessible is a select control containing selectable
* items.
*/
virtual bool IsSelect();
/**
* Return an array of selected items.
*/
virtual already_AddRefed<nsIArray> SelectedItems();
/**
* Return the number of selected items.
*/
virtual PRUint32 SelectedItemCount();
/**
* Return selected item at the given index.
*/
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
/**
* Determine if item at the given index is selected.
*/
virtual bool IsItemSelected(PRUint32 aIndex);
/**
* Add item at the given index the selection. Return true if success.
*/
virtual bool AddItemToSelection(PRUint32 aIndex);
/**
* Remove item at the given index from the selection. Return if success.
*/
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
/**
* Select all items. Return true if success.
*/
virtual bool SelectAll();
/**
* Unselect all items. Return true if success.
*/
virtual bool UnselectAll();
protected:
//////////////////////////////////////////////////////////////////////////////
@ -367,9 +475,6 @@ protected:
*/
nsAccessible *GetFirstAvailableAccessible(nsINode *aStartNode) const;
// Hyperlink helpers
virtual nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);
//////////////////////////////////////////////////////////////////////////////
// Action helpers
@ -438,14 +543,24 @@ protected:
*
* @param aEvent the accessible event to fire.
*/
virtual nsresult FirePlatformEvent(nsAccEvent *aEvent) = 0;
virtual nsresult FirePlatformEvent(AccEvent* aEvent) = 0;
// Data Members
nsRefPtr<nsAccessible> mParent;
nsTArray<nsRefPtr<nsAccessible> > mChildren;
PRBool mAreChildrenInitialized;
PRInt32 mIndexInParent;
enum ChildrenFlags {
eChildrenUninitialized = 0x00,
eMixedChildren = 0x01,
eEmbeddedChildren = 0x02
};
ChildrenFlags mChildrenFlags;
nsAutoPtr<EmbeddedObjCollector> mEmbeddedObjCollector;
PRInt32 mIndexOfEmbeddedChild;
friend class EmbeddedObjCollector;
nsAutoPtr<AccGroupInfo> mGroupInfo;
friend class AccGroupInfo;

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -63,6 +63,8 @@ class nsApplicationAccessible: public nsAccessibleWrap,
public nsIAccessibleApplication
{
public:
using nsAccessible::GetChildAtPoint;
nsApplicationAccessible();
// nsISupports

View File

@ -204,27 +204,6 @@ nsLinkableAccessible::GetKeyboardShortcut(nsAString& aKeyboardShortcut)
return nsAccessible::GetKeyboardShortcut(aKeyboardShortcut);
}
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible. nsIAccessibleHyperLink
NS_IMETHODIMP
nsLinkableAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
{
if (mIsLink) {
nsAccessible *actionAcc = GetActionAccessible();
if (actionAcc) {
nsCOMPtr<nsIAccessibleHyperLink> hyperLinkAcc = do_QueryObject(actionAcc);
NS_ASSERTION(hyperLinkAcc,
"nsIAccessibleHyperLink isn't implemented.");
if (hyperLinkAcc)
return hyperLinkAcc->GetURI(aIndex, aURI);
}
}
return NS_ERROR_INVALID_ARG;
}
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible. nsAccessNode
@ -242,6 +221,26 @@ nsLinkableAccessible::Shutdown()
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible: HyperLinkAccessible
already_AddRefed<nsIURI>
nsLinkableAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
{
if (mIsLink) {
nsAccessible* link = GetActionAccessible();
if (link) {
NS_ASSERTION(link->IsHyperLink(),
"nsIAccessibleHyperLink isn't implemented.");
if (link->IsHyperLink())
return link->GetAnchorURI(aAnchorIndex);
}
}
return nsnull;
}
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible

View File

@ -55,6 +55,8 @@
class nsLeafAccessible : public nsAccessibleWrap
{
public:
using nsAccessible::GetChildAtPoint;
nsLeafAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
@ -94,9 +96,6 @@ public:
NS_IMETHOD TakeFocus();
NS_IMETHOD GetKeyboardShortcut(nsAString& _retval);
// nsIAccessibleHyperLink
NS_IMETHOD GetURI(PRInt32 i, nsIURI **aURI);
// nsAccessNode
virtual PRBool Init();
virtual void Shutdown();
@ -104,6 +103,9 @@ public:
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
// HyperLinkAccessible
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
protected:
/**
* Return an accessible for cached action node.

View File

@ -264,8 +264,7 @@ nsCaretAccessible::NormalSelectionChanged(nsIDOMDocument *aDoc,
mLastCaretOffset = caretOffset;
mLastTextAccessible.swap(textAcc);
nsRefPtr<nsAccEvent> event =
new nsAccCaretMoveEvent(textNode);
nsRefPtr<AccEvent> event = new AccCaretMoveEvent(textNode);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
return mRootAccessible->FireDelayedAccessibleEvent(event);
@ -285,9 +284,9 @@ nsCaretAccessible::SpellcheckSelectionChanged(nsIDOMDocument *aDoc,
nsAccUtils::GetTextAccessibleFromSelection(aSel);
NS_ENSURE_STATE(textAcc);
nsRefPtr<nsAccEvent> event =
new nsAccEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
textAcc, nsnull);
nsRefPtr<AccEvent> event =
new AccEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
textAcc, nsnull);
nsEventShell::FireEvent(event);
return NS_OK;

View File

@ -73,10 +73,13 @@
#include "nsIURI.h"
#include "nsIWebNavigation.h"
#include "nsFocusManager.h"
#include "mozilla/dom/Element.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
#endif
namespace dom = mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// Static member initialization
@ -608,8 +611,8 @@ nsDocAccessible::Init()
// Fire reorder event to notify new accessible document has been created and
// attached to the tree.
nsRefPtr<nsAccEvent> reorderEvent =
new nsAccReorderEvent(mParent, PR_FALSE, PR_TRUE, mDocument);
nsRefPtr<AccEvent> reorderEvent =
new AccReorderEvent(mParent, PR_FALSE, PR_TRUE, mDocument);
if (!reorderEvent)
return PR_FALSE;
@ -875,11 +878,11 @@ NS_IMETHODIMP nsDocAccessible::Observe(nsISupports *aSubject, const char *aTopic
if (!nsCRT::strcmp(aTopic,"obs_documentCreated")) {
// State editable will now be set, readonly is now clear
// Normally we only fire delayed events created from the node, not an
// accessible object. See the nsAccStateChangeEvent constructor for details
// accessible object. See the AccStateChangeEvent constructor for details
// about this exceptional case.
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE, PR_TRUE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE, PR_TRUE);
FireDelayedAccessibleEvent(event);
}
@ -895,7 +898,8 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsDocAccessible)
void
nsDocAccessible::AttributeWillChange(nsIDocument *aDocument,
nsIContent* aContent, PRInt32 aNameSpaceID,
dom::Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute, PRInt32 aModType)
{
// XXX TODO: bugs 381599 467143 472142 472143
@ -905,15 +909,16 @@ nsDocAccessible::AttributeWillChange(nsIDocument *aDocument,
}
void
nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
nsDocAccessible::AttributeChanged(nsIDocument *aDocument,
dom::Element* aElement,
PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRInt32 aModType)
{
AttributeChangedImpl(aContent, aNameSpaceID, aAttribute);
AttributeChangedImpl(aElement, aNameSpaceID, aAttribute);
// If it was the focused node, cache the new state
if (aContent == gLastFocusedNode) {
nsAccessible *focusedAccessible = GetAccService()->GetAccessible(aContent);
if (aElement == gLastFocusedNode) {
nsAccessible *focusedAccessible = GetAccService()->GetAccessible(aElement);
if (focusedAccessible)
gLastFocusedAccessiblesState = nsAccUtils::State(focusedAccessible);
}
@ -967,17 +972,17 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
// Note. We use the attribute instead of the disabled state bit because
// ARIA's aria-disabled does not affect the disabled state bit.
nsRefPtr<nsAccEvent> enabledChangeEvent =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_ENABLED,
PR_TRUE);
nsRefPtr<AccEvent> enabledChangeEvent =
new AccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_ENABLED,
PR_TRUE);
FireDelayedAccessibleEvent(enabledChangeEvent);
nsRefPtr<nsAccEvent> sensitiveChangeEvent =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_SENSITIVE,
PR_TRUE);
nsRefPtr<AccEvent> sensitiveChangeEvent =
new AccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_SENSITIVE,
PR_TRUE);
FireDelayedAccessibleEvent(sensitiveChangeEvent);
return;
@ -1028,7 +1033,7 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
// seem right but we had started using it for something else
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelect->GetNode(),
nsAccEvent::eAllowDupes);
AccEvent::eAllowDupes);
static nsIContent::AttrValuesArray strings[] =
{&nsAccessibilityAtoms::_empty, &nsAccessibilityAtoms::_false, nsnull};
@ -1045,10 +1050,10 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
}
if (aAttribute == nsAccessibilityAtoms::contenteditable) {
nsRefPtr<nsAccEvent> editableChangeEvent =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE);
nsRefPtr<AccEvent> editableChangeEvent =
new AccStateChangeEvent(aContent,
nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE);
FireDelayedAccessibleEvent(editableChangeEvent);
return;
}
@ -1062,19 +1067,17 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
// there is an ARIA role present or not.
if (aAttribute == nsAccessibilityAtoms::aria_required) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::STATE_REQUIRED,
PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_REQUIRED,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
if (aAttribute == nsAccessibilityAtoms::aria_invalid) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::STATE_INVALID,
PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_INVALID,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
@ -1102,10 +1105,9 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
// We treat aria-expanded as a global ARIA state for historical reasons
if (aAttribute == nsAccessibilityAtoms::aria_expanded) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
@ -1124,8 +1126,8 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
const PRUint32 kState = (aAttribute == nsAccessibilityAtoms::aria_checked) ?
nsIAccessibleStates::STATE_CHECKED :
nsIAccessibleStates::STATE_PRESSED;
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent, kState, PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, kState, PR_FALSE);
FireDelayedAccessibleEvent(event);
if (aContent == gLastFocusedNode) {
// State changes for MIXED state currently only supported for focused item, because
@ -1138,10 +1140,9 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
PRBool isMixed =
(nsAccUtils::State(accessible) & nsIAccessibleStates::STATE_MIXED) != 0;
if (wasMixed != isMixed) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::STATE_MIXED,
PR_FALSE, isMixed);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_MIXED,
PR_FALSE, isMixed);
FireDelayedAccessibleEvent(event);
}
}
@ -1150,10 +1151,9 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
}
if (aAttribute == nsAccessibilityAtoms::aria_readonly) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(aContent,
nsIAccessibleStates::STATE_READONLY,
PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_READONLY,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
@ -1174,7 +1174,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
if (aAttribute == nsAccessibilityAtoms::aria_multiselectable &&
aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) {
// This affects whether the accessible supports nsIAccessibleSelectable.
// This affects whether the accessible supports SelectAccessible.
// COM says we cannot change what interfaces are supported on-the-fly,
// so invalidate this object. A new one will be created on demand.
InvalidateCacheSubtree(aContent,
@ -1272,7 +1272,7 @@ nsDocAccessible::ParentChainChanged(nsIContent *aContent)
#ifdef DEBUG_ACCDOCMGR
nsresult
nsDocAccessible::HandleAccEvent(nsAccEvent *aAccEvent)
nsDocAccessible::HandleAccEvent(AccEvent* aAccEvent)
{
NS_LOG_ACCDOCLOAD_HANDLEEVENT(aAccEvent)
@ -1295,9 +1295,9 @@ nsDocAccessible::FireValueChangeForTextFields(nsAccessible *aAccessible)
return;
// Dependent value change event for text changes in textfields
nsRefPtr<nsAccEvent> valueChangeEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible,
PR_FALSE, eAutoDetect, nsAccEvent::eRemoveDupes);
nsRefPtr<AccEvent> valueChangeEvent =
new AccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible,
PR_FALSE, eAutoDetect, AccEvent::eRemoveDupes);
FireDelayedAccessibleEvent(valueChangeEvent);
}
@ -1350,17 +1350,17 @@ nsDocAccessible::FireTextChangeEventForText(nsIContent *aContent,
return;
// Normally we only fire delayed events created from the node, not an
// accessible object. See the nsAccTextChangeEvent constructor for details
// accessible object. See the AccTextChangeEvent constructor for details
// about this exceptional case.
nsRefPtr<nsAccEvent> event =
new nsAccTextChangeEvent(textAccessible, offset + textOffset, text,
aIsInserted, PR_FALSE);
nsRefPtr<AccEvent> event =
new AccTextChangeEvent(textAccessible, offset + textOffset, text,
aIsInserted, PR_FALSE);
FireDelayedAccessibleEvent(event);
FireValueChangeForTextFields(textAccessible);
}
already_AddRefed<nsAccEvent>
already_AddRefed<AccEvent>
nsDocAccessible::CreateTextChangeEventForNode(nsAccessible *aContainerAccessible,
nsIContent *aChangeNode,
nsAccessible *aChangeChild,
@ -1427,9 +1427,9 @@ nsDocAccessible::CreateTextChangeEventForNode(nsAccessible *aContainerAccessible
if (text.IsEmpty())
return nsnull;
nsAccEvent *event =
new nsAccTextChangeEvent(aContainerAccessible, offset, text,
aIsInserting, aIsAsynch, aIsFromUserInput);
AccEvent* event = new AccTextChangeEvent(aContainerAccessible, offset, text,
aIsInserting, aIsAsynch,
aIsFromUserInput);
NS_IF_ADDREF(event);
return event;
@ -1438,12 +1438,12 @@ nsDocAccessible::CreateTextChangeEventForNode(nsAccessible *aContainerAccessible
// nsDocAccessible public member
nsresult
nsDocAccessible::FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
nsAccEvent::EEventRule aAllowDupes,
AccEvent::EEventRule aAllowDupes,
PRBool aIsAsynch,
EIsFromUserInput aIsFromUserInput)
{
nsRefPtr<nsAccEvent> event =
new nsAccEvent(aEventType, aNode, aIsAsynch, aIsFromUserInput, aAllowDupes);
nsRefPtr<AccEvent> event =
new AccEvent(aEventType, aNode, aIsAsynch, aIsFromUserInput, aAllowDupes);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
return FireDelayedAccessibleEvent(event);
@ -1451,7 +1451,7 @@ nsDocAccessible::FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
// nsDocAccessible public member
nsresult
nsDocAccessible::FireDelayedAccessibleEvent(nsAccEvent *aEvent)
nsDocAccessible::FireDelayedAccessibleEvent(AccEvent* aEvent)
{
NS_ENSURE_ARG(aEvent);
NS_LOG_ACCDOCLOAD_FIREEVENT(aEvent)
@ -1463,7 +1463,7 @@ nsDocAccessible::FireDelayedAccessibleEvent(nsAccEvent *aEvent)
}
void
nsDocAccessible::ProcessPendingEvent(nsAccEvent *aEvent)
nsDocAccessible::ProcessPendingEvent(AccEvent* aEvent)
{
nsAccessible *accessible = aEvent->GetAccessible();
nsINode *node = aEvent->GetNode();
@ -1530,7 +1530,7 @@ nsDocAccessible::ProcessPendingEvent(nsAccEvent *aEvent)
// the offset, length and text for the text change.
if (node && node != mDocument) {
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
nsRefPtr<nsAccEvent> textChangeEvent =
nsRefPtr<AccEvent> textChangeEvent =
CreateTextChangeEventForNode(containerAccessible, content, accessible,
PR_TRUE, PR_TRUE, isFromUserInput);
if (textChangeEvent) {
@ -1564,8 +1564,8 @@ nsDocAccessible::ProcessPendingEvent(nsAccEvent *aEvent)
GetAccService()->GetAccessible(gLastFocusedNode);
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, focusedAcc);
#endif
nsRefPtr<nsAccEvent> caretMoveEvent =
new nsAccCaretMoveEvent(accessible, caretOffset);
nsRefPtr<AccEvent> caretMoveEvent =
new AccCaretMoveEvent(accessible, caretOffset);
if (!caretMoveEvent)
return;
@ -1583,7 +1583,7 @@ nsDocAccessible::ProcessPendingEvent(nsAccEvent *aEvent)
// Fire reorder event if it's unconditional (see InvalidateCacheSubtree
// method) or if changed node (that is the reason of this reorder event)
// is accessible or has accessible children.
nsAccReorderEvent *reorderEvent = downcast_accEvent(aEvent);
AccReorderEvent* reorderEvent = downcast_accEvent(aEvent);
if (reorderEvent->IsUnconditionalEvent() ||
reorderEvent->HasAccessibleInReasonSubtree()) {
nsEventShell::FireEvent(aEvent);
@ -1710,9 +1710,11 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
aChangeType == nsIAccessibilityService::FRAME_SHOW ||
aChangeType == nsIAccessibilityService::NODE_APPEND;
#ifdef DEBUG
PRBool isChanging =
aChangeType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE ||
aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE;
#endif
NS_ASSERTION(isChanging || isHiding || isShowing,
"Incorrect aChangeEventType passed in");
@ -1850,7 +1852,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
// nsIAccessibleStates::STATE_INVISIBLE for the event's accessible object.
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SHOW, childNode,
nsAccEvent::eCoalesceFromSameSubtree,
AccEvent::eCoalesceFromSameSubtree,
isAsynch);
// Check to see change occurred in an ARIA menu, and fire
@ -1858,7 +1860,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(childNode);
if (roleMapEntry && roleMapEntry->role == nsIAccessibleRole::ROLE_MENUPOPUP) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
childNode, nsAccEvent::eRemoveDupes,
childNode, AccEvent::eRemoveDupes,
isAsynch);
}
@ -1867,7 +1869,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
while (PR_TRUE) {
if (roleMapEntry && roleMapEntry->role == nsIAccessibleRole::ROLE_ALERT) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_ALERT, ancestor,
nsAccEvent::eRemoveDupes, isAsynch);
AccEvent::eRemoveDupes, isAsynch);
break;
}
ancestor = ancestor->GetParent();
@ -1895,10 +1897,9 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
PRBool isUnconditionalEvent = childAccessible ||
aChild && nsAccUtils::HasAccessibleChildren(childNode);
nsRefPtr<nsAccEvent> reorderEvent =
new nsAccReorderEvent(containerAccessible, isAsynch,
isUnconditionalEvent,
aChild ? aChild : nsnull);
nsRefPtr<AccEvent> reorderEvent =
new AccReorderEvent(containerAccessible, isAsynch, isUnconditionalEvent,
aChild ? aChild : nsnull);
NS_ENSURE_TRUE(reorderEvent,);
FireDelayedAccessibleEvent(reorderEvent);
@ -1928,7 +1929,7 @@ nsDocAccessible::FireShowHideEvents(nsINode *aNode,
if (accessible) {
// Found an accessible, so fire the show/hide on it and don't look further
// into this subtree.
nsRefPtr<nsAccEvent> event;
nsRefPtr<AccEvent> event;
if (aDelayedOrNormal == eDelayedEvent &&
aEventType == nsIAccessibleEvent::EVENT_HIDE) {
// Use AccHideEvent for delayed hide events to coalesce text change events
@ -1937,9 +1938,9 @@ nsDocAccessible::FireShowHideEvents(nsINode *aNode,
aIsAsyncChange, aIsFromUserInput);
} else {
event = new nsAccEvent(aEventType, accessible, aIsAsyncChange,
aIsFromUserInput,
nsAccEvent::eCoalesceFromSameSubtree);
event = new AccEvent(aEventType, accessible, aIsAsyncChange,
aIsFromUserInput,
AccEvent::eCoalesceFromSameSubtree);
}
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);

View File

@ -82,6 +82,8 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
NS_DECL_NSIOBSERVER
public:
using nsAccessible::GetParent;
nsDocAccessible(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference* aShell);
virtual ~nsDocAccessible();
@ -115,7 +117,7 @@ public:
virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
#ifdef DEBUG_ACCDOCMGR
virtual nsresult HandleAccEvent(nsAccEvent *aAccEvent);
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
#endif
// nsIAccessibleText
@ -149,7 +151,7 @@ public:
* code synchronous with a DOM event
*/
nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
nsAccEvent::EEventRule aAllowDupes = nsAccEvent::eRemoveDupes,
AccEvent::EEventRule aAllowDupes = AccEvent::eRemoveDupes,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
@ -158,7 +160,7 @@ public:
*
* @param aEvent [in] the event to fire
*/
nsresult FireDelayedAccessibleEvent(nsAccEvent *aEvent);
nsresult FireDelayedAccessibleEvent(AccEvent* aEvent);
/**
* Find the accessible object in the accessibility cache that corresponds to
@ -205,7 +207,7 @@ public:
* Process the event when the queue of pending events is untwisted. Fire
* accessible events as result of the processing.
*/
void ProcessPendingEvent(nsAccEvent* aEvent);
void ProcessPendingEvent(AccEvent* aEvent);
protected:
@ -274,7 +276,7 @@ protected:
* @param aIsAsync [in] whether casual change is async
* @param aIsFromUserInput [in] the event is known to be from user input
*/
already_AddRefed<nsAccEvent>
already_AddRefed<AccEvent>
CreateTextChangeEventForNode(nsAccessible *aContainerAccessible,
nsIContent *aChangeNode,
nsAccessible *aAccessible,

View File

@ -47,7 +47,7 @@
////////////////////////////////////////////////////////////////////////////////
void
nsEventShell::FireEvent(nsAccEvent *aEvent)
nsEventShell::FireEvent(AccEvent* aEvent)
{
if (!aEvent)
return;
@ -72,8 +72,8 @@ nsEventShell::FireEvent(PRUint32 aEventType, nsAccessible *aAccessible,
{
NS_ENSURE_TRUE(aAccessible,);
nsRefPtr<nsAccEvent> event = new nsAccEvent(aEventType, aAccessible,
aIsAsynch, aIsFromUserInput);
nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
aIsAsynch, aIsFromUserInput);
FireEvent(event);
}
@ -123,12 +123,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsAccEventQueue)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mDocument");
cb.NoteXPCOMChild(static_cast<nsIAccessible*>(tmp->mDocument.get()));
PRUint32 i, length = tmp->mEvents.Length();
for (i = 0; i < length; ++i) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvents[i]");
cb.NoteXPCOMChild(tmp->mEvents[i].get());
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_MEMBER(mEvents, AccEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsAccEventQueue)
@ -143,7 +138,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAccEventQueue)
// nsAccEventQueue: public
void
nsAccEventQueue::Push(nsAccEvent *aEvent)
nsAccEventQueue::Push(AccEvent* aEvent)
{
mEvents.AppendElement(aEvent);
@ -203,15 +198,15 @@ nsAccEventQueue::WillRefresh(mozilla::TimeStamp aTime)
// Process only currently queued events. Newly appended events during events
// flushing won't be processed.
nsTArray < nsRefPtr<nsAccEvent> > events;
nsTArray < nsRefPtr<AccEvent> > events;
events.SwapElements(mEvents);
PRUint32 length = events.Length();
NS_ASSERTION(length, "How did we get here without events to fire?");
for (PRUint32 index = 0; index < length; index ++) {
nsAccEvent *accEvent = events[index];
if (accEvent->mEventRule != nsAccEvent::eDoNotEmit) {
AccEvent* accEvent = events[index];
if (accEvent->mEventRule != AccEvent::eDoNotEmit) {
mDocument->ProcessPendingEvent(accEvent);
AccHideEvent* hideEvent = downcast_accEvent(accEvent);
@ -240,7 +235,7 @@ nsAccEventQueue::CoalesceEvents()
{
PRUint32 numQueuedEvents = mEvents.Length();
PRInt32 tail = numQueuedEvents - 1;
nsAccEvent* tailEvent = mEvents[tail];
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.
@ -248,10 +243,10 @@ nsAccEventQueue::CoalesceEvents()
return;
switch(tailEvent->mEventRule) {
case nsAccEvent::eCoalesceFromSameSubtree:
case AccEvent::eCoalesceFromSameSubtree:
{
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* thisEvent = mEvents[index];
AccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventType != tailEvent->mEventType)
continue; // Different type
@ -280,7 +275,7 @@ nsAccEventQueue::CoalesceEvents()
tailEvent->mEventRule = thisEvent->mEventRule;
// Coalesce text change events for hide events.
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit)
if (tailEvent->mEventRule != AccEvent::eDoNotEmit)
CoalesceTextChangeEventsFor(tailHideEvent, thisHideEvent);
return;
@ -302,7 +297,7 @@ nsAccEventQueue::CoalesceEvents()
PRBool thisCanBeDescendantOfTail = PR_FALSE;
// Coalesce depending on whether this event was coalesced or not.
if (thisEvent->mEventRule == nsAccEvent::eDoNotEmit) {
if (thisEvent->mEventRule == AccEvent::eDoNotEmit) {
// If this event was coalesced then do not emit tail event iff tail
// event has the same target or its target is contained by this event
// target. Note, we don't need to check whether tail event target
@ -313,7 +308,7 @@ nsAccEventQueue::CoalesceEvents()
// node siblings while this event was coalesced.
if (thisEvent->mNode == tailEvent->mNode) {
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
thisEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
@ -331,11 +326,11 @@ nsAccEventQueue::CoalesceEvents()
// be conditional events (be or not be fired in the end).
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameSource(thisEvent, tailEvent);
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit)
if (tailEvent->mEventRule != AccEvent::eDoNotEmit)
continue;
}
else {
tailEvent->mEventRule = nsAccEvent::eDoNotEmit;
tailEvent->mEventRule = AccEvent::eDoNotEmit;
}
return;
@ -367,13 +362,13 @@ nsAccEventQueue::CoalesceEvents()
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(thisEvent, tailEvent);
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit)
if (tailEvent->mEventRule != AccEvent::eDoNotEmit)
continue;
return;
}
tailEvent->mEventRule = nsAccEvent::eDoNotEmit;
tailEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
@ -391,7 +386,7 @@ nsAccEventQueue::CoalesceEvents()
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(tailEvent, thisEvent);
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit)
if (tailEvent->mEventRule != AccEvent::eDoNotEmit)
continue;
return;
@ -399,9 +394,9 @@ nsAccEventQueue::CoalesceEvents()
// Do not emit thisEvent, also apply this result to sibling nodes of
// thisNode.
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
thisEvent->mEventRule = AccEvent::eDoNotEmit;
ApplyToSiblings(0, index, thisEvent->mEventType,
thisEvent->mNode, nsAccEvent::eDoNotEmit);
thisEvent->mNode, AccEvent::eDoNotEmit);
continue;
}
@ -416,32 +411,32 @@ nsAccEventQueue::CoalesceEvents()
} break; // case eCoalesceFromSameSubtree
case nsAccEvent::eCoalesceFromSameDocument:
case AccEvent::eCoalesceFromSameDocument:
{
// 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.
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* thisEvent = mEvents[index];
AccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventType == tailEvent->mEventType &&
thisEvent->mEventRule == tailEvent->mEventRule &&
thisEvent->GetDocAccessible() == tailEvent->GetDocAccessible()) {
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
thisEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
}
} break; // case eCoalesceFromSameDocument
case nsAccEvent::eRemoveDupes:
case AccEvent::eRemoveDupes:
{
// Check for repeat events, coalesce newly appended event by more older
// event.
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* accEvent = mEvents[index];
AccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule &&
accEvent->mNode == tailEvent->mNode) {
tailEvent->mEventRule = nsAccEvent::eDoNotEmit;
tailEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
}
@ -455,12 +450,12 @@ nsAccEventQueue::CoalesceEvents()
void
nsAccEventQueue::ApplyToSiblings(PRUint32 aStart, PRUint32 aEnd,
PRUint32 aEventType, nsINode* aNode,
nsAccEvent::EEventRule aEventRule)
AccEvent::EEventRule aEventRule)
{
for (PRUint32 index = aStart; index < aEnd; index ++) {
nsAccEvent* accEvent = mEvents[index];
AccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == aEventType &&
accEvent->mEventRule != nsAccEvent::eDoNotEmit &&
accEvent->mEventRule != AccEvent::eDoNotEmit &&
accEvent->mNode->GetNodeParent() == aNode->GetNodeParent()) {
accEvent->mEventRule = aEventRule;
}
@ -468,38 +463,38 @@ nsAccEventQueue::ApplyToSiblings(PRUint32 aStart, PRUint32 aEnd,
}
void
nsAccEventQueue::CoalesceReorderEventsFromSameSource(nsAccEvent *aAccEvent1,
nsAccEvent *aAccEvent2)
nsAccEventQueue::CoalesceReorderEventsFromSameSource(AccEvent* aAccEvent1,
AccEvent* aAccEvent2)
{
// Do not emit event2 if event1 is unconditional.
nsAccReorderEvent *reorderEvent1 = downcast_accEvent(aAccEvent1);
AccReorderEvent* reorderEvent1 = downcast_accEvent(aAccEvent1);
if (reorderEvent1->IsUnconditionalEvent()) {
aAccEvent2->mEventRule = nsAccEvent::eDoNotEmit;
aAccEvent2->mEventRule = AccEvent::eDoNotEmit;
return;
}
// Do not emit event1 if event2 is unconditional.
nsAccReorderEvent *reorderEvent2 = downcast_accEvent(aAccEvent2);
AccReorderEvent* reorderEvent2 = downcast_accEvent(aAccEvent2);
if (reorderEvent2->IsUnconditionalEvent()) {
aAccEvent1->mEventRule = nsAccEvent::eDoNotEmit;
aAccEvent1->mEventRule = AccEvent::eDoNotEmit;
return;
}
// Do not emit event2 if event1 is valid, otherwise do not emit event1.
if (reorderEvent1->HasAccessibleInReasonSubtree())
aAccEvent2->mEventRule = nsAccEvent::eDoNotEmit;
aAccEvent2->mEventRule = AccEvent::eDoNotEmit;
else
aAccEvent1->mEventRule = nsAccEvent::eDoNotEmit;
aAccEvent1->mEventRule = AccEvent::eDoNotEmit;
}
void
nsAccEventQueue::CoalesceReorderEventsFromSameTree(nsAccEvent *aAccEvent,
nsAccEvent *aDescendantAccEvent)
nsAccEventQueue::CoalesceReorderEventsFromSameTree(AccEvent* aAccEvent,
AccEvent* aDescendantAccEvent)
{
// Do not emit descendant event if this event is unconditional.
nsAccReorderEvent *reorderEvent = downcast_accEvent(aAccEvent);
AccReorderEvent* reorderEvent = downcast_accEvent(aAccEvent);
if (reorderEvent->IsUnconditionalEvent())
aDescendantAccEvent->mEventRule = nsAccEvent::eDoNotEmit;
aDescendantAccEvent->mEventRule = AccEvent::eDoNotEmit;
}
void
@ -509,7 +504,7 @@ nsAccEventQueue::CoalesceTextChangeEventsFor(AccHideEvent* aTailEvent,
// XXX: we need a way to ignore SplitNode and JoinNode() when they do not
// affect the text within the hypertext.
nsAccTextChangeEvent* textEvent = aThisEvent->mTextChangeEvent;
AccTextChangeEvent* textEvent = aThisEvent->mTextChangeEvent;
if (!textEvent)
return;
@ -557,7 +552,7 @@ nsAccEventQueue::CreateTextChangeEventFor(AccHideEvent* aEvent)
return;
aEvent->mTextChangeEvent =
new nsAccTextChangeEvent(textAccessible, offset, text, PR_FALSE,
aEvent->mIsAsync,
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
new AccTextChangeEvent(textAccessible, offset, text, PR_FALSE,
aEvent->mIsAsync,
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
}

View File

@ -39,7 +39,7 @@
#ifndef _nsEventShell_H_
#define _nsEventShell_H_
#include "nsAccEvent.h"
#include "AccEvent.h"
#include "a11yGeneric.h"
@ -59,7 +59,7 @@ public:
/**
* Fire the accessible event.
*/
static void FireEvent(nsAccEvent *aEvent);
static void FireEvent(AccEvent* aEvent);
/**
* Fire accessible event of the given type for the given accessible.
@ -105,7 +105,7 @@ public:
/**
* Push event to queue, coalesce it if necessary. Start pending processing.
*/
void Push(nsAccEvent *aEvent);
void Push(AccEvent* aEvent);
/**
* Shutdown the queue.
@ -142,20 +142,20 @@ private:
*/
void ApplyToSiblings(PRUint32 aStart, PRUint32 aEnd,
PRUint32 aEventType, nsINode* aNode,
nsAccEvent::EEventRule aEventRule);
AccEvent::EEventRule aEventRule);
/**
* Do not emit one of two given reorder events fired for the same DOM node.
*/
void CoalesceReorderEventsFromSameSource(nsAccEvent *aAccEvent1,
nsAccEvent *aAccEvent2);
void CoalesceReorderEventsFromSameSource(AccEvent* aAccEvent1,
AccEvent* aAccEvent2);
/**
* Do not emit one of two given reorder events fired for DOM nodes in the case
* when one DOM node is in parent chain of second one.
*/
void CoalesceReorderEventsFromSameTree(nsAccEvent *aAccEvent,
nsAccEvent *aDescendantAccEvent);
void CoalesceReorderEventsFromSameTree(AccEvent* aAccEvent,
AccEvent* aDescendantAccEvent);
/**
* Coalesce text change events caused by sibling hide events.
@ -186,7 +186,7 @@ private:
* Pending events array. Don't make this an nsAutoTArray; we use
* SwapElements() on it.
*/
nsTArray<nsRefPtr<nsAccEvent> > mEvents;
nsTArray<nsRefPtr<AccEvent> > mEvents;
};
#endif

View File

@ -191,7 +191,7 @@ nsOuterDocAccessible::InvalidateChildren()
// then allow nsAccDocManager to handle this case since the document
// accessible is created and appended as a child when it's requested.
mAreChildrenInitialized = PR_FALSE;
mChildrenFlags = eChildrenUninitialized;
}
PRBool

View File

@ -403,10 +403,10 @@ nsRootAccessible::FireAccessibleFocusEvent(nsAccessible *aAccessible,
if (menuBarAccessible) {
mCurrentARIAMenubar = menuBarAccessible->GetNode();
if (mCurrentARIAMenubar) {
nsRefPtr<nsAccEvent> menuStartEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_MENU_START,
menuBarAccessible, PR_FALSE, aIsFromUserInput,
nsAccEvent::eAllowDupes);
nsRefPtr<AccEvent> menuStartEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
menuBarAccessible, PR_FALSE, aIsFromUserInput,
AccEvent::eAllowDupes);
if (menuStartEvent) {
FireDelayedAccessibleEvent(menuStartEvent);
}
@ -416,9 +416,9 @@ nsRootAccessible::FireAccessibleFocusEvent(nsAccessible *aAccessible,
}
}
else if (mCurrentARIAMenubar) {
nsRefPtr<nsAccEvent> menuEndEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_MENU_END, mCurrentARIAMenubar,
PR_FALSE, aIsFromUserInput, nsAccEvent::eAllowDupes);
nsRefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mCurrentARIAMenubar,
PR_FALSE, aIsFromUserInput, AccEvent::eAllowDupes);
if (menuEndEvent) {
FireDelayedAccessibleEvent(menuEndEvent);
}
@ -446,7 +446,7 @@ nsRootAccessible::FireAccessibleFocusEvent(nsAccessible *aAccessible,
// Coalesce focus events from the same document, because DOM focus event might
// be fired for the document node and then for the focused DOM element.
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_FOCUS,
finalFocusNode, nsAccEvent::eCoalesceFromSameDocument,
finalFocusNode, AccEvent::eCoalesceFromSameDocument,
aIsAsynch, aIsFromUserInput);
return PR_TRUE;
@ -549,9 +549,9 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
PRBool isEnabled = (state & (nsIAccessibleStates::STATE_CHECKED |
nsIAccessibleStates::STATE_SELECTED)) != 0;
nsRefPtr<nsAccEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsRefPtr<AccEvent> accEvent =
new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsEventShell::FireEvent(accEvent);
if (isEnabled)
@ -565,10 +565,9 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
PRBool isEnabled = !!(state & nsIAccessibleStates::STATE_CHECKED);
nsRefPtr<nsAccEvent> accEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsRefPtr<AccEvent> accEvent =
new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsEventShell::FireEvent(accEvent);
return NS_OK;
@ -600,9 +599,9 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
PRUint32 state = nsAccUtils::State(accessible); // collapsed/expanded changed
PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0;
nsRefPtr<nsAccEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, isEnabled);
nsRefPtr<AccEvent> accEvent =
new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, isEnabled);
nsEventShell::FireEvent(accEvent);
return NS_OK;
}
@ -723,7 +722,8 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
}
if (!fireFocus) {
nsCOMPtr<nsINode> realFocusedNode = GetCurrentFocus();
nsIContent* realFocusedContent = realFocusedNode->AsElement();
nsIContent* realFocusedContent =
realFocusedNode->IsElement() ? realFocusedNode->AsElement() : nsnull;
nsIContent* containerContent = targetContent;
while (containerContent) {
nsCOMPtr<nsIDOMXULPopupElement> popup = do_QueryInterface(containerContent);
@ -753,7 +753,7 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
}
else if (eventType.EqualsLiteral("ValueChange")) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
targetNode, nsAccEvent::eRemoveDupes);
targetNode, AccEvent::eRemoveDupes);
}
#ifdef DEBUG
else if (eventType.EqualsLiteral("mouseover")) {
@ -887,10 +887,10 @@ nsRootAccessible::HandlePopupShownEvent(nsAccessible *aAccessible)
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_TRUE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_TRUE);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
nsEventShell::FireEvent(event);
@ -929,10 +929,10 @@ nsRootAccessible::HandlePopupHidingEvent(nsINode *aNode,
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_FALSE);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_FALSE);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
nsEventShell::FireEvent(event);

View File

@ -465,9 +465,10 @@ nsFontSizeTextAttr::Format(const nscoord& aValue, nsAString& aFormattedValue)
// ATK does not specify a unit and will likely follow IA2 here.
//
// XXX todo: consider sharing this code with layout module? (bug 474621)
float inches = static_cast<float>(aValue) /
static_cast<float>(mDC->AppUnitsPerInch());
int pts = static_cast<int>(inches * 72 + .5); // 72 pts per inch
float px =
NSAppUnitsToFloatPixels(aValue, nsIDeviceContext::AppUnitsPerCSSPixel());
// Each pt is 4/3 of a CSS pixel.
int pts = NS_lround(px*3/4);
nsAutoString value;
value.AppendInt(pts);

View File

@ -44,7 +44,6 @@
#include "nsTextEquivUtils.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOMNSEditableElement.h"
@ -122,30 +121,23 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
PRBool mixed = PR_FALSE; // or mixed.
PRBool state = PR_FALSE; // Radio buttons and check boxes can be checked or mixed
nsCOMPtr<nsIDOMNSHTMLInputElement> html5CheckboxElement =
do_QueryInterface(mContent);
if (html5CheckboxElement) {
html5CheckboxElement->GetIndeterminate(&mixed);
if (mixed) {
*aState |= nsIAccessibleStates::STATE_MIXED;
return NS_OK; // indeterminate can't be checked at the same time.
}
}
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement =
do_QueryInterface(mContent);
if (htmlCheckboxElement) {
htmlCheckboxElement->GetChecked(&checked);
if (checked)
*aState |= nsIAccessibleStates::STATE_CHECKED;
}
htmlCheckboxElement->GetIndeterminate(&state);
if (state) {
*aState |= nsIAccessibleStates::STATE_MIXED;
} else { // indeterminate can't be checked at the same time.
htmlCheckboxElement->GetChecked(&state);
if (state)
*aState |= nsIAccessibleStates::STATE_CHECKED;
}
}
return NS_OK;
}

View File

@ -65,51 +65,6 @@ nsHTMLImageMapAccessible::
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLImageMapAccessible, nsHTMLImageAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageMapAccessible: nsIAccessibleHyperLink
NS_IMETHODIMP
nsHTMLImageMapAccessible::GetAnchorCount(PRInt32 *aAnchorCount)
{
NS_ENSURE_ARG_POINTER(aAnchorCount);
return GetChildCount(aAnchorCount);
}
NS_IMETHODIMP
nsHTMLImageMapAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
*aURI = nsnull;
nsAccessible *areaAcc = GetChildAt(aIndex);
if (!areaAcc)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIDOMNode> areaNode;
areaAcc->GetDOMNode(getter_AddRefs(areaNode));
nsCOMPtr<nsIContent> link(do_QueryInterface(areaNode));
if (link)
*aURI = link->GetHrefURI().get();
return NS_OK;
}
NS_IMETHODIMP
nsHTMLImageMapAccessible::GetAnchor(PRInt32 aIndex, nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
nsAccessible *areaAcc = GetChildAt(aIndex);
if (!areaAcc)
return NS_ERROR_INVALID_ARG;
NS_ADDREF(*aAccessible = areaAcc);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageMapAccessible: nsAccessible public
@ -120,6 +75,32 @@ nsHTMLImageMapAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageMapAccessible: HyperLinkAccessible
PRUint32
nsHTMLImageMapAccessible::AnchorCount()
{
return GetChildCount();
}
nsAccessible*
nsHTMLImageMapAccessible::GetAnchor(PRUint32 aAnchorIndex)
{
return GetChildAt(aAnchorIndex);
}
already_AddRefed<nsIURI>
nsHTMLImageMapAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
{
nsAccessible* area = GetChildAt(aAnchorIndex);
if (!area)
return nsnull;
nsIContent* linkContent = area->GetContent();
return linkContent ? linkContent->GetHrefURI() : nsnull;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageMapAccessible: nsAccessible protected
@ -281,6 +262,26 @@ nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageMapAccessible: HyperLinkAccessible
PRUint32
nsHTMLAreaAccessible::StartOffset()
{
// Image map accessible is not hypertext accessible therefore
// StartOffset/EndOffset implementations of nsAccessible doesn't work here.
// We return index in parent because image map contains area links only which
// are embedded objects.
// XXX: image map should be a hypertext accessible.
return GetIndexInParent();
}
PRUint32
nsHTMLAreaAccessible::EndOffset()
{
return GetIndexInParent() + 1;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLAreaAccessible: nsAccessible protected

View File

@ -57,14 +57,14 @@ public:
// nsISupports and cycle collector
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleHyperLink
NS_IMETHOD GetAnchorCount(PRInt32 *aAnchorCount);
NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI);
NS_IMETHOD GetAnchor(PRInt32 aIndex, nsIAccessible **aAccessible);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
// HyperLinkAccessible
virtual PRUint32 AnchorCount();
virtual nsAccessible* GetAnchor(PRUint32 aAnchorIndex);
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
protected:
// nsAccessible
@ -81,8 +81,9 @@ private:
*/
class nsHTMLAreaAccessible : public nsHTMLLinkAccessible
{
public:
using nsAccessible::GetChildAtPoint;
nsHTMLAreaAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
@ -97,6 +98,10 @@ public:
PRBool aDeepestChild,
nsIAccessible **aChild);
// HyperLinkAccessible
virtual PRUint32 StartOffset();
virtual PRUint32 EndOffset();
protected:
// nsAccessible

View File

@ -163,23 +163,19 @@ nsHTMLLinkAccessible::DoAction(PRUint8 aIndex)
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleHyperLink
// HyperLinkAccessible
NS_IMETHODIMP
nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
bool
nsHTMLLinkAccessible::IsHyperLink()
{
NS_ENSURE_ARG_POINTER(aURI);
*aURI = nsnull;
// Expose HyperLinkAccessible unconditionally.
return true;
}
if (aIndex != 0)
return NS_ERROR_INVALID_ARG;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> uri = mContent->GetHrefURI();
uri.forget(aURI);
return NS_OK;
already_AddRefed<nsIURI>
nsHTMLLinkAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
{
return aAnchorIndex == 0 ? mContent->GetHrefURI() : nsnull;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -56,13 +56,14 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsIAccessibleHyperLink
NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
// HyperLinkAccessible
virtual bool IsHyperLink();
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
protected:
enum { eAction_Jump = 0 };

View File

@ -56,252 +56,13 @@
#include "nsIServiceManager.h"
#include "nsIMutableArray.h"
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible::iterator
nsHTMLSelectableAccessible::iterator::iterator(nsHTMLSelectableAccessible *aParent, nsIWeakReference *aWeakShell):
mWeakShell(aWeakShell), mParentSelect(aParent)
{
mLength = mIndex = 0;
mSelCount = 0;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect =
do_QueryInterface(mParentSelect->mContent);
if (htmlSelect) {
htmlSelect->GetOptions(getter_AddRefs(mOptions));
if (mOptions)
mOptions->GetLength(&mLength);
}
}
PRBool nsHTMLSelectableAccessible::iterator::Advance()
{
if (mIndex < mLength) {
nsCOMPtr<nsIDOMNode> tempNode;
if (mOptions) {
mOptions->Item(mIndex, getter_AddRefs(tempNode));
mOption = do_QueryInterface(tempNode);
}
mIndex++;
return PR_TRUE;
}
return PR_FALSE;
}
void nsHTMLSelectableAccessible::iterator::CalcSelectionCount(PRInt32 *aSelectionCount)
{
PRBool isSelected = PR_FALSE;
if (mOption)
mOption->GetSelected(&isSelected);
if (isSelected)
(*aSelectionCount)++;
}
void
nsHTMLSelectableAccessible::iterator::AddAccessibleIfSelected(nsIMutableArray *aSelectedAccessibles,
nsPresContext *aContext)
{
PRBool isSelected = PR_FALSE;
nsAccessible *optionAcc = nsnull;
if (mOption) {
mOption->GetSelected(&isSelected);
if (isSelected) {
nsCOMPtr<nsIContent> optionContent(do_QueryInterface(mOption));
optionAcc = GetAccService()->GetAccessibleInWeakShell(optionContent,
mWeakShell);
}
}
if (optionAcc)
aSelectedAccessibles->AppendElement(static_cast<nsIAccessible*>(optionAcc),
PR_FALSE);
}
PRBool
nsHTMLSelectableAccessible::iterator::GetAccessibleIfSelected(PRInt32 aIndex,
nsPresContext *aContext,
nsIAccessible **aAccessible)
{
PRBool isSelected = PR_FALSE;
*aAccessible = nsnull;
if (mOption) {
mOption->GetSelected(&isSelected);
if (isSelected) {
if (mSelCount == aIndex) {
nsCOMPtr<nsIContent> optionContent(do_QueryInterface(mOption));
nsAccessible *accessible =
GetAccService()->GetAccessibleInWeakShell(optionContent, mWeakShell);
NS_IF_ADDREF(*aAccessible = accessible);
return PR_TRUE;
}
mSelCount++;
}
}
return PR_FALSE;
}
void nsHTMLSelectableAccessible::iterator::Select(PRBool aSelect)
{
if (mOption)
mOption->SetSelected(aSelect);
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible
nsHTMLSelectableAccessible::
nsHTMLSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLSelectableAccessible, nsAccessible, nsIAccessibleSelectable)
// Helper methods
NS_IMETHODIMP nsHTMLSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
{
*aSelState = PR_FALSE;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mContent));
if (!htmlSelect)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
htmlSelect->GetOptions(getter_AddRefs(options));
if (!options)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> tempNode;
options->Item(aIndex, getter_AddRefs(tempNode));
nsCOMPtr<nsIDOMHTMLOptionElement> tempOption(do_QueryInterface(tempNode));
if (!tempOption)
return NS_ERROR_FAILURE;
tempOption->GetSelected(aSelState);
nsresult rv = NS_OK;
if (eSelection_Add == aMethod && !(*aSelState))
rv = tempOption->SetSelected(PR_TRUE);
else if (eSelection_Remove == aMethod && (*aSelState))
rv = tempOption->SetSelected(PR_FALSE);
return rv;
}
// Interface methods
NS_IMETHODIMP nsHTMLSelectableAccessible::GetSelectedChildren(nsIArray **_retval)
{
*_retval = nsnull;
nsCOMPtr<nsIMutableArray> selectedAccessibles =
do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_STATE(selectedAccessibles);
nsPresContext *context = GetPresContext();
if (!context)
return NS_ERROR_FAILURE;
nsHTMLSelectableAccessible::iterator iter(this, mWeakShell);
while (iter.Advance())
iter.AddAccessibleIfSelected(selectedAccessibles, context);
PRUint32 uLength = 0;
selectedAccessibles->GetLength(&uLength);
if (uLength != 0) { // length of nsIArray containing selected options
*_retval = selectedAccessibles;
NS_ADDREF(*_retval);
}
return NS_OK;
}
// return the nth selected child's nsIAccessible object
NS_IMETHODIMP nsHTMLSelectableAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **_retval)
{
*_retval = nsnull;
nsPresContext *context = GetPresContext();
if (!context)
return NS_ERROR_FAILURE;
nsHTMLSelectableAccessible::iterator iter(this, mWeakShell);
while (iter.Advance())
if (iter.GetAccessibleIfSelected(aIndex, context, _retval))
return NS_OK;
// No matched item found
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLSelectableAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
{
*aSelectionCount = 0;
nsHTMLSelectableAccessible::iterator iter(this, mWeakShell);
while (iter.Advance())
iter.CalcSelectionCount(aSelectionCount);
return NS_OK;
}
NS_IMETHODIMP nsHTMLSelectableAccessible::AddChildToSelection(PRInt32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Add, &isSelected);
}
NS_IMETHODIMP nsHTMLSelectableAccessible::RemoveChildFromSelection(PRInt32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Remove, &isSelected);
}
NS_IMETHODIMP nsHTMLSelectableAccessible::IsChildSelected(PRInt32 aIndex, PRBool *_retval)
{
*_retval = PR_FALSE;
return ChangeSelection(aIndex, eSelection_GetState, _retval);
}
NS_IMETHODIMP nsHTMLSelectableAccessible::ClearSelection()
{
nsHTMLSelectableAccessible::iterator iter(this, mWeakShell);
while (iter.Advance())
iter.Select(PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP nsHTMLSelectableAccessible::SelectAllSelection(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mContent));
if (!htmlSelect)
return NS_ERROR_FAILURE;
htmlSelect->GetMultiple(_retval);
if (*_retval) {
nsHTMLSelectableAccessible::iterator iter(this, mWeakShell);
while (iter.Advance())
iter.Select(PR_TRUE);
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLSelectListAccessible::
nsHTMLSelectListAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLSelectableAccessible(aContent, aShell)
nsAccessibleWrap(aContent, aShell)
{
}
@ -312,8 +73,7 @@ nsresult
nsHTMLSelectListAccessible::GetStateInternal(PRUint32 *aState,
PRUint32 *aExtraState)
{
nsresult rv = nsHTMLSelectableAccessible::GetStateInternal(aState,
aExtraState);
nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
// As a nsHTMLSelectListAccessible we can have the following states:
@ -352,6 +112,33 @@ nsHTMLSelectListAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible: SelectAccessible
bool
nsHTMLSelectListAccessible::IsSelect()
{
return true;
}
bool
nsHTMLSelectListAccessible::SelectAll()
{
nsCOMPtr<nsIDOMHTMLSelectElement> selectElm(do_QueryInterface(mContent));
PRBool isMultiple = PR_FALSE;
selectElm->GetMultiple(&isMultiple);
return isMultiple ? nsAccessibleWrap::SelectAll() : false;
}
bool
nsHTMLSelectListAccessible::UnselectAll()
{
nsCOMPtr<nsIDOMHTMLSelectElement> selectElm(do_QueryInterface(mContent));
PRBool isMultiple = PR_FALSE;
selectElm->GetMultiple(&isMultiple);
return isMultiple ? nsAccessibleWrap::UnselectAll() : false;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible: nsAccessible protected
@ -676,6 +463,16 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsHTMLSelectOptionAccessible::SetSelected(PRBool aSelect)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLOptionElement> optionElm(do_QueryInterface(mContent));
return optionElm->SetSelected(aSelect);
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptionAccessible: static methods
@ -763,8 +560,8 @@ nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibleOpti
return;
nsRefPtr<nsAccEvent> selWithinEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN, multiSelect);
nsRefPtr<AccEvent> selWithinEvent =
new AccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN, multiSelect);
if (!selWithinEvent)
return;
@ -780,8 +577,7 @@ nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibleOpti
eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
}
nsRefPtr<nsAccEvent> selAddRemoveEvent =
new nsAccEvent(eventType, option);
nsRefPtr<AccEvent> selAddRemoveEvent = new AccEvent(eventType, option);
if (selAddRemoveEvent)
option->GetDocAccessible()->FireDelayedAccessibleEvent(selAddRemoveEvent);

View File

@ -39,7 +39,6 @@
#ifndef __nsHTMLSelectAccessible_h__
#define __nsHTMLSelectAccessible_h__
#include "nsIAccessibleSelectable.h"
#include "nsAccessibilityAtoms.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsIDOMHTMLOptionsCollection.h"
@ -63,58 +62,10 @@ class nsIMutableArray;
* - nsHTMLSelectOptionAccessible(s)
*/
/** ------------------------------------------------------ */
/** First, the common widgets */
/** ------------------------------------------------------ */
/*
* The HTML implementation of nsIAccessibleSelectable.
*/
class nsHTMLSelectableAccessible : public nsAccessibleWrap
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESELECTABLE
nsHTMLSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLSelectableAccessible() {}
protected:
NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
class iterator
{
protected:
PRUint32 mLength;
PRUint32 mIndex;
PRInt32 mSelCount;
nsCOMPtr<nsIDOMHTMLOptionsCollection> mOptions;
nsCOMPtr<nsIDOMHTMLOptionElement> mOption;
nsCOMPtr<nsIWeakReference> mWeakShell;
nsHTMLSelectableAccessible *mParentSelect;
public:
iterator(nsHTMLSelectableAccessible *aParent, nsIWeakReference *aWeakShell);
void CalcSelectionCount(PRInt32 *aSelectionCount);
void Select(PRBool aSelect);
void AddAccessibleIfSelected(nsIMutableArray *aSelectedAccessibles,
nsPresContext *aContext);
PRBool GetAccessibleIfSelected(PRInt32 aIndex, nsPresContext *aContext,
nsIAccessible **aAccessible);
PRBool Advance();
};
friend class iterator;
};
/*
* The list that contains all the options in the select.
*/
class nsHTMLSelectListAccessible : public nsHTMLSelectableAccessible
class nsHTMLSelectListAccessible : public nsAccessibleWrap
{
public:
@ -125,6 +76,11 @@ public:
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
// SelectAccessible
virtual bool IsSelect();
virtual bool SelectAll();
virtual bool UnselectAll();
protected:
// nsAccessible
@ -153,6 +109,7 @@ public:
NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD GetNumActions(PRUint8 *_retval);
NS_IMETHOD SetSelected(PRBool aSelect);
// nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);

View File

@ -895,8 +895,16 @@ nsHTMLTableAccessible::GetCellAt(PRInt32 aRow, PRInt32 aColumn,
nsCOMPtr<nsIContent> cellContent(do_QueryInterface(cellElement));
nsAccessible *cell =
GetAccService()->GetAccessibleInWeakShell(cellContent, mWeakShell);
if (cell)
CallQueryInterface(cell, aTableCellAccessible);
if (!cell) {
return NS_ERROR_INVALID_ARG;
}
if (cell != this) {
// XXX bug 576838: crazy tables (like table6 in tables/test_table2.html) may
// return itself as a cell what makes Orca hang.
NS_ADDREF(*aTableCellAccessible = cell);
}
return NS_OK;
}

View File

@ -1091,11 +1091,8 @@ nsHyperTextAccessible::GetTextAttributes(PRBool aIncludeDefAttrs,
NS_ADDREF(*aAttributes = attributes);
}
PRInt32 offsetAccIdx = -1;
PRInt32 startOffset = 0, endOffset = 0;
nsAccessible *offsetAcc = GetAccessibleAtOffset(aOffset, &offsetAccIdx,
&startOffset, &endOffset);
if (!offsetAcc) {
nsAccessible* accAtOffset = GetChildAtOffset(aOffset);
if (!accAtOffset) {
// Offset 0 is correct offset when accessible has empty text. Include
// default attributes if they were requested, otherwise return empty set.
if (aOffset == 0) {
@ -1108,17 +1105,21 @@ nsHyperTextAccessible::GetTextAttributes(PRBool aIncludeDefAttrs,
return NS_ERROR_INVALID_ARG;
}
PRInt32 accAtOffsetIdx = accAtOffset->GetIndexInParent();
PRInt32 startOffset = GetChildOffset(accAtOffsetIdx);
PRInt32 endOffset = GetChildOffset(accAtOffsetIdx + 1);
PRInt32 offsetInAcc = aOffset - startOffset;
nsTextAttrsMgr textAttrsMgr(this, aIncludeDefAttrs, offsetAcc, offsetAccIdx);
nsTextAttrsMgr textAttrsMgr(this, aIncludeDefAttrs, accAtOffset,
accAtOffsetIdx);
nsresult rv = textAttrsMgr.GetAttributes(*aAttributes, &startOffset,
&endOffset);
NS_ENSURE_SUCCESS(rv, rv);
// Compute spelling attributes on text accessible only.
nsIFrame *offsetFrame = offsetAcc->GetFrame();
nsIFrame *offsetFrame = accAtOffset->GetFrame();
if (offsetFrame && offsetFrame->GetType() == nsAccessibilityAtoms::textFrame) {
nsCOMPtr<nsIDOMNode> node = offsetAcc->GetDOMNode();
nsCOMPtr<nsIDOMNode> node = accAtOffset->GetDOMNode();
PRInt32 nodeOffset = 0;
nsresult rv = RenderedToContentOffset(offsetFrame, offsetInAcc,
@ -1369,7 +1370,7 @@ nsHyperTextAccessible::GetLinkIndex(nsIAccessibleHyperLink* aLink,
}
NS_IMETHODIMP
nsHyperTextAccessible::GetLinkIndexAtOffset(PRInt32 aCharIndex,
nsHyperTextAccessible::GetLinkIndexAtOffset(PRInt32 aOffset,
PRInt32* aLinkIndex)
{
NS_ENSURE_ARG_POINTER(aLinkIndex);
@ -1378,29 +1379,7 @@ nsHyperTextAccessible::GetLinkIndexAtOffset(PRInt32 aCharIndex,
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 characterCount = 0;
PRInt32 linkIndex = 0;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0;
childIdx < childCount && characterCount <= aCharIndex; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
PRUint32 role = nsAccUtils::Role(childAcc);
if (role == nsIAccessibleRole::ROLE_TEXT_LEAF ||
role == nsIAccessibleRole::ROLE_STATICTEXT) {
characterCount += nsAccUtils::TextLength(childAcc);
}
else {
if (characterCount ++ == aCharIndex) {
*aLinkIndex = linkIndex;
break;
}
if (role != nsIAccessibleRole::ROLE_WHITESPACE) {
++ linkIndex;
}
}
}
*aLinkIndex = GetLinkIndexAtOffset(aOffset);
return NS_OK;
}
@ -2043,7 +2022,6 @@ nsHyperTextAccessible::ScrollSubstringToPoint(PRInt32 aStartIndex,
void
nsHyperTextAccessible::InvalidateChildren()
{
mLinks = nsnull;
mOffsets.Clear();
nsAccessibleWrap::InvalidateChildren();
@ -2110,70 +2088,77 @@ nsresult nsHyperTextAccessible::RenderedToContentOffset(nsIFrame *aFrame, PRUint
// nsHyperTextAccessible public
PRInt32
nsHyperTextAccessible::GetChildOffset(nsAccessible* aChild,
nsHyperTextAccessible::GetChildOffset(PRUint32 aChildIndex,
PRBool aInvalidateAfter)
{
PRInt32 index = GetIndexOf(aChild);
if (index == -1 || index == 0)
return index;
if (aChildIndex == 0)
return aChildIndex;
PRInt32 count = mOffsets.Length() - index;
PRInt32 count = mOffsets.Length() - aChildIndex;
if (count > 0) {
if (aInvalidateAfter)
mOffsets.RemoveElementsAt(index, count);
mOffsets.RemoveElementsAt(aChildIndex, count);
return mOffsets[index - 1];
return mOffsets[aChildIndex - 1];
}
PRUint32 lastOffset = mOffsets.IsEmpty() ?
0 : mOffsets[mOffsets.Length() - 1];
EnsureChildren();
while (mOffsets.Length() < index) {
while (mOffsets.Length() < aChildIndex) {
nsAccessible* child = mChildren[mOffsets.Length()];
lastOffset += nsAccUtils::TextLength(child);
mOffsets.AppendElement(lastOffset);
}
return mOffsets[index - 1];
}
////////////////////////////////////////////////////////////////////////////////
// nsHyperTextAccessible protected
AccCollector*
nsHyperTextAccessible::GetLinkCollector()
{
if (IsDefunct())
return nsnull;
if (!mLinks)
mLinks = new AccCollector(this, filters::GetEmbeddedObject);
return mLinks;
return mOffsets[aChildIndex - 1];
}
nsAccessible *
nsHyperTextAccessible::GetAccessibleAtOffset(PRInt32 aOffset, PRInt32 *aAccIdx,
PRInt32 *aStartOffset,
PRInt32 *aEndOffset)
PRInt32
nsHyperTextAccessible::GetChildIndexAtOffset(PRUint32 aOffset)
{
PRInt32 startOffset = 0, endOffset = 0;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *child = mChildren[childIdx];
endOffset += nsAccUtils::TextLength(child);
if (endOffset > aOffset) {
*aStartOffset = startOffset;
*aEndOffset = endOffset;
*aAccIdx = childIdx;
return child;
PRUint32 lastOffset = 0;
PRUint32 offsetCount = mOffsets.Length();
if (offsetCount > 0) {
lastOffset = mOffsets[offsetCount - 1];
if (aOffset < lastOffset) {
PRUint32 low = 0, high = offsetCount;
while (high > low) {
PRUint32 mid = (high + low) >> 1;
if (mOffsets[mid] == aOffset)
return mid < offsetCount - 1 ? mid + 1 : mid;
if (mOffsets[mid] < aOffset)
low = mid + 1;
else
high = mid;
}
if (high == offsetCount)
return -1;
return low;
}
startOffset = endOffset;
}
return nsnull;
PRUint32 childCount = GetChildCount();
while (mOffsets.Length() < childCount) {
nsAccessible* child = GetChildAt(mOffsets.Length());
lastOffset += nsAccUtils::TextLength(child);
mOffsets.AppendElement(lastOffset);
if (aOffset < lastOffset)
return mOffsets.Length() - 1;
}
if (aOffset == lastOffset)
return mOffsets.Length() - 1;
return -1;
}
////////////////////////////////////////////////////////////////////////////////
// nsHyperTextAccessible protected
nsresult
nsHyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame *aFrame,
PRInt32 aOffset,

View File

@ -106,8 +106,7 @@ public:
*/
inline PRUint32 GetLinkCount()
{
AccCollector* links = GetLinkCollector();
return links ? links->Count() : 0;
return GetEmbeddedChildCount();
}
/**
@ -115,8 +114,7 @@ public:
*/
inline nsAccessible* GetLinkAt(PRUint32 aIndex)
{
AccCollector* links = GetLinkCollector();
return links ? links->GetAccessibleAt(aIndex) : nsnull;
return GetEmbeddedChildAt(aIndex);
}
/**
@ -124,8 +122,16 @@ public:
*/
inline PRInt32 GetLinkIndex(nsAccessible* aLink)
{
AccCollector* links = GetLinkCollector();
return links ? links->GetIndexAt(aLink) : -1;
return GetIndexOfEmbeddedChild(aLink);
}
/**
* Return link accessible at the given text offset.
*/
inline PRInt32 GetLinkIndexAtOffset(PRUint32 aOffset)
{
nsAccessible* child = GetChildAtOffset(aOffset);
return child ? GetLinkIndex(child) : -1;
}
/**
@ -187,23 +193,46 @@ public:
PRInt32 *aEndOffset);
/**
* Return text offset the given child accessible of hypertext accessible.
* Return text offset of the given child accessible within hypertext
* accessible.
*
* @param aChild [in] accessible child to get text offset for
* @param aInvalidateAfter [in, optional] indicates whether invalidate
* cached offsets for next siblings of the child
*/
PRInt32 GetChildOffset(nsAccessible* aChild,
PRBool aInvalidateAfter = PR_FALSE)
{
PRInt32 index = GetIndexOf(aChild);
return index == -1 ? -1 : GetChildOffset(index, aInvalidateAfter);
}
/**
* Return text offset for the child accessible index.
*/
PRInt32 GetChildOffset(PRUint32 aChildIndex,
PRBool aInvalidateAfter = PR_FALSE);
/**
* Return child accessible at the given text offset.
*
* @param aOffset [in] the given text offset
*/
PRInt32 GetChildIndexAtOffset(PRUint32 aOffset);
/**
* Return child accessible at the given text offset.
*
* @param aOffset [in] the given text offset
*/
nsAccessible* GetChildAtOffset(PRUint32 aOffset)
{
return GetChildAt(GetChildIndexAtOffset(aOffset));
}
protected:
// nsHyperTextAccessible
/**
* Return link collection, create it if necessary.
*/
AccCollector* GetLinkCollector();
/*
* This does the work for nsIAccessibleText::GetText[At|Before|After]Offset
* @param aType, eGetBefore, eGetAt, eGetAfter
@ -299,18 +328,6 @@ protected:
*/
PRInt32 GetCaretLineNumber();
/**
* Return an accessible at the given hypertext offset.
*
* @param aOffset [out] the given hypertext offset
* @param aAccIdx [out] child index of returned accessible
* @param aStartOffset [out] start hypertext offset of returned accessible
* @param aEndOffset [out] end hypertext offset of returned accessible
*/
nsAccessible *GetAccessibleAtOffset(PRInt32 aOffset, PRInt32 *aAccIdx,
PRInt32 *aStartOffset,
PRInt32 *aEndOffset);
// Helpers
nsresult GetDOMPointByFrameOffset(nsIFrame *aFrame, PRInt32 aOffset,
nsIAccessible *aAccessible,

View File

@ -78,7 +78,7 @@ class nsAccessibleWrap : public nsAccessible
virtual void Shutdown ();
virtual void InvalidateChildren();
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);
virtual nsresult HandleAccEvent(AccEvent* aEvent);
// ignored means that the accessible might still have children, but is not displayed
// to the user. it also has no native accessible object represented for it.
@ -98,7 +98,7 @@ class nsAccessibleWrap : public nsAccessible
protected:
virtual nsresult FirePlatformEvent(nsAccEvent *aEvent);
virtual nsresult FirePlatformEvent(AccEvent* aEvent);
/**
* Return true if the parent doesn't have children to expose to AT.

View File

@ -161,7 +161,7 @@ nsAccessibleWrap::Shutdown ()
}
nsresult
nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
nsAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -174,7 +174,7 @@ nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
}
nsresult
nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
nsAccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;

View File

@ -44,15 +44,8 @@
#include "AccessibleHyperlink.h"
#include "AccessibleHyperlink_i.c"
#include "nsIAccessible.h"
#include "nsIAccessibleHyperlink.h"
#include "nsAccessible.h"
#include "nsIWinAccessNode.h"
#include "nsAccessNodeWrap.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIURI.h"
// IUnknown
@ -62,8 +55,8 @@ CAccessibleHyperlink::QueryInterface(REFIID iid, void** ppv)
*ppv = NULL;
if (IID_IAccessibleHyperlink == iid) {
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (!thisObj->IsHyperLink())
return E_NOINTERFACE;
*ppv = static_cast<IAccessibleHyperlink*>(this);
@ -82,21 +75,23 @@ CAccessibleHyperlink::get_anchor(long aIndex, VARIANT *aAnchor)
__try {
VariantInit(aAnchor);
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (thisObj->IsDefunct() || !thisObj->IsHyperLink())
return E_FAIL;
nsCOMPtr<nsIAccessible> anchor;
nsresult rv = acc->GetAnchor(aIndex, getter_AddRefs(anchor));
if (NS_FAILED(rv))
return GetHRESULT(rv);
if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
return E_INVALIDARG;
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(anchor));
nsAccessible* anchor = thisObj->GetAnchor(aIndex);
if (!anchor)
return S_FALSE;
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryObject(anchor));
if (!winAccessNode)
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
nsresult rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
if (NS_FAILED(rv))
return E_FAIL;
@ -115,17 +110,19 @@ CAccessibleHyperlink::get_anchorTarget(long aIndex, VARIANT *aAnchorTarget)
__try {
VariantInit(aAnchorTarget);
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (thisObj->IsDefunct() || !thisObj->IsHyperLink())
return E_FAIL;
nsCOMPtr<nsIURI> uri;
nsresult rv = acc->GetURI(aIndex, getter_AddRefs(uri));
if (NS_FAILED(rv) || !uri)
return GetHRESULT(rv);
if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
return E_INVALIDARG;
nsCOMPtr<nsIURI> uri = thisObj->GetAnchorURI(aIndex);
if (!uri)
return S_FALSE;
nsCAutoString prePath;
rv = uri->GetPrePath(prePath);
nsresult rv = uri->GetPrePath(prePath);
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -153,16 +150,11 @@ CAccessibleHyperlink::get_startIndex(long *aIndex)
__try {
*aIndex = 0;
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (thisObj->IsDefunct() || !thisObj->IsHyperLink())
return E_FAIL;
PRInt32 index = 0;
nsresult rv = acc->GetStartIndex(&index);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aIndex = index;
*aIndex = thisObj->StartOffset();
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@ -175,16 +167,11 @@ CAccessibleHyperlink::get_endIndex(long *aIndex)
__try {
*aIndex = 0;
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (thisObj->IsDefunct() || !thisObj->IsHyperLink())
return E_FAIL;
PRInt32 index = 0;
nsresult rv = acc->GetEndIndex(&index);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aIndex = index;
*aIndex = thisObj->EndOffset();
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@ -197,16 +184,11 @@ CAccessibleHyperlink::get_valid(boolean *aValid)
__try {
*aValid = false;
nsCOMPtr<nsIAccessibleHyperLink> acc(do_QueryObject(this));
if (!acc)
nsRefPtr<nsAccessible> thisObj = do_QueryObject(this);
if (thisObj->IsDefunct() || !thisObj->IsHyperLink())
return E_FAIL;
PRBool isValid = PR_FALSE;
nsresult rv = acc->GetValid(&isValid);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aValid = isValid;
*aValid = thisObj->IsValid();
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }

View File

@ -117,16 +117,11 @@ CAccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long *aHyperlinkIndex)
__try {
*aHyperlinkIndex = 0;
nsCOMPtr<nsIAccessibleHyperText> hyperAcc(do_QueryObject(this));
nsRefPtr<nsHyperTextAccessible> hyperAcc(do_QueryObject(this));
if (!hyperAcc)
return E_FAIL;
PRInt32 index = 0;
nsresult rv = hyperAcc->GetLinkIndexAtOffset(aCharIndex, &index);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aHyperlinkIndex = index;
*aHyperlinkIndex = hyperAcc->GetLinkIndexAtOffset(aCharIndex);
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }

View File

@ -70,7 +70,7 @@ PRBool nsAccessNodeWrap::gIsEnumVariantSupportDisabled = 0;
// Used to determine whether an IAccessible2 compatible screen reader is loaded.
PRBool nsAccessNodeWrap::gIsIA2Disabled = PR_FALSE;
nsAccTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;
AccTextChangeEvent* nsAccessNodeWrap::gTextEvent = nsnull;
// Pref to disallow CtrlTab preview functionality if JAWS or Window-Eyes are
// running.

View File

@ -71,7 +71,7 @@
typedef LRESULT (STDAPICALLTYPE *LPFNNOTIFYWINEVENT)(DWORD event,HWND hwnd,LONG idObjectType,LONG idObject);
typedef LRESULT (STDAPICALLTYPE *LPFNGETGUITHREADINFO)(DWORD idThread, GUITHREADINFO* pgui);
class nsAccTextChangeEvent;
class AccTextChangeEvent;
class nsAccessNodeWrap : public nsAccessNode,
public nsIWinAccessNode,
@ -187,7 +187,7 @@ protected:
* It is used in nsHyperTextAccessibleWrap for IA2::newText/oldText
* implementation.
*/
static nsAccTextChangeEvent *gTextEvent;
static AccTextChangeEvent* gTextEvent;
};
/**

View File

@ -44,7 +44,6 @@
#include "nsRelUtils.h"
#include "nsIAccessibleDocument.h"
#include "nsIAccessibleSelectable.h"
#include "nsIAccessibleEvent.h"
#include "nsIAccessibleWin32Object.h"
@ -697,7 +696,7 @@ __try {
/**
* This method is called when a client wants to know which children of a node
* are selected. Note that this method can only find selected children for
* nsIAccessible object which implement nsIAccessibleSelectable.
* nsIAccessible object which implement SelectAccessible.
*
* The VARIANT return value arguement is expected to either contain a single IAccessible
* or an IEnumVARIANT of IAccessibles. We return the IEnumVARIANT regardless of the number
@ -717,17 +716,12 @@ __try {
VariantInit(pvarChildren);
pvarChildren->vt = VT_EMPTY;
nsCOMPtr<nsIAccessibleSelectable>
select(do_QueryInterface(static_cast<nsIAccessible*>(this)));
if (select) { // do we have an nsIAccessibleSelectable?
// we have an accessible that can have children selected
nsCOMPtr<nsIArray> selectedOptions;
// gets the selected options as nsIAccessibles.
select->GetSelectedChildren(getter_AddRefs(selectedOptions));
if (selectedOptions) { // false if the select has no children or none are selected
if (IsSelect()) {
nsCOMPtr<nsIArray> selectedItems = SelectedItems();
if (selectedItems) {
// 1) Create and initialize the enumeration
nsRefPtr<AccessibleEnumerator> pEnum = new AccessibleEnumerator(selectedOptions);
nsRefPtr<AccessibleEnumerator> pEnum =
new AccessibleEnumerator(selectedItems);
// 2) Put the enumerator in the VARIANT
if (!pEnum)
@ -1582,7 +1576,7 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
// nsAccessible
nsresult
nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
nsAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
nsresult rv = nsAccessible::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
@ -1591,7 +1585,7 @@ nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
}
nsresult
nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
nsAccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
{
PRUint32 eventType = aEvent->GetEventType();

View File

@ -307,7 +307,7 @@ public: // construction, destruction
UINT *puArgErr);
// nsAccessible
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);
virtual nsresult HandleAccEvent(AccEvent* aEvent);
// Helper methods
static PRInt32 GetChildIDFor(nsIAccessible* aAccessible);
@ -346,7 +346,7 @@ public: // construction, destruction
void UnattachIEnumVariant();
protected:
virtual nsresult FirePlatformEvent(nsAccEvent *aEvent);
virtual nsresult FirePlatformEvent(AccEvent* aEvent);
// mEnumVARIANTPosition not the current accessible's position, but a "cursor" of
// where we are in the current list of children, with respect to

View File

@ -51,7 +51,7 @@ IMPL_IUNKNOWN_INHERITED2(nsHyperTextAccessibleWrap,
CAccessibleEditableText);
nsresult
nsHyperTextAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
nsHyperTextAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
PRUint32 eventType = aEvent->GetEventType();
@ -100,6 +100,8 @@ nsHyperTextAccessibleWrap::GetModifiedText(PRBool aGetInsertedText,
*aStartOffset = gTextEvent->GetStartOffset();
*aEndOffset = *aStartOffset + gTextEvent->GetLength();
return gTextEvent->GetModifiedText(aText);
gTextEvent->GetModifiedText(aText);
return NS_OK;
}

View File

@ -61,7 +61,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsAccessible
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);
virtual nsresult HandleAccEvent(AccEvent* aEvent);
protected:
virtual nsresult GetModifiedText(PRBool aGetInsertedText, nsAString& aText,

View File

@ -259,8 +259,7 @@ __try {
return E_FAIL;
}
nsCOMPtr<nsIRenderingContext> rc;
presShell->CreateRenderingContext(frame, getter_AddRefs(rc));
nsCOMPtr<nsIRenderingContext> rc = presShell->GetReferenceRenderingContext();
if (!rc) {
return E_FAIL;
}

View File

@ -53,7 +53,8 @@ public: // construction, destruction
virtual ~nsAccessibleWrap();
protected:
virtual nsresult FirePlatformEvent(nsAccEvent *aEvent) {
virtual nsresult FirePlatformEvent(AccEvent* aEvent)
{
return NS_OK;
}
};

View File

@ -316,12 +316,9 @@ nsXFormsEditableAccessible::GetAssociatedEditor(nsIEditor **aEditor)
return sXFormsService->GetEditor(DOMNode, aEditor);
}
////////////////////////////////////////////////////////////////////////////////
// nsXFormsSelectableAccessible
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsSelectableAccessible,
nsXFormsEditableAccessible,
nsIAccessibleSelectable)
////////////////////////////////////////////////////////////////////////////////
nsXFormsSelectableAccessible::
nsXFormsSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
@ -331,265 +328,225 @@ nsXFormsSelectableAccessible::
mContent->NodeInfo()->Equals(nsAccessibilityAtoms::select1);
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::GetSelectedChildren(nsIArray **aAccessibles)
bool
nsXFormsSelectableAccessible::IsSelect()
{
NS_ENSURE_ARG_POINTER(aAccessibles);
return true;
}
*aAccessibles = nsnull;
nsCOMPtr<nsIMutableArray> accessibles =
already_AddRefed<nsIArray>
nsXFormsSelectableAccessible::SelectedItems()
{
nsCOMPtr<nsIMutableArray> selectedItems =
do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(accessibles, NS_ERROR_OUT_OF_MEMORY);
if (!selectedItems)
return nsnull;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
nsCOMPtr<nsIDOMNode> item;
nsCOMPtr<nsIDOMNode> itemDOMNode;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
if (!item)
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(item, getter_AddRefs(accessible));
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
accessibles->AppendElement(accessible, PR_FALSE);
NS_ADDREF(*aAccessibles = accessibles);
return NS_OK;
}
nsCOMPtr<nsIDOMNodeList> items;
rv = sXFormsService->GetSelectedItemsForSelect(DOMNode,
getter_AddRefs(items));
NS_ENSURE_SUCCESS(rv, rv);
if (!items)
return NS_OK;
PRUint32 length = 0;
items->GetLength(&length);
if (!length)
return NS_OK;
for (PRUint32 index = 0; index < length; index++) {
nsCOMPtr<nsIDOMNode> item;
items->Item(index, getter_AddRefs(item));
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(item, getter_AddRefs(accessible));
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
accessibles->AppendElement(accessible, PR_FALSE);
}
NS_ADDREF(*aAccessibles = accessibles);
return NS_OK;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::GetSelectionCount(PRInt32 *aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
nsCOMPtr<nsIDOMNode> item;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
getter_AddRefs(itemDOMNode));
if (NS_FAILED(rv) || !itemDOMNode)
return nsnull;
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemDOMNode));
nsIAccessible* item = GetAccService()->GetAccessibleInWeakShell(itemNode,
mWeakShell);
if (item)
*aCount = 1;
selectedItems->AppendElement(item, PR_FALSE);
return NS_OK;
nsIMutableArray* items = nsnull;
selectedItems.forget(&items);
return items;
}
nsCOMPtr<nsIDOMNodeList> items;
nsCOMPtr<nsIDOMNodeList> itemNodeList;
rv = sXFormsService->GetSelectedItemsForSelect(DOMNode,
getter_AddRefs(items));
NS_ENSURE_SUCCESS(rv, rv);
if (!items)
return NS_OK;
getter_AddRefs(itemNodeList));
if (NS_FAILED(rv) || !itemNodeList)
return nsnull;
PRUint32 length = 0;
items->GetLength(&length);
if (length)
*aCount = length;
itemNodeList->GetLength(&length);
for (PRUint32 index = 0; index < length; index++) {
nsCOMPtr<nsIDOMNode> itemDOMNode;
itemNodeList->Item(index, getter_AddRefs(itemDOMNode));
if (!itemDOMNode)
return nsnull;
return NS_OK;
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemDOMNode));
nsIAccessible* item = GetAccService()->GetAccessibleInWeakShell(itemNode,
mWeakShell);
if (item)
selectedItems->AppendElement(item, PR_FALSE);
}
nsIMutableArray* items = nsnull;
selectedItems.forget(&items);
return items;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::AddChildToSelection(PRInt32 aIndex)
PRUint32
nsXFormsSelectableAccessible::SelectedItemCount()
{
nsCOMPtr<nsIDOMNode> item = GetItemByIndex(&aIndex);
if (!item)
return NS_OK;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
nsCOMPtr<nsIDOMNode> item;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(item));
return NS_SUCCEEDED(rv) && item ? 1 : 0;
}
nsCOMPtr<nsIDOMNodeList> itemNodeList;
rv = sXFormsService->GetSelectedItemsForSelect(DOMNode,
getter_AddRefs(itemNodeList));
if (NS_FAILED(rv) || !itemNodeList)
return 0;
PRUint32 length = 0;
itemNodeList->GetLength(&length);
return length;
}
bool
nsXFormsSelectableAccessible::AddItemToSelection(PRUint32 aIndex)
{
nsCOMPtr<nsIDOMNode> itemDOMNode(do_QueryInterface(GetItemByIndex(&aIndex)));
if (!itemDOMNode)
return false;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element)
return sXFormsService->SetSelectedItemForSelect1(DOMNode, item);
sXFormsService->SetSelectedItemForSelect1(DOMNode, itemDOMNode);
else
sXFormsService->AddItemToSelectionForSelect(DOMNode, itemDOMNode);
return sXFormsService->AddItemToSelectionForSelect(DOMNode, item);
return true;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::RemoveChildFromSelection(PRInt32 aIndex)
bool
nsXFormsSelectableAccessible::RemoveItemFromSelection(PRUint32 aIndex)
{
nsCOMPtr<nsIDOMNode> item = GetItemByIndex(&aIndex);
if (!item)
return NS_OK;
nsCOMPtr<nsIDOMNode> itemDOMNode(do_QueryInterface(GetItemByIndex(&aIndex)));
if (!itemDOMNode)
return false;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
nsCOMPtr<nsIDOMNode> selitem;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(selitem));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> selItemDOMNode;
sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(selItemDOMNode));
if (selItemDOMNode == itemDOMNode)
sXFormsService->SetSelectedItemForSelect1(DOMNode, nsnull);
if (selitem != item)
return NS_ERROR_FAILURE;
return sXFormsService->SetSelectedItemForSelect1(DOMNode, nsnull);
return true;
}
return sXFormsService->RemoveItemFromSelectionForSelect(DOMNode, item);
sXFormsService->RemoveItemFromSelectionForSelect(DOMNode, itemDOMNode);
return true;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::RefSelection(PRInt32 aIndex,
nsIAccessible **aAccessible)
nsAccessible*
nsXFormsSelectableAccessible::GetSelectedItem(PRUint32 aIndex)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
if (aIndex != 0)
return NS_OK;
return nsnull;
nsCOMPtr<nsIDOMNode> item;
nsCOMPtr<nsIDOMNode> itemDOMNode;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
if (item)
return GetAccService()->GetAccessibleFor(item, aAccessible);
return NS_OK;
getter_AddRefs(itemDOMNode));
if (NS_SUCCEEDED(rv) && itemDOMNode) {
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemDOMNode));
return GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell);
}
return nsnull;
}
nsCOMPtr<nsIDOMNodeList> items;
nsCOMPtr<nsIDOMNodeList> itemNodeList;
rv = sXFormsService->GetSelectedItemsForSelect(DOMNode,
getter_AddRefs(items));
NS_ENSURE_SUCCESS(rv, rv);
getter_AddRefs(itemNodeList));
if (NS_FAILED(rv) || !itemNodeList)
return nsnull;
if (!items)
return NS_OK;
nsCOMPtr<nsIDOMNode> itemDOMNode;
itemNodeList->Item(aIndex, getter_AddRefs(itemDOMNode));
PRUint32 length = 0;
items->GetLength(&length);
if (aIndex < 0 || PRUint32(aIndex) >= length)
return NS_OK;
nsCOMPtr<nsIDOMNode> item;
items->Item(aIndex, getter_AddRefs(item));
nsCOMPtr<nsIAccessible> accessible;
return GetAccService()->GetAccessibleFor(item, getter_AddRefs(accessible));
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemDOMNode));
return GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell);
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::IsChildSelected(PRInt32 aIndex,
PRBool *aIsSelected)
bool
nsXFormsSelectableAccessible::IsItemSelected(PRUint32 aIndex)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = PR_FALSE;
nsCOMPtr<nsIDOMNode> item = GetItemByIndex(&aIndex);
if (!item)
return NS_OK;
nsCOMPtr<nsIDOMNode> itemDOMNode(do_QueryInterface(GetItemByIndex(&aIndex)));
if (!itemDOMNode)
return false;
nsresult rv;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element) {
nsCOMPtr<nsIDOMNode> selitem;
rv = sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(selitem));
NS_ENSURE_SUCCESS(rv, rv);
if (selitem == item)
*aIsSelected = PR_TRUE;
return NS_OK;
nsCOMPtr<nsIDOMNode> selItemDOMNode;
sXFormsService->GetSelectedItemForSelect1(DOMNode,
getter_AddRefs(selItemDOMNode));
return selItemDOMNode == itemDOMNode;
}
return sXFormsService->IsSelectItemSelected(DOMNode, item, aIsSelected);
PRBool isSelected = PR_FALSE;
sXFormsService->IsSelectItemSelected(DOMNode, itemDOMNode, &isSelected);
return isSelected;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::ClearSelection()
bool
nsXFormsSelectableAccessible::UnselectAll()
{
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
if (mIsSelect1Element)
return sXFormsService->SetSelectedItemForSelect1(DOMNode, nsnull);
sXFormsService->SetSelectedItemForSelect1(DOMNode, nsnull);
return sXFormsService->ClearSelectionForSelect(DOMNode);
sXFormsService->ClearSelectionForSelect(DOMNode);
return true;
}
NS_IMETHODIMP
nsXFormsSelectableAccessible::SelectAllSelection(PRBool *aMultipleSelection)
bool
nsXFormsSelectableAccessible::SelectAll()
{
NS_ENSURE_ARG_POINTER(aMultipleSelection);
if (mIsSelect1Element)
return false;
if (mIsSelect1Element) {
*aMultipleSelection = PR_FALSE;
return NS_OK;
}
*aMultipleSelection = PR_TRUE;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return sXFormsService->SelectAllItemsForSelect(DOMNode);
sXFormsService->SelectAllItemsForSelect(DOMNode);
return true;
}
already_AddRefed<nsIDOMNode>
nsXFormsSelectableAccessible::GetItemByIndex(PRInt32 *aIndex,
nsIAccessible *aAccessible)
nsIContent*
nsXFormsSelectableAccessible::GetItemByIndex(PRUint32* aIndex,
nsAccessible* aAccessible)
{
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
if (!accessible)
accessible = this;
nsAccessible* accessible = aAccessible ? aAccessible : this;
PRInt32 childCount = accessible->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *child = accessible->GetChildAt(childIdx);
nsCOMPtr<nsIDOMNode> childNode(child->GetDOMNode());
nsCOMPtr<nsIContent> childContent(do_QueryInterface(childNode));
if (!childContent)
continue;
nsIContent* childContent = child->GetContent();
nsINodeInfo *nodeInfo = childContent->NodeInfo();
if (nodeInfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
if (nodeInfo->Equals(nsAccessibilityAtoms::item)) {
if (!*aIndex)
return childNode.forget();
return childContent;
--*aIndex;
} else if (nodeInfo->Equals(nsAccessibilityAtoms::choices)) {
nsIDOMNode *itemNode = GetItemByIndex(aIndex, child).get();
if (itemNode)
return itemNode;
nsIContent* itemContent = GetItemByIndex(aIndex, child);
if (itemContent)
return itemContent;
}
}
}

View File

@ -162,12 +162,21 @@ class nsXFormsSelectableAccessible : public nsXFormsEditableAccessible
public:
nsXFormsSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESELECTABLE
// SelectAccessible
virtual bool IsSelect();
virtual already_AddRefed<nsIArray> SelectedItems();
virtual PRUint32 SelectedItemCount();
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
virtual bool IsItemSelected(PRUint32 aIndex);
virtual bool AddItemToSelection(PRUint32 aIndex);
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
virtual bool SelectAll();
virtual bool UnselectAll();
protected:
already_AddRefed<nsIDOMNode> GetItemByIndex(PRInt32 *aIndex,
nsIAccessible *aAccessible = nsnull);
nsIContent* GetItemByIndex(PRUint32* aIndex,
nsAccessible* aAccessible = nsnull);
PRBool mIsSelect1Element;
};

View File

@ -0,0 +1,61 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = accessibility
LIBRARY_NAME = accessibility_xpcom_s
LIBXUL_LIBRARY = 1
CPPSRCS = \
nsAccEvent.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = \
-I$(srcdir)/../base \
$(NULL)

View File

@ -0,0 +1,206 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccEvent.h"
#include "nsDocAccessible.h"
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS1(nsAccEvent, nsIAccessibleEvent)
NS_IMETHODIMP
nsAccEvent::GetIsFromUserInput(PRBool* aIsFromUserInput)
{
*aIsFromUserInput = mEvent->IsFromUserInput();
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetEventType(PRUint32* aEventType)
{
*aEventType = mEvent->GetEventType();
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetAccessible(nsIAccessible** aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
NS_IF_ADDREF(*aAccessible = mEvent->GetAccessible());
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetDOMNode(nsIDOMNode** aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
nsINode* node = mEvent->GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetAccessibleDocument(nsIAccessibleDocument** aDocAccessible)
{
NS_ENSURE_ARG_POINTER(aDocAccessible);
NS_IF_ADDREF(*aDocAccessible = mEvent->GetDocAccessible());
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccStateChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccStateChangeEvent, nsAccEvent,
nsIAccessibleStateChangeEvent)
NS_IMETHODIMP
nsAccStateChangeEvent::GetState(PRUint32* aState)
{
NS_ENSURE_ARG_POINTER(aState);
*aState = static_cast<AccStateChangeEvent*>(mEvent.get())->GetState();
return NS_OK;
}
NS_IMETHODIMP
nsAccStateChangeEvent::IsExtraState(PRBool* aIsExtraState)
{
NS_ENSURE_ARG_POINTER(aIsExtraState);
*aIsExtraState = static_cast<AccStateChangeEvent*>(mEvent.get())->IsExtraState();
return NS_OK;
}
NS_IMETHODIMP
nsAccStateChangeEvent::IsEnabled(PRBool* aIsEnabled)
{
NS_ENSURE_ARG_POINTER(aIsEnabled);
*aIsEnabled = static_cast<AccStateChangeEvent*>(mEvent.get())->IsStateEnabled();
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccTextChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccTextChangeEvent, nsAccEvent,
nsIAccessibleTextChangeEvent)
NS_IMETHODIMP
nsAccTextChangeEvent::GetStart(PRInt32* aStart)
{
NS_ENSURE_ARG_POINTER(aStart);
*aStart = static_cast<AccTextChangeEvent*>(mEvent.get())->GetStartOffset();
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::GetLength(PRUint32* aLength)
{
NS_ENSURE_ARG_POINTER(aLength);
*aLength = static_cast<AccTextChangeEvent*>(mEvent.get())->GetLength();
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::IsInserted(PRBool* aIsInserted)
{
NS_ENSURE_ARG_POINTER(aIsInserted);
*aIsInserted = static_cast<AccTextChangeEvent*>(mEvent.get())->IsTextInserted();
return NS_OK;
}
NS_IMETHODIMP
nsAccTextChangeEvent::GetModifiedText(nsAString& aModifiedText)
{
static_cast<AccTextChangeEvent*>(mEvent.get())->GetModifiedText(aModifiedText);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccCaretMoveEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccCaretMoveEvent, nsAccEvent,
nsIAccessibleCaretMoveEvent)
NS_IMETHODIMP
nsAccCaretMoveEvent::GetCaretOffset(PRInt32 *aCaretOffset)
{
NS_ENSURE_ARG_POINTER(aCaretOffset);
*aCaretOffset = static_cast<AccCaretMoveEvent*>(mEvent.get())->GetCaretOffset();
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccTableChangeEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccTableChangeEvent, nsAccEvent,
nsIAccessibleTableChangeEvent)
NS_IMETHODIMP
nsAccTableChangeEvent::GetRowOrColIndex(PRInt32 *aRowOrColIndex)
{
NS_ENSURE_ARG_POINTER(aRowOrColIndex);
*aRowOrColIndex =
static_cast<AccTableChangeEvent*>(mEvent.get())->GetIndex();
return NS_OK;
}
NS_IMETHODIMP
nsAccTableChangeEvent::GetNumRowsOrCols(PRInt32* aNumRowsOrCols)
{
NS_ENSURE_ARG_POINTER(aNumRowsOrCols);
*aNumRowsOrCols = static_cast<AccTableChangeEvent*>(mEvent.get())->GetCount();
return NS_OK;
}

View File

@ -0,0 +1,148 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsAccEvent_H_
#define _nsAccEvent_H_
#include "nsIAccessibleEvent.h"
#include "AccEvent.h"
/**
* Generic accessible event.
*/
class nsAccEvent: public nsIAccessibleEvent
{
public:
nsAccEvent(AccEvent* aEvent) : mEvent(aEvent) { }
virtual ~nsAccEvent() { }
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLEEVENT
protected:
nsRefPtr<AccEvent> mEvent;
private:
nsAccEvent();
nsAccEvent(const nsAccEvent&);
nsAccEvent& operator =(const nsAccEvent&);
};
/**
* Accessible state change event.
*/
class nsAccStateChangeEvent: public nsAccEvent,
public nsIAccessibleStateChangeEvent
{
public:
nsAccStateChangeEvent(AccStateChangeEvent* aEvent) : nsAccEvent(aEvent) { }
virtual ~nsAccStateChangeEvent() { }
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESTATECHANGEEVENT
private:
nsAccStateChangeEvent();
nsAccStateChangeEvent(const nsAccStateChangeEvent&);
nsAccStateChangeEvent& operator =(const nsAccStateChangeEvent&);
};
/**
* Accessible text change event.
*/
class nsAccTextChangeEvent: public nsAccEvent,
public nsIAccessibleTextChangeEvent
{
public:
nsAccTextChangeEvent(AccTextChangeEvent* aEvent) : nsAccEvent(aEvent) { }
virtual ~nsAccTextChangeEvent() { }
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXTCHANGEEVENT
private:
nsAccTextChangeEvent();
nsAccTextChangeEvent(const nsAccTextChangeEvent&);
nsAccTextChangeEvent& operator =(const nsAccTextChangeEvent&);
};
/**
* Accessible caret move event.
*/
class nsAccCaretMoveEvent: public nsAccEvent,
public nsIAccessibleCaretMoveEvent
{
public:
nsAccCaretMoveEvent(AccCaretMoveEvent* aEvent) : nsAccEvent(aEvent) { }
virtual ~nsAccCaretMoveEvent() { }
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLECARETMOVEEVENT
private:
nsAccCaretMoveEvent();
nsAccCaretMoveEvent(const nsAccCaretMoveEvent&);
nsAccCaretMoveEvent& operator =(const nsAccCaretMoveEvent&);
};
/**
* Accessible table change event.
*/
class nsAccTableChangeEvent : public nsAccEvent,
public nsIAccessibleTableChangeEvent
{
public:
nsAccTableChangeEvent(AccTableChangeEvent* aEvent) : nsAccEvent(aEvent) { }
virtual ~nsAccTableChangeEvent() { }
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETABLECHANGEEVENT
private:
nsAccTableChangeEvent();
nsAccTableChangeEvent(const nsAccTableChangeEvent&);
nsAccTableChangeEvent& operator =(const nsAccTableChangeEvent&);
};
#endif

View File

@ -879,7 +879,6 @@ nsXULListitemAccessible::
eCaseMatters);
}
/** Inherit the ISupports impl from nsAccessible, we handle nsIAccessibleSelectable */
NS_IMPL_ISUPPORTS_INHERITED0(nsXULListitemAccessible, nsAccessible)
nsAccessible *

View File

@ -65,7 +65,6 @@ static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
// nsXULSelectableAccessible
////////////////////////////////////////////////////////////////////////////////
// Helper methos
nsXULSelectableAccessible::
nsXULSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
@ -73,7 +72,8 @@ nsXULSelectableAccessible::
mSelectControl = do_QueryInterface(aContent);
}
NS_IMPL_ISUPPORTS_INHERITED1(nsXULSelectableAccessible, nsAccessible, nsIAccessibleSelectable)
////////////////////////////////////////////////////////////////////////////////
// nsXULSelectableAccessible: nsAccessNode
void
nsXULSelectableAccessible::Shutdown()
@ -82,51 +82,23 @@ nsXULSelectableAccessible::Shutdown()
nsAccessibleWrap::Shutdown();
}
nsresult nsXULSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
////////////////////////////////////////////////////////////////////////////////
// nsXULSelectableAccessible: SelectAccessible
bool
nsXULSelectableAccessible::IsSelect()
{
*aSelState = PR_FALSE;
if (!mSelectControl) {
return NS_ERROR_FAILURE;
}
nsAccessible* child = GetChildAt(aIndex);
NS_ENSURE_TRUE(child, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> childNode;
child->GetDOMNode(getter_AddRefs(childNode));
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(childNode));
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
item->GetSelected(aSelState);
if (eSelection_GetState == aMethod) {
return NS_OK;
}
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
do_QueryInterface(mSelectControl);
if (eSelection_Add == aMethod && !(*aSelState)) {
return xulMultiSelect ? xulMultiSelect->AddItemToSelection(item) :
mSelectControl->SetSelectedItem(item);
}
if (eSelection_Remove == aMethod && (*aSelState)) {
return xulMultiSelect ? xulMultiSelect->RemoveItemFromSelection(item) :
mSelectControl->SetSelectedItem(nsnull);
}
return NS_ERROR_FAILURE;
return !!mSelectControl;
}
// Interface methods
NS_IMETHODIMP nsXULSelectableAccessible::GetSelectedChildren(nsIArray **aChildren)
already_AddRefed<nsIArray>
nsXULSelectableAccessible::SelectedItems()
{
*aChildren = nsnull;
if (!mSelectControl) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIMutableArray> selectedAccessibles =
nsCOMPtr<nsIMutableArray> selectedItems =
do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_STATE(selectedAccessibles);
if (!selectedItems)
return nsnull;
// For XUL multi-select control
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
@ -135,129 +107,165 @@ NS_IMETHODIMP nsXULSelectableAccessible::GetSelectedChildren(nsIArray **aChildre
PRInt32 length = 0;
xulMultiSelect->GetSelectedCount(&length);
for (PRInt32 index = 0; index < length; index++) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
xulMultiSelect->GetSelectedItem(index, getter_AddRefs(selectedItem));
nsCOMPtr<nsIContent> selectedContent(do_QueryInterface(selectedItem));
nsAccessible *selectedAcc =
GetAccService()->GetAccessibleInWeakShell(selectedContent, mWeakShell);
if (selectedAcc)
selectedAccessibles->AppendElement(static_cast<nsIAccessible*>(selectedAcc),
PR_FALSE);
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
xulMultiSelect->GetSelectedItem(index, getter_AddRefs(itemElm));
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
nsAccessible* item =
GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell);
if (item)
selectedItems->AppendElement(static_cast<nsIAccessible*>(item),
PR_FALSE);
}
}
else { // Single select?
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
mSelectControl->GetSelectedItem(getter_AddRefs(selectedItem));
nsCOMPtr<nsIContent> selectedContent(do_QueryInterface(selectedItem));
if(selectedContent) {
nsAccessible *selectedAcc =
GetAccService()->GetAccessibleInWeakShell(selectedContent, mWeakShell);
if (selectedAcc)
selectedAccessibles->AppendElement(static_cast<nsIAccessible*>(selectedAcc),
PR_FALSE);
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
mSelectControl->GetSelectedItem(getter_AddRefs(itemElm));
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
if(itemNode) {
nsAccessible* item =
GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell);
if (item)
selectedItems->AppendElement(static_cast<nsIAccessible*>(item),
PR_FALSE);
}
}
PRUint32 uLength = 0;
selectedAccessibles->GetLength(&uLength);
if (uLength != 0) { // length of nsIArray containing selected options
NS_ADDREF(*aChildren = selectedAccessibles);
}
return NS_OK;
nsIMutableArray* items = nsnull;
selectedItems.forget(&items);
return items;
}
// return the nth selected child's nsIAccessible object
NS_IMETHODIMP nsXULSelectableAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aAccessible)
nsAccessible*
nsXULSelectableAccessible::GetSelectedItem(PRUint32 aIndex)
{
*aAccessible = nsnull;
if (!mSelectControl) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (xulMultiSelect)
xulMultiSelect->GetSelectedItem(aIndex, getter_AddRefs(selectedItem));
if (aIndex == 0)
mSelectControl->GetSelectedItem(getter_AddRefs(selectedItem));
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
if (multiSelectControl)
multiSelectControl->GetSelectedItem(aIndex, getter_AddRefs(itemElm));
else if (aIndex == 0)
mSelectControl->GetSelectedItem(getter_AddRefs(itemElm));
if (!selectedItem)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> selectedContent(do_QueryInterface(selectedItem));
nsAccessible *selectedAcc =
GetAccService()->GetAccessibleInWeakShell(selectedContent, mWeakShell);
if (!selectedAcc)
return NS_ERROR_FAILURE;
NS_ADDREF(*aAccessible = selectedAcc);
return NS_OK;
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
return itemNode ?
GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell) : nsnull;
}
NS_IMETHODIMP nsXULSelectableAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
PRUint32
nsXULSelectableAccessible::SelectedItemCount()
{
*aSelectionCount = 0;
if (!mSelectControl) {
return NS_ERROR_FAILURE;
}
// For XUL multi-select control
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (xulMultiSelect)
return xulMultiSelect->GetSelectedCount(aSelectionCount);
if (multiSelectControl) {
PRInt32 count = 0;
multiSelectControl->GetSelectedCount(&count);
return count;
}
// For XUL single-select control/menulist
PRInt32 index;
mSelectControl->GetSelectedIndex(&index);
if (index >= 0)
*aSelectionCount = 1;
return NS_OK;
return (index >= 0) ? 1 : 0;
}
NS_IMETHODIMP nsXULSelectableAccessible::AddChildToSelection(PRInt32 aIndex)
bool
nsXULSelectableAccessible::AddItemToSelection(PRUint32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Add, &isSelected);
nsAccessible* item = GetChildAt(aIndex);
if (!item)
return false;
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
do_QueryInterface(item->GetContent());
if (!itemElm)
return false;
PRBool isItemSelected = PR_FALSE;
itemElm->GetSelected(&isItemSelected);
if (isItemSelected)
return true;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (multiSelectControl)
multiSelectControl->AddItemToSelection(itemElm);
else
mSelectControl->SetSelectedItem(itemElm);
return true;
}
NS_IMETHODIMP nsXULSelectableAccessible::RemoveChildFromSelection(PRInt32 aIndex)
bool
nsXULSelectableAccessible::RemoveItemFromSelection(PRUint32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Remove, &isSelected);
nsAccessible* item = GetChildAt(aIndex);
if (!item)
return false;
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
do_QueryInterface(item->GetContent());
if (!itemElm)
return false;
PRBool isItemSelected = PR_FALSE;
itemElm->GetSelected(&isItemSelected);
if (!isItemSelected)
return true;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (multiSelectControl)
multiSelectControl->RemoveItemFromSelection(itemElm);
else
mSelectControl->SetSelectedItem(nsnull);
return true;
}
NS_IMETHODIMP nsXULSelectableAccessible::IsChildSelected(PRInt32 aIndex, PRBool *aIsSelected)
bool
nsXULSelectableAccessible::IsItemSelected(PRUint32 aIndex)
{
*aIsSelected = PR_FALSE;
return ChangeSelection(aIndex, eSelection_GetState, aIsSelected);
nsAccessible* item = GetChildAt(aIndex);
if (!item)
return false;
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
do_QueryInterface(item->GetContent());
if (!itemElm)
return false;
PRBool isItemSelected = PR_FALSE;
itemElm->GetSelected(&isItemSelected);
return isItemSelected;
}
NS_IMETHODIMP nsXULSelectableAccessible::ClearSelection()
bool
nsXULSelectableAccessible::UnselectAll()
{
if (!mSelectControl) {
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
multiSelectControl ?
multiSelectControl->ClearSelection() : mSelectControl->SetSelectedIndex(-1);
return true;
}
bool
nsXULSelectableAccessible::SelectAll()
{
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (multiSelectControl) {
multiSelectControl->SelectAll();
return true;
}
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
do_QueryInterface(mSelectControl);
return xulMultiSelect ? xulMultiSelect->ClearSelection() : mSelectControl->SetSelectedIndex(-1);
}
NS_IMETHODIMP nsXULSelectableAccessible::SelectAllSelection(PRBool *aSucceeded)
{
*aSucceeded = PR_TRUE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
do_QueryInterface(mSelectControl);
if (xulMultiSelect)
return xulMultiSelect->SelectAll();
// otherwise, don't support this method
*aSucceeded = PR_FALSE;
return NS_ERROR_NOT_IMPLEMENTED;
return false;
}

View File

@ -40,27 +40,32 @@
#define _nsXULMenuAccessible_H_
#include "nsAccessibleWrap.h"
#include "nsIAccessibleSelectable.h"
#include "nsIDOMXULSelectCntrlEl.h"
/**
* The basic implementation of nsIAccessibleSelectable.
* The basic implementation of SelectAccessible for XUL select controls.
*/
class nsXULSelectableAccessible : public nsAccessibleWrap
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESELECTABLE
nsXULSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsXULSelectableAccessible() {}
// nsAccessNode
virtual void Shutdown();
protected:
nsresult ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
// SelectAccessible
virtual bool IsSelect();
virtual already_AddRefed<nsIArray> SelectedItems();
virtual PRUint32 SelectedItemCount();
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
virtual bool IsItemSelected(PRUint32 aIndex);
virtual bool AddItemToSelection(PRUint32 aIndex);
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
virtual bool SelectAll();
virtual bool UnselectAll();
protected:
// nsIDOMXULMultiSelectControlElement inherits from this, so we'll always have
// one of these if the widget is valid and not defunct
nsCOMPtr<nsIDOMXULSelectControlElement> mSelectControl;

View File

@ -238,26 +238,52 @@ nsXULLinkAccessible::DoAction(PRUint8 aIndex)
}
////////////////////////////////////////////////////////////////////////////////
// nsXULLinkAccessible. nsIAccessibleHyperLink
// nsXULLinkAccessible: HyperLinkAccessible
NS_IMETHODIMP
nsXULLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
bool
nsXULLinkAccessible::IsHyperLink()
{
NS_ENSURE_ARG_POINTER(aURI);
*aURI = nsnull;
// Expose HyperLinkAccessible unconditionally.
return true;
}
if (aIndex != 0)
return NS_ERROR_INVALID_ARG;
PRUint32
nsXULLinkAccessible::StartOffset()
{
// If XUL link accessible is not contained by hypertext accessible then
// start offset matches index in parent because the parent doesn't contains
// a text.
// XXX: accessible parent of XUL link accessible should be a hypertext
// accessible.
if (nsAccessible::IsHyperLink())
return nsAccessible::StartOffset();
return GetIndexInParent();
}
if (IsDefunct())
return NS_ERROR_FAILURE;
PRUint32
nsXULLinkAccessible::EndOffset()
{
if (nsAccessible::IsHyperLink())
return nsAccessible::EndOffset();
return GetIndexInParent() + 1;
}
already_AddRefed<nsIURI>
nsXULLinkAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
{
if (aAnchorIndex != 0)
return nsnull;
nsAutoString href;
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::href, href);
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
nsIDocument* document = mContent->GetOwnerDoc();
return NS_NewURI(aURI, href,
document ? document->GetDocumentCharacterSet().get() : nsnull,
baseURI);
nsIURI* anchorURI = nsnull;
NS_NewURI(&anchorURI, href,
document ? document->GetDocumentCharacterSet().get() : nsnull,
baseURI);
return anchorURI;
}

View File

@ -91,14 +91,17 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsIAccessibleHyperLink
NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI);
// nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
// HyperLinkAccessible
virtual bool IsHyperLink();
virtual PRUint32 StartOffset();
virtual PRUint32 EndOffset();
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
protected:
enum { eAction_Jump = 0 };

View File

@ -57,7 +57,7 @@
nsXULTreeAccessible::
nsXULTreeAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsXULSelectableAccessible(aContent, aShell)
nsAccessibleWrap(aContent, aShell)
{
mTree = nsCoreUtils::GetTreeBoxObject(aContent);
if (mTree)
@ -85,10 +85,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXULTreeAccessible)
NS_INTERFACE_MAP_STATIC_AMBIGUOUS(nsXULTreeAccessible)
NS_INTERFACE_MAP_END_INHERITING(nsXULSelectableAccessible)
NS_INTERFACE_MAP_END_INHERITING(nsAccessible)
NS_IMPL_ADDREF_INHERITED(nsXULTreeAccessible, nsXULSelectableAccessible)
NS_IMPL_RELEASE_INHERITED(nsXULTreeAccessible, nsXULSelectableAccessible)
NS_IMPL_ADDREF_INHERITED(nsXULTreeAccessible, nsAccessible)
NS_IMPL_RELEASE_INHERITED(nsXULTreeAccessible, nsAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeAccessible: nsAccessible implementation
@ -160,7 +160,7 @@ nsXULTreeAccessible::GetValue(nsAString& aValue)
PRBool
nsXULTreeAccessible::IsDefunct()
{
return nsXULSelectableAccessible::IsDefunct() || !mTree || !mTreeView;
return nsAccessibleWrap::IsDefunct() || !mTree || !mTreeView;
}
void
@ -175,7 +175,7 @@ nsXULTreeAccessible::Shutdown()
mTree = nsnull;
mTreeView = nsnull;
nsXULSelectableAccessible::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@ -197,8 +197,8 @@ nsXULTreeAccessible::GetRoleInternal(PRUint32 *aRole)
cols->GetPrimaryColumn(getter_AddRefs(primaryCol));
*aRole = primaryCol ?
nsIAccessibleRole::ROLE_OUTLINE :
nsIAccessibleRole::ROLE_LIST;
static_cast<PRUint32>(nsIAccessibleRole::ROLE_OUTLINE) :
static_cast<PRUint32>(nsIAccessibleRole::ROLE_LIST);
return NS_OK;
}
@ -262,8 +262,7 @@ nsXULTreeAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
// If we failed to find tree cell for the given point then it might be
// tree columns.
if (row == -1 || !column)
return nsXULSelectableAccessible::
GetChildAtPoint(aX, aY, aDeepestChild, aChild);
return nsAccessibleWrap::GetChildAtPoint(aX, aY, aDeepestChild, aChild);
nsAccessible *child = GetTreeItemAccessible(row);
if (aDeepestChild && child) {
@ -280,23 +279,26 @@ nsXULTreeAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
}
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeAccessible: nsAccessibleSelectable implementation
// nsXULTreeAccessible: SelectAccessible
NS_IMETHODIMP nsXULTreeAccessible::GetSelectedChildren(nsIArray **_retval)
bool
nsXULTreeAccessible::IsSelect()
{
// Ask tree selection to get all selected children
*_retval = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
return true;
}
already_AddRefed<nsIArray>
nsXULTreeAccessible::SelectedItems()
{
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (!selection)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMutableArray> selectedAccessibles =
return nsnull;
nsCOMPtr<nsIMutableArray> selectedItems =
do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_STATE(selectedAccessibles);
if (!selectedItems)
return nsnull;
PRInt32 rowIndex, rowCount;
PRBool isSelected;
@ -304,98 +306,95 @@ NS_IMETHODIMP nsXULTreeAccessible::GetSelectedChildren(nsIArray **_retval)
for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
selection->IsSelected(rowIndex, &isSelected);
if (isSelected) {
nsIAccessible *tempAccessible = GetTreeItemAccessible(rowIndex);
NS_ENSURE_STATE(tempAccessible);
selectedAccessibles->AppendElement(tempAccessible, PR_FALSE);
nsIAccessible* item = GetTreeItemAccessible(rowIndex);
if (item)
selectedItems->AppendElement(item, PR_FALSE);
}
}
PRUint32 length;
selectedAccessibles->GetLength(&length);
if (length != 0) {
*_retval = selectedAccessibles;
NS_IF_ADDREF(*_retval);
}
return NS_OK;
nsIMutableArray* items = nsnull;
selectedItems.forget(&items);
return items;
}
NS_IMETHODIMP nsXULTreeAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
PRUint32
nsXULTreeAccessible::SelectedItemCount()
{
*aSelectionCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection)
selection->GetCount(aSelectionCount);
return NS_OK;
}
NS_IMETHODIMP nsXULTreeAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection) {
selection->IsSelected(aIndex, aSelState);
if ((!(*aSelState) && eSelection_Add == aMethod) ||
((*aSelState) && eSelection_Remove == aMethod))
return selection->ToggleSelect(aIndex);
PRInt32 count = 0;
selection->GetCount(&count);
return count;
}
return NS_OK;
return 0;
}
NS_IMETHODIMP nsXULTreeAccessible::AddChildToSelection(PRInt32 aIndex)
bool
nsXULTreeAccessible::AddItemToSelection(PRUint32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Add, &isSelected);
}
NS_IMETHODIMP nsXULTreeAccessible::RemoveChildFromSelection(PRInt32 aIndex)
{
PRBool isSelected;
return ChangeSelection(aIndex, eSelection_Remove, &isSelected);
}
NS_IMETHODIMP nsXULTreeAccessible::IsChildSelected(PRInt32 aIndex, PRBool *_retval)
{
return ChangeSelection(aIndex, eSelection_GetState, _retval);
}
NS_IMETHODIMP nsXULTreeAccessible::ClearSelection()
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection)
selection->ClearSelection();
if (selection) {
PRBool isSelected = PR_FALSE;
selection->IsSelected(aIndex, &isSelected);
if (!isSelected)
selection->ToggleSelect(aIndex);
return NS_OK;
return true;
}
return false;
}
NS_IMETHODIMP
nsXULTreeAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aAccessible)
bool
nsXULTreeAccessible::RemoveItemFromSelection(PRUint32 aIndex)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection) {
PRBool isSelected = PR_FALSE;
selection->IsSelected(aIndex, &isSelected);
if (isSelected)
selection->ToggleSelect(aIndex);
if (IsDefunct())
return NS_ERROR_FAILURE;
return true;
}
return false;
}
bool
nsXULTreeAccessible::IsItemSelected(PRUint32 aIndex)
{
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection) {
PRBool isSelected = PR_FALSE;
selection->IsSelected(aIndex, &isSelected);
return isSelected;
}
return false;
}
bool
nsXULTreeAccessible::UnselectAll()
{
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (!selection)
return NS_ERROR_FAILURE;
return false;
selection->ClearSelection();
return true;
}
nsAccessible*
nsXULTreeAccessible::GetSelectedItem(PRUint32 aIndex)
{
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (!selection)
return nsnull;
PRInt32 rowIndex, rowCount;
PRInt32 selCount = 0;
@ -404,26 +403,19 @@ nsXULTreeAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aAccessible)
for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
selection->IsSelected(rowIndex, &isSelected);
if (isSelected) {
if (selCount == aIndex) {
NS_IF_ADDREF(*aAccessible = GetTreeItemAccessible(rowIndex));
return NS_OK;
}
if (selCount == aIndex)
return GetTreeItemAccessible(rowIndex);
selCount++;
}
}
return NS_OK;
return nsnull;
}
NS_IMETHODIMP
nsXULTreeAccessible::SelectAllSelection(PRBool *aIsMultiSelectable)
bool
nsXULTreeAccessible::SelectAll()
{
NS_ENSURE_ARG_POINTER(aIsMultiSelectable);
*aIsMultiSelectable = PR_FALSE;
if (IsDefunct())
return NS_ERROR_FAILURE;
// see if we are multiple select if so set ourselves as such
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
@ -431,12 +423,12 @@ nsXULTreeAccessible::SelectAllSelection(PRBool *aIsMultiSelectable)
PRBool single = PR_FALSE;
selection->GetSingle(&single);
if (!single) {
*aIsMultiSelectable = PR_TRUE;
selection->SelectAll();
return true;
}
}
return NS_OK;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@ -521,8 +513,8 @@ nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount)
nsAccessible *accessible = mAccessibleCache.GetWeak(key);
if (accessible) {
nsRefPtr<nsAccEvent> event =
new nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, accessible, PR_FALSE);
nsRefPtr<AccEvent> event =
new AccEvent(nsIAccessibleEvent::EVENT_HIDE, accessible, PR_FALSE);
nsEventShell::FireEvent(event);
accessible->Shutdown();
@ -622,8 +614,8 @@ nsXULTreeAccessible::TreeViewChanged()
// Fire only notification destroy/create events on accessible tree to lie to
// AT because it should be expensive to fire destroy events for each tree item
// in cache.
nsRefPtr<nsAccEvent> eventDestroy =
new nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, this, PR_FALSE);
nsRefPtr<AccEvent> eventDestroy =
new AccEvent(nsIAccessibleEvent::EVENT_HIDE, this, PR_FALSE);
if (!eventDestroy)
return;
@ -633,8 +625,8 @@ nsXULTreeAccessible::TreeViewChanged()
mTree->GetView(getter_AddRefs(mTreeView));
nsRefPtr<nsAccEvent> eventCreate =
new nsAccEvent(nsIAccessibleEvent::EVENT_SHOW, this, PR_FALSE);
nsRefPtr<AccEvent> eventCreate =
new AccEvent(nsIAccessibleEvent::EVENT_SHOW, this, PR_FALSE);
if (!eventCreate)
return;
@ -989,8 +981,8 @@ nsXULTreeItemAccessibleBase::GetStateInternal(PRUint32 *aState,
PRBool isContainerOpen;
mTreeView->IsContainerOpen(mRow, &isContainerOpen);
*aState |= isContainerOpen ?
nsIAccessibleStates::STATE_EXPANDED:
nsIAccessibleStates::STATE_COLLAPSED;
static_cast<PRUint32>(nsIAccessibleStates::STATE_EXPANDED) :
static_cast<PRUint32>(nsIAccessibleStates::STATE_COLLAPSED);
}
// selected state
@ -1178,8 +1170,8 @@ nsXULTreeItemAccessible::GetRoleInternal(PRUint32 *aRole)
columns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
*aRole = primaryColumn ?
nsIAccessibleRole::ROLE_OUTLINEITEM :
nsIAccessibleRole::ROLE_LISTITEM;
static_cast<PRUint32>(nsIAccessibleRole::ROLE_OUTLINEITEM) :
static_cast<PRUint32>(nsIAccessibleRole::ROLE_LISTITEM);
return NS_OK;
}

View File

@ -61,9 +61,13 @@ const PRUint32 kDefaultTreeCacheSize = 256;
{ 0xb8, 0xe1, 0x2c, 0x44, 0xb0, 0x41, 0x85, 0xe3 } \
}
class nsXULTreeAccessible : public nsXULSelectableAccessible
class nsXULTreeAccessible : public nsAccessibleWrap
{
public:
using nsAccessible::GetChildCount;
using nsAccessible::GetChildAt;
using nsAccessible::GetChildAtPoint;
nsXULTreeAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports and cycle collection
@ -75,9 +79,6 @@ public:
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
// nsIAccessibleSelectable
NS_DECL_NSIACCESSIBLESELECTABLE
// nsAccessNode
virtual PRBool IsDefunct();
virtual void Shutdown();
@ -92,6 +93,17 @@ public:
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
virtual PRInt32 GetChildCount();
// SelectAccessible
virtual bool IsSelect();
virtual already_AddRefed<nsIArray> SelectedItems();
virtual PRUint32 SelectedItemCount();
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
virtual bool IsItemSelected(PRUint32 aIndex);
virtual bool AddItemToSelection(PRUint32 aIndex);
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
virtual bool SelectAll();
virtual bool UnselectAll();
// nsXULTreeAccessible
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEACCESSIBLE_IMPL_CID)
@ -140,8 +152,6 @@ protected:
nsCOMPtr<nsITreeBoxObject> mTree;
nsCOMPtr<nsITreeView> mTreeView;
nsAccessibleHashtable mAccessibleCache;
NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeAccessible,
@ -162,6 +172,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeAccessible,
class nsXULTreeItemAccessibleBase : public nsAccessibleWrap
{
public:
using nsAccessible::GetParent;
nsXULTreeItemAccessibleBase(nsIContent *aContent, nsIWeakReference *aShell,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow);

View File

@ -586,8 +586,8 @@ nsXULTreeGridAccessible::GetRoleInternal(PRUint32 *aRole)
treeColumns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
*aRole = primaryColumn ?
nsIAccessibleRole::ROLE_TREE_TABLE :
nsIAccessibleRole::ROLE_TABLE;
static_cast<PRUint32>(nsIAccessibleRole::ROLE_TREE_TABLE) :
static_cast<PRUint32>(nsIAccessibleRole::ROLE_TABLE);
return NS_OK;
}
@ -1238,9 +1238,9 @@ nsXULTreeGridCellAccessible::CellInvalidated()
mTreeView->GetCellValue(mRow, mColumn, textEquiv);
if (mCachedTextEquiv != textEquiv) {
PRBool isEnabled = textEquiv.EqualsLiteral("true");
nsRefPtr<nsAccEvent> accEvent =
new nsAccStateChangeEvent(this, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsRefPtr<AccEvent> accEvent =
new AccStateChangeEvent(this, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
nsEventShell::FireEvent(accEvent);
mCachedTextEquiv = textEquiv;

View File

@ -75,6 +75,10 @@ protected:
class nsXULTreeGridRowAccessible : public nsXULTreeItemAccessibleBase
{
public:
using nsAccessible::GetChildCount;
using nsAccessible::GetChildAt;
using nsAccessible::GetChildAtPoint;
nsXULTreeGridRowAccessible(nsIContent *aContent, nsIWeakReference *aShell,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow);
@ -127,6 +131,8 @@ class nsXULTreeGridCellAccessible : public nsLeafAccessible,
public nsIAccessibleTableCell
{
public:
using nsAccessible::GetParent;
nsXULTreeGridCellAccessible(nsIContent *aContent, nsIWeakReference *aShell,
nsXULTreeGridRowAccessible *aRowAcc,
nsITreeBoxObject *aTree, nsITreeView *aTreeView,

View File

@ -42,7 +42,17 @@ srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible
DIRS = actions attributes events relations selectable states table tree
DIRS = \
actions \
attributes \
events \
hyperlink \
relations \
selectable \
states \
table \
tree \
$(null)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
@ -98,8 +108,6 @@ _TEST_FILES =\
test_nsIAccessible_selects.html \
test_nsIAccessible_focus.html \
test_nsIAccessibleDocument.html \
test_nsIAccessibleHyperLink.html \
test_nsIAccessibleHyperLink.xul \
test_nsIAccessibleHyperText.html \
test_nsIAccessibleImage.html \
test_nsIAccessNode_utils.html \

View File

@ -13,11 +13,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
src="../actions.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
src="../actions.js"></script>
<script type="application/javascript">
function doTest()

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
src="../actions.js"></script>
<script type="application/javascript">
function doTest()

View File

@ -2,7 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.css"
<?xml-stylesheet href="../nsIAccessible_name.css"
type="text/css"?>
@ -15,11 +15,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js" />
src="../events.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js" />
src="../actions.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
src="../actions.js"></script>
<script type="application/javascript">
function doTest()

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
src="../actions.js"></script>
<script type="application/javascript">
function doTest()
@ -84,16 +84,16 @@
</pre>
<a href="http://mozilla.org" id="link1">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img1">
<img src="../moz.png" id="img1">
</a>
<a id="link2" onmousedown="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img2">
<img src="../moz.png" id="img2">
</a>
<a id="link3" onclick="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img3">
<img src="../moz.png" id="img3">
</a>
<a id="link4" onmouseup="">
<img src="chrome://mochikit/content/a11y/accessible/moz.png" id="img4">
<img src="../moz.png" id="img4">
</a>
</body>
</html>

View File

@ -12,16 +12,16 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/treeview.js" />
src="../treeview.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js" />
src="../states.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js" />
src="../events.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js" />
src="../actions.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -2,7 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/treeview.css"
<?xml-stylesheet href="../treeview.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -14,16 +14,16 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/treeview.js" />
src="../treeview.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js" />
src="../states.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js" />
src="../events.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js" />
src="../actions.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -2,6 +2,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=475006
https://bugzilla.mozilla.org/show_bug.cgi?id=391829
https://bugzilla.mozilla.org/show_bug.cgi?id=581952
-->
<head>
<title>Group attributes tests</title>
@ -14,9 +15,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript">
function doTest()
@ -69,6 +70,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
testAttrs("statusChild", {"container-live-role" : "status"}, true);
testAttrs("timerChild", {"container-live-role" : "timer"}, true);
// absent aria-label and aria-labelledby object attribute
testAbsentAttrs("label", {"label" : "foo"});
testAbsentAttrs("labelledby", {"labelledby" : "label"});
// container that has no default live attribute
testAttrs("liveGroup", {"live" : "polite"}, true);
testAttrs("liveGroupChild", {"container-live" : "polite"}, true);
@ -93,11 +98,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
title="Extend nsARIAMap to capture ARIA attribute characteristics">
Mozilla Bug 475006
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=391829"
title="Add support for container-live-role to object attributes">
Mozilla Bug 391829
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=391829"
title="Add support for container-live-role to object attributes">
Mozilla Bug 391829
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=581952"
title="Make explicit that aria-label is not an object attribute">
Mozilla Bug 475006
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -129,6 +139,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
<div id="status" role="status">excuse <div id="statusChild">me</div></div>
<div id="timer" role="timer">excuse <div id="timerChild">me</div></div>
<!-- aria-label[ledby] should not be an object attribute -->
<div id="label" role="checkbox" aria-label="foo"></div>
<div id="labelledby" role="checkbox" aria-labelledby="label"></div>
<!-- unusual live case -->
<div id="liveGroup" role="group" aria-live="polite">
excuse <div id="liveGroupChild">me</div>

View File

@ -14,9 +14,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=460932
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript">
function testCSSAttrs(aID)

View File

@ -11,9 +11,9 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript">
function doTest()

View File

@ -12,9 +12,9 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js" />
src="../attributes.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -12,12 +12,12 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/treeview.js" />
src="../treeview.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js" />
src="../attributes.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -10,11 +10,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
@ -428,8 +428,12 @@
ID = "area14";
defAttrs = buildDefaultTextAttrs(ID, kInputFontSize);
attrs = { };
testTextAttrs(ID, 0, attrs, defAttrs, 0, 0);
// XXX: While we expose text leaf accessibles for placeholder we grab its
// style, bug 545817.
// attrs = { color: "rgb(109, 109, 109)" };
//testTextAttrs(ID, 0, attrs, defAttrs, 0, 0);
todo(false, "enable commented tests when bug 545817 is fixed");
//////////////////////////////////////////////////////////////////////////
// area15, embed char tests, "*plain*plain**bold*bold*"

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// Constants
const EVENT_ALERT = nsIAccessibleEvent.EVENT_ALERT;
const EVENT_DOCUMENT_LOAD_COMPLETE = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE;
const EVENT_DOCUMENT_RELOAD = nsIAccessibleEvent.EVENT_DOCUMENT_RELOAD;
const EVENT_DOCUMENT_LOAD_STOPPED = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_STOPPED;
@ -315,37 +316,48 @@ function eventQueue(aEventType)
invoker.debugCheck(aEvent);
// Search through unexpected events to ensure no one of them was handled.
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
var idx = 0;
for (; idx < this.mEventSeq.length; idx++) {
if (this.mEventSeq[idx].unexpected && this.compareEvents(idx, aEvent))
invoker.wasCaught[idx] = true;
}
// Wait for next expected event in an order specified by event sequence.
// We've handled all expected events, next invoker processing is pending.
if (this.mEventSeqIdx == this.mEventSeq.length)
return;
// Compute next expected event index.
for (var idx = this.mEventSeqIdx + 1;
idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected; idx++);
for (idx = this.mEventSeqIdx + 1;
idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected;
idx++);
// No expected events were registered, proceed to next invoker to ensure
// unexpected events for current invoker won't be handled.
if (idx == this.mEventSeq.length) {
// There is no expected events in the sequence.
this.mEventSeqIdx = idx;
this.processNextInvokerInTimeout();
return;
}
// Check if handled event matches expected event.
var matched = this.compareEvents(idx, aEvent);
this.dumpEventToDOM(aEvent, idx, matched);
if (matched) {
this.checkEvent(idx, aEvent);
invoker.wasCaught[idx] = true;
// The last event is expected and was handled, proceed next invoker.
if (idx == this.mEventSeq.length - 1) {
this.processNextInvokerInTimeout();
return;
}
this.mEventSeqIdx = idx;
// Get next expected event index.
while (++idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected);
// If the last expected event was processed, proceed next invoker in
// timeout to ensure unexpected events for current invoker won't be
// handled.
if (idx == this.mEventSeq.length) {
this.mEventSeqIdx = idx;
this.processNextInvokerInTimeout();
}
}
}

View File

@ -50,6 +50,7 @@ _TEST_FILES =\
docload_wnd.xul \
focus.html \
scroll.html \
test_aria_alert.html \
test_aria_statechange.html \
test_attrs.html \
test_caretmove.html \

View File

@ -0,0 +1,93 @@
<html>
<head>
<title>ARIA alert event testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../states.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
function showAlert(aID)
{
this.DOMNode = document.createElement("div");
this.invoke = function showAlert_invoke()
{
this.DOMNode.setAttribute("role", "alert");
this.DOMNode.setAttribute("id", aID);
var text = document.createTextNode("alert");
this.DOMNode.appendChild(text);
document.body.appendChild(this.DOMNode);
};
this.getID = function showAlert_getID()
{
return "Show ARIA alert " + aID;
};
}
function changeAlert(aID)
{
this.__defineGetter__("DOMNode", function() { return getNode(aID) });
this.invoke = function changeAlert_invoke()
{
this.DOMNode.textContent = "new alert";
}
this.getID = function showAlert_getID()
{
return "Change ARIA alert " + aID;
}
}
////////////////////////////////////////////////////////////////////////////
// Do tests
var gQueue = null;
//gA11yEventDumpID = "eventdump";
function doTests()
{
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_ALERT);
gQueue.push(new showAlert("alert"));
gQueue.push(new changeAlert("alert"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=591199"
title="mochitest for bug 334386: fire alert event when ARIA alert is shown or new its children are inserted">
Mozilla Bug 591199
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="eventdump"></div>
</body>
</html>

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
src="../states.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">

View File

@ -14,11 +14,11 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript">

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
/**

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">

View File

@ -12,13 +12,13 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
src="../role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
src="../states.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
@ -186,7 +186,7 @@
function openWndShutdownDoc()
{
this.__proto__ =
new openDialogWnd("chrome://mochikit/content/a11y/accessible/events/docload_wnd.html");
new openDialogWnd("../events/docload_wnd.html");
var thisObj = this;
var docChecker = {

View File

@ -14,11 +14,11 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
src="../role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
<![CDATA[
@ -26,7 +26,7 @@
function doTest()
{
var w = window.openDialog("chrome://mochikit/content/a11y/accessible/events/docload_wnd.xul",
var w = window.openDialog("../events/docload_wnd.xul",
"docload_test",
"chrome,width=600,height=600");
}

View File

@ -12,12 +12,12 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
src="../attributes.js"></script>
<script type="application/javascript">

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
function openCloseDialog(aID)

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js" />
src="../events.js" />
<script type="application/javascript">
/**

View File

@ -14,9 +14,9 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
src="../events.js"></script>
<script type="application/javascript">
/**

Some files were not shown because too many files have changed in this diff Show More