зеркало из https://github.com/mozilla/gecko-dev.git
Bug 106710. Expose anonymous content via accessibility API's. r=jgaunt, sr=waterson
This commit is contained in:
Родитель
72ca9383ae
Коммит
d21aea8332
|
@ -73,6 +73,9 @@ interface nsIAccessible : nsISupports
|
|||
|
||||
nsIDOMNode accGetDOMNode();
|
||||
|
||||
// Used by Accessible implementation to save data and speed up accessibility tree walking
|
||||
[noscript] void CacheOptimizations(in nsIAccessible aParent, in PRInt32 aSiblingIndex, in nsIDOMNodeList aSiblingList);
|
||||
|
||||
// MSAA State flags - used for bitfield. More than 1 allowed.
|
||||
const unsigned long STATE_UNAVAILABLE = 0x00000001; // Disabled, maps to opposite of Java ENABLED, Gnome/ATK SENSITIVE?
|
||||
const unsigned long STATE_SELECTED = 0x00000002;
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsXULFormControlAccessible.h"
|
||||
#include "nsXULTextAccessible.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// IFrame
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -75,7 +76,6 @@
|
|||
|
||||
//--------------------
|
||||
|
||||
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -563,44 +563,6 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// This method finds the content node in the parent document
|
||||
// corresponds to the docshell
|
||||
// This code is copied and pasted from nsEventStateManager.cpp
|
||||
// Is also inefficient - better solution should come along as part of
|
||||
// Bug 85602: "FindContentForDocShell walks entire content tree"
|
||||
// Hopefully there will be a better method soon, with a public interface
|
||||
|
||||
nsIContent*
|
||||
nsAccessibilityService::FindContentForDocShell(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIDocShell* aDocShell)
|
||||
{
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps));
|
||||
if (supps) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
|
||||
if (docShell.get() == aDocShell)
|
||||
return aContent;
|
||||
}
|
||||
|
||||
// walk children content
|
||||
PRInt32 count;
|
||||
aContent->ChildCount(count);
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
nsIContent* foundContent = FindContentForDocShell(aPresShell, child, aDocShell);
|
||||
if (foundContent != nsnull) {
|
||||
return foundContent;
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent)
|
||||
{
|
||||
|
@ -612,9 +574,9 @@ void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell
|
|||
presContext->GetContainer(getter_AddRefs(pcContainer));
|
||||
if (!pcContainer)
|
||||
return;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
|
||||
nsCOMPtr<nsISupports> docShellSupports(do_QueryInterface(pcContainer));
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(pcContainer));
|
||||
if (!treeItem)
|
||||
return;
|
||||
|
||||
|
@ -640,9 +602,10 @@ void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell
|
|||
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
parentDoc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
nsIContent *tempContent;
|
||||
tempContent = FindContentForDocShell(parentPresShell, rootContent, docShell);
|
||||
|
||||
nsCOMPtr<nsIContent> tempContent;
|
||||
parentPresShell->FindContentForShell(docShellSupports, getter_AddRefs(tempContent));
|
||||
|
||||
if (tempContent) {
|
||||
*aOwnerContent = tempContent;
|
||||
*aOwnerShell = parentPresShell;
|
||||
|
@ -663,8 +626,8 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
if (!aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
|
||||
nsCOMPtr<nsIAccessibleProvider> accProv(do_QueryInterface(aNode));
|
||||
if (accProv) {
|
||||
accProv->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
@ -710,8 +673,25 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
nsCOMPtr<nsIPresShell> ownerShell;
|
||||
nsCOMPtr<nsIContent> ownerContent;
|
||||
GetOwnerFor(shell, getter_AddRefs(ownerShell), getter_AddRefs(ownerContent));
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
if (content) {
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
}
|
||||
else {
|
||||
doc->GetRootContent(getter_AddRefs(content));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
CreateRootAccessible(presContext, frame, getter_AddRefs(newAcc));
|
||||
*_retval = newAcc;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ---- If still no nsIContent, return ----
|
||||
|
|
|
@ -71,4 +71,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif /* __nsIccessibilityService_h__ */
|
||||
#endif /* __nsIAccessibilityService_h__ */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -50,6 +50,8 @@
|
|||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIBindingManager.h"
|
||||
|
||||
#define ACCESSIBLE_BUNDLE_URL "chrome://global/locale/accessible.properties"
|
||||
|
||||
|
@ -58,6 +60,8 @@ class nsIDocShell;
|
|||
class nsIFrame;
|
||||
class nsIWebShell;
|
||||
|
||||
enum { eSiblingsUninitialized = -1, eSiblingsWalkNormalDOM = -2}; // Used in sibling index field as flags
|
||||
|
||||
class nsAccessible : public nsGenericAccessible
|
||||
{
|
||||
public:
|
||||
|
@ -84,7 +88,6 @@ public:
|
|||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
|
||||
|
||||
// Helper Routines for Sub-Docs
|
||||
static nsresult GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
|
||||
static nsresult GetDocShellObjects(nsIDocShell* aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIPresContext** aPresContext,
|
||||
|
@ -122,11 +125,15 @@ protected:
|
|||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendStringWithSpaces(nsAWritableString *aFlatString, nsAReadableString& textEquivalent);
|
||||
NS_IMETHOD GetFocusedElement(nsIDOMElement **aFocusedElement);
|
||||
NS_IMETHOD CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList);
|
||||
|
||||
// Data Members
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIFocusController> mFocusController;
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIDOMNodeList> mSiblingList; // If some of our computed siblings are anonymous content nodes, cache node list
|
||||
PRInt32 mSiblingIndex; // Cache where we are in list of kids that we got from nsIBindingManager::GetContentList(parentContent)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -237,4 +237,7 @@ NS_IMETHODIMP nsGenericAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsGenericAccessible::CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsIWebProgress.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
|
@ -496,7 +497,7 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetURL(nsAWritableString& aURL)
|
|||
NS_ASSERTION(presShell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsAccessible::GetDocShellFromPS(presShell, getter_AddRefs(docShell));
|
||||
GetDocShellFromPS(presShell, getter_AddRefs(docShell));
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(docShell));
|
||||
nsXPIDLCString theURL;
|
||||
|
@ -565,3 +566,21 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell)
|
||||
{
|
||||
*aDocShell = nsnull;
|
||||
if (aPresShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
aPresShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptObj;
|
||||
doc->GetScriptGlobalObject(getter_AddRefs(scriptObj));
|
||||
if (scriptObj) {
|
||||
scriptObj->GetDocShell(aDocShell);
|
||||
if (*aDocShell)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -59,10 +59,11 @@ class nsDocAccessibleMixin
|
|||
nsDocAccessibleMixin(nsIDocument *doc);
|
||||
nsDocAccessibleMixin(nsIWeakReference *aShell);
|
||||
virtual ~nsDocAccessibleMixin();
|
||||
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
|
||||
PRBool mTopLevelDocument;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
|
|
@ -40,16 +40,9 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameRootAccessible)
|
||||
|
@ -162,9 +155,8 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
|||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsRootAccessible(aShell)
|
||||
mOuterNode(aNode), nsRootAccessible(aShell)
|
||||
{
|
||||
mRealDOMNode = aNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
@ -174,113 +166,42 @@ nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
|||
{
|
||||
}
|
||||
|
||||
nsHTMLIFrameRootAccessible::Init()
|
||||
{
|
||||
if (!mOuterAccessible) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mOuterNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> parentShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(parentShell));
|
||||
if (parentShell) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mOuterNode));
|
||||
nsIFrame* frame = nsnull;
|
||||
parentShell->GetPrimaryFrameFor(content, &frame);
|
||||
NS_ASSERTION(frame, "No outer frame.");
|
||||
frame->GetAccessible(getter_AddRefs(mOuterAccessible));
|
||||
NS_ASSERTION(mOuterAccessible, "Something's wrong - there's no accessible for the outer parent of this frame.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccParent(nsIAccessible * *_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccParent(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccParent(_retval);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccNextSibling (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccNextSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccNextSibling(_retval);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccPreviousSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccPreviousSibling(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible** aAcc)
|
||||
{
|
||||
// Start by finding our PresShell and from that
|
||||
// we get our nsIDocShell in order to walk the DocShell tree
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
if (!presShell) {
|
||||
*aAcc = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
|
||||
// Now that we have the DocShell QI
|
||||
// it to a tree item to find it's parent
|
||||
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
|
||||
if (item) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> itemParent;
|
||||
item->GetParent(getter_AddRefs(itemParent));
|
||||
// QI to get the WebShell for the parent document
|
||||
nsCOMPtr<nsIDocShell> parentDocShell(do_QueryInterface(itemParent));
|
||||
if (parentDocShell) {
|
||||
// Get the PresShell/Content and
|
||||
// Root Content Node of the parent document
|
||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
||||
nsCOMPtr<nsIPresContext> parentPresContext;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
if (NS_SUCCEEDED(GetDocShellObjects(parentDocShell,
|
||||
getter_AddRefs(parentPresShell),
|
||||
getter_AddRefs(parentPresContext),
|
||||
getter_AddRefs(rootContent)))) {
|
||||
// QI the DocShell (of this sub-doc) to a webshell
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
|
||||
if (webShell && parentPresShell && parentPresContext && rootContent) {
|
||||
// Now, find the Content in the parent document
|
||||
// that represents this sub-doc,
|
||||
// we do that matching webshells
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (FindContentForWebShell(parentPresShell,
|
||||
rootContent,
|
||||
webShell,
|
||||
getter_AddRefs(content))) {
|
||||
// OK, we found the content node in the parent doc
|
||||
// that corresponds to this sub-doc
|
||||
// Get the frame for that content
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(parentPresShell);
|
||||
nsIFrame* frame = nsnull;
|
||||
parentPresShell->GetPrimaryFrameFor(content, &frame);
|
||||
#ifdef NS_DEBUG_X
|
||||
printf("** Found: Con:%p Fr:%p", content, frame);
|
||||
char * name;
|
||||
if (GetNameForFrame(frame, &name)) {
|
||||
printf(" Name:[%s]", name);
|
||||
nsMemory::Free(name);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
|
||||
|
||||
*aAcc = acc;
|
||||
NS_IF_ADDREF(*aAcc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,14 @@ class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
|||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
Init();
|
||||
|
||||
// In these variable names, "outer" relates to the nsHTMLIFrameAccessible, as opposed to the
|
||||
// nsHTMLIFrameRootAccessible which is "inner".
|
||||
// The outer node is a <browser> or <iframe> tag, whereas the inner node corresponds to the inner document root.
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mOuterNode;
|
||||
nsCOMPtr<nsIAccessible> mOuterAccessible;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsXULFormControlAccessible.h"
|
||||
#include "nsXULTextAccessible.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// IFrame
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -75,7 +76,6 @@
|
|||
|
||||
//--------------------
|
||||
|
||||
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -563,44 +563,6 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// This method finds the content node in the parent document
|
||||
// corresponds to the docshell
|
||||
// This code is copied and pasted from nsEventStateManager.cpp
|
||||
// Is also inefficient - better solution should come along as part of
|
||||
// Bug 85602: "FindContentForDocShell walks entire content tree"
|
||||
// Hopefully there will be a better method soon, with a public interface
|
||||
|
||||
nsIContent*
|
||||
nsAccessibilityService::FindContentForDocShell(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIDocShell* aDocShell)
|
||||
{
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps));
|
||||
if (supps) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
|
||||
if (docShell.get() == aDocShell)
|
||||
return aContent;
|
||||
}
|
||||
|
||||
// walk children content
|
||||
PRInt32 count;
|
||||
aContent->ChildCount(count);
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
nsIContent* foundContent = FindContentForDocShell(aPresShell, child, aDocShell);
|
||||
if (foundContent != nsnull) {
|
||||
return foundContent;
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent)
|
||||
{
|
||||
|
@ -612,9 +574,9 @@ void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell
|
|||
presContext->GetContainer(getter_AddRefs(pcContainer));
|
||||
if (!pcContainer)
|
||||
return;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
|
||||
nsCOMPtr<nsISupports> docShellSupports(do_QueryInterface(pcContainer));
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(pcContainer));
|
||||
if (!treeItem)
|
||||
return;
|
||||
|
||||
|
@ -640,9 +602,10 @@ void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell
|
|||
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
parentDoc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
nsIContent *tempContent;
|
||||
tempContent = FindContentForDocShell(parentPresShell, rootContent, docShell);
|
||||
|
||||
nsCOMPtr<nsIContent> tempContent;
|
||||
parentPresShell->FindContentForShell(docShellSupports, getter_AddRefs(tempContent));
|
||||
|
||||
if (tempContent) {
|
||||
*aOwnerContent = tempContent;
|
||||
*aOwnerShell = parentPresShell;
|
||||
|
@ -663,8 +626,8 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
if (!aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
|
||||
nsCOMPtr<nsIAccessibleProvider> accProv(do_QueryInterface(aNode));
|
||||
if (accProv) {
|
||||
accProv->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
@ -710,8 +673,25 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
nsCOMPtr<nsIPresShell> ownerShell;
|
||||
nsCOMPtr<nsIContent> ownerContent;
|
||||
GetOwnerFor(shell, getter_AddRefs(ownerShell), getter_AddRefs(ownerContent));
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
if (content) {
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
}
|
||||
else {
|
||||
doc->GetRootContent(getter_AddRefs(content));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
CreateRootAccessible(presContext, frame, getter_AddRefs(newAcc));
|
||||
*_retval = newAcc;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ---- If still no nsIContent, return ----
|
||||
|
|
|
@ -71,4 +71,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif /* __nsIccessibilityService_h__ */
|
||||
#endif /* __nsIAccessibilityService_h__ */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -50,6 +50,8 @@
|
|||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIBindingManager.h"
|
||||
|
||||
#define ACCESSIBLE_BUNDLE_URL "chrome://global/locale/accessible.properties"
|
||||
|
||||
|
@ -58,6 +60,8 @@ class nsIDocShell;
|
|||
class nsIFrame;
|
||||
class nsIWebShell;
|
||||
|
||||
enum { eSiblingsUninitialized = -1, eSiblingsWalkNormalDOM = -2}; // Used in sibling index field as flags
|
||||
|
||||
class nsAccessible : public nsGenericAccessible
|
||||
{
|
||||
public:
|
||||
|
@ -84,7 +88,6 @@ public:
|
|||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
|
||||
|
||||
// Helper Routines for Sub-Docs
|
||||
static nsresult GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
|
||||
static nsresult GetDocShellObjects(nsIDocShell* aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIPresContext** aPresContext,
|
||||
|
@ -122,11 +125,15 @@ protected:
|
|||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendStringWithSpaces(nsAWritableString *aFlatString, nsAReadableString& textEquivalent);
|
||||
NS_IMETHOD GetFocusedElement(nsIDOMElement **aFocusedElement);
|
||||
NS_IMETHOD CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList);
|
||||
|
||||
// Data Members
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIFocusController> mFocusController;
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIDOMNodeList> mSiblingList; // If some of our computed siblings are anonymous content nodes, cache node list
|
||||
PRInt32 mSiblingIndex; // Cache where we are in list of kids that we got from nsIBindingManager::GetContentList(parentContent)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -237,4 +237,7 @@ NS_IMETHODIMP nsGenericAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsGenericAccessible::CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -40,16 +40,9 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameRootAccessible)
|
||||
|
@ -162,9 +155,8 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
|||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsRootAccessible(aShell)
|
||||
mOuterNode(aNode), nsRootAccessible(aShell)
|
||||
{
|
||||
mRealDOMNode = aNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
@ -174,113 +166,42 @@ nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
|||
{
|
||||
}
|
||||
|
||||
nsHTMLIFrameRootAccessible::Init()
|
||||
{
|
||||
if (!mOuterAccessible) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mOuterNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> parentShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(parentShell));
|
||||
if (parentShell) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mOuterNode));
|
||||
nsIFrame* frame = nsnull;
|
||||
parentShell->GetPrimaryFrameFor(content, &frame);
|
||||
NS_ASSERTION(frame, "No outer frame.");
|
||||
frame->GetAccessible(getter_AddRefs(mOuterAccessible));
|
||||
NS_ASSERTION(mOuterAccessible, "Something's wrong - there's no accessible for the outer parent of this frame.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccParent(nsIAccessible * *_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccParent(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccParent(_retval);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccNextSibling (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccNextSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccNextSibling(_retval);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
|
||||
return accessible->GetAccPreviousSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
Init();
|
||||
return mOuterAccessible->GetAccPreviousSibling(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible** aAcc)
|
||||
{
|
||||
// Start by finding our PresShell and from that
|
||||
// we get our nsIDocShell in order to walk the DocShell tree
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
if (!presShell) {
|
||||
*aAcc = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
|
||||
// Now that we have the DocShell QI
|
||||
// it to a tree item to find it's parent
|
||||
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
|
||||
if (item) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> itemParent;
|
||||
item->GetParent(getter_AddRefs(itemParent));
|
||||
// QI to get the WebShell for the parent document
|
||||
nsCOMPtr<nsIDocShell> parentDocShell(do_QueryInterface(itemParent));
|
||||
if (parentDocShell) {
|
||||
// Get the PresShell/Content and
|
||||
// Root Content Node of the parent document
|
||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
||||
nsCOMPtr<nsIPresContext> parentPresContext;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
if (NS_SUCCEEDED(GetDocShellObjects(parentDocShell,
|
||||
getter_AddRefs(parentPresShell),
|
||||
getter_AddRefs(parentPresContext),
|
||||
getter_AddRefs(rootContent)))) {
|
||||
// QI the DocShell (of this sub-doc) to a webshell
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
|
||||
if (webShell && parentPresShell && parentPresContext && rootContent) {
|
||||
// Now, find the Content in the parent document
|
||||
// that represents this sub-doc,
|
||||
// we do that matching webshells
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (FindContentForWebShell(parentPresShell,
|
||||
rootContent,
|
||||
webShell,
|
||||
getter_AddRefs(content))) {
|
||||
// OK, we found the content node in the parent doc
|
||||
// that corresponds to this sub-doc
|
||||
// Get the frame for that content
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(parentPresShell);
|
||||
nsIFrame* frame = nsnull;
|
||||
parentPresShell->GetPrimaryFrameFor(content, &frame);
|
||||
#ifdef NS_DEBUG_X
|
||||
printf("** Found: Con:%p Fr:%p", content, frame);
|
||||
char * name;
|
||||
if (GetNameForFrame(frame, &name)) {
|
||||
printf(" Name:[%s]", name);
|
||||
nsMemory::Free(name);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
|
||||
|
||||
*aAcc = acc;
|
||||
NS_IF_ADDREF(*aAcc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,14 @@ class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
|||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
Init();
|
||||
|
||||
// In these variable names, "outer" relates to the nsHTMLIFrameAccessible, as opposed to the
|
||||
// nsHTMLIFrameRootAccessible which is "inner".
|
||||
// The outer node is a <browser> or <iframe> tag, whereas the inner node corresponds to the inner document root.
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mOuterNode;
|
||||
nsCOMPtr<nsIAccessible> mOuterAccessible;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsIWebProgress.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
|
@ -496,7 +497,7 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetURL(nsAWritableString& aURL)
|
|||
NS_ASSERTION(presShell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsAccessible::GetDocShellFromPS(presShell, getter_AddRefs(docShell));
|
||||
GetDocShellFromPS(presShell, getter_AddRefs(docShell));
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(docShell));
|
||||
nsXPIDLCString theURL;
|
||||
|
@ -565,3 +566,21 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell)
|
||||
{
|
||||
*aDocShell = nsnull;
|
||||
if (aPresShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
aPresShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptObj;
|
||||
doc->GetScriptGlobalObject(getter_AddRefs(scriptObj));
|
||||
if (scriptObj) {
|
||||
scriptObj->GetDocShell(aDocShell);
|
||||
if (*aDocShell)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -59,10 +59,11 @@ class nsDocAccessibleMixin
|
|||
nsDocAccessibleMixin(nsIDocument *doc);
|
||||
nsDocAccessibleMixin(nsIWeakReference *aShell);
|
||||
virtual ~nsDocAccessibleMixin();
|
||||
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
|
||||
PRBool mTopLevelDocument;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
|
|
@ -961,23 +961,20 @@ RootAccessible::~RootAccessible()
|
|||
|
||||
void RootAccessible::GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible>& aAcc)
|
||||
{
|
||||
// If the child ID given == 0 (CHILDID_SELF), they are asking for the root accessible object
|
||||
// If the child ID given < NS_CONTENT_ID_COUNTER_BASE, then they are navigating to the children
|
||||
// immediately below the root accessible (pane) object
|
||||
if (varChild.lVal < NS_CONTENT_ID_COUNTER_BASE) {
|
||||
Accessible::GetNSAccessibleFor(varChild, aAcc);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise fall through and check our circular array of event information, because the child ID
|
||||
// Check our circular array of event information, because the child ID
|
||||
// asked for corresponds to an event target. See RootAccessible::HandleEvent to see how we provide this unique ID.
|
||||
for (int i=0; i < mListCount; i++)
|
||||
{
|
||||
if (varChild.lVal == mList[i].mId) {
|
||||
|
||||
aAcc = nsnull;
|
||||
if (varChild.lVal < 0) {
|
||||
for (int i=0; i < mListCount; i++) {
|
||||
if (varChild.lVal == mList[i].mId) {
|
||||
aAcc = mList[i].mAccessible;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Accessible::GetNSAccessibleFor(varChild, aAcc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RootAccessible::HandleEvent(PRUint32 aEvent, nsIAccessible* aAccessible)
|
||||
|
@ -997,14 +994,10 @@ PRUint32 RootAccessible::GetIdFor(nsIAccessible* aAccessible)
|
|||
// can call back and get the IAccessible the event occured on.
|
||||
// We use the unique ID exposed through nsIContent::GetContentID()
|
||||
|
||||
PRUint32 uniqueID = 0; // magic value of 0 means we're on the document itself
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
aAccessible->AccGetDOMNode(getter_AddRefs(domNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(domNode));
|
||||
if (content)
|
||||
content->GetContentID(&uniqueID);
|
||||
PRUint32 uniqueID = - NS_REINTERPRET_CAST(PRUint32, (domNode.get()));
|
||||
|
||||
// Lets make one and add it to the list
|
||||
mList[mNextPos].mId = uniqueID;
|
||||
mList[mNextPos].mAccessible = aAccessible;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче