Bug 210782. Separate public and private accessibility interfaces. r=kyle, sr=jst

This commit is contained in:
aaronl%netscape.com 2003-07-09 07:01:46 +00:00
parent d113f9f41e
commit 3e0c33e5da
21 changed files with 369 additions and 141 deletions

View File

@ -43,6 +43,7 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsIAccessibilityService.h" #include "nsIAccessibilityService.h"
#include "nsIAccessibleRetrieval.h"
#include "nscore.h" #include "nscore.h"
static NS_IMETHODIMP static NS_IMETHODIMP
@ -51,9 +52,9 @@ NS_ConstructAccessibilityService(nsISupports *aOuter, REFNSIID aIID, void **aRes
nsresult rv; nsresult rv;
NS_ASSERTION(aOuter == nsnull, "no aggregation"); NS_ASSERTION(aOuter == nsnull, "no aggregation");
nsIAccessibilityService* accessibility; nsIAccessibilityService* accessibility;
rv = NS_NewAccessibilityService(&accessibility); rv = NS_GetAccessibilityService(&accessibility);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("Unable to construct chrome registry"); NS_ERROR("Unable to construct accessibility service");
return rv; return rv;
} }
rv = accessibility->QueryInterface(aIID, aResult); rv = accessibility->QueryInterface(aIID, aResult);
@ -70,6 +71,11 @@ static const nsModuleComponentInfo components[] =
"@mozilla.org/accessibilityService;1", "@mozilla.org/accessibilityService;1",
NS_ConstructAccessibilityService NS_ConstructAccessibilityService
}, },
{ "AccessibleRetrieval",
NS_ACCESSIBLE_RETRIEVAL_CID,
"@mozilla.org/accessibleRetrieval;1",
NS_ConstructAccessibilityService
},
}; };
NS_IMPL_NSGETMODULE(nsAccessibilityModule, components); NS_IMPL_NSGETMODULE(nsAccessibilityModule, components);

View File

@ -40,9 +40,12 @@ GRE_MODULE = 1
XPIDLSRCS = \ XPIDLSRCS = \
nsIAccessibilityService.idl \ nsIAccessibilityService.idl \
nsIAccessibleRetrieval.idl \
nsIAccessible.idl \ nsIAccessible.idl \
nsPIAccessible.idl \
nsIAccessibleCaret.idl \ nsIAccessibleCaret.idl \
nsIAccessibleDocument.idl \ nsIAccessibleDocument.idl \
nsPIAccessibleDocument.idl \
nsIAccessibleEventReceiver.idl \ nsIAccessibleEventReceiver.idl \
nsIAccessibleProvider.idl \ nsIAccessibleProvider.idl \
nsIAccessibleSelectable.idl \ nsIAccessibleSelectable.idl \

View File

@ -19,8 +19,8 @@
* Portions created by the Initial Developer are Copyright (C) 2003 * Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com) * Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or

View File

@ -23,24 +23,17 @@
*/ */
#include "nsISupports.idl" #include "nsISupports.idl"
#include "nsIAccessibleRetrieval.idl"
interface nsIDOMNode;
interface nsIAccessible;
interface nsIAccessibleCaret;
interface nsIWeakReference;
interface nsIAccessibleEventListener; interface nsIAccessibleEventListener;
interface nsIDocument; interface nsIDocument;
interface nsIPresShell;
interface nsIDOMWindow;
interface nsIAccessNode;
interface nsObjectFrame; interface nsObjectFrame;
[scriptable, uuid(68D9720A-0984-42b6-A3F5-8237ED925727)] [scriptable, uuid(68D9720A-0984-42b6-A3F5-8237ED925727)]
interface nsIAccessibilityService : nsISupports interface nsIAccessibilityService : nsIAccessibleRetrieval
{ {
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode); nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
nsIAccessible createRootAccessible(in nsIPresShell aShell, in nsIDocument aDocument); nsIAccessible createRootAccessible(in nsIPresShell aShell, in nsIDocument aDocument);
nsIAccessibleCaret createCaretAccessible(in nsIDOMNode aNode, in nsIAccessible aRootAccessible);
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame); nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);
nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent); nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
@ -98,13 +91,6 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createXULToolbarAccessible(in nsIDOMNode aNode); nsIAccessible createXULToolbarAccessible(in nsIDOMNode aNode);
nsIAccessible createXULToolbarSeparatorAccessible(in nsIDOMNode aNode); nsIAccessible createXULToolbarSeparatorAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTooltipAccessible(in nsIDOMNode aNode); nsIAccessible createXULTooltipAccessible(in nsIDOMNode aNode);
nsIAccessible getAccessibleFor(in nsIDOMNode aNode);
nsIAccessible getAccessibleInWindow(in nsIDOMNode aNode, in nsIDOMWindow aDOMWin);
nsIAccessible getAccessibleInWeakShell(in nsIDOMNode aNode, in nsIWeakReference aPresShell);
nsIAccessible getAccessibleInShell(in nsIDOMNode aNode, in nsIPresShell aPresShell);
[noscript] nsIAccessNode getCachedAccessNode(in nsIDOMNode aNode, in nsIWeakReference aShell);
[noscript] nsIAccessible getCachedAccessible(in nsIDOMNode aNode, in nsIWeakReference aShell);
}; };
@ -116,6 +102,6 @@ interface nsIAccessibilityService : nsISupports
{ 0xde401c37, 0x9a7f, 0x4278, { 0xa6, 0xf8, 0x3d, 0xe2, 0x83, 0x39, 0x89, 0xef } } { 0xde401c37, 0x9a7f, 0x4278, { 0xa6, 0xf8, 0x3d, 0xe2, 0x83, 0x39, 0x89, 0xef } }
extern nsresult extern nsresult
NS_NewAccessibilityService(nsIAccessibilityService** aResult); NS_GetAccessibilityService(nsIAccessibilityService** aResult);
%} %}

View File

@ -1,28 +1,41 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
* *
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Eric D Vaughan (evaughan@netscape.com) * Original Author: Eric D Vaughan (evaughan@netscape.com)
* * Contributor(s): Aaron Leventhal (aaronl@netscape.com)
* Contributor(s): * John Gaunt (jgaunt@netscape.com)
* Aaron Leventhal *
* John Gaunt * Alternatively, the contents of this file may be used under the terms of
*/ * either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl" #include "nsISupports.idl"
#include "nsIDOMNode.idl" #include "nsIDOMNode.idl"
@ -77,11 +90,6 @@ interface nsIAccessible : nsISupports
nsIDOMNode accGetDOMNode(); nsIDOMNode accGetDOMNode();
[noscript] void setAccParent(in nsIAccessible aAccParent);
[noscript] void setAccFirstChild(in nsIAccessible aAccFirstChild);
[noscript] void setAccNextSibling(in nsIAccessible aAccNextSibling);
[noscript] void invalidateChildren();
[noscript] void fireToolkitEvent(in unsigned long aEvent, in nsIAccessible aTarget, in voidPtr aData);
[noscript] void getNativeInterface(out voidPtr aOutAccessible); [noscript] void getNativeInterface(out voidPtr aOutAccessible);
// MSAA State flags - used for bitfield. More than 1 allowed. // MSAA State flags - used for bitfield. More than 1 allowed.

View File

@ -1,27 +1,40 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public * The contents of this file are subject to the Mozilla Public License Version
* License Version 1.1 (the "License"); you may not use this file * 1.1 (the "License"); you may not use this file except in compliance with
* except in compliance with the License. You may obtain a copy of * the License. You may obtain a copy of the License at
* the License at http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS * Software distributed under the License is distributed on an "AS IS" basis,
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* implied. See the License for the specific language governing * for the specific language governing rights and limitations under the
* rights and limitations under the License. * License.
* *
* The Original Code is the Mozilla browser. * The Original Code is mozilla.org code.
* *
* The Initial Developer of the Original Code is Netscape * The Initial Developer of the Original Code is
* Communications Corporation. Portions created by Netscape are * Netscape Communications Corporation.
* Copyright (C) 1999 Netscape Communications Corporation. All * Portions created by the Initial Developer are Copyright (C) 2002
* Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Original Author: Aaron Leventhal * Original Author: Aaron Leventhal (aaronl@netscape.com)
* * Contributor(s): John Gaunt (jgaunt@netscape.com)
* Contributor(s): *
* John Gaunt * Alternatively, the contents of this file may be used under the terms of
*/ * either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl" #include "nsISupports.idl"
@ -46,8 +59,5 @@ interface nsIAccessibleDocument : nsISupports
readonly attribute nsIAccessibleCaret caretAccessible; readonly attribute nsIAccessibleCaret caretAccessible;
[noscript] readonly attribute voidPtr windowHandle; [noscript] readonly attribute voidPtr windowHandle;
[noscript] nsIAccessNode getCachedAccessNode(in voidPtr aUniqueID); [noscript] nsIAccessNode getCachedAccessNode(in voidPtr aUniqueID);
[noscript] void invalidateCacheSubtree(in nsIDOMNode aStartNode);
[noscript] nsIAccessible getAccessibleInParentChain(in nsIDOMNode aDOMNode); [noscript] nsIAccessible getAccessibleInParentChain(in nsIDOMNode aDOMNode);
[noscript] void cacheAccessNode(in voidPtr aUniqueID, in nsIAccessNode aAccessNode);
[noscript] void destroy();
}; };

View File

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMNode;
interface nsIAccessible;
interface nsIWeakReference;
interface nsIPresShell;
interface nsIDOMWindow;
interface nsIAccessNode;
[scriptable, uuid(663CA4A8-D219-4000-925D-D8F66406B626)]
interface nsIAccessibleRetrieval : nsISupports
{
nsIAccessible getAccessibleFor(in nsIDOMNode aNode);
nsIAccessible getAccessibleInWindow(in nsIDOMNode aNode, in nsIDOMWindow aDOMWin);
nsIAccessible getAccessibleInWeakShell(in nsIDOMNode aNode, in nsIWeakReference aPresShell);
nsIAccessible getAccessibleInShell(in nsIDOMNode aNode, in nsIPresShell aPresShell);
nsIAccessNode getCachedAccessNode(in nsIDOMNode aNode, in nsIWeakReference aShell);
nsIAccessible getCachedAccessible(in nsIDOMNode aNode, in nsIWeakReference aShell);
};
%{ C++
// for component registration
// {663CA4A8-D219-4000-925D-D8F66406B626}
#define NS_ACCESSIBLE_RETRIEVAL_CID \
{ 0x663ca4a8, 0xd219, 0x4000, { 0x92, 0x5d, 0xd8, 0xf6, 0x64, 0x6, 0xb6, 0x26 } }
%}

