diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 07e458f5b13..a8abbecf806 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -399,6 +399,9 @@ void nsRootAccessible::TryFireEarlyLoadEvent(nsIAccessible *aAccessible, nsIDOMN GetDocAccessibleFor(rootContentTreeItem); nsCOMPtr rootContentAccessible = do_QueryInterface(rootContentDocAccessible); + if (!rootContentAccessible) { + return; + } PRUint32 state; rootContentAccessible->GetFinalState(&state); if (state & STATE_BUSY) { diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index 6497eb4210a..c593816f731 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -170,10 +170,11 @@ NS_IMETHODIMP nsHTMLButtonAccessible::DoAction(PRUint8 index) NS_IMETHODIMP nsHTMLButtonAccessible::GetState(PRUint32 *_retval) { - nsFormControlAccessible::GetState(_retval); nsCOMPtr element(do_QueryInterface(mDOMNode)); - NS_ASSERTION(element, "No nsIDOMElement for button node!"); - + if (!element) { + return NS_ERROR_FAILURE; // Button accessible shut down + } + nsFormControlAccessible::GetState(_retval); nsAutoString buttonType; element->GetAttribute(NS_LITERAL_STRING("type"), buttonType); if (buttonType.LowerCaseEqualsLiteral("submit")) @@ -274,12 +275,13 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetRole(PRUint32 *_retval) NS_IMETHODIMP nsHTML4ButtonAccessible::GetState(PRUint32 *_retval) { + nsCOMPtr element(do_QueryInterface(mDOMNode)); + if (!element) { + return NS_ERROR_FAILURE; // Button accessible shut down + } nsAccessible::GetState(_retval); *_retval |= STATE_FOCUSABLE; - nsCOMPtr element(do_QueryInterface(mDOMNode)); - NS_ASSERTION(element, "No nsIDOMElement for button node!"); - nsAutoString buttonType; element->GetAttribute(NS_LITERAL_STRING("type"), buttonType); if (buttonType.LowerCaseEqualsLiteral("submit")) diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index 204b48dccb6..4db6d9e21f1 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -460,13 +460,6 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetRole(PRUint32 *aRole) return NS_OK; } -/** Return our cached parent */ -NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetParent(nsIAccessible **aParent) -{ - NS_IF_ADDREF(*aParent = mParent); - return NS_OK; -} - /** * Get our Name from our Content's subtree */ @@ -602,7 +595,9 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index) return NS_ERROR_FAILURE; // Clear old selection nsCOMPtr oldHTMLOptionNode, selectNode; - nsCOMPtr accessNode(do_QueryInterface(mParent)); + nsCOMPtr parent; + GetParent(getter_AddRefs(parent)); + nsCOMPtr accessNode(do_QueryInterface(parent)); NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode"); accessNode->GetDOMNode(getter_AddRefs(selectNode)); GetFocusedOptionNode(selectNode, getter_AddRefs(oldHTMLOptionNode)); diff --git a/accessible/src/html/nsHTMLSelectAccessible.h b/accessible/src/html/nsHTMLSelectAccessible.h index d80e8abd4e4..e5d57cb99fb 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.h +++ b/accessible/src/html/nsHTMLSelectAccessible.h @@ -157,7 +157,6 @@ public: NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetState(PRUint32 *_retval); NS_IMETHOD GetRole(PRUint32 *aRole); - NS_IMETHOD GetParent(nsIAccessible **aParent); NS_IMETHOD GetName(nsAString& aName); nsIFrame* GetBoundsFrame(); static nsresult GetFocusedOptionNode(nsIDOMNode *aListNode, nsIDOMNode **aFocusedOptionNode); diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index 9b98093c639..75f037cb48f 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -909,6 +909,8 @@ nsAccessibleWrap::Next(ULONG aNumElementsRequested, VARIANT FAR* pvar, ULONG FAR PRBool wasAccessibleFetched = PR_FALSE; nsAccessibleWrap *msaaAccessible = NS_STATIC_CAST(nsAccessibleWrap*, pvar[*aNumElementsFetched].pdispVal); + if (!msaaAccessible) + break; if (childIndex >= mEnumVARIANTPosition) { if (++*aNumElementsFetched >= aNumElementsRequested) break; @@ -1003,7 +1005,7 @@ STDMETHODIMP nsAccessibleWrap::Invoke(DISPID dispIdMember, REFIID riid, NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible) { *aOutAccessible = NS_STATIC_CAST(IAccessible*, this); - NS_STATIC_CAST(IAccessible*, this)->AddRef(); + NS_ADDREF_THIS(); return NS_OK; } diff --git a/accessible/src/msaa/nsDocAccessibleWrap.cpp b/accessible/src/msaa/nsDocAccessibleWrap.cpp index a95790b6f76..dc2af4b8e96 100644 --- a/accessible/src/msaa/nsDocAccessibleWrap.cpp +++ b/accessible/src/msaa/nsDocAccessibleWrap.cpp @@ -239,6 +239,9 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireToolkitEvent(PRUint32 aEvent, nsIAccessib } else { childID = GetChildIDFor(aAccessible); // get the id for the accessible + if (!childID) { + return NS_OK; // Can't fire an event without a child ID + } if (aAccessible != this) { // See if we're in a scrollable area with its own window nsCOMPtr accessible; @@ -278,6 +281,9 @@ PRInt32 nsDocAccessibleWrap::GetChildIDFor(nsIAccessible* aAccessible) void *uniqueID; nsCOMPtr accessNode(do_QueryInterface(aAccessible)); + if (!accessNode) { + return 0; + } accessNode->GetUniqueID(&uniqueID); // Yes, this means we're only compatibible with 32 bit diff --git a/accessible/src/xul/nsXULMenuAccessible.cpp b/accessible/src/xul/nsXULMenuAccessible.cpp index c4068a9a145..b7776e4eb2a 100644 --- a/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/accessible/src/xul/nsXULMenuAccessible.cpp @@ -98,9 +98,11 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetState(PRUint32 *_retval) nsCOMPtr parentAccessible; if (parentAccessible) { GetParent(getter_AddRefs(parentAccessible)); - parentAccessible->GetFinalState(&parentState); - *_retval &= ~STATE_OFFSCREEN; // clear the old OFFSCREEN bit - *_retval |= (parentState & STATE_OFFSCREEN); // or it with the parent's offscreen bit + if (parentAccessible) { + parentAccessible->GetFinalState(&parentState); + *_retval &= ~STATE_OFFSCREEN; // clear the old OFFSCREEN bit + *_retval |= (parentState & STATE_OFFSCREEN); // or it with the parent's offscreen bit + } } return NS_OK;