LCOV - code coverage report
Current view: directory - accessible/src/base - nsDocAccessible.h (source / functions) Found Hit Coverage
Test: app.info Lines: 66 1 1.5 %
Date: 2012-06-02 Functions: 31 1 3.2 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2003
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Original Author: Aaron Leventhal (aaronl@netscape.com)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef _nsDocAccessible_H_
      40                 : #define _nsDocAccessible_H_
      41                 : 
      42                 : #include "nsIAccessibleCursorable.h"
      43                 : #include "nsIAccessibleDocument.h"
      44                 : #include "nsIAccessiblePivot.h"
      45                 : 
      46                 : #include "nsEventShell.h"
      47                 : #include "nsHyperTextAccessibleWrap.h"
      48                 : #include "NotificationController.h"
      49                 : 
      50                 : #include "nsClassHashtable.h"
      51                 : #include "nsDataHashtable.h"
      52                 : #include "nsIDocument.h"
      53                 : #include "nsIDocumentObserver.h"
      54                 : #include "nsIEditor.h"
      55                 : #include "nsIObserver.h"
      56                 : #include "nsIScrollPositionListener.h"
      57                 : #include "nsITimer.h"
      58                 : #include "nsIWeakReference.h"
      59                 : #include "nsCOMArray.h"
      60                 : #include "nsIDocShellTreeNode.h"
      61                 : 
      62                 : class nsIScrollableView;
      63                 : class nsAccessiblePivot;
      64                 : 
      65                 : const PRUint32 kDefaultCacheSize = 256;
      66                 : 
      67                 : #define NS_DOCACCESSIBLE_IMPL_CID                       \
      68                 : {  /* 5641921c-a093-4292-9dca-0b51813db57d */           \
      69                 :   0x5641921c,                                           \
      70                 :   0xa093,                                               \
      71                 :   0x4292,                                               \
      72                 :   { 0x9d, 0xca, 0x0b, 0x51, 0x81, 0x3d, 0xb5, 0x7d }    \
      73                 : }
      74                 : 
      75                 : class nsDocAccessible : public nsHyperTextAccessibleWrap,
      76                 :                         public nsIAccessibleDocument,
      77                 :                         public nsIDocumentObserver,
      78                 :                         public nsIObserver,
      79                 :                         public nsIScrollPositionListener,
      80                 :                         public nsSupportsWeakReference,
      81                 :                         public nsIAccessibleCursorable,
      82                 :                         public nsIAccessiblePivotObserver
      83                 : {
      84                 :   NS_DECL_ISUPPORTS_INHERITED
      85            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocAccessible, nsAccessible)
      86                 : 
      87                 :   NS_DECL_NSIACCESSIBLEDOCUMENT
      88                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOCACCESSIBLE_IMPL_CID)
      89                 : 
      90                 :   NS_DECL_NSIOBSERVER
      91                 : 
      92                 :   NS_DECL_NSIACCESSIBLECURSORABLE
      93                 : 
      94                 :   NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
      95                 : 
      96                 : public:
      97                 :   using nsAccessible::GetParent;
      98                 : 
      99                 :   nsDocAccessible(nsIDocument *aDocument, nsIContent *aRootContent,
     100                 :                   nsIPresShell* aPresShell);
     101                 :   virtual ~nsDocAccessible();
     102                 : 
     103                 :   // nsIAccessible
     104                 :   NS_IMETHOD GetName(nsAString& aName);
     105                 :   NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
     106                 :   NS_IMETHOD TakeFocus(void);
     107                 : 
     108                 :   // nsIScrollPositionListener
     109               0 :   virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) {}
     110                 :   virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
     111                 : 
     112                 :   // nsIDocumentObserver
     113                 :   NS_DECL_NSIDOCUMENTOBSERVER
     114                 : 
     115                 :   // nsAccessNode
     116                 :   virtual bool Init();
     117                 :   virtual void Shutdown();
     118                 :   virtual nsIFrame* GetFrame() const;
     119                 :   virtual bool IsDefunct() const;
     120               0 :   virtual nsINode* GetNode() const { return mDocument; }
     121               0 :   virtual nsIDocument* GetDocumentNode() const { return mDocument; }
     122                 : 
     123                 :   // nsAccessible
     124                 :   virtual void Description(nsString& aDescription);
     125                 :   virtual nsAccessible* FocusedChild();
     126                 :   virtual mozilla::a11y::role NativeRole();
     127                 :   virtual PRUint64 NativeState();
     128                 :   virtual void ApplyARIAState(PRUint64* aState);
     129                 : 
     130                 :   virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
     131                 : 
     132                 : #ifdef DEBUG_ACCDOCMGR
     133                 :   virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
     134                 : #endif
     135                 : 
     136                 :   // nsHyperTextAccessible
     137                 :   virtual already_AddRefed<nsIEditor> GetEditor() const;
     138                 : 
     139                 :   // nsDocAccessible
     140                 : 
     141                 :   /**
     142                 :    * Return presentation shell for this document accessible.
     143                 :    */
     144               0 :   nsIPresShell* PresShell() const { return mPresShell; }
     145                 : 
     146                 :   /**
     147                 :    * Return true if associated DOM document was loaded and isn't unloading.
     148                 :    */
     149               0 :   bool IsContentLoaded() const
     150                 :   {
     151                 :     // eDOMLoaded flag check is used for error pages as workaround to make this
     152                 :     // method return correct result since error pages do not receive 'pageshow'
     153                 :     // event and as consequence nsIDocument::IsShowing() returns false.
     154               0 :     return mDocument && mDocument->IsVisible() &&
     155               0 :       (mDocument->IsShowing() || HasLoadState(eDOMLoaded));
     156                 :   }
     157                 : 
     158                 :   /**
     159                 :    * Document load states.
     160                 :    */
     161                 :   enum LoadState {
     162                 :     // initial tree construction is pending
     163                 :     eTreeConstructionPending = 0,
     164                 :     // initial tree construction done
     165                 :     eTreeConstructed = 1,
     166                 :     // DOM document is loaded.
     167                 :     eDOMLoaded = 1 << 1,
     168                 :     // document is ready
     169                 :     eReady = eTreeConstructed | eDOMLoaded,
     170                 :     // document and all its subdocuments are ready
     171                 :     eCompletelyLoaded = eReady | 1 << 2
     172                 :   };
     173                 : 
     174                 :   /**
     175                 :    * Return true if the document has given document state.
     176                 :    */
     177               0 :   bool HasLoadState(LoadState aState) const
     178                 :     { return (mLoadState & static_cast<PRUint32>(aState)) == 
     179               0 :         static_cast<PRUint32>(aState); }
     180                 : 
     181                 :   /**
     182                 :    * Return a native window handler or pointer depending on platform.
     183                 :    */
     184                 :   virtual void* GetNativeWindow() const;
     185                 : 
     186                 :   /**
     187                 :    * Return the parent document.
     188                 :    */
     189               0 :   nsDocAccessible* ParentDocument() const
     190               0 :     { return mParent ? mParent->Document() : nsnull; }
     191                 : 
     192                 :   /**
     193                 :    * Return the child document count.
     194                 :    */
     195               0 :   PRUint32 ChildDocumentCount() const
     196               0 :     { return mChildDocuments.Length(); }
     197                 : 
     198                 :   /**
     199                 :    * Return the child document at the given index.
     200                 :    */
     201               0 :   nsDocAccessible* GetChildDocumentAt(PRUint32 aIndex) const
     202               0 :     { return mChildDocuments.SafeElementAt(aIndex, nsnull); }
     203                 : 
     204                 :   /**
     205                 :    * Non-virtual method to fire a delayed event after a 0 length timeout.
     206                 :    *
     207                 :    * @param aEventType   [in] the nsIAccessibleEvent event type
     208                 :    * @param aDOMNode     [in] DOM node the accesible event should be fired for
     209                 :    * @param aAllowDupes  [in] rule to process an event (see EEventRule constants)
     210                 :    */
     211                 :   nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsINode *aNode,
     212                 :                                       AccEvent::EEventRule aAllowDupes = AccEvent::eRemoveDupes,
     213                 :                                       EIsFromUserInput aIsFromUserInput = eAutoDetect);
     214                 : 
     215                 :   /**
     216                 :    * Fire accessible event after timeout.
     217                 :    *
     218                 :    * @param aEvent  [in] the event to fire
     219                 :    */
     220                 :   nsresult FireDelayedAccessibleEvent(AccEvent* aEvent);
     221                 : 
     222                 :   /**
     223                 :    * Fire value change event on the given accessible if applicable.
     224                 :    */
     225               0 :   inline void MaybeNotifyOfValueChange(nsAccessible* aAccessible)
     226                 :   {
     227               0 :     mozilla::a11y::role role = aAccessible->Role();
     228               0 :     if (role == mozilla::a11y::roles::ENTRY ||
     229                 :         role == mozilla::a11y::roles::COMBOBOX) {
     230                 :       nsRefPtr<AccEvent> valueChangeEvent =
     231                 :         new AccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible,
     232               0 :                      eAutoDetect, AccEvent::eRemoveDupes);
     233               0 :       FireDelayedAccessibleEvent(valueChangeEvent);
     234                 :     }
     235               0 :   }
     236                 : 
     237                 :   /**
     238                 :    * Get/set the anchor jump.
     239                 :    */
     240               0 :   inline nsAccessible* AnchorJump()
     241               0 :     { return GetAccessibleOrContainer(mAnchorJumpElm); }
     242                 : 
     243               0 :   inline void SetAnchorJump(nsIContent* aTargetNode)
     244               0 :     { mAnchorJumpElm = aTargetNode; }
     245                 : 
     246                 :   /**
     247                 :    * Bind the child document to the tree.
     248                 :    */
     249               0 :   inline void BindChildDocument(nsDocAccessible* aDocument)
     250                 :   {
     251               0 :     mNotificationController->ScheduleChildDocBinding(aDocument);
     252               0 :   }
     253                 : 
     254                 :   /**
     255                 :    * Process the generic notification.
     256                 :    *
     257                 :    * @note  The caller must guarantee that the given instance still exists when
     258                 :    *          notification is processed.
     259                 :    * @see   NotificationController::HandleNotification
     260                 :    */
     261                 :   template<class Class, class Arg>
     262               0 :   inline void HandleNotification(Class* aInstance,
     263                 :                                  typename TNotification<Class, Arg>::Callback aMethod,
     264                 :                                  Arg* aArg)
     265                 :   {
     266               0 :     if (mNotificationController) {
     267               0 :       mNotificationController->HandleNotification<Class, Arg>(aInstance,
     268                 :                                                               aMethod, aArg);
     269                 :     }
     270               0 :   }
     271                 : 
     272                 :   /**
     273                 :    * Return the cached accessible by the given DOM node if it's in subtree of
     274                 :    * this document accessible or the document accessible itself, otherwise null.
     275                 :    *
     276                 :    * @return the accessible object
     277                 :    */
     278                 :   nsAccessible* GetAccessible(nsINode* aNode) const;
     279                 : 
     280                 :   /**
     281                 :    * Return whether the given DOM node has an accessible or not.
     282                 :    */
     283               0 :   inline bool HasAccessible(nsINode* aNode) const
     284               0 :     { return GetAccessible(aNode); }
     285                 : 
     286                 :   /**
     287                 :    * Return true if the given accessible is in document.
     288                 :    */
     289               0 :   inline bool IsInDocument(nsAccessible* aAccessible) const
     290                 :   {
     291               0 :     nsAccessible* acc = aAccessible;
     292               0 :     while (acc && !acc->IsPrimaryForNode())
     293               0 :       acc = acc->Parent();
     294                 : 
     295               0 :     return acc ? mNodeToAccessibleMap.Get(acc->GetNode()) : false;
     296                 :   }
     297                 : 
     298                 :   /**
     299                 :    * Return the cached accessible by the given unique ID within this document.
     300                 :    *
     301                 :    * @note   the unique ID matches with the uniqueID() of nsAccessNode
     302                 :    *
     303                 :    * @param  aUniqueID  [in] the unique ID used to cache the node.
     304                 :    */
     305               0 :   inline nsAccessible* GetAccessibleByUniqueID(void* aUniqueID)
     306                 :   {
     307               0 :     return UniqueID() == aUniqueID ?
     308               0 :       this : mAccessibleCache.GetWeak(aUniqueID);
     309                 :   }
     310                 : 
     311                 :   /**
     312                 :    * Return the cached accessible by the given unique ID looking through
     313                 :    * this and nested documents.
     314                 :    */
     315                 :   nsAccessible* GetAccessibleByUniqueIDInSubtree(void* aUniqueID);
     316                 : 
     317                 :   /**
     318                 :    * Return an accessible for the given DOM node or container accessible if
     319                 :    * the node is not accessible.
     320                 :    */
     321                 :   nsAccessible* GetAccessibleOrContainer(nsINode* aNode);
     322                 : 
     323                 :   /**
     324                 :    * Return a container accessible for the given DOM node.
     325                 :    */
     326               0 :   inline nsAccessible* GetContainerAccessible(nsINode* aNode)
     327                 :   {
     328               0 :     return aNode ? GetAccessibleOrContainer(aNode->GetNodeParent()) : nsnull;
     329                 :   }
     330                 : 
     331                 :   /**
     332                 :    * Return true if the given ID is referred by relation attribute.
     333                 :    *
     334                 :    * @note Different elements may share the same ID if they are hosted inside
     335                 :    *       XBL bindings. Be careful the result of this method may be  senseless
     336                 :    *       while it's called for XUL elements (where XBL is used widely).
     337                 :    */
     338               0 :   bool IsDependentID(const nsAString& aID) const
     339               0 :     { return mDependentIDsHash.Get(aID, nsnull); }
     340                 : 
     341                 :   /**
     342                 :    * Initialize the newly created accessible and put it into document caches.
     343                 :    *
     344                 :    * @param  aAccessible    [in] created accessible
     345                 :    * @param  aRoleMapEntry  [in] the role map entry role the ARIA role or nsnull
     346                 :    *                          if none
     347                 :    */
     348                 :   bool BindToDocument(nsAccessible* aAccessible, nsRoleMapEntry* aRoleMapEntry);
     349                 : 
     350                 :   /**
     351                 :    * Remove from document and shutdown the given accessible.
     352                 :    */
     353                 :   void UnbindFromDocument(nsAccessible* aAccessible);
     354                 : 
     355                 :   /**
     356                 :    * Notify the document accessible that content was inserted.
     357                 :    */
     358                 :   void ContentInserted(nsIContent* aContainerNode,
     359                 :                        nsIContent* aStartChildNode,
     360                 :                        nsIContent* aEndChildNode);
     361                 : 
     362                 :   /**
     363                 :    * Notify the document accessible that content was removed.
     364                 :    */
     365                 :   void ContentRemoved(nsIContent* aContainerNode, nsIContent* aChildNode);
     366                 : 
     367                 :   /**
     368                 :    * Updates accessible tree when rendered text is changed.
     369                 :    */
     370               0 :   inline void UpdateText(nsIContent* aTextNode)
     371                 :   {
     372               0 :     NS_ASSERTION(mNotificationController, "The document was shut down!");
     373                 : 
     374                 :     // Ignore the notification if initial tree construction hasn't been done yet.
     375               0 :     if (mNotificationController && HasLoadState(eTreeConstructed))
     376               0 :       mNotificationController->ScheduleTextUpdate(aTextNode);
     377               0 :   }
     378                 : 
     379                 :   /**
     380                 :    * Recreate an accessible, results in hide/show events pair.
     381                 :    */
     382                 :   void RecreateAccessible(nsIContent* aContent);
     383                 : 
     384                 : protected:
     385                 : 
     386                 :   void LastRelease();
     387                 : 
     388                 :   // nsAccessible
     389                 :   virtual void CacheChildren();
     390                 : 
     391                 :   // nsDocAccessible
     392                 :     virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
     393                 :     virtual nsresult AddEventListeners();
     394                 :     virtual nsresult RemoveEventListeners();
     395                 : 
     396                 :   /**
     397                 :    * Marks this document as loaded or loading.
     398                 :    */
     399               0 :   inline void NotifyOfLoad(PRUint32 aLoadEventType)
     400                 :   {
     401               0 :     mLoadState |= eDOMLoaded;
     402               0 :     mLoadEventType = aLoadEventType;
     403               0 :   }
     404                 : 
     405                 :   void NotifyOfLoading(bool aIsReloading);
     406                 : 
     407                 :   friend class nsAccDocManager;
     408                 : 
     409                 :   /**
     410                 :    * Perform initial update (create accessible tree).
     411                 :    * Can be overridden by wrappers to prepare initialization work.
     412                 :    */
     413                 :   virtual void DoInitialUpdate();
     414                 : 
     415                 :   /**
     416                 :    * Process document load notification, fire document load and state busy
     417                 :    * events if applicable.
     418                 :    */
     419                 :   void ProcessLoad();
     420                 : 
     421                 :     void AddScrollListener();
     422                 :     void RemoveScrollListener();
     423                 : 
     424                 :   /**
     425                 :    * Append the given document accessible to this document's child document
     426                 :    * accessibles.
     427                 :    */
     428               0 :   bool AppendChildDocument(nsDocAccessible* aChildDocument)
     429                 :   {
     430               0 :     return mChildDocuments.AppendElement(aChildDocument);
     431                 :   }
     432                 : 
     433                 :   /**
     434                 :    * Remove the given document accessible from this document's child document
     435                 :    * accessibles.
     436                 :    */
     437               0 :   void RemoveChildDocument(nsDocAccessible* aChildDocument)
     438                 :   {
     439               0 :     mChildDocuments.RemoveElement(aChildDocument);
     440               0 :   }
     441                 : 
     442                 :   /**
     443                 :    * Add dependent IDs pointed by accessible element by relation attribute to
     444                 :    * cache. If the relation attribute is missed then all relation attributes
     445                 :    * are checked.
     446                 :    *
     447                 :    * @param aRelProvider [in] accessible that element has relation attribute
     448                 :    * @param aRelAttr     [in, optional] relation attribute
     449                 :    */
     450                 :   void AddDependentIDsFor(nsAccessible* aRelProvider,
     451                 :                           nsIAtom* aRelAttr = nsnull);
     452                 : 
     453                 :   /**
     454                 :    * Remove dependent IDs pointed by accessible element by relation attribute
     455                 :    * from cache. If the relation attribute is absent then all relation
     456                 :    * attributes are checked.
     457                 :    *
     458                 :    * @param aRelProvider [in] accessible that element has relation attribute
     459                 :    * @param aRelAttr     [in, optional] relation attribute
     460                 :    */
     461                 :   void RemoveDependentIDsFor(nsAccessible* aRelProvider,
     462                 :                              nsIAtom* aRelAttr = nsnull);
     463                 : 
     464                 :   /**
     465                 :    * Update or recreate an accessible depending on a changed attribute.
     466                 :    *
     467                 :    * @param aElement   [in] the element the attribute was changed on
     468                 :    * @param aAttribute [in] the changed attribute
     469                 :    * @return            true if an action was taken on the attribute change
     470                 :    */
     471                 :   bool UpdateAccessibleOnAttrChange(mozilla::dom::Element* aElement,
     472                 :                                     nsIAtom* aAttribute);
     473                 : 
     474                 :     /**
     475                 :      * Fires accessible events when attribute is changed.
     476                 :      *
     477                 :      * @param aContent - node that attribute is changed for
     478                 :      * @param aNameSpaceID - namespace of changed attribute
     479                 :      * @param aAttribute - changed attribute
     480                 :      */
     481                 :     void AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute);
     482                 : 
     483                 :     /**
     484                 :      * Fires accessible events when ARIA attribute is changed.
     485                 :      *
     486                 :      * @param aContent - node that attribute is changed for
     487                 :      * @param aAttribute - changed attribute
     488                 :      */
     489                 :     void ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute);
     490                 : 
     491                 :   /**
     492                 :    * Process ARIA active-descendant attribute change.
     493                 :    */
     494                 :   void ARIAActiveDescendantChanged(nsIContent* aElm);
     495                 : 
     496                 :   /**
     497                 :    * Process the event when the queue of pending events is untwisted. Fire
     498                 :    * accessible events as result of the processing.
     499                 :    */
     500                 :   void ProcessPendingEvent(AccEvent* aEvent);
     501                 : 
     502                 :   /**
     503                 :    * Update the accessible tree for inserted content.
     504                 :    */
     505                 :   void ProcessContentInserted(nsAccessible* aContainer,
     506                 :                               const nsTArray<nsCOMPtr<nsIContent> >* aInsertedContent);
     507                 : 
     508                 :   /**
     509                 :    * Used to notify the document to make it process the invalidation list.
     510                 :    *
     511                 :    * While children are cached we may encounter the case there's no accessible
     512                 :    * for referred content by related accessible. Store these related nodes to
     513                 :    * invalidate their containers later.
     514                 :    */
     515                 :   void ProcessInvalidationList();
     516                 : 
     517                 :   /**
     518                 :    * Update the accessible tree for content insertion or removal.
     519                 :    */
     520                 :   void UpdateTree(nsAccessible* aContainer, nsIContent* aChildNode,
     521                 :                   bool aIsInsert);
     522                 : 
     523                 :   /**
     524                 :    * Helper for UpdateTree() method. Go down to DOM subtree and updates
     525                 :    * accessible tree. Return one of these flags.
     526                 :    */
     527                 :   enum EUpdateTreeFlags {
     528                 :     eNoAccessible = 0,
     529                 :     eAccessible = 1,
     530                 :     eAlertAccessible = 2
     531                 :   };
     532                 : 
     533                 :   PRUint32 UpdateTreeInternal(nsAccessible* aChild, bool aIsInsert);
     534                 : 
     535                 :   /**
     536                 :    * Create accessible tree.
     537                 :    */
     538                 :   void CacheChildrenInSubtree(nsAccessible* aRoot);
     539                 : 
     540                 :   /**
     541                 :    * Remove accessibles in subtree from node to accessible map.
     542                 :    */
     543                 :   void UncacheChildrenInSubtree(nsAccessible* aRoot);
     544                 : 
     545                 :   /**
     546                 :    * Shutdown any cached accessible in the subtree.
     547                 :    *
     548                 :    * @param aAccessible  [in] the root of the subrtee to invalidate accessible
     549                 :    *                      child/parent refs in
     550                 :    */
     551                 :   void ShutdownChildrenInSubtree(nsAccessible *aAccessible);
     552                 : 
     553                 :   /**
     554                 :    * Return true if accessibility events accompanying document accessible
     555                 :    * loading should be fired.
     556                 :    *
     557                 :    * The rules are: do not fire events for root chrome document accessibles and
     558                 :    * for sub document accessibles (like HTML frame of iframe) of the loading
     559                 :    * document accessible.
     560                 :    *
     561                 :    * XXX: in general AT expect events for document accessible loading into
     562                 :    * tabbrowser, events from other document accessibles may break AT. We need to
     563                 :    * figure out what AT wants to know about loading page (for example, some of
     564                 :    * them have separate processing of iframe documents on the page and therefore
     565                 :    * they need a way to distinguish sub documents from page document). Ideally
     566                 :    * we should make events firing for any loaded document and provide additional
     567                 :    * info AT are needing.
     568                 :    */
     569                 :   bool IsLoadEventTarget() const;
     570                 : 
     571                 :   /**
     572                 :    * Used to fire scrolling end event after page scroll.
     573                 :    *
     574                 :    * @param aTimer    [in] the timer object
     575                 :    * @param aClosure  [in] the document accessible where scrolling happens
     576                 :    */
     577                 :   static void ScrollTimerCallback(nsITimer* aTimer, void* aClosure);
     578                 : 
     579                 : protected:
     580                 : 
     581                 :   /**
     582                 :    * Cache of accessibles within this document accessible.
     583                 :    */
     584                 :   nsAccessibleHashtable mAccessibleCache;
     585                 :   nsDataHashtable<nsPtrHashKey<const nsINode>, nsAccessible*>
     586                 :     mNodeToAccessibleMap;
     587                 : 
     588                 :     nsCOMPtr<nsIDocument> mDocument;
     589                 :     nsCOMPtr<nsITimer> mScrollWatchTimer;
     590                 :     PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
     591                 : 
     592                 :   /**
     593                 :    * Bit mask of document load states (@see LoadState).
     594                 :    */
     595                 :   PRUint32 mLoadState;
     596                 : 
     597                 :   /**
     598                 :    * Type of document load event fired after the document is loaded completely.
     599                 :    */
     600                 :   PRUint32 mLoadEventType;
     601                 : 
     602                 :   /**
     603                 :    * Reference to anchor jump element.
     604                 :    */
     605                 :   nsCOMPtr<nsIContent> mAnchorJumpElm;
     606                 : 
     607                 :   /**
     608                 :    * Keep the ARIA attribute old value that is initialized by
     609                 :    * AttributeWillChange and used by AttributeChanged notifications.
     610                 :    */
     611                 :   nsIAtom* mARIAAttrOldValue;
     612                 : 
     613                 :   nsTArray<nsRefPtr<nsDocAccessible> > mChildDocuments;
     614                 : 
     615                 :   /**
     616                 :    * Whether we support nsIAccessibleCursorable, used when querying the interface.
     617                 :    */
     618                 :   bool mIsCursorable;
     619                 : 
     620                 :   /**
     621                 :    * The virtual cursor of the document when it supports nsIAccessibleCursorable.
     622                 :    */
     623                 :   nsRefPtr<nsAccessiblePivot> mVirtualCursor;
     624                 : 
     625                 :   /**
     626                 :    * A storage class for pairing content with one of its relation attributes.
     627                 :    */
     628                 :   class AttrRelProvider
     629               0 :   {
     630                 :   public:
     631               0 :     AttrRelProvider(nsIAtom* aRelAttr, nsIContent* aContent) :
     632               0 :       mRelAttr(aRelAttr), mContent(aContent) { }
     633                 : 
     634                 :     nsIAtom* mRelAttr;
     635                 :     nsCOMPtr<nsIContent> mContent;
     636                 : 
     637                 :   private:
     638                 :     AttrRelProvider();
     639                 :     AttrRelProvider(const AttrRelProvider&);
     640                 :     AttrRelProvider& operator =(const AttrRelProvider&);
     641                 :   };
     642                 : 
     643                 :   /**
     644                 :    * The cache of IDs pointed by relation attributes.
     645                 :    */
     646                 :   typedef nsTArray<nsAutoPtr<AttrRelProvider> > AttrRelProviderArray;
     647                 :   nsClassHashtable<nsStringHashKey, AttrRelProviderArray> mDependentIDsHash;
     648                 : 
     649                 :   friend class RelatedAccIterator;
     650                 : 
     651                 :   /**
     652                 :    * Used for our caching algorithm. We store the list of nodes that should be
     653                 :    * invalidated.
     654                 :    *
     655                 :    * @see ProcessInvalidationList
     656                 :    */
     657                 :   nsTArray<nsIContent*> mInvalidationList;
     658                 : 
     659                 :   /**
     660                 :    * Used to process notification from core and accessible events.
     661                 :    */
     662                 :   nsRefPtr<NotificationController> mNotificationController;
     663                 :   friend class NotificationController;
     664                 : 
     665                 : private:
     666                 : 
     667                 :   nsIPresShell* mPresShell;
     668                 : };
     669                 : 
     670                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsDocAccessible,
     671                 :                               NS_DOCACCESSIBLE_IMPL_CID)
     672                 : 
     673                 : inline nsDocAccessible*
     674               0 : nsAccessible::AsDoc()
     675                 : {
     676                 :   return mFlags & eDocAccessible ?
     677               0 :     static_cast<nsDocAccessible*>(this) : nsnull;
     678                 : }
     679                 : 
     680                 : #endif

Generated by: LCOV version 1.7