View File

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIAccessible;
[scriptable, uuid(52F1BE88-84F7-4f7f-B31C-062AFE7DF15D)]
interface nsPIAccessible : nsISupports
{
[noscript] void setAccParent(in nsIAccessible aAccParent);
[noscript] void setAccFirstChild(in nsIAccessible aAccFirstChild);
[noscript] void setAccNextSibling(in nsIAccessible aAccNextSibling);
[noscript] void invalidateChildren();
[noscript] void fireToolkitEvent(in unsigned long aEvent, in nsIAccessible aTarget, in voidPtr aData);
};

View File

@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIAccessNode;
interface nsIDOMNode;
[scriptable, uuid(F0809603-74E8-4284-8366-B293A5D0B758)]
interface nsPIAccessibleDocument : nsISupports
{
[noscript] void invalidateCacheSubtree(in nsIDOMNode aStartNode);
[noscript] void cacheAccessNode(in voidPtr aUniqueID, in nsIAccessNode aAccessNode);
[noscript] void destroy();
};

View File

@ -42,6 +42,7 @@
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsIAccessibilityService.h" #include "nsIAccessibilityService.h"
#include "nsIAccessibleDocument.h" #include "nsIAccessibleDocument.h"
#include "nsPIAccessibleDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMCSSStyleDeclaration.h" #include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -136,7 +137,10 @@ NS_IMETHODIMP nsAccessNode::Init()
} }
void* uniqueID; void* uniqueID;
GetUniqueID(&uniqueID); GetUniqueID(&uniqueID);
docAccessible->CacheAccessNode(uniqueID, this); nsCOMPtr<nsPIAccessibleDocument> privateDocAccessible =
do_QueryInterface(docAccessible);
NS_ASSERTION(privateDocAccessible, "No private docaccessible for docaccessible");
privateDocAccessible->CacheAccessNode(uniqueID, this);
#ifdef DEBUG #ifdef DEBUG
mIsInitialized = PR_TRUE; mIsInitialized = PR_TRUE;
#endif #endif

View File

@ -101,6 +101,8 @@
#include "nsXULTreeAccessibleWrap.h" #include "nsXULTreeAccessibleWrap.h"
#endif #endif
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
/** /**
* nsAccessibilityService * nsAccessibilityService
*/ */
@ -123,10 +125,11 @@ nsAccessibilityService::nsAccessibilityService()
nsAccessibilityService::~nsAccessibilityService() nsAccessibilityService::~nsAccessibilityService()
{ {
nsAccessibilityService::gAccessibilityService = nsnull;
nsAccessNodeWrap::ShutdownAccessibility(); nsAccessNodeWrap::ShutdownAccessibility();
} }
NS_IMPL_THREADSAFE_ISUPPORTS4(nsAccessibilityService, nsIAccessibilityService, NS_IMPL_THREADSAFE_ISUPPORTS5(nsAccessibilityService, nsIAccessibilityService, nsIAccessibleRetrieval,
nsIObserver, nsIWebProgressListener, nsISupportsWeakReference); nsIObserver, nsIWebProgressListener, nsISupportsWeakReference);
// nsIObserver // nsIObserver
@ -242,7 +245,8 @@ nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIW
nsresult nsresult
nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell) nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell)
{ nsCOMPtr<nsIDOMDocument> domDoc; {
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc)); aNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc)); nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
if (!doc) if (!doc)
@ -328,22 +332,6 @@ nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsAccessibilityService::CreateCaretAccessible(nsIDOMNode *aNode,
nsIAccessible *aRootAccessible,
nsIAccessibleCaret **_retval)
{
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsCaretAccessible(aNode, weakShell, aRootAccessible);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
/** /**
* HTML widget creation * HTML widget creation
*/ */
@ -1708,19 +1696,28 @@ nsresult nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
nsresult nsresult
NS_NewAccessibilityService(nsIAccessibilityService** aResult) nsAccessibilityService::GetAccessibilityService(nsIAccessibilityService** aResult)
{ {
NS_PRECONDITION(aResult != nsnull, "null ptr"); NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult) if (! aResult)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsAccessibilityService* accService = new nsAccessibilityService(); *aResult = nsnull;
if (!accService) if (!nsAccessibilityService::gAccessibilityService) {
gAccessibilityService = new nsAccessibilityService();
if (!gAccessibilityService ) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(accService); }
*aResult = accService; }
*aResult = nsAccessibilityService::gAccessibilityService;
NS_ADDREF(*aResult);
return NS_OK; return NS_OK;
} }
nsresult
NS_GetAccessibilityService(nsIAccessibilityService** aResult)
{
return nsAccessibilityService::GetAccessibilityService(aResult);
}

View File

@ -62,11 +62,13 @@ public:
virtual ~nsAccessibilityService(); virtual ~nsAccessibilityService();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLERETRIEVAL
NS_DECL_NSIACCESSIBILITYSERVICE NS_DECL_NSIACCESSIBILITYSERVICE
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIWEBPROGRESSLISTENER
static nsresult GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell); static nsresult GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell);
static nsresult GetAccessibilityService(nsIAccessibilityService** aResult);
private: private:
nsresult GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent); nsresult GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent);
@ -74,6 +76,7 @@ private:
nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell); nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell);
nsresult GetAccessible(nsIDOMNode *aNode, nsIPresShell *aPresShell, nsresult GetAccessible(nsIDOMNode *aNode, nsIPresShell *aPresShell,
nsIWeakReference *aWeakShell, nsIAccessible **aAccessible); nsIWeakReference *aWeakShell, nsIAccessible **aAccessible);
static nsAccessibilityService *gAccessibilityService;
}; };
#endif /* __nsIAccessibilityService_h__ */ #endif /* __nsIAccessibilityService_h__ */

View File

@ -96,7 +96,7 @@
//----------------------------------------------------- //-----------------------------------------------------
// construction // construction
//----------------------------------------------------- //-----------------------------------------------------
NS_IMPL_ISUPPORTS_INHERITED1(nsAccessible, nsAccessNode, nsIAccessible) NS_IMPL_ISUPPORTS_INHERITED2(nsAccessible, nsAccessNode, nsIAccessible, nsPIAccessible)
nsAccessible::nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsAccessNodeWrap(aNode, aShell), nsAccessible::nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsAccessNodeWrap(aNode, aShell),
mParent(nsnull), mFirstChild(nsnull), mNextSibling(nsnull) mParent(nsnull), mFirstChild(nsnull), mNextSibling(nsnull)
@ -217,7 +217,8 @@ NS_IMETHODIMP nsAccessible::Shutdown()
if (mFirstChild) { if (mFirstChild) {
nsCOMPtr<nsIAccessible> current(mFirstChild), next; nsCOMPtr<nsIAccessible> current(mFirstChild), next;
while (current) { while (current) {
current->SetAccParent(nsnull); nsCOMPtr<nsPIAccessible> privateAcc(do_QueryInterface(current));
privateAcc->SetAccParent(nsnull);
current->GetAccNextSibling(getter_AddRefs(next)); current->GetAccNextSibling(getter_AddRefs(next));
current = next; current = next;
} }
@ -225,7 +226,8 @@ NS_IMETHODIMP nsAccessible::Shutdown()
// Now invalidate the child count and pointers to other accessibles // Now invalidate the child count and pointers to other accessibles
InvalidateChildren(); InvalidateChildren();
if (mParent) { if (mParent) {
mParent->InvalidateChildren(); nsCOMPtr<nsPIAccessible> privateParent(do_QueryInterface(mParent));
privateParent->InvalidateChildren();
mParent = nsnull; mParent = nsnull;
} }
@ -287,7 +289,8 @@ NS_IMETHODIMP nsAccessible::GetAccNextSibling(nsIAccessible * *aAccNextSibling)
if (NS_SUCCEEDED(walker.GetNextSibling())) { if (NS_SUCCEEDED(walker.GetNextSibling())) {
*aAccNextSibling = walker.mState.accessible; *aAccNextSibling = walker.mState.accessible;
NS_ADDREF(*aAccNextSibling); NS_ADDREF(*aAccNextSibling);
(*aAccNextSibling)->SetAccParent(mParent); nsCOMPtr<nsPIAccessible> privateAcc(do_QueryInterface(*aAccNextSibling));
privateAcc->SetAccParent(mParent);
mNextSibling = *aAccNextSibling; mNextSibling = *aAccNextSibling;
} }
@ -314,7 +317,8 @@ NS_IMETHODIMP nsAccessible::GetAccPreviousSibling(nsIAccessible * *aAccPreviousS
*aAccPreviousSibling = walker.mState.accessible; *aAccPreviousSibling = walker.mState.accessible;
NS_ADDREF(*aAccPreviousSibling); NS_ADDREF(*aAccPreviousSibling);
// Use last walker state to cache data on prev accessible // Use last walker state to cache data on prev accessible
(*aAccPreviousSibling)->SetAccParent(mParent); nsCOMPtr<nsPIAccessible> privateAcc(do_QueryInterface(*aAccPreviousSibling));
privateAcc->SetAccParent(mParent);
} }
return NS_OK; return NS_OK;
@ -377,16 +381,16 @@ void nsAccessible::CacheChildren(PRBool aWalkAnonContent)
if (mAccChildCount == eChildCountUninitialized) { if (mAccChildCount == eChildCountUninitialized) {
nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, aWalkAnonContent); nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, aWalkAnonContent);
nsCOMPtr<nsIAccessible> prevAccessible; nsCOMPtr<nsPIAccessible> privatePrevAccessible;
mAccChildCount = 0; mAccChildCount = 0;
walker.GetFirstChild(); walker.GetFirstChild();
SetAccFirstChild(walker.mState.accessible); SetAccFirstChild(walker.mState.accessible);
while (walker.mState.accessible) { while (walker.mState.accessible) {
walker.mState.accessible->SetAccParent(this);
++mAccChildCount; ++mAccChildCount;
prevAccessible = walker.mState.accessible; privatePrevAccessible = do_QueryInterface(walker.mState.accessible);
privatePrevAccessible->SetAccParent(this);
walker.GetNextSibling(); walker.GetNextSibling();
prevAccessible->SetAccNextSibling(walker.mState.accessible); privatePrevAccessible->SetAccNextSibling(walker.mState.accessible);
} }
} }
} }
@ -1352,7 +1356,7 @@ NS_IMETHODIMP nsAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTa
if (!mWeakShell) if (!mWeakShell)
return NS_ERROR_FAILURE; // Don't fire event for accessible that has been shut down return NS_ERROR_FAILURE; // Don't fire event for accessible that has been shut down
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible()); nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
nsCOMPtr<nsIAccessible> eventHandlingAccessible(do_QueryInterface(docAccessible)); nsCOMPtr<nsPIAccessible> eventHandlingAccessible(do_QueryInterface(docAccessible));
if (eventHandlingAccessible) { if (eventHandlingAccessible) {
return eventHandlingAccessible->FireToolkitEvent(aEvent, aTarget, aData); return eventHandlingAccessible->FireToolkitEvent(aEvent, aTarget, aData);
} }

