-r aarol, jgaunt

-sr brendan
This commit is contained in:
evaughan%netscape.com 2001-05-11 21:11:38 +00:00
Родитель b26d5adb54
Коммит 94198ed5d8
101 изменённых файлов: 7790 добавлений и 2135 удалений

Просмотреть файл

@ -19,14 +19,14 @@
# Contributor(s):
#
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src build
DIRS = public src build
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,165 @@
<html>
<head>
<title>
How the Accessible Module works
</title>
</head>
<body>
<h1>How the Accessible module (accessibility.dll) works</h1>
<ul>
<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.
</p>
</ul>
<h2>What is MSAA?</h2>
<ul>
<p>
A 3rd part accessibility aid, such as a screen reader, wants to track what's happening inside Mozilla. It needs to know about
focus changes and other events, and it needs to know whtat data nodes there are in the layout tree.
Using this information,
the screen reader will speak out loud important changes to the document or UI, and allow the user to track
where they navigate. Some screen readers also magnify text and images in the currently focused area, and others
show information on a <a href="http://www.audiodata.de/e/produkte/pc/lapbraille/">refreshable braille display</a>.
</p>
<p>
In Windows, accesibility aids acquires the necessary information to do this using hacks and MSAA. MSAA is supposed
to be the "right way" for accessibility aids to get information, but sometimes the hacks are more effective.
For example, screen readers look for screen draws of a vertical blinking line, to determine the location of the caret.
Without doing this, screen readers would not be able to let the user know where there caret has moved to in most programs,
because so many applications do not use the system caret (ours is an example). This is so commonly done, that
no one even bothers to support the MSAA caret, because the hack works.
</p>
<p>
MSAA provides information in two different ways:
<ol>
<li>a COM interface (IAccessible) that allows applications to expose the tree of data nodes that make up
each window in the user interface currently being interacted with and</li>
<li> a set of system messages
that confer accessibility-related events such as focus changes, changes to document content and alerts.</li>
</ol>
</p>
<p>
To really learn about MSAA, you need to download
the entire <a href="http://www.microsoft.com/enable/msaa/download.htm">MSAA SDK</a>.
Without downloading the SDK, you won't get the complete documentation.
The SDK also contains some very useful tools, such as the Accessible Event Watcher, which shows what accessible
events are being generated by a given piece of software. The Accessible Explorer and Inspect Object tools
show the tree of data nodes the Accessible object is exposing through COM.
</p>
</ul>
<h2>IAccessible Interface</h2>
<ul>
<p>
The IAccessible interface is used in a tree of IAccessible's, each one representing a data node, similar to a DOM.
</p>
<p>
Here are the methods supported in IAccessible:
<ul>
<li>get_accParent: Get the parent of an IAccessible.</li>
<li>get_accChildCount: Get the number of children of an IAccesible.</li>
<li>get_accChild: Get the child of an Iaccessible.</li>
<li>get_accName: Get the "name" of the IAccessible, for example the name of a button, checkbox or menuitem.</li>
<li>get_accValue: Get the "value" of the IAccessible, for example a number in a slider, a URL for a link, the text a user entered in a field.</li>
<li>get_accDescription: Get a long description of the current IAccessible. This is not really too useful.</li>
<li>get_accRole: Get an enumerated value representing what this IAccessible is used for, for example.</li>
is it a link, static text, editable text, a checkbox, or a table cell, etc.</li>
<li>get_accState: a 32 bit field representing possible on/off states, such as focused, fousable, selected, selectable, visible, protected (for passwords),
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: 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>
<li>accLocation: Get the x,y coordinates, and the height and width of this IAccessible node.</li>
<li>accNavigate: Navigate up, down, left or right from this IAccessible.</li>
<li>accHitTest: Find out what IAccessible exists and a specific coordinate.</li>
<li>accDoDefaultAction: Perform the action described by get_accDefaultAction.</li>
<li>put_accName: Change the name.</li>
<li>put_accValue: Change the value.</li>
</ul>
</p>
<p>
Rather than directly implement IAccessible with an Accessible class, we have chosen to proxy to our own interface,
called nsIAccessible, which is more robust. It has the capability of supporting other new accessibility API's such
as Sun's Gnome Accessiblity API. Our nsIAccessible implementation can proxy further to a variety of classes, each specialized for a particular kind of
widget or data node.
</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 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 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>
<p>
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>
<p>
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 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 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. 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>
<h2>MSAA Events</h2>
<ul>
<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 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 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
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>
<p>
Every RootAccessible has an nsRootAccessible which is an nsIAccessibleEventReceiver. The RootAccessible
uses this to register itself as an nsIAccessibleEventListener. In the end, nsRootAccessible registers itself as a listener
of Mozilla's internal and DOM events. It's HandleEvent routine translates these events into MSAA events, and passes them along to
with an nsIAccessible to the original RootAccessible::HandleEvent
which turns that nsIAccessible into a NotifyWinEvent call, complete with a fake child ID.
</p>
<p>
Most MSAA events aren't utilized by accessibility aids. Therefore we implement only the handful that matter.
The most important event is the focus event, followed by name, state and value change events.
</p>
</ul>
</body>
</html>

Двоичные данные
accessible/macbuild/accessible.mcp

Двоичный файл не отображается.

Двоичные данные
accessible/macbuild/accessibleIDL.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -19,23 +19,22 @@
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = accessibility
MODULE = accessibility
XPIDL_MODULE= accessibility
XPIDLSRCS = \
nsIAccessibilityService.idl \
nsIAccessible.idl \
nsIMutableAccessible.idl \
nsIAccessibleEventReceiver.idl \
nsIAccessibleEventListener.idl \
$(NULL)
XPIDLSRCS = \
nsIAccessibilityService.idl \
nsIAccessible.idl \
nsIAccessibleEventReceiver.idl \
nsIAccessibleEventListener.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -26,9 +26,8 @@ XPIDL_MODULE=accessibility
XPIDLSRCS = \
.\nsIAccessibilityService.idl \
.\nsIAccessible.idl \
.\nsIMutableAccessible.idl \
.\nsIAccessibleEventReceiver.idl \
.\nsIAccessibleEventListener.idl \
$(NULL)
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -24,20 +24,26 @@
#include "nsISupports.idl"
#include "domstubs.idl"
#include "nsIMutableAccessible.idl"
#include "nsIAtom.idl"
#include "domstubs.idl"
#include "nsIAccessible.idl"
[scriptable, uuid(68D9720A-0984-42b6-A3F5-8237ED925727)]
interface nsIAccessibilityService : nsISupports
{
nsIAccessible createRootAccessible(in nsISupports aPresShell, in nsISupports aFrame);
nsIMutableAccessible createMutableAccessible(in nsISupports aNode);
nsIAccessible createHTMLBlockAccessible(in nsIAccessible aAccessible, in nsIDOMNode aNode, in nsISupports aPresShell);
nsIAccessible createRootAccessible(in nsISupports aPresContext, in nsISupports aFrame);
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 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);
};

Просмотреть файл

@ -20,6 +20,8 @@
* Original Author: Eric D Vaughan (evaughan@netscape.com)
*
* Contributor(s):
* Aaron Leventhal
* John Gaunt
*/
#include "nsISupports.idl"
@ -27,25 +29,6 @@
[scriptable, uuid(B26FBE47-9A5F-42a1-822B-082461AE4D6D)]
interface nsIAccessible : nsISupports
{
/* Can't use these javascript can't tell us if properties are undefined
readonly attribute nsIAccessible accParent;
readonly attribute nsIAccessible accNextSibling;
readonly attribute nsIAccessible accPreviousSibling;
readonly attribute nsIAccessible accFirstChild;
readonly attribute nsIAccessible accLastChild;
readonly attribute long accChildCount;
attribute wstring accName;
attribute wstring accValue;
readonly attribute wstring accDescription;
readonly attribute wstring accRole;
readonly attribute unsigned long accState;
readonly attribute wstring accHelp;
readonly attribute wstring accDefaultAction;
readonly attribute boolean accFocused;
*/
nsIAccessible getAccParent();
nsIAccessible getAccNextSibling();
nsIAccessible getAccPreviousSibling();
@ -59,12 +42,12 @@ interface nsIAccessible : nsISupports
void setAccValue(in wstring value);
wstring getAccDescription();
wstring getAccRole();
unsigned long getAccRole();
unsigned long getAccState();
unsigned long getAccExtState();
wstring getAccDefaultAction();
wstring getAccHelp();
boolean getAccFocused();
nsIAccessible getAccFocused();
nsIAccessible accGetAt(in long x, in long y);
@ -75,15 +58,18 @@ interface nsIAccessible : nsISupports
void accGetBounds(out long x,
out long y,
out long width,
out long height);
out long width,
out long height);
void accAddSelection();
void accRemoveSelection();
void accExtendSelection();
void accTakeSelection();
void accTakeFocus();
void accDoDefaultAction();
PRUint8 getAccNumActions();
wstring getAccActionName(in PRUint8 index);
void accDoAction(in PRUint8 index); // Action number 0 is the default action
// MSAA State flags - used for bitfield. More than 1 allowed.
const unsigned long STATE_UNAVAILABLE = 0x00000001; // Disabled, maps to opposite of Java ENABLED, Gnome/ATK SENSITIVE?
@ -134,7 +120,6 @@ interface nsIAccessible : nsISupports
const unsigned long STATE_VERTICAL = 0x80000000; // Especially used for sliders and scrollbars
/*
// MSAA Roles - only one per nsIAccessible or IAccessible
const unsigned long ROLE_TITLEBAR = 0x00000001;
const unsigned long ROLE_MENUBAR = 0x00000002;
@ -199,7 +184,4 @@ interface nsIAccessible : nsISupports
const unsigned long ROLE_CLOCK = 0x0000003D;
const unsigned long ROLE_SPLITBUTTON = 0x0000003E; // New in MSAA 2.0
const unsigned long ROLE_IPADDRESS = 0x0000003F; // New in MSAA 2.0
*/
};

Просмотреть файл

@ -28,7 +28,14 @@
[scriptable, uuid(BEE49E7D-9D06-49bf-8984-1694C697D74F)]
interface nsIAccessibleEventListener : nsISupports
{
const unsigned long EVENT_FOCUS = 0x8005;
// these are set to the values given by MSAA
const unsigned long EVENT_FOCUS = 0x8005;
const unsigned long EVENT_STATE_CHANGE = 0x800A;
const unsigned long EVENT_NAME_CHANGE = 0x800C;
const unsigned long EVENT_SELECTION = 0x8006;
const unsigned long EVENT_SELECTION_ADD = 0x8007;
const unsigned long EVENT_SELECTION_REMOVE = 0x8008;
const unsigned long EVENT_SELECTION_WITHIN = 0x8009;
void handleEvent(in unsigned long aEvent, in nsIAccessible aTarget);
};

Просмотреть файл

@ -1,36 +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: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s): pav
*/
#include "nsIAccessible.idl"
#include "nsIAtom.idl"
[scriptable, uuid(AD3274E5-9DD1-4614-81C8-BFF992869CBE)]
interface nsIMutableAccessible : nsIAccessible
{
void SetNameAsNodeValue();
void SetName(in wstring aName);
void SetNameAsAttribute(in nsIAtom aAtom);
void SetRole(in wstring aRole);
void SetIsLeaf(in boolean aLeaf);
};

1
accessible/src/MANIFEST Normal file
Просмотреть файл

@ -0,0 +1 @@
accessible.properties

Просмотреть файл

@ -19,27 +19,31 @@
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = accessibility
LIBRARY_NAME = accessibility_s
REQUIRES = xpcom string layout widget dom view locale gfx2
MODULE = accessibility
LIBRARY_NAME = accessibility_s
REQUIRES = xpcom string layout widget dom view locale gfx2
CPPSRCS = \
nsAccessible.cpp \
nsAccessibilityService.cpp \
nsMutableAccessible.cpp \
nsRootAccessible.cpp \
nsHTMLFormControlAccessible.cpp \
nsHTMLTextAccessible.cpp \
nsSelectAccessible.cpp \
nsGenericAccessible.cpp \
$(NULL)
CPPSRCS = \
nsAccessible.cpp \
nsAccessibilityService.cpp \
nsRootAccessible.cpp \
nsHTMLIFrameRootAccessible.cpp \
nsHTMLFormControlAccessible.cpp \
nsHTMLTextAccessible.cpp \
nsHTMLTableAccessible.cpp \
nsHTMLImageAccessible.cpp \
nsHTMLAreaAccessible.cpp \
nsHTMLLinkAccessible.cpp \
nsSelectAccessible.cpp \
nsGenericAccessible.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
override NO_SHARED_LIB=1

Просмотреть файл

@ -0,0 +1,5 @@
jump = Jump
press = Press
check = Check
uncheck = Uncheck
select = Select

Просмотреть файл

@ -0,0 +1 @@
accessible.properties

Просмотреть файл

@ -0,0 +1,5 @@
jump = Jump
press = Press
check = Check
uncheck = Uncheck
select = Select

Просмотреть файл

@ -0,0 +1,3 @@
en-US.jar:
locale/en-US/global/accessible.properties

Просмотреть файл

