2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
#ifndef mozilla_a11y_DocAccessible_h__
|
|
|
|
#define mozilla_a11y_DocAccessible_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-01 22:14:51 -08:00
|
|
|
#include "nsIAccessibleCursorable.h"
|
2010-06-08 09:39:58 -07:00
|
|
|
#include "nsIAccessibleDocument.h"
|
2012-02-01 22:14:51 -08:00
|
|
|
#include "nsIAccessiblePivot.h"
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsEventShell.h"
|
2011-01-18 00:03:38 -08:00
|
|
|
#include "nsHyperTextAccessibleWrap.h"
|
|
|
|
#include "NotificationController.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2010-11-17 18:55:44 -08:00
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsDataHashtable.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDocumentObserver.h"
|
|
|
|
#include "nsIEditor.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIScrollPositionListener.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsIWeakReference.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
|
|
|
|
|
|
|
class nsIScrollableView;
|
2012-02-01 22:14:51 -08:00
|
|
|
class nsAccessiblePivot;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
const PRUint32 kDefaultCacheSize = 256;
|
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
class DocAccessible : public nsHyperTextAccessibleWrap,
|
|
|
|
public nsIAccessibleDocument,
|
|
|
|
public nsIDocumentObserver,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsIScrollPositionListener,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIAccessibleCursorable,
|
|
|
|
public nsIAccessiblePivotObserver
|
2012-02-01 22:14:51 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocAccessible, Accessible)
|
2008-08-06 05:19:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIACCESSIBLEDOCUMENT
|
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-01 22:14:51 -08:00
|
|
|
NS_DECL_NSIACCESSIBLECURSORABLE
|
|
|
|
|
|
|
|
NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
|
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
public:
|
2010-08-18 19:14:50 -07:00
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
|
|
|
|
nsIPresShell* aPresShell);
|
|
|
|
virtual ~DocAccessible();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
// nsIAccessible
|
2012-05-27 02:01:40 -07:00
|
|
|
NS_IMETHOD GetAttributes(nsIPersistentProperties** aAttributes);
|
2009-06-24 19:08:53 -07:00
|
|
|
NS_IMETHOD TakeFocus(void);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
// nsIScrollPositionListener
|
2010-01-28 16:03:42 -08:00
|
|
|
virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) {}
|
|
|
|
virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
// nsIDocumentObserver
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
// nsAccessNode
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool Init();
|
2010-06-11 21:04:35 -07:00
|
|
|
virtual void Shutdown();
|
2011-02-22 05:54:56 -08:00
|
|
|
virtual nsIFrame* GetFrame() const;
|
2010-06-11 01:23:18 -07:00
|
|
|
virtual nsINode* GetNode() const { return mDocument; }
|
2010-11-05 21:11:08 -07:00
|
|
|
virtual nsIDocument* GetDocumentNode() const { return mDocument; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2012-04-30 20:08:31 -07:00
|
|
|
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
2011-04-23 06:14:05 -07:00
|
|
|
virtual void Description(nsString& aDescription);
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* FocusedChild();
|
2012-01-11 19:07:35 -08:00
|
|
|
virtual mozilla::a11y::role NativeRole();
|
2011-04-09 16:38:06 -07:00
|
|
|
virtual PRUint64 NativeState();
|
2012-05-17 02:37:37 -07:00
|
|
|
virtual void ApplyARIAState(PRUint64* aState) const;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2012-05-23 02:21:40 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
virtual nsresult HandleAccEvent(AccEvent* aEvent);
|
2010-06-08 09:39:58 -07:00
|
|
|
#endif
|
|
|
|
|
2012-05-07 17:00:36 -07:00
|
|
|
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
// nsHyperTextAccessible
|
|
|
|
virtual already_AddRefed<nsIEditor> GetEditor() const;
|
2007-08-14 09:25:24 -07:00
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
// DocAccessible
|
2007-04-16 21:45:42 -07:00
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
/**
|
|
|
|
* Return presentation shell for this document accessible.
|
|
|
|
*/
|
|
|
|
nsIPresShell* PresShell() const { return mPresShell; }
|
|
|
|
|
2012-04-10 20:42:42 -07:00
|
|
|
/**
|
|
|
|
* Return the presentation shell's context.
|
|
|
|
*/
|
|
|
|
nsPresContext* PresContext() const { return mPresShell->GetPresContext(); }
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
/**
|
|
|
|
* Return true if associated DOM document was loaded and isn't unloading.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsContentLoaded() const
|
2010-06-08 09:39:58 -07:00
|
|
|
{
|
2011-08-08 00:55:36 -07:00
|
|
|
// eDOMLoaded flag check is used for error pages as workaround to make this
|
|
|
|
// method return correct result since error pages do not receive 'pageshow'
|
|
|
|
// event and as consequence nsIDocument::IsShowing() returns false.
|
2010-06-08 09:39:58 -07:00
|
|
|
return mDocument && mDocument->IsVisible() &&
|
2011-08-08 00:55:36 -07:00
|
|
|
(mDocument->IsShowing() || HasLoadState(eDOMLoaded));
|
2010-06-08 09:39:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-08-08 00:55:36 -07:00
|
|
|
* Document load states.
|
2010-06-08 09:39:58 -07:00
|
|
|
*/
|
2011-08-08 00:55:36 -07:00
|
|
|
enum LoadState {
|
|
|
|
// initial tree construction is pending
|
|
|
|
eTreeConstructionPending = 0,
|
|
|
|
// initial tree construction done
|
|
|
|
eTreeConstructed = 1,
|
|
|
|
// DOM document is loaded.
|
|
|
|
eDOMLoaded = 1 << 1,
|
|
|
|
// document is ready
|
|
|
|
eReady = eTreeConstructed | eDOMLoaded,
|
|
|
|
// document and all its subdocuments are ready
|
|
|
|
eCompletelyLoaded = eReady | 1 << 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the document has given document state.
|
|
|
|
*/
|
|
|
|
bool HasLoadState(LoadState aState) const
|
2012-02-07 14:38:54 -08:00
|
|
|
{ return (mLoadState & static_cast<PRUint32>(aState)) ==
|
|
|
|
static_cast<PRUint32>(aState); }
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2010-09-16 20:23:17 -07:00
|
|
|
/**
|
|
|
|
* Return a native window handler or pointer depending on platform.
|
|
|
|
*/
|
|
|
|
virtual void* GetNativeWindow() const;
|
|
|
|
|
2010-09-09 07:44:56 -07:00
|
|
|
/**
|
|
|
|
* Return the parent document.
|
|
|
|
*/
|
2012-05-29 19:21:24 -07:00
|
|
|
DocAccessible* ParentDocument() const;
|
2010-09-09 07:44:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the child document count.
|
|
|
|
*/
|
|
|
|
PRUint32 ChildDocumentCount() const
|
|
|
|
{ return mChildDocuments.Length(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the child document at the given index.
|
|
|
|
*/
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* GetChildDocumentAt(PRUint32 aIndex) const
|
2010-09-09 07:44:56 -07:00
|
|
|
{ return mChildDocuments.SafeElementAt(aIndex, nsnull); }
|
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
/**
|
|
|
|
* Non-virtual method to fire a delayed event after a 0 length timeout.
|
|
|
|
*
|
2009-09-02 19:01:18 -07:00
|
|
|
* @param aEventType [in] the nsIAccessibleEvent event type
|
2009-06-24 19:08:53 -07:00
|
|
|
* @param aDOMNode [in] DOM node the accesible event should be fired for
|
|
|
|
* @param aAllowDupes [in] rule to process an event (see EEventRule constants)
|
|
|
|
*/
|
2010-06-11 01:23:18 -07:00
|
|
|
nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
|
2010-08-24 19:08:28 -07:00
|
|
|
AccEvent::EEventRule aAllowDupes = AccEvent::eRemoveDupes,
|
2010-01-20 03:16:32 -08:00
|
|
|
EIsFromUserInput aIsFromUserInput = eAutoDetect);
|
2009-06-24 19:08:53 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fire accessible event after timeout.
|
|
|
|
*
|
|
|
|
* @param aEvent [in] the event to fire
|
|
|
|
*/
|
2010-08-24 19:08:28 -07:00
|
|
|
nsresult FireDelayedAccessibleEvent(AccEvent* aEvent);
|
2007-04-16 21:45:42 -07:00
|
|
|
|
2011-12-01 08:12:02 -08:00
|
|
|
/**
|
|
|
|
* Fire value change event on the given accessible if applicable.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void MaybeNotifyOfValueChange(Accessible* aAccessible)
|
2011-12-01 08:12:02 -08:00
|
|
|
{
|
2012-01-11 20:42:47 -08:00
|
|
|
mozilla::a11y::role role = aAccessible->Role();
|
|
|
|
if (role == mozilla::a11y::roles::ENTRY ||
|
|
|
|
role == mozilla::a11y::roles::COMBOBOX) {
|
2011-12-01 08:12:02 -08:00
|
|
|
nsRefPtr<AccEvent> valueChangeEvent =
|
|
|
|
new AccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible,
|
|
|
|
eAutoDetect, AccEvent::eRemoveDupes);
|
|
|
|
FireDelayedAccessibleEvent(valueChangeEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-24 19:33:37 -08:00
|
|
|
/**
|
2011-10-07 22:16:37 -07:00
|
|
|
* Get/set the anchor jump.
|
2011-01-24 19:33:37 -08:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* AnchorJump()
|
2011-10-07 22:16:37 -07:00
|
|
|
{ return GetAccessibleOrContainer(mAnchorJumpElm); }
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
void SetAnchorJump(nsIContent* aTargetNode)
|
2011-10-07 22:16:37 -07:00
|
|
|
{ mAnchorJumpElm = aTargetNode; }
|
2011-01-24 19:33:37 -08:00
|
|
|
|
2011-01-25 22:35:51 -08:00
|
|
|
/**
|
|
|
|
* Bind the child document to the tree.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void BindChildDocument(DocAccessible* aDocument)
|
2011-01-25 22:35:51 -08:00
|
|
|
{
|
|
|
|
mNotificationController->ScheduleChildDocBinding(aDocument);
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
/**
|
|
|
|
* Process the generic notification.
|
|
|
|
*
|
|
|
|
* @note The caller must guarantee that the given instance still exists when
|
|
|
|
* notification is processed.
|
|
|
|
* @see NotificationController::HandleNotification
|
|
|
|
*/
|
|
|
|
template<class Class, class Arg>
|
2012-05-28 18:18:45 -07:00
|
|
|
void HandleNotification(Class* aInstance,
|
2011-01-18 00:03:38 -08:00
|
|
|
typename TNotification<Class, Arg>::Callback aMethod,
|
|
|
|
Arg* aArg)
|
|
|
|
{
|
|
|
|
if (mNotificationController) {
|
|
|
|
mNotificationController->HandleNotification<Class, Arg>(aInstance,
|
|
|
|
aMethod, aArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
/**
|
2010-10-20 21:16:10 -07:00
|
|
|
* Return the cached accessible by the given DOM node if it's in subtree of
|
|
|
|
* this document accessible or the document accessible itself, otherwise null.
|
2009-06-24 19:08:53 -07:00
|
|
|
*
|
2010-10-20 21:16:10 -07:00
|
|
|
* @return the accessible object
|
2009-06-24 19:08:53 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetAccessible(nsINode* aNode) const;
|
2011-01-27 20:37:08 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether the given DOM node has an accessible or not.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
bool HasAccessible(nsINode* aNode) const
|
2011-08-04 02:54:06 -07:00
|
|
|
{ return GetAccessible(aNode); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the given accessible is in document.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
bool IsInDocument(Accessible* aAccessible) const
|
2011-01-27 20:37:08 -08:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* acc = aAccessible;
|
2011-08-04 02:54:06 -07:00
|
|
|
while (acc && !acc->IsPrimaryForNode())
|
|
|
|
acc = acc->Parent();
|
|
|
|
|
|
|
|
return acc ? mNodeToAccessibleMap.Get(acc->GetNode()) : false;
|
2011-01-27 20:37:08 -08:00
|
|
|
}
|
2009-06-24 19:08:53 -07:00
|
|
|
|
2010-02-11 05:56:01 -08:00
|
|
|
/**
|
2010-10-20 21:16:10 -07:00
|
|
|
* Return the cached accessible by the given unique ID within this document.
|
2010-02-11 05:56:01 -08:00
|
|
|
*
|
2010-10-20 21:16:10 -07:00
|
|
|
* @note the unique ID matches with the uniqueID() of nsAccessNode
|
2010-02-11 05:56:01 -08:00
|
|
|
*
|
|
|
|
* @param aUniqueID [in] the unique ID used to cache the node.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetAccessibleByUniqueID(void* aUniqueID)
|
2010-10-20 21:16:10 -07:00
|
|
|
{
|
|
|
|
return UniqueID() == aUniqueID ?
|
|
|
|
this : mAccessibleCache.GetWeak(aUniqueID);
|
|
|
|
}
|
2010-02-11 05:56:01 -08:00
|
|
|
|
2010-09-09 07:44:56 -07:00
|
|
|
/**
|
|
|
|
* Return the cached accessible by the given unique ID looking through
|
|
|
|
* this and nested documents.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetAccessibleByUniqueIDInSubtree(void* aUniqueID);
|
2010-09-09 07:44:56 -07:00
|
|
|
|
2011-01-27 20:37:38 -08:00
|
|
|
/**
|
|
|
|
* Return an accessible for the given DOM node or container accessible if
|
|
|
|
* the node is not accessible.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetAccessibleOrContainer(nsINode* aNode);
|
2011-01-27 20:37:38 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a container accessible for the given DOM node.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetContainerAccessible(nsINode* aNode)
|
2011-01-27 20:37:38 -08:00
|
|
|
{
|
|
|
|
return aNode ? GetAccessibleOrContainer(aNode->GetNodeParent()) : nsnull;
|
|
|
|
}
|
|
|
|
|
2010-11-18 21:44:47 -08:00
|
|
|
/**
|
|
|
|
* Return true if the given ID is referred by relation attribute.
|
|
|
|
*
|
|
|
|
* @note Different elements may share the same ID if they are hosted inside
|
|
|
|
* XBL bindings. Be careful the result of this method may be senseless
|
|
|
|
* while it's called for XUL elements (where XBL is used widely).
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDependentID(const nsAString& aID) const
|
2010-11-18 21:44:47 -08:00
|
|
|
{ return mDependentIDsHash.Get(aID, nsnull); }
|
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
/**
|
2010-11-12 11:00:55 -08:00
|
|
|
* Initialize the newly created accessible and put it into document caches.
|
2009-06-24 19:08:53 -07:00
|
|
|
*
|
2010-11-12 11:00:55 -08:00
|
|
|
* @param aAccessible [in] created accessible
|
|
|
|
* @param aRoleMapEntry [in] the role map entry role the ARIA role or nsnull
|
|
|
|
* if none
|
2009-06-24 19:08:53 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
bool BindToDocument(Accessible* aAccessible, nsRoleMapEntry* aRoleMapEntry);
|
2009-06-24 19:08:53 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
/**
|
2010-11-12 11:01:04 -08:00
|
|
|
* Remove from document and shutdown the given accessible.
|
2009-08-19 23:45:19 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void UnbindFromDocument(Accessible* aAccessible);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
/**
|
2011-01-18 00:03:38 -08:00
|
|
|
* Notify the document accessible that content was inserted.
|
2009-06-24 19:08:53 -07:00
|
|
|
*/
|
2011-01-18 00:03:38 -08:00
|
|
|
void ContentInserted(nsIContent* aContainerNode,
|
|
|
|
nsIContent* aStartChildNode,
|
|
|
|
nsIContent* aEndChildNode);
|
2009-06-24 19:08:53 -07:00
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
/**
|
2011-01-18 00:03:38 -08:00
|
|
|
* Notify the document accessible that content was removed.
|
2010-10-20 21:16:10 -07:00
|
|
|
*/
|
2011-01-18 00:03:38 -08:00
|
|
|
void ContentRemoved(nsIContent* aContainerNode, nsIContent* aChildNode);
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2011-01-28 00:42:22 -08:00
|
|
|
/**
|
|
|
|
* Updates accessible tree when rendered text is changed.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void UpdateText(nsIContent* aTextNode)
|
2011-01-28 00:42:22 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mNotificationController, "The document was shut down!");
|
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
// Ignore the notification if initial tree construction hasn't been done yet.
|
|
|
|
if (mNotificationController && HasLoadState(eTreeConstructed))
|
2011-01-28 00:42:22 -08:00
|
|
|
mNotificationController->ScheduleTextUpdate(aTextNode);
|
|
|
|
}
|
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
/**
|
|
|
|
* Recreate an accessible, results in hide/show events pair.
|
|
|
|
*/
|
2011-01-31 19:00:06 -08:00
|
|
|
void RecreateAccessible(nsIContent* aContent);
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2009-06-24 19:08:53 -07:00
|
|
|
protected:
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
void LastRelease();
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2010-11-20 17:00:29 -08:00
|
|
|
virtual void CacheChildren();
|
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
// DocAccessible
|
|
|
|
virtual nsresult AddEventListeners();
|
|
|
|
virtual nsresult RemoveEventListeners();
|
2011-03-02 06:41:42 -08:00
|
|
|
|
|
|
|
/**
|
2011-08-08 00:55:36 -07:00
|
|
|
* Marks this document as loaded or loading.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void NotifyOfLoad(PRUint32 aLoadEventType)
|
2011-08-08 00:55:36 -07:00
|
|
|
{
|
|
|
|
mLoadState |= eDOMLoaded;
|
|
|
|
mLoadEventType = aLoadEventType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyOfLoading(bool aIsReloading);
|
|
|
|
|
|
|
|
friend class nsAccDocManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform initial update (create accessible tree).
|
2011-03-02 06:41:42 -08:00
|
|
|
* Can be overridden by wrappers to prepare initialization work.
|
|
|
|
*/
|
2011-08-08 00:55:36 -07:00
|
|
|
virtual void DoInitialUpdate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process document load notification, fire document load and state busy
|
|
|
|
* events if applicable.
|
|
|
|
*/
|
|
|
|
void ProcessLoad();
|
2011-03-02 06:41:42 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void AddScrollListener();
|
|
|
|
void RemoveScrollListener();
|
2008-02-02 09:02:09 -08:00
|
|
|
|
2010-09-09 07:44:56 -07:00
|
|
|
/**
|
|
|
|
* Append the given document accessible to this document's child document
|
|
|
|
* accessibles.
|
|
|
|
*/
|
2012-05-27 02:01:40 -07:00
|
|
|
bool AppendChildDocument(DocAccessible* aChildDocument)
|
2010-09-09 07:44:56 -07:00
|
|
|
{
|
|
|
|
return mChildDocuments.AppendElement(aChildDocument);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the given document accessible from this document's child document
|
|
|
|
* accessibles.
|
|
|
|
*/
|
2012-05-27 02:01:40 -07:00
|
|
|
void RemoveChildDocument(DocAccessible* aChildDocument)
|
2010-09-09 07:44:56 -07:00
|
|
|
{
|
|
|
|
mChildDocuments.RemoveElement(aChildDocument);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:55:44 -08:00
|
|
|
/**
|
|
|
|
* Add dependent IDs pointed by accessible element by relation attribute to
|
|
|
|
* cache. If the relation attribute is missed then all relation attributes
|
|
|
|
* are checked.
|
|
|
|
*
|
|
|
|
* @param aRelProvider [in] accessible that element has relation attribute
|
|
|
|
* @param aRelAttr [in, optional] relation attribute
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void AddDependentIDsFor(Accessible* aRelProvider,
|
2010-11-17 18:55:44 -08:00
|
|
|
nsIAtom* aRelAttr = nsnull);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove dependent IDs pointed by accessible element by relation attribute
|
|
|
|
* from cache. If the relation attribute is absent then all relation
|
|
|
|
* attributes are checked.
|
|
|
|
*
|
|
|
|
* @param aRelProvider [in] accessible that element has relation attribute
|
|
|
|
* @param aRelAttr [in, optional] relation attribute
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void RemoveDependentIDsFor(Accessible* aRelProvider,
|
2010-11-17 18:55:44 -08:00
|
|
|
nsIAtom* aRelAttr = nsnull);
|
|
|
|
|
2010-12-18 10:33:00 -08:00
|
|
|
/**
|
|
|
|
* Update or recreate an accessible depending on a changed attribute.
|
|
|
|
*
|
|
|
|
* @param aElement [in] the element the attribute was changed on
|
|
|
|
* @param aAttribute [in] the changed attribute
|
|
|
|
* @return true if an action was taken on the attribute change
|
|
|
|
*/
|
|
|
|
bool UpdateAccessibleOnAttrChange(mozilla::dom::Element* aElement,
|
|
|
|
nsIAtom* aAttribute);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-16 21:45:42 -07:00
|
|
|
/**
|
2007-09-18 14:36:41 -07:00
|
|
|
* Fires accessible events when attribute is changed.
|
|
|
|
*
|
|
|
|
* @param aContent - node that attribute is changed for
|
|
|
|
* @param aNameSpaceID - namespace of changed attribute
|
|
|
|
* @param aAttribute - changed attribute
|
|
|
|
*/
|
|
|
|
void AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fires accessible events when ARIA attribute is changed.
|
2007-04-16 21:45:42 -07:00
|
|
|
*
|
|
|
|
* @param aContent - node that attribute is changed for
|
|
|
|
* @param aAttribute - changed attribute
|
|
|
|
*/
|
|
|
|
void ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute);
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
/**
|
|
|
|
* Process ARIA active-descendant attribute change.
|
|
|
|
*/
|
|
|
|
void ARIAActiveDescendantChanged(nsIContent* aElm);
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
/**
|
|
|
|
* Process the event when the queue of pending events is untwisted. Fire
|
|
|
|
* accessible events as result of the processing.
|
|
|
|
*/
|
|
|
|
void ProcessPendingEvent(AccEvent* aEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the accessible tree for inserted content.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void ProcessContentInserted(Accessible* aContainer,
|
2011-01-18 00:03:38 -08:00
|
|
|
const nsTArray<nsCOMPtr<nsIContent> >* aInsertedContent);
|
|
|
|
|
2011-07-24 20:15:37 -07:00
|
|
|
/**
|
|
|
|
* Used to notify the document to make it process the invalidation list.
|
|
|
|
*
|
|
|
|
* While children are cached we may encounter the case there's no accessible
|
|
|
|
* for referred content by related accessible. Store these related nodes to
|
|
|
|
* invalidate their containers later.
|
|
|
|
*/
|
|
|
|
void ProcessInvalidationList();
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
/**
|
|
|
|
* Update the accessible tree for content insertion or removal.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void UpdateTree(Accessible* aContainer, nsIContent* aChildNode,
|
2011-04-06 22:17:29 -07:00
|
|
|
bool aIsInsert);
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
/**
|
|
|
|
* Helper for UpdateTree() method. Go down to DOM subtree and updates
|
|
|
|
* accessible tree. Return one of these flags.
|
|
|
|
*/
|
|
|
|
enum EUpdateTreeFlags {
|
|
|
|
eNoAccessible = 0,
|
|
|
|
eAccessible = 1,
|
|
|
|
eAlertAccessible = 2
|
|
|
|
};
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
PRUint32 UpdateTreeInternal(Accessible* aChild, bool aIsInsert);
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2011-01-20 00:02:00 -08:00
|
|
|
/**
|
|
|
|
* Create accessible tree.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void CacheChildrenInSubtree(Accessible* aRoot);
|
2011-01-20 00:02:00 -08:00
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
/**
|
|
|
|
* Remove accessibles in subtree from node to accessible map.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void UncacheChildrenInSubtree(Accessible* aRoot);
|
2010-10-20 21:16:10 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown any cached accessible in the subtree.
|
|
|
|
*
|
|
|
|
* @param aAccessible [in] the root of the subrtee to invalidate accessible
|
|
|
|
* child/parent refs in
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void ShutdownChildrenInSubtree(Accessible* aAccessible);
|
2010-10-20 21:16:10 -07:00
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
/**
|
2012-05-29 19:21:24 -07:00
|
|
|
* Return true if the document is a target of document loading events
|
|
|
|
* (for example, state busy change or document reload events).
|
2011-08-08 00:55:36 -07:00
|
|
|
*
|
2012-05-29 19:21:24 -07:00
|
|
|
* Rules: The root chrome document accessible is never an event target
|
|
|
|
* (for example, Firefox UI window). If the sub document is loaded within its
|
|
|
|
* parent document then the parent document is a target only (aka events
|
|
|
|
* coalescence).
|
2011-08-08 00:55:36 -07:00
|
|
|
*/
|
|
|
|
bool IsLoadEventTarget() const;
|
|
|
|
|
2010-12-18 10:33:00 -08:00
|
|
|
/**
|
|
|
|
* Used to fire scrolling end event after page scroll.
|
|
|
|
*
|
|
|
|
* @param aTimer [in] the timer object
|
|
|
|
* @param aClosure [in] the document accessible where scrolling happens
|
|
|
|
*/
|
|
|
|
static void ScrollTimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
protected:
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
/**
|
|
|
|
* Cache of accessibles within this document accessible.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleHashtable mAccessibleCache;
|
|
|
|
nsDataHashtable<nsPtrHashKey<const nsINode>, Accessible*>
|
2010-11-17 18:55:44 -08:00
|
|
|
mNodeToAccessibleMap;
|
2010-06-11 21:04:35 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDocument> mDocument;
|
|
|
|
nsCOMPtr<nsITimer> mScrollWatchTimer;
|
|
|
|
PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
|
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
/**
|
|
|
|
* Bit mask of document load states (@see LoadState).
|
|
|
|
*/
|
|
|
|
PRUint32 mLoadState;
|
2009-09-07 09:46:56 -07:00
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
/**
|
2011-08-08 00:55:36 -07:00
|
|
|
* Type of document load event fired after the document is loaded completely.
|
2010-06-08 09:39:58 -07:00
|
|
|
*/
|
2011-08-08 00:55:36 -07:00
|
|
|
PRUint32 mLoadEventType;
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2011-10-07 22:16:37 -07:00
|
|
|
/**
|
|
|
|
* Reference to anchor jump element.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mAnchorJumpElm;
|
|
|
|
|
2011-08-11 04:45:36 -07:00
|
|
|
/**
|
|
|
|
* Keep the ARIA attribute old value that is initialized by
|
|
|
|
* AttributeWillChange and used by AttributeChanged notifications.
|
|
|
|
*/
|
|
|
|
nsIAtom* mARIAAttrOldValue;
|
2010-09-09 07:44:56 -07:00
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
nsTArray<nsRefPtr<DocAccessible> > mChildDocuments;
|
2010-11-17 18:55:44 -08:00
|
|
|
|
2012-02-01 22:14:51 -08:00
|
|
|
/**
|
|
|
|
* Whether we support nsIAccessibleCursorable, used when querying the interface.
|
|
|
|
*/
|
|
|
|
bool mIsCursorable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The virtual cursor of the document when it supports nsIAccessibleCursorable.
|
|
|
|
*/
|
|
|
|
nsRefPtr<nsAccessiblePivot> mVirtualCursor;
|
|
|
|
|
2010-11-17 18:55:44 -08:00
|
|
|
/**
|
|
|
|
* A storage class for pairing content with one of its relation attributes.
|
|
|
|
*/
|
|
|
|
class AttrRelProvider
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AttrRelProvider(nsIAtom* aRelAttr, nsIContent* aContent) :
|
|
|
|
mRelAttr(aRelAttr), mContent(aContent) { }
|
|
|
|
|
|
|
|
nsIAtom* mRelAttr;
|
2010-11-22 03:49:15 -08:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2010-11-17 18:55:44 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
AttrRelProvider();
|
|
|
|
AttrRelProvider(const AttrRelProvider&);
|
|
|
|
AttrRelProvider& operator =(const AttrRelProvider&);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The cache of IDs pointed by relation attributes.
|
|
|
|
*/
|
|
|
|
typedef nsTArray<nsAutoPtr<AttrRelProvider> > AttrRelProviderArray;
|
|
|
|
nsClassHashtable<nsStringHashKey, AttrRelProviderArray> mDependentIDsHash;
|
|
|
|
|
|
|
|
friend class RelatedAccIterator;
|
2010-11-18 21:44:47 -08:00
|
|
|
|
|
|
|
/**
|
2011-07-24 20:15:37 -07:00
|
|
|
* Used for our caching algorithm. We store the list of nodes that should be
|
|
|
|
* invalidated.
|
2010-11-18 21:44:47 -08:00
|
|
|
*
|
2011-07-24 20:15:37 -07:00
|
|
|
* @see ProcessInvalidationList
|
2010-11-18 21:44:47 -08:00
|
|
|
*/
|
|
|
|
nsTArray<nsIContent*> mInvalidationList;
|
2011-01-18 00:03:38 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to process notification from core and accessible events.
|
|
|
|
*/
|
|
|
|
nsRefPtr<NotificationController> mNotificationController;
|
|
|
|
friend class NotificationController;
|
2012-02-07 14:38:54 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
nsIPresShell* mPresShell;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
inline DocAccessible*
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible::AsDoc()
|
2011-05-19 22:17:47 -07:00
|
|
|
{
|
|
|
|
return mFlags & eDocAccessible ?
|
2012-05-27 02:01:40 -07:00
|
|
|
static_cast<DocAccessible*>(this) : nsnull;
|
2011-05-19 22:17:47 -07:00
|
|
|
}
|
|
|
|
|
2010-11-17 18:55:44 -08:00
|
|
|
#endif
|