View File

@ -33,8 +33,7 @@
* decision by deleting the provisions above and replace them with the notice * decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete * and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under * the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL. * the terms of any one of the NPL, the GPL or the LGPL. *
*
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef _nsAccessible_H_ #ifndef _nsAccessible_H_
@ -42,6 +41,7 @@
#include "nsAccessNodeWrap.h" #include "nsAccessNodeWrap.h"
#include "nsIAccessible.h" #include "nsIAccessible.h"
#include "nsPIAccessible.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsString.h" #include "nsString.h"
@ -56,7 +56,9 @@ class nsIAtom;
// When mNextSibling is set to this, it indicates there ar eno more siblings // When mNextSibling is set to this, it indicates there ar eno more siblings
#define DEAD_END_ACCESSIBLE NS_STATIC_CAST(nsIAccessible*, (void*)1) #define DEAD_END_ACCESSIBLE NS_STATIC_CAST(nsIAccessible*, (void*)1)
class nsAccessible : public nsAccessNodeWrap, public nsIAccessible class nsAccessible : public nsAccessNodeWrap,
public nsIAccessible,
public nsPIAccessible
{ {
public: public:
// to eliminate the confusion of "magic numbers" -- if ( 0 ){ foo; } // to eliminate the confusion of "magic numbers" -- if ( 0 ){ foo; }
@ -69,6 +71,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLE NS_DECL_NSIACCESSIBLE
NS_DECL_NSPIACCESSIBLE
NS_IMETHOD GetFocusedNode(nsIDOMNode **aFocusedNode); NS_IMETHOD GetFocusedNode(nsIDOMNode **aFocusedNode);

View File

@ -60,7 +60,7 @@
NS_IMPL_ISUPPORTS_INHERITED2(nsCaretAccessible, nsLeafAccessible, nsIAccessibleCaret, nsISelectionListener) NS_IMPL_ISUPPORTS_INHERITED2(nsCaretAccessible, nsLeafAccessible, nsIAccessibleCaret, nsISelectionListener)
nsCaretAccessible::nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsIAccessible *aRootAccessible): nsCaretAccessible::nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsRootAccessible *aRootAccessible):
nsLeafAccessible(aDocumentNode, aShell), mVisible(PR_TRUE), mCurrentDOMNode(nsnull), mRootAccessible(aRootAccessible) nsLeafAccessible(aDocumentNode, aShell), mVisible(PR_TRUE), mCurrentDOMNode(nsnull), mRootAccessible(aRootAccessible)
{ {
} }

View File

@ -45,6 +45,8 @@
#include "nsISelectionListener.h" #include "nsISelectionListener.h"
#include "nsRect.h" #include "nsRect.h"
class nsRootAccessible;
/* /*
* This special accessibility class is for the caret, which is really the currently focused selection. * This special accessibility class is for the caret, which is really the currently focused selection.
* There is only 1 visible caret per top level window (nsRootAccessible) * There is only 1 visible caret per top level window (nsRootAccessible)
@ -59,7 +61,7 @@ class nsCaretAccessible : public nsLeafAccessible, public nsIAccessibleCaret, pu
public: public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsIAccessible *aRootAccessible); nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsRootAccessible *aRootAccessible);
/* ----- nsIAccessible ----- */ /* ----- nsIAccessible ----- */
NS_IMETHOD GetAccParent(nsIAccessible **_retval); NS_IMETHOD GetAccParent(nsIAccessible **_retval);
@ -85,7 +87,7 @@ private:
nsCOMPtr<nsIDOMNode> mCurrentDOMNode; nsCOMPtr<nsIDOMNode> mCurrentDOMNode;
// mListener is not a com pointer. It's a copy of the listener in the nsRootAccessible owner. // mListener is not a com pointer. It's a copy of the listener in the nsRootAccessible owner.
//See nsRootAccessible.h for details of the lifetime if this listener //See nsRootAccessible.h for details of the lifetime if this listener
nsIAccessible *mRootAccessible; nsRootAccessible *mRootAccessible;
nsCOMPtr<nsIWeakReference> mDomSelectionWeak; nsCOMPtr<nsIWeakReference> mDomSelectionWeak;
}; };

View File

@ -121,6 +121,7 @@ nsDocAccessible::~nsDocAccessible()
NS_INTERFACE_MAP_BEGIN(nsDocAccessible) NS_INTERFACE_MAP_BEGIN(nsDocAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument) NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsPIAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver) NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationListener) NS_INTERFACE_MAP_ENTRY(nsIDOMMutationListener)
@ -356,9 +357,10 @@ NS_IMETHODIMP nsDocAccessible::Init()
// It should be changed to use GetAccessibleInWeakShell() // It should be changed to use GetAccessibleInWeakShell()
nsCOMPtr<nsIAccessible> accParent; nsCOMPtr<nsIAccessible> accParent;
accService->GetAccessibleFor(ownerNode, getter_AddRefs(accParent)); accService->GetAccessibleFor(ownerNode, getter_AddRefs(accParent));
if (accParent) { nsCOMPtr<nsPIAccessible> privateAccParent(do_QueryInterface(accParent));
if (privateAccParent) {
SetAccParent(accParent); SetAccParent(accParent);
accParent->SetAccFirstChild(this); privateAccParent->SetAccFirstChild(this);
} }
} }
} }
@ -968,6 +970,11 @@ nsDocAccessible::GetAccessibleInParentChain(nsIDOMNode *aNode,
NS_ASSERTION(parentNode, "Impossible! Crawled up parent chain without " NS_ASSERTION(parentNode, "Impossible! Crawled up parent chain without "
"finding accessible. There should have at least " "finding accessible. There should have at least "
"been a document accessible at the root."); "been a document accessible at the root.");
if (!parentNode) {
// XXX Todo We need to figure out why this is happening.
// For now, return safely.
return NS_ERROR_FAILURE;
}
currentNode = parentNode; currentNode = parentNode;
} }
@ -1001,8 +1008,10 @@ void nsDocAccessible::HandleMutationEvent(nsIDOMEvent *aEvent, PRUint32 aAccessi
nsCOMPtr<nsIAccessibleDocument> docAccessible; nsCOMPtr<nsIAccessibleDocument> docAccessible;
GetEventDocAccessible(subTreeToInvalidate, getter_AddRefs(docAccessible)); GetEventDocAccessible(subTreeToInvalidate, getter_AddRefs(docAccessible));
nsCOMPtr<nsPIAccessibleDocument> privateDocAccessible =
do_QueryInterface(docAccessible);
docAccessible->InvalidateCacheSubtree(subTreeToInvalidate); privateDocAccessible->InvalidateCacheSubtree(subTreeToInvalidate);
// We need to get an accessible for the mutation event's target node // We need to get an accessible for the mutation event's target node
// If there is no accessible for that node, we need to keep moving up the parent // If there is no accessible for that node, we need to keep moving up the parent
@ -1013,13 +1022,16 @@ void nsDocAccessible::HandleMutationEvent(nsIDOMEvent *aEvent, PRUint32 aAccessi
nsCOMPtr<nsIAccessible> accessible; nsCOMPtr<nsIAccessible> accessible;
docAccessible->GetAccessibleInParentChain(targetNode, getter_AddRefs(accessible)); docAccessible->GetAccessibleInParentChain(targetNode, getter_AddRefs(accessible));
accessible->InvalidateChildren(); nsCOMPtr<nsPIAccessible> privateAccessible(do_QueryInterface(accessible));
if (!privateAccessible)
return;
privateAccessible->InvalidateChildren();
#ifdef XP_WIN #ifdef XP_WIN
// Windows MSAA clients crash if they listen to create or destroy events // Windows MSAA clients crash if they listen to create or destroy events
aAccessibleEventType = nsIAccessibleEventReceiver::EVENT_REORDER; aAccessibleEventType = nsIAccessibleEventReceiver::EVENT_REORDER;
#endif #endif
accessible->FireToolkitEvent(aAccessibleEventType, accessible, nsnull); privateAccessible->FireToolkitEvent(aAccessibleEventType, accessible, nsnull);
} }
NS_IMETHODIMP nsDocAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData) NS_IMETHODIMP nsDocAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData)

View File

@ -41,6 +41,7 @@
#include "nsBaseWidgetAccessible.h" #include "nsBaseWidgetAccessible.h"
#include "nsIAccessibleDocument.h" #include "nsIAccessibleDocument.h"
#include "nsPIAccessibleDocument.h"
#include "nsIAccessibleEventReceiver.h" #include "nsIAccessibleEventReceiver.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMMutationListener.h" #include "nsIDOMMutationListener.h"
@ -58,6 +59,7 @@ const PRUint32 kDefaultCacheSize = 256;
class nsDocAccessible : public nsBlockAccessible, class nsDocAccessible : public nsBlockAccessible,
public nsIAccessibleDocument, public nsIAccessibleDocument,
public nsPIAccessibleDocument,
public nsIAccessibleEventReceiver, public nsIAccessibleEventReceiver,
public nsIWebProgressListener, public nsIWebProgressListener,
public nsIObserver, public nsIObserver,
@ -69,6 +71,7 @@ class nsDocAccessible : public nsBlockAccessible,
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEDOCUMENT NS_DECL_NSIACCESSIBLEDOCUMENT
NS_DECL_NSPIACCESSIBLEDOCUMENT
NS_DECL_NSIACCESSIBLEEVENTRECEIVER NS_DECL_NSIACCESSIBLEEVENTRECEIVER
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER

View File

