Bug 606924, part5 - rename GetCachedAccessible, r=fer, a=final+
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 28 Jan 2011 12:37:08 +0800
changeset 61461 63586498435058ef012421c3057b09b6f0965f13
parent 61460 103c3d98d560ce2f0d32a2f867e08f63218928fd
child 61462 0b39828124f935852a17dc07d9d8179d6a3e826f
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersfer, final
bugs606924
milestone2.0b11pre
Bug 606924, part5 - rename GetCachedAccessible, r=fer, a=final+
accessible/src/base/NotificationController.cpp
accessible/src/base/nsAccDocManager.cpp
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsAccessible.h
accessible/src/base/nsDocAccessible.cpp
accessible/src/base/nsDocAccessible.h
accessible/src/msaa/nsDocAccessibleWrap.cpp
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -238,17 +238,17 @@ NotificationController::WillRefresh(mozi
   // Bind hanging child documents.
   PRUint32 childDocCount = mHangingChildDocuments.Length();
   for (PRUint32 idx = 0; idx < childDocCount; idx++) {
     nsDocAccessible* childDoc = mHangingChildDocuments[idx];
 
     nsIContent* ownerContent = mDocument->GetDocumentNode()->
       FindContentForSubDocument(childDoc->GetDocumentNode());
     if (ownerContent) {
-      nsAccessible* outerDocAcc = mDocument->GetCachedAccessible(ownerContent);
+      nsAccessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
       if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
         if (mDocument->AppendChildDocument(childDoc)) {
           // Fire reorder event to notify new accessible document has been
           // attached to the tree.
           nsRefPtr<AccEvent> reorderEvent =
               new AccEvent(nsIAccessibleEvent::EVENT_REORDER, outerDocAcc,
                            eAutoDetect, AccEvent::eCoalesceFromSameSubtree);
           if (reorderEvent)
--- a/accessible/src/base/nsAccDocManager.cpp
+++ b/accessible/src/base/nsAccDocManager.cpp
@@ -518,15 +518,15 @@ nsAccDocManager::SearchAccessibleInDocCa
                                             void* aUserArg)
 {
   NS_ASSERTION(aDocAccessible,
                "No doc accessible for the object in doc accessible cache!");
 
   if (aDocAccessible) {
     nsSearchAccessibleInCacheArg* arg =
       static_cast<nsSearchAccessibleInCacheArg*>(aUserArg);
-    arg->mAccessible = aDocAccessible->GetCachedAccessible(arg->mNode);
+    arg->mAccessible = aDocAccessible->GetAccessible(arg->mNode);
     if (arg->mAccessible)
       return PL_DHASH_STOP;
   }
 
   return PL_DHASH_NEXT;
 }
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -779,17 +779,17 @@ nsAccessibilityService::GetAccessibleInS
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessibilityService public
 
 nsAccessible*
 nsAccessibilityService::GetAccessible(nsINode* aNode)
 {
   nsDocAccessible* document = GetDocAccessible(aNode->GetOwnerDoc());
-  return document ? document->GetCachedAccessible(aNode) : nsnull;
+  return document ? document->GetAccessible(aNode) : nsnull;
 }
 
 nsAccessible*
 nsAccessibilityService::GetAccessibleOrContainer(nsINode* aNode,
                                                  nsIWeakReference* aWeakShell)
 {
   if (!aNode || !aNode->IsInDoc())
     return nsnull;
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -3175,17 +3175,17 @@ nsAccessible::CacheChildren()
 {
   nsAccTreeWalker walker(mWeakShell, mContent, GetAllowsAnonChildAccessibles());
 
   nsRefPtr<nsAccessible> child;
   while ((child = walker.GetNextChild()) && AppendChild(child));
 }
 
 void
-nsAccessible::TestChildCache(nsAccessible *aCachedChild)
+nsAccessible::TestChildCache(nsAccessible* aCachedChild) const
 {
 #ifdef DEBUG
   PRInt32 childCount = mChildren.Length();
   if (childCount == 0) {
     NS_ASSERTION(mChildrenFlags == eChildrenUninitialized,
                  "No children but initialized!");
     return;
   }
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -345,17 +345,17 @@ public:
    */
   virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
                                 PRUint32 aLength);
 
   /**
    * Assert if child not in parent's cache if the cache was initialized at this
    * point.
    */
-  void TestChildCache(nsAccessible *aCachedChild);
+  void TestChildCache(nsAccessible* aCachedChild) const;
 
   //////////////////////////////////////////////////////////////////////////////
   // HyperLinkAccessible
 
   /**
    * Return true if the accessible is hyper link accessible.
    */
   virtual bool IsHyperLink();
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -583,28 +583,28 @@ NS_IMETHODIMP nsDocAccessible::GetAssoci
   editor->GetIsDocumentEditable(&isEditable);
   if (isEditable) {
     NS_ADDREF(*aEditor = editor);
   }
   return NS_OK;
 }
 
 // nsDocAccessible public method
-nsAccessible *
-nsDocAccessible::GetCachedAccessible(nsINode *aNode)
+nsAccessible*
+nsDocAccessible::GetAccessible(nsINode* aNode) const
 {
   nsAccessible* accessible = mNodeToAccessibleMap.Get(aNode);
 
   // No accessible in the cache, check if the given ID is unique ID of this
   // document accessible.
   if (!accessible) {
     if (GetNode() != aNode)
       return nsnull;
 
-    accessible = this;
+    accessible = const_cast<nsDocAccessible*>(this);
   }
 
 #ifdef DEBUG
   // All cached accessible nodes should be in the parent
   // It will assert if not all the children were created
   // when they were first cached, and no invalidation
   // ever corrected parent accessible's child cache.
   nsAccessible* parent(accessible->GetCachedParent());
@@ -937,17 +937,17 @@ nsDocAccessible::AttributeWillChange(nsI
   // such as the existence of aria-pressed for button (so we know if we need to
   // newly expose it as a toggle button) etc.
 
   // Update dependent IDs cache. Take care of elements that are accessible
   // because dependent IDs cache doesn't contain IDs from non accessible
   // elements.
   if (aModType == nsIDOMMutationEvent::MODIFICATION ||
       aModType == nsIDOMMutationEvent::REMOVAL) {
-    nsAccessible* accessible = GetCachedAccessible(aElement);
+    nsAccessible* accessible = GetAccessible(aElement);
     if (accessible)
       RemoveDependentIDsFor(accessible, aAttribute);
   }
 }
 
 void
 nsDocAccessible::AttributeChanged(nsIDocument *aDocument,
                                   dom::Element* aElement,
@@ -962,17 +962,17 @@ nsDocAccessible::AttributeChanged(nsIDoc
   if (UpdateAccessibleOnAttrChange(aElement, aAttribute))
     return;
 
   // Ignore attribute change if the element doesn't have an accessible (at all
   // or still) iff the element is not a root content of this document accessible
   // (which is treated as attribute change on this document accessible).
   // Note: we don't bail if all the content hasn't finished loading because
   // these attributes are changing for a loaded part of the content.
-  nsAccessible* accessible = GetCachedAccessible(aElement);
+  nsAccessible* accessible = GetAccessible(aElement);
   if (!accessible && (mContent != aElement))
     return;
 
   // Fire accessible events iff there's an accessible, otherwise we consider
   // the accessible state wasn't changed, i.e. its state is initial state.
   AttributeChangedImpl(aElement, aNameSpaceID, aAttribute);
 
   // Update dependent IDs cache. Take care of accessible elements because no
@@ -1303,26 +1303,26 @@ nsDocAccessible::GetNativeWindow() const
     vm->GetRootWidget(getter_AddRefs(widget));
     if (widget)
       return widget->GetNativeData(NS_NATIVE_WINDOW);
   }
   return nsnull;
 }
 
 nsAccessible*
-nsDocAccessible::GetCachedAccessibleByUniqueIDInSubtree(void* aUniqueID)
+nsDocAccessible::GetAccessibleByUniqueIDInSubtree(void* aUniqueID)
 {
-  nsAccessible* child = GetCachedAccessibleByUniqueID(aUniqueID);
+  nsAccessible* child = GetAccessibleByUniqueID(aUniqueID);
   if (child)
     return child;
 
   PRUint32 childDocCount = mChildDocuments.Length();
   for (PRUint32 childDocIdx= 0; childDocIdx < childDocCount; childDocIdx++) {
     nsDocAccessible* childDocument = mChildDocuments.ElementAt(childDocIdx);
-    child = childDocument->GetCachedAccessibleByUniqueIDInSubtree(aUniqueID);
+    child = childDocument->GetAccessibleByUniqueIDInSubtree(aUniqueID);
     if (child)
       return child;
   }
 
   return nsnull;
 }
 
 bool
@@ -1568,17 +1568,17 @@ nsDocAccessible::AddDependentIDsFor(nsAc
         if (provider) {
           providers->AppendElement(provider);
 
           // We've got here during the children caching. If the referenced
           // content is not accessible then store it to pend its container
           // children invalidation (this happens immediately after the caching
           // is finished).
           nsIContent* dependentContent = iter.GetElem(id);
-          if (dependentContent && !GetCachedAccessible(dependentContent)) {
+          if (dependentContent && !HasAccessible(dependentContent)) {
             mInvalidationList.AppendElement(dependentContent);
           }
         }
       }
     }
 
     // If the relation attribute is given then we don't have anything else to
     // check.
@@ -1835,17 +1835,17 @@ nsDocAccessible::ProcessAnchorJump(nsICo
                              target->GetNode());
 }
 
 void
 nsDocAccessible::ProcessContentInserted(nsAccessible* aContainer,
                                         const nsTArray<nsCOMPtr<nsIContent> >* aInsertedContent)
 {
   // Process the notification if the container accessible is still in tree.
-  if (!GetCachedAccessible(aContainer->GetNode()))
+  if (!HasAccessible(aContainer->GetNode()))
     return;
 
   if (aContainer == this) {
     // If new root content has been inserted then update it.
     nsIContent* rootContent = nsCoreUtils::GetRoleContent(mDocument);
     if (rootContent && rootContent != mContent)
       mContent = rootContent;
 
@@ -1937,17 +1937,17 @@ nsDocAccessible::UpdateTreeInternal(nsAc
        node = node->GetNextSibling()) {
 
     // Tree update triggers for content insertion even if no content was
     // inserted actually, check if the given content has a frame to discard
     // this case early.
     if (aIsInsert && !node->GetPrimaryFrame())
       continue;
 
-    nsAccessible* accessible = GetCachedAccessible(node);
+    nsAccessible* accessible = GetAccessible(node);
 
     if (!accessible) {
       updateFlags |= UpdateTreeInternal(aContainer, node->GetFirstChild(),
                                         nsnull, aIsInsert);
       continue;
     }
 
     updateFlags |= eAccessible;
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -225,36 +225,44 @@ public:
   }
 
   /**
    * 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.
    *
    * @return the accessible object
    */
-  nsAccessible* GetCachedAccessible(nsINode* aNode);
+  nsAccessible* GetAccessible(nsINode* aNode) const;
+
+  /**
+   * Return whether the given DOM node has an accessible or not.
+   */
+  inline bool HasAccessible(nsINode* aNode)
+  {
+    return GetAccessible(aNode);
+  }
 
   /**
    * Return the cached accessible by the given unique ID within this document.
    *
    * @note   the unique ID matches with the uniqueID() of nsAccessNode
    *
    * @param  aUniqueID  [in] the unique ID used to cache the node.
    */
-  nsAccessible* GetCachedAccessibleByUniqueID(void* aUniqueID)
+  inline nsAccessible* GetAccessibleByUniqueID(void* aUniqueID)
   {
     return UniqueID() == aUniqueID ?
       this : mAccessibleCache.GetWeak(aUniqueID);
   }
 
   /**
    * Return the cached accessible by the given unique ID looking through
    * this and nested documents.
    */
-  nsAccessible* GetCachedAccessibleByUniqueIDInSubtree(void* aUniqueID);
+  nsAccessible* GetAccessibleByUniqueIDInSubtree(void* aUniqueID);
 
   /**
    * 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).
    */
--- a/accessible/src/msaa/nsDocAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsDocAccessibleWrap.cpp
@@ -104,17 +104,17 @@ nsDocAccessibleWrap::GetXPAccessibleFor(
 {
   // If lVal negative then it is treated as child ID and we should look for
   // accessible through whole accessible subtree including subdocuments.
   // Otherwise we treat lVal as index in parent.
 
   if (aVarChild.vt == VT_I4 && aVarChild.lVal < 0) {
     // Convert child ID to unique ID.
     void* uniqueID = reinterpret_cast<void*>(-aVarChild.lVal);
-    return GetCachedAccessibleByUniqueIDInSubtree(uniqueID);
+    return GetAccessibleByUniqueIDInSubtree(uniqueID);
   }
 
   return nsAccessibleWrap::GetXPAccessibleFor(aVarChild);
 }
 
 STDMETHODIMP nsDocAccessibleWrap::get_URL(/* [out] */ BSTR __RPC_FAR *aURL)
 {
 __try {