--- a/Makefile.in
+++ b/Makefile.in
@@ -129,48 +129,78 @@ ifdef MOZ_PROFILE
echo splitting symbols out of binaries
/bin/find $(DIST) -name "*.dll" -exec splitsym {} \;
/bin/find $(DIST) -name "*.exe" -exec splitsym {} \;
/bin/find $(DIST) -name "*.EXE" -exec splitsym {} \;
mkdir -p $(DIST)/$(BUILDID)
/bin/find $(DIST) -name "*.dbg" -exec mv {} $(DIST)/$(BUILDID) \;
endif # MOZ_PROFILE
endif # MOZILLA_OFFICIAL
+endif # WINNT
+
+ifeq ($(OS_ARCH),WINNT)
+SYM_FIND_CMD := /bin/find . -path dist -prune -o -name "*.exe" \
+ -o -name "*.dll" -o -name "*.EXE" | sed "s/\.[^\.]*$$/\.pdb/"
+# we want to copy PDB files on Windows
+MAKE_SYM_STORE_ARGS := -c
+DUMP_SYMS_BIN := $(topsrcdir)/toolkit/airbag/tools/win32/dump_syms.exe
+endif
+ifeq ($(OS_ARCH),Darwin)
+# need to pass arch flags for universal builds
+ifdef UNIVERSAL_BINARY
+MAKE_SYM_STORE_ARGS := -a "ppc i386"
+SYM_DIST := $(DIST)/universal
+else
+MAKE_SYM_STORE_ARGS := -a $(OS_TEST)
+SYM_DIST := $(DIST)
+endif
+# |file| is stupid on universal binaries, it produces one line of output
+# for the file, and one line of output for each architecture contained within.
+SYM_FIND_CMD := find -L $(SYM_DIST) -type f -a -perm -100 -o -name "*.dylib" \
+ | xargs file -L | grep "Mach-O" | grep -v "for architecture" | cut -f1 -d':'
+DUMP_SYMS_BIN := $(DIST)/host/bin/dump_syms
+endif
+ifeq ($(OS_ARCH),Linux)
+MAKE_SYM_STORE_ARGS :=
+SYM_FIND_CMD := find -L $(DIST)/bin -type f -a -perm -100 -o -name "*.so" \
+ | xargs file -L | grep "ELF" | cut -f1 -d':'
+DUMP_SYMS_BIN := $(DIST)/host/bin/dump_syms
+endif
+
+ifdef MOZ_SYMBOLS_EXTRA_BUILDID
+EXTRA_BUILDID := -$(MOZ_SYMBOLS_EXTRA_BUILDID)
+endif
buildsymbols:
-ifdef MOZ_DEBUG_SYMBOLS
ifdef MOZ_AIRBAG
echo building symbol store
mkdir -p $(DIST)/crashreporter-symbols/$(BUILDID)
- /bin/find . -path "./dist" -prune -o -name "*.exe" \
- -o -name "*.dll" -o -name "*.EXE" | sed "s/\.[^\.]*$$/\.pdb/" | \
- xargs $(topsrcdir)/toolkit/airbag/tools/make_symbol_store.pl -c \
- $(topsrcdir)/toolkit/airbag/tools/win32/dump_syms.exe \
+ $(SYM_FIND_CMD) | \
+ xargs $(topsrcdir)/toolkit/airbag/tools/make_symbol_store.pl \
+ $(MAKE_SYM_STORE_ARGS) $(DUMP_SYMS_BIN) \
$(DIST)/crashreporter-symbols/$(BUILDID) > \
- $(DIST)/crashreporter-symbols/$(BUILDID)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_ARCH)-$(BUILDID)-symbols.txt
+ $(DIST)/crashreporter-symbols/$(BUILDID)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_ARCH)-$(BUILDID)$(EXTRA_BUILDID)-symbols.txt
echo packing symbols
mkdir -p $(topsrcdir)/../$(BUILDID)
cd $(DIST)/crashreporter-symbols/$(BUILDID) && \
zip -r9D ../crashreporter-symbols-$(BUILDID).zip .
mv $(DIST)/crashreporter-symbols/crashreporter-symbols-$(BUILDID).zip \
$(topsrcdir)/../$(BUILDID)
-endif # MOZ_DEBUG_SYMBOLS
endif # MOZ_AIRBAG
uploadsymbols:
-ifdef MOZ_DEBUG_SYMBOLS
ifdef MOZ_AIRBAG
$(topsrcdir)/toolkit/airbag/tools/upload_symbols.sh $(topsrcdir)/../$(BUILDID)/crashreporter-symbols-$(BUILDID).zip
endif
-endif
+ifeq ($(OS_ARCH),WINNT)
signnss:
ifdef MOZILLA_OFFICIAL
echo signing NSS libs
cd $(DIST)/bin; ./shlibsign.exe -v -i softokn3.dll
cd $(DIST)/bin; ./shlibsign.exe -v -i freebl3.dll
endif # MOZILLA_OFFICIAL
-BUILDID = $(shell cat $(DEPTH)/config/build_number)
deliver: splitsymbols rebase signnss
endif # WINNT
+BUILDID = $(shell cat $(DEPTH)/config/build_number)
--- a/accessible/public/Makefile.in
+++ b/accessible/public/Makefile.in
@@ -50,20 +50,20 @@ MODULE = accessibility
XPIDL_MODULE= accessibility
GRE_MODULE = 1
XPIDLSRCS = \
nsIAccessibleTypes.idl \
nsIAccessibilityService.idl \
nsIAccessibleRetrieval.idl \
nsIAccessible.idl \
+ nsIAccessibleRelation.idl \
nsIAccessibleRole.idl \
nsIAccessibleStates.idl \
nsPIAccessible.idl \
- nsIAccessibleCaret.idl \
nsIAccessibleDocument.idl \
nsPIAccessibleDocument.idl \
nsIAccessibleProvider.idl \
nsIAccessibleSelectable.idl \
nsIAccessNode.idl \
nsPIAccessNode.idl \
nsIAccessibleEvent.idl \
nsIAccessibleEditableText.idl \
--- a/accessible/public/msaa/Makefile.in
+++ b/accessible/public/msaa/Makefile.in
@@ -45,16 +45,17 @@ MODULE = accessibility
XPIDL_MODULE = accessibility-msaa
GRE_MODULE = 1
DEFFILE = $(win_srcdir)/AccessibleMarshal.def
include $(DEPTH)/config/autoconf.mk
XPIDLSRCS = \
nsIAccessibleWin32Object.idl \
+ nsIWinAccessNode.idl \
$(NULL)
DEFINES += -DREGISTER_PROXY_DLL -D_WIN32_WINNT=0x400
GARBAGE += $(MIDL_GENERATED_FILES) done_gen dlldata.c
FORCE_SHARED_LIB = 1
new file mode 100755
--- /dev/null
+++ b/accessible/public/msaa/nsIWinAccessNode.idl
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Mozilla browser.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+
+%{C++
+#include "Guiddef.h"
+%}
+
+[ref] native MSCOMIIDRef(IID);
+
+[uuid(63efe9c5-2610-4d2f-861b-e4ddfe1b70d9)]
+interface nsIWinAccessNode : nsISupports
+{
+ voidPtr queryNativeInterface([const] in MSCOMIIDRef aIID);
+};
+
--- a/accessible/public/nsIAccessNode.idl
+++ b/accessible/public/nsIAccessNode.idl
@@ -32,35 +32,36 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
-
+
interface nsIDOMNode;
interface nsIAccessibleDocument;
+interface nsIDOMCSSPrimitiveValue;
/**
* An interface used by in-process accessibility clients
* to get style, window, markup and other information about
* a DOM node. When accessibility is active in Gecko,
* every DOM node can have one nsIAccessNode for each
* pres shell the DOM node is rendered in.
* The nsIAccessNode implementations are instantiated lazily.
* The nsIAccessNode tree for a given dom window
* has a one to one relationship to the DOM tree.
* If the DOM node for this access node is "accessible",
* then a QueryInterface to nsIAccessible will succeed.
*
* @status UNDER_REVIEW
*/
-[scriptable, uuid(11c0007f-531c-43b7-be63-a3060a13d8d2)]
+[scriptable, uuid(71a3b4e7-e83d-45cf-a20e-9ce292bcf19f)]
interface nsIAccessNode : nsISupports
{
/**
* The DOM node this nsIAccessNode is associated with.
*/
readonly attribute nsIDOMNode DOMNode;
/**
@@ -153,9 +154,22 @@ interface nsIAccessNode : nsISupports
* on the version of CSS being used. Therefore, for bounds information,
* it is better to use nsIAccessible::accGetBounds.
* @param pseudoElt The pseudo element to retrieve style for, or NULL
* for general computed style information for this node.
* @param propertyName Retrieve the computed style value for this property name,
* for example "border-bottom".
*/
DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
+
+ /**
+ * The method is similar to getComputedStyleValue() excepting that this one
+ * returns nsIDOMCSSPrimitiveValue.
+ */
+ nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
+ in DOMString propertyName);
+
+ /**
+ * The language for the current DOM node, e.g. en, de, etc.
+ */
+ readonly attribute DOMString language;
};
+
--- a/accessible/public/nsIAccessibilityService.idl
+++ b/accessible/public/nsIAccessibilityService.idl
@@ -40,28 +40,28 @@
#include "nsIAccessibleRetrieval.idl"
interface nsIAccessibleEventListener;
interface nsIDocument;
interface nsIFrame;
interface nsObjectFrame;
interface nsIContent;
-[scriptable, uuid(e4cdb7c5-d029-4bee-bff5-99455c6e0057)]
+[uuid(e4cdb7c5-d029-4bee-bff5-99455c6e0057)]
interface nsIAccessibilityService : nsIAccessibleRetrieval
{
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
nsIAccessible createRootAccessible(in nsIPresShell aShell, in nsIDocument aDocument);
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);
nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
nsIAccessible createHyperTextAccessible(in nsISupports aFrame);
nsIAccessible createHTMLBRAccessible(in nsISupports aFrame);
nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame);
- [noscript] nsIAccessible createHTMLAccessibleByMarkup(in nsIFrame aFrame, in nsIWeakReference aWeakShell, in nsIDOMNode aDOMNode, in AString aRole);
+ nsIAccessible createHTMLAccessibleByMarkup(in nsIFrame aFrame, in nsIWeakReference aWeakShell, in nsIDOMNode aDOMNode, in AString aRole);
nsIAccessible createHTMLLIAccessible(in nsISupports aFrame, in nsISupports aBulletFrame, in AString aBulletText);
nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame);
nsIAccessible createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsIWeakReference aPresShell);
nsIAccessible createHTMLGenericAccessible(in nsISupports aFrame);
nsIAccessible createHTMLGroupboxAccessible(in nsISupports aFrame);
nsIAccessible createHTMLHRAccessible(in nsISupports aFrame);
nsIAccessible createHTMLImageAccessible(in nsISupports aFrame);
nsIAccessible createHTMLLabelAccessible(in nsISupports aFrame);
@@ -70,39 +70,39 @@ interface nsIAccessibilityService : nsIA
nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame);
nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsIWeakReference aPresShell);
nsIAccessible createHTMLTableAccessible(in nsISupports aFrame);
nsIAccessible createHTMLTableCellAccessible(in nsISupports aFrame);
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame);
- [noscript] nsIAccessible getAccessible(in nsIDOMNode aNode, in nsIPresShell aPresShell,
+ nsIAccessible getAccessible(in nsIDOMNode aNode, in nsIPresShell aPresShell,
in nsIWeakReference aWeakShell,
inout nsIFrame frameHint, out boolean aIsHidden);
// For gtk+ native window accessible
- [noscript] nsIAccessible addNativeRootAccessible(in voidPtr aAtkAccessible);
- [noscript] void removeNativeRootAccessible(in nsIAccessible aRootAccessible);
+ nsIAccessible addNativeRootAccessible(in voidPtr aAtkAccessible);
+ void removeNativeRootAccessible(in nsIAccessible aRootAccessible);
/**
* Invalidate the accessibility cache associated with aPresShell, for accessibles
* that were generated for aContainerContent and it's subtree.
* The container content node for the change is passed in, rather than the
* changed presentation for the content node itself.
* @param aPresShell The presShell where changes occured
* @param aChangeContent The affected DOM content
* @param aEvent The event from nsIAccessibleEvent that
* caused the change:
* Must be one of:
* EVENT_REORDER (change),
* EVENT_SHOW (make visible or create) or
* EVENT_HIDE (destroy or hide)
*/
- [noscript] void invalidateSubtreeFor(in nsIPresShell aPresShell,
+ void invalidateSubtreeFor(in nsIPresShell aPresShell,
in nsIContent aChangedContent,
in PRUint32 aEvent);
};
%{ C++
// for component registration
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -39,30 +39,31 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIArray.idl"
interface nsIPersistentProperties;
interface nsIDOMDOMStringList;
+interface nsIAccessibleRelation;
/**
* A cross-platform interface that supports platform-specific
* accessibility APIs like MSAA and ATK. Contains the sum of what's needed
* to support IAccessible as well as ATK's generic accessibility objects.
* Can also be used by in-process accessibility clients to get information
* about objects in the accessible tree. The accessible tree is a subset of
* nodes in the DOM tree -- such as documents, focusable elements and text.
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
*
* @status UNDER_REVIEW
*/
-[scriptable, uuid(b3674866-49a9-4cf2-bfea-c00be2d4a695)]
+[scriptable, uuid(004b6882-2df1-49df-bb5f-0fb81a5b1edf)]
interface nsIAccessible : nsISupports
{
/**
* Parent node in accessible tree.
*/
readonly attribute nsIAccessible parent;
/**
@@ -217,24 +218,43 @@ interface nsIAccessible : nsISupports
nsIAccessible getAccessibleAbove();
/**
* Accessible node geometrically below this one
*/
nsIAccessible getAccessibleBelow();
/**
- * Accessible node related to this one
+ * Return accessible related to this one by the given relation type (see.
+ * constants defined in nsIAccessibleRelation).
*/
nsIAccessible getAccessibleRelated(in unsigned long aRelationType);
- void getBounds(out long x,
- out long y,
- out long width,
- out long height);
+ /**
+ * Returns the number of accessible relations for this object.
+ */
+ readonly attribute unsigned long relationsCount;
+
+ /**
+ * Returns one accessible relation for this object.
+ *
+ * @param index - relation index (0-based)
+ */
+ nsIAccessibleRelation getRelation(in unsigned long index);
+
+ /**
+ * Returns multiple accessible relations for this object.
+ */
+ nsIArray getRelations();
+
+ /**
+ * Return accessible's x and y coordinates relative to the screen and
+ * accessible's width and height.
+ */
+ void getBounds(out long x, out long y, out long width, out long height);
/**
* Add or remove this accessible to the current selection
*/
void setSelected(in boolean isSelected);
/**
* Extend the current selection from its current accessible anchor node
@@ -278,86 +298,10 @@ interface nsIAccessible : nsISupports
*/
void doAction(in PRUint8 index);
/**
* Get a pointer to accessibility interface for this node, which is specific
* to the OS/accessibility toolkit we're running on.
*/
[noscript] void getNativeInterface(out voidPtr aOutAccessible);
-
- /**
- * API states we map from opposite states
- * VISIBLE -- mapped as the opposite of INVISIBLE
- * SHOWING -- mapped as the opposite of OFFSCREEN
- *
- * ATK states we don't have in nsIAccessible:
- * ARMED -- no clear use case, used briefly when button is activated
- * HAS_TOOLTIP -- no known use case
- * ICONIFIED -- Mozilla does not have elements which are collapsable into icons
- * TRUNCATED -- need use case. Indicates that an object's onscreen content is truncated, e.g. a text value in a spreadsheet cell. No IA2 state.
- */
+};
-/**
- * Relation Types -- most of these come from ATK's atkrelationtype.h
- * When adding support for relations, make sure to add them to appropriate
- * places in nsAccessibleWrap implementations
- * RELATION_NULL:
- * RELATION_CONTROLLED_BY: Controlled by one or more target objects.
- * RELATION_CONTROLLER_FOR: Controller for one or more target objects.
- * RELATION_LABEL_FOR: Label for one or more target objects.
- * RELATION_LABELLED_BY: Labelled by one or more target objects.
- * RELATION_MEMBER_OF: Member of a group of one or more target objects.
- * RELATION_NODE_CHILD_OF: Cell in a treetable which is displayed because a
- * cell in the same col is expanded & identifies it.
- * RELATION_FLOWS_TO: Has content that flows logically to another
- * object in a sequential way, e.g. text flow.
- * RELATION_FLOWS_FROM: Has content that flows logically from another
- * object in a sequential way, e.g. text flow.
- * RELATION_SUBWINDOW_OF: Subwindow attached to a component but otherwise
- * not connected in the UI hierarchy to that component.
- * RELATION_EMBEDS: Visually embeds another object's content, i.e.
- * this object's content flows around another's content.
- * RELATION_EMBEDDED_BY: Inverse of RELATION_EMBEDS; this object's content
- * is visually embedded in another object.
- * RELATION_POPUP_FOR: Popup for another object.
- * RELATION_PARENT_WINDOW_OF: Parent window of another object.
- * RELATION_DEFAULT_BUTTON: Part of a form/dialog with a related default button.
- * RELATION_DESCRIBED_BY: Described by one or more target objects.
- * RELATION_DESCRIPTION_FOR: Description for one or more target objects.
- */
-
- const unsigned long RELATION_NUL = 0x00; // ATK_RELATION_NUL
- const unsigned long RELATION_CONTROLLED_BY = 0x01; // ATK_RELATION_CONTROLLED_BY
- const unsigned long RELATION_CONTROLLER_FOR = 0x02; // ATK_RELATION_CONTROLLER_FOR
- const unsigned long RELATION_LABEL_FOR = 0x03; // ATK_RELATION_LABEL_FOR
- const unsigned long RELATION_LABELLED_BY = 0x04; // ATK_RELATION_LABELLED_BY
- const unsigned long RELATION_MEMBER_OF = 0x05; // ATK_RELATION_MEMBER_OF
- const unsigned long RELATION_NODE_CHILD_OF = 0x06; // ATK_RELATION_NODE_CHILD_OF
- const unsigned long RELATION_FLOWS_TO = 0x07; // ATK_RELATION_FLOWS_TO
- const unsigned long RELATION_FLOWS_FROM = 0x08; // ATK_RELATION_FLOWS_FROM
- const unsigned long RELATION_SUBWINDOW_OF = 0x09; // ATK_RELATION_SUBWINDOW_OF
- const unsigned long RELATION_EMBEDS = 0x0a; // ATK_RELATION_EMBEDS
- const unsigned long RELATION_EMBEDDED_BY = 0x0b; // ATK_RELATION_EMBEDDED_BY
- const unsigned long RELATION_POPUP_FOR = 0x0c; // ATK_RELATION_POPUP_FOR
- const unsigned long RELATION_PARENT_WINDOW_OF = 0x0d; // ATK_RELATION_PARENT_WINDOW_OF
- const unsigned long RELATION_DESCRIBED_BY = 0x0e; // ATK_RELATION_DESCRIBED_BY
- const unsigned long RELATION_DESCRIPTION_FOR = 0x0f; // ATK_RELATION_DESCRIPTION_FOR
- const unsigned long RELATION_DEFAULT_BUTTON = 0x4000; // MSAA only, no ATK relation
-
-// MSAA relationship extensions to accNavigate
- const unsigned long NAVRELATION_CONTROLLED_BY = 0x1000;
- const unsigned long NAVRELATION_CONTROLLER_FOR = 0x1001;
- const unsigned long NAVRELATION_LABEL_FOR = 0x1002;
- const unsigned long NAVRELATION_LABELLED_BY = 0x1003;
- const unsigned long NAVRELATION_MEMBER_OF = 0x1004;
- const unsigned long NAVRELATION_NODE_CHILD_OF = 0x1005;
- const unsigned long NAVRELATION_FLOWS_TO = 0x1006;
- const unsigned long NAVRELATION_FLOWS_FROM = 0x1007;
- const unsigned long NAVRELATION_SUBWINDOW_OF = 0x1008;
- const unsigned long NAVRELATION_EMBEDS = 0x1009;
- const unsigned long NAVRELATION_EMBEDDED_BY = 0x100a;
- const unsigned long NAVRELATION_POPUP_FOR = 0x100b;
- const unsigned long NAVRELATION_PARENT_WINDOW_OF = 0x100c;
- const unsigned long NAVRELATION_DEFAULT_BUTTON = 0x100d;
- const unsigned long NAVRELATION_DESCRIBED_BY = 0x100e;
- const unsigned long NAVRELATION_DESCRIPTION_FOR = 0x100f;
-};
deleted file mode 100644
--- a/accessible/public/nsIAccessibleCaret.idl
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Mozilla browser.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-#include "nsIDOMNode.idl"
-
-[scriptable, uuid(9124c666-6133-4be6-b3ed-dd0ec35f1e64)]
-interface nsIAccessibleCaret : nsISupports
-{
- void attachNewSelectionListener(in nsIDOMNode aFocusedNode);
- void removeSelectionListener();
-};
--- a/accessible/public/nsIAccessibleDocument.idl
+++ b/accessible/public/nsIAccessibleDocument.idl
@@ -53,17 +53,17 @@ interface nsIDOMWindow;
* You can QueryInterface to nsIAccessibleDocument from
* the nsIAccessible or nsIAccessNode for the root node
* of a document. You can also get one from
* nsIAccessNode::GetAccessibleDocument() or
* nsIAccessibleEvent::GetAccessibleDocument()
*
* @status UNDER_REVIEW
*/
-[scriptable, uuid(DD22939F-B470-4a56-9B80-8C7BA4031334)]
+[scriptable, uuid(ae5792a3-77ad-40d6-8450-d28d19b66889)]
interface nsIAccessibleDocument : nsISupports
{
/**
* The URL of the document
*/
readonly attribute AString URL;
/**
@@ -86,21 +86,16 @@ interface nsIAccessibleDocument : nsISup
*/
readonly attribute nsIDOMDocument document;
/**
* The nsIDOMWindow that the document resides in.
*/
readonly attribute nsIDOMWindow window;
- /*
- * The accessible for the caret belonging to this window.
- */
- readonly attribute nsIAccessible caretAccessible;
-
/**
* The namespace for each ID that is handed back.
*/
AString getNameSpaceURIForID(in short nameSpaceID);
/**
* The window handle for the OS window the document is being displayed in.
* For example, in Windows you can static cast it to an HWND.
@@ -115,13 +110,15 @@ interface nsIAccessibleDocument : nsISup
* @return The nsIAccessNode cached for this particular unique ID.
*/
[noscript] nsIAccessNode getCachedAccessNode(in voidPtr aUniqueID);
/**
* Returns the first accessible parent of a DOM node.
* Guaranteed not to return nsnull if the DOM node is in a document.
* @param aDOMNode The DOM node we need an accessible for.
+ * @param aCanCreate Can accessibles be created or must it be the first
+ * cached accessible in the parent chain?
* @return An first nsIAccessible found by crawling up the DOM node
* to the document root.
*/
- nsIAccessible getAccessibleInParentChain(in nsIDOMNode aDOMNode);
+ nsIAccessible getAccessibleInParentChain(in nsIDOMNode aDOMNode, in boolean aCanCreate);
};
--- a/accessible/public/nsIAccessibleProvider.idl
+++ b/accessible/public/nsIAccessibleProvider.idl
@@ -40,17 +40,17 @@
#include "nsISupports.idl"
/**
* nsIAccessibleProvider interface is used to link element and accessible
object. For that XBL binding of element should implement the interface.
*/
-[scriptable, uuid(18797ea7-44cc-469e-8923-bd5d1c144461)]
+[scriptable, uuid(7250d0f0-732d-4981-b73e-dd5d71b16183)]
interface nsIAccessibleProvider : nsISupports
{
/**
* Constants set of common use.
*/
/** For elements that spawn a new document. For example now it is used by
<xul:iframe>, <xul:browser> and <xul:editor>. */
@@ -82,31 +82,28 @@ interface nsIAccessibleProvider : nsISup
const long XULRadioGroup = 0x00001020;
/** The single tab in a dialog or tabbrowser/editor interface */
const long XULTab = 0x00001021;
/** A combination of a tabs object and a tabpanels object */
const long XULTabBox = 0x00001022;
- /** The display area for a dialog or tabbrowser interface */
- const long XULTabPanels = 0x00001023;
-
/** The collection of tab objects, useable in the TabBox and independant of
as well */
- const long XULTabs = 0x00001024;
+ const long XULTabs = 0x00001023;
- const long XULText = 0x00001025;
- const long XULTextBox = 0x00001026;
- const long XULTree = 0x00001027;
- const long XULTreeColumns = 0x00001028;
- const long XULTreeColumnitem = 0x00001029;
- const long XULToolbar = 0x00001030;
- const long XULToolbarSeparator = 0x00001031;
- const long XULTooltip = 0x00001032;
+ const long XULText = 0x00001024;
+ const long XULTextBox = 0x00001025;
+ const long XULTree = 0x00001026;
+ const long XULTreeColumns = 0x00001027;
+ const long XULTreeColumnitem = 0x00001028;
+ const long XULToolbar = 0x00001029;
+ const long XULToolbarSeparator = 0x00001030;
+ const long XULTooltip = 0x00001031;
/**
* Constants set is used by XForms elements.
*/
/** Used for xforms elements that provide accessible object for itself as
* well for anonymous content. This property are used for upload,
new file mode 100755
--- /dev/null
+++ b/accessible/public/nsIAccessibleRelation.idl
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+#include "nsIArray.idl"
+
+interface nsIAccessible;
+
+/**
+ * This interface gives access to an accessible's set of relations.
+ * Be carefull, do not change constants until ATK has a structure to map gecko
+ * constants into ATK constants.
+ */
+[scriptable, uuid(f42a1589-70ab-4704-877f-4a9162bbe188)]
+interface nsIAccessibleRelation : nsISupports
+{
+
+ const unsigned long RELATION_NUL = 0x00;
+
+ /**
+ * Some attribute of this object is affected by a target object.
+ */
+ const unsigned long RELATION_CONTROLLED_BY = 0x01;
+
+ /**
+ * This object is interactive and controls some attribute of a target object.
+ */
+ const unsigned long RELATION_CONTROLLER_FOR = 0x02;
+
+ /**
+ * This object is label for a target object.
+ */
+ const unsigned long RELATION_LABEL_FOR = 0x03;
+
+ /**
+ * This object is labelled by a target object.
+ */
+ const unsigned long RELATION_LABELLED_BY = 0x04;
+
+ /**
+ * This object is a member of a group of one or more objects. When there is
+ * more than one object in the group each member may have one and the same
+ * target, e.g. a grouping object. It is also possible that each member has
+ * multiple additional targets, e.g. one for every other member in the group.
+ */
+ const unsigned long RELATION_MEMBER_OF = 0x05;
+
+ /**
+ * This object is a child of a target object.
+ */
+ const unsigned long RELATION_NODE_CHILD_OF = 0x06;
+
+ /**
+ * Content flows from this object to a target object, i.e. has content that
+ * flows logically to another object in a sequential way, e.g. text flow.
+ */
+ const unsigned long RELATION_FLOWS_TO = 0x07;
+
+ /**
+ * Content flows to this object from a target object, i.e. has content that
+ * flows logically from another object in a sequential way, e.g. text flow.
+ */
+ const unsigned long RELATION_FLOWS_FROM = 0x08;
+
+ /**
+ * This object is a sub window of a target object.
+ */
+ const unsigned long RELATION_SUBWINDOW_OF = 0x09;
+
+ /**
+ * This object embeds a target object. This relation can be used on the
+ * OBJID_CLIENT accessible for a top level window to show where the content
+ * areas are.
+ */
+ const unsigned long RELATION_EMBEDS = 0x0a;
+
+ /**
+ * This object is embedded by a target object.
+ */
+ const unsigned long RELATION_EMBEDDED_BY = 0x0b;
+
+ /**
+ * This object is a transient component related to the target object. When
+ * this object is activated the target object doesn't loose focus.
+ */
+ const unsigned long RELATION_POPUP_FOR = 0x0c;
+
+ /**
+ * This object is a parent window of the target object.
+ */
+ const unsigned long RELATION_PARENT_WINDOW_OF = 0x0d;
+
+ /**
+ * This object is described by the target object.
+ */
+ const unsigned long RELATION_DESCRIBED_BY = 0x0e;
+
+ /**
+ * This object is describes the target object.
+ */
+ const unsigned long RELATION_DESCRIPTION_FOR = 0x0f;
+
+ /**
+ * Part of a form/dialog with a related default button. It is used for
+ * MSAA only, no for IA2 nor ATK.
+ */
+ const unsigned long RELATION_DEFAULT_BUTTON = 0x4000;
+
+ /**
+ * Returns the type of the relation.
+ */
+ readonly attribute unsigned long relationType;
+
+ /**
+ * Returns the number of targets for this relation.
+ */
+ readonly attribute unsigned long targetsCount;
+
+ /**
+ * Returns one accessible relation target.
+ * @param index - 0 based index of relation target.
+ */
+ nsIAccessible getTarget(in unsigned long index);
+
+ /**
+ * Returns multiple accessible relation targets.
+ */
+ nsIArray getTargets();
+};
--- a/accessible/public/nsIAccessibleRetrieval.idl
+++ b/accessible/public/nsIAccessibleRetrieval.idl
@@ -39,16 +39,18 @@
#include "nsISupports.idl"
interface nsIDOMNode;
interface nsIAccessible;
interface nsIWeakReference;
interface nsIPresShell;
interface nsIDOMWindow;
interface nsIAccessNode;
+interface nsIDOMDOMStringList;
+
/**
* An interface for in-process accessibility clients
* wishing to get an nsIAccessible or nsIAccessNode for
* a given DOM node.
* More documentation at:
* http://www.mozilla.org/projects/ui/accessibility
*
@@ -134,16 +136,31 @@ interface nsIAccessibleRetrieval : nsISu
* Return an nsIAccessible for an already created DOM node in the given weak shell.
* Does not create a new one -- only returns cached accessibles.
* @param aNode The DOM node to get an accessible for.
* @param aPresShell The presentation shell which contains layout info for the DOM node.
* @return The nsIAccessible for the given DOM node or null if
* an accessible does not already exist for this DOM node.
*/
nsIAccessible getCachedAccessible(in nsIDOMNode aNode, in nsIWeakReference aShell);
+
+ /**
+ * Returns accessible role as a string.
+ *
+ * @param aRole - the accessible role constants.
+ */
+ AString getStringRole(in unsigned long aRole);
+
+ /**
+ * Returns list which contains accessible states as a strings.
+ *
+ * @param aStates - accessible states.
+ * @param aExtraStates - accessible extra states.
+ */
+ nsIDOMDOMStringList getStringStates(in unsigned long aStates, in unsigned long aExtraStates);
};
%{ C++
// for component registration
// {663CA4A8-D219-4000-925D-D8F66406B626}
#define NS_ACCESSIBLE_RETRIEVAL_CID \
--- a/accessible/public/nsIAccessibleTable.idl
+++ b/accessible/public/nsIAccessibleTable.idl
@@ -38,50 +38,153 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIAccessible;
-[scriptable, uuid(0A7E98A9-CA7D-42F0-BFE1-2CFC35256038)]
+[scriptable, uuid(a776fee4-c0b8-4872-9e1e-72017243383f)]
interface nsIAccessibleTable : nsISupports
{
attribute nsIAccessible caption;
attribute AString summary;
readonly attribute long columns;
readonly attribute nsIAccessibleTable columnHeader;
readonly attribute long rows;
readonly attribute nsIAccessibleTable rowHeader;
- void getSelectedColumns (out unsigned long columnsSize,
- [retval, array, size_is(columnsSize)] out long columns);
-
- void getSelectedRows (out unsigned long rowsSize,
- [retval, array, size_is(rowsSize)] out long rows);
-
- /**
- * gets a cell
- */
- nsIAccessible cellRefAt (in long row, in long column);
+ /**
+ * Returns the accessible object at the specified row and column in the table.
+ * If both row and column index are valid then the corresponding accessible
+ * object is returned that represents the requested cell regardless of whether
+ * the cell is currently visible (on the screen).
+ *
+ * @param row - The row index for which to retrieve the cell.
+ * @param column - The column index for which to retrieve the cell.
+ */
+ nsIAccessible cellRefAt(in long row, in long column);
/**
* get an index
*/
long getIndexAt (in long row, in long column);
long getColumnAtIndex (in long index);
long getRowAtIndex (in long index);
- long getColumnExtentAt (in long row, in long column);
- long getRowExtentAt (in long row, in long column);
+
+ /**
+ * Returns the number of columns occupied by the accessible object
+ * at the specified row and column in the table. The result differs from 1
+ * if the specified cell spans multiple columns.
+ *
+ * @param row - Row index of the accessible for which to return
+ * the column extent.
+ * @param column - Column index of the accessible for which to return
+ * the column extent.
+ */
+ long getColumnExtentAt(in long row, in long column);
+
+ /**
+ * Returns the number of rows occupied by the accessible oject
+ * at the specified row and column in the table. The result differs from 1
+ * if the specified cell spans multiple rows.
+ *
+ * @param row - Row index of the accessible for which to return
+ * the column extent.
+ * @param column - Column index of the accessible for which to return
+ * the column extent.
+ */
+ long getRowExtentAt(in long row, in long column);
- AString getColumnDescription (in long column);
- AString getRowDescription (in long row);
+ /**
+ * Returns the description text of the specified column in the table.
+ * @param column - The index of the column for which to retrieve
+ * the description.
+ */
+ AString getColumnDescription(in long column);
+
+ /**
+ * Returns the description text of the specified row in the table.
+ * @param row - The index of the row for which to retrieve the description.
+ */
+ AString getRowDescription(in long row);
- boolean isColumnSelected (in long column);
- boolean isRowSelected (in long row);
- boolean isCellSelected (in long row, in long column);
+ /**
+ * Returns a boolean value indicating whether the specified column is
+ * completely selected.
+ *
+ * @param column - Index of the column for which to determine whether it is
+ * selected.
+ */
+ boolean isColumnSelected(in long column);
+
+ /**
+ * Returns a boolean value indicating whether the specified row is completely
+ * selected.
+ *
+ * @param row - Index of the row for which to determine whether it is
+ * selected.
+ */
+ boolean isRowSelected(in long row);
/**
- * Use heuristics to determine if table is most likely used for layout
- */
+ * Returns a boolean value indicating whether the specified cell is selected.
+ *
+ * @param row - Index of the row for the cell to determine whether it is
+ * selected.
+ * @param column - Index of the column for the cell to determine whether it
+ * is selected.
+ */
+ boolean isCellSelected(in long row, in long column);
+
+ /**
+ * Returns a list of column indexes currently selected.
+ *
+ * @param columnsSize - Length of array
+ * @param columns - Array of indexes of selected columns
+ */
+ void getSelectedColumns(out unsigned long columnsSize,
+ [retval, array, size_is(columnsSize)] out long columns);
+
+ /**
+ * Returns a list of row indexes currently selected.
+ *
+ * @param rowsSize - Length of array
+ * @param rows - Array of indexes of selected rows
+ */
+ void getSelectedRows(out unsigned long rowsSize,
+ [retval, array, size_is(rowsSize)] out long rows);
+
+ /**
+ * Selects a row and unselects all previously selected rows.
+ *
+ * @param row - Index of the row to be selected.
+ */
+ void selectRow(in long row);
+
+ /**
+ * Selects a column and unselects all previously selected columns.
+ *
+ * @param column - Index of the column to be selected.
+ */
+ void selectColumn(in long column);
+
+ /**
+ * Unselects one row, leaving other selected rows selected (if any).
+ *
+ * @param row - Index of the row to be selected.
+ */
+ void unselectRow(in long row);
+
+ /**
+ * Unselects one column, leaving other selected columns selected (if any).
+ *
+ * @param column - Index of the column to be selected.
+ */
+ void unselectColumn(in long column);
+
+ /**
+ * Use heuristics to determine if table is most likely used for layout.
+ */
boolean isProbablyForLayout();
};
+
--- a/accessible/src/atk/Makefile.in
+++ b/accessible/src/atk/Makefile.in
@@ -91,16 +91,20 @@ endif
EXPORTS = \
nsAccessNodeWrap.h \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
+ nsHyperTextAccessibleWrap.h \
+ nsHTMLImageAccessibleWrap.h \
+ nsHTMLTableAccessibleWrap.h \
+ nsAccessibleRelationWrap.h \
$(NULL)
# we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
include $(topsrcdir)/config/rules.mk
--- a/accessible/src/atk/nsAccessNodeWrap.cpp
+++ b/accessible/src/atk/nsAccessNodeWrap.cpp
@@ -62,20 +62,17 @@ nsAccessNodeWrap::nsAccessNodeWrap(nsIDO
//-----------------------------------------------------
nsAccessNodeWrap::~nsAccessNodeWrap()
{
}
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
-
- // Init accessibility for ATK
- nsAppRootAccessible::Load();
}
void nsAccessNodeWrap::ShutdownAccessibility()
{
nsAccessNode::ShutdownXPAccessibility();
// Shutdown accessibility for ATK
- nsAppRootAccessible::Unload();
+ nsApplicationAccessibleWrap::Unload();
}
new file mode 100755
--- /dev/null
+++ b/accessible/src/atk/nsAccessibleRelationWrap.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NS_ACCESSIBLE_RELATION_WRAP_H
+#define _NS_ACCESSIBLE_RELATION_WRAP_H
+
+#include "nsAccessibleRelation.h"
+
+typedef class nsAccessibleRelation nsAccessibleRelationWrap;
+
+#endif
+
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -34,20 +34,20 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-#include "nsMai.h"
#include "nsAccessibleWrap.h"
-#include "nsAppRootAccessible.h"
+#include "nsAccessibleEventData.h"
#include "nsString.h"
+#include "nsAutoPtr.h"
#include "prprf.h"
#include "nsRoleMap.h"
#include "nsStateMap.h"
#include "nsMaiInterfaceComponent.h"
#include "nsMaiInterfaceAction.h"
#include "nsMaiInterfaceText.h"
#include "nsMaiInterfaceEditableText.h"
@@ -56,16 +56,18 @@
#include "nsMaiInterfaceHypertext.h"
#include "nsMaiInterfaceHyperlinkImpl.h"
#include "nsMaiInterfaceTable.h"
#include "nsXPCOMStrings.h"
#include "nsComponentManagerUtils.h"
#include "nsMaiInterfaceDocument.h"
#include "nsMaiInterfaceImage.h"
+#include "nsAppRootAccessible.h"
+
extern "C" GType g_atk_hyperlink_impl_type; //defined in nsAppRootAccessible.cpp
/* MaiAtkObject */
enum {
ACTIVATE,
CREATE,
DEACTIVATE,
@@ -223,16 +225,18 @@ static AtkRelationSet* refRelationSe
*/
G_END_DECLS
static GType GetMaiAtkType(PRUint16 interfacesBits);
static const char * GetUniqueMaiAtkTypeName(PRUint16 interfacesBits);
static gpointer parent_class = NULL;
+static GQuark quark_mai_hyperlink = 0;
+
GType
mai_atk_object_get_type(void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiAtkObjectClass),
@@ -244,16 +248,17 @@ mai_atk_object_get_type(void)
sizeof(MaiAtkObject), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc)NULL,
NULL /* value table */
};
type = g_type_register_static(ATK_TYPE_OBJECT,
"MaiAtkObject", &tinfo, GTypeFlags(0));
+ quark_mai_hyperlink = g_quark_from_static_string("MaiHyperlink");
}
return type;
}
/*
* Must keep sychronization with enumerate AtkProperty in
* accessible/src/base/nsAccessibleEventData.h
*/
@@ -295,34 +300,77 @@ nsAccessibleWrap::~nsAccessibleWrap()
{
#ifdef MAI_LOGGING
++mAccWrapDeleted;
#endif
MAI_LOG_DEBUG(("==nsAccessibleWrap deleting: this=%p,total=%d left=%d\n",
(void*)this, mAccWrapDeleted,
(mAccWrapCreated-mAccWrapDeleted)));
+}
+NS_IMETHODIMP nsAccessibleWrap::Shutdown()
+{
if (mAtkObject) {
if (IS_MAI_OBJECT(mAtkObject)) {
MAI_ATK_OBJECT(mAtkObject)->accWrap = nsnull;
}
+ SetMaiHyperlink(nsnull);
g_object_unref(mAtkObject);
+ mAtkObject = nsnull;
+ }
+ return nsAccessible::Shutdown();
+}
+
+MaiHyperlink* nsAccessibleWrap::GetMaiHyperlink(PRBool aCreate /* = PR_TRUE */)
+{
+ // make sure mAtkObject is created
+ GetAtkObject();
+
+ NS_ASSERTION(quark_mai_hyperlink, "quark_mai_hyperlink not initialized");
+ NS_ASSERTION(IS_MAI_OBJECT(mAtkObject), "Invalid AtkObject");
+ MaiHyperlink* maiHyperlink = nsnull;
+ if (quark_mai_hyperlink && IS_MAI_OBJECT(mAtkObject)) {
+ maiHyperlink = (MaiHyperlink*)g_object_get_qdata(G_OBJECT(mAtkObject),
+ quark_mai_hyperlink);
+ if (!maiHyperlink && aCreate) {
+ maiHyperlink = new MaiHyperlink(this);
+ SetMaiHyperlink(maiHyperlink);
+ }
+ }
+ return maiHyperlink;
+}
+
+void nsAccessibleWrap::SetMaiHyperlink(MaiHyperlink* aMaiHyperlink)
+{
+ NS_ASSERTION(quark_mai_hyperlink, "quark_mai_hyperlink not initialized");
+ NS_ASSERTION(IS_MAI_OBJECT(mAtkObject), "Invalid AtkObject");
+ if (quark_mai_hyperlink && IS_MAI_OBJECT(mAtkObject)) {
+ MaiHyperlink* maiHyperlink = GetMaiHyperlink(PR_FALSE);
+ if (!maiHyperlink && !aMaiHyperlink) {
+ return; // Never set and we're shutting down
+ }
+ if (maiHyperlink) {
+ delete maiHyperlink;
+ }
+ g_object_set_qdata(G_OBJECT(mAtkObject), quark_mai_hyperlink,
+ aMaiHyperlink);
}
}
NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
{
*aOutAccessible = nsnull;
- if (!IsEmbeddedObject(this)) {
- // We don't create ATK objects for nsIAccessible plain text leaves
- return NS_ERROR_FAILURE;
- }
if (!mAtkObject) {
+ if (!IsEmbeddedObject(this)) {
+ // We don't create ATK objects for nsIAccessible plain text leaves
+ return NS_ERROR_FAILURE;
+ }
+
GType type = GetMaiAtkType(CreateMaiInterfaces());
NS_ENSURE_TRUE(type, NS_ERROR_FAILURE);
mAtkObject =
NS_REINTERPRET_CAST(AtkObject *,
g_object_new(type, NULL));
NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
atk_object_initialize(mAtkObject, this);
@@ -337,16 +385,26 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativ
AtkObject *
nsAccessibleWrap::GetAtkObject(void)
{
void *atkObj = nsnull;
GetNativeInterface(&atkObj);
return NS_STATIC_CAST(AtkObject *, atkObj);
}
+// Get AtkObject from nsIAccessible interface
+/* static */
+AtkObject *
+nsAccessibleWrap::GetAtkObject(nsIAccessible * acc)
+{
+ void *atkObjPtr = nsnull;
+ acc->GetNativeInterface(&atkObjPtr);
+ return atkObjPtr ? ATK_OBJECT(atkObjPtr) : nsnull;
+}
+
/* private */
PRUint16
nsAccessibleWrap::CreateMaiInterfaces(void)
{
PRUint16 interfacesBits = 0;
// Add Interfaces for each nsIAccessible.ext interfaces
@@ -653,76 +711,68 @@ finalizeCB(GObject *aObj)
// finalize of GObjectClass will unref the accessible parent if has
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize(aObj);
}
const gchar *
getNameCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
-
- nsAutoString uniName;
-
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return nsnull;
+ }
/* nsIAccessible is responsible for the non-NULL name */
+ nsAutoString uniName;
nsresult rv = accWrap->GetName(uniName);
NS_ENSURE_SUCCESS(rv, nsnull);
- if (uniName.Length() > 0) {
- NS_ConvertUTF8toUTF16 objName(aAtkObj->name);
- if (!uniName.Equals(objName)) {
- atk_object_set_name(aAtkObj,
- NS_ConvertUTF16toUTF8(uniName).get());
- }
+ NS_ConvertUTF8toUTF16 objName(aAtkObj->name);
+ if (!uniName.Equals(objName)) {
+ atk_object_set_name(aAtkObj,
+ NS_ConvertUTF16toUTF8(uniName).get());
}
return aAtkObj->name;
}
const gchar *
getDescriptionCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
-
- if (!aAtkObj->description) {
- gint len;
- nsAutoString uniDesc;
-
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return nsnull;
+ }
- /* nsIAccessible is responsible for the non-NULL description */
- nsresult rv = accWrap->GetDescription(uniDesc);
- NS_ENSURE_SUCCESS(rv, nsnull);
- len = uniDesc.Length();
- if (len > 0) {
- atk_object_set_description(aAtkObj,
- NS_ConvertUTF16toUTF8(uniDesc).get());
- }
+ /* nsIAccessible is responsible for the non-NULL description */
+ nsAutoString uniDesc;
+ nsresult rv = accWrap->GetDescription(uniDesc);
+ NS_ENSURE_SUCCESS(rv, nsnull);
+
+ NS_ConvertUTF8toUTF16 objDesc(aAtkObj->description);
+ if (!uniDesc.Equals(objDesc)) {
+ atk_object_set_description(aAtkObj,
+ NS_ConvertUTF16toUTF8(uniDesc).get());
}
return aAtkObj->description;
}
AtkRole
getRoleCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), ATK_ROLE_INVALID);
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return ATK_ROLE_INVALID;
+ }
#ifdef DEBUG_A11Y
- nsAccessibleWrap *testAccWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
- NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(testAccWrap), "Does not support nsIAccessibleText when it should");
+ NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(accWrap), "Does not support nsIAccessibleText when it should");
#endif
if (aAtkObj->role == ATK_ROLE_INVALID) {
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
-
PRUint32 accRole, atkRole;
nsresult rv = accWrap->GetFinalRole(&accRole);
NS_ENSURE_SUCCESS(rv, ATK_ROLE_INVALID);
atkRole = atkRoleMap[accRole]; // map to the actual value
NS_ASSERTION(atkRoleMap[nsIAccessibleRole::ROLE_LAST_ENTRY] ==
kROLE_ATK_LAST_ENTRY, "ATK role map skewed");
aAtkObj->role = NS_STATIC_CAST(AtkRole, atkRole);
@@ -765,51 +815,48 @@ GetAttributeSet(nsIAccessible* aAccessib
}
return objAttributeSet;
}
AtkAttributeSet *
getAttributesCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
- return GetAttributeSet(accWrap);
+ return accWrap ? GetAttributeSet(accWrap) : nsnull;
}
AtkObject *
getParentCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ if (!aAtkObj->accessible_parent) {
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return nsnull;
+ }
- nsCOMPtr<nsIAccessible> accParent;
- nsresult rv = accWrap->GetParent(getter_AddRefs(accParent));
- if (NS_FAILED(rv) || !accParent)
- return nsnull;
- nsIAccessible *tmpParent = accParent;
- nsAccessibleWrap *accWrapParent = NS_STATIC_CAST(nsAccessibleWrap *,
- tmpParent);
+ nsCOMPtr<nsIAccessible> accParent;
+ nsresult rv = accWrap->GetParent(getter_AddRefs(accParent));
+ if (NS_FAILED(rv) || !accParent)
+ return nsnull;
- AtkObject *parentAtkObj = accWrapParent->GetAtkObject();
- if (parentAtkObj && !aAtkObj->accessible_parent) {
- atk_object_set_parent(aAtkObj, parentAtkObj);
+ atk_object_set_parent(aAtkObj,
+ nsAccessibleWrap::GetAtkObject(accParent));
}
- return parentAtkObj;
+ return aAtkObj->accessible_parent;
}
gint
getChildCountCB(AtkObject *aAtkObj)
{
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), 0);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return 0;
+ }
PRInt32 count = 0;
nsCOMPtr<nsIAccessibleHyperText> hyperText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(hyperText));
if (hyperText) {
// If HyperText, then number of links matches number of children
hyperText->GetLinks(&count);
}
@@ -830,19 +877,20 @@ refChildCB(AtkObject *aAtkObj, gint aChi
if (aChildIndex < 0) {
return nsnull;
}
// XXX Fix this so it is not O(n^2) to walk through the children!
// Either we can cache the last accessed child so that we can just GetNextSibling()
// or we should cache an array of children in each nsAccessible
// (instead of mNextSibling on the children)
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), nsnull);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return nsnull;
+ }
nsresult rv;
nsCOMPtr<nsIAccessible> accChild;
nsCOMPtr<nsIAccessibleHyperText> hyperText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(hyperText));
if (hyperText) {
// If HyperText, then number of links matches number of children
nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
@@ -855,39 +903,37 @@ refChildCB(AtkObject *aAtkObj, gint aChi
if (!accText) { // Accessible Text that is not HyperText has no children
rv = accWrap->GetChildAt(aChildIndex, getter_AddRefs(accChild));
}
}
if (NS_FAILED(rv) || !accChild)
return nsnull;
- nsIAccessible *tmpAccChild = accChild;
- nsAccessibleWrap *accWrapChild =
- NS_STATIC_CAST(nsAccessibleWrap*, tmpAccChild);
+ AtkObject* childAtkObj = nsAccessibleWrap::GetAtkObject(accChild);
- //this will addref parent
- AtkObject *childAtkObj = accWrapChild->GetAtkObject();
NS_ASSERTION(childAtkObj, "Fail to get AtkObj");
if (!childAtkObj)
return nsnull;
- atk_object_set_parent(childAtkObj,
- accWrap->GetAtkObject());
+
+ //this will addref parent
+ atk_object_set_parent(childAtkObj, aAtkObj);
g_object_ref(childAtkObj);
return childAtkObj;
}
gint
getIndexInParentCB(AtkObject *aAtkObj)
{
// We don't use nsIAccessible::GetIndexInParent() because
// for ATK we don't want to include text leaf nodes as children
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), -1);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return -1;
+ }
nsCOMPtr<nsIAccessible> parent;
accWrap->GetParent(getter_AddRefs(parent));
if (!parent) {
return -1; // No parent
}
nsCOMPtr<nsIAccessible> sibling;
@@ -941,19 +987,22 @@ static void TranslateStates(PRUint32 aSt
}
AtkStateSet *
refStateSetCB(AtkObject *aAtkObj)
{
AtkStateSet *state_set = nsnull;
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), state_set);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ TranslateStates(nsIAccessibleStates::EXT_STATE_DEFUNCT,
+ gAtkStateMapExt, state_set);
+ return state_set;
+ }
// Map states
PRUint32 accState = 0, accExtState = 0;
nsresult rv = accWrap->GetFinalState(&accState, &accExtState);
NS_ENSURE_SUCCESS(rv, state_set);
TranslateStates(accState, gAtkStateMap, state_set);
TranslateStates(accExtState, gAtkStateMapExt, state_set);
@@ -962,100 +1011,106 @@ refStateSetCB(AtkObject *aAtkObj)
}
AtkRelationSet *
refRelationSetCB(AtkObject *aAtkObj)
{
AtkRelationSet *relation_set = nsnull;
relation_set = ATK_OBJECT_CLASS(parent_class)->ref_relation_set(aAtkObj);
- NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), relation_set);
- nsAccessibleWrap *accWrap =
- NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
+ if (!accWrap) {
+ return relation_set;
+ }
AtkObject *accessible_array[1];
AtkRelation* relation;
- PRUint32 relationType[] = {nsIAccessible::RELATION_LABELLED_BY,
- nsIAccessible::RELATION_LABEL_FOR,
- nsIAccessible::RELATION_NODE_CHILD_OF,
- nsIAccessible::RELATION_CONTROLLED_BY,
- nsIAccessible::RELATION_CONTROLLER_FOR,
- nsIAccessible::RELATION_EMBEDS,
- nsIAccessible::RELATION_FLOWS_TO,
- nsIAccessible::RELATION_FLOWS_FROM,
- nsIAccessible::RELATION_DESCRIBED_BY,
- nsIAccessible::RELATION_DESCRIPTION_FOR,
+ PRUint32 relationType[] = {nsIAccessibleRelation::RELATION_LABELLED_BY,
+ nsIAccessibleRelation::RELATION_LABEL_FOR,
+ nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
+ nsIAccessibleRelation::RELATION_CONTROLLED_BY,
+ nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
+ nsIAccessibleRelation::RELATION_EMBEDS,
+ nsIAccessibleRelation::RELATION_FLOWS_TO,
+ nsIAccessibleRelation::RELATION_FLOWS_FROM,
+ nsIAccessibleRelation::RELATION_DESCRIBED_BY,
+ nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
};
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(relationType); i++) {
relation = atk_relation_set_get_relation_by_type(relation_set, NS_STATIC_CAST(AtkRelationType, relationType[i]));
if (relation) {
atk_relation_set_remove(relation_set, relation);
}
nsIAccessible* accRelated;
nsresult rv = accWrap->GetAccessibleRelated(relationType[i], &accRelated);
if (NS_SUCCEEDED(rv) && accRelated) {
- accessible_array[0] = NS_STATIC_CAST(nsAccessibleWrap*, accRelated)->GetAtkObject();
+ accessible_array[0] = nsAccessibleWrap::GetAtkObject(accRelated);
relation = atk_relation_new(accessible_array, 1,
NS_STATIC_CAST(AtkRelationType, relationType[i]));
atk_relation_set_add(relation_set, relation);
g_object_unref(relation);
}
}
return relation_set;
}
-// Check if aAtkObj is a valid MaiAtkObject
-nsresult
-CheckMaiAtkObject(AtkObject *aAtkObj)
-{
- NS_ENSURE_ARG(IS_MAI_OBJECT(aAtkObj));
- nsAccessibleWrap * tmpAccWrap = MAI_ATK_OBJECT(aAtkObj)->accWrap;
- if (tmpAccWrap == nsnull)
- return NS_ERROR_INVALID_POINTER;
- if (tmpAccWrap != nsAppRootAccessible::Create() && !tmpAccWrap->IsValidObject())
- return NS_ERROR_INVALID_POINTER;
- if (tmpAccWrap->GetAtkObject() != aAtkObj)
- return NS_ERROR_FAILURE;
- return NS_OK;
-}
-
// Check if aAtkObj is a valid MaiAtkObject, and return the nsAccessibleWrap
// for it.
nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj)
{
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nsnull);
- nsAccessibleWrap * tmpAccWrap = MAI_ATK_OBJECT(aAtkObj)->accWrap;
- NS_ENSURE_TRUE(tmpAccWrap != nsnull, nsnull);
+ nsAccessibleWrap *tmpAccWrap = MAI_ATK_OBJECT(aAtkObj)->accWrap;
+
+ // Check if AccessibleWrap was deconstructed
+ if (tmpAccWrap == nsnull) {
+ return nsnull;
+ }
+
NS_ENSURE_TRUE(tmpAccWrap->GetAtkObject() == aAtkObj, nsnull);
+
+ nsRefPtr<nsApplicationAccessibleWrap> appAccWrap =
+ nsAccessNode::GetApplicationAccessible();
+ nsAccessibleWrap* tmpAppAccWrap =
+ NS_STATIC_CAST(nsAccessibleWrap*, appAccWrap.get());
+
+ if (tmpAppAccWrap != tmpAccWrap && !tmpAccWrap->IsValidObject())
+ return nsnull;
+
return tmpAccWrap;
}
NS_IMETHODIMP
nsAccessibleWrap::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
{
nsresult rv = nsAccessible::FireAccessibleEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAccessible> accessible;
aEvent->GetAccessible(getter_AddRefs(accessible));
- nsIAccessible *tmpAccessible = accessible;
- nsAccessibleWrap *accWrap = NS_STATIC_CAST(nsAccessibleWrap*, tmpAccessible);
- NS_ENSURE_TRUE(accWrap, NS_ERROR_FAILURE);
-
- AtkObject *atkObj = accWrap->GetAtkObject();
- NS_ENSURE_TRUE(atkObj, NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
PRUint32 type = 0;
rv = aEvent->GetEventType(&type);
NS_ENSURE_SUCCESS(rv, rv);
+ AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accessible);
+
+ // We don't create ATK objects for nsIAccessible plain text leaves,
+ // just return NS_OK in such case
+ if (!atkObj) {
+ NS_ASSERTION(type == nsIAccessibleEvent::EVENT_SHOW ||
+ type == nsIAccessibleEvent::EVENT_HIDE,
+ "Event other than SHOW and HIDE fired for plain text leaves");
+ return NS_OK;
+ }
+
switch (type) {
case nsIAccessibleEvent::EVENT_STATE_CHANGE:
return FireAtkStateChangeEvent(aEvent, atkObj);
case nsIAccessibleEvent::EVENT_TEXT_CHANGED:
return FireAtkTextChangedEvent(aEvent, atkObj);
case nsIAccessibleEvent::EVENT_PROPERTY_CHANGED:
--- a/accessible/src/atk/nsAccessibleWrap.h
+++ b/accessible/src/atk/nsAccessibleWrap.h
@@ -71,47 +71,54 @@ enum AtkProperty {
};
struct AtkPropertyChange {
PRInt32 type; // property type as listed above
void *oldvalue;
void *newvalue;
};
+class MaiHyperlink;
+
/**
* nsAccessibleWrap, and its descendents in atk directory provide the
* implementation of AtkObject.
*/
class nsAccessibleWrap: public nsAccessible
{
public:
nsAccessibleWrap(nsIDOMNode*, nsIWeakReference *aShell);
virtual ~nsAccessibleWrap();
+ NS_IMETHOD Shutdown();
#ifdef MAI_LOGGING
virtual void DumpnsAccessibleWrapInfo(int aDepth) {}
static PRInt32 mAccWrapCreated;
static PRInt32 mAccWrapDeleted;
#endif
-public:
// return the atk object for this nsAccessibleWrap
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
AtkObject * GetAtkObject(void);
+ static AtkObject * GetAtkObject(nsIAccessible * acc);
PRBool IsValidObject();
+
+ // get/set the MaiHyperlink object for this nsAccessibleWrap
+ MaiHyperlink* GetMaiHyperlink(PRBool aCreate = PR_TRUE);
+ void SetMaiHyperlink(MaiHyperlink* aMaiHyperlink);
static const char * ReturnString(nsAString &aString) {
static nsCString returnedString;
returnedString = NS_ConvertUTF16toUTF8(aString);
return returnedString.get();
}
-
+
protected:
nsresult FireAtkStateChangeEvent(nsIAccessibleEvent *aEvent,
AtkObject *aObject);
nsresult FireAtkTextChangedEvent(nsIAccessibleEvent *aEvent,
AtkObject *aObject);
nsresult FireAtkPropChangedEvent(nsIAccessibleEvent *aEvent,
AtkObject *aObject);
--- a/accessible/src/atk/nsAppRootAccessible.cpp
+++ b/accessible/src/atk/nsAppRootAccessible.cpp
@@ -39,31 +39,28 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsMai.h"
#include "nsAppRootAccessible.h"
#include "prlink.h"
#include "nsIServiceManager.h"
+#include "nsAutoPtr.h"
#include <gtk/gtk.h>
#include <atk/atk.h>
typedef GType (* AtkGetTypeType) (void);
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
static PRBool sATKChecked = PR_FALSE;
static PRLibrary *sATKLib = nsnull;
-static PRBool sInitialized = PR_FALSE;
static const char sATKLibName[] = "libatk-1.0.so.0";
static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type";
-/* app root accessible */
-static nsAppRootAccessible *sAppRoot = nsnull;
-
/* gail function pointer */
static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener,
const gchar *event_type);
static void (* gail_remove_global_event_listener) (guint remove_listener);
static AtkObject * (*gail_get_root) (void);
/* maiutil */
@@ -84,20 +81,18 @@ static void _listener_info_destroy(gpoin
static guint add_listener (GSignalEmissionHook listener,
const gchar *object_type,
const gchar *signal,
const gchar *hook_data,
guint gail_listenerid = 0);
static AtkKeyEventStruct *atk_key_event_from_gdk_event_key(GdkEventKey *key);
static gboolean notify_hf(gpointer key, gpointer value, gpointer data);
static void insert_hf(gpointer key, gpointer value, gpointer data);
-static gboolean remove_hf(gpointer key, gpointer value, gpointer data);
static gint mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event,
gpointer func_data);
-static void value_destroy_func(gpointer data);
static GHashTable *listener_list = NULL;
static gint listener_idx = 1;
#define MAI_TYPE_UTIL (mai_util_get_type ())
#define MAI_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
MAI_TYPE_UTIL, MaiUtil))
#define MAI_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
@@ -118,19 +113,25 @@ typedef void (*GnomeAccessibilityShutdow
G_END_DECLS
struct MaiUtil
{
AtkUtil parent;
GList *listener_list;
};
-struct MaiKeyListenerInfo
+struct MaiKeyEventInfo
{
- AtkKeySnoopFunc listener;
+ AtkKeyEventStruct *key_event;
+ gpointer func_data;
+};
+
+union AtkKeySnoopFuncPointer
+{
+ AtkKeySnoopFunc func_ptr;
gpointer data;
};
struct GnomeAccessibilityModule
{
const char *libName;
PRLibrary *lib;
const char *initName;
@@ -257,16 +258,17 @@ mai_util_add_global_event_listener(GSign
rc = add_listener (listener, "MaiAtkObject", split_string[1],
event_type, gail_listenerid);
}
else {
rc = add_listener (listener, split_string[1], split_string[2],
event_type);
}
+ g_strfreev(split_string);
}
return rc;
}
static void
mai_util_remove_global_event_listener(guint remove_listener)
{
if (remove_listener > 0) {
@@ -287,29 +289,23 @@ mai_util_remove_global_event_listener(gu
/* Remove the emission hook */
g_signal_remove_emission_hook(listener_info->signal_id,
listener_info->hook_id);
/* Remove the element from the hash */
g_hash_table_remove(listener_list, &tmp_idx);
}
else {
- /* do not use g_warning with such complex format args, */
- /* Forte CC can not preprocess it correctly */
- g_log((gchar *)0, G_LOG_LEVEL_WARNING,
- "Invalid listener hook_id %ld or signal_id %d\n",
- listener_info->hook_id, listener_info->signal_id);
+ g_warning("Invalid listener hook_id %ld or signal_id %d\n",
+ listener_info->hook_id, listener_info->signal_id);
}
}
else {
- /* do not use g_warning with such complex format args, */
- /* Forte CC can not preprocess it correctly */
- g_log((gchar *)0, G_LOG_LEVEL_WARNING,
- "No listener with the specified listener id %d",
- remove_listener);
+ g_warning("No listener with the specified listener id %d",
+ remove_listener);
}
}
else {
g_warning("Invalid listener_id %d", remove_listener);
}
}
static AtkKeyEventStruct *
@@ -348,99 +344,82 @@ atk_key_event_from_gdk_event_key (GdkEve
(unsigned int) event->keycode,
(unsigned long int) event->timestamp));
return event;
}
static gboolean
notify_hf(gpointer key, gpointer value, gpointer data)
{
- AtkKeyEventStruct *event = (AtkKeyEventStruct *) data;
- MaiKeyListenerInfo *info = (MaiKeyListenerInfo *)value;
-
- return (*(info->listener))(event, info->data) ? TRUE : FALSE;
-}
-
-static void
-value_destroy_func(gpointer data)
-{
- g_free(data);
+ MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
+ AtkKeySnoopFuncPointer atkKeySnoop;
+ atkKeySnoop.data = value;
+ return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE;
}
static void
insert_hf(gpointer key, gpointer value, gpointer data)
{
GHashTable *new_table = (GHashTable *) data;
g_hash_table_insert (new_table, key, value);
}
-static gboolean
-remove_hf(gpointer key, gpointer value, gpointer data)
-{
- AtkKeySnoopFunc listener = (AtkKeySnoopFunc)data;
- MaiKeyListenerInfo *info = (MaiKeyListenerInfo *)value;
- if (info->listener == listener)
- return TRUE;
- return FALSE;
-}
-
static gint
mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
{
/* notify each AtkKeySnoopFunc in turn... */
+ MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1);
gint consumed = 0;
if (key_listener_list) {
- AtkKeyEventStruct *keyEvent = atk_key_event_from_gdk_event_key(event);
GHashTable *new_hash = g_hash_table_new(NULL, NULL);
g_hash_table_foreach (key_listener_list, insert_hf, new_hash);
- consumed = g_hash_table_foreach_steal (new_hash, notify_hf, keyEvent);
+ info->key_event = atk_key_event_from_gdk_event_key (event);
+ info->func_data = func_data;
+ consumed = g_hash_table_foreach_steal (new_hash, notify_hf, info);
g_hash_table_destroy (new_hash);
- g_free (keyEvent);
+ g_free(info->key_event);
}
+ g_free(info);
return (consumed ? 1 : 0);
}
static guint
mai_util_add_key_event_listener (AtkKeySnoopFunc listener,
gpointer data)
{
NS_ENSURE_TRUE(listener, 0);
static guint key=0;
- MaiKeyListenerInfo *info = g_new0(MaiKeyListenerInfo, 1);
- NS_ENSURE_TRUE(info, 0);
-
- info->listener = listener;
- info->data = data;
if (!key_listener_list) {
- key_listener_list = g_hash_table_new_full(NULL, NULL, NULL,
- value_destroy_func);
- key_snooper_id = gtk_key_snooper_install(mai_key_snooper, NULL);
+ key_listener_list = g_hash_table_new(NULL, NULL);
+ key_snooper_id = gtk_key_snooper_install(mai_key_snooper, data);
}
+ AtkKeySnoopFuncPointer atkKeySnoop;
+ atkKeySnoop.func_ptr = listener;
g_hash_table_insert(key_listener_list, GUINT_TO_POINTER (key++),
- (gpointer)info);
+ atkKeySnoop.data);
return key;
}
static void
mai_util_remove_key_event_listener (guint remove_listener)
{
- g_hash_table_foreach_remove(key_listener_list, remove_hf,
- (gpointer)remove_listener);
+ g_hash_table_remove(key_listener_list, GUINT_TO_POINTER (remove_listener));
if (g_hash_table_size(key_listener_list) == 0) {
gtk_key_snooper_remove(key_snooper_id);
}
}
AtkObject *
mai_util_get_root(void)
{
- nsAppRootAccessible *root = nsAppRootAccessible::Create();
+ nsRefPtr<nsApplicationAccessibleWrap> root =
+ nsAccessNode::GetApplicationAccessible();
if (root)
return root->GetAtkObject();
// We've shutdown, try to use gail instead
// (to avoid assert in spi_atk_tidy_windows())
if (gail_get_root)
return gail_get_root();
@@ -506,31 +485,31 @@ add_listener (GSignalEmissionHook listen
else {
g_warning("Invalid object type %s\n", object_type);
}
return rc;
}
static nsresult LoadGtkModule(GnomeAccessibilityModule& aModule);
-nsAppRootAccessible::nsAppRootAccessible():
- nsAccessibleWrap(nsnull, nsnull),
- mChildren(nsnull)
+// nsApplicationAccessibleWrap
+
+nsApplicationAccessibleWrap::nsApplicationAccessibleWrap():
+ nsApplicationAccessible()
{
MAI_LOG_DEBUG(("======Create AppRootAcc=%p\n", (void*)this));
}
-nsAppRootAccessible::~nsAppRootAccessible()
+nsApplicationAccessibleWrap::~nsApplicationAccessibleWrap()
{
MAI_LOG_DEBUG(("======Destory AppRootAcc=%p\n", (void*)this));
}
-/* virtual functions */
-
-NS_IMETHODIMP nsAppRootAccessible::Init()
+NS_IMETHODIMP
+nsApplicationAccessibleWrap::Init()
{
// load and initialize gail library
nsresult rv = LoadGtkModule(sGail);
if (NS_SUCCEEDED(rv)) {
(*sGail.init)();
}
else {
MAI_LOG_DEBUG(("Fail to load lib: %s\n", sGail.libName));
@@ -545,29 +524,22 @@ NS_IMETHODIMP nsAppRootAccessible::Init(
rv = LoadGtkModule(sAtkBridge);
if (NS_SUCCEEDED(rv)) {
// init atk-bridge
(*sAtkBridge.init)();
}
else
MAI_LOG_DEBUG(("Fail to load lib: %s\n", sAtkBridge.libName));
- mChildren = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
- return rv;
+ return nsApplicationAccessible::Init();
}
-/* static */ void nsAppRootAccessible::Load()
+void
+nsApplicationAccessibleWrap::Unload()
{
- sInitialized = PR_TRUE;
-}
-
-/* static */ void nsAppRootAccessible::Unload()
-{
- sInitialized = PR_FALSE;
- NS_IF_RELEASE(sAppRoot);
if (sAtkBridge.lib) {
// Do not shutdown/unload atk-bridge,
// an exit function registered will take care of it
// if (sAtkBridge.shutdown)
// (*sAtkBridge.shutdown)();
// PR_UnloadLibrary(sAtkBridge.lib);
sAtkBridge.lib = NULL;
sAtkBridge.init = NULL;
@@ -585,160 +557,18 @@ NS_IMETHODIMP nsAppRootAccessible::Init(
sGail.shutdown = NULL;
}
// if (sATKLib) {
// PR_UnloadLibrary(sATKLib);
// sATKLib = nsnull;
// }
}
-NS_IMETHODIMP nsAppRootAccessible::GetName(nsAString& _retval)
-{
- nsCOMPtr<nsIStringBundleService> bundleService =
- do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-
- NS_ASSERTION(bundleService, "String bundle service must be present!");
-
- nsCOMPtr<nsIStringBundle> bundle;
- bundleService->CreateBundle("chrome://branding/locale/brand.properties",
- getter_AddRefs(bundle));
- nsXPIDLString appName;
-
- if (bundle) {
- bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
- getter_Copies(appName));
- } else {
- NS_WARNING("brand.properties not present, using default app name");
- appName.AssignLiteral("Mozilla");
- }
-
- _retval.Assign(appName);
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetDescription(nsAString& aDescription)
-{
- GetName(aDescription);
- aDescription.AppendLiteral(" Root Accessible");
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetRole(PRUint32 *aRole)
-{
- *aRole = nsIAccessibleRole::ROLE_APP_ROOT;
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetFinalRole(PRUint32 *aFinalRole)
-{
- return GetRole(aFinalRole);
-}
-
NS_IMETHODIMP
-nsAppRootAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
-{
- *aState = 0;
- if (aExtraState)
- *aExtraState = 0;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetParent(nsIAccessible ** aParent)
-{
- *aParent = nsnull;
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetChildAt(PRInt32 aChildNum,
- nsIAccessible **aChild)
-{
- PRUint32 count = 0;
- nsresult rv = NS_OK;
- *aChild = nsnull;
- if (mChildren)
- rv = mChildren->GetLength(&count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (aChildNum >= NS_STATIC_CAST(PRInt32, count) || count == 0)
- return NS_ERROR_INVALID_ARG;
-
- if (aChildNum < 0)
- aChildNum = count - 1;
-
- nsCOMPtr<nsIWeakReference> childWeakRef;
- rv = mChildren->QueryElementAt(aChildNum, NS_GET_IID(nsIWeakReference),
- getter_AddRefs(childWeakRef));
- if (childWeakRef) {
- MAI_LOG_DEBUG(("GetChildAt(%d), has weak ref\n", aChildNum));
- nsCOMPtr<nsIAccessible> childAcc = do_QueryReferent(childWeakRef);
- if (childAcc) {
- MAI_LOG_DEBUG(("GetChildAt(%d), has Acc Child ref\n", aChildNum));
- NS_IF_ADDREF(*aChild = childAcc);
- }
- else
- MAI_LOG_DEBUG(("GetChildAt(%d), NOT has Acc Child ref\n",
- aChildNum));
-
- }
- else
- MAI_LOG_DEBUG(("GetChildAt(%d), NOT has weak ref\n", aChildNum));
- return rv;
-}
-
-void nsAppRootAccessible::CacheChildren()
-{
- if (!mChildren) {
- mAccChildCount = eChildCountUninitialized;
- return;
- }
-
- if (mAccChildCount == eChildCountUninitialized) {
- nsCOMPtr<nsISimpleEnumerator> enumerator;
- mChildren->Enumerate(getter_AddRefs(enumerator));
-
- nsCOMPtr<nsIWeakReference> childWeakRef;
- nsCOMPtr<nsIAccessible> accessible;
- nsCOMPtr<nsPIAccessible> previousAccessible;
- PRBool hasMoreElements;
- while(NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreElements))
- && hasMoreElements) {
- enumerator->GetNext(getter_AddRefs(childWeakRef));
- accessible = do_QueryReferent(childWeakRef);
- if (accessible) {
- if (previousAccessible) {
- previousAccessible->SetNextSibling(accessible);
- }
- else {
- SetFirstChild(accessible);
- }
- previousAccessible = do_QueryInterface(accessible);
- previousAccessible->SetParent(this);
- }
- }
-
- PRUint32 count = 0;
- mChildren->GetLength(&count);
- mAccChildCount = NS_STATIC_CAST(PRInt32, count);
- }
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetNextSibling(nsIAccessible * *aNextSibling)
-{
- *aNextSibling = nsnull;
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetPreviousSibling(nsIAccessible * *aPreviousSibling)
-{
- *aPreviousSibling = nsnull;
- return NS_OK;
-}
-
-NS_IMETHODIMP nsAppRootAccessible::GetNativeInterface(void **aOutAccessible)
+nsApplicationAccessibleWrap::GetNativeInterface(void **aOutAccessible)
{
*aOutAccessible = nsnull;
if (!mAtkObject) {
mAtkObject =
NS_REINTERPRET_CAST(AtkObject *,
g_object_new(MAI_TYPE_ATK_OBJECT, NULL));
NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
@@ -748,29 +578,27 @@ NS_IMETHODIMP nsAppRootAccessible::GetNa
mAtkObject->layer = ATK_LAYER_INVALID;
}
*aOutAccessible = mAtkObject;
return NS_OK;
}
nsresult
-nsAppRootAccessible::AddRootAccessible(nsIAccessible *aRootAccWrap)
+nsApplicationAccessibleWrap::AddRootAccessible(nsIAccessible *aRootAccWrap)
{
NS_ENSURE_ARG_POINTER(aRootAccWrap);
- nsresult rv = NS_ERROR_FAILURE;
+ // add by weak reference
+ nsresult rv = nsApplicationAccessible::AddRootAccessible(aRootAccWrap);
+ NS_ENSURE_SUCCESS(rv, rv);
- // add by weak reference
- rv = mChildren->AppendElement(aRootAccWrap, PR_TRUE);
- InvalidateChildren();
+ AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
+ atk_object_set_parent(atkAccessible, mAtkObject);
- void* atkAccessible;
- aRootAccWrap->GetNativeInterface(&atkAccessible);
- atk_object_set_parent((AtkObject*)atkAccessible, mAtkObject);
PRUint32 count = 0;
mChildren->GetLength(&count);
g_signal_emit_by_name(mAtkObject, "children_changed::add", count - 1,
atkAccessible, NULL);
#ifdef MAI_LOGGING
if (NS_SUCCEEDED(rv)) {
MAI_LOG_DEBUG(("\nAdd RootAcc=%p OK, count=%d\n",
@@ -780,30 +608,29 @@ nsAppRootAccessible::AddRootAccessible(n
MAI_LOG_DEBUG(("\nAdd RootAcc=%p Failed, count=%d\n",
(void*)aRootAccWrap, count));
#endif
return rv;
}
nsresult
-nsAppRootAccessible::RemoveRootAccessible(nsIAccessible *aRootAccWrap)
+nsApplicationAccessibleWrap::RemoveRootAccessible(nsIAccessible *aRootAccWrap)
{
NS_ENSURE_ARG_POINTER(aRootAccWrap);
PRUint32 index = 0;
nsresult rv = NS_ERROR_FAILURE;
// we must use weak ref to get the index
nsCOMPtr<nsIWeakReference> weakPtr = do_GetWeakReference(aRootAccWrap);
rv = mChildren->IndexOf(0, weakPtr, &index);
- void* atkAccessible;
- aRootAccWrap->GetNativeInterface(&atkAccessible);
- atk_object_set_parent((AtkObject*)atkAccessible, NULL);
+ AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
+ atk_object_set_parent(atkAccessible, NULL);
g_signal_emit_by_name(mAtkObject, "children_changed::remove", index,
atkAccessible, NULL);
#ifdef MAI_LOGGING
PRUint32 count = 0;
mChildren->GetLength(&count);
if (NS_SUCCEEDED(rv)) {
@@ -818,42 +645,29 @@ nsAppRootAccessible::RemoveRootAccessibl
NS_ENSURE_SUCCESS(rv, rv);
rv = mChildren->RemoveElementAt(index);
#endif
InvalidateChildren();
return rv;
}
-nsAppRootAccessible *
-nsAppRootAccessible::Create()
+void
+nsApplicationAccessibleWrap::PreCreate()
{
if (!sATKChecked) {
sATKLib = PR_LoadLibrary(sATKLibName);
if (sATKLib) {
AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol);
if (pfn_atk_hyperlink_impl_get_type) {
g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
}
}
sATKChecked = PR_TRUE;
}
- if (!sAppRoot && sInitialized) {
- sAppRoot = new nsAppRootAccessible();
- NS_ASSERTION(sAppRoot, "OUT OF MEMORY");
- if (sAppRoot) {
- if (NS_FAILED(sAppRoot->Init())) {
- delete sAppRoot;
- sAppRoot = nsnull;
- }
- else
- NS_IF_ADDREF(sAppRoot);
- }
- }
- return sAppRoot;
}
static nsresult
LoadGtkModule(GnomeAccessibilityModule& aModule)
{
NS_ENSURE_ARG(aModule.libName);
if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
--- a/accessible/src/atk/nsAppRootAccessible.h
+++ b/accessible/src/atk/nsAppRootAccessible.h
@@ -37,65 +37,32 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_APP_ROOT_ACCESSIBLE_H__
#define __NS_APP_ROOT_ACCESSIBLE_H__
-#include "nsIMutableArray.h"
-#include "nsIAccessibleDocument.h"
-#include "nsAccessibilityService.h"
-#include "nsAccessibleWrap.h"
-#include "nsRootAccessibleWrap.h"
-
-#define MAI_TYPE_APP_ROOT (MAI_TYPE_ATK_OBJECT)
+#include "nsApplicationAccessible.h"
-/* nsAppRootAccessible is for the whole application of Mozilla.
- * Only one instance of nsAppRootAccessible exists for one Mozilla instance.
- * And this one should be created when Mozilla Startup (if accessibility
- * feature has been enabled) and destroyed when Mozilla Shutdown.
- *
- * All the accessibility objects for toplevel windows are direct children of
- * the nsAppRootAccessible instance.
- */
-class nsAppRootAccessible;
-class nsAppRootAccessible: public nsAccessibleWrap
+class nsApplicationAccessibleWrap: public nsApplicationAccessible
{
public:
- virtual ~nsAppRootAccessible();
-
- static nsAppRootAccessible *Create();
- static void Load();
static void Unload();
+ static void PreCreate();
public:
- nsAppRootAccessible();
-
- /* virtual function from nsAccessNode */
- NS_IMETHOD Init();
+ nsApplicationAccessibleWrap();
+ virtual ~nsApplicationAccessibleWrap();
- /* virtual functions from nsAccessible */
- NS_IMETHOD GetName(nsAString & aName);
- NS_IMETHOD GetDescription(nsAString & aDescription);
- NS_IMETHOD GetRole(PRUint32 *aRole);
- NS_IMETHOD GetFinalRole(PRUint32 *aFinalRole);
- NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
- NS_IMETHOD GetParent(nsIAccessible * *aParent);
- NS_IMETHOD GetNextSibling(nsIAccessible * *aNextSibling);
- NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
- NS_IMETHOD GetChildAt(PRInt32 aChildNum, nsIAccessible **aChild);
+ // nsPIAccessNode
+ NS_IMETHOD Init();
// return the atk object for app root accessible
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
- nsresult AddRootAccessible(nsIAccessible *aRootAccWrap);
- nsresult RemoveRootAccessible(nsIAccessible *aRootAccWrap);
-
-protected:
- virtual void CacheChildren();
-
-private:
- nsCOMPtr<nsIMutableArray> mChildren;
+ // nsApplicationAccessible
+ virtual nsresult AddRootAccessible(nsIAccessible *aRootAccWrap);
+ virtual nsresult RemoveRootAccessible(nsIAccessible *aRootAccWrap);
};
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */
--- a/accessible/src/atk/nsDocAccessibleWrap.cpp
+++ b/accessible/src/atk/nsDocAccessibleWrap.cpp
@@ -71,27 +71,32 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireT
{
NS_ENSURE_ARG_POINTER(aAccessible);
// First fire nsIObserver event for internal xpcom accessibility clients
nsDocAccessible::FireToolkitEvent(aEvent, aAccessible, aEventData);
nsresult rv = NS_ERROR_FAILURE;
- nsAccessibleWrap *accWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, aAccessible);
MAI_LOG_DEBUG(("\n\nReceived event: aEvent=%u, obj=0x%x, data=0x%x \n",
aEvent, aAccessible, aEventData));
+
+ AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(aAccessible);
+
// We don't create ATK objects for nsIAccessible plain text leaves,
// just return NS_OK in such case
- AtkObject *atkObj = accWrap->GetAtkObject();
if (!atkObj) {
+ NS_ASSERTION(aEvent == nsIAccessibleEvent::EVENT_SHOW ||
+ aEvent == nsIAccessibleEvent::EVENT_HIDE,
+ "Event other than SHOW and HIDE fired for plain text leaves");
return NS_OK;
}
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(atkObj);
+
AtkTableChange * pAtkTableChange = nsnull;
switch (aEvent) {
case nsIAccessibleEvent::EVENT_FOCUS:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_FOCUS\n"));
nsRefPtr<nsRootAccessible> rootAccWrap = accWrap->GetRootAccessible();
if (rootAccWrap && rootAccWrap->mActivated) {
@@ -336,18 +341,21 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireT
case nsIAccessibleEvent::EVENT_DOCUMENT_ATTRIBUTES_CHANGED:
{
MAI_LOG_DEBUG(("\n\nReceived: EVENT_DOCUMENT_ATTRIBUTES_CHANGED\n"));
g_signal_emit_by_name (atkObj, "attributes_changed");
rv = NS_OK;
} break;
+ case nsIAccessibleEvent::EVENT_MENUPOPUP_START:
+ // fire extra focus event, then go down to EVENT_SHOW
+ atk_focus_tracker_notify(atkObj);
+
case nsIAccessibleEvent::EVENT_SHOW:
- case nsIAccessibleEvent::EVENT_MENUPOPUP_START:
MAI_LOG_DEBUG(("\n\nReceived: EVENT_SHOW\n"));
atk_object_notify_state_change(atkObj, ATK_STATE_VISIBLE, PR_TRUE);
atk_object_notify_state_change(atkObj, ATK_STATE_SHOWING, PR_TRUE);
rv = NS_OK;
break;
case nsIAccessibleEvent::EVENT_HIDE:
case nsIAccessibleEvent::EVENT_MENUPOPUP_END:
new file mode 100755
--- /dev/null
+++ b/accessible/src/atk/nsHTMLImageAccessibleWrap.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NSHTMLIMAGEACCESSIBLEWRAP_H
+#define _NSHTMLIMAGEACCESSIBLEWRAP_H
+
+#include "nsHTMLImageAccessible.h"
+
+typedef class nsHTMLImageAccessible nsHTMLImageAccessibleWrap;
+
+#endif
+
new file mode 100644
--- /dev/null
+++ b/accessible/src/atk/nsHTMLTableAccessibleWrap.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NSHTMLTABLEACCESSIBLEWRAP_H
+#define _NSHTMLTABLEACCESSIBLEWRAP_H
+
+#include "nsHTMLTableAccessible.h"
+
+typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
+
+typedef class nsHTMLTableHeadAccessible nsHTMLTableHeadAccessibleWrap;
+
+#endif
+
new file mode 100755
--- /dev/null
+++ b/accessible/src/atk/nsHyperTextAccessibleWrap.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Alexander Surkov <surkov.alexander@gmail.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NSHYPERTEXTACCESSIBLEWRAP_H
+#define _NSHYPERTEXTACCESSIBLEWRAP_H
+
+#include "nsHyperTextAccessible.h"
+
+typedef class nsHyperTextAccessible nsHyperTextAccessibleWrap;
+
+#endif
+
--- a/accessible/src/atk/nsMai.h
+++ b/accessible/src/atk/nsMai.h
@@ -76,12 +76,11 @@ PR_END_MACRO
#define IS_MAI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
MAI_TYPE_ATK_OBJECT))
#define IS_MAI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
MAI_TYPE_ATK_OBJECT))
#define MAI_ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
MAI_TYPE_ATK_OBJECT, \
MaiAtkObjectClass))
GType mai_atk_object_get_type(void);
-nsresult CheckMaiAtkObject(AtkObject *aAtkObj);
nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj);
#endif /* __NS_MAI_H__ */
--- a/accessible/src/atk/nsMaiHyperlink.cpp
+++ b/accessible/src/atk/nsMaiHyperlink.cpp
@@ -126,27 +126,20 @@ mai_atk_hyperlink_get_type(void)
MaiHyperlink::MaiHyperlink(nsIAccessibleHyperLink *aAcc):
mHyperlink(aAcc),
mMaiAtkHyperlink(nsnull)
{
}
MaiHyperlink::~MaiHyperlink()
{
- if (mMaiAtkHyperlink)
+ if (mMaiAtkHyperlink) {
+ MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = nsnull;
g_object_unref(mMaiAtkHyperlink);
-}
-
-// MaiHyperlink use its nsIAccessibleHyperlink raw pointer as ID
-NS_IMETHODIMP MaiHyperlink::GetUniqueID(void **aUniqueID)
-{
- if (!mHyperlink)
- return NS_ERROR_FAILURE;
- *aUniqueID = NS_STATIC_CAST(void*, mHyperlink.get());
- return NS_OK;
+ }
}
AtkHyperlink *
MaiHyperlink::GetAtkHyperlink(void)
{
NS_ENSURE_TRUE(mHyperlink, nsnull);
if (mMaiAtkHyperlink)
@@ -207,63 +200,59 @@ classInitCB(AtkHyperlinkClass *aClass)
void
finalizeCB(GObject *aObj)
{
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
if (!MAI_IS_ATK_HYPERLINK(aObj))
return;
- MaiAtkHyperlink *maiHyperlink = MAI_ATK_HYPERLINK(aObj);
- if (maiHyperlink->uri)
- g_free(maiHyperlink->uri);
- maiHyperlink->maiHyperlink = nsnull;
+ MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aObj);
+ if (maiAtkHyperlink->uri)
+ g_free(maiAtkHyperlink->uri);
+ maiAtkHyperlink->maiHyperlink = nsnull;
/* call parent finalize function */
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize(aObj);
}
gchar *
getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, nsnull);
- MaiAtkHyperlink *maiHyperlink = MAI_ATK_HYPERLINK(aLink);
- if (maiHyperlink->uri)
- return g_strdup(maiHyperlink->uri);
+ MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aLink);
+ if (maiAtkHyperlink->uri)
+ return g_strdup(maiAtkHyperlink->uri);
nsCOMPtr<nsIURI> uri;
nsresult rv = accHyperlink->GetURI(aLinkIndex,getter_AddRefs(uri));
if (NS_FAILED(rv) || !uri)
return nsnull;
nsCAutoString cautoStr;
rv = uri->GetSpec(cautoStr);
- maiHyperlink->uri = ToNewCString(cautoStr);
- return g_strdup(maiHyperlink->uri);
+ maiAtkHyperlink->uri = ToNewCString(cautoStr);
+ return g_strdup(maiAtkHyperlink->uri);
}
AtkObject *
getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, nsnull);
nsCOMPtr<nsIAccessible> accObj;
- nsresult rv = accHyperlink->GetObject(aLinkIndex, getter_AddRefs(accObj));
- NS_ENSURE_SUCCESS(rv, nsnull);
- AtkObject *atkObj = nsnull;
- if (accObj) {
- nsIAccessible *tmpObj = accObj;
- nsAccessibleWrap *accWrap = NS_STATIC_CAST(nsAccessibleWrap *, tmpObj);
- atkObj = accWrap->GetAtkObject();
- }
- //no need to add ref it, because it is "get" not "ref" ???
+ accHyperlink->GetObject(aLinkIndex, getter_AddRefs(accObj));
+ NS_ENSURE_TRUE(accObj, nsnull);
+
+ AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accObj);
+ //no need to add ref it, because it is "get" not "ref"
return atkObj;
}
gint
getEndIndexCB(AtkHyperlink *aLink)
{
nsIAccessibleHyperLink *accHyperlink = get_accessible_hyperlink(aLink);
NS_ENSURE_TRUE(accHyperlink, -1);
--- a/accessible/src/atk/nsMaiHyperlink.h
+++ b/accessible/src/atk/nsMaiHyperlink.h
@@ -51,23 +51,22 @@ typedef struct _AtkHyperlink
* MaiHyperlink is a auxiliary class for MaiInterfaceHyperText.
*/
class MaiHyperlink
{
public:
MaiHyperlink(nsIAccessibleHyperLink *aAcc);
~MaiHyperlink();
- NS_IMETHOD GetUniqueID(void **aUniqueID);
public:
AtkHyperlink *GetAtkHyperlink(void);
nsIAccessibleHyperLink *GetAccHyperlink(void) {
return mHyperlink;
}
protected:
- nsCOMPtr<nsIAccessibleHyperLink> mHyperlink;
+ nsIAccessibleHyperLink *mHyperlink;
AtkHyperlink *mMaiAtkHyperlink;
public:
static nsresult Initialize(AtkHyperlink *aObj, MaiHyperlink *aClass);
};
#endif /* __MAI_HYPERLINK_H__ */
--- a/accessible/src/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/src/atk/nsMaiInterfaceAction.cpp
@@ -54,62 +54,67 @@ actionInterfaceInitCB(AtkActionIface *aI
aIface->get_keybinding = getKeyBindingCB;
aIface->get_name = getActionNameCB;
}
gboolean
doActionCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsresult rv = accWrap->DoAction(aActionIndex);
return (NS_FAILED(rv)) ? FALSE : TRUE;
}
gint
getActionCountCB(AtkAction *aAction)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
PRUint8 num = 0;
nsresult rv = accWrap->GetNumActions(&num);
return (NS_FAILED(rv)) ? 0 : NS_STATIC_CAST(gint, num);
}
const gchar *
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsAutoString description;
nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
NS_ENSURE_SUCCESS(rv, nsnull);
return nsAccessibleWrap::ReturnString(description);
}
const gchar *
getActionNameCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsAutoString autoStr;
nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
NS_ENSURE_SUCCESS(rv, nsnull);
return nsAccessibleWrap::ReturnString(autoStr);
}
const gchar *
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
//return all KeyBindings including accesskey and shortcut
nsAutoString allKeyBinding;
//get accesskey
nsAutoString accessKey;
nsresult rv = accWrap->GetKeyboardShortcut(accessKey);
--- a/accessible/src/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/src/atk/nsMaiInterfaceComponent.cpp
@@ -64,35 +64,34 @@ componentInterfaceInitCB(AtkComponentIfa
}
AtkObject *
refAccessibleAtPointCB(AtkComponent *aComponent,
gint aAccX, gint aAccY,
AtkCoordType aCoordType)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
// or ATK_XY_SCREEN what is definition this in nsIAccessible ???
if (aCoordType == ATK_XY_WINDOW) {
/* deal with the coord type */
}
nsCOMPtr<nsIAccessible> pointAcc;
- nsresult rv = accWrap->GetChildAtPoint(aAccX, aAccY, getter_AddRefs(pointAcc));
- if (NS_FAILED(rv))
+ accWrap->GetChildAtPoint(aAccX, aAccY, getter_AddRefs(pointAcc));
+ if (!pointAcc) {
return nsnull;
+ }
- nsIAccessible *tmpAcc = pointAcc;
- nsAccessibleWrap *tmpAccWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
- AtkObject *atkObj = tmpAccWrap->GetAtkObject();
- if (!atkObj)
- return nsnull;
- g_object_ref(atkObj);
+ AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(pointAcc);
+ if (atkObj) {
+ g_object_ref(atkObj);
+ }
return atkObj;
}
void
getExtentsCB(AtkComponent *aComponent,
gint *aAccX,
gint *aAccY,
gint *aAccWidth,
@@ -145,13 +144,14 @@ getExtentsCB(AtkComponent *aComponent,
*aAccWidth = nsAccWidth;
*aAccHeight = nsAccHeight;
}
gboolean
grabFocusCB(AtkComponent *aComponent)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsresult rv = accWrap->TakeFocus();
return (NS_FAILED(rv)) ? FALSE : TRUE;
}
--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
@@ -35,69 +35,93 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccessibleWrap.h"
#include "nsMaiInterfaceDocument.h"
+#include "nsAccessibilityAtoms.h"
const char *const kDocTypeName = "W3C-doctype";
const char *const kDocUrlName = "DocURL";
const char *const kMimeTypeName = "MimeType";
void
documentInterfaceInitCB(AtkDocumentIface *aIface)
{
NS_ASSERTION(aIface, "Invalid Interface");
if(!aIface)
return;
/*
- * We don't support get_document, get_locale and set_attribute right now.
+ * We don't support get_document or set_attribute right now.
* get_document_type is deprecated, we return DocType in
* get_document_attribute_value and get_document_attributes instead.
*/
aIface->get_document_attributes = getDocumentAttributesCB;
aIface->get_document_attribute_value = getDocumentAttributeValueCB;
+ aIface->get_document_locale = getDocumentLocaleCB;
+}
+
+const gchar *
+getDocumentLocaleCB(AtkDocument *aDocument)
+{
+ nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
+ if (!accWrap)
+ return nsnull;
+
+ nsCOMPtr<nsIAccessNode> docAccessNode;
+ accWrap->QueryInterface(NS_GET_IID(nsIAccessNode),
+ getter_AddRefs(docAccessNode));
+ NS_ENSURE_TRUE(docAccessNode, nsnull);
+
+ nsAutoString locale;
+ docAccessNode->GetLanguage(locale);
+ if (locale.IsEmpty()) {
+ return nsnull;
+ }
+ return nsAccessibleWrap::ReturnString(locale);
}
const gchar *
getDocumentTypeCB(AtkDocument *aDocument)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
getter_AddRefs(accDocument));
NS_ENSURE_TRUE(accDocument, nsnull);
- nsAutoString aMimeType;
- nsresult rv = accDocument->GetMimeType(aMimeType);
+ nsAutoString mimeType;
+ nsresult rv = accDocument->GetMimeType(mimeType);
NS_ENSURE_SUCCESS(rv, nsnull);
- return nsAccessibleWrap::ReturnString(aMimeType);
+ return nsAccessibleWrap::ReturnString(mimeType);
}
static inline GSList *
prependToList(GSList *aList, const char *const aName, const nsAutoString &aValue)
{
// libspi will free these
AtkAttribute *atkAttr = (AtkAttribute *)g_malloc(sizeof(AtkAttribute));
atkAttr->name = g_strdup(aName);
atkAttr->value = g_strdup(NS_ConvertUTF16toUTF8(aValue).get());
return g_slist_prepend(aList, atkAttr);
}
AtkAttributeSet *
getDocumentAttributesCB(AtkDocument *aDocument)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
getter_AddRefs(accDocument));
NS_ENSURE_TRUE(accDocument, nsnull);
// according to atkobject.h, AtkAttributeSet is a GSList
GSList *attributes = nsnull;
@@ -121,17 +145,18 @@ getDocumentAttributesCB(AtkDocument *aDo
return attributes;
}
const gchar *
getDocumentAttributeValueCB(AtkDocument *aDocument,
const gchar *aAttrName)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
getter_AddRefs(accDocument));
NS_ENSURE_TRUE(accDocument, nsnull);
nsresult rv;
nsAutoString attrValue;
--- a/accessible/src/atk/nsMaiInterfaceDocument.h
+++ b/accessible/src/atk/nsMaiInterfaceDocument.h
@@ -44,14 +44,15 @@
#include "nsMai.h"
#include "nsIAccessibleDocument.h"
G_BEGIN_DECLS
/* document interface callbacks */
void documentInterfaceInitCB(AtkDocumentIface *aIface);
AtkAttributeSet* getDocumentAttributesCB(AtkDocument *aDocument);
+const gchar* getDocumentLocaleCB(AtkDocument *aDocument);
const gchar* getDocumentAttributeValueCB(AtkDocument *aDocument,
const gchar *aAttrName);
G_END_DECLS
#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
@@ -60,17 +60,18 @@ editableTextInterfaceInitCB(AtkEditableT
/* static, callbacks for atkeditabletext virutal functions */
gboolean
setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
gint aStartOffset, gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleEditableText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, FALSE);
nsCOMPtr<nsISupports> attrSet;
/* how to insert attributes into nsISupports ??? */
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
@@ -48,19 +48,21 @@ hyperlinkImplInterfaceInitCB(AtkHyperlin
aIface->get_hyperlink = getHyperlinkCB;
}
AtkHyperlink*
getHyperlinkCB(AtkHyperlinkImpl *aImpl)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleHyperLink> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperLink),
getter_AddRefs(accHyperlink));
NS_ENSURE_TRUE(accHyperlink, nsnull);
- MaiHyperlink *maiHyperlink = new MaiHyperlink(accHyperlink);
+ MaiHyperlink *maiHyperlink = accWrap->GetMaiHyperlink();
+ NS_ENSURE_TRUE(maiHyperlink, nsnull);
return maiHyperlink->GetAtkHyperlink();
}
--- a/accessible/src/atk/nsMaiInterfaceHypertext.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHypertext.cpp
@@ -50,39 +50,46 @@ hypertextInterfaceInitCB(AtkHypertextIfa
aIface->get_link = getLinkCB;
aIface->get_n_links = getLinkCountCB;
aIface->get_link_index = getLinkIndexCB;
}
AtkHyperlink *
getLinkCB(AtkHypertext *aText, gint aLinkIndex)
{
- nsresult rv;
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
- nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
+ nsCOMPtr<nsIAccessibleHyperText> hyperText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
- getter_AddRefs(accHyperlink));
- NS_ENSURE_TRUE(accHyperlink, nsnull);
+ getter_AddRefs(hyperText));
+ NS_ENSURE_TRUE(hyperText, nsnull);
nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
- rv = accHyperlink->GetLink(aLinkIndex, getter_AddRefs(hyperLink));
+ nsresult rv = hyperText->GetLink(aLinkIndex, getter_AddRefs(hyperLink));
if (NS_FAILED(rv) || !hyperLink)
return nsnull;
- MaiHyperlink *maiHyperlink = new MaiHyperlink(hyperLink);
+ nsCOMPtr<nsIAccessible> hyperLinkAcc(do_QueryInterface(hyperLink));
+ AtkObject *hyperLinkAtkObj = nsAccessibleWrap::GetAtkObject(hyperLinkAcc);
+ nsAccessibleWrap *accChild = GetAccessibleWrap(hyperLinkAtkObj);
+ NS_ENSURE_TRUE(accChild, nsnull);
+
+ MaiHyperlink *maiHyperlink = accChild->GetMaiHyperlink();
+ NS_ENSURE_TRUE(maiHyperlink, nsnull);
return maiHyperlink->GetAtkHyperlink();
}
gint
getLinkCountCB(AtkHypertext *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
getter_AddRefs(accHyperlink));
NS_ENSURE_TRUE(accHyperlink, -1);
PRInt32 count = -1;
nsresult rv = accHyperlink->GetLinks(&count);
@@ -90,17 +97,18 @@ getLinkCountCB(AtkHypertext *aText)
return count;
}
gint
getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
getter_AddRefs(accHyperlink));
NS_ENSURE_TRUE(accHyperlink, -1);
PRInt32 index = -1;
nsresult rv = accHyperlink->GetLinkIndex(aCharIndex, &index);
--- a/accessible/src/atk/nsMaiInterfaceSelection.cpp
+++ b/accessible/src/atk/nsMaiInterfaceSelection.cpp
@@ -55,117 +55,123 @@ selectionInterfaceInitCB(AtkSelectionIfa
aIface->remove_selection = removeSelectionCB;
aIface->select_all_selection = selectAllSelectionCB;
}
gboolean
addSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
return NS_SUCCEEDED(accSelection->AddChildToSelection(i));
}
gboolean
clearSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
return NS_SUCCEEDED(accSelection->ClearSelection());
}
AtkObject *
refSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, nsnull);
- AtkObject *atkObj = nsnull;
nsCOMPtr<nsIAccessible> accSelect;
- nsresult rv = accSelection->RefSelection(i, getter_AddRefs(accSelect));
- if (NS_SUCCEEDED(rv) && accSelect) {
- nsIAccessible *tmpAcc = accSelect;
- nsAccessibleWrap *refAccWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
- atkObj = refAccWrap->GetAtkObject();
- if (atkObj)
- g_object_ref(atkObj);
+ accSelection->RefSelection(i, getter_AddRefs(accSelect));
+ if (!accSelect) {
+ return nsnull;
+ }
+
+ AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accSelect);
+ if (atkObj) {
+ g_object_ref(atkObj);
}
return atkObj;
}
gint
getSelectionCountCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, -1);
PRInt32 num = 0;
nsresult rv = accSelection->GetSelectionCount(&num);
return (NS_FAILED(rv)) ? -1 : num;
}
gboolean
isChildSelectedCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
PRBool result = FALSE;
nsresult rv = accSelection->IsChildSelected(i, &result);
return (NS_FAILED(rv)) ? FALSE : result;
}
gboolean
removeSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
nsresult rv = accSelection->RemoveChildFromSelection(i);
return (NS_FAILED(rv)) ? FALSE : TRUE;
}
gboolean
selectAllSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
getter_AddRefs(accSelection));
NS_ENSURE_TRUE(accSelection, FALSE);
PRBool result = FALSE;
nsresult rv = accSelection->SelectAllSelection(&result);
--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
@@ -67,42 +67,42 @@ tableInterfaceInitCB(AtkTableIface *aIfa
aIface->is_selected = isCellSelectedCB;
}
/* static */
AtkObject*
refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessible> cell;
nsresult rv = accTable->CellRefAt(aRow, aColumn,getter_AddRefs(cell));
if (NS_FAILED(rv) || !cell)
return nsnull;
- nsIAccessible *tmpAcc = cell;
- nsAccessibleWrap *cellAccWrap = NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
-
- AtkObject *atkObj = cellAccWrap->GetAtkObject();
- if (atkObj)
- g_object_ref(atkObj);
- return atkObj;
+ AtkObject *cellAtkObj = nsAccessibleWrap::GetAtkObject(cell);
+ if (cellAtkObj) {
+ g_object_ref(cellAtkObj);
+ }
+ return cellAtkObj;
}
gint
getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 index;
nsresult rv = accTable->GetIndexAt(aRow, aColumn, &index);
@@ -110,17 +110,18 @@ getIndexAtCB(AtkTable *aTable, gint aRow
return NS_STATIC_CAST(gint, index);
}
gint
getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 col;
nsresult rv = accTable->GetColumnAtIndex(aIndex, &col);
@@ -128,17 +129,18 @@ getColumnAtIndexCB(AtkTable *aTable, gin
return NS_STATIC_CAST(gint, col);
}
gint
getRowAtIndexCB(AtkTable *aTable, gint aIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 row;
nsresult rv = accTable->GetRowAtIndex(aIndex, &row);
@@ -146,17 +148,18 @@ getRowAtIndexCB(AtkTable *aTable, gint a
return NS_STATIC_CAST(gint, row);
}
gint
getColumnCountCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 count;
nsresult rv = accTable->GetColumns(&count);
@@ -164,17 +167,18 @@ getColumnCountCB(AtkTable *aTable)
return NS_STATIC_CAST(gint, count);
}
gint
getRowCountCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 count;
nsresult rv = accTable->GetRows(&count);
@@ -183,17 +187,18 @@ getRowCountCB(AtkTable *aTable)
return NS_STATIC_CAST(gint, count);
}
gint
getColumnExtentAtCB(AtkTable *aTable,
gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 extent;
nsresult rv = accTable->GetColumnExtentAt(aRow, aColumn, &extent);
@@ -202,17 +207,18 @@ getColumnExtentAtCB(AtkTable *aTable,
return NS_STATIC_CAST(gint, extent);
}
gint
getRowExtentAtCB(AtkTable *aTable,
gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
PRInt32 extent;
nsresult rv = accTable->GetRowExtentAt(aRow, aColumn, &extent);
@@ -220,40 +226,38 @@ getRowExtentAtCB(AtkTable *aTable,
return NS_STATIC_CAST(gint, extent);
}
AtkObject*
getCaptionCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessible> caption;
nsresult rv = accTable->GetCaption(getter_AddRefs(caption));
if (NS_FAILED(rv) || !caption)
return nsnull;
- nsIAccessible *tmpAcc = caption;
- nsAccessibleWrap *captionAccWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
-
- return captionAccWrap->GetAtkObject();
+ return nsAccessibleWrap::GetAtkObject(caption);
}
const gchar*
getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsAutoString autoStr;
nsresult rv = accTable->GetColumnDescription(aColumn, autoStr);
@@ -261,17 +265,18 @@ getColumnDescriptionCB(AtkTable *aTable,
return nsAccessibleWrap::ReturnString(autoStr);
}
AtkObject*
getColumnHeaderCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = accTable->GetColumnHeader(getter_AddRefs(header));
@@ -286,28 +291,25 @@ getColumnHeaderCB(AtkTable *aTable, gint
//
// 2. "GetColumnHeader" defined in nsIAccessibleTable returns
// nsXULTreeColumnsAccessibleWrap, which exports nsIAccessibleTable and is
// "ROLE_LIST".
nsCOMPtr<nsIAccessible> accHeader;
header->CellRefAt(0, aColumn, getter_AddRefs(accHeader));
NS_ENSURE_TRUE(accHeader, nsnull);
- nsIAccessible *tmpAcc = accHeader;
- nsAccessibleWrap *headerAccWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
-
- return headerAccWrap->GetAtkObject();
+ return nsAccessibleWrap::GetAtkObject(accHeader);
}
const gchar*
getRowDescriptionCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsAutoString autoStr;
nsresult rv = accTable->GetRowDescription(aRow, autoStr);
@@ -315,49 +317,47 @@ getRowDescriptionCB(AtkTable *aTable, gi
return nsAccessibleWrap::ReturnString(autoStr);
}
AtkObject*
getRowHeaderCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = accTable->GetRowHeader(getter_AddRefs(header));
NS_ENSURE_SUCCESS(rv, nsnull);
nsCOMPtr<nsIAccessible> accHeader(do_QueryInterface(header));
- NS_ENSURE_TRUE(accTable, nsnull);
+ NS_ENSURE_TRUE(accHeader, nsnull);
- nsIAccessible *tmpAcc = accHeader;
- nsAccessibleWrap *headerAccWrap =
- NS_STATIC_CAST(nsAccessibleWrap *, tmpAcc);
-
- return headerAccWrap->GetAtkObject();
+ return nsAccessibleWrap::GetAtkObject(accHeader);
}
AtkObject*
getSummaryCB(AtkTable *aTable)
{
/* ??? in nsIAccessibleTable, it returns a nsAString */
return nsnull;
}
gint
getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, 0);
PRUint32 size = 0;
PRInt32 *columns = NULL;
@@ -381,17 +381,18 @@ getSelectedColumnsCB(AtkTable *aTable, g
*aSelected = atkColumns;
return size;
}
gint
getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, 0);
PRUint32 size = 0;
PRInt32 *rows = NULL;
@@ -415,49 +416,52 @@ getSelectedRowsCB(AtkTable *aTable, gint
*aSelected = atkRows;
return size;
}
gboolean
isColumnSelectedCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, FALSE);
PRBool outValue;
nsresult rv = accTable->IsColumnSelected(aColumn, &outValue);
return NS_FAILED(rv) ? FALSE : NS_STATIC_CAST(gboolean, outValue);
}
gboolean
isRowSelectedCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, FALSE);
PRBool outValue;
nsresult rv = accTable->IsRowSelected(aRow, &outValue);
return NS_FAILED(rv) ? FALSE : NS_STATIC_CAST(gboolean, outValue);
}
gboolean
isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, FALSE);
PRBool outValue;
nsresult rv = accTable->IsCellSelected(aRow, aColumn, &outValue);
--- a/accessible/src/atk/nsMaiInterfaceText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceText.cpp
@@ -84,17 +84,18 @@ void ConvertTexttoAsterisks(nsAccessible
aString.Replace(i, 1, NS_LITERAL_STRING("*"));
}
}
gchar *
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
nsAutoString autoStr;
nsresult rv = accText->GetText(aStartOffset, aEndOffset, autoStr);
@@ -108,17 +109,18 @@ getTextCB(AtkText *aText, gint aStartOff
}
gchar *
getTextAfterOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
nsAutoString autoStr;
PRInt32 startOffset = 0, endOffset = 0;
@@ -136,17 +138,18 @@ getTextAfterOffsetCB(AtkText *aText, gin
}
gchar *
getTextAtOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
nsAutoString autoStr;
PRInt32 startOffset = 0, endOffset = 0;
@@ -162,17 +165,18 @@ getTextAtOffsetCB(AtkText *aText, gint a
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}
gunichar
getCharacterAtOffsetCB(AtkText *aText, gint aOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, 0);
/* PRUnichar is unsigned short in Mozilla */
/* gnuichar is guint32 in glib */
@@ -191,17 +195,18 @@ getCharacterAtOffsetCB(AtkText *aText, g
}
gchar *
getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
nsAutoString autoStr;
PRInt32 startOffset = 0, endOffset = 0;
@@ -217,17 +222,18 @@ getTextBeforeOffsetCB(AtkText *aText, gi
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}
gint
getCaretOffsetCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, 0);
PRInt32 offset;
nsresult rv = accText->GetCaretOffset(&offset);
@@ -235,17 +241,18 @@ getCaretOffsetCB(AtkText *aText)
}
AtkAttributeSet *
getRunAttributesCB(AtkText *aText, gint aOffset,
gint *aStartOffset,
gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
nsCOMPtr<nsIAccessible> accessibleWithAttrs;
PRInt32 startOffset = 0, endOffset = 0;
@@ -280,19 +287,21 @@ getCharacterExtentsCB(AtkText *aText, gi
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
if (!accText)
return;
PRInt32 extY = 0, extX = 0;
PRInt32 extWidth = 0, extHeight = 0;
- PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ?
- nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
- nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
+ PRUint32 geckoCoordType;
+ if (aCoords == ATK_XY_SCREEN)
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
+ else
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
nsresult rv = accText->GetCharacterExtents(aOffset, &extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
*aX = extX;
*aY = extY;
*aWidth = extWidth;
*aHeight = extHeight;
@@ -312,19 +321,21 @@ getRangeExtentsCB(AtkText *aText, gint a
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
if (!accText)
return;
PRInt32 extY = 0, extX = 0;
PRInt32 extWidth = 0, extHeight = 0;
- PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ?
- nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
- nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
+ PRUint32 geckoCoordType;
+ if (aCoords == ATK_XY_SCREEN)
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
+ else
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
nsresult rv = accText->GetRangeExtents(aStartOffset, aEndOffset,
&extX, &extY,
&extWidth, &extHeight,
geckoCoordType);
aRect->x = extX;
aRect->y = extY;
aRect->width = extWidth;
@@ -332,17 +343,18 @@ getRangeExtentsCB(AtkText *aText, gint a
NS_ASSERTION(NS_SUCCEEDED(rv),
"MaiInterfaceText::GetRangeExtents, failed\n");
}
gint
getCharacterCountCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, 0);
+ if (!accWrap)
+ return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, 0);
PRInt32 count = 0;
nsresult rv = accText->GetCharacterCount(&count);
@@ -350,54 +362,59 @@ getCharacterCountCB(AtkText *aText)
}
gint
getOffsetAtPointCB(AtkText *aText,
gint aX, gint aY,
AtkCoordType aCoords)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, -1);
+ if (!accWrap)
+ return -1;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, -1);
PRInt32 offset = 0;
- PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ?
- nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
- nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
+ PRUint32 geckoCoordType;
+ if (aCoords == ATK_XY_SCREEN)
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
+ else
+ geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
accText->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset);
return NS_STATIC_CAST(gint, offset);
}
gint
getTextSelectionCountCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
PRInt32 selectionCount;
nsresult rv = accText->GetSelectionCount(&selectionCount);
return NS_FAILED(rv) ? 0 : selectionCount;
}
gchar *
getTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, nsnull);
+ if (!accWrap)
+ return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, nsnull);
PRInt32 startOffset = 0, endOffset = 0;
nsresult rv = accText->GetSelectionBounds(aSelectionNum,
@@ -413,67 +430,71 @@ getTextSelectionCB(AtkText *aText, gint
// set methods
gboolean
addTextSelectionCB(AtkText *aText,
gint aStartOffset,
gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, FALSE);
nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
gboolean
removeTextSelectionCB(AtkText *aText,
gint aSelectionNum)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, FALSE);
nsresult rv = accText->RemoveSelection(aSelectionNum);
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
gboolean
setTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint aStartOffset, gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, FALSE);
nsresult rv = accText->SetSelectionBounds(aSelectionNum,
aStartOffset, aEndOffset);
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
}
gboolean
setCaretOffsetCB(AtkText *aText, gint aOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
getter_AddRefs(accText));
NS_ENSURE_TRUE(accText, FALSE);
nsresult rv = accText->SetCaretOffset(aOffset);
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
@@ -125,29 +125,30 @@ getMinimumIncrementCB(AtkValue *obj, GVa
return;
nsCOMPtr<nsIAccessibleValue> accValue;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
getter_AddRefs(accValue));
if (!accValue)
return;
- memset (accValue, 0, sizeof (GValue));
+ memset (minimumIncrement, 0, sizeof (GValue));
double accDouble;
if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
return;
g_value_init (minimumIncrement, G_TYPE_DOUBLE);
g_value_set_double (minimumIncrement, accDouble);
}
gboolean
setCurrentValueCB(AtkValue *obj, const GValue *value)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
- NS_ENSURE_TRUE(accWrap, FALSE);
+ if (!accWrap)
+ return FALSE;
nsCOMPtr<nsIAccessibleValue> accValue;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
getter_AddRefs(accValue));
NS_ENSURE_TRUE(accValue, FALSE);
double accDouble =g_value_get_double (value);
return !NS_FAILED(accValue->SetCurrentValue(accDouble));
--- a/accessible/src/atk/nsRootAccessibleWrap.cpp
+++ b/accessible/src/atk/nsRootAccessibleWrap.cpp
@@ -36,202 +36,15 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsMai.h"
#include "nsRootAccessibleWrap.h"
-#include "nsAppRootAccessible.h"
-#include "nsIDOMWindow.h"
-#include "nsPIDOMWindow.h"
-#include "nsIDOMXULMultSelectCntrlEl.h"
-#include "nsIFocusController.h"
-
-#ifdef MOZ_XUL
-#include "nsIAccessibleTreeCache.h"
-#endif
-
-nsRootAccessibleWrap::nsRootAccessibleWrap(nsIDOMNode *aDOMNode,
- nsIWeakReference* aShell):
- nsRootAccessible(aDOMNode, aShell)
-{
- MAI_LOG_DEBUG(("New Root Acc=%p\n", (void*)this));
-}
-
-NS_IMETHODIMP nsRootAccessibleWrap::Init()
-{
- nsresult rv = nsRootAccessible::Init();
- nsAppRootAccessible *root = nsAppRootAccessible::Create();
- if (root) {
- root->AddRootAccessible(this);
- }
- return rv;
-}
-
-nsRootAccessibleWrap::~nsRootAccessibleWrap()
-{
- MAI_LOG_DEBUG(("Delete Root Acc=%p\n", (void*)this));
-}
-
-NS_IMETHODIMP nsRootAccessibleWrap::Shutdown()
-{
- nsAppRootAccessible *root = nsAppRootAccessible::Create();
- if (root) {
- root->RemoveRootAccessible(this);
- root = nsnull;
- }
- return nsRootAccessible::Shutdown();
-}
-
-NS_IMETHODIMP nsRootAccessibleWrap::GetParent(nsIAccessible ** aParent)
-{
- nsAppRootAccessible *root = nsAppRootAccessible::Create();
- nsresult rv = NS_OK;
- if (root) {
- NS_IF_ADDREF(*aParent = root);
- }
- else {
- *aParent = nsnull;
- rv = NS_ERROR_FAILURE;
- }
- return rv;
-}
-
-/* virtual */
-nsresult nsRootAccessibleWrap::HandleEventWithTarget(nsIDOMEvent *aEvent,
- nsIDOMNode *aTargetNode)
-{
- nsAutoString eventType;
- aEvent->GetType(eventType);
- nsAutoString localName;
- aTargetNode->GetLocalName(localName);
-
- if (eventType.EqualsLiteral("pagehide")) {
- nsRootAccessible::HandleEventWithTarget(aEvent, aTargetNode);
- return NS_OK;
- }
-
- nsCOMPtr<nsIAccessible> accessible;
- nsCOMPtr<nsIAccessibilityService> accService = GetAccService();
- accService->GetAccessibleFor(aTargetNode, getter_AddRefs(accessible));
- if (!accessible)
- return NS_OK;
-
- if (eventType.EqualsLiteral("popupshown")) {
- nsRootAccessible::HandleEventWithTarget(aEvent, aTargetNode);
- nsCOMPtr<nsIContent> content(do_QueryInterface(aTargetNode));
-
- // 1) Don't fire focus events for tooltips, that wouldn't make any sense.
- // 2) Don't fire focus events for autocomplete popups, because they
- // come up automatically while the user is typing, and setting focus
- // there would interrupt the user.
-
- // If the AT wants to know about these popups it can track the ATK state
- // change event we fire for ATK_STATE_INVISIBLE on the popup. This is
- // fired as a result of the nsIAccessibleEvent::EVENT_MENUPOPUP_START we
- // fire in the nsRootAccessible event handling for all popups.
- if (!content->NodeInfo()->Equals(nsAccessibilityAtoms::tooltip,
- kNameSpaceID_XUL) &&
- !content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
- NS_LITERAL_STRING("autocomplete"), eIgnoreCase)) {
- FireAccessibleFocusEvent(accessible, aTargetNode, aEvent);
- }
- return NS_OK;
- }
-
- nsCOMPtr<nsPIAccessible> privAcc(do_QueryInterface(accessible));
-
-#ifdef MOZ_XUL
- // If it's a tree element, need the currently selected item
- nsCOMPtr<nsIAccessible> treeItemAccessible;
- if (localName.EqualsLiteral("tree")) {
- nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
- do_QueryInterface(aTargetNode);
- if (multiSelect) {
- PRInt32 treeIndex = -1;
- multiSelect->GetCurrentIndex(&treeIndex);
- if (treeIndex >= 0) {
- nsCOMPtr<nsIAccessibleTreeCache> treeCache(do_QueryInterface(accessible));
- if (!treeCache ||
- NS_FAILED(treeCache->GetCachedTreeitemAccessible(
- treeIndex,
- nsnull,
- getter_AddRefs(treeItemAccessible))) ||
- !treeItemAccessible) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- accessible = treeItemAccessible;
- }
- }
- }
-#endif
-
- if (eventType.EqualsLiteral("focus")) {
-#ifdef MOZ_XUL
- if (treeItemAccessible) { // use focused treeitem
- privAcc = do_QueryInterface(treeItemAccessible);
- privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS,
- treeItemAccessible, nsnull);
- accessible = treeItemAccessible;
- }
- else
-#endif
- if (localName.EqualsIgnoreCase("radiogroup")) {
- // fire focus event for checked radio instead of radiogroup
- PRInt32 childCount = 0;
- accessible->GetChildCount(&childCount);
- nsCOMPtr<nsIAccessible> radioAcc;
- for (PRInt32 index = 0; index < childCount; index++) {
- accessible->GetChildAt(index, getter_AddRefs(radioAcc));
- if (radioAcc) {
- PRUint32 state = State(radioAcc);
- if (state & (nsIAccessibleStates::STATE_CHECKED |
- nsIAccessibleStates::STATE_SELECTED)) {
- break;
- }
- }
- }
- accessible = radioAcc;
- if (radioAcc) {
- privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS, radioAcc, nsnull);
- }
- }
- else if (!FireAccessibleFocusEvent(accessible, aTargetNode, aEvent)) {
- accessible = nsnull; // Focus event not fired, don't fire state change
- }
- if (accessible) {
- // Fire state change event for focus
- nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
- new nsAccStateChangeEvent(accessible,
- nsIAccessibleStates::STATE_FOCUSED,
- PR_FALSE, PR_TRUE);
- return FireAccessibleEvent(accEvent);
- }
- }
- else if (eventType.EqualsLiteral("select")) {
-#ifdef MOZ_XUL
- if (treeItemAccessible) { // it's a XUL <tree>
- // use EVENT_FOCUS instead of EVENT_SELECTION_CHANGED
- privAcc = do_QueryInterface(treeItemAccessible);
- privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS,
- treeItemAccessible, nsnull);
- }
- else
-#endif
- if (localName.LowerCaseEqualsLiteral("tabpanels")) {
- // make GOK refresh "UI-Grab" window
- privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_REORDER, accessible, nsnull);
- }
- } else {
- nsRootAccessible::HandleEventWithTarget(aEvent, aTargetNode);
- }
-
- return NS_OK;
-}
nsNativeRootAccessibleWrap::nsNativeRootAccessibleWrap(AtkObject *aAccessible):
nsRootAccessible(nsnull, nsnull)
{
g_object_ref(aAccessible);
nsAccessibleWrap::mAtkObject = aAccessible;
}
--- a/accessible/src/atk/nsRootAccessibleWrap.h
+++ b/accessible/src/atk/nsRootAccessibleWrap.h
@@ -39,37 +39,22 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_ROOT_ACCESSIBLE_WRAP_H__
#define __NS_ROOT_ACCESSIBLE_WRAP_H__
#include "nsRootAccessible.h"
-/* nsRootAccessibleWrap is the accessible class for toplevel Window.
- * The instance of nsRootAccessibleWrap will be child of MaiAppRoot instance.
+typedef nsRootAccessible nsRootAccessibleWrap;
+
+/* nsNativeRootAccessibleWrap is the accessible class for gtk+ native window.
+ * The instance of nsNativeRootAccessibleWrap is a child of MaiAppRoot instance.
* It is added into root when the toplevel window is created, and removed
* from root when the toplevel window is destroyed.
*/
-
-class nsRootAccessibleWrap: public nsRootAccessible
-{
-public:
- nsRootAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference* aShell);
- virtual ~nsRootAccessibleWrap();
-
- NS_IMETHOD Init();
- NS_IMETHOD Shutdown();
- NS_IMETHOD GetParent(nsIAccessible ** aParent);
-protected:
- virtual nsresult HandleEventWithTarget(nsIDOMEvent *aEvent,
- nsIDOMNode *aTargetNode);
-
-};
-
-// For gtk+ native window
class nsNativeRootAccessibleWrap: public nsRootAccessible
{
public:
nsNativeRootAccessibleWrap(AtkObject *aAccessible);
};
#endif /* __NS_ROOT_ACCESSIBLE_WRAP_H__ */
--- a/accessible/src/atk/nsXULTreeAccessibleWrap.cpp
+++ b/accessible/src/atk/nsXULTreeAccessibleWrap.cpp
@@ -59,17 +59,17 @@ nsXULTreeAccessible(aDOMNode, aShell)
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetChildCount(PRInt32 *aAccChildCount)
{
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
// get treecols count, which is cached by nsAccessibleTreeWalker
// by going through DOM structure of XUL tree
nsAccessible::GetChildCount(aAccChildCount);
- if (*aAccChildCount != eChildCountUninitialized) {
+ if (*aAccChildCount != 0 && *aAccChildCount != eChildCountUninitialized) {
// add the count of table cell (or tree item) accessibles, which are
// created and appended by XUL tree accessible implementation
PRInt32 rowCount, colCount = 1;
mTreeView->GetRowCount(&rowCount);
mFirstChild->GetChildCount(&colCount);
*aAccChildCount += rowCount * colCount;
}
@@ -104,17 +104,18 @@ NS_IMETHODIMP nsXULTreeAccessibleWrap::S
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetColumns(PRInt32 *aColumns)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIAccessible> acc;
rv = nsAccessible::GetFirstChild(getter_AddRefs(acc));
NS_ENSURE_TRUE(acc, NS_ERROR_FAILURE);
- return acc->GetChildCount(aColumns);
+ rv = acc->GetChildCount(aColumns);
+ return *aColumns > 0 ? rv : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIAccessible> acc;
nsAccessible::GetFirstChild(getter_AddRefs(acc));
@@ -354,16 +355,40 @@ NS_IMETHODIMP nsXULTreeAccessibleWrap::I
return selection->IsSelected(aRow, _retval);
}
NS_IMETHODIMP nsXULTreeAccessibleWrap::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, PRBool *_retval)
{
return IsRowSelected(aRow, _retval);
}
+NS_IMETHODIMP
+nsXULTreeAccessibleWrap::SelectRow(PRInt32 aRow)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeAccessibleWrap::SelectColumn(PRInt32 aColumn)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeAccessibleWrap::UnselectRow(PRInt32 aRow)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeAccessibleWrap::UnselectColumn(PRInt32 aColumn)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
NS_IMETHODIMP nsXULTreeAccessibleWrap::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState)
{
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
PRInt32 rowIndex;
nsresult rv = GetRowAtIndex(aIndex, &rowIndex);
nsCOMPtr<nsITreeSelection> selection;
@@ -427,17 +452,18 @@ NS_IMETHODIMP nsXULTreeColumnsAccessible
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::SetSummary(const nsAString &aSummary)
{
mSummary = aSummary;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumns(PRInt32 *aColumns)
{
- return GetChildCount(aColumns);
+ nsresult rv = GetChildCount(aColumns);
+ return *aColumns > 0 ? rv : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumnHeader(nsIAccessibleTable * *aColumnHeader)
{
// Column header not supported.
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -554,13 +580,37 @@ NS_IMETHODIMP nsXULTreeColumnsAccessible
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, PRBool *_retval)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
+NS_IMETHODIMP
+nsXULTreeColumnsAccessibleWrap::SelectRow(PRInt32 aRow)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeColumnsAccessibleWrap::SelectColumn(PRInt32 aColumn)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeColumnsAccessibleWrap::UnselectRow(PRInt32 aRow)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsXULTreeColumnsAccessibleWrap::UnselectColumn(PRInt32 aColumn)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
{
*aIsProbablyForLayout = PR_FALSE;
return NS_OK;
}
--- a/accessible/src/base/Makefile.in
+++ b/accessible/src/base/Makefile.in
@@ -69,26 +69,29 @@ REQUIRES = appshell \
xpcom \
xuldoc \
imglib2 \
$(NULL)
CPPSRCS = \
nsAccessNode.cpp \
nsAccessibleEventData.cpp \
+ nsARIAMap.cpp \
nsDocAccessible.cpp \
nsOuterDocAccessible.cpp \
nsAccessibilityAtoms.cpp \
nsAccessibilityUtils.cpp \
nsAccessibilityService.cpp \
nsAccessible.cpp \
+ nsAccessibleRelation.cpp \
nsAccessibleTreeWalker.cpp \
nsBaseWidgetAccessible.cpp \
nsFormControlAccessible.cpp \
nsRootAccessible.cpp \
+ nsApplicationAccessible.cpp \
nsCaretAccessible.cpp \
nsTextAccessible.cpp \
$(NULL)
EXPORTS = \
nsRootAccessible.h \
nsAccessibleEventData.h \
nsAccessNode.h \
new file mode 100644
--- /dev/null
+++ b/accessible/src/base/nsARIAMap.cpp
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Aaron Leventhal <aleventh@us.ibm.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsARIAMap.h"
+#include "nsIAccessibleRole.h"
+#include "nsIAccessibleStates.h"
+
+/**
+ * This list of WAI-defined roles are currently hardcoded.
+ * Eventually we will most likely be loading an RDF resource that contains this information
+ * Using RDF will also allow for role extensibility. See bug 280138.
+ *
+ * XXX Should we store attribute names in this table as atoms instead of strings?
+ * Definition of nsRoleMapEntry and nsStateMapEntry contains comments explaining this table.
+ *
+ * When no nsIAccessibleRole neum mapping exists for an ARIA role, the
+ * role will be exposed via the object attribute "xml-roles".
+ * In addition, in MSAA, the unmapped role will also be exposed as a BSTR string role.
+ *
+ * There are no nsIAccessibleRole enums for the following landmark roles:
+ * banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs
+ */
+
+static const nsStateMapEntry kEndEntry = {0, 0, 0}; // To fill in array of state mappings
+
+nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
+{
+ {"alert", nsIAccessibleRole::ROLE_ALERT, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"alertdialog", nsIAccessibleRole::ROLE_ALERT, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"application", nsIAccessibleRole::ROLE_APPLICATION, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"button", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"pressed", kBoolState, nsIAccessibleStates::STATE_PRESSED},
+ {"haspopup", kBoolState, nsIAccessibleStates::STATE_HASPOPUP}, kEndEntry},
+ {"buttonsubmit", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_DEFAULT, kEndEntry},
+ {"buttoncancel", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"checkbox", nsIAccessibleRole::ROLE_CHECKBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"checkboxtristate", nsIAccessibleRole::ROLE_CHECKBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED},
+ {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"columnheader", nsIAccessibleRole::ROLE_COLUMNHEADER, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"combobox", nsIAccessibleRole::ROLE_COMBOBOX, eNameLabelOrTitle, eHasValueMinMax, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY},
+ {"expanded", kBoolState, nsIAccessibleStates::STATE_EXPANDED},
+ {"multiselectable", kBoolState, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, kEndEntry},
+ {"description", nsIAccessibleRole::ROLE_TEXT_CONTAINER, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"dialog", nsIAccessibleRole::ROLE_DIALOG, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"document", nsIAccessibleRole::ROLE_DOCUMENT, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"grid", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_FOCUSABLE,
+ {"multiselectable", kBoolState, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"gridcell", nsIAccessibleRole::ROLE_CELL, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"group", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"label", nsIAccessibleRole::ROLE_LABEL, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"link", nsIAccessibleRole::ROLE_LINK, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_LINKED, kEndEntry},
+ {"list", nsIAccessibleRole::ROLE_LIST, eNameLabelOrTitle, eNoValue, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY},
+ {"multiselectable", kBoolState, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, kEndEntry},
+ {"listbox", nsIAccessibleRole::ROLE_LIST, eNameLabelOrTitle, eNoValue, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY},
+ {"multiselectable", kBoolState, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, kEndEntry},
+ {"listitem", nsIAccessibleRole::ROLE_LISTITEM, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
+ {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, kEndEntry},
+ {"menu", nsIAccessibleRole::ROLE_MENUPOPUP, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"menubar", nsIAccessibleRole::ROLE_MENUBAR, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"menuitem", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"haspopup", kBoolState, nsIAccessibleStates::STATE_HASPOPUP},
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
+ {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
+ {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, kEndEntry},
+ {"menuitemcheckbox", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED }, kEndEntry},
+ {"menuitemradio", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED }, kEndEntry},
+ {"option", nsIAccessibleRole::ROLE_LISTITEM, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
+ {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, kEndEntry},
+ {"progressbar", nsIAccessibleRole::ROLE_PROGRESSBAR, eNameLabelOrTitle, eHasValueMinMax, nsIAccessibleStates::STATE_READONLY,
+ {"valuenow", "unknown", nsIAccessibleStates::STATE_MIXED}, kEndEntry},
+ {"radio", nsIAccessibleRole::ROLE_RADIOBUTTON, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED}, kEndEntry},
+ {"radiogroup", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"rowheader", nsIAccessibleRole::ROLE_ROWHEADER, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"secret", nsIAccessibleRole::ROLE_PASSWORD_TEXT, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_PROTECTED,
+ kEndEntry}, // nsIAccessibleStates::EXT_STATE_SINGLE_LINE manually supported in code
+ {"separator", nsIAccessibleRole::ROLE_SEPARATOR, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"slider", nsIAccessibleRole::ROLE_SLIDER, eNameLabelOrTitle, eHasValueMinMax, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"spinbutton", nsIAccessibleRole::ROLE_SPINBUTTON, eNameLabelOrTitle, eHasValueMinMax, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry},
+ {"spreadsheet", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE | nsIAccessibleStates::STATE_FOCUSABLE,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry}, // Still supported, but deprecated in favor of grid
+ {"status", nsIAccessibleRole::ROLE_STATUSBAR, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"tab", nsIAccessibleRole::ROLE_PAGETAB, eNameOkFromChildren, eNoValue, kNoReqStates, kEndEntry},
+ {"table", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"td", nsIAccessibleRole::ROLE_CELL, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"th", nsIAccessibleRole::ROLE_CELL, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"tablist", nsIAccessibleRole::ROLE_PAGETABLIST, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"tabpanel", nsIAccessibleRole::ROLE_PROPERTYPAGE, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"textarea", nsIAccessibleRole::ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry}, // XXX nsIAccessibleStates::EXT_STATE_MULTI_LINE supported in code
+ {"textfield", nsIAccessibleRole::ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY},
+ {"haspopup", kBoolState, nsIAccessibleStates::STATE_HASPOPUP}, kEndEntry}, // XXX nsIAccessibleStates::EXT_STATE_SINGLE_LINE supported in code
+ {"toolbar", nsIAccessibleRole::ROLE_TOOLBAR, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {"tree", nsIAccessibleRole::ROLE_OUTLINE, eNameLabelOrTitle, eNoValue, kNoReqStates,
+ {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY},
+ {"multiselectable", kBoolState, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, kEndEntry},
+ {"treeitem", nsIAccessibleRole::ROLE_OUTLINEITEM, eNameOkFromChildren, eNoValue, kNoReqStates,
+ {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
+ {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
+ {"expanded", kBoolState, nsIAccessibleStates::STATE_EXPANDED},
+ {"expanded", "false", nsIAccessibleStates::STATE_COLLAPSED},
+ {"checked", kBoolState, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
+ {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
+ {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE},},
+ {"treegroup", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry},
+ {nsnull, nsIAccessibleRole::ROLE_NOTHING, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry} // Last item
+};
+
+/**
+ * Universal states:
+ * The following state rules are applied to any accessible element,
+ * whether there is an ARIA role or not:
+ */
+nsStateMapEntry nsARIAMap::gWAIUnivStateMap[] = {
+ {"disabled", kBoolState, nsIAccessibleStates::STATE_UNAVAILABLE},
+ {"required", kBoolState, nsIAccessibleStates::STATE_REQUIRED},
+ {"invalid", kBoolState, nsIAccessibleStates::STATE_INVALID},
+ kEndEntry
+};
+
new file mode 100644
--- /dev/null
+++ b/accessible/src/base/nsARIAMap.h
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Aaron Leventhal <aleventh@us.ibm.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _nsARIAMap_H_
+#define _nsARIAMap_H_
+
+#include "prtypes.h"
+
+// Name mapping rule: can the name be computed from descendants?
+enum ENameRule
+{
+ // eNameLabelOrTitle:
+ // Collect name from:
+ // 1) The content subtrees pointed to by labelledby
+ // which contains the IDs for the label content, or if unspecified
+ // 2) The title attribute if specified
+ eNameLabelOrTitle,
+
+ // eNameOkFromChildren
+ // Collect name from:
+ // 1) The content subtrees pointed to by labelledby
+ // which contains the IDs for the label content, or if un specified
+ // 2) The text and text equivalents from descendents,
+ // as well as the value of controls, collected in depth-first order, or if empty
+ // 3) The title attribute if specified
+ eNameOkFromChildren
+};
+
+// Is nsIAccessible value supported for this role or not?
+enum EValueRule
+{
+ eNoValue,
+ eHasValueMinMax // Supports value, min and max from aaa:valuenow, valuemin and valuemax
+};
+
+// Used for an nsStateMapEntry if a given state attribute supports "true" and "false"
+#define kBoolState 0
+
+// Used in nsRoleMapEntry.state if no nsIAccessibleStates are automatic for a given role
+#define kNoReqStates 0
+
+// For this name and value pair, what is the nsIAccessibleStates mapping.
+// nsStateMapEntry.state
+struct nsStateMapEntry
+{
+ const char* attributeName; // magic value of nsnull means last entry in map
+ const char* attributeValue; // magic value of kBoolState (0) means supports "true" and "false"
+ PRUint32 state; // If match, this is the nsIAccessibleStates to map to
+};
+
+// For each ARIA role, this maps the nsIAccessible information
+struct nsRoleMapEntry
+{
+ // ARIA role: string representation such as "button"
+ const char *roleString;
+
+ // Role mapping rule: maps to this nsIAccessibleRole
+ PRUint32 role;
+
+ // Name mapping rule: how to compute nsIAccessible name
+ ENameRule nameRule;
+
+ // Value mapping rule: how to compute nsIAccessible value
+ EValueRule valueRule;
+
+ // Automatic state mapping rule: always include in nsIAccessibleStates
+ PRUint32 state; // or kNoReqStates if no nsIAccessibleStates are automatic for this role.
+
+ // ARIA properties supported for this role
+ // (in other words, the aaa:foo attribute to nsIAccessibleStates mapping rules)
+ // Currently you cannot have unlimited mappings, because
+ // a variable sized array would not allow the use of
+ // C++'s struct initialization feature.
+ nsStateMapEntry attributeMap1;
+ nsStateMapEntry attributeMap2;
+ nsStateMapEntry attributeMap3;
+ nsStateMapEntry attributeMap4;
+ nsStateMapEntry attributeMap5;
+ nsStateMapEntry attributeMap6;
+ nsStateMapEntry attributeMap7;
+};
+
+/**
+ * These are currently initialized (hardcoded) in nsARIAMap.cpp,
+ * and provide the mappings for WAI-ARIA roles and properties using the
+ * structs defined in this file.
+ */
+struct nsARIAMap
+{
+ static nsRoleMapEntry gWAIRoleMap[];
+ static nsStateMapEntry gWAIUnivStateMap[];
+};
+
+#endif
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -43,47 +43,59 @@
#include "nsIAccessibilityService.h"
#include "nsIAccessibleDocument.h"
#include "nsPIAccessibleDocument.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
#include "nsIDocumentViewer.h"
#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
+#include "nsIDOMHTMLDocument.h"
+#include "nsIDOMHTMLElement.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIFrame.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsITimer.h"
#include "nsRootAccessible.h"
#include "nsIFocusController.h"
+#include "nsIObserverService.h"
+
+#ifdef MOZ_ACCESSIBILITY_ATK
+#include "nsAppRootAccessible.h"
+#else
+#include "nsApplicationAccessibleWrap.h"
+#endif
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
nsIStringBundle *nsAccessNode::gStringBundle = 0;
nsIStringBundle *nsAccessNode::gKeyStringBundle = 0;
nsITimer *nsAccessNode::gDoCommandTimer = 0;
nsIDOMNode *nsAccessNode::gLastFocusedNode = 0;
PRBool nsAccessNode::gIsAccessibilityActive = PR_FALSE;
PRBool nsAccessNode::gIsCacheDisabled = PR_FALSE;
PRBool nsAccessNode::gIsFormFillEnabled = PR_FALSE;
nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> nsAccessNode::gGlobalDocAccessibleCache;
+nsApplicationAccessibleWrap *nsAccessNode::gApplicationAccessible = nsnull;
+
nsIAccessibilityService *nsAccessNode::sAccService = nsnull;
nsIAccessibilityService *nsAccessNode::GetAccService()
{
if (!sAccService) {
nsresult rv = CallGetService("@mozilla.org/accessibilityService;1",
&sAccService);
NS_ASSERTION(NS_SUCCEEDED(rv), "No accessibility service");
}
@@ -192,16 +204,43 @@ NS_IMETHODIMP nsAccessNode::GetUniqueID(
NS_IMETHODIMP nsAccessNode::GetOwnerWindow(void **aWindow)
{
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
NS_ASSERTION(docAccessible, "No root accessible pointer back, Init() not called.");
return docAccessible->GetWindowHandle(aWindow);
}
+already_AddRefed<nsApplicationAccessibleWrap>
+nsAccessNode::GetApplicationAccessible()
+{
+ if (!gIsAccessibilityActive) {
+ return nsnull;
+ }
+
+ if (!gApplicationAccessible) {
+ nsApplicationAccessibleWrap::PreCreate();
+
+ gApplicationAccessible = new nsApplicationAccessibleWrap();
+ if (!gApplicationAccessible)
+ return nsnull;
+
+ NS_ADDREF(gApplicationAccessible);
+
+ nsresult rv = gApplicationAccessible->Init();
+ if (NS_FAILED(rv)) {
+ NS_RELEASE(gApplicationAccessible);
+ return nsnull;
+ }
+ }
+
+ NS_ADDREF(gApplicationAccessible);
+ return gApplicationAccessible;
+}
+
void nsAccessNode::InitXPAccessibility()
{
if (gIsAccessibilityActive) {
return;
}
nsCOMPtr<nsIStringBundleService> stringBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
@@ -219,36 +258,52 @@ void nsAccessNode::InitXPAccessibility()
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("accessibility.disablecache", &gIsCacheDisabled);
prefBranch->GetBoolPref("browser.formfill.enable", &gIsFormFillEnabled);
}
gIsAccessibilityActive = PR_TRUE;
+ NotifyA11yInitOrShutdown();
+}
+
+void nsAccessNode::NotifyA11yInitOrShutdown()
+{
+ nsCOMPtr<nsIObserverService> obsService =
+ do_GetService("@mozilla.org/observer-service;1");
+ NS_ASSERTION(obsService, "No observer service to notify of a11y init/shutdown");
+ if (obsService) {
+ static const PRUnichar kInitIndicator[] = { '1', 0 };
+ static const PRUnichar kShutdownIndicator[] = { '0', 0 };
+ obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown",
+ gIsAccessibilityActive ? kInitIndicator : kShutdownIndicator);
+ }
}
void nsAccessNode::ShutdownXPAccessibility()
{
// Called by nsAccessibilityService::Shutdown()
// which happens when xpcom is shutting down
// at exit of program
if (!gIsAccessibilityActive) {
return;
}
NS_IF_RELEASE(gStringBundle);
NS_IF_RELEASE(gKeyStringBundle);
NS_IF_RELEASE(gDoCommandTimer);
NS_IF_RELEASE(gLastFocusedNode);
NS_IF_RELEASE(sAccService);
+ NS_IF_RELEASE(gApplicationAccessible);
ClearCache(gGlobalDocAccessibleCache);
gIsAccessibilityActive = PR_FALSE;
+ NotifyA11yInitOrShutdown();
}
already_AddRefed<nsIPresShell> nsAccessNode::GetPresShell()
{
nsIPresShell *presShell = nsnull;
if (mWeakShell)
CallQueryReferent(mWeakShell.get(), &presShell);
if (!presShell) {
@@ -294,19 +349,19 @@ already_AddRefed<nsRootAccessible> nsAcc
nsCOMPtr<nsIAccessibleDocument> accDoc = GetDocAccessibleFor(root);
if (!accDoc) {
return nsnull;
}
// nsRootAccessible has a special QI
// that let us get that concrete type directly.
- nsRootAccessible* foo;
- accDoc->QueryInterface(NS_GET_IID(nsRootAccessible), (void**)&foo); // addrefs
- return foo;
+ nsRootAccessible* rootAccessible;
+ accDoc->QueryInterface(NS_GET_IID(nsRootAccessible), (void**)&rootAccessible); // addrefs
+ return rootAccessible;
}
nsIFrame* nsAccessNode::GetFrame()
{
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
if (!shell)
return nsnull;
@@ -540,16 +595,41 @@ nsAccessNode::GetComputedStyleValue(cons
}
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
GetComputedStyleDeclaration(aPseudoElt, domElement, getter_AddRefs(styleDecl));
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
return styleDecl->GetPropertyValue(aPropertyName, aValue);
}
+NS_IMETHODIMP
+nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
+ const nsAString& aPropertyName,
+ nsIDOMCSSPrimitiveValue **aCSSValue)
+{
+ NS_ENSURE_ARG_POINTER(aCSSValue);
+
+ *aCSSValue = nsnull;
+
+ nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(mDOMNode));
+ if (!domElement)
+ return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
+ GetComputedStyleDeclaration(aPseudoElt, domElement,
+ getter_AddRefs(styleDecl));
+ NS_ENSURE_STATE(styleDecl);
+
+ nsCOMPtr<nsIDOMCSSValue> cssValue;
+ styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
+ NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
+
+ return CallQueryInterface(cssValue, aCSSValue);
+}
+
void nsAccessNode::GetComputedStyleDeclaration(const nsAString& aPseudoElt,
nsIDOMElement *aElement,
nsIDOMCSSStyleDeclaration **aCssDecl)
{
*aCssDecl = nsnull;
// Returns number of items in style declaration
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (!content) {
@@ -624,17 +704,17 @@ nsAccessNode::GetPresShellFor(nsIDOMNode
nsCOMPtr<nsIDOMDocument> domDocument;
aNode->GetOwnerDocument(getter_AddRefs(domDocument));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
if (!doc) { // This is necessary when the node is the document node
doc = do_QueryInterface(aNode);
}
nsIPresShell *presShell = nsnull;
if (doc) {
- presShell = doc->GetShellAt(0);
+ presShell = doc->GetPrimaryShell();
NS_IF_ADDREF(presShell);
}
return presShell;
}
already_AddRefed<nsIDocShellTreeItem>
nsAccessNode::GetDocShellTreeItemFor(nsIDOMNode *aStartNode)
@@ -745,8 +825,52 @@ already_AddRefed<nsIDOMNode> nsAccessNod
focusedDOMDocument->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&focusedNode);
}
else {
focusedElement->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&focusedNode);
}
return focusedNode;
}
+
+NS_IMETHODIMP
+nsAccessNode::GetLanguage(nsAString& aLanguage)
+{
+ aLanguage.Truncate();
+ nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
+ if (!content) {
+ // For documents make sure we look for lang attribute on
+ // document element
+ nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDOMNode));
+ if (domDoc) {
+ nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDOMNode));
+ if (htmlDoc) {
+ // Make sure we look for lang attribute on HTML <body>
+ nsCOMPtr<nsIDOMHTMLElement> bodyElement;
+ htmlDoc->GetBody(getter_AddRefs(bodyElement));
+ content = do_QueryInterface(bodyElement);
+ }
+ if (!content) {
+ nsCOMPtr<nsIDOMElement> docElement;
+ domDoc->GetDocumentElement(getter_AddRefs(docElement));
+ content = do_QueryInterface(docElement);
+ }
+ }
+ if (!content) {
+ return NS_ERROR_FAILURE;
+ }
+ }
+
+ nsIContent *walkUp = content;
+ while (walkUp && !walkUp->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::lang, aLanguage)) {
+ walkUp = walkUp->GetParent();
+ }
+
+ if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
+ nsIDocument *doc = content->GetOwnerDoc();
+ if (doc) {
+ doc->GetHeaderData(nsAccessibilityAtoms::headerContentLanguage, aLanguage);
+ }
+ }
+
+ return NS_OK;
+}
+
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -59,16 +59,17 @@
class nsIPresShell;
class nsPresContext;
class nsIAccessibleDocument;
class nsIFrame;
class nsIDOMNodeList;
class nsITimer;
class nsRootAccessible;
+class nsApplicationAccessibleWrap;
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
/* hashkey wrapper using void* KeyType
*
* @see nsTHashtable::EntryType for specification
*/
@@ -101,16 +102,21 @@ class nsAccessNode: public nsIAccessNode
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSNODE
NS_DECL_NSPIACCESSNODE
static void InitXPAccessibility();
static void ShutdownXPAccessibility();
+ /**
+ * Return an application accessible.
+ */
+ static already_AddRefed<nsApplicationAccessibleWrap> GetApplicationAccessible();
+
// Static methods for handling per-document cache
static void PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache,
void* aUniqueID, nsIAccessNode *aAccessNode);
static void GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache, void* aUniqueID,
nsIAccessNode **aAccessNode);
static void ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache);
static PLDHashOperator PR_CALLBACK ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg);
@@ -160,24 +166,30 @@ protected:
nsCOMPtr<nsIDOMNode> mDOMNode;
nsCOMPtr<nsIWeakReference> mWeakShell;
#ifdef DEBUG_A11Y
PRBool mIsInitialized;
#endif
+ /**
+ * Notify global nsIObserver's that a11y is getting init'd or shutdown
+ */
+ static void NotifyA11yInitOrShutdown();
+
// Static data, we do our own refcounting for our static data
static nsIStringBundle *gStringBundle;
static nsIStringBundle *gKeyStringBundle;
static nsITimer *gDoCommandTimer;
static PRBool gIsAccessibilityActive;
static PRBool gIsCacheDisabled;
static PRBool gIsFormFillEnabled;
static nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> gGlobalDocAccessibleCache;
private:
static nsIAccessibilityService *sAccService;
+ static nsApplicationAccessibleWrap *gApplicationAccessible;
};
#endif
--- a/accessible/src/base/nsAccessibilityAtomList.h
+++ b/accessible/src/base/nsAccessibilityAtomList.h
@@ -66,20 +66,23 @@ ACCESSIBILITY_ATOM(submit, "submit")
ACCESSIBILITY_ATOM(_true, "true")
// Header info
ACCESSIBILITY_ATOM(headerContentLanguage, "content-language")
// Alphabetical list of frame types
ACCESSIBILITY_ATOM(areaFrame, "AreaFrame")
ACCESSIBILITY_ATOM(blockFrame, "BlockFrame")
+ACCESSIBILITY_ATOM(boxFrame, "BoxFrame")
ACCESSIBILITY_ATOM(brFrame, "BRFrame")
+ACCESSIBILITY_ATOM(deckFrame, "DeckFrame")
ACCESSIBILITY_ATOM(inlineBlockFrame, "InlineBlockFrame")
ACCESSIBILITY_ATOM(inlineFrame, "InlineFrame")
ACCESSIBILITY_ATOM(objectFrame, "ObjectFrame")
+ACCESSIBILITY_ATOM(scrollFrame, "ScrollFrame")
ACCESSIBILITY_ATOM(textFrame, "TextFrame")
ACCESSIBILITY_ATOM(tableCellFrame, "TableCellFrame")
ACCESSIBILITY_ATOM(tableOuterFrame, "TableOuterFrame")
// Alphabetical list of tag names
ACCESSIBILITY_ATOM(a, "a")
ACCESSIBILITY_ATOM(abbr, "abbr")
ACCESSIBILITY_ATOM(acronym, "acronym")
@@ -142,16 +145,17 @@ ACCESSIBILITY_ATOM(owns, "owns")
// Alphabetical list of attributes
ACCESSIBILITY_ATOM(acceltext, "acceltext")
ACCESSIBILITY_ATOM(accesskey, "accesskey")
ACCESSIBILITY_ATOM(alt, "alt")
ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
ACCESSIBILITY_ATOM(autocomplete, "autocomplete") // Used as attribute value too
ACCESSIBILITY_ATOM(control, "control")
+ACCESSIBILITY_ATOM(cycles, "cycles") // used for XUL cycler attribute
ACCESSIBILITY_ATOM(data, "data")
ACCESSIBILITY_ATOM(disabled, "disabled")
ACCESSIBILITY_ATOM(editable, "editable")
ACCESSIBILITY_ATOM(_for, "for")
ACCESSIBILITY_ATOM(href, "href")
ACCESSIBILITY_ATOM(id, "id")
ACCESSIBILITY_ATOM(lang, "lang")
ACCESSIBILITY_ATOM(multiline, "multiline")
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -34,25 +34,26 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// NOTE: alphabetically ordered
#include "nsAccessibilityAtoms.h"
#include "nsAccessibilityService.h"
+#include "nsAccessibilityUtils.h"
#include "nsCURILoader.h"
#include "nsDocAccessible.h"
#include "nsHTMLAreaAccessible.h"
-#include "nsHTMLImageAccessible.h"
+#include "nsHTMLImageAccessibleWrap.h"
#include "nsHTMLLinkAccessible.h"
#include "nsHTMLSelectAccessible.h"
-#include "nsHTMLTableAccessible.h"
+#include "nsHTMLTableAccessibleWrap.h"
#include "nsHTMLTextAccessible.h"
-#include "nsHyperTextAccessible.h"
+#include "nsHyperTextAccessibleWrap.h"
#include "nsIAccessibilityService.h"
#include "nsIAccessibleProvider.h"
#include "nsIDOMDocument.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLLegendElement.h"
#include "nsIDOMHTMLObjectElement.h"
#include "nsIDOMHTMLOptGroupElement.h"
#include "nsIDOMHTMLOptionElement.h"
@@ -92,25 +93,27 @@
#include "nsXULTreeAccessibleWrap.h"
#endif
// For native window support for object/embed/applet tags
#ifdef XP_WIN
#include "nsHTMLWin32ObjectAccessible.h"
#endif
-#ifdef MOZ_ACCESSIBILITY_ATK
-#include "nsAppRootAccessible.h"
-#endif
-
#ifndef DISABLE_XFORMS_HOOKS
#include "nsXFormsFormControlsAccessible.h"
#include "nsXFormsWidgetsAccessible.h"
#endif
+#ifdef MOZ_ACCESSIBILITY_ATK
+#include "nsAppRootAccessible.h"
+#else
+#include "nsApplicationAccessibleWrap.h"
+#endif
+
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
/**
* nsAccessibilityService
*/
nsAccessibilityService::nsAccessibilityService()
{
@@ -283,40 +286,37 @@ nsAccessibilityService::GetInfo(nsISuppo
return NS_ERROR_FAILURE;
*aNode = node;
NS_IF_ADDREF(*aNode);
nsCOMPtr<nsIDocument> document = content->GetDocument();
if (!document)
return NS_ERROR_FAILURE;
-#ifdef DEBUG_A11Y
- PRInt32 shells = document->GetNumberOfShells();
- NS_ASSERTION(shells > 0,"Error no shells!");
-#endif
+ NS_ASSERTION(document->GetPrimaryShell(),"Error no shells!");
// do_GetWR only works into a |nsCOMPtr| :-(
nsCOMPtr<nsIWeakReference> weakShell =
- do_GetWeakReference(document->GetShellAt(0));
+ do_GetWeakReference(document->GetPrimaryShell());
NS_IF_ADDREF(*aShell = weakShell);
return NS_OK;
}
nsresult
nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
if (!doc)
return NS_ERROR_INVALID_ARG;
// ---- Get the pres shell ----
- nsIPresShell *shell = doc->GetShellAt(0);
+ nsIPresShell *shell = doc->GetPrimaryShell();
if (!shell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWeakReference> weakRef(do_GetWeakReference(shell));
*aWeakShell = weakRef;
NS_IF_ADDREF(*aWeakShell);
@@ -355,17 +355,17 @@ nsAccessibilityService::CreateRootAccess
{
*aRootAcc = nsnull;
nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(aDocument));
NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);
nsIPresShell *presShell = aShell;
if (!presShell) {
- presShell = aDocument->GetShellAt(0);
+ presShell = aDocument->GetPrimaryShell();
}
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
nsCOMPtr<nsISupports> container = aDocument->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
do_QueryInterface(container);
NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE);
@@ -527,23 +527,24 @@ nsAccessibilityService::CreateHyperTextA
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIWeakReference> weakShell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
- if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::onclick)) {
+
+ if (nsAccessibilityUtils::HasListener(content, NS_LITERAL_STRING("click"))) {
// nsLinkableAccessible inherits from nsHyperTextAccessible, but
// it also includes code for dealing with the onclick
*aAccessible = new nsLinkableAccessible(node, weakShell);
}
else {
- *aAccessible = new nsHyperTextAccessible(node, weakShell);
+ *aAccessible = new nsHyperTextAccessibleWrap(node, weakShell);
}
if (nsnull == *aAccessible)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aAccessible);
return NS_OK;
}
@@ -584,42 +585,30 @@ nsAccessibilityService::CreateHTMLImageA
nsCOMPtr<nsIWeakReference> weakShell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = nsnull;
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(node));
if (domElement) {
- *_retval = new nsHTMLImageAccessible(node, weakShell);
+ *_retval = new nsHTMLImageAccessibleWrap(node, weakShell);
}
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
-nsAccessibilityService::CreateHTMLGenericAccessible(nsISupports *aFrame, nsIAccessible **_retval)
+nsAccessibilityService::CreateHTMLGenericAccessible(nsISupports *aFrame, nsIAccessible **aAccessible)
{
- nsIFrame* frame;
- nsCOMPtr<nsIDOMNode> node;
- nsCOMPtr<nsIWeakReference> weakShell;
- nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
- if (NS_FAILED(rv))
- return rv;
-
- *_retval = new nsAccessibleWrap(node, weakShell);
- if (! *_retval)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*_retval);
- return NS_OK;
+ return CreateHyperTextAccessible(aFrame, aAccessible);
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLGroupboxAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIWeakReference> weakShell;
@@ -741,17 +730,17 @@ nsAccessibilityService::CreateHTMLTableA
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIWeakReference> weakShell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
- *_retval = new nsHTMLTableAccessible(node, weakShell);
+ *_retval = new nsHTMLTableAccessibleWrap(node, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
@@ -764,18 +753,18 @@ nsAccessibilityService::CreateHTMLTableH
NS_ENSURE_ARG_POINTER(aDOMNode);
nsresult rv = NS_OK;
nsCOMPtr<nsIWeakReference> weakShell;
rv = GetShellFromNode(aDOMNode, getter_AddRefs(weakShell));
NS_ENSURE_SUCCESS(rv, rv);
- nsHTMLTableHeadAccessible* accTableHead =
- new nsHTMLTableHeadAccessible(aDOMNode, weakShell);
+ nsHTMLTableHeadAccessibleWrap* accTableHead =
+ new nsHTMLTableHeadAccessibleWrap(aDOMNode, weakShell);
NS_ENSURE_TRUE(accTableHead, NS_ERROR_OUT_OF_MEMORY);
*_retval = NS_STATIC_CAST(nsIAccessible *, accTableHead);
NS_IF_ADDREF(*_retval);
return rv;
#endif
@@ -913,38 +902,159 @@ NS_IMETHODIMP nsAccessibilityService::Ge
if (!accessibleDoc) {
*aAccessNode = nsnull;
return NS_ERROR_FAILURE;
}
return accessibleDoc->GetCachedAccessNode(NS_STATIC_CAST(void*, aNode), aAccessNode);
}
+NS_IMETHODIMP
+nsAccessibilityService::GetStringRole(PRUint32 aRole, nsAString& aString)
+{
+ if ( aRole >= NS_ARRAY_LENGTH(kRoleNames)) {
+ aString.AssignLiteral("unknown");
+ return NS_OK;
+ }
+
+ CopyUTF8toUTF16(kRoleNames[aRole], aString);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAccessibilityService::GetStringStates(PRUint32 aStates, PRUint32 aExtraStates,
+ nsIDOMDOMStringList **aStringStates)
+{
+ nsAccessibleDOMStringList *stringStates = new nsAccessibleDOMStringList();
+ NS_ENSURE_TRUE(stringStates, NS_ERROR_OUT_OF_MEMORY);
+
+ //states
+ if (aStates & nsIAccessibleStates::STATE_UNAVAILABLE)
+ stringStates->Add(NS_LITERAL_STRING("unavailable"));
+ if (aStates & nsIAccessibleStates::STATE_SELECTED)
+ stringStates->Add(NS_LITERAL_STRING("selected"));
+ if (aStates & nsIAccessibleStates::STATE_FOCUSED)
+ stringStates->Add(NS_LITERAL_STRING("focused"));
+ if (aStates & nsIAccessibleStates::STATE_PRESSED)
+ stringStates->Add(NS_LITERAL_STRING("pressed"));
+ if (aStates & nsIAccessibleStates::STATE_CHECKED)
+ stringStates->Add(NS_LITERAL_STRING("checked"));
+ if (aStates & nsIAccessibleStates::STATE_MIXED)
+ stringStates->Add(NS_LITERAL_STRING("mixed"));
+ if (aStates & nsIAccessibleStates::STATE_READONLY)
+ stringStates->Add(NS_LITERAL_STRING("readonly"));
+ if (aStates & nsIAccessibleStates::STATE_HOTTRACKED)
+ stringStates->Add(NS_LITERAL_STRING("hottracked"));
+ if (aStates & nsIAccessibleStates::STATE_DEFAULT)
+ stringStates->Add(NS_LITERAL_STRING("default"));
+ if (aStates & nsIAccessibleStates::STATE_EXPANDED)
+ stringStates->Add(NS_LITERAL_STRING("expanded"));
+ if (aStates & nsIAccessibleStates::STATE_COLLAPSED)
+ stringStates->Add(NS_LITERAL_STRING("collapsed"));
+ if (aStates & nsIAccessibleStates::STATE_BUSY)
+ stringStates->Add(NS_LITERAL_STRING("busy"));
+ if (aStates & nsIAccessibleStates::STATE_FLOATING)
+ stringStates->Add(NS_LITERAL_STRING("floating"));
+ if (aStates & nsIAccessibleStates::STATE_ANIMATED)
+ stringStates->Add(NS_LITERAL_STRING("animated"));
+ if (aStates & nsIAccessibleStates::STATE_INVISIBLE)
+ stringStates->Add(NS_LITERAL_STRING("invisible"));
+ if (aStates & nsIAccessibleStates::STATE_OFFSCREEN)
+ stringStates->Add(NS_LITERAL_STRING("offscreen"));
+ if (aStates & nsIAccessibleStates::STATE_SIZEABLE)
+ stringStates->Add(NS_LITERAL_STRING("sizeable"));
+ if (aStates & nsIAccessibleStates::STATE_MOVEABLE)
+ stringStates->Add(NS_LITERAL_STRING("moveable"));
+ if (aStates & nsIAccessibleStates::STATE_SELFVOICING)
+ stringStates->Add(NS_LITERAL_STRING("selfvoicing"));
+ if (aStates & nsIAccessibleStates::STATE_FOCUSABLE)
+ stringStates->Add(NS_LITERAL_STRING("focusable"));
+ if (aStates & nsIAccessibleStates::STATE_SELECTABLE)
+ stringStates->Add(NS_LITERAL_STRING("selectable"));
+ if (aStates & nsIAccessibleStates::STATE_LINKED)
+ stringStates->Add(NS_LITERAL_STRING("linked"));
+ if (aStates & nsIAccessibleStates::STATE_TRAVERSED)
+ stringStates->Add(NS_LITERAL_STRING("traversed"));
+ if (aStates & nsIAccessibleStates::STATE_MULTISELECTABLE)
+ stringStates->Add(NS_LITERAL_STRING("multiselectable"));
+ if (aStates & nsIAccessibleStates::STATE_EXTSELECTABLE)
+ stringStates->Add(NS_LITERAL_STRING("extselectable"));
+ if (aStates & nsIAccessibleStates::STATE_PROTECTED)
+ stringStates->Add(NS_LITERAL_STRING("protected"));
+ if (aStates & nsIAccessibleStates::STATE_HASPOPUP)
+ stringStates->Add(NS_LITERAL_STRING("haspopup"));
+ if (aStates & nsIAccessibleStates::STATE_REQUIRED)
+ stringStates->Add(NS_LITERAL_STRING("required"));
+ if (aStates & nsIAccessibleStates::STATE_IMPORTANT)
+ stringStates->Add(NS_LITERAL_STRING("important"));
+ if (aStates & nsIAccessibleStates::STATE_INVALID)
+ stringStates->Add(NS_LITERAL_STRING("invalid"));
+ if (aStates & nsIAccessibleStates::STATE_CHECKABLE)
+ stringStates->Add(NS_LITERAL_STRING("checkable"));
+
+ //extraStates
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT)
+ stringStates->Add(NS_LITERAL_STRING("selectable text"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_EDITABLE)
+ stringStates->Add(NS_LITERAL_STRING("editable"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_ACTIVE)
+ stringStates->Add(NS_LITERAL_STRING("active"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_EXPANDABLE)
+ stringStates->Add(NS_LITERAL_STRING("expandable"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_MODAL)
+ stringStates->Add(NS_LITERAL_STRING("modal"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_MULTI_LINE)
+ stringStates->Add(NS_LITERAL_STRING("multi line"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_SENSITIVE)
+ stringStates->Add(NS_LITERAL_STRING("sensitive"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_SINGLE_LINE)
+ stringStates->Add(NS_LITERAL_STRING("single line"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_TRANSIENT)
+ stringStates->Add(NS_LITERAL_STRING("transient"));
+ if (aExtraStates & nsIAccessibleStates::EXT_STATE_VERTICAL)
+ stringStates->Add(NS_LITERAL_STRING("vertical"));
+
+ //unknown states
+ PRUint32 stringStatesLength = 0;
+
+ stringStates->GetLength(&stringStatesLength);
+ if (!stringStatesLength)
+ stringStates->Add(NS_LITERAL_STRING("unknown"));
+
+ NS_ADDREF(*aStringStates = stringStates);
+ return NS_OK;
+}
+
/**
* GetAccessibleFor - get an nsIAccessible from a DOM node
*/
NS_IMETHODIMP
nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsIAccessible **aAccessible)
{
+ NS_ENSURE_ARG_POINTER(aAccessible);
+ *aAccessible = nsnull;
+
+ NS_ENSURE_ARG(aNode);
+
// We use presentation shell #0 because we assume that is presentation of
// given node window.
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
nsCOMPtr<nsIDocument> doc;
if (content) {
doc = content->GetDocument();
}
else {// Could be document node
doc = do_QueryInterface(aNode);
}
if (!doc)
return NS_ERROR_FAILURE;
- nsIPresShell *presShell = doc->GetShellAt(0);
+ nsIPresShell *presShell = doc->GetPrimaryShell();
return GetAccessibleInShell(aNode, presShell, aAccessible);
}
NS_IMETHODIMP
nsAccessibilityService::GetAttachedAccessibleFor(nsIDOMNode *aNode,
nsIAccessible **aAccessible)
{
NS_ENSURE_ARG(aNode);
@@ -961,41 +1071,59 @@ nsAccessibilityService::GetAttachedAcces
return GetAccessibleFor(aNode, aAccessible);
}
NS_IMETHODIMP nsAccessibilityService::GetAccessibleInWindow(nsIDOMNode *aNode,
nsIDOMWindow *aWin,
nsIAccessible **aAccessible)
{
+ NS_ENSURE_ARG_POINTER(aAccessible);
+ *aAccessible = nsnull;
+
+ NS_ENSURE_ARG(aNode);
+ NS_ENSURE_ARG(aWin);
+
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(aWin));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
if (!docShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> presShell;
docShell->GetPresShell(getter_AddRefs(presShell));
return GetAccessibleInShell(aNode, presShell, aAccessible);
}
NS_IMETHODIMP nsAccessibilityService::GetAccessibleInShell(nsIDOMNode *aNode,
nsIPresShell *aPresShell,
nsIAccessible **aAccessible)
{
+ NS_ENSURE_ARG_POINTER(aAccessible);
+ *aAccessible = nsnull;
+
+ NS_ENSURE_ARG(aNode);
+ NS_ENSURE_ARG(aPresShell);
+
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(aPresShell));
nsIFrame *outFrameUnused = NULL;
PRBool isHiddenUnused = false;
return GetAccessible(aNode, aPresShell, weakShell,
&outFrameUnused, &isHiddenUnused, aAccessible);
}
NS_IMETHODIMP nsAccessibilityService::GetAccessibleInWeakShell(nsIDOMNode *aNode,
nsIWeakReference *aWeakShell,
nsIAccessible **aAccessible)
{
+ NS_ENSURE_ARG_POINTER(aAccessible);
+ *aAccessible = nsnull;
+
+ NS_ENSURE_ARG(aNode);
+ NS_ENSURE_ARG(aWeakShell);
+
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(aWeakShell));
nsIFrame *outFrameUnused = NULL;
PRBool isHiddenUnused = false;
return GetAccessible(aNode, presShell, aWeakShell,
&outFrameUnused, &isHiddenUnused, aAccessible);
}
nsresult nsAccessibilityService::InitAccessible(nsIAccessible *aAccessibleIn,
@@ -1186,18 +1314,19 @@ NS_IMETHODIMP nsAccessibilityService::Ge
// don't want focus ever to be 'lost'
return NS_OK;
}
// Elements may implement nsIAccessibleProvider via XBL. This allows them to
// say what kind of accessible to create.
nsresult rv = GetAccessibleByType(aNode, getter_AddRefs(newAcc));
NS_ENSURE_SUCCESS(rv, rv);
-
- if (!newAcc && !content->IsNodeOfType(nsINode::eHTML)) {
+
+ PRBool isHTML = content->IsNodeOfType(nsINode::eHTML);
+ if (!newAcc && !isHTML) {
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
content->Tag() == nsAccessibilityAtoms::svg) {
newAcc = new nsEnumRoleAccessible(aNode, aWeakShell,
nsIAccessibleRole::ROLE_DIAGRAM);
}
else if (content->GetNameSpaceID() == kNameSpaceID_MathML &&
content->Tag() == nsAccessibilityAtoms::math) {
newAcc = new nsEnumRoleAccessible(aNode, aWeakShell,
@@ -1238,32 +1367,36 @@ NS_IMETHODIMP nsAccessibilityService::Ge
}
}
if (tryFrame) {
frame->GetAccessible(getter_AddRefs(newAcc)); // Try using frame to do it
}
}
+ if (!newAcc) {
+ GetAccessibleForDeckChildren(aNode, getter_AddRefs(newAcc));
+ }
+
// If no accessible, see if we need to create a generic accessible because
// of some property that makes this object interesting
// We don't do this for <body>, <html>, <window>, <dialog> etc. which
// correspond to the doc accessible and will be created in any case
if (!newAcc && content->Tag() != nsAccessibilityAtoms::body && content->GetParent() &&
(content->IsFocusable() ||
- content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::onclick) ||
+ (isHTML && nsAccessibilityUtils::HasListener(content, NS_LITERAL_STRING("click"))) ||
content->HasAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::describedby) ||
content->HasAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::labelledby) ||
content->HasAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::required) ||
content->HasAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::invalid) ||
!role.IsEmpty())) {
// This content is focusable or has an interesting dynamic content accessibility property.
// If it's interesting we need it in the accessibility hierarchy so that events or
// other accessibles can point to it, or so that it can hold a state, etc.
- if (content->IsNodeOfType(nsINode::eHTML)) {
+ if (isHTML) {
// Interesting HTML container which may have selectable text and/or embedded objects
CreateHyperTextAccessible(frame, getter_AddRefs(newAcc));
}
else { // XUL, SVG, MathML etc.
// Interesting generic non-HTML container
newAcc = new nsAccessibleWrap(aNode, aWeakShell);
}
}
@@ -1342,22 +1475,22 @@ nsAccessibilityService::GetRelevantConte
nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
nsIAccessible **aAccessible)
{
NS_ENSURE_ARG(aNode);
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
- nsCOMPtr<nsIAccessibleProvider> node(do_QueryInterface(aNode));
- if (!node)
+ nsCOMPtr<nsIAccessibleProvider> accessibleProvider(do_QueryInterface(aNode));
+ if (!accessibleProvider)
return NS_OK;
PRInt32 type;
- nsresult rv = node->GetAccessibleType(&type);
+ nsresult rv = accessibleProvider->GetAccessibleType(&type);
NS_ENSURE_SUCCESS(rv, rv);
if (type == nsIAccessibleProvider::OuterDoc)
return CreateOuterDocAccessible(aNode, aAccessible);
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
@@ -1397,17 +1530,17 @@ nsresult nsAccessibilityService::GetAcce
return NS_ERROR_FAILURE;
PRBool hasTextEquivalent;
// Prefer value over tooltiptext
elt->HasAttribute(NS_LITERAL_STRING("tooltiptext"), &hasTextEquivalent);
if (!hasTextEquivalent)
return NS_OK;
- *aAccessible = new nsHTMLImageAccessible(aNode, weakShell);
+ *aAccessible = new nsHTMLImageAccessibleWrap(aNode, weakShell);
break;
}
case nsIAccessibleProvider::XULLink:
*aAccessible = new nsXULLinkAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULListbox:
*aAccessible = new nsXULListboxAccessible(aNode, weakShell);
break;
@@ -1455,19 +1588,16 @@ nsresult nsAccessibilityService::GetAcce
*aAccessible = new nsXULRadioGroupAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULTab:
*aAccessible = new nsXULTabAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULTabBox:
*aAccessible = new nsXULTabBoxAccessible(aNode, weakShell);
break;
- case nsIAccessibleProvider::XULTabPanels:
- *aAccessible = new nsXULTabPanelsAccessible(aNode, weakShell);
- break;
case nsIAccessibleProvider::XULTabs:
*aAccessible = new nsXULTabsAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULText:
*aAccessible = new nsXULTextAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULTextBox:
*aAccessible = new nsXULTextFieldAccessible(aNode, weakShell);
@@ -1570,32 +1700,38 @@ NS_IMETHODIMP nsAccessibilityService::Ad
{
#ifdef MOZ_ACCESSIBILITY_ATK
nsNativeRootAccessibleWrap* rootAccWrap =
new nsNativeRootAccessibleWrap((AtkObject*)aAtkAccessible);
*aRootAccessible = NS_STATIC_CAST(nsIAccessible*, rootAccWrap);
NS_ADDREF(*aRootAccessible);
- nsAppRootAccessible *appRoot = nsAppRootAccessible::Create();
+ nsRefPtr<nsApplicationAccessibleWrap> appRoot =
+ nsAccessNode::GetApplicationAccessible();
+ NS_ENSURE_STATE(appRoot);
+
appRoot->AddRootAccessible(*aRootAccessible);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP nsAccessibilityService::RemoveNativeRootAccessible(nsIAccessible * aRootAccessible)
{
#ifdef MOZ_ACCESSIBILITY_ATK
void* atkAccessible;
aRootAccessible->GetNativeInterface(&atkAccessible);
- nsAppRootAccessible *appRoot = nsAppRootAccessible::Create();
+ nsRefPtr<nsApplicationAccessibleWrap> appRoot =
+ nsAccessNode::GetApplicationAccessible();
+ NS_ENSURE_STATE(appRoot);
+
appRoot->RemoveRootAccessible(aRootAccessible);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
@@ -1644,8 +1780,36 @@ nsAccessibilityService::GetAccessibility
}
nsresult
NS_GetAccessibilityService(nsIAccessibilityService** aResult)
{
return nsAccessibilityService::GetAccessibilityService(aResult);
}
+nsresult
+nsAccessibilityService::GetAccessibleForDeckChildren(nsIDOMNode *aNode, nsIAccessible** aAccessible)
+{
+ nsCOMPtr<nsIWeakReference> weakShell;
+ GetShellFromNode(aNode, getter_AddRefs(weakShell));
+ NS_ENSURE_TRUE(weakShell, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIPresShell> shell(do_QueryReferent(weakShell));
+ NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
+
+ nsIFrame* frame = nsnull;
+ nsIFrame* parentFrame = nsnull;
+ nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
+
+ if (content) {
+ frame = shell->GetPrimaryFrameFor(content);
+ }
+
+ if (frame && (frame->GetType() == nsAccessibilityAtoms::boxFrame ||
+ frame->GetType() == nsAccessibilityAtoms::scrollFrame)) {
+ parentFrame = frame->GetParent();
+ if (parentFrame && parentFrame->GetType() == nsAccessibilityAtoms::deckFrame) {
+ *aAccessible = new nsEnumRoleAccessible(aNode, weakShell, nsIAccessibleRole::ROLE_PROPERTYPAGE);
+ NS_ADDREF(*aAccessible);
+ }
+ }
+
+ return NS_OK;
+}
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -47,16 +47,135 @@
class nsIFrame;
class nsIWeakReference;
class nsIDOMNode;
class nsObjectFrame;
class nsIDocShell;
class nsIPresShell;
class nsIContent;
+static const char kRoleNames[][20] = {
+ "nothing", //ROLE_NOTHING
+ "titlebar", //ROLE_TITLEBAR
+ "menubar", //ROLE_MENUBAR
+ "scrollbar", //ROLE_SCROLLBAR
+ "grip", //ROLE_GRIP
+ "sound", //ROLE_SOUND
+ "cursor", //ROLE_CURSOR
+ "caret", //ROLE_CARET
+ "alert", //ROLE_ALERT
+ "window", //ROLE_WINDOW
+ "client", //ROLE_CLIENT
+ "menupopup", //ROLE_MENUPOPUP
+ "menuitem", //ROLE_MENUITEM
+ "tooltip", //ROLE_TOOLTIP
+ "application", //ROLE_APPLICATION
+ "document", //ROLE_DOCUMENT
+ "pane", //ROLE_PANE
+ "chart", //ROLE_CHART
+ "dialog", //ROLE_DIALOG
+ "border", //ROLE_BORDER
+ "grouping", //ROLE_GROUPING
+ "separator", //ROLE_SEPARATOR
+ "toolbar", //ROLE_TOOLBAR
+ "statusbar", //ROLE_STATUSBAR
+ "table", //ROLE_TABLE
+ "columnheader", //ROLE_COLUMNHEADER
+ "rowheader", //ROLE_ROWHEADER
+ "column", //ROLE_COLUMN
+ "row", //ROLE_ROW
+ "cell", //ROLE_CELL
+ "link", //ROLE_LINK
+ "helpballoon", //ROLE_HELPBALLOON
+ "character", //ROLE_CHARACTER
+ "list", //ROLE_LIST
+ "listitem", //ROLE_LISTITEM
+ "outline", //ROLE_OUTLINE
+ "outlineitem", //ROLE_OUTLINEITEM
+ "pagetab", //ROLE_PAGETAB
+ "propertypage", //ROLE_PROPERTYPAGE
+ "indicator", //ROLE_INDICATOR
+ "graphic", //ROLE_GRAPHIC
+ "statictext", //ROLE_STATICTEXT
+ "text leaf", //ROLE_TEXT_LEAF
+ "pushbutton", //ROLE_PUSHBUTTON
+ "checkbutton", //ROLE_CHECKBUTTON
+ "radiobutton", //ROLE_RADIOBUTTON
+ "combobox", //ROLE_COMBOBOX
+ "droplist", //ROLE_DROPLIST
+ "progressbar", //ROLE_PROGRESSBAR
+ "dial", //ROLE_DIAL
+ "hotkeyfield", //ROLE_HOTKEYFIELD
+ "slider", //ROLE_SLIDER
+ "spinbutton", //ROLE_SPINBUTTON
+ "diagram", //ROLE_DIAGRAM
+ "animation", //ROLE_ANIMATION
+ "equation", //ROLE_EQUATION
+ "buttondropdown", //ROLE_BUTTONDROPDOWN
+ "buttonmenu", //ROLE_BUTTONMENU
+ "buttondropdowngrid", //ROLE_BUTTONDROPDOWNGRID
+ "whitespace", //ROLE_WHITESPACE
+ "pagetablist", //ROLE_PAGETABLIST
+ "clock", //ROLE_CLOCK
+ "splitbutton", //ROLE_SPLITBUTTON
+ "ipaddress", //ROLE_IPADDRESS
+ "accel label", //ROLE_ACCEL_LABEL
+ "arrow", //ROLE_ARROW
+ "canvas", //ROLE_CANVAS
+ "check menu item", //ROLE_CHECK_MENU_ITEM
+ "color chooser", //ROLE_COLOR_CHOOSER
+ "date editor", //ROLE_DATE_EDITOR
+ "desktop icon", //ROLE_DESKTOP_ICON
+ "desktop frame", //ROLE_DESKTOP_FRAME
+ "directory pane", //ROLE_DIRECTORY_PANE
+ "file chooser", //ROLE_FILE_CHOOSER
+ "font chooser", //ROLE_FONT_CHOOSER
+ "chrome window", //ROLE_CHROME_WINDOW
+ "glass pane", //ROLE_GLASS_PANE
+ "html container", //ROLE_HTML_CONTAINER
+ "icon", //ROLE_ICON
+ "label", //ROLE_LABEL
+ "layered pane", //ROLE_LAYERED_PANE
+ "option pane", //ROLE_OPTION_PANE
+ "password text", //ROLE_PASSWORD_TEXT
+ "popup menu", //ROLE_POPUP_MENU
+ "radio menu item", //ROLE_RADIO_MENU_ITEM
+ "root pane", //ROLE_ROOT_PANE
+ "scroll pane", //ROLE_SCROLL_PANE
+ "split pane", //ROLE_SPLIT_PANE
+ "table column header", //ROLE_TABLE_COLUMN_HEADER
+ "table row header", //ROLE_TABLE_ROW_HEADER
+ "tear off menu item", //ROLE_TEAR_OFF_MENU_ITEM
+ "terminal", //ROLE_TERMINAL
+ "text container", //ROLE_TEXT_CONTAINER
+ "toggle button", //ROLE_TOGGLE_BUTTON
+ "tree table", //ROLE_TREE_TABLE
+ "viewport", //ROLE_VIEWPORT
+ "header", //ROLE_HEADER
+ "footer", //ROLE_FOOTER
+ "paragraph", //ROLE_PARAGRAPH
+ "ruler", //ROLE_RULER
+ "autocomplete", //ROLE_AUTOCOMPLETE
+ "editbar", //ROLE_EDITBAR
+ "entry", //ROLE_ENTRY
+ "caption", //ROLE_CAPTION
+ "document frame", //ROLE_DOCUMENT_FRAME
+ "heading", //ROLE_HEADING
+ "page", //ROLE_PAGE
+ "section", //ROLE_SECTION
+ "redundant object", //ROLE_REDUNDANT_OBJECT
+ "form", //ROLE_FORM
+ "ime", //ROLE_IME
+ "app root", //ROLE_APP_ROOT
+ "parent menuitem", //ROLE_PARENT_MENUITEM
+ "calendar", //ROLE_CALENDAR
+ "combobox list", //ROLE_COMBOBOX_LIST
+ "combobox listitem" //ROLE_COMBOBOX_LISTITEM
+};
+
class nsAccessibilityService : public nsIAccessibilityService,
public nsIObserver,
public nsIWebProgressListener,
public nsSupportsWeakReference
{
public:
nsAccessibilityService();
virtual ~nsAccessibilityService();
@@ -77,11 +196,17 @@ private:
static nsAccessibilityService *gAccessibilityService;
nsresult InitAccessible(nsIAccessible *aAccessibleIn, nsIAccessible **aAccessibleOut);
/**
* Return accessible object for elements implementing nsIAccessibleProvider
* interface.
*/
nsresult GetAccessibleByType(nsIDOMNode *aNode, nsIAccessible **aAccessible);
+ PRBool HasListener(nsIContent *aContent, nsAString& aEventType);
+
+ /**
+ * Return accessible object if parent is a deck frame
+ */
+ nsresult GetAccessibleForDeckChildren(nsIDOMNode *aNode, nsIAccessible **aAccessible);
};
#endif /* __nsIAccessibilityService_h__ */
--- a/accessible/src/base/nsAccessibilityUtils.cpp
+++ b/accessible/src/base/nsAccessibilityUtils.cpp
@@ -34,16 +34,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccessibilityUtils.h"
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
+#include "nsIEventListenerManager.h"
void
nsAccessibilityUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
nsAString& aAttrValue)
{
nsCAutoString attrName;
aAttrName->ToUTF8String(attrName);
@@ -150,8 +151,18 @@ nsAccessibilityUtils::SetAccAttrsForXULS
PRUint32 itemsCount;
control->GetItemCount(&itemsCount);
PRInt32 indexOf;
control->GetIndexOfItem(item, &indexOf);
SetAccGroupAttrs(aAttributes, 0, indexOf + 1, itemsCount);
}
+
+PRBool nsAccessibilityUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
+{
+ NS_ENSURE_ARG_POINTER(aContent);
+ nsCOMPtr<nsIEventListenerManager> listenerManager;
+ aContent->GetListenerManager(PR_FALSE, getter_AddRefs(listenerManager));
+
+ return listenerManager && listenerManager->HasListenersFor(aEventType);
+}
+
--- a/accessible/src/base/nsAccessibilityUtils.h
+++ b/accessible/src/base/nsAccessibilityUtils.h
@@ -38,16 +38,17 @@
#ifndef nsAccessibilityUtils_h_
#define nsAccessibilityUtils_h_
#include "nsAccessibilityAtoms.h"
#include "nsIDOMNode.h"
#include "nsIPersistentProperties2.h"
+#include "nsIContent.h"
class nsAccessibilityUtils
{
public:
/**
* Returns value of attribute from the given attributes container.
*
* @param aAttributes - attributes container
@@ -94,11 +95,13 @@ public:
* Set group attributes - 'level', 'setsize', 'posinset'.
*
* @param aNode - XUL element that implements
* nsIDOMXULSelectControlItemElement interface
* @param aAttributes - attributes container
*/
static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes);
+
+ static PRBool HasListener(nsIContent *aContent, const nsAString& aEventType);
};
#endif
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -33,19 +33,21 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccessible.h"
+#include "nsAccessibleRelation.h"
#include "nsIAccessibleDocument.h"
#include "nsIDocument.h"
#include "nsIDOMNSDocument.h"
+#include "nsIDOMNSHTMLElement.h"
#include "nsIImageDocument.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIScrollableView.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
@@ -505,24 +507,24 @@ NS_IMETHODIMP nsAccessible::Init()
}
prefix += ':';
PRUint32 length = prefix.Length();
if (length > 1 && StringBeginsWith(roleString, prefix)) {
roleString.Cut(0, length);
nsCString utf8Role = NS_ConvertUTF16toUTF8(roleString); // For easy comparison
ToLowerCase(utf8Role);
PRUint32 index;
- for (index = 0; gWAIRoleMap[index].roleString; index ++) {
- if (utf8Role.Equals(gWAIRoleMap[index].roleString)) {
+ for (index = 0; nsARIAMap::gWAIRoleMap[index].roleString; index ++) {
+ if (utf8Role.Equals(nsARIAMap::gWAIRoleMap[index].roleString)) {
break; // The dynamic role attribute maps to an entry in our table
}
}
// Always use some entry if there is a role string
// If no match, we use the last entry which maps to ROLE_NOTHING
- mRoleMapEntry = &gWAIRoleMap[index];
+ mRoleMapEntry = &nsARIAMap::gWAIRoleMap[index];
}
}
}
return nsAccessNodeWrap::Init();
}
nsIContent *nsAccessible::GetRoleContent(nsIDOMNode *aDOMNode)
@@ -590,17 +592,17 @@ NS_IMETHODIMP nsAccessible::GetParent(ns
nsresult rv = GetCachedParent(aParent);
if (NS_FAILED(rv) || *aParent) {
return rv;
}
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
NS_ENSURE_TRUE(docAccessible, NS_ERROR_FAILURE);
- return docAccessible->GetAccessibleInParentChain(mDOMNode, aParent);
+ return docAccessible->GetAccessibleInParentChain(mDOMNode, PR_TRUE, aParent);
}
NS_IMETHODIMP nsAccessible::GetCachedParent(nsIAccessible ** aParent)
{
*aParent = nsnull;
if (!mWeakShell) {
// This node has been shut down
return NS_ERROR_FAILURE;
@@ -920,19 +922,23 @@ PRBool nsAccessible::IsVisible(PRBool *a
return PR_FALSE;
// Get the bounds of the current frame, relative to the current view.
// We don't use the more accurate GetBoundsRect, because that is more expensive
// and the STATE_OFFSCREEN flag that this is used for only needs to be a rough
// indicator
nsRect relFrameRect = frame->GetRect();
- nsPoint frameOffset;
nsIView *containingView = frame->GetViewExternal();
- if (!containingView) {
+ if (containingView) {
+ // When frame itself has a view, it has the same bounds as the view
+ relFrameRect.x = relFrameRect.y = 0;
+ }
+ else {
+ nsPoint frameOffset;
frame->GetOffsetFromView(frameOffset, &containingView);
if (!containingView)
return PR_FALSE; // no view -- not visible
relFrameRect.x = frameOffset.x;
relFrameRect.y = frameOffset.y;
}
nsRectVisibility rectVisibility;
@@ -1054,29 +1060,36 @@ nsAccessible::GetState(PRUint32 *aState,
if (display && display->mOpacity == 1.0f &&
!(state & nsIAccessibleStates::STATE_INVISIBLE)) {
*aExtraState |= nsIAccessibleStates::EXT_STATE_OPAQUE;
}
const nsStyleXUL *xulStyle = frame->GetStyleXUL();
if (xulStyle) {
// In XUL all boxes are either vertical or horizontal
- *aExtraState |= (xulStyle->mBoxOrient == NS_STYLE_BOX_ORIENT_VERTICAL) ?
- nsIAccessibleStates::EXT_STATE_VERTICAL :
- nsIAccessibleStates::EXT_STATE_HORIZONTAL;
+ if (xulStyle->mBoxOrient == NS_STYLE_BOX_ORIENT_VERTICAL) {
+ *aExtraState |= nsIAccessibleStates::EXT_STATE_VERTICAL;
+ }
+ else {
+ *aExtraState |= nsIAccessibleStates::EXT_STATE_HORIZONTAL;
+ }
}
}
// XXX We can remove this hack once we support RDF-based role & state maps
if (mRoleMapEntry && (mRoleMapEntry->role == nsIAccessibleRole::ROLE_ENTRY ||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_PASSWORD_TEXT)) {
PRBool isEqual =
NS_LITERAL_CSTRING("textarea").Equals(mRoleMapEntry->roleString);
- *aExtraState = isEqual? nsIAccessibleStates::EXT_STATE_MULTI_LINE :
- nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
+ if (isEqual) {
+ *aExtraState |= nsIAccessibleStates::EXT_STATE_MULTI_LINE;
+ }
+ else {
+ *aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
+ }
}
if (!(state & nsIAccessibleStates::STATE_UNAVAILABLE)) { // If not disabled
*aExtraState |= nsIAccessibleStates::EXT_STATE_ENABLED |
nsIAccessibleStates::EXT_STATE_SENSITIVE;
}
if (state & (nsIAccessibleStates::STATE_COLLAPSED |
@@ -1405,16 +1418,22 @@ NS_IMETHODIMP nsAccessible::TakeSelectio
}
return NS_ERROR_FAILURE;
}
/* void takeFocus (); */
NS_IMETHODIMP nsAccessible::TakeFocus()
{
+ nsCOMPtr<nsIDOMNSHTMLElement> htmlElement(do_QueryInterface(mDOMNode));
+ if (htmlElement) {
+ // HTML Elements also set the caret position
+ // in order to affect tabbing order
+ return htmlElement->Focus();
+ }
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content) {
return NS_ERROR_FAILURE;
}
content->SetFocus(GetPresContext());
return NS_OK;
}
@@ -1861,17 +1880,17 @@ nsresult nsAccessible::GetHTMLName(nsASt
aLabel = label;
return NS_OK;
}
}
if (aCanAggregateSubtree) {
// Don't use AppendFlatStringFromSubtree for container widgets like menulist
nsresult rv = AppendFlatStringFromSubtree(content, &aLabel);
- if (NS_SUCCEEDED(rv)) {
+ if (NS_SUCCEEDED(rv) && !aLabel.IsEmpty()) {
return NS_OK;
}
}
// Still try the title as as fallback method in that case.
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title,
aLabel)) {
aLabel.SetIsVoid(PR_TRUE);
@@ -2013,142 +2032,16 @@ nsAccessible::FireAccessibleEvent(nsIAcc
nsCOMPtr<nsIObserverService> obsService =
do_GetService("@mozilla.org/observer-service;1");
NS_ENSURE_TRUE(obsService, NS_ERROR_FAILURE);
return obsService->NotifyObservers(aEvent, NS_ACCESSIBLE_EVENT_TOPIC, nsnull);
}
-nsRoleMapEntry nsAccessible::gWAIRoleMap[] =
-{
- // This list of WAI-defined roles are currently hardcoded.
- // Eventually we will most likely be loading an RDF resource that contains this information
- // Using RDF will also allow for role extensibility. See bug 280138.
- // XXX Should we store attribute names in this table as atoms instead of strings?
- // Definition of nsRoleMapEntry and nsStateMapEntry contains comments explaining this table.
- {"alert", nsIAccessibleRole::ROLE_ALERT, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"alertdialog", nsIAccessibleRole::ROLE_ALERT, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"application", nsIAccessibleRole::ROLE_APPLICATION, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"button", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"pressed", BOOL_STATE, nsIAccessibleStates::STATE_PRESSED},
- {"haspopup", BOOL_STATE, nsIAccessibleStates::STATE_HASPOPUP}, END_ENTRY},
- {"buttonsubmit", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_DEFAULT, END_ENTRY},
- {"buttoncancel", nsIAccessibleRole::ROLE_PUSHBUTTON, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"checkbox", nsIAccessibleRole::ROLE_CHECKBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"checkboxtristate", nsIAccessibleRole::ROLE_CHECKBUTTON, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED},
- {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"columnheader", nsIAccessibleRole::ROLE_COLUMNHEADER, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"combobox", nsIAccessibleRole::ROLE_COMBOBOX, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY},
- {"expanded", BOOL_STATE, nsIAccessibleStates::STATE_EXPANDED},
- {"multiselectable", BOOL_STATE, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, END_ENTRY},
- {"description", nsIAccessibleRole::ROLE_TEXT_CONTAINER, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"dialog", nsIAccessibleRole::ROLE_DIALOG, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"document", nsIAccessibleRole::ROLE_DOCUMENT, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"label", nsIAccessibleRole::ROLE_LABEL, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"list", nsIAccessibleRole::ROLE_LIST, eNameLabelOrTitle, eNoValue, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY},
- {"multiselectable", BOOL_STATE, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, END_ENTRY},
- {"listbox", nsIAccessibleRole::ROLE_LIST, eNameLabelOrTitle, eNoValue, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY},
- {"multiselectable", BOOL_STATE, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, END_ENTRY},
- {"listitem", nsIAccessibleRole::ROLE_LISTITEM, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
- {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, END_ENTRY},
- {"menu", nsIAccessibleRole::ROLE_MENUPOPUP, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"menubar", nsIAccessibleRole::ROLE_MENUBAR, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"menuitem", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"haspopup", BOOL_STATE, nsIAccessibleStates::STATE_HASPOPUP},
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
- {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
- {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, END_ENTRY},
- {"menuitemcheckbox", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED }, END_ENTRY},
- {"menuitemradio", nsIAccessibleRole::ROLE_MENUITEM, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_CHECKABLE,
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED }, END_ENTRY},
- {"grid", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_FOCUSABLE,
- {"multiselectable", BOOL_STATE, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"gridcell", nsIAccessibleRole::ROLE_CELL, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"group", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"link", nsIAccessibleRole::ROLE_LINK, eNameOkFromChildren, eNoValue, nsIAccessibleStates::STATE_LINKED, END_ENTRY},
- {"option", nsIAccessibleRole::ROLE_LISTITEM, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
- {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE}, END_ENTRY},
- {"progressbar", nsIAccessibleRole::ROLE_PROGRESSBAR, eNameLabelOrTitle, eHasValueMinMax, nsIAccessibleStates::STATE_READONLY,
- {"valuenow", "unknown", nsIAccessibleStates::STATE_MIXED}, END_ENTRY},
- {"radio", nsIAccessibleRole::ROLE_RADIOBUTTON, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED}, END_ENTRY},
- {"radiogroup", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"rowheader", nsIAccessibleRole::ROLE_ROWHEADER, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"secret", nsIAccessibleRole::ROLE_PASSWORD_TEXT, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_PROTECTED,
- END_ENTRY}, // nsIAccessibleStates::EXT_STATE_SINGLE_LINE manually supported in code
- {"separator", nsIAccessibleRole::ROLE_SEPARATOR, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"slider", nsIAccessibleRole::ROLE_SLIDER, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"spinbutton", nsIAccessibleRole::ROLE_SPINBUTTON, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY},
- {"spreadsheet", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE | nsIAccessibleStates::STATE_FOCUSABLE,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY}, // Still supported, but deprecated in favor of grid
- {"status", nsIAccessibleRole::ROLE_STATUSBAR, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"tab", nsIAccessibleRole::ROLE_PAGETAB, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
- {"table", nsIAccessibleRole::ROLE_TABLE, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"td", nsIAccessibleRole::ROLE_CELL, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"th", nsIAccessibleRole::ROLE_CELL, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"tablist", nsIAccessibleRole::ROLE_PAGETABLIST, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"tabpanel", nsIAccessibleRole::ROLE_PROPERTYPAGE, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"textarea", nsIAccessibleRole::ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY}, END_ENTRY}, // XXX nsIAccessibleStates::EXT_STATE_MULTI_LINE supported in code
- {"textfield", nsIAccessibleRole::ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY},
- {"haspopup", BOOL_STATE, nsIAccessibleStates::STATE_HASPOPUP}, END_ENTRY}, // XXX nsIAccessibleStates::EXT_STATE_SINGLE_LINE supported in code
- {"toolbar", nsIAccessibleRole::ROLE_TOOLBAR, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {"tree", nsIAccessibleRole::ROLE_OUTLINE, eNameLabelOrTitle, eNoValue, eNoReqStates,
- {"readonly", BOOL_STATE, nsIAccessibleStates::STATE_READONLY},
- {"multiselectable", BOOL_STATE, nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE}, END_ENTRY},
- {"treeitem", nsIAccessibleRole::ROLE_OUTLINEITEM, eNameOkFromChildren, eNoValue, eNoReqStates,
- {"selected", BOOL_STATE, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
- {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE},
- {"expanded", BOOL_STATE, nsIAccessibleStates::STATE_EXPANDED},
- {"expanded", "false", nsIAccessibleStates::STATE_COLLAPSED},
- {"checked", BOOL_STATE, nsIAccessibleStates::STATE_CHECKED | nsIAccessibleStates::STATE_CHECKABLE},
- {"checked", "mixed", nsIAccessibleStates::STATE_MIXED},
- {"checked", "false", nsIAccessibleStates::STATE_CHECKABLE},},
- {"treegroup", nsIAccessibleRole::ROLE_GROUPING, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
- {nsnull, nsIAccessibleRole::ROLE_NOTHING, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY} // Last item
-};
-
-// XHTML 2 roles
-// These don't need a mapping - they are exposed either through DOM or via MSAA role string
-// banner, contentinfo, main, navigation, note, search, secondary, seealso
-
-nsStateMapEntry nsAccessible::gUnivStateMap[] = {
- {"disabled", BOOL_STATE, nsIAccessibleStates::STATE_UNAVAILABLE},
- {"required", BOOL_STATE, nsIAccessibleStates::STATE_REQUIRED},
- {"invalid", BOOL_STATE, nsIAccessibleStates::STATE_INVALID}
-};
-
NS_IMETHODIMP nsAccessible::GetFinalRole(PRUint32 *aRole)
{
if (mRoleMapEntry) {
*aRole = mRoleMapEntry->role;
if (*aRole != nsIAccessibleRole::ROLE_NOTHING) {
return NS_OK;
}
}
@@ -2333,17 +2226,17 @@ PRBool nsAccessible::MappedAttrState(nsI
// Return true if we should continue
if (!aStateMapEntry->attributeName) {
return PR_FALSE; // Stop looking -- no more states
}
nsAutoString attribValue;
nsCOMPtr<nsIAtom> attribAtom = do_GetAtom(aStateMapEntry->attributeName); // XXX put atoms directly in entry
if (aContent->GetAttr(kNameSpaceID_WAIProperties, attribAtom, attribValue)) {
- if (aStateMapEntry->attributeValue == BOOL_STATE) {
+ if (aStateMapEntry->attributeValue == kBoolState) {
// No attribute value map specified in state map entry indicates state cleared
if (attribValue.EqualsLiteral("false")) {
return *aStateInOut &= ~aStateMapEntry->state;
}
return *aStateInOut |= aStateMapEntry->state;
}
if (NS_ConvertUTF16toUTF8(attribValue).Equals(aStateMapEntry->attributeValue)) {
return *aStateInOut |= aStateMapEntry->state;
@@ -2371,19 +2264,20 @@ nsAccessible::GetARIAState(PRUint32 *aSt
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
// Test for universal states first
nsIContent *content = GetRoleContent(mDOMNode);
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE); // Node already shut down
- PRUint32 length = NS_ARRAY_LENGTH(nsAccessible::gUnivStateMap);
- for (PRUint32 index = 0; index < length; index++) {
- MappedAttrState(content, aState, &nsAccessible::gUnivStateMap[index]);
+ PRUint32 index = 0;
+ while (nsARIAMap::gWAIUnivStateMap[index].attributeName != nsnull) {
+ MappedAttrState(content, aState, &nsARIAMap::gWAIUnivStateMap[index]);
+ ++ index;
}
if (!mRoleMapEntry)
return NS_OK;
// Once DHTML role is used, we're only readonly if DHTML readonly used
(*aState) &= ~nsIAccessibleStates::STATE_READONLY;
@@ -2671,99 +2565,99 @@ NS_IMETHODIMP nsAccessible::GetAccessibl
}
nsCOMPtr<nsIDOMNode> relatedNode;
nsAutoString relatedID;
// Search for the related DOM node according to the specified "relation type"
switch (aRelationType)
{
- case RELATION_LABEL_FOR:
+ case nsIAccessibleRelation::RELATION_LABEL_FOR:
{
if (content->Tag() == nsAccessibilityAtoms::label) {
nsIAtom *relatedIDAttr = content->IsNodeOfType(nsINode::eHTML) ?
nsAccessibilityAtoms::_for : nsAccessibilityAtoms::control;
content->GetAttr(kNameSpaceID_None, relatedIDAttr, relatedID);
}
if (relatedID.IsEmpty()) {
const PRUint32 kAncestorLevelsToSearch = 3;
relatedNode = FindNeighbourPointingToThis(nsAccessibilityAtoms::labelledby,
kAncestorLevelsToSearch);
}
break;
}
- case RELATION_LABELLED_BY:
+ case nsIAccessibleRelation::RELATION_LABELLED_BY:
{
content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::labelledby, relatedID);
if (relatedID.IsEmpty()) {
relatedNode = do_QueryInterface(GetLabelContent(content));
}
break;
}
- case RELATION_DESCRIBED_BY:
+ case nsIAccessibleRelation::RELATION_DESCRIBED_BY:
{
content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::describedby, relatedID);
if (relatedID.IsEmpty()) {
nsIContent *description =
FindNeighbourPointingToNode(content,
nsAccessibilityAtoms::description,
nsAccessibilityAtoms::control);
relatedNode = do_QueryInterface(description);
}
break;
}
- case RELATION_DESCRIPTION_FOR:
+ case nsIAccessibleRelation::RELATION_DESCRIPTION_FOR:
{
const PRUint32 kAncestorLevelsToSearch = 3;
relatedNode =
FindNeighbourPointingToThis(nsAccessibilityAtoms::describedby,
kAncestorLevelsToSearch);
if (!relatedNode && content->Tag() == nsAccessibilityAtoms::description &&
content->IsNodeOfType(nsINode::eXUL)) {
// This affectively adds an optional control attribute to xul:description,
// which only affects accessibility, by allowing the description to be
// tied to a control.
content->GetAttr(kNameSpaceID_None,
nsAccessibilityAtoms::control, relatedID);
}
break;
}
- case RELATION_NODE_CHILD_OF:
+ case nsIAccessibleRelation::RELATION_NODE_CHILD_OF:
{
relatedNode = FindNeighbourPointingToThis(nsAccessibilityAtoms::owns);
break;
}
- case RELATION_CONTROLLED_BY:
+ case nsIAccessibleRelation::RELATION_CONTROLLED_BY:
{
relatedNode = FindNeighbourPointingToThis(nsAccessibilityAtoms::controls);
break;
}
- case RELATION_CONTROLLER_FOR:
+ case nsIAccessibleRelation::RELATION_CONTROLLER_FOR:
{
content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::controls, relatedID);
break;
}
- case RELATION_FLOWS_TO:
+ case nsIAccessibleRelation::RELATION_FLOWS_TO:
{
content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::flowto, relatedID);
break;
}
- case RELATION_FLOWS_FROM:
+ case nsIAccessibleRelation::RELATION_FLOWS_FROM:
{
relatedNode = FindNeighbourPointingToThis(nsAccessibilityAtoms::flowto);
break;
}
- case RELATION_DEFAULT_BUTTON:
+ case nsIAccessibleRelation::RELATION_DEFAULT_BUTTON:
{
if (content->IsNodeOfType(nsINode::eHTML)) {
nsCOMPtr<nsIForm> form;
while ((form = do_QueryInterface(content)) == nsnull &&
(content = content->GetParent()) != nsnull) /* nothing */ ;
if (form) {
relatedNode = do_QueryInterface(form->GetDefaultSubmitElement());
@@ -2821,24 +2715,82 @@ NS_IMETHODIMP nsAccessible::GetAccessibl
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMElement> relatedEl;
domDoc->GetElementById(relatedID, getter_AddRefs(relatedEl));
relatedNode = do_QueryInterface(relatedEl);
}
// Return the corresponding accessible if the related DOM node is found
if (relatedNode) {
- nsCOMPtr<nsIAccessibilityService> accService =
- do_GetService("@mozilla.org/accessibilityService;1");
+ nsCOMPtr<nsIAccessibilityService> accService = GetAccService();
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
return accService->GetAccessibleInWeakShell(relatedNode, mWeakShell, aRelated);
}
return NS_ERROR_FAILURE;
}
+NS_IMETHODIMP
+nsAccessible::GetRelationsCount(PRUint32 *aCount)
+{
+ NS_ENSURE_ARG_POINTER(aCount);
+ *aCount = 0;
+
+ nsCOMPtr<nsIArray> relations;
+ nsresult rv = GetRelations(getter_AddRefs(relations));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return relations->GetLength(aCount);
+}
+
+NS_IMETHODIMP
+nsAccessible::GetRelation(PRUint32 aIndex, nsIAccessibleRelation **aRelation)
+{
+ NS_ENSURE_ARG_POINTER(aRelation);
+ *aRelation = nsnull;
+
+ nsCOMPtr<nsIArray> relations;
+ nsresult rv = GetRelations(getter_AddRefs(relations));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIAccessibleRelation> relation;
+ rv = relations->QueryElementAt(aIndex, NS_GET_IID(nsIAccessibleRelation),
+ getter_AddRefs(relation));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ NS_IF_ADDREF(*aRelation = relation);
+ return rv;
+}
+
+NS_IMETHODIMP
+nsAccessible::GetRelations(nsIArray **aRelations)
+{
+ NS_ENSURE_ARG_POINTER(aRelations);
+
+ nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
+ NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
+
+ // Latest nsIAccessibleRelation is RELATION_DESCRIPTION_FOR (0xof)
+ for (PRUint32 relType = 0; relType < 0x0f; ++relType) {
+ nsCOMPtr<nsIAccessible> accessible;
+ nsresult rv = GetAccessibleRelated(relType, getter_AddRefs(accessible));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (accessible) {
+ nsCOMPtr<nsIAccessibleRelation> relation =
+ new nsAccessibleRelationWrap(relType, accessible);
+ NS_ENSURE_TRUE(relation, NS_ERROR_OUT_OF_MEMORY);
+
+ relations->AppendElement(relation, PR_FALSE);
+ }
+ }
+
+ NS_ADDREF(*aRelations = relations);
+ return NS_OK;
+}
+
/* void extendSelection (); */
NS_IMETHODIMP nsAccessible::ExtendSelection()
{
// XXX Should be implemented, but not high priority
return NS_ERROR_NOT_IMPLEMENTED;
}
/* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
@@ -2857,17 +2809,17 @@ void nsAccessible::DoCommandCallback(nsI
if (xulElement) {
xulElement->Click();
}
else {
nsIDocument *doc = content->GetDocument();
if (!doc) {
return;
}
- nsCOMPtr<nsIPresShell> presShell = doc->GetShellAt(0);
+ nsCOMPtr<nsIPresShell> presShell = doc->GetPrimaryShell();
nsPIDOMWindow *outerWindow = doc->GetWindow();
if (presShell && outerWindow) {
nsAutoPopupStatePusher popupStatePusher(outerWindow, openAllowed);
nsMouseEvent downEvent(PR_TRUE, NS_MOUSE_BUTTON_DOWN, nsnull,
nsMouseEvent::eSynthesized);
nsMouseEvent upEvent(PR_TRUE, NS_MOUSE_BUTTON_UP, nsnull,
nsMouseEvent::eSynthesized);
@@ -3236,17 +3188,17 @@ PRBool nsAccessible::CheckVisibilityInPa
}
view = view->GetParent();
}
nsIDocument* parentDoc = document->GetParentDocument();
if (parentDoc != nsnull) {
nsIContent* content = parentDoc->FindContentForSubDocument(document);
if (content != nsnull) {
- nsIPresShell* shell = parentDoc->GetShellAt(0);
+ nsIPresShell* shell = parentDoc->GetPrimaryShell();
nsIFrame* frame = shell->GetPrimaryFrameFor(content);
while (frame != nsnull && !frame->HasView()) {
frame = frame->GetParent();
}
if (frame != nsnull) {
view = frame->GetViewExternal();
}
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -34,95 +34,51 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsAccessible_H_
#define _nsAccessible_H_
-#include "nsIAccessibleRole.h"
-#include "nsIAccessibleStates.h"
#include "nsAccessNodeWrap.h"
#include "nsAccessibilityUtils.h"
+
#include "nsIAccessible.h"
#include "nsPIAccessible.h"
#include "nsIAccessibleHyperLink.h"
#include "nsIAccessibleSelectable.h"
#include "nsIAccessibleValue.h"
+#include "nsIAccessibleRole.h"
+#include "nsIAccessibleStates.h"
+#include "nsAccessibleRelationWrap.h"
+#include "nsIAccessibleEvent.h"
+
#include "nsIDOMNodeList.h"
#include "nsINameSpaceManager.h"
#include "nsWeakReference.h"
#include "nsString.h"
#include "nsIDOMDOMStringList.h"
+#include "nsARIAMap.h"
struct nsRect;
class nsIContent;
class nsIFrame;
class nsIPresShell;
class nsIDOMNode;
class nsIAtom;
class nsIView;
// When mNextSibling is set to this, it indicates there ar eno more siblings
#define DEAD_END_ACCESSIBLE NS_STATIC_CAST(nsIAccessible*, (void*)1)
// Saves a data member -- if child count equals this value we haven't
// cached children or child count yet
enum { eChildCountUninitialized = -1 };
-struct nsStateMapEntry
-{
- const char* attributeName; // magic value of nsnull means last entry in map
- const char* attributeValue; // magic value of nsnull means any value
- PRUint32 state; // OR state with this
-};
-
-enum ENameRule {
- eNameLabelOrTitle, // Collect name if explicitly specified from
- // 1) content subtree pointed to by labelledby
- // which contains the ID for the label content, or
- // 2) title attribute if specified
- eNameOkFromChildren // Collect name from
- // 1) labelledby attribute if specified, or
- // 2) text & img descendents, or
- // 3) title attribute if specified
-};
-
-enum EValueRule {
- eNoValue,
- eHasValueMinMax // Supports value, min and max from waistate:valuenow, valuemin and valuemax
-};
-
-#define eNoReqStates 0
-#define END_ENTRY {0, 0, 0} // To fill in array of state mappings
-#define BOOL_STATE 0
-
-struct nsRoleMapEntry
-{
- const char *roleString; // such as "button"
- PRUint32 role; // use this role
- ENameRule nameRule; // how to compute name
- EValueRule valueRule; // how to compute name
- PRUint32 state; // always OR state with this
- // For this role with a DOM attribute/value match definined in
- // nsStateMapEntry.attributeName && .attributeValue, OR accessible state with
- // nsStateMapEntry.state
- // Currently you can have up to 3 DOM attributes with accessible state mappings.
- // A variable sized array would not allow use of C++'s struct initialization feature.
- nsStateMapEntry attributeMap1;
- nsStateMapEntry attributeMap2;
- nsStateMapEntry attributeMap3;
- nsStateMapEntry attributeMap4;
- nsStateMapEntry attributeMap5;
- nsStateMapEntry attributeMap6;
- nsStateMapEntry attributeMap7;
-};
-
-
class nsAccessibleDOMStringList : public nsIDOMDOMStringList
{
public:
nsAccessibleDOMStringList();
virtual ~nsAccessibleDOMStringList();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMSTRINGLIST
@@ -302,16 +258,13 @@ protected:
// Check the visibility across both parent content and chrome
PRBool CheckVisibilityInParentChain(nsIDocument* aDocument, nsIView* aView);
// Data Members
nsCOMPtr<nsIAccessible> mParent;
nsIAccessible *mFirstChild, *mNextSibling;
nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well
PRInt32 mAccChildCount;
-
- static nsRoleMapEntry gWAIRoleMap[];
- static nsStateMapEntry gUnivStateMap[];
};
#endif
--- a/accessible/src/base/nsAccessibleEventData.cpp
+++ b/accessible/src/base/nsAccessibleEventData.cpp
@@ -63,26 +63,19 @@ nsAccEvent::GetEventType(PRUint32 *aEven
}
NS_IMETHODIMP
nsAccEvent::GetAccessible(nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nsnull;
- if (!mAccessible) {
- NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
- nsCOMPtr<nsIAccessibilityService> accService =
- do_GetService("@mozilla.org/accessibilityService;1");
- NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
- accService->GetAccessibleFor(mDOMNode, getter_AddRefs(mAccessible));
- if (!mAccessible) {
- return NS_OK;
- }
- }
+ if (!mAccessible)
+ mAccessible = GetAccessibleByNode();
+
NS_IF_ADDREF(*aAccessible = mAccessible);
return NS_OK;
}
NS_IMETHODIMP
nsAccEvent::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
@@ -114,16 +107,32 @@ nsAccEvent::GetAccessibleDocument(nsIAcc
NS_ENSURE_TRUE(accessNode, NS_ERROR_FAILURE);
accessNode->GetAccessibleDocument(getter_AddRefs(mDocAccessible));
}
NS_IF_ADDREF(*aDocAccessible = mDocAccessible);
return NS_OK;
}
+already_AddRefed<nsIAccessible>
+nsAccEvent::GetAccessibleByNode()
+{
+ if (!mDOMNode)
+ return nsnull;
+
+ nsCOMPtr<nsIAccessibilityService> accService =
+ do_GetService("@mozilla.org/accessibilityService;1");
+ if (!accService)
+ return nsnull;
+
+ nsIAccessible *accessible = nsnull;
+ accService->GetAcces