@ -123,5 +123,7 @@ NS_IMETHODIMP nsOuterDocAccessible::Init()
NS_ENSURE_TRUE(innerAccessible, NS_ERROR_FAILURE); NS_ENSURE_TRUE(innerAccessible, NS_ERROR_FAILURE);
SetAccFirstChild(innerAccessible); // weak ref SetAccFirstChild(innerAccessible); // weak ref
return innerAccessible->SetAccParent(this); nsCOMPtr<nsPIAccessible> privateInnerAccessible =
do_QueryInterface(innerAccessible);
return privateInnerAccessible->SetAccParent(this);
} }

View File

@ -39,6 +39,7 @@
// NOTE: alphabetically ordered // NOTE: alphabetically ordered
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsAccessibleEventData.h" #include "nsAccessibleEventData.h"
#include "nsCaretAccessible.h"
#include "nsHTMLSelectAccessible.h" #include "nsHTMLSelectAccessible.h"
#include "nsIAccessibleCaret.h" #include "nsIAccessibleCaret.h"
#include "nsIChromeEventHandler.h" #include "nsIChromeEventHandler.h"
@ -206,7 +207,7 @@ NS_IMETHODIMP nsRootAccessible::AddEventListeners()
} }
if (!mCaretAccessible) if (!mCaretAccessible)
mAccService->CreateCaretAccessible(mDOMNode, this, getter_AddRefs(mCaretAccessible)); mCaretAccessible = new nsCaretAccessible(mDOMNode, mWeakShell, this);
return NS_OK; return NS_OK;
} }
@ -254,7 +255,8 @@ NS_IMETHODIMP nsRootAccessible::GetCaretAccessible(nsIAccessibleCaret **aCaretAc
void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *focusAccessible, nsIDOMNode *focusNode) void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *focusAccessible, nsIDOMNode *focusNode)
{ {
if (focusAccessible && focusNode && gLastFocusedNode != focusNode) { if (focusAccessible && focusNode && gLastFocusedNode != focusNode) {
focusAccessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS, focusAccessible, nsnull); nsCOMPtr<nsPIAccessible> privateFocusAcc(do_QueryInterface(focusAccessible));
privateFocusAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS, focusAccessible, nsnull);
NS_IF_RELEASE(gLastFocusedNode); NS_IF_RELEASE(gLastFocusedNode);
PRUint32 role = ROLE_NOTHING; PRUint32 role = ROLE_NOTHING;
focusAccessible->GetAccRole(&role); focusAccessible->GetAccRole(&role);
@ -355,21 +357,26 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
nsAutoString eventType; nsAutoString eventType;
aEvent->GetType(eventType); aEvent->GetType(eventType);
nsCOMPtr<nsPIAccessible> privAcc(do_QueryInterface(accessible));
#ifndef MOZ_ACCESSIBILITY_ATK #ifndef MOZ_ACCESSIBILITY_ATK
#ifdef MOZ_XUL #ifdef MOZ_XUL
// tree event // tree event
if (treeItemAccessible && if (treeItemAccessible && (eventType.EqualsIgnoreCase("DOMMenuItemActive") ||
(eventType.EqualsIgnoreCase("DOMMenuItemActive") || eventType.EqualsIgnoreCase("select"))) { eventType.EqualsIgnoreCase("select"))) {
treeItemAccessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS, treeItemAccessible, nsnull); privAcc = do_QueryInterface(treeItemAccessible);
privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS,
treeItemAccessible, nsnull);
return NS_OK; return NS_OK;
} }
#endif #endif
if (eventType.EqualsIgnoreCase("unload")) { if (eventType.EqualsIgnoreCase("unload")) {
nsCOMPtr<nsIAccessibleDocument> accDoc(do_QueryInterface(accessible)); nsCOMPtr<nsPIAccessibleDocument> privateAccDoc =
NS_ASSERTION(accDoc, "No document for unload event target"); do_QueryInterface(accessible);
accDoc->Destroy(); if (privateAccDoc) {
privateAccDoc->Destroy();
}
} }
else if (eventType.EqualsIgnoreCase("focus") || else if (eventType.EqualsIgnoreCase("focus") ||
eventType.EqualsIgnoreCase("DOMMenuItemActive")) { eventType.EqualsIgnoreCase("DOMMenuItemActive")) {
@ -390,24 +397,27 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
FireAccessibleFocusEvent(accessible, targetNode); FireAccessibleFocusEvent(accessible, targetNode);
} }
else if (eventType.EqualsIgnoreCase("CheckboxStateChange")) { else if (eventType.EqualsIgnoreCase("CheckboxStateChange")) {
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE, accessible, nsnull); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE,
accessible, nsnull);
} }
else if (eventType.EqualsIgnoreCase("RadioStateChange") ) { else if (eventType.EqualsIgnoreCase("RadioStateChange") ) {
// first the XUL radio buttons // first the XUL radio buttons
if (targetNode && if (targetNode &&
NS_SUCCEEDED(mAccService->GetAccessibleInShell(targetNode, eventShell, NS_SUCCEEDED(mAccService->GetAccessibleInShell(targetNode, eventShell,
getter_AddRefs(accessible)))) { getter_AddRefs(accessible)))) {
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE, accessible, nsnull); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE,
accessible, nsnull);
FireAccessibleFocusEvent(accessible, targetNode); FireAccessibleFocusEvent(accessible, targetNode);
} }
else { // for the html radio buttons -- apparently the focus code just works. :-) else { // for the html radio buttons -- apparently the focus code just works. :-)
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE, accessible, nsnull); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE,
accessible, nsnull);
} }
} }
else if (eventType.EqualsIgnoreCase("DOMMenuBarActive")) else if (eventType.EqualsIgnoreCase("DOMMenuBarActive"))
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_MENUSTART, accessible, nsnull); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_MENUSTART, accessible, nsnull);
else if (eventType.EqualsIgnoreCase("DOMMenuBarInactive")) { else if (eventType.EqualsIgnoreCase("DOMMenuBarInactive")) {
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_MENUEND, accessible, nsnull); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_MENUEND, accessible, nsnull);
GetAccFocused(getter_AddRefs(accessible)); GetAccFocused(getter_AddRefs(accessible));
if (accessible) { if (accessible) {
accessible->AccGetDOMNode(getter_AddRefs(targetNode)); accessible->AccGetDOMNode(getter_AddRefs(targetNode));
@ -425,20 +435,24 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
PRUint32 role = ROLE_NOTHING; PRUint32 role = ROLE_NOTHING;
accessible->GetAccRole(&role); accessible->GetAccRole(&role);
if (role == ROLE_MENUPOPUP) if (role == ROLE_MENUPOPUP)
accessible->FireToolkitEvent(menuEvent, accessible, nsnull); privAcc->FireToolkitEvent(menuEvent, accessible, nsnull);
} }
} }
#else #else
AtkStateChange stateData; AtkStateChange stateData;
if (eventType.EqualsIgnoreCase("focus") || eventType.EqualsIgnoreCase("DOMMenuItemActive")) { if (eventType.EqualsIgnoreCase("focus") ||
if (treeItemAccessible) // use focused treeitem eventType.EqualsIgnoreCase("DOMMenuItemActive")) {
treeItemAccessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS, treeItemAccessible, nsnull); if (treeItemAccessible) { // use focused treeitem
privAcc = do_QueryInterface(treeItemAccessible);
privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS,
treeItemAccessible, nsnull);
}
else if (anchorElement) { else if (anchorElement) {
nsCOMPtr<nsIAccessibleHyperText> hyperText(do_QueryInterface(accessible)); nsCOMPtr<nsIAccessibleHyperText> hyperText(do_QueryInterface(accessible));
if (hyperText) { if (hyperText) {
PRInt32 selectedLink; PRInt32 selectedLink;
hyperText->GetSelectedLinkIndex(&selectedLink); hyperText->GetSelectedLinkIndex(&selectedLink);
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_ATK_LINK_SELECTED, accessible, &selectedLink); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_ATK_LINK_SELECTED, accessible, &selectedLink);
} }
} }
else if (optionTargetNode && // use focused option else if (optionTargetNode && // use focused option
@ -451,14 +465,16 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
else if (eventType.EqualsIgnoreCase("select")) { else if (eventType.EqualsIgnoreCase("select")) {
if (treeBox && treeIndex >= 0) // it's a XUL <tree> if (treeBox && treeIndex >= 0) // it's a XUL <tree>
// use EVENT_FOCUS instead of EVENT_ATK_SELECTION_CHANGE // use EVENT_FOCUS instead of EVENT_ATK_SELECTION_CHANGE
treeItemAccessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS, treeItemAccessible, nsnull); privAcc = do_QueryInterface(treeItemAccessible);
privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_FOCUS,
treeItemAccessible, nsnull);
} }
else if (eventType.EqualsIgnoreCase("CheckboxStateChange") || // it's a XUL <checkbox> else if (eventType.EqualsIgnoreCase("CheckboxStateChange") || // it's a XUL <checkbox>
eventType.EqualsIgnoreCase("RadioStateChange")) { // it's a XUL <radio> eventType.EqualsIgnoreCase("RadioStateChange")) { // it's a XUL <radio>
accessible->GetAccState(&stateData.state); accessible->GetAccState(&stateData.state);
stateData.enable = (stateData.state & STATE_CHECKED) != 0; stateData.enable = (stateData.state & STATE_CHECKED) != 0;
stateData.state = STATE_CHECKED; stateData.state = STATE_CHECKED;
accessible->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE, accessible, &stateData); privAcc->FireToolkitEvent(nsIAccessibleEventReceiver::EVENT_STATE_CHANGE, accessible, &stateData);
if (eventType.EqualsIgnoreCase("RadioStateChange")) { if (eventType.EqualsIgnoreCase("RadioStateChange")) {
FireAccessibleFocusEvent(accessible, targetNode); FireAccessibleFocusEvent(accessible, targetNode);
} }

View File

@ -171,7 +171,8 @@ NS_IMETHODIMP nsXULButtonAccessible::GetAccFirstChild(nsIAccessible **aResult)
PRUint32 role; PRUint32 role;
if (NS_SUCCEEDED(walker.mState.accessible->GetAccRole(&role)) && role == ROLE_PUSHBUTTON) { if (NS_SUCCEEDED(walker.mState.accessible->GetAccRole(&role)) && role == ROLE_PUSHBUTTON) {
mFirstChild = walker.mState.accessible; mFirstChild = walker.mState.accessible;
mFirstChild->SetAccNextSibling(nsnull); nsCOMPtr<nsPIAccessible> privChildAcc = do_QueryInterface(mFirstChild);
privChildAcc->SetAccNextSibling(nsnull);
} }
} }
} }