@ -33,18 +33,26 @@
#include "nsIFrame.h"
#include "nsRootAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsMutableAccessible.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsLayoutAtoms.h"
#include "nsSelectAccessible.h"
#include "nsHTMLTextAccessible.h"
#include "nsHTMLTableAccessible.h"
#include "nsHTMLImageAccessible.h"
#include "nsHTMLAreaAccessible.h"
#include "nsHTMLLinkAccessible.h"
// IFrame
#include "nsIDocShell.h"
#include "nsHTMLIFrameRootAccessible.h"
//--------------------
nsAccessibilityService::nsAccessibilityService()
{
NS_INIT_REFCNT();
NS_INIT_REFCNT();
//printf("################################## nsAccessibilityService\n");
}
nsAccessibilityService::~nsAccessibilityService()
@ -64,7 +72,7 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
{
nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
@ -74,7 +82,8 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsRootAccessible(wr,f);
//printf("################################## CreateRootAccessible\n");
*_retval = new nsRootAccessible(wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
@ -82,48 +91,15 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateMutableAccessible(nsISupports* aNode, nsIMutableAccessible **_retval)
{
*_retval = new nsMutableAccessible(aNode);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
nsCOMPtr<nsIContent> n = do_QueryInterface(node);
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
c->GetShell(getter_AddRefs(s));
NS_ASSERTION(s,"Error not presshell!!");
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsHTMLBlockAccessible(aAccessible, n,wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
nsCOMPtr<nsIContent> n = do_QueryInterface(node);
/*
nsCOMPtr<nsIContent> n(do_QueryInterface(node));
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
@ -131,12 +107,15 @@ nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNo
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, n, wr);
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, node, wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
*/
return NS_ERROR_FAILURE;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
@ -157,13 +136,15 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLRadioButtonAccessible(shell,node);
if (*_retval) {
@ -173,7 +154,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupport
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
/* nsIAccessible createHTMLButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
@ -191,6 +172,24 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aF
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTML4ButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTML4ButtonAccessible(shell,node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
@ -201,6 +200,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
if (NS_FAILED(rv))
return rv;
//printf("################################## CreateHTMLTextAccessible\n");
*_retval = new nsHTMLTextAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
@ -209,17 +209,113 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTableAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTableAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTableCellAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTableCellAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLImageAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(aFrame));
if (!imageFrame)
return NS_ERROR_FAILURE;
*_retval = new nsHTMLImageAccessible(shell, node, imageFrame);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLAreaAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsISupports *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
nsIAccessible **_retval)
{
nsCOMPtr<nsIPresShell> shell(do_QueryInterface(aShell));
*_retval = new nsHTMLAreaAccessible(shell, aDOMNode, aAccParent);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTextFieldAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTextFieldAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aNode)
{
*aRealFrame = NS_STATIC_CAST(nsIFrame*, aFrame);
nsCOMPtr<nsIContent> content;
(*aRealFrame)->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
*aNode = node;
NS_ADDREF(*aNode);
nsCOMPtr<nsIDocument> document;
content->GetDocument(*getter_AddRefs(document));
if (!document)
return NS_ERROR_FAILURE;
if (!document)
return NS_ERROR_FAILURE;
#ifdef DEBUG
PRInt32 shells = document->GetNumberOfShells();
@ -232,21 +328,66 @@ NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aR
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
*_retval = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
NS_ASSERTION(content,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> presShell;
presContext->GetShell(getter_AddRefs(presShell));
NS_ASSERTION(presShell,"Error non PresShell passed to accessible factory!!!");
nsCOMPtr<nsIWeakReference> weakRef = getter_AddRefs(NS_GetWeakReference(presShell));
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc))) && doc) {
nsCOMPtr<nsIPresShell> presShell = getter_AddRefs(doc->GetShellAt(0));
if (presShell) {
nsCOMPtr<nsISupports> supps;
presShell->GetSubShellFor(content, getter_AddRefs(supps));
if (supps) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
if (docShell) {
nsCOMPtr<nsIPresShell> ps;
docShell->GetPresShell(getter_AddRefs(ps));
if (ps) {
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;
}
}
}
}
}
return NS_ERROR_FAILURE;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
nsresult
NS_NewAccessibilityService(nsIAccessibilityService** aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsAccessibilityService* a = new nsAccessibilityService();
if (a == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(a);
*aResult = a;
return NS_OK;
nsAccessibilityService* a = new nsAccessibilityService();
if (a == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(a);
*aResult = a;
return NS_OK;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -31,8 +31,16 @@
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsWeakReference.h"
#include "nsIFocusController.h"
#include "nsRect.h"
#include "nsPoint.h"
#define ACCESSIBLE_BUNDLE_URL "chrome://global/locale/accessible.properties"
class nsIFrame;
class nsIDocShell;
class nsIWebShell;
class nsIContent;
class nsAccessible : public nsIAccessible
// public nsIAccessibleWidgetAccess
@ -44,36 +52,65 @@ class nsAccessible : public nsIAccessible
//NS_IMETHOD AccGetWidget(nsIWidget**);
public:
nsAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual ~nsAccessible();
public:
nsAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
virtual ~nsAccessible();
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
// Helper Routines for Sub-Docs
static nsresult GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
static nsresult GetDocShellObjects(nsIDocShell* aDocShell,
nsIPresShell** aPresShell,
nsIPresContext** aPresContext,
nsIContent** aContent);
static nsresult GetDocShells(nsIPresShell* aPresShell,
nsIDocShell** aDocShell,
nsIDocShell** aParentDocShell);
static nsresult GetParentPresShellAndContent(nsIPresShell* aPresShell,
nsIPresShell** aParentPresShell,
nsIContent** aSubShellContent);
static PRBool FindContentForWebShell(nsIPresShell* aParentPresShell,
nsIContent* aParentContent,
nsIWebShell* aWebShell,
nsIContent** aFoundContent);
nsresult CalcOffset(nsIFrame* aFrame,
nsIPresContext * aPresContext,
nsRect& aRect);
nsresult GetAbsPosition(nsIPresShell* aPresShell, nsPoint& aPoint);
nsresult GetAbsoluteFramePosition(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsRect& aAbsoluteTwipsRect,
nsRect& aAbsolutePixelRect);
static nsresult GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut);
protected:
virtual nsIFrame* GetFrame();
virtual nsIFrame* GetBoundsFrame();
virtual void GetBounds(nsRect& aRect);
virtual void GetPresContext(nsCOMPtr<nsIPresContext>& aContext);
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewParentAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
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);
nsCOMPtr<nsIContent> mContent;
// 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(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
nsHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
protected:
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aFrame, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aFrame, nsIWeakReference* aShell);
};
#endif

Просмотреть файл

@ -26,6 +26,21 @@
#include "nsIFrame.h"
#include "nsCOMPtr.h"
#include "nsIWeakReference.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)
@ -44,181 +59,203 @@ nsGenericAccessible::~nsGenericAccessible()
/* nsIAccessible getAccParent (); */
NS_IMETHODIMP nsGenericAccessible::GetAccParent(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccNextSibling (); */
NS_IMETHODIMP nsGenericAccessible::GetAccNextSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccPreviousSibling (); */
NS_IMETHODIMP nsGenericAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsGenericAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsGenericAccessible::GetAccLastChild(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsGenericAccessible::GetAccChildCount(PRInt32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsGenericAccessible::GetAccName(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsGenericAccessible::GetAccValue(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setAccName (in wstring name); */
NS_IMETHODIMP nsGenericAccessible::SetAccName(const PRUnichar *name)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setAccValue (in wstring value); */
NS_IMETHODIMP nsGenericAccessible::SetAccValue(const PRUnichar *value)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccDescription (); */
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsGenericAccessible::GetAccRole(PRUnichar **_retval)
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsGenericAccessible::GetAccRole(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccState (); */
NS_IMETHODIMP nsGenericAccessible::GetAccState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsGenericAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsGenericAccessible::GetAccNumActions(PRUint8 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::AccDoAction(PRUint8 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccFocused(); */
NS_IMETHODIMP nsGenericAccessible::GetAccFocused(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccHelp (); */
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean getAccFocused (); */
NS_IMETHODIMP nsGenericAccessible::GetAccFocused(PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accGetAt (in long x, in long y); */
NS_IMETHODIMP nsGenericAccessible::AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateRight (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateRight(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateLeft (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateLeft(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateUp (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateUp(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateDown (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateDown(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accGetBounds (out long x, out long y, out long width, out long height); */
NS_IMETHODIMP nsGenericAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accAddSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccAddSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accRemoveSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccRemoveSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accExtendSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccExtendSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accTakeSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccTakeSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accTakeFocus (); */
NS_IMETHODIMP nsGenericAccessible::AccTakeFocus()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoDefaultAction (); */
NS_IMETHODIMP nsGenericAccessible::AccDoDefaultAction()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccExtState (); */
NS_IMETHODIMP nsGenericAccessible::GetAccExtState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
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);
@ -229,80 +266,170 @@ nsDOMAccessible::nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode)
/* 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<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;
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;
rv = selection->Collapse(parent, 0);
if (NS_FAILED(rv))
return rv;
return NS_OK;
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<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;
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;
PRInt32 offsetInParent = 0;
nsCOMPtr<nsIDOMNode> child;
rv = parent->GetFirstChild(getter_AddRefs(child));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDOMNode> next;
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);
while(child)
{
if (child == mNode) {
// Collapse selection to just before desired element,
rv = selection->Collapse(parent, offsetInParent);
if (NS_FAILED(rv))
return rv;
}
child->GetNextSibling(getter_AddRefs(next));
child = next;
offsetInParent++;
// then extend it to just after
rv = selection->Extend(parent, offsetInParent+1);
return rv;
}
// didn't find a child
return NS_ERROR_FAILURE;
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<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsIContent> content = do_QueryInterface(mNode);
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
//-------------
@ -333,3 +460,126 @@ NS_IMETHODIMP nsLeafDOMAccessible::GetAccChildCount(PRInt32 *_retval)
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;
}

Просмотреть файл

@ -42,7 +42,7 @@ class nsGenericAccessible : public nsIAccessible
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLE
public:
public:
nsGenericAccessible();
virtual ~nsGenericAccessible();
};
@ -58,11 +58,15 @@ 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);
protected:
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
nsCOMPtr<nsIWeakReference> mPresShell;
nsCOMPtr<nsIDOMNode> mNode;
};
@ -80,4 +84,23 @@ class nsLeafDOMAccessible : public nsDOMAccessible
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

Просмотреть файл

@ -31,10 +31,20 @@
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsReadableUtils.h"
#include "nsILink.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsIURI.h"
#include "nsIDocShellTreeItem.h"
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMTextListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMutationListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMMutationListener)
NS_INTERFACE_MAP_END_INHERITING(nsAccessible)
NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsAccessible);
@ -43,10 +53,12 @@ NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsAccessible);
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell, nsIFrame* aFrame):nsAccessible(nsnull,nsnull,aShell)
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,nsnull,aShell)
{
// mFrame = aFrame;
mListener = nsnull;
mListener = nsnull;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
shell->GetDocument(getter_AddRefs(mDocument));
mDOMNode = do_QueryInterface(mDocument);
}
//-----------------------------------------------------
@ -60,60 +72,120 @@ nsRootAccessible::~nsRootAccessible()
/* attribute wstring accName; */
NS_IMETHODIMP nsRootAccessible::GetAccName(PRUnichar * *aAccName)
{
*aAccName = ToNewUnicode(NS_LITERAL_STRING("Mozilla Document"));
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()
{
//if (!mFrame) {
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsIFrame* root = nsnull;
if (shell)
shell->GetRootFrame(&root);
return root;
//}
// return mFrame;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* root = nsnull;
if (shell)
shell->GetRootFrame(&root);
return root;
}
nsIAccessible* nsRootAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
void nsRootAccessible::GetBounds(nsRect& aBounds)
{
return new nsHTMLBlockAccessible(aAccessible, aContent, aShell);
nsIFrame* frame = GetFrame();
frame->GetRect(aBounds);
}
/* readonly attribute nsIAccessible accParent; */
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)
{
*aAccParent = nsnull;
return NS_OK;
}
/* readonly attribute wstring accRole; */
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUnichar * *aAccRole)
/* readonly attribute unsigned long accRole; */
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
{
*aAccRole = ToNewUnicode(NS_LITERAL_STRING("client"));
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsISupports> container;
context->GetContainer(getter_AddRefs(container));
if (container) {
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem, docTreeItem(do_QueryInterface(container));
if (docTreeItem) {
docTreeItem->GetSameTypeParent(getter_AddRefs(parentTreeItem));
// Basically, if this docshell has a parent of the same type, it's a frame
if (parentTreeItem) {
*aAccRole = ROLE_PANE;
return NS_OK;
}
}
}
*aAccRole = ROLE_CLIENT;
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::GetAccValue(PRUnichar * *aAccValue)
{
nsCOMPtr<nsIURI> pURI(mDocument->GetDocumentURL());
char *path;
pURI->GetSpec(&path);
*aAccValue = ToNewUnicode(nsLiteralCString(path));
return NS_OK;
}
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventListener *aListener)
{
if (!mListener)
{
// add an event listener to the document
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIDocument> document;
shell->GetDocument(getter_AddRefs(document));
// add an event listener to the document
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIDocument> document;
shell->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDOMEventReceiver> receiver;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(receiver))) && receiver)
{
nsresult rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *, this), NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
// use AddEventListenerByIID from the nsIDOMEventReceiver interface
nsCOMPtr<nsIDOMEventReceiver> receiver;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(receiver))) && receiver)
{
nsresult rv = NS_OK;
// add this as a FocusListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *, this), NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a FormListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFormListener*, this), NS_GET_IID(nsIDOMFormListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a TextListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMTextListener*, this), NS_GET_IID(nsIDOMTextListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a MutationListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMMutationListener*, this), NS_GET_IID(nsIDOMMutationListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
// use AddEventListener from the nsIDOMEventTarget interface -- for UserDefinedTypes
nsCOMPtr<nsIDOMEventTarget> target;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventTarget), getter_AddRefs(target))) && target)
{
nsresult rv = NS_OK;
// we're a DOMEventListener now!!
nsCOMPtr<nsIDOMEventListener> listener;
rv = this->QueryInterface( NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener) );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to QI");
// add ourself as a CheckboxStateChange listener
rv = target->AddEventListener( nsAutoString(NS_LITERAL_STRING("CheckboxStateChange")) , listener, PR_TRUE );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add ourself as a RadiobuttonStateChange listener
rv = target->AddEventListener( nsAutoString(NS_LITERAL_STRING("RadiobuttonStateChange")) , listener, PR_TRUE );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
}
// create a weak reference to the listener
@ -127,7 +199,7 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
{
if (mListener)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIDocument> document;
if (!shell)
return NS_OK;
@ -147,53 +219,128 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
return NS_OK;
}
// --------------- nsIDOMEventListener Methods (3) ------------------------
/*
* Leaving the check for focus here since we want a global perspective on it
* otherwise ask the target itself what event to pass to windows
*/
NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
{
if (mListener) {
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
// create and accessible for the target
nsCOMPtr<nsIContent> content = do_QueryInterface(t);
nsCOMPtr<nsIContent> content(do_QueryInterface(t));
if (!content)
return NS_OK;
if (!content)
return NS_OK;
nsAutoString eventType;
aEvent->GetType(eventType);
if (mCurrentFocus == content)
return NS_OK;
// the "focus" type is pulled from nsDOMEvent.cpp
if ( eventType.EqualsIgnoreCase("focus") ) {
if (mCurrentFocus == content)
return NS_OK;
mCurrentFocus = content;
}
mCurrentFocus = content;
nsIFrame* frame = nsnull;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
shell->GetPrimaryFrameFor(content, &frame);
if (!frame)
return NS_OK;
nsIFrame* frame = nsnull;
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
shell->GetPrimaryFrameFor(content, &frame);
nsCOMPtr<nsIAccessible> a(do_QueryInterface(frame));
if (!a)
a = do_QueryInterface(content);
if (!frame)
return NS_OK;
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);
}
}
nsCOMPtr<nsIAccessible> a = do_QueryInterface(frame);
if (a) {
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
nsCOMPtr<nsIAccessible> na(CreateNewAccessible(a, node, mPresShell));
if ( !na )
return NS_OK;
if (!a)
a = do_QueryInterface(content);
nsCOMPtr<nsIAccessible> na = CreateNewAccessible(a, content, mPresShell);
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
if ( eventType.EqualsIgnoreCase("focus") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
}
else if ( eventType.EqualsIgnoreCase("change") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
else if ( eventType.EqualsIgnoreCase("CheckboxStateChange") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
else if ( eventType.EqualsIgnoreCase("RadiobuttonStateChange") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::Focus(nsIDOMEvent* aEvent)
{
// see this event when the focus changed from one element to another, although all
// textareas seem to share the same focus and radio button groups do too
return HandleEvent(aEvent);
}
NS_IMETHODIMP nsRootAccessible::Blur(nsIDOMEvent* aEvent) { return NS_OK; }
// ------- nsIDOMFormListener Methods (5) -------------
NS_IMETHODIMP nsRootAccessible::Submit(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::Reset(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::Change(nsIDOMEvent* aEvent)
{
// get change events when the form elements changes its state, checked->not,
// deleted text, new text, change in selection
return HandleEvent(aEvent);
}
NS_IMETHODIMP nsRootAccessible::Select(nsIDOMEvent* aEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::Blur(nsIDOMEvent* aEvent)
{
NS_IMETHODIMP nsRootAccessible::Input(nsIDOMEvent* aEvent)
{
// get Input events when text is entered or deleted in a textarea
//return HandleEvent(aEvent);
return NS_OK;
}
// -------- nsIDOMTextListener -----------------
NS_IMETHODIMP nsRootAccessible::HandleText(nsIDOMEvent* aTextEvent) { return NS_OK; }
// -------- nsIDOMMutationEventListener -----------------
NS_IMETHODIMP nsRootAccessible::SubtreeModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeInserted(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeRemoved(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeRemovedFromDocument(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeInsertedIntoDocument(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::AttrModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::CharacterDataModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }

Просмотреть файл

@ -26,44 +26,73 @@
#include "nsAccessible.h"
#include "nsIAccessibleEventReceiver.h"
#include "nsIAccessibleEventListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMTextListener.h"
#include "nsIDOMMutationListener.h"
#include "nsIDocument.h"
class nsRootAccessible : public nsAccessible,
public nsIAccessibleEventReceiver,
public nsIDOMFocusListener
public nsIDOMFocusListener,
public nsIDOMFormListener,
public nsIDOMTextListener,
public nsIDOMMutationListener
{
NS_DECL_ISUPPORTS_INHERITED
public:
nsRootAccessible(nsIWeakReference* aShell, nsIFrame* aFrame = nsnull);
nsRootAccessible(nsIWeakReference* aShell);
virtual ~nsRootAccessible();
/* attribute wstring accName; */
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
NS_IMETHOD GetAccValue(PRUnichar * *aAccValue);
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
NS_IMETHOD GetAccRole(PRUnichar * *aAccRole);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
// ----- nsIAccessibleEventReceiver ------
// ----- nsIAccessibleEventReceiver -------------------
NS_IMETHOD AddAccessibleEventListener(nsIAccessibleEventListener *aListener);
NS_IMETHOD RemoveAccessibleEventListener(nsIAccessibleEventListener *aListener);
// ----- nsIDOMEventListener --------
// ----- nsIDOMEventListener --------------------------
NS_IMETHOD HandleEvent(nsIDOMEvent* anEvent);
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
// ----- nsIDOMFormListener ---------------------------
NS_IMETHOD Submit(nsIDOMEvent* aEvent);
NS_IMETHOD Reset(nsIDOMEvent* aEvent);
NS_IMETHOD Change(nsIDOMEvent* aEvent);
NS_IMETHOD Select(nsIDOMEvent* aEvent);
NS_IMETHOD Input(nsIDOMEvent* aEvent);
// ----- nsIDOMTextListener ---------------------------
NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
// ----- nsIDOMMutationEventListener ------------------
NS_IMETHOD SubtreeModified(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeInserted(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeRemoved(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeRemovedFromDocument(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeInsertedIntoDocument(nsIDOMEvent* aMutationEvent);
NS_IMETHOD AttrModified(nsIDOMEvent* aMutationEvent);
NS_IMETHOD CharacterDataModified(nsIDOMEvent* aMutationEvent);
protected:
virtual void GetBounds(nsRect& aRect);
virtual nsIFrame* GetFrame();
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
// 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;
};

Просмотреть файл

@ -17,7 +17,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Original Author: Eric Vaughan (evaughan@netscape.com)
*
* Contributor(s):
*/
@ -31,12 +31,13 @@
#include "nsIFrame.h"
#include "nsRootAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsMutableAccessible.h"
//#include "nsMutableAccessible.h"
#include "nsLayoutAtoms.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsReadableUtils.h"
#if 0
class nsSelectChildAccessible : public nsAccessible,
public nsIDOMMenuListener
{
@ -49,7 +50,7 @@ public:
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
@ -87,7 +88,7 @@ public:
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccExtState(PRUint32 *_retval);
@ -121,7 +122,7 @@ public:
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(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);
@ -142,7 +143,7 @@ public:
virtual ~nsListChildAccessible() {}
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
@ -189,9 +190,9 @@ NS_IMETHODIMP nsSelectAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("combo box"));
*_retval = ROLE_COMBOBOX;
return NS_OK;
}
@ -270,52 +271,44 @@ nsAccessible(aAccessible, aContent, aShell)
NS_IMETHODIMP nsSelectChildAccessible::GetAccValue(PRUnichar **_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
rv = nsAccessible::GetAccRole(&string);
rv = nsAccessible::GetAccRole(&role);
if (NS_FAILED(rv)) {
*_retval = nsnull;
return rv;
}
nsAutoString role(string);
// if its the text in the combo box then
// its value should be its name.
if (role.EqualsIgnoreCase("text")) {
if (role == ROLE_TEXT) {
rv = nsAccessible::GetAccName(_retval);
} else {
rv = nsAccessible::GetAccValue(_retval);
}
delete string;
return rv;
}
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUint32 *_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
rv = nsAccessible::GetAccRole(&string);
if (NS_FAILED(rv)) {
*_retval = nsnull;
return rv;
}
nsAutoString role(string);
rv = nsAccessible::GetAccRole(&role);
if (NS_FAILED(rv))
return rv;
// any text in the combo box is static
if (role.EqualsIgnoreCase("text")) {
if (role == ROLE_STATICTEXT) {
// if it the comboboxes text. Make it static
*_retval = ToNewUnicode(NS_LITERAL_STRING("static text"));
*_retval = role;
} else {
rv = nsAccessible::GetAccRole(_retval);
}
delete string;
return rv;
}
@ -323,19 +316,18 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
nsAccessible::GetAccRole(&string);
nsAutoString role(string);
nsAccessible::GetAccRole(&role);
// if button then we need to make the name be open or close
if (role.EqualsIgnoreCase("push button"))
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);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
if (!eventReceiver) {
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
@ -362,8 +354,6 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
*_retval = nsnull;
}
delete string;
return rv;
}
@ -371,7 +361,7 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
nsSelectChildAccessible::~nsSelectChildAccessible()
{
if (mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mSelectContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
if (eventReceiver)
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
}
@ -380,7 +370,9 @@ nsSelectChildAccessible::~nsSelectChildAccessible()
NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
{
mOpen = PR_TRUE;
#ifdef DEBUG
printf("Open\n");
#endif
/* TBD send state change event */
@ -390,7 +382,10 @@ NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -400,7 +395,9 @@ NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectChildAccessible::Close(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -457,7 +454,7 @@ nsSelectWindowAccessible::nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAcces
nsSelectWindowAccessible::~nsSelectWindowAccessible()
{
if (mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
if (eventReceiver)
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
}
@ -466,7 +463,9 @@ nsSelectWindowAccessible::~nsSelectWindowAccessible()
NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
{
mOpen = PR_TRUE;
#ifdef DEBUG
printf("Open\n");
#endif
/* TBD send state change event */
@ -476,7 +475,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -486,7 +487,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectWindowAccessible::Close(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -500,7 +503,7 @@ NS_IMETHODIMP nsSelectWindowAccessible::GetAccState(PRUint32 *_retval)
if (!mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
if (!eventReceiver) {
*_retval = 0;
return NS_ERROR_NOT_IMPLEMENTED;
@ -538,9 +541,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("window"));
*_retval = ROLE_WINDOW;
return NS_OK;
}
@ -618,7 +621,7 @@ nsSelectListAccessible::nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessibl
void nsSelectListAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* frame = nsnull;
shell->GetPrimaryFrameFor(mContent, &frame);
if (aFrame == frame)
@ -645,9 +648,9 @@ NS_IMETHODIMP nsSelectListAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("list"));
*_retval = ROLE_LIST;
return NS_OK;
}
@ -693,7 +696,7 @@ nsIAccessible* nsListChildAccessible::CreateNewAccessible(nsIAccessible* aAccess
void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* frame = nsnull;
shell->GetPrimaryFrameFor(mSelectContent, &frame);
if (aFrame == frame)
@ -702,9 +705,9 @@ void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aLis
aList = nsnull;
}
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("list item"));
*_retval = ROLE_LISTITEM;
return NS_OK;
}
@ -715,3 +718,5 @@ NS_IMETHODIMP nsListChildAccessible::GetAccParent(nsIAccessible **_retval)
return NS_OK;
}
#endif

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsCOMPtr.h"
#include "nsIAtom.h"
/*
class nsSelectAccessible : public nsAccessible
{
public:
@ -37,7 +38,7 @@ public:
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
virtual ~nsSelectAccessible() {}
@ -46,6 +47,6 @@ public:
nsCOMPtr<nsIAtom> mPopupAtom;
};
*/
#endif

Просмотреть файл

@ -0,0 +1,218 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsGenericAccessible.h"
#include "nsHTMLAreaAccessible.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLAreaElement.h"
// --- area -----
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIPresShell *aPresShell, nsIDOMNode *aDomNode, nsIAccessible *aAccParent):
nsGenericAccessible(), mPresShell(aPresShell), mDOMNode(aDomNode), mAccParent(aAccParent)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = 0;
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
if (elt) {
nsAutoString hrefString;
elt->GetAttribute(NS_LITERAL_STRING("title"), hrefString);
if (!hrefString.IsEmpty()) {
*_retval = hrefString.ToNewUnicode();
return NS_OK;
}
}
return NS_OK;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_LINK;
return NS_OK;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(PRUnichar **_retval)
{
*_retval = 0;
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
if (elt) {
nsAutoString hrefString;
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
*_retval = hrefString.ToNewUnicode();
}
return NS_OK;
}
/* wstring getAccDescription (); */
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(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)
{
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccParent(nsIAccessible * *aAccParent)
{
*aAccParent = mAccParent;
NS_IF_ADDREF(*aAccParent);
return NS_OK;
}
nsIAccessible *nsHTMLAreaAccessible::CreateAreaAccessible(nsIDOMNode *aDOMNode)
{
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTMLAreaAccessible(mPresShell, aDOMNode, mAccParent, &acc);
return acc;
}
return nsnull;
}
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccNextSibling(nsIAccessible * *aAccNextSibling)
{
*aAccNextSibling = nsnull;
nsCOMPtr<nsIDOMNode> nextNode;
mDOMNode->GetNextSibling(getter_AddRefs(nextNode));
if (nextNode)
*aAccNextSibling = CreateAreaAccessible(nextNode);
return NS_OK;
}
/* readonly attribute nsIAccessible accPreviousSibling; */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccPreviousSibling(nsIAccessible * *aAccPrevSibling)
{
*aAccPrevSibling = nsnull;
nsCOMPtr<nsIDOMNode> prevNode;
mDOMNode->GetPreviousSibling(getter_AddRefs(prevNode));
if (prevNode)
*aAccPrevSibling = CreateAreaAccessible(prevNode);
return NS_OK;
}
/* void accGetBounds (out long x, out long y, out long width, out long height); */
NS_IMETHODIMP nsHTMLAreaAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
//nsIFrame *frame;
// Do a better job on this later - need to use GetRect on mAreas of nsImageMap from nsImageFrame
//return mAccParent->nsAccessible::AccGetBounds(x,y,width,height);
*x = *y = *width = *height = 0;
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLAreaAccessible_H_
#define _nsHTMLAreaAccessible_H_
#include "nsGenericAccessible.h"
#include "nsHTMLLinkAccessible.h"
/* Accessible for image map areas - must be child of image
*/
class nsHTMLAreaAccessible : public nsGenericAccessible
{
public:
nsHTMLAreaAccessible(nsIPresShell *presShell, nsIDOMNode *domNode, nsIAccessible *accParent);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_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(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

Просмотреть файл

@ -23,36 +23,116 @@
#include "nsHTMLFormControlAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsIDOMHTMLButtonElement.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLLabelElement.h"
#include "nsIDOMHTMLFormElement.h"
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsLeafDOMAccessible(aShell, aNode)
{
}
NS_IMETHODIMP nsHTMLFormControlAccessible::AppendLabelFor(nsIContent *aLookNode, nsAReadableString *aId, nsAWritableString *aLabel)
{
PRInt32 numChildren = 0;
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement(do_QueryInterface(aLookNode));
if (labelElement) {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aLookNode));
nsresult rv = NS_OK;
if (elt) {
nsAutoString labelIsFor;
elt->GetAttribute(NS_LITERAL_STRING("for"),labelIsFor);
if (labelIsFor.Equals(*aId))
rv = AppendFlatStringFromSubtree(aLookNode, aLabel);
}
return rv;
}
aLookNode->ChildCount(numChildren);
nsIContent *contentWalker;
PRInt32 index;
for (index = 0; index < numChildren; index++) {
aLookNode->ChildAt(index, contentWalker);
if (contentWalker)
AppendLabelFor(contentWalker, aId, aLabel);
}
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(PRUnichar **_retval)
{
// go up tree get name of label if there is one.
return NS_ERROR_NOT_IMPLEMENTED;
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement;
nsCOMPtr<nsIDOMHTMLFormElement> formElement;
nsAutoString nameString;
nsresult rv = NS_OK;
// go up tree get name of ancestor label if there is one. Don't go up farther than form element
while (walkUpContent && nameString.IsEmpty() && !formElement) {
labelElement = do_QueryInterface(walkUpContent);
if (labelElement)
rv = AppendFlatStringFromSubtree(walkUpContent, &nameString);
formElement = do_QueryInterface(walkUpContent); // reached top ancestor in form
nsCOMPtr<nsIContent> nextParent;
walkUpContent->GetParent(*getter_AddRefs(nextParent));
walkUpContent = nextParent;
}
// There can be a label targeted at this control using the for="control_id" attribute
// To save computing time, only look for those inside of a form element
walkUpContent = do_QueryInterface(formElement);
if (walkUpContent) {
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,&nameString);
}
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
return NS_OK;
}
/* wstring getAccState (); */
/* long getAccState (); */
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, checked
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
// can be
// focusable, focused, checked, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
*_retval = (checked ? STATE_CHECKED : 0);
return NS_OK;
*_retval = STATE_FOCUSABLE;
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked) *_retval |= STATE_CHECKED;
PRBool disabled = PR_FALSE;
element->GetDisabled(&disabled);
if (disabled)
*_retval |= STATE_UNAVAILABLE;
nsAutoString typeString;
element->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
return NS_OK;
}
// --- checkbox -----
@ -62,38 +142,47 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccRole(PRUnichar **_retval)
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("check box"));
return NS_OK;
*_retval = ROLE_CHECKBUTTON;
return NS_OK;
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = 1;
return NS_OK;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
if (index == 0) {
// check or uncheck
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked)
*_retval = ToNewUnicode(NS_LITERAL_STRING("Check"));
else
*_retval = ToNewUnicode(NS_LITERAL_STRING("UnCheck"));
if (element)
element->GetChecked(&checked);
*_retval = ToNewUnicode(checked? NS_LITERAL_STRING("uncheck"): NS_LITERAL_STRING("check"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoDefaultAction (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoDefaultAction()
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
return NS_OK;
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_NOT_IMPLEMENTED;
}
@ -104,25 +193,39 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("Select"));
return NS_OK;
*_retval = 1;
return NS_OK;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUnichar **_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("radio button"));
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("select"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoDefaultAction()
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoAction(PRUint8 index)
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
element->Click();
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_RADIOBUTTON;
return NS_OK;
}
@ -134,42 +237,213 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("Press"));
return NS_OK;
*_retval = 1;
return NS_OK;;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUnichar **_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("push button"));
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_PUSHBUTTON;
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = nsnull;
nsCOMPtr<nsIDOMHTMLInputElement> button = do_QueryInterface(mNode);
*_retval = nsnull;
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mNode));
if (!button)
return NS_ERROR_FAILURE;
if (!button)
return NS_ERROR_FAILURE;
nsAutoString name;
button->GetValue(name);
name.CompressWhitespace();
nsAutoString name;
button->GetValue(name);
name.CompressWhitespace();
*_retval = name.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoDefaultAction()
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
element->Click();
*_retval = name.ToNewUnicode();
return NS_OK;
}
// ----- HTML 4 Button: can contain arbitrary HTML content -----
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsDOMAccessible(aShell, aNode)
{
}
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = 1;
return NS_OK;;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_PUSHBUTTON;
return NS_OK;
}
/* long getAccState (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
{
*_retval |= STATE_FOCUSABLE;
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = nsnull;
nsresult rv = NS_ERROR_FAILURE;
nsAutoString name;
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
if (content)
rv = AppendFlatStringFromSubtree(content, &name);
if (NS_SUCCEEDED(rv)) {
name.CompressWhitespace();
*_retval = name.ToNewUnicode();
}
return rv;
}
// --- textfield -----
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TEXT;
return NS_OK;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(PRUnichar **_retval)
{
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
if (textArea) {
nsAutoString valueString;
textArea->GetValue(valueString);
*_retval = ToNewUnicode(valueString);
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* long getAccState (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, protected. readonly, unavailable, selected
*_retval = STATE_FOCUSABLE;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
PRBool isReadOnly = PR_FALSE;
elt->HasAttribute(NS_LITERAL_STRING("readonly"), &isReadOnly);
if (isReadOnly)
*_retval |= STATE_READONLY;
// 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 isCollapsed = PR_TRUE;
domSel->GetIsCollapsed(&isCollapsed);
if (!isCollapsed)
*_retval |=STATE_SELECTED;
}
}
}
if (!textArea) {
if (inputElement) {
/////// ====== Must be a password field, so it uses nsIDOMHTMLFormControl ==== ///////
PRUint32 moreStates = 0;
nsresult rv = nsHTMLFormControlAccessible::GetAccState(&moreStates);
*_retval |= moreStates;
return rv;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
PRBool disabled = PR_FALSE;
textArea->GetDisabled(&disabled);
if (disabled)
*_retval |= STATE_UNAVAILABLE;
return NS_OK;
}

Просмотреть файл

@ -40,6 +40,9 @@ public:
nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
protected:
NS_IMETHODIMP AppendLabelFor(nsIContent *aLookNode, nsAReadableString *aId, nsAWritableString *aLabel);
};
class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
@ -47,9 +50,10 @@ class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
@ -57,9 +61,10 @@ class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
@ -67,11 +72,34 @@ class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTML4ButtonAccessible : public nsDOMAccessible
{
public:
nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLTextFieldAccessible : public nsHTMLFormControlAccessible
{
public:
nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -0,0 +1,216 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Contributor(s):
*/
#include "nsHTMLIFrameRootAccessible.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIDocShell.h"
#include "nsIWebShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsReadableUtils.h"
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot):
nsDOMAccessible(aShell, aNode)
{
mRootAccessible = aRoot;
}
/* attribute wstring accName; */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(PRUnichar * *aAccName)
{
return mRootAccessible->GetAccName(aAccName);
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
return mRootAccessible->GetAccFirstChild(_retval);
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccLastChild(nsIAccessible **_retval)
{
return mRootAccessible->GetAccLastChild(_retval);
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccChildCount(PRInt32 *_retval)
{
return mRootAccessible->GetAccChildCount(_retval);
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
{
return mRootAccessible->GetAccRole(_retval);
}
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode):
nsRootAccessible(aShell)
{
mRealDOMNode = aNode;
}
//-----------------------------------------------------
// destruction
//-----------------------------------------------------
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; */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccParent(nsIAccessible * *_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccParent(_retval);
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccNextSibling (); */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccNextSibling(_retval);
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccPreviousSibling (); */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccPreviousSibling(_retval);
*_retval = nsnull;
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)
{
// 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));
nsCOMPtr<nsIDocShell> docShell;
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
// Now that we have the DocShell QI
// it to a tree item to find it's parent
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
if (item) {
nsCOMPtr<nsIDocShellTreeItem> itemParent;
item->GetParent(getter_AddRefs(itemParent));
// QI to get the WebShell for the parent document
nsCOMPtr<nsIDocShell> parentDocShell(do_QueryInterface(itemParent));
if (parentDocShell) {
// Get the PresShell/Content and
// Root Content Node of the parent document
nsCOMPtr<nsIPresShell> parentPresShell;
nsCOMPtr<nsIPresContext> parentPresContext;
nsCOMPtr<nsIContent> rootContent;
if (NS_SUCCEEDED(GetDocShellObjects(parentDocShell,
getter_AddRefs(parentPresShell),
getter_AddRefs(parentPresContext),
getter_AddRefs(rootContent)))) {
// QI the DocShell (of this sub-doc) to a webshell
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
if (webShell && parentPresShell && parentPresContext && rootContent) {
// Now, find the Content in the parent document
// that represents this sub-doc,
// we do that matching webshells
nsCOMPtr<nsIContent> content;
if (FindContentForWebShell(parentPresShell,
rootContent,
webShell,
getter_AddRefs(content))) {
// 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(getter_AddRefs(NS_GetWeakReference(parentPresShell)));
nsIFrame* frame = nsnull;
parentPresShell->GetPrimaryFrameFor(content, &frame);
#ifdef NS_DEBUG_X
printf("** Found: Con:%p Fr:%p", content, frame);
char * name;
if (GetNameForFrame(frame, &name)) {
printf(" Name:[%s]", name);
nsMemory::Free(name);
}
printf("\n");
#endif
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
*aAcc = CreateNewAccessible(acc, node, wr);
NS_IF_ADDREF(*aAcc);
return NS_OK;
}
}
}
}
}
}
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Contributor(s):
*/
#ifndef _nsIFrameRootAccessible_H_
#define _nsIFrameRootAccessible_H_
#include "nsRootAccessible.h"
#include "nsGenericAccessible.h"
class nsIWebShell;
class nsHTMLIFrameAccessible : public nsDOMAccessible
{
public:
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(PRUnichar * *aAccName);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
protected:
nsCOMPtr<nsIAccessible> mRootAccessible;
};
class nsHTMLIFrameRootAccessible : public nsRootAccessible
{
public:
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode);
virtual ~nsHTMLIFrameRootAccessible();
/* attribute wstring accName; */
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
/* nsIAccessible getAccNextSibling (); */
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
/* 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;
};
#endif

Просмотреть файл

@ -0,0 +1,146 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsGenericAccessible.h"
#include "nsHTMLImageAccessible.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIHTMLDocument.h"
#include "nsIDocument.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
// --- image -----
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame):
nsLinkableAccessible(aShell, aDOMNode), mPresShell(aShell)
{
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIDocument> doc;
aShell->GetDocument(getter_AddRefs(doc));
nsAutoString mapElementName;
if (doc && element) {
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
element->GetAttribute(NS_LITERAL_STRING("usemap"),mapElementName);
if (htmlDoc && !mapElementName.IsEmpty()) {
if (mapElementName.CharAt(0) == '#')
mapElementName.Cut(0,1);
htmlDoc->GetImageMap(mapElementName, getter_AddRefs(mMapElement));
}
}
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(PRUnichar **_retval)
{
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mNode));
if (imageContent) {
nsAutoString nameString;
nsresult rv = AppendFlatStringFromContentNode(imageContent, &nameString);
if (NS_SUCCEEDED(rv)) {
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
}
return rv;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_GRAPHIC;
return NS_OK;
}
nsIAccessible *nsHTMLImageAccessible::CreateAreaAccessible(PRUint32 areaNum)
{
if (!mMapElement)
return nsnull;
if (areaNum == -1) {
PRInt32 numAreaMaps;
GetAccChildCount(&numAreaMaps);
if (numAreaMaps<=0)
return nsnull;
areaNum = NS_STATIC_CAST(PRUint32,numAreaMaps-1);
}
nsIDOMHTMLCollection *mapAreas;
mMapElement->GetAreas(&mapAreas);
if (!mapAreas)
return nsnull;
nsIDOMNode *domNode = nsnull;
mapAreas->Item(areaNum,&domNode);
if (!domNode)
return nsnull;
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
nsCOMPtr<nsISupports> presShell(do_QueryInterface(mPresShell));
accService->CreateHTMLAreaAccessible(presShell, domNode, this, &acc);
return acc;
}
return nsnull;
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
*_retval = CreateAreaAccessible(0);
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = CreateAreaAccessible(-1);
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
if (mMapElement) {
nsIDOMHTMLCollection *mapAreas;
mMapElement->GetAreas(&mapAreas);
if (mapAreas) {
PRUint32 length;
mapAreas->GetLength(&length);
*_retval = NS_STATIC_CAST(PRInt32, length);
}
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLImageAccessible_H_
#define _nsHTMLImageAccessible_H_
#include "nsGenericAccessible.h"
#include "nsIFrame.h"
#include "nsIImageFrame.h"
#include "nsIDOMHTMLMapElement.h"
/* Accessible for supporting images
* supports:
* - gets name, role
* - support basic state
*/
class nsHTMLImageAccessible : public nsLinkableAccessible
{
public:
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);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
protected:
nsIAccessible *CreateAreaAccessible(PRUint32 areaNum);
nsCOMPtr<nsIDOMHTMLMapElement> mMapElement;
nsCOMPtr<nsIPresShell> mPresShell;
};
#endif

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsHTMLLinkAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPresContext.h"
#include "nsReadableUtils.h"
#include "nsIDOMElement.h"
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsLinkableAccessible(aShell, aDomNode)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(PRUnichar **_retval)
{
if (!IsALink()) // Also initializes private data members
return NS_ERROR_FAILURE;
nsAutoString nameString;
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
return rv;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_LINK;
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;
}

Просмотреть файл

@ -18,34 +18,24 @@
* Rights Reserved.
*
* Contributor(s):
* Author: Aaron Leventhal (aaronl@netscape.com)
*/
#ifndef _nsMutableAccessible_H_
#define _nsMutableAccessible_H_
#ifndef _nsHTMLLinkAccessible_H_
#define _nsHTMLLinkAccessible_H_
#include "nsIMutableAccessible.h"
#include "nsAccessible.h"
#include "nsString.h"
#include "nsGenericAccessible.h"
class nsMutableAccessible : public nsIMutableAccessible
class nsHTMLLinkAccessible : public nsLinkableAccessible
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLE
NS_DECL_NSIMUTABLEACCESSIBLE
nsMutableAccessible(nsISupports* aNode);
virtual ~nsMutableAccessible();
public:
nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
private:
nsCOMPtr<nsISupports> mNode;
nsString mName;
nsString mRole;
nsCOMPtr<nsIAtom> mNameAttribute;
PRPackedBool mNameNodeValue;
PRPackedBool mNameStringSet;
PRPackedBool mIsLeaf;
};
#endif
#endif

Просмотреть файл

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsHTMLTableAccessible.h"
#include "nsWeakReference.h"
#include "nsReadableUtils.h"
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsDOMAccessible(aShell, aDomNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_CELL;
return NS_OK;
}
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsDOMAccessible(aShell, aDomNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTableAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TABLE;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLTableAccessible_H_
#define _nsHTMLTableAccessible_H_
#include "nsGenericAccessible.h"
class nsHTMLTableCellAccessible : public nsDOMAccessible
{
public:
nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
};
class nsHTMLTableAccessible : public nsDOMAccessible
{
public:
nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -22,30 +22,62 @@
*/
#include "nsHTMLTextAccessible.h"
#include "nsICheckboxControlFrame.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPresContext.h"
#include "nsReadableUtils.h"
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsLeafDOMAccessible(aShell, aDomNode)
nsLinkableAccessible(aShell, aDomNode)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(PRUnichar **_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)
{
nsAutoString value;
mNode->GetNodeValue(value);
value.CompressWhitespace();
*_retval = value.ToNewUnicode();
*_retval = ROLE_STATICTEXT;
return NS_OK;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccRole(PRUnichar **_retval)
{
nsAutoString role(NS_LITERAL_STRING("text"));
*_retval = role.ToNewUnicode();
return NS_OK;
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}

Просмотреть файл

@ -28,16 +28,16 @@
class nsIWeakReference;
class nsITextControlFrame;
class nsHTMLTextAccessible : public nsLeafDOMAccessible
class nsHTMLTextAccessible : public nsLinkableAccessible
{
public:
nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
private:
nsCOMPtr<nsIDOMNode> mDomNode;
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
};
#endif

3
accessible/src/jar.mn Normal file
Просмотреть файл

@ -0,0 +1,3 @@
en-US.jar:
locale/en-US/global/accessible.properties

Просмотреть файл

@ -26,19 +26,24 @@ LIBRARY_NAME=accessibility_s
CPP_OBJS=\
.\$(OBJDIR)\nsAccessible.obj \
.\$(OBJDIR)\nsRootAccessible.obj \
.\$(OBJDIR)\nsMutableAccessible.obj \
.\$(OBJDIR)\nsHTMLIFrameRootAccessible.obj \
.\$(OBJDIR)\nsAccessibilityService.obj \
.\$(OBJDIR)\nsSelectAccessible.obj \
.\$(OBJDIR)\nsGenericAccessible.obj \
.\$(OBJDIR)\nsHTMLFormControlAccessible.obj \
.\$(OBJDIR)\nsHTMLTextAccessible.obj \
$(NULL)
.\$(OBJDIR)\nsHTMLImageAccessible.obj \
.\$(OBJDIR)\nsHTMLAreaAccessible.obj \
.\$(OBJDIR)\nsHTMLTableAccessible.obj \
.\$(OBJDIR)\nsHTMLLinkAccessible.obj \
$(NULL)
LINCS= \
-I..\..\layout\html\forms\public \
-I..\..\layout\html\forms\src \
-I..\..\layout\html\base\src \
$(NULL)
-I..\..\layout\html\forms\public \
-I..\..\layout\html\forms\src \
-I..\..\layout\html\base\src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -33,18 +33,26 @@
#include "nsIFrame.h"
#include "nsRootAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsMutableAccessible.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsLayoutAtoms.h"
#include "nsSelectAccessible.h"
#include "nsHTMLTextAccessible.h"
#include "nsHTMLTableAccessible.h"
#include "nsHTMLImageAccessible.h"
#include "nsHTMLAreaAccessible.h"
#include "nsHTMLLinkAccessible.h"
// IFrame
#include "nsIDocShell.h"
#include "nsHTMLIFrameRootAccessible.h"
//--------------------
nsAccessibilityService::nsAccessibilityService()
{
NS_INIT_REFCNT();
NS_INIT_REFCNT();
//printf("################################## nsAccessibilityService\n");
}
nsAccessibilityService::~nsAccessibilityService()
@ -64,7 +72,7 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
{
nsIFrame* f = NS_STATIC_CAST(nsIFrame*, aFrame);
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
@ -74,7 +82,8 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsRootAccessible(wr,f);
//printf("################################## CreateRootAccessible\n");
*_retval = new nsRootAccessible(wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
@ -82,48 +91,15 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateMutableAccessible(nsISupports* aNode, nsIMutableAccessible **_retval)
{
*_retval = new nsMutableAccessible(aNode);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
nsCOMPtr<nsIContent> n = do_QueryInterface(node);
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
c->GetShell(getter_AddRefs(s));
NS_ASSERTION(s,"Error not presshell!!");
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsHTMLBlockAccessible(aAccessible, n,wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
nsCOMPtr<nsIContent> n = do_QueryInterface(node);
/*
nsCOMPtr<nsIContent> n(do_QueryInterface(node));
NS_ASSERTION(n,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> c = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPresContext> c(do_QueryInterface(aPresContext));
NS_ASSERTION(c,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> s;
@ -131,12 +107,15 @@ nsAccessibilityService::CreateHTMLSelectAccessible(nsIAtom* aPopupAtom, nsIDOMNo
nsCOMPtr<nsIWeakReference> wr = getter_AddRefs(NS_GetWeakReference(s));
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, n, wr);
*_retval = new nsSelectAccessible(aPopupAtom, nsnull, node, wr);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
*/
return NS_ERROR_FAILURE;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
@ -157,13 +136,15 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLRadioButtonAccessible(shell,node);
if (*_retval) {
@ -173,7 +154,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupport
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLCheckboxAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
/* nsIAccessible createHTMLButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
@ -191,6 +172,24 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aF
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTML4ButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTML4ButtonAccessible(shell,node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
@ -201,6 +200,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
if (NS_FAILED(rv))
return rv;
//printf("################################## CreateHTMLTextAccessible\n");
*_retval = new nsHTMLTextAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
@ -209,17 +209,113 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTableAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTableAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTableCellAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTableCellAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLImageAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIImageFrame> imageFrame(do_QueryInterface(aFrame));
if (!imageFrame)
return NS_ERROR_FAILURE;
*_retval = new nsHTMLImageAccessible(shell, node, imageFrame);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLAreaAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLAreaAccessible(nsISupports *aShell, nsIDOMNode *aDOMNode, nsIAccessible *aAccParent,
nsIAccessible **_retval)
{
nsCOMPtr<nsIPresShell> shell(do_QueryInterface(aShell));
*_retval = new nsHTMLAreaAccessible(shell, aDOMNode, aAccParent);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
/* nsIAccessible createHTMLTextFieldAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(shell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTextFieldAccessible(shell, node);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
} else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIPresShell** aShell, nsIDOMNode** aNode)
{
*aRealFrame = NS_STATIC_CAST(nsIFrame*, aFrame);
nsCOMPtr<nsIContent> content;
(*aRealFrame)->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
*aNode = node;
NS_ADDREF(*aNode);
nsCOMPtr<nsIDocument> document;
content->GetDocument(*getter_AddRefs(document));
if (!document)
return NS_ERROR_FAILURE;
if (!document)
return NS_ERROR_FAILURE;
#ifdef DEBUG
PRInt32 shells = document->GetNumberOfShells();
@ -232,21 +328,66 @@ NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aR
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLIFrameAccessible(nsIDOMNode* node, nsISupports* aPresContext, nsIAccessible **_retval)
{
*_retval = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
NS_ASSERTION(content,"Error non nsIContent passed to accessible factory!!!");
nsCOMPtr<nsIPresContext> presContext(do_QueryInterface(aPresContext));
NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!");
nsCOMPtr<nsIPresShell> presShell;
presContext->GetShell(getter_AddRefs(presShell));
NS_ASSERTION(presShell,"Error non PresShell passed to accessible factory!!!");
nsCOMPtr<nsIWeakReference> weakRef = getter_AddRefs(NS_GetWeakReference(presShell));
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc))) && doc) {
nsCOMPtr<nsIPresShell> presShell = getter_AddRefs(doc->GetShellAt(0));
if (presShell) {
nsCOMPtr<nsISupports> supps;
presShell->GetSubShellFor(content, getter_AddRefs(supps));
if (supps) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
if (docShell) {
nsCOMPtr<nsIPresShell> ps;
docShell->GetPresShell(getter_AddRefs(ps));
if (ps) {
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;
}
}
}
}
}
return NS_ERROR_FAILURE;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
nsresult
NS_NewAccessibilityService(nsIAccessibilityService** aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsAccessibilityService* a = new nsAccessibilityService();
if (a == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(a);
*aResult = a;
return NS_OK;
nsAccessibilityService* a = new nsAccessibilityService();
if (a == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(a);
*aResult = a;
return NS_OK;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -31,8 +31,16 @@
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsWeakReference.h"
#include "nsIFocusController.h"
#include "nsRect.h"
#include "nsPoint.h"
#define ACCESSIBLE_BUNDLE_URL "chrome://global/locale/accessible.properties"
class nsIFrame;
class nsIDocShell;
class nsIWebShell;
class nsIContent;
class nsAccessible : public nsIAccessible
// public nsIAccessibleWidgetAccess
@ -44,36 +52,65 @@ class nsAccessible : public nsIAccessible
//NS_IMETHOD AccGetWidget(nsIWidget**);
public:
nsAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual ~nsAccessible();
public:
nsAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
virtual ~nsAccessible();
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList) { aList = nsnull; }
// Helper Routines for Sub-Docs
static nsresult GetDocShellFromPS(nsIPresShell* aPresShell, nsIDocShell** aDocShell);
static nsresult GetDocShellObjects(nsIDocShell* aDocShell,
nsIPresShell** aPresShell,
nsIPresContext** aPresContext,
nsIContent** aContent);
static nsresult GetDocShells(nsIPresShell* aPresShell,
nsIDocShell** aDocShell,
nsIDocShell** aParentDocShell);
static nsresult GetParentPresShellAndContent(nsIPresShell* aPresShell,
nsIPresShell** aParentPresShell,
nsIContent** aSubShellContent);
static PRBool FindContentForWebShell(nsIPresShell* aParentPresShell,
nsIContent* aParentContent,
nsIWebShell* aWebShell,
nsIContent** aFoundContent);
nsresult CalcOffset(nsIFrame* aFrame,
nsIPresContext * aPresContext,
nsRect& aRect);
nsresult GetAbsPosition(nsIPresShell* aPresShell, nsPoint& aPoint);
nsresult GetAbsoluteFramePosition(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsRect& aAbsoluteTwipsRect,
nsRect& aAbsolutePixelRect);
static nsresult GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut);
protected:
virtual nsIFrame* GetFrame();
virtual nsIFrame* GetBoundsFrame();
virtual void GetBounds(nsRect& aRect);
virtual void GetPresContext(nsCOMPtr<nsIPresContext>& aContext);
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewPreviousAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewParentAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewFirstAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewLastAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
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);
nsCOMPtr<nsIContent> mContent;
// 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(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
nsHTMLBlockAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
protected:
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aFrame, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aFrame, nsIWeakReference* aShell);
};
#endif

Просмотреть файл

@ -26,6 +26,21 @@
#include "nsIFrame.h"
#include "nsCOMPtr.h"
#include "nsIWeakReference.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)
@ -44,181 +59,203 @@ nsGenericAccessible::~nsGenericAccessible()
/* nsIAccessible getAccParent (); */
NS_IMETHODIMP nsGenericAccessible::GetAccParent(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccNextSibling (); */
NS_IMETHODIMP nsGenericAccessible::GetAccNextSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccPreviousSibling (); */
NS_IMETHODIMP nsGenericAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsGenericAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsGenericAccessible::GetAccLastChild(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsGenericAccessible::GetAccChildCount(PRInt32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsGenericAccessible::GetAccName(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsGenericAccessible::GetAccValue(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setAccName (in wstring name); */
NS_IMETHODIMP nsGenericAccessible::SetAccName(const PRUnichar *name)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setAccValue (in wstring value); */
NS_IMETHODIMP nsGenericAccessible::SetAccValue(const PRUnichar *value)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccDescription (); */
NS_IMETHODIMP nsGenericAccessible::GetAccDescription(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsGenericAccessible::GetAccRole(PRUnichar **_retval)
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsGenericAccessible::GetAccRole(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccState (); */
NS_IMETHODIMP nsGenericAccessible::GetAccState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsGenericAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsGenericAccessible::GetAccNumActions(PRUint8 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::AccDoAction(PRUint8 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccFocused(); */
NS_IMETHODIMP nsGenericAccessible::GetAccFocused(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccHelp (); */
NS_IMETHODIMP nsGenericAccessible::GetAccHelp(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean getAccFocused (); */
NS_IMETHODIMP nsGenericAccessible::GetAccFocused(PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accGetAt (in long x, in long y); */
NS_IMETHODIMP nsGenericAccessible::AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateRight (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateRight(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateLeft (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateLeft(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateUp (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateUp(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible accNavigateDown (); */
NS_IMETHODIMP nsGenericAccessible::AccNavigateDown(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accGetBounds (out long x, out long y, out long width, out long height); */
NS_IMETHODIMP nsGenericAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accAddSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccAddSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accRemoveSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccRemoveSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accExtendSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccExtendSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accTakeSelection (); */
NS_IMETHODIMP nsGenericAccessible::AccTakeSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accTakeFocus (); */
NS_IMETHODIMP nsGenericAccessible::AccTakeFocus()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoDefaultAction (); */
NS_IMETHODIMP nsGenericAccessible::AccDoDefaultAction()
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccExtState (); */
NS_IMETHODIMP nsGenericAccessible::GetAccExtState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
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);
@ -229,80 +266,170 @@ nsDOMAccessible::nsDOMAccessible(nsIPresShell* aShell, nsIDOMNode* aNode)
/* 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<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;
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;
rv = selection->Collapse(parent, 0);
if (NS_FAILED(rv))
return rv;
return NS_OK;
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<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;
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;
PRInt32 offsetInParent = 0;
nsCOMPtr<nsIDOMNode> child;
rv = parent->GetFirstChild(getter_AddRefs(child));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDOMNode> next;
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);
while(child)
{
if (child == mNode) {
// Collapse selection to just before desired element,
rv = selection->Collapse(parent, offsetInParent);
if (NS_FAILED(rv))
return rv;
}
child->GetNextSibling(getter_AddRefs(next));
child = next;
offsetInParent++;
// then extend it to just after
rv = selection->Extend(parent, offsetInParent+1);
return rv;
}
// didn't find a child
return NS_ERROR_FAILURE;
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<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsIContent> content = do_QueryInterface(mNode);
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
//-------------
@ -333,3 +460,126 @@ NS_IMETHODIMP nsLeafDOMAccessible::GetAccChildCount(PRInt32 *_retval)
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;
}

Просмотреть файл

@ -42,7 +42,7 @@ class nsGenericAccessible : public nsIAccessible
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLE
public:
public:
nsGenericAccessible();
virtual ~nsGenericAccessible();
};
@ -58,11 +58,15 @@ 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);
protected:
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAWritableString *aFlatString);
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAWritableString *aFlatString);
nsCOMPtr<nsIWeakReference> mPresShell;
nsCOMPtr<nsIDOMNode> mNode;
};
@ -80,4 +84,23 @@ class nsLeafDOMAccessible : public nsDOMAccessible
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

Просмотреть файл

@ -0,0 +1,218 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsGenericAccessible.h"
#include "nsHTMLAreaAccessible.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLAreaElement.h"
// --- area -----
nsHTMLAreaAccessible::nsHTMLAreaAccessible(nsIPresShell *aPresShell, nsIDOMNode *aDomNode, nsIAccessible *aAccParent):
nsGenericAccessible(), mPresShell(aPresShell), mDOMNode(aDomNode), mAccParent(aAccParent)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = 0;
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
if (elt) {
nsAutoString hrefString;
elt->GetAttribute(NS_LITERAL_STRING("title"), hrefString);
if (!hrefString.IsEmpty()) {
*_retval = hrefString.ToNewUnicode();
return NS_OK;
}
}
return NS_OK;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_LINK;
return NS_OK;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(PRUnichar **_retval)
{
*_retval = 0;
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
if (elt) {
nsAutoString hrefString;
elt->GetAttribute(NS_LITERAL_STRING("href"), hrefString);
*_retval = hrefString.ToNewUnicode();
}
return NS_OK;
}
/* wstring getAccDescription (); */
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(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)
{
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccParent(nsIAccessible * *aAccParent)
{
*aAccParent = mAccParent;
NS_IF_ADDREF(*aAccParent);
return NS_OK;
}
nsIAccessible *nsHTMLAreaAccessible::CreateAreaAccessible(nsIDOMNode *aDOMNode)
{
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTMLAreaAccessible(mPresShell, aDOMNode, mAccParent, &acc);
return acc;
}
return nsnull;
}
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccNextSibling(nsIAccessible * *aAccNextSibling)
{
*aAccNextSibling = nsnull;
nsCOMPtr<nsIDOMNode> nextNode;
mDOMNode->GetNextSibling(getter_AddRefs(nextNode));
if (nextNode)
*aAccNextSibling = CreateAreaAccessible(nextNode);
return NS_OK;
}
/* readonly attribute nsIAccessible accPreviousSibling; */
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccPreviousSibling(nsIAccessible * *aAccPrevSibling)
{
*aAccPrevSibling = nsnull;
nsCOMPtr<nsIDOMNode> prevNode;
mDOMNode->GetPreviousSibling(getter_AddRefs(prevNode));
if (prevNode)
*aAccPrevSibling = CreateAreaAccessible(prevNode);
return NS_OK;
}
/* void accGetBounds (out long x, out long y, out long width, out long height); */
NS_IMETHODIMP nsHTMLAreaAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
//nsIFrame *frame;
// Do a better job on this later - need to use GetRect on mAreas of nsImageMap from nsImageFrame
//return mAccParent->nsAccessible::AccGetBounds(x,y,width,height);
*x = *y = *width = *height = 0;
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLAreaAccessible_H_
#define _nsHTMLAreaAccessible_H_
#include "nsGenericAccessible.h"
#include "nsHTMLLinkAccessible.h"
/* Accessible for image map areas - must be child of image
*/
class nsHTMLAreaAccessible : public nsGenericAccessible
{
public:
nsHTMLAreaAccessible(nsIPresShell *presShell, nsIDOMNode *domNode, nsIAccessible *accParent);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_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(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

Просмотреть файл

@ -23,36 +23,116 @@
#include "nsHTMLFormControlAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsIDOMHTMLButtonElement.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLLabelElement.h"
#include "nsIDOMHTMLFormElement.h"
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsLeafDOMAccessible(aShell, aNode)
{
}
NS_IMETHODIMP nsHTMLFormControlAccessible::AppendLabelFor(nsIContent *aLookNode, nsAReadableString *aId, nsAWritableString *aLabel)
{
PRInt32 numChildren = 0;
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement(do_QueryInterface(aLookNode));
if (labelElement) {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aLookNode));
nsresult rv = NS_OK;
if (elt) {
nsAutoString labelIsFor;
elt->GetAttribute(NS_LITERAL_STRING("for"),labelIsFor);
if (labelIsFor.Equals(*aId))
rv = AppendFlatStringFromSubtree(aLookNode, aLabel);
}
return rv;
}
aLookNode->ChildCount(numChildren);
nsIContent *contentWalker;
PRInt32 index;
for (index = 0; index < numChildren; index++) {
aLookNode->ChildAt(index, contentWalker);
if (contentWalker)
AppendLabelFor(contentWalker, aId, aLabel);
}
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(PRUnichar **_retval)
{
// go up tree get name of label if there is one.
return NS_ERROR_NOT_IMPLEMENTED;
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMHTMLLabelElement> labelElement;
nsCOMPtr<nsIDOMHTMLFormElement> formElement;
nsAutoString nameString;
nsresult rv = NS_OK;
// go up tree get name of ancestor label if there is one. Don't go up farther than form element
while (walkUpContent && nameString.IsEmpty() && !formElement) {
labelElement = do_QueryInterface(walkUpContent);
if (labelElement)
rv = AppendFlatStringFromSubtree(walkUpContent, &nameString);
formElement = do_QueryInterface(walkUpContent); // reached top ancestor in form
nsCOMPtr<nsIContent> nextParent;
walkUpContent->GetParent(*getter_AddRefs(nextParent));
walkUpContent = nextParent;
}
// There can be a label targeted at this control using the for="control_id" attribute
// To save computing time, only look for those inside of a form element
walkUpContent = do_QueryInterface(formElement);
if (walkUpContent) {
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,&nameString);
}
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
return NS_OK;
}
/* wstring getAccState (); */
/* long getAccState (); */
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, checked
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
// can be
// focusable, focused, checked, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
*_retval = (checked ? STATE_CHECKED : 0);
return NS_OK;
*_retval = STATE_FOCUSABLE;
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked) *_retval |= STATE_CHECKED;
PRBool disabled = PR_FALSE;
element->GetDisabled(&disabled);
if (disabled)
*_retval |= STATE_UNAVAILABLE;
nsAutoString typeString;
element->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
return NS_OK;
}
// --- checkbox -----
@ -62,38 +142,47 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccRole(PRUnichar **_retval)
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("check box"));
return NS_OK;
*_retval = ROLE_CHECKBUTTON;
return NS_OK;
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = 1;
return NS_OK;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
if (index == 0) {
// check or uncheck
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked)
*_retval = ToNewUnicode(NS_LITERAL_STRING("Check"));
else
*_retval = ToNewUnicode(NS_LITERAL_STRING("UnCheck"));
if (element)
element->GetChecked(&checked);
*_retval = ToNewUnicode(checked? NS_LITERAL_STRING("uncheck"): NS_LITERAL_STRING("check"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoDefaultAction (); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoDefaultAction()
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
return NS_OK;
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_NOT_IMPLEMENTED;
}
@ -104,25 +193,39 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("Select"));
return NS_OK;
*_retval = 1;
return NS_OK;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUnichar **_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("radio button"));
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("select"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoDefaultAction()
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::AccDoAction(PRUint8 index)
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
element->Click();
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_RADIOBUTTON;
return NS_OK;
}
@ -134,42 +237,213 @@ nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* wstring getAccDefaultAction (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccDefaultAction(PRUnichar **_retval)
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("Press"));
return NS_OK;
*_retval = 1;
return NS_OK;;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUnichar **_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("push button"));
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_PUSHBUTTON;
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = nsnull;
nsCOMPtr<nsIDOMHTMLInputElement> button = do_QueryInterface(mNode);
*_retval = nsnull;
nsCOMPtr<nsIDOMHTMLInputElement> button(do_QueryInterface(mNode));
if (!button)
return NS_ERROR_FAILURE;
if (!button)
return NS_ERROR_FAILURE;
nsAutoString name;
button->GetValue(name);
name.CompressWhitespace();
nsAutoString name;
button->GetValue(name);
name.CompressWhitespace();
*_retval = name.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoDefaultAction()
{
nsCOMPtr<nsIDOMHTMLInputElement> element = do_QueryInterface(mNode);
element->Click();
*_retval = name.ToNewUnicode();
return NS_OK;
}
// ----- HTML 4 Button: can contain arbitrary HTML content -----
nsHTML4ButtonAccessible::nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsDOMAccessible(aShell, aNode)
{
}
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccNumActions(PRUint8 *_retval)
{
*_retval = 1;
return NS_OK;;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, PRUnichar **_retval)
{
if (index == 0) {
*_retval = ToNewUnicode(NS_LITERAL_STRING("press"));
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mNode));
element->Click();
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_PUSHBUTTON;
return NS_OK;
}
/* long getAccState (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
{
*_retval |= STATE_FOCUSABLE;
return NS_OK;
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(PRUnichar **_retval)
{
*_retval = nsnull;
nsresult rv = NS_ERROR_FAILURE;
nsAutoString name;
nsCOMPtr<nsIContent> content(do_QueryInterface(mNode));
if (content)
rv = AppendFlatStringFromSubtree(content, &name);
if (NS_SUCCEEDED(rv)) {
name.CompressWhitespace();
*_retval = name.ToNewUnicode();
}
return rv;
}
// --- textfield -----
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode):
nsHTMLFormControlAccessible(aShell, aNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TEXT;
return NS_OK;
}
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(PRUnichar **_retval)
{
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
if (textArea) {
nsAutoString valueString;
textArea->GetValue(valueString);
*_retval = ToNewUnicode(valueString);
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* long getAccState (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, protected. readonly, unavailable, selected
*_retval = STATE_FOCUSABLE;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mNode));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mNode));
PRBool isReadOnly = PR_FALSE;
elt->HasAttribute(NS_LITERAL_STRING("readonly"), &isReadOnly);
if (isReadOnly)
*_retval |= STATE_READONLY;
// 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 isCollapsed = PR_TRUE;
domSel->GetIsCollapsed(&isCollapsed);
if (!isCollapsed)
*_retval |=STATE_SELECTED;
}
}
}
if (!textArea) {
if (inputElement) {
/////// ====== Must be a password field, so it uses nsIDOMHTMLFormControl ==== ///////
PRUint32 moreStates = 0;
nsresult rv = nsHTMLFormControlAccessible::GetAccState(&moreStates);
*_retval |= moreStates;
return rv;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
PRBool disabled = PR_FALSE;
textArea->GetDisabled(&disabled);
if (disabled)
*_retval |= STATE_UNAVAILABLE;
return NS_OK;
}

Просмотреть файл

@ -40,6 +40,9 @@ public:
nsHTMLFormControlAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
protected:
NS_IMETHODIMP AppendLabelFor(nsIContent *aLookNode, nsAReadableString *aId, nsAWritableString *aLabel);
};
class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
@ -47,9 +50,10 @@ class nsHTMLCheckboxAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLCheckboxAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
@ -57,9 +61,10 @@ class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLRadioButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
@ -67,11 +72,34 @@ class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible
public:
nsHTMLButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccDefaultAction(PRUnichar **_retval);
NS_IMETHOD AccDoDefaultAction(void);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTML4ButtonAccessible : public nsDOMAccessible
{
public:
nsHTML4ButtonAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, PRUnichar **_retval);
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLTextFieldAccessible : public nsHTMLFormControlAccessible
{
public:
nsHTMLTextFieldAccessible(nsIPresShell* aShell, nsIDOMNode* aNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -0,0 +1,216 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Contributor(s):
*/
#include "nsHTMLIFrameRootAccessible.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIDocShell.h"
#include "nsIWebShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsReadableUtils.h"
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIPresShell* aShell, nsIDOMNode* aNode, nsIAccessible* aRoot):
nsDOMAccessible(aShell, aNode)
{
mRootAccessible = aRoot;
}
/* attribute wstring accName; */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(PRUnichar * *aAccName)
{
return mRootAccessible->GetAccName(aAccName);
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
return mRootAccessible->GetAccFirstChild(_retval);
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccLastChild(nsIAccessible **_retval)
{
return mRootAccessible->GetAccLastChild(_retval);
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccChildCount(PRInt32 *_retval)
{
return mRootAccessible->GetAccChildCount(_retval);
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
{
return mRootAccessible->GetAccRole(_retval);
}
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode):
nsRootAccessible(aShell)
{
mRealDOMNode = aNode;
}
//-----------------------------------------------------
// destruction
//-----------------------------------------------------
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; */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccParent(nsIAccessible * *_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccParent(_retval);
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccNextSibling (); */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccNextSibling(nsIAccessible **_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccNextSibling(_retval);
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccPreviousSibling (); */
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
{
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetHTMLIFrameAccessible(getter_AddRefs(accessible))))
return accessible->GetAccPreviousSibling(_retval);
*_retval = nsnull;
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)
{
// 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));
nsCOMPtr<nsIDocShell> docShell;
if (NS_SUCCEEDED(GetDocShellFromPS(presShell, getter_AddRefs(docShell)))) {
// Now that we have the DocShell QI
// it to a tree item to find it's parent
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
if (item) {
nsCOMPtr<nsIDocShellTreeItem> itemParent;
item->GetParent(getter_AddRefs(itemParent));
// QI to get the WebShell for the parent document
nsCOMPtr<nsIDocShell> parentDocShell(do_QueryInterface(itemParent));
if (parentDocShell) {
// Get the PresShell/Content and
// Root Content Node of the parent document
nsCOMPtr<nsIPresShell> parentPresShell;
nsCOMPtr<nsIPresContext> parentPresContext;
nsCOMPtr<nsIContent> rootContent;
if (NS_SUCCEEDED(GetDocShellObjects(parentDocShell,
getter_AddRefs(parentPresShell),
getter_AddRefs(parentPresContext),
getter_AddRefs(rootContent)))) {
// QI the DocShell (of this sub-doc) to a webshell
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
if (webShell && parentPresShell && parentPresContext && rootContent) {
// Now, find the Content in the parent document
// that represents this sub-doc,
// we do that matching webshells
nsCOMPtr<nsIContent> content;
if (FindContentForWebShell(parentPresShell,
rootContent,
webShell,
getter_AddRefs(content))) {
// 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(getter_AddRefs(NS_GetWeakReference(parentPresShell)));
nsIFrame* frame = nsnull;
parentPresShell->GetPrimaryFrameFor(content, &frame);
#ifdef NS_DEBUG_X
printf("** Found: Con:%p Fr:%p", content, frame);
char * name;
if (GetNameForFrame(frame, &name)) {
printf(" Name:[%s]", name);
nsMemory::Free(name);
}
printf("\n");
#endif
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
*aAcc = CreateNewAccessible(acc, node, wr);
NS_IF_ADDREF(*aAcc);
return NS_OK;
}
}
}
}
}
}
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Contributor(s):
*/
#ifndef _nsIFrameRootAccessible_H_
#define _nsIFrameRootAccessible_H_
#include "nsRootAccessible.h"
#include "nsGenericAccessible.h"
class nsIWebShell;
class nsHTMLIFrameAccessible : public nsDOMAccessible
{
public:
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(PRUnichar * *aAccName);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
protected:
nsCOMPtr<nsIAccessible> mRootAccessible;
};
class nsHTMLIFrameRootAccessible : public nsRootAccessible
{
public:
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell, nsIDOMNode* aNode);
virtual ~nsHTMLIFrameRootAccessible();
/* attribute wstring accName; */
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
/* nsIAccessible getAccNextSibling (); */
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
/* 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;
};
#endif

Просмотреть файл

@ -0,0 +1,146 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsGenericAccessible.h"
#include "nsHTMLImageAccessible.h"
#include "nsReadableUtils.h"
#include "nsAccessible.h"
#include "nsIHTMLDocument.h"
#include "nsIDocument.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
// --- image -----
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIPresShell* aShell, nsIDOMNode* aDOMNode, nsIImageFrame *aImageFrame):
nsLinkableAccessible(aShell, aDOMNode), mPresShell(aShell)
{
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIDocument> doc;
aShell->GetDocument(getter_AddRefs(doc));
nsAutoString mapElementName;
if (doc && element) {
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
element->GetAttribute(NS_LITERAL_STRING("usemap"),mapElementName);
if (htmlDoc && !mapElementName.IsEmpty()) {
if (mapElementName.CharAt(0) == '#')
mapElementName.Cut(0,1);
htmlDoc->GetImageMap(mapElementName, getter_AddRefs(mMapElement));
}
}
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccName(PRUnichar **_retval)
{
nsCOMPtr<nsIContent> imageContent(do_QueryInterface(mNode));
if (imageContent) {
nsAutoString nameString;
nsresult rv = AppendFlatStringFromContentNode(imageContent, &nameString);
if (NS_SUCCEEDED(rv)) {
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
}
return rv;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_GRAPHIC;
return NS_OK;
}
nsIAccessible *nsHTMLImageAccessible::CreateAreaAccessible(PRUint32 areaNum)
{
if (!mMapElement)
return nsnull;
if (areaNum == -1) {
PRInt32 numAreaMaps;
GetAccChildCount(&numAreaMaps);
if (numAreaMaps<=0)
return nsnull;
areaNum = NS_STATIC_CAST(PRUint32,numAreaMaps-1);
}
nsIDOMHTMLCollection *mapAreas;
mMapElement->GetAreas(&mapAreas);
if (!mapAreas)
return nsnull;
nsIDOMNode *domNode = nsnull;
mapAreas->Item(areaNum,&domNode);
if (!domNode)
return nsnull;
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
nsCOMPtr<nsISupports> presShell(do_QueryInterface(mPresShell));
accService->CreateHTMLAreaAccessible(presShell, domNode, this, &acc);
return acc;
}
return nsnull;
}
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
*_retval = CreateAreaAccessible(0);
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = CreateAreaAccessible(-1);
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLImageAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
if (mMapElement) {
nsIDOMHTMLCollection *mapAreas;
mMapElement->GetAreas(&mapAreas);
if (mapAreas) {
PRUint32 length;
mapAreas->GetLength(&length);
*_retval = NS_STATIC_CAST(PRInt32, length);
}
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLImageAccessible_H_
#define _nsHTMLImageAccessible_H_
#include "nsGenericAccessible.h"
#include "nsIFrame.h"
#include "nsIImageFrame.h"
#include "nsIDOMHTMLMapElement.h"
/* Accessible for supporting images
* supports:
* - gets name, role
* - support basic state
*/
class nsHTMLImageAccessible : public nsLinkableAccessible
{
public:
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);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
protected:
nsIAccessible *CreateAreaAccessible(PRUint32 areaNum);
nsCOMPtr<nsIDOMHTMLMapElement> mMapElement;
nsCOMPtr<nsIPresShell> mPresShell;
};
#endif

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsHTMLLinkAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPresContext.h"
#include "nsReadableUtils.h"
#include "nsIDOMElement.h"
nsHTMLLinkAccessible::nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsLinkableAccessible(aShell, aDomNode)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(PRUnichar **_retval)
{
if (!IsALink()) // Also initializes private data members
return NS_ERROR_FAILURE;
nsAutoString nameString;
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &nameString);
nameString.CompressWhitespace();
*_retval = nameString.ToNewUnicode();
return rv;
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_LINK;
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;
}

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the 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):
* Author: Aaron Leventhal (aaronl@netscape.com)
*/
#ifndef _nsHTMLLinkAccessible_H_
#define _nsHTMLLinkAccessible_H_
#include "nsGenericAccessible.h"
class nsHTMLLinkAccessible : public nsLinkableAccessible
{
public:
nsHTMLLinkAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
private:
};
#endif

Просмотреть файл

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#include "nsHTMLTableAccessible.h"
#include "nsWeakReference.h"
#include "nsReadableUtils.h"
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsDOMAccessible(aShell, aDomNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_CELL;
return NS_OK;
}
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsDOMAccessible(aShell, aDomNode)
{
}
/* unsigned long getAccRole (); */
NS_IMETHODIMP nsHTMLTableAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TABLE;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Author: Aaron Leventhal (aaronl@netscape.com)
* Contributor(s):
*/
#ifndef _nsHTMLTableAccessible_H_
#define _nsHTMLTableAccessible_H_
#include "nsGenericAccessible.h"
class nsHTMLTableCellAccessible : public nsDOMAccessible
{
public:
nsHTMLTableCellAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
};
class nsHTMLTableAccessible : public nsDOMAccessible
{
public:
nsHTMLTableAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -22,30 +22,62 @@
*/
#include "nsHTMLTextAccessible.h"
#include "nsICheckboxControlFrame.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPresContext.h"
#include "nsReadableUtils.h"
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode):
nsLeafDOMAccessible(aShell, aDomNode)
nsLinkableAccessible(aShell, aDomNode)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(PRUnichar **_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)
{
nsAutoString value;
mNode->GetNodeValue(value);
value.CompressWhitespace();
*_retval = value.ToNewUnicode();
*_retval = ROLE_STATICTEXT;
return NS_OK;
}
/* wstring getAccRole (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccRole(PRUnichar **_retval)
{
nsAutoString role(NS_LITERAL_STRING("text"));
*_retval = role.ToNewUnicode();
return NS_OK;
/* nsIAccessible getAccFirstChild (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* nsIAccessible getAccLastChild (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccLastChild(nsIAccessible **_retval)
{
*_retval = nsnull;
return NS_OK;
}
/* long getAccChildCount (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccChildCount(PRInt32 *_retval)
{
*_retval = 0;
return NS_OK;
}

Просмотреть файл

@ -28,16 +28,16 @@
class nsIWeakReference;
class nsITextControlFrame;
class nsHTMLTextAccessible : public nsLeafDOMAccessible
class nsHTMLTextAccessible : public nsLinkableAccessible
{
public:
nsHTMLTextAccessible(nsIPresShell* aShell, nsIDOMNode* aDomNode);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
private:
nsCOMPtr<nsIDOMNode> mDomNode;
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
};
#endif

Просмотреть файл

@ -1,263 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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.
*
* Contributor(s):
*/
#include "nsMutableAccessible.h"
#include "nsINameSpaceManager.h"
NS_IMPL_ISUPPORTS1(nsMutableAccessible, nsIAccessible)
nsMutableAccessible::nsMutableAccessible(nsISupports* aNode)
{
NS_INIT_ISUPPORTS();
NS_ASSERTION(aNode,"We must have a valid node!!");
mNode = aNode;
mNameNodeValue = PR_FALSE;
mNameStringSet = PR_FALSE;
mRole = NS_LITERAL_STRING("unknown");
mIsLeaf = PR_FALSE;
}
nsMutableAccessible::~nsMutableAccessible()
{
}
NS_IMETHODIMP nsMutableAccessible::SetIsLeaf(PRBool aLeaf)
{
mIsLeaf = aLeaf;
return NS_OK;
}
/* void SetNodeAsNodeValue (); */
NS_IMETHODIMP nsMutableAccessible::SetNameAsNodeValue()
{
mNameNodeValue = PR_TRUE;
return NS_OK;
}
/* void SetName (in wstring name); */
NS_IMETHODIMP nsMutableAccessible::SetName(const PRUnichar *aName)
{
mName = aName;
mNameStringSet = PR_TRUE;
return NS_OK;
}
/* void SetNameAsAttribute (in nsIAtom atom); */
NS_IMETHODIMP nsMutableAccessible::SetNameAsAttribute(nsIAtom *aAttribute)
{
mNameAttribute = aAttribute;
return NS_OK;
}
/* void SetNameAsAttribute (in nsIAtom atom); */
NS_IMETHODIMP nsMutableAccessible::SetRole(const PRUnichar *aRole)
{
mRole = aRole;
return NS_OK;
}
NS_IMETHODIMP nsMutableAccessible::GetAccParent(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccNextSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccFirstChild(nsIAccessible **_retval)
{
if (mIsLeaf) {
*_retval = nsnull;
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccLastChild(nsIAccessible **_retval)
{
if (mIsLeaf) {
*_retval = nsnull;
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccChildCount(PRInt32 *_retval)
{
if (mIsLeaf) {
*_retval = 0;
return NS_OK;
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccName(PRUnichar **_retval)
{
nsAutoString value;
if (mNameNodeValue) {
// see if we can get nodevalue
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mNode);
if (node) {
node->GetNodeValue(value);
value.CompressWhitespace();
} else {
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
} else if (mNameStringSet) {
value = mName;
} else if (mNameAttribute) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mNode);
content->GetAttribute(kNameSpaceID_None, mNameAttribute, value);
value.CompressWhitespace();
} else {
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
*_retval = value.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP nsMutableAccessible::GetAccValue(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::SetAccName(const PRUnichar *name)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::SetAccValue(const PRUnichar *value)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccDescription(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccRole(PRUnichar **_retval)
{
*_retval = mRole.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP nsMutableAccessible::GetAccState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccExtState(PRUint32 *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccDefaultAction(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccHelp(PRUnichar **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::GetAccFocused(PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccGetAt(PRInt32 x, PRInt32 y, nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccNavigateRight(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccNavigateLeft(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccNavigateUp(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccNavigateDown(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccAddSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccRemoveSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccExtendSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccTakeSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccTakeFocus()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMutableAccessible::AccDoDefaultAction()
{
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -31,10 +31,20 @@
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsReadableUtils.h"
#include "nsILink.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsIURI.h"
#include "nsIDocShellTreeItem.h"
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleEventReceiver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMTextListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMutationListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMMutationListener)
NS_INTERFACE_MAP_END_INHERITING(nsAccessible)
NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsAccessible);
@ -43,10 +53,12 @@ NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsAccessible);
//-----------------------------------------------------
// construction
//-----------------------------------------------------
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell, nsIFrame* aFrame):nsAccessible(nsnull,nsnull,aShell)
nsRootAccessible::nsRootAccessible(nsIWeakReference* aShell):nsAccessible(nsnull,nsnull,aShell)
{
// mFrame = aFrame;
mListener = nsnull;
mListener = nsnull;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
shell->GetDocument(getter_AddRefs(mDocument));
mDOMNode = do_QueryInterface(mDocument);
}
//-----------------------------------------------------
@ -60,60 +72,120 @@ nsRootAccessible::~nsRootAccessible()
/* attribute wstring accName; */
NS_IMETHODIMP nsRootAccessible::GetAccName(PRUnichar * *aAccName)
{
*aAccName = ToNewUnicode(NS_LITERAL_STRING("Mozilla Document"));
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()
{
//if (!mFrame) {
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsIFrame* root = nsnull;
if (shell)
shell->GetRootFrame(&root);
return root;
//}
// return mFrame;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* root = nsnull;
if (shell)
shell->GetRootFrame(&root);
return root;
}
nsIAccessible* nsRootAccessible::CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell)
void nsRootAccessible::GetBounds(nsRect& aBounds)
{
return new nsHTMLBlockAccessible(aAccessible, aContent, aShell);
nsIFrame* frame = GetFrame();
frame->GetRect(aBounds);
}
/* readonly attribute nsIAccessible accParent; */
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)
{
*aAccParent = nsnull;
return NS_OK;
}
/* readonly attribute wstring accRole; */
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUnichar * *aAccRole)
/* readonly attribute unsigned long accRole; */
NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
{
*aAccRole = ToNewUnicode(NS_LITERAL_STRING("client"));
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsISupports> container;
context->GetContainer(getter_AddRefs(container));
if (container) {
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem, docTreeItem(do_QueryInterface(container));
if (docTreeItem) {
docTreeItem->GetSameTypeParent(getter_AddRefs(parentTreeItem));
// Basically, if this docshell has a parent of the same type, it's a frame
if (parentTreeItem) {
*aAccRole = ROLE_PANE;
return NS_OK;
}
}
}
*aAccRole = ROLE_CLIENT;
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::GetAccValue(PRUnichar * *aAccValue)
{
nsCOMPtr<nsIURI> pURI(mDocument->GetDocumentURL());
char *path;
pURI->GetSpec(&path);
*aAccValue = ToNewUnicode(nsLiteralCString(path));
return NS_OK;
}
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventListener *aListener)
{
if (!mListener)
{
// add an event listener to the document
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIDocument> document;
shell->GetDocument(getter_AddRefs(document));
// add an event listener to the document
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIDocument> document;
shell->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDOMEventReceiver> receiver;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(receiver))) && receiver)
{
nsresult rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *, this), NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
// use AddEventListenerByIID from the nsIDOMEventReceiver interface
nsCOMPtr<nsIDOMEventReceiver> receiver;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(receiver))) && receiver)
{
nsresult rv = NS_OK;
// add this as a FocusListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *, this), NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a FormListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFormListener*, this), NS_GET_IID(nsIDOMFormListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a TextListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMTextListener*, this), NS_GET_IID(nsIDOMTextListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add this as a MutationListener to the document
rv = receiver->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMMutationListener*, this), NS_GET_IID(nsIDOMMutationListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
// use AddEventListener from the nsIDOMEventTarget interface -- for UserDefinedTypes
nsCOMPtr<nsIDOMEventTarget> target;
if (NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIDOMEventTarget), getter_AddRefs(target))) && target)
{
nsresult rv = NS_OK;
// we're a DOMEventListener now!!
nsCOMPtr<nsIDOMEventListener> listener;
rv = this->QueryInterface( NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener) );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to QI");
// add ourself as a CheckboxStateChange listener
rv = target->AddEventListener( nsAutoString(NS_LITERAL_STRING("CheckboxStateChange")) , listener, PR_TRUE );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
// add ourself as a RadiobuttonStateChange listener
rv = target->AddEventListener( nsAutoString(NS_LITERAL_STRING("RadiobuttonStateChange")) , listener, PR_TRUE );
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register listener");
}
}
// create a weak reference to the listener
@ -127,7 +199,7 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
{
if (mListener)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIDocument> document;
if (!shell)
return NS_OK;
@ -147,53 +219,128 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener(nsIAccessibleEvent
return NS_OK;
}
// --------------- nsIDOMEventListener Methods (3) ------------------------
/*
* Leaving the check for focus here since we want a global perspective on it
* otherwise ask the target itself what event to pass to windows
*/
NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
{
if (mListener) {
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
// create and accessible for the target
nsCOMPtr<nsIContent> content = do_QueryInterface(t);
nsCOMPtr<nsIContent> content(do_QueryInterface(t));
if (!content)
return NS_OK;
if (!content)
return NS_OK;
nsAutoString eventType;
aEvent->GetType(eventType);
if (mCurrentFocus == content)
return NS_OK;
// the "focus" type is pulled from nsDOMEvent.cpp
if ( eventType.EqualsIgnoreCase("focus") ) {
if (mCurrentFocus == content)
return NS_OK;
mCurrentFocus = content;
}
mCurrentFocus = content;
nsIFrame* frame = nsnull;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
shell->GetPrimaryFrameFor(content, &frame);
if (!frame)
return NS_OK;
nsIFrame* frame = nsnull;
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
shell->GetPrimaryFrameFor(content, &frame);
nsCOMPtr<nsIAccessible> a(do_QueryInterface(frame));
if (!a)
a = do_QueryInterface(content);
if (!frame)
return NS_OK;
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);
}
}
nsCOMPtr<nsIAccessible> a = do_QueryInterface(frame);
if (a) {
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
nsCOMPtr<nsIAccessible> na(CreateNewAccessible(a, node, mPresShell));
if ( !na )
return NS_OK;
if (!a)
a = do_QueryInterface(content);
nsCOMPtr<nsIAccessible> na = CreateNewAccessible(a, content, mPresShell);
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
if ( eventType.EqualsIgnoreCase("focus") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, na);
}
else if ( eventType.EqualsIgnoreCase("change") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
else if ( eventType.EqualsIgnoreCase("CheckboxStateChange") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
else if ( eventType.EqualsIgnoreCase("RadiobuttonStateChange") ) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, na);
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::Focus(nsIDOMEvent* aEvent)
{
// see this event when the focus changed from one element to another, although all
// textareas seem to share the same focus and radio button groups do too
return HandleEvent(aEvent);
}
NS_IMETHODIMP nsRootAccessible::Blur(nsIDOMEvent* aEvent) { return NS_OK; }
// ------- nsIDOMFormListener Methods (5) -------------
NS_IMETHODIMP nsRootAccessible::Submit(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::Reset(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::Change(nsIDOMEvent* aEvent)
{
// get change events when the form elements changes its state, checked->not,
// deleted text, new text, change in selection
return HandleEvent(aEvent);
}
NS_IMETHODIMP nsRootAccessible::Select(nsIDOMEvent* aEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::Blur(nsIDOMEvent* aEvent)
{
NS_IMETHODIMP nsRootAccessible::Input(nsIDOMEvent* aEvent)
{
// get Input events when text is entered or deleted in a textarea
//return HandleEvent(aEvent);
return NS_OK;
}
// -------- nsIDOMTextListener -----------------
NS_IMETHODIMP nsRootAccessible::HandleText(nsIDOMEvent* aTextEvent) { return NS_OK; }
// -------- nsIDOMMutationEventListener -----------------
NS_IMETHODIMP nsRootAccessible::SubtreeModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeInserted(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeRemoved(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeRemovedFromDocument(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::NodeInsertedIntoDocument(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::AttrModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }
NS_IMETHODIMP nsRootAccessible::CharacterDataModified(nsIDOMEvent* aMutationEvent) { return NS_OK; }

Просмотреть файл

@ -26,44 +26,73 @@
#include "nsAccessible.h"
#include "nsIAccessibleEventReceiver.h"
#include "nsIAccessibleEventListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMTextListener.h"
#include "nsIDOMMutationListener.h"
#include "nsIDocument.h"
class nsRootAccessible : public nsAccessible,
public nsIAccessibleEventReceiver,
public nsIDOMFocusListener
public nsIDOMFocusListener,
public nsIDOMFormListener,
public nsIDOMTextListener,
public nsIDOMMutationListener
{
NS_DECL_ISUPPORTS_INHERITED
public:
nsRootAccessible(nsIWeakReference* aShell, nsIFrame* aFrame = nsnull);
nsRootAccessible(nsIWeakReference* aShell);
virtual ~nsRootAccessible();
/* attribute wstring accName; */
NS_IMETHOD GetAccName(PRUnichar * *aAccName);
NS_IMETHOD GetAccValue(PRUnichar * *aAccValue);
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
NS_IMETHOD GetAccRole(PRUnichar * *aAccRole);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
// ----- nsIAccessibleEventReceiver ------
// ----- nsIAccessibleEventReceiver -------------------
NS_IMETHOD AddAccessibleEventListener(nsIAccessibleEventListener *aListener);
NS_IMETHOD RemoveAccessibleEventListener(nsIAccessibleEventListener *aListener);
// ----- nsIDOMEventListener --------
// ----- nsIDOMEventListener --------------------------
NS_IMETHOD HandleEvent(nsIDOMEvent* anEvent);
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
// ----- nsIDOMFormListener ---------------------------
NS_IMETHOD Submit(nsIDOMEvent* aEvent);
NS_IMETHOD Reset(nsIDOMEvent* aEvent);
NS_IMETHOD Change(nsIDOMEvent* aEvent);
NS_IMETHOD Select(nsIDOMEvent* aEvent);
NS_IMETHOD Input(nsIDOMEvent* aEvent);
// ----- nsIDOMTextListener ---------------------------
NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
// ----- nsIDOMMutationEventListener ------------------
NS_IMETHOD SubtreeModified(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeInserted(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeRemoved(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeRemovedFromDocument(nsIDOMEvent* aMutationEvent);
NS_IMETHOD NodeInsertedIntoDocument(nsIDOMEvent* aMutationEvent);
NS_IMETHOD AttrModified(nsIDOMEvent* aMutationEvent);
NS_IMETHOD CharacterDataModified(nsIDOMEvent* aMutationEvent);
protected:
virtual void GetBounds(nsRect& aRect);
virtual nsIFrame* GetFrame();
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIDOMNode* aNode, nsIWeakReference* aShell);
// 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;
};

Просмотреть файл

@ -17,7 +17,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Original Author: Eric Vaughan (evaughan@netscape.com)
*
* Contributor(s):
*/
@ -31,12 +31,13 @@
#include "nsIFrame.h"
#include "nsRootAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsMutableAccessible.h"
//#include "nsMutableAccessible.h"
#include "nsLayoutAtoms.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsReadableUtils.h"
#if 0
class nsSelectChildAccessible : public nsAccessible,
public nsIDOMMenuListener
{
@ -49,7 +50,7 @@ public:
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
virtual nsIAccessible* CreateNewNextAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
@ -87,7 +88,7 @@ public:
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccExtState(PRUint32 *_retval);
@ -121,7 +122,7 @@ public:
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccRole(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);
@ -142,7 +143,7 @@ public:
virtual ~nsListChildAccessible() {}
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
virtual void GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList);
virtual nsIAccessible* CreateNewAccessible(nsIAccessible* aAccessible, nsIContent* aContent, nsIWeakReference* aShell);
@ -189,9 +190,9 @@ NS_IMETHODIMP nsSelectAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("combo box"));
*_retval = ROLE_COMBOBOX;
return NS_OK;
}
@ -270,52 +271,44 @@ nsAccessible(aAccessible, aContent, aShell)
NS_IMETHODIMP nsSelectChildAccessible::GetAccValue(PRUnichar **_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
rv = nsAccessible::GetAccRole(&string);
rv = nsAccessible::GetAccRole(&role);
if (NS_FAILED(rv)) {
*_retval = nsnull;
return rv;
}
nsAutoString role(string);
// if its the text in the combo box then
// its value should be its name.
if (role.EqualsIgnoreCase("text")) {
if (role == ROLE_TEXT) {
rv = nsAccessible::GetAccName(_retval);
} else {
rv = nsAccessible::GetAccValue(_retval);
}
delete string;
return rv;
}
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUint32 *_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
rv = nsAccessible::GetAccRole(&string);
if (NS_FAILED(rv)) {
*_retval = nsnull;
return rv;
}
nsAutoString role(string);
rv = nsAccessible::GetAccRole(&role);
if (NS_FAILED(rv))
return rv;
// any text in the combo box is static
if (role.EqualsIgnoreCase("text")) {
if (role == ROLE_STATICTEXT) {
// if it the comboboxes text. Make it static
*_retval = ToNewUnicode(NS_LITERAL_STRING("static text"));
*_retval = role;
} else {
rv = nsAccessible::GetAccRole(_retval);
}
delete string;
return rv;
}
@ -323,19 +316,18 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
{
nsresult rv = NS_OK;
PRUnichar* string = nsnull;
PRUint32 role = 0;
// look at our role
nsAccessible::GetAccRole(&string);
nsAutoString role(string);
nsAccessible::GetAccRole(&role);
// if button then we need to make the name be open or close
if (role.EqualsIgnoreCase("push button"))
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);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
if (!eventReceiver) {
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
@ -362,8 +354,6 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
*_retval = nsnull;
}
delete string;
return rv;
}
@ -371,7 +361,7 @@ NS_IMETHODIMP nsSelectChildAccessible::GetAccName(PRUnichar **_retval)
nsSelectChildAccessible::~nsSelectChildAccessible()
{
if (mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mSelectContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mSelectContent));
if (eventReceiver)
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
}
@ -380,7 +370,9 @@ nsSelectChildAccessible::~nsSelectChildAccessible()
NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
{
mOpen = PR_TRUE;
#ifdef DEBUG
printf("Open\n");
#endif
/* TBD send state change event */
@ -390,7 +382,10 @@ NS_IMETHODIMP nsSelectChildAccessible::Create(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -400,7 +395,9 @@ NS_IMETHODIMP nsSelectChildAccessible::Destroy(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectChildAccessible::Close(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -457,7 +454,7 @@ nsSelectWindowAccessible::nsSelectWindowAccessible(nsIAtom* aPopupAtom, nsIAcces
nsSelectWindowAccessible::~nsSelectWindowAccessible()
{
if (mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
if (eventReceiver)
eventReceiver->RemoveEventListener(NS_LITERAL_STRING("create"), this, PR_TRUE);
}
@ -466,7 +463,9 @@ nsSelectWindowAccessible::~nsSelectWindowAccessible()
NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
{
mOpen = PR_TRUE;
#ifdef DEBUG
printf("Open\n");
#endif
/* TBD send state change event */
@ -476,7 +475,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::Create(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -486,7 +487,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::Destroy(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsSelectWindowAccessible::Close(nsIDOMEvent* aEvent)
{
mOpen = PR_FALSE;
#ifdef DEBUG
printf("Close\n");
#endif
/* TBD send state change event */
@ -500,7 +503,7 @@ NS_IMETHODIMP nsSelectWindowAccessible::GetAccState(PRUint32 *_retval)
if (!mRegistered) {
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(mContent));
if (!eventReceiver) {
*_retval = 0;
return NS_ERROR_NOT_IMPLEMENTED;
@ -538,9 +541,9 @@ NS_IMETHODIMP nsSelectWindowAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectWindowAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("window"));
*_retval = ROLE_WINDOW;
return NS_OK;
}
@ -618,7 +621,7 @@ nsSelectListAccessible::nsSelectListAccessible(nsIAtom* aPopupAtom, nsIAccessibl
void nsSelectListAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* frame = nsnull;
shell->GetPrimaryFrameFor(mContent, &frame);
if (aFrame == frame)
@ -645,9 +648,9 @@ NS_IMETHODIMP nsSelectListAccessible::GetAccName(PRUnichar **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsSelectListAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("list"));
*_retval = ROLE_LIST;
return NS_OK;
}
@ -693,7 +696,7 @@ nsIAccessible* nsListChildAccessible::CreateNewAccessible(nsIAccessible* aAccess
void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aList)
{
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
nsIFrame* frame = nsnull;
shell->GetPrimaryFrameFor(mSelectContent, &frame);
if (aFrame == frame)
@ -702,9 +705,9 @@ void nsListChildAccessible::GetListAtomForFrame(nsIFrame* aFrame, nsIAtom*& aLis
aList = nsnull;
}
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUnichar **_retval)
NS_IMETHODIMP nsListChildAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ToNewUnicode(NS_LITERAL_STRING("list item"));
*_retval = ROLE_LISTITEM;
return NS_OK;
}
@ -715,3 +718,5 @@ NS_IMETHODIMP nsListChildAccessible::GetAccParent(nsIAccessible **_retval)
return NS_OK;
}
#endif

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsCOMPtr.h"
#include "nsIAtom.h"
/*
class nsSelectAccessible : public nsAccessible
{
public:
@ -37,7 +38,7 @@ public:
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccName(PRUnichar **_retval);
NS_IMETHOD GetAccValue(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUnichar **_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
virtual ~nsSelectAccessible() {}
@ -46,6 +47,6 @@ public:
nsCOMPtr<nsIAtom> mPopupAtom;
};
*/
#endif

Просмотреть файл

@ -45,8 +45,10 @@ nsDOMMutationEvent::nsDOMMutationEvent(nsIPresContext* aPresContext,
nsEvent* aEvent)
:nsDOMEvent(aPresContext, aEvent, NS_LITERAL_STRING("MutationEvents"))
{
nsMutationEvent* mutation = (nsMutationEvent*)mEvent;
SetTarget(mutation->mTarget);
if ( aEvent ) {
nsMutationEvent* mutation = (nsMutationEvent*)aEvent;
SetTarget(mutation->mTarget);
}
}
nsDOMMutationEvent::~nsDOMMutationEvent() {

Просмотреть файл

@ -64,6 +64,10 @@
#include "nsIRadioControlFrame.h"
#include "nsIFormManager.h"
#include "nsIDOMMutationEvent.h"
#include "nsIDOMEventReceiver.h"
#include "nsMutationEvent.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
@ -206,6 +210,9 @@ protected:
nsresult GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
nsresult MouseClickForAltText(nsIPresContext* aPresContext);
//Helper method
nsresult FireEventForAccessibility(nsIPresContext* aPresContext,
const nsAReadableString& aEventType);
void SelectAll(nsIPresContext* aPresContext);
PRBool IsImage() const
@ -937,10 +944,10 @@ nsHTMLInputElement::MouseClickForAltText(nsIPresContext* aPresContext)
NS_IMETHODIMP
nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus)
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
if ((aEvent->message == NS_FOCUS_CONTENT && mSkipFocusEvent) ||
@ -1060,6 +1067,9 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
PRBool checked;
GetChecked(&checked);
SetChecked(!checked);
// Fire an event to notify accessibility
nsLocalString checkboxStateChange(NS_LITERAL_STRING("CheckboxStateChange"));
FireEventForAccessibility( aPresContext, checkboxStateChange);
}
break;
@ -1076,6 +1086,11 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
SetChecked(PR_TRUE);
// Fire an event to notify accessibility
if ( selectedRadiobtn != this ) {
nsLocalString radiobuttonStateChange(NS_LITERAL_STRING("RadiobuttonStateChange"));
FireEventForAccessibility( aPresContext, radiobuttonStateChange);
}
}
break;
@ -1655,3 +1670,47 @@ nsHTMLInputElement::GetSelectionRange(PRInt32* aSelectionStart,
return NS_OK;
}
nsresult
nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext,
const nsAReadableString& aEventType)
{
nsCOMPtr<nsIEventListenerManager> listenerManager;
nsresult rv = GetListenerManager(getter_AddRefs(listenerManager));
if ( !listenerManager )
return rv;
// Create the DOM event
nsCOMPtr<nsIDOMEvent> domEvent;
nsLocalString mutationEvent(NS_LITERAL_STRING("MutationEvent"));
rv = listenerManager->CreateEvent(aPresContext,
nsnull,
mutationEvent,
getter_AddRefs(domEvent) );
if ( !domEvent )
return NS_ERROR_FAILURE;
// Initialize the mutation event
nsCOMPtr<nsIDOMMutationEvent> mutEvent(do_QueryInterface(domEvent));
if ( !mutEvent )
return NS_ERROR_FAILURE;
nsAutoString empty;
mutEvent->InitMutationEvent( aEventType, PR_TRUE, PR_TRUE, nsnull, empty, empty, empty);
// Set the target of the event to this nsHTMLInputElement, which should be checkbox content??
nsCOMPtr<nsIPrivateDOMEvent> privEvent(do_QueryInterface(domEvent));
if ( ! privEvent )
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(NS_STATIC_CAST(nsIDOMHTMLInputElement *, this)));
if ( ! targ )
return NS_ERROR_FAILURE;
privEvent->SetTarget(targ);
// Dispatch the event
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(listenerManager));
if ( ! eventReceiver )
return NS_ERROR_FAILURE;
eventReceiver->DispatchEvent(domEvent);
return NS_OK;
}

Просмотреть файл

@ -63,7 +63,6 @@
#include "nsListControlFrame.h"
#include "nsIElementFactory.h"
#include "nsContentCID.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsISupportsArray.h"
#include "nsINameSpaceManager.h"
#include "nsContentCID.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsINameSpaceManager.h"
#include "nsIPresState.h"
#include "nsCSSRendering.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsCSSRendering.h"
#include "nsIPresState.h"
#include "nsINameSpaceManager.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsFormControlFrame.h"
#include "nsIFrameManager.h"
#include "nsINameSpaceManager.h"
#include "nsIAccessibilityService.h"
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
@ -161,7 +162,17 @@ nsHTMLButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsStyleConsts.h"
#include "nsFormFrame.h"
#include "nsFormControlFrame.h"
#include "nsIAccessibilityService.h"
//Enumeration of possible mouse states used to detect mouse clicks
/*enum nsMouseState {
@ -198,7 +199,18 @@ nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
}
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
}

Просмотреть файл

@ -270,7 +270,17 @@ nsresult nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)this;
return NS_OK;
}
} /* else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTMLFrameAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
} */
return NS_NOINTERFACE;
}

Просмотреть файл

@ -65,6 +65,10 @@
#include "nsINameSpaceManager.h"
#include "nsIPrintContext.h"
// For Accessibility
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#ifdef INCLUDE_XUL
#include "nsIDOMXULElement.h"
#include "nsIBoxObject.h"
@ -122,6 +126,9 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
#endif
// nsISupports
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD Paint(nsIPresContext* aPresContext,
@ -155,6 +162,7 @@ protected:
nsHTMLReflowMetrics& aDesiredSize);
virtual PRIntn GetSkipSides() const;
PRBool mIsInline;
nsCOMPtr<nsIPresContext> mPresContext;
};
/*******************************************************************************
@ -230,6 +238,33 @@ nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame()
//printf("nsHTMLFrameOuterFrame destructor %X \n", this);
}
//--------------------------------------------------------------
// Frames are not refcounted, no need to AddRef
NS_IMETHODIMP
nsHTMLFrameOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIAccessible* acc = nsnull;
accService->CreateHTMLIFrameAccessible(node, mPresContext, &acc);
NS_IF_ADDREF(acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
return nsHTMLFrameOuterFrameSuper::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
nsIContent* aContent,
@ -237,6 +272,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
// determine if we are a <frame> or <iframe>
if (aContent) {
nsCOMPtr<nsIDOMHTMLFrameElement> frameElem = do_QueryInterface(aContent);

Просмотреть файл

@ -62,7 +62,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#include "nsImageMapUtils.h"
#include "nsIFrameManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -146,16 +145,13 @@ nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Image").get());
acc->SetRole(NS_LITERAL_STRING("graphic").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -69,7 +69,6 @@
#include "nsIAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsIAccessibilityService.h"
//#include "nsIMutableAccessible.h"
#ifdef IBMBIDI
#include "nsBidiFrames.h"
@ -780,37 +779,7 @@ NS_IMETHODIMP nsTextFrame::QueryInterface(const nsIID& aIID,
nsIAccessible* acc = nsnull;
accService->CreateHTMLTextAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtrResult = acc;
/*
nsIMutableAccessible* acc = nsnull;
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
accService->CreateMutableAccessible(mContent,&acc);
if (node)
acc->SetNameAsNodeValue();
else {
// see if it is text content
nsCOMPtr<nsITextContent> text = do_QueryInterface(mContent);
if (text) {
const nsTextFragment* frag = nsnull;
text->GetText(&frag);
if (frag->Is2b()) {
acc->SetName(frag->Get2b());
} else {
nsAutoString name;
name.AssignWithConversion(frag->Get1b());
acc->SetName(name.get());
}
}
}
acc->SetRole(NS_LITERAL_STRING("text").get());
acc->SetIsLeaf(PR_TRUE);
*aInstancePtrResult = acc;
*/
return NS_OK;
return NS_OK;
}
return NS_ERROR_FAILURE;
#ifdef IBMBIDI

Просмотреть файл

@ -270,7 +270,17 @@ nsresult nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)this;
return NS_OK;
}
} /* else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTMLFrameAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
} */
return NS_NOINTERFACE;
}

Просмотреть файл

@ -62,7 +62,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#include "nsImageMapUtils.h"
#include "nsIFrameManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -146,16 +145,13 @@ nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Image").get());
acc->SetRole(NS_LITERAL_STRING("graphic").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -69,7 +69,6 @@
#include "nsIAccessible.h"
#include "nsINameSpaceManager.h"
#include "nsIAccessibilityService.h"
//#include "nsIMutableAccessible.h"
#ifdef IBMBIDI
#include "nsBidiFrames.h"
@ -780,37 +779,7 @@ NS_IMETHODIMP nsTextFrame::QueryInterface(const nsIID& aIID,
nsIAccessible* acc = nsnull;
accService->CreateHTMLTextAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtrResult = acc;
/*
nsIMutableAccessible* acc = nsnull;
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
accService->CreateMutableAccessible(mContent,&acc);
if (node)
acc->SetNameAsNodeValue();
else {
// see if it is text content
nsCOMPtr<nsITextContent> text = do_QueryInterface(mContent);
if (text) {
const nsTextFragment* frag = nsnull;
text->GetText(&frag);
if (frag->Is2b()) {
acc->SetName(frag->Get2b());
} else {
nsAutoString name;
name.AssignWithConversion(frag->Get1b());
acc->SetName(name.get());
}
}
}
acc->SetRole(NS_LITERAL_STRING("text").get());
acc->SetIsLeaf(PR_TRUE);
*aInstancePtrResult = acc;
*/
return NS_OK;
return NS_OK;
}
return NS_ERROR_FAILURE;
#ifdef IBMBIDI

Просмотреть файл

@ -65,6 +65,10 @@
#include "nsINameSpaceManager.h"
#include "nsIPrintContext.h"
// For Accessibility
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#ifdef INCLUDE_XUL
#include "nsIDOMXULElement.h"
#include "nsIBoxObject.h"
@ -122,6 +126,9 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
#endif
// nsISupports
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD Paint(nsIPresContext* aPresContext,
@ -155,6 +162,7 @@ protected:
nsHTMLReflowMetrics& aDesiredSize);
virtual PRIntn GetSkipSides() const;
PRBool mIsInline;
nsCOMPtr<nsIPresContext> mPresContext;
};
/*******************************************************************************
@ -230,6 +238,33 @@ nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame()
//printf("nsHTMLFrameOuterFrame destructor %X \n", this);
}
//--------------------------------------------------------------
// Frames are not refcounted, no need to AddRef
NS_IMETHODIMP
nsHTMLFrameOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIAccessible* acc = nsnull;
accService->CreateHTMLIFrameAccessible(node, mPresContext, &acc);
NS_IF_ADDREF(acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
return nsHTMLFrameOuterFrameSuper::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
nsIContent* aContent,
@ -237,6 +272,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
// determine if we are a <frame> or <iframe>
if (aContent) {
nsCOMPtr<nsIDOMHTMLFrameElement> frameElem = do_QueryInterface(aContent);

Просмотреть файл

@ -63,7 +63,6 @@
#include "nsListControlFrame.h"
#include "nsIElementFactory.h"
#include "nsContentCID.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsISupportsArray.h"
#include "nsINameSpaceManager.h"
#include "nsContentCID.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsINameSpaceManager.h"
#include "nsIPresState.h"
#include "nsCSSRendering.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsCSSRendering.h"
#include "nsIPresState.h"
#include "nsINameSpaceManager.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"

Просмотреть файл

@ -102,7 +102,6 @@
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -412,16 +411,12 @@ nsGfxTextControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Text Field").get());
acc->SetRole(NS_LITERAL_STRING("text").get());
acc->SetIsLeaf(PR_TRUE);
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLTextFieldAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);

Просмотреть файл

@ -91,7 +91,6 @@
#include "nsIScriptGlobalObject.h" //needed for notify selection changed to update the menus ect.
#include "nsIDOMWindowInternal.h" //needed for notify selection changed to update the menus ect.
#include "nsITextContent.h" //needed to create initial text control content
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -1282,16 +1281,12 @@ nsGfxTextControlFrame2::QueryInterface(const nsIID& aIID, void** aInstancePtr)
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Text Field").get());
acc->SetRole(NS_LITERAL_STRING("text").get());
acc->SetIsLeaf(PR_TRUE);
nsIAccessible* acc = nsnull;
accService->CreateHTMLTextFieldAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
return nsBoxFrame::QueryInterface(aIID, aInstancePtr);
}

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsFormControlFrame.h"
#include "nsIFrameManager.h"
#include "nsINameSpaceManager.h"
#include "nsIAccessibilityService.h"
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
@ -161,7 +162,17 @@ nsHTMLButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsStyleConsts.h"
#include "nsFormFrame.h"
#include "nsFormControlFrame.h"
#include "nsIAccessibilityService.h"
//Enumeration of possible mouse states used to detect mouse clicks
/*enum nsMouseState {
@ -198,7 +199,18 @@ nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
}
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
nsresult rv;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsIAccessible* acc = nsnull;
accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
}

Просмотреть файл

@ -47,7 +47,6 @@
#include "nsCOMPtr.h"
#include "nsIHTMLTableCellElement.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -1179,14 +1178,10 @@ nsresult nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
nsAutoString name;
acc->SetName(NS_LITERAL_STRING("Cell").get());
acc->SetRole(NS_LITERAL_STRING("cell").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLTableCellAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
} else {

Просмотреть файл

@ -37,7 +37,6 @@
#include "nsLayoutAtoms.h"
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -128,13 +127,10 @@ nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePt
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Table").get());
acc->SetRole(NS_LITERAL_STRING("table").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLTableAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
} else {

Просмотреть файл

@ -6,18 +6,18 @@
<IMG SRC="mapimg87.gif" USEMAP="#firstmap" BORDER=0 ALT="This is a tooltip">
<MAP NAME=firstmap>
<AREA SHAPE=rect ID="upper_left" COORDS="12,15,82,86" HREF=up_left.htm>
<AREA SHAPE=rect ID="middle_middle" COORDS="122,103,191,172" HREF=mid_mid.htm>
<AREA SHAPE=rect ID="lower_middle" COORDS="121,192,192,261" HREF=low_mid.htm>
<AREA SHAPE=circle ID="upper_middle" COORDS="157,52,33" HREF=up_mid.htm>
<AREA SHAPE=circle ID="middle_left" COORDS="47,135,33" HREF=mid_left.htm>
<AREA SHAPE=circle ID="lower_right" COORDS="259,227,34" HREF=low_rt.htm>
<AREA SHAPE=poly ID="lower_left" COORDS="57,198,23,221,23,241,58,265,93,241,93,221" HREF=low_left.htm>
<AREA SHAPE=poly ID="middle_right" COORDS="264,106,232,127,230,148,264,171,298,148,298,126" HREF=mid_rt.htm>
<AREA SHAPE=poly ID="upper_right" COORDS="261,18,226,41,226,59,263,85,295,59,296,38" HREF=up_rt.htm>
<AREA SHAPE=poly ID="left_brown" COORDS="89,8,89,156,5,193,9,223,63,190,97,214,97,246,62,274,109,275,109,98,140,97" HREF = left_brn.htm>
<AREA SHAPE=poly ID="top_brown" COORDS="94,4,105,22,166,11,164,5" HREF=top_brn.htm>
<AREA SHAPE=poly ID="right_brown" COORDS="168,5,169,11,194,33,194,257,265,283,265,270,220,247,220,200,255,179,227,158,227,123,265,98,221,68,220,36,269,6" HREF=rt_brn.htm>
<AREA SHAPE=rect ID="upper_left" COORDS="12,15,82,86" HREF=up_left.htm >
<AREA SHAPE=rect ID="middle_middle" COORDS="122,103,191,172" HREF=mid_mid.htm >
<AREA SHAPE=rect ID="lower_middle" COORDS="121,192,192,261" HREF=low_mid.htm >
<AREA SHAPE=circle ID="upper_middle" COORDS="157,52,33" HREF=up_mid.htm >
<AREA SHAPE=circle ID="middle_left" COORDS="47,135,33" HREF=mid_left.htm >
<AREA SHAPE=circle ID="lower_right" COORDS="259,227,34" HREF=low_rt.htm >
<AREA SHAPE=poly ID="lower_left" COORDS="57,198,23,221,23,241,58,265,93,241,93,221" HREF=low_left.htm >
<AREA SHAPE=poly ID="middle_right" COORDS="264,106,232,127,230,148,264,171,298,148,298,126" HREF=mid_rt.htm >
<AREA SHAPE=poly ID="upper_right" COORDS="261,18,226,41,226,59,263,85,295,59,296,38" HREF=up_rt.htm >
<AREA SHAPE=poly ID="left_brown" COORDS="89,8,89,156,5,193,9,223,63,190,97,214,97,246,62,274,109,275,109,98,140,97" HREF = left_brn.htm >
<AREA SHAPE=poly ID="top_brown" COORDS="94,4,105,22,166,11,164,5" HREF=top_brn.htm >
<AREA SHAPE=poly ID="right_brown" COORDS="168,5,169,11,194,33,194,257,265,283,265,270,220,247,220,200,255,179,227,158,227,123,265,98,221,68,220,36,269,6" HREF=rt_brn.htm >
<AREA SHAPE=default HREF="default.htm">
</MAP>
</P>

Просмотреть файл

@ -47,7 +47,6 @@
#include "nsCOMPtr.h"
#include "nsIHTMLTableCellElement.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -1179,14 +1178,10 @@ nsresult nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
nsAutoString name;
acc->SetName(NS_LITERAL_STRING("Cell").get());
acc->SetRole(NS_LITERAL_STRING("cell").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLTableCellAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
} else {

Просмотреть файл

@ -37,7 +37,6 @@
#include "nsLayoutAtoms.h"
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
#include "nsIMutableAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
@ -128,13 +127,10 @@ nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePt
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
if (accService) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent);
nsIMutableAccessible* acc = nsnull;
accService->CreateMutableAccessible(node,&acc);
acc->SetName(NS_LITERAL_STRING("Table").get());
acc->SetRole(NS_LITERAL_STRING("table").get());
*aInstancePtr = acc;
return NS_OK;
nsIAccessible* acc = nsnull;
accService->CreateHTMLTableAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
*aInstancePtr = acc;
return NS_OK;
}
return NS_ERROR_FAILURE;
} else {

Просмотреть файл

@ -98,14 +98,6 @@
</content>
</binding>
<binding id="scrollbarbutton">
<content>
<xul:box class="scrollbarbutton-box" flex="1">
<xul:image class="scrollbarbutton-icon" inherits="src"/>
</xul:box>
</content>
</binding>
<binding id="slider">
<content>
<xul:button class="slider-button"/>

Просмотреть файл

@ -66,7 +66,7 @@
</content>
</binding>
<binding id="thumb" extends="xul:button">
<binding id="thumb" extends="chrome://global/content/scrollbarBindings.xml#thumb">
<content>
<xul:box class="thumb-box" autostretch="never" orient="vertical" flex="1">
<xul:spring class="thumb-spring" flex="1"/>
@ -84,12 +84,7 @@
</content>
</binding>
<binding id="scrollbarbutton">
<content>
<xul:box class="scrollbarbutton-box" flex="1">
<xul:image class="scrollbarbutton-icon" inherits="src"/>
</xul:box>
</content>
<binding id="scrollbarbutton" extends="chrome://global/content/scrollbarBindings.xml#scrollbarbutton">
</binding>
<binding id="slider">

Просмотреть файл

@ -29,6 +29,10 @@
#include "nsXPIDLString.h"
#include "nsIAccessibleEventReceiver.h"
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
//#define DEBUG_LEAKS
#ifdef DEBUG_LEAKS
@ -43,22 +47,21 @@ EXTERN_C GUID CDECL CLSID_Accessible =
* Class Accessible
*/
#ifdef IS_ACCESSIBLE
// accessibility only on Windows2000 and Windows98
#ifdef OBJID_WINDOW
//-----------------------------------------------------
// construction
//-----------------------------------------------------
Accessible::Accessible(nsIAccessible* aAcc, HWND aWnd)
{
mAccessible = aAcc;
mWnd = aWnd;
m_cRef = 0;
mAccessible = aAcc; // The nsIAccessible we're proxying from
mWnd = aWnd; // The window handle, for NotifyWinEvent, or getting the accessible parent thru the window parent
m_cRef = 0; // for reference counting, so we know when to delete ourselves
// mCachedIndex and mCachedChild allows fast order(N) indexing of children when moving forward through the
// list 1 at a time,rather than going back to the first child each time, it can just get the next sibling
mCachedIndex = 0;
mCachedChild = NULL;
mCachedChild = NULL;
#ifdef DEBUG_LEAKS
printf("Accessibles=%d\n", ++gAccessibles);
@ -84,33 +87,33 @@ Accessible::~Accessible()
//-----------------------------------------------------
STDMETHODIMP Accessible::QueryInterface(REFIID riid, void** ppv)
{
*ppv=NULL;
*ppv=NULL;
if ( (IID_IUnknown == riid) || (IID_IAccessible == riid) || (IID_IDispatch == riid)) {
*ppv = this;
AddRef();
return S_OK;
}
if ( (IID_IUnknown == riid) || (IID_IAccessible == riid) || (IID_IDispatch == riid)) {
*ppv = this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
return E_NOINTERFACE;
}
//-----------------------------------------------------
STDMETHODIMP_(ULONG) Accessible::AddRef()
{
return ++m_cRef;
return ++m_cRef;
}
//-----------------------------------------------------
STDMETHODIMP_(ULONG) Accessible::Release()
{
if (0 != --m_cRef)
return m_cRef;
if (0 != --m_cRef)
return m_cRef;
delete this;
delete this;
return 0;
return 0;
}
//-----------------------------------------------------
@ -119,7 +122,7 @@ STDMETHODIMP_(ULONG) Accessible::Release()
STDMETHODIMP Accessible::get_accParent( IDispatch __RPC_FAR *__RPC_FAR *ppdispParent)
{
nsCOMPtr<nsIAccessible> parent = nsnull;
nsCOMPtr<nsIAccessible> parent(nsnull);
mAccessible->GetAccParent(getter_AddRefs(parent));
if (parent) {
@ -152,7 +155,6 @@ STDMETHODIMP Accessible::get_accChildCount( long __RPC_FAR *pcountChildren)
{
PRInt32 count = 0;
mAccessible->GetAccChildCount(&count);
//printf("Count=%d\n",count);
*pcountChildren = count;
return S_OK;
}
@ -255,56 +257,13 @@ STDMETHODIMP Accessible::get_accRole(
if (!a)
return S_FALSE;
nsXPIDLString idlrole;
nsresult rv = a->GetAccRole(getter_Copies(idlrole));
PRUint32 role = 0;
nsresult rv = a->GetAccRole(&role);
if (NS_FAILED(rv))
return S_FALSE;
nsAutoString role(idlrole);
if (role.EqualsIgnoreCase("text"))
pvarRole->lVal = ROLE_SYSTEM_TEXT;
else if (role.EqualsIgnoreCase("static text"))
pvarRole->lVal = ROLE_SYSTEM_STATICTEXT;
else if (role.EqualsIgnoreCase("graphic"))
pvarRole->lVal = ROLE_SYSTEM_GRAPHIC;
else if (role.EqualsIgnoreCase("table"))
pvarRole->lVal = ROLE_SYSTEM_TABLE;
else if (role.EqualsIgnoreCase("cell"))
pvarRole->lVal = ROLE_SYSTEM_CELL;
else if (role.EqualsIgnoreCase("row"))
pvarRole->lVal = ROLE_SYSTEM_ROW;
else if (role.EqualsIgnoreCase("text"))
pvarRole->lVal = ROLE_SYSTEM_TEXT;
else if (role.EqualsIgnoreCase("combo box"))
pvarRole->lVal = ROLE_SYSTEM_COMBOBOX;
else if (role.EqualsIgnoreCase("link"))
pvarRole->lVal = ROLE_SYSTEM_LINK;
else if (role.EqualsIgnoreCase("list"))
pvarRole->lVal = ROLE_SYSTEM_LIST;
else if (role.EqualsIgnoreCase("list item"))
pvarRole->lVal = ROLE_SYSTEM_LISTITEM;
else if (role.EqualsIgnoreCase("push button"))
pvarRole->lVal = ROLE_SYSTEM_PUSHBUTTON;
else if (role.EqualsIgnoreCase("radio button"))
pvarRole->lVal = ROLE_SYSTEM_PUSHBUTTON;
else if (role.EqualsIgnoreCase("indicator"))
pvarRole->lVal = ROLE_SYSTEM_INDICATOR;
else if (role.EqualsIgnoreCase("check box"))
pvarRole->lVal = ROLE_SYSTEM_CHECKBUTTON;
else if (role.EqualsIgnoreCase("scrollbar"))
pvarRole->lVal = ROLE_SYSTEM_SCROLLBAR;
else if (role.EqualsIgnoreCase("slider"))
pvarRole->lVal = ROLE_SYSTEM_SLIDER;
else if (role.EqualsIgnoreCase("client"))
pvarRole->lVal = ROLE_SYSTEM_CLIENT;
else if (role.EqualsIgnoreCase("window"))
pvarRole->lVal = ROLE_SYSTEM_WINDOW;
else
pvarRole->lVal = ROLE_SYSTEM_ALERT;
return S_FALSE;
pvarRole->lVal = role;
return S_OK;
}
STDMETHODIMP Accessible::get_accState(
@ -330,10 +289,6 @@ STDMETHODIMP Accessible::get_accState(
return S_OK;
}
PRBool Accessible::InState(const nsString& aStates, const char* aState)
{
return (aStates.Find(aState) == 0);
}
STDMETHODIMP Accessible::get_accHelp(
/* [optional][in] */ VARIANT varChild,
@ -360,9 +315,19 @@ STDMETHODIMP Accessible::get_accKeyboardShortcut(
STDMETHODIMP Accessible::get_accFocus(
/* [retval][out] */ VARIANT __RPC_FAR *pvarChild)
{
// Return the current nsIAccessible that has focus
VariantInit(pvarChild);
nsCOMPtr<nsIAccessible> focusedAccessible;
if (NS_SUCCEEDED(mAccessible->GetAccFocused(getter_AddRefs(focusedAccessible)))) {
pvarChild->vt = VT_DISPATCH;
pvarChild->pdispVal = new Accessible(focusedAccessible, mWnd);
pvarChild->pdispVal->AddRef();
return S_OK;
}
pvarChild->vt = VT_EMPTY;
return S_OK;
return S_FALSE;
}
STDMETHODIMP Accessible::get_accSelection(
@ -381,7 +346,7 @@ STDMETHODIMP Accessible::get_accDefaultAction(
GetNSAccessibleFor(varChild,a);
if (a) {
nsXPIDLString name;
nsresult rv = a->GetAccDefaultAction(getter_Copies(name));
nsresult rv = a->GetAccActionName(0,getter_Copies(name));
if (NS_FAILED(rv))
return S_FALSE;
@ -421,21 +386,25 @@ STDMETHODIMP Accessible::accLocation(
/* [out] */ long __RPC_FAR *pcyHeight,
/* [optional][in] */ VARIANT varChild)
{
PRInt32 x,y,w,h;
mAccessible->AccGetBounds(&x,&y,&w,&h);
nsCOMPtr<nsIAccessible> a;
GetNSAccessibleFor(varChild,a);
POINT cpos;
cpos.x = x;
cpos.y = y;
if (a) {
PRInt32 x,y,w,h;
a->AccGetBounds(&x,&y,&w,&h);
::ClientToScreen(mWnd, &cpos);
POINT cpos;
cpos.x = x;
cpos.y = y;
*pxLeft = cpos.x;
*pyTop = cpos.y;
*pcxWidth = w;
*pcyHeight = h;
*pxLeft = x;
*pyTop = y;
*pcxWidth = w;
*pcyHeight = h;
return S_OK;
}
return S_OK;
return S_FALSE;
}
STDMETHODIMP Accessible::accNavigate(
@ -496,13 +465,8 @@ STDMETHODIMP Accessible::accHitTest(
// convert to window coords
nsCOMPtr<nsIAccessible> a;
POINT cpos;
cpos.x = xLeft;
cpos.y = yTop;
::ScreenToClient(mWnd, &cpos);
xLeft = cpos.x;
yTop = cpos.y;
xLeft = xLeft;
yTop = yTop;
mAccessible->AccGetAt(xLeft,yTop, getter_AddRefs(a));
@ -530,10 +494,7 @@ STDMETHODIMP Accessible::accHitTest(
STDMETHODIMP Accessible::accDoDefaultAction(
/* [optional][in] */ VARIANT varChild)
{
if (NS_SUCCEEDED(mAccessible->AccDoDefaultAction()))
return S_OK;
else
return DISP_E_MEMBERNOTFOUND;
return NS_SUCCEEDED(mAccessible->AccDoAction(0))? NS_OK: DISP_E_MEMBERNOTFOUND;
}
STDMETHODIMP Accessible::put_accName(
@ -550,31 +511,35 @@ STDMETHODIMP Accessible::put_accValue(
return S_FALSE;
}
// For IDispatch support
STDMETHODIMP
Accessible::GetTypeInfoCount(UINT *p)
{
*p = 0;
return E_NOTIMPL;
*p = 0;
return E_NOTIMPL;
}
// For IDispatch support
STDMETHODIMP Accessible::GetTypeInfo(UINT i, LCID lcid, ITypeInfo **ppti)
{
*ppti = 0;
return E_NOTIMPL;
*ppti = 0;
return E_NOTIMPL;
}
// For IDispatch support
STDMETHODIMP
Accessible::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
return E_NOTIMPL;
return E_NOTIMPL;
}
// For IDispatch support
STDMETHODIMP Accessible::Invoke(DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
return E_NOTIMPL;
return E_NOTIMPL;
}
//------- Helper methods ---------
@ -642,14 +607,14 @@ RootAccessible::RootAccessible(nsIAccessible* aAcc, HWND aWnd):Accessible(aAcc,a
mNextId = -1;
mNextPos = 0;
nsCOMPtr<nsIAccessibleEventReceiver> r = do_QueryInterface(mAccessible);
nsCOMPtr<nsIAccessibleEventReceiver> r(do_QueryInterface(mAccessible));
if (r)
r->AddAccessibleEventListener(this);
}
RootAccessible::~RootAccessible()
{
nsCOMPtr<nsIAccessibleEventReceiver> r = do_QueryInterface(mAccessible);
nsCOMPtr<nsIAccessibleEventReceiver> r(do_QueryInterface(mAccessible));
if (r)
r->RemoveAccessibleEventListener(this);
@ -677,8 +642,10 @@ void RootAccessible::GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible
NS_IMETHODIMP RootAccessible::HandleEvent(PRUint32 aEvent, nsIAccessible* aAccessible)
{
#ifdef DEBUG
// print focus event!!
printf("Focus Changed!!!\n");
#endif
// get the id for the accessible
PRInt32 id = GetIdFor(aAccessible);
@ -701,12 +668,11 @@ PRInt32 RootAccessible::GetIdFor(nsIAccessible* aAccessible)
mList[mNextPos].mAccessible = aAccessible;
mNextId--;
mNextPos++;
if (++mNextPos >= MAX_LIST_SIZE)
mNextPos = 0;
if (mListCount < MAX_LIST_SIZE)
mListCount++;
return mNextId+1;
}
#endif
#endif

Просмотреть файл

@ -20,39 +20,41 @@
* Contributor(s):
*/
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
#ifndef _Accessible_H_
#define _Accessible_H_
#include "OLEIDL.H"
#include "OLEACC.H"
#include "winable.h"
#ifndef WM_GETOBJECT
#define WM_GETOBJECT 0x03d
#endif
#include "nsCOMPtr.h"
#include "nsIAccessible.h"
#include "nsIAccessibleEventListener.h"
#include "nsString.h"
#define IS_ACCESSIBLE
class Accessible : public IAccessible
{
#ifdef IS_ACCESSIBLE
public: // construction, destruction
Accessible(nsIAccessible*, HWND aWin = 0);
virtual ~Accessible();
// accessibility only on Windows2000 and Windows98
#ifdef OBJID_WINDOW
public: // construction, destruction
Accessible(nsIAccessible*, HWND aWin = 0);
virtual ~Accessible();
public: // IUnknown methods - see iunknown.h for documentation
STDMETHODIMP_(ULONG) AddRef ();
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) Release ();
public: // IUnknown methods - see iunknown.h for documentation
STDMETHODIMP_(ULONG) AddRef ();
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) Release ();
// Return the registered OLE class ID of this object's CfDataObj.
CLSID GetClassID() const;
CLSID GetClassID() const;
public:
public:
virtual /* [id][propget][hidden] */ HRESULT STDMETHODCALLTYPE get_accParent(
/* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispParent);
@ -140,8 +142,8 @@ class Accessible : public IAccessible
/* [in] */ BSTR szValue);
STDMETHODIMP GetTypeInfoCount(UINT *p);
STDMETHODIMP GetTypeInfo(UINT i, LCID lcid, ITypeInfo **ppti);
STDMETHODIMP GetTypeInfoCount(UINT *p);
STDMETHODIMP GetTypeInfo(UINT i, LCID lcid, ITypeInfo **ppti);
STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId);
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
@ -150,8 +152,8 @@ class Accessible : public IAccessible
static ULONG g_cRef; // the cum reference count of all instances
ULONG m_cRef; // the reference count
static ULONG g_cRef; // the cum reference count of all instances
ULONG m_cRef; // the reference count
nsCOMPtr<nsIAccessible> mAccessible;
nsCOMPtr<nsIAccessible> mCachedChild;
HWND mWnd;
@ -163,8 +165,6 @@ class Accessible : public IAccessible
PRBool InState(const nsString& aStates, const char* aState);
STDMETHODIMP GetAttribute(const char* aName, VARIANT varChild, BSTR __RPC_FAR *aString);
#endif
#endif
};
class nsAccessibleEventMap
@ -179,11 +179,6 @@ public:
class RootAccessible: public Accessible,
public nsIAccessibleEventListener
{
#ifdef IS_ACCESSIBLE
// accessibility only on Windows2000 and Windows98
#ifdef OBJID_WINDOW
public:
RootAccessible(nsIAccessible*, HWND aWin = 0);
virtual ~RootAccessible();
@ -204,10 +199,6 @@ private:
PRInt32 mNextId;
PRInt32 mNextPos;
#endif
#endif
};
#endif
#endif

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsTransform2D.h"
#include "nsStringUtil.h"
#include <windows.h>
//#include <winuser.h>
#include <zmouse.h>
//#include "sysmets.h"
@ -53,11 +54,8 @@
#include "prtime.h"
#include "nsIRenderingContextWin.h"
// accessibility only on Windows2000 and Windows98
#if(WINVER >= 0x0400)
#include "nsIAccessible.h"
#include "Accessible.h"
#endif
#include <imm.h>
#ifdef MOZ_AIMM
@ -3367,9 +3365,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
nsServiceManager::ReleaseService(kCClipboardCID, clipboard);
} break;
#ifdef IS_ACCESSIBLE
// accessibility only on Windows2000 and Windows98
#ifdef WM_GETOBJECT
case WM_GETOBJECT:
{
if (lParam == OBJID_CLIENT) {
@ -3391,8 +3386,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
}
}
break;
#endif
#endif
default: {
// Handle both flavors of mouse wheel events.

Просмотреть файл

@ -5,8 +5,140 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="thumb" extends="xul:box">
<content>
<xul:spring flex="1"/>
<xul:image inherits="src"/>
<xul:spring flex="1"/>
</content>
<implementation implements="nsIAccessible">
<method name="getAccDescription">
<body>
<![CDATA[
return 'This is a scrollbars thumb';
]]>
</body>
</method>
<method name="getAccValue">
<body>
<![CDATA[
return this.getAttribute('curpos');
]]>
</body>
</method>
<method name="getAccName">
<body>
<![CDATA[
return 'Thumb';
]]>
</body>
</method>
<method name="getAccRole">
<body>
<![CDATA[
return 'indicator';
]]>
</body>
</method>
<method name="getAccChildCount">
<body>
<![CDATA[
return 0;
]]>
</body>
</method>
<method name="getAccFirstChild">
<body>
<![CDATA[
return null;
]]>
</body>
</method>
<method name="getAccLastChild">
<body>
<![CDATA[
return null;
]]>
</body>
</method>
</implementation>
</binding>
<binding id="scrollbarbutton">
<content>
<xul:box class="scrollbarbutton-box" flex="1">
<xul:image class="scrollbarbutton-icon" inherits="src"/>
</xul:box>
</content>
<implementation implements="nsIAccessible">
<method name="getAccDefaultAction">
<body>
<![CDATA[
return 'Click';
]]>
</body>
</method>
<method name="getAccDescription">
<body>
<![CDATA[
return 'Adjusts scrollbar';
]]>
</body>
</method>
<method name="getAccName">
<body>
<![CDATA[
return 'scrollbar button';
]]>
</body>
</method>
<method name="getAccRole">
<body>
<![CDATA[
return 'push button';
]]>
</body>
</method>
<method name="accDoDefaultAction">
<body>
<![CDATA[
this.click();
dump("We just clicked!!!\n");
]]>
</body>
</method>
<method name="getAccChildCount">
<body>
<![CDATA[
return 0;
]]>
</body>
</method>
<method name="getAccFirstChild">
<body>
<![CDATA[
return null;
]]>
</body>
</method>
<method name="getAccLastChild">
<body>
<![CDATA[
return null;
]]>
</body>
</method>
</implementation>
</binding>
<binding id="scrollbar">
<implementation>
<implementation implements="nsIAccessible">
<method name="initScrollbar">
<body>
<![CDATA[
@ -66,12 +198,42 @@
<constructor>
this.initScrollbar();
</constructor>
<method name="getAccDescription">
<body>
<![CDATA[
return 'This is a scrollbar';
]]>
</body>
</method>
<method name="getAccValue">
<body>
<![CDATA[
return this.getAttribute('curpos');
]]>
</body>
</method>
<method name="getAccName">
<body>
<![CDATA[
return 'Scroll Bar';
]]>
</body>
</method>
<method name="getAccRole">
<body>
<![CDATA[
return 'scrollbar';
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="contextmenu" action="event.preventDefault();"/>
</handlers>
</binding>
</bindings>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше