This commit is contained in:
Ben Turner 2010-06-19 14:21:28 -07:00
Родитель 8fb20a559b b986a922e4
Коммит 4fb0877a0c
1142 изменённых файлов: 120535 добавлений и 23385 удалений

Просмотреть файл

@ -56,7 +56,7 @@ interface nsIDOMCSSPrimitiveValue;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(bd458843-1895-42c6-b7f9-f0ca88eeab6b)]
[scriptable, uuid(ef16ff42-0256-4b48-ae87-b18a95b7f7d6)]
interface nsIAccessNode : nsISupports
{
/**
@ -64,45 +64,6 @@ interface nsIAccessNode : nsISupports
*/
readonly attribute nsIDOMNode DOMNode;
/**
* The number of DOM children for the DOM node, which
* matches the number of nsIAccessNode children for this
* nsIAccessNode.
*/
readonly attribute long numChildren;
/**
* Get the nth child of this node
* @param childNum Zero-based child index
* @return The nth nsIAccessNode child
*/
nsIAccessNode getChildNodeAt(in long childNum);
/**
* The parent nsIAccessNode
*/
readonly attribute nsIAccessNode parentNode;
/**
* The first nsIAccessNode child
*/
readonly attribute nsIAccessNode firstChildNode;
/**
* The last nsIAccessNode child
*/
readonly attribute nsIAccessNode lastChildNode;
/**
* The previous nsIAccessNode sibling
*/
readonly attribute nsIAccessNode previousSiblingNode;
/**
* The next nsIAccessNode sibling
*/
readonly attribute nsIAccessNode nextSiblingNode;
/**
* The document accessible that this access node resides in.
*/

Просмотреть файл

@ -51,10 +51,10 @@ class nsIFrame;
class nsIPresShell;
class nsObjectFrame;
// 9f43b315-53c6-4d46-9818-9c8593e91984
// 10ff6dca-b219-4b64-9a4c-67a62b86edce
#define NS_IACCESSIBILITYSERVICE_IID \
{0x9f43b315, 0x53c6, 0x4d46, \
{0x98, 0x18, 0x9c, 0x85, 0x93, 0xe9, 0x19, 0x84} }
{ 0x10ff6dca, 0xb219, 0x4b64, \
{ 0x9a, 0x4c, 0x67, 0xa6, 0x2b, 0x86, 0xed, 0xce } }
class nsIAccessibilityService : public nsIAccessibleRetrieval
{
@ -166,6 +166,12 @@ public:
*/
virtual void NotifyOfAnchorJumpTo(nsIContent *aTarget) = 0;
/**
* Notify the accessibility service that the given presshell is
* being destroyed.
*/
virtual void PresShellDestroyed(nsIPresShell *aPresShell) = 0;
/**
* Fire accessible event of the given type for the given target.
*

Просмотреть файл

@ -56,7 +56,7 @@ interface nsIDOMDOMStringList;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(3e5cbd5c-dbab-4ea3-b82b-4cd6201d6fe0)]
[scriptable, uuid(420f0f49-27c1-4ac1-b509-5aba4353909b)]
interface nsIAccessibleRetrieval : nsISupports
{
/**
@ -128,6 +128,16 @@ interface nsIAccessibleRetrieval : nsISupports
* @return - accessible relation type presented as human readable string
*/
AString getStringRelationType(in unsigned long aRelationType);
/**
* Return an accessible for the given DOM node from the cache.
* @note the method is intended for testing purposes
*
* @param aNode [in] the DOM node to get an accessible for
*
* @return cached accessible for the given DOM node if any
*/
nsIAccessible getAccessibleFromCache(in nsIDOMNode aNode);
};

Просмотреть файл

@ -44,16 +44,17 @@
*/
/*
* Class nsAccessNodeWrap
*/
////////////////////////////////////////////////////////////////////////////////
// nsAccessNodeWrap
////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsAccessNodeWrap::nsAccessNodeWrap(nsIDOMNode *aNode, nsIWeakReference* aShell):
nsAccessNode(aNode, aShell)
nsAccessNodeWrap::
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessNode(aContent, aShell)
{
}

Просмотреть файл

@ -48,7 +48,7 @@
class nsAccessNodeWrap : public nsAccessNode
{
public: // construction, destruction
nsAccessNodeWrap(nsIDOMNode *aNode, nsIWeakReference* aShell);
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessNodeWrap();
static void InitAccessibility();

Просмотреть файл

@ -270,10 +270,9 @@ PRInt32 nsAccessibleWrap::mAccWrapCreated = 0;
PRInt32 nsAccessibleWrap::mAccWrapDeleted = 0;
#endif
nsAccessibleWrap::nsAccessibleWrap(nsIDOMNode* aNode,
nsIWeakReference *aShell)
: nsAccessible(aNode, aShell),
mAtkObject(nsnull)
nsAccessibleWrap::
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessible(aContent, aShell), mAtkObject(nsnull)
{
#ifdef MAI_LOGGING
++mAccWrapCreated;
@ -307,11 +306,11 @@ void nsAccessibleWrap::ShutdownAtkObject()
}
}
nsresult
void
nsAccessibleWrap::Shutdown()
{
ShutdownAtkObject();
return nsAccessible::Shutdown();
nsAccessible::Shutdown();
}
MaiHyperlink* nsAccessibleWrap::GetMaiHyperlink(PRBool aCreate /* = PR_TRUE */)
@ -562,7 +561,7 @@ GetUniqueMaiAtkTypeName(PRUint16 interfacesBits)
PRBool nsAccessibleWrap::IsValidObject()
{
// to ensure we are not shut down
return (mDOMNode != nsnull);
return !IsDefunct();
}
/* static functions for ATK callbacks */
@ -1109,8 +1108,7 @@ nsAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
nsresult
nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
{
nsCOMPtr<nsIAccessible> accessible;
aEvent->GetAccessible(getter_AddRefs(accessible));
nsAccessible *accessible = aEvent->GetAccessible();
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
PRUint32 type = aEvent->GetEventType();
@ -1157,7 +1155,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_VALUE_CHANGE\n"));
nsCOMPtr<nsIAccessibleValue> value(do_QueryInterface(accessible));
nsCOMPtr<nsIAccessibleValue> value(do_QueryObject(accessible));
if (value) { // Make sure this is a numeric value
// Don't fire for MSAA string value changes (e.g. text editing)
// ATK values are always numeric
@ -1179,13 +1177,12 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_CARET_MOVED\n"));
nsCOMPtr<nsIAccessibleCaretMoveEvent> caretMoveEvent(do_QueryInterface(aEvent));
nsAccCaretMoveEvent *caretMoveEvent = downcast_accEvent(aEvent);
NS_ASSERTION(caretMoveEvent, "Event needs event data");
if (!caretMoveEvent)
break;
PRInt32 caretOffset = -1;
caretMoveEvent->GetCaretOffset(&caretOffset);
PRInt32 caretOffset = caretMoveEvent->GetCaretOffset();
MAI_LOG_DEBUG(("\n\nCaret postion: %d", caretOffset));
g_signal_emit_by_name(atkObj,
@ -1209,12 +1206,11 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_ROW_INSERT:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_INSERT\n"));
nsCOMPtr<nsIAccessibleTableChangeEvent> tableEvent = do_QueryInterface(aEvent);
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 rowIndex, numRows;
tableEvent->GetRowOrColIndex(&rowIndex);
tableEvent->GetNumRowsOrCols(&numRows);
PRInt32 rowIndex = tableEvent->GetIndex();
PRInt32 numRows = tableEvent->GetCount();
g_signal_emit_by_name(atkObj,
"row_inserted",
@ -1227,12 +1223,11 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_ROW_DELETE:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_DELETE\n"));
nsCOMPtr<nsIAccessibleTableChangeEvent> tableEvent = do_QueryInterface(aEvent);
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 rowIndex, numRows;
tableEvent->GetRowOrColIndex(&rowIndex);
tableEvent->GetNumRowsOrCols(&numRows);
PRInt32 rowIndex = tableEvent->GetIndex();
PRInt32 numRows = tableEvent->GetCount();
g_signal_emit_by_name(atkObj,
"row_deleted",
@ -1252,12 +1247,11 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_INSERT:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_INSERT\n"));
nsCOMPtr<nsIAccessibleTableChangeEvent> tableEvent = do_QueryInterface(aEvent);
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 colIndex, numCols;
tableEvent->GetRowOrColIndex(&colIndex);
tableEvent->GetNumRowsOrCols(&numCols);
PRInt32 colIndex = tableEvent->GetIndex();
PRInt32 numCols = tableEvent->GetCount();
g_signal_emit_by_name(atkObj,
"column_inserted",
@ -1270,12 +1264,11 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_DELETE:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_DELETE\n"));
nsCOMPtr<nsIAccessibleTableChangeEvent> tableEvent = do_QueryInterface(aEvent);
nsAccTableChangeEvent *tableEvent = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
PRInt32 colIndex, numCols;
tableEvent->GetRowOrColIndex(&colIndex);
tableEvent->GetNumRowsOrCols(&numCols);
PRInt32 colIndex = tableEvent->GetIndex();
PRInt32 numCols = tableEvent->GetCount();
g_signal_emit_by_name(atkObj,
"column_deleted",
@ -1319,7 +1312,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_ACTIVATED\n"));
nsRootAccessible *rootAcc =
static_cast<nsRootAccessible *>(accessible.get());
static_cast<nsRootAccessible *>(accessible);
rootAcc->mActivated = PR_TRUE;
guint id = g_signal_lookup ("activate", MAI_TYPE_ATK_OBJECT);
g_signal_emit(atkObj, id, 0);
@ -1332,7 +1325,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_DEACTIVATED\n"));
nsRootAccessible *rootAcc =
static_cast<nsRootAccessible *>(accessible.get());
static_cast<nsRootAccessible *>(accessible);
rootAcc->mActivated = PR_FALSE;
guint id = g_signal_lookup ("deactivate", MAI_TYPE_ATK_OBJECT);
g_signal_emit(atkObj, id, 0);
@ -1379,18 +1372,12 @@ nsAccessibleWrap::FireAtkStateChangeEvent(nsAccEvent *aEvent,
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_STATE_CHANGE\n"));
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
do_QueryInterface(aEvent);
nsAccStateChangeEvent *event = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
PRUint32 state = 0;
event->GetState(&state);
PRBool isExtra;
event->IsExtraState(&isExtra);
PRBool isEnabled;
event->IsEnabled(&isEnabled);
PRUint32 state = event->GetState();
PRBool isExtra = event->IsExtraState();
PRBool isEnabled = event->IsStateEnabled();
PRInt32 stateIndex = AtkStateMap::GetStateIndexFor(state);
if (stateIndex >= 0) {
@ -1421,18 +1408,12 @@ nsAccessibleWrap::FireAtkTextChangedEvent(nsAccEvent *aEvent,
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_REMOVED/INSERTED\n"));
nsCOMPtr<nsIAccessibleTextChangeEvent> event =
do_QueryInterface(aEvent);
nsAccTextChangeEvent *event = downcast_accEvent(aEvent);
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
PRInt32 start = 0;
event->GetStart(&start);
PRUint32 length = 0;
event->GetLength(&length);
PRBool isInserted;
event->IsInserted(&isInserted);
PRInt32 start = event->GetStartOffset();
PRUint32 length = event->GetLength();
PRBool isInserted = event->IsTextInserted();
PRBool isFromUserInput = aEvent->IsFromUserInput();

Просмотреть файл

@ -85,12 +85,12 @@ class MaiHyperlink;
class nsAccessibleWrap: public nsAccessible
{
public:
nsAccessibleWrap(nsIDOMNode*, nsIWeakReference *aShell);
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessibleWrap();
void ShutdownAtkObject();
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
#ifdef MAI_LOGGING
virtual void DumpnsAccessibleWrapInfo(int aDepth) {}

Просмотреть файл

@ -532,7 +532,7 @@ nsApplicationAccessibleWrap::~nsApplicationAccessibleWrap()
nsAccessibleWrap::ShutdownAtkObject();
}
nsresult
PRBool
nsApplicationAccessibleWrap::Init()
{
// XXX following code is copied from widget/src/gtk2/nsWindow.cpp

Просмотреть файл

@ -55,7 +55,7 @@ public:
virtual ~nsApplicationAccessibleWrap();
// nsAccessNode
virtual nsresult Init();
virtual PRBool Init();
// return the atk object for app root accessible
NS_IMETHOD GetNativeInterface(void **aOutAccessible);

Просмотреть файл

@ -43,11 +43,14 @@
#include "nsMai.h"
#include "nsDocAccessibleWrap.h"
//----- nsDocAccessibleWrap -----
////////////////////////////////////////////////////////////////////////////////
// nsDocAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsDocAccessibleWrap::nsDocAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell):
nsDocAccessible(aDOMNode, aShell), mActivated(PR_FALSE)
nsDocAccessibleWrap::
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsDocAccessible(aDocument, aRootContent, aShell), mActivated(PR_FALSE)
{
}

Просмотреть файл

@ -51,7 +51,8 @@
class nsDocAccessibleWrap: public nsDocAccessible
{
public:
nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
PRBool mActivated;

Просмотреть файл

@ -78,9 +78,8 @@ refAccessibleAtPointCB(AtkComponent *aComponent,
// nsIAccessible getChildAtPoint (x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsCOMPtr<nsIDOMNode> domNode;
accWrap->GetDOMNode(getter_AddRefs(domNode));
nsIntPoint winCoords = nsCoreUtils::GetScreenCoordsForWindow(domNode);
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
aAccX += winCoords.x;
aAccY += winCoords.y;
}
@ -119,9 +118,8 @@ getExtentsCB(AtkComponent *aComponent,
if (NS_FAILED(rv))
return;
if (aCoordType == ATK_XY_WINDOW) {
nsCOMPtr<nsIDOMNode> domNode;
accWrap->GetDOMNode(getter_AddRefs(domNode));
nsIntPoint winCoords = nsCoreUtils::GetScreenCoordsForWindow(domNode);
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
nsAccX -= winCoords.x;
nsAccY -= winCoords.y;
}

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsRootAccessibleWrap.h"
nsNativeRootAccessibleWrap::nsNativeRootAccessibleWrap(AtkObject *aAccessible):
nsRootAccessible(nsnull, nsnull)
nsRootAccessible(nsnull, nsnull, nsnull)
{
g_object_ref(aAccessible);
mAtkObject = aAccessible;

Просмотреть файл

@ -51,9 +51,9 @@
////////////////////////////////////////////////////////////////////////////////
// Constructor
nsARIAGridAccessible::nsARIAGridAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell) :
nsAccessibleWrap(aDomNode, aShell)
nsARIAGridAccessible::
nsARIAGridAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
@ -458,18 +458,18 @@ nsARIAGridAccessible::GetSelectedCells(nsIArray **aCells)
nsAccessible *row = nsnull;
while (row = rowIter.GetNext()) {
nsAccIterator cellIter(row, nsAccIterator::GetCell);
nsIAccessible *cell = nsnull;
nsAccessible *cell = nsnull;
if (nsAccUtils::IsARIASelected(row)) {
while (cell = cellIter.GetNext())
selCells->AppendElement(cell, PR_FALSE);
selCells->AppendElement(static_cast<nsIAccessible *>(cell), PR_FALSE);
continue;
}
while (cell = cellIter.GetNext()) {
if (nsAccUtils::IsARIASelected(cell))
selCells->AppendElement(cell, PR_FALSE);
selCells->AppendElement(static_cast<nsIAccessible *>(cell), PR_FALSE);
}
}
@ -756,7 +756,7 @@ nsresult
nsARIAGridAccessible::SetARIASelected(nsAccessible *aAccessible,
PRBool aIsSelected, PRBool aNotify)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aAccessible->GetDOMNode()));
nsIContent *content = aAccessible->GetContent();
NS_ENSURE_STATE(content);
nsresult rv = NS_OK;
@ -897,9 +897,9 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *acolumnCount,
////////////////////////////////////////////////////////////////////////////////
// Constructor
nsARIAGridCellAccessible::nsARIAGridCellAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell) :
nsHyperTextAccessibleWrap(aDomNode, aShell)
nsARIAGridCellAccessible::
nsARIAGridCellAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
@ -1058,8 +1058,7 @@ nsARIAGridCellAccessible::IsSelected(PRBool *aIsSelected)
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row;
GetParent(getter_AddRefs(row));
nsAccessible *row = GetParent();
if (nsAccUtils::Role(row) != nsIAccessibleRole::ROLE_ROW)
return NS_OK;
@ -1084,17 +1083,11 @@ nsARIAGridCellAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
return NS_OK;
// Check aria-selected="true" on the row.
nsCOMPtr<nsIAccessible> row;
GetParent(getter_AddRefs(row));
nsAccessible *row = GetParent();
if (nsAccUtils::Role(row) != nsIAccessibleRole::ROLE_ROW)
return NS_OK;
nsRefPtr<nsAccessible> acc = do_QueryObject(row);
nsCOMPtr<nsIDOMNode> rowNode;
acc->GetDOMNode(getter_AddRefs(rowNode));
NS_ENSURE_STATE(rowNode);
nsCOMPtr<nsIContent> rowContent(do_QueryInterface(rowNode));
nsIContent *rowContent = row->GetContent();
if (nsAccUtils::HasDefinedARIAToken(rowContent,
nsAccessibilityAtoms::aria_selected) &&
!rowContent->AttrValueIs(kNameSpaceID_None,

Просмотреть файл

@ -50,7 +50,7 @@ class nsARIAGridAccessible : public nsAccessibleWrap,
public nsIAccessibleTable
{
public:
nsARIAGridAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsARIAGridAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -110,7 +110,7 @@ class nsARIAGridCellAccessible : public nsHyperTextAccessibleWrap,
public nsIAccessibleTableCell
{
public:
nsARIAGridCellAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsARIAGridCellAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsRefPtrHashtable.h"
#include "nsCycleCollectionParticipant.h"
class nsIAccessNode;
class nsIAccessible;
////////////////////////////////////////////////////////////////////////////////
// Accessible cache utils
@ -53,11 +53,11 @@ class nsIAccessNode;
*/
template <class T>
static PLDHashOperator
ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessNode, void* aUserArg)
ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessible, void* aUserArg)
{
NS_ASSERTION(aAccessNode, "Calling ClearCacheEntry with a NULL pointer!");
if (aAccessNode)
aAccessNode->Shutdown();
NS_ASSERTION(aAccessible, "Calling ClearCacheEntry with a NULL pointer!");
if (aAccessible)
aAccessible->Shutdown();
return PL_DHASH_REMOVE;
}
@ -77,7 +77,7 @@ ClearCache(nsRefPtrHashtable<nsVoidPtrHashKey, T> & aCache)
*/
template <class T>
static PLDHashOperator
CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessNode,
CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
void *aUserArg)
{
nsCycleCollectionTraversalCallback *cb =
@ -85,7 +85,7 @@ CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessNode,
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "accessible cache entry");
nsISupports *supports = static_cast<nsIAccessNode*>(aAccessNode);
nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
cb->NoteXPCOMChild(supports);
return PL_DHASH_NEXT;
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- 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
*
@ -95,6 +96,7 @@ nsAccDocManager::ShutdownDocAccessiblesInTree(nsIDocument *aDocument)
ShutdownDocAccessiblesInTree(treeItem, aDocument);
}
////////////////////////////////////////////////////////////////////////////////
// nsAccDocManager protected
@ -127,6 +129,22 @@ nsAccDocManager::Shutdown()
ClearDocCache();
}
void
nsAccDocManager::ShutdownDocAccessible(nsIDocument *aDocument)
{
nsDocAccessible* docAccessible =
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument));
if (!docAccessible)
return;
// We're allowed to not remove listeners when accessible document is shutdown
// since we don't keep strong reference on chrome event target and listeners
// are removed automatically when chrome event target goes away.
docAccessible->Shutdown();
mDocAccessibleCache.Remove(static_cast<void*>(aDocument));
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
@ -202,8 +220,6 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress,
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDOMNode> DOMNode = do_QueryInterface(document);
// Fire reload and state busy events on existing document accessible while
// event from user input flag can be calculated properly and accessible
// is alive. When new document gets loaded then this one is destroyed.
@ -223,7 +239,7 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress,
// 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(DOMNode, nsIAccessibleStates::STATE_BUSY,
new nsAccStateChangeEvent(document, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_TRUE);
docAcc->FireDelayedAccessibleEvent(stateEvent);
@ -357,15 +373,14 @@ nsAccDocManager::HandleDOMDocumentLoad(nsIDocument *aDocument,
}
// Fire complete/load stopped if the load event type is given.
nsCOMPtr<nsIDOMNode> DOMNode = do_QueryInterface(aDocument);
if (aLoadEventType) {
nsRefPtr<nsAccEvent> loadEvent = new nsAccEvent(aLoadEventType, DOMNode);
nsRefPtr<nsAccEvent> loadEvent = new nsAccEvent(aLoadEventType, aDocument);
docAcc->FireDelayedAccessibleEvent(loadEvent);
}
// Fire busy state change event.
nsRefPtr<nsAccEvent> stateEvent =
new nsAccStateChangeEvent(DOMNode, nsIAccessibleStates::STATE_BUSY,
new nsAccStateChangeEvent(aDocument, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_FALSE);
docAcc->FireDelayedAccessibleEvent(stateEvent);
}
@ -415,35 +430,12 @@ nsAccDocManager::AddListeners(nsIDocument *aDocument,
}
}
void
nsAccDocManager::RemoveListeners(nsIDocument *aDocument)
{
// Document has no window when application shuts down. The document can still
// exist because we didn't receive a "pagehide" event.
nsPIDOMWindow *window = aDocument->GetWindow();
if (!window)
return;
nsPIDOMEventTarget *target = window->GetChromeEventHandler();
nsIEventListenerManager* elm = target->GetListenerManager(PR_TRUE);
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
NS_EVENT_FLAG_CAPTURE, nsnull);
NS_LOG_ACCDOCDESTROY("removed 'pagehide' listener", aDocument)
if (nsCoreUtils::IsRootDocument(aDocument)) {
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
NS_EVENT_FLAG_CAPTURE, nsnull);
NS_LOG_ACCDOCDESTROY("removed 'DOMContentLoaded' listener", aDocument)
}
}
nsDocAccessible*
nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
{
// Ignore temporary and hiding documents.
if (aDocument->IsInitialDocument() || !aDocument->IsVisible())
// Ignore temporary, hiding and svg resource documents.
if (aDocument->IsInitialDocument() || !aDocument->IsVisible() ||
aDocument->GetDisplayDocument())
return nsnull;
// Ignore documents without presshell.
@ -453,9 +445,9 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
// Do not create document accessible until role content is loaded, otherwise
// we get accessible document with wrong role.
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(aDocument));
if (!nsCoreUtils::GetRoleContent(DOMNode))
return NS_OK;
nsIContent *rootElm = nsCoreUtils::GetRoleContent(aDocument);
if (!rootElm)
return nsnull;
PRBool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);
@ -468,8 +460,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
return nsnull;
nsIContent* ownerContent = parentDoc->FindContentForSubDocument(aDocument);
nsCOMPtr<nsIDOMNode> ownerNode(do_QueryInterface(ownerContent));
if (!ownerNode)
if (!ownerContent)
return nsnull;
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
@ -477,7 +468,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
// GetAccessible() is bad because it doesn't support our concept of multiple
// presshells per doc. It should be changed to use
// GetAccessibleInWeakShell().
outerDocAcc = GetAccService()->GetAccessible(ownerNode);
outerDocAcc = GetAccService()->GetAccessible(ownerContent);
if (!outerDocAcc)
return nsnull;
}
@ -487,8 +478,8 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
// We only create root accessibles for the true root, otherwise create a
// doc accessible.
nsDocAccessible *docAcc = isRootDoc ?
new nsRootAccessibleWrap(DOMNode, weakShell) :
new nsDocAccessibleWrap(DOMNode, weakShell);
new nsRootAccessibleWrap(aDocument, rootElm, weakShell) :
new nsDocAccessibleWrap(aDocument, rootElm, weakShell);
if (!docAcc)
return nsnull;
@ -504,17 +495,16 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
if (outerDocAcc) {
// Root document accessible doesn't have associated outerdoc accessible, it
// adds itself to application accessible instead.
NS_LOG_ACCDOCCREATE("append document to outerdoc", aDocument)
outerDocAcc->AppendChild(docAcc);
}
if (!GetAccService()->InitAccessible(docAcc,
nsAccUtils::GetRoleMapEntry(DOMNode))) {
nsAccUtils::GetRoleMapEntry(aDocument))) {
mDocAccessibleCache.Remove(static_cast<void*>(aDocument));
return nsnull;
}
NS_LOG_ACCDOCCREATE("document created", aDocument)
NS_LOG_ACCDOCCREATE("document creation finished", aDocument)
AddListeners(aDocument, isRootDoc);
return docAcc;
@ -525,43 +515,30 @@ nsAccDocManager::ShutdownDocAccessiblesInTree(nsIDocShellTreeItem *aTreeItem,
nsIDocument *aDocument)
{
nsCOMPtr<nsIDocShellTreeNode> treeNode(do_QueryInterface(aTreeItem));
if (!treeNode)
return;
PRInt32 subDocumentsCount = 0;
treeNode->GetChildCount(&subDocumentsCount);
for (PRInt32 idx = 0; idx < subDocumentsCount; idx++) {
nsCOMPtr<nsIDocShellTreeItem> treeItemChild;
treeNode->GetChildAt(idx, getter_AddRefs(treeItemChild));
NS_ASSERTION(treeItemChild, "No tree item when there should be");
if (!treeItemChild)
continue;
if (treeNode) {
PRInt32 subDocumentsCount = 0;
treeNode->GetChildCount(&subDocumentsCount);
for (PRInt32 idx = 0; idx < subDocumentsCount; idx++) {
nsCOMPtr<nsIDocShellTreeItem> treeItemChild;
treeNode->GetChildAt(idx, getter_AddRefs(treeItemChild));
NS_ASSERTION(treeItemChild, "No tree item when there should be");
if (!treeItemChild)
continue;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(treeItemChild));
nsCOMPtr<nsIContentViewer> contentViewer;
docShell->GetContentViewer(getter_AddRefs(contentViewer));
if (!contentViewer)
continue;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(treeItemChild));
nsCOMPtr<nsIContentViewer> contentViewer;
docShell->GetContentViewer(getter_AddRefs(contentViewer));
if (!contentViewer)
continue;
ShutdownDocAccessiblesInTree(treeItemChild, contentViewer->GetDocument());
ShutdownDocAccessiblesInTree(treeItemChild, contentViewer->GetDocument());
}
}
ShutdownDocAccessible(aDocument);
}
void
nsAccDocManager::ShutdownDocAccessible(nsIDocument *aDocument)
{
RemoveListeners(aDocument);
nsDocAccessible *docAccessible =
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument));
if (docAccessible)
docAccessible->Shutdown();
mDocAccessibleCache.Remove(static_cast<void*>(aDocument));
}
////////////////////////////////////////////////////////////////////////////////
// nsAccDocManager static
@ -575,14 +552,8 @@ nsAccDocManager::ClearDocCacheEntry(const void* aKey,
NS_ASSERTION(aDocAccessible,
"Calling ClearDocCacheEntry with a NULL pointer!");
if (aDocAccessible) {
nsCOMPtr<nsIDocument> document = aDocAccessible->GetDOMDocument();
NS_ASSERTION(document, "Document accessible was shutdown already!");
if (document)
accDocMgr->RemoveListeners(document);
if (aDocAccessible)
aDocAccessible->Shutdown();
}
return PL_DHASH_REMOVE;
}
@ -598,12 +569,9 @@ nsAccDocManager::SearchAccessibleInDocCache(const void* aKey,
if (aDocAccessible) {
nsSearchAccessibleInCacheArg* arg =
static_cast<nsSearchAccessibleInCacheArg*>(aUserArg);
nsAccessNode* accessNode =
aDocAccessible->GetCachedAccessNode(arg->mUniqueID);
if (accessNode) {
arg->mAccessible = do_QueryObject(accessNode);
arg->mAccessible = aDocAccessible->GetCachedAccessible(arg->mUniqueID);
if (arg->mAccessible)
return PL_DHASH_STOP;
}
}
return PL_DHASH_NEXT;

Просмотреть файл

@ -48,6 +48,8 @@
class nsDocAccessible;
//#define DEBUG_ACCDOCMGR
/**
* Manage the document accessible life cycle.
*/
@ -80,6 +82,14 @@ public:
*/
void ShutdownDocAccessiblesInTree(nsIDocument *aDocument);
/**
* Return document accessible from the cache. Convenient method for testing.
*/
inline nsDocAccessible* GetDocAccessibleFromCache(nsIDocument* aDocument) const
{
return mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument));
}
protected:
nsAccDocManager() { };
@ -93,6 +103,11 @@ protected:
*/
void Shutdown();
/**
* Shutdown the document accessible.
*/
void ShutdownDocAccessible(nsIDocument* aDocument);
private:
nsAccDocManager(const nsAccDocManager&);
nsAccDocManager& operator =(const nsAccDocManager&);
@ -132,10 +147,9 @@ private:
PRBool IsEventTargetDocument(nsIDocument *aDocument) const;
/**
* Add/remove 'pagehide' and 'DOMContentLoaded' event listeners.
* Add 'pagehide' and 'DOMContentLoaded' event listeners.
*/
void AddListeners(nsIDocument *aDocument, PRBool aAddPageShowListener);
void RemoveListeners(nsIDocument *aDocument);
/**
* Create document or root accessible.
@ -148,11 +162,6 @@ private:
void ShutdownDocAccessiblesInTree(nsIDocShellTreeItem *aTreeItem,
nsIDocument *aDocument);
/**
* Shutdown the document accessible.
*/
void ShutdownDocAccessible(nsIDocument *aDocument);
typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsDocAccessible>
nsDocAccessibleHashtable;
@ -174,7 +183,7 @@ private:
struct nsSearchAccessibleInCacheArg
{
nsRefPtr<nsAccessible> mAccessible;
nsAccessible *mAccessible;
void *mUniqueID;
};
@ -189,8 +198,6 @@ private:
/**
* nsAccDocManager debugging macros.
*/
//#define DEBUG_ACCDOCMGR
#ifdef DEBUG_ACCDOCMGR
// Enable these to log accessible document loading, creation or destruction.
@ -200,9 +207,7 @@ private:
// Common macros, do not use directly.
#define NS_LOG_ACCDOC_ADDRESS(aDocument, aDocAcc) \
printf("DOM id: 0x%x, acc id: 0x%x", \
reinterpret_cast<PRInt32>(static_cast<void*>(aDocument)), \
reinterpret_cast<PRInt32>(aDocAcc));
printf("DOM id: %p, acc id: %p", aDocument, aDocAcc);
#define NS_LOG_ACCDOC_URI(aDocument) \
nsIURI *uri = aDocument->GetDocumentURI(); \
@ -255,19 +260,18 @@ private:
#define NS_LOG_ACCDOC_DOCPRESSHELL(aDocument) \
nsIPresShell *ps = aDocument->GetPrimaryShell(); \
printf("presshell: 0x%x", reinterpret_cast<PRInt32>(ps)); \
printf("presshell: %p", ps); \
nsIScrollableFrame *sf = ps ? \
ps->GetRootScrollFrameAsScrollableExternal() : nsnull; \
printf(", root scroll frame: 0x%x", reinterpret_cast<PRInt32>(sf));
printf(", root scroll frame: %p", sf);
#define NS_LOG_ACCDOC_DOCLOADGROUP(aDocument) \
nsCOMPtr<nsILoadGroup> loadGroup = aDocument->GetDocumentLoadGroup(); \
printf("load group: 0x%x", reinterpret_cast<PRInt32>(loadGroup.get()));
printf("load group: %p", loadGroup);
#define NS_LOG_ACCDOC_DOCPARENT(aDocument) \
nsIDocument *parentDoc = aDocument->GetParentDocument(); \
printf("parent id: 0x%x", \
reinterpret_cast<PRInt32>(parentDoc)); \
printf("parent id: %p", parentDoc); \
if (parentDoc) { \
printf("\n parent "); \
NS_LOG_ACCDOC_URI(parentDoc) \
@ -382,20 +386,31 @@ private:
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD) { \
strEventType.AssignLiteral("reload"); \
} else if (type == nsIAccessibleEvent::EVENT_STATE_CHANGE) { \
nsCOMPtr<nsIAccessibleStateChangeEvent> event(do_QueryObject(aEvent)); \
PRUint32 state = 0; \
event->GetState(&state); \
if (state == nsIAccessibleStates::STATE_BUSY) { \
PRBool isEnabled; \
event->IsEnabled(&isEnabled); \
nsAccStateChangeEvent *event = downcast_accEvent(aEvent); \
if (event->GetState() == nsIAccessibleStates::STATE_BUSY) { \
strEventType.AssignLiteral("busy "); \
if (isEnabled) \
if (event->IsStateEnabled()) \
strEventType.AppendLiteral("true"); \
else \
strEventType.AppendLiteral("false"); \
} \
}
#define NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc) \
{ \
nsINode* node = aAcc->GetNode(); \
nsIDocument* doc = aAcc->GetDocumentNode(); \
nsDocAccessible *docacc = GetAccService()->GetDocAccessibleFromCache(doc); \
printf(" " aName " accessible: %p, node: %p\n", aAcc, node); \
printf(" docacc for " aName " accessible: %p, node: %p\n", docacc, doc); \
printf(" "); \
NS_LOG_ACCDOC_URI(doc) \
printf("\n"); \
}
#define NS_LOG_ACCDOC_MSG(aMsg) \
printf("\n" aMsg "\n"); \
#define NS_LOG_ACCDOC_TEXT(aMsg) \
printf(" " aMsg "\n");
@ -430,7 +445,7 @@ private:
#define NS_LOG_ACCDOCLOAD(aMsg, aWebProgress, aRequest, aStateFlags) \
{ \
printf("\nA11Y DOCLOAD: " aMsg "\n"); \
NS_LOG_ACCDOC_MSG("A11Y DOCLOAD: " aMsg); \
\
nsCOMPtr<nsIDOMWindow> DOMWindow; \
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow)); \
@ -440,7 +455,7 @@ private:
if (DOMDocument) { \
nsCOMPtr<nsIDocument> document(do_QueryInterface(DOMDocument)); \
nsDocAccessible *docAcc = \
mDocAccessibleCache.GetWeak(static_cast<void*>(document)); \
GetAccService()->GetDocAccessibleFromCache(document); \
NS_LOG_ACCDOC_DOCINFO(document, docAcc) \
\
printf(" {\n"); \
@ -462,9 +477,9 @@ private:
#define NS_LOG_ACCDOCLOAD2(aMsg, aDocument) \
{ \
printf("\nA11Y DOCLOAD: " aMsg "\n"); \
NS_LOG_ACCDOC_MSG("A11Y DOCLOAD: " aMsg); \
nsDocAccessible *docAcc = \
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument)); \
GetAccService()->GetDocAccessibleFromCache(aDocument); \
NS_LOG_ACCDOC_DOCINFO(aDocument, docAcc) \
}
@ -495,16 +510,19 @@ private:
// Accessible document creation macros.
#ifdef DEBUG_ACCDOCMGR_DOCCREATE
#define NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, aDocAcc) \
printf("\nA11Y DOCCREATE: " aMsg "\n"); \
NS_LOG_ACCDOC_MSG("A11Y DOCCREATE: " aMsg); \
NS_LOG_ACCDOC_DOCINFO(aDocument, aDocAcc)
#define NS_LOG_ACCDOCCREATE(aMsg, aDocument) \
{ \
nsDocAccessible *docAcc = \
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument)); \
GetAccService()->GetDocAccessibleFromCache(aDocument); \
NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, docAcc) \
}
#define NS_LOG_ACCDOCCREATE_ACCADDRESS(aName, aAcc) \
NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc)
#define NS_LOG_ACCDOCCREATE_TEXT(aMsg) \
NS_LOG_ACCDOC_TEXT(aMsg)
@ -513,16 +531,24 @@ private:
// Accessible document destruction macros.
#ifdef DEBUG_ACCDOCMGR_DOCDESTROY
#define NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, aDocAcc) \
printf("\nA11Y DOCDESTROY: " aMsg "\n"); \
NS_LOG_ACCDOC_MSG("A11Y DOCDESTROY: " aMsg); \
NS_LOG_ACCDOC_DOCINFO(aDocument, aDocAcc)
#define NS_LOG_ACCDOCDESTROY(aMsg, aDocument) \
nsDocAccessible *docAcc = \
mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument)); \
NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, docAcc)
{ \
nsDocAccessible* docAcc = \
GetAccService()->GetDocAccessibleFromCache(aDocument); \
NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, docAcc) \
}
#define NS_LOG_ACCDOCDESTROY_TEXT(aMsg) \
NS_LOG_ACCDOC_TEXT(aMsg)
#define NS_LOG_ACCDOCDESTROY_ACCADDRESS(aName, aAcc) \
NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc)
#define NS_LOG_ACCDOCDESTROY_MSG(aMsg) \
NS_LOG_ACCDOC_MSG(aMsg)
#define NS_LOG_ACCDOCDESTROY_TEXT(aMsg) \
NS_LOG_ACCDOC_TEXT(aMsg)
#endif // DEBUG_ACCDOCMGR_DOCDESTROY
@ -540,12 +566,15 @@ private:
#ifndef DEBUG_ACCDOCMGR_DOCCREATE
#define NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, aDocAcc)
#define NS_LOG_ACCDOCCREATE(aMsg, aDocument)
#define NS_LOG_ACCDOCCREATE_ACCADDRESS(aName, aAcc)
#define NS_LOG_ACCDOCCREATE_TEXT(aMsg)
#endif
#ifndef DEBUG_ACCDOCMGR_DOCDESTROY
#define NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, aDocAcc)
#define NS_LOG_ACCDOCDESTROY(aMsg, aDocument)
#define NS_LOG_ACCDOCDESTROY_MSG(aMsg)
#define NS_LOG_ACCDOCDESTROY_ACCADDRESS(aName, aAcc)
#define NS_LOG_ACCDOCDESTROY_TEXT(aMsg)
#endif

