diff --git a/mozilla/accessible/accessible-docs.html b/mozilla/accessible/accessible-docs.html index 33b085d4ce7..e774cf23ee4 100644 --- a/mozilla/accessible/accessible-docs.html +++ b/mozilla/accessible/accessible-docs.html @@ -8,6 +8,10 @@
+See also: +Gecko Info for Windows Accessibility Vendors, a primer for vendors of 3rd party accessibility software, on how to use our MSAA and other relevant API's. +
+The Accessible module is where we implement support for the Microsoft Active Accessibility (MSAA) API (bug 12952). Support for Sun's Gnome Accessibility API is part of our future plans as well. @@ -70,8 +74,8 @@ checked, etc.
-Rather than directly implement IAccessible with an Accessible class, we have chosen to proxy to our own interface, -called nsIAccessible, which is more robust. It has the capability of supporting other new accessibility API's such -as Sun's Gnome Accessiblity API. Our nsIAccessible implementation can proxy further to a variety of classes, each specialized for a particular kind of -widget or data node. -
--The first thing that happens when an accessibility aid wants to watch our application is it sends the main application -window a WM_GETOBJECT message requesting an IAccessible for the window. This event is received in mozilla/widget/src/windows/nsWindow.cpp. +Rather than directly implement IAccessible with an Accessible class, we have chosen to proxy to our own cross-platform interface, +called nsIAccessible, which is more robust. It has the capability of supporting other new accessibility API's such +as Sun's Gnome Accessiblity API. The nsIAccessible interface is implemented by a variety of classes for each of the +various objects in HTML. Each class is tailored to the specific abilities and properties of the HTML objects it applies to. +
++The first thing that happens when an accessibility aid wants to watch our application is calls the Windows API function +AccessibleObjectFromWindow(). This in turns sends the window in question +a WM_GETOBJECT message requesting an IAccessible for the window. +In our case, this event is received in mozilla/widget/src/windows/nsWindow.cpp. We send back an IAccessible interface that represents that root window. The accessibility aid will use -that IAccessible to get at the rest of the tree, by asking for it's children IAccessibles, asking the children for the +that first IAccessible to reach rest of the IAccessible hierarchy, by asking for it's children IAccessibles, asking the children for the grandchildren IAccessibles, and so on. Until this WM_GETOBJECT message is processed, the accessibility.dll is not loaded, so there is almost zero overhead for accessibility in Mozilla.
+-To create a RootAccessible IAccessible for the window we get a WM_GETOBJECT message in, nsWindow.cpp first generates an internal event -called NS_GETACCESSIBLE, which is handled in nsFrame.cpp via the creation of an nsRootAccessible implementation of the nsIAccessible interface. -Next the new RootAccessible is created. RootAccessible and Accessible are both implemented +To create the root IAccessible for a window the first time it gets the WM_GETOBJECT message in, +nsWindow.cpp first generates an internal event +called NS_GETACCESSIBLE, +which is handled in nsFrame.cpp via the creation of an nsRootAccessible implementation of the nsIAccessible interface. +The first IAccessible is then created by instantiating a RootAccessible class. This RootAccessible is also cached by +the nsWindow it's for, so that any additional WM_GETOBJECT messages use the same RootAccessible. +The RootAccessible class used to implement IAccessible here is slightly different from the normal Accessible class +that's used, in that it keeps track of event data. +RootAccessible and Accessible are both implemented in mozilla/widget/src/windows/Accessible.cpp).
- +The implementations of IAccessible (Accessible and RootAccessible), don't know anything about Mozilla +objects. They merely proxy to our cross platform accessibility classes, which all have an nsIAccessible interface. +
-The impementation for nsIAccessible knows how +The base implementation for nsIAccessible is called nsAccessible. It has default implementations for all the +nsIAccessible methods. It also knows how to walk Mozilla's content DOM and frame tree, exposing only the objects that are needed for accessibility. -Essentially, nsAccessible knows what it needs to expose by QueryInterfacing the DOM node's primary frame for -an nsIAccessible. If it gets one, it's considered an accessible object. A frame that wishes to return -an nsIAccessible when QI'd for it, creates one of the correct type on the fly using nsIAccessibilityService. +Essentially, nsAccessible knows what it needs to expose by asking each DOM node's primary frame for +an nsIAccessible, using the GetAccessible() method. If it gets one, it's considered an accessible object. +A frame that wishes to return +an nsIAccessible GetAccessible() is called, creates one of the correct type on the fly using +nsIAccessibilityService methods built for that purpose.
The specific implementations -of nsIAccessible for each widget or content type inherit from nsGenericAccessible, which simply returns -NS_ERROR_NOT_IMPLEMENTED for every method. The specific implementation then overrides those methods +of nsIAccessible for each widget or content type inherit from nsAccessible. +Each implementation then overrides those methods it wishes to implement, and does nothing for those methods it wants the default behavior for. For example, the default behavior for nsIAccessible::getAccFirstChild is to -instantial a nsDOMTreeWalker, and ask it for the first child. It doesn't need to do this, however, for images, -because an implementation exists for nsHTMLImageAccessible::getAccFirstChild (returns the first image map area -for the image if one exists). +instantial a nsDOMTreeWalker, and ask it for the first child. However, nsImageAccessible overrides getAccFirstChild, +returning the first area of an image map if there is one, otherwise nsnull.
When an accessibility-related event occurs within an application such as Mozilla, it must use NotifyWinEvent from the Win32 API. NotifyWinEvent is passed arguments for the window the event occured in, and the number of the child -within that window. Accessibility aids use a WIN32 call to register as a listener for these events. +within that window. Accessibility aids use the Win32 call SetWinEventHook() to register as a listener for these events.
-The accessibility aid is choose which events it is interested in learning more about by sending a window a WM_???? -event requesting the IAccessible to the node corresponding to the -child number that had been indicated from NotifyWinEvent. In Mozilla, this creates a problem. We cannot +The accessibility aid is choose which events it is interested in learning more about by using the Win32 API call +AccessibleObjectFromEvent, requesting the IAccessible to the node corresponding to the +child number that had been indicated from NotifyWinEvent(). This ends up asking our RootAccessible for the child +IAccessible that matches the window handle and child id we indicated through NotofyWinEvent(). +
++In Mozilla, this creates a problem. We cannot keep track of a child number for every important accessible node in a document. We deal with this by generating fake child IDs for the most recent accessibile events that we have generated, in a circular array.
Since there is a RootAccessible for each top level window that might generate MSAA events, that's where we do the bookkeeping -for these events and their nsIAccessible's. Whenever NotifyWinEvent is called, a new fake ID is generated (We use +for these events and their nsIAccessible's. Whenever NotifyWinEvent() is called, a new fake ID is generated (We use negative numbers for the fake IDs). When the callback comes to request the IAccessible for that child number, we check the circular array for that ID, and voila, we have the corresponding nsIAccessible to proxy.
diff --git a/mozilla/accessible/build/Makefile.in b/mozilla/accessible/build/Makefile.in index ca0f978b8d6..5f90c7549b7 100644 --- a/mozilla/accessible/build/Makefile.in +++ b/mozilla/accessible/build/Makefile.in @@ -39,14 +39,13 @@ CPPSRCS = nsAccessibilityFactory.cpp LOCAL_INCLUDES = -I$(srcdir)/../src SHARED_LIBRARY_LIBS = \ - $(DIST)/lib/libaccessibility_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libchrome_s.$(LIB_SUFFIX) \ - $(NULL) + $(DIST)/lib/libaccessibility_s.$(LIB_SUFFIX) \ + $(NULL) -EXTRA_DSO_LDOPTS = \ - $(MOZ_COMPONENT_LIBS) \ - -lgkgfx \ - $(NULL) +EXTRA_DSO_LDOPTS = \ + $(MOZ_COMPONENT_LIBS) \ + -lgkgfx \ + $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/accessible/build/makefile.win b/mozilla/accessible/build/makefile.win index 3a44c5c7a15..b6178fabecb 100644 --- a/mozilla/accessible/build/makefile.win +++ b/mozilla/accessible/build/makefile.win @@ -25,20 +25,22 @@ LIBRARY_NAME=accessibility MODULE_NAME=nsAccessibilityModule CPP_OBJS=\ - .\$(OBJDIR)\nsAccessibilityFactory.obj \ - $(NULL) + .\$(OBJDIR)\nsAccessibilityFactory.obj \ + $(NULL) LINCS = $(LINCS) -I..\src # for implementation headers -SUB_LIBRARIES=\ - $(DIST)\lib\accessibility_s.lib \ - $(NULL) +SHARED_LIBRARY_LIBS=\ + $(DIST)\lib\accessibility_s.lib \ + $(NULL) LLIBS=\ - $(DIST)\lib\xpcom.lib \ - $(DIST)\lib\timer_s.lib \ - $(DIST)\lib\gkgfx.lib \ - $(LIBNSPR) + $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\timer_s.lib \ + $(DIST)\lib\gkgfx.lib \ + $(DIST)\lib\contentshared_s.lib \ + $(LIBNSPR) \ + $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/accessible/macbuild/accessible.mcp b/mozilla/accessible/macbuild/accessible.mcp index be05252555f..ec680e8fd32 100644 Binary files a/mozilla/accessible/macbuild/accessible.mcp and b/mozilla/accessible/macbuild/accessible.mcp differ diff --git a/mozilla/accessible/macbuild/accessibleIDL.mcp b/mozilla/accessible/macbuild/accessibleIDL.mcp index 54b8313e858..6453b415ed0 100644 Binary files a/mozilla/accessible/macbuild/accessibleIDL.mcp and b/mozilla/accessible/macbuild/accessibleIDL.mcp differ diff --git a/mozilla/accessible/public/Makefile.in b/mozilla/accessible/public/Makefile.in index 38dd3fb255a..3a03a40a3f2 100644 --- a/mozilla/accessible/public/Makefile.in +++ b/mozilla/accessible/public/Makefile.in @@ -32,9 +32,14 @@ XPIDL_MODULE= accessibility XPIDLSRCS = \ nsIAccessibilityService.idl \ nsIAccessible.idl \ + nsIAccessibleDocument.idl \ nsIAccessibleEventReceiver.idl \ nsIAccessibleEventListener.idl \ + nsIAccessibleSelectable.idl \ $(NULL) +EXPORTS = \ + $(NULL) + include $(topsrcdir)/config/rules.mk diff --git a/mozilla/accessible/public/makefile.win b/mozilla/accessible/public/makefile.win index a24791d81a9..0ee73dd6f71 100644 --- a/mozilla/accessible/public/makefile.win +++ b/mozilla/accessible/public/makefile.win @@ -26,8 +26,13 @@ XPIDL_MODULE=accessibility XPIDLSRCS = \ .\nsIAccessibilityService.idl \ .\nsIAccessible.idl \ + .\nsIAccessibleDocument.idl \ .\nsIAccessibleEventReceiver.idl \ .\nsIAccessibleEventListener.idl \ + .\nsIAccessibleSelectable.idl \ + $(NULL) + +EXPORTS = \ $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/accessible/public/nsIAccessibilityService.idl b/mozilla/accessible/public/nsIAccessibilityService.idl index 5430f5e85b1..815476451ef 100644 --- a/mozilla/accessible/public/nsIAccessibilityService.idl +++ b/mozilla/accessible/public/nsIAccessibilityService.idl @@ -28,22 +28,28 @@ #include "domstubs.idl" #include "nsIAccessible.idl" +interface nsIWeakReference; + [scriptable, uuid(68D9720A-0984-42b6-A3F5-8237ED925727)] interface nsIAccessibilityService : nsISupports { nsIAccessible createRootAccessible(in nsISupports aPresContext, in nsISupports aFrame); - nsIAccessible createHTMLSelectAccessible(in nsIAtom aAccessible, in nsIDOMNode aNode, in nsISupports aPresShell); + nsIAccessible createHTMLSelectAccessible(in nsIDOMNode aNode, in nsISupports aPresShell); + nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsISupports aPresShell); nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame); nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame); nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame); nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame); nsIAccessible createHTMLTextAccessible(in nsISupports aFrame); nsIAccessible createHTMLImageAccessible(in nsISupports aFrame); - nsIAccessible createHTMLAreaAccessible(in nsISupports aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent); + nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent); nsIAccessible createHTMLTableAccessible(in nsISupports aFrame); nsIAccessible createHTMLTableCellAccessible(in nsISupports aFrame); nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame); nsIAccessible createHTMLIFrameAccessible(in nsIDOMNode aNode, in nsISupports aPresContext); + nsIAccessible createHTMLBlockAccessible(in nsIDOMNode aNode, in nsISupports aDocument); + nsIAccessible createAccessible(in nsIDOMNode aNode, in nsISupports aDocument); + nsIAccessible GetAccessibleFor(in nsIWeakReference aPresShell, in nsIDOMNode aNode); }; diff --git a/mozilla/accessible/public/nsIAccessible.idl b/mozilla/accessible/public/nsIAccessible.idl index 8e131ddf3c5..d98116d34cf 100644 --- a/mozilla/accessible/public/nsIAccessible.idl +++ b/mozilla/accessible/public/nsIAccessible.idl @@ -26,29 +26,28 @@ #include "nsISupports.idl" #include "nsIDOMNode.idl" +#include "domstubs.idl" [scriptable, uuid(B26FBE47-9A5F-42a1-822B-082461AE4D6D)] interface nsIAccessible : nsISupports { - nsIAccessible getAccParent(); - nsIAccessible getAccNextSibling(); - nsIAccessible getAccPreviousSibling(); - nsIAccessible getAccFirstChild(); - nsIAccessible getAccLastChild(); + readonly attribute nsIAccessible accParent; + readonly attribute nsIAccessible accNextSibling; + readonly attribute nsIAccessible accPreviousSibling; + readonly attribute nsIAccessible accFirstChild; + readonly attribute nsIAccessible accLastChild; - long getAccChildCount(); - wstring getAccName(); - wstring getAccValue(); - void setAccName(in wstring name); - void setAccValue(in wstring value); + readonly attribute long accChildCount; + attribute DOMString accName; + readonly attribute DOMString accValue; - wstring getAccDescription(); - unsigned long getAccRole(); - unsigned long getAccState(); - unsigned long getAccExtState(); + readonly attribute DOMString accDescription; + readonly attribute unsigned long accRole; + readonly attribute unsigned long accState; + readonly attribute unsigned long accExtState; - wstring getAccHelp(); - nsIAccessible getAccFocused(); + readonly attribute DOMString accHelp; + readonly attribute nsIAccessible accFocused; nsIAccessible accGetAt(in long x, in long y); @@ -68,8 +67,8 @@ interface nsIAccessible : nsISupports void accTakeSelection(); void accTakeFocus(); - PRUint8 getAccNumActions(); - wstring getAccActionName(in PRUint8 index); + readonly attribute PRUint8 accNumActions; + DOMString getAccActionName(in PRUint8 index); void accDoAction(in PRUint8 index); // Action number 0 is the default action nsIDOMNode accGetDOMNode(); diff --git a/mozilla/accessible/public/nsIAccessibleDocument.idl b/mozilla/accessible/public/nsIAccessibleDocument.idl new file mode 100644 index 00000000000..f3b564a29a9 --- /dev/null +++ b/mozilla/accessible/public/nsIAccessibleDocument.idl @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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: Aaron Leventhal + * + * Contributor(s): + * John Gaunt + */ + +#include "nsISupports.idl" +#include "nsIAccessible.idl" +#include "domstubs.idl" +interface nsIDocument; + +[scriptable, uuid(8781FC88-355F-4439-881F-6504A0A1CEB6)] +interface nsIAccessibleDocument : nsISupports +{ + readonly attribute DOMString URL; + readonly attribute DOMString title; + readonly attribute DOMString mimeType; + readonly attribute DOMString docType; + DOMString getNameSpaceURIForID(in short nameSpaceID); + [noscript] nsIDocument getDocument(); + +}; diff --git a/mozilla/accessible/public/nsIAccessibleSelectable.idl b/mozilla/accessible/public/nsIAccessibleSelectable.idl new file mode 100644 index 00000000000..45908df85c4 --- /dev/null +++ b/mozilla/accessible/public/nsIAccessibleSelectable.idl @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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: John Gaunt (jgaunt@netscape.com) + * + * Contributor(s): + * John Gaunt + */ + +#include "nsISupports.idl" +#include "nsIAccessible.idl" +#include "nsISupportsArray.idl" + +[scriptable, uuid(34d268d6-1dd2-11b2-9d63-83a5e0ada290)] +interface nsIAccessibleSelectable : nsISupports +{ + nsISupportsArray GetSelectedChildren(); +}; diff --git a/mozilla/accessible/src/Makefile.in b/mozilla/accessible/src/Makefile.in index 5aef2e157b7..f5d32c1b908 100644 --- a/mozilla/accessible/src/Makefile.in +++ b/mozilla/accessible/src/Makefile.in @@ -41,10 +41,14 @@ CPPSRCS = \ nsHTMLImageAccessible.cpp \ nsHTMLAreaAccessible.cpp \ nsHTMLLinkAccessible.cpp \ - nsSelectAccessible.cpp \ + nsHTMLSelectAccessible.cpp \ nsGenericAccessible.cpp \ $(NULL) +EXPORTS = \ + nsRootAccessible.h \ + $(NULL) + # we don't want the shared lib, but we want to force the creation of a static lib. FORCE_STATIC_LIB = 1 diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 6ca72a6265e..e52eadb581b 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -33,14 +33,18 @@ #include "nsIFrame.h" #include "nsRootAccessible.h" #include "nsINameSpaceManager.h" -#include "nsHTMLFormControlAccessible.h" #include "nsLayoutAtoms.h" -#include "nsSelectAccessible.h" +#include "nsIDOMNode.h" #include "nsHTMLTextAccessible.h" #include "nsHTMLTableAccessible.h" #include "nsHTMLImageAccessible.h" #include "nsHTMLAreaAccessible.h" #include "nsHTMLLinkAccessible.h" +#include "nsHTMLSelectAccessible.h" +#include "nsIDOMHTMLAreaElement.h" +#include "nsHTMLFormControlAccessible.h" +#include "nsILink.h" +#include "nsIDocShellTreeItem.h" // IFrame #include "nsIDocShell.h" @@ -52,7 +56,6 @@ nsAccessibilityService::nsAccessibilityService() { NS_INIT_REFCNT(); - //printf("################################## nsAccessibilityService\n"); } nsAccessibilityService::~nsAccessibilityService() @@ -80,60 +83,76 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo NS_ASSERTION(s,"Error not presshell!!"); - nsCOMPtr