Bug 952782 - Use nsIDocument instead of nsIDOMDocument in accessible r=tbsaunde, bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 20 Jan 2014 16:52:04 -0500
changeset 164321 92e6323c830f2a5d10b000f604777d312fa23d20
parent 164320 a0fd2401968ce95bd6a879f3620c9660f8b65c07
child 164322 45578475913846d489764c6604c4dab9744a0013
push id38677
push userdzbarsky@gmail.com
push dateMon, 20 Jan 2014 21:52:29 +0000
treeherdermozilla-inbound@92e6323c830f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde, bz
bugs952782
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 952782 - Use nsIDocument instead of nsIDOMDocument in accessible r=tbsaunde, bz
accessible/src/base/nsCoreUtils.cpp
accessible/src/generic/Accessible.cpp
accessible/src/generic/DocAccessible.cpp
accessible/src/generic/RootAccessible.cpp
accessible/src/html/HTMLTableAccessible.cpp
accessible/src/xul/XULTabAccessible.cpp
content/base/src/moz.build
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -5,17 +5,16 @@
 
 #include "nsCoreUtils.h"
 
 #include "nsIAccessibleTypes.h"
 
 #include "nsIBaseWindow.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsRange.h"
 #include "nsIBoxObject.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDocShell.h"
 #include "nsEventListenerManager.h"
 #include "nsIPresShell.h"
@@ -29,16 +28,17 @@
 #include "nsView.h"
 #include "nsGkAtoms.h"
 #include "nsDOMTouchEvent.h"
 
 #include "nsComponentManagerUtils.h"
 
 #include "nsITreeBoxObject.h"
 #include "nsITreeColumns.h"
+#include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsCoreUtils
 ////////////////////////////////////////////////////////////////////////////////
 
 bool
@@ -211,28 +211,26 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsIN
   return aNode;
 }
 
 nsIContent*
 nsCoreUtils::GetRoleContent(nsINode *aNode)
 {
   nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
   if (!content) {
-    nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aNode));
-    if (domDoc) {
+    nsCOMPtr<nsIDocument> doc(do_QueryInterface(aNode));
+    if (doc) {
       nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(aNode));
       if (htmlDoc) {
         nsCOMPtr<nsIDOMHTMLElement> bodyElement;
         htmlDoc->GetBody(getter_AddRefs(bodyElement));
         content = do_QueryInterface(bodyElement);
       }
       else {
-        nsCOMPtr<nsIDOMElement> docElement;
-        domDoc->GetDocumentElement(getter_AddRefs(docElement));
-        content = do_QueryInterface(docElement);
+        return doc->GetDocumentElement();
       }
     }
   }
 
   return content;
 }
 
 bool
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -24,17 +24,16 @@
 #include "RootAccessible.h"
 #include "States.h"
 #include "StyleInfo.h"
 #include "TableAccessible.h"
 #include "TableCellAccessible.h"
 #include "TreeWalker.h"
 
 #include "nsIDOMElement.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMTreeWalker.h"
 #include "nsIDOMXULButtonElement.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMXULLabelElement.h"
@@ -78,16 +77,17 @@
 #endif
 
 #include "mozilla/Assertions.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/unused.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/TreeWalker.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible: nsISupports and cycle collection
 
@@ -3069,35 +3069,36 @@ Accessible::GetSiblingAtOffset(int32_t a
 
 Accessible* 
 Accessible::GetFirstAvailableAccessible(nsINode *aStartNode) const
 {
   Accessible* accessible = mDoc->GetAccessible(aStartNode);
   if (accessible)
     return accessible;
 
-  nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aStartNode->OwnerDoc());
-  NS_ENSURE_TRUE(domDoc, nullptr);
-
-  nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(aStartNode);
-  nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetNode());
-  nsCOMPtr<nsIDOMTreeWalker> walker;
-  domDoc->CreateTreeWalker(rootNode,
-                           nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
-                           nullptr, 1, getter_AddRefs(walker));
+  nsCOMPtr<nsIDocument> doc = aStartNode->OwnerDoc();
+
+  nsCOMPtr<nsINode> currentNode = aStartNode;
+  ErrorResult rv;
+  nsRefPtr<dom::TreeWalker> walker =
+    doc->CreateTreeWalker(*GetNode(),
+                          nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
+                          nullptr, rv);
   NS_ENSURE_TRUE(walker, nullptr);
 
-  walker->SetCurrentNode(currentNode);
+  walker->SetCurrentNode(*currentNode, rv);
+  if (rv.Failed())
+    return nullptr;
+
   while (true) {
-    walker->NextNode(getter_AddRefs(currentNode));
-    if (!currentNode)
+    currentNode = walker->NextNode(rv);
+    if (!currentNode || rv.Failed())
       return nullptr;
 
-    nsCOMPtr<nsINode> node(do_QueryInterface(currentNode));
-    Accessible* accessible = mDoc->GetAccessible(node);
+    Accessible* accessible = mDoc->GetAccessible(currentNode);
     if (accessible)
       return accessible;
   }
 
   return nullptr;
 }
 
 double
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -17,17 +17,16 @@
 
 #include "nsIMutableArray.h"
 #include "nsICommandManager.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIDOMAttr.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMDocumentType.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMXULPopupElement.h"
 #include "nsIEditingSession.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -37,16 +36,17 @@
 #include "nsIServiceManager.h"
 #include "nsViewManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsUnicharUtils.h"
 #include "nsIURI.h"
 #include "nsIWebNavigation.h"
 #include "nsFocusManager.h"
 #include "mozilla/Assertions.h"
+#include "mozilla/dom/DocumentType.h"
 #include "mozilla/dom/Element.h"
 
 #ifdef MOZ_XUL
 #include "nsIXULDocument.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::a11y;
@@ -347,48 +347,49 @@ DocAccessible::GetURL(nsAString& aURL)
   }
   CopyUTF8toUTF16(theURL, aURL);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocAccessible::GetTitle(nsAString& aTitle)
 {
-  nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(mDocumentNode);
-  if (!domDocument) {
+  if (!mDocumentNode) {
     return NS_ERROR_FAILURE;
   }
-  return domDocument->GetTitle(aTitle);
+  nsString title;
+  mDocumentNode->GetTitle(title);
+  aTitle = title;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 DocAccessible::GetMimeType(nsAString& aMimeType)
 {
-  nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(mDocumentNode);
-  if (!domDocument) {
+  if (!mDocumentNode) {
     return NS_ERROR_FAILURE;
   }
-  return domDocument->GetContentType(aMimeType);
+  return mDocumentNode->GetContentType(aMimeType);
 }
 
 NS_IMETHODIMP
 DocAccessible::GetDocType(nsAString& aDocType)
 {
-  nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDocumentNode));
-  nsCOMPtr<nsIDOMDocumentType> docType;
-
 #ifdef MOZ_XUL
   nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocumentNode));
   if (xulDoc) {
     aDocType.AssignLiteral("window"); // doctype not implemented for XUL at time of writing - causes assertion
     return NS_OK;
   } else
 #endif
-  if (domDoc && NS_SUCCEEDED(domDoc->GetDoctype(getter_AddRefs(docType))) && docType) {
-    return docType->GetPublicId(aDocType);
+  if (mDocumentNode) {
+    dom::DocumentType* docType = mDocumentNode->GetDoctype();
+    if (docType) {
+      return docType->GetPublicId(aDocType);
+    }
   }
 
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 DocAccessible::GetNameSpaceURIForID(int16_t aNameSpaceID, nsAString& aNameSpaceURI)
 {
--- a/accessible/src/generic/RootAccessible.cpp
+++ b/accessible/src/generic/RootAccessible.cpp
@@ -79,19 +79,17 @@ RootAccessible::Name(nsString& aName)
   aName.Truncate();
 
   if (mRoleMapEntry) {
     Accessible::Name(aName);
     if (!aName.IsEmpty())
       return eNameOK;
   }
 
-  nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocumentNode);
-  NS_ENSURE_TRUE(document, eNameOK);
-  document->GetTitle(aName);
+  mDocumentNode->GetTitle(aName);
   return eNameOK;
 }
 
 role
 RootAccessible::NativeRole()
 {
   // If it's a <dialog> or <wizard>, use roles::DIALOG instead
   dom::Element* rootElm = mDocumentNode->GetRootElement();
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -15,17 +15,16 @@
 #include "nsTextEquivUtils.h"
 #include "Relation.h"
 #include "Role.h"
 #include "States.h"
 #include "TreeWalker.h"
 
 #include "mozilla/dom/HTMLTableElement.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMRange.h"
 #include "nsISelectionPrivate.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMHTMLCollection.h"
 #include "nsIDocument.h"
 #include "nsIMutableArray.h"
 #include "nsIPersistentProperties2.h"
--- a/accessible/src/xul/XULTabAccessible.cpp
+++ b/accessible/src/xul/XULTabAccessible.cpp
@@ -8,17 +8,16 @@
 #include "nsAccUtils.h"
 #include "Relation.h"
 #include "Role.h"
 #include "States.h"
 
 // NOTE: alphabetically ordered
 #include "nsIAccessibleRelation.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDOMXULRelatedElement.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTabAccessible
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -12,30 +12,32 @@ EXPORTS += [
     'nsAttrValue.h',
     'nsAttrValueInlines.h',
     'nsContentList.h',
     'nsContentListDeclarations.h',
     'nsContentSink.h',
     'nsCrossSiteListenerProxy.h',
     'nsDOMAttributeMap.h',
     'nsFrameMessageManager.h',
+    'nsGenericDOMDataNode.h',
     'nsGkAtomList.h',
     'nsGkAtoms.h',
     'nsImageLoadingContent.h',
     'nsMappedAttributeElement.h',
     'nsNodeInfoManager.h',
     'nsNodeUtils.h',
     'nsPropertyTable.h',
     'nsRange.h',
     'nsSandboxFlags.h',
     'nsScriptLoader.h',
     'nsStubDocumentObserver.h',
     'nsStubMutationObserver.h',
     'nsStyledElement.h',
     'nsTextFragment.h',
+    'nsTraversal.h',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     EXPORTS += [
         'nsDOMDataChannel.h',
         'nsDOMDataChannelDeclarations.h',
     ]
     SOURCES += [