Compare commits
24 Commits
NETSCAPE_6
...
Style_2001
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97b3584524 | ||
|
|
eef60ca80d | ||
|
|
5433e8cb38 | ||
|
|
3f53da6800 | ||
|
|
1d3fa61b0c | ||
|
|
59afca8767 | ||
|
|
639785293e | ||
|
|
9eee880150 | ||
|
|
dfd5ce3d52 | ||
|
|
f168a0a31d | ||
|
|
1b218ccfff | ||
|
|
b102d25fcb | ||
|
|
7f69117d42 | ||
|
|
c18aa8f931 | ||
|
|
a59c7214d1 | ||
|
|
ce3bfe4651 | ||
|
|
7fb5739cdb | ||
|
|
fb8622adf3 | ||
|
|
cc593639ce | ||
|
|
c09ddbb296 | ||
|
|
ce577888bd | ||
|
|
e6ccd4d50e | ||
|
|
7179091daf | ||
|
|
4916a285e0 |
@@ -99,8 +99,13 @@ DIRS += \
|
||||
expat \
|
||||
htmlparser \
|
||||
gfx \
|
||||
gfx2 \
|
||||
modules/libpr0n \
|
||||
$(NULL)
|
||||
|
||||
ifdef USE_IMG2
|
||||
DIRS += gfx2 modules/libpr0n
|
||||
endif
|
||||
|
||||
DIRS += \
|
||||
modules/plugin \
|
||||
dom \
|
||||
view \
|
||||
@@ -115,27 +120,25 @@ DIRS += \
|
||||
sun-java \
|
||||
profile \
|
||||
themes \
|
||||
accessible \
|
||||
$(NULL)
|
||||
|
||||
ifdef ACCESSIBILITY
|
||||
DIRS += accessible
|
||||
endif
|
||||
|
||||
# This must preceed xpfe
|
||||
ifdef MOZ_JPROF
|
||||
DIRS += tools/jprof
|
||||
endif
|
||||
|
||||
ifdef MOZ_BUILD_XPFE
|
||||
DIRS += xpfe
|
||||
endif
|
||||
|
||||
DIRS += xpinstall
|
||||
|
||||
ifdef MOZ_PSM
|
||||
DIRS += security/manager
|
||||
ifdef MOZ_NSS_AUTOCONF
|
||||
DIRS += security/nss
|
||||
endif
|
||||
|
||||
ifdef MOZ_LDAP_XPCOM
|
||||
DIRS += directory/c-sdk/ldap directory/xpcom
|
||||
DIRS += security/manager
|
||||
endif
|
||||
|
||||
ifdef MOZ_EXTENSIONS
|
||||
@@ -154,9 +157,13 @@ ifdef ENABLE_TESTS
|
||||
DIRS += xpcom/tests
|
||||
endif
|
||||
|
||||
ifdef MOZ_LDAP_XPCOM
|
||||
DIRS += directory/c-sdk/ldap directory/xpcom
|
||||
endif
|
||||
|
||||
DIRS += l10n
|
||||
|
||||
ifneq (,$(MOZ_STATIC_COMPONENTS)$(MOZ_META_COMPONENTS))
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
DIRS += modules/staticmod
|
||||
endif
|
||||
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
<h1>How the Accessible module (accessibility.dll) works</h1>
|
||||
<ul>
|
||||
<p>
|
||||
See also:
|
||||
<a href="http://www.mozilla.org/projects/ui/accessibility/vendors-win.html">Gecko Info for Windows Accessibility Vendors</a>, a primer for vendors of 3rd party accessibility software, on how to use our MSAA and other relevant API's.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://lxr.mozilla.org/seamonkey/source/accessible/">Accessible module</a> is where we implement support for the <a href="http://www.microsoft.com/enable/msaa/">Microsoft Active Accessibility (MSAA) API</a>
|
||||
(<a href="http://bugzilla.mozilla.org/show_bug.cgi?id=12952">bug 12952</a>).
|
||||
Support for Sun's <a href="http://www.sun.com/access/gnome/">Gnome Accessibility API</a> is part of our future plans as well.
|
||||
@@ -74,8 +70,8 @@ checked, etc. </li>
|
||||
<li>get_accHelp: Get context sensitive help for the IAccessible.</li>
|
||||
<li>get_accHelpTopic: We don't use this, it's only if the Windows help system is used.</li>
|
||||
<li>get_accKeyboardShortcut: What is the keyboard shortcut for this IAccessible.</li>
|
||||
<li>get_accFocus: Which child is focused?</li>
|
||||
<li>get_accSelection: Which children of this item are selected?</li>
|
||||
<li>get_accFocus: Not sure, why aren't states used for this.</li>
|
||||
<li>get_accSelection: Hmm...</li>
|
||||
<li>get_accDefaultAction: Get a description or name of the default action for this component, such as "jump" for links.</li>
|
||||
|
||||
<li>accSelect: Select the item associated with this IAccessible.</li>
|
||||
@@ -87,66 +83,49 @@ checked, etc. </li>
|
||||
<li>put_accValue: Change the value.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</ul>
|
||||
<h2>The Basics</h2>
|
||||
<ul>
|
||||
<p>
|
||||
Rather than directly implement IAccessible with an Accessible class, we have chosen to proxy to our own cross-platform interface,
|
||||
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. 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.
|
||||
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.
|
||||
</p>
|
||||
<ul>
|
||||
<li>IAccessible (MSAA) is implemented by Accessible, which proxies to nsIAccessible (Mozilla's API)</li>
|
||||
<li>IAccessible is also implemented by RootAccessible, representing the root IAccessible for a window,
|
||||
and also proxies to an nsIAccessible. In this case nsIAccessible will be implemented by nsRootAccessible.</li>
|
||||
</ul>
|
||||
<p>
|
||||
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 <a href="http://lxr.mozilla.org/seamonkey/search?string=WM_GETOBJECT">WM_GETOBJECT</a> message requesting an IAccessible for the window.
|
||||
In our case, this event is received in mozilla/widget/src/windows/nsWindow.cpp.
|
||||
The first thing that happens when an accessibility aid wants to watch our application is it sends the main application
|
||||
window a <a href="http://lxr.mozilla.org/seamonkey/search?string=WM_GETOBJECT">WM_GETOBJECT</a> message requesting an IAccessible for the window. 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 first IAccessible to reach rest of the IAccessible hierarchy, by asking for it's children IAccessibles, asking the children for the
|
||||
that IAccessible to get at the rest of the tree, 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.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
<h2>How the IAccessible's are Created</h2>
|
||||
<ul>
|
||||
<p>
|
||||
To create the root IAccessible for a window the first time it gets the <a href="http://lxr.mozilla.org/seamonkey/search?string=WM_GETOBJECT">WM_GETOBJECT</a> message in,
|
||||
nsWindow.cpp first generates an internal event
|
||||
called <a href="http://lxr.mozilla.org/seamonkey/search?string=NS_GETACCESSIBLE">NS_GETACCESSIBLE</a>,
|
||||
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
|
||||
To create a RootAccessible IAccessible for the window we get a <a href="http://lxr.mozilla.org/seamonkey/search?string=WM_GETOBJECT">WM_GETOBJECT</a> message in, nsWindow.cpp first generates an internal event
|
||||
called <a href="http://lxr.mozilla.org/seamonkey/search?string=NS_GETACCESSIBLE">NS_GETACCESSIBLE</a>, 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
|
||||
in <a href="http://lxr.mozilla.org/seamonkey/source/widget/source/windows/Accessible.cpp">
|
||||
mozilla/widget/src/windows/Accessible.cpp</a>).
|
||||
</P>
|
||||
</ul>
|
||||
<h2>The Real Power Behind IAccessible's</h2>
|
||||
<ul>
|
||||
<p>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.
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
The base implementation for nsIAccessible is called nsAccessible. It has default implementations for all the
|
||||
nsIAccessible methods. It also knows how
|
||||
The impementation for nsIAccessible 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 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.
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
The specific implementations
|
||||
of nsIAccessible for each widget or content type inherit from nsAccessible.
|
||||
Each implementation then overrides those methods
|
||||
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
|
||||
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. However, nsImageAccessible overrides getAccFirstChild,
|
||||
returning the first area of an image map if there is one, otherwise nsnull.
|
||||
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).
|
||||
</p>
|
||||
|
||||
</ul>
|
||||
@@ -155,22 +134,18 @@ returning the first area of an image map if there is one, otherwise nsnull.
|
||||
<p>
|
||||
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 the Win32 call SetWinEventHook() to register as a listener for these events.
|
||||
within that window. Accessibility aids use a WIN32 call to register as a listener for these events.
|
||||
</p>
|
||||
<p>
|
||||
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().
|
||||
</p>
|
||||
<p>
|
||||
In Mozilla, this creates a problem. We cannot
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
@@ -31,7 +31,6 @@ LIBRARY_NAME = accessibility
|
||||
EXPORT_LIBRARY = 1
|
||||
SHORT_LIBNAME = access
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsAccessibilityModule
|
||||
REQUIRES = xpcom string dom
|
||||
|
||||
CPPSRCS = nsAccessibilityFactory.cpp
|
||||
@@ -39,19 +38,14 @@ CPPSRCS = nsAccessibilityFactory.cpp
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../src
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libaccessibility_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
$(DIST)/lib/libaccessibility_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libchrome_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LIBS = \
|
||||
gkconshared_s \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-L$(DIST)/lib \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
-lgkgfx \
|
||||
$(NULL)
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-lgkgfx \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
@@ -21,26 +21,27 @@
|
||||
|
||||
DEPTH=..\..
|
||||
MODULE=accessibility
|
||||
LIBRARY_NAME=accessibility
|
||||
MODULE_NAME=nsAccessibilityModule
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=accessibility
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
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)
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\timer_s.lib \
|
||||
$(DIST)\lib\gkgfx.lib \
|
||||
$(DIST)\lib\contentshared_s.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\accessibility_s.lib \
|
||||
$(DIST)\lib\timer_s.lib \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -32,14 +32,9 @@ XPIDL_MODULE= accessibility
|
||||
XPIDLSRCS = \
|
||||
nsIAccessibilityService.idl \
|
||||
nsIAccessible.idl \
|
||||
nsIAccessibleDocument.idl \
|
||||
nsIAccessibleEventReceiver.idl \
|
||||
nsIAccessibleEventListener.idl \
|
||||
nsIAccessibleSelectable.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
@@ -26,13 +26,8 @@ XPIDL_MODULE=accessibility
|
||||
XPIDLSRCS = \
|
||||
.\nsIAccessibilityService.idl \
|
||||
.\nsIAccessible.idl \
|
||||
.\nsIAccessibleDocument.idl \
|
||||
.\nsIAccessibleEventReceiver.idl \
|
||||
.\nsIAccessibleEventListener.idl \
|
||||
.\nsIAccessibleSelectable.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -28,29 +28,22 @@
|
||||
#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 createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell);
|
||||
nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell);
|
||||
nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsISupports aPresShell);
|
||||
nsIAccessible createHTMLSelectAccessible(in nsIAtom aAccessible, in nsIDOMNode aNode, 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 nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
|
||||
nsIAccessible createHTMLAreaAccessible(in nsISupports 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 nsIDOMNode aNode);
|
||||
};
|
||||
|
||||
|
||||
@@ -63,5 +56,4 @@ interface nsIAccessibilityService : nsISupports
|
||||
|
||||
extern nsresult
|
||||
NS_NewAccessibilityService(nsIAccessibilityService** aResult);
|
||||
|
||||
%}
|
||||
|
||||
@@ -26,28 +26,29 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIDOMNode.idl"
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(B26FBE47-9A5F-42a1-822B-082461AE4D6D)]
|
||||
interface nsIAccessible : nsISupports
|
||||
{
|
||||
readonly attribute nsIAccessible accParent;
|
||||
readonly attribute nsIAccessible accNextSibling;
|
||||
readonly attribute nsIAccessible accPreviousSibling;
|
||||
readonly attribute nsIAccessible accFirstChild;
|
||||
readonly attribute nsIAccessible accLastChild;
|
||||
nsIAccessible getAccParent();
|
||||
nsIAccessible getAccNextSibling();
|
||||
nsIAccessible getAccPreviousSibling();
|
||||
nsIAccessible getAccFirstChild();
|
||||
nsIAccessible getAccLastChild();
|
||||
|
||||
readonly attribute long accChildCount;
|
||||
attribute DOMString accName;
|
||||
readonly attribute DOMString accValue;
|
||||
long getAccChildCount();
|
||||
wstring getAccName();
|
||||
wstring getAccValue();
|
||||
void setAccName(in wstring name);
|
||||
void setAccValue(in wstring value);
|
||||
|
||||
readonly attribute DOMString accDescription;
|
||||
readonly attribute unsigned long accRole;
|
||||
readonly attribute unsigned long accState;
|
||||
readonly attribute unsigned long accExtState;
|
||||
wstring getAccDescription();
|
||||
unsigned long getAccRole();
|
||||
unsigned long getAccState();
|
||||
unsigned long getAccExtState();
|
||||
|
||||
readonly attribute DOMString accHelp;
|
||||
readonly attribute nsIAccessible accFocused;
|
||||
wstring getAccHelp();
|
||||
nsIAccessible getAccFocused();
|
||||
|
||||
nsIAccessible accGetAt(in long x, in long y);
|
||||
|
||||
@@ -67,8 +68,8 @@ interface nsIAccessible : nsISupports
|
||||
void accTakeSelection();
|
||||
void accTakeFocus();
|
||||
|
||||
readonly attribute PRUint8 accNumActions;
|
||||
DOMString getAccActionName(in PRUint8 index);
|
||||
PRUint8 getAccNumActions();
|
||||
wstring getAccActionName(in PRUint8 index);
|
||||
void accDoAction(in PRUint8 index); // Action number 0 is the default action
|
||||
|
||||
nsIDOMNode accGetDOMNode();
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/* -*- 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();
|
||||
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
/* -*- 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();
|
||||
};
|
||||
@@ -28,7 +28,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = accessibility
|
||||
LIBRARY_NAME = accessibility_s
|
||||
REQUIRES = xpcom string layout widget dom view locale intl docshell webshell necko htmlparser xuldoc imglib2 gfx2
|
||||
REQUIRES = xpcom string layout widget dom view locale gfx2 js intl docshell webshell necko uriloader htmlparser
|
||||
|
||||
CPPSRCS = \
|
||||
nsAccessible.cpp \
|
||||
@@ -41,18 +41,13 @@ CPPSRCS = \
|
||||
nsHTMLImageAccessible.cpp \
|
||||
nsHTMLAreaAccessible.cpp \
|
||||
nsHTMLLinkAccessible.cpp \
|
||||
nsHTMLSelectListAccessible.cpp \
|
||||
nsHTMLComboboxAccessible.cpp \
|
||||
nsHTMLListboxAccessible.cpp \
|
||||
nsSelectAccessible.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
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@ jump = Jump
|
||||
press = Press
|
||||
check = Check
|
||||
uncheck = Uncheck
|
||||
select = Select
|
||||
select = Select
|
||||
@@ -2,4 +2,4 @@ jump = Jump
|
||||
press = Press
|
||||
check = Check
|
||||
uncheck = Uncheck
|
||||
select = Select
|
||||
select = Select
|
||||
@@ -33,22 +33,14 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsSelectAccessible.h"
|
||||
#include "nsHTMLTextAccessible.h"
|
||||
#include "nsHTMLTableAccessible.h"
|
||||
#include "nsHTMLImageAccessible.h"
|
||||
#include "nsHTMLAreaAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
#include "nsHTMLComboboxAccessible.h"
|
||||
#include "nsHTMLListboxAccessible.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
|
||||
// IFrame
|
||||
#include "nsIDocShell.h"
|
||||
@@ -60,6 +52,7 @@
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
//printf("################################## nsAccessibilityService\n");
|
||||
}
|
||||
|
||||
nsAccessibilityService::~nsAccessibilityService()
|
||||
@@ -77,102 +70,70 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsAccessibilityService, nsIAccessibilityService);
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISupports* aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
// XXX - jgaunt - looks like we aren't using this
|
||||
//nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresShell> s;
|
||||
c->GetShell(getter_AddRefs(s));
|
||||
|
||||
NS_ASSERTION(presShell,"Error not presshell!!");
|
||||
NS_ASSERTION(s,"Error not presshell!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
|
||||
nsCOMPtr<nsIWeakReference> wr (getter_AddRefs(NS_GetWeakReference(s)));
|
||||
|
||||
*_retval = new nsRootAccessible(weakShell);
|
||||
if (! *_retval)
|
||||
//printf("################################## CreateRootAccessible\n");
|
||||
*_retval = new nsRootAccessible(wr);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
/*
|
||||
nsCOMPtr<nsIContent> n(do_QueryInterface(node));
|
||||
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
nsCOMPtr<nsIPresShell> s;
|
||||
c->GetShell(getter_AddRefs(s));
|
||||
|
||||
*_retval = new nsHTMLComboboxAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
|
||||
|
||||
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, node, wr);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*/
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
|
||||
*_retval = new nsHTMLListboxAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, nsIAccessible *aAccParent, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(aAccParent, aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLCheckboxAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLCheckboxAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -180,17 +141,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupport
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLRadioButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLRadioButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -198,17 +159,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aF
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTML4ButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -216,17 +177,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *a
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTML4ButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTML4ButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -234,17 +195,18 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTextAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
//printf("################################## CreateHTMLTextAccessible\n");
|
||||
*_retval = new nsHTMLTextAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,17 +215,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFr
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTableAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTableCellAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -271,17 +233,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableCellAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTableCellAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLImageAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -289,37 +251,36 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFr
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsIImageFrame* imageFrame = nsnull;
|
||||
|
||||
// not using a nsCOMPtr frames don't support them.
|
||||
aFrame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame);
|
||||
|
||||
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(aFrame));
|
||||
if (!imageFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = new nsHTMLImageAccessible(node, imageFrame, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLImageAccessible(shell, node, imageFrame);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLAreaAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsIWeakReference *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsISupports *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
|
||||
nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLAreaAccessible(aDOMNode, aAccParent, aShell);
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryInterface(aShell));
|
||||
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLAreaAccessible(shell, aDOMNode, aAccParent);
|
||||
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextFieldAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -327,103 +288,52 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTextFieldAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTextFieldAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode)
|
||||
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aNode)
|
||||
{
|
||||
NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
|
||||
*aRealFrame = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
nsCOMPtr<nsIContent> content;
|
||||
(*aRealFrame)->GetContent(getter_AddRefs(content));
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
*aNode = node;
|
||||
NS_IF_ADDREF(*aNode);
|
||||
NS_ADDREF(*aNode);
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
// do_GetWR only works into a |nsCOMPtr| :-(
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
weakShell = do_GetWeakReference(tempShell);
|
||||
NS_IF_ADDREF(*aShell = weakShell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateAccessible(nsIDOMNode* aDOMNode, nsISupports* aDocument, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document (do_QueryInterface(aDocument));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(tempShell);
|
||||
*aShell = document->GetShellAt(0);
|
||||
NS_IF_ADDREF(*aShell);
|
||||
|
||||
*_retval = new nsAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLBlockAccessible(nsIDOMNode* aDOMNode, nsISupports* aDocument, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document (do_QueryInterface(aDocument));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(tempShell);
|
||||
|
||||
*_retval = new nsAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||
NS_ASSERTION(content,"Error non nsIContent passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
@@ -433,12 +343,11 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
NS_ASSERTION(presShell,"Error non PresShell passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(presShell);
|
||||
nsCOMPtr<nsIWeakReference> weakRef (getter_AddRefs(NS_GetWeakReference(presShell)));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc))) && doc) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresShell> presShell = getter_AddRefs(doc->GetShellAt(0));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
presShell->GetSubShellFor(content, getter_AddRefs(supps));
|
||||
@@ -448,22 +357,13 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
nsCOMPtr<nsIPresShell> ps;
|
||||
docShell->GetPresShell(getter_AddRefs(ps));
|
||||
if (ps) {
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(ps);
|
||||
nsCOMPtr<nsIDocument> innerDoc;
|
||||
ps->GetDocument(getter_AddRefs(innerDoc));
|
||||
if (innerDoc) {
|
||||
nsCOMPtr<nsIAccessible> root = new nsHTMLIFrameRootAccessible(aDOMNode, wr);
|
||||
if ( root ) {
|
||||
nsHTMLIFrameAccessible* frameAcc = new nsHTMLIFrameAccessible(aDOMNode, root, weakRef, innerDoc);
|
||||
if ( frameAcc != nsnull ) {
|
||||
*_retval = NS_STATIC_CAST(nsIAccessible*, frameAcc);
|
||||
if ( *_retval ) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIWeakReference> wr (getter_AddRefs(NS_GetWeakReference(ps)));
|
||||
//printf("################################## CreateHTMLIFrameAccessible\n");
|
||||
|
||||
nsCOMPtr<nsIAccessible> root = new nsHTMLIFrameRootAccessible(wr,node);
|
||||
*_retval = new nsHTMLIFrameAccessible(presShell, node, root);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,198 +372,6 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// This method finds the content node in the parent document
|
||||
// corresponds to the docshell
|
||||
// This code is copied and pasted from nsEventStateManager.cpp
|
||||
// Is also inefficient - better solution should come along as part of
|
||||
// Bug 85602: "FindContentForDocShell walks entire content tree"
|
||||
// Hopefully there will be a better method soon, with a public interface
|
||||
|
||||
nsIContent*
|
||||
nsAccessibilityService::FindContentForDocShell(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIDocShell* aDocShell)
|
||||
{
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps));
|
||||
if (supps) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
|
||||
if (docShell.get() == aDocShell)
|
||||
return aContent;
|
||||
}
|
||||
|
||||
// walk children content
|
||||
PRInt32 count;
|
||||
aContent->ChildCount(count);
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
nsIContent* foundContent = FindContentForDocShell(aPresShell, child, aDocShell);
|
||||
if (foundContent != nsnull) {
|
||||
return foundContent;
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
aPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (!presContext)
|
||||
return;
|
||||
nsCOMPtr<nsISupports> pcContainer;
|
||||
presContext->GetContainer(getter_AddRefs(pcContainer));
|
||||
if (!pcContainer)
|
||||
return;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
if (!treeItem)
|
||||
return;
|
||||
|
||||
// Get Parent Doc
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItemParent;
|
||||
treeItem->GetParent(getter_AddRefs(treeItemParent));
|
||||
if (!treeItemParent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShell> parentDS(do_QueryInterface(treeItemParent));
|
||||
if (!parentDS)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
||||
parentDS->GetPresShell(getter_AddRefs(parentPresShell));
|
||||
if (!parentPresShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> parentDoc;
|
||||
parentPresShell->GetDocument(getter_AddRefs(parentDoc));
|
||||
if (!parentDoc)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
parentDoc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
nsIContent *tempContent;
|
||||
tempContent = FindContentForDocShell(parentPresShell, rootContent, docShell);
|
||||
if (tempContent) {
|
||||
*aOwnerContent = tempContent;
|
||||
*aOwnerShell = parentPresShell;
|
||||
NS_ADDREF(*aOwnerShell);
|
||||
NS_ADDREF(*aOwnerContent);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------
|
||||
* GetAccessibleFor - get an nsIAccessible from a DOM node
|
||||
* ------------------------------------------------------- */
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
||||
nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
if (!aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// ---- Get the document for this node ----
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIDocument> nodeIsDoc(do_QueryInterface(aNode));
|
||||
if (nodeIsDoc)
|
||||
doc = nodeIsDoc;
|
||||
else {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
doc = do_QueryInterface(domDoc);
|
||||
}
|
||||
if (!doc)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// ---- Get the pres shell ----
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// ---- 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
|
||||
|
||||
// ---- Check if we need outer owning doc ----
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
if (!content && nodeIsDoc) {
|
||||
// This happens when we're on the document node, which will not QI to an nsIContent,
|
||||
// When that happens, we try to get the outer, parent document node that contains the document
|
||||
// For example, a <browser> or <iframe> element
|
||||
nsCOMPtr<nsIPresShell> ownerShell;
|
||||
nsCOMPtr<nsIContent> ownerContent;
|
||||
GetOwnerFor(shell, getter_AddRefs(ownerShell), getter_AddRefs(ownerContent));
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
}
|
||||
|
||||
// ---- If still no nsIContent, return ----
|
||||
if (!content)
|
||||
return PR_FALSE;
|
||||
|
||||
// ---- Try using frame to get IAccessible ----
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
frame->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
||||
// ---- Try QI'ing node to get nsIAccessible ----
|
||||
if (!newAcc)
|
||||
newAcc = do_QueryInterface(aNode);
|
||||
|
||||
// ---- If link, create link accessible ----
|
||||
if (!newAcc) {
|
||||
// is it a link?
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(aNode));
|
||||
if (link) {
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(shell));
|
||||
newAcc = new nsHTMLLinkAccessible(aNode, weakShell);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- If <select> option, create select option accessible
|
||||
if (!newAcc) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(do_QueryInterface(aNode));
|
||||
if (optionElement) {
|
||||
// nsHTMLSelectionOptionAccessible's must be created via the parent
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
aNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
if (parentNode) {
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
GetAccessibleFor(parentNode, getter_AddRefs(parentAccessible));
|
||||
if (parentAccessible) {
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(shell));
|
||||
newAcc = new nsHTMLSelectOptionAccessible(parentAccessible, aNode, weakShell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!newAcc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = newAcc;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -675,11 +383,11 @@ NS_NewAccessibilityService(nsIAccessibilityService** aResult)
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAccessibilityService* accService = new nsAccessibilityService();
|
||||
if (!accService)
|
||||
nsAccessibilityService* a = new nsAccessibilityService();
|
||||
if (a == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(accService);
|
||||
*aResult = accService;
|
||||
NS_ADDREF(a);
|
||||
*aResult = a;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,8 @@
|
||||
#define __nsAccessibilityService_h__
|
||||
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIWeakReference;
|
||||
class nsIPresShell;
|
||||
class nsIDOMNode;
|
||||
|
||||
class nsAccessibilityService : public nsIAccessibilityService
|
||||
@@ -50,9 +46,7 @@ public:
|
||||
public:
|
||||
|
||||
private:
|
||||
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent);
|
||||
void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent);
|
||||
nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell);
|
||||
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aContent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
#define _nsAccessible_H_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
@@ -42,27 +42,16 @@ class nsIDocShell;
|
||||
class nsIWebShell;
|
||||
class nsIContent;
|
||||
|
||||
class nsAccessible : public nsGenericAccessible
|
||||
class nsAccessible : public nsIAccessible
|
||||
// public nsIAccessibleWidgetAccess
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFocused(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD AccRemoveSelection(void);
|
||||
NS_IMETHOD AccTakeSelection(void);
|
||||
NS_IMETHOD AccTakeFocus(void);
|
||||
NS_IMETHOD AccGetDOMNode(nsIDOMNode **_retval);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIAccessibilityService methods:
|
||||
NS_DECL_NSIACCESSIBLE
|
||||
|
||||
public:
|
||||
nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual ~nsAccessible();
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
|
||||
@@ -93,63 +82,33 @@ public:
|
||||
nsRect& aAbsoluteTwipsRect,
|
||||
nsRect& aAbsolutePixelRect);
|
||||
static nsresult GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut);
|
||||
|
||||
// helper method to verify frames
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
|
||||
protected:
|
||||
virtual nsIFrame* GetFrame();
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual void GetPresContext(nsCOMPtr<nsIPresContext>& aContext);
|
||||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewParentAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
// Data Members
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIAccessible> mAccessible;
|
||||
nsCOMPtr<nsIFocusController> mFocusController;
|
||||
|
||||
};
|
||||
|
||||
/* Special Accessible that knows how to handle hit detection for flowing text */
|
||||
class nsHTMLBlockAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLBlockAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
|
||||
protected:
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aFrame, nsIWeakReference* aShell);
|
||||
};
|
||||
|
||||
/* Leaf version of DOM Accessible
|
||||
* has no children
|
||||
*/
|
||||
class nsLeafAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsLinkableAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
|
||||
protected:
|
||||
PRBool IsALink();
|
||||
PRBool mIsALinkCached; // -1 = unknown, 0 = not a link, 1 = is a link
|
||||
nsCOMPtr<nsIContent> mLinkContent;
|
||||
PRBool mIsLinkVisited;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,12 +22,25 @@
|
||||
*/
|
||||
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILink.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLBRElement.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsGenericAccessible, nsIAccessible)
|
||||
@@ -80,25 +93,31 @@ NS_IMETHODIMP nsGenericAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void setAccName (in wstring name); */
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccName(const nsAReadableString& name)
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccName(const PRUnichar *name)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void setAccValue (in wstring value); */
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccValue(const PRUnichar *value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccDescription (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -122,7 +141,7 @@ NS_IMETHODIMP nsGenericAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -140,7 +159,7 @@ NS_IMETHODIMP nsGenericAccessible::GetAccFocused(nsIAccessible **_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccHelp (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -222,4 +241,356 @@ NS_IMETHODIMP nsGenericAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//-------------
|
||||
// nsDOMAccessible
|
||||
//-------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAccessible::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMNode))) {
|
||||
nsIDOMNode* node = mNode;
|
||||
*aResult = (void*) node;
|
||||
NS_ADDREF(node);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsGenericAccessible::QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
nsDOMAccessible::nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode)
|
||||
{
|
||||
mPresShell = do_GetWeakReference(aShell);
|
||||
mNode = aNode;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
||||
{
|
||||
*_retval = mNode;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void accRemoveSelection (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccRemoveSelection()
|
||||
{
|
||||
nsCOMPtr<nsISelectionController> control(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = control->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = mNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = selection->Collapse(parent, 0);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void accTakeSelection (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccTakeSelection()
|
||||
{
|
||||
nsCOMPtr<nsISelectionController> control(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = control->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = mNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 offsetInParent = 0;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
rv = parent->GetFirstChild(getter_AddRefs(child));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> next;
|
||||
|
||||
while(child)
|
||||
{
|
||||
if (child == mNode) {
|
||||
// Collapse selection to just before desired element,
|
||||
rv = selection->Collapse(parent, offsetInParent);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// then extend it to just after
|
||||
rv = selection->Extend(parent, offsetInParent+1);
|
||||
return rv;
|
||||
}
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(next));
|
||||
child = next;
|
||||
offsetInParent++;
|
||||
}
|
||||
|
||||
// didn't find a child
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void accTakeFocus (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccTakeFocus()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
content->SetFocus(context);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent(do_QueryInterface(aContent));
|
||||
if (textContent) {
|
||||
nsCOMPtr<nsIDOMComment> commentNode(do_QueryInterface(aContent));
|
||||
if (!commentNode) {
|
||||
PRBool isHTMLBlock = PR_FALSE;
|
||||
nsIFrame *frame;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
aContent->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent) {
|
||||
nsresult rv = shell->GetPrimaryFrameFor(parentContent, &frame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// If this text is inside a block level frame (as opposed to span level), we need to add spaces around that
|
||||
// block's text, so we don't get words jammed together in final name
|
||||
// Extra spaces will be trimmed out later
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
frame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (styleContext) {
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (display->IsBlockLevel() || display->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
isHTMLBlock = PR_TRUE;
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsAutoString text;
|
||||
textContent->CopyText(text);
|
||||
if (text.Length()>0)
|
||||
aFlatString->Append(text);
|
||||
if (isHTMLBlock)
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLBRElement> brElement(do_QueryInterface(aContent));
|
||||
if (brElement) {
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> imageContent(do_QueryInterface(aContent));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputContent(do_QueryInterface(aContent));
|
||||
if (imageContent || inputContent) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aContent));
|
||||
nsAutoString textEquivalent;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("alt"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("name"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("src"), textEquivalent);
|
||||
if (!textEquivalent.IsEmpty()) {
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
aFlatString->Append(textEquivalent);
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString)
|
||||
{
|
||||
// Depth first search for all text nodes that are decendants of content node.
|
||||
// Append all the text into one flat string
|
||||
|
||||
PRInt32 numChildren = 0;
|
||||
|
||||
aContent->ChildCount(numChildren);
|
||||
if (numChildren == 0) {
|
||||
nsAutoString contentText;
|
||||
AppendFlatStringFromContentNode(aContent, aFlatString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *contentWalker;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < numChildren; index++) {
|
||||
aContent->ChildAt(index, contentWalker);
|
||||
AppendFlatStringFromSubtree(contentWalker, aFlatString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------
|
||||
// nsLeafFrameAccessible
|
||||
//-------------
|
||||
|
||||
nsLeafDOMAccessible::nsLeafDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccLastChild (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getAccChildCount (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------
|
||||
// nsLinkableAccessible
|
||||
//----------------
|
||||
|
||||
nsLinkableAccessible::nsLinkableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode), mIsALinkCached(PR_FALSE), mLinkContent(nsnull), mIsLinkVisited(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
/* long GetAccState (); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval |= STATE_READONLY | STATE_SELECTABLE;
|
||||
if (IsALink()) {
|
||||
*_retval |= STATE_FOCUSABLE | STATE_LINKED;
|
||||
if (mIsLinkVisited)
|
||||
*_retval |= STATE_TRAVERSED;
|
||||
}
|
||||
|
||||
// Get current selection and find out if current node is in it
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
nsIFrame *frame;
|
||||
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
frame->GetSelectionController(context,getter_AddRefs(selCon));
|
||||
if (selCon) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
|
||||
if (domSel) {
|
||||
PRBool isSelected = PR_FALSE, isCollapsed = PR_TRUE;
|
||||
domSel->ContainsNode(mNode, PR_TRUE, &isSelected);
|
||||
domSel->GetIsCollapsed(&isCollapsed);
|
||||
if (isSelected && !isCollapsed)
|
||||
*_retval |=STATE_SELECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Focused? Do we implement that here or up the chain?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;;
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (IsALink()) {
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("jump"));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (IsALink()) {
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
nsMouseEvent linkClickEvent;
|
||||
linkClickEvent.eventStructType = NS_EVENT;
|
||||
linkClickEvent.message = NS_MOUSE_LEFT_CLICK;
|
||||
linkClickEvent.isShift = PR_FALSE;
|
||||
linkClickEvent.isControl = PR_FALSE;
|
||||
linkClickEvent.isAlt = PR_FALSE;
|
||||
linkClickEvent.isMeta = PR_FALSE;
|
||||
linkClickEvent.clickCount = 0;
|
||||
linkClickEvent.widget = nsnull;
|
||||
|
||||
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
||||
mLinkContent->HandleDOMEvent(presContext, &linkClickEvent,
|
||||
nsnull, NS_EVENT_FLAG_INIT, &eventStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsLinkableAccessible::IsALink()
|
||||
{
|
||||
if (mIsALinkCached) // Cached answer?
|
||||
return mLinkContent? PR_TRUE: PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
|
||||
if (walkUpContent) {
|
||||
nsCOMPtr<nsIContent> tempContent = walkUpContent;
|
||||
while (walkUpContent) {
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(walkUpContent));
|
||||
if (link) {
|
||||
mLinkContent = tempContent;
|
||||
mIsALinkCached = PR_TRUE;
|
||||
nsLinkState linkState;
|
||||
link->GetLinkState(linkState);
|
||||
if (linkState == eLinkState_Visited)
|
||||
mIsLinkVisited = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
walkUpContent->GetParent(*getter_AddRefs(tempContent));
|
||||
walkUpContent = tempContent;
|
||||
}
|
||||
}
|
||||
mIsALinkCached = PR_TRUE; // Cached that there is no link
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@@ -47,5 +47,61 @@ class nsGenericAccessible : public nsIAccessible
|
||||
virtual ~nsGenericAccessible();
|
||||
};
|
||||
|
||||
/**
|
||||
* And accessible that observes a dom node
|
||||
* supports:
|
||||
* - selection
|
||||
* - focus
|
||||
*/
|
||||
class nsDOMAccessible : public nsGenericAccessible
|
||||
{
|
||||
public:
|
||||
nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD AccTakeSelection(void);
|
||||
NS_IMETHOD AccTakeFocus(void);
|
||||
NS_IMETHOD AccRemoveSelection(void);
|
||||
NS_IMETHOD AccGetDOMNode(nsIDOMNode **_retval);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIDOMNode> mNode;
|
||||
};
|
||||
|
||||
/* Leaf version of DOM Accessible
|
||||
* has no children
|
||||
*/
|
||||
class nsLeafDOMAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsLeafDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsLinkableAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsLinkableAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMNode> mDomNode;
|
||||
PRBool IsALink();
|
||||
PRBool mIsALinkCached; // -1 = unknown, 0 = not a link, 1 = is a link
|
||||
nsCOMPtr<nsIContent> mLinkContent;
|
||||
PRBool mIsLinkVisited;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
@@ -36,24 +35,9 @@
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
|
||||
@@ -61,24 +45,18 @@ NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsAccessible)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsAccessible);
|
||||
|
||||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,aShell),
|
||||
nsDocAccessibleMixin(aShell), mAccService(do_GetService("@mozilla.org/accessibilityService;1"))
|
||||
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,nsnull,aShell)
|
||||
{
|
||||
mListener = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
shell->GetDocument(getter_AddRefs(mDocument));
|
||||
mDOMNode = do_QueryInterface(mDocument);
|
||||
|
||||
nsLayoutAtoms::AddRefAtoms();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
@@ -86,23 +64,24 @@ nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull
|
||||
//-----------------------------------------------------
|
||||
nsRootAccessible::~nsRootAccessible()
|
||||
{
|
||||
nsLayoutAtoms::ReleaseAtoms();
|
||||
RemoveAccessibleEventListener(mListener);
|
||||
}
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccName(nsAWritableString& aAccName)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
return GetTitle(aAccName);
|
||||
const nsString* docTitle = mDocument->GetDocumentTitle();
|
||||
if (docTitle && !docTitle->IsEmpty())
|
||||
*aAccName = docTitle->ToNewUnicode();
|
||||
else *aAccName = ToNewUnicode(NS_LITERAL_STRING("Document"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// helpers
|
||||
nsIFrame* nsRootAccessible::GetFrame()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell)
|
||||
return nsnull;
|
||||
|
||||
nsIFrame* root = nsnull;
|
||||
if (shell)
|
||||
shell->GetRootFrame(&root);
|
||||
@@ -116,6 +95,11 @@ void nsRootAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
(*aRelativeFrame)->GetRect(aBounds);
|
||||
}
|
||||
|
||||
nsIAccessible* nsRootAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell)
|
||||
{
|
||||
return new nsHTMLBlockAccessible(aAccessible, aNode, aShell);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
{
|
||||
@@ -127,16 +111,6 @@ NS_IMETHODIMP nsRootAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
*aAccRole = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
// Commenting this out for now.
|
||||
// It was requested that we always use pane objects instead of client objects.
|
||||
// However, it might be asked that we put client objects back.
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsISupports> container;
|
||||
@@ -154,21 +128,16 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
|
||||
}
|
||||
|
||||
*aAccRole = ROLE_CLIENT;
|
||||
*/
|
||||
|
||||
*aAccRole = ROLE_PANE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccState(PRUint32 *aAccState)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccValue(PRUnichar * *aAccValue)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetAccState(aAccState);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccValue(nsAWritableString& aAccValue)
|
||||
{
|
||||
return GetURL(aAccValue);
|
||||
nsCOMPtr<nsIURI> pURI(mDocument->GetDocumentURL());
|
||||
char *path;
|
||||
pURI->GetSpec(&path);
|
||||
*aAccValue = ToNewUnicode(nsLiteralCString(path));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
|
||||
@@ -178,9 +147,6 @@ NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventLis
|
||||
{
|
||||
// add an event listener to the document
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
shell->GetDocument(getter_AddRefs(document));
|
||||
|
||||
@@ -244,64 +210,70 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
|
||||
NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (mListener) {
|
||||
// optionTargetNode is set to current option for HTML selects
|
||||
nsCOMPtr<nsIDOMNode> targetNode, optionTargetNode;
|
||||
nsresult rv = GetTargetNode(aEvent, targetNode);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Check to see if it's a select element. If so, need the currently focused option
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(targetNode));
|
||||
if (selectElement) // ----- Target Node is an HTML <select> element ------
|
||||
nsHTMLSelectOptionAccessible::GetFocusedOptionNode(mPresShell, targetNode, optionTargetNode);
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
aEvent->GetOriginalTarget(getter_AddRefs(t));
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(t));
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString eventType;
|
||||
aEvent->GetType(eventType);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
// the "focus" type is pulled from nsDOMEvent.cpp
|
||||
if ( eventType.EqualsIgnoreCase("focus") ) {
|
||||
if (mCurrentFocus == content)
|
||||
return NS_OK;
|
||||
mCurrentFocus = content;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAccessible> a(do_QueryInterface(frame));
|
||||
if (!a)
|
||||
a = do_QueryInterface(content);
|
||||
|
||||
if (!a) {
|
||||
// is it a link?
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(content));
|
||||
if (link) {
|
||||
#ifdef DEBUG
|
||||
printf("focus link!\n");
|
||||
#endif
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
if (node)
|
||||
a = new nsHTMLLinkAccessible(shell, node);
|
||||
}
|
||||
}
|
||||
|
||||
if (a) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> na(CreateNewAccessible(a, node, mPresShell));
|
||||
if ( !na )
|
||||
return NS_OK;
|
||||
|
||||
if (NS_SUCCEEDED(mAccService->GetAccessibleFor(targetNode, getter_AddRefs(accessible)))) {
|
||||
if ( eventType.EqualsIgnoreCase("focus") ) {
|
||||
if (mCurrentFocus != targetNode) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, accessible);
|
||||
mCurrentFocus = targetNode;
|
||||
}
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("change") ) {
|
||||
if (optionTargetNode) { // Set to current option only for HTML selects
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_SELECTION, accessible);
|
||||
if (mCurrentFocus != optionTargetNode &&
|
||||
NS_SUCCEEDED(mAccService->GetAccessibleFor(optionTargetNode, getter_AddRefs(accessible)))) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, accessible);
|
||||
mCurrentFocus = optionTargetNode;
|
||||
}
|
||||
}
|
||||
else
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("CheckboxStateChange") ) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("RadiobuttonStateChange") ) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr<nsIDOMNode>& aTargetNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
|
||||
aEvent->GetOriginalTarget(getter_AddRefs(domEventTarget));
|
||||
|
||||
nsresult rv;
|
||||
aTargetNode = do_QueryInterface(domEventTarget, &rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// ------- nsIDOMFocusListener Methods (1) -------------
|
||||
// ------- nsIDOMFocusListener Methods (2) -------------
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
@@ -332,147 +304,5 @@ NS_IMETHODIMP nsRootAccessible::Select(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
// gets Input events when text is entered or deleted in a textarea or input
|
||||
NS_IMETHODIMP nsRootAccessible::Input(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
// ------- nsIAccessibleDocument Methods (5) ---------------
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetURL(aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetMimeType(aMimeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocType(aDocType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetNameSpaceURIForID(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
|
||||
nsDocAccessibleMixin::nsDocAccessibleMixin(nsIDocument *aDoc):mDocument(aDoc)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocAccessibleMixin::nsDocAccessibleMixin(nsIWeakReference *aPresShell)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
shell->GetDocument(getter_AddRefs(mDocument));
|
||||
}
|
||||
|
||||
nsDocAccessibleMixin::~nsDocAccessibleMixin()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
nsCOMPtr<nsIURI> pURI;
|
||||
mDocument->GetDocumentURL(getter_AddRefs(pURI));
|
||||
nsXPIDLCString path;
|
||||
pURI->GetSpec(getter_Copies(path));
|
||||
aURL.Assign(NS_ConvertUTF8toUCS2(path).get());
|
||||
//XXXaaronl Need to use CopyUTF8toUCS2(nsDependentCString(path), aURL); when it's written
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
// This doesn't leak - we don't own the const pointer that's returned
|
||||
aTitle = *(mDocument->GetDocumentTitle());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
if (mDocument)
|
||||
return mDocument->GetContentType(aMimeType);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMDocumentType> docType;
|
||||
|
||||
if (xulDoc) {
|
||||
aDocType = NS_LITERAL_STRING("window"); // doctype not implemented for XUL at time of writing - causes assertion
|
||||
return NS_OK;
|
||||
}
|
||||
else if (domDoc && NS_SUCCEEDED(domDoc->GetDoctype(getter_AddRefs(docType))) && docType) {
|
||||
return docType->GetName(aDocType);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsINameSpaceManager> nameSpaceManager;
|
||||
if (NS_SUCCEEDED(mDocument->GetNameSpaceManager(*getter_AddRefs(nameSpaceManager))))
|
||||
return nameSpaceManager->GetNameSpaceURI(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
*doc = mDocument;
|
||||
if (mDocument) {
|
||||
NS_IF_ADDREF(*doc);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetAccState(PRUint32 *aAccState)
|
||||
{
|
||||
// Screen readers need to know when the document is finished loading (STATE_BUSY flag)
|
||||
// We do it this way, rather than via nsIWebProgressListener, because
|
||||
// if accessibility was turned on after a document already finished loading,
|
||||
// we would get no state changes from nsIWebProgressListener.
|
||||
// The GetBusyFlags method, however, always has the current busy state information for us.
|
||||
|
||||
*aAccState = 0;
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
presShell->GetPresContext(getter_AddRefs(context));
|
||||
if (context) {
|
||||
nsCOMPtr<nsISupports> container;
|
||||
context->GetContainer(getter_AddRefs(container));
|
||||
if (container) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
if (docShell) {
|
||||
PRUint32 busyFlags;
|
||||
docShell->GetBusyFlags(&busyFlags);
|
||||
if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE)
|
||||
*aAccState = nsIAccessible::STATE_BUSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -26,35 +26,17 @@
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleEventReceiver.h"
|
||||
#include "nsIAccessibleEventListener.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
|
||||
class nsDocAccessibleMixin
|
||||
{
|
||||
public:
|
||||
nsDocAccessibleMixin(nsIDocument *doc);
|
||||
nsDocAccessibleMixin(nsIWeakReference *aShell);
|
||||
virtual ~nsDocAccessibleMixin();
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
class nsRootAccessible : public nsAccessible,
|
||||
public nsDocAccessibleMixin,
|
||||
public nsIAccessibleDocument,
|
||||
public nsIAccessibleEventReceiver,
|
||||
public nsIDOMFocusListener,
|
||||
public nsIDOMFormListener
|
||||
|
||||
{
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
@@ -62,11 +44,10 @@ class nsRootAccessible : public nsAccessible,
|
||||
virtual ~nsRootAccessible();
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& aAccValue);
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
NS_IMETHOD GetAccValue(PRUnichar * *aAccValue);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
// ----- nsIAccessibleEventReceiver -------------------
|
||||
|
||||
@@ -87,19 +68,17 @@ class nsRootAccessible : public nsAccessible,
|
||||
NS_IMETHOD Select(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Input(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
protected:
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsIFrame* GetFrame();
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr<nsIDOMNode>& aTargetNode);
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsIFrame* GetFrame();
|
||||
|
||||
// not a com pointer. We don't own the listener
|
||||
// it is the callers responsibility to remove the listener
|
||||
// otherwise we will get into circular referencing problems
|
||||
nsIAccessibleEventListener* mListener;
|
||||
nsCOMPtr<nsIDOMNode> mCurrentFocus;
|
||||
nsCOMPtr<nsIAccessibilityService> mAccService;
|
||||
// not a com pointer. We don't own the listener
|
||||
// it is the callers responsibility to remove the listener
|
||||
// otherwise we will get into circular referencing problems
|
||||
nsIAccessibleEventListener* mListener;
|
||||
nsCOMPtr<nsIContent> mCurrentFocus;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
|
||||
|
||||
722
mozilla/accessible/src/base/nsSelectAccessible.cpp
Normal file
722
mozilla/accessible/src/base/nsSelectAccessible.cpp
Normal file
@@ -0,0 +1,722 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsSelectAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
//#include "nsMutableAccessible.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMMenuListener.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#if 0
|
||||
class nsSelectChildAccessible : public nsAccessible,
|
||||
public nsIDOMMenuListener
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsSelectChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectChildAccessible();
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
|
||||
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
// popup listener
|
||||
NS_IMETHOD Create(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Destroy(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Action(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIContent> mSelectContent;
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsSelectChildAccessible, nsAccessible, nsIDOMMenuListener)
|
||||
|
||||
class nsSelectWindowAccessible : public nsAccessible,
|
||||
public nsIDOMMenuListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aPrev, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectWindowAccessible();
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccExtState(PRUint32 *_retval);
|
||||
|
||||
// popup listener
|
||||
NS_IMETHOD Create(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Destroy(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Action(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
// helpers
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIAccessible> mPrev;
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsSelectWindowAccessible, nsAccessible, nsIDOMMenuListener)
|
||||
|
||||
class nsSelectListAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectListAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
class nsListChildAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsListChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsListChildAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIContent> mSelectContent;
|
||||
};
|
||||
|
||||
//---------
|
||||
|
||||
nsSelectAccessible::nsSelectAccessible(nsIAtom* aPopupAtom,
|
||||
nsIAccessible* aAccessible,
|
||||
nsIContent* aContent,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
// our value is our first child's value. Which is the combo boxes text.
|
||||
nsCOMPtr<nsIAccessible> text;
|
||||
nsresult rv = GetAccFirstChild(getter_AddRefs(text));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// look at our role
|
||||
return text->GetAccValue(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_COMBOBOX;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
// get the last child. Wrap it with a connector that connects it to the window accessible
|
||||
nsCOMPtr<nsIAccessible> last;
|
||||
nsresult rv = nsAccessible::GetAccLastChild(getter_AddRefs(last));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!last) {
|
||||
// we have a parent but not previous
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, this, nsnull, nsnull, mContent, mPresShell);
|
||||
} else {
|
||||
*_retval = last;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
// get the last child. Wrap it with a connector that connects it to the window accessible
|
||||
nsCOMPtr<nsIAccessible> first;
|
||||
nsresult rv = nsAccessible::GetAccFirstChild(getter_AddRefs(first));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!first) {
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, this, nsnull, nsnull, mContent, mPresShell);
|
||||
} else {
|
||||
*_retval = first;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectAccessible::CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
return CreateNewLastAccessible(aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectAccessible::CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsSelectChildAccessible(mPopupAtom, mContent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = nsAccessible::GetAccChildCount(_retval);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// always have one more that is our window child
|
||||
(*_retval)++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
|
||||
nsSelectChildAccessible::nsSelectChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell):
|
||||
nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
mSelectContent = aSelectContent;
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
rv = nsAccessible::GetAccRole(&role);
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// if its the text in the combo box then
|
||||
// its value should be its name.
|
||||
if (role == ROLE_TEXT) {
|
||||
rv = nsAccessible::GetAccName(_retval);
|
||||
} else {
|
||||
rv = nsAccessible::GetAccValue(_retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
rv = nsAccessible::GetAccRole(&role);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// any text in the combo box is static
|
||||
if (role == ROLE_STATICTEXT) {
|
||||
// if it the comboboxes text. Make it static
|
||||
*_retval = role;
|
||||
} else {
|
||||
rv = nsAccessible::GetAccRole(_retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
nsAccessible::GetAccRole(&role);
|
||||
|
||||
// if button then we need to make the name be open or close
|
||||
if (role == ROLE_PUSHBUTTON) {
|
||||
{
|
||||
// if its a button and not already registered,
|
||||
// register ourselves as a popup listener
|
||||
if (!mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
|
||||
if (!eventReceiver) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
eventReceiver->AddEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
// get the current state open or closed
|
||||
// set _retval to it.
|
||||
// notice its supposed to be reversed. Close if opened
|
||||
// and Open if closed.
|
||||
|
||||
if (mOpen)
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("Close"));
|
||||
else
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("Open"));
|
||||
|
||||
} else {
|
||||
/*rv = nsAccessible::GetAccName(_retval);*/
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
*_retval = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsSelectChildAccessible::~nsSelectChildAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
#ifdef DEBUG
|
||||
printf("Open\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectChildAccessible::CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
return CreateNewPreviousAccessible(aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectChildAccessible::CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsSelectChildAccessible(mPopupAtom, mSelectContent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> next;
|
||||
nsresult rv = nsAccessible::GetAccNextSibling(getter_AddRefs(next));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!next) {
|
||||
// ok no more siblings. Lets create our window
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, parent, nsnull, nsnull, mSelectContent, mPresShell);
|
||||
} else {
|
||||
*_retval = next;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
nsSelectWindowAccessible::nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aPrev, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
mPrev = aPrev;
|
||||
mPopupAtom = aPopupAtom;
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
nsSelectWindowAccessible::~nsSelectWindowAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
#ifdef DEBUG
|
||||
printf("Open\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// not not already one register ourselves as a popup listener
|
||||
|
||||
if (!mRegistered) {
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
|
||||
if (!eventReceiver) {
|
||||
*_retval = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult rv = eventReceiver->AddEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
// if open we are visible if closed we are invisible
|
||||
// set _retval to it.
|
||||
if (mOpen)
|
||||
*_retval |= STATE_DEFAULT;
|
||||
else
|
||||
*_retval |= STATE_INVISIBLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccExtState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval=0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mPrev;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsSelectListAccessible(mPopupAtom, this, nsnull, mContent, mPresShell);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsSelectListAccessible(mPopupAtom, this, nsnull, mContent, mPresShell);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
*x = *y = *width = *height = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
nsIFrame* nsSelectWindowAccessible::GetBoundsFrame()
|
||||
{
|
||||
// get our frame
|
||||
nsIFrame* frame = GetFrame();
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
// get its first popup child that should be the window
|
||||
frame->FirstChild(context, mPopupAtom, &frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
//----------
|
||||
|
||||
|
||||
nsSelectListAccessible::nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
void nsSelectListAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mContent, &frame);
|
||||
if (aFrame == frame)
|
||||
aList = mPopupAtom;
|
||||
else
|
||||
aList = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return mParent->AccGetBounds(x,y,width,height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LIST;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectListAccessible::CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mContent, this, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectListAccessible::CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mContent, this, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
//--------
|
||||
|
||||
nsListChildAccessible::nsListChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell):
|
||||
nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
mPopupAtom = aPopupAtom;
|
||||
mSelectContent = aSelectContent;
|
||||
}
|
||||
|
||||
nsIAccessible* nsListChildAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mSelectContent, mParent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mSelectContent, &frame);
|
||||
if (aFrame == frame)
|
||||
aList = mPopupAtom;
|
||||
else
|
||||
aList = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsListChildAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
52
mozilla/accessible/src/base/nsSelectAccessible.h
Normal file
52
mozilla/accessible/src/base/nsSelectAccessible.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsSelectAccessible_h__
|
||||
#define __nsSelectAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
/*
|
||||
class nsSelectAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsSelectAccessible(nsIAtom* aPopupAtom, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
|
||||
virtual ~nsSelectAccessible() {}
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
@@ -24,29 +24,32 @@
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsHTMLAreaAccessible.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
|
||||
// --- area -----
|
||||
|
||||
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIDOMNode *aDomNode, nsIAccessible *aAccParent, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell), mAccParent(aAccParent)
|
||||
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIPresShell *aPresShell, nsIDOMNode *aDomNode, nsIAccessible *aAccParent):
|
||||
nsGenericAccessible(), mPresShell(aPresShell), mDOMNode(aDomNode), mAccParent(aAccParent)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(nsAWritableString & _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), _retval);
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), hrefString);
|
||||
if (!hrefString.IsEmpty()) {
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -59,25 +62,85 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
if (elt)
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), _retval);
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccDescription (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccDescription(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccDescription(PRUnichar **_retval)
|
||||
{
|
||||
// Still to do - follow IE's standard here
|
||||
*_retval = 0;
|
||||
nsAutoString shapeString;
|
||||
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(mDOMNode));
|
||||
if (area)
|
||||
area->GetShape(_retval);
|
||||
if (area) {
|
||||
area->GetShape(shapeString);
|
||||
if (!shapeString.IsEmpty())
|
||||
*_retval = ToNewUnicode(shapeString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("jump"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
mPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
nsMouseEvent linkClickEvent;
|
||||
linkClickEvent.eventStructType = NS_EVENT;
|
||||
linkClickEvent.message = NS_MOUSE_LEFT_CLICK;
|
||||
linkClickEvent.isShift = PR_FALSE;
|
||||
linkClickEvent.isControl = PR_FALSE;
|
||||
linkClickEvent.isAlt = PR_FALSE;
|
||||
linkClickEvent.isMeta = PR_FALSE;
|
||||
linkClickEvent.clickCount = 0;
|
||||
linkClickEvent.widget = nsnull;
|
||||
|
||||
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
content->HandleDOMEvent(presContext, &linkClickEvent,
|
||||
nsnull, NS_EVENT_FLAG_INIT, &eventStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = STATE_LINKED | STATE_FOCUSABLE | STATE_READONLY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
@@ -109,7 +172,8 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
|
||||
nsIAccessible *nsHTMLAreaAccessible::CreateAreaAccessible(nsIDOMNode *aDOMNode)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
||||
if (accService) {
|
||||
nsIAccessible* acc = nsnull;
|
||||
accService->CreateHTMLAreaAccessible(mPresShell, aDOMNode, mAccParent, &acc);
|
||||
|
||||
@@ -25,31 +25,37 @@
|
||||
#define _nsHTMLAreaAccessible_H_
|
||||
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
|
||||
/* Accessible for image map areas - must be child of image
|
||||
*/
|
||||
|
||||
class nsHTMLAreaAccessible : public nsLinkableAccessible
|
||||
class nsHTMLAreaAccessible : public nsGenericAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLAreaAccessible(nsIDOMNode *domNode, nsIAccessible *accParent, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString & _retval);
|
||||
nsHTMLAreaAccessible(nsIPresShell *presShell, nsIDOMNode *domNode, nsIAccessible *accParent);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible * *aAccNextSibling);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible * *aAccPreviousSibling);
|
||||
NS_IMETHOD GetAccDescription(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccDescription(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
|
||||
protected:
|
||||
nsIAccessible *CreateAreaAccessible(nsIDOMNode *aDOMNode);
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIAccessible> mAccParent;
|
||||
nsCOMPtr<nsIPresShell> mPresShell;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,15 +29,13 @@
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDOMHTMLLabelElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aNode, aShell)
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsLeafDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,19 +69,20 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::AppendLabelFor(nsIContent *aLookNode,
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
|
||||
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement;
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> formElement;
|
||||
nsAutoString nameString;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString label;
|
||||
|
||||
// go up tree get name of ancestor label if there is one. Don't go up farther than form element
|
||||
while (walkUpContent && label.IsEmpty() && !formElement) {
|
||||
while (walkUpContent && nameString.IsEmpty() && !formElement) {
|
||||
labelElement = do_QueryInterface(walkUpContent);
|
||||
if (labelElement)
|
||||
rv = AppendFlatStringFromSubtree(walkUpContent, &label);
|
||||
rv = AppendFlatStringFromSubtree(walkUpContent, &nameString);
|
||||
formElement = do_QueryInterface(walkUpContent); // reached top ancestor in form
|
||||
nsCOMPtr<nsIContent> nextParent;
|
||||
walkUpContent->GetParent(*getter_AddRefs(nextParent));
|
||||
@@ -96,19 +95,16 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval
|
||||
walkUpContent = do_QueryInterface(formElement);
|
||||
|
||||
if (walkUpContent) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
nsAutoString forId;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("id"), forId);
|
||||
// Actually we'll be walking down the content this time, with a depth first search
|
||||
if (!forId.IsEmpty())
|
||||
AppendLabelFor(walkUpContent,&forId,&label);
|
||||
AppendLabelFor(walkUpContent,&forId,&nameString);
|
||||
}
|
||||
|
||||
label.CompressWhitespace();
|
||||
if (label.IsEmpty())
|
||||
return nsAccessible::GetAccName(_retval);
|
||||
|
||||
_retval.Assign(label);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -118,10 +114,9 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// can be
|
||||
// focusable, focused, checked, protected, unavailable
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
*_retval = STATE_FOCUSABLE;
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
element->GetChecked(&checked);
|
||||
@@ -142,8 +137,8 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
|
||||
|
||||
// --- checkbox -----
|
||||
|
||||
nsHTMLCheckboxAccessible::nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLCheckboxAccessible::nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -162,44 +157,44 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
// check or uncheck
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
if (element)
|
||||
element->GetChecked(&checked);
|
||||
|
||||
if (checked)
|
||||
_retval = NS_LITERAL_STRING("uncheck");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("uncheck"));
|
||||
else
|
||||
_retval = NS_LITERAL_STRING("check");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("check"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) { // 0 is the magic value for default action
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
PRBool checked = PR_FALSE;
|
||||
element->GetChecked(&checked);
|
||||
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//------ Radio button -------
|
||||
|
||||
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -211,24 +206,24 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("select");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("select"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -242,8 +237,8 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
|
||||
// ----- Button -----
|
||||
|
||||
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -255,24 +250,24 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("press");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
@@ -283,9 +278,10 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mDOMNode));
|
||||
*_retval = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mNode));
|
||||
|
||||
if (!button)
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -293,7 +289,8 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
nsAutoString name;
|
||||
button->GetValue(name);
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
|
||||
*_retval = name.ToNewUnicode();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -301,8 +298,8 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
|
||||
// ----- HTML 4 Button: can contain arbitrary HTML content -----
|
||||
|
||||
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aNode, aShell)
|
||||
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -314,24 +311,24 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("press");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
@@ -344,26 +341,25 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
/* long getAccState (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
|
||||
if (content)
|
||||
rv = AppendFlatStringFromSubtree(content, &name);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
*_retval = name.ToNewUnicode();
|
||||
}
|
||||
|
||||
return rv;
|
||||
@@ -372,8 +368,8 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
|
||||
// --- textfield -----
|
||||
|
||||
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -385,21 +381,17 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
|
||||
if (textArea) {
|
||||
textArea->GetValue(_retval);
|
||||
nsAutoString valueString;
|
||||
textArea->GetValue(valueString);
|
||||
*_retval = ToNewUnicode(valueString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
if (inputElement) {
|
||||
inputElement->GetValue(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* long getAccState (); */
|
||||
@@ -408,13 +400,12 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
// can be
|
||||
// focusable, focused, protected. readonly, unavailable, selected
|
||||
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
*_retval = STATE_FOCUSABLE;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
PRBool isReadOnly = PR_FALSE;
|
||||
elt->HasAttribute(NS_LITERAL_STRING("readonly"), &isReadOnly);
|
||||
if (isReadOnly)
|
||||
@@ -422,13 +413,9 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
|
||||
// Get current selection and find out if current node is in it
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
nsIFrame *frame;
|
||||
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
@@ -454,7 +441,7 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
*_retval |= moreStates;
|
||||
return rv;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
PRBool disabled = PR_FALSE;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef _nsHTMLFormControlAccessible_H_
|
||||
#define _nsHTMLFormControlAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsICheckboxControlFrame;
|
||||
|
||||
@@ -33,12 +33,12 @@ class nsICheckboxControlFrame;
|
||||
* - walking up to get name from label
|
||||
* - support basic state
|
||||
*/
|
||||
class nsHTMLFormControlAccessible : public nsLeafAccessible
|
||||
class nsHTMLFormControlAccessible : public nsLeafDOMAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
protected:
|
||||
@@ -49,10 +49,10 @@ class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -60,10 +60,10 @@ class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -71,24 +71,24 @@ class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
class nsHTML4ButtonAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTML4ButtonAccessible : public nsDOMAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -96,9 +96,9 @@ public:
|
||||
class nsHTMLTextFieldAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
@@ -30,55 +30,19 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsRootAccessible)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameAccessible, nsHTMLBlockAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameAccessible, nsHTMLBlockAccessible);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameAccessible::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
|
||||
if ( !aInstancePtr )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (aIID.Equals(NS_GET_IID(nsIAccessibleDocument))) {
|
||||
*aInstancePtr = (void*)(nsIAccessibleDocument*) this;
|
||||
NS_IF_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsHTMLBlockAccessible::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *aDoc):
|
||||
nsHTMLBlockAccessible(aNode, aShell), mRootAccessible(aRoot), nsDocAccessibleMixin(aDoc)
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
mRootAccessible = aRoot;
|
||||
}
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(nsAWritableString& aAccName)
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
return GetTitle(aAccName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccValue(nsAWritableString& aAccValue)
|
||||
{
|
||||
return GetURL(aAccValue);
|
||||
return mRootAccessible->GetAccName(aAccName);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
@@ -102,54 +66,13 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PANE;
|
||||
return NS_OK;
|
||||
return mRootAccessible->GetAccRole(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccState(PRUint32 *aAccState)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetAccState(aAccState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetURL(aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetMimeType(aMimeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocType(aDocType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetNameSpaceURIForID(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
//=============================//
|
||||
// nsHTMLIFrameRootAccessible //
|
||||
//=============================//
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode):
|
||||
nsRootAccessible(aShell)
|
||||
{
|
||||
mRealDOMNode = aNode;
|
||||
@@ -160,6 +83,23 @@ nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWea
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
||||
{
|
||||
}
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
if (shell)
|
||||
shell->GetDocument(getter_AddRefs(document));
|
||||
if (document) {
|
||||
const nsString* docTitle = document->GetDocumentTitle();
|
||||
if (docTitle && !docTitle->IsEmpty()) {
|
||||
*aAccName = docTitle->ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aAccName = ToNewUnicode(NS_LITERAL_STRING("Frame"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
@@ -182,7 +122,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_ret
|
||||
return accessible->GetAccNextSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
@@ -194,7 +134,14 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **
|
||||
return accessible->GetAccPreviousSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PANE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible** aAcc)
|
||||
@@ -202,11 +149,6 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
// Start by finding our PresShell and from that
|
||||
// we get our nsIDocShell in order to walk the DocShell tree
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
if (!presShell) {
|
||||
*aAcc = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
|
||||
// Now that we have the DocShell QI
|
||||
@@ -241,7 +183,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
// OK, we found the content node in the parent doc
|
||||
// that corresponds to this sub-doc
|
||||
// Get the frame for that content
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(parentPresShell);
|
||||
nsCOMPtr<nsIWeakReference> wr(getter_AddRefs(NS_GetWeakReference(parentPresShell)));
|
||||
nsIFrame* frame = nsnull;
|
||||
parentPresShell->GetPrimaryFrameFor(content, &frame);
|
||||
#ifdef NS_DEBUG_X
|
||||
@@ -258,7 +200,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
|
||||
|
||||
*aAcc = acc;
|
||||
*aAcc = CreateNewAccessible(acc, node, wr);
|
||||
NS_IF_ADDREF(*aAcc);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -24,29 +24,20 @@
|
||||
#define _nsIFrameRootAccessible_H_
|
||||
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsIWebShell;
|
||||
class nsIWeakReference;
|
||||
|
||||
class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
|
||||
public nsIAccessibleDocument,
|
||||
public nsDocAccessibleMixin
|
||||
class nsHTMLIFrameAccessible : public nsDOMAccessible
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
public:
|
||||
nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *doc);
|
||||
nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& AccValue);
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAccessible> mRootAccessible;
|
||||
@@ -54,10 +45,9 @@ class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
|
||||
|
||||
class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
|
||||
public:
|
||||
nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode);
|
||||
virtual ~nsHTMLIFrameRootAccessible();
|
||||
|
||||
/* attribute wstring accName; */
|
||||
@@ -69,9 +59,15 @@ class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,21 +30,15 @@
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsIImageFrame.h"
|
||||
|
||||
// --- image -----
|
||||
|
||||
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDOMNode, aShell)
|
||||
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame):
|
||||
nsLinkableAccessible(aShell, aDOMNode), mPresShell(aShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
shell->GetDocument(getter_AddRefs(doc));
|
||||
aShell->GetDocument(getter_AddRefs(doc));
|
||||
nsAutoString mapElementName;
|
||||
|
||||
if (doc && element) {
|
||||
@@ -58,56 +52,20 @@ nsLinkableAccessible(aDOMNode, aShell)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// The state is a bitfield, get our inherited state, then logically OR it with STATE_ANIMATED if this
|
||||
// is an animated image.
|
||||
|
||||
nsLinkableAccessible::GetAccState(_retval);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame *frame = nsnull;
|
||||
if (content && shell)
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
|
||||
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(frame));
|
||||
|
||||
nsCOMPtr<imgIRequest> imageRequest;
|
||||
if (imageFrame)
|
||||
imageFrame->GetImageRequest(getter_AddRefs(imageRequest));
|
||||
|
||||
nsCOMPtr<imgIContainer> imgContainer;
|
||||
if (imageRequest)
|
||||
imageRequest->GetImage(getter_AddRefs(imgContainer));
|
||||
|
||||
if (imgContainer) {
|
||||
PRUint32 numFrames;
|
||||
imgContainer->GetNumFrames(&numFrames);
|
||||
if (numFrames > 1)
|
||||
*_retval |= STATE_ANIMATED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mNode));
|
||||
if (imageContent) {
|
||||
nsAutoString name;
|
||||
rv = AppendFlatStringFromContentNode(imageContent, &name);
|
||||
nsAutoString nameString;
|
||||
nsresult rv = AppendFlatStringFromContentNode(imageContent, &nameString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
return rv;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccRole (); */
|
||||
@@ -141,12 +99,12 @@ nsIAccessible *nsHTMLImageAccessible::CreateAreaAccessible(PRUint32 areaNum)
|
||||
if (!domNode)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
if (!accService)
|
||||
return nsnull;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
||||
if (accService) {
|
||||
nsIAccessible* acc = nsnull;
|
||||
accService->CreateHTMLAreaAccessible(mPresShell, domNode, this, &acc);
|
||||
nsCOMPtr<nsISupports> presShell(do_QueryInterface(mPresShell));
|
||||
accService->CreateHTMLAreaAccessible(presShell, domNode, this, &acc);
|
||||
return acc;
|
||||
}
|
||||
return nsnull;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef _nsHTMLImageAccessible_H_
|
||||
#define _nsHTMLImageAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
@@ -38,9 +38,8 @@ class nsHTMLImageAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLImageAccessible(nsIDOMNode* aDomNode, nsIImageFrame *imageFrame, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode, nsIImageFrame *imageFrame);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
@@ -49,6 +48,7 @@ public:
|
||||
protected:
|
||||
nsIAccessible *CreateAreaAccessible(PRUint32 areaNum);
|
||||
nsCOMPtr<nsIDOMHTMLMapElement> mMapElement;
|
||||
nsCOMPtr<nsIPresShell> mPresShell;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,24 +32,21 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsLinkableAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
if (!IsALink()) // Also initializes private data members
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString name;
|
||||
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &name);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
}
|
||||
nsAutoString nameString;
|
||||
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -61,3 +58,14 @@ NS_IMETHODIMP nsHTMLLinkAccessible::GetAccRole(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -24,15 +24,18 @@
|
||||
#ifndef _nsHTMLLinkAccessible_H_
|
||||
#define _nsHTMLLinkAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsHTMLLinkAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,794 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsHTMLSelectAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
|
||||
/*
|
||||
* A class the represents the text field in the Select to the left
|
||||
* of the drop down button
|
||||
*/
|
||||
class nsHTMLSelectTextFieldAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* A base class that can listen to menu events. Its used so the
|
||||
* button and the window accessibles can change there name and role
|
||||
* depending on whether the drop down list is dropped down on not
|
||||
*/
|
||||
class nsMenuListenerAccessible : public nsAccessible, public nsIDOMXULListener
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsMenuListenerAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsMenuListenerAccessible();
|
||||
|
||||
// popup listener
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Command(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
virtual void SetupMenuListener();
|
||||
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsMenuListenerAccessible, nsAccessible, nsIDOMXULListener)
|
||||
|
||||
/**
|
||||
* A class that represents the button inside the Select to the right of the text field
|
||||
*/
|
||||
class nsHTMLSelectButtonAccessible : public nsMenuListenerAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* A class that represents the window that lives to the right
|
||||
* of the drop down button inside the Select. This is the window
|
||||
* that is made visible when the button is pressed.
|
||||
*/
|
||||
class nsHTMLSelectWindowAccessible : public nsMenuListenerAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectWindowAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* The list that contains all the options in the select. It is inside the window.
|
||||
*/
|
||||
class nsHTMLSelectListAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectListAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLSelectListAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
//--------- nsHTMLSelectAccessible -----
|
||||
|
||||
nsHTMLSelectAccessible::nsHTMLSelectAccessible(nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLSelectAccessible, nsAccessible, nsIAccessibleSelectable)
|
||||
|
||||
// ------------- Helper method for determination of proper Frame ------
|
||||
//static
|
||||
PRBool nsHTMLSelectAccessible::IsCorrectFrame( nsIFrame* aFrame, nsIAtom* aAtom ) {
|
||||
if (!aFrame || !aAtom)
|
||||
return PR_FALSE;
|
||||
nsCOMPtr<nsIAtom> frameType;
|
||||
aFrame->GetFrameType(getter_AddRefs(frameType));
|
||||
if (frameType.get() != aAtom)
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> text;
|
||||
GetAccFirstChild(getter_AddRefs(text));
|
||||
if (text)
|
||||
return text->GetAccValue(_retval);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_COMBOBOX;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
// create a window accessible
|
||||
*_retval = new nsHTMLSelectWindowAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
// create a text field
|
||||
|
||||
*_retval = new nsHTMLSelectTextFieldAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
// always have 3 children
|
||||
*_retval = 3;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetSelectedChildren(nsISupportsArray **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------- SelectTextFieldAccessible ------
|
||||
|
||||
nsHTMLSelectTextFieldAccessible::nsHTMLSelectTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if ( !frame )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::textFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AppendFlatStringFromSubtree(content, &_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectTextFieldAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our first child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if ( !frame )
|
||||
return;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// --------- nsMenuListenerAccessible -----------
|
||||
|
||||
nsMenuListenerAccessible::nsMenuListenerAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
nsMenuListenerAccessible::~nsMenuListenerAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::PopupShowing(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::PopupHiding(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuListenerAccessible::SetupMenuListener()
|
||||
{
|
||||
// not not already one register ourselves as a popup listener
|
||||
if (!mRegistered) {
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (!eventReceiver) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = eventReceiver->AddEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------- SelectButtonAccessible ------
|
||||
|
||||
nsHTMLSelectButtonAccessible::nsHTMLSelectButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsMenuListenerAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->GetNextSibling(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::gfxButtonControlFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(content));
|
||||
if (element)
|
||||
{
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectButtonAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our second child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetNextSibling(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::gfxButtonControlFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PUSHBUTTON;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
return GetAccActionName(0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
{
|
||||
SetupMenuListener();
|
||||
|
||||
// get the current state open or closed
|
||||
// set _retval to it.
|
||||
// notice its supposed to be reversed. Close if opened
|
||||
// and Open if closed.
|
||||
|
||||
if (mOpen)
|
||||
_retval = NS_LITERAL_STRING("Close");
|
||||
else
|
||||
_retval = NS_LITERAL_STRING("Open");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectWindowAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectTextFieldAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
nsHTMLSelectWindowAccessible::nsHTMLSelectWindowAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell)
|
||||
:nsMenuListenerAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
SetupMenuListener();
|
||||
|
||||
// if open we are visible if closed we are invisible
|
||||
// set _retval to it.
|
||||
if (mOpen)
|
||||
*_retval |= STATE_DEFAULT;
|
||||
else
|
||||
*_retval |= STATE_INVISIBLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectWindowAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our first option
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
// now get its frame
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
*aRelativeFrame = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(child));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::listControlFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
//----------
|
||||
|
||||
|
||||
nsHTMLSelectListAccessible::nsHTMLSelectListAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return mParent->AccGetBounds(x,y,width,height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LIST;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> last;
|
||||
mDOMNode->GetLastChild(getter_AddRefs(last));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, last, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> first;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(first));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, first, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------
|
||||
|
||||
nsHTMLSelectOptionAccessible::nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> next;
|
||||
mDOMNode->GetNextSibling(getter_AddRefs(next));
|
||||
|
||||
if (next) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, next, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> prev;
|
||||
mDOMNode->GetPreviousSibling(getter_AddRefs(prev));
|
||||
|
||||
if (prev) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, prev, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content (do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString option;
|
||||
nsresult rv = AppendFlatStringFromSubtree(content, &option);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
option.CompressWhitespace();
|
||||
_retval.Assign(option);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsHTMLSelectAccessible_h__
|
||||
#define __nsHTMLSelectAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
|
||||
class nsHTMLSelectAccessible : public nsAccessible,
|
||||
public nsIAccessibleSelectable
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLESELECTABLE
|
||||
|
||||
nsHTMLSelectAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLSelectAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
|
||||
// helper method to verify frames
|
||||
static PRBool IsCorrectFrame( nsIFrame* aFrame, nsIAtom* aAtom );
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Each option in the Select. These are in the nsListAccessible
|
||||
*/
|
||||
class nsHTMLSelectOptionAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aDomNode, aShell)
|
||||
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccRole(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aDomNode, aShell)
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,20 +24,20 @@
|
||||
#ifndef _nsHTMLTableAccessible_H_
|
||||
#define _nsHTMLTableAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsHTMLTableCellAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTMLTableCellAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsHTMLTableAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTMLTableAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "nsHTMLTextAccessible.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsISelection.h"
|
||||
@@ -32,26 +31,36 @@
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsLinkableAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
nsAutoString nameString;
|
||||
nsresult rv = NS_OK;
|
||||
//if (IsALink()) {
|
||||
// rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
|
||||
//}
|
||||
//else
|
||||
mNode->GetNodeValue(nameString);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_TEXT;
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef _nsHTMLTextAccessible_H_
|
||||
#define _nsHTMLTextAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsIWeakReference;
|
||||
class nsITextControlFrame;
|
||||
@@ -32,8 +32,8 @@ class nsHTMLTextAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
|
||||
@@ -28,7 +28,7 @@ CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsRootAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLIFrameRootAccessible.obj \
|
||||
.\$(OBJDIR)\nsAccessibilityService.obj \
|
||||
.\$(OBJDIR)\nsHTMLSelectListAccessible.obj \
|
||||
.\$(OBJDIR)\nsSelectAccessible.obj \
|
||||
.\$(OBJDIR)\nsGenericAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLFormControlAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLTextAccessible.obj \
|
||||
@@ -36,12 +36,6 @@ CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsHTMLAreaAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLLinkAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLComboboxAccessible.obj \
|
||||
.\$(OBJDIR)\nsHTMLListboxAccessible.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
.\nsRootAccessible.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
|
||||
@@ -33,22 +33,14 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsSelectAccessible.h"
|
||||
#include "nsHTMLTextAccessible.h"
|
||||
#include "nsHTMLTableAccessible.h"
|
||||
#include "nsHTMLImageAccessible.h"
|
||||
#include "nsHTMLAreaAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
#include "nsHTMLComboboxAccessible.h"
|
||||
#include "nsHTMLListboxAccessible.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
|
||||
// IFrame
|
||||
#include "nsIDocShell.h"
|
||||
@@ -60,6 +52,7 @@
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
//printf("################################## nsAccessibilityService\n");
|
||||
}
|
||||
|
||||
nsAccessibilityService::~nsAccessibilityService()
|
||||
@@ -77,102 +70,70 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsAccessibilityService, nsIAccessibilityService);
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISupports* aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
// XXX - jgaunt - looks like we aren't using this
|
||||
//nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresShell> s;
|
||||
c->GetShell(getter_AddRefs(s));
|
||||
|
||||
NS_ASSERTION(presShell,"Error not presshell!!");
|
||||
NS_ASSERTION(s,"Error not presshell!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
|
||||
nsCOMPtr<nsIWeakReference> wr (getter_AddRefs(NS_GetWeakReference(s)));
|
||||
|
||||
*_retval = new nsRootAccessible(weakShell);
|
||||
if (! *_retval)
|
||||
//printf("################################## CreateRootAccessible\n");
|
||||
*_retval = new nsRootAccessible(wr);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
/*
|
||||
nsCOMPtr<nsIContent> n(do_QueryInterface(node));
|
||||
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
nsCOMPtr<nsIPresShell> s;
|
||||
c->GetShell(getter_AddRefs(s));
|
||||
|
||||
*_retval = new nsHTMLComboboxAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
|
||||
|
||||
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, node, wr);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*/
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
|
||||
*_retval = new nsHTMLListboxAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, nsIAccessible *aAccParent, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(presShell);
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(aAccParent, aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLCheckboxAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLCheckboxAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -180,17 +141,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupport
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLRadioButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLRadioButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -198,17 +159,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aF
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTML4ButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -216,17 +177,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *a
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTML4ButtonAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTML4ButtonAccessible(shell,node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -234,17 +195,18 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTextAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
//printf("################################## CreateHTMLTextAccessible\n");
|
||||
*_retval = new nsHTMLTextAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,17 +215,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFr
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTableAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTableCellAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -271,17 +233,17 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableCellAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTableCellAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLImageAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -289,37 +251,36 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFr
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsIImageFrame* imageFrame = nsnull;
|
||||
|
||||
// not using a nsCOMPtr frames don't support them.
|
||||
aFrame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame);
|
||||
|
||||
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(aFrame));
|
||||
if (!imageFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = new nsHTMLImageAccessible(node, imageFrame, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLImageAccessible(shell, node, imageFrame);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLAreaAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsIWeakReference *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsISupports *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
|
||||
nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLAreaAccessible(aDOMNode, aAccParent, aShell);
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryInterface(aShell));
|
||||
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLAreaAccessible(shell, aDOMNode, aAccParent);
|
||||
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextFieldAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
@@ -327,103 +288,52 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTextFieldAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
*_retval = new nsHTMLTextFieldAccessible(shell, node);
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode)
|
||||
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aNode)
|
||||
{
|
||||
NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
|
||||
*aRealFrame = NS_STATIC_CAST(nsIFrame*, aFrame);
|
||||
nsCOMPtr<nsIContent> content;
|
||||
(*aRealFrame)->GetContent(getter_AddRefs(content));
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
*aNode = node;
|
||||
NS_IF_ADDREF(*aNode);
|
||||
NS_ADDREF(*aNode);
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
// do_GetWR only works into a |nsCOMPtr| :-(
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
weakShell = do_GetWeakReference(tempShell);
|
||||
NS_IF_ADDREF(*aShell = weakShell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateAccessible(nsIDOMNode* aDOMNode, nsISupports* aDocument, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document (do_QueryInterface(aDocument));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(tempShell);
|
||||
*aShell = document->GetShellAt(0);
|
||||
NS_IF_ADDREF(*aShell);
|
||||
|
||||
*_retval = new nsAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLBlockAccessible(nsIDOMNode* aDOMNode, nsISupports* aDocument, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document (do_QueryInterface(aDocument));
|
||||
if (!document)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 shells = document->GetNumberOfShells();
|
||||
NS_ASSERTION(shells > 0,"Error no shells!");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> tempShell;
|
||||
document->GetShellAt(0, getter_AddRefs(tempShell));
|
||||
nsCOMPtr<nsIWeakReference> weakShell = do_GetWeakReference(tempShell);
|
||||
|
||||
*_retval = new nsAccessible(aDOMNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||
NS_ASSERTION(content,"Error non nsIContent passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
|
||||
@@ -433,12 +343,11 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
presContext->GetShell(getter_AddRefs(presShell));
|
||||
NS_ASSERTION(presShell,"Error non PresShell passed to accessible factory!!!");
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(presShell);
|
||||
nsCOMPtr<nsIWeakReference> weakRef (getter_AddRefs(NS_GetWeakReference(presShell)));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc))) && doc) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIPresShell> presShell = getter_AddRefs(doc->GetShellAt(0));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
presShell->GetSubShellFor(content, getter_AddRefs(supps));
|
||||
@@ -448,22 +357,13 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
nsCOMPtr<nsIPresShell> ps;
|
||||
docShell->GetPresShell(getter_AddRefs(ps));
|
||||
if (ps) {
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(ps);
|
||||
nsCOMPtr<nsIDocument> innerDoc;
|
||||
ps->GetDocument(getter_AddRefs(innerDoc));
|
||||
if (innerDoc) {
|
||||
nsCOMPtr<nsIAccessible> root = new nsHTMLIFrameRootAccessible(aDOMNode, wr);
|
||||
if ( root ) {
|
||||
nsHTMLIFrameAccessible* frameAcc = new nsHTMLIFrameAccessible(aDOMNode, root, weakRef, innerDoc);
|
||||
if ( frameAcc != nsnull ) {
|
||||
*_retval = NS_STATIC_CAST(nsIAccessible*, frameAcc);
|
||||
if ( *_retval ) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIWeakReference> wr (getter_AddRefs(NS_GetWeakReference(ps)));
|
||||
//printf("################################## CreateHTMLIFrameAccessible\n");
|
||||
|
||||
nsCOMPtr<nsIAccessible> root = new nsHTMLIFrameRootAccessible(wr,node);
|
||||
*_retval = new nsHTMLIFrameAccessible(presShell, node, root);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,198 +372,6 @@ nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* aDOMNode, nsISupp
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// This method finds the content node in the parent document
|
||||
// corresponds to the docshell
|
||||
// This code is copied and pasted from nsEventStateManager.cpp
|
||||
// Is also inefficient - better solution should come along as part of
|
||||
// Bug 85602: "FindContentForDocShell walks entire content tree"
|
||||
// Hopefully there will be a better method soon, with a public interface
|
||||
|
||||
nsIContent*
|
||||
nsAccessibilityService::FindContentForDocShell(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIDocShell* aDocShell)
|
||||
{
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
nsCOMPtr<nsISupports> supps;
|
||||
aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps));
|
||||
if (supps) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
|
||||
if (docShell.get() == aDocShell)
|
||||
return aContent;
|
||||
}
|
||||
|
||||
// walk children content
|
||||
PRInt32 count;
|
||||
aContent->ChildCount(count);
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
nsIContent* foundContent = FindContentForDocShell(aPresShell, child, aDocShell);
|
||||
if (foundContent != nsnull) {
|
||||
return foundContent;
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent)
|
||||
{
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
aPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (!presContext)
|
||||
return;
|
||||
nsCOMPtr<nsISupports> pcContainer;
|
||||
presContext->GetContainer(getter_AddRefs(pcContainer));
|
||||
if (!pcContainer)
|
||||
return;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
if (!treeItem)
|
||||
return;
|
||||
|
||||
// Get Parent Doc
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItemParent;
|
||||
treeItem->GetParent(getter_AddRefs(treeItemParent));
|
||||
if (!treeItemParent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShell> parentDS(do_QueryInterface(treeItemParent));
|
||||
if (!parentDS)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
||||
parentDS->GetPresShell(getter_AddRefs(parentPresShell));
|
||||
if (!parentPresShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> parentDoc;
|
||||
parentPresShell->GetDocument(getter_AddRefs(parentDoc));
|
||||
if (!parentDoc)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
parentDoc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
nsIContent *tempContent;
|
||||
tempContent = FindContentForDocShell(parentPresShell, rootContent, docShell);
|
||||
if (tempContent) {
|
||||
*aOwnerContent = tempContent;
|
||||
*aOwnerShell = parentPresShell;
|
||||
NS_ADDREF(*aOwnerShell);
|
||||
NS_ADDREF(*aOwnerContent);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------
|
||||
* GetAccessibleFor - get an nsIAccessible from a DOM node
|
||||
* ------------------------------------------------------- */
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
||||
nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
if (!aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// ---- Get the document for this node ----
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIDocument> nodeIsDoc(do_QueryInterface(aNode));
|
||||
if (nodeIsDoc)
|
||||
doc = nodeIsDoc;
|
||||
else {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
doc = do_QueryInterface(domDoc);
|
||||
}
|
||||
if (!doc)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// ---- Get the pres shell ----
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
doc->GetShellAt(0, getter_AddRefs(shell));
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// ---- 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
|
||||
|
||||
// ---- Check if we need outer owning doc ----
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
if (!content && nodeIsDoc) {
|
||||
// This happens when we're on the document node, which will not QI to an nsIContent,
|
||||
// When that happens, we try to get the outer, parent document node that contains the document
|
||||
// For example, a <browser> or <iframe> element
|
||||
nsCOMPtr<nsIPresShell> ownerShell;
|
||||
nsCOMPtr<nsIContent> ownerContent;
|
||||
GetOwnerFor(shell, getter_AddRefs(ownerShell), getter_AddRefs(ownerContent));
|
||||
shell = ownerShell;
|
||||
content = ownerContent;
|
||||
}
|
||||
|
||||
// ---- If still no nsIContent, return ----
|
||||
if (!content)
|
||||
return PR_FALSE;
|
||||
|
||||
// ---- Try using frame to get IAccessible ----
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> newAcc;
|
||||
frame->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
||||
// ---- Try QI'ing node to get nsIAccessible ----
|
||||
if (!newAcc)
|
||||
newAcc = do_QueryInterface(aNode);
|
||||
|
||||
// ---- If link, create link accessible ----
|
||||
if (!newAcc) {
|
||||
// is it a link?
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(aNode));
|
||||
if (link) {
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(shell));
|
||||
newAcc = new nsHTMLLinkAccessible(aNode, weakShell);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- If <select> option, create select option accessible
|
||||
if (!newAcc) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(do_QueryInterface(aNode));
|
||||
if (optionElement) {
|
||||
// nsHTMLSelectionOptionAccessible's must be created via the parent
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
aNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
if (parentNode) {
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
GetAccessibleFor(parentNode, getter_AddRefs(parentAccessible));
|
||||
if (parentAccessible) {
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(shell));
|
||||
newAcc = new nsHTMLSelectOptionAccessible(parentAccessible, aNode, weakShell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!newAcc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = newAcc;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -675,11 +383,11 @@ NS_NewAccessibilityService(nsIAccessibilityService** aResult)
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAccessibilityService* accService = new nsAccessibilityService();
|
||||
if (!accService)
|
||||
nsAccessibilityService* a = new nsAccessibilityService();
|
||||
if (a == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(accService);
|
||||
*aResult = accService;
|
||||
NS_ADDREF(a);
|
||||
*aResult = a;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,8 @@
|
||||
#define __nsAccessibilityService_h__
|
||||
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIWeakReference;
|
||||
class nsIPresShell;
|
||||
class nsIDOMNode;
|
||||
|
||||
class nsAccessibilityService : public nsIAccessibilityService
|
||||
@@ -50,9 +46,7 @@ public:
|
||||
public:
|
||||
|
||||
private:
|
||||
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent);
|
||||
void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent);
|
||||
nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell);
|
||||
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aContent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
#define _nsAccessible_H_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
@@ -42,27 +42,16 @@ class nsIDocShell;
|
||||
class nsIWebShell;
|
||||
class nsIContent;
|
||||
|
||||
class nsAccessible : public nsGenericAccessible
|
||||
class nsAccessible : public nsIAccessible
|
||||
// public nsIAccessibleWidgetAccess
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFocused(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD AccRemoveSelection(void);
|
||||
NS_IMETHOD AccTakeSelection(void);
|
||||
NS_IMETHOD AccTakeFocus(void);
|
||||
NS_IMETHOD AccGetDOMNode(nsIDOMNode **_retval);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIAccessibilityService methods:
|
||||
NS_DECL_NSIACCESSIBLE
|
||||
|
||||
public:
|
||||
nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual ~nsAccessible();
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
|
||||
@@ -93,63 +82,33 @@ public:
|
||||
nsRect& aAbsoluteTwipsRect,
|
||||
nsRect& aAbsolutePixelRect);
|
||||
static nsresult GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut);
|
||||
|
||||
// helper method to verify frames
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
|
||||
protected:
|
||||
virtual nsIFrame* GetFrame();
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual void GetPresContext(nsCOMPtr<nsIPresContext>& aContext);
|
||||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewParentAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
// Data Members
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIAccessible> mAccessible;
|
||||
nsCOMPtr<nsIFocusController> mFocusController;
|
||||
|
||||
};
|
||||
|
||||
/* Special Accessible that knows how to handle hit detection for flowing text */
|
||||
class nsHTMLBlockAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLBlockAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
|
||||
protected:
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aFrame, nsIWeakReference* aShell);
|
||||
};
|
||||
|
||||
/* Leaf version of DOM Accessible
|
||||
* has no children
|
||||
*/
|
||||
class nsLeafAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsLeafAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsLinkableAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
|
||||
protected:
|
||||
PRBool IsALink();
|
||||
PRBool mIsALinkCached; // -1 = unknown, 0 = not a link, 1 = is a link
|
||||
nsCOMPtr<nsIContent> mLinkContent;
|
||||
PRBool mIsLinkVisited;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,12 +22,25 @@
|
||||
*/
|
||||
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILink.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLBRElement.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsGenericAccessible, nsIAccessible)
|
||||
@@ -80,25 +93,31 @@ NS_IMETHODIMP nsGenericAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void setAccName (in wstring name); */
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccName(const nsAReadableString& name)
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccName(const PRUnichar *name)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void setAccValue (in wstring value); */
|
||||
NS_IMETHODIMP nsGenericAccessible::SetAccValue(const PRUnichar *value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccDescription (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -122,7 +141,7 @@ NS_IMETHODIMP nsGenericAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -140,7 +159,7 @@ NS_IMETHODIMP nsGenericAccessible::GetAccFocused(nsIAccessible **_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccHelp (); */
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -222,4 +241,356 @@ NS_IMETHODIMP nsGenericAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//-------------
|
||||
// nsDOMAccessible
|
||||
//-------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAccessible::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMNode))) {
|
||||
nsIDOMNode* node = mNode;
|
||||
*aResult = (void*) node;
|
||||
NS_ADDREF(node);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsGenericAccessible::QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
nsDOMAccessible::nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode)
|
||||
{
|
||||
mPresShell = do_GetWeakReference(aShell);
|
||||
mNode = aNode;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AccGetDOMNode(nsIDOMNode **_retval)
|
||||
{
|
||||
*_retval = mNode;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void accRemoveSelection (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccRemoveSelection()
|
||||
{
|
||||
nsCOMPtr<nsISelectionController> control(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = control->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = mNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = selection->Collapse(parent, 0);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void accTakeSelection (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccTakeSelection()
|
||||
{
|
||||
nsCOMPtr<nsISelectionController> control(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = control->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = mNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 offsetInParent = 0;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
rv = parent->GetFirstChild(getter_AddRefs(child));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> next;
|
||||
|
||||
while(child)
|
||||
{
|
||||
if (child == mNode) {
|
||||
// Collapse selection to just before desired element,
|
||||
rv = selection->Collapse(parent, offsetInParent);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// then extend it to just after
|
||||
rv = selection->Extend(parent, offsetInParent+1);
|
||||
return rv;
|
||||
}
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(next));
|
||||
child = next;
|
||||
offsetInParent++;
|
||||
}
|
||||
|
||||
// didn't find a child
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void accTakeFocus (); */
|
||||
NS_IMETHODIMP nsDOMAccessible::AccTakeFocus()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
content->SetFocus(context);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent(do_QueryInterface(aContent));
|
||||
if (textContent) {
|
||||
nsCOMPtr<nsIDOMComment> commentNode(do_QueryInterface(aContent));
|
||||
if (!commentNode) {
|
||||
PRBool isHTMLBlock = PR_FALSE;
|
||||
nsIFrame *frame;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
aContent->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent) {
|
||||
nsresult rv = shell->GetPrimaryFrameFor(parentContent, &frame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// If this text is inside a block level frame (as opposed to span level), we need to add spaces around that
|
||||
// block's text, so we don't get words jammed together in final name
|
||||
// Extra spaces will be trimmed out later
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
frame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (styleContext) {
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (display->IsBlockLevel() || display->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
isHTMLBlock = PR_TRUE;
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsAutoString text;
|
||||
textContent->CopyText(text);
|
||||
if (text.Length()>0)
|
||||
aFlatString->Append(text);
|
||||
if (isHTMLBlock)
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLBRElement> brElement(do_QueryInterface(aContent));
|
||||
if (brElement) {
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> imageContent(do_QueryInterface(aContent));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputContent(do_QueryInterface(aContent));
|
||||
if (imageContent || inputContent) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aContent));
|
||||
nsAutoString textEquivalent;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("alt"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("name"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("src"), textEquivalent);
|
||||
if (!textEquivalent.IsEmpty()) {
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
aFlatString->Append(textEquivalent);
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDOMAccessible::AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString)
|
||||
{
|
||||
// Depth first search for all text nodes that are decendants of content node.
|
||||
// Append all the text into one flat string
|
||||
|
||||
PRInt32 numChildren = 0;
|
||||
|
||||
aContent->ChildCount(numChildren);
|
||||
if (numChildren == 0) {
|
||||
nsAutoString contentText;
|
||||
AppendFlatStringFromContentNode(aContent, aFlatString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *contentWalker;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < numChildren; index++) {
|
||||
aContent->ChildAt(index, contentWalker);
|
||||
AppendFlatStringFromSubtree(contentWalker, aFlatString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------
|
||||
// nsLeafFrameAccessible
|
||||
//-------------
|
||||
|
||||
nsLeafDOMAccessible::nsLeafDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccLastChild (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getAccChildCount (); */
|
||||
NS_IMETHODIMP nsLeafDOMAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------
|
||||
// nsLinkableAccessible
|
||||
//----------------
|
||||
|
||||
nsLinkableAccessible::nsLinkableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode), mIsALinkCached(PR_FALSE), mLinkContent(nsnull), mIsLinkVisited(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
/* long GetAccState (); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval |= STATE_READONLY | STATE_SELECTABLE;
|
||||
if (IsALink()) {
|
||||
*_retval |= STATE_FOCUSABLE | STATE_LINKED;
|
||||
if (mIsLinkVisited)
|
||||
*_retval |= STATE_TRAVERSED;
|
||||
}
|
||||
|
||||
// Get current selection and find out if current node is in it
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
nsIFrame *frame;
|
||||
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
frame->GetSelectionController(context,getter_AddRefs(selCon));
|
||||
if (selCon) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
|
||||
if (domSel) {
|
||||
PRBool isSelected = PR_FALSE, isCollapsed = PR_TRUE;
|
||||
domSel->ContainsNode(mNode, PR_TRUE, &isSelected);
|
||||
domSel->GetIsCollapsed(&isCollapsed);
|
||||
if (isSelected && !isCollapsed)
|
||||
*_retval |=STATE_SELECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Focused? Do we implement that here or up the chain?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;;
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (IsALink()) {
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("jump"));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (IsALink()) {
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
nsMouseEvent linkClickEvent;
|
||||
linkClickEvent.eventStructType = NS_EVENT;
|
||||
linkClickEvent.message = NS_MOUSE_LEFT_CLICK;
|
||||
linkClickEvent.isShift = PR_FALSE;
|
||||
linkClickEvent.isControl = PR_FALSE;
|
||||
linkClickEvent.isAlt = PR_FALSE;
|
||||
linkClickEvent.isMeta = PR_FALSE;
|
||||
linkClickEvent.clickCount = 0;
|
||||
linkClickEvent.widget = nsnull;
|
||||
|
||||
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
||||
mLinkContent->HandleDOMEvent(presContext, &linkClickEvent,
|
||||
nsnull, NS_EVENT_FLAG_INIT, &eventStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsLinkableAccessible::IsALink()
|
||||
{
|
||||
if (mIsALinkCached) // Cached answer?
|
||||
return mLinkContent? PR_TRUE: PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
|
||||
if (walkUpContent) {
|
||||
nsCOMPtr<nsIContent> tempContent = walkUpContent;
|
||||
while (walkUpContent) {
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(walkUpContent));
|
||||
if (link) {
|
||||
mLinkContent = tempContent;
|
||||
mIsALinkCached = PR_TRUE;
|
||||
nsLinkState linkState;
|
||||
link->GetLinkState(linkState);
|
||||
if (linkState == eLinkState_Visited)
|
||||
mIsLinkVisited = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
walkUpContent->GetParent(*getter_AddRefs(tempContent));
|
||||
walkUpContent = tempContent;
|
||||
}
|
||||
}
|
||||
mIsALinkCached = PR_TRUE; // Cached that there is no link
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@@ -47,5 +47,61 @@ class nsGenericAccessible : public nsIAccessible
|
||||
virtual ~nsGenericAccessible();
|
||||
};
|
||||
|
||||
/**
|
||||
* And accessible that observes a dom node
|
||||
* supports:
|
||||
* - selection
|
||||
* - focus
|
||||
*/
|
||||
class nsDOMAccessible : public nsGenericAccessible
|
||||
{
|
||||
public:
|
||||
nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD AccTakeSelection(void);
|
||||
NS_IMETHOD AccTakeFocus(void);
|
||||
NS_IMETHOD AccRemoveSelection(void);
|
||||
NS_IMETHOD AccGetDOMNode(nsIDOMNode **_retval);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
|
||||
nsCOMPtr<nsIWeakReference> mPresShell;
|
||||
nsCOMPtr<nsIDOMNode> mNode;
|
||||
};
|
||||
|
||||
/* Leaf version of DOM Accessible
|
||||
* has no children
|
||||
*/
|
||||
class nsLeafDOMAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsLeafDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsLinkableAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsLinkableAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMNode> mDomNode;
|
||||
PRBool IsALink();
|
||||
PRBool mIsALinkCached; // -1 = unknown, 0 = not a link, 1 = is a link
|
||||
nsCOMPtr<nsIContent> mLinkContent;
|
||||
PRBool mIsLinkVisited;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,29 +24,32 @@
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsHTMLAreaAccessible.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
|
||||
// --- area -----
|
||||
|
||||
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIDOMNode *aDomNode, nsIAccessible *aAccParent, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell), mAccParent(aAccParent)
|
||||
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIPresShell *aPresShell, nsIDOMNode *aDomNode, nsIAccessible *aAccParent):
|
||||
nsGenericAccessible(), mPresShell(aPresShell), mDOMNode(aDomNode), mAccParent(aAccParent)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(nsAWritableString & _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), _retval);
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), hrefString);
|
||||
if (!hrefString.IsEmpty()) {
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -59,25 +62,85 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
if (elt)
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), _retval);
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccDescription (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccDescription(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccDescription(PRUnichar **_retval)
|
||||
{
|
||||
// Still to do - follow IE's standard here
|
||||
*_retval = 0;
|
||||
nsAutoString shapeString;
|
||||
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(mDOMNode));
|
||||
if (area)
|
||||
area->GetShape(_retval);
|
||||
if (area) {
|
||||
area->GetShape(shapeString);
|
||||
if (!shapeString.IsEmpty())
|
||||
*_retval = ToNewUnicode(shapeString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("jump"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
mPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
nsMouseEvent linkClickEvent;
|
||||
linkClickEvent.eventStructType = NS_EVENT;
|
||||
linkClickEvent.message = NS_MOUSE_LEFT_CLICK;
|
||||
linkClickEvent.isShift = PR_FALSE;
|
||||
linkClickEvent.isControl = PR_FALSE;
|
||||
linkClickEvent.isAlt = PR_FALSE;
|
||||
linkClickEvent.isMeta = PR_FALSE;
|
||||
linkClickEvent.clickCount = 0;
|
||||
linkClickEvent.widget = nsnull;
|
||||
|
||||
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
content->HandleDOMEvent(presContext, &linkClickEvent,
|
||||
nsnull, NS_EVENT_FLAG_INIT, &eventStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = STATE_LINKED | STATE_FOCUSABLE | STATE_READONLY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
@@ -109,7 +172,8 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
|
||||
nsIAccessible *nsHTMLAreaAccessible::CreateAreaAccessible(nsIDOMNode *aDOMNode)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
||||
if (accService) {
|
||||
nsIAccessible* acc = nsnull;
|
||||
accService->CreateHTMLAreaAccessible(mPresShell, aDOMNode, mAccParent, &acc);
|
||||
|
||||
@@ -25,31 +25,37 @@
|
||||
#define _nsHTMLAreaAccessible_H_
|
||||
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
|
||||
/* Accessible for image map areas - must be child of image
|
||||
*/
|
||||
|
||||
class nsHTMLAreaAccessible : public nsLinkableAccessible
|
||||
class nsHTMLAreaAccessible : public nsGenericAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLAreaAccessible(nsIDOMNode *domNode, nsIAccessible *accParent, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString & _retval);
|
||||
nsHTMLAreaAccessible(nsIPresShell *presShell, nsIDOMNode *domNode, nsIAccessible *accParent);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible * *aAccNextSibling);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible * *aAccPreviousSibling);
|
||||
NS_IMETHOD GetAccDescription(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccDescription(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
|
||||
protected:
|
||||
nsIAccessible *CreateAreaAccessible(nsIDOMNode *aDOMNode);
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIAccessible> mAccParent;
|
||||
nsCOMPtr<nsIPresShell> mPresShell;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,728 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s): John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsHTMLComboboxAccessible.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
/** ----- nsHTMLComboboxAccessible ----- */
|
||||
|
||||
/**
|
||||
* Constructor -- create the nsHTMLAccessible and set initial state
|
||||
* closed and not registered
|
||||
*/
|
||||
nsHTMLComboboxAccessible::nsHTMLComboboxAccessible(nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
SetupMenuListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor -- If we are registered, remove ourselves as a listener.
|
||||
*/
|
||||
nsHTMLComboboxAccessible::~nsHTMLComboboxAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/** Inherit the ISupports impl from nsAccessible -- handle nsIDOMXULListener ourself */
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsHTMLComboboxAccessible, nsAccessible, nsIDOMXULListener)
|
||||
|
||||
/**
|
||||
* Tell our caller we are a combobox
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_COMBOBOX;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our last child, a nsHTMLComboboxWindowAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLComboboxWindowAccessible(this, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our first child, a nsHTMLComboboxTextFieldAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLComboboxTextFieldAccessible(this, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We always have 3 children: TextField, Button, Window. In that order
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 3;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* nsIAccessibleSelectable method. No-op because our selection is returned through
|
||||
* GetValue(). This _may_ change just to provide additional info for the vendors
|
||||
* and another option for them to get at stuff.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetSelectedChildren(nsISupportsArray **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our value is the value of our ( first ) selected child. SelectElement
|
||||
* returns this by default with GetValue().
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> select (do_QueryInterface(mDOMNode));
|
||||
if (select) {
|
||||
select->GetValue(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLComboboxAccessible we can have the following states:
|
||||
* STATE_FOCUSED
|
||||
* STATE_READONLY
|
||||
* STATE_FOCUSABLE
|
||||
* STATE_HASPOPUP
|
||||
* STATE_EXPANDED
|
||||
* STATE_COLLAPSED
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
if (mOpen)
|
||||
*_retval |= STATE_EXPANDED;
|
||||
else
|
||||
*_retval |= STATE_COLLAPSED;
|
||||
|
||||
*_retval |= STATE_HASPOPUP | STATE_READONLY | STATE_FOCUSABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our state to open and (TBD) fire an event to MSAA saying our state
|
||||
* has changed.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::PopupShowing(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our state to not open and (TDB) fire an event to MSAA saying
|
||||
* our state has changed.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::PopupHiding(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our state to not open and (TDB) fire an event to MSAA saying
|
||||
* our state has changed.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we aren't already registered, register ourselves as a
|
||||
* listener to "popupshowing" events on our DOM node. Set our
|
||||
* state to registered, but don't notify MSAA as they
|
||||
* don't need to know about this state.
|
||||
*/
|
||||
void
|
||||
nsHTMLComboboxAccessible::SetupMenuListener()
|
||||
{
|
||||
// if not already registered as a popup listener, register ourself
|
||||
if (!mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (eventReceiver && NS_SUCCEEDED(eventReceiver->AddEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE)))
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ----- nsHTMLComboboxTextFieldAccessible ----- */
|
||||
|
||||
/**
|
||||
* Constructor -- create the nsLeafAccessible and set our parent
|
||||
*/
|
||||
nsHTMLComboboxTextFieldAccessible::nsHTMLComboboxTextFieldAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently gets the text from the first option, needs to check for selection
|
||||
* and then return that text.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if (!frame || !context)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::textFrame))
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AppendFlatStringFromSubtree(content, &_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the BlockFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void nsHTMLComboboxTextFieldAccessible::GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
{
|
||||
// get our first child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if (!frame || !context)
|
||||
return;
|
||||
|
||||
frame->FirstChild(context, nsnull, aBoundingFrame);
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
|
||||
return;
|
||||
#endif
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for our parent
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our next sibling, a
|
||||
* nsHTMLComboboxButtonAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLComboboxButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We are the first child of our parent, no previous sibling
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our role is currently only static text, but we should be able to have
|
||||
* editable text here and we need to check that case.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLComboboxTextFieldAccessible we can have the following states:
|
||||
* STATE_READONLY
|
||||
* STATE_FOCUSED
|
||||
* STATE_FOCUSABLE
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
*_retval |= STATE_READONLY | STATE_FOCUSABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** -----SelectButtonAccessible ----- */
|
||||
|
||||
/**
|
||||
* Constructor -- create the nsMenuListenerAccessible and set our parent
|
||||
*/
|
||||
nsHTMLComboboxButtonAccessible::nsHTMLComboboxButtonAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmaticaly click on the button, causing either the display or
|
||||
* the hiding of the drop down box ( window ).
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if (!context)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
frame->GetNextSibling(&frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::gfxButtonControlFrame))
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
// We only have one action, click. Any other index is meaningless(wrong)
|
||||
if (index == eAction_Click) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(content));
|
||||
if (element)
|
||||
{
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Just one action ( click ).
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the gfxButtonControlFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void nsHTMLComboboxButtonAccessible::GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
{
|
||||
// get our second child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
|
||||
return;
|
||||
#endif
|
||||
|
||||
frame->GetNextSibling(aBoundingFrame);
|
||||
frame->GetNextSibling(&frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::gfxButtonControlFrame))
|
||||
return;
|
||||
#endif
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell our caller we are a button.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PUSHBUTTON;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for our parent
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name from GetAccActionName()
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
return GetAccActionName(eAction_Click, _retval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Our action name is the reverse of our state:
|
||||
* if we are closed -> open is our name.
|
||||
* if we are open -> closed is our name.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
{
|
||||
// we are open or closed
|
||||
PRBool isOpen = PR_FALSE;
|
||||
nsIFrame *boundsFrame = GetBoundsFrame();
|
||||
nsIComboboxControlFrame* comboFrame;
|
||||
boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame);
|
||||
if (!comboFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
comboFrame->IsDroppedDown(&isOpen);
|
||||
if (isOpen)
|
||||
_retval = NS_LITERAL_STRING("Close");
|
||||
else
|
||||
_retval = NS_LITERAL_STRING("Open");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our next sibling, a
|
||||
* nsHTMLComboboxWindowAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLComboboxWindowAccessible(parent, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our previous sibling, a
|
||||
* nsHTMLComboboxTextFieldAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLComboboxTextFieldAccessible(parent, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* No Children. Just a button ( over-riding nsAccessible )
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* No Children. Just a button ( over-riding nsAccessible )
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* No Children. Just a button ( over-riding nsAccessible )
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLComboboxButtonAccessible we can have the following states:
|
||||
* STATE_PRESSED
|
||||
* STATE_FOCUSED
|
||||
* STATE_FOCUSABLE
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
// we are open or closed
|
||||
PRBool isOpen = PR_FALSE;
|
||||
nsIFrame *boundsFrame = GetBoundsFrame();
|
||||
nsIComboboxControlFrame* comboFrame;
|
||||
boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame);
|
||||
if (!comboFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
comboFrame->IsDroppedDown(&isOpen);
|
||||
if (isOpen)
|
||||
*_retval |= STATE_PRESSED;
|
||||
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** ----- nsHTMLComboboxWindowAccessible ----- */
|
||||
|
||||
/**
|
||||
* Constructor -- create the nsMenuListener and set our parent
|
||||
*/
|
||||
nsHTMLComboboxWindowAccessible::nsHTMLComboboxWindowAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLComboboxWindowAccessible we can have the following states:
|
||||
* STATE_FOCUSED
|
||||
* STATE_FOCUSABLE
|
||||
* STATE_INVISIBLE
|
||||
* STATE_FLOATING
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
// we are open or closed
|
||||
PRBool isOpen = PR_FALSE;
|
||||
nsIFrame *boundsFrame = GetBoundsFrame();
|
||||
nsIComboboxControlFrame* comboFrame = nsnull;
|
||||
boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame);
|
||||
if (!comboFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
comboFrame->IsDroppedDown(&isOpen);
|
||||
if (! isOpen)
|
||||
*_retval |= STATE_INVISIBLE;
|
||||
|
||||
*_retval |= STATE_FOCUSABLE | STATE_FLOATING;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell our caller we are a window
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for our parent
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our previous sibling, a
|
||||
* nsHTMLComboboxButtonAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLComboboxButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We are the last sibling of our parent.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We only have one child, a list
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We only have one child, a list
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We only have one child, a list
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxWindowAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the areaFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void nsHTMLComboboxWindowAccessible::GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
{
|
||||
// get our first option
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
// now get its frame
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
*aBoundingFrame = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(child));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
|
||||
return;
|
||||
#endif
|
||||
|
||||
frame->GetParent(aBoundingFrame);
|
||||
frame->GetParent(&frame);
|
||||
#ifdef DEBUG
|
||||
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::areaFrame))
|
||||
return;
|
||||
#endif
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: John Gaunt (jgaunt@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsHTMLComboboxAccessible_h__
|
||||
#define __nsHTMLComboboxAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
|
||||
/*
|
||||
* A class the represents the HTML Combobox widget.
|
||||
*/
|
||||
class nsHTMLComboboxAccessible : public nsAccessible,
|
||||
public nsIAccessibleSelectable,
|
||||
public nsIDOMXULListener
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLESELECTABLE
|
||||
|
||||
nsHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLComboboxAccessible();
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
// popup listener
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Command(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
virtual void SetupMenuListener();
|
||||
|
||||
protected:
|
||||
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* A class the represents the text field in the Select to the left
|
||||
* of the drop down button
|
||||
*/
|
||||
class nsHTMLComboboxTextFieldAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLComboboxTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/**
|
||||
* A class that represents the button inside the Select to the
|
||||
* right of the text field
|
||||
*/
|
||||
class nsHTMLComboboxButtonAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
enum { eAction_Click=0 };
|
||||
|
||||
nsHTMLComboboxButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* A class that represents the window that lives to the right
|
||||
* of the drop down button inside the Select. This is the window
|
||||
* that is made visible when the button is pressed.
|
||||
*/
|
||||
class nsHTMLComboboxWindowAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLComboboxWindowAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -29,15 +29,13 @@
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDOMHTMLLabelElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aNode, aShell)
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsLeafDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,19 +69,20 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::AppendLabelFor(nsIContent *aLookNode,
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
|
||||
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement;
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> formElement;
|
||||
nsAutoString nameString;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString label;
|
||||
|
||||
// go up tree get name of ancestor label if there is one. Don't go up farther than form element
|
||||
while (walkUpContent && label.IsEmpty() && !formElement) {
|
||||
while (walkUpContent && nameString.IsEmpty() && !formElement) {
|
||||
labelElement = do_QueryInterface(walkUpContent);
|
||||
if (labelElement)
|
||||
rv = AppendFlatStringFromSubtree(walkUpContent, &label);
|
||||
rv = AppendFlatStringFromSubtree(walkUpContent, &nameString);
|
||||
formElement = do_QueryInterface(walkUpContent); // reached top ancestor in form
|
||||
nsCOMPtr<nsIContent> nextParent;
|
||||
walkUpContent->GetParent(*getter_AddRefs(nextParent));
|
||||
@@ -96,19 +95,16 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval
|
||||
walkUpContent = do_QueryInterface(formElement);
|
||||
|
||||
if (walkUpContent) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
nsAutoString forId;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("id"), forId);
|
||||
// Actually we'll be walking down the content this time, with a depth first search
|
||||
if (!forId.IsEmpty())
|
||||
AppendLabelFor(walkUpContent,&forId,&label);
|
||||
AppendLabelFor(walkUpContent,&forId,&nameString);
|
||||
}
|
||||
|
||||
label.CompressWhitespace();
|
||||
if (label.IsEmpty())
|
||||
return nsAccessible::GetAccName(_retval);
|
||||
|
||||
_retval.Assign(label);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -118,10 +114,9 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// can be
|
||||
// focusable, focused, checked, protected, unavailable
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
*_retval = STATE_FOCUSABLE;
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
element->GetChecked(&checked);
|
||||
@@ -142,8 +137,8 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
|
||||
|
||||
// --- checkbox -----
|
||||
|
||||
nsHTMLCheckboxAccessible::nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLCheckboxAccessible::nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -162,44 +157,44 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
// check or uncheck
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
if (element)
|
||||
element->GetChecked(&checked);
|
||||
|
||||
if (checked)
|
||||
_retval = NS_LITERAL_STRING("uncheck");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("uncheck"));
|
||||
else
|
||||
_retval = NS_LITERAL_STRING("check");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("check"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) { // 0 is the magic value for default action
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
PRBool checked = PR_FALSE;
|
||||
element->GetChecked(&checked);
|
||||
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//------ Radio button -------
|
||||
|
||||
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -211,24 +206,24 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("select");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("select"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -242,8 +237,8 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
|
||||
// ----- Button -----
|
||||
|
||||
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -255,24 +250,24 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("press");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
@@ -283,9 +278,10 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mDOMNode));
|
||||
*_retval = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mNode));
|
||||
|
||||
if (!button)
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -293,7 +289,8 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
nsAutoString name;
|
||||
button->GetValue(name);
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
|
||||
*_retval = name.ToNewUnicode();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -301,8 +298,8 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
|
||||
// ----- HTML 4 Button: can contain arbitrary HTML content -----
|
||||
|
||||
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aNode, aShell)
|
||||
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -314,24 +311,24 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccActionName (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
|
||||
{
|
||||
if (index == 0) {
|
||||
_retval = NS_LITERAL_STRING("press");
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
@@ -344,26 +341,25 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
/* long getAccState (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
|
||||
if (content)
|
||||
rv = AppendFlatStringFromSubtree(content, &name);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
*_retval = name.ToNewUnicode();
|
||||
}
|
||||
|
||||
return rv;
|
||||
@@ -372,8 +368,8 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
|
||||
// --- textfield -----
|
||||
|
||||
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLFormControlAccessible(aNode, aShell)
|
||||
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
|
||||
nsHTMLFormControlAccessible(aShell, aNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -385,21 +381,17 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
|
||||
if (textArea) {
|
||||
textArea->GetValue(_retval);
|
||||
nsAutoString valueString;
|
||||
textArea->GetValue(valueString);
|
||||
*_retval = ToNewUnicode(valueString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
if (inputElement) {
|
||||
inputElement->GetValue(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* long getAccState (); */
|
||||
@@ -408,13 +400,12 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
// can be
|
||||
// focusable, focused, protected. readonly, unavailable, selected
|
||||
|
||||
nsAccessible::GetAccState(_retval);
|
||||
*_retval |= STATE_FOCUSABLE;
|
||||
*_retval = STATE_FOCUSABLE;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
PRBool isReadOnly = PR_FALSE;
|
||||
elt->HasAttribute(NS_LITERAL_STRING("readonly"), &isReadOnly);
|
||||
if (isReadOnly)
|
||||
@@ -422,13 +413,9 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
|
||||
// Get current selection and find out if current node is in it
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
|
||||
nsIFrame *frame;
|
||||
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
@@ -454,7 +441,7 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
*_retval |= moreStates;
|
||||
return rv;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
PRBool disabled = PR_FALSE;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef _nsHTMLFormControlAccessible_H_
|
||||
#define _nsHTMLFormControlAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsICheckboxControlFrame;
|
||||
|
||||
@@ -33,12 +33,12 @@ class nsICheckboxControlFrame;
|
||||
* - walking up to get name from label
|
||||
* - support basic state
|
||||
*/
|
||||
class nsHTMLFormControlAccessible : public nsLeafAccessible
|
||||
class nsHTMLFormControlAccessible : public nsLeafDOMAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
protected:
|
||||
@@ -49,10 +49,10 @@ class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -60,10 +60,10 @@ class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -71,24 +71,24 @@ class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
class nsHTML4ButtonAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTML4ButtonAccessible : public nsDOMAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTML4ButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
};
|
||||
|
||||
@@ -96,9 +96,9 @@ public:
|
||||
class nsHTMLTextFieldAccessible : public nsHTMLFormControlAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
@@ -30,55 +30,19 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsRootAccessible)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameAccessible, nsHTMLBlockAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameAccessible, nsHTMLBlockAccessible);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameAccessible::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
|
||||
if ( !aInstancePtr )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (aIID.Equals(NS_GET_IID(nsIAccessibleDocument))) {
|
||||
*aInstancePtr = (void*)(nsIAccessibleDocument*) this;
|
||||
NS_IF_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsHTMLBlockAccessible::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *aDoc):
|
||||
nsHTMLBlockAccessible(aNode, aShell), mRootAccessible(aRoot), nsDocAccessibleMixin(aDoc)
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot):
|
||||
nsDOMAccessible(aShell, aNode)
|
||||
{
|
||||
mRootAccessible = aRoot;
|
||||
}
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(nsAWritableString& aAccName)
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
return GetTitle(aAccName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccValue(nsAWritableString& aAccValue)
|
||||
{
|
||||
return GetURL(aAccValue);
|
||||
return mRootAccessible->GetAccName(aAccName);
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
@@ -102,54 +66,13 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PANE;
|
||||
return NS_OK;
|
||||
return mRootAccessible->GetAccRole(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccState(PRUint32 *aAccState)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetAccState(aAccState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetURL(aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetMimeType(aMimeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocType(aDocType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetNameSpaceURIForID(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
//=============================//
|
||||
// nsHTMLIFrameRootAccessible //
|
||||
//=============================//
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode):
|
||||
nsRootAccessible(aShell)
|
||||
{
|
||||
mRealDOMNode = aNode;
|
||||
@@ -160,6 +83,23 @@ nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWea
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
||||
{
|
||||
}
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
if (shell)
|
||||
shell->GetDocument(getter_AddRefs(document));
|
||||
if (document) {
|
||||
const nsString* docTitle = document->GetDocumentTitle();
|
||||
if (docTitle && !docTitle->IsEmpty()) {
|
||||
*aAccName = docTitle->ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aAccName = ToNewUnicode(NS_LITERAL_STRING("Frame"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
@@ -182,7 +122,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_ret
|
||||
return accessible->GetAccNextSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
@@ -194,7 +134,14 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **
|
||||
return accessible->GetAccPreviousSibling(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PANE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible** aAcc)
|
||||
@@ -202,11 +149,6 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
// Start by finding our PresShell and from that
|
||||
// we get our nsIDocShell in order to walk the DocShell tree
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
if (!presShell) {
|
||||
*aAcc = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
|
||||
// Now that we have the DocShell QI
|
||||
@@ -241,7 +183,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
// OK, we found the content node in the parent doc
|
||||
// that corresponds to this sub-doc
|
||||
// Get the frame for that content
|
||||
nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(parentPresShell);
|
||||
nsCOMPtr<nsIWeakReference> wr(getter_AddRefs(NS_GetWeakReference(parentPresShell)));
|
||||
nsIFrame* frame = nsnull;
|
||||
parentPresShell->GetPrimaryFrameFor(content, &frame);
|
||||
#ifdef NS_DEBUG_X
|
||||
@@ -258,7 +200,7 @@ NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetHTMLIFrameAccessible(nsIAccessible*
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
|
||||
|
||||
*aAcc = acc;
|
||||
*aAcc = CreateNewAccessible(acc, node, wr);
|
||||
NS_IF_ADDREF(*aAcc);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -24,29 +24,20 @@
|
||||
#define _nsIFrameRootAccessible_H_
|
||||
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsIWebShell;
|
||||
class nsIWeakReference;
|
||||
|
||||
class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
|
||||
public nsIAccessibleDocument,
|
||||
public nsDocAccessibleMixin
|
||||
class nsHTMLIFrameAccessible : public nsDOMAccessible
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
public:
|
||||
nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *doc);
|
||||
nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& AccValue);
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAccessible> mRootAccessible;
|
||||
@@ -54,10 +45,9 @@ class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
|
||||
|
||||
class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
|
||||
public:
|
||||
nsHTMLIFrameRootAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode);
|
||||
virtual ~nsHTMLIFrameRootAccessible();
|
||||
|
||||
/* attribute wstring accName; */
|
||||
@@ -69,9 +59,15 @@ class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
||||
/* nsIAccessible getAccPreviousSibling (); */
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
|
||||
NS_IMETHOD GetHTMLIFrameAccessible(nsIAccessible** aAcc);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mRealDOMNode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,21 +30,15 @@
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsIImageFrame.h"
|
||||
|
||||
// --- image -----
|
||||
|
||||
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDOMNode, aShell)
|
||||
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame):
|
||||
nsLinkableAccessible(aShell, aDOMNode), mPresShell(aShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
shell->GetDocument(getter_AddRefs(doc));
|
||||
aShell->GetDocument(getter_AddRefs(doc));
|
||||
nsAutoString mapElementName;
|
||||
|
||||
if (doc && element) {
|
||||
@@ -58,56 +52,20 @@ nsLinkableAccessible(aDOMNode, aShell)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// The state is a bitfield, get our inherited state, then logically OR it with STATE_ANIMATED if this
|
||||
// is an animated image.
|
||||
|
||||
nsLinkableAccessible::GetAccState(_retval);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame *frame = nsnull;
|
||||
if (content && shell)
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
|
||||
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(frame));
|
||||
|
||||
nsCOMPtr<imgIRequest> imageRequest;
|
||||
if (imageFrame)
|
||||
imageFrame->GetImageRequest(getter_AddRefs(imageRequest));
|
||||
|
||||
nsCOMPtr<imgIContainer> imgContainer;
|
||||
if (imageRequest)
|
||||
imageRequest->GetImage(getter_AddRefs(imgContainer));
|
||||
|
||||
if (imgContainer) {
|
||||
PRUint32 numFrames;
|
||||
imgContainer->GetNumFrames(&numFrames);
|
||||
if (numFrames > 1)
|
||||
*_retval |= STATE_ANIMATED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mNode));
|
||||
if (imageContent) {
|
||||
nsAutoString name;
|
||||
rv = AppendFlatStringFromContentNode(imageContent, &name);
|
||||
nsAutoString nameString;
|
||||
nsresult rv = AppendFlatStringFromContentNode(imageContent, &nameString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
return rv;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* wstring getAccRole (); */
|
||||
@@ -141,12 +99,12 @@ nsIAccessible *nsHTMLImageAccessible::CreateAreaAccessible(PRUint32 areaNum)
|
||||
if (!domNode)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
if (!accService)
|
||||
return nsnull;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
||||
if (accService) {
|
||||
nsIAccessible* acc = nsnull;
|
||||
accService->CreateHTMLAreaAccessible(mPresShell, domNode, this, &acc);
|
||||
nsCOMPtr<nsISupports> presShell(do_QueryInterface(mPresShell));
|
||||
accService->CreateHTMLAreaAccessible(presShell, domNode, this, &acc);
|
||||
return acc;
|
||||
}
|
||||
return nsnull;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef _nsHTMLImageAccessible_H_
|
||||
#define _nsHTMLImageAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
@@ -38,9 +38,8 @@ class nsHTMLImageAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLImageAccessible(nsIDOMNode* aDomNode, nsIImageFrame *imageFrame, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode, nsIImageFrame *imageFrame);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
@@ -49,6 +48,7 @@ public:
|
||||
protected:
|
||||
nsIAccessible *CreateAreaAccessible(PRUint32 areaNum);
|
||||
nsCOMPtr<nsIDOMHTMLMapElement> mMapElement;
|
||||
nsCOMPtr<nsIPresShell> mPresShell;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,24 +32,21 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsLinkableAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
if (!IsALink()) // Also initializes private data members
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString name;
|
||||
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &name);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
}
|
||||
nsAutoString nameString;
|
||||
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -61,3 +58,14 @@ NS_IMETHODIMP nsHTMLLinkAccessible::GetAccRole(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
|
||||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
|
||||
*_retval = hrefString.ToNewUnicode();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -24,15 +24,18 @@
|
||||
#ifndef _nsHTMLLinkAccessible_H_
|
||||
#define _nsHTMLLinkAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsHTMLLinkAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsHTMLListboxAccessible.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
/** ----- nsHTMLListboxAccessible ----- */
|
||||
|
||||
/**
|
||||
* Constructor -- create the nsHTMLAccessible
|
||||
*/
|
||||
nsHTMLListboxAccessible::nsHTMLListboxAccessible(nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
/** Inherit the ISupports impl from nsAccessible */
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLListboxAccessible, nsAccessible, nsIAccessibleSelectable)
|
||||
|
||||
/**
|
||||
* Tell our caller we are a list ( there isn't a listbox value )
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our last child, a nsHTMLListboxWindowAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Through the arg, pass back our first child, a nsHTMLListboxWindowAccessible object
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* We always have 1 child: SelectList.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* nsIAccessibleSelectable method. This needs to get from the select the list
|
||||
* of select options and then iterate through that pulling out the selected
|
||||
* items and creating IAccessible objects for them. Put the IAccessibles in
|
||||
* the nsISupportsArray and return them.
|
||||
* retval will be nsnull if:
|
||||
* - there are no options in the select
|
||||
* - there are options but none are selected
|
||||
* - the DOMNode is not a nsIDOMHTMLSelectElement ( shouldn't happen )
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetSelectedChildren(nsISupportsArray **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> select(do_QueryInterface(mDOMNode));
|
||||
if(select) {
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
// get all the options in the select
|
||||
select->GetOptions(getter_AddRefs(options));
|
||||
if (options) {
|
||||
// set up variables we need to get the selected options and to get their nsIAccessile objects
|
||||
PRUint32 length;
|
||||
options->GetLength(&length);
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
nsCOMPtr<nsISupportsArray> selectedAccessibles;
|
||||
NS_NewISupportsArray(getter_AddRefs(selectedAccessibles));
|
||||
if (!selectedAccessibles || !accService)
|
||||
return NS_ERROR_FAILURE;
|
||||
// find the selected options and get the accessible objects;
|
||||
PRBool isSelected = PR_FALSE;
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
for (PRUint32 i = 0 ; i < length ; i++) {
|
||||
nsCOMPtr<nsIDOMNode> tempNode;
|
||||
options->Item(i,getter_AddRefs(tempNode));
|
||||
if (tempNode) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> tempOption(do_QueryInterface(tempNode));
|
||||
if (tempOption)
|
||||
tempOption->GetSelected(&isSelected);
|
||||
if (isSelected) {
|
||||
nsCOMPtr<nsIAccessible> tempAccess;
|
||||
accService->CreateHTMLSelectOptionAccessible(tempOption, this, context, getter_AddRefs(tempAccess));
|
||||
if ( tempAccess )
|
||||
selectedAccessibles->AppendElement(tempAccess);
|
||||
isSelected = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedAccessibles->Count(&length); // reusing length
|
||||
if ( length != 0 ) { // length of nsISupportsArray containing selected options
|
||||
*_retval = selectedAccessibles;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no options, not a select or none of the options are selected
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our value is the value of our ( first ) selected child. SelectElement
|
||||
* returns this by default with GetValue().
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> select (do_QueryInterface(mDOMNode));
|
||||
if ( select ) {
|
||||
select->GetValue(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLListboxAccessible we can have the following states:
|
||||
* STATE_FOCUSED
|
||||
* STATE_READONLY
|
||||
* STATE_FOCUSABLE
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLListboxAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
*_retval |= STATE_READONLY | STATE_FOCUSABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: John Gaunt (jgaunt@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsHTMLListboxAccessible_h__
|
||||
#define __nsHTMLListboxAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
|
||||
/*
|
||||
* A class the represents the HTML Combobox widget.
|
||||
*/
|
||||
class nsHTMLListboxAccessible : public nsAccessible,
|
||||
public nsIAccessibleSelectable
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLESELECTABLE
|
||||
|
||||
nsHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLListboxAccessible() {}
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,794 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsHTMLSelectAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
|
||||
/*
|
||||
* A class the represents the text field in the Select to the left
|
||||
* of the drop down button
|
||||
*/
|
||||
class nsHTMLSelectTextFieldAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* A base class that can listen to menu events. Its used so the
|
||||
* button and the window accessibles can change there name and role
|
||||
* depending on whether the drop down list is dropped down on not
|
||||
*/
|
||||
class nsMenuListenerAccessible : public nsAccessible, public nsIDOMXULListener
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsMenuListenerAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsMenuListenerAccessible();
|
||||
|
||||
// popup listener
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Command(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
virtual void SetupMenuListener();
|
||||
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsMenuListenerAccessible, nsAccessible, nsIDOMXULListener)
|
||||
|
||||
/**
|
||||
* A class that represents the button inside the Select to the right of the text field
|
||||
*/
|
||||
class nsHTMLSelectButtonAccessible : public nsMenuListenerAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
|
||||
NS_IMETHOD AccDoAction(PRUint8 index);
|
||||
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* A class that represents the window that lives to the right
|
||||
* of the drop down button inside the Select. This is the window
|
||||
* that is made visible when the button is pressed.
|
||||
*/
|
||||
class nsHTMLSelectWindowAccessible : public nsMenuListenerAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectWindowAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
virtual void GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* The list that contains all the options in the select. It is inside the window.
|
||||
*/
|
||||
class nsHTMLSelectListAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectListAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLSelectListAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
//--------- nsHTMLSelectAccessible -----
|
||||
|
||||
nsHTMLSelectAccessible::nsHTMLSelectAccessible(nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLSelectAccessible, nsAccessible, nsIAccessibleSelectable)
|
||||
|
||||
// ------------- Helper method for determination of proper Frame ------
|
||||
//static
|
||||
PRBool nsHTMLSelectAccessible::IsCorrectFrame( nsIFrame* aFrame, nsIAtom* aAtom ) {
|
||||
if (!aFrame || !aAtom)
|
||||
return PR_FALSE;
|
||||
nsCOMPtr<nsIAtom> frameType;
|
||||
aFrame->GetFrameType(getter_AddRefs(frameType));
|
||||
if (frameType.get() != aAtom)
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> text;
|
||||
GetAccFirstChild(getter_AddRefs(text));
|
||||
if (text)
|
||||
return text->GetAccValue(_retval);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_COMBOBOX;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
// create a window accessible
|
||||
*_retval = new nsHTMLSelectWindowAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
// create a text field
|
||||
|
||||
*_retval = new nsHTMLSelectTextFieldAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
// always have 3 children
|
||||
*_retval = 3;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectAccessible::GetSelectedChildren(nsISupportsArray **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------- SelectTextFieldAccessible ------
|
||||
|
||||
nsHTMLSelectTextFieldAccessible::nsHTMLSelectTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if ( !frame )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::textFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AppendFlatStringFromSubtree(content, &_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectTextFieldAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our first child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
if ( !frame )
|
||||
return;
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectTextFieldAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// --------- nsMenuListenerAccessible -----------
|
||||
|
||||
nsMenuListenerAccessible::nsMenuListenerAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
nsMenuListenerAccessible::~nsMenuListenerAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::PopupShowing(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::PopupHiding(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMenuListenerAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuListenerAccessible::SetupMenuListener()
|
||||
{
|
||||
// not not already one register ourselves as a popup listener
|
||||
if (!mRegistered) {
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mDOMNode));
|
||||
if (!eventReceiver) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = eventReceiver->AddEventListener(NS_LITERAL_STRING("popupshowing"), this, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------- SelectButtonAccessible ------
|
||||
|
||||
nsHTMLSelectButtonAccessible::nsHTMLSelectButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsMenuListenerAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/* void accDoAction (in PRUint8 index); */
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame->GetNextSibling(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::gfxButtonControlFrame) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
frame->GetContent(getter_AddRefs(content));
|
||||
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(content));
|
||||
if (element)
|
||||
{
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* PRUint8 getAccNumActions (); */
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccNumActions(PRUint8 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectButtonAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our second child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
frame->FirstChild(context, nsnull, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetNextSibling(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::gfxButtonControlFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PUSHBUTTON;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
return GetAccActionName(0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
|
||||
{
|
||||
SetupMenuListener();
|
||||
|
||||
// get the current state open or closed
|
||||
// set _retval to it.
|
||||
// notice its supposed to be reversed. Close if opened
|
||||
// and Open if closed.
|
||||
|
||||
if (mOpen)
|
||||
_retval = NS_LITERAL_STRING("Close");
|
||||
else
|
||||
_retval = NS_LITERAL_STRING("Open");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectWindowAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectTextFieldAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectButtonAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
nsHTMLSelectWindowAccessible::nsHTMLSelectWindowAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell)
|
||||
:nsMenuListenerAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsAccessible::GetAccState(_retval);
|
||||
|
||||
SetupMenuListener();
|
||||
|
||||
// if open we are visible if closed we are invisible
|
||||
// set _retval to it.
|
||||
if (mOpen)
|
||||
*_retval |= STATE_DEFAULT;
|
||||
else
|
||||
*_retval |= STATE_INVISIBLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsHTMLSelectButtonAccessible(parent, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsHTMLSelectListAccessible(this, mDOMNode, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectWindowAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectWindowAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
{
|
||||
// get our first option
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
// now get its frame
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
*aRelativeFrame = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(child));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::blockFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(&frame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( frame, nsLayoutAtoms::areaFrame) )
|
||||
return;
|
||||
|
||||
frame->GetParent(aRelativeFrame);
|
||||
if ( ! nsHTMLSelectAccessible::IsCorrectFrame( *aRelativeFrame, nsLayoutAtoms::listControlFrame) )
|
||||
return;
|
||||
|
||||
frame->GetRect(aBounds);
|
||||
}
|
||||
|
||||
//----------
|
||||
|
||||
|
||||
nsHTMLSelectListAccessible::nsHTMLSelectListAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return mParent->AccGetBounds(x,y,width,height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LIST;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> last;
|
||||
mDOMNode->GetLastChild(getter_AddRefs(last));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, last, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> first;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(first));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, first, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------
|
||||
|
||||
nsHTMLSelectOptionAccessible::nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> next;
|
||||
mDOMNode->GetNextSibling(getter_AddRefs(next));
|
||||
|
||||
if (next) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, next, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> prev;
|
||||
mDOMNode->GetPreviousSibling(getter_AddRefs(prev));
|
||||
|
||||
if (prev) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, prev, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content (do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString option;
|
||||
nsresult rv = AppendFlatStringFromSubtree(content, &option);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
option.CompressWhitespace();
|
||||
_retval.Assign(option);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsHTMLSelectAccessible_h__
|
||||
#define __nsHTMLSelectAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
|
||||
class nsHTMLSelectAccessible : public nsAccessible,
|
||||
public nsIAccessibleSelectable
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLESELECTABLE
|
||||
|
||||
nsHTMLSelectAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLSelectAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
|
||||
// helper method to verify frames
|
||||
static PRBool IsCorrectFrame( nsIFrame* aFrame, nsIAtom* aAtom );
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Each option in the Select. These are in the nsListAccessible
|
||||
*/
|
||||
class nsHTMLSelectOptionAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,312 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s): John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
|
||||
/** ----- nsHTMLSelectListAccessible ----- */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
nsHTMLSelectListAccessible::nsHTMLSelectListAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return mParent->AccGetBounds(x,y,width,height);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LIST;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> last;
|
||||
mDOMNode->GetLastChild(getter_AddRefs(last));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, last, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> first;
|
||||
mDOMNode->GetFirstChild(getter_AddRefs(first));
|
||||
|
||||
*_retval = new nsHTMLSelectOptionAccessible(this, first, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLSelectListAccessible we can have the following states:
|
||||
* STATE_MULTISELECTABLE
|
||||
* STATE_EXTSELECTABLE
|
||||
* no STATE_FOCUSED! -- can't be focused, options are focused instead
|
||||
* no STATE_FOCUSABLE! -- can't be focused, options are focused instead
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> select (do_QueryInterface(mDOMNode));
|
||||
if ( select ) {
|
||||
PRBool multiple;
|
||||
select->GetMultiple(&multiple);
|
||||
if ( multiple )
|
||||
*_retval |= STATE_MULTISELECTABLE | STATE_EXTSELECTABLE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** ----- nsHTMLSelectOptionAccessible ----- */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
nsHTMLSelectOptionAccessible::nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> next;
|
||||
mDOMNode->GetNextSibling(getter_AddRefs(next));
|
||||
|
||||
if (next) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, next, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> prev;
|
||||
mDOMNode->GetPreviousSibling(getter_AddRefs(prev));
|
||||
|
||||
if (prev) {
|
||||
*_retval = new nsHTMLSelectOptionAccessible(mParent, prev, mPresShell);
|
||||
if ( ! *_retval )
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content (do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString option;
|
||||
nsresult rv = AppendFlatStringFromSubtree(content, &option);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAWritableString
|
||||
option.CompressWhitespace();
|
||||
_retval.Assign(option);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLSelectOptionAccessible we can have the following states:
|
||||
* STATE_SELECTABLE
|
||||
* STATE_SELECTED
|
||||
* STATE_FOCUSED
|
||||
* STATE_FOCUSABLE
|
||||
* STATE_INVISIBLE // not implemented yet
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// this sets either STATE_FOCUSED or 0 (nsAccessible::GetAccState() doesn't know about list options)
|
||||
*_retval = 0;
|
||||
nsCOMPtr<nsIDOMNode> focusedOptionNode, parentNode;
|
||||
mParent->AccGetDOMNode(getter_AddRefs(parentNode));
|
||||
GetFocusedOptionNode(mPresShell, parentNode, focusedOptionNode);
|
||||
if (focusedOptionNode == mDOMNode)
|
||||
*_retval |= STATE_FOCUSED;
|
||||
|
||||
// Are we selected?
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option (do_QueryInterface(mDOMNode));
|
||||
if ( option ) {
|
||||
PRBool isSelected = PR_FALSE;
|
||||
option->GetSelected(&isSelected);
|
||||
if ( isSelected )
|
||||
*_retval |= STATE_SELECTED;
|
||||
}
|
||||
|
||||
*_retval |= STATE_SELECTABLE | STATE_FOCUSABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIWeakReference *aPresShell,
|
||||
nsIDOMNode *aListNode,
|
||||
nsCOMPtr<nsIDOMNode>& aFocusedOptionNode)
|
||||
{
|
||||
NS_ASSERTION(aListNode, "Called GetFocusedOptionNode without a valid list node");
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aPresShell));
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsIFrame *frame = nsnull;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aListNode));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv; // How can list content not have a list frame?
|
||||
NS_ASSERTION(listFrame, "We don't have a list frame, but rv returned a success code.");
|
||||
|
||||
// Get what's focused by asking frame for "selected item".
|
||||
// Don't use DOM method of getting selected item, which instead gives *first* selected option
|
||||
PRInt32 focusedOptionIndex = 0;
|
||||
rv = listFrame->GetSelectedIndex(&focusedOptionIndex);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
|
||||
// Get options
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(aListNode));
|
||||
NS_ASSERTION(selectElement, "No select element where it should be");
|
||||
rv = selectElement->GetOptions(getter_AddRefs(options));
|
||||
}
|
||||
|
||||
// Either use options and focused index, or default to list node itself
|
||||
if (NS_SUCCEEDED(rv) && options && focusedOptionIndex >= 0) // Something is focused
|
||||
rv = options->Item(focusedOptionIndex, getter_AddRefs(aFocusedOptionNode));
|
||||
else { // If no options in list or focusedOptionIndex <0, then we are not focused on an item
|
||||
aFocusedOptionNode = aListNode; // return normal target content
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsHTMLSelectListAccessible_h__
|
||||
#define __nsHTMLSelectListAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
/*
|
||||
* The list that contains all the options in the select.
|
||||
*/
|
||||
class nsHTMLSelectListAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectListAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLSelectListAccessible() {}
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
/*
|
||||
* Options inside the select, contained within the list
|
||||
*/
|
||||
class nsHTMLSelectOptionAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLSelectOptionAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
static nsresult GetFocusedOptionNode(nsIWeakReference *aPresShell, nsIDOMNode *aListNode, nsCOMPtr<nsIDOMNode>& aFocusedOptionNode);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aDomNode, aShell)
|
||||
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccRole(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLBlockAccessible(aDomNode, aShell)
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsDOMAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,20 +24,20 @@
|
||||
#ifndef _nsHTMLTableAccessible_H_
|
||||
#define _nsHTMLTableAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsHTMLTableCellAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTMLTableCellAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
class nsHTMLTableAccessible : public nsHTMLBlockAccessible
|
||||
class nsHTMLTableAccessible : public nsDOMAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "nsHTMLTextAccessible.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsISelection.h"
|
||||
@@ -32,26 +31,36 @@
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
|
||||
nsLinkableAccessible(aShell, aDomNode)
|
||||
{
|
||||
}
|
||||
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAWritableString& _retval)
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
nsAutoString nameString;
|
||||
nsresult rv = NS_OK;
|
||||
//if (IsALink()) {
|
||||
// rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
|
||||
//}
|
||||
//else
|
||||
mNode->GetNodeValue(nameString);
|
||||
nameString.CompressWhitespace();
|
||||
*_retval = nameString.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_TEXT;
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef _nsHTMLTextAccessible_H_
|
||||
#define _nsHTMLTextAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsGenericAccessible.h"
|
||||
|
||||
class nsIWeakReference;
|
||||
class nsITextControlFrame;
|
||||
@@ -32,8 +32,8 @@ class nsHTMLTextAccessible : public nsLinkableAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
@@ -36,24 +35,9 @@
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHTMLSelectListAccessible.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
|
||||
@@ -61,24 +45,18 @@ NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFormListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsAccessible)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsAccessible);
|
||||
NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsAccessible);
|
||||
|
||||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,aShell),
|
||||
nsDocAccessibleMixin(aShell), mAccService(do_GetService("@mozilla.org/accessibilityService;1"))
|
||||
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,nsnull,aShell)
|
||||
{
|
||||
mListener = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
|
||||
shell->GetDocument(getter_AddRefs(mDocument));
|
||||
mDOMNode = do_QueryInterface(mDocument);
|
||||
|
||||
nsLayoutAtoms::AddRefAtoms();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
@@ -86,23 +64,24 @@ nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull
|
||||
//-----------------------------------------------------
|
||||
nsRootAccessible::~nsRootAccessible()
|
||||
{
|
||||
nsLayoutAtoms::ReleaseAtoms();
|
||||
RemoveAccessibleEventListener(mListener);
|
||||
}
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccName(nsAWritableString& aAccName)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccName(PRUnichar * *aAccName)
|
||||
{
|
||||
return GetTitle(aAccName);
|
||||
const nsString* docTitle = mDocument->GetDocumentTitle();
|
||||
if (docTitle && !docTitle->IsEmpty())
|
||||
*aAccName = docTitle->ToNewUnicode();
|
||||
else *aAccName = ToNewUnicode(NS_LITERAL_STRING("Document"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// helpers
|
||||
nsIFrame* nsRootAccessible::GetFrame()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell)
|
||||
return nsnull;
|
||||
|
||||
nsIFrame* root = nsnull;
|
||||
if (shell)
|
||||
shell->GetRootFrame(&root);
|
||||
@@ -116,6 +95,11 @@ void nsRootAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
(*aRelativeFrame)->GetRect(aBounds);
|
||||
}
|
||||
|
||||
nsIAccessible* nsRootAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell)
|
||||
{
|
||||
return new nsHTMLBlockAccessible(aAccessible, aNode, aShell);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIAccessible accParent; */
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
{
|
||||
@@ -127,16 +111,6 @@ NS_IMETHODIMP nsRootAccessible::GetAccParent(nsIAccessible * *aAccParent)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell) {
|
||||
*aAccRole = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
// Commenting this out for now.
|
||||
// It was requested that we always use pane objects instead of client objects.
|
||||
// However, it might be asked that we put client objects back.
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
shell->GetPresContext(getter_AddRefs(context));
|
||||
nsCOMPtr<nsISupports> container;
|
||||
@@ -154,21 +128,16 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
|
||||
}
|
||||
|
||||
*aAccRole = ROLE_CLIENT;
|
||||
*/
|
||||
|
||||
*aAccRole = ROLE_PANE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccState(PRUint32 *aAccState)
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccValue(PRUnichar * *aAccValue)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetAccState(aAccState);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetAccValue(nsAWritableString& aAccValue)
|
||||
{
|
||||
return GetURL(aAccValue);
|
||||
nsCOMPtr<nsIURI> pURI(mDocument->GetDocumentURL());
|
||||
char *path;
|
||||
pURI->GetSpec(&path);
|
||||
*aAccValue = ToNewUnicode(nsLiteralCString(path));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
|
||||
@@ -178,9 +147,6 @@ NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventLis
|
||||
{
|
||||
// add an event listener to the document
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
shell->GetDocument(getter_AddRefs(document));
|
||||
|
||||
@@ -244,64 +210,70 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
|
||||
NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (mListener) {
|
||||
// optionTargetNode is set to current option for HTML selects
|
||||
nsCOMPtr<nsIDOMNode> targetNode, optionTargetNode;
|
||||
nsresult rv = GetTargetNode(aEvent, targetNode);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Check to see if it's a select element. If so, need the currently focused option
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(targetNode));
|
||||
if (selectElement) // ----- Target Node is an HTML <select> element ------
|
||||
nsHTMLSelectOptionAccessible::GetFocusedOptionNode(mPresShell, targetNode, optionTargetNode);
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
aEvent->GetOriginalTarget(getter_AddRefs(t));
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(t));
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString eventType;
|
||||
aEvent->GetType(eventType);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
// the "focus" type is pulled from nsDOMEvent.cpp
|
||||
if ( eventType.EqualsIgnoreCase("focus") ) {
|
||||
if (mCurrentFocus == content)
|
||||
return NS_OK;
|
||||
mCurrentFocus = content;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAccessible> a(do_QueryInterface(frame));
|
||||
if (!a)
|
||||
a = do_QueryInterface(content);
|
||||
|
||||
if (!a) {
|
||||
// is it a link?
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(content));
|
||||
if (link) {
|
||||
#ifdef DEBUG
|
||||
printf("focus link!\n");
|
||||
#endif
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
if (node)
|
||||
a = new nsHTMLLinkAccessible(shell, node);
|
||||
}
|
||||
}
|
||||
|
||||
if (a) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
nsCOMPtr<nsIAccessible> na(CreateNewAccessible(a, node, mPresShell));
|
||||
if ( !na )
|
||||
return NS_OK;
|
||||
|
||||
if (NS_SUCCEEDED(mAccService->GetAccessibleFor(targetNode, getter_AddRefs(accessible)))) {
|
||||
if ( eventType.EqualsIgnoreCase("focus") ) {
|
||||
if (mCurrentFocus != targetNode) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, accessible);
|
||||
mCurrentFocus = targetNode;
|
||||
}
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("change") ) {
|
||||
if (optionTargetNode) { // Set to current option only for HTML selects
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_SELECTION, accessible);
|
||||
if (mCurrentFocus != optionTargetNode &&
|
||||
NS_SUCCEEDED(mAccService->GetAccessibleFor(optionTargetNode, getter_AddRefs(accessible)))) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, accessible);
|
||||
mCurrentFocus = optionTargetNode;
|
||||
}
|
||||
}
|
||||
else
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("CheckboxStateChange") ) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
else if ( eventType.EqualsIgnoreCase("RadiobuttonStateChange") ) {
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible);
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr<nsIDOMNode>& aTargetNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
|
||||
aEvent->GetOriginalTarget(getter_AddRefs(domEventTarget));
|
||||
|
||||
nsresult rv;
|
||||
aTargetNode = do_QueryInterface(domEventTarget, &rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// ------- nsIDOMFocusListener Methods (1) -------------
|
||||
// ------- nsIDOMFocusListener Methods (2) -------------
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
@@ -332,147 +304,5 @@ NS_IMETHODIMP nsRootAccessible::Select(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
// gets Input events when text is entered or deleted in a textarea or input
|
||||
NS_IMETHODIMP nsRootAccessible::Input(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
// ------- nsIAccessibleDocument Methods (5) ---------------
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetURL(aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetMimeType(aMimeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocType(aDocType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetNameSpaceURIForID(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
|
||||
nsDocAccessibleMixin::nsDocAccessibleMixin(nsIDocument *aDoc):mDocument(aDoc)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocAccessibleMixin::nsDocAccessibleMixin(nsIWeakReference *aPresShell)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aPresShell));
|
||||
NS_ASSERTION(shell,"Shell is gone!!! What are we doing here?");
|
||||
shell->GetDocument(getter_AddRefs(mDocument));
|
||||
}
|
||||
|
||||
nsDocAccessibleMixin::~nsDocAccessibleMixin()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetURL(nsAWritableString& aURL)
|
||||
{
|
||||
nsCOMPtr<nsIURI> pURI;
|
||||
mDocument->GetDocumentURL(getter_AddRefs(pURI));
|
||||
nsXPIDLCString path;
|
||||
pURI->GetSpec(getter_Copies(path));
|
||||
aURL.Assign(NS_ConvertUTF8toUCS2(path).get());
|
||||
//XXXaaronl Need to use CopyUTF8toUCS2(nsDependentCString(path), aURL); when it's written
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetTitle(nsAWritableString& aTitle)
|
||||
{
|
||||
// This doesn't leak - we don't own the const pointer that's returned
|
||||
aTitle = *(mDocument->GetDocumentTitle());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetMimeType(nsAWritableString& aMimeType)
|
||||
{
|
||||
if (mDocument)
|
||||
return mDocument->GetContentType(aMimeType);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocType(nsAWritableString& aDocType)
|
||||
{
|
||||
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMDocumentType> docType;
|
||||
|
||||
if (xulDoc) {
|
||||
aDocType = NS_LITERAL_STRING("window"); // doctype not implemented for XUL at time of writing - causes assertion
|
||||
return NS_OK;
|
||||
}
|
||||
else if (domDoc && NS_SUCCEEDED(domDoc->GetDoctype(getter_AddRefs(docType))) && docType) {
|
||||
return docType->GetName(aDocType);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAWritableString& aNameSpaceURI)
|
||||
{
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsINameSpaceManager> nameSpaceManager;
|
||||
if (NS_SUCCEEDED(mDocument->GetNameSpaceManager(*getter_AddRefs(nameSpaceManager))))
|
||||
return nameSpaceManager->GetNameSpaceURI(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
*doc = mDocument;
|
||||
if (mDocument) {
|
||||
NS_IF_ADDREF(*doc);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetAccState(PRUint32 *aAccState)
|
||||
{
|
||||
// Screen readers need to know when the document is finished loading (STATE_BUSY flag)
|
||||
// We do it this way, rather than via nsIWebProgressListener, because
|
||||
// if accessibility was turned on after a document already finished loading,
|
||||
// we would get no state changes from nsIWebProgressListener.
|
||||
// The GetBusyFlags method, however, always has the current busy state information for us.
|
||||
|
||||
*aAccState = 0;
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
presShell->GetPresContext(getter_AddRefs(context));
|
||||
if (context) {
|
||||
nsCOMPtr<nsISupports> container;
|
||||
context->GetContainer(getter_AddRefs(container));
|
||||
if (container) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
if (docShell) {
|
||||
PRUint32 busyFlags;
|
||||
docShell->GetBusyFlags(&busyFlags);
|
||||
if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE)
|
||||
*aAccState = nsIAccessible::STATE_BUSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -26,35 +26,17 @@
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleEventReceiver.h"
|
||||
#include "nsIAccessibleEventListener.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
|
||||
class nsDocAccessibleMixin
|
||||
{
|
||||
public:
|
||||
nsDocAccessibleMixin(nsIDocument *doc);
|
||||
nsDocAccessibleMixin(nsIWeakReference *aShell);
|
||||
virtual ~nsDocAccessibleMixin();
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
class nsRootAccessible : public nsAccessible,
|
||||
public nsDocAccessibleMixin,
|
||||
public nsIAccessibleDocument,
|
||||
public nsIAccessibleEventReceiver,
|
||||
public nsIDOMFocusListener,
|
||||
public nsIDOMFormListener
|
||||
|
||||
{
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
@@ -62,11 +44,10 @@ class nsRootAccessible : public nsAccessible,
|
||||
virtual ~nsRootAccessible();
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAWritableString& aAccValue);
|
||||
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
|
||||
NS_IMETHOD GetAccValue(PRUnichar * *aAccValue);
|
||||
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
// ----- nsIAccessibleEventReceiver -------------------
|
||||
|
||||
@@ -87,19 +68,17 @@ class nsRootAccessible : public nsAccessible,
|
||||
NS_IMETHOD Select(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Input(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
protected:
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsIFrame* GetFrame();
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr<nsIDOMNode>& aTargetNode);
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsIFrame* GetFrame();
|
||||
|
||||
// not a com pointer. We don't own the listener
|
||||
// it is the callers responsibility to remove the listener
|
||||
// otherwise we will get into circular referencing problems
|
||||
nsIAccessibleEventListener* mListener;
|
||||
nsCOMPtr<nsIDOMNode> mCurrentFocus;
|
||||
nsCOMPtr<nsIAccessibilityService> mAccService;
|
||||
// not a com pointer. We don't own the listener
|
||||
// it is the callers responsibility to remove the listener
|
||||
// otherwise we will get into circular referencing problems
|
||||
nsIAccessibleEventListener* mListener;
|
||||
nsCOMPtr<nsIContent> mCurrentFocus;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
|
||||
|
||||
722
mozilla/accessible/src/nsSelectAccessible.cpp
Normal file
722
mozilla/accessible/src/nsSelectAccessible.cpp
Normal file
@@ -0,0 +1,722 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Eric Vaughan (evaughan@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsSelectAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
//#include "nsMutableAccessible.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMMenuListener.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#if 0
|
||||
class nsSelectChildAccessible : public nsAccessible,
|
||||
public nsIDOMMenuListener
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsSelectChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectChildAccessible();
|
||||
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
|
||||
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
// popup listener
|
||||
NS_IMETHOD Create(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Destroy(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Action(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIContent> mSelectContent;
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsSelectChildAccessible, nsAccessible, nsIDOMMenuListener)
|
||||
|
||||
class nsSelectWindowAccessible : public nsAccessible,
|
||||
public nsIDOMMenuListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aPrev, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectWindowAccessible();
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccExtState(PRUint32 *_retval);
|
||||
|
||||
// popup listener
|
||||
NS_IMETHOD Create(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Destroy(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Action(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
// helpers
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIAccessible> mPrev;
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
PRBool mRegistered;
|
||||
PRBool mOpen;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsSelectWindowAccessible, nsAccessible, nsIDOMMenuListener)
|
||||
|
||||
class nsSelectListAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsSelectListAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
};
|
||||
|
||||
class nsListChildAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsListChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual ~nsListChildAccessible() {}
|
||||
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
|
||||
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
|
||||
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAccessible> mParent;
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
nsCOMPtr<nsIContent> mSelectContent;
|
||||
};
|
||||
|
||||
//---------
|
||||
|
||||
nsSelectAccessible::nsSelectAccessible(nsIAtom* aPopupAtom,
|
||||
nsIAccessible* aAccessible,
|
||||
nsIContent* aContent,
|
||||
nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
// our value is our first child's value. Which is the combo boxes text.
|
||||
nsCOMPtr<nsIAccessible> text;
|
||||
nsresult rv = GetAccFirstChild(getter_AddRefs(text));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// look at our role
|
||||
return text->GetAccValue(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_COMBOBOX;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
// get the last child. Wrap it with a connector that connects it to the window accessible
|
||||
nsCOMPtr<nsIAccessible> last;
|
||||
nsresult rv = nsAccessible::GetAccLastChild(getter_AddRefs(last));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!last) {
|
||||
// we have a parent but not previous
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, this, nsnull, nsnull, mContent, mPresShell);
|
||||
} else {
|
||||
*_retval = last;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
// get the last child. Wrap it with a connector that connects it to the window accessible
|
||||
nsCOMPtr<nsIAccessible> first;
|
||||
nsresult rv = nsAccessible::GetAccFirstChild(getter_AddRefs(first));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!first) {
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, this, nsnull, nsnull, mContent, mPresShell);
|
||||
} else {
|
||||
*_retval = first;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectAccessible::CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
return CreateNewLastAccessible(aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectAccessible::CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsSelectChildAccessible(mPopupAtom, mContent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = nsAccessible::GetAccChildCount(_retval);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// always have one more that is our window child
|
||||
(*_retval)++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
|
||||
nsSelectChildAccessible::nsSelectChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell):
|
||||
nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
mSelectContent = aSelectContent;
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccValue(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
rv = nsAccessible::GetAccRole(&role);
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// if its the text in the combo box then
|
||||
// its value should be its name.
|
||||
if (role == ROLE_TEXT) {
|
||||
rv = nsAccessible::GetAccName(_retval);
|
||||
} else {
|
||||
rv = nsAccessible::GetAccValue(_retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
rv = nsAccessible::GetAccRole(&role);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// any text in the combo box is static
|
||||
if (role == ROLE_STATICTEXT) {
|
||||
// if it the comboboxes text. Make it static
|
||||
*_retval = role;
|
||||
} else {
|
||||
rv = nsAccessible::GetAccRole(_retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 role = 0;
|
||||
|
||||
// look at our role
|
||||
nsAccessible::GetAccRole(&role);
|
||||
|
||||
// if button then we need to make the name be open or close
|
||||
if (role == ROLE_PUSHBUTTON) {
|
||||
{
|
||||
// if its a button and not already registered,
|
||||
// register ourselves as a popup listener
|
||||
if (!mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
|
||||
if (!eventReceiver) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
eventReceiver->AddEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
// get the current state open or closed
|
||||
// set _retval to it.
|
||||
// notice its supposed to be reversed. Close if opened
|
||||
// and Open if closed.
|
||||
|
||||
if (mOpen)
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("Close"));
|
||||
else
|
||||
*_retval = ToNewUnicode(NS_LITERAL_STRING("Open"));
|
||||
|
||||
} else {
|
||||
/*rv = nsAccessible::GetAccName(_retval);*/
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
*_retval = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsSelectChildAccessible::~nsSelectChildAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
#ifdef DEBUG
|
||||
printf("Open\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectChildAccessible::CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
return CreateNewPreviousAccessible(aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectChildAccessible::CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsSelectChildAccessible(mPopupAtom, mSelectContent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectChildAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> next;
|
||||
nsresult rv = nsAccessible::GetAccNextSibling(getter_AddRefs(next));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!next) {
|
||||
// ok no more siblings. Lets create our window
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetAccParent(getter_AddRefs(parent));
|
||||
|
||||
*_retval = new nsSelectWindowAccessible(mPopupAtom, parent, nsnull, nsnull, mSelectContent, mPresShell);
|
||||
} else {
|
||||
*_retval = next;
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
nsSelectWindowAccessible::nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aPrev, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
mPrev = aPrev;
|
||||
mPopupAtom = aPopupAtom;
|
||||
mRegistered = PR_FALSE;
|
||||
mOpen = PR_FALSE;
|
||||
}
|
||||
|
||||
nsSelectWindowAccessible::~nsSelectWindowAccessible()
|
||||
{
|
||||
if (mRegistered) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
|
||||
if (eventReceiver)
|
||||
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_TRUE;
|
||||
#ifdef DEBUG
|
||||
printf("Open\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::Close(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOpen = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
printf("Close\n");
|
||||
#endif
|
||||
|
||||
/* TBD send state change event */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// not not already one register ourselves as a popup listener
|
||||
|
||||
if (!mRegistered) {
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
|
||||
if (!eventReceiver) {
|
||||
*_retval = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult rv = eventReceiver->AddEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
mRegistered = PR_TRUE;
|
||||
}
|
||||
|
||||
// if open we are visible if closed we are invisible
|
||||
// set _retval to it.
|
||||
if (mOpen)
|
||||
*_retval |= STATE_DEFAULT;
|
||||
else
|
||||
*_retval |= STATE_INVISIBLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccExtState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval=0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_WINDOW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mPrev;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccLastChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsSelectListAccessible(mPopupAtom, this, nsnull, mContent, mPresShell);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccFirstChild(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = new nsSelectListAccessible(mPopupAtom, this, nsnull, mContent, mPresShell);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::GetAccChildCount(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP nsSelectWindowAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
*x = *y = *width = *height = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
nsIFrame* nsSelectWindowAccessible::GetBoundsFrame()
|
||||
{
|
||||
// get our frame
|
||||
nsIFrame* frame = GetFrame();
|
||||
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
GetPresContext(context);
|
||||
|
||||
// get its first popup child that should be the window
|
||||
frame->FirstChild(context, mPopupAtom, &frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
//----------
|
||||
|
||||
|
||||
nsSelectListAccessible::nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
:nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mPopupAtom = aPopupAtom;
|
||||
mParent = aParent;
|
||||
}
|
||||
|
||||
void nsSelectListAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mContent, &frame);
|
||||
if (aFrame == frame)
|
||||
aList = mPopupAtom;
|
||||
else
|
||||
aList = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
return mParent->AccGetBounds(x,y,width,height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccName(PRUnichar **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LIST;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSelectListAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectListAccessible::CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mContent, this, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
nsIAccessible* nsSelectListAccessible::CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mContent, this, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
//--------
|
||||
|
||||
nsListChildAccessible::nsListChildAccessible(nsIAtom* aPopupAtom, nsIContent* aSelectContent, nsIAccessible* aParent, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell):
|
||||
nsAccessible(aAccessible, aContent, aShell)
|
||||
{
|
||||
mParent = aParent;
|
||||
mPopupAtom = aPopupAtom;
|
||||
mSelectContent = aSelectContent;
|
||||
}
|
||||
|
||||
nsIAccessible* nsListChildAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
|
||||
{
|
||||
NS_ASSERTION(aAccessible && aContent,"Error not accessible or content");
|
||||
return new nsListChildAccessible(mPopupAtom, mSelectContent, mParent, aAccessible, aContent, aShell);
|
||||
}
|
||||
|
||||
void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mSelectContent, &frame);
|
||||
if (aFrame == frame)
|
||||
aList = mPopupAtom;
|
||||
else
|
||||
aList = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsListChildAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = mParent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
52
mozilla/accessible/src/nsSelectAccessible.h
Normal file
52
mozilla/accessible/src/nsSelectAccessible.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __nsSelectAccessible_h__
|
||||
#define __nsSelectAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
/*
|
||||
class nsSelectAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsSelectAccessible(nsIAtom* aPopupAtom, nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccName(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccValue(PRUnichar **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
|
||||
virtual ~nsSelectAccessible() {}
|
||||
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
|
||||
|
||||
nsCOMPtr<nsIAtom> mPopupAtom;
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
2
mozilla/aclocal.m4
vendored
2
mozilla/aclocal.m4
vendored
@@ -5,9 +5,9 @@ dnl
|
||||
|
||||
builtin(include, build/autoconf/glib.m4)dnl
|
||||
builtin(include, build/autoconf/gtk.m4)dnl
|
||||
builtin(include, build/autoconf/gdk-pixbuf.m4)dnl
|
||||
builtin(include, build/autoconf/libIDL.m4)dnl
|
||||
builtin(include, build/autoconf/nspr.m4)dnl
|
||||
builtin(include, build/autoconf/pkg.m4)dnl
|
||||
dnl
|
||||
define(MOZ_TOPSRCDIR,.)dnl MOZ_TOPSRCDIR is used in altoptions.m4
|
||||
builtin(include, build/autoconf/altoptions.m4)dnl
|
||||
|
||||
@@ -147,7 +147,6 @@ MAKEFILES_htmlparser="
|
||||
htmlparser/Makefile
|
||||
htmlparser/robot/Makefile
|
||||
htmlparser/robot/test/Makefile
|
||||
htmlparser/public/Makefile
|
||||
htmlparser/src/Makefile
|
||||
htmlparser/tests/Makefile
|
||||
htmlparser/tests/grabpage/Makefile
|
||||
@@ -315,6 +314,13 @@ modules/mpfilelocprovider/src/Makefile
|
||||
|
||||
MAKEFILES_libimg="
|
||||
modules/libimg/Makefile
|
||||
modules/libimg/public/Makefile
|
||||
modules/libimg/public_com/Makefile
|
||||
modules/libimg/src/Makefile
|
||||
modules/libimg/gifcom/Makefile
|
||||
modules/libimg/jpgcom/Makefile
|
||||
modules/libimg/pngcom/Makefile
|
||||
modules/libimg/mngcom/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_libjar="
|
||||
@@ -348,11 +354,11 @@ modules/oji/src/Makefile
|
||||
|
||||
MAKEFILES_plugin="
|
||||
modules/plugin/Makefile
|
||||
modules/plugin/base/src/Makefile
|
||||
modules/plugin/base/public/Makefile
|
||||
modules/plugin/samples/simple/Makefile
|
||||
modules/plugin/samples/SanePlugin/Makefile
|
||||
modules/plugin/samples/default/unix/Makefile
|
||||
modules/plugin/nglsrc/Makefile
|
||||
modules/plugin/public/Makefile
|
||||
modules/plugin/test/Makefile
|
||||
modules/plugin/SanePlugin/Makefile
|
||||
modules/plugin/default/unix/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_access_builtin="
|
||||
@@ -538,6 +544,9 @@ widget/src/qt/Makefile
|
||||
widget/src/xlib/window_service/Makefile
|
||||
widget/src/xpwidgets/Makefile
|
||||
widget/src/support/Makefile
|
||||
widget/tests/Makefile
|
||||
widget/tests/scribble/Makefile
|
||||
widget/tests/widget/Makefile
|
||||
widget/timer/Makefile
|
||||
widget/timer/public/Makefile
|
||||
widget/timer/src/Makefile
|
||||
@@ -770,14 +779,61 @@ content/base/public/Makefile
|
||||
intl/locale/public/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_security="
|
||||
security/Makefile
|
||||
security/psm/Makefile
|
||||
security/psm/lib/Makefile
|
||||
security/psm/lib/client/Makefile
|
||||
security/psm/lib/protocol/Makefile
|
||||
|
||||
intl/strres/public/Makefile
|
||||
intl/locale/idl/Makefile
|
||||
intl/locale/public/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_psm_glue="
|
||||
extensions/psm-glue/public/Makefile
|
||||
extensions/psm-glue/Makefile
|
||||
extensions/psm-glue/src/Makefile
|
||||
netwerk/base/public/Makefile
|
||||
netwerk/build/Makefile
|
||||
netwerk/socket/base/Makefile
|
||||
dom/public/Makefile
|
||||
uriloader/base/Makefile
|
||||
modules/libpref/public/Makefile
|
||||
profile/public/Makefile
|
||||
caps/idl/Makefile
|
||||
caps/include/Makefile
|
||||
netwerk/protocol/http/public/Makefile
|
||||
widget/public/Makefile
|
||||
rdf/base/idl/Makefile
|
||||
xpfe/appshell/public/Makefile
|
||||
gfx/idl/Makefile
|
||||
gfx/public/Makefile
|
||||
docshell/base/Makefile
|
||||
layout/html/forms/public/Makefile
|
||||
layout/base/public/Makefile
|
||||
content/base/public/Makefile
|
||||
dom/src/base/Makefile
|
||||
modules/oji/public/Makefile
|
||||
gfx2/public/Makefile
|
||||
embedding/components/windowwatcher/public/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_inspector="
|
||||
extensions/inspector/Makefile
|
||||
extensions/inspector/base/Makefile
|
||||
extensions/inspector/base/public/Makefile
|
||||
extensions/inspector/base/Makefile
|
||||
extensions/inspector/base/src/Makefile
|
||||
extensions/inspector/build/Makefile
|
||||
extensions/inspector/Makefile
|
||||
extensions/inspector/build/src/Makefile
|
||||
extensions/inspector/build/Makefile
|
||||
extensions/inspector/resources/content/Makefile
|
||||
extensions/inspector/resources/Makefile
|
||||
extensions/inspector/resources/locale/en-US/Makefile
|
||||
extensions/inspector/resources/locale/Makefile
|
||||
extensions/inspector/resources/skin/classic/Makefile
|
||||
extensions/inspector/resources/skin/Makefile
|
||||
extensions/inspector/resources/skin/modern/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_transformiix="
|
||||
@@ -806,6 +862,7 @@ if [ "$MOZ_MAIL_NEWS" ]; then
|
||||
fi
|
||||
|
||||
|
||||
if [ "$USE_IMG2" ]; then
|
||||
MAKEFILES_libpr0n="
|
||||
modules/libpr0n/Makefile
|
||||
modules/libpr0n/public/Makefile
|
||||
@@ -829,6 +886,8 @@ fi
|
||||
accessible/src/Makefile
|
||||
accessible/build/Makefile
|
||||
"
|
||||
fi
|
||||
|
||||
if [ ! "$SYSTEM_JPEG" ]; then
|
||||
MAKEFILES_jpeg="jpeg/Makefile"
|
||||
fi
|
||||
@@ -904,8 +963,7 @@ fi
|
||||
|
||||
# tools/jprof
|
||||
if [ "$MOZ_JPROF" ]; then
|
||||
MAKEFILES_jprof="tools/jprof/Makefile
|
||||
tools/jprof/stub/Makefile"
|
||||
MAKEFILES_jprof="tools/jprof/Makefile"
|
||||
fi
|
||||
|
||||
# tools/leaky
|
||||
@@ -956,117 +1014,67 @@ fi
|
||||
|
||||
for extension in $MOZ_EXTENSIONS; do
|
||||
case "$extension" in
|
||||
access-builtin ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/access-builtin/Makefile
|
||||
extensions/access-builtin/accessproxy/Makefile
|
||||
" ;;
|
||||
content-packs ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/content-packs/Makefile
|
||||
extensions/content-packs/resources/Makefile
|
||||
" ;;
|
||||
cookie ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/cookie/Makefile
|
||||
extensions/cookie/tests/Makefile
|
||||
extensions/cookie/Makefile
|
||||
extensions/cookie/tests/Makefile
|
||||
" ;;
|
||||
ctl ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/ctl/Makefile
|
||||
extensions/ctl/public/Makefile
|
||||
extensions/ctl/src/Makefile
|
||||
extensions/ctl/src/pangoLite/Makefile
|
||||
extensions/ctl/src/thaiShaper/Makefile
|
||||
" ;;
|
||||
cview ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/cview/Makefile
|
||||
extensions/cview/resources/Makefile
|
||||
" ;;
|
||||
help ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/help/Makefile
|
||||
extensions/help/resources/Makefile
|
||||
" ;;
|
||||
inspector ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
$MAKEFILES_inspector"
|
||||
;;
|
||||
irc ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/irc/Makefile
|
||||
" ;;
|
||||
p3p ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/p3p/Makefile
|
||||
extensions/p3p/public/Makefile
|
||||
extensions/p3p/resources/Makefile
|
||||
extensions/p3p/resources/content/Makefile
|
||||
extensions/p3p/resources/locale/Makefile
|
||||
extensions/p3p/resources/locale/en-US/Makefile
|
||||
extensions/p3p/resources/skin/Makefile
|
||||
extensions/p3p/src/Makefile
|
||||
" ;;
|
||||
pics ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/pics/Makefile
|
||||
extensions/pics/public/Makefile
|
||||
extensions/pics/src/Makefile
|
||||
extensions/pics/tests/Makefile
|
||||
" ;;
|
||||
transformiix ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
$MAKEFILES_transformiix"
|
||||
;;
|
||||
universalchardet ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/universalchardet/Makefile
|
||||
extensions/universalchardet/src/Makefile
|
||||
extensions/universalchardet/tests/Makefile
|
||||
extensions/irc/Makefile
|
||||
" ;;
|
||||
venkman ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/venkman/Makefile"
|
||||
;;
|
||||
vixen ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/vixen/Makefile
|
||||
extensions/vixen/base/Makefile
|
||||
extensions/vixen/base/public/Makefile
|
||||
extensions/vixen/base/src/Makefile
|
||||
extensions/vixen/build/Makefile
|
||||
extensions/vixen/build/src/Makefile
|
||||
extensions/vixen/resources/Makefile
|
||||
" ;;
|
||||
extensions/venkman/Makefile"
|
||||
;;
|
||||
transformiix ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
$MAKEFILES_transformiix"
|
||||
;;
|
||||
wallet ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/wallet/Makefile
|
||||
extensions/wallet/public/Makefile
|
||||
extensions/wallet/src/Makefile
|
||||
extensions/wallet/editor/Makefile
|
||||
extensions/wallet/cookieviewer/Makefile
|
||||
extensions/wallet/signonviewer/Makefile
|
||||
extensions/wallet/walletpreview/Makefile
|
||||
extensions/wallet/build/Makefile
|
||||
extensions/wallet/Makefile
|
||||
extensions/wallet/public/Makefile
|
||||
extensions/wallet/src/Makefile
|
||||
extensions/wallet/editor/Makefile
|
||||
extensions/wallet/cookieviewer/Makefile
|
||||
extensions/wallet/signonviewer/Makefile
|
||||
extensions/wallet/walletpreview/Makefile
|
||||
extensions/wallet/build/Makefile
|
||||
" ;;
|
||||
access-builtin ) MAKEFILES_access_builtin="$MAKEFILES_extensions
|
||||
extensions/access-builtin/Makefile
|
||||
extensions/access-builtin/accessproxy/Makefile
|
||||
" ;;
|
||||
xmlextras ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/xmlextras/Makefile
|
||||
extensions/xmlextras/base/Makefile
|
||||
extensions/xmlextras/base/src/Makefile
|
||||
extensions/xmlextras/base/public/Makefile
|
||||
extensions/xmlextras/build/Makefile
|
||||
extensions/xmlextras/build/src/Makefile
|
||||
extensions/xmlextras/schema/Makefile
|
||||
extensions/xmlextras/schema/public/Makefile
|
||||
extensions/xmlextras/schema/src/Makefile
|
||||
extensions/xmlextras/soap/Makefile
|
||||
extensions/xmlextras/soap/public/Makefile
|
||||
extensions/xmlextras/soap/src/Makefile
|
||||
extensions/xmlextras/tests/Makefile
|
||||
extensions/xmlextras/wsdl/Makefile
|
||||
extensions/xmlextras/wsdl/public/Makefile
|
||||
extensions/xmlextras/wsdl/src/Makefile
|
||||
" ;;
|
||||
xml-rpc ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/xml-rpc/Makefile
|
||||
extensions/xml-rpc/idl/Makefile
|
||||
extensions/xml-rpc/src/Makefile
|
||||
extensions/xmlextras/Makefile
|
||||
extensions/xmlextras/base/Makefile
|
||||
extensions/xmlextras/base/src/Makefile
|
||||
extensions/xmlextras/base/public/Makefile
|
||||
extensions/xmlextras/build/Makefile
|
||||
extensions/xmlextras/build/src/Makefile
|
||||
extensions/xmlextras/soap/Makefile
|
||||
extensions/xmlextras/soap/public/Makefile
|
||||
extensions/xmlextras/soap/src/Makefile
|
||||
extensions/xmlextras/tests/Makefile
|
||||
" ;;
|
||||
xmlterm ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/xmlterm/Makefile
|
||||
extensions/xmlterm/base/Makefile
|
||||
extensions/xmlterm/geckoterm/Makefile
|
||||
extensions/xmlterm/linetest/Makefile
|
||||
extensions/xmlterm/scripts/Makefile
|
||||
extensions/xmlterm/tests/Makefile
|
||||
extensions/xmlterm/ui/Makefile
|
||||
extensions/xmlterm/Makefile
|
||||
extensions/xmlterm/base/Makefile
|
||||
extensions/xmlterm/geckoterm/Makefile
|
||||
extensions/xmlterm/linetest/Makefile
|
||||
extensions/xmlterm/scripts/Makefile
|
||||
extensions/xmlterm/tests/Makefile
|
||||
extensions/xmlterm/ui/Makefile
|
||||
" ;;
|
||||
xml-rpc ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/xml-rpc/Makefile
|
||||
extensions/xml-rpc/idl/Makefile
|
||||
extensions/xml-rpc/src/Makefile
|
||||
" ;;
|
||||
inspector ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
$MAKEFILES_inspector"
|
||||
;;
|
||||
help ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/help/resources/Makefile
|
||||
extensions/help/Makefile
|
||||
" ;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -1112,9 +1120,9 @@ $MAKEFILES_libpr0n
|
||||
$MAKEFILES_libjar
|
||||
$MAKEFILES_libpref
|
||||
$MAKEFILES_libutil
|
||||
$MAKEFILES_mpfilelocprovider
|
||||
$MAKEFILES_liveconnect
|
||||
$MAKEFILES_mailnews
|
||||
$MAKEFILES_mpfilelocprovider
|
||||
$MAKEFILES_oji
|
||||
$MAKEFILES_plugin
|
||||
$MAKEFILES_netwerk
|
||||
@@ -1151,6 +1159,8 @@ else
|
||||
necko) add_makefiles "
|
||||
$MAKEFILES_netwerk $MAKEFILES_dbm $MAKEFILES_xpcom"
|
||||
;;
|
||||
psm) add_makefiles "$MAKEFILES_dbm $MAKEFILES_xpcom $MAKEFILES_security $MAKEFILES_js $MAKEFILES_psm_glue"
|
||||
;;
|
||||
psm2) add_makefiles "$MAKEFILES_dbm $MAKEFILES_js $MAKEFILES_xpcom $MAKEFILES_psm2"
|
||||
;;
|
||||
string) add_makefiles "$MAKEFILES_string"
|
||||
|
||||
166
mozilla/build/autoconf/gdk-pixbuf.m4
Normal file
166
mozilla/build/autoconf/gdk-pixbuf.m4
Normal file
@@ -0,0 +1,166 @@
|
||||
# Configure paths for gdk-pixbuf
|
||||
# Elliot Lee 2000-01-10
|
||||
# stolen from Raph Levien 98-11-18
|
||||
# stolen from Manish Singh 98-9-30
|
||||
# stolen back from Frank Belew
|
||||
# stolen from Manish Singh
|
||||
# Shamelessly stolen from Owen Taylor
|
||||
|
||||
dnl AM_PATH_GDK_PIXBUF([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Test for GDK_PIXBUF, and define GDK_PIXBUF_CFLAGS and GDK_PIXBUF_LIBS
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_GDK_PIXBUF,
|
||||
[dnl
|
||||
dnl Get the cflags and libraries from the gdk-pixbuf-config script
|
||||
dnl
|
||||
AC_ARG_WITH(gdk-pixbuf-prefix,[ --with-gdk-pixbuf-prefix=PFX Prefix where GDK_PIXBUF is installed (optional)],
|
||||
gdk_pixbuf_prefix="$withval", gdk_pixbuf_prefix="")
|
||||
AC_ARG_WITH(gdk-pixbuf-exec-prefix,[ --with-gdk-pixbuf-exec-prefix=PFX Exec prefix where GDK_PIXBUF is installed (optional)],
|
||||
gdk_pixbuf_exec_prefix="$withval", gdk_pixbuf_exec_prefix="")
|
||||
AC_ARG_ENABLE(gdk_pixbuftest, [ --disable-gdk_pixbuftest Do not try to compile and run a test GDK_PIXBUF program],
|
||||
, enable_gdk_pixbuftest=yes)
|
||||
|
||||
if test x$gdk_pixbuf_exec_prefix != x ; then
|
||||
gdk_pixbuf_args="$gdk_pixbuf_args --exec-prefix=$gdk_pixbuf_exec_prefix"
|
||||
if test x${GDK_PIXBUF_CONFIG+set} = xset ; then
|
||||
GDK_PIXBUF_CONFIG=$gdk_pixbuf_exec_prefix/gdk-pixbuf-config
|
||||
fi
|
||||
fi
|
||||
if test x$gdk_pixbuf_prefix != x ; then
|
||||
gdk_pixbuf_args="$gdk_pixbuf_args --prefix=$gdk_pixbuf_prefix"
|
||||
if test x${GDK_PIXBUF_CONFIG+set} = xset ; then
|
||||
GDK_PIXBUF_CONFIG=$gdk_pixbuf_prefix/bin/gdk-pixbuf-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(GDK_PIXBUF_CONFIG, gdk-pixbuf-config, no)
|
||||
min_gdk_pixbuf_version=ifelse([$1], ,0.2.5,$1)
|
||||
AC_MSG_CHECKING(for GDK_PIXBUF - version >= $min_gdk_pixbuf_version)
|
||||
no_gdk_pixbuf=""
|
||||
if test "$GDK_PIXBUF_CONFIG" = "no" ; then
|
||||
no_gdk_pixbuf=yes
|
||||
else
|
||||
GDK_PIXBUF_CFLAGS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --cflags`
|
||||
GDK_PIXBUF_LIBS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --libs`
|
||||
|
||||
gdk_pixbuf_major_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
gdk_pixbuf_minor_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
gdk_pixbuf_micro_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "x$enable_gdk_pixbuftest" = "xyes" ; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS"
|
||||
LIBS="$LIBS $GDK_PIXBUF_LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed GDK_PIXBUF is sufficiently new. (Also sanity
|
||||
dnl checks the results of gdk-pixbuf-config to some extent
|
||||
dnl
|
||||
rm -f conf.gdk_pixbuftest
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
char*
|
||||
my_strdup (char *str)
|
||||
{
|
||||
char *new_str;
|
||||
|
||||
if (str)
|
||||
{
|
||||
new_str = malloc ((strlen (str) + 1) * sizeof(char));
|
||||
strcpy (new_str, str);
|
||||
}
|
||||
else
|
||||
new_str = NULL;
|
||||
|
||||
return new_str;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
int major, minor, micro;
|
||||
char *tmp_version;
|
||||
|
||||
system ("touch conf.gdk_pixbuftest");
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = my_strdup("$min_gdk_pixbuf_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_gdk_pixbuf_version");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (($gdk_pixbuf_major_version > major) ||
|
||||
(($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version > minor)) ||
|
||||
(($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version == minor) && ($gdk_pixbuf_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** 'gdk-pixbuf-config --version' returned %d.%d.%d, but the minimum version\n", $gdk_pixbuf_major_version, $gdk_pixbuf_minor_version, $gdk_pixbuf_micro_version);
|
||||
printf("*** of GDK_PIXBUF required is %d.%d.%d. If gdk-pixbuf-config is correct, then it is\n", major, minor, micro);
|
||||
printf("*** best to upgrade to the required version.\n");
|
||||
printf("*** If gdk-pixbuf-config was wrong, set the environment variable GDK_PIXBUF_CONFIG\n");
|
||||
printf("*** to point to the correct copy of gdk-pixbuf-config, and remove the file\n");
|
||||
printf("*** config.cache before re-running configure\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
],, no_gdk_pixbuf=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
if test "x$no_gdk_pixbuf" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test "$GDK_PIXBUF_CONFIG" = "no" ; then
|
||||
echo "*** The gdk-pixbuf-config script installed by GDK_PIXBUF could not be found"
|
||||
echo "*** If GDK_PIXBUF was installed in PREFIX, make sure PREFIX/bin is in"
|
||||
echo "*** your path, or set the GDK_PIXBUF_CONFIG environment variable to the"
|
||||
echo "*** full path to gdk-pixbuf-config."
|
||||
else
|
||||
if test -f conf.gdk_pixbuftest ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run GDK_PIXBUF test program, checking why..."
|
||||
CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS"
|
||||
LIBS="$LIBS $GDK_PIXBUF_LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
], [ return 0; ],
|
||||
[ echo "*** The test program compiled, but did not run. This usually means"
|
||||
echo "*** that the run-time linker is not finding GDK_PIXBUF or finding the wrong"
|
||||
echo "*** version of GDK_PIXBUF. If it is not finding GDK_PIXBUF, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system"
|
||||
echo "***"
|
||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
|
||||
[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
||||
echo "*** exact error that occured. This usually means GDK_PIXBUF was incorrectly installed"
|
||||
echo "*** or that you have moved GDK_PIXBUF since it was installed. In the latter case, you"
|
||||
echo "*** may want to edit the gdk-pixbuf-config script: $GDK_PIXBUF_CONFIG" ])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
GDK_PIXBUF_CFLAGS=""
|
||||
GDK_PIXBUF_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(GDK_PIXBUF_CFLAGS)
|
||||
AC_SUBST(GDK_PIXBUF_LIBS)
|
||||
rm -f conf.gdk_pixbuftest
|
||||
])
|
||||
@@ -1,57 +0,0 @@
|
||||
dnl This file is Copyright 2001 Red Hat, Inc.
|
||||
dnl This file is in the public domain.
|
||||
dnl
|
||||
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
AC_DEFUN(PKG_CHECK_MODULES, [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
else
|
||||
if ! $PKG_CONFIG --atleast-pkgconfig-version 0.7.0; then
|
||||
echo "*** Your version of pkg-config is too old. You need version 0.7.0 or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
else
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
@@ -72,13 +72,7 @@
|
||||
#pragma peephole off
|
||||
#pragma optimize_for_size off
|
||||
#else
|
||||
|
||||
#if TARGET_CARBON
|
||||
#pragma traceback on /* should always be ON for Carbon builds */
|
||||
#else
|
||||
#pragma traceback off /* leave on until the final release, so MacsBug logs are interpretable */
|
||||
#endif
|
||||
|
||||
#pragma traceback on /* leave on until the final release, so MacsBug logs are interpretable */
|
||||
#pragma global_optimizer on
|
||||
#pragma optimization_level 4
|
||||
#pragma scheduling 603
|
||||
|
||||
@@ -44,7 +44,6 @@ use Moz::BuildCore;
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla opt build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:MozillaDefinesOptions.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
@@ -60,8 +59,7 @@ my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla opt progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
"buildmodule", "MozillaBuildList.pm"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
@@ -72,7 +70,7 @@ SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", $config_header_file_name);
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:");
|
||||
|
||||
my($do_checkout) = 0;
|
||||
my($do_build) = 1;
|
||||
|
||||
@@ -44,7 +44,6 @@ use Moz::BuildCore;
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla debug build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:MozillaDebugDefinesOptions.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
@@ -60,8 +59,7 @@ my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla debug progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
"buildmodule", "MozillaBuildList.pm"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
@@ -72,7 +70,7 @@ SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(1, ":mozilla:dist:viewer_debug:", $config_header_file_name);
|
||||
SetupDefaultBuildOptions(1, ":mozilla:dist:viewer_debug:");
|
||||
|
||||
my($do_pull) = 0; # overridden by flags and prefs
|
||||
my($do_build) = 1;
|
||||
|
||||
@@ -9,8 +9,6 @@ use vars qw( @ISA @EXPORT );
|
||||
|
||||
# perl includes
|
||||
use Cwd;
|
||||
use POSIX;
|
||||
use Time::Local;
|
||||
use File::Basename;
|
||||
use LWP::Simple;
|
||||
|
||||
@@ -47,7 +45,7 @@ sub DoPrebuildCheck()
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GenBuildSystemInfo
|
||||
#// Configure Build System
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub GenBuildSystemInfo()
|
||||
@@ -184,7 +182,7 @@ sub ConfigureBuildSystem()
|
||||
|
||||
printf("UNIVERSAL_INTERFACES_VERSION = 0x%04X\n", $main::UNIVERSAL_INTERFACES_VERSION);
|
||||
|
||||
UpdateConfigHeader($main::DEFINESOPTIONS_FILE);
|
||||
UpdateConfigHeader(":mozilla:config:mac:DefinesOptions.h");
|
||||
|
||||
# alias required CodeWarrior libs into the Essential Files folder (only the Profiler lib now)
|
||||
MakeLibAliases();
|
||||
@@ -242,8 +240,8 @@ sub get_url_contents($)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub uniq
|
||||
{
|
||||
my $lastval;
|
||||
grep(($_ ne $lastval, $lastval = $_)[$[], @_);
|
||||
my $lastval;
|
||||
grep(($_ ne $lastval, $lastval = $_)[$[], @_);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,81 +250,22 @@ sub uniq
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub get_files_from_content($)
|
||||
{
|
||||
my($content) = @_;
|
||||
|
||||
my(@jscalls) = grep (/return js_file_menu[^{]*/, split(/\n/, $content));
|
||||
my $i;
|
||||
|
||||
for ($i = 0; $i < @jscalls ; $i++)
|
||||
{
|
||||
$jscalls[$i] =~ s/.*\(|\).*//g;
|
||||
my(@callparams) = split(/,/, $jscalls[$i]);
|
||||
my ($repos, $dir, $file, $rev) = grep(s/['\s]//g, @callparams);
|
||||
$jscalls[$i] = "$dir/$file";
|
||||
}
|
||||
my($content) = @_;
|
||||
|
||||
my(@jscalls) = grep (/return js_file_menu[^{]*/, split(/\n/, $content));
|
||||
my $i;
|
||||
|
||||
for ($i = 0; $i < @jscalls ; $i++)
|
||||
{
|
||||
$jscalls[$i] =~ s/.*\(|\).*//g;
|
||||
my(@callparams) = split(/,/, $jscalls[$i]);
|
||||
my ($repos, $dir, $file, $rev) = grep(s/['\s]//g, @callparams);
|
||||
$jscalls[$i] = "$dir/$file";
|
||||
}
|
||||
|
||||
&uniq(sort(@jscalls));
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getLastUpdateTime
|
||||
#//
|
||||
#// Get the last time we updated. Return 0 on failure
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getLastUpdateTime($)
|
||||
{
|
||||
my($timestamp_file) = @_;
|
||||
|
||||
my($time_string);
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
unless (open(TIMESTAMP_FILE, "< $timestamp_file")) { return 0; }
|
||||
|
||||
while (<TIMESTAMP_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
$time_string = $line;
|
||||
}
|
||||
|
||||
# get the epoch seconds
|
||||
my($last_update_secs) = $time_string;
|
||||
$last_update_secs =~ s/\s#.+$//;
|
||||
|
||||
print "FAST_UPDATE found that you last updated at ".localtime($last_update_secs)."\n";
|
||||
|
||||
# how long ago was this, in hours?
|
||||
my($gm_now) = time();
|
||||
my($update_hours) = 1 + ceil(($gm_now - $last_update_secs) / (60 * 60));
|
||||
|
||||
return $update_hours;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// saveCheckoutTimestamp
|
||||
#//
|
||||
#// Create a file on disk containing the current time. Param is time(), which is an Epoch seconds
|
||||
#// (and therefore in GMT).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub saveCheckoutTimestamp($$)
|
||||
{
|
||||
my($gm_secs, $timestamp_file) = @_;
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
open(TIMESTAMP_FILE, ">$timestamp_file") || die "Failed to open $timestamp_file\n";
|
||||
print(TIMESTAMP_FILE "# time of last checkout or update, in GMT. Used by FAST_UPDATE\n");
|
||||
print(TIMESTAMP_FILE "$gm_secs \# around ".localtime()." local time\n");
|
||||
close(TIMESTAMP_FILE);
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FastUpdate
|
||||
@@ -334,82 +273,39 @@ sub saveCheckoutTimestamp($$)
|
||||
#// Use Bonsai url data to update only those dirs which have new files
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FastUpdate($$)
|
||||
sub FastUpdate($)
|
||||
{
|
||||
my($modules, $timestamp_file) = @_; # list of modules to check out
|
||||
my($num_hours) = @_;
|
||||
|
||||
my($num_hours) = getLastUpdateTime($timestamp_file);
|
||||
if ($num_hours == 0 || $num_hours > 170) {
|
||||
print "Can't fast_update; last update was too long ago, or never. Doing normal checkout.\n";
|
||||
return 0;
|
||||
}
|
||||
my($the_module) = "SeaMonkeyAll";
|
||||
my($the_branch) = "HEAD";
|
||||
my($search_type) = "hours";
|
||||
my($min_date) = "";
|
||||
my($max_date) = "";
|
||||
my($url) = "http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=${the_module}&branch=${the_branch}&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=${num_hours}&date=${search_type}&mindate=${min_date}&maxdate=${max_date}&cvsroot=%2Fcvsroot";
|
||||
|
||||
print "Doing fast update, pulling files changed in the last $num_hours hours\n";
|
||||
my(@files) = &get_files_from_content(&get_url_contents($url));
|
||||
|
||||
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
my(@cvs_co_list);
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
my($co_file);
|
||||
foreach $co_file (@files)
|
||||
{
|
||||
my(@cvs_co) = ["", "", ""];
|
||||
@cvs_co[0] = $co_file;
|
||||
push(@cvs_co_list, \@cvs_co);
|
||||
}
|
||||
|
||||
#print "Time now is $checkout_start_time ($checkout_start_time + 0)\n";
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
|
||||
# assume that things pulled by date wont change
|
||||
if ($date ne "") {
|
||||
print "$module is pulled by date, so ignoring in FastUpdate.\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my($search_type) = "hours";
|
||||
my($min_date) = "";
|
||||
my($max_date) = "";
|
||||
my($url) = "http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=${module}&branch=${revision}&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=${num_hours}&date=${search_type}&mindate=${min_date}&maxdate=${max_date}&cvsroot=%2Fcvsroot";
|
||||
|
||||
if ($revision eq "") {
|
||||
print "Getting list of checkins to $module from Bonsai...\n";
|
||||
} else {
|
||||
print "Getting list of checkins to $module on branch $revision from Bonsai...\n";
|
||||
}
|
||||
my(@files) = &get_files_from_content(&get_url_contents($url));
|
||||
|
||||
if ($#files > 0)
|
||||
{
|
||||
my(@cvs_co_list);
|
||||
|
||||
my($co_file);
|
||||
foreach $co_file (@files)
|
||||
{
|
||||
print "Updating $co_file\n";
|
||||
push(@cvs_co_list, $co_file);
|
||||
}
|
||||
|
||||
my($result) = $session->update($revision, \@cvs_co_list);
|
||||
# result of 1 is success
|
||||
if (!$result) { die "Error: Fast update failed\n"; }
|
||||
} else {
|
||||
print "No files in this module changed\n";
|
||||
}
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
return 1;
|
||||
CheckoutModules(\@cvs_co_list);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Checkout
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CheckoutModules($$$)
|
||||
sub CheckoutModules($)
|
||||
{
|
||||
my($modules, $pull_date, $timestamp_file) = @_; # list of modules to check out
|
||||
my($modules) = @_; # list of modules to check out
|
||||
|
||||
my($start_time) = TimeStart();
|
||||
|
||||
@@ -418,34 +314,34 @@ sub CheckoutModules($$$)
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
if ($date eq "") {
|
||||
$date = $pull_date;
|
||||
}
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
CheckOutModule($session, $module, $revision, $date);
|
||||
# print "Checking out $module with ref $revision, date $date\n";
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
TimeEnd($start_time, "Checkout");
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ReadCheckoutModulesFile
|
||||
#// Checkout
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ReadCheckoutModulesFile($$)
|
||||
sub Checkout($)
|
||||
{
|
||||
my($modules_file, $co_list) = @_;
|
||||
my($checkout_list) = @_;
|
||||
|
||||
my($checkout_file) = getScriptFolder().":".$modules_file;
|
||||
unless ( $main::build{pull} ) { return; }
|
||||
|
||||
StartBuildModule("pull");
|
||||
|
||||
my(@cvs_co_list);
|
||||
|
||||
my($checkout_file) = getScriptFolder().":".$checkout_list;
|
||||
local(*CHECKOUT_FILE);
|
||||
open(CHECKOUT_FILE, "< $checkout_file") || die "Error: failed to open checkout list $checkout_file\n";
|
||||
while (<CHECKOUT_FILE>)
|
||||
@@ -484,53 +380,19 @@ sub ReadCheckoutModulesFile($$)
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unrecognized line '$line' in $modules_file\n";
|
||||
die "Error: unrecognized line '$line' in $checkout_list\n";
|
||||
}
|
||||
|
||||
# strip surrounding space from date
|
||||
@cvs_co[$date] =~ s/^\s*|\s*$//g;
|
||||
|
||||
# print "Going to check out '@cvs_co[$module]', '@cvs_co[$revision]', '@cvs_co[$date]'\n";
|
||||
push(@$co_list, \@cvs_co);
|
||||
push(@cvs_co_list, \@cvs_co);
|
||||
}
|
||||
|
||||
close(CHECKOUT_FILE);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// PullFromCVS
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub PullFromCVS($$)
|
||||
{
|
||||
unless ( $main::build{pull} ) { return; }
|
||||
|
||||
my($modules_file, $timestamp_file) = @_;
|
||||
|
||||
StartBuildModule("pull");
|
||||
|
||||
my(@cvs_co_list);
|
||||
ReadCheckoutModulesFile($modules_file, \@cvs_co_list);
|
||||
|
||||
if ($main::FAST_UPDATE && $main::options{pull_by_date})
|
||||
{
|
||||
die "Error: you can't use FAST_UPDATE if you are pulling by date.\n";
|
||||
}
|
||||
|
||||
my($did_fast_update) = $main::FAST_UPDATE && FastUpdate(\@cvs_co_list, $timestamp_file);
|
||||
if (!$did_fast_update)
|
||||
{
|
||||
my($pull_date) = "";
|
||||
if ($main::options{pull_by_date})
|
||||
{
|
||||
# acceptable CVS date formats are (in local time):
|
||||
# ISO8601 (e.g. "1972-09-24 20:05") and Internet (e.g. "24 Sep 1972 20:05").
|
||||
# Perl's localtime() string format also seems to work.
|
||||
$pull_date = localtime().""; # force string interp.
|
||||
print "Pulling by date $pull_date\n";
|
||||
}
|
||||
|
||||
CheckoutModules(\@cvs_co_list, $pull_date, $timestamp_file);
|
||||
}
|
||||
CheckoutModules(\@cvs_co_list);
|
||||
|
||||
EndBuildModule("pull");
|
||||
}
|
||||
@@ -578,8 +440,13 @@ sub RunBuild($$$$)
|
||||
# run a pre-build check to see that the tools etc are in order
|
||||
DoPrebuildCheck();
|
||||
|
||||
# do the pull
|
||||
PullFromCVS($input_files->{"checkoutdata"}, $input_files->{"checkouttime"});
|
||||
if ($main::FAST_UPDATE)
|
||||
{
|
||||
my($hours) = 8; # update files checked in during last 8 hours
|
||||
FastUpdate($hours);
|
||||
} else {
|
||||
Checkout($input_files->{"checkoutdata"});
|
||||
}
|
||||
|
||||
unless ($do_build) { return; }
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ use Mac::StandardFile;
|
||||
use Moz::Moz;
|
||||
use Moz::BuildFlags;
|
||||
use Moz::MacCVS;
|
||||
#use Moz::ProjectXML; #optional; required for static build only
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@@ -48,9 +47,9 @@ use vars qw(@ISA @EXPORT);
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetupDefaultBuildOptions
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetupDefaultBuildOptions($$$)
|
||||
sub SetupDefaultBuildOptions($$)
|
||||
{
|
||||
my($debug, $bin_dir, $config_header_file_name) = @_;
|
||||
my($debug, $bin_dir) = @_;
|
||||
|
||||
# Here we set up defaults for the various build flags.
|
||||
# If you want to override any of these, it's best to do
|
||||
@@ -99,7 +98,6 @@ sub SetupDefaultBuildOptions($$$)
|
||||
#-------------------------------------------------------------
|
||||
|
||||
$main::BIN_DIRECTORY = $bin_dir;
|
||||
$main::DEFINESOPTIONS_FILE = $config_header_file_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,100 +216,6 @@ sub BuildIDLProject($$)
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# CreateStaticLibTargets
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub CreateXMLStaticLibTargets($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($xml_path, @suffix_list);
|
||||
if ($suffix eq "") { die "XML munging: $xml_path must end in .xml\n"; }
|
||||
|
||||
#sniff the file to see if we need to fix up broken Pro5-exported XML
|
||||
print "Parsing $xml_path\n";
|
||||
|
||||
my $ide_version = Moz::ProjectXML::SniffProjectXMLIDEVersion($xml_path);
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
my $new_file = $project_dir.$project_name."2.xml";
|
||||
|
||||
print "Cleaning up Pro 5 xml to $new_file\n";
|
||||
|
||||
Moz::ProjectXML::CleanupPro5XML($xml_path, $new_file);
|
||||
|
||||
unlink $xml_path;
|
||||
rename ($new_file, $xml_path);
|
||||
}
|
||||
|
||||
my $doc = Moz::ProjectXML::ParseXMLDocument($xml_path);
|
||||
my @target_list = Moz::ProjectXML::GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
my %target_hash; # for easy lookups below
|
||||
foreach $target (@target_list) { $target_hash{$target} = 1; }
|
||||
|
||||
foreach $target (@target_list)
|
||||
{
|
||||
if ($target =~ /(.+).shlb$/) # if this is a shared lib target
|
||||
{
|
||||
my $target_base = $1;
|
||||
my $static_target = $target_base.".o";
|
||||
|
||||
# ensure that this does not exist already
|
||||
if ($target_hash{$static_target}) {
|
||||
print "Static target $static_target already exists in project. Not making\n";
|
||||
next;
|
||||
}
|
||||
|
||||
print "Making static target '$static_target' from target '$target'\n";
|
||||
|
||||
Moz::ProjectXML::CloneTarget($doc, $target, $static_target);
|
||||
Moz::ProjectXML::SetAsStaticLibraryTarget($doc, $static_target, $static_target);
|
||||
}
|
||||
}
|
||||
|
||||
print "Writing XML file to $xml_path\n";
|
||||
my $temp_path = $project_dir."_".$project_name.".xml";
|
||||
Moz::ProjectXML::WriteXMLDocument($doc, $temp_path, $ide_version);
|
||||
Moz::ProjectXML::DisposeXMLDocument($doc);
|
||||
|
||||
if (-e $temp_path)
|
||||
{
|
||||
unlink $xml_path;
|
||||
rename ($temp_path, $xml_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: Failed to add new targets to XML project\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ProcessProjectXML
|
||||
#//
|
||||
#// Helper routine to allow for XML pre-processing. This should read in the XML, process it,
|
||||
#// and replace the original file with the processed version.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ProcessProjectXML($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
# we need to manually load Moz::ProjectXML, becaues not everyone will have the
|
||||
# required perl modules in their distro.
|
||||
my($cur_dir) = cwd();
|
||||
|
||||
chdir(dirname($0)); # change to the script dir
|
||||
eval "require Moz::ProjectXML";
|
||||
if ($@) { die "Error: could not do Project XML munging because you do not have the correct XML modules installed. Error is:\n################\n $@################"; }
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
CreateXMLStaticLibTargets($xml_path);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Build one project, and make the alias. Parameters are project path, target name, shared library
|
||||
#// name, make shlb alias (boolean), make xSYM alias (boolean), and is component (boolean).
|
||||
@@ -319,74 +223,19 @@ sub ProcessProjectXML($)
|
||||
|
||||
sub BuildOneProjectWithOutput($$$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $output_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
my ($project_path, $target_name, $output_name, $alias_shlb, $alias_xSYM, $component) = @_;
|
||||
|
||||
unless ($project_path =~ m/^$main::BUILD_ROOT.+/) { return; }
|
||||
|
||||
my (@suffix_list) = (".mcp", ".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Project: $project_path must end in .xml or .mcp\n"; }
|
||||
|
||||
# $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
# Put libraries in "Essential Files" folder, Components in "Components" folder
|
||||
my($output_dir) = $component ? "Components:" : "Essential Files:";
|
||||
my($output_path) = $dist_dir.$output_dir;
|
||||
|
||||
if ($main::options{static_build})
|
||||
{
|
||||
if ($output_name =~ /\.o$/ || $output_name =~ /\.[Ll]ib$/)
|
||||
{
|
||||
$alias_xSYM = 0;
|
||||
$alias_lib = 1;
|
||||
$output_path = $main::DEBUG ? ":mozilla:dist:static_libs_debug:" : ":mozilla:dist:static_libs:";
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is on to export projects to XML, export and munge them
|
||||
if ($main::EXPORT_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_out_path = $project_path;
|
||||
|
||||
$xml_out_path =~ s/\.mcp$/\.xml/;
|
||||
|
||||
# only do this if project is newer?
|
||||
if (! -e $xml_out_path)
|
||||
{
|
||||
ExportProjectToXML(full_path_to($project_path), full_path_to($xml_out_path));
|
||||
ProcessProjectXML($xml_out_path);
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is set to use XML projects, default to XML if the file
|
||||
# is present.
|
||||
if ($main::USE_XML_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_project_path = $project_dir.$project_name.".xml";
|
||||
if (-e $xml_project_path)
|
||||
{
|
||||
$project_path = $xml_project_path;
|
||||
$suffix = ".xml";
|
||||
}
|
||||
}
|
||||
|
||||
if ($suffix eq ".xml")
|
||||
{
|
||||
my($xml_path) = $project_path;
|
||||
# Prepend an "_" onto the name of the generated project file so it doesn't conflict
|
||||
$project_path = $project_dir . "_" . $project_name . ".mcp";
|
||||
my($project_modtime) = (-e $project_path ? GetFileModDate($project_path) : 0);
|
||||
my($xml_modtime) = (-e $xml_path ? GetFileModDate($xml_path) : 0);
|
||||
|
||||
if ($xml_modtime > $project_modtime)
|
||||
{
|
||||
print("Importing $project_path from $project_name.xml.\n");
|
||||
unlink($project_path);
|
||||
# Might want to delete the "xxx.mcp Data" dir ???
|
||||
ImportXMLProject(full_path_to($xml_path), full_path_to($project_path));
|
||||
}
|
||||
}
|
||||
my($component_dir) = $component ? "Components:" : "Essential Files:";
|
||||
|
||||
my($project_dir) = $project_path;
|
||||
$project_dir =~ s/:[^:]+$/:/; # chop off leaf name
|
||||
|
||||
if ($main::CLOBBER_LIBS)
|
||||
{
|
||||
@@ -396,8 +245,8 @@ sub BuildOneProjectWithOutput($$$$$$)
|
||||
|
||||
BuildProject($project_path, $target_name);
|
||||
|
||||
$alias_lib ? MakeAlias("$project_dir$output_name", "$output_path") : 0;
|
||||
$alias_xSYM ? MakeAlias("$project_dir$output_name.xSYM", "$output_path") : 0;
|
||||
$alias_shlb ? MakeAlias("$project_dir$output_name", "$dist_dir$component_dir") : 0;
|
||||
$alias_xSYM ? MakeAlias("$project_dir$output_name.xSYM", "$dist_dir$component_dir") : 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
@@ -409,10 +258,9 @@ sub BuildOneProjectWithOutput($$$$$$)
|
||||
|
||||
sub BuildOneProject($$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
|
||||
my ($project_path, $target_name, $alias_shlb, $alias_xSYM, $component) = @_;
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name,
|
||||
$alias_lib, $alias_xSYM, $component);
|
||||
$alias_shlb, $alias_xSYM, $component);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,10 +25,7 @@ Replaces the AppleScript library I<CodeWarriorLib>.
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::AppleEvents;
|
||||
@@ -36,7 +33,7 @@ use Mac::AppleEvents::Simple;
|
||||
use Mac::Processes;
|
||||
use Mac::MoreFiles;
|
||||
use Mac::StandardFile;
|
||||
|
||||
use File::Basename;
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '1.02';
|
||||
@@ -431,48 +428,7 @@ sub import_project ($$) {
|
||||
my($prm) = "kocl:type(PRJD), rtyp:TEXT(@), data:TEXT(@), &subj:'null'()";
|
||||
|
||||
my($evt) = do_event(qw/core crel/, $app, $prm, $project_path, $xml_file);
|
||||
my($result) = _get_event_result($evt);
|
||||
|
||||
if ($result eq "") {
|
||||
_close(_get_project($project_path));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub export_project ($$) {
|
||||
my($project_path, $xml_out_path) = @_;
|
||||
my($p, $project_was_closed);
|
||||
|
||||
$project_was_closed = 0;
|
||||
while (1) {
|
||||
$p = _get_project($project_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW bug: be sure to close your Find window\n";
|
||||
}
|
||||
$project_was_closed = 1;
|
||||
_open_file($project_path);
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# avoid problems with the Project Messages window
|
||||
_close_named_window("Project Messages");
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:indx, want:type(PRJD), " .
|
||||
q"seld:1, from:'null'()}, kfil:TEXT(@)";
|
||||
|
||||
my($evt) = do_event(qw/CWIE EXPT/, $app, $prm, $xml_out_path);
|
||||
|
||||
if ($project_was_closed) {
|
||||
$p = _get_project($project_path);
|
||||
_close($p);
|
||||
}
|
||||
|
||||
return _get_event_result($evt);
|
||||
return $evt->{ERROR};
|
||||
}
|
||||
|
||||
sub _doc_named ($) {
|
||||
@@ -507,18 +463,11 @@ sub _save_errors_window ($) {
|
||||
|
||||
|
||||
sub _close_errors_window () {
|
||||
return _close_named_window('Errors & Warnings');
|
||||
}
|
||||
|
||||
|
||||
sub _close_named_window ($) {
|
||||
my($window_name) = @_;
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(cwin), " .
|
||||
q"seld:TEXT(@), from:'null'()}";
|
||||
|
||||
my($evt) = do_event(qw/core clos/, $app, $prm, $window_name);
|
||||
my($evt) = do_event(qw/core clos/, $app, $prm, 'Errors & Warnings');
|
||||
return($evt->{REPLY} eq 'aevt\ansr{}' ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -541,21 +490,6 @@ sub _get_folder ($$) {
|
||||
);
|
||||
}
|
||||
|
||||
sub _get_event_result ($)
|
||||
{
|
||||
my($evt) = @_;
|
||||
|
||||
my($result) = $evt->{ERROR};
|
||||
|
||||
if ( $result eq "" && $evt->{ERRNO} != 0 )
|
||||
{
|
||||
$result = "unknown error (".$evt->{ERRNO}.")";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub _save_appath ($$) {
|
||||
|
||||
my($cwd) = cwd(); # remember the current working dir
|
||||
|
||||
@@ -457,9 +457,6 @@ sub registerChromePackage($$$$$$)
|
||||
mkpath($chrome_dir);
|
||||
|
||||
my($inst_chrome) = ${chrome_dir}.":installed-chrome.txt";
|
||||
my $filecontents;
|
||||
my $skinselect = "";
|
||||
my $set = 0;
|
||||
|
||||
if (open(CHROMEFILE, "<$inst_chrome")) {
|
||||
while (<CHROMEFILE>) {
|
||||
@@ -473,27 +470,11 @@ sub registerChromePackage($$$$$$)
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
return 0;
|
||||
}
|
||||
# Make sure to move the skin,install,select statement to the bottom
|
||||
# see bugzilla bug 104953 for details.
|
||||
if(!/skin,install,select,(.*)/)
|
||||
{
|
||||
$filecontents .= "$_\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinselect = $_;
|
||||
$set = 1;
|
||||
}
|
||||
}
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
}
|
||||
open(CHROMEFILE, ">${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
|
||||
print (CHROMEFILE $filecontents);
|
||||
open(CHROMEFILE, ">>${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
|
||||
print(CHROMEFILE "${chrome_entry}\n");
|
||||
if ($set == 1)
|
||||
{
|
||||
print (CHROMEFILE "$skinselect\n");
|
||||
}
|
||||
close(CHROMEFILE) || die "Error: Failed to close $inst_chrome\n";
|
||||
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ use Cwd;
|
||||
|
||||
use File::Copy;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
@@ -56,7 +55,6 @@ use Moz::CodeWarriorLib;
|
||||
BuildProject
|
||||
BuildProjectClean
|
||||
ImportXMLProject
|
||||
ExportProjectToXML
|
||||
OpenErrorLog
|
||||
MakeAlias
|
||||
GetFileModDate
|
||||
@@ -284,8 +282,7 @@ sub BuildProjectClean($;$)
|
||||
sub ImportXMLProject($$)
|
||||
{
|
||||
my ($xml_path, $project_path) = @_;
|
||||
|
||||
# my ($codewarrior_ide_name) = Moz::CodeWarriorLib::getCodeWarriorIDEName();
|
||||
my ($codewarrior_ide_name) = Moz::CodeWarriorLib::getCodeWarriorIDEName();
|
||||
# my $ascript = <<EOS;
|
||||
# tell application "$codewarrior_ide_name"
|
||||
# make new (project document) as ("$project_path") with data ("$xml_path")
|
||||
@@ -302,30 +299,6 @@ sub ImportXMLProject($$)
|
||||
}
|
||||
}
|
||||
|
||||
sub ExportProjectToXML($$)
|
||||
{
|
||||
my ($project_path, $xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".mcp");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Project: $project_path doesn't look like a project file.\n"; }
|
||||
|
||||
if (-e $xml_path) {
|
||||
print "$xml_path exists - not exporting $project_path\n";
|
||||
}
|
||||
else {
|
||||
print "Exporting $project_path to $xml_path\n";
|
||||
my($export_error) = Moz::CodeWarriorLib::export_project($project_path, $xml_path);
|
||||
if ($export_error ne "") {
|
||||
die "Error: export_project failed with error '$export_error'\n";
|
||||
}
|
||||
|
||||
if (! -e $xml_path) {
|
||||
die "Error: XML export to $xml_path failed\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 Miscellaneous
|
||||
|
||||
|
||||
@@ -1,932 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
package Moz::ProjectXML;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use XML::DOM;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
ParseXMLDocument
|
||||
DisposeXMLDocument
|
||||
WriteXMLDocument
|
||||
CleanupPro5XML
|
||||
GetTargetsList
|
||||
CloneTarget
|
||||
SetAsSharedLibraryTarget
|
||||
SetAsStaticLibraryTarget
|
||||
AddTarget
|
||||
RemoveTarget
|
||||
GetTargetSetting
|
||||
SetTargetSetting
|
||||
getChildElementTextContents
|
||||
);
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# A module for reading, manipulating, and writing XML-format CodeWarrior project files.
|
||||
#
|
||||
# Sample usage:
|
||||
#
|
||||
# use ProjectXML;
|
||||
#
|
||||
# my $doc = ProjectXML::ParseXMLDocument("Test.mcp.xml");
|
||||
# ProjectXML::CloneTarget($doc, "Test.shlb", "Test.lib");
|
||||
# ProjectXML::SetAsStaticLibraryTarget($doc, "Test.lib", "TestOutput.lib");
|
||||
# ProjectXML::WriteXMLDocument($doc, "Test_out.xml");
|
||||
# ProjectXML::DisposeXMLDocument($doc);
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ParseXMLDocument
|
||||
#// Note that the caller must call DisposeXMLDocument on the returned doc
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ParseXMLDocument($)
|
||||
{
|
||||
my($doc_path) = @_;
|
||||
|
||||
my $parser = new XML::DOM::Parser(ErrorContext => 2);
|
||||
my $doc = $parser->parsefile($doc_path);
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DisposeXMLDocument
|
||||
#// Needed to avoid memory leaks - cleanup circular references for garbage collection
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub DisposeXMLDocument($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
$doc->dispose();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WriteXMLDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub _pro5_tag_compression($$)
|
||||
{
|
||||
return 1; # Pro 5 is broken and can't import XML with <foo/> style tags
|
||||
}
|
||||
|
||||
sub _pro6plus_tag_compression($$)
|
||||
{
|
||||
return 0; # Pro 6 can deal with empty XML tags like <foo/>
|
||||
}
|
||||
|
||||
sub WriteXMLDocument($$$)
|
||||
{
|
||||
my($doc, $file_path, $ide_version) = @_;
|
||||
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro5_tag_compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro6plus_tag_compression);
|
||||
}
|
||||
|
||||
$doc->printToFile($file_path);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CleanupPro5XML
|
||||
#// XML Projects exported by Pro 5 contain garbage data under the MWMerge_MacOS_skipResources
|
||||
#// setting. This routine cleans this up, saving the result to a new file
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CleanupPro5XML($$)
|
||||
{
|
||||
my($xml_path, $out_path) = @_;
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
local(*CLEANED_FILE);
|
||||
open(CLEANED_FILE, "> $out_path") || die "Error: failed to open file $out_path for writing\n";
|
||||
|
||||
my $in_skip_resources_settings = 0;
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
my $test_line = $line;
|
||||
chomp($test_line);
|
||||
|
||||
my $out_line = $test_line;
|
||||
if ($test_line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$ide_version = "4.0_mozilla"; # pseudo IDE version so we know we touched it
|
||||
$out_line = "<?codewarrior exportversion=\"".$export_version."\" ideversion=\"".$ide_version."\"?>";
|
||||
}
|
||||
|
||||
print CLEANED_FILE "$out_line\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~ /MWMerge_MacOS_skipResources/)
|
||||
{
|
||||
$in_skip_resources_settings = 1;
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
elsif($in_skip_resources_settings && $line =~ /<!-- Settings for/)
|
||||
{
|
||||
# leaving bad settings lines. Write closing tag
|
||||
print CLEANED_FILE " <!-- Corrupted setting entries removed by script -->\n";
|
||||
print CLEANED_FILE " </SETTING>\n\n";
|
||||
|
||||
print CLEANED_FILE "$line";
|
||||
|
||||
$in_skip_resources_settings = 0;
|
||||
}
|
||||
elsif (!$in_skip_resources_settings)
|
||||
{
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
close(CLEANED_FILE);
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# SniffProjectXMLIDEVersion
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub SniffProjectXMLIDEVersion($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my $found_version = "";
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
unless ($line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
die "Error: Failed to find ideversion in $xml_path in line $line\n";
|
||||
}
|
||||
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$found_version = $ide_version;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
|
||||
return $found_version;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetsList
|
||||
#// Returns an array of target names
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetsList($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
my $nodes = $doc->getElementsByTagName("TARGET");
|
||||
my $n = $nodes->getLength;
|
||||
|
||||
my @target_names;
|
||||
|
||||
for (my $i = 0; $i < $n; $i++)
|
||||
{
|
||||
my ($node) = $nodes->item($i);
|
||||
|
||||
my($target_name) = getChildElementTextContents($node, "NAME");
|
||||
push(@target_names, $target_name);
|
||||
}
|
||||
|
||||
return @target_names;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CloneTarget
|
||||
#// Clone the named target, renaming it to 'new_name'
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CloneTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $new_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
# clone here
|
||||
my $target_clone = $target_node->cloneNode(1); # deep clone
|
||||
|
||||
# -- munge target settings --
|
||||
|
||||
# set the target name field
|
||||
setChildElementTextContents($doc, $target_clone, "NAME", $new_name);
|
||||
|
||||
# set the targetname pref
|
||||
setTargetNodeSetting($doc, $target_clone, "Targetname", $new_name);
|
||||
|
||||
# -- insert new target subtree --
|
||||
|
||||
my $target_list = $target_node->getParentNode();
|
||||
$target_list->appendChild($target_clone);
|
||||
|
||||
# -- now add to targetorder --
|
||||
my (@target_order_nodes) = getChildOfDocument($doc, "TARGETORDER");
|
||||
|
||||
my $target_order = @target_order_nodes[0];
|
||||
|
||||
my $new_order = $doc->createElement("ORDEREDTARGET");
|
||||
my $order_name = $doc->createElement("NAME");
|
||||
|
||||
$new_order->appendChild($order_name);
|
||||
|
||||
setChildElementTextContents($doc, $new_order, "NAME", $new_name);
|
||||
$target_order->appendChild($new_order);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsSharedLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsSharedLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "SharedLibrary");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1936223330"); #'shlb'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddFileToTarget
|
||||
#//
|
||||
#// Add a file to the specified target(s).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddFileToTarget($$$)
|
||||
{
|
||||
my($doc, $target_list, $file_name) = @_;
|
||||
|
||||
# the file must be added in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE> (with linkage flags if necessary)
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveFileFromTarget
|
||||
#//
|
||||
#// Remove a file from the specified target, removing it from the entire project
|
||||
#// if no other targets reference it.
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveFileFromTarget($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
# the file must be removed in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE>
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
|
||||
# first, remove from <FILELIST>
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
unless ($file_node) { return; }
|
||||
|
||||
$filelist_node->removeChild($file_node);
|
||||
|
||||
# next, remove from <LINKORDER>
|
||||
my $linkorder_node = getFirstChildElement($target_node, "LINKORDER");
|
||||
unless ($linkorder_node) { die "Error: failed to find LINKORDER node\n"; }
|
||||
|
||||
my $fileref_node = getChildNodeByGrandchildContents($doc, $linkorder_node, "FILEREF", "PATH", $file_name);
|
||||
unless ($fileref_node) { die "Error: link order node for file $file_name not found\n"; }
|
||||
|
||||
$linkorder_node->removeChild($fileref_node);
|
||||
|
||||
# last, remove from <GROUPLIST>
|
||||
# <GROUPLIST> is cross-target, so we have to be careful here.
|
||||
my $grouplist_node = getChildOfDocument($doc, "GROUPLIST");
|
||||
unless ($grouplist_node) { die "Error: failed to find GROUPLIST node\n"; }
|
||||
|
||||
# if the file isn't in any other targets, remove it from the groups
|
||||
if (!GetFileInUse($doc, $file_name))
|
||||
{
|
||||
print "File $file_name is in no other targest. Removing from project\n";
|
||||
|
||||
my @group_nodes;
|
||||
getChildElementsOfType($doc, $grouplist_node, "GROUP", \@group_nodes);
|
||||
my $group_node;
|
||||
foreach $group_node (@group_nodes)
|
||||
{
|
||||
my @fileref_nodes;
|
||||
getChildElementsOfType($doc, $group_node, "FILEREF", \@fileref_nodes);
|
||||
|
||||
my $fileref_node;
|
||||
foreach $fileref_node (@fileref_nodes)
|
||||
{
|
||||
my $path_name = getChildElementTextContents($fileref_node, "PATH");
|
||||
if ($path_name eq $file_name)
|
||||
{
|
||||
print "Removing $file_name from project group list\n";
|
||||
$group_node->removeChild($fileref_node);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# can a file appear in more than one group?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsStaticLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsStaticLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "Library");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1061109567"); #'????'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
|
||||
# static targets don't need any library linkage, so we can remove linkage
|
||||
# with all .shlb and .Lib files.
|
||||
|
||||
my(@obsolete_files) = ("NSStdLibStubs", "InterfacesStubs", "InterfaceLib", "InternetConfigLib");
|
||||
|
||||
print " Removing libraries etc. from target\n";
|
||||
|
||||
# get all files in target
|
||||
my @target_files = GetTargetFilesList($doc, $target_name);
|
||||
my $target_file;
|
||||
foreach $target_file (@target_files)
|
||||
{
|
||||
if ($target_file =~ /(\.shlb|\.lib|\.Lib|\.o|\.exp)$/)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $target_file);
|
||||
}
|
||||
}
|
||||
|
||||
print " Removing stub libraries from target\n";
|
||||
|
||||
# then remove files with known names
|
||||
my $obs_file;
|
||||
foreach $obs_file (@obsolete_files)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $obs_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetSetting
|
||||
#// Get the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetSetting($$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
return getTargetNodeSetting($target_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetTargetSetting
|
||||
#// Set the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetTargetSetting($$$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name, $new_value) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
setTargetNodeSetting($doc, $target_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFilesList
|
||||
#// Return an array of the files in the target (in filelist order)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFilesList($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
my @files_list;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my @file_nodes;
|
||||
getChildElementsOfType($doc, $filelist_node, "FILE", \@file_nodes);
|
||||
|
||||
my $node;
|
||||
foreach $node (@file_nodes)
|
||||
{
|
||||
my $file_name = getChildElementTextContents($node, "PATH");
|
||||
push(@files_list, $file_name);
|
||||
}
|
||||
|
||||
return @files_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FileIsInTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FileIsInTarget($$$)
|
||||
{
|
||||
my($doc, $file_name, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
unless ($target_node) { die "Error: no target found called $target_name\n"; }
|
||||
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileTargetsList
|
||||
#// Return an array of the targets that a file is in (expensive)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileTargetsList($$)
|
||||
{
|
||||
my ($doc, $file_name) = @_;
|
||||
|
||||
my @target_list;
|
||||
|
||||
my @targets = GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
foreach $target (@targets)
|
||||
{
|
||||
if (FileIsInTarget($doc, $file_name, $target))
|
||||
{
|
||||
push(@target_list, $target);
|
||||
}
|
||||
}
|
||||
|
||||
return @target_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFileNode
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFileNode($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
|
||||
return $file_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileInUse
|
||||
#// Return true if the file is used by any target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileInUse($$)
|
||||
{
|
||||
my($doc, $file_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
|
||||
my $target_node = $targetlist_node->getFirstChild();
|
||||
|
||||
while ($target_node)
|
||||
{
|
||||
if ($target_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$target_node->getTagName() eq "TARGET")
|
||||
{
|
||||
# if this is a target node
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1; # found it
|
||||
}
|
||||
}
|
||||
|
||||
$target_node = $target_node->getNextSibling();
|
||||
}
|
||||
|
||||
# not found
|
||||
return 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildOfDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildOfDocument($$)
|
||||
{
|
||||
my($doc, $child_type) = @_;
|
||||
|
||||
return getFirstChildElement($doc->getDocumentElement(), $child_type);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getFirstChildElement
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getFirstChildElement($$)
|
||||
{
|
||||
my($node, $element_name) = @_;
|
||||
|
||||
my $found_node;
|
||||
|
||||
unless ($node) { die "getFirstChildElement called with empty node\n"; }
|
||||
|
||||
#look for the first "element_name" child
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $element_name)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementsOfType
|
||||
#//
|
||||
#// Return an array of refs to child nodes of the given type
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildElementsOfType($$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $array_ref) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
push(@$array_ref, $child_node);
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Given <FOOPY><NERD>Hi!</NERD></FOOPY>, where $node is <FOOPY>,
|
||||
# returns "Hi!". If > 1 <NERD> node, returns the contents of the first.
|
||||
#
|
||||
sub getChildElementTextContents($$)
|
||||
{
|
||||
my($node, $tag_name) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $text_node = $first_element->getFirstChild();
|
||||
|
||||
my $text_contents = "";
|
||||
|
||||
# concat adjacent text nodes
|
||||
while ($text_node)
|
||||
{
|
||||
if ($text_node->getNodeTypeName() ne "TEXT_NODE")
|
||||
{
|
||||
last;
|
||||
}
|
||||
|
||||
$text_contents = $text_contents.$text_node->getData();
|
||||
$text_node = $text_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $text_contents;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setChildElementTextContents($$$$)
|
||||
{
|
||||
my($doc, $node, $tag_name, $contents_text) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $new_text_node = $doc->createTextNode($contents_text);
|
||||
|
||||
# replace all child elements with a text element
|
||||
removeAllChildren($first_element);
|
||||
|
||||
$first_element->appendChild($new_text_node);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildNodeByContents
|
||||
#//
|
||||
#// Consider <foo><bar><baz>Foopy</baz></bar><bar><baz>Loopy</baz></bar></foo>
|
||||
#// This function, when called with getChildNodeByContents($foonode, "bar", "baz", "Loopy")
|
||||
#// returns the second <bar> node.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildNodeByGrandchildContents($$$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $gc_type, $gc_contents) = @_; # gc = grandchild
|
||||
|
||||
my $found_node;
|
||||
my $child_node = $node->getFirstChild();
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
# check for a child of this node of type
|
||||
my $child_contents = getChildElementTextContents($child_node, $gc_type);
|
||||
|
||||
if ($child_contents eq $gc_contents)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNode($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
return getChildNodeByGrandchildContents($doc, $targetlist_node, "TARGET", "NAME", $target_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNamedSettingNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNamedSettingNode($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node;
|
||||
|
||||
my $settinglist_node = getFirstChildElement($target_node, "SETTINGLIST");
|
||||
my $child_node = $settinglist_node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName ne "ELEMENT_NODE")
|
||||
{
|
||||
$child_node = $child_node->getNextSibling();
|
||||
next;
|
||||
}
|
||||
|
||||
if ($child_node->getTagName() eq "SETTING")
|
||||
{
|
||||
my $set_name = getChildElementTextContents($child_node, "NAME");
|
||||
|
||||
if ($set_name eq $setting_name)
|
||||
{
|
||||
$setting_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $setting_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNodeSetting($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
return getChildElementTextContents($setting_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setTargetNodeSetting($$$$)
|
||||
{
|
||||
my($doc, $target_node, $setting_name, $new_value) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
|
||||
setChildElementTextContents($doc, $setting_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// elementInArray
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub elementInArray($$)
|
||||
{
|
||||
my($element, $array) = @_;
|
||||
my $test;
|
||||
foreach $test (@$array)
|
||||
{
|
||||
if ($test eq $element) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// removeAllChildren
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub removeAllChildren($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
$node->removeChild($child_node);
|
||||
$child_node = $node->getFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeData
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeData($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
unless ($node) { die "Null node passed to dumpNodeData\n"; }
|
||||
|
||||
print "Dumping node $node\n";
|
||||
|
||||
my($node_type) = $node->getNodeTypeName();
|
||||
|
||||
if ($node_type eq "ELEMENT_NODE")
|
||||
{
|
||||
my($node_name) = $node->getTagName();
|
||||
print "Element $node_name\n";
|
||||
}
|
||||
elsif ($node_type eq "TEXT_NODE")
|
||||
{
|
||||
my($node_data) = $node->getData;
|
||||
# my(@node_vals) = unpack("C*", $node_data);
|
||||
print "Text '$node_data'\n"; # may contain LF chars
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Node $node_type\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeTree
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeTree($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my($child_node) = $node->getFirstChild();
|
||||
|
||||
unless ($child_node) { return; }
|
||||
|
||||
# recurse
|
||||
dumpNodeData($child_node);
|
||||
|
||||
# then go through child nodes
|
||||
while ($child_node)
|
||||
{
|
||||
dumpNodeTree($child_node);
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -35,7 +35,6 @@ apprunner 0
|
||||
resources 0
|
||||
|
||||
options_flags
|
||||
pull_by_date 0
|
||||
chrome_jars 1
|
||||
chrome_files 0
|
||||
use_jars 1
|
||||
@@ -52,25 +51,21 @@ inspector 0
|
||||
mailextras 1
|
||||
xptlink 0
|
||||
psm 0
|
||||
psm2 0
|
||||
embedding_test 1
|
||||
embedding_test_carbon 0
|
||||
carbon 0 TARGET_CARBON
|
||||
cache 1 MOZ_NEW_CACHE
|
||||
useimg2 1 USE_IMG2
|
||||
lowmem 0 MOZ_MAC_LOWMEM
|
||||
accessible 1 ACCESSIBILITY
|
||||
accessible 1
|
||||
bidi 1 IBMBIDI
|
||||
p3p 0
|
||||
jsdebugger 0
|
||||
moz_logging 1 MOZ_LOGGING
|
||||
moz_logging 1
|
||||
chatzilla 1
|
||||
content_packs 1
|
||||
xml_rpc 1
|
||||
cview 1
|
||||
help 1
|
||||
timeline 0 MOZ_TIMELINE
|
||||
static_build 0 MOZ_STATIC_COMPONENT_LIBS
|
||||
string_debug 0 DEBUG_STRING
|
||||
string_stats 0 DEBUG_STRING_STATS
|
||||
|
||||
filepath_flags
|
||||
idepath ":CodeWarrior IDE Path.txt"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,16 +3,17 @@
|
||||
# where tag and date are optional (non-trailing commas are required)
|
||||
#
|
||||
# Examples:
|
||||
# mozilla/nsprpub, NSPRPUB_CLIENT_TAG
|
||||
# mozilla/nsprpub, NSPRPUB_CLIENT_BRANCH
|
||||
# mozilla/gc, , 10/25/2000 12:00:00
|
||||
#
|
||||
|
||||
mozilla/nsprpub, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/security/nss, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/security/manager, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/accessible, NETSCAPE_6_2_2_BRANCH
|
||||
DirectorySDKSourceC, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/lib/mac/Instrumentation, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/gfx2, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/modules/libpr0n, NETSCAPE_6_2_2_BRANCH
|
||||
SeaMonkeyAll, NETSCAPE_6_2_2_BRANCH
|
||||
mozilla/nsprpub, NSPRPUB_CLIENT_BRANCH
|
||||
mozilla/security/nss, NSS_CLIENT_TAG
|
||||
mozilla/security/psm,
|
||||
mozilla/security/manager,
|
||||
mozilla/accessible, Style_20010518_Branch
|
||||
DirectorySDKSourceC, LDAPCSDK_40_BRANCH
|
||||
mozilla/lib/mac/Instrumentation
|
||||
mozilla/gfx2, Style_20010518_Branch
|
||||
mozilla/modules/libpr0n, Style_20010518_Branch
|
||||
SeaMonkeyAll, Style_20010518_Branch
|
||||
|
||||
@@ -59,8 +59,7 @@ my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
"buildmodule", "MozillaBuildList.pm"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
@@ -71,7 +70,7 @@ SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", "");
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:");
|
||||
|
||||
my($do_checkout) = 1;
|
||||
my($do_build) = 0;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 135 B |
@@ -1,51 +0,0 @@
|
||||
/* XPM */
|
||||
/* Copyright © 2001, The Mozilla Organization. */
|
||||
/* http://mozilla.org/ <endico@mozilla.org> */
|
||||
static char * mozicon16_xpm[] = {
|
||||
"16 16 30 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #E23621",
|
||||
"@ c #D4331F",
|
||||
"# c #C62F1D",
|
||||
"$ c #C2C2C2",
|
||||
"% c #BABABA",
|
||||
"& c #B82C1B",
|
||||
"* c #AA2919",
|
||||
"= c #9B2517",
|
||||
"- c #8F8F8F",
|
||||
"; c #8D2215",
|
||||
"> c #848484",
|
||||
", c #808080",
|
||||
"' c #7F1E13",
|
||||
") c #711B11",
|
||||
"! c #707070",
|
||||
"~ c #63180E",
|
||||
"{ c #606060",
|
||||
"] c #55140C",
|
||||
"^ c #505050",
|
||||
"/ c #47110A",
|
||||
"( c #390E08",
|
||||
"_ c #303030",
|
||||
": c #2A0A06",
|
||||
"< c #202020",
|
||||
"[ c #1C0704",
|
||||
"} c #101010",
|
||||
"| c #0E0302",
|
||||
"1 c #000000",
|
||||
" ",
|
||||
" ",
|
||||
" _1_ ",
|
||||
" %1+++1*@< ",
|
||||
" 11@)=/++11 ",
|
||||
" 1|1++;1++[+)1% ",
|
||||
" }1)+|+++;#++++{",
|
||||
"^^1++1+++11|++/_",
|
||||
" %1|+1(++/&1-1)_",
|
||||
" -11+++(@@]]+|1 ",
|
||||
" }1++++11 {% ",
|
||||
" ^(++++1 ",
|
||||
" |++#^ ",
|
||||
" >|1- ",
|
||||
" ",
|
||||
" "};
|
||||
@@ -1,85 +0,0 @@
|
||||
/* XPM */
|
||||
/* Copyright © 2001, The Mozilla Organization. */
|
||||
/* http://mozilla.org/ <endico@mozilla.org> */
|
||||
static char * mozicon50_xpm[] = {
|
||||
"50 50 30 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #E23621",
|
||||
"@ c #D4331F",
|
||||
"# c #C62F1D",
|
||||
"$ c #C2C2C2",
|
||||
"% c #BABABA",
|
||||
"& c #B82C1B",
|
||||
"* c #AA2919",
|
||||
"= c #9B2517",
|
||||
"- c #8F8F8F",
|
||||
"; c #8D2215",
|
||||
"> c #848484",
|
||||
", c #808080",
|
||||
"' c #7F1E13",
|
||||
") c #711B11",
|
||||
"! c #707070",
|
||||
"~ c #63180E",
|
||||
"{ c #606060",
|
||||
"] c #55140C",
|
||||
"^ c #505050",
|
||||
"/ c #47110A",
|
||||
"( c #390E08",
|
||||
"_ c #303030",
|
||||
": c #2A0A06",
|
||||
"< c #202020",
|
||||
"[ c #1C0704",
|
||||
"} c #101010",
|
||||
"| c #0E0302",
|
||||
"1 c #000000",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" %!_|1111_!% ",
|
||||
" %^}1111111111<{{__1_^% ",
|
||||
" >|111~*#++*;(111|11[:1<% ",
|
||||
" %_111(#++++++++&1:~*+@@)1< ",
|
||||
" -|111;+++*~((/++;#+#)[11/|1% ",
|
||||
" {111|&+++;111]@++&;/1|~)1111- ",
|
||||
" %_1111;+++#111~+++'(:|(@;|1111{ ",
|
||||
" %<1111|#*@+])/1=++/)@+))+_!1[]11_% ",
|
||||
" -11111111=++@+*1*+*'1:&@]@;}}{;'|1|^% ",
|
||||
" !}1111111]++++++=#;|11/;+@&/='(:;@]111_> ",
|
||||
" !11}^|1111&+++++++;/111'+&@+)1[]*+++@)[11|^% ",
|
||||
" -_!%%_11111++++++#](((((|+@(;++#*+++++++&]|11<% ",
|
||||
" -11111[|+++++;~+++++++++&|~+++++++++++++;:1|- ",
|
||||
" !}1111[)[+++++|&++++++++&+;1:#+++++++++++++|1{ ",
|
||||
" !11|}11)@=++++*1@++++++++~+*11|'+++++++++++)11^ ",
|
||||
" !1}!!111~++++++*1;++++++++(*]1111(#+++++++++1[1< ",
|
||||
" ^- ^1111(++++++*1[@+++++++(|111111|'++++++++/+|_ ",
|
||||
" _1|_111@+++++;11]+++++++;111|111}<[;++++++@+(1 ",
|
||||
" ^}!-}111)+++++]111;+++++++:1[;111_{<}['&+++++:1 ",
|
||||
" {%%}1111|@++++)1;'(#++++++@/1;&(111{_-111(()=1_ ",
|
||||
" <11<111/+++++]:++#]+++++++&'@+*]|11_-}><^<}1! ",
|
||||
" {1_-_1111;+++++]]++)/@+++++++++@++=~:11_<}!}} ",
|
||||
" _- {11111|++++++=+++(|)@++@*)][1]#+++@;|1111^ ",
|
||||
" -1_1111/++++++++++@[11:[11111111:'&#;|1<_^% ",
|
||||
" <!_1111#+++++++++++@)|1111|^>!^<11111|{ ",
|
||||
" --}_|11++++++++++++@)1111^% %>{{{% ",
|
||||
" --}111));++++++++@:1|1|- ",
|
||||
" -_111[;+++++++++';@|1- ",
|
||||
" ^11(;+#+++++++]=++)1^ ",
|
||||
" _1:/'@+++++++*1(*]1> ",
|
||||
" %<1|=+++++++++'11|1 ",
|
||||
" ^11]@+++++*;+~11_ ",
|
||||
" >|1|)#++++((#[1^ ",
|
||||
" %^111/;#+&1111> ",
|
||||
" %^|1111(|111% ",
|
||||
" >^_|11111- ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
@@ -1,11 +0,0 @@
|
||||
--- mozilla/layout/html/base/src/nsBlockFrame.cpp.alpha-compiler Mon Jan 1 23:56:52 2001
|
||||
+++ mozilla/layout/html/base/src/nsBlockFrame.cpp Mon Jan 1 23:57:44 2001
|
||||
@@ -563,7 +563,7 @@
|
||||
#define BRS_COMPUTEMAXWIDTH 0x00000400
|
||||
#define BRS_LASTFLAG BRS_COMPUTEMAXWIDTH
|
||||
|
||||
- PRInt16 mFlags;
|
||||
+ PRInt32 mFlags;
|
||||
|
||||
void SetFlag(PRUint32 aFlag, PRBool aValue)
|
||||
{
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# check our arguments
|
||||
|
||||
LIST_FILE=$1
|
||||
PACKAGE_FILE=$2
|
||||
TARGET_DIR=$3
|
||||
SRC_DIR=$4
|
||||
DIR_NAME=$5
|
||||
|
||||
if [ -z "$LIST_FILE" ]; then
|
||||
echo $0 list-file package-file target-dir src-dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$PACKAGE_FILE" ]; then
|
||||
echo $0 list-file package-file target-dir src-dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$TARGET_DIR" ]; then
|
||||
echo $0 list-file package-file target-dir src-dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SRC_DIR" ]; then
|
||||
echo $0 list-file package-file target-dir src-dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DIR_NAME" ]; then
|
||||
echo $0 list-file package-file target-dir src-dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$LIST_FILE" ]; then
|
||||
echo $0 list file not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo $0 target dir not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$SRC_DIR" ]; then
|
||||
echo $0 src dir not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# try to figure out if we should be using cp -Lr or cp -r
|
||||
|
||||
touch /tmp/foo-copy-package
|
||||
cp -L /tmp/foo-copy-package /tmp/foo-copy-package2 2>/dev/null >/dev/null
|
||||
if [ "$?" -ne "0" ]; then
|
||||
COPY="cp"
|
||||
else
|
||||
COPY="cp -L"
|
||||
fi
|
||||
|
||||
rm -f /tmp/foo-copy-package /tmp/foo-copy-package2
|
||||
|
||||
# OK, do our file copy
|
||||
|
||||
cd $SRC_DIR
|
||||
|
||||
for i in `cat $LIST_FILE`
|
||||
do
|
||||
$COPY -vrP ${i} ${TARGET_DIR}
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "Copy of $i to $TARGET_DIR failed!"
|
||||
else
|
||||
echo ${DIR_NAME}/${i} >> $PACKAGE_FILE
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
--- mozilla/editor/ui/composer/content/editor.xul.debug Sun Aug 5 15:49:15 2001
|
||||
+++ mozilla/editor/ui/composer/content/editor.xul Sun Aug 5 15:49:32 2001
|
||||
@@ -155,7 +155,7 @@
|
||||
<menu id="tasksMenu" accesskey="t"/>
|
||||
|
||||
<!-- DEBUG only -->
|
||||
- <menu id="debugMenu" />
|
||||
+ <!-- <menu id="debugMenu" /> -->
|
||||
<!-- end DEBUG only -->
|
||||
|
||||
<!-- help menu filled from globalOverlay -->
|
||||
--- mozilla/editor/ui/composer/content/editorOverlay.xul.debug Sun Aug 5 15:47:09 2001
|
||||
+++ mozilla/editor/ui/composer/content/editorOverlay.xul Sun Aug 5 15:48:58 2001
|
||||
@@ -804,6 +804,7 @@
|
||||
<menuitem id="menu_pasteQuote" accesskey="&editpastequotation.accesskey;" observes="cmd_pasteQuote"/>
|
||||
|
||||
<!-- DEBUG only -->
|
||||
+ <!--
|
||||
<menu id="debugMenu" label="&debugMenu.label;">
|
||||
<menupopup>
|
||||
<menuitem label="&newEditorTestPage.label;" oncommand="window.openDialog('chrome://editor/content','_blank','chrome,all,dialog=no','chrome://editor/content/EditorInitPage.html')"/>
|
||||
@@ -857,6 +858,7 @@
|
||||
oncommand="window.focus()"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
+ -->
|
||||
<!-- end DEBUG only -->
|
||||
|
||||
</overlay>
|
||||
--- mozilla/editor/ui/composer/content/TextEditorAppShell.xul.debug Sun Aug 5 15:49:45 2001
|
||||
+++ mozilla/editor/ui/composer/content/TextEditorAppShell.xul Sun Aug 5 15:49:55 2001
|
||||
@@ -113,7 +113,7 @@
|
||||
<menu accesskey="t" id="tasksMenu"/>
|
||||
|
||||
<!-- DEBUG only -->
|
||||
- <menu id="debugMenu" />
|
||||
+ <!-- <menu id="debugMenu" /> -->
|
||||
<!-- end DEBUG only -->
|
||||
|
||||
<!-- help menu filled from globalOverlay -->
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 880 B |
@@ -1,193 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# 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 Christopher Blizzard.
|
||||
# Portions created by Christopher Blizzard are Copyright (C)
|
||||
# Christopher Blizzard. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
# This script will read one of the mozilla packages- file on unix and
|
||||
# copy it to a target directory. It's for unix only and is really
|
||||
# designed for use in building rpms or other packages.
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Find;
|
||||
|
||||
use strict;
|
||||
|
||||
# global vars
|
||||
my $srcdir = "";
|
||||
my $package_name = "";
|
||||
my $package_file = "";
|
||||
my $output_file = "";
|
||||
my $shared_pass;
|
||||
my $retval;
|
||||
|
||||
# std return val
|
||||
|
||||
$retval = GetOptions('source=s', \$srcdir,
|
||||
'package=s', \$package_name,
|
||||
'package-file=s', \$package_file,
|
||||
'output-file=s', \$output_file,
|
||||
'shared!', \$shared_pass);
|
||||
|
||||
# make sure that all of the values are specific on the command line
|
||||
if (!$retval || !$srcdir || !$package_name ||
|
||||
!$package_file || !$output_file) {
|
||||
print_usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# try to open the packages file
|
||||
|
||||
open (PACKAGE_FILE, $package_file) || die("$0: Failed to open file $package_file for reading.");
|
||||
|
||||
print "chdir to $srcdir\n";
|
||||
chdir($srcdir);
|
||||
|
||||
my @file_list;
|
||||
my @exclude_list;
|
||||
my @final_file_list;
|
||||
my $reading_package = 0;
|
||||
|
||||
LINE: while (<PACKAGE_FILE>) {
|
||||
s/\;.*//; # it's a comment, kill it.
|
||||
s/^\s+//; # nuke leading whitespace
|
||||
s/\s+$//; # nuke trailing whitespace
|
||||
|
||||
# it's a blank line, skip it.
|
||||
if (/^$/) {
|
||||
next LINE;
|
||||
}
|
||||
|
||||
# it's a new component
|
||||
if (/^\[/) {
|
||||
my $this_package;
|
||||
( $this_package ) = /^\[(.+)\]$/;
|
||||
if ($this_package eq $package_name) {
|
||||
$reading_package = 1;
|
||||
}
|
||||
else {
|
||||
$reading_package = 0;
|
||||
}
|
||||
next LINE;
|
||||
}
|
||||
|
||||
# read this line
|
||||
if ($reading_package) {
|
||||
# see if it's a deletion
|
||||
if (/^-/) {
|
||||
my $this_file;
|
||||
( $this_file ) = /^-(.+)$/;
|
||||
push (@exclude_list, $this_file);
|
||||
}
|
||||
else {
|
||||
push (@file_list, $_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close PACKAGE_FILE;
|
||||
|
||||
# Expand our file list
|
||||
|
||||
expand_file_list(\@file_list, \@exclude_list, \@final_file_list);
|
||||
|
||||
print "final file list\n";
|
||||
foreach (@final_file_list) {
|
||||
print $_ . "\n";
|
||||
}
|
||||
|
||||
open (OUTPUT_FILE, ">>$output_file") || die("Failed to open output file\n");
|
||||
foreach (@final_file_list) {
|
||||
# strip off the bin/
|
||||
s/^bin\///;
|
||||
|
||||
# if it's a shared library and we're doing a shared pass print it.
|
||||
# otherwise ignore it.
|
||||
my $is_shared_library = 0;
|
||||
$is_shared_library = /^[a-zA-Z0-9]+\.so$/;
|
||||
if ($shared_pass && $is_shared_library) {
|
||||
print ("Adding $_\n");
|
||||
print (OUTPUT_FILE $_ . "\n");
|
||||
}
|
||||
elsif (!$shared_pass && !$is_shared_library) {
|
||||
print ("Adding $_\n");
|
||||
print (OUTPUT_FILE $_ . "\n");
|
||||
}
|
||||
else {
|
||||
print("Ignoring $_\n");
|
||||
}
|
||||
}
|
||||
close OUTPUT_FILE;
|
||||
|
||||
#print "\nexlude list\n";
|
||||
#foreach (@exclude_list) {
|
||||
# print $_ . "\n";
|
||||
#}
|
||||
|
||||
# this function expands a list of files
|
||||
|
||||
sub expand_file_list {
|
||||
my $file_list_ref = shift;
|
||||
my $exclude_list_ref = shift;
|
||||
my $final_file_list_ref = shift;
|
||||
my $this_file;
|
||||
foreach $this_file (@{$file_list_ref}) {
|
||||
# is it a wild card?
|
||||
if ($this_file =~ /\*$/) {
|
||||
print "Wild card $this_file\n";
|
||||
# expand that wild card, removing anything in the exclude
|
||||
# list
|
||||
my @temp_list;
|
||||
@temp_list = glob($this_file);
|
||||
foreach $this_file (@temp_list) {
|
||||
if (!in_exclude_list($this_file, $exclude_list_ref)) {
|
||||
push (@{$final_file_list_ref}, $this_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!in_exclude_list($this_file, $exclude_list_ref)) {
|
||||
push (@{$final_file_list_ref}, $this_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# is this file in the exlude list?
|
||||
|
||||
sub in_exclude_list {
|
||||
my $file = shift;
|
||||
my $exclude_list_ref = shift;
|
||||
my $this_file;
|
||||
foreach $this_file (@{$exclude_list_ref}) {
|
||||
if ($file eq $this_file) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
# print out a usage message
|
||||
|
||||
sub print_usage {
|
||||
print ("$0: --source dir --package name --package-file file --output-file file [--shared]\n");
|
||||
print ("\t source is the source directory where the files can be found.\n");
|
||||
print ("\t package is the name of the package to list\n");
|
||||
print ("\t package-file is the file that contains the list of packages\n");
|
||||
print ("\t output-file is the file which will contain the list of files\n");
|
||||
print ("\t shared pulls out only the shared libraries\n");
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
--- mozilla/xpfe/browser/resources/content/navigatorOverlay.xul.debug Tue Aug 14 10:21:49 2001
|
||||
+++ mozilla/xpfe/browser/resources/content/navigatorOverlay.xul Tue Aug 14 10:23:00 2001
|
||||
@@ -338,119 +338,7 @@
|
||||
<menu id="tasksMenu"/>
|
||||
|
||||
<menu accesskey="&helpMenuCmd.accesskey;" id="menu_Help"/>
|
||||
- <!-- Menu for testing. -->
|
||||
- <menu id="debugMenu" accesskey="&debugMenu.accesskey;" label="&debugMenu.label;">
|
||||
- <menupopup>
|
||||
- <menu label="&debugVerCmd.label;">
|
||||
- <menupopup>
|
||||
- <menuitem label="&ver1Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org'"/>
|
||||
- <menuitem label="&ver2Cmd.label;" oncommand="window._content.location.href='http://www.yahoo.com'"/>
|
||||
- <menuitem label="&ver3Cmd.label;" oncommand="window._content.location.href='http://www.netscape.com'"/>
|
||||
- <menuitem label="&ver4Cmd.label;" oncommand="window._content.location.href='http://www.excite.com'"/>
|
||||
- <menuitem label="&ver5Cmd.label;" oncommand="window._content.location.href='http://www.microsoft.com'"/>
|
||||
- <menuitem label="&ver6Cmd.label;" oncommand="window._content.location.href='http://www.city.net'"/>
|
||||
- <menuitem label="&ver7Cmd.label;" oncommand="window._content.location.href='http://www.mirabilis.com'"/>
|
||||
- <menuitem label="&ver8Cmd.label;" oncommand="window._content.location.href='http://www.time.com/time/index.html'"/>
|
||||
- <menuitem label="&ver9Cmd.label;" oncommand="window._content.location.href='http://www.warnerbros.com/home_moz3_day.html'"/>
|
||||
- <menuitem label="&ver10Cmd.label;" oncommand="window._content.location.href='http://www.cnn.com'"/>
|
||||
- <menuitem label="&ver11Cmd.label;" oncommand="window._content.location.href='http://www.usatoday.com'"/>
|
||||
- <menuitem label="&ver12Cmd.label;" oncommand="window._content.location.href='http://www.disney.go.com'"/>
|
||||
- <menuitem label="&ver13Cmd.label;" oncommand="window._content.location.href='http://www.hotwired.com'"/>
|
||||
- <menuitem label="&ver14Cmd.label;" oncommand="window._content.location.href='http://www.hotbot.com'"/>
|
||||
- <menuseparator />
|
||||
- <menuitem label="&ver15Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/browser/debugtc/bft_frame_index.html'"/>
|
||||
- <menuitem label="&ver16Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test6.html'"/>
|
||||
- <menuitem label="&ver17Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/browser/debugtc/bft_browser_applet.html'"/>
|
||||
- <menuitem label="&ver18Cmd.label;" oncommand="window._content.location.href='http://www.abcnews.com'"/>
|
||||
- <menuitem label="&ver19Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/browser/debugtc/bft_browser_imagemap.html'"/>
|
||||
- <menuitem label="&ver20Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test2.html'"/>
|
||||
- <menuitem label="&ver21Cmd.label;" oncommand="window._content.location.href='http://www.libpng.org/pub/png/png-MagnoliaAlpha.html'"/>
|
||||
- <menuitem label="&ver22Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test13.html'"/>
|
||||
- <menuitem label="&ver23Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test2.html'"/>
|
||||
- <menuitem label="&ver24Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/browser/debugtc/bft_browser_html_mix3.html'"/>
|
||||
- <menuitem label="&ver25Cmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/browser/debugtc/bft_browser_link.html'"/>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
|
||||
- <menu label="&viewDemoMenu.label;">
|
||||
- <menupopup>
|
||||
- <menuitem label="&demo0Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test0.html'"/>
|
||||
- <menuitem label="&demo1Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test1.html'"/>
|
||||
- <menuitem label="&demo2Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test2.html'"/>
|
||||
- <menuitem label="&demo3Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test3.html'"/>
|
||||
- <menuitem label="&demo4Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test4.html'"/>
|
||||
- <menuitem label="&demo5Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test5.html'"/>
|
||||
- <menuitem label="&demo6Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test6.html'"/>
|
||||
- <menuitem label="&demo7Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test7.html'"/>
|
||||
- <menuitem label="&demo8Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test8.html'"/>
|
||||
- <menuitem label="&demo9Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test9.html'"/>
|
||||
- <menuitem label="&demo10Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test10.html'"/>
|
||||
- <menuitem label="&demo11Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test11.html'"/>
|
||||
- <menuitem label="&demo12Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test12.html'"/>
|
||||
- <menuitem label="&demo13Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test13.html'"/>
|
||||
- <menuitem label="&demo14Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test14.html'"/>
|
||||
- <menuitem label="&demo15Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test15.html'"/>
|
||||
- <menuitem label="&demo16Cmd.label;" oncommand="window._content.location.href='resource:/res/samples/test16.html'"/>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
-
|
||||
- <menu label="XBL Test Suite">
|
||||
- <menupopup>
|
||||
- <menuitem label="#0 Remote XBL" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test0/test.xul'"/>
|
||||
- <menuitem label="#1 Technicolor DIV" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test1/test.html'"/>
|
||||
- <menuitem label="#2 Rollover Madness" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test2/test.html'"/>
|
||||
- <menuitem label="#3 Popups in HTML" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test3/test.html'"/>
|
||||
- <menuitem label="#4 Partition Magic" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test4/test.html'"/>
|
||||
- <menuitem label="#5 Sticky Notes" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test5/test.html'"/>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
-
|
||||
- <menu label="XUL Test Suite">
|
||||
- <menupopup>
|
||||
- <menuitem label="#1 Popups" oncommand="window._content.location.href='http://www.mozilla.org/projects/xul/tests/popups.xul'"/>
|
||||
- <menuitem label="#2 Descriptions and Labels" oncommand="window._content.location.href='http://www.mozilla.org/projects/xul/tests/label.xul'"/>
|
||||
- <menuitem label="#3 Dialog Buttons" oncommand="window._content.location.href='http://www.mozilla.org/projects/xul/tests/buttons.xul'"/>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
-
|
||||
- <menuitem label="Form Manager Samples" oncommand="window._content.location.href='chrome://communicator/locale/wallet/index.html';"/>
|
||||
-
|
||||
- <menuitem label="&domviewer.label;" oncommand="window._content.location.href='chrome://communicator/content/domviewer/DOMDataSourceViewer.xul'"/>
|
||||
- <menuitem label="&browserbuster.label;" oncommand="window._content.location.href='http://komodo.mozilla.org/buster/'"/>
|
||||
- <menuitem label="&editor-test-page.label;" oncommand="window.openDialog('chrome://editor/content','_blank','chrome,all,dialog=no','chrome://editor/content/EditorInitPage.html')"/>
|
||||
- <menuitem label="&flush-memory.label;" oncommand="Components.classes['@mozilla.org/xpcom/memory-service;1'].getService(Components.interfaces.nsIMemory).heapMinimize(true);" />
|
||||
-
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
-
|
||||
- <menu id="qaMenu" accesskey="&QA.accesskey;" label="&QA.label;">
|
||||
- <menupopup>
|
||||
- <menuitem label="&PrecheckinTests.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/precheckin-tests.html'"/>
|
||||
- <menuseparator />
|
||||
- <menuitem label="&QABugCmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/bug-writing-guidelines.html'"/>
|
||||
- <menuitem label="&QATempCmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/help/bug-form.html'"/>
|
||||
- <menuitem label="&QASmokeCmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/smoketests/'"/>
|
||||
- <menuitem label="&QAKnownBugCmd.label;" oncommand="window._content.location.href='http://www.mozilla.org/quality/most-frequent-bugs/'"/>
|
||||
- <menuseparator />
|
||||
- <menuitem label="&strresCmd.label;" oncommand="window._content.location.href='resource:/res/strres-test.xul'"/>
|
||||
-
|
||||
- <menuseparator />
|
||||
- <menuitem label="&BloatDumpNewCmd.label;" oncommand="window._content.location.href='about:bloat?new'"/>
|
||||
- <menuitem label="&BloatDumpAllCmd.label;" oncommand="window._content.location.href='about:bloat'"/>
|
||||
- <menuitem label="&BloatClearCmd.label;" oncommand="window._content.location.href='about:bloat?clear'"/>
|
||||
-
|
||||
- <menuseparator />
|
||||
-
|
||||
- <menu label="Leak Detector">
|
||||
- <menupopup>
|
||||
- <menuitem label="&LeaksDumpLeaksCmd.label;" oncommand="dumpMemoryLeaks();"/>
|
||||
- <menuitem label="&LeaksTraceChromeCmd.label;" oncommand="traceChrome();"/>
|
||||
- <menuitem label="&LeaksTraceDocumentCmd.label;" oncommand="traceDocument();"/>
|
||||
- <menuitem label="&LeaksTraceVerboseCmd.label;" oncommand="traceVerbose(this.getAttribute('checked'))" type="checkbox" checked="false"/>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
- </menupopup>
|
||||
- </menu>
|
||||
</menubar>
|
||||
|
||||
</overlay>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user