Bug 631026 - do no implement nsHyperText for XUL documents, r=surkov, a=davidb
authorFernando Herrera <fherrera@onirica.com>
Tue, 15 Feb 2011 10:44:15 +0800
changeset 62541 9ea616f391af2d51a7cb24818f3b4a86cffe6f81
parent 62540 7d54028aae4bc1fac2e8f06091cee678560408cf
child 62542 0a7448775fa0c2168bec4b9cefed8f91e74f93a2
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewerssurkov, davidb
bugs631026
milestone2.0b12pre
Bug 631026 - do no implement nsHyperText for XUL documents, r=surkov, a=davidb
accessible/src/atk/nsAccessibleWrap.cpp
accessible/src/base/nsDocAccessible.cpp
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -454,20 +454,17 @@ nsAccessibleWrap::CreateMaiInterfaces(vo
 
     // HyperLinkAccessible
     if (IsHyperLink()) {
        interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
     }
 
     if (!nsAccUtils::MustPrune(this)) {  // These interfaces require children
       //nsIAccessibleHypertext
-      nsCOMPtr<nsIAccessibleHyperText> accessInterfaceHypertext;
-      QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
-                     getter_AddRefs(accessInterfaceHypertext));
-      if (accessInterfaceHypertext) {
+      if (IsHyperText()) {
           interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
       }
 
       //nsIAccessibleTable
       nsCOMPtr<nsIAccessibleTable> accessInterfaceTable;
       QueryInterface(NS_GET_IID(nsIAccessibleTable),
                      getter_AddRefs(accessInterfaceTable));
       if (accessInterfaceTable) {
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -108,16 +108,20 @@ nsDocAccessible::
   mDocument(aDocument), mScrollPositionChangedTicks(0), mIsLoaded(PR_FALSE),
   mCacheRoot(nsnull), mIsPostCacheProcessing(PR_FALSE)
 {
   mDependentIDsHash.Init();
   // XXX aaronl should we use an algorithm for the initial cache size?
   mAccessibleCache.Init(kDefaultCacheSize);
   mNodeToAccessibleMap.Init(kDefaultCacheSize);
 
+  // If this is a XUL Document, it should not implement nsHyperText
+  if (mDocument && mDocument->IsXUL())
+    mFlags &= ~eHyperTextAccessible;
+
   // For GTK+ native window, we do nothing here.
   if (!mDocument)
     return;
 
   // nsAccDocManager creates document accessible when scrollable frame is
   // available already, it should be safe time to add scroll listener.
   AddScrollListener();
 }
@@ -165,21 +169,20 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
 
   nsresult status;
   if (!foundInterface) {
     // HTML document accessible must inherit from nsHyperTextAccessible to get
     // support text interfaces. XUL document accessible doesn't need this.
     // However at some point we may push <body> to implement the interfaces and
     // return nsDocAccessible to inherit from nsAccessibleWrap.
 
-    if (mDocument && mDocument->IsXUL())
-      status = nsAccessible::QueryInterface(aIID, (void**)&foundInterface);
-    else
-      status = nsHyperTextAccessible::QueryInterface(aIID,
-                                                     (void**)&foundInterface);
+    status = IsHyperText() ? 
+      nsHyperTextAccessible::QueryInterface(aIID,
+                                            (void**)&foundInterface) :
+      nsAccessible::QueryInterface(aIID, (void**)&foundInterface);
   } else {
     NS_ADDREF(foundInterface);
     status = NS_OK;
   }
 
   *aInstancePtr = foundInterface;
   return status;
 }