From a493925bc572e02e30ba6606fe434afc8b08e0e1 Mon Sep 17 00:00:00 2001 From: "simford.dong%sun.com" Date: Mon, 21 Jul 2003 06:08:11 +0000 Subject: [PATCH] Bug 212104 Browser just exits when find finds a link while running with gtk 2.2 and atk libraries on AIX, r=kyle, sr=henry. GTK2 bug, not included in default build. --- accessible/src/atk/nsAccessibleHyperText.cpp | 14 ++++++++++---- accessible/src/atk/nsDocAccessibleWrap.cpp | 7 +++++++ accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp | 2 +- accessible/src/base/nsAccessible.cpp | 11 ++++++----- accessible/src/base/nsAccessible.h | 2 +- accessible/src/xul/nsXULFormControlAccessible.cpp | 2 +- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/accessible/src/atk/nsAccessibleHyperText.cpp b/accessible/src/atk/nsAccessibleHyperText.cpp index d9ad9493bfc..7bb13959704 100644 --- a/accessible/src/atk/nsAccessibleHyperText.cpp +++ b/accessible/src/atk/nsAccessibleHyperText.cpp @@ -444,11 +444,17 @@ NS_IMETHODIMP nsAccessibleHyperText::GetSelectedLinkIndex(PRInt32 *aSelectedLink { *aSelectedLinkIndex = -1; - nsCOMPtr focusedNode; - NS_REINTERPRET_CAST(nsAccessible*, this)->GetFocusedNode(getter_AddRefs(focusedNode)); - - PRUint32 index, count, linkCount = 0; + PRUint32 count; mTextChildren->Count(&count); + if (count <= 0) + return NS_ERROR_FAILURE; + + nsCOMPtr curNode(do_QueryInterface(mTextChildren->ElementAt(0))); + + nsCOMPtr focusedNode; + nsAccessible::GetFocusedNode(curNode, getter_AddRefs(focusedNode)); + + PRUint32 index, linkCount = 0; for (index = 0; index < count; index++) { nsCOMPtr domNode(do_QueryInterface(mTextChildren->ElementAt(index))); nsCOMPtr parentNode; diff --git a/accessible/src/atk/nsDocAccessibleWrap.cpp b/accessible/src/atk/nsDocAccessibleWrap.cpp index ecf765d23e0..7f9b0d0faae 100644 --- a/accessible/src/atk/nsDocAccessibleWrap.cpp +++ b/accessible/src/atk/nsDocAccessibleWrap.cpp @@ -337,6 +337,13 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireToolkitEvent(PRUint32 aEvent, rv = NS_OK; break; + case nsIAccessibleEventReceiver::EVENT_ATK_LINK_SELECTED: + MAI_LOG_DEBUG(("\n\nReceived: EVENT_ATK_LINK_SELECTED\n")); + g_signal_emit_by_name(accWrap->GetAtkObject(), + "link_selected"); + rv = NS_OK; + break; + // Is a superclass of ATK event children_changed case nsIAccessibleEventReceiver::EVENT_REORDER: AtkChildrenChange *pAtkChildrenChange; diff --git a/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp b/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp index 6b6dc690194..cd229bfd1bf 100644 --- a/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp +++ b/accessible/src/atk/nsHTMLLinkAccessibleWrap.cpp @@ -117,7 +117,7 @@ NS_IMETHODIMP nsHTMLLinkAccessibleWrap::IsValid(PRBool *aIsValid) NS_IMETHODIMP nsHTMLLinkAccessibleWrap::IsSelected(PRBool *aIsSelected) { nsCOMPtr focusedNode; - GetFocusedNode(getter_AddRefs(focusedNode)); + GetFocusedNode(mDOMNode, getter_AddRefs(focusedNode)); *aIsSelected = (focusedNode == mDOMNode); return NS_OK; } diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 4aa7db0621e..d551f7090d8 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -499,16 +499,16 @@ PRBool nsAccessible::IsPartiallyVisible(PRBool *aIsOffscreen) return PR_FALSE; } -NS_IMETHODIMP nsAccessible::GetFocusedNode(nsIDOMNode **aFocusedNode) +nsresult nsAccessible::GetFocusedNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aFocusedNode) { nsCOMPtr focusController; nsCOMPtr document; - nsCOMPtr content(do_QueryInterface(mDOMNode)); + nsCOMPtr content(do_QueryInterface(aCurrentNode)); if (content) content->GetDocument(getter_AddRefs(document)); if (!document) - document = do_QueryInterface(mDOMNode); + document = do_QueryInterface(aCurrentNode); if (document) { nsCOMPtr ourGlobal; document->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); @@ -561,7 +561,7 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState) else { *aAccState |= STATE_FOCUSABLE; nsCOMPtr focusedNode; - if (NS_SUCCEEDED(GetFocusedNode(getter_AddRefs(focusedNode))) && focusedNode == mDOMNode) + if (NS_SUCCEEDED(GetFocusedNode(mDOMNode, getter_AddRefs(focusedNode))) && focusedNode == mDOMNode) *aAccState |= STATE_FOCUSED; } } @@ -585,7 +585,8 @@ NS_IMETHODIMP nsAccessible::GetAccFocused(nsIAccessible **aAccFocused) nsCOMPtr accService(do_GetService("@mozilla.org/accessibilityService;1")); nsCOMPtr focusedNode; - if (accService && NS_SUCCEEDED(GetFocusedNode(getter_AddRefs(focusedNode)))) { + if (accService && + NS_SUCCEEDED(GetFocusedNode(mDOMNode, getter_AddRefs(focusedNode)))) { nsCOMPtr accessible; if (NS_SUCCEEDED(accService->GetAccessibleInWeakShell(focusedNode, mWeakShell, diff --git a/accessible/src/base/nsAccessible.h b/accessible/src/base/nsAccessible.h index 6b1e083637f..79b75657667 100644 --- a/accessible/src/base/nsAccessible.h +++ b/accessible/src/base/nsAccessible.h @@ -73,7 +73,7 @@ public: NS_DECL_NSIACCESSIBLE NS_DECL_NSPIACCESSIBLE - NS_IMETHOD GetFocusedNode(nsIDOMNode **aFocusedNode); + static nsresult GetFocusedNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aFocusedNode); // nsIAccessNode NS_IMETHOD Shutdown(); diff --git a/accessible/src/xul/nsXULFormControlAccessible.cpp b/accessible/src/xul/nsXULFormControlAccessible.cpp index 1e41bab575b..8300492d209 100644 --- a/accessible/src/xul/nsXULFormControlAccessible.cpp +++ b/accessible/src/xul/nsXULFormControlAccessible.cpp @@ -499,7 +499,7 @@ NS_IMETHODIMP nsXULRadioButtonAccessible::GetAccState(PRUint32 *_retval) mDOMNode->GetParentNode(getter_AddRefs(parentNode)); if (parentNode) { nsCOMPtr focusedNode; - GetFocusedNode(getter_AddRefs(focusedNode)); + GetFocusedNode(mDOMNode, getter_AddRefs(focusedNode)); if (focusedNode == parentNode) *_retval |= STATE_FOCUSED; }