From 7cf86d274f9a794308b551128a3c8800a87e0c0c Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Thu, 18 Mar 2010 13:45:10 +0800 Subject: [PATCH] Bug 553005 - add getApplicationAccessible() method to nsIAccesibleRetrival, r=davidb --- accessible/public/nsIAccessibleRetrieval.idl | 7 +++++- .../src/base/nsAccessibilityService.cpp | 13 +++++++++++ accessible/tests/mochitest/common.js | 23 +------------------ 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/accessible/public/nsIAccessibleRetrieval.idl b/accessible/public/nsIAccessibleRetrieval.idl index 0b9d03cbca2..4e13db055b0 100644 --- a/accessible/public/nsIAccessibleRetrieval.idl +++ b/accessible/public/nsIAccessibleRetrieval.idl @@ -56,9 +56,14 @@ interface nsIDOMDOMStringList; * * @status UNDER_REVIEW */ -[scriptable, uuid(5f5a6f98-835d-4771-8bfe-a0c7cdc85fec)] +[scriptable, uuid(3df14f00-7253-4b9c-97c2-b4632090da23)] interface nsIAccessibleRetrieval : nsISupports { + /** + * Return application accessible. + */ + nsIAccessible getApplicationAccessible(); + /** * Return an nsIAccessible for a DOM node in pres shell 0. * Create a new accessible of the appropriate type if necessary, diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 039bf9a4a78..4b9a05b12da 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -960,6 +960,19 @@ nsAccessibilityService::GetCachedAccessNode(nsIDOMNode *aNode, //////////////////////////////////////////////////////////////////////////////// // nsIAccessibleRetrieval +NS_IMETHODIMP +nsAccessibilityService::GetApplicationAccessible(nsIAccessible **aApplicationAccessible) +{ + NS_ENSURE_ARG_POINTER(aApplicationAccessible); + *aApplicationAccessible = nsnull; + + nsRefPtr appAcc = + nsAccessNode::GetApplicationAccessible(); + NS_ENSURE_STATE(appAcc); + + return CallQueryInterface(appAcc, aApplicationAccessible); +} + NS_IMETHODIMP nsAccessibilityService::GetStringRole(PRUint32 aRole, nsAString& aString) { diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index 8e6ff39c658..97f0f619e5a 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -277,28 +277,7 @@ function getRootAccessible(aAccOrElmOrID) */ function getApplicationAccessible() { - var acc = getAccessible(document), parent = null; - while (acc) { - - try { - parent = acc.parent; - } catch (e) { - ok(false, "Can't get a parent for " + prettyName(acc)); - return null; - } - - if (!parent) { - if (acc.role == ROLE_APP_ROOT) - return acc; - - ok(false, "No application accessible!"); - return null; - } - - acc = parent; - } - - return null; + return gAccRetrieval.getApplicationAccessible(); } /**