Просмотреть файл

@ -49,14 +49,10 @@
#include "nsIDOMDocument.h"
#include "nsIEventStateManager.h"
#include "nsIPersistentProperties2.h"
#include "nsIServiceManager.h"
#ifdef MOZ_XUL
#include "nsIDOMXULMultSelectCntrlEl.h"
#endif
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent
@ -65,11 +61,17 @@
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent. nsISupports
NS_IMPL_CYCLE_COLLECTION_1(nsAccEvent, mAccessible)
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(nsAccEvent)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
@ -79,7 +81,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAccEvent)
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent. Constructors
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
@ -88,11 +90,11 @@ nsAccEvent::nsAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
CaptureIsFromUserInput(aIsFromUserInput);
}
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsIDOMNode *aDOMNode,
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsINode *aNode,
PRBool aIsAsync, EIsFromUserInput aIsFromUserInput,
EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
mNode(do_QueryInterface(aDOMNode))
mNode(aNode)
{
CaptureIsFromUserInput(aIsFromUserInput);
}
@ -127,10 +129,7 @@ nsAccEvent::GetAccessible(nsIAccessible **aAccessible)
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
if (!mAccessible)
mAccessible = GetAccessibleByNode();
NS_IF_ADDREF(*aAccessible = mAccessible);
NS_IF_ADDREF(*aAccessible = GetAccessible());
return NS_OK;
}
@ -161,19 +160,20 @@ nsAccEvent::GetAccessibleDocument(nsIAccessibleDocument **aDocAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent: public methods
nsAccessible *
nsAccEvent::GetAccessible()
{
if (!mAccessible)
mAccessible = GetAccessibleForNode();
return mAccessible;
}
nsINode*
nsAccEvent::GetNode()
{
if (!mNode) {
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(mAccessible));
if (!accessNode)
return nsnull;
nsCOMPtr<nsIDOMNode> DOMNode;
accessNode->GetDOMNode(getter_AddRefs(DOMNode));
mNode = do_QueryInterface(DOMNode);
}
if (!mNode && mAccessible)
mNode = mAccessible->GetNode();
return mNode;
}
@ -191,16 +191,13 @@ nsAccEvent::GetDocAccessible()
////////////////////////////////////////////////////////////////////////////////
// nsAccEvent: protected methods
already_AddRefed<nsIAccessible>
nsAccEvent::GetAccessibleByNode()
nsAccessible *
nsAccEvent::GetAccessibleForNode() const
{
if (!mNode)
return nsnull;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mNode));
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(DOMNode, getter_AddRefs(accessible));
nsAccessible *accessible = GetAccService()->GetAccessible(mNode);
#ifdef MOZ_XUL
// hack for xul tree table. We need a better way for firing delayed event
@ -220,20 +217,19 @@ nsAccEvent::GetAccessibleByNode()
if (treeIndex >= 0) {
nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(accessible);
if (treeAcc)
accessible = treeAcc->GetTreeItemAccessible(treeIndex);
return treeAcc->GetTreeItemAccessible(treeIndex);
}
}
}
#endif
return accessible.forget();
return accessible;
}
void
nsAccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
{
nsCOMPtr<nsIDOMNode> targetNode;
GetDOMNode(getter_AddRefs(targetNode));
nsINode *targetNode = GetNode();
#ifdef DEBUG
if (!targetNode) {
@ -276,13 +272,12 @@ nsAccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
// nsAccReorderEvent
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(nsAccReorderEvent, nsAccEvent,
nsAccReorderEvent)
NS_IMPL_ISUPPORTS_INHERITED0(nsAccReorderEvent, nsAccEvent)
nsAccReorderEvent::nsAccReorderEvent(nsIAccessible *aAccTarget,
nsAccReorderEvent::nsAccReorderEvent(nsAccessible *aAccTarget,
PRBool aIsAsynch,
PRBool aIsUnconditional,
nsIDOMNode *aReasonNode) :
nsINode *aReasonNode) :
nsAccEvent(::nsIAccessibleEvent::EVENT_REORDER, aAccTarget,
aIsAsynch, eAutoDetect, nsAccEvent::eCoalesceFromSameSubtree),
mUnconditionalEvent(aIsUnconditional), mReasonNode(aReasonNode)
@ -301,9 +296,7 @@ nsAccReorderEvent::HasAccessibleInReasonSubtree()
if (!mReasonNode)
return PR_FALSE;
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(mReasonNode, getter_AddRefs(accessible));
nsAccessible *accessible = GetAccService()->GetAccessible(mReasonNode);
return accessible || nsAccUtils::HasAccessibleChildren(mReasonNode);
}
@ -318,7 +311,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccStateChangeEvent, nsAccEvent,
// 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(nsIAccessible *aAccessible,
nsAccStateChangeEvent(nsAccessible *aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch,
EIsFromUserInput aIsFromUserInput):
@ -329,8 +322,7 @@ nsAccStateChangeEvent::
}
nsAccStateChangeEvent::
nsAccStateChangeEvent(nsIDOMNode *aNode,
PRUint32 aState, PRBool aIsExtraState,
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled):
nsAccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
mState(aState), mIsExtraState(aIsExtraState), mIsEnabled(aIsEnabled)
@ -338,15 +330,14 @@ nsAccStateChangeEvent::
}
nsAccStateChangeEvent::
nsAccStateChangeEvent(nsIDOMNode *aNode,
PRUint32 aState, PRBool aIsExtraState):
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState) :
nsAccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
mState(aState), mIsExtraState(aIsExtraState)
{
// Use GetAccessibleByNode() because we do not want to store an accessible
// Use GetAccessibleForNode() because we do not want to store an accessible
// since it leads to problems with delayed events in the case when
// an accessible gets reorder event before delayed event is processed.
nsCOMPtr<nsIAccessible> accessible(GetAccessibleByNode());
nsAccessible *accessible = GetAccessibleForNode();
if (accessible) {
PRUint32 state = 0, extraState = 0;
accessible->GetState(&state, mIsExtraState ? &extraState : nsnull);
@ -359,6 +350,7 @@ nsAccStateChangeEvent::
NS_IMETHODIMP
nsAccStateChangeEvent::GetState(PRUint32 *aState)
{
NS_ENSURE_ARG_POINTER(aState);
*aState = mState;
return NS_OK;
}
@ -366,6 +358,7 @@ nsAccStateChangeEvent::GetState(PRUint32 *aState)
NS_IMETHODIMP
nsAccStateChangeEvent::IsExtraState(PRBool *aIsExtraState)
{
NS_ENSURE_ARG_POINTER(aIsExtraState);
*aIsExtraState = mIsExtraState;
return NS_OK;
}
@ -373,6 +366,7 @@ nsAccStateChangeEvent::IsExtraState(PRBool *aIsExtraState)
NS_IMETHODIMP
nsAccStateChangeEvent::IsEnabled(PRBool *aIsEnabled)
{
NS_ENSURE_ARG_POINTER(aIsEnabled);
*aIsEnabled = mIsEnabled;
return NS_OK;
}
@ -393,7 +387,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccTextChangeEvent, nsAccEvent,
// a defunct accessible so the behaviour should be equivalent.
// XXX revisit this when coalescence is faster (eCoalesceFromSameSubtree)
nsAccTextChangeEvent::
nsAccTextChangeEvent(nsIAccessible *aAccessible,
nsAccTextChangeEvent(nsAccessible *aAccessible,
PRInt32 aStart, PRUint32 aLength,
nsAString& aModifiedText, PRBool aIsInserted,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput) :
@ -407,6 +401,7 @@ nsAccTextChangeEvent::
NS_IMETHODIMP
nsAccTextChangeEvent::GetStart(PRInt32 *aStart)
{
NS_ENSURE_ARG_POINTER(aStart);
*aStart = mStart;
return NS_OK;
}
@ -414,6 +409,7 @@ nsAccTextChangeEvent::GetStart(PRInt32 *aStart)
NS_IMETHODIMP
nsAccTextChangeEvent::GetLength(PRUint32 *aLength)
{
NS_ENSURE_ARG_POINTER(aLength);
*aLength = mLength;
return NS_OK;
}
@ -421,6 +417,7 @@ nsAccTextChangeEvent::GetLength(PRUint32 *aLength)
NS_IMETHODIMP
nsAccTextChangeEvent::IsInserted(PRBool *aIsInserted)
{
NS_ENSURE_ARG_POINTER(aIsInserted);
*aIsInserted = mIsInserted;
return NS_OK;
}
@ -440,14 +437,14 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccCaretMoveEvent, nsAccEvent,
nsIAccessibleCaretMoveEvent)
nsAccCaretMoveEvent::
nsAccCaretMoveEvent(nsIAccessible *aAccessible, PRInt32 aCaretOffset) :
nsAccCaretMoveEvent(nsAccessible *aAccessible, PRInt32 aCaretOffset) :
nsAccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible, PR_TRUE), // Currently always asynch
mCaretOffset(aCaretOffset)
{
}
nsAccCaretMoveEvent::
nsAccCaretMoveEvent(nsIDOMNode *aNode) :
nsAccCaretMoveEvent(nsINode *aNode) :
nsAccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aNode, PR_TRUE), // Currently always asynch
mCaretOffset(-1)
{
@ -470,7 +467,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccTableChangeEvent, nsAccEvent,
nsIAccessibleTableChangeEvent)
nsAccTableChangeEvent::
nsAccTableChangeEvent(nsIAccessible *aAccessible, PRUint32 aEventType,
nsAccTableChangeEvent(nsAccessible *aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols, PRBool aIsAsynch):
nsAccEvent(aEventType, aAccessible, aIsAsynch),
mRowOrColIndex(aRowOrColIndex), mNumRowsOrCols(aNumRowsOrCols)

Просмотреть файл

@ -43,13 +43,7 @@
#include "nsIAccessibleEvent.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsString.h"
#include "nsCycleCollectionParticipant.h"
#include "nsINode.h"
#include "nsIDOMNode.h"
#include "nsAccessible.h"
class nsDocAccessible;
@ -64,14 +58,9 @@ enum EIsFromUserInput
eAutoDetect = -1
};
#define NS_ACCEVENT_IMPL_CID \
{ /* 39bde096-317e-4294-b23b-4af4a9b283f7 */ \
0x39bde096, \
0x317e, \
0x4294, \
{ 0xb2, 0x3b, 0x4a, 0xf4, 0xa9, 0xb2, 0x83, 0xf7 } \
}
/**
* Generic accessible event.
*/
class nsAccEvent: public nsIAccessibleEvent
{
public:
@ -100,16 +89,13 @@ public:
eDoNotEmit
};
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCEVENT_IMPL_CID)
// Initialize with an nsIAccessible
nsAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
nsAccEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
// Initialize with an nsIDOMNode
nsAccEvent(PRUint32 aEventType, nsIDOMNode *aDOMNode,
PRBool aIsAsynch = PR_FALSE,
nsAccEvent(PRUint32 aEventType, nsINode *aNode, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
virtual ~nsAccEvent() {}
@ -124,16 +110,31 @@ public:
EEventRule GetEventRule() const { return mEventRule; }
PRBool IsAsync() const { return mIsAsync; }
PRBool IsFromUserInput() const { return mIsFromUserInput; }
nsIAccessible* GetAccessible() const { return mAccessible; }
nsAccessible *GetAccessible();
nsINode* GetNode();
nsDocAccessible* GetDocAccessible();
enum EventGroup {
eGenericEvent,
eReorderEvent,
eStateChangeEvent,
eTextChangeEvent,
eCaretMoveEvent,
eTableChangeEvent
};
static const EventGroup kEventGroup = eGenericEvent;
virtual unsigned int GetEventGroups() const
{
return 1U << eGenericEvent;
}
protected:
/**
* Get an accessible from event target node.
*/
already_AddRefed<nsIAccessible> GetAccessibleByNode();
nsAccessible *GetAccessibleForNode() const;
/**
* Determine whether the event is from user input by event state manager if
@ -146,34 +147,32 @@ protected:
PRUint32 mEventType;
EEventRule mEventRule;
PRPackedBool mIsAsync;
nsCOMPtr<nsIAccessible> mAccessible;
nsRefPtr<nsAccessible> mAccessible;
nsCOMPtr<nsINode> mNode;
friend class nsAccEventQueue;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccEvent, NS_ACCEVENT_IMPL_CID)
#define NS_ACCREORDEREVENT_IMPL_CID \
{ /* f2629eb8-2458-4358-868c-3912b15b767a */ \
0xf2629eb8, \
0x2458, \
0x4358, \
{ 0x86, 0x8c, 0x39, 0x12, 0xb1, 0x5b, 0x76, 0x7a } \
}
/**
* Accessible reorder event.
*/
class nsAccReorderEvent : public nsAccEvent
{
public:
nsAccReorderEvent(nsIAccessible *aAccTarget, PRBool aIsAsynch,
PRBool aIsUnconditional, nsIDOMNode *aReasonNode);
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCREORDEREVENT_IMPL_CID)
nsAccReorderEvent(nsAccessible *aAccTarget, PRBool aIsAsynch,
PRBool aIsUnconditional, nsINode *aReasonNode);
NS_DECL_ISUPPORTS_INHERITED
// nsAccEvent
static const EventGroup kEventGroup = eReorderEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eReorderEvent);
}
// nsAccReorderEvent
/**
* Return true if event is unconditional, i.e. must be fired.
*/
@ -186,42 +185,57 @@ public:
private:
PRBool mUnconditionalEvent;
nsCOMPtr<nsIDOMNode> mReasonNode;
nsCOMPtr<nsINode> mReasonNode;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccReorderEvent, NS_ACCREORDEREVENT_IMPL_CID)
/**
* Accessible state change event.
*/
class nsAccStateChangeEvent: public nsAccEvent,
public nsIAccessibleStateChangeEvent
{
public:
nsAccStateChangeEvent(nsIAccessible *aAccessible,
nsAccStateChangeEvent(nsAccessible *aAccessible,
PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
nsAccStateChangeEvent(nsIDOMNode *aNode,
PRUint32 aState, PRBool aIsExtraState,
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState,
PRBool aIsEnabled);
nsAccStateChangeEvent(nsIDOMNode *aNode,
PRUint32 aState, PRBool aIsExtraState);
nsAccStateChangeEvent(nsINode *aNode, PRUint32 aState, PRBool aIsExtraState);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESTATECHANGEEVENT
// nsAccEvent
static const EventGroup kEventGroup = eStateChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eStateChangeEvent);
}
// nsAccStateChangeEvent
PRUint32 GetState() const { return mState; }
PRBool IsExtraState() const { return mIsExtraState; }
PRBool IsStateEnabled() const { return mIsEnabled; }
private:
PRUint32 mState;
PRBool mIsExtraState;
PRBool mIsEnabled;
};
/**
* Accessible text change event.
*/
class nsAccTextChangeEvent: public nsAccEvent,
public nsIAccessibleTextChangeEvent
{
public:
nsAccTextChangeEvent(nsIAccessible *aAccessible, PRInt32 aStart,
nsAccTextChangeEvent(nsAccessible *aAccessible, PRInt32 aStart,
PRUint32 aLength, nsAString& aModifiedText,
PRBool aIsInserted, PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
@ -229,6 +243,18 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXTCHANGEEVENT
// nsAccEvent
static const EventGroup kEventGroup = eTextChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eTextChangeEvent);
}
// nsAccTextChangeEvent
PRInt32 GetStartOffset() const { return mStart; }
PRUint32 GetLength() const { return mLength; }
PRBool IsTextInserted() const { return mIsInserted; }
private:
PRInt32 mStart;
PRUint32 mLength;
@ -236,34 +262,86 @@ private:
nsString mModifiedText;
};
/**
* Accessible caret move event.
*/
class nsAccCaretMoveEvent: public nsAccEvent,
public nsIAccessibleCaretMoveEvent
{
public:
nsAccCaretMoveEvent(nsIAccessible *aAccessible, PRInt32 aCaretOffset);
nsAccCaretMoveEvent(nsIDOMNode *aNode);
nsAccCaretMoveEvent(nsAccessible *aAccessible, PRInt32 aCaretOffset);
nsAccCaretMoveEvent(nsINode *aNode);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLECARETMOVEEVENT
// nsAccEvent
static const EventGroup kEventGroup = eCaretMoveEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
}
// nsAccCaretMoveEvent
PRInt32 GetCaretOffset() const { return mCaretOffset; }
private:
PRInt32 mCaretOffset;
};
/**
* Accessible table change event.
*/
class nsAccTableChangeEvent : public nsAccEvent,
public nsIAccessibleTableChangeEvent {
public nsIAccessibleTableChangeEvent
{
public:
nsAccTableChangeEvent(nsIAccessible *aAccessible, PRUint32 aEventType,
nsAccTableChangeEvent(nsAccessible *aAccessible, PRUint32 aEventType,
PRInt32 aRowOrColIndex, PRInt32 aNumRowsOrCols,
PRBool aIsAsynch);
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETABLECHANGEEVENT
// nsAccEvent
static const EventGroup kEventGroup = eTableChangeEvent;
virtual unsigned int GetEventGroups() const
{
return nsAccEvent::GetEventGroups() | (1U << eTableChangeEvent);
}
// nsAccTableChangeEvent
PRUint32 GetIndex() const { return mRowOrColIndex; }
PRUint32 GetCount() const { return mNumRowsOrCols; }
private:
PRUint32 mRowOrColIndex; // the start row/column after which the rows are inserted/deleted.
PRUint32 mNumRowsOrCols; // the number of inserted/deleted rows/columns
};
/**
* Downcast the generic accessible event object to derived type.
*/
class downcast_accEvent
{
public:
downcast_accEvent(nsAccEvent *e) : mRawPtr(e) { }
template<class Destination>
operator Destination*() {
if (!mRawPtr)
return nsnull;
return mRawPtr->GetEventGroups() & (1U << Destination::kEventGroup) ?
static_cast<Destination*>(mRawPtr) : nsnull;
}
private:
nsAccEvent *mRawPtr;
};
#endif

Просмотреть файл

@ -112,9 +112,8 @@ nsAccTreeWalker::GetNextChildInternal(PRBool aNoWalkUp)
mState->childIdx++;
PRBool isHidden = PR_FALSE;
nsCOMPtr<nsIDOMNode> childDOMNode(do_QueryInterface(childNode));
nsRefPtr<nsAccessible> accessible =
GetAccService()->GetAccessible(childDOMNode, presShell, mWeakShell,
GetAccService()->GetAccessible(childNode, presShell, mWeakShell,
&isHidden);
if (accessible)

Просмотреть файл

@ -101,15 +101,15 @@ nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
}
PRInt32
nsAccUtils::GetDefaultLevel(nsAccessible *aAcc)
nsAccUtils::GetDefaultLevel(nsAccessible *aAccessible)
{
PRUint32 role = nsAccUtils::Role(aAcc);
PRUint32 role = nsAccUtils::Role(aAccessible);
if (role == nsIAccessibleRole::ROLE_OUTLINEITEM)
return 1;
if (role == nsIAccessibleRole::ROLE_ROW) {
nsCOMPtr<nsIAccessible> parent = aAcc->GetParent();
nsAccessible *parent = aAccessible->GetParent();
if (Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE) {
// It is a row inside flatten treegrid. Group level is always 1 until it
// is overriden by aria-level attribute.
@ -121,31 +121,24 @@ nsAccUtils::GetDefaultLevel(nsAccessible *aAcc)
}
PRInt32
nsAccUtils::GetARIAOrDefaultLevel(nsIAccessible *aAcc)
nsAccUtils::GetARIAOrDefaultLevel(nsAccessible *aAccessible)
{
nsRefPtr<nsAccessible> acc = do_QueryObject(aAcc);
NS_ENSURE_TRUE(acc, 0);
nsCOMPtr<nsIDOMNode> node;
acc->GetDOMNode(getter_AddRefs(node));
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
NS_ENSURE_TRUE(content, 0);
PRInt32 level = 0;
nsCoreUtils::GetUIntAttr(content, nsAccessibilityAtoms::aria_level, &level);
nsCoreUtils::GetUIntAttr(aAccessible->GetContent(),
nsAccessibilityAtoms::aria_level, &level);
if (level != 0)
return level;
return GetDefaultLevel(acc);
return GetDefaultLevel(aAccessible);
}
void
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(nsIDOMNode *aNode,
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(nsIContent *aContent,
PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(aNode));
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(aContent));
if (!item)
return;
@ -182,11 +175,11 @@ nsAccUtils::GetPositionAndSizeForXULSelectControlItem(nsIDOMNode *aNode,
}
void
nsAccUtils::GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
nsAccUtils::GetPositionAndSizeForXULContainerItem(nsIContent *aContent,
PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aContent));
if (!item)
return;
@ -246,9 +239,9 @@ nsAccUtils::GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
}
PRInt32
nsAccUtils::GetLevelForXULContainerItem(nsIDOMNode *aNode)
nsAccUtils::GetLevelForXULContainerItem(nsIContent *aContent)
{
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aContent));
if (!item)
return 0;
@ -287,8 +280,7 @@ nsAccUtils::SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
// container-live, and container-live-role attributes
if (live.IsEmpty()) {
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(ancestor));
nsRoleMapEntry *role = GetRoleMapEntry(node);
nsRoleMapEntry *role = GetRoleMapEntry(ancestor);
if (nsAccUtils::HasDefinedARIAToken(ancestor,
nsAccessibilityAtoms::aria_live)) {
ancestor->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_live,
@ -343,46 +335,34 @@ nsAccUtils::HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom)
}
PRBool
nsAccUtils::HasAccessibleChildren(nsIDOMNode *aNode)
nsAccUtils::HasAccessibleChildren(nsINode *aNode)
{
if (!aNode)
return PR_FALSE;
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (!content)
return PR_FALSE;
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode);
if (!presShell)
return PR_FALSE;
nsIFrame *frame = content->GetPrimaryFrame();
if (!frame)
return PR_FALSE;
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
nsAccTreeWalker walker(weakShell, content, PR_FALSE);
nsRefPtr<nsAccessible> accessible = walker.GetNextChild();
return accessible ? PR_TRUE : PR_FALSE;
}
already_AddRefed<nsIAccessible>
nsAccUtils::GetAncestorWithRole(nsIAccessible *aDescendant, PRUint32 aRole)
nsAccessible *
nsAccUtils::GetAncestorWithRole(nsAccessible *aDescendant, PRUint32 aRole)
{
nsCOMPtr<nsIAccessible> parentAccessible = aDescendant, testRoleAccessible;
while (NS_SUCCEEDED(parentAccessible->GetParent(getter_AddRefs(testRoleAccessible))) &&
testRoleAccessible) {
PRUint32 testRole = nsAccUtils::Role(testRoleAccessible);
if (testRole == aRole) {
nsIAccessible *returnAccessible = testRoleAccessible;
NS_ADDREF(returnAccessible);
return returnAccessible;
}
nsCOMPtr<nsIAccessibleDocument> docAccessible = do_QueryInterface(testRoleAccessible);
if (docAccessible) {
nsAccessible *document = aDescendant->GetDocAccessible();
nsAccessible *parent = aDescendant;
while ((parent = parent->GetParent())) {
PRUint32 testRole = nsAccUtils::Role(parent);
if (testRole == aRole)
return parent;
if (parent == document)
break;
}
parentAccessible.swap(testRoleAccessible);
}
return nsnull;
}
@ -487,8 +467,8 @@ nsAccUtils::GetARIATreeItemParent(nsIAccessible *aStartTreeItem,
}
}
already_AddRefed<nsIAccessible>
nsAccUtils::GetSelectableContainer(nsIAccessible *aAccessible, PRUint32 aState)
nsAccessible *
nsAccUtils::GetSelectableContainer(nsAccessible *aAccessible, PRUint32 aState)
{
if (!aAccessible)
return nsnull;
@ -497,57 +477,41 @@ nsAccUtils::GetSelectableContainer(nsIAccessible *aAccessible, PRUint32 aState)
return nsnull;
nsCOMPtr<nsIAccessibleSelectable> container;
nsCOMPtr<nsIAccessible> parent, accessible(aAccessible);
nsAccessible *parent = aAccessible;
while (!container) {
accessible->GetParent(getter_AddRefs(parent));
parent = parent->GetParent();
if (!parent || Role(parent) == nsIAccessibleRole::ROLE_PANE)
return nsnull;
container = do_QueryInterface(parent);
parent.swap(accessible);
container = do_QueryObject(parent);
}
return accessible.forget();
return parent;
}
already_AddRefed<nsIAccessible>
nsAccUtils::GetMultiSelectableContainer(nsIDOMNode *aNode)
nsAccessible *
nsAccUtils::GetMultiSelectableContainer(nsINode *aNode)
{
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(aNode, getter_AddRefs(accessible));
nsCOMPtr<nsIAccessible> container =
GetSelectableContainer(accessible, State(accessible));
nsAccessible *accessible = GetAccService()->GetAccessible(aNode);
nsAccessible *container = GetSelectableContainer(accessible,
State(accessible));
if (State(container) & nsIAccessibleStates::STATE_MULTISELECTABLE)
return container.forget();
return container;
return nsnull;
}
PRBool
nsAccUtils::IsARIASelected(nsIAccessible *aAccessible)
nsAccUtils::IsARIASelected(nsAccessible *aAccessible)
{
nsRefPtr<nsAccessible> acc = do_QueryObject(aAccessible);
nsCOMPtr<nsIDOMNode> node;
acc->GetDOMNode(getter_AddRefs(node));
NS_ASSERTION(node, "No DOM node!");
if (node) {
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
if (content->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::aria_selected,
nsAccessibilityAtoms::_true, eCaseMatters))
return PR_TRUE;
}
return PR_FALSE;
return aAccessible->GetContent()->
AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_selected,
nsAccessibilityAtoms::_true, eCaseMatters);
}
already_AddRefed<nsIAccessibleText>
already_AddRefed<nsHyperTextAccessible>
nsAccUtils::GetTextAccessibleFromSelection(nsISelection *aSelection,
nsIDOMNode **aNode)
nsINode **aNode)
{
// Get accessible from selection's focus DOM point (the DOM point where
// selection is ended).
@ -568,30 +532,22 @@ nsAccUtils::GetTextAccessibleFromSelection(nsISelection *aSelection,
while (resultNode) {
// Make sure to get the correct starting node for selection events inside
// XBL content trees.
nsCOMPtr<nsIDOMNode> resultDOMNode(do_QueryInterface(resultNode));
nsCOMPtr<nsIDOMNode> relevantDOMNode;
GetAccService()->GetRelevantContentNodeFor(resultDOMNode,
getter_AddRefs(relevantDOMNode));
if (relevantDOMNode) {
resultNode = do_QueryInterface(relevantDOMNode);
resultDOMNode.swap(relevantDOMNode);
}
if (!resultNode || !resultNode->IsNodeOfType(nsINode::eTEXT)) {
nsAccessible *accessible = GetAccService()->GetAccessible(resultDOMNode);
resultNode = GetAccService()->GetRelevantContentNodeFor(resultNode);
if (!resultNode->IsNodeOfType(nsINode::eTEXT)) {
nsAccessible *accessible = GetAccService()->GetAccessible(resultNode);
if (accessible) {
nsIAccessibleText *textAcc = nsnull;
nsHyperTextAccessible *textAcc = nsnull;
CallQueryInterface(accessible, &textAcc);
if (textAcc) {
if (aNode)
resultDOMNode.forget(aNode);
NS_ADDREF(*aNode = resultNode);
return textAcc;
}
}
}
resultNode = resultNode->GetParent();
resultNode = resultNode->GetNodeParent();
}
NS_NOTREACHED("No nsIAccessibleText for selection change event!");
@ -602,7 +558,7 @@ nsAccUtils::GetTextAccessibleFromSelection(nsISelection *aSelection,
nsresult
nsAccUtils::ConvertToScreenCoords(PRInt32 aX, PRInt32 aY,
PRUint32 aCoordinateType,
nsIAccessNode *aAccessNode,
nsAccessNode *aAccessNode,
nsIntPoint *aCoords)
{
NS_ENSURE_ARG_POINTER(aCoords);
@ -637,7 +593,7 @@ nsAccUtils::ConvertToScreenCoords(PRInt32 aX, PRInt32 aY,
nsresult
nsAccUtils::ConvertScreenCoordsTo(PRInt32 *aX, PRInt32 *aY,
PRUint32 aCoordinateType,
nsIAccessNode *aAccessNode)
nsAccessNode *aAccessNode)
{
switch (aCoordinateType) {
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
@ -669,31 +625,16 @@ nsAccUtils::ConvertScreenCoordsTo(PRInt32 *aX, PRInt32 *aY,
}
nsIntPoint
nsAccUtils::GetScreenCoordsForWindow(nsIAccessNode *aAccessNode)
nsAccUtils::GetScreenCoordsForWindow(nsAccessNode *aAccessNode)
{
nsCOMPtr<nsIDOMNode> DOMNode;
aAccessNode->GetDOMNode(getter_AddRefs(DOMNode));
if (DOMNode)
return nsCoreUtils::GetScreenCoordsForWindow(DOMNode);
return nsIntPoint(0, 0);
return nsCoreUtils::GetScreenCoordsForWindow(aAccessNode->GetNode());
}
nsIntPoint
nsAccUtils::GetScreenCoordsForParent(nsIAccessNode *aAccessNode)
nsAccUtils::GetScreenCoordsForParent(nsAccessNode *aAccessNode)
{
nsRefPtr<nsAccessNode> parent;
nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(aAccessNode));
if (accessible) {
nsCOMPtr<nsIAccessible> parentAccessible;
accessible->GetParent(getter_AddRefs(parentAccessible));
parent = do_QueryObject(parentAccessible);
} else {
nsCOMPtr<nsIAccessNode> parentAccessNode;
aAccessNode->GetParentNode(getter_AddRefs(parentAccessNode));
parent = do_QueryObject(parentAccessNode);
}
nsAccessible *parent =
GetAccService()->GetContainerAccessible(aAccessNode->GetNode(), PR_TRUE);
if (!parent)
return nsIntPoint(0, 0);
@ -706,7 +647,7 @@ nsAccUtils::GetScreenCoordsForParent(nsIAccessNode *aAccessNode)
}
nsRoleMapEntry*
nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
nsAccUtils::GetRoleMapEntry(nsINode *aNode)
{
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
nsAutoString roleString;
@ -875,11 +816,9 @@ nsAccUtils::MustPrune(nsIAccessible *aAccessible)
}
PRBool
nsAccUtils::IsNodeRelevant(nsIDOMNode *aNode)
nsAccUtils::IsNodeRelevant(nsINode *aNode)
{
nsCOMPtr<nsIDOMNode> relevantNode;
GetAccService()->GetRelevantContentNodeFor(aNode, getter_AddRefs(relevantNode));
return aNode == relevantNode;
return aNode == GetAccService()->GetRelevantContentNodeFor(aNode);
}
nsresult

Просмотреть файл

@ -59,6 +59,7 @@
class nsAccessNode;
class nsAccessible;
class nsHyperTextAccessible;
class nsHTMLTableAccessible;
class nsDocAccessible;
#ifdef MOZ_XUL
@ -106,13 +107,13 @@ public:
* Return ARIA level value or the default one if ARIA is missed for the
* given accessible.
*/
static PRInt32 GetARIAOrDefaultLevel(nsIAccessible *aAcc);
static PRInt32 GetARIAOrDefaultLevel(nsAccessible *aAccessible);
/**
* Compute position in group (posinset) and group size (setsize) for
* nsIDOMXULSelectControlItemElement node.
*/
static void GetPositionAndSizeForXULSelectControlItem(nsIDOMNode *aNode,
static void GetPositionAndSizeForXULSelectControlItem(nsIContent *aContent,
PRInt32 *aPosInSet,
PRInt32 *aSetSize);
@ -120,14 +121,14 @@ public:
* Compute group position and group size (posinset and setsize) for
* nsIDOMXULContainerItemElement node.
*/
static void GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
static void GetPositionAndSizeForXULContainerItem(nsIContent *aContent,
PRInt32 *aPosInSet,
PRInt32 *aSetSize);
/**
* Compute group level for nsIDOMXULContainerItemElement node.
*/
static PRInt32 GetLevelForXULContainerItem(nsIDOMNode *aNode);
static PRInt32 GetLevelForXULContainerItem(nsIContent *aContent);
/**
* Set container-foo live region attributes for the given node.
@ -162,7 +163,7 @@ public:
/**
* Return document accessible for the given DOM node.
*/
static nsDocAccessible *GetDocAccessibleFor(nsIDOMNode *aNode)
static nsDocAccessible *GetDocAccessibleFor(nsINode *aNode)
{
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode);
return presShell ?
@ -184,16 +185,18 @@ public:
/**
* Return true if the given DOM node contains accessible children.
*/
static PRBool HasAccessibleChildren(nsIDOMNode *aNode);
static PRBool HasAccessibleChildren(nsINode *aNode);
/**
* If an ancestor in this document exists with the given role, return it
* @param aDescendant Descendant to start search with
* @param aRole Role to find matching ancestor for
* @return The ancestor accessible with the given role, or nsnull if no match is found
* Return ancestor in this document with the given role if it exists.
*
* @param aDescendant [in] descendant to start search with
* @param aRole [in] role to find matching ancestor for
* @return the ancestor accessible with the given role, or
* nsnull if no match is found
*/
static already_AddRefed<nsIAccessible>
GetAncestorWithRole(nsIAccessible *aDescendant, PRUint32 aRole);
static nsAccessible * GetAncestorWithRole(nsAccessible *aDescendant,
PRUint32 aRole);
/**
* For an ARIA tree item , get the accessible that represents its conceptual parent.
@ -214,20 +217,19 @@ public:
* @param aAccessible [in] the item accessible
* @param aState [in] the state of the item accessible
*/
static already_AddRefed<nsIAccessible>
GetSelectableContainer(nsIAccessible *aAccessible, PRUint32 aState);
static nsAccessible *GetSelectableContainer(nsAccessible *aAccessible,
PRUint32 aState);
/**
* Return multi selectable container for the given item.
*/
static already_AddRefed<nsIAccessible>
GetMultiSelectableContainer(nsIDOMNode *aNode);
static nsAccessible *GetMultiSelectableContainer(nsINode *aNode);
/**
* Return true if the DOM node of given accessible has aria-selected="true"
* attribute.
*/
static PRBool IsARIASelected(nsIAccessible *aAccessible);
static PRBool IsARIASelected(nsAccessible *aAccessible);
/**
* Return text accessible containing focus point of the given selection.
@ -237,9 +239,9 @@ public:
* @param aNode [out, optional] the DOM node of text accessible
* @return text accessible
*/
static already_AddRefed<nsIAccessibleText>
static already_AddRefed<nsHyperTextAccessible>
GetTextAccessibleFromSelection(nsISelection *aSelection,
nsIDOMNode **aNode = nsnull);
nsINode **aNode = nsnull);
/**
* Converts the given coordinates to coordinates relative screen.
@ -254,7 +256,7 @@ public:
*/
static nsresult ConvertToScreenCoords(PRInt32 aX, PRInt32 aY,
PRUint32 aCoordinateType,
nsIAccessNode *aAccessNode,
nsAccessNode *aAccessNode,
nsIntPoint *aCoords);
/**
@ -270,29 +272,31 @@ public:
*/
static nsresult ConvertScreenCoordsTo(PRInt32 *aX, PRInt32 *aY,
PRUint32 aCoordinateType,
nsIAccessNode *aAccessNode);
nsAccessNode *aAccessNode);
/**
* Returns coordinates relative screen for the top level window.
*
* @param aAccessNode the accessible hosted in the window
*/
static nsIntPoint GetScreenCoordsForWindow(nsIAccessNode *aAccessNode);
static nsIntPoint GetScreenCoordsForWindow(nsAccessNode *aAccessNode);
/**
* Returns coordinates relative screen for the parent of the given accessible.
*
* @param aAccessNode the accessible
*/
static nsIntPoint GetScreenCoordsForParent(nsIAccessNode *aAccessNode);
static nsIntPoint GetScreenCoordsForParent(nsAccessNode *aAccessNode);
/**
* Get the role map entry for a given DOM node. This will use the first
* ARIA role if the role attribute provides a space delimited list of roles.
* @param aNode The DOM node to get the role map entry for
* @return A pointer to the role map entry for the ARIA role, or nsnull if none
*
* @param aNode [in] the DOM node to get the role map entry for
* @return a pointer to the role map entry for the ARIA role, or nsnull
* if none
*/
static nsRoleMapEntry* GetRoleMapEntry(nsIDOMNode *aNode);
static nsRoleMapEntry *GetRoleMapEntry(nsINode *aNode);
/**
* Return the role of the given accessible.
@ -410,7 +414,7 @@ public:
* Return true if the given node can be accessible and attached to
* the document's accessible tree.
*/
static PRBool IsNodeRelevant(nsIDOMNode *aNode);
static PRBool IsNodeRelevant(nsINode *aNode);
/**
* Search hint enum constants. Used by GetHeaderCellsFor() method.

Просмотреть файл

@ -80,7 +80,7 @@
nsIStringBundle *nsAccessNode::gStringBundle = 0;
nsIStringBundle *nsAccessNode::gKeyStringBundle = 0;
nsIDOMNode *nsAccessNode::gLastFocusedNode = 0;
nsINode *nsAccessNode::gLastFocusedNode = nsnull;
PRBool nsAccessNode::gIsCacheDisabled = PR_FALSE;
PRBool nsAccessNode::gIsFormFillEnabled = PR_FALSE;
@ -109,8 +109,9 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(nsAccessNode, nsIAccessNode,
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode construction/desctruction
nsAccessNode::nsAccessNode(nsIDOMNode *aNode, nsIWeakReference* aShell):
mDOMNode(aNode), mWeakShell(aShell)
nsAccessNode::
nsAccessNode(nsIContent *aContent, nsIWeakReference *aShell) :
mContent(aContent), mWeakShell(aShell)
{
#ifdef DEBUG_A11Y
mIsInitialized = PR_FALSE;
@ -136,79 +137,38 @@ void nsAccessNode::LastRelease()
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public
nsresult
PRBool
nsAccessNode::Init()
{
// We have to put this here, instead of constructor, otherwise
// we don't have the virtual GetUniqueID() method for the hash key.
// We need that for accessibles that don't have DOM nodes
#ifdef DEBUG_A11Y
NS_ASSERTION(!mIsInitialized, "Initialized twice!");
#endif
nsDocAccessible *docAcc = nsnull;
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (presShell)
docAcc = GetAccService()->GetDocAccessible(presShell->GetDocument());
NS_ASSERTION(docAcc, "Cannot cache new nsAccessNode");
if (!docAcc) {
#ifdef DEBUG
docAcc = GetAccService()->GetDocAccessible(presShell->GetDocument());
#endif
return NS_ERROR_FAILURE;
}
void* uniqueID;
GetUniqueID(&uniqueID);
if (!docAcc->CacheAccessNode(uniqueID, this))
return NS_ERROR_OUT_OF_MEMORY;
// Make sure an ancestor in real content is cached
// so that nsDocAccessible::RefreshNodes() can find the anonymous subtree to release when
// the root node goes away
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (content && content->IsInAnonymousSubtree()) {
// Specific examples of where this is used: <input type="file"> and <xul:findbar>
nsAccessible *parent = GetAccService()->GetContainerAccessible(mDOMNode,
PR_TRUE);
if (parent)
parent->EnsureChildren();
}
#ifdef DEBUG_A11Y
mIsInitialized = PR_TRUE;
#endif
return NS_OK;
return PR_TRUE;
}
nsresult
void
nsAccessNode::Shutdown()
{
mDOMNode = nsnull;
mContent = nsnull;
mWeakShell = nsnull;
return NS_OK;
}
// nsIAccessNode
NS_IMETHODIMP nsAccessNode::GetUniqueID(void **aUniqueID)
{
*aUniqueID = static_cast<void*>(mDOMNode);
*aUniqueID = static_cast<void*>(GetNode());
return NS_OK;
}
// nsIAccessNode
NS_IMETHODIMP nsAccessNode::GetOwnerWindow(void **aWindow)
NS_IMETHODIMP
nsAccessNode::GetOwnerWindow(void **aWindow)
{
NS_ENSURE_ARG_POINTER(aWindow);
*aWindow = nsnull;
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
if (!docAccessible)
return NS_ERROR_FAILURE; // This node or doc accessible is shut down
return docAccessible->GetWindowHandle(aWindow);
if (IsDefunct())
return NS_ERROR_FAILURE;
return GetDocAccessible()->GetWindowHandle(aWindow);
}
nsApplicationAccessible*
@ -300,7 +260,7 @@ void nsAccessNode::ShutdownXPAccessibility()
PRBool
nsAccessNode::IsDefunct()
{
if (!mDOMNode)
if (!mContent)
return PR_TRUE;
// Call GetPresShell() since the accessible may be shut down in it.
@ -335,11 +295,18 @@ nsPresContext* nsAccessNode::GetPresContext()
return presShell->GetPresContext();
}
nsDocAccessible *
nsAccessNode::GetDocAccessible() const
{
return mContent ?
GetAccService()->GetDocAccessible(mContent->GetOwnerDoc()) : nsnull;
}
already_AddRefed<nsRootAccessible> nsAccessNode::GetRootAccessible()
{
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
nsCoreUtils::GetDocShellTreeItemFor(mDOMNode);
NS_ASSERTION(docShellTreeItem, "No docshell tree item for mDOMNode");
nsCoreUtils::GetDocShellTreeItemFor(mContent);
NS_ASSERTION(docShellTreeItem, "No docshell tree item for mContent");
if (!docShellTreeItem) {
return nsnull;
}
@ -358,47 +325,21 @@ already_AddRefed<nsRootAccessible> nsAccessNode::GetRootAccessible()
nsIFrame*
nsAccessNode::GetFrame()
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
return content ? content->GetPrimaryFrame() : nsnull;
return mContent ? mContent->GetPrimaryFrame() : nsnull;
}
#ifdef DEBUG
PRBool
nsAccessNode::IsInCache()
{
nsDocAccessible *docAccessible = nsAccUtils::GetDocAccessibleFor(mWeakShell);
if (!docAccessible)
return nsnull;
void* uniqueID = nsnull;
GetUniqueID(&uniqueID);
return docAccessible->GetCachedAccessNode(uniqueID) ? PR_TRUE : PR_FALSE;
}
#endif
////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode
NS_IMETHODIMP
nsAccessNode::GetDOMNode(nsIDOMNode **aNode)
nsAccessNode::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_IF_ADDREF(*aNode = mDOMNode);
return NS_OK;
}
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
NS_IMETHODIMP
nsAccessNode::GetNumChildren(PRInt32 *aNumChildren)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content) {
*aNumChildren = 0;
return NS_ERROR_NULL_POINTER;
}
*aNumChildren = content->GetChildCount();
nsINode *node = GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
return NS_OK;
}
@ -408,7 +349,7 @@ nsAccessNode::GetDocument(nsIAccessibleDocument **aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
NS_IF_ADDREF(*aDocument = nsAccUtils::GetDocAccessibleFor(mWeakShell));
NS_IF_ADDREF(*aDocument = GetDocAccessible());
return NS_OK;
}
@ -427,7 +368,7 @@ nsAccessNode::GetInnerHTML(nsAString& aInnerHTML)
{
aInnerHTML.Truncate();
nsCOMPtr<nsIDOMNSHTMLElement> domNSElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNSHTMLElement> domNSElement(do_QueryInterface(mContent));
NS_ENSURE_TRUE(domNSElement, NS_ERROR_NULL_POINTER);
return domNSElement->GetInnerHTML(aInnerHTML);
@ -472,114 +413,6 @@ nsAccessNode::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
return NS_OK;
}
// nsAccessNode protected
nsresult
nsAccessNode::MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode)
{
*aAccessNode = nsnull;
nsCOMPtr<nsIAccessNode> accessNode =
GetAccService()->GetCachedAccessNode(aNode, mWeakShell);
if (!accessNode)
accessNode = GetAccService()->GetAccessibleInWeakShell(aNode, mWeakShell);
if (accessNode) {
NS_ADDREF(*aAccessNode = accessNode);
return NS_OK;
}
nsAccessNode *newAccessNode = new nsAccessNode(aNode, mWeakShell);
if (!newAccessNode) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aAccessNode = newAccessNode);
newAccessNode->Init();
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetFirstChildNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetFirstChild(getter_AddRefs(domNode));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetLastChildNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetLastChild(getter_AddRefs(domNode));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetParentNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetParentNode(getter_AddRefs(domNode));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetPreviousSiblingNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetPreviousSibling(getter_AddRefs(domNode));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetNextSiblingNode(nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetNextSibling(getter_AddRefs(domNode));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetChildNodeAt(PRInt32 aChildNum, nsIAccessNode **aAccessNode)
{
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode =
do_QueryInterface(content->GetChildAt(aChildNum));
return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
@ -588,9 +421,8 @@ nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mDOMNode,
getter_AddRefs(styleDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
return styleDecl->GetPropertyValue(aPropertyName, aValue);
@ -607,9 +439,8 @@ nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mDOMNode,
getter_AddRefs(styleDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_STATE(styleDecl);
nsCOMPtr<nsIDOMCSSValue> cssValue;
@ -620,11 +451,14 @@ nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
}
// nsAccessNode public
already_AddRefed<nsIDOMNode> nsAccessNode::GetCurrentFocus()
already_AddRefed<nsINode>
nsAccessNode::GetCurrentFocus()
{
nsIPresShell *shell = nsCoreUtils::GetPresShellFor(mDOMNode);
// XXX: consider to use nsFocusManager directly, it allows us to avoid
// unnecessary query interface calls.
nsCOMPtr<nsIPresShell> shell = GetPresShell();
NS_ENSURE_TRUE(shell, nsnull);
nsCOMPtr<nsIDocument> doc = shell->GetDocument();
nsIDocument *doc = shell->GetDocument();
NS_ENSURE_TRUE(doc, nsnull);
nsIDOMWindow* win = doc->GetWindow();
@ -636,7 +470,7 @@ already_AddRefed<nsIDOMNode> nsAccessNode::GetCurrentFocus()
fm->GetFocusedElementForWindow(win, PR_TRUE, getter_AddRefs(focusedWindow),
getter_AddRefs(focusedElement));
nsIDOMNode *focusedNode = nsnull;
nsINode *focusedNode = nsnull;
if (focusedElement) {
CallQueryInterface(focusedElement, &focusedNode);
}
@ -654,34 +488,14 @@ NS_IMETHODIMP
nsAccessNode::GetLanguage(nsAString& aLanguage)
{
aLanguage.Truncate();
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content) {
// For documents make sure we look for lang attribute on
// document element
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDOMNode));
if (domDoc) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDOMNode));
if (htmlDoc) {
// Make sure we look for lang attribute on HTML <body>
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
htmlDoc->GetBody(getter_AddRefs(bodyElement));
content = do_QueryInterface(bodyElement);
}
if (!content) {
nsCOMPtr<nsIDOMElement> docElement;
domDoc->GetDocumentElement(getter_AddRefs(docElement));
content = do_QueryInterface(docElement);
}
}
if (!content) {
return NS_ERROR_FAILURE;
}
}
nsCoreUtils::GetLanguageFor(content, nsnull, aLanguage);
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage);
if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
nsIDocument *doc = content->GetOwnerDoc();
nsIDocument *doc = mContent->GetOwnerDoc();
if (doc) {
doc->GetHeaderData(nsAccessibilityAtoms::headerContentLanguage, aLanguage);
}
@ -689,12 +503,3 @@ nsAccessNode::GetLanguage(nsAString& aLanguage)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode protected
nsDocAccessible*
nsAccessNode::GetDocAccessible() const
{
return nsAccUtils::GetDocAccessibleFor(mWeakShell);
}

Просмотреть файл

@ -66,9 +66,6 @@ class nsPresContext;
class nsIFrame;
class nsIDocShellTreeItem;
typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsAccessNode>
nsAccessNodeHashtable;
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
@ -82,9 +79,10 @@ typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsAccessNode>
class nsAccessNode: public nsIAccessNode
{
public: // construction, destruction
nsAccessNode(nsIDOMNode *, nsIWeakReference* aShell);
virtual ~nsAccessNode();
public:
nsAccessNode(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessNode();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessNode, nsIAccessNode)
@ -101,33 +99,42 @@ class nsAccessNode: public nsIAccessNode
static nsApplicationAccessible* GetApplicationAccessible();
/**
* Return the document accessible for this accesnode.
* Return the document accessible for this access node.
*/
nsDocAccessible* GetDocAccessible() const;
nsDocAccessible *GetDocAccessible() const;
/**
* Return the root document accessible for this accessnode.
*/
already_AddRefed<nsRootAccessible> GetRootAccessible();
static nsIDOMNode *gLastFocusedNode;
/**
* Reference to a node of focused accessible.
*/
static nsINode *gLastFocusedNode;
already_AddRefed<nsIDOMNode> GetCurrentFocus();
/**
* Return focused node within accessible window.
*
* XXX: it shouldn't break us if we return focused node not depending on
* window so that we can turn this method into util method.
*/
already_AddRefed<nsINode> GetCurrentFocus();
/**
* Returns true when the accessible is defunct.
*/
virtual PRBool IsDefunct();
/**
* Initialize the access node object, add it to the cache.
*/
virtual nsresult Init();
/**
* Initialize the access node object, add it to the cache.
*/
virtual PRBool Init();
/**
* Shutdown the access node object.
*/
virtual nsresult Shutdown();
/**
* Shutdown the access node object.
*/
virtual void Shutdown();
/**
* Return frame for the given access node object.
@ -137,7 +144,33 @@ class nsAccessNode: public nsIAccessNode
/**
* Return DOM node associated with this accessible.
*/
nsIDOMNode *GetDOMNode() const { return mDOMNode; }
already_AddRefed<nsIDOMNode> GetDOMNode() const
{
nsIDOMNode *DOMNode = nsnull;
if (GetNode())
CallQueryInterface(GetNode(), &DOMNode);
return DOMNode;
}
/**
* Return DOM node associated with the accessible.
*/
virtual nsINode* GetNode() const { return mContent; }
nsIContent* GetContent() const { return mContent; }
nsIDocument* GetDocumentNode() const
{ return mContent ? mContent->GetOwnerDoc() : nsnull; }
/**
* Return node type information of DOM node associated with the accessible.
*/
PRBool IsContent() const
{
return GetNode() && GetNode()->IsNodeOfType(nsINode::eCONTENT);
}
PRBool IsDocument() const
{
return GetNode() && GetNode()->IsNodeOfType(nsINode::eDOCUMENT);
}
/**
* Return the corresponding press shell for this accessible.
@ -150,26 +183,13 @@ class nsAccessNode: public nsIAccessNode
*/
PRBool HasWeakShell() const { return !!mWeakShell; }
#ifdef DEBUG
/**
* Return true if the access node is cached.
*/
PRBool IsInCache();
#endif
protected:
nsresult MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode);
nsPresContext* GetPresContext();
void LastRelease();
nsCOMPtr<nsIDOMNode> mDOMNode;
nsCOMPtr<nsIWeakReference> mWeakShell;
#ifdef DEBUG_A11Y
PRBool mIsInitialized;
#endif
nsCOMPtr<nsIContent> mContent;
nsCOMPtr<nsIWeakReference> mWeakShell;
/**
* Notify global nsIObserver's that a11y is getting init'd or shutdown

Просмотреть файл

@ -57,6 +57,7 @@
// Alphabetical list of generic atoms
ACCESSIBILITY_ATOM(button, "button")
ACCESSIBILITY_ATOM(checkbox, "checkbox")
ACCESSIBILITY_ATOM(col, "col")
ACCESSIBILITY_ATOM(_empty, "")
ACCESSIBILITY_ATOM(_false, "false")
@ -64,7 +65,10 @@ ACCESSIBILITY_ATOM(image, "image")
ACCESSIBILITY_ATOM(menu, "menu")
ACCESSIBILITY_ATOM(menuButton, "menu-button")
ACCESSIBILITY_ATOM(menugenerated, "menugenerated")
ACCESSIBILITY_ATOM(multiple, "multiple")
ACCESSIBILITY_ATOM(open, "open")
ACCESSIBILITY_ATOM(password, "password")
ACCESSIBILITY_ATOM(radio, "radio")
ACCESSIBILITY_ATOM(reset, "reset")
ACCESSIBILITY_ATOM(row, "row")
ACCESSIBILITY_ATOM(submit, "submit")
@ -122,6 +126,7 @@ ACCESSIBILITY_ATOM(label, "label")
ACCESSIBILITY_ATOM(legend, "legend")
ACCESSIBILITY_ATOM(li, "li")
ACCESSIBILITY_ATOM(link, "link")
ACCESSIBILITY_ATOM(listcell, "listcell") // XUL
ACCESSIBILITY_ATOM(listcols, "listcols") // XUL
ACCESSIBILITY_ATOM(listcol, "listcol") // XUL
ACCESSIBILITY_ATOM(listhead, "listhead") // XUL
@ -161,6 +166,7 @@ ACCESSIBILITY_ATOM(acceltext, "acceltext")
ACCESSIBILITY_ATOM(accesskey, "accesskey")
ACCESSIBILITY_ATOM(alt, "alt")
ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
ACCESSIBILITY_ATOM(checked, "checked")
ACCESSIBILITY_ATOM(contenteditable, "contenteditable")
ACCESSIBILITY_ATOM(control, "control")
ACCESSIBILITY_ATOM(disabled, "disabled")
@ -175,6 +181,7 @@ ACCESSIBILITY_ATOM(editable, "editable")
ACCESSIBILITY_ATOM(_for, "for")
ACCESSIBILITY_ATOM(headers, "headers") // HTML table
ACCESSIBILITY_ATOM(hidden, "hidden") // XUL tree columns
ACCESSIBILITY_ATOM(hover, "hover") // XUL color picker
ACCESSIBILITY_ATOM(href, "href") // XUL, XLink
ACCESSIBILITY_ATOM(increment, "increment") // XUL
ACCESSIBILITY_ATOM(lang, "lang")
@ -183,12 +190,14 @@ ACCESSIBILITY_ATOM(longDesc, "longdesc")
ACCESSIBILITY_ATOM(max, "max") // XUL
ACCESSIBILITY_ATOM(maxpos, "maxpos") // XUL
ACCESSIBILITY_ATOM(minpos, "minpos") // XUL
ACCESSIBILITY_ATOM(_moz_menuactive, "_moz-menuactive") // XUL
ACCESSIBILITY_ATOM(multiline, "multiline") // XUL
ACCESSIBILITY_ATOM(name, "name")
ACCESSIBILITY_ATOM(onclick, "onclick")
ACCESSIBILITY_ATOM(popup, "popup")
ACCESSIBILITY_ATOM(readonly, "readonly")
ACCESSIBILITY_ATOM(scope, "scope") // HTML table
ACCESSIBILITY_ATOM(seltype, "seltype") // XUL listbox
ACCESSIBILITY_ATOM(simple, "simple") // XLink
ACCESSIBILITY_ATOM(src, "src")
ACCESSIBILITY_ATOM(selected, "selected")

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -44,20 +44,8 @@
#include "a11yGeneric.h"
#include "nsAccDocManager.h"
#include "nsCOMArray.h"
#include "nsIObserver.h"
class nsAccessNode;
class nsAccessible;
class nsIFrame;
class nsIWeakReference;
class nsIDOMNode;
class nsObjectFrame;
class nsIDocShell;
class nsIPresShell;
class nsIContent;
struct nsRoleMapEntry;
class nsAccessibilityService : public nsAccDocManager,
public nsIAccessibilityService,
public nsIObserver
@ -136,18 +124,12 @@ public:
virtual void NotifyOfAnchorJumpTo(nsIContent *aTarget);
virtual void PresShellDestroyed(nsIPresShell* aPresShell);
virtual nsresult FireAccessibleEvent(PRUint32 aEvent, nsIAccessible *aTarget);
// nsAccessibiltiyService
/**
* Return presentation shell for the given node.
*
* @param aNode - the given DOM node.
*/
static nsresult GetShellFromNode(nsIDOMNode *aNode,
nsIWeakReference **weakShell);
/**
* Return true if accessibility service has been shutdown.
*/
@ -163,13 +145,13 @@ public:
* hidden
*/
already_AddRefed<nsAccessible>
GetAccessible(nsIDOMNode *aNode, nsIPresShell *aPresShell,
GetAccessible(nsINode *aNode, nsIPresShell *aPresShell,
nsIWeakReference *aWeakShell, PRBool *aIsHidden = nsnull);
/**
* Return an accessible for the given DOM node.
*/
nsAccessible *GetAccessible(nsIDOMNode *aNode);
nsAccessible *GetAccessible(nsINode *aNode);
/**
* Return an accessible for a DOM node in the given pres shell.
@ -177,7 +159,7 @@ public:
* @param aNode [in] the given node.
* @param aPresShell [in] the presentation shell of the given node.
*/
nsAccessible *GetAccessibleInWeakShell(nsIDOMNode *aNode,
nsAccessible *GetAccessibleInWeakShell(nsINode *aNode,
nsIWeakReference *aPresShell);
/**
@ -187,18 +169,33 @@ public:
* @param aCanCreate [in] specifies if accessible can be created if it didn't
* exist
*/
nsAccessible *GetContainerAccessible(nsIDOMNode *aNode, PRBool aCanCreate);
nsAccessible *GetContainerAccessible(nsINode *aNode, PRBool aCanCreate);
/**
* Return an access node for the DOM node in the given presentation shell if
* the access node already exists, otherwise null.
* The same as getAccessibleFor method except it returns accessible only if
* it is attached, i.e. accessible is certified to be a descendant of the root
* accessible.
*
* @param aNode [in] the DOM node to get an access node for
* @param aPresShell [in] the presentation shell which contains layout info
* for the DOM node
* XXX: this method must go away once we'll implement correct accessible tree.
*
* @param aNode [in] the DOM node to get an accessible for
* @return the accessible for the given DOM node
*/
nsAccessNode* GetCachedAccessNode(nsIDOMNode *aNode,
nsIWeakReference *aShell);
nsAccessible *GetAttachedAccessibleFor(nsINode *aNode);
/**
* Return an DOM node that is relevant to attached accessible check. This
* node is either from bindings chain if given node is anonymous and owner
* binding denies accessible in anonymous content or given node (it's not
* important whether it is accessible or not). This method doesn't create
* accessible object for returned node.
*
* XXX: this method must go away once we'll implement correct accessible tree.
*
* @param aNode [in] the DOM node to get relevant content node
* @return the DOM node for parent attached accessible
*/
nsINode *GetRelevantContentNodeFor(nsINode *aNode);
/**
* Initialize an accessible and cache it. The method should be called for
@ -213,6 +210,18 @@ public:
PRBool InitAccessible(nsAccessible *aAccessible,
nsRoleMapEntry *aRoleMapEntry);
protected:
/**
* Return an accessible for the DOM node in the given presentation shell if
* the accessible already exists, otherwise null.
*
* @param aNode [in] the DOM node to get an access node for
* @param aPresShell [in] the presentation shell which contains layout info
* for the DOM node
*/
nsAccessible *GetCachedAccessible(nsINode *aNode,
nsIWeakReference *aShell);
private:
// nsAccessibilityService creation is controlled by friend
// NS_GetAccessibilityService, keep constructors private.
@ -234,20 +243,19 @@ private:
/**
* Return presentation shell, DOM node for the given frame.
*
* @param aFrame - the given frame
* @param aShell [out] - presentation shell for DOM node associated with the
* given frame
* @param aContent [out] - DOM node associated with the given frame
* @param aFrame [in] the given frame
* @param aShell [out] presentation shell for DOM node associated with the
* given frame
* @param aContent [out] DOM node associated with the given frame
*/
nsresult GetInfo(nsIFrame *aFrame,
nsIWeakReference **aShell,
nsIDOMNode **aContent);
nsresult GetInfo(nsIFrame *aFrame, nsIWeakReference **aShell,
nsIContent **aContent);
/**
* Return accessible for HTML area element associated with an image map.
*/
already_AddRefed<nsAccessible>
GetAreaAccessible(nsIFrame *aImageFrame, nsIDOMNode *aAreaNode,
GetAreaAccessible(nsIFrame *aImageFrame, nsINode *aAreaNode,
nsIWeakReference *aWeakShell);
/**
@ -255,20 +263,20 @@ private:
* interface.
*/
already_AddRefed<nsAccessible>
CreateAccessibleByType(nsIDOMNode *aNode, nsIWeakReference *aWeakShell);
CreateAccessibleByType(nsIContent *aContent, nsIWeakReference *aWeakShell);
/**
* Create accessible for HTML node by tag name.
*/
already_AddRefed<nsAccessible>
CreateHTMLAccessibleByMarkup(nsIFrame *aFrame, nsIWeakReference *aWeakShell,
nsIDOMNode *aNode);
nsINode *aNode);
/**
* Create accessible if parent is a deck frame.
*/
already_AddRefed<nsAccessible>
CreateAccessibleForDeckChild(nsIFrame *aFrame, nsIDOMNode *aNode,
CreateAccessibleForDeckChild(nsIFrame *aFrame, nsIContent *aContent,
nsIWeakReference *aWeakShell);
#ifdef MOZ_XUL
@ -276,7 +284,8 @@ private:
* Create accessible for XUL tree element.
*/
already_AddRefed<nsAccessible>
CreateAccessibleForXULTree(nsIDOMNode *aNode, nsIWeakReference *aWeakShell);
CreateAccessibleForXULTree(nsIContent *aContent,
nsIWeakReference *aWeakShell);
#endif
/**

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -92,7 +92,7 @@ class nsAccessible : public nsAccessNodeWrap,
public nsIAccessibleValue
{
public:
nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessible();
NS_DECL_ISUPPORTS_INHERITED
@ -107,7 +107,8 @@ public:
//////////////////////////////////////////////////////////////////////////////
// nsAccessNode
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
//////////////////////////////////////////////////////////////////////////////
// Public methods
@ -270,6 +271,13 @@ public:
*/
nsAccessible* GetCachedFirstChild();
#ifdef DEBUG
/**
* Return true if the access node is cached.
*/
PRBool IsInCache();
#endif
//////////////////////////////////////////////////////////////////////////////
// Miscellaneous methods
@ -349,7 +357,7 @@ protected:
* @param aStartNode [in] the DOM node to start from
* @return the resulting accessible
*/
nsAccessible *GetFirstAvailableAccessible(nsIDOMNode *aStartNode) const;
nsAccessible *GetFirstAvailableAccessible(nsINode *aStartNode) const;
// Hyperlink helpers
virtual nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);

Просмотреть файл

@ -64,19 +64,31 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsApplicationAccessible, nsAccessible,
nsIAccessibleApplication)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode
// nsIAccessible
NS_IMETHODIMP
nsApplicationAccessible::GetRootDocument(nsIAccessibleDocument **aRootDocument)
nsApplicationAccessible::GetParent(nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
*aRootDocument = nsnull;
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
NS_IMETHODIMP
nsApplicationAccessible::GetNextSibling(nsIAccessible **aNextSibling)
{
NS_ENSURE_ARG_POINTER(aNextSibling);
*aNextSibling = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetPreviousSibling(nsIAccessible **aPreviousSibling)
{
NS_ENSURE_ARG_POINTER(aPreviousSibling);
*aPreviousSibling = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetName(nsAString& aName)
@ -107,17 +119,30 @@ nsApplicationAccessible::GetName(nsAString& aName)
}
NS_IMETHODIMP
nsApplicationAccessible::GetDescription(nsAString& aValue)
nsApplicationAccessible::GetValue(nsAString &aValue)
{
aValue.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetDescription(nsAString &aDescription)
{
aDescription.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetKeyboardShortcut(nsAString &aKeyboardShortcut)
{
aKeyboardShortcut.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRole(PRUint32 *aRole)
{
NS_ENSURE_ARG_POINTER(aRole);
return GetRoleInternal(aRole);
}
@ -125,21 +150,144 @@ NS_IMETHODIMP
nsApplicationAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
{
NS_ENSURE_ARG_POINTER(aState);
*aState = 0;
if (aExtraState)
*aExtraState = 0;
GetStateInternal(aState, aExtraState);
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetParent(nsIAccessible **aAccessible)
nsApplicationAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nsnull;
return NS_OK;
}
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
NS_IMETHODIMP
nsApplicationAccessible::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup)
{
NS_ENSURE_ARG_POINTER(aGroupLevel);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
nsIAccessible **aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsApplicationAccessible::GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY,
nsIAccessible **aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation)
{
NS_ENSURE_ARG_POINTER(aRelation);
*aRelation = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRelationsCount(PRUint32 *aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRelation(PRUint32 aIndex,
nsIAccessibleRelation **aRelation)
{
NS_ENSURE_ARG_POINTER(aRelation);
*aRelation = nsnull;
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRelations(nsIArray **aRelations)
{
NS_ENSURE_ARG_POINTER(aRelations);
*aRelations = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::SetSelected(PRBool aIsSelected)
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::TakeSelection()
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::TakeFocus()
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetNumActions(PRUint8 *aNumActions)
{
NS_ENSURE_ARG_POINTER(aNumActions);
*aNumActions = 0;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetActionName(PRUint8 aIndex, nsAString &aName)
{
aName.Truncate();
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsApplicationAccessible::GetActionDescription(PRUint8 aIndex,
nsAString &aDescription)
{
aDescription.Truncate();
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsApplicationAccessible::DoAction(PRUint8 aIndex)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
@ -209,23 +357,28 @@ nsApplicationAccessible::IsDefunct()
return nsAccessibilityService::IsShutdown();
}
nsresult
PRBool
nsApplicationAccessible::Init()
{
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
return NS_OK;
return PR_TRUE;
}
nsresult
void
nsApplicationAccessible::Shutdown()
{
mAppInfo = nsnull;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessible public methods
nsresult
nsApplicationAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
{
return NS_OK;
}
nsresult
nsApplicationAccessible::GetRoleInternal(PRUint32 *aRole)
{
@ -238,6 +391,14 @@ nsApplicationAccessible::GetStateInternal(PRUint32 *aState,
PRUint32 *aExtraState)
{
*aState = 0;
if (IsDefunct()) {
if (aExtraState)
*aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT;
return NS_OK_DEFUNCT_OBJECT;
}
if (aExtraState)
*aExtraState = 0;
@ -345,3 +506,91 @@ nsApplicationAccessible::RemoveRootAccessible(nsIAccessible *aRootAccessible)
// properly.
return mChildren.RemoveElement(aRootAccessible) ? NS_OK : NS_ERROR_FAILURE;
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode
NS_IMETHODIMP
nsApplicationAccessible::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetDocument(nsIAccessibleDocument **aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetRootDocument(nsIAccessibleDocument **aRootDocument)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
*aRootDocument = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetInnerHTML(nsAString &aInnerHTML)
{
aInnerHTML.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::ScrollTo(PRUint32 aScrollType)
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::ScrollToPoint(PRUint32 aCoordinateType,
PRInt32 aX, PRInt32 aY)
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetOwnerWindow(void **aOwnerWindow)
{
NS_ENSURE_ARG_POINTER(aOwnerWindow);
*aOwnerWindow = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetUniqueID(void **aUniqueID)
{
NS_ENSURE_ARG_POINTER(aUniqueID);
*aUniqueID = static_cast<void *>(this);
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetComputedStyleValue(const nsAString &aPseudoElt,
const nsAString &aPropertyName,
nsAString &aValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetComputedStyleCSSValue(const nsAString &aPseudoElt,
const nsAString &aPropertyName,
nsIDOMCSSPrimitiveValue **aCSSPrimitiveValue)
{
NS_ENSURE_ARG_POINTER(aCSSPrimitiveValue);
*aCSSPrimitiveValue = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsApplicationAccessible::GetLanguage(nsAString &aLanguage)
{
aLanguage.Truncate();
return NS_OK;
}

Просмотреть файл

@ -69,25 +69,48 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessNode
NS_IMETHOD GetRootDocument(nsIAccessibleDocument **aRootDocument);
NS_DECL_NSIACCESSNODE
// nsIAccessible
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetDescription(nsAString& aValue);
NS_IMETHOD GetParent(nsIAccessible **aParent);
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
NS_IMETHOD GetName(nsAString &aName);
NS_IMETHOD GetValue(nsAString &aValue);
NS_IMETHOD GetDescription(nsAString &aDescription);
NS_IMETHOD GetKeyboardShortcut(nsAString &aKeyboardShortcut);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
NS_IMETHOD GetParent(nsIAccessible **aAccessible);
NS_IMETHOD GetState(PRUint32 *aState , PRUint32 *aExtraState );
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup);
NS_IMETHOD GetChildAtPoint(PRInt32 aX, PRInt32 aY, nsIAccessible **aChild);
NS_IMETHOD GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY, nsIAccessible **aChild);
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
NS_IMETHOD GetRelationsCount(PRUint32 *aRelationsCount);
NS_IMETHOD GetRelation(PRUint32 aIndex, nsIAccessibleRelation **aRelation);
NS_IMETHOD GetRelations(nsIArray **aRelations);
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD SetSelected(PRBool aIsSelected);
NS_IMETHOD TakeSelection();
NS_IMETHOD TakeFocus();
NS_IMETHOD GetNumActions(PRUint8 *aNumActions);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString &aName);
NS_IMETHOD GetActionDescription(PRUint8 aIndex, nsAString &aDescription);
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsIAccessibleApplication
NS_DECL_NSIACCESSIBLEAPPLICATION
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsAccessible* GetParent();

Просмотреть файл

@ -56,8 +56,9 @@
// nsLeafAccessible
////////////////////////////////////////////////////////////////////////////////
nsLeafAccessible::nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsAccessibleWrap(aNode, aShell)
nsLeafAccessible::
nsLeafAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
@ -91,8 +92,8 @@ nsLeafAccessible::CacheChildren()
////////////////////////////////////////////////////////////////////////////////
nsLinkableAccessible::
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsAccessibleWrap(aNode, aShell),
nsLinkableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell),
mActionContent(nsnull),
mIsLink(PR_FALSE),
mIsOnclick(PR_FALSE)
@ -227,18 +228,18 @@ nsLinkableAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
////////////////////////////////////////////////////////////////////////////////
// nsLinkableAccessible. nsAccessNode
nsresult
PRBool
nsLinkableAccessible::Init()
{
CacheActionContent();
return nsAccessibleWrap::Init();
}
nsresult
void
nsLinkableAccessible::Shutdown()
{
mActionContent = nsnull;
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@ -247,7 +248,7 @@ nsLinkableAccessible::Shutdown()
void
nsLinkableAccessible::CacheActionContent()
{
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
nsIContent* walkUpContent = mContent;
PRBool isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
if (isOnclick) {
@ -258,11 +259,8 @@ nsLinkableAccessible::CacheActionContent()
while ((walkUpContent = walkUpContent->GetParent())) {
isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
nsCOMPtr<nsIDOMNode> walkUpNode(do_QueryInterface(walkUpContent));
nsAccessible *walkUpAcc =
GetAccService()->GetAccessibleInWeakShell(walkUpNode, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(walkUpContent, mWeakShell);
if (nsAccUtils::Role(walkUpAcc) == nsIAccessibleRole::ROLE_LINK &&
nsAccUtils::State(walkUpAcc) & nsIAccessibleStates::STATE_LINKED) {
@ -286,20 +284,20 @@ nsLinkableAccessible::GetActionAccessible() const
// this accessible. If the action accessible is not null then it is used to
// redirect methods calls otherwise we use method implementation from the
// base class.
nsCOMPtr<nsIDOMNode> actionNode(do_QueryInterface(mActionContent));
if (!actionNode || mDOMNode == actionNode)
if (!mActionContent || mContent == mActionContent)
return nsnull;
return GetAccService()->GetAccessibleInWeakShell(actionNode, mWeakShell);
return GetAccService()->GetAccessibleInWeakShell(mActionContent, mWeakShell);
}
//---------------------
////////////////////////////////////////////////////////////////////////////////
// nsEnumRoleAccessible
//---------------------
////////////////////////////////////////////////////////////////////////////////
nsEnumRoleAccessible::nsEnumRoleAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell, PRUint32 aRole) :
nsAccessibleWrap(aNode, aShell),
mRole(aRole)
nsEnumRoleAccessible::
nsEnumRoleAccessible(nsIContent *aNode, nsIWeakReference *aShell,
PRUint32 aRole) :
nsAccessibleWrap(aNode, aShell), mRole(aRole)
{
}

Просмотреть файл

@ -43,8 +43,6 @@
#include "nsHyperTextAccessibleWrap.h"
#include "nsIContent.h"
class nsIDOMNode;
/**
* This file contains a number of classes that are used as base
* classes for the different accessibility implementations of
@ -57,7 +55,7 @@ class nsIDOMNode;
class nsLeafAccessible : public nsAccessibleWrap
{
public:
nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsLeafAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -84,7 +82,7 @@ class nsLinkableAccessible : public nsAccessibleWrap
public:
enum { eAction_Jump = 0 };
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsLinkableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
@ -100,8 +98,8 @@ public:
NS_IMETHOD GetURI(PRInt32 i, nsIURI **aURI);
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
@ -128,7 +126,8 @@ protected:
class nsEnumRoleAccessible : public nsAccessibleWrap
{
public:
nsEnumRoleAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell, PRUint32 aRole);
nsEnumRoleAccessible(nsIContent *aContent, nsIWeakReference *aShell,
PRUint32 aRole);
virtual ~nsEnumRoleAccessible() { }
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -110,7 +110,8 @@ nsresult nsCaretAccessible::ClearControlSelectionListener()
return selPrivate->RemoveSelectionListener(this);
}
nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode)
nsresult
nsCaretAccessible::SetControlSelectionListener(nsIContent *aCurrentNode)
{
NS_ENSURE_TRUE(mRootAccessible, NS_ERROR_FAILURE);
@ -126,10 +127,7 @@ nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode
nsCOMPtr<nsISelectionController> controller =
GetSelectionControllerForNode(mCurrentControl);
#ifdef DEBUG
PRUint16 nodeType;
nsresult result = aCurrentNode->GetNodeType(&nodeType);
NS_ASSERTION(NS_SUCCEEDED(result) &&
(controller || nodeType == nsIDOMNode::DOCUMENT_NODE),
NS_ASSERTION(controller || aCurrentNode->IsNodeOfType(nsINode::eDOCUMENT),
"No selection controller for non document node!");
#endif
if (!controller)
@ -247,8 +245,8 @@ nsCaretAccessible::NormalSelectionChanged(nsIDOMDocument *aDoc,
return NS_OK; // No selection
}
nsCOMPtr<nsIDOMNode> textNode;
nsCOMPtr<nsIAccessibleText> textAcc =
nsCOMPtr<nsINode> textNode;
nsRefPtr<nsHyperTextAccessible> textAcc =
nsAccUtils::GetTextAccessibleFromSelection(aSel, getter_AddRefs(textNode));
NS_ENSURE_STATE(textAcc);
@ -264,7 +262,7 @@ nsCaretAccessible::NormalSelectionChanged(nsIDOMDocument *aDoc,
}
}
mLastCaretOffset = caretOffset;
mLastTextAccessible = textAcc;
mLastTextAccessible.swap(textAcc);
nsRefPtr<nsAccEvent> event =
new nsAccCaretMoveEvent(textNode);
@ -283,15 +281,13 @@ nsCaretAccessible::SpellcheckSelectionChanged(nsIDOMDocument *aDoc,
// misspelled word). If spellchecking is disabled (for example,
// @spellcheck="false" on html:body) then we won't fire any event.
nsCOMPtr<nsIAccessibleText> textAcc =
nsRefPtr<nsHyperTextAccessible> textAcc =
nsAccUtils::GetTextAccessibleFromSelection(aSel);
NS_ENSURE_STATE(textAcc);
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(textAcc));
nsRefPtr<nsAccEvent> event =
new nsAccEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
acc, nsnull);
textAcc, nsnull);
nsEventShell::FireEvent(event);
return NS_OK;
@ -309,15 +305,10 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
return caretRect; // Return empty rect
}
nsCOMPtr<nsIAccessNode> lastAccessNode(do_QueryInterface(mLastTextAccessible));
NS_ENSURE_TRUE(lastAccessNode, caretRect);
nsCOMPtr<nsIDOMNode> lastNodeWithCaret;
lastAccessNode->GetDOMNode(getter_AddRefs(lastNodeWithCaret));
nsINode *lastNodeWithCaret = mLastTextAccessible->GetNode();
NS_ENSURE_TRUE(lastNodeWithCaret, caretRect);
nsIPresShell *presShell =
nsCoreUtils::GetPresShellFor(lastNodeWithCaret);
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(lastNodeWithCaret);
NS_ENSURE_TRUE(presShell, caretRect);
nsRefPtr<nsCaret> caret = presShell->GetCaret();
@ -361,25 +352,20 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
}
already_AddRefed<nsISelectionController>
nsCaretAccessible::GetSelectionControllerForNode(nsIDOMNode *aNode)
nsCaretAccessible::GetSelectionControllerForNode(nsIContent *aContent)
{
if (!aNode)
if (!aContent)
return nsnull;
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode);
nsIDocument *document = aContent->GetOwnerDoc();
if (!document)
return nsnull;
nsIPresShell *presShell = document->GetPrimaryShell();
if (!presShell)
return nsnull;
nsCOMPtr<nsIDocument> doc = presShell->GetDocument();
if (!doc)
return nsnull;
// Get selection controller only for form controls, not for the document.
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (!content)
return nsnull;
nsIFrame *frame = content->GetPrimaryFrame();
nsIFrame *frame = aContent->GetPrimaryFrame();
if (!frame)
return nsnull;

Просмотреть файл

@ -38,17 +38,11 @@
#ifndef __nsCaretAccessible_h__
#define __nsCaretAccessible_h__
#include "nsIWeakReference.h"
#include "nsIAccessibleText.h"
#include "nsIDOMNode.h"
#include "nsHyperTextAccessible.h"
#include "nsISelectionListener.h"
#include "nsISelectionController.h"
#include "nsRect.h"
class nsRootAccessible;
class nsIView;
class nsIPresShell;
class nsIWidget;
/*
* This special accessibility class is for the caret, which is really the currently focused selection.
@ -92,7 +86,7 @@ public:
* to via AddDocSelectionListener().
* @param aFocusedNode The node for the focused control
*/
nsresult SetControlSelectionListener(nsIDOMNode *aCurrentNode);
nsresult SetControlSelectionListener(nsIContent *aCurrentNode);
/**
* Stop listening to selection events for any control.
@ -125,21 +119,26 @@ protected:
nsresult NormalSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel);
nsresult SpellcheckSelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel);
/**
* Return selection controller for the given node.
*/
already_AddRefed<nsISelectionController>
GetSelectionControllerForNode(nsIDOMNode *aNode);
GetSelectionControllerForNode(nsIContent *aNode);
private:
// The currently focused control -- never a document.
// We listen to selection for one control at a time (the focused one)
// Document selection is handled separately via additional listeners on all active documents
// The current control is set via SetControlSelectionListener()
nsCOMPtr<nsIDOMNode> mCurrentControl; // Selection controller for the currently focused control
// Currently focused control.
nsCOMPtr<nsIContent> mCurrentControl;
// Info for the the last selection event.
// If it was on a control, then its control's selection. Otherwise, it's for
// a document where the selection changed.
nsCOMPtr<nsIWeakReference> mLastUsedSelection; // Weak ref to nsISelection
nsCOMPtr<nsIAccessibleText> mLastTextAccessible;
nsRefPtr<nsHyperTextAccessible> mLastTextAccessible;
PRInt32 mLastCaretOffset;
nsRootAccessible *mRootAccessible;

Просмотреть файл

@ -236,38 +236,16 @@ nsCoreUtils::GetAccessKeyFor(nsIContent *aContent)
return key;
}
already_AddRefed<nsIDOMElement>
nsCoreUtils::GetDOMElementFor(nsIDOMNode *aNode)
nsIContent *
nsCoreUtils::GetDOMElementFor(nsIContent *aContent)
{
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
nsIDOMElement *element = nsnull;
if (aContent->IsElement())
return aContent;
if (node->IsElement())
CallQueryInterface(node, &element);
if (aContent->IsNodeOfType(nsINode::eTEXT))
return aContent->GetParent();
else if (node->IsNodeOfType(nsINode::eTEXT)) {
nsCOMPtr<nsINode> nodeParent = node->GetNodeParent();
NS_ASSERTION(nodeParent, "Text node has no parent!");
if (nodeParent)
CallQueryInterface(nodeParent, &element);
}
else if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(node));
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
htmlDoc->GetBody(getter_AddRefs(bodyElement));
if (bodyElement) {
CallQueryInterface(bodyElement, &element);
return element;
}
}
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(node));
domDoc->GetDocumentElement(&element);
}
return element;
return nsnull;
}
nsINode *
@ -289,13 +267,13 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsINode *aNode, PRUint32 aOffset)
}
nsIContent*
nsCoreUtils::GetRoleContent(nsIDOMNode *aDOMNode)
nsCoreUtils::GetRoleContent(nsINode *aNode)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (!content) {
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aNode));
if (domDoc) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(aNode));
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
htmlDoc->GetBody(getter_AddRefs(bodyElement));
@ -320,7 +298,8 @@ nsCoreUtils::IsAncestorOf(nsINode *aPossibleAncestorNode,
NS_ENSURE_TRUE(aPossibleAncestorNode && aPossibleDescendantNode, PR_FALSE);
nsINode *parentNode = aPossibleDescendantNode;
while ((parentNode = parentNode->GetNodeParent()) != aRootNode) {
while ((parentNode = parentNode->GetNodeParent()) &&
parentNode != aRootNode) {
if (parentNode == aPossibleAncestorNode)
return PR_TRUE;
}
@ -443,7 +422,7 @@ nsCoreUtils::ConvertScrollTypeToPercents(PRUint32 aScrollType,
}
nsIntPoint
nsCoreUtils::GetScreenCoordsForWindow(nsIDOMNode *aNode)
nsCoreUtils::GetScreenCoordsForWindow(nsINode *aNode)
{
nsIntPoint coords(0, 0);
nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShellTreeItemFor(aNode));
@ -469,17 +448,12 @@ nsCoreUtils::GetScreenCoordsForWindow(nsIDOMNode *aNode)
}
already_AddRefed<nsIDocShellTreeItem>
nsCoreUtils::GetDocShellTreeItemFor(nsIDOMNode *aNode)
nsCoreUtils::GetDocShellTreeItemFor(nsINode *aNode)
{
if (!aNode)
return nsnull;
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
if (!doc)
doc = do_QueryInterface(aNode);
nsIDocument *doc = aNode->GetOwnerDoc();
NS_ASSERTION(doc, "No document for node passed in");
NS_ENSURE_TRUE(doc, nsnull);
@ -551,16 +525,6 @@ nsCoreUtils::IsErrorPage(nsIDocument *aDocument)
return FindInReadable(neterror, start, end);
}
nsIFrame*
nsCoreUtils::GetFrameFor(nsIDOMElement *aElm)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aElm));
if (!content)
return nsnull;
return content->GetPrimaryFrame();
}
PRBool
nsCoreUtils::IsCorrectFrameType(nsIFrame *aFrame, nsIAtom *aAtom)
{
@ -956,28 +920,27 @@ nsCoreUtils::GetElementsHavingIDRefsAttrImpl(nsIContent *aRootContent,
}
}
void
already_AddRefed<nsIDOMCSSStyleDeclaration>
nsCoreUtils::GetComputedStyleDeclaration(const nsAString& aPseudoElt,
nsIDOMNode *aNode,
nsIDOMCSSStyleDeclaration **aCssDecl)
nsIContent *aContent)
{
*aCssDecl = nsnull;
nsCOMPtr<nsIDOMElement> domElement = GetDOMElementFor(aNode);
if (!domElement)
return;
nsIContent* content = GetDOMElementFor(aContent);
if (!content)
return nsnull;
// Returns number of items in style declaration
nsCOMPtr<nsIContent> content = do_QueryInterface(domElement);
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return;
nsIDocument* document = content->GetOwnerDoc();
if (!document)
return nsnull;
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(doc->GetWindow()));
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(document->GetWindow()));
if (!viewCSS)
return;
return nsnull;
viewCSS->GetComputedStyle(domElement, aPseudoElt, aCssDecl);
nsIDOMCSSStyleDeclaration* cssDecl = nsnull;
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(content));
viewCSS->GetComputedStyle(domElement, aPseudoElt, &cssDecl);
return cssDecl;
}
already_AddRefed<nsIBoxObject>
@ -994,36 +957,28 @@ nsCoreUtils::GetTreeBodyBoxObject(nsITreeBoxObject *aTreeBoxObj)
return boxObj;
}
void
nsCoreUtils::GetTreeBoxObject(nsIDOMNode *aDOMNode,
nsITreeBoxObject **aBoxObject)
already_AddRefed<nsITreeBoxObject>
nsCoreUtils::GetTreeBoxObject(nsIContent *aContent)
{
nsAutoString name;
nsCOMPtr<nsIDOMNode> parentNode, currentNode;
// Find DOMNode's parents recursively until reach the <tree> tag
currentNode = aDOMNode;
while (currentNode) {
currentNode->GetLocalName(name);
if (name.EqualsLiteral("tree")) {
nsIContent* currentContent = aContent;
while (currentContent) {
if (currentContent->NodeInfo()->Equals(nsAccessibilityAtoms::tree,
kNameSpaceID_XUL)) {
// We will get the nsITreeBoxObject from the tree node
nsCOMPtr<nsIDOMXULElement> xulElement(do_QueryInterface(currentNode));
nsCOMPtr<nsIDOMXULElement> xulElement(do_QueryInterface(currentContent));
if (xulElement) {
nsCOMPtr<nsIBoxObject> box;
xulElement->GetBoxObject(getter_AddRefs(box));
nsCOMPtr<nsITreeBoxObject> treeBox(do_QueryInterface(box));
if (treeBox) {
*aBoxObject = treeBox;
NS_ADDREF(*aBoxObject);
return;
}
if (treeBox)
return treeBox.forget();
}
}
currentNode->GetParentNode(getter_AddRefs(parentNode));
currentNode = parentNode;
currentContent = currentContent->GetParent();
}
*aBoxObject = nsnull;
return nsnull;
}
already_AddRefed<nsITreeColumn>
@ -1141,20 +1096,19 @@ nsCoreUtils::IsColumnHidden(nsITreeColumn *aColumn)
}
void
nsCoreUtils::GeneratePopupTree(nsIDOMNode *aNode, PRBool aIsAnon)
nsCoreUtils::GeneratePopupTree(nsIContent *aContent, PRBool aIsAnon)
{
// Set menugenerated="true" on the menupopup node to generate the sub-menu
// items if they have not been generated.
nsCOMPtr<nsIDOMNodeList> list;
if (aIsAnon) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
nsIDocument* document = content->GetCurrentDoc();
if (aIsAnon) {
nsIDocument* document = aContent->GetCurrentDoc();
if (document)
document->GetXBLChildNodesFor(content, getter_AddRefs(list));
document->GetXBLChildNodesFor(aContent, getter_AddRefs(list));
} else {
aNode->GetChildNodes(getter_AddRefs(list));
list = aContent->GetChildNodesList();
}
PRUint32 length = 0;

Просмотреть файл

@ -119,12 +119,11 @@ public:
* Return DOM element related with the given node, i.e.
* a) itself if it is DOM element
* b) parent element if it is text node
* c) body element if it is HTML document node
* d) document element if it is document node.
* c) otherwise nsnull
*
* @param aNode [in] the given DOM node
*/
static already_AddRefed<nsIDOMElement> GetDOMElementFor(nsIDOMNode *aNode);
static nsIContent* GetDOMElementFor(nsIContent *aContent);
/**
* Return DOM node for the given DOM point.
@ -135,12 +134,12 @@ public:
* Return the nsIContent* to check for ARIA attributes on -- this may not
* always be the DOM node for the accessible. Specifically, for doc
* accessibles, it is not the document node, but either the root element or
* <body> in HTML. Similar with GetDOMElementFor() method.
* <body> in HTML.
*
* @param aDOMNode DOM node for the accessible that may be affected by ARIA
* @return the nsIContent which may have ARIA markup
* @param aNode [in] DOM node for the accessible that may be affected by ARIA
* @return the nsIContent which may have ARIA markup
*/
static nsIContent *GetRoleContent(nsIDOMNode *aDOMNode);
static nsIContent* GetRoleContent(nsINode *aNode);
/**
* Is the first passed in node an ancestor of the second?
@ -215,13 +214,13 @@ public:
*
* @param aNode the DOM node hosted in the window.
*/
static nsIntPoint GetScreenCoordsForWindow(nsIDOMNode *aNode);
static nsIntPoint GetScreenCoordsForWindow(nsINode *aNode);
/**
* Return document shell tree item for the given DOM node.
*/
static already_AddRefed<nsIDocShellTreeItem>
GetDocShellTreeItemFor(nsIDOMNode *aNode);
GetDocShellTreeItemFor(nsINode *aNode);
/**
* Return true if document is loading.
@ -243,11 +242,6 @@ public:
*/
static PRBool IsErrorPage(nsIDocument *aDocument);
/**
* Retrun frame for the given DOM element.
*/
static nsIFrame* GetFrameFor(nsIDOMElement *aElm);
/**
* Retrun true if the type of given frame equals to the given frame type.
*
@ -259,12 +253,17 @@ public:
/**
* Return presShell for the document containing the given DOM node.
*/
static nsIPresShell *GetPresShellFor(nsIDOMNode *aNode)
static nsIPresShell *GetPresShellFor(nsINode *aNode)
{
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
nsIDocument *document = node->GetOwnerDoc();
nsIDocument *document = aNode->GetOwnerDoc();
return document ? document->GetPrimaryShell() : nsnull;
}
static already_AddRefed<nsIWeakReference> GetWeakShellFor(nsINode *aNode)
{
nsCOMPtr<nsIWeakReference> weakShell =
do_GetWeakReference(GetPresShellFor(aNode));
return weakShell.forget();
}
/**
* Return document node for the given document shell tree item.
@ -340,9 +339,9 @@ public:
/**
* Return computed styles declaration for the given node.
*/
static void GetComputedStyleDeclaration(const nsAString& aPseudoElt,
nsIDOMNode *aNode,
nsIDOMCSSStyleDeclaration **aCssDecl);
static already_AddRefed<nsIDOMCSSStyleDeclaration>
GetComputedStyleDeclaration(const nsAString& aPseudoElt,
nsIContent *aContent);
/**
* Search element in neighborhood of the given element by tag name and
@ -432,8 +431,8 @@ public:
/**
* Return tree box object from any levels DOMNode under the XUL tree.
*/
static void
GetTreeBoxObject(nsIDOMNode* aDOMNode, nsITreeBoxObject** aBoxObject);
static already_AddRefed<nsITreeBoxObject>
GetTreeBoxObject(nsIContent* aContent);
/**
* Return first sensible column for the given tree box object.
@ -487,11 +486,12 @@ public:
/**
* Generates frames for popup subtree.
*
* @param aNode [in] DOM node containing the menupopup element as a child
* @param aContent [in] DOM node containing the menupopup element as a child
* @param aIsAnon [in] specifies whether popup should be searched inside of
* anonymous or explicit content
*/
static void GeneratePopupTree(nsIDOMNode *aNode, PRBool aIsAnon = PR_FALSE);
static void GeneratePopupTree(nsIContent *aContent,
PRBool aIsAnon = PR_FALSE);
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -82,7 +82,8 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
NS_DECL_NSIOBSERVER
public:
nsDocAccessible(nsIDOMNode *aNode, nsIWeakReference* aShell);
nsDocAccessible(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference* aShell);
virtual ~nsDocAccessible();
// nsIAccessible
@ -100,10 +101,11 @@ public:
NS_DECL_NSIDOCUMENTOBSERVER
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
virtual nsIFrame* GetFrame();
virtual PRBool IsDefunct();
virtual nsINode* GetNode() const { return mDocument; }
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -122,8 +124,6 @@ public:
// nsDocAccessible
nsIDocument *GetDOMDocument() const { return mDocument; }
/**
* Return true if associated DOM document was loaded and isn't unloading.
*/
@ -149,7 +149,7 @@ public:
* @param aIsAsynch [in] set to PR_TRUE if this is not being called from
* code synchronous with a DOM event
*/
nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsIDOMNode *aDOMNode,
nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
nsAccEvent::EEventRule aAllowDupes = nsAccEvent::eRemoveDupes,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
@ -176,31 +176,31 @@ public:
void InvalidateCacheSubtree(nsIContent *aContent, PRUint32 aEvent);
/**
* Return the cached access node by the given unique ID if it's in subtree of
* Return the cached accessible by the given unique ID if it's in subtree of
* this document accessible or the document accessible itself, otherwise null.
*
* @note the unique ID matches with the uniqueID attribute on nsIAccessNode
*
* @param aUniqueID [in] the unique ID used to cache the node.
*
* @return the access node object
* @return the accessible object
*/
nsAccessNode* GetCachedAccessNode(void *aUniqueID);
nsAccessible* GetCachedAccessible(void *aUniqueID);
/**
* Cache the access node.
* Cache the accessible.
*
* @param aUniquID [in] the unique identifier of accessible
* @param aAccessNode [in] accessible to cache
* @param aAccessible [in] accessible to cache
*
* @return true if node beign cached, otherwise false
* @return true if accessible being cached, otherwise false
*/
PRBool CacheAccessNode(void *aUniqueID, nsAccessNode *aAccessNode);
PRBool CacheAccessible(void *aUniqueID, nsAccessible *aAccessible);
/**
* Remove the given access node from document cache.
* Remove the given accessible from document cache.
*/
void RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode);
void RemoveAccessNodeFromCache(nsAccessible *aAccessible);
/**
* Process the event when the queue of pending events is untwisted. Fire
@ -223,9 +223,13 @@ protected:
* @param aStartNode [in] the root of the subrtee to invalidate accessible
* child/parent refs in
*/
void InvalidateChildrenInSubtree(nsIDOMNode *aStartNode);
void InvalidateChildrenInSubtree(nsINode *aStartNode);
/**
* Traverse through DOM tree and shutdown accessible objects.
*/
void RefreshNodes(nsINode *aStartNode);
void RefreshNodes(nsIDOMNode *aStartNode);
static void ScrollTimerCallback(nsITimer *aTimer, void *aClosure);
/**
@ -262,7 +266,7 @@ protected:
* Create a text change event for a changed node.
*
* @param aContainerAccessible [in] the parent accessible for the node
* @param aNode [in] the node that is being inserted or
* @param aChangeNode [in] the node that is being inserted or
* removed, or shown/hidden
* @param aAccessible [in] the accessible for that node, or nsnull
* if none exists
@ -273,7 +277,7 @@ protected:
*/
already_AddRefed<nsAccEvent>
CreateTextChangeEventForNode(nsAccessible *aContainerAccessible,
nsIDOMNode *aNode,
nsIContent *aChangeNode,
nsAccessible *aAccessible,
PRBool aIsInserting,
PRBool aIsAsynch,
@ -299,18 +303,23 @@ protected:
* @param aIsAsyncChange [in] whether casual change is async
* @param aIsFromUserInput [in] the event is known to be from user input
*/
nsresult FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNode,
nsresult FireShowHideEvents(nsINode *aDOMNode, PRBool aAvoidOnThisNode,
PRUint32 aEventType,
EEventFiringType aDelayedOrNormal,
PRBool aIsAsyncChange,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
/**
* If the given accessible object is a ROLE_ENTRY, fire a value change event for it
*/
void FireValueChangeForTextFields(nsIAccessible *aPossibleTextFieldAccessible);
/**
* Fire a value change event for the the given accessible if it is a text
* field (has a ROLE_ENTRY).
*/
void FireValueChangeForTextFields(nsAccessible *aAccessible);
/**
* Cache of accessibles within this document accessible.
*/
nsAccessibleHashtable mAccessibleCache;
nsAccessNodeHashtable mAccessNodeCache;
void *mWnd;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsITimer> mScrollWatchTimer;

Просмотреть файл

@ -52,23 +52,22 @@ nsEventShell::FireEvent(nsAccEvent *aEvent)
if (!aEvent)
return;
nsRefPtr<nsAccessible> acc = do_QueryObject(aEvent->GetAccessible());
NS_ENSURE_TRUE(acc,);
nsAccessible *accessible = aEvent->GetAccessible();
NS_ENSURE_TRUE(accessible,);
nsCOMPtr<nsIDOMNode> node;
aEvent->GetDOMNode(getter_AddRefs(node));
nsINode* node = aEvent->GetNode();
if (node) {
sEventTargetNode = node;
sEventFromUserInput = aEvent->IsFromUserInput();
}
acc->HandleAccEvent(aEvent);
accessible->HandleAccEvent(aEvent);
sEventTargetNode = nsnull;
}
void
nsEventShell::FireEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
nsEventShell::FireEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsynch, EIsFromUserInput aIsFromUserInput)
{
NS_ENSURE_TRUE(aAccessible,);
@ -80,7 +79,7 @@ nsEventShell::FireEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
}
void
nsEventShell::GetEventAttributes(nsIDOMNode *aNode,
nsEventShell::GetEventAttributes(nsINode *aNode,
nsIPersistentProperties *aAttributes)
{
if (aNode != sEventTargetNode)
@ -95,7 +94,7 @@ nsEventShell::GetEventAttributes(nsIDOMNode *aNode,
// nsEventShell: private
PRBool nsEventShell::sEventFromUserInput = PR_FALSE;
nsCOMPtr<nsIDOMNode> nsEventShell::sEventTargetNode;
nsCOMPtr<nsINode> nsEventShell::sEventTargetNode;
////////////////////////////////////////////////////////////////////////////////
@ -103,7 +102,7 @@ nsCOMPtr<nsIDOMNode> nsEventShell::sEventTargetNode;
////////////////////////////////////////////////////////////////////////////////
nsAccEventQueue::nsAccEventQueue(nsDocAccessible *aDocument):
mProcessingStarted(PR_FALSE), mDocument(aDocument), mFlushingEventsCount(0)
mObservingRefresh(PR_FALSE), mDocument(aDocument)
{
}
@ -158,6 +157,13 @@ nsAccEventQueue::Push(nsAccEvent *aEvent)
void
nsAccEventQueue::Shutdown()
{
if (mObservingRefresh) {
nsCOMPtr<nsIPresShell> shell = mDocument->GetPresShell();
if (!shell ||
shell->RemoveRefreshObserver(this, Flush_Display)) {
mObservingRefresh = PR_FALSE;
}
}
mDocument = nsnull;
mEvents.Clear();
}
@ -170,14 +176,19 @@ nsAccEventQueue::PrepareFlush()
{
// If there are pending events in the queue and events flush isn't planed
// yet start events flush asynchronously.
if (mEvents.Length() > 0 && !mProcessingStarted) {
NS_DISPATCH_RUNNABLEMETHOD(Flush, this)
mProcessingStarted = PR_TRUE;
if (mEvents.Length() > 0 && !mObservingRefresh) {
nsCOMPtr<nsIPresShell> shell = mDocument->GetPresShell();
// Use a Flush_Display observer so that it will get called after
// style and ayout have been flushed.
if (shell &&
shell->AddRefreshObserver(this, Flush_Display)) {
mObservingRefresh = PR_TRUE;
}
}
}
void
nsAccEventQueue::Flush()
nsAccEventQueue::WillRefresh(mozilla::TimeStamp aTime)
{
// If the document accessible is now shut down, don't fire events in it
// anymore.
@ -188,42 +199,31 @@ nsAccEventQueue::Flush()
if (!presShell)
return;
// Flush layout so that all the frame construction, reflow, and styles are
// up-to-date. This will ensure we can get frames for the related nodes, as
// well as get the most current information for calculating things like
// visibility. We don't flush the display because we don't care about
// painting. If no flush is necessary the method will simple return.
presShell->FlushPendingNotifications(Flush_Layout);
// Process only currently queued events. Newly appended events during events
// flushing won't be processed.
mFlushingEventsCount = mEvents.Length();
NS_ASSERTION(mFlushingEventsCount,
"How did we get here without events to fire?");
nsTArray < nsRefPtr<nsAccEvent> > 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 < mFlushingEventsCount; index ++) {
for (PRUint32 index = 0; index < length; index ++) {
// No presshell means the document was shut down during event handling
// by AT.
if (!mDocument || !mDocument->HasWeakShell())
break;
nsAccEvent *accEvent = mEvents[index];
nsAccEvent *accEvent = events[index];
if (accEvent->mEventRule != nsAccEvent::eDoNotEmit)
mDocument->ProcessPendingEvent(accEvent);
}
// Mark we are ready to start event processing again.
mProcessingStarted = PR_FALSE;
// If the document accessible is alive then remove processed events from the
// queue (otherwise they were removed on shutdown already) and reinitialize
// queue processing callback if necessary (new events might occur duiring
// delayed event processing).
if (mDocument && mDocument->HasWeakShell()) {
mEvents.RemoveElementsAt(0, mFlushingEventsCount);
mFlushingEventsCount = 0;
PrepareFlush();
if (mEvents.Length() == 0) {
nsCOMPtr<nsIPresShell> shell = mDocument->GetPresShell();
if (!shell ||
shell->RemoveRefreshObserver(this, Flush_Display)) {
mObservingRefresh = PR_FALSE;
}
}
}
@ -242,7 +242,7 @@ nsAccEventQueue::CoalesceEvents()
switch(tailEvent->mEventRule) {
case nsAccEvent::eCoalesceFromSameSubtree:
{
for (PRInt32 index = tail - 1; index >= mFlushingEventsCount; index--) {
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventType != tailEvent->mEventType)
@ -366,7 +366,7 @@ nsAccEventQueue::CoalesceEvents()
// Do not emit thisEvent, also apply this result to sibling nodes of
// thisNode.
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
ApplyToSiblings(mFlushingEventsCount, index, thisEvent->mEventType,
ApplyToSiblings(0, index, thisEvent->mEventType,
thisEvent->mNode, nsAccEvent::eDoNotEmit);
continue;
}
@ -387,7 +387,7 @@ nsAccEventQueue::CoalesceEvents()
// 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 >= mFlushingEventsCount; index--) {
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventType == tailEvent->mEventType &&
thisEvent->mEventRule == tailEvent->mEventRule &&
@ -402,7 +402,7 @@ nsAccEventQueue::CoalesceEvents()
{
// Check for repeat events, coalesce newly appended event by more older
// event.
for (PRInt32 index = tail - 1; index >= mFlushingEventsCount; index--) {
for (PRInt32 index = tail - 1; index >= 0; index--) {
nsAccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule &&
@ -438,14 +438,14 @@ nsAccEventQueue::CoalesceReorderEventsFromSameSource(nsAccEvent *aAccEvent1,
nsAccEvent *aAccEvent2)
{
// Do not emit event2 if event1 is unconditional.
nsCOMPtr<nsAccReorderEvent> reorderEvent1 = do_QueryInterface(aAccEvent1);
nsAccReorderEvent *reorderEvent1 = downcast_accEvent(aAccEvent1);
if (reorderEvent1->IsUnconditionalEvent()) {
aAccEvent2->mEventRule = nsAccEvent::eDoNotEmit;
return;
}
// Do not emit event1 if event2 is unconditional.
nsCOMPtr<nsAccReorderEvent> reorderEvent2 = do_QueryInterface(aAccEvent2);
nsAccReorderEvent *reorderEvent2 = downcast_accEvent(aAccEvent2);
if (reorderEvent2->IsUnconditionalEvent()) {
aAccEvent1->mEventRule = nsAccEvent::eDoNotEmit;
return;
@ -463,7 +463,7 @@ nsAccEventQueue::CoalesceReorderEventsFromSameTree(nsAccEvent *aAccEvent,
nsAccEvent *aDescendantAccEvent)
{
// Do not emit descendant event if this event is unconditional.
nsCOMPtr<nsAccReorderEvent> reorderEvent = do_QueryInterface(aAccEvent);
nsAccReorderEvent *reorderEvent = downcast_accEvent(aAccEvent);
if (reorderEvent->IsUnconditionalEvent())
aDescendantAccEvent->mEventRule = nsAccEvent::eDoNotEmit;
}

Просмотреть файл

@ -45,6 +45,8 @@
#include "nsAutoPtr.h"
#include "nsRefreshDriver.h"
class nsIPersistentProperties;
/**
@ -67,7 +69,7 @@ public:
* @param aIsAsync [in, optional] specifies whether the origin change
* this event is fired owing to is async.
*/
static void FireEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
static void FireEvent(PRUint32 aEventType, nsAccessible *aAccessible,
PRBool aIsAsynch = PR_FALSE,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
@ -78,11 +80,11 @@ public:
* @param aNode [in] the DOM node
* @param aAttributes [in, out] the attributes
*/
static void GetEventAttributes(nsIDOMNode *aNode,
static void GetEventAttributes(nsINode *aNode,
nsIPersistentProperties *aAttributes);
private:
static nsCOMPtr<nsIDOMNode> sEventTargetNode;
static nsCOMPtr<nsINode> sEventTargetNode;
static PRBool sEventFromUserInput;
};
@ -90,7 +92,8 @@ private:
/**
* Event queue.
*/
class nsAccEventQueue : public nsISupports
class nsAccEventQueue : public nsISupports,
public nsARefreshObserver
{
public:
nsAccEventQueue(nsDocAccessible *aDocument);
@ -120,9 +123,7 @@ private:
* Process pending events. It calls nsDocAccessible::ProcessPendingEvent()
* where the real event processing is happen.
*/
void Flush();
NS_DECL_RUNNABLEMETHOD(nsAccEventQueue, Flush)
virtual void WillRefresh(mozilla::TimeStamp aTime);
/**
* Coalesce redundant events from the queue.
@ -157,9 +158,10 @@ private:
nsAccEvent *aDescendantAccEvent);
/**
* Indicates whether events flush is run.
* Indicates whether we're waiting on a refresh notification from our
* presshell to flush events
*/
PRBool mProcessingStarted;
PRBool mObservingRefresh;
/**
* The document accessible reference owning this queue.
@ -167,13 +169,8 @@ private:
nsRefPtr<nsDocAccessible> mDocument;
/**
* The number of events processed currently. Used to avoid event coalescence
* with new events appended to the queue because of events handling.
*/
PRInt32 mFlushingEventsCount;
/**
* Pending events array.
* Pending events array. Don't make this an nsAutoTArray; we use
* SwapElements() on it.
*/
nsTArray<nsRefPtr<nsAccEvent> > mEvents;
};

Просмотреть файл

@ -44,27 +44,25 @@
#include "nsIDOMXULElement.h"
#include "nsIDOMXULControlElement.h"
// ------------
// Radio button
// ------------
////////////////////////////////////////////////////////////////////////////////
// nsRadioButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsRadioButtonAccessible::nsRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
{
nsRadioButtonAccessible::
nsRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsFormControlAccessible(aContent, aShell)
{
}
/**
*
*/
NS_IMETHODIMP nsRadioButtonAccessible::GetNumActions(PRUint8 *_retval)
NS_IMETHODIMP
nsRadioButtonAccessible::GetNumActions(PRUint8 *aNumActions)
{
*_retval = 1;
NS_ENSURE_ARG_POINTER(aNumActions);
*aNumActions = 1;
return NS_OK;
}
/**
*
*/
NS_IMETHODIMP nsRadioButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
if (aIndex == eAction_Click) {

Просмотреть файл

@ -44,13 +44,13 @@
typedef nsLeafAccessible nsFormControlAccessible;
/**
* nsRadioButtonAccessible
* Generic class used for radio buttons.
*/
class nsRadioButtonAccessible : public nsFormControlAccessible
{
public:
nsRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetNumActions(PRUint8 *_retval);

Просмотреть файл

@ -45,9 +45,9 @@
// nsOuterDocAccessible
////////////////////////////////////////////////////////////////////////////////
nsOuterDocAccessible::nsOuterDocAccessible(nsIDOMNode* aNode,
nsIWeakReference* aShell):
nsAccessibleWrap(aNode, aShell)
nsOuterDocAccessible::
nsOuterDocAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
@ -156,21 +156,24 @@ nsOuterDocAccessible::DoAction(PRUint8 aIndex)
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public
nsresult
void
nsOuterDocAccessible::Shutdown()
{
// Shutdown child document if any.
// XXX: sometimes outerdoc accessible is shutdown because of layout style
// change however the presshell of underlying document isn't destroyed and
// the document doesn't get pagehide events. Shutdown underlying document if
// any to avoid hanging document accessible.
NS_LOG_ACCDOCDESTROY_MSG("A11y outerdoc shutdown")
NS_LOG_ACCDOCDESTROY_ACCADDRESS("outerdoc", this)
nsAccessible *childAcc = mChildren.SafeElementAt(0, nsnull);
if (childAcc) {
nsRefPtr<nsDocAccessible> docAcc(do_QueryObject(childAcc));
NS_LOG_ACCDOCDESTROY_FOR("outerdoc document shutdown",
docAcc->GetDOMDocument(), docAcc.get())
GetAccService()->ShutdownDocAccessiblesInTree(docAcc->GetDOMDocument());
NS_LOG_ACCDOCDESTROY("outerdoc's child document shutdown",
childAcc->GetDocumentNode())
GetAccService()->ShutdownDocAccessiblesInTree(childAcc->GetDocumentNode());
}
nsAccessible::InvalidateChildren();
return nsAccessibleWrap::Shutdown();
nsAccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@ -201,6 +204,11 @@ nsOuterDocAccessible::AppendChild(nsAccessible *aAccessible)
return PR_FALSE;
aAccessible->SetParent(this);
NS_LOG_ACCDOCCREATE("append document to outerdoc",
aAccessible->GetDocumentNode())
NS_LOG_ACCDOCCREATE_ACCADDRESS("outerdoc", this)
return PR_TRUE;
}
@ -213,13 +221,19 @@ nsOuterDocAccessible::RemoveChild(nsAccessible *aAccessible)
return PR_FALSE;
}
NS_LOG_ACCDOCDESTROY("remove document from outerdoc",
child->GetDocumentNode())
NS_LOG_ACCDOCDESTROY_ACCADDRESS("outerdoc", this)
mChildren.RemoveElement(child);
NS_ASSERTION(!mChildren.Length(),
"This child document of outerdoc accessible wasn't removed!");
return PR_TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessible protected
@ -228,14 +242,12 @@ nsOuterDocAccessible::CacheChildren()
{
// Request document accessible for the content document to make sure it's
// created because once it's created it appends itself as a child.
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIDocument *outerDoc = content->GetCurrentDoc();
nsIDocument *outerDoc = mContent->GetCurrentDoc();
if (!outerDoc)
return;
nsIDocument *innerDoc = outerDoc->GetSubDocumentFor(content);
nsCOMPtr<nsIDOMNode> innerNode(do_QueryInterface(innerDoc));
if (!innerNode)
nsIDocument *innerDoc = outerDoc->GetSubDocumentFor(mContent);
if (!innerDoc)
return;
nsDocAccessible *docAcc = GetAccService()->GetDocAccessible(innerDoc);

Просмотреть файл

@ -53,8 +53,7 @@
class nsOuterDocAccessible : public nsAccessibleWrap
{
public:
nsOuterDocAccessible(nsIDOMNode* aNode,
nsIWeakReference* aShell);
nsOuterDocAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
@ -65,7 +64,7 @@ public:
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsCoreUtils.h"
#include "nsRelUtils.h"
#include "mozilla/dom/Element.h"
#include "nsHTMLSelectAccessible.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
@ -105,8 +106,10 @@ NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsDocAccessible)
////////////////////////////////////////////////////////////////////////////////
// Constructor/desctructor
nsRootAccessible::nsRootAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
nsDocAccessibleWrap(aDOMNode, aShell)
nsRootAccessible::
nsRootAccessible(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsDocAccessibleWrap(aDocument, aRootContent, aShell)
{
}
@ -171,7 +174,7 @@ PRUint32 nsRootAccessible::GetChromeFlags()
// by nsIWebBrowserChrome::CHROME_WINDOW_[FLAGNAME]
// Not simple: nsIXULWindow is not just a QI from nsIDOMWindow
nsCOMPtr<nsIDocShellTreeItem> treeItem =
nsCoreUtils::GetDocShellTreeItemFor(mDOMNode);
nsCoreUtils::GetDocShellTreeItemFor(mDocument);
NS_ENSURE_TRUE(treeItem, 0);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
@ -317,13 +320,15 @@ nsRootAccessible::GetCaretAccessible()
}
PRBool
nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
nsIDOMNode *aNode,
nsRootAccessible::FireAccessibleFocusEvent(nsAccessible *aAccessible,
nsINode *aNode,
nsIDOMEvent *aFocusEvent,
PRBool aForceEvent,
PRBool aIsAsynch,
EIsFromUserInput aIsFromUserInput)
{
// Implementors: only fire delayed/async events from this method.
if (mCaretAccessible) {
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aFocusEvent));
if (nsevent) {
@ -337,12 +342,12 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
// stays outside on that binding parent.
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
nsevent->GetOriginalTarget(getter_AddRefs(domEventTarget));
nsCOMPtr<nsIDOMNode> realFocusedNode(do_QueryInterface(domEventTarget));
nsCOMPtr<nsIContent> realFocusedNode(do_QueryInterface(domEventTarget));
if (!realFocusedNode) {
// When FireCurrentFocusEvent() synthesizes a focus event,
// the orignal target does not exist, so use the passed-in node
// which is the relevant focused node
realFocusedNode = aNode;
realFocusedNode = do_QueryInterface(aNode);
}
if (realFocusedNode) {
mCaretAccessible->SetControlSelectionListener(realFocusedNode);
@ -351,27 +356,17 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
}
// Check for aria-activedescendant, which changes which element has focus
nsCOMPtr<nsIDOMNode> finalFocusNode = aNode;
nsCOMPtr<nsIAccessible> finalFocusAccessible = aAccessible;
nsCOMPtr<nsIContent> finalFocusContent =
nsCoreUtils::GetRoleContent(finalFocusNode);
nsINode *finalFocusNode = aNode;
nsAccessible *finalFocusAccessible = aAccessible;
nsIContent *finalFocusContent = nsCoreUtils::GetRoleContent(finalFocusNode);
if (finalFocusContent) {
nsAutoString id;
if (finalFocusContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_activedescendant, id)) {
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
if (!domDoc) { // Maybe the passed-in node actually is a doc
domDoc = do_QueryInterface(aNode);
}
if (!domDoc) {
return PR_FALSE;
}
nsCOMPtr<nsIDOMElement> relatedEl;
domDoc->GetElementById(id, getter_AddRefs(relatedEl));
finalFocusNode = do_QueryInterface(relatedEl);
nsIDocument *doc = aNode->GetOwnerDoc();
finalFocusNode = doc->GetElementById(id);
if (!finalFocusNode) {
// If aria-activedescendant is set to nonextistant ID, then treat as focus
// If aria-activedescendant is set to nonexistant ID, then treat as focus
// on the activedescendant container (which has real DOM focus)
finalFocusNode = aNode;
}
@ -385,10 +380,10 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
}
if (!finalFocusAccessible) {
GetAccService()->GetAccessibleFor(finalFocusNode, getter_AddRefs(finalFocusAccessible));
finalFocusAccessible = GetAccService()->GetAccessible(finalFocusNode);
// For activedescendant, the ARIA spec does not require that the user agent
// checks whether finalFocusNode is actually a descendant of the element with
// the activedescendant attribute.
// checks whether finalFocusNode is actually a DOM descendant of the element
// with the aria-activedescendant attribute.
if (!finalFocusAccessible) {
return PR_FALSE;
}
@ -401,16 +396,19 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
// The natural role is the role that this type of element normally has
PRUint32 naturalRole = nsAccUtils::RoleInternal(finalFocusAccessible);
if (role != naturalRole) { // Must be a DHTML menuitem
nsCOMPtr<nsIAccessible> menuBarAccessible =
nsAccessible *menuBarAccessible =
nsAccUtils::GetAncestorWithRole(finalFocusAccessible,
nsIAccessibleRole::ROLE_MENUBAR);
nsCOMPtr<nsIAccessNode> menuBarAccessNode = do_QueryInterface(menuBarAccessible);
if (menuBarAccessNode) {
menuBarAccessNode->GetDOMNode(getter_AddRefs(mCurrentARIAMenubar));
if (menuBarAccessible) {
mCurrentARIAMenubar = menuBarAccessible->GetNode();
if (mCurrentARIAMenubar) {
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
menuBarAccessible, PR_FALSE,
aIsFromUserInput);
nsRefPtr<nsAccEvent> menuStartEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_MENU_START,
menuBarAccessible, PR_FALSE, aIsFromUserInput,
nsAccEvent::eAllowDupes);
if (menuStartEvent) {
FireDelayedAccessibleEvent(menuStartEvent);
}
}
}
}
@ -459,7 +457,7 @@ nsRootAccessible::FireCurrentFocusEvent()
if (IsDefunct())
return;
nsCOMPtr<nsIDOMNode> focusedNode = GetCurrentFocus();
nsCOMPtr<nsINode> focusedNode = GetCurrentFocus();
if (!focusedNode) {
return; // No current focus
}
@ -472,28 +470,20 @@ nsRootAccessible::FireCurrentFocusEvent()
getter_AddRefs(event))) &&
NS_SUCCEEDED(event->InitEvent(NS_LITERAL_STRING("focus"), PR_TRUE, PR_TRUE))) {
// Get the target node we really want for the event.
nsIAccessibilityService* accService = GetAccService();
if (accService) {
nsCOMPtr<nsIDOMNode> targetNode;
accService->GetRelevantContentNodeFor(focusedNode,
getter_AddRefs(targetNode));
if (targetNode) {
// If the focused element is document element or HTML body element
// then simulate the focus event for the document.
nsCOMPtr<nsIContent> targetContent(do_QueryInterface(targetNode));
if (targetContent) {
nsCOMPtr<nsIDOMNode> document =
do_QueryInterface(targetContent->GetOwnerDoc());
if (targetContent == nsCoreUtils::GetRoleContent(document)) {
HandleEventWithTarget(event, document);
return;
}
}
// Otherwise simulate the focus event for currently focused node.
HandleEventWithTarget(event, targetNode);
nsINode *targetNode =
GetAccService()->GetRelevantContentNodeFor(focusedNode);
if (targetNode) {
// If the focused element is document element or HTML body element
// then simulate the focus event for the document.
nsINode *document = targetNode->GetOwnerDoc();
if (targetNode == nsCoreUtils::GetRoleContent(document)) {
HandleEventWithTarget(event, document);
return;
}
// Otherwise simulate the focus event for currently focused node.
HandleEventWithTarget(event, targetNode);
}
}
}
@ -510,19 +500,22 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
GetTargetNode(aEvent, getter_AddRefs(targetNode));
if (!targetNode)
return NS_ERROR_FAILURE;
return HandleEventWithTarget(aEvent, targetNode);
nsCOMPtr<nsINode> node(do_QueryInterface(targetNode));
return HandleEventWithTarget(aEvent, node);
}
// nsRootAccessible protected member
nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
nsIDOMNode* aTargetNode)
nsINode* aTargetNode)
{
nsAutoString eventType;
aEvent->GetType(eventType);
nsAutoString localName;
aTargetNode->GetLocalName(localName);
nsCOMPtr<nsIContent> targetContent(do_QueryInterface(aTargetNode));
if (targetContent)
targetContent->NodeInfo()->GetName(localName);
#ifdef MOZ_XUL
PRBool isTree = localName.EqualsLiteral("tree");
#endif
@ -536,16 +529,16 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
}
#endif
nsIAccessibilityService *accService = GetAccService();
nsAccessibilityService *accService = GetAccService();
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
nsIPresShell *eventShell = nsCoreUtils::GetPresShellFor(aTargetNode);
if (!eventShell) {
nsCOMPtr<nsIWeakReference> weakShell =
nsCoreUtils::GetWeakShellFor(aTargetNode);
if (!weakShell)
return NS_OK;
}
nsAccessible *accessible =
accService->GetAccessibleInShell(aTargetNode, eventShell);
accService->GetAccessibleInWeakShell(aTargetNode, weakShell);
if (eventType.EqualsLiteral("popuphiding"))
return HandlePopupHidingEvent(aTargetNode, accessible);
@ -667,7 +660,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
else
#endif
if (eventType.EqualsLiteral("focus")) {
if (aTargetNode == mDOMNode && mDOMNode != gLastFocusedNode) {
if (aTargetNode == mDocument && mDocument != gLastFocusedNode) {
// Got focus event for the window, we will make sure that an accessible
// focus event for initial focus is fired. We do this on a short timer
// because the initial focus may not have been set yet.
@ -677,7 +670,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
// Keep a reference to the target node. We might want to change
// it to the individual radio button or selected item, and send
// the focus event to that.
nsCOMPtr<nsIDOMNode> focusedItem(aTargetNode);
nsCOMPtr<nsINode> focusedItem(aTargetNode);
if (!treeItemAccessible) {
nsCOMPtr<nsIDOMXULSelectControlElement> selectControl =
@ -696,7 +689,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
if (!focusedItem)
return NS_OK;
accessible = accService->GetAccessibleInShell(focusedItem, eventShell);
accessible = accService->GetAccessibleInWeakShell(focusedItem,
weakShell);
if (!accessible)
return NS_OK;
}
@ -757,7 +751,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
}
}
if (!fireFocus) {
nsCOMPtr<nsIDOMNode> realFocusedNode = GetCurrentFocus();
nsCOMPtr<nsINode> realFocusedNode = GetCurrentFocus();
nsCOMPtr<nsIContent> realFocusedContent = do_QueryInterface(realFocusedNode);
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(aTargetNode);
nsIContent *containerContent = targetContent;
@ -829,33 +823,34 @@ void nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNo
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode
nsresult
PRBool
nsRootAccessible::Init()
{
nsApplicationAccessible *applicationAcc = GetApplicationAccessible();
NS_ENSURE_STATE(applicationAcc);
if (!applicationAcc)
return PR_FALSE;
applicationAcc->AddRootAccessible(this);
return nsDocAccessibleWrap::Init();
}
nsresult
void
nsRootAccessible::Shutdown()
{
// Called manually or by nsAccessNode::LastRelease()
if (!mWeakShell) {
return NS_OK; // Already shutdown
}
if (!mWeakShell)
return; // Already shutdown
nsApplicationAccessible *applicationAcc = GetApplicationAccessible();
NS_ENSURE_STATE(applicationAcc);
if (!applicationAcc)
return;
applicationAcc->RemoveRootAccessible(this);
mCurrentARIAMenubar = nsnull;
return nsDocAccessibleWrap::Shutdown();
nsDocAccessibleWrap::Shutdown();
}
// nsRootAccessible protected member
@ -919,12 +914,12 @@ nsRootAccessible::GetRelationByType(PRUint32 aRelationType,
NS_ENSURE_ARG_POINTER(aRelation);
*aRelation = nsnull;
if (!mDOMNode || aRelationType != nsIAccessibleRelation::RELATION_EMBEDS) {
if (!mDocument || aRelationType != nsIAccessibleRelation::RELATION_EMBEDS) {
return nsDocAccessibleWrap::GetRelationByType(aRelationType, aRelation);
}
nsCOMPtr<nsIDocShellTreeItem> treeItem =
nsCoreUtils::GetDocShellTreeItemFor(mDOMNode);
nsCoreUtils::GetDocShellTreeItemFor(mDocument);
nsCOMPtr<nsIDocShellTreeItem> contentTreeItem = GetContentDocShell(treeItem);
// there may be no content area, so we need a null check
if (contentTreeItem) {
@ -950,7 +945,7 @@ nsRootAccessible::GetParent()
// Protected members
nsresult
nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
nsRootAccessible::HandlePopupShownEvent(nsAccessible *aAccessible)
{
PRUint32 role = nsAccUtils::Role(aAccessible);
@ -972,10 +967,7 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
if (role == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
// Fire expanded state change event for comboboxes and autocompeletes.
nsCOMPtr<nsIAccessible> comboboxAcc;
nsresult rv = aAccessible->GetParent(getter_AddRefs(comboboxAcc));
NS_ENSURE_SUCCESS(rv, rv);
nsAccessible *comboboxAcc = aAccessible->GetParent();
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
@ -985,7 +977,6 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
PR_FALSE, PR_TRUE);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
nsRefPtr<nsAccessible> acc(do_QueryObject(comboboxAcc));
nsEventShell::FireEvent(event);
return NS_OK;
}
@ -995,19 +986,17 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
}
nsresult
nsRootAccessible::HandlePopupHidingEvent(nsIDOMNode *aNode,
nsIAccessible *aAccessible)
nsRootAccessible::HandlePopupHidingEvent(nsINode *aNode,
nsAccessible *aAccessible)
{
// If accessible focus was on or inside popup that closes, then restore it
// to true current focus. This is the case when we've been getting
// DOMMenuItemActive events inside of a combo box that closes. The real focus
// is on the combo box. It's also the case when a popup gets focus in ATK --
// when it closes we need to fire an event to restore focus to where it was.
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
nsCOMPtr<nsINode> lastFocusedNode(do_QueryInterface(gLastFocusedNode));
if (gLastFocusedNode &&
nsCoreUtils::IsAncestorOf(node, lastFocusedNode)) {
nsCoreUtils::IsAncestorOf(aNode, gLastFocusedNode)) {
// Focus was on or inside of a popup that's being hidden
FireCurrentFocusEvent();
}
@ -1020,10 +1009,7 @@ nsRootAccessible::HandlePopupHidingEvent(nsIDOMNode *aNode,
if (role != nsIAccessibleRole::ROLE_COMBOBOX_LIST)
return NS_OK;
nsCOMPtr<nsIAccessible> comboboxAcc;
nsresult rv = aAccessible->GetParent(getter_AddRefs(comboboxAcc));
NS_ENSURE_SUCCESS(rv, rv);
nsAccessible *comboboxAcc = aAccessible->GetParent();
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {

Просмотреть файл

@ -68,7 +68,8 @@ class nsRootAccessible : public nsDocAccessibleWrap,
NS_DECL_ISUPPORTS_INHERITED
public:
nsRootAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell);
nsRootAccessible(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsRootAccessible();
// nsIAccessible
@ -80,8 +81,8 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
// nsAccessNode
virtual nsresult Init();
virtual nsresult Shutdown();
virtual PRBool Init();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -103,8 +104,8 @@ public:
* item was the same
* @return boolean -- was a focus event actually fired
*/
PRBool FireAccessibleFocusEvent(nsIAccessible *aFocusAccessible,
nsIDOMNode *aFocusNode,
PRBool FireAccessibleFocusEvent(nsAccessible *aFocusAccessible,
nsINode *aFocusNode,
nsIDOMEvent *aFocusEvent,
PRBool aForceEvent = PR_FALSE,
PRBool aIsAsynch = PR_FALSE,
@ -123,16 +124,23 @@ protected:
nsresult AddEventListeners();
nsresult RemoveEventListeners();
nsresult HandleEventWithTarget(nsIDOMEvent* aEvent,
nsIDOMNode* aTargetNode);
/**
* Process DOM events.
*/
nsresult HandleEventWithTarget(nsIDOMEvent* aEvent, nsINode* aTargetNode);
static void GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNode);
/**
* Used in HandleEventWithTarget().
*/
nsresult HandlePopupShownEvent(nsIAccessible *aAccessible);
nsresult HandlePopupHidingEvent(nsIDOMNode *aNode,
nsIAccessible *aAccessible);
/**
* Process "popupshown" event. Used by HandleEventWithTarget().
*/
nsresult HandlePopupShownEvent(nsAccessible *aAccessible);
/*
* Process "popuphiding" event. Used by HandleEventWithTarget().
*/
nsresult HandlePopupHidingEvent(nsINode *aNode, nsAccessible *aAccessible);
#ifdef MOZ_XUL
nsresult HandleTreeRowCountChangedEvent(nsIDOMEvent *aEvent,
@ -145,7 +153,7 @@ protected:
already_AddRefed<nsIDocShellTreeItem>
GetContentDocShell(nsIDocShellTreeItem *aStart);
nsRefPtr<nsCaretAccessible> mCaretAccessible;
nsCOMPtr<nsIDOMNode> mCurrentARIAMenubar;
nsCOMPtr<nsINode> mCurrentARIAMenubar;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsRootAccessible, NS_ROOTACCESSIBLE_IMPL_CID)

Просмотреть файл

@ -45,8 +45,8 @@
////////////////////////////////////////////////////////////////////////////////
nsTextAccessible::
nsTextAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
nsLinkableAccessible(aDOMNode, aShell)
nsTextAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsLinkableAccessible(aContent, aShell)
{
}

Просмотреть файл

@ -47,7 +47,7 @@
class nsTextAccessible : public nsLinkableAccessible
{
public:
nsTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsTextAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -131,24 +131,26 @@ nsTextAttrsMgr::GetAttributes(nsIPersistentProperties *aAttributes,
return NS_OK;
}
nsIDOMNode *hyperTextNode = mHyperTextAcc->GetDOMNode();
nsCOMPtr<nsIDOMElement> hyperTextElm =
nsCoreUtils::GetDOMElementFor(mHyperTextAcc->GetDOMNode());
nsIFrame *rootFrame = nsCoreUtils::GetFrameFor(hyperTextElm);
// Get the content and frame of the accessible. In the case of document
// accessible it's role content and root frame.
nsIContent *hyperTextElm = mHyperTextAcc->GetContent();
nsIFrame *rootFrame = mHyperTextAcc->GetFrame();
NS_ASSERTION(rootFrame, "No frame for accessible!");
if (!rootFrame)
return NS_OK;
nsIDOMNode *offsetNode = nsnull;
nsCOMPtr<nsIDOMElement> offsetElm;
nsIContent *offsetNode = nsnull, *offsetElm = nsnull;
nsIFrame *frame = nsnull;
if (mOffsetAcc) {
offsetNode = mOffsetAcc->GetDOMNode();
offsetNode = mOffsetAcc->GetContent();
offsetElm = nsCoreUtils::GetDOMElementFor(offsetNode);
frame = nsCoreUtils::GetFrameFor(offsetElm);
frame = offsetElm->GetPrimaryFrame();
}
nsTPtrArray<nsITextAttr> textAttrArray(10);
// "language" text attribute
nsLangTextAttr langTextAttr(mHyperTextAcc, hyperTextNode, offsetNode);
nsLangTextAttr langTextAttr(mHyperTextAcc, hyperTextElm, offsetNode);
textAttrArray.AppendElement(static_cast<nsITextAttr*>(&langTextAttr));
// "color" text attribute
@ -224,8 +226,7 @@ nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray,
if (nsAccUtils::IsEmbeddedObject(currAcc))
break;
nsCOMPtr<nsIDOMElement> currElm =
nsCoreUtils::GetDOMElementFor(currAcc->GetDOMNode());
nsIContent *currElm = nsCoreUtils::GetDOMElementFor(currAcc->GetContent());
NS_ENSURE_STATE(currElm);
PRBool offsetFound = PR_FALSE;
@ -250,8 +251,7 @@ nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray,
if (nsAccUtils::IsEmbeddedObject(currAcc))
break;
nsCOMPtr<nsIDOMElement> currElm =
nsCoreUtils::GetDOMElementFor(currAcc->GetDOMNode());
nsIContent *currElm = nsCoreUtils::GetDOMElementFor(currAcc->GetContent());
NS_ENSURE_STATE(currElm);
PRBool offsetFound = PR_FALSE;
@ -279,25 +279,20 @@ nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray,
// nsLangTextAttr
nsLangTextAttr::nsLangTextAttr(nsHyperTextAccessible *aRootAcc,
nsIDOMNode *aRootNode, nsIDOMNode *aNode) :
nsTextAttr<nsAutoString>(aNode == nsnull)
nsIContent *aRootContent, nsIContent *aContent) :
nsTextAttr<nsAutoString>(aContent == nsnull), mRootContent(aRootContent)
{
mRootContent = do_QueryInterface(aRootNode);
nsresult rv = aRootAcc->GetLanguage(mRootNativeValue);
mIsRootDefined = NS_SUCCEEDED(rv) && !mRootNativeValue.IsEmpty();
if (aNode) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
mIsDefined = GetLang(content, mNativeValue);
}
if (aContent)
mIsDefined = GetLang(aContent, mNativeValue);
}
PRBool
nsLangTextAttr::GetValueFor(nsIDOMElement *aElm, nsAutoString *aValue)
nsLangTextAttr::GetValueFor(nsIContent *aElm, nsAutoString *aValue)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElm);
return GetLang(content, *aValue);
return GetLang(aElm, *aValue);
}
void
@ -313,17 +308,19 @@ nsLangTextAttr::GetLang(nsIContent *aContent, nsAString& aLang)
return !aLang.IsEmpty();
}
////////////////////////////////////////////////////////////////////////////////
// nsCSSTextAttr
////////////////////////////////////////////////////////////////////////////////
nsCSSTextAttr::nsCSSTextAttr(PRUint32 aIndex, nsIDOMElement *aRootElm,
nsIDOMElement *aElm) :
nsTextAttr<nsAutoString>(aElm == nsnull), mIndex(aIndex)
nsCSSTextAttr::nsCSSTextAttr(PRUint32 aIndex, nsIContent *aRootContent,
nsIContent *aContent) :
nsTextAttr<nsAutoString>(aContent == nsnull), mIndex(aIndex)
{
mIsRootDefined = GetValueFor(aRootElm, &mRootNativeValue);
mIsRootDefined = GetValueFor(aRootContent, &mRootNativeValue);
if (aElm)
mIsDefined = GetValueFor(aElm, &mNativeValue);
if (aContent)
mIsDefined = GetValueFor(aContent, &mNativeValue);
}
nsIAtom*
@ -333,11 +330,10 @@ nsCSSTextAttr::GetName()
}
PRBool
nsCSSTextAttr::GetValueFor(nsIDOMElement *aElm, nsAutoString *aValue)
nsCSSTextAttr::GetValueFor(nsIContent *aContent, nsAutoString *aValue)
{
nsCOMPtr<nsIDOMCSSStyleDeclaration> currStyleDecl;
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aElm,
getter_AddRefs(currStyleDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> currStyleDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aContent);
if (!currStyleDecl)
return PR_FALSE;
@ -364,8 +360,10 @@ nsCSSTextAttr::Format(const nsAutoString& aValue, nsAString& aFormattedValue)
aFormattedValue = aValue;
}
////////////////////////////////////////////////////////////////////////////////
// nsBackgroundTextAttr
////////////////////////////////////////////////////////////////////////////////
nsBGColorTextAttr::nsBGColorTextAttr(nsIFrame *aRootFrame, nsIFrame *aFrame) :
nsTextAttr<nscolor>(aFrame == nsnull), mRootFrame(aRootFrame)
@ -376,9 +374,9 @@ nsBGColorTextAttr::nsBGColorTextAttr(nsIFrame *aRootFrame, nsIFrame *aFrame) :
}
PRBool
nsBGColorTextAttr::GetValueFor(nsIDOMElement *aElm, nscolor *aValue)
nsBGColorTextAttr::GetValueFor(nsIContent *aContent, nscolor *aValue)
{
nsIFrame *frame = nsCoreUtils::GetFrameFor(aElm);
nsIFrame *frame = aContent->GetPrimaryFrame();
if (!frame)
return PR_FALSE;
@ -426,8 +424,10 @@ nsBGColorTextAttr::GetColor(nsIFrame *aFrame, nscolor *aColor)
return GetColor(parentFrame, aColor);
}
////////////////////////////////////////////////////////////////////////////////
// nsFontSizeTextAttr
////////////////////////////////////////////////////////////////////////////////
nsFontSizeTextAttr::nsFontSizeTextAttr(nsIFrame *aRootFrame, nsIFrame *aFrame) :
nsTextAttr<nscoord>(aFrame == nsnull)
@ -444,9 +444,9 @@ nsFontSizeTextAttr::nsFontSizeTextAttr(nsIFrame *aRootFrame, nsIFrame *aFrame) :
}
PRBool
nsFontSizeTextAttr::GetValueFor(nsIDOMElement *aElm, nscoord *aValue)
nsFontSizeTextAttr::GetValueFor(nsIContent *aContent, nscoord *aValue)
{
nsIFrame *frame = nsCoreUtils::GetFrameFor(aElm);
nsIFrame *frame = aContent->GetPrimaryFrame();
if (!frame)
return PR_FALSE;
@ -487,6 +487,7 @@ nsFontSizeTextAttr::GetFontSize(nsIFrame *aFrame)
////////////////////////////////////////////////////////////////////////////////
// nsFontWeightTextAttr
////////////////////////////////////////////////////////////////////////////////
nsFontWeightTextAttr::nsFontWeightTextAttr(nsIFrame *aRootFrame,
nsIFrame *aFrame) :
@ -502,9 +503,9 @@ nsFontWeightTextAttr::nsFontWeightTextAttr(nsIFrame *aRootFrame,
}
PRBool
nsFontWeightTextAttr::GetValueFor(nsIDOMElement *aElm, PRInt32 *aValue)
nsFontWeightTextAttr::GetValueFor(nsIContent *aContent, PRInt32 *aValue)
{
nsIFrame *frame = nsCoreUtils::GetFrameFor(aElm);
nsIFrame *frame = aContent->GetPrimaryFrame();
if (!frame)
return PR_FALSE;

Просмотреть файл

@ -156,7 +156,7 @@ public:
* Return true if the text attribute value on the given element equals with
* predefined attribute value.
*/
virtual PRBool Equal(nsIDOMElement *aElm) = 0;
virtual PRBool Equal(nsIContent *aContent) = 0;
};
@ -196,10 +196,10 @@ public:
return PR_TRUE;
}
virtual PRBool Equal(nsIDOMElement *aElm)
virtual PRBool Equal(nsIContent *aContent)
{
T nativeValue;
PRBool isDefined = GetValueFor(aElm, &nativeValue);
PRBool isDefined = GetValueFor(aContent, &nativeValue);
if (!mIsDefined && !isDefined)
return PR_TRUE;
@ -216,7 +216,7 @@ public:
protected:
// Return native value for the given DOM element.
virtual PRBool GetValueFor(nsIDOMElement *aElm, T *aValue) = 0;
virtual PRBool GetValueFor(nsIContent *aContent, T *aValue) = 0;
// Format native value to text attribute value.
virtual void Format(const T& aValue, nsAString& aFormattedValue) = 0;
@ -244,8 +244,8 @@ protected:
class nsLangTextAttr : public nsTextAttr<nsAutoString>
{
public:
nsLangTextAttr(nsHyperTextAccessible *aRootAcc, nsIDOMNode *aRootNode,
nsIDOMNode *aNode);
nsLangTextAttr(nsHyperTextAccessible *aRootAcc, nsIContent *aRootContent,
nsIContent *aContent);
// nsITextAttr
virtual nsIAtom *GetName() { return nsAccessibilityAtoms::language; }
@ -253,7 +253,7 @@ public:
protected:
// nsTextAttr
virtual PRBool GetValueFor(nsIDOMElement *aElm, nsAutoString *aValue);
virtual PRBool GetValueFor(nsIContent *aElm, nsAutoString *aValue);
virtual void Format(const nsAutoString& aValue, nsAString& aFormattedValue);
private:
@ -269,7 +269,8 @@ private:
class nsCSSTextAttr : public nsTextAttr<nsAutoString>
{
public:
nsCSSTextAttr(PRUint32 aIndex, nsIDOMElement *aRootElm, nsIDOMElement *aElm);
nsCSSTextAttr(PRUint32 aIndex, nsIContent *aRootContent,
nsIContent *aContent);
// nsITextAttr
virtual nsIAtom *GetName();
@ -277,7 +278,7 @@ public:
protected:
// nsTextAttr
virtual PRBool GetValueFor(nsIDOMElement *aElm, nsAutoString *aValue);
virtual PRBool GetValueFor(nsIContent *aContent, nsAutoString *aValue);
virtual void Format(const nsAutoString& aValue, nsAString& aFormattedValue);
private:
@ -299,7 +300,7 @@ public:
protected:
// nsTextAttr
virtual PRBool GetValueFor(nsIDOMElement *aElm, nscolor *aValue);
virtual PRBool GetValueFor(nsIContent *aContent, nscolor *aValue);
virtual void Format(const nscolor& aValue, nsAString& aFormattedValue);
private:
@ -323,7 +324,7 @@ public:
protected:
// nsTextAttr
virtual PRBool GetValueFor(nsIDOMElement *aElm, nscoord *aValue);
virtual PRBool GetValueFor(nsIContent *aContent, nscoord *aValue);
virtual void Format(const nscoord& aValue, nsAString& aFormattedValue);
private:
@ -355,7 +356,7 @@ public:
protected:
// nsTextAttr
virtual PRBool GetValueFor(nsIDOMElement *aElm, PRInt32 *aValue);
virtual PRBool GetValueFor(nsIContent *aElm, PRInt32 *aValue);
virtual void Format(const PRInt32& aValue, nsAString& aFormattedValue);
private:

Просмотреть файл

@ -54,7 +54,7 @@ NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x24)
// nsTextEquivUtils. Public.
nsresult
nsTextEquivUtils::GetNameFromSubtree(nsIAccessible *aAccessible,
nsTextEquivUtils::GetNameFromSubtree(nsAccessible *aAccessible,
nsAString& aName)
{
aName.Truncate();
@ -68,12 +68,8 @@ nsTextEquivUtils::GetNameFromSubtree(nsIAccessible *aAccessible,
PRUint32 nameRule = gRoleToNameRulesMap[role];
if (nameRule == eFromSubtree) {
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
nsCOMPtr<nsIDOMNode> DOMNode;
accessNode->GetDOMNode(getter_AddRefs(DOMNode));
nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode));
if (content) {
//XXX: is it necessary to care the accessible is not a document?
if (aAccessible->IsContent()) {
nsAutoString name;
AppendFromAccessibleChildren(aAccessible, &name);
name.CompressWhitespace();
@ -88,18 +84,13 @@ nsTextEquivUtils::GetNameFromSubtree(nsIAccessible *aAccessible,
}
nsresult
nsTextEquivUtils::GetTextEquivFromIDRefs(nsIAccessible *aAccessible,
nsTextEquivUtils::GetTextEquivFromIDRefs(nsAccessible *aAccessible,
nsIAtom *aIDRefsAttr,
nsAString& aTextEquiv)
{
aTextEquiv.Truncate();
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
nsCOMPtr<nsIDOMNode> DOMNode;
accessNode->GetDOMNode(getter_AddRefs(DOMNode));
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(DOMNode);
nsIContent* content = aAccessible->GetContent();
if (!content)
return NS_OK;
@ -130,7 +121,7 @@ nsTextEquivUtils::GetTextEquivFromIDRefs(nsIAccessible *aAccessible,
}
nsresult
nsTextEquivUtils::AppendTextEquivFromContent(nsIAccessible *aInitiatorAcc,
nsTextEquivUtils::AppendTextEquivFromContent(nsAccessible *aInitiatorAcc,
nsIContent *aContent,
nsAString *aString)
{
@ -140,8 +131,7 @@ nsTextEquivUtils::AppendTextEquivFromContent(nsIAccessible *aInitiatorAcc,
gInitiatorAcc = aInitiatorAcc;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(aContent));
nsIPresShell *shell = nsCoreUtils::GetPresShellFor(DOMNode);
nsCOMPtr<nsIWeakReference> shell = nsCoreUtils::GetWeakShellFor(aContent);
if (!shell) {
NS_ASSERTION(PR_TRUE, "There is no presshell!");
gInitiatorAcc = nsnull;
@ -159,7 +149,7 @@ nsTextEquivUtils::AppendTextEquivFromContent(nsIAccessible *aInitiatorAcc,
if (isVisible) {
nsAccessible *accessible =
GetAccService()->GetAccessibleInShell(DOMNode, shell);
GetAccService()->GetAccessibleInWeakShell(aContent, shell);
if (accessible) {
rv = AppendFromAccessible(accessible, aString);
goThroughDOMSubtree = PR_FALSE;
@ -178,11 +168,8 @@ nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent *aContent,
nsAString *aString)
{
if (aContent->IsNodeOfType(nsINode::eTEXT)) {
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(aContent));
PRBool isHTMLBlock = PR_FALSE;
nsIContent *parentContent = aContent->GetParent();
if (parentContent) {
nsIFrame *frame = parentContent->GetPrimaryFrame();
@ -230,18 +217,17 @@ nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent *aContent,
////////////////////////////////////////////////////////////////////////////////
// nsTextEquivUtils. Private.
nsCOMPtr<nsIAccessible> nsTextEquivUtils::gInitiatorAcc;
nsRefPtr<nsAccessible> nsTextEquivUtils::gInitiatorAcc;
nsresult
nsTextEquivUtils::AppendFromAccessibleChildren(nsIAccessible *aAccessible,
nsTextEquivUtils::AppendFromAccessibleChildren(nsAccessible *aAccessible,
nsAString *aString)
{
nsresult rv = NS_OK_NO_NAME_CLAUSE_HANDLED;
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
PRInt32 childCount = accessible->GetChildCount();
PRInt32 childCount = aAccessible->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *child = accessible->GetChildAt(childIdx);
nsAccessible *child = aAccessible->GetChildAt(childIdx);
rv = AppendFromAccessible(child, aString);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -250,18 +236,13 @@ nsTextEquivUtils::AppendFromAccessibleChildren(nsIAccessible *aAccessible,
}
nsresult
nsTextEquivUtils::AppendFromAccessible(nsIAccessible *aAccessible,
nsTextEquivUtils::AppendFromAccessible(nsAccessible *aAccessible,
nsAString *aString)
{
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
nsCOMPtr<nsIDOMNode> DOMNode;
accessNode->GetDOMNode(getter_AddRefs(DOMNode));
nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode));
NS_ASSERTION(content, "There is no content!");
if (content) {
nsresult rv = AppendTextEquivFromTextContent(content, aString);
//XXX: is it necessary to care the accessible is not a document?
if (aAccessible->IsContent()) {
nsresult rv = AppendTextEquivFromTextContent(aAccessible->GetContent(),
aString);
if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED)
return rv;
}
@ -310,7 +291,7 @@ nsTextEquivUtils::AppendFromAccessible(nsIAccessible *aAccessible,
}
nsresult
nsTextEquivUtils::AppendFromValue(nsIAccessible *aAccessible,
nsTextEquivUtils::AppendFromValue(nsAccessible *aAccessible,
nsAString *aString)
{
PRUint32 role = nsAccUtils::Role(aAccessible);
@ -333,13 +314,11 @@ nsTextEquivUtils::AppendFromValue(nsIAccessible *aAccessible,
NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED;
}
nsRefPtr<nsAccessible> acc = do_QueryObject(aAccessible);
nsCOMPtr<nsIDOMNode> node;
acc->GetDOMNode(getter_AddRefs(node));
NS_ENSURE_STATE(node);
//XXX: is it necessary to care the accessible is not a document?
if (aAccessible->IsDocument())
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
NS_ENSURE_STATE(content);
nsIContent *content = aAccessible->GetContent();
nsCOMPtr<nsIContent> parent = content->GetParent();
PRInt32 indexOf = parent->IndexOf(content);

Просмотреть файл

@ -40,7 +40,7 @@
#ifndef _nsTextEquivUtils_H_
#define _nsTextEquivUtils_H_
#include "nsIAccessible.h"
#include "nsAccessible.h"
#include "nsIContent.h"
#include "nsIStringBundle.h"
@ -80,7 +80,7 @@ public:
* @param aAccessible [in] the given accessible
* @param aName [out] accessible name
*/
static nsresult GetNameFromSubtree(nsIAccessible *aAccessible,
static nsresult GetNameFromSubtree(nsAccessible *aAccessible,
nsAString& aName);
/**
@ -91,7 +91,7 @@ public:
* @param aIDRefsAttr [in] IDRefs attribute on DOM node of the accessible
* @param aTextEquiv [out] result text equivalent
*/
static nsresult GetTextEquivFromIDRefs(nsIAccessible *aAccessible,
static nsresult GetTextEquivFromIDRefs(nsAccessible *aAccessible,
nsIAtom *aIDRefsAttr,
nsAString& aTextEquiv);
@ -106,7 +106,7 @@ public:
* computed from
* @param aString [in, out] the string
*/
static nsresult AppendTextEquivFromContent(nsIAccessible *aInitiatorAcc,
static nsresult AppendTextEquivFromContent(nsAccessible *aInitiatorAcc,
nsIContent *aContent,
nsAString *aString);
@ -125,20 +125,20 @@ private:
* Iterates accessible children and calculates text equivalent from each
* child.
*/
static nsresult AppendFromAccessibleChildren(nsIAccessible *aAccessible,
static nsresult AppendFromAccessibleChildren(nsAccessible *aAccessible,
nsAString *aString);
/**
* Calculates text equivalent from the given accessible and its subtree if
* allowed.
*/
static nsresult AppendFromAccessible(nsIAccessible *aAccessible,
static nsresult AppendFromAccessible(nsAccessible *aAccessible,
nsAString *aString);
/**
* Calculates text equivalent from the value of given accessible.
*/
static nsresult AppendFromValue(nsIAccessible *aAccessible,
static nsresult AppendFromValue(nsAccessible *aAccessible,
nsAString *aString);
/**
* Iterates DOM children and calculates text equivalent from each child node.
@ -181,7 +181,7 @@ private:
* for bailing out during recursive text computation, or for special cases
* like step f. of the ARIA implementation guide.
*/
static nsCOMPtr<nsIAccessible> gInitiatorAcc;
static nsRefPtr<nsAccessible> gInitiatorAcc;
};
#endif

Просмотреть файл

@ -61,11 +61,14 @@
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h"
// --- checkbox -----
////////////////////////////////////////////////////////////////////////////////
// nsHTMLCheckboxAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLCheckboxAccessible::nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
{
nsHTMLCheckboxAccessible::
nsHTMLCheckboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsFormControlAccessible(aContent, aShell)
{
}
nsresult
@ -123,8 +126,8 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
PRBool mixed = PR_FALSE; // or mixed.
nsCOMPtr<nsIDOMNSHTMLInputElement>
html5CheckboxElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNSHTMLInputElement> html5CheckboxElement =
do_QueryInterface(mContent);
if (html5CheckboxElement) {
html5CheckboxElement->GetIndeterminate(&mixed);
@ -135,7 +138,8 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
}
}
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement =
do_QueryInterface(mContent);
if (htmlCheckboxElement) {
htmlCheckboxElement->GetChecked(&checked);
@ -150,9 +154,10 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
// nsHTMLRadioButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsRadioButtonAccessible(aNode, aShell)
{
nsHTMLRadioButtonAccessible::
nsHTMLRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsRadioButtonAccessible(aContent, aShell)
{
}
nsresult
@ -166,7 +171,8 @@ nsHTMLRadioButtonAccessible::GetStateInternal(PRUint32 *aState,
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement =
do_QueryInterface(mContent);
if (htmlRadioElement)
htmlRadioElement->GetChecked(&checked);
@ -181,27 +187,25 @@ nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsAutoString nsURI;
mDOMNode->GetNamespaceURI(nsURI);
mContent->NodeInfo()->GetNamespaceURI(nsURI);
nsAutoString tagName;
mDOMNode->GetLocalName(tagName);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
mContent->NodeInfo()->GetName(tagName);
nsAutoString type;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, type);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, type);
nsAutoString name;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::name, name);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::name, name);
nsCOMPtr<nsIDOMNodeList> inputs;
nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mContent));
nsCOMPtr<nsIDOMHTMLFormElement> form;
radio->GetForm(getter_AddRefs(form));
if (form) {
form->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
} else {
nsCOMPtr<nsIDOMDocument> document;
mDOMNode->GetOwnerDocument(getter_AddRefs(document));
nsIDocument* doc = mContent->GetOwnerDoc();
nsCOMPtr<nsIDOMDocument> document(do_QueryInterface(doc));
if (document)
document->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
}
@ -228,7 +232,7 @@ nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
count++;
if (itemNode == mDOMNode)
if (item == mContent)
indexOf = count;
}
}
@ -241,9 +245,10 @@ nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
// nsHTMLButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)
{
nsHTMLButtonAccessible::
nsHTMLButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMETHODIMP nsHTMLButtonAccessible::GetNumActions(PRUint8 *_retval)
@ -279,12 +284,8 @@ nsHTMLButtonAccessible::GetStateInternal(PRUint32 *aState,
aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
nsAutoString buttonType;
element->GetAttribute(NS_LITERAL_STRING("type"), buttonType);
if (buttonType.LowerCaseEqualsLiteral("submit"))
if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::submit, eIgnoreCase))
*aState |= nsIAccessibleStates::STATE_DEFAULT;
return NS_OK;
@ -304,14 +305,12 @@ nsHTMLButtonAccessible::GetNameInternal(nsAString& aName)
if (!aName.IsEmpty())
return NS_OK;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
// No name from HTML or ARIA
nsAutoString name;
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value,
name) &&
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt,
name)) {
if (!mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value,
name) &&
!mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt,
name)) {
// Use the button's (default) label if nothing else works
nsIFrame* frame = GetFrame();
if (frame) {
@ -322,9 +321,9 @@ nsHTMLButtonAccessible::GetNameInternal(nsAString& aName)
}
if (name.IsEmpty() &&
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src,
name)) {
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::data, name);
!mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src,
name)) {
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::data, name);
}
name.CompressWhitespace();
@ -334,11 +333,14 @@ nsHTMLButtonAccessible::GetNameInternal(nsAString& aName)
}
// ----- HTML 4 Button: can contain arbitrary HTML content -----
////////////////////////////////////////////////////////////////////////////////
// nsHTML4ButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)
{
nsHTML4ButtonAccessible::
nsHTML4ButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMETHODIMP nsHTML4ButtonAccessible::GetNumActions(PRUint8 *_retval)
@ -381,23 +383,23 @@ nsHTML4ButtonAccessible::GetStateInternal(PRUint32 *aState,
aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No element for button's dom node!");
*aState |= nsIAccessibleStates::STATE_FOCUSABLE;
nsAutoString buttonType;
element->GetAttribute(NS_LITERAL_STRING("type"), buttonType);
if (buttonType.LowerCaseEqualsLiteral("submit"))
if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::submit, eIgnoreCase))
*aState |= nsIAccessibleStates::STATE_DEFAULT;
return NS_OK;
}
// --- textfield -----
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTextFieldAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLTextFieldAccessible::
nsHTMLTextFieldAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
@ -407,10 +409,9 @@ nsresult
nsHTMLTextFieldAccessible::GetRoleInternal(PRUint32 *aRole)
{
*aRole = nsIAccessibleRole::ROLE_ENTRY;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content &&
content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::password, eIgnoreCase)) {
if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::password, eIgnoreCase)) {
*aRole = nsIAccessibleRole::ROLE_PASSWORD_TEXT;
}
return NS_OK;
@ -425,8 +426,7 @@ nsHTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
if (!aName.IsEmpty())
return NS_OK;
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (!content->GetBindingParent())
if (!mContent->GetBindingParent())
return NS_OK;
// XXX: bug 459640
@ -434,9 +434,8 @@ nsHTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
// This means we're part of another control, so use parent accessible for name.
// This ensures that a textbox inside of a XUL widget gets
// an accessible name.
nsCOMPtr<nsIAccessible> parent;
rv = GetParent(getter_AddRefs(parent));
return parent ? parent->GetName(aName) : rv;
nsAccessible* parent = GetParent();
return parent ? parent->GetName(aName) : NS_OK;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval)
@ -448,12 +447,12 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval)
if (state & nsIAccessibleStates::STATE_PROTECTED) // Don't return password text!
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
if (textArea) {
return textArea->GetValue(_retval);
}
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mContent));
if (inputElement) {
return inputElement->GetValue(_retval);
}
@ -470,28 +469,23 @@ nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState,
NS_ENSURE_A11Y_SUCCESS(rv, rv);
// can be focusable, focused, protected. readonly, unavailable, selected
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ASSERTION(content, "Should not have gotten here if upcalled GetExtState() succeeded");
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::password, eIgnoreCase)) {
if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::password, eIgnoreCase)) {
*aState |= nsIAccessibleStates::STATE_PROTECTED;
}
else {
nsCOMPtr<nsIAccessible> parent;
GetParent(getter_AddRefs(parent));
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
*aState |= nsIAccessibleStates::STATE_HASPOPUP;
}
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
*aState |= nsIAccessibleStates::STATE_READONLY;
}
if (!aExtraState)
return NS_OK;
nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mContent));
// Is it an <input> or a <textarea> ?
if (htmlInput) {
*aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
@ -503,7 +497,7 @@ nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState,
if (!(*aExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE))
return NS_OK;
nsCOMPtr<nsIContent> bindingContent = content->GetBindingParent();
nsCOMPtr<nsIContent> bindingContent = mContent->GetBindingParent();
if (bindingContent &&
bindingContent->NodeInfo()->Equals(nsAccessibilityAtoms::textbox,
kNameSpaceID_XUL) &&
@ -521,8 +515,8 @@ nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState,
// we're talking here is based on what the user types, where a popup of
// possible choices comes up.
nsAutoString autocomplete;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::autocomplete,
autocomplete);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::autocomplete,
autocomplete);
if (!autocomplete.LowerCaseEqualsLiteral("off")) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
@ -559,7 +553,7 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetActionName(PRUint8 aIndex, nsAString
NS_IMETHODIMP nsHTMLTextFieldAccessible::DoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMNSHTMLElement> element(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNSHTMLElement> element(do_QueryInterface(mContent));
if ( element ) {
return element->Focus();
}
@ -571,7 +565,7 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::DoAction(PRUint8 index)
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAssociatedEditor(nsIEditor **aEditor)
{
*aEditor = nsnull;
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mContent));
NS_ENSURE_TRUE(editableElt, NS_ERROR_FAILURE);
// nsGenericHTMLElement::GetEditor has a security check.
@ -593,15 +587,14 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAssociatedEditor(nsIEditor **aEditor
return rv;
}
// --- groupbox -----
////////////////////////////////////////////////////////////////////////////////
// nsHTMLGroupboxAccessible
////////////////////////////////////////////////////////////////////////////////
/*
* The HTML for this is <fieldset> <legend>box-title</legend> form elements </fieldset>
*/
nsHTMLGroupboxAccessible::nsHTMLGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)
{
nsHTMLGroupboxAccessible::
nsHTMLGroupboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
nsresult
@ -613,16 +606,13 @@ nsHTMLGroupboxAccessible::GetRoleInternal(PRUint32 *aRole)
nsIContent* nsHTMLGroupboxAccessible::GetLegend()
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
NS_ENSURE_TRUE(content, nsnull);
nsresult count = 0;
nsIContent *testLegendContent;
while ((testLegendContent = content->GetChildAt(count ++ )) != nsnull) {
if (testLegendContent->NodeInfo()->Equals(nsAccessibilityAtoms::legend,
content->GetNameSpaceID())) {
nsIContent *legendContent = nsnull;
while ((legendContent = mContent->GetChildAt(count++)) != nsnull) {
if (legendContent->NodeInfo()->Equals(nsAccessibilityAtoms::legend,
mContent->GetNameSpaceID())) {
// Either XHTML namespace or no namespace
return testLegendContent;
return legendContent;
}
}
@ -664,12 +654,15 @@ nsHTMLGroupboxAccessible::GetRelationByType(PRUint32 aRelationType,
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLegendAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLLegendAccessible::nsHTMLLegendAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)
{
nsHTMLLegendAccessible::
nsHTMLLegendAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMETHODIMP

Просмотреть файл

@ -42,13 +42,16 @@
#include "nsFormControlAccessible.h"
#include "nsHyperTextAccessibleWrap.h"
/**
* Accessible for HTML input@type="checkbox".
*/
class nsHTMLCheckboxAccessible : public nsFormControlAccessible
{
public:
enum { eAction_Click = 0 };
nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLCheckboxAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetNumActions(PRUint8 *_retval);
@ -60,11 +63,15 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Accessible for HTML input@type="radio" element.
*/
class nsHTMLRadioButtonAccessible : public nsRadioButtonAccessible
{
public:
nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
@ -72,13 +79,18 @@ public:
PRInt32 *aSetSize);
};
/**
* Accessible for HTML input@type="button", @type="submit", @type="image"
* elements.
*/
class nsHTMLButtonAccessible : public nsHyperTextAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetNumActions(PRUint8 *_retval);
@ -91,13 +103,17 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Accessible for HTML button element.
*/
class nsHTML4ButtonAccessible : public nsHyperTextAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTML4ButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetNumActions(PRUint8 *_retval);
@ -109,13 +125,17 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Accessible for HTML input@type="text" element.
*/
class nsHTMLTextFieldAccessible : public nsHyperTextAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLTextFieldAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
@ -134,10 +154,14 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Accessible for HTML fieldset element.
*/
class nsHTMLGroupboxAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLGroupboxAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
@ -151,10 +175,14 @@ protected:
nsIContent* GetLegend();
};
/**
* Accessible for HTML legend element.
*/
class nsHTMLLegendAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLLegendAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHTMLLegendAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,

Просмотреть файл

@ -57,8 +57,8 @@
////////////////////////////////////////////////////////////////////////////////
nsHTMLImageAccessible::
nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
nsLinkableAccessible(aDOMNode, aShell)
nsHTMLImageAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsLinkableAccessible(aContent, aShell)
{
}
@ -77,7 +77,7 @@ nsHTMLImageAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
nsresult rv = nsLinkableAccessible::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mContent));
nsCOMPtr<imgIRequest> imageRequest;
if (content)
@ -101,9 +101,8 @@ nsHTMLImageAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
nsresult
nsHTMLImageAccessible::GetNameInternal(nsAString& aName)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
PRBool hasAltAttrib =
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, aName);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, aName);
if (!aName.IsEmpty())
return NS_OK;
@ -172,15 +171,14 @@ nsHTMLImageAccessible::DoAction(PRUint8 aIndex)
if (IsValidLongDescIndex(aIndex)) {
//get the long description uri and open in a new window
nsCOMPtr<nsIDOMHTMLImageElement> element(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLImageElement> element(do_QueryInterface(mContent));
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
nsAutoString longDesc;
nsresult rv = element->GetLongDesc(longDesc);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> domDocument;
rv = mDOMNode->GetOwnerDocument(getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
nsIDocument* document = mContent->GetOwnerDoc();
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(piWindow));
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
@ -223,10 +221,8 @@ nsHTMLImageAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
nsresult rv = nsLinkableAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString src;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src, src);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src, src);
if (!src.IsEmpty())
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::src, src);
@ -242,8 +238,7 @@ nsHTMLImageAccessible::HasLongDesc()
if (IsDefunct())
return PR_FALSE;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
return (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::longDesc));
return mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::longDesc);
}
PRBool

Просмотреть файл

@ -51,7 +51,7 @@ class nsHTMLImageAccessible : public nsLinkableAccessible,
public nsIAccessibleImage
{
public:
nsHTMLImageAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLImageAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -54,9 +54,9 @@
////////////////////////////////////////////////////////////////////////////////
nsHTMLImageMapAccessible::
nsHTMLImageMapAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsHTMLImageMapAccessible(nsIContent *aContent, nsIWeakReference *aShell,
nsIDOMHTMLMapElement *aMapElm) :
nsHTMLImageAccessibleWrap(aDOMNode, aShell), mMapElement(aMapElm)
nsHTMLImageAccessibleWrap(aContent, aShell), mMapElement(aMapElm)
{
}
@ -143,19 +143,19 @@ nsHTMLImageMapAccessible::CacheChildren()
if (!areaNode)
return;
nsCOMPtr<nsIContent> areaContent(do_QueryInterface(areaNode));
nsRefPtr<nsAccessible> areaAcc =
new nsHTMLAreaAccessible(areaNode, mWeakShell);
new nsHTMLAreaAccessible(areaContent, mWeakShell);
if (!areaAcc)
return;
nsresult rv = areaAcc->Init();
if (NS_FAILED(rv)) {
if (!areaAcc->Init()) {
areaAcc->Shutdown();
return;
}
// We must respect ARIA on area elements (for the canvas map technique)
areaAcc->SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(areaNode));
areaAcc->SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(areaContent));
mChildren.AppendElement(areaAcc);
areaAcc->SetParent(this);
@ -168,8 +168,8 @@ nsHTMLImageMapAccessible::CacheChildren()
////////////////////////////////////////////////////////////////////////////////
nsHTMLAreaAccessible::
nsHTMLAreaAccessible(nsIDOMNode *aNode, nsIWeakReference *aShell) :
nsHTMLLinkAccessible(aNode, aShell)
nsHTMLAreaAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLLinkAccessible(aContent, aShell)
{
}
@ -185,9 +185,8 @@ nsHTMLAreaAccessible::GetNameInternal(nsAString & aName)
if (!aName.IsEmpty())
return NS_OK;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt,
aName)) {
if (!mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt,
aName)) {
return GetValue(aName);
}
@ -200,7 +199,7 @@ nsHTMLAreaAccessible::GetDescription(nsAString& aDescription)
aDescription.Truncate();
// Still to do - follow IE's standard here
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(mContent));
if (area)
area->GetShape(aDescription);
@ -208,21 +207,25 @@ nsHTMLAreaAccessible::GetDescription(nsAString& aDescription)
}
NS_IMETHODIMP
nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height)
nsHTMLAreaAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
// Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame
*x = *y = *width = *height = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
// Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame.
nsPresContext *presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
nsCOMPtr<nsIContent> ourContent(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(ourContent, NS_ERROR_FAILURE);
nsIFrame *frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
nsIImageFrame *imageFrame = do_QueryFrame(frame);
@ -233,21 +236,21 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
nsRect rect;
nsIntRect orgRectPixels;
rv = map->GetBoundsForAreaContent(ourContent, rect);
nsresult rv = map->GetBoundsForAreaContent(mContent, rect);
NS_ENSURE_SUCCESS(rv, rv);
*x = presContext->AppUnitsToDevPixels(rect.x);
*y = presContext->AppUnitsToDevPixels(rect.y);
*aX = presContext->AppUnitsToDevPixels(rect.x);
*aY = presContext->AppUnitsToDevPixels(rect.y);
// XXX Areas are screwy; they return their rects as a pair of points, one pair
// stored into the width and height.
*width = presContext->AppUnitsToDevPixels(rect.width - rect.x);
*height = presContext->AppUnitsToDevPixels(rect.height - rect.y);
*aWidth = presContext->AppUnitsToDevPixels(rect.width - rect.x);
*aHeight = presContext->AppUnitsToDevPixels(rect.height - rect.y);
// Put coords in absolute screen coords
orgRectPixels = frame->GetScreenRectExternal();
*x += orgRectPixels.x;
*y += orgRectPixels.y;
*aX += orgRectPixels.x;
*aY += orgRectPixels.y;
return NS_OK;
}

Просмотреть файл

@ -51,7 +51,7 @@
class nsHTMLImageMapAccessible : public nsHTMLImageAccessibleWrap
{
public:
nsHTMLImageMapAccessible(nsIDOMNode *aNode, nsIWeakReference *aShell,
nsHTMLImageMapAccessible(nsIContent *aContent, nsIWeakReference *aShell,
nsIDOMHTMLMapElement *aMapElm);
// nsISupports and cycle collector
@ -83,7 +83,7 @@ class nsHTMLAreaAccessible : public nsHTMLLinkAccessible
{
public:
nsHTMLAreaAccessible(nsIDOMNode *aNode, nsIWeakReference *aShell);
nsHTMLAreaAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsIAccessible
NS_IMETHOD GetDescription(nsAString& aDescription);

Просмотреть файл

@ -45,11 +45,12 @@
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLinkAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aDomNode, aShell)
{
nsHTMLLinkAccessible::
nsHTMLLinkAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
// Expose nsIAccessibleHyperLink unconditionally
@ -75,21 +76,19 @@ nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
*aState &= ~nsIAccessibleStates::STATE_READONLY;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content && content->HasAttr(kNameSpaceID_None,
nsAccessibilityAtoms::name)) {
if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::name)) {
// This is how we indicate it is a named anchor
// In other words, this anchor can be selected as a location :)
// There is no other better state to use to indicate this.
*aState |= nsIAccessibleStates::STATE_SELECTABLE;
}
nsLinkState linkState = content->GetLinkState();
nsLinkState linkState = mContent->GetLinkState();
if (linkState == eLinkState_NotLink || linkState == eLinkState_Unknown) {
// This is a either named anchor (a link with also a name attribute) or
// it doesn't have any attributes. Check if 'click' event handler is
// registered, otherwise bail out.
PRBool isOnclick = nsCoreUtils::HasClickListener(content);
PRBool isOnclick = nsCoreUtils::HasClickListener(mContent);
if (!isOnclick)
return NS_OK;
}
@ -114,10 +113,8 @@ nsHTMLLinkAccessible::GetValue(nsAString& aValue)
return NS_OK;
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (mDOMNode && presShell)
return presShell->GetLinkLocation(mDOMNode, aValue);
return NS_OK;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return presShell->GetLinkLocation(DOMNode, aValue);
}
NS_IMETHODIMP
@ -177,10 +174,11 @@ nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
if (aIndex != 0)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIContent> link(do_QueryInterface(mDOMNode));
NS_ENSURE_STATE(link);
if (IsDefunct())
return NS_ERROR_FAILURE;
*aURI = link->GetHrefURI().get();
nsCOMPtr<nsIURI> uri = mContent->GetHrefURI();
uri.forget(aURI);
return NS_OK;
}
@ -190,11 +188,9 @@ nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
PRBool
nsHTMLLinkAccessible::IsLinked()
{
nsCOMPtr<nsIContent> link(do_QueryInterface(mDOMNode));
if (!link)
if (IsDefunct())
return PR_FALSE;
nsLinkState linkState = link->GetLinkState();
nsLinkState linkState = mContent->GetLinkState();
return linkState != eLinkState_NotLink && linkState != eLinkState_Unknown;
}

Просмотреть файл

@ -45,7 +45,7 @@
class nsHTMLLinkAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLLinkAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "nsDocAccessible.h"
#include "nsEventShell.h"
#include "nsIAccessibleEvent.h"
#include "nsTextEquivUtils.h"
@ -55,34 +56,21 @@
#include "nsIServiceManager.h"
#include "nsIMutableArray.h"
/**
* Selects, Listboxes and Comboboxes, are made up of a number of different
* widgets, some of which are shared between the two. This file contains
* all of the widgets for both of the Selects, for HTML only.
*
* Listbox:
* - nsHTMLSelectListAccessible
* - nsHTMLSelectOptionAccessible
*
* Comboboxes:
* - nsHTMLComboboxAccessible
* - nsHTMLComboboxListAccessible [ inserted in accessible tree ]
* - nsHTMLSelectOptionAccessible(s)
*/
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible::iterator
/** ------------------------------------------------------ */
/** Impl. of nsHTMLSelectableAccessible */
/** ------------------------------------------------------ */
// Helper class
nsHTMLSelectableAccessible::iterator::iterator(nsHTMLSelectableAccessible *aParent, nsIWeakReference *aWeakShell):
mWeakShell(aWeakShell), mParentSelect(aParent)
{
mLength = mIndex = 0;
mSelCount = 0;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mParentSelect->mDOMNode));
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect =
do_QueryInterface(mParentSelect->mContent);
if (htmlSelect) {
htmlSelect->GetOptions(getter_AddRefs(mOptions));
if (mOptions)
@ -125,8 +113,8 @@ nsHTMLSelectableAccessible::iterator::AddAccessibleIfSelected(nsIMutableArray *a
if (mOption) {
mOption->GetSelected(&isSelected);
if (isSelected) {
nsCOMPtr<nsIDOMNode> optionNode(do_QueryInterface(mOption));
optionAcc = GetAccService()->GetAccessibleInWeakShell(optionNode,
nsCOMPtr<nsIContent> optionContent(do_QueryInterface(mOption));
optionAcc = GetAccService()->GetAccessibleInWeakShell(optionContent,
mWeakShell);
}
}
@ -149,9 +137,9 @@ nsHTMLSelectableAccessible::iterator::GetAccessibleIfSelected(PRInt32 aIndex,
mOption->GetSelected(&isSelected);
if (isSelected) {
if (mSelCount == aIndex) {
nsCOMPtr<nsIDOMNode> optionNode(do_QueryInterface(mOption));
nsCOMPtr<nsIContent> optionContent(do_QueryInterface(mOption));
nsAccessible *accessible =
GetAccService()->GetAccessibleInWeakShell(optionNode, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(optionContent, mWeakShell);
NS_IF_ADDREF(*aAccessible = accessible);
return PR_TRUE;
@ -169,9 +157,12 @@ void nsHTMLSelectableAccessible::iterator::Select(PRBool aSelect)
mOption->SetSelected(aSelect);
}
nsHTMLSelectableAccessible::nsHTMLSelectableAccessible(nsIDOMNode* aDOMNode,
nsIWeakReference* aShell):
nsAccessibleWrap(aDOMNode, aShell)
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectableAccessible
nsHTMLSelectableAccessible::
nsHTMLSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
@ -182,7 +173,7 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint
{
*aSelState = PR_FALSE;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mContent));
if (!htmlSelect)
return NS_ERROR_FAILURE;
@ -290,7 +281,7 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::SelectAllSelection(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLSelectElement> htmlSelect(do_QueryInterface(mContent));
if (!htmlSelect)
return NS_ERROR_FAILURE;
@ -303,18 +294,14 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::SelectAllSelection(PRBool *_retval)
return NS_OK;
}
/** ------------------------------------------------------ */
/** First, the common widgets */
/** ------------------------------------------------------ */
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible
////////////////////////////////////////////////////////////////////////////////
/** Default Constructor */
nsHTMLSelectListAccessible::nsHTMLSelectListAccessible(nsIDOMNode* aDOMNode,
nsIWeakReference* aShell)
:nsHTMLSelectableAccessible(aDOMNode, aShell)
nsHTMLSelectListAccessible::
nsHTMLSelectListAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLSelectableAccessible(aContent, aShell)
{
}
@ -333,14 +320,13 @@ nsHTMLSelectListAccessible::GetStateInternal(PRUint32 *aState,
// nsIAccessibleStates::STATE_MULTISELECTABLE
// nsIAccessibleStates::STATE_EXTSELECTABLE
nsCOMPtr<nsIDOMHTMLSelectElement> select (do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLSelectElement> select(do_QueryInterface(mContent));
if (select) {
if (*aState & nsIAccessibleStates::STATE_FOCUSED) {
// Treat first focusable option node as actual focus, in order
// to avoid confusing JAWS, which needs focus on the option
nsCOMPtr<nsIDOMNode> focusedOption;
nsHTMLSelectOptionAccessible::GetFocusedOptionNode(mDOMNode,
getter_AddRefs(focusedOption));
nsCOMPtr<nsIContent> focusedOption =
nsHTMLSelectOptionAccessible::GetFocusedOption(mContent);
if (focusedOption) { // Clear focused state since it is on option
*aState &= ~nsIAccessibleStates::STATE_FOCUSED;
}
@ -376,9 +362,7 @@ nsHTMLSelectListAccessible::CacheChildren()
// as well as the accessibles for them. Avoid whitespace text nodes. We want
// to count all the <optgroup>s and <option>s as children because we want
// a flat tree under the Select List.
nsCOMPtr<nsIContent> selectContent(do_QueryInterface(mDOMNode));
CacheOptSiblings(selectContent);
CacheOptSiblings(mContent);
}
////////////////////////////////////////////////////////////////////////////////
@ -399,10 +383,8 @@ nsHTMLSelectListAccessible::CacheOptSiblings(nsIContent *aParentContent)
tag == nsAccessibilityAtoms::optgroup) {
// Get an accessible for option or optgroup and cache it.
nsCOMPtr<nsIDOMNode> childNode(do_QueryInterface(childContent));
nsAccessible *accessible =
GetAccService()->GetAccessibleInWeakShell(childNode, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(childContent, mWeakShell);
if (accessible) {
mChildren.AppendElement(accessible);
accessible->SetParent(this);
@ -421,13 +403,11 @@ nsHTMLSelectListAccessible::CacheOptSiblings(nsIContent *aParentContent)
////////////////////////////////////////////////////////////////////////////////
nsHTMLSelectOptionAccessible::
nsHTMLSelectOptionAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aDOMNode, aShell)
nsHTMLSelectOptionAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
nsCOMPtr<nsIDOMNode> parentNode;
aDOMNode->GetParentNode(getter_AddRefs(parentNode));
if (!parentNode)
nsIContent *parentContent = aContent->GetParent();
if (!parentContent)
return;
// If the parent node is a Combobox, then the option's accessible parent
@ -436,7 +416,7 @@ nsHTMLSelectOptionAccessible::
// nsHTMLComboboxListAccessible is inserted into the accessible hierarchy
// where there is no DOM node for it.
nsAccessible *parentAcc =
GetAccService()->GetAccessibleInWeakShell(parentNode, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(parentContent, mWeakShell);
if (!parentAcc)
return;
@ -467,14 +447,13 @@ nsHTMLSelectOptionAccessible::GetNameInternal(nsAString& aName)
{
// CASE #1 -- great majority of the cases
// find the label attribute - this is what the W3C says we should use
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::label, aName);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::label, aName);
if (!aName.IsEmpty())
return NS_OK;
// CASE #2 -- no label parameter, get the first child,
// use it if it is a text node
nsCOMPtr<nsIContent> text = content->GetChildAt(0);
nsIContent *text = mContent->GetChildAt(0);
if (!text)
return NS_OK;
@ -532,8 +511,7 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
nsCOMPtr<nsIDOMNode> selectNode = do_QueryInterface(selectContent);
NS_ENSURE_TRUE(selectNode, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(selectContent, NS_ERROR_FAILURE);
// Is disabled?
if (0 == (*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) {
@ -543,19 +521,17 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState,
// Firefox draws a focus ring around the first non-disabled option.
// We need to indicated STATE_FOCUSED in that case, because it
// prevents JAWS from ignoring the list
// GetFocusedOptionNode() ensures that an option node is
// GetFocusedOption() ensures that an option node is
// returned in this case, as long as some focusable option exists
// in the listbox
nsCOMPtr<nsIDOMNode> focusedOptionNode;
GetFocusedOptionNode(selectNode, getter_AddRefs(focusedOptionNode));
if (focusedOptionNode == mDOMNode) {
nsCOMPtr<nsIContent> focusedOption = GetFocusedOption(selectContent);
if (focusedOption == mContent)
*aState |= nsIAccessibleStates::STATE_FOCUSED;
}
}
// Are we selected?
PRBool isSelected = PR_FALSE;
nsCOMPtr<nsIDOMHTMLOptionElement> option (do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mContent));
if (option) {
option->GetSelected(&isSelected);
if ( isSelected )
@ -603,8 +579,7 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState,
PRInt32
nsHTMLSelectOptionAccessible::GetLevelInternal()
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIContent *parentContent = content->GetParent();
nsIContent *parentContent = mContent->GetParent();
PRInt32 level =
parentContent->NodeInfo()->Equals(nsAccessibilityAtoms::optgroup) ? 2 : 1;
@ -620,9 +595,8 @@ nsHTMLSelectOptionAccessible::GetLevelInternal()
void
nsHTMLSelectOptionAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIContent *parentContent = content->GetParent();
{
nsIContent *parentContent = mContent->GetParent();
PRInt32 posInSet = 0, setSize = 0;
PRBool isContentFound = PR_FALSE;
@ -630,9 +604,9 @@ nsHTMLSelectOptionAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRUint32 childCount = parentContent->GetChildCount();
for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
nsIContent *childContent = parentContent->GetChildAt(childIdx);
if (childContent->NodeInfo()->Equals(content->NodeInfo())) {
if (childContent->NodeInfo()->Equals(mContent->NodeInfo())) {
if (!isContentFound) {
if (childContent == content)
if (childContent == mContent)
isContentFound = PR_TRUE;
posInSet++;
@ -667,17 +641,17 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
{
if (index == eAction_Select) { // default action
nsCOMPtr<nsIDOMHTMLOptionElement> newHTMLOption(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLOptionElement> newHTMLOption(do_QueryInterface(mContent));
if (!newHTMLOption)
return NS_ERROR_FAILURE;
// Clear old selection
nsCOMPtr<nsIDOMNode> oldHTMLOptionNode, selectNode;
nsAccessible* parent = GetParent();
NS_ASSERTION(parent, "No parent!");
parent->GetDOMNode(getter_AddRefs(selectNode));
GetFocusedOptionNode(selectNode, getter_AddRefs(oldHTMLOptionNode));
nsCOMPtr<nsIDOMHTMLOptionElement> oldHTMLOption(do_QueryInterface(oldHTMLOptionNode));
nsCOMPtr<nsIContent> oldHTMLOptionContent =
GetFocusedOption(parent->GetContent());
nsCOMPtr<nsIDOMHTMLOptionElement> oldHTMLOption =
do_QueryInterface(oldHTMLOptionContent);
if (oldHTMLOption)
oldHTMLOption->SetSelected(PR_FALSE);
// Set new selection
@ -685,21 +659,20 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
// If combo box, and open, close it
// First, get the <select> widgets list control frame
nsCOMPtr<nsIDOMNode> testSelectNode;
nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(mDOMNode));
nsIContent *selectContent = mContent;
do {
thisNode->GetParentNode(getter_AddRefs(testSelectNode));
nsCOMPtr<nsIDOMHTMLSelectElement> selectControl(do_QueryInterface(testSelectNode));
selectContent = selectContent->GetParent();
nsCOMPtr<nsIDOMHTMLSelectElement> selectControl =
do_QueryInterface(selectContent);
if (selectControl)
break;
thisNode = testSelectNode;
} while (testSelectNode);
} while (selectContent);
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
nsCOMPtr<nsIContent> selectContent(do_QueryInterface(testSelectNode));
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mContent));
if (!testSelectNode || !selectContent || !presShell || !option)
if (!selectContent || !presShell || !option)
return NS_ERROR_FAILURE;
nsIFrame *selectFrame = selectContent->GetPrimaryFrame();
@ -730,16 +703,14 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
* need to use the frame to get the focused option because for some reason we
* weren't getting the proper notification when the focus changed using the DOM
*/
nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNode,
nsIDOMNode **aFocusedOptionNode)
already_AddRefed<nsIContent>
nsHTMLSelectOptionAccessible::GetFocusedOption(nsIContent *aListNode)
{
*aFocusedOptionNode = nsnull;
NS_ASSERTION(aListNode, "Called GetFocusedOptionNode without a valid list node");
nsCOMPtr<nsIContent> content(do_QueryInterface(aListNode));
nsIFrame *frame = content->GetPrimaryFrame();
nsIFrame *frame = aListNode->GetPrimaryFrame();
if (!frame)
return NS_ERROR_FAILURE;
return nsnull;
PRInt32 focusedOptionIndex = 0;
@ -781,37 +752,45 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNod
// Either use options and focused index, or default return null
if (NS_SUCCEEDED(rv) && options && focusedOptionIndex >= 0) { // Something is focused
rv = options->Item(focusedOptionIndex, aFocusedOptionNode);
nsCOMPtr<nsIDOMNode> focusedOptionNode;
options->Item(focusedOptionIndex, getter_AddRefs(focusedOptionNode));
nsIContent *focusedOption = nsnull;
if (focusedOptionNode)
CallQueryInterface(focusedOptionNode, &focusedOption);
return focusedOption;
}
return rv;
return nsnull;
}
void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibleOption)
void
nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibleOptionNode)
{
if (!aPossibleOption || aPossibleOption->Tag() != nsAccessibilityAtoms::option ||
!aPossibleOption->IsHTML()) {
if (!aPossibleOptionNode ||
aPossibleOptionNode->Tag() != nsAccessibilityAtoms::option ||
!aPossibleOptionNode->IsHTML()) {
return;
}
nsCOMPtr<nsIDOMNode> optionNode(do_QueryInterface(aPossibleOption));
NS_ASSERTION(optionNode, "No option node for nsIContent with option tag!");
nsCOMPtr<nsIAccessible> multiSelect =
nsAccUtils::GetMultiSelectableContainer(optionNode);
nsAccessible *multiSelect =
nsAccUtils::GetMultiSelectableContainer(aPossibleOptionNode);
if (!multiSelect)
return;
nsCOMPtr<nsIAccessible> optionAccessible;
GetAccService()->GetAccessibleFor(optionNode,
getter_AddRefs(optionAccessible));
if (!optionAccessible)
nsAccessible *option = GetAccService()->GetAccessible(aPossibleOptionNode);
if (!option)
return;
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelect);
PRUint32 state = nsAccUtils::State(optionAccessible);
nsRefPtr<nsAccEvent> selWithinEvent =
new nsAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN, multiSelect);
if (!selWithinEvent)
return;
option->GetDocAccessible()->FireDelayedAccessibleEvent(selWithinEvent);
PRUint32 state = nsAccUtils::State(option);
PRUint32 eventType;
if (state & nsIAccessibleStates::STATE_SELECTED) {
eventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
@ -820,7 +799,11 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
}
nsEventShell::FireEvent(eventType, optionAccessible);
nsRefPtr<nsAccEvent> setAddRemoveEvent =
new nsAccEvent(eventType, option);
if (setAddRemoveEvent)
option->GetDocAccessible()->FireDelayedAccessibleEvent(setAddRemoveEvent);
}
////////////////////////////////////////////////////////////////////////////////
@ -829,7 +812,7 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState,
PRUint32* aExtraState)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIContent *content = mContent;
while (content && content->Tag() != nsAccessibilityAtoms::select) {
content = content->GetParent();
}
@ -846,13 +829,15 @@ nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState,
return nsnull;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptGroupAccessible
////////////////////////////////////////////////////////////////////////////////
/** Default Constructor */
nsHTMLSelectOptGroupAccessible::nsHTMLSelectOptGroupAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsHTMLSelectOptionAccessible(aDOMNode, aShell)
nsHTMLSelectOptGroupAccessible::
nsHTMLSelectOptGroupAccessible(nsIContent *aContent,
nsIWeakReference *aShell) :
nsHTMLSelectOptionAccessible(aContent, aShell)
{
}
@ -905,20 +890,17 @@ nsHTMLSelectOptGroupAccessible::CacheChildren()
// CreateAttributeContent() in nsCSSFrameConstructor
}
/** ------------------------------------------------------ */
/** Finally, the Combobox widgets */
/** ------------------------------------------------------ */
////////////////////////////////////////////////////////////////////////////////
// nsHTMLComboboxAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLComboboxAccessible::nsHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsAccessibleWrap(aDOMNode, aShell)
nsHTMLComboboxAccessible::
nsHTMLComboboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
/** We are a combobox */
nsresult
nsHTMLComboboxAccessible::GetRoleInternal(PRUint32 *aRole)
{
@ -943,7 +925,7 @@ nsHTMLComboboxAccessible::CacheChildren()
if (!mListAccessible) {
mListAccessible =
new nsHTMLComboboxListAccessible(mParent, mDOMNode, mWeakShell);
new nsHTMLComboboxListAccessible(mParent, mContent, mWeakShell);
if (!mListAccessible)
return;
@ -954,7 +936,7 @@ nsHTMLComboboxAccessible::CacheChildren()
mListAccessible->SetParent(this);
}
nsresult
void
nsHTMLComboboxAccessible::Shutdown()
{
nsAccessibleWrap::Shutdown();
@ -963,7 +945,6 @@ nsHTMLComboboxAccessible::Shutdown()
mListAccessible->Shutdown();
mListAccessible = nsnull;
}
return NS_OK;
}
/**
@ -1018,14 +999,13 @@ nsHTMLComboboxAccessible::GetFocusedOptionAccessible()
if (IsDefunct())
return nsnull;
nsCOMPtr<nsIDOMNode> focusedOptionNode;
nsHTMLSelectOptionAccessible::
GetFocusedOptionNode(mDOMNode, getter_AddRefs(focusedOptionNode));
if (!focusedOptionNode) {
nsCOMPtr<nsIContent> focusedOption =
nsHTMLSelectOptionAccessible::GetFocusedOption(mContent);
if (!focusedOption) {
return nsnull;
}
return GetAccService()->GetAccessibleInWeakShell(focusedOptionNode,
return GetAccService()->GetAccessibleInWeakShell(focusedOption,
mWeakShell);
}
@ -1102,10 +1082,10 @@ NS_IMETHODIMP nsHTMLComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString&
// nsHTMLComboboxListAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLComboboxListAccessible::nsHTMLComboboxListAccessible(nsIAccessible *aParent,
nsIDOMNode* aDOMNode,
nsIWeakReference* aShell):
nsHTMLSelectListAccessible(aDOMNode, aShell)
nsHTMLComboboxListAccessible::
nsHTMLComboboxListAccessible(nsIAccessible *aParent, nsIContent *aContent,
nsIWeakReference *aShell) :
nsHTMLSelectListAccessible(aContent, aShell)
{
}
@ -1151,7 +1131,8 @@ nsHTMLComboboxListAccessible::GetStateInternal(PRUint32 *aState,
NS_IMETHODIMP nsHTMLComboboxListAccessible::GetUniqueID(void **aUniqueID)
{
// Since mDOMNode is same for all tree item, use |this| pointer as the unique Id
// Since mContent is same for all tree item, use |this| pointer as the unique
// Id.
*aUniqueID = static_cast<void*>(this);
return NS_OK;
}
@ -1172,12 +1153,9 @@ void nsHTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBo
nsHTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame);
return;
}
// get our first option
nsCOMPtr<nsIDOMNode> child;
mDOMNode->GetFirstChild(getter_AddRefs(child));
// now get its frame
nsCOMPtr<nsIContent> content(do_QueryInterface(child));
// Get the first option.
nsIContent* content = mContent->GetChildAt(0);
if (!content) {
return;
}

Просмотреть файл

@ -59,8 +59,6 @@ class nsIMutableArray;
*
* Comboboxes:
* - nsHTMLComboboxAccessible
* - nsHTMLComboboxTextFieldAccessible
* - nsHTMLComboboxButtonAccessible
* - nsHTMLComboboxListAccessible [ inserted in accessible tree ]
* - nsHTMLSelectOptionAccessible(s)
*/
@ -79,7 +77,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLESELECTABLE
nsHTMLSelectableAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsHTMLSelectableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLSelectableAccessible() {}
protected:
@ -120,7 +118,7 @@ class nsHTMLSelectListAccessible : public nsHTMLSelectableAccessible
{
public:
nsHTMLSelectListAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsHTMLSelectListAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLSelectListAccessible() {}
// nsAccessible
@ -148,7 +146,7 @@ class nsHTMLSelectOptionAccessible : public nsHyperTextAccessibleWrap
public:
enum { eAction_Select = 0 };
nsHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsHTMLSelectOptionAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLSelectOptionAccessible() {}
// nsIAccessible
@ -166,7 +164,12 @@ public:
PRInt32 *aSetSize);
nsIFrame* GetBoundsFrame();
static nsresult GetFocusedOptionNode(nsIDOMNode *aListNode, nsIDOMNode **aFocusedOptionNode);
/**
* Return focused option if any.
*/
static already_AddRefed<nsIContent> GetFocusedOption(nsIContent *aListNode);
static void SelectionChangedIfOption(nsIContent *aPossibleOption);
private:
@ -187,7 +190,7 @@ class nsHTMLSelectOptGroupAccessible : public nsHTMLSelectOptionAccessible
{
public:
nsHTMLSelectOptGroupAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsHTMLSelectOptGroupAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLSelectOptGroupAccessible() {}
// nsIAccessible
@ -218,7 +221,7 @@ class nsHTMLComboboxAccessible : public nsAccessibleWrap
public:
enum { eAction_Click = 0 };
nsHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsHTMLComboboxAccessible(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsHTMLComboboxAccessible() {}
// nsIAccessible
@ -229,7 +232,7 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -260,7 +263,7 @@ class nsHTMLComboboxListAccessible : public nsHTMLSelectListAccessible
public:
nsHTMLComboboxListAccessible(nsIAccessible *aParent,
nsIDOMNode* aDOMNode,
nsIContent *aContent,
nsIWeakReference* aShell);
virtual ~nsHTMLComboboxListAccessible() {}

Просмотреть файл

@ -70,8 +70,8 @@
////////////////////////////////////////////////////////////////////////////////
nsHTMLTableCellAccessible::
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell) :
nsHyperTextAccessibleWrap(aDomNode, aShell)
nsHTMLTableCellAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
@ -99,9 +99,7 @@ nsHTMLTableCellAccessible::GetStateInternal(PRUint32 *aState,
nsresult rv= nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mWeakShell);
nsIFrame *frame = content->GetPrimaryFrame();
nsIFrame *frame = mContent->GetPrimaryFrame();
NS_ASSERTION(frame, "No frame for valid cell accessible!");
if (frame) {
@ -291,13 +289,11 @@ nsHTMLTableCellAccessible::GetTableAccessible()
nsITableCellLayout*
nsHTMLTableCellAccessible::GetCellLayout()
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIFrame *frame = content->GetPrimaryFrame();
nsIFrame *frame = mContent->GetPrimaryFrame();
NS_ASSERTION(frame, "The frame cannot be obtaied for HTML table cell.");
if (!frame)
return nsnull;
nsITableCellLayout *cellLayout = do_QueryFrame(frame);
return cellLayout;
}
@ -316,11 +312,9 @@ nsresult
nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
nsIArray **aHeaderCells)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
// Get header cells from @header attribute.
nsCOMPtr<nsIArray> headerCellElms;
nsCoreUtils::GetElementsByIDRefsAttr(content, nsAccessibilityAtoms::headers,
nsCoreUtils::GetElementsByIDRefsAttr(mContent, nsAccessibilityAtoms::headers,
getter_AddRefs(headerCellElms));
if (headerCellElms) {
@ -332,11 +326,11 @@ nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
PRUint32 count = 0;
rv = headerCellElms->GetLength(&count);
if (NS_SUCCEEDED(rv) && count > 0) {
nsCOMPtr<nsIDOMNode> headerCellNode;
nsCOMPtr<nsIContent> headerCellContent;
for (PRUint32 idx = 0; idx < count; idx++) {
headerCellNode = do_QueryElementAt(headerCellElms, idx, &rv);
headerCellContent = do_QueryElementAt(headerCellElms, idx, &rv);
nsAccessible *headerCell =
GetAccService()->GetAccessibleInWeakShell(headerCellNode, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(headerCellContent, mWeakShell);
if (headerCell &&
(aRowOrColumnHeaderCell == nsAccUtils::eRowHeaderCells &&
@ -368,9 +362,9 @@ nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
////////////////////////////////////////////////////////////////////////////////
nsHTMLTableHeaderCellAccessible::
nsHTMLTableHeaderCellAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell) :
nsHTMLTableCellAccessible(aDomNode, aShell)
nsHTMLTableHeaderCellAccessible(nsIContent *aContent,
nsIWeakReference *aShell) :
nsHTMLTableCellAccessible(aContent, aShell)
{
}
@ -380,14 +374,12 @@ nsHTMLTableHeaderCellAccessible::
nsresult
nsHTMLTableHeaderCellAccessible::GetRoleInternal(PRUint32 *aRole)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
// Check value of @scope attribute.
static nsIContent::AttrValuesArray scopeValues[] =
{&nsAccessibilityAtoms::col, &nsAccessibilityAtoms::row, nsnull};
PRInt32 valueIdx =
content->FindAttrValueIn(kNameSpaceID_None, nsAccessibilityAtoms::scope,
scopeValues, eCaseMatters);
mContent->FindAttrValueIn(kNameSpaceID_None, nsAccessibilityAtoms::scope,
scopeValues, eCaseMatters);
switch (valueIdx) {
case 0:
@ -400,10 +392,10 @@ nsHTMLTableHeaderCellAccessible::GetRoleInternal(PRUint32 *aRole)
// Assume it's columnheader if there are headers in siblings, oterwise
// rowheader.
nsIContent* parent = content->GetParent();
nsIContent *parent = mContent->GetParent();
NS_ENSURE_STATE(parent);
PRInt32 indexInParent = parent->IndexOf(content);
PRInt32 indexInParent = parent->IndexOf(mContent);
for (PRInt32 idx = indexInParent - 1; idx >= 0; idx--) {
nsIContent* sibling = parent->GetChildAt(idx);
@ -442,9 +434,9 @@ nsHTMLTableHeaderCellAccessible::GetRoleInternal(PRUint32 *aRole)
////////////////////////////////////////////////////////////////////////////////
nsHTMLTableAccessible::
nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell) :
nsAccessibleWrap(aDomNode, aShell)
{
nsHTMLTableAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessibleWrap(aContent, aShell)
{
}
////////////////////////////////////////////////////////////////////////////////
@ -504,12 +496,8 @@ nsHTMLTableAccessible::GetNameInternal(nsAString& aName)
{
nsAccessible::GetNameInternal(aName);
if (aName.IsEmpty()) {
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content) {
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, aName);
}
}
if (aName.IsEmpty())
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, aName);
return NS_OK;
}
@ -517,13 +505,9 @@ nsHTMLTableAccessible::GetNameInternal(nsAString& aName)
nsresult
nsHTMLTableAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
nsresult rv = nsAccessibleWrap::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
PRBool isProbablyForLayout;
IsProbablyForLayout(&isProbablyForLayout);
if (isProbablyForLayout) {
@ -572,7 +556,7 @@ nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
NS_IMETHODIMP
nsHTMLTableAccessible::GetSummary(nsAString &aSummary)
{
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mContent));
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
return table->GetSummary(aSummary);
@ -738,8 +722,9 @@ nsHTMLTableAccessible::GetSelectedCells(nsIArray **aCells)
if (NS_SUCCEEDED(rv) && startRowIndex == rowIndex &&
startColIndex == columnIndex && isSelected) {
nsCOMPtr<nsIContent> cellContent(do_QueryInterface(cellElement));
nsAccessible *cell =
GetAccService()->GetAccessibleInWeakShell(cellElement, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(cellContent, mWeakShell);
selCells->AppendElement(static_cast<nsIAccessible*>(cell), PR_FALSE);
}
}
@ -911,8 +896,9 @@ nsHTMLTableAccessible::GetCellAt(PRInt32 aRow, PRInt32 aColumn,
nsresult rv = GetCellAt(aRow, aColumn, *getter_AddRefs(cellElement));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> cellContent(do_QueryInterface(cellElement));
nsAccessible *cell =
GetAccService()->GetAccessibleInWeakShell(cellElement, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(cellContent, mWeakShell);
if (cell)
CallQueryInterface(cell, aTableCellAccessible);
@ -1214,8 +1200,6 @@ nsHTMLTableAccessible::RemoveRowsOrColumnsFromSelection(PRInt32 aIndex,
PRUint32 aTarget,
PRBool aIsOuter)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsITableLayout *tableLayout = GetTableLayout();
NS_ENSURE_STATE(tableLayout);
@ -1238,11 +1222,11 @@ nsHTMLTableAccessible::RemoveRowsOrColumnsFromSelection(PRInt32 aIndex,
PRInt32 endColIdx = doUnselectRow ? count - 1 : aIndex;
if (aIsOuter)
return tableSelection->RestrictCellsToSelection(content,
return tableSelection->RestrictCellsToSelection(mContent,
startRowIdx, startColIdx,
endRowIdx, endColIdx);
return tableSelection->RemoveCellsFromSelection(content,
return tableSelection->RemoveCellsFromSelection(mContent,
startRowIdx, startColIdx,
endRowIdx, endColIdx);
}
@ -1250,8 +1234,7 @@ nsHTMLTableAccessible::RemoveRowsOrColumnsFromSelection(PRInt32 aIndex,
nsITableLayout*
nsHTMLTableAccessible::GetTableLayout()
{
nsCOMPtr<nsIContent> tableContent(do_QueryInterface(mDOMNode));
nsIFrame *frame = tableContent->GetPrimaryFrame();
nsIFrame *frame = mContent->GetPrimaryFrame();
if (!frame)
return nsnull;
@ -1319,7 +1302,7 @@ PRBool
nsHTMLTableAccessible::HasDescendant(const nsAString& aTagName,
PRBool aAllowEmpty)
{
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mContent));
NS_ENSURE_TRUE(tableElt, PR_FALSE);
nsCOMPtr<nsIDOMNodeList> nodeList;
@ -1397,8 +1380,7 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
RETURN_LAYOUT_ANSWER(PR_FALSE, "Has role attribute");
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) {
if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) {
// Role attribute is present, but overridden roles have already been dealt with.
// Only landmarks and other roles that don't override the role from native
// markup are left to deal with here.
@ -1407,7 +1389,8 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
// Check for legitimate data table elements or attributes
nsAutoString summary;
if ((content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, summary) && !summary.IsEmpty()) ||
if ((mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, summary) &&
!summary.IsEmpty()) ||
HasDescendant(NS_LITERAL_STRING("caption"), PR_FALSE) ||
HasDescendant(NS_LITERAL_STRING("th")) ||
HasDescendant(NS_LITERAL_STRING("thead")) ||
@ -1461,7 +1444,7 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
// Check for styled background color across the row
// Alternating background color is a common way
nsCOMPtr<nsIDOMNodeList> nodeList;
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mContent));
tableElt->GetElementsByTagName(NS_LITERAL_STRING("tr"), getter_AddRefs(nodeList));
NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);
PRUint32 length;
@ -1470,10 +1453,10 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
for (PRUint32 rowCount = 0; rowCount < length; rowCount ++) {
nsCOMPtr<nsIDOMNode> rowNode;
nodeList->Item(rowCount, getter_AddRefs(rowNode));
nsCOMPtr<nsIContent> rowContent(do_QueryInterface(rowNode));
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), rowNode,
getter_AddRefs(styleDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), rowContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
lastRowColor = color;
@ -1500,12 +1483,9 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
NS_ENSURE_TRUE(tableFrame , NS_ERROR_FAILURE);
nsSize tableSize = tableFrame->GetSize();
nsCOMPtr<nsIAccessibleDocument> docAccessible = GetDocAccessible();
nsDocAccessible *docAccessible = GetDocAccessible();
NS_ENSURE_TRUE(docAccessible, NS_ERROR_FAILURE);
nsRefPtr<nsAccessNode> docAccessNode = do_QueryObject(docAccessible);
nsIFrame *docFrame = docAccessNode->GetFrame();
nsIFrame *docFrame = docAccessible->GetFrame();
NS_ENSURE_TRUE(docFrame , NS_ERROR_FAILURE);
nsSize docSize = docFrame->GetSize();

Просмотреть файл

@ -52,7 +52,7 @@ class nsHTMLTableCellAccessible : public nsHyperTextAccessibleWrap,
public nsIAccessibleTableCell
{
public:
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLTableCellAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -95,8 +95,8 @@ protected:
class nsHTMLTableHeaderCellAccessible : public nsHTMLTableCellAccessible
{
public:
nsHTMLTableHeaderCellAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell);
nsHTMLTableHeaderCellAccessible(nsIContent *aContent,
nsIWeakReference *aShell);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -124,7 +124,7 @@ class nsHTMLTableAccessible : public nsAccessibleWrap,
public nsIAccessibleTable
{
public:
nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLTableAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETABLE
@ -207,8 +207,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsHTMLTableAccessible,
class nsHTMLCaptionAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLCaptionAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aDomNode, aShell) { }
nsHTMLCaptionAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell) { }
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,

Просмотреть файл

@ -52,9 +52,10 @@
// nsHTMLTextAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsTextAccessibleWrap(aDomNode, aShell)
{
nsHTMLTextAccessible::
nsHTMLTextAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsTextAccessibleWrap(aContent, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTextAccessible, nsTextAccessible)
@ -102,10 +103,6 @@ nsHTMLTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
nsresult
nsHTMLTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
PRUint32 role;
GetRoleInternal(&role);
if (role == nsIAccessibleRole::ROLE_STATICTEXT) {
@ -117,13 +114,15 @@ nsHTMLTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLHRAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLHRAccessible::nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsLeafAccessible(aDomNode, aShell)
{
nsHTMLHRAccessible::
nsHTMLHRAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsLeafAccessible(aContent, aShell)
{
}
nsresult
@ -133,9 +132,15 @@ nsHTMLHRAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
nsHTMLBRAccessible::nsHTMLBRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsLeafAccessible(aDomNode, aShell)
{
////////////////////////////////////////////////////////////////////////////////
// nsHTMLBRAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLBRAccessible::
nsHTMLBRAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsLeafAccessible(aContent, aShell)
{
}
nsresult
@ -175,14 +180,14 @@ nsHTMLBRAccessible::GetNameInternal(nsAString& aName)
// nsHTMLLabelAccessible
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLabelAccessible, nsHyperTextAccessible)
nsHTMLLabelAccessible::
nsHTMLLabelAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell) :
nsHyperTextAccessibleWrap(aDomNode, aShell)
nsHTMLLabelAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLabelAccessible, nsHyperTextAccessible)
nsresult
nsHTMLLabelAccessible::GetNameInternal(nsAString& aName)
{
@ -201,12 +206,12 @@ nsHTMLLabelAccessible::GetRoleInternal(PRUint32 *aRole)
////////////////////////////////////////////////////////////////////////////////
nsHTMLLIAccessible::
nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
const nsAString& aBulletText):
nsHyperTextAccessibleWrap(aDOMNode, aShell)
nsHTMLLIAccessible(nsIContent *aContent, nsIWeakReference *aShell,
const nsAString& aBulletText) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
if (!aBulletText.IsEmpty()) {
mBulletAccessible = new nsHTMLListBulletAccessible(mDOMNode, mWeakShell,
mBulletAccessible = new nsHTMLListBulletAccessible(mContent, mWeakShell,
aBulletText);
if (mBulletAccessible)
mBulletAccessible->Init();
@ -215,7 +220,7 @@ nsHTMLLIAccessible::
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLIAccessible, nsHyperTextAccessible)
nsresult
void
nsHTMLLIAccessible::Shutdown()
{
if (mBulletAccessible) {
@ -223,9 +228,8 @@ nsHTMLLIAccessible::Shutdown()
mBulletAccessible->Shutdown();
}
nsresult rv = nsHyperTextAccessibleWrap::Shutdown();
nsHyperTextAccessibleWrap::Shutdown();
mBulletAccessible = nsnull;
return rv;
}
nsresult
@ -282,9 +286,9 @@ nsHTMLLIAccessible::CacheChildren()
////////////////////////////////////////////////////////////////////////////////
nsHTMLListBulletAccessible::
nsHTMLListBulletAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell,
nsHTMLListBulletAccessible(nsIContent *aContent, nsIWeakReference *aShell,
const nsAString& aBulletText) :
nsLeafAccessible(aDomNode, aShell), mBulletText(aBulletText)
nsLeafAccessible(aContent, aShell), mBulletText(aBulletText)
{
mBulletText += ' '; // Otherwise bullets are jammed up against list text
}
@ -292,16 +296,17 @@ nsHTMLListBulletAccessible::
NS_IMETHODIMP
nsHTMLListBulletAccessible::GetUniqueID(void **aUniqueID)
{
// Since mDOMNode is same as for list item, use |this| pointer as the unique Id
// Since mContent is same as for list item, use |this| pointer as the unique
// id.
*aUniqueID = static_cast<void*>(this);
return NS_OK;
}
nsresult
void
nsHTMLListBulletAccessible::Shutdown()
{
mBulletText.Truncate();
return nsLeafAccessible::Shutdown();
nsLeafAccessible::Shutdown();
}
NS_IMETHODIMP
@ -352,6 +357,12 @@ nsHTMLListBulletAccessible::GetParent()
// nsHTMLListAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLListAccessible::
nsHTMLListAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLListAccessible, nsHyperTextAccessible)
nsresult

Просмотреть файл

@ -44,12 +44,13 @@
#include "nsAutoPtr.h"
#include "nsBaseWidgetAccessible.h"
class nsIWeakReference;
/**
* Used for text nodes within HTML document.
*/
class nsHTMLTextAccessible : public nsTextAccessibleWrap
{
public:
nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLTextAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -63,19 +64,25 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Used for HTML hr element.
*/
class nsHTMLHRAccessible : public nsLeafAccessible
{
public:
nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLHRAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
};
/**
* Used for HTML br element.
*/
class nsHTMLBRAccessible : public nsLeafAccessible
{
public:
nsHTMLBRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLBRAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
@ -83,10 +90,13 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Used for HTML label element.
*/
class nsHTMLLabelAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLLabelAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLLabelAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
@ -95,10 +105,13 @@ public:
virtual nsresult GetRoleInternal(PRUint32 *aRole);
};
/**
* Used for bullet of HTML list item element (for example, HTML li).
*/
class nsHTMLListBulletAccessible : public nsLeafAccessible
{
public:
nsHTMLListBulletAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
nsHTMLListBulletAccessible(nsIContent *aContent, nsIWeakReference *aShell,
const nsAString& aBulletText);
// nsIAccessNode
@ -108,7 +121,7 @@ public:
NS_IMETHOD GetName(nsAString& aName);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -128,11 +141,13 @@ protected:
nsString mBulletText;
};
/**
* Used for HTML list (like HTML ul).
*/
class nsHTMLListAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLListAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aDOMNode, aShell) { }
nsHTMLListAccessible(nsIContent *aContent, nsIWeakReference *aShell);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -142,10 +157,13 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};
/**
* Used for HTML list item (e.g. HTML li).
*/
class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
nsHTMLLIAccessible(nsIContent *aContent, nsIWeakReference *aShell,
const nsAString& aBulletText);
// nsISupports
@ -155,7 +173,7 @@ public:
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);

Просмотреть файл

@ -72,9 +72,15 @@
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
// ------------
////////////////////////////////////////////////////////////////////////////////
// nsHyperTextAccessible
// ------------
////////////////////////////////////////////////////////////////////////////////
nsHyperTextAccessible::
nsHyperTextAccessible(nsIContent *aNode, nsIWeakReference *aShell) :
nsAccessibleWrap(aNode, aShell)
{
}
NS_IMPL_ADDREF_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
NS_IMPL_RELEASE_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
@ -83,66 +89,50 @@ nsresult nsHyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePt
{
*aInstancePtr = nsnull;
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mDOMNode));
if (mDOMNode && !xulDoc) {
// We need XUL doc check for now because for now nsDocAccessible must
// inherit from nsHyperTextAccessible in order for HTML document accessibles
// to get support for these interfaces.
// However at some point we may push <body> to implement the interfaces and
// return nsDocAccessible to inherit from nsAccessibleWrap.
if (aIID.Equals(NS_GET_IID(nsHyperTextAccessible))) {
*aInstancePtr = static_cast<nsHyperTextAccessible*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsHyperTextAccessible))) {
*aInstancePtr = static_cast<nsHyperTextAccessible*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (mRoleMapEntry &&
(mRoleMapEntry->role == nsIAccessibleRole::ROLE_GRAPHIC ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_IMAGE_MAP ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_SLIDER ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_PROGRESSBAR ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_SEPARATOR)) {
// ARIA roles that these interfaces are not appropriate for
return nsAccessible::QueryInterface(aIID, aInstancePtr);
}
if (mRoleMapEntry &&
(mRoleMapEntry->role == nsIAccessibleRole::ROLE_GRAPHIC ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_IMAGE_MAP ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_SLIDER ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_PROGRESSBAR ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_SEPARATOR)) {
// ARIA roles that these interfaces are not appropriate for
return nsAccessible::QueryInterface(aIID, aInstancePtr);
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
*aInstancePtr = static_cast<nsIAccessibleText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
*aInstancePtr = static_cast<nsIAccessibleText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
*aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
*aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
*aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
*aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
NS_ADDREF_THIS();
return NS_OK;
}
return nsAccessible::QueryInterface(aIID, aInstancePtr);
}
nsHyperTextAccessible::nsHyperTextAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsAccessibleWrap(aNode, aShell)
{
}
nsresult
nsHyperTextAccessible::GetRoleInternal(PRUint32 *aRole)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (!content) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
nsIAtom *tag = content->Tag();
nsIAtom *tag = mContent->Tag();
if (tag == nsAccessibilityAtoms::form) {
*aRole = nsIAccessibleRole::ROLE_FORM;
@ -475,9 +465,9 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
NS_IMETHODIMP nsHyperTextAccessible::GetText(PRInt32 aStartOffset, PRInt32 aEndOffset, nsAString &aText)
{
if (!mDOMNode) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
return GetPosAndText(aStartOffset, aEndOffset, &aText) ? NS_OK : NS_ERROR_FAILURE;
}
@ -508,9 +498,9 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterCount(PRInt32 *aCharacterCount)
*/
NS_IMETHODIMP nsHyperTextAccessible::GetCharacterAtOffset(PRInt32 aOffset, PRUnichar *aCharacter)
{
if (!mDOMNode) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
nsAutoString text;
nsresult rv = GetText(aOffset, aOffset + 1, text);
if (NS_FAILED(rv)) {
@ -525,7 +515,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterAtOffset(PRInt32 aOffset, PRUni
}
nsAccessible*
nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode *aNode,
nsHyperTextAccessible::DOMPointToHypertextOffset(nsINode *aNode,
PRInt32 aNodeOffset,
PRInt32 *aHyperTextOffset,
PRBool aIsEndOffset)
@ -538,14 +528,12 @@ nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode *aNode,
return nsnull;
PRUint32 addTextOffset = 0;
nsCOMPtr<nsIDOMNode> findNode;
nsINode* findNode = nsnull;
unsigned short nodeType;
aNode->GetNodeType(&nodeType);
if (aNodeOffset == -1) {
findNode = aNode;
}
else if (nodeType == nsIDOMNode::TEXT_NODE) {
} else if (aNode->IsNodeOfType(nsINode::eTEXT)) {
// For text nodes, aNodeOffset comes in as a character offset
// Text offset will be added at the end, if we find the offset in this hypertext
// We want the "skipped" offset into the text (rendered text without the extra whitespace)
@ -557,26 +545,26 @@ nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode *aNode,
NS_ENSURE_SUCCESS(rv, nsnull);
// Get the child node and
findNode = aNode;
}
else {
// For non-text nodes, aNodeOffset comes in as a child node index
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(aNode));
// Should not happen, but better to protect against crash if doc node is somehow passed in
NS_ENSURE_TRUE(parentContent, nsnull);
// findNode could be null if aNodeOffset == # of child nodes, which means one of two things:
// 1) we're at the end of the children, keep findNode = null, so that we get the last possible offset
// 2) there are no children and the passed-in node is mDOMNode, which means we're an aempty nsIAccessibleText
// 3) there are no children, and the passed-in node is not mDOMNode -- use parentContent for the node to find
findNode = do_QueryInterface(parentContent->GetChildAt(aNodeOffset));
} else {
// findNode could be null if aNodeOffset == # of child nodes, which means
// one of two things:
// 1) we're at the end of the children, keep findNode = null, so that we get
// the last possible offset
// 2) there are no children and the passed-in node is mContent, which means
// we're an aempty nsIAccessibleText
// 3) there are no children, and the passed-in node is not mContent -- use
// parentContent for the node to find
findNode = aNode->GetChildAt(aNodeOffset);
if (!findNode && !aNodeOffset) {
if (SameCOMIdentity(parentContent, mDOMNode)) {
if (aNode == GetNode()) {
// There are no children, which means this is an empty nsIAccessibleText, in which
// case we can only be at hypertext offset 0
*aHyperTextOffset = 0;
return nsnull;
}
findNode = do_QueryInterface(parentContent); // Case #2: there are no children
findNode = aNode; // Case #2: there are no children
}
}
@ -584,8 +572,8 @@ nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode *aNode,
// accessible for the next DOM node which has one (based on forward depth first search)
nsAccessible *descendantAcc = nsnull;
if (findNode) {
nsCOMPtr<nsIContent> findContent = do_QueryInterface(findNode);
if (findContent->IsHTML() &&
nsCOMPtr<nsIContent> findContent(do_QueryInterface(findNode));
if (findContent && findContent->IsHTML() &&
findContent->NodeInfo()->Equals(nsAccessibilityAtoms::br) &&
findContent->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::mozeditorbogusnode,
@ -754,7 +742,7 @@ PRInt32
nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
nsIFrame *aFromFrame,
PRInt32 aFromOffset,
nsIAccessible *aFromAccessible,
nsAccessible *aFromAccessible,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRBool aNeedsStart)
@ -775,9 +763,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
nsresult rv;
PRInt32 contentOffset = aFromOffset;
if (nsAccUtils::IsText(aFromAccessible)) {
nsRefPtr<nsAccessNode> accessNode = do_QueryObject(aFromAccessible);
nsIFrame *frame = accessNode->GetFrame();
nsIFrame *frame = aFromAccessible->GetFrame();
NS_ENSURE_TRUE(frame, -1);
if (frame->GetType() == nsAccessibilityAtoms::textFrame) {
@ -807,14 +793,14 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
// Turn the resulting node and offset into a hyperTextOffset
PRInt32 hyperTextOffset;
nsCOMPtr<nsIDOMNode> resultNode = do_QueryInterface(pos.mResultContent);
NS_ENSURE_TRUE(resultNode, -1);
if (!pos.mResultContent)
return -1;
// If finalAccessible is nsnull, then DOMPointToHypertextOffset() searched
// through the hypertext children without finding the node/offset position.
nsAccessible *finalAccessible =
DOMPointToHypertextOffset(resultNode, pos.mContentOffset, &hyperTextOffset,
aDirection == eDirNext);
DOMPointToHypertextOffset(pos.mResultContent, pos.mContentOffset,
&hyperTextOffset, aDirection == eDirNext);
if (!finalAccessible && aDirection == eDirPrevious) {
// If we reached the end during search, this means we didn't find the DOM point
@ -966,10 +952,8 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
GetCharacterCount(&textLength);
if (aBoundaryType == BOUNDARY_LINE_START && aOffset > 0 && aOffset == textLength) {
// Asking for start of line, while on last character
if (startAcc) {
nsRefPtr<nsAccessNode> startAccessNode = do_QueryObject(startAcc);
startFrame = startAccessNode->GetFrame();
}
if (startAcc)
startFrame = startAcc->GetFrame();
}
if (!startFrame) {
return aOffset > textLength ? NS_ERROR_FAILURE : NS_OK;
@ -1176,10 +1160,7 @@ nsHyperTextAccessible::GetDefaultTextAttributes(nsIPersistentProperties **aAttri
PRInt32
nsHyperTextAccessible::GetLevelInternal()
{
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
NS_ENSURE_TRUE(content, 0);
nsIAtom *tag = content->Tag();
nsIAtom *tag = mContent->Tag();
if (tag == nsAccessibilityAtoms::h1)
return 1;
if (tag == nsAccessibilityAtoms::h2)
@ -1213,7 +1194,7 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
oldValueUnused);
}
if (gLastFocusedNode == mDOMNode) {
if (gLastFocusedNode == GetNode()) {
PRInt32 lineNumber = GetCaretLineNumber();
if (lineNumber >= 1) {
nsAutoString strLineNumber;
@ -1505,12 +1486,12 @@ NS_IMETHODIMP
nsHyperTextAccessible::GetAssociatedEditor(nsIEditor **aEditor)
{
NS_ENSURE_ARG_POINTER(aEditor);
*aEditor = nsnull;
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
if (!content->HasFlag(NODE_IS_EDITABLE)) {
if (IsDefunct())
return NS_ERROR_FAILURE;
if (!mContent->HasFlag(NODE_IS_EDITABLE)) {
// If we're inside an editable container, then return that container's editor
nsCOMPtr<nsIAccessible> ancestor, current = this;
while (NS_SUCCEEDED(current->GetParent(getter_AddRefs(ancestor))) && ancestor) {
@ -1528,7 +1509,7 @@ nsHyperTextAccessible::GetAssociatedEditor(nsIEditor **aEditor)
}
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
nsCoreUtils::GetDocShellTreeItemFor(mDOMNode);
nsCoreUtils::GetDocShellTreeItemFor(mContent);
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(docShellTreeItem));
if (!editingSession)
return NS_OK; // No editing session interface
@ -1600,13 +1581,13 @@ nsHyperTextAccessible::GetCaretOffset(PRInt32 *aCaretOffset)
// No caret if the focused node is not inside this DOM node and this DOM node
// is not inside of focused node.
nsCOMPtr<nsINode> thisNode(do_QueryInterface(mDOMNode));
nsCOMPtr<nsINode> lastFocusedNode(do_QueryInterface(gLastFocusedNode));
PRBool isInsideOfFocusedNode =
nsCoreUtils::IsAncestorOf(lastFocusedNode, thisNode);
if (!isInsideOfFocusedNode && mDOMNode != gLastFocusedNode &&
!nsCoreUtils::IsAncestorOf(thisNode, lastFocusedNode))
nsINode* thisNode = GetNode();
PRBool isInsideOfFocusedNode =
nsCoreUtils::IsAncestorOf(gLastFocusedNode, thisNode);
if (!isInsideOfFocusedNode && thisNode != gLastFocusedNode &&
!nsCoreUtils::IsAncestorOf(thisNode, gLastFocusedNode))
return NS_OK;
// Turn the focus node and offset of the selection into caret hypretext
@ -1626,8 +1607,8 @@ nsHyperTextAccessible::GetCaretOffset(PRInt32 *aCaretOffset)
// No caret if this DOM node is inside of focused node but the selection's
// focus point is not inside of this DOM node.
nsCOMPtr<nsINode> focusNode(do_QueryInterface(focusDOMNode));
if (isInsideOfFocusedNode) {
nsCOMPtr<nsINode> focusNode(do_QueryInterface(focusDOMNode));
nsINode *resultNode =
nsCoreUtils::GetDOMNodeFromDOMPoint(focusNode, focusOffset);
@ -1636,7 +1617,7 @@ nsHyperTextAccessible::GetCaretOffset(PRInt32 *aCaretOffset)
return NS_OK;
}
DOMPointToHypertextOffset(focusDOMNode, focusOffset, aCaretOffset);
DOMPointToHypertextOffset(focusNode, focusOffset, aCaretOffset);
return NS_OK;
}
@ -1656,10 +1637,8 @@ PRInt32 nsHyperTextAccessible::GetCaretLineNumber()
nsCOMPtr<nsIDOMNode> caretNode;
domSel->GetFocusNode(getter_AddRefs(caretNode));
nsCOMPtr<nsIContent> caretContent = do_QueryInterface(caretNode);
nsCOMPtr<nsINode> thisNode(do_QueryInterface(mDOMNode));
if (!caretContent || !nsCoreUtils::IsAncestorOf(thisNode, caretContent)) {
if (!caretContent || !nsCoreUtils::IsAncestorOf(GetNode(), caretContent))
return -1;
}
PRInt32 caretOffset, returnOffsetUnused;
domSel->GetFocusOffset(&caretOffset);
@ -1670,7 +1649,7 @@ PRInt32 nsHyperTextAccessible::GetCaretLineNumber()
PRInt32 lineNumber = 1;
nsAutoLineIterator lineIterForCaret;
nsCOMPtr<nsIContent> hyperTextContent = do_QueryInterface(mDOMNode);
nsIContent *hyperTextContent = IsContent() ? mContent.get() : nsnull;
while (caretFrame) {
if (hyperTextContent == caretFrame->GetContent()) {
return lineNumber; // Must be in a single line hyper text, there is no line iterator
@ -1714,9 +1693,9 @@ nsHyperTextAccessible::GetSelections(PRInt16 aType,
nsISelection **aDomSel,
nsCOMArray<nsIDOMRange>* aRanges)
{
if (!mDOMNode) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
if (aSelCon) {
*aSelCon = nsnull;
}
@ -1766,7 +1745,7 @@ nsHyperTextAccessible::GetSelections(PRInt16 aType,
nsCOMPtr<nsISelection2> selection2(do_QueryInterface(domSel));
NS_ENSURE_TRUE(selection2, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> startNode(mDOMNode);
nsCOMPtr<nsINode> startNode = GetNode();
if (peditor) {
nsCOMPtr<nsIDOMElement> editorRoot;
editor->GetRootElement(getter_AddRefs(editorRoot));
@ -1774,15 +1753,11 @@ nsHyperTextAccessible::GetSelections(PRInt16 aType,
}
NS_ENSURE_STATE(startNode);
nsCOMPtr<nsIDOMNodeList> childNodes;
nsresult rv = startNode->GetChildNodes(getter_AddRefs(childNodes));
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 numChildren;
rv = childNodes->GetLength(&numChildren);
NS_ENSURE_SUCCESS(rv, rv);
rv = selection2->GetRangesForIntervalCOMArray(startNode, 0,
startNode, numChildren,
PR_TRUE, aRanges);
PRUint32 childCount = startNode->GetChildCount();
nsCOMPtr<nsIDOMNode> startDOMNode(do_QueryInterface(startNode));
nsresult rv = selection2->
GetRangesForIntervalCOMArray(startDOMNode, 0, startDOMNode, childCount,
PR_TRUE, aRanges);
NS_ENSURE_SUCCESS(rv, rv);
// Remove collapsed ranges
PRInt32 numRanges = aRanges->Count();
@ -1836,14 +1811,16 @@ NS_IMETHODIMP nsHyperTextAccessible::GetSelectionBounds(PRInt32 aSelectionNum, P
nsCOMPtr<nsIDOMRange> range = ranges[aSelectionNum];
// Get start point
nsCOMPtr<nsIDOMNode> startNode;
range->GetStartContainer(getter_AddRefs(startNode));
nsCOMPtr<nsIDOMNode> startDOMNode;
range->GetStartContainer(getter_AddRefs(startDOMNode));
nsCOMPtr<nsINode> startNode(do_QueryInterface(startDOMNode));
PRInt32 startOffset;
range->GetStartOffset(&startOffset);
// Get end point
nsCOMPtr<nsIDOMNode> endNode;
range->GetEndContainer(getter_AddRefs(endNode));
nsCOMPtr<nsIDOMNode> endDOMNode;
range->GetEndContainer(getter_AddRefs(endDOMNode));
nsCOMPtr<nsINode> endNode(do_QueryInterface(endDOMNode));
PRInt32 endOffset;
range->GetEndOffset(&endOffset);
@ -2191,24 +2168,25 @@ nsHyperTextAccessible::DOMRangeBoundToHypertextOffset(nsIDOMRange *aRange,
PRBool aIsStartHTOffset,
PRInt32 *aHTOffset)
{
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIDOMNode> DOMNode;
PRInt32 nodeOffset = 0;
nsresult rv;
if (aIsStartBound) {
rv = aRange->GetStartContainer(getter_AddRefs(node));
rv = aRange->GetStartContainer(getter_AddRefs(DOMNode));
NS_ENSURE_SUCCESS(rv, rv);
rv = aRange->GetStartOffset(&nodeOffset);
NS_ENSURE_SUCCESS(rv, rv);
} else {
rv = aRange->GetEndContainer(getter_AddRefs(node));
rv = aRange->GetEndContainer(getter_AddRefs(DOMNode));
NS_ENSURE_SUCCESS(rv, rv);
rv = aRange->GetEndOffset(&nodeOffset);
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsINode> node(do_QueryInterface(DOMNode));
nsAccessible *startAcc =
DOMPointToHypertextOffset(node, nodeOffset, aHTOffset);

Просмотреть файл

@ -74,7 +74,7 @@ class nsHyperTextAccessible : public nsAccessibleWrap,
public nsIAccessibleEditableText
{
public:
nsHyperTextAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
nsHyperTextAccessible(nsIContent *aContent, nsIWeakReference *aShell);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXT
NS_DECL_NSIACCESSIBLEHYPERTEXT
@ -120,7 +120,7 @@ public:
* it is within the current nsHyperTextAccessible,
* otherwise nsnull
*/
nsAccessible *DOMPointToHypertextOffset(nsIDOMNode *aNode,
nsAccessible *DOMPointToHypertextOffset(nsINode *aNode,
PRInt32 aNodeOffset,
PRInt32 *aHypertextOffset,
PRBool aIsEndOffset = PR_FALSE);
@ -186,7 +186,7 @@ protected:
* @return the resulting offset into this hypertext
*/
PRInt32 GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame,
PRInt32 aFromOffset, nsIAccessible *aFromAccessible,
PRInt32 aFromOffset, nsAccessible *aFromAccessible,
nsSelectionAmount aAmount, nsDirection aDirection,
PRBool aNeedsStart);

Просмотреть файл

@ -48,7 +48,7 @@
class nsAccessNodeWrap : public nsAccessNode
{
public: // construction, destruction
nsAccessNodeWrap(nsIDOMNode *aNode, nsIWeakReference* aShell);
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessNodeWrap();
static void InitAccessibility();

Просмотреть файл

@ -51,8 +51,9 @@
// construction
//-----------------------------------------------------
nsAccessNodeWrap::nsAccessNodeWrap(nsIDOMNode *aNode, nsIWeakReference* aShell):
nsAccessNode(aNode, aShell)
nsAccessNodeWrap::
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessNode(aContent, aShell)
{
}

Просмотреть файл

@ -58,11 +58,11 @@ struct objc_class;
class nsAccessibleWrap : public nsAccessible
{
public: // construction, destruction
nsAccessibleWrap(nsIDOMNode*, nsIWeakReference *aShell);
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessibleWrap();
// creates the native accessible connected to this one.
NS_IMETHOD Init ();
virtual PRBool Init ();
// get the native obj-c object (mozAccessible)
NS_IMETHOD GetNativeInterface (void **aOutAccessible);
@ -75,7 +75,7 @@ class nsAccessibleWrap : public nsAccessible
// returns a pointer to the native window for this accessible tree.
void GetNativeWindow (void **aOutNativeWindow);
virtual nsresult Shutdown ();
virtual void Shutdown ();
virtual void InvalidateChildren();
virtual nsresult HandleAccEvent(nsAccEvent *aEvent);

Просмотреть файл

@ -46,9 +46,9 @@
#import "mozActionElements.h"
#import "mozTextAccessible.h"
nsAccessibleWrap::nsAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference *aShell):
nsAccessible(aNode, aShell),
mNativeWrapper(nsnull)
nsAccessibleWrap::
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessible(aContent, aShell), mNativeWrapper(nsnull)
{
}
@ -60,19 +60,20 @@ nsAccessibleWrap::~nsAccessibleWrap()
}
}
nsresult
PRBool
nsAccessibleWrap::Init ()
{
// need to pass the call up, so we're cached (which nsAccessNode::Init() takes care of).
nsresult rv = nsAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsAccessible::Init())
return PR_FALSE;
if (!mNativeWrapper && !AncestorIsFlat()) {
// Create our native object using the class type specified in GetNativeType().
mNativeWrapper = new AccessibleWrapper (this, GetNativeType());
if (!mNativeWrapper)
return PR_FALSE;
}
return NS_OK;
return PR_TRUE;
}
NS_IMETHODIMP
@ -148,7 +149,7 @@ nsAccessibleWrap::GetNativeType ()
// this method is very important. it is fired when an accessible object "dies". after this point
// the object might still be around (because some 3rd party still has a ref to it), but it is
// in fact 'dead'.
nsresult
void
nsAccessibleWrap::Shutdown ()
{
if (mNativeWrapper) {
@ -156,7 +157,7 @@ nsAccessibleWrap::Shutdown ()
mNativeWrapper = nsnull;
}
return nsAccessible::Shutdown();
nsAccessible::Shutdown();
}
nsresult
@ -184,8 +185,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
eventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE)
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
aEvent->GetAccessible(getter_AddRefs(accessible));
nsAccessible *accessible = aEvent->GetAccessible();
NS_ENSURE_STATE(accessible);
mozAccessible *nativeAcc = nil;

Просмотреть файл

@ -44,15 +44,16 @@
class nsDocAccessibleWrap: public nsDocAccessible
{
public:
nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
// nsIAccessNode
// nsIAccessNode
/**
* Creates the native accessible connected to this one.
*/
virtual nsresult Init ();
/**
* Creates the native accessible connected to this one.
*/
virtual PRBool Init();
};
#endif

Просмотреть файл

@ -40,8 +40,9 @@
#import "mozAccessibleWrapper.h"
nsDocAccessibleWrap::
nsDocAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsDocAccessible(aDOMNode, aShell)
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsDocAccessible(aDocument, aRootContent, aShell)
{
}
@ -49,18 +50,20 @@ nsDocAccessibleWrap::~nsDocAccessibleWrap()
{
}
nsresult
PRBool
nsDocAccessibleWrap::Init ()
{
nsresult rv = nsDocAccessible::Init();
NS_ENSURE_SUCCESS(rv, rv);
if (!nsDocAccessible::Init())
return PR_FALSE;
NS_ASSERTION(!mNativeWrapper, "nsDocAccessibleWrap::Init() called more than once!");
if (!mNativeWrapper) {
// Create our native object using the class type specified in GetNativeType().
mNativeWrapper = new AccessibleWrapper (this, GetNativeType());
if (!mNativeWrapper)
return PR_FALSE;
}
return NS_OK;
return PR_TRUE;
}

Просмотреть файл

@ -49,9 +49,10 @@ struct objc_class;
class nsRootAccessibleWrap : public nsRootAccessible
{
public:
nsRootAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsRootAccessibleWrap();
public:
nsRootAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsRootAccessibleWrap();
objc_class* GetNativeType ();

Просмотреть файл

@ -48,8 +48,10 @@
#import "mozAccessibleWrapper.h"
nsRootAccessibleWrap::nsRootAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
nsRootAccessible(aDOMNode, aShell)
nsRootAccessibleWrap::
nsRootAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsRootAccessible(aDocument, aRootContent, aShell)
{
}

Просмотреть файл

@ -53,8 +53,8 @@ class nsARIAGridAccessibleWrap : public nsARIAGridAccessible,
public CAccessibleTable
{
public:
nsARIAGridAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsARIAGridAccessible(aNode, aShell) {}
nsARIAGridAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsARIAGridAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
@ -71,8 +71,8 @@ class nsARIAGridCellAccessibleWrap : public nsARIAGridCellAccessible,
public CAccessibleTableCell
{
public:
nsARIAGridCellAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsARIAGridCellAccessible(aNode, aShell) {}
nsARIAGridCellAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsARIAGridCellAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -70,7 +70,7 @@ PRBool nsAccessNodeWrap::gIsEnumVariantSupportDisabled = 0;
// Used to determine whether an IAccessible2 compatible screen reader is loaded.
PRBool nsAccessNodeWrap::gIsIA2Disabled = PR_FALSE;
nsIAccessibleTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;
nsAccTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;
// Pref to disallow CtrlTab preview functionality if JAWS or Window-Eyes are
// running.
@ -81,22 +81,16 @@ nsIAccessibleTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
/*
* Class nsAccessNodeWrap
*/
////////////////////////////////////////////////////////////////////////////////
// nsAccessNodeWrap
////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsAccessNodeWrap::nsAccessNodeWrap(nsIDOMNode *aNode, nsIWeakReference* aShell):
nsAccessNode(aNode, aShell)
nsAccessNodeWrap::
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessNode(aContent, aShell)
{
}
//-----------------------------------------------------
// destruction
//-----------------------------------------------------
nsAccessNodeWrap::~nsAccessNodeWrap()
{
}
@ -188,26 +182,28 @@ __try{
*aNodeName = nsnull;
*aNodeValue = nsnull;
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(GetNode()));
PRUint16 nodeType = 0;
mDOMNode->GetNodeType(&nodeType);
DOMNode->GetNodeType(&nodeType);
*aNodeType=static_cast<unsigned short>(nodeType);
if (*aNodeType != NODETYPE_TEXT) {
nsAutoString nodeName;
mDOMNode->GetNodeName(nodeName);
DOMNode->GetNodeName(nodeName);
*aNodeName = ::SysAllocString(nodeName.get());
}
nsAutoString nodeValue;
mDOMNode->GetNodeValue(nodeValue);
DOMNode->GetNodeValue(nodeValue);
*aNodeValue = ::SysAllocString(nodeValue.get());
*aNameSpaceID = content ? static_cast<short>(content->GetNameSpaceID()) : 0;
*aNameSpaceID = IsContent() ?
static_cast<short>(mContent->GetNameSpaceID()) : 0;
// This is a unique ID for every content node. The 3rd party
// accessibility application can compare this to the childID we
@ -217,12 +213,7 @@ __try{
GetUniqueID(&uniqueID);
*aUniqueID = - NS_PTR_TO_INT32(uniqueID);
*aNumChildren = 0;
PRUint32 numChildren = 0;
nsCOMPtr<nsIDOMNodeList> nodeList;
mDOMNode->GetChildNodes(getter_AddRefs(nodeList));
if (nodeList && NS_OK == nodeList->GetLength(&numChildren))
*aNumChildren = static_cast<unsigned int>(numChildren);
*aNumChildren = GetNode()->GetChildCount();
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -240,12 +231,10 @@ STDMETHODIMP nsAccessNodeWrap::get_attributes(
__try{
*aNumAttribs = 0;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content)
if (IsDefunct() || IsDocument())
return E_FAIL;
PRUint32 numAttribs = content->GetAttrCount();
PRUint32 numAttribs = mContent->GetAttrCount();
if (numAttribs > aMaxAttribs)
numAttribs = aMaxAttribs;
*aNumAttribs = static_cast<unsigned short>(numAttribs);
@ -254,10 +243,10 @@ __try{
aNameSpaceIDs[index] = 0; aAttribValues[index] = aAttribNames[index] = nsnull;
nsAutoString attributeValue;
const nsAttrName* name = content->GetAttrNameAt(index);
const nsAttrName* name = mContent->GetAttrNameAt(index);
aNameSpaceIDs[index] = static_cast<short>(name->NamespaceID());
aAttribNames[index] = ::SysAllocString(name->LocalName()->GetUTF16String());
content->GetAttr(name->NamespaceID(), name->LocalName(), attributeValue);
mContent->GetAttr(name->NamespaceID(), name->LocalName(), attributeValue);
aAttribValues[index] = ::SysAllocString(attributeValue.get());
}
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@ -273,15 +262,10 @@ STDMETHODIMP nsAccessNodeWrap::get_attributesForNames(
/* [length_is][size_is][retval] */ BSTR __RPC_FAR *aAttribValues)
{
__try {
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!domElement || !content)
return E_FAIL;
if (!content->GetDocument())
if (IsDefunct() || IsDocument())
return E_FAIL;
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(mContent));
nsCOMPtr<nsINameSpaceManager> nameSpaceManager =
do_GetService(NS_NAMESPACEMANAGER_CONTRACTID);
@ -320,12 +304,11 @@ STDMETHODIMP nsAccessNodeWrap::get_computedStyle(
__try{
*aNumStyleProperties = 0;
if (IsDefunct())
if (IsDefunct() || IsDocument())
return E_FAIL;
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mDOMNode,
getter_AddRefs(cssDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mContent);
NS_ENSURE_TRUE(cssDecl, E_FAIL);
PRUint32 length;
@ -356,12 +339,11 @@ STDMETHODIMP nsAccessNodeWrap::get_computedStyleForProperties(
/* [length_is][size_is][out] */ BSTR __RPC_FAR *aStyleValues)
{
__try {
if (IsDefunct())
if (IsDefunct() || IsDocument())
return E_FAIL;
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mDOMNode,
getter_AddRefs(cssDecl));
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mContent);
NS_ENSURE_TRUE(cssDecl, E_FAIL);
PRUint32 index;
@ -391,30 +373,17 @@ __try {
return E_FAIL;
}
ISimpleDOMNode* nsAccessNodeWrap::MakeAccessNode(nsIDOMNode *node)
ISimpleDOMNode*
nsAccessNodeWrap::MakeAccessNode(nsINode *aNode)
{
if (!node)
if (!aNode)
return NULL;
nsAccessNodeWrap *newNode = NULL;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
nsCOMPtr<nsIDocument> doc;
if (content)
doc = content->GetDocument();
else {
// Get the document via QueryInterface, since there is no content node
doc = do_QueryInterface(node);
content = do_QueryInterface(node);
}
if (!doc)
return NULL;
ISimpleDOMNode *iNode = NULL;
nsAccessible *acc =
GetAccService()->GetAccessibleInWeakShell(node, mWeakShell);
GetAccService()->GetAccessibleInWeakShell(aNode, mWeakShell);
if (acc) {
IAccessible *msaaAccessible = nsnull;
acc->GetNativeInterface((void**)&msaaAccessible); // addrefs
@ -422,7 +391,13 @@ ISimpleDOMNode* nsAccessNodeWrap::MakeAccessNode(nsIDOMNode *node)
msaaAccessible->Release(); // Release IAccessible
}
else {
newNode = new nsAccessNodeWrap(node, mWeakShell);
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (!content) {
NS_NOTREACHED("The node is a document which is not accessible!");
return NULL;
}
newNode = new nsAccessNodeWrap(content, mWeakShell);
if (!newNode)
return NULL;
@ -438,12 +413,11 @@ ISimpleDOMNode* nsAccessNodeWrap::MakeAccessNode(nsIDOMNode *node)
STDMETHODIMP nsAccessNodeWrap::get_parentNode(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
{
__try {
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node;
mDOMNode->GetParentNode(getter_AddRefs(node));
*aNode = MakeAccessNode(node);
*aNode = MakeAccessNode(GetNode()->GetNodeParent());
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -452,12 +426,11 @@ __try {
STDMETHODIMP nsAccessNodeWrap::get_firstChild(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
{
__try {
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node;
mDOMNode->GetFirstChild(getter_AddRefs(node));
*aNode = MakeAccessNode(node);
*aNode = MakeAccessNode(GetNode()->GetFirstChild());
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -465,13 +438,12 @@ __try {
STDMETHODIMP nsAccessNodeWrap::get_lastChild(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
{
__try {
if (!mDOMNode)
__try {
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node;
mDOMNode->GetLastChild(getter_AddRefs(node));
*aNode = MakeAccessNode(node);
*aNode = MakeAccessNode(GetNode()->GetLastChild());
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -480,12 +452,11 @@ STDMETHODIMP nsAccessNodeWrap::get_lastChild(ISimpleDOMNode __RPC_FAR *__RPC_FAR
STDMETHODIMP nsAccessNodeWrap::get_previousSibling(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
{
__try {
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node;
mDOMNode->GetPreviousSibling(getter_AddRefs(node));
*aNode = MakeAccessNode(node);
*aNode = MakeAccessNode(GetNode()->GetPreviousSibling());
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -494,12 +465,11 @@ __try {
STDMETHODIMP nsAccessNodeWrap::get_nextSibling(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
{
__try {
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node;
mDOMNode->GetNextSibling(getter_AddRefs(node));
*aNode = MakeAccessNode(node);
*aNode = MakeAccessNode(GetNode()->GetNextSibling());
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -512,17 +482,11 @@ nsAccessNodeWrap::get_childAt(unsigned aChildIndex,
__try {
*aNode = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content)
return E_FAIL; // Node already shut down
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> node =
do_QueryInterface(content->GetChildAt(aChildIndex));
*aNode = MakeAccessNode(GetNode()->GetChildAt(aChildIndex));
if (!node)
return E_FAIL; // No such child
*aNode = MakeAccessNode(node);
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -534,7 +498,7 @@ nsAccessNodeWrap::get_innerHTML(BSTR __RPC_FAR *aInnerHTML)
__try {
*aInnerHTML = nsnull;
nsCOMPtr<nsIDOMNSHTMLElement> domNSElement(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMNSHTMLElement> domNSElement(do_QueryInterface(GetNode()));
if (!domNSElement)
return E_FAIL; // Node already shut down

Просмотреть файл

@ -71,6 +71,8 @@
typedef LRESULT (STDAPICALLTYPE *LPFNNOTIFYWINEVENT)(DWORD event,HWND hwnd,LONG idObjectType,LONG idObject);
typedef LRESULT (STDAPICALLTYPE *LPFNGETGUITHREADINFO)(DWORD idThread, GUITHREADINFO* pgui);
class nsAccTextChangeEvent;
class nsAccessNodeWrap : public nsAccessNode,
public nsIWinAccessNode,
public ISimpleDOMNode,
@ -83,9 +85,9 @@ class nsAccessNodeWrap : public nsAccessNode,
public: // IServiceProvider
STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** ppv);
public: // construction, destruction
nsAccessNodeWrap(nsIDOMNode *, nsIWeakReference* aShell);
virtual ~nsAccessNodeWrap();
public: // construction, destruction
nsAccessNodeWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessNodeWrap();
// IUnknown
STDMETHODIMP QueryInterface(REFIID, void**);
@ -162,9 +164,17 @@ class nsAccessNodeWrap : public nsAccessNode,
static void TurnOffNewTabSwitchingForJawsAndWE();
static void DoATSpecificProcessing();
protected:
protected:
void GetAccessibleFor(nsIDOMNode *node, nsIAccessible **newAcc);
ISimpleDOMNode* MakeAccessNode(nsIDOMNode *node);
/**
* Return ISimpleDOMNode instance for existing accessible object or
* creates new nsAccessNode instance if the accessible doesn't exist.
*
* @note ISimpleDOMNode is returned addrefed
*/
ISimpleDOMNode *MakeAccessNode(nsINode *aNode);
static PRBool gIsEnumVariantSupportDisabled;
@ -178,7 +188,7 @@ class nsAccessNodeWrap : public nsAccessNode,
* It is used in nsHyperTextAccessibleWrap for IA2::newText/oldText
* implementation.
*/
static nsIAccessibleTextChangeEvent *gTextEvent;
static nsAccTextChangeEvent *gTextEvent;
};
/**

Просмотреть файл

@ -82,15 +82,16 @@ EXTERN_C GUID CDECL CLSID_Accessible =
static const PRInt32 kIEnumVariantDisconnected = -1;
/*
* Class nsAccessibleWrap
*/
////////////////////////////////////////////////////////////////////////////////
// nsAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsAccessibleWrap::nsAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference *aShell):
nsAccessible(aNode, aShell), mEnumVARIANTPosition(0), mTypeInfo(NULL)
nsAccessibleWrap::
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsAccessible(aContent, aShell), mEnumVARIANTPosition(0), mTypeInfo(NULL)
{
}
@ -323,9 +324,6 @@ __try {
if (!*pszName)
return E_OUTOFMEMORY;
#ifdef DEBUG_A11Y
NS_ASSERTION(mIsInitialized, "Access node was not initialized");
#endif
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -481,7 +479,7 @@ __try {
// -- Try BSTR role
// Could not map to known enumerated MSAA role like ROLE_BUTTON
// Use BSTR role to expose role attribute or tag name + namespace
nsIContent *content = nsCoreUtils::GetRoleContent(xpAccessible->GetDOMNode());
nsIContent *content = xpAccessible->GetContent();
if (!content)
return E_FAIL;
@ -596,9 +594,8 @@ STDMETHODIMP nsAccessibleWrap::get_accFocus(
// VT_DISPATCH: pdispVal member is the address of the IDispatch interface
// for the child object with the keyboard focus.
__try {
if (!mDOMNode) {
return E_FAIL; // This node is shut down
}
if (IsDefunct())
return E_FAIL;
VariantInit(pvarChild);
@ -1470,7 +1467,7 @@ nsAccessibleWrap::get_windowHandle(HWND *aWindowHandle)
__try {
*aWindowHandle = 0;
if (!mDOMNode)
if (IsDefunct())
return E_FAIL;
void *handle = nsnull;
@ -1666,8 +1663,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
// Means we're not active.
NS_ENSURE_TRUE(mWeakShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> accessible;
aEvent->GetAccessible(getter_AddRefs(accessible));
nsAccessible *accessible = aEvent->GetAccessible();
if (!accessible)
return NS_OK;
@ -1681,11 +1677,11 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
return NS_OK; // Can't fire an event without a child ID
// See if we're in a scrollable area with its own window
nsCOMPtr<nsIAccessible> newAccessible;
nsAccessible *newAccessible = nsnull;
if (eventType == nsIAccessibleEvent::EVENT_HIDE) {
// Don't use frame from current accessible when we're hiding that
// accessible.
accessible->GetParent(getter_AddRefs(newAccessible));
newAccessible = accessible->GetParent();
} else {
newAccessible = accessible;
}
@ -1731,14 +1727,13 @@ PRInt32 nsAccessibleWrap::GetChildIDFor(nsIAccessible* aAccessible)
}
HWND
nsAccessibleWrap::GetHWNDFor(nsIAccessible *aAccessible)
nsAccessibleWrap::GetHWNDFor(nsAccessible *aAccessible)
{
nsRefPtr<nsAccessNode> accessNode = do_QueryObject(aAccessible);
if (!accessNode)
return 0;
HWND hWnd = 0;
nsIFrame *frame = accessNode->GetFrame();
if (!aAccessible)
return hWnd;
nsIFrame *frame = aAccessible->GetFrame();
if (frame) {
nsIWidget *window = frame->GetWindow();
PRBool isVisible;
@ -1764,7 +1759,7 @@ nsAccessibleWrap::GetHWNDFor(nsIAccessible *aAccessible)
if (!hWnd) {
void* handle = nsnull;
nsDocAccessible *accessibleDoc = accessNode->GetDocAccessible();
nsDocAccessible *accessibleDoc = aAccessible->GetDocAccessible();
if (!accessibleDoc)
return 0;

Просмотреть файл

@ -103,9 +103,9 @@ class nsAccessibleWrap : public nsAccessible,
public IAccessible2,
public IEnumVARIANT
{
public: // construction, destruction
nsAccessibleWrap(nsIDOMNode*, nsIWeakReference *aShell);
virtual ~nsAccessibleWrap();
public: // construction, destruction
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsAccessibleWrap();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -311,7 +311,7 @@ class nsAccessibleWrap : public nsAccessible,
// Helper methods
static PRInt32 GetChildIDFor(nsIAccessible* aAccessible);
static HWND GetHWNDFor(nsIAccessible *aAccessible);
static HWND GetHWNDFor(nsAccessible *aAccessible);
static HRESULT ConvertToIA2Attributes(nsIPersistentProperties *aAttributes,
BSTR *aIA2Attributes);

Просмотреть файл

@ -57,9 +57,10 @@
// nsDocAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsDocAccessibleWrap::nsDocAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell) :
nsDocAccessible(aDOMNode, aShell)
nsDocAccessibleWrap::
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsDocAccessible(aDocument, aRootContent, aShell)
{
}

Просмотреть файл

@ -53,8 +53,9 @@ class nsDocAccessibleWrap: public nsDocAccessible,
public ISimpleDOMDocument
{
public:
nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
nsDocAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
// IUnknown
STDMETHODIMP_(ULONG) AddRef();

Просмотреть файл

@ -48,8 +48,8 @@ class nsHTMLImageAccessibleWrap : public nsHTMLImageAccessible,
public CAccessibleImage
{
public:
nsHTMLImageAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHTMLImageAccessible(aNode, aShell){}
nsHTMLImageAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLImageAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -54,8 +54,8 @@ class nsHTMLTableAccessibleWrap : public nsHTMLTableAccessible,
public CAccessibleTable
{
public:
nsHTMLTableAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHTMLTableAccessible(aNode, aShell){}
nsHTMLTableAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLTableAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
@ -73,8 +73,8 @@ class nsHTMLTableCellAccessibleWrap : public nsHTMLTableCellAccessible,
public CAccessibleTableCell
{
public:
nsHTMLTableCellAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHTMLTableCellAccessible(aNode, aShell) {}
nsHTMLTableCellAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsHTMLTableCellAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
@ -92,9 +92,9 @@ class nsHTMLTableHeaderCellAccessibleWrap : public nsHTMLTableHeaderCellAccessib
public CAccessibleTableCell
{
public:
nsHTMLTableHeaderCellAccessibleWrap(nsIDOMNode* aNode,
nsIWeakReference* aShell) :
nsHTMLTableHeaderCellAccessible(aNode, aShell) {}
nsHTMLTableHeaderCellAccessibleWrap(nsIContent *aContent,
nsIWeakReference *aShell) :
nsHTMLTableHeaderCellAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -43,12 +43,10 @@
////////////////////////////////////////////////////////////////////////////////
nsHTMLWin32ObjectOwnerAccessible::
nsHTMLWin32ObjectOwnerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell,
void* aHwnd) :
nsAccessibleWrap(aNode, aShell)
nsHTMLWin32ObjectOwnerAccessible(nsIContent *aContent,
nsIWeakReference *aShell, void *aHwnd) :
nsAccessibleWrap(aContent, aShell), mHwnd(aHwnd)
{
mHwnd = aHwnd;
// Our only child is a nsHTMLWin32ObjectAccessible object.
mNativeAccessible = new nsHTMLWin32ObjectAccessible(mHwnd);
}
@ -56,12 +54,11 @@ nsHTMLWin32ObjectOwnerAccessible::
////////////////////////////////////////////////////////////////////////////////
// nsHTMLWin32ObjectOwnerAccessible: nsAccessNode implementation
nsresult
void
nsHTMLWin32ObjectOwnerAccessible::Shutdown()
{
nsAccessibleWrap::Shutdown();
mNativeAccessible = nsnull;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -53,11 +53,12 @@ public:
// because the native plugin accessible doesn't know where it exists in the
// Mozilla tree, and returns null for previous and next sibling. This would
// have the effect of cutting off all content after the plugin.
nsHTMLWin32ObjectOwnerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell, void* aHwnd);
nsHTMLWin32ObjectOwnerAccessible(nsIContent *aContent,
nsIWeakReference *aShell, void *aHwnd);
virtual ~nsHTMLWin32ObjectOwnerAccessible() {}
// nsAccessNode
virtual nsresult Shutdown();
virtual void Shutdown();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
@ -86,7 +87,7 @@ class nsHTMLWin32ObjectAccessible : public nsLeafAccessible,
{
public:
nsHTMLWin32ObjectAccessible(void* aHwnd);
nsHTMLWin32ObjectAccessible(void *aHwnd);
virtual ~nsHTMLWin32ObjectAccessible() {}
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -57,18 +57,17 @@ nsHyperTextAccessibleWrap::HandleAccEvent(nsAccEvent *aEvent)
if (eventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
eventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
nsCOMPtr<nsIAccessible> accessible;
aEvent->GetAccessible(getter_AddRefs(accessible));
nsAccessible *accessible = aEvent->GetAccessible();
if (accessible) {
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(accessible));
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryObject(accessible));
if (winAccessNode) {
void *instancePtr = NULL;
nsresult rv = winAccessNode->QueryNativeInterface(IID_IAccessibleText,
&instancePtr);
if (NS_SUCCEEDED(rv)) {
NS_IF_RELEASE(gTextEvent);
NS_IF_ADDREF(gTextEvent = downcast_accEvent(aEvent));
CallQueryInterface(aEvent, &gTextEvent);
(static_cast<IUnknown*>(instancePtr))->Release();
}
}
@ -90,26 +89,17 @@ nsHyperTextAccessibleWrap::GetModifiedText(PRBool aGetInsertedText,
if (!gTextEvent)
return NS_OK;
PRBool isInserted;
gTextEvent->IsInserted(&isInserted);
PRBool isInserted = gTextEvent->IsTextInserted();
if (aGetInsertedText != isInserted)
return NS_OK;
nsCOMPtr<nsIAccessibleEvent> event(do_QueryInterface(gTextEvent));
nsCOMPtr<nsIAccessible> targetAcc;
event->GetAccessible(getter_AddRefs(targetAcc));
nsAccessible *targetAcc = gTextEvent->GetAccessible();
if (targetAcc != this)
return NS_OK;
PRInt32 offset;
PRUint32 length;
gTextEvent->GetStart(&offset);
gTextEvent->GetLength(&length);
*aStartOffset = offset;
*aEndOffset = offset + length;
*aStartOffset = gTextEvent->GetStartOffset();
*aEndOffset = *aStartOffset + gTextEvent->GetLength();
return gTextEvent->GetModifiedText(aText);
}

Просмотреть файл

@ -51,8 +51,8 @@ class nsHyperTextAccessibleWrap : public nsHyperTextAccessible,
public CAccessibleEditableText
{
public:
nsHyperTextAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHyperTextAccessible(aNode, aShell){}
nsHyperTextAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsHyperTextAccessible(aContent, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -45,10 +45,14 @@
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
//----- nsRootAccessibleWrap -----
////////////////////////////////////////////////////////////////////////////////
// nsRootAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsRootAccessibleWrap::nsRootAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
nsRootAccessible(aDOMNode, aShell)
nsRootAccessibleWrap::
nsRootAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell) :
nsRootAccessible(aDocument, aRootContent, aShell)
{
}

Просмотреть файл

@ -48,9 +48,10 @@
class nsRootAccessibleWrap: public nsRootAccessible
{
public:
nsRootAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsRootAccessibleWrap();
public:
nsRootAccessibleWrap(nsIDocument *aDocument, nsIContent *aRootContent,
nsIWeakReference *aShell);
virtual ~nsRootAccessibleWrap();
};
#endif

Просмотреть файл

@ -50,13 +50,14 @@
#include "nsIRenderingContext.h"
#include "nsIComponentManager.h"
// --------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// nsTextAccessibleWrap Accessible
// --------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
nsTextAccessibleWrap::nsTextAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsTextAccessible(aDOMNode, aShell)
{
nsTextAccessibleWrap::
nsTextAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsTextAccessible(aContent, aShell)
{
}
STDMETHODIMP_(ULONG) nsTextAccessibleWrap::AddRef()
@ -89,12 +90,13 @@ STDMETHODIMP nsTextAccessibleWrap::get_domText(
__try {
*aDomText = NULL;
if (!mDOMNode) {
return E_FAIL; // Node already shut down
}
if (IsDefunct())
return E_FAIL;
nsAutoString nodeValue;
mDOMNode->GetNodeValue(nodeValue);
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
DOMNode->GetNodeValue(nodeValue);
if (nodeValue.IsEmpty())
return S_FALSE;
@ -155,9 +157,8 @@ STDMETHODIMP nsTextAccessibleWrap::get_unclippedSubstringBounds(
__try {
*aX = *aY = *aWidth = *aHeight = 0;
if (!mDOMNode) {
return E_FAIL; // Node already shut down
}
if (IsDefunct())
return E_FAIL;
if (NS_FAILED(GetCharacterExtents(aStartIndex, aEndIndex,
aX, aY, aWidth, aHeight))) {
@ -174,9 +175,13 @@ STDMETHODIMP nsTextAccessibleWrap::scrollToSubstring(
/* [in] */ unsigned int aEndIndex)
{
__try {
if (IsDefunct())
return E_FAIL;
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
nsresult rv =
nsCoreUtils::ScrollSubstringTo(GetFrame(), mDOMNode, aStartIndex,
mDOMNode, aEndIndex,
nsCoreUtils::ScrollSubstringTo(GetFrame(), DOMNode, aStartIndex,
DOMNode, aEndIndex,
nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
if (NS_FAILED(rv))
return E_FAIL;

Просмотреть файл

@ -49,9 +49,9 @@ class nsIRenderingContext;
class nsTextAccessibleWrap : public nsTextAccessible,
public ISimpleDOMText
{
public:
nsTextAccessibleWrap(nsIDOMNode *, nsIWeakReference* aShell);
virtual ~nsTextAccessibleWrap() {}
public:
nsTextAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsTextAccessibleWrap() {}
// IUnknown methods - see iunknown.h for documentation
STDMETHODIMP_(ULONG) AddRef();

Просмотреть файл

@ -43,8 +43,8 @@
////////////////////////////////////////////////////////////////////////////////
nsXULListboxAccessibleWrap::
nsXULListboxAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULListboxAccessible(aDOMNode, aShell)
nsXULListboxAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsXULListboxAccessible(aContent, aShell)
{
}
@ -62,8 +62,8 @@ IMPL_IUNKNOWN_QUERY_TAIL
////////////////////////////////////////////////////////////////////////////////
nsXULListCellAccessibleWrap::
nsXULListCellAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULListCellAccessible(aDOMNode, aShell)
nsXULListCellAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsXULListCellAccessible(aContent, aShell)
{
}

Просмотреть файл

@ -52,7 +52,7 @@ class nsXULListboxAccessibleWrap : public nsXULListboxAccessible,
public CAccessibleTable
{
public:
nsXULListboxAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
nsXULListboxAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
// IUnknown
DECL_IUNKNOWN_INHERITED
@ -69,7 +69,7 @@ class nsXULListCellAccessibleWrap : public nsXULListCellAccessible,
public CAccessibleTableCell
{
public:
nsXULListCellAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
nsXULListCellAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -39,13 +39,13 @@
#include "nsAccessibilityAtoms.h"
#include "nsINameSpaceManager.h"
// --------------------------------------------------------
// nsXULMenuAccessibleWrap Accessible
// --------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// nsXULMenuAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsXULMenuitemAccessibleWrap::nsXULMenuitemAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell):
nsXULMenuitemAccessible(aDOMNode, aShell)
nsXULMenuitemAccessibleWrap::
nsXULMenuitemAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsXULMenuitemAccessible(aContent, aShell)
{
}
@ -58,11 +58,9 @@ nsXULMenuitemAccessibleWrap::GetName(nsAString& aName)
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ASSERTION(content, "Should not have gotten past nsXULMenuitemAccessible::GetName");
nsAutoString accel;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::acceltext, accel);
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::acceltext, accel);
if (!accel.IsEmpty()) {
aName += NS_LITERAL_STRING("\t") + accel;
}

Просмотреть файл

@ -43,7 +43,7 @@
class nsXULMenuitemAccessibleWrap : public nsXULMenuitemAccessible
{
public:
nsXULMenuitemAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
nsXULMenuitemAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
virtual ~nsXULMenuitemAccessibleWrap() {}
// nsIAccessible

Просмотреть файл

@ -44,8 +44,8 @@
////////////////////////////////////////////////////////////////////////////////
nsXULTreeGridAccessibleWrap::
nsXULTreeGridAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULTreeGridAccessible(aDOMNode, aShell)
nsXULTreeGridAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell) :
nsXULTreeGridAccessible(aContent, aShell)
{
}
@ -62,13 +62,13 @@ IMPL_IUNKNOWN_INHERITED1(nsXULTreeGridAccessibleWrap,
////////////////////////////////////////////////////////////////////////////////
nsXULTreeGridCellAccessibleWrap::
nsXULTreeGridCellAccessibleWrap(nsIDOMNode *aDOMNode,
nsXULTreeGridCellAccessibleWrap(nsIContent *aContent,
nsIWeakReference *aShell,
nsXULTreeGridRowAccessible *aRowAcc,
nsITreeBoxObject *aTree,
nsITreeView *aTreeView,
PRInt32 aRow, nsITreeColumn* aColumn) :
nsXULTreeGridCellAccessible(aDOMNode, aShell, aRowAcc, aTree, aTreeView,
nsXULTreeGridCellAccessible(aContent, aShell, aRowAcc, aTree, aTreeView,
aRow, aColumn)
{
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше