Bug 352105 Fix accessibility EMBEDS relations

r=aaronleventhal
This commit is contained in:
ginn.chen%sun.com 2006-09-15 05:10:58 +00:00
parent 498a2bdfba
commit 7d75ef1d60
4 changed files with 78 additions and 34 deletions

View File

@ -1062,17 +1062,21 @@ refRelationSetCB(AtkObject *aAtkObj)
nsIAccessible::RELATION_DESCRIPTION_FOR,
};
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(relationType); i++) {
if (!atk_relation_set_contains(relation_set, NS_STATIC_CAST(AtkRelationType, relationType[i]))) {
nsIAccessible* accRelated;
nsresult rv = accWrap->GetAccessibleRelated(relationType[i], &accRelated);
if (NS_SUCCEEDED(rv) && accRelated) {
accessible_array[0] = NS_STATIC_CAST(nsAccessibleWrap*, accRelated)->GetAtkObject();
relation = atk_relation_new(accessible_array, 1,
NS_STATIC_CAST(AtkRelationType, relationType[i]));
atk_relation_set_add(relation_set, relation);
}
}
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(relationType); i++) {
relation = atk_relation_set_get_relation_by_type(relation_set, NS_STATIC_CAST(AtkRelationType, relationType[i]));
if (relation) {
atk_relation_set_remove(relation_set, relation);
}
nsIAccessible* accRelated;
nsresult rv = accWrap->GetAccessibleRelated(relationType[i], &accRelated);
if (NS_SUCCEEDED(rv) && accRelated) {
accessible_array[0] = NS_STATIC_CAST(nsAccessibleWrap*, accRelated)->GetAtkObject();
relation = atk_relation_new(accessible_array, 1,
NS_STATIC_CAST(AtkRelationType, relationType[i]));
atk_relation_set_add(relation_set, relation);
g_object_unref(relation);
}
}
return relation_set;

View File

@ -46,6 +46,7 @@
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
#include "nsIDocumentViewer.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
@ -509,14 +510,29 @@ nsAccessNode::GetDocAccessibleFor(nsIWeakReference *aPresShell)
}
already_AddRefed<nsIAccessibleDocument>
nsAccessNode::GetDocAccessibleFor(nsISupports *aContainer)
nsAccessNode::GetDocAccessibleFor(nsISupports *aContainer, PRBool aCanCreate)
{
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
NS_ASSERTION(docShell, "This method currently only supports docshells");
nsCOMPtr<nsIPresShell> presShell;
docShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
return weakShell ? GetDocAccessibleFor(weakShell) : nsnull;
if (!aCanCreate) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
NS_ASSERTION(docShell, "This method currently only supports docshells");
nsCOMPtr<nsIPresShell> presShell;
docShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
return weakShell ? GetDocAccessibleFor(weakShell) : nsnull;
}
nsCOMPtr<nsIDOMNode> node = GetDOMNodeForContainer(aContainer);
if (!node) {
return nsnull;
}
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(node, getter_AddRefs(accessible));
nsIAccessibleDocument *docAccessible = nsnull;
if (accessible) {
CallQueryInterface(accessible, &docAccessible);
}
return docAccessible;
}
already_AddRefed<nsIAccessibleDocument>
@ -565,6 +581,27 @@ nsAccessNode::GetDocShellTreeItemFor(nsIDOMNode *aStartNode)
return docShellTreeItem;
}
already_AddRefed<nsIDOMNode>
nsAccessNode::GetDOMNodeForContainer(nsISupports *aContainer)
{
nsIDOMNode* node = nsnull;
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(aContainer);
nsCOMPtr<nsIContentViewer> cv;
shell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
if (docv) {
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(getter_AddRefs(doc));
if (doc) {
CallQueryInterface(doc.get(), &node);
}
}
}
return node;
}
void nsAccessNode::PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> &aCache,
void* aUniqueID,
nsIAccessNode *aAccessNode)

View File

@ -117,10 +117,11 @@ class nsAccessNode: public nsIAccessNode, public nsPIAccessNode
// Static cache methods for global document cache
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIWeakReference *aPresShell);
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsISupports *aContainer);
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsISupports *aContainer, PRBool aCanCreate = PR_FALSE);
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDOMNode *aNode);
static already_AddRefed<nsIDocShellTreeItem> GetDocShellTreeItemFor(nsIDOMNode *aStartNode);
static already_AddRefed<nsIDOMNode> GetDOMNodeForContainer(nsISupports *aContainer);
static already_AddRefed<nsIPresShell> GetPresShellFor(nsIDOMNode *aStartNode);
// Return PR_TRUE if there is a role attribute

View File

@ -41,7 +41,14 @@
#include "nsCaretAccessible.h"
#include "nsHTMLSelectAccessible.h"
#include "nsIAccessibleCaret.h"
#include "nsIBaseWindow.h"
#include "nsICaret.h"
#include "nsIChromeEventHandler.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
@ -50,7 +57,6 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMNSEvent.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
@ -62,27 +68,18 @@
#include "nsIFrame.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIScrollableView.h"
#include "nsISelectionPrivate.h"
#include "nsIServiceManager.h"
#include "nsIViewManager.h"
#include "nsLayoutAtoms.h"
#include "nsPIDOMWindow.h"
#include "nsReadableUtils.h"
#include "nsRootAccessible.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIBaseWindow.h"
#ifdef MOZ_XUL
#include "nsXULTreeAccessible.h"
#include "nsIXULDocument.h"
#endif
#include "nsAccessibilityService.h"
#include "nsISelectionPrivate.h"
#include "nsICaret.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsAccessibleEventData.h"
#include "nsIDOMDocument.h"
// Expanded version of NS_IMPL_ISUPPORTS_INHERITED2
// so we can QI directly to concrete nsRootAccessible
@ -940,7 +937,8 @@ nsRootAccessible::GetContentDocShell(nsIDocShellTreeItem *aStart)
PRInt32 itemType;
aStart->GetItemType(&itemType);
if (itemType == nsIDocShellTreeItem::typeContent) {
nsCOMPtr<nsIAccessibleDocument> accDoc = GetDocAccessibleFor(aStart);
nsCOMPtr<nsIAccessibleDocument> accDoc =
GetDocAccessibleFor(aStart, PR_TRUE);
nsCOMPtr<nsIAccessible> accessible = do_QueryInterface(accDoc);
// If ancestor chain of accessibles is not completely visible,
// don't use this one. This happens for example if it's inside
@ -988,8 +986,12 @@ NS_IMETHODIMP nsRootAccessible::GetAccessibleRelated(PRUint32 aRelationType,
nsCOMPtr<nsIDocShellTreeItem> contentTreeItem = GetContentDocShell(treeItem);
// there may be no content area, so we need a null check
if (contentTreeItem) {
nsCOMPtr<nsIAccessibleDocument> accDoc = GetDocAccessibleFor(contentTreeItem);
return accDoc->QueryInterface(NS_GET_IID(nsIAccessible), (void**)aRelated);
nsCOMPtr<nsIAccessibleDocument> accDoc =
GetDocAccessibleFor(contentTreeItem, PR_TRUE);
NS_ASSERTION(accDoc, "No EMBEDS document");
if (accDoc) {
accDoc->QueryInterface(NS_GET_IID(nsIAccessible), (void**)aRelated);
}
}
return NS_OK;
}