зеркало из https://github.com/mozilla/pjs.git
Bug 101615. Unique child ID's for accessible event targets. r=jgaunt, sr=vidur
This commit is contained in:
Родитель
2bbdd47a50
Коммит
48d2ac6b1d
|
@ -685,7 +685,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
// ---- Check if area node ----
|
||||
nsCOMPtr<nsIDOMHTMLAreaElement> areaContent(do_QueryInterface(aNode));
|
||||
if (areaContent) // Area elements are implemented in nsHTMLImageAccessible as children of the image
|
||||
return PR_FALSE; // Return, otherwise the image frame looks like an accessible object in the wrong place
|
||||
return NS_ERROR_FAILURE; // Return, otherwise the image frame looks like an accessible object in the wrong place
|
||||
|
||||
// ---- Check if we need outer owning doc ----
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
|
@ -702,13 +702,13 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
|
||||
// ---- If still no nsIContent, return ----
|
||||
if (!content)
|
||||
return PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// ---- Try using frame to get IAccessible ----
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
frame->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
|
|
@ -685,7 +685,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
// ---- Check if area node ----
|
||||
nsCOMPtr<nsIDOMHTMLAreaElement> areaContent(do_QueryInterface(aNode));
|
||||
if (areaContent) // Area elements are implemented in nsHTMLImageAccessible as children of the image
|
||||
return PR_FALSE; // Return, otherwise the image frame looks like an accessible object in the wrong place
|
||||
return NS_ERROR_FAILURE; // Return, otherwise the image frame looks like an accessible object in the wrong place
|
||||
|
||||
// ---- Check if we need outer owning doc ----
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
|
@ -702,13 +702,13 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
|
||||
// ---- If still no nsIContent, return ----
|
||||
if (!content)
|
||||
return PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// ---- Try using frame to get IAccessible ----
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
frame->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
|
|
@ -926,7 +926,6 @@ RootAccessible::RootAccessible(nsIAccessible* aAcc, HWND aWnd):DocAccessible(aAc
|
|||
{
|
||||
|
||||
mListCount = 0;
|
||||
mNextId = -1;
|
||||
mNextPos = 0;
|
||||
|
||||
nsCOMPtr<nsIAccessibleEventReceiver> r(do_QueryInterface(mAccessible));
|
||||
|
@ -947,12 +946,16 @@ RootAccessible::~RootAccessible()
|
|||
|
||||
void RootAccessible::GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible>& aAcc)
|
||||
{
|
||||
aAcc = nsnull;
|
||||
DocAccessible::GetNSAccessibleFor(varChild, aAcc);
|
||||
|
||||
if (aAcc)
|
||||
return;
|
||||
// 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
|
||||
// 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) {
|
||||
|
@ -964,37 +967,37 @@ void RootAccessible::GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible
|
|||
|
||||
NS_IMETHODIMP RootAccessible::HandleEvent(PRUint32 aEvent, nsIAccessible* aAccessible)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// print focus event!!
|
||||
printf("Focus Changed!!!\n");
|
||||
#endif
|
||||
|
||||
// get the id for the accessible
|
||||
PRInt32 id = GetIdFor(aAccessible);
|
||||
|
||||
// notify the window system
|
||||
NotifyWinEvent(aEvent, mWnd, OBJID_CLIENT, id);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 RootAccessible::GetIdFor(nsIAccessible* aAccessible)
|
||||
PRUint32 RootAccessible::GetIdFor(nsIAccessible* aAccessible)
|
||||
{
|
||||
// max of 99999 ids can be generated
|
||||
if (mNextId < -99999)
|
||||
mNextId = -1;
|
||||
|
||||
// A child ID of the window is required, when we use NotifyWinEvent, so that the 3rd party application
|
||||
// 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);
|
||||
|
||||
// Lets make one and add it to the list
|
||||
mList[mNextPos].mId = mNextId;
|
||||
mList[mNextPos].mId = uniqueID;
|
||||
mList[mNextPos].mAccessible = aAccessible;
|
||||
|
||||
mNextId--;
|
||||
if (++mNextPos >= MAX_LIST_SIZE)
|
||||
mNextPos = 0;
|
||||
if (mListCount < MAX_LIST_SIZE)
|
||||
mListCount++;
|
||||
|
||||
return mNextId+1;
|
||||
return uniqueID;
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
// nsIAccessibleEventListener
|
||||
NS_DECL_NSIACCESSIBLEEVENTLISTENER
|
||||
|
||||
virtual PRInt32 GetIdFor(nsIAccessible* aAccessible);
|
||||
virtual PRUint32 GetIdFor(nsIAccessible* aAccessible);
|
||||
virtual void GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible>& aAcc);
|
||||
|
||||
private:
|
||||
|
@ -246,7 +246,6 @@ private:
|
|||
// events fire.
|
||||
nsAccessibleEventMap mList[MAX_LIST_SIZE];
|
||||
PRInt32 mListCount;
|
||||
PRInt32 mNextId;
|
||||
PRInt32 mNextPos;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -142,13 +142,14 @@ STDMETHODIMP SimpleDOMNode::get_nodeInfo(
|
|||
/* [out] */ short __RPC_FAR *aNameSpaceID,
|
||||
/* [out] */ BSTR __RPC_FAR *aNodeValue,
|
||||
/* [out] */ unsigned int __RPC_FAR *aNumChildren,
|
||||
/* [out] */ unsigned int __RPC_FAR *aUniqueID,
|
||||
/* [out] */ unsigned short __RPC_FAR *aNodeType)
|
||||
{
|
||||
*aNodeName = nsnull;
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
GetElementAndContentFor(domElement, content);
|
||||
|
||||
|
||||
PRUint16 nodeType = 0;
|
||||
mDOMNode->GetNodeType(&nodeType);
|
||||
*aNodeType=NS_STATIC_CAST(unsigned short, nodeType);
|
||||
|
@ -165,8 +166,14 @@ STDMETHODIMP SimpleDOMNode::get_nodeInfo(
|
|||
*aNodeValue = ::SysAllocString(nodeValue.get());
|
||||
|
||||
PRInt32 nameSpaceID = 0;
|
||||
if (content)
|
||||
*aUniqueID = 0; // magic value of 0 means we're on the document node.
|
||||
if (content) {
|
||||
content->GetNameSpaceID(nameSpaceID);
|
||||
// This is a unique ID for every content node.
|
||||
// The 3rd party accessibility application can compare this to the childID we return for
|
||||
// events such as focus events, to correlate back to data nodes in their internal object model.
|
||||
content->GetContentID(NS_STATIC_CAST(PRUint32*, aUniqueID));
|
||||
}
|
||||
*aNameSpaceID = NS_STATIC_CAST(short, nameSpaceID);
|
||||
|
||||
*aNumChildren = 0;
|
||||
|
|
|
@ -67,6 +67,7 @@ class SimpleDOMNode : public ISimpleDOMNode
|
|||
/* [out] */ short __RPC_FAR *nameSpaceID,
|
||||
/* [out] */ BSTR __RPC_FAR *nodeValue,
|
||||
/* [out] */ unsigned int __RPC_FAR *numChildren,
|
||||
/* [out] */ unsigned int __RPC_FAR *aUniqueID,
|
||||
/* [out][retval] */ unsigned short __RPC_FAR *nodeType);
|
||||
|
||||
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
|
||||
|
|
|
@ -28,9 +28,10 @@ cpp_quote("//")
|
|||
cpp_quote("// get_nodeInfo(")
|
||||
cpp_quote("// /* [out] */ BSTR *nodeName, // For elements, this is the tag name")
|
||||
cpp_quote("// /* [out] */ short *nameSpaceID,")
|
||||
cpp_quote("// /* [out] */ unsigned short *nodeType,")
|
||||
cpp_quote("// /* [out] */ BSTR *nodeValue, ")
|
||||
cpp_quote("// /* [out] */ unsigned int *numChildren); ")
|
||||
cpp_quote("// /* [out] */ unsigned int *uniqueID; // In Win32 accessible events we generate, the target's childID matches to this")
|
||||
cpp_quote("// /* [out] */ unsigned short *nodeType,")
|
||||
cpp_quote("// ---------------------------------------------------------------------------------------------------=")
|
||||
cpp_quote("// Get the basic information about a node.")
|
||||
cpp_quote("// The namespace ID can be mapped to an URI using nsISimpleDOMDocument::get_nameSpaceURIForID()")
|
||||
|
@ -45,6 +46,15 @@ cpp_quote("// ------------------------------------------------------------------
|
|||
cpp_quote("// Returns 3 arrays - the attribute names and values, and a namespace ID for each")
|
||||
cpp_quote("// If the namespace ID is 0, it's the same namespace as the node's namespace")
|
||||
cpp_quote("//")
|
||||
cpp_quote("// get_attributesForNames(")
|
||||
cpp_quote("// /* [in] */ unsigned short numAttribs,")
|
||||
cpp_quote("// /* [in] */ BSTR *attribNames,")
|
||||
cpp_quote("// /* [in] */ short *nameSpaceID,")
|
||||
cpp_quote("// /* [out] */ BSTR *attribValues);")
|
||||
cpp_quote("// ---------------------------------------------------------------------------------------------------=")
|
||||
cpp_quote("// Takes 2 arrays - the attribute names and namespace IDs, and returns an array of corresponding values")
|
||||
cpp_quote("// If the namespace ID is 0, it's the same namespace as the node's namespace")
|
||||
cpp_quote("//")
|
||||
cpp_quote("// computedStyle( ")
|
||||
cpp_quote("// /* [in] */ unsigned short maxStyleProperties,")
|
||||
cpp_quote("// /* [out] */ unsigned short *numStyleProperties, ")
|
||||
|
@ -89,8 +99,7 @@ const long DISPID_NODE_ATTRIBUTESFORNAMES = -5902;
|
|||
const long DISPID_NODE_COMPSTYLE = -5903;
|
||||
const long DISPID_NODE_COMPSTYLEFORPROPS = -5904;
|
||||
|
||||
[object, uuid(772cf37b-261b-4b5e-87ba-ff629cfcab3a)]
|
||||
|
||||
[object, uuid(0c365a54-70b7-4317-a68f-aad8d3f45da7)]
|
||||
interface ISimpleDOMNode : IUnknown
|
||||
{
|
||||
const unsigned short NODETYPE_ELEMENT = 1;
|
||||
|
@ -111,6 +120,7 @@ interface ISimpleDOMNode : IUnknown
|
|||
[out] short *nameSpaceID,
|
||||
[out] BSTR *nodeValue,
|
||||
[out] unsigned int *numChildren,
|
||||
[out] unsigned int *uniqueID, // In Win32 accessible events we generate, the target's childID matches to this
|
||||
[out, retval] unsigned short *nodeType
|
||||
);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче