зеркало из https://github.com/mozilla/pjs.git
Bug 340829. Implement big hunk of new-atk, nsAccessibleHyperText, to support specialized accessibility interfaces cross-platform and expose containment hierarchy as such. r=ginn.chen
This commit is contained in:
Родитель
c2eda3f750
Коммит
5d1389f2f1
|
@ -54,7 +54,7 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
|
|||
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createXULAlertAccessible(in nsIDOMNode aNode);
|
||||
nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
|
||||
nsIAccessible createHTMLBlockAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHyperTextAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLButtonAccessibleXBL(in nsIDOMNode aNode);
|
||||
nsIAccessible createHTMLAccessibleByMarkup(in nsISupports aFrame, in nsIWeakReference aWeakShell, in nsIDOMNode aDOMNode, in AString aRole);
|
||||
|
@ -74,7 +74,6 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
|
|||
nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsIWeakReference aPresShell);
|
||||
nsIAccessible createHTMLTableAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLTableCellAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLTableCaptionAccessible(in nsIDOMNode aDOMNode);
|
||||
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
|
||||
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame);
|
||||
|
|
|
@ -148,6 +148,12 @@ interface nsIAccessible : nsISupports
|
|||
*/
|
||||
readonly attribute unsigned long extState;
|
||||
|
||||
/**
|
||||
* True if this element is live in an editor.
|
||||
* False if the content is being displayed but not edited.
|
||||
*/
|
||||
readonly attribute boolean isEditable;
|
||||
|
||||
/**
|
||||
* Help text associated with node
|
||||
*/
|
||||
|
@ -293,6 +299,7 @@ interface nsIAccessible : nsISupports
|
|||
* Extended state flags (for now non-MSAA, for Java and Gnome/ATK support)
|
||||
* "Extended state flags" has seperate value space from "MSAA State flags".
|
||||
*/
|
||||
const unsigned long EXT_STATE_SELECTABLE_TEXT= 0x00100000; // For text which is selectable, object must implement nsIAccessibleText
|
||||
const unsigned long EXT_STATE_EDITABLE = 0x00200000; // Used for XUL/HTML input (type = text,password) element
|
||||
const unsigned long EXT_STATE_ACTIVE = 0x00400000; // This window is currently the active window
|
||||
const unsigned long EXT_STATE_EXPANDABLE = 0x00800000; // An item that can be expanded, such as a tree item with children
|
||||
|
@ -452,8 +459,9 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_INDICATOR = 66U }; // ATK_ROLE_UNKNOWN
|
||||
enum { ROLE_GRAPHIC = 26U }; // ATK_ROLE_IMAGE
|
||||
// Read-only text, can't be modified or selected
|
||||
enum { ROLE_STATICTEXT = 60U }; // ATK_ROLE_TEXT
|
||||
enum { ROLE_TEXT = 60U }; // ATK_ROLE_TEXT
|
||||
enum { ROLE_STATICTEXT = 50000U }; // No matching ATK role, we will strip out
|
||||
enum { ROLE_TEXT_LEAF = 50000U }; // No matching ATK role, we will strip out
|
||||
enum { ROLE_TEXT_CONTAINER = 60U }; // ATK_ROLE_TEXT
|
||||
enum { ROLE_PUSHBUTTON = 42U }; // ATK_ROLE_PUSH_BUTTON
|
||||
enum { ROLE_CHECKBUTTON = 7U }; // ATK_ROLE_CHECK_BOX
|
||||
enum { ROLE_RADIOBUTTON = 43U }; // ATK_ROLE_RADIO_BUTTON
|
||||
|
@ -481,7 +489,7 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_IPADDRESS = 66U }; // ATK_ROLE_UNKNOWN
|
||||
enum { ROLE_NOTHING = 66U }; // ATK_ROLE_UNKNOWN
|
||||
// Represent top level window
|
||||
enum { ROLE_FRAME = 22U }; // ATK_ROLE_FRAME
|
||||
enum { ROLE_FRAME = 22U }; // ATK_ROLE_FRAME
|
||||
|
||||
// Other roles from atk.h
|
||||
enum { ROLE_ACCEL_LABEL = 1U }; // ATK_ROLE_ACCEL_LABEL
|
||||
|
@ -530,6 +538,7 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_PAGE = 82U }; // ATK_ROLE_PAGE
|
||||
enum { ROLE_SECTION = 83U }; // ATK_ROLE_SECTION
|
||||
enum { ROLE_REDUNDANT_OBJECT = 84U }; // ATK_ROLE_REDUNDANT_OBJECT
|
||||
enum { ROLE_FORM = 85U }; // ATK_ROLE_FORM
|
||||
#else
|
||||
// MSAA Roles - only one per nsIAccessible or IAccessible
|
||||
enum { ROLE_TITLEBAR = 1U };
|
||||
|
@ -576,7 +585,7 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_INDICATOR = 39U };
|
||||
enum { ROLE_GRAPHIC = 40U };
|
||||
enum { ROLE_STATICTEXT = 41U };
|
||||
enum { ROLE_TEXT = 42U };
|
||||
enum { ROLE_TEXT_LEAF = 42U };
|
||||
enum { ROLE_PUSHBUTTON = 43U };
|
||||
enum { ROLE_CHECKBUTTON = 44U };
|
||||
enum { ROLE_RADIOBUTTON = 45U };
|
||||
|
@ -614,6 +623,11 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_PAGE = ROLE_NOTHING };
|
||||
enum { ROLE_SECTION = ROLE_NOTHING };
|
||||
enum { ROLE_REDUNDANT_OBJECT = ROLE_NOTHING };
|
||||
enum { ROLE_HTML_CONTAINER = ROLE_NOTHING };
|
||||
enum { ROLE_FORM = ROLE_NOTHING };
|
||||
enum { ROLE_PARAGRAPH = ROLE_NOTHING };
|
||||
enum { ROLE_TEXT_CONTAINER = ROLE_NOTHING };
|
||||
enum { ROLE_LABEL = ROLE_STATICTEXT };
|
||||
|
||||
// MSAA relationship extensions to accNavigate
|
||||
enum { NAVRELATION_CONTROLLED_BY = 0x1000 };
|
||||
|
|
|
@ -81,14 +81,6 @@ interface nsIAccessibleDocument : nsISupports
|
|||
*/
|
||||
readonly attribute AString docType;
|
||||
|
||||
/**
|
||||
* True if the document is live in an editor.
|
||||
* False if the document is being displayed but not edited.
|
||||
* If a <div> is contentEditable, then it has its own document,
|
||||
* with isEditable == true.
|
||||
*/
|
||||
readonly attribute boolean isEditable;
|
||||
|
||||
/**
|
||||
* The nsIDOMDocument interface associated with this document.
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
typedef long nsAccessibleTextBoundary;
|
||||
typedef long nsAccessibleCoordType;
|
||||
|
||||
interface nsIAccessible;
|
||||
|
||||
[scriptable, uuid(E44D3FA6-9CB2-432A-8BDB-69D72B6ADA00)]
|
||||
interface nsIAccessibleText : nsISupports
|
||||
{
|
||||
|
@ -93,9 +95,14 @@ interface nsIAccessibleText : nsISupports
|
|||
*/
|
||||
wchar getCharacterAtOffset (in long offset);
|
||||
|
||||
nsISupports getAttributeRange (in long offset,
|
||||
out long rangeStartOffset,
|
||||
out long rangeEndOffset);
|
||||
/**
|
||||
* Get the accessible and start/end offsets around the given offset.
|
||||
* This accessible get return the DOM node and layout frame
|
||||
* with the uniform attributes for this range of text
|
||||
*/
|
||||
nsIAccessible getAttributeRange (in long offset,
|
||||
out long rangeStartOffset,
|
||||
out long rangeEndOffset);
|
||||
|
||||
void getCharacterExtents (in long offset,
|
||||
out long x,
|
||||
|
|
|
@ -68,12 +68,8 @@ CPPSRCS = \
|
|||
nsDocAccessibleWrap.cpp \
|
||||
nsRootAccessibleWrap.cpp \
|
||||
nsAppRootAccessible.cpp \
|
||||
nsAccessibleText.cpp \
|
||||
nsAccessibleHyperText.cpp \
|
||||
nsHTMLFormControlAccessibleWrap.cpp \
|
||||
nsHTMLLinkAccessibleWrap.cpp \
|
||||
nsHTMLTableAccessibleWrap.cpp \
|
||||
nsHTMLBlockAccessible.cpp \
|
||||
nsMaiInterfaceComponent.cpp \
|
||||
nsMaiInterfaceAction.cpp \
|
||||
nsMaiInterfaceText.cpp \
|
||||
|
@ -87,7 +83,6 @@ CPPSRCS = \
|
|||
|
||||
#ifdef MOZ_XUL
|
||||
CPPSRCS += \
|
||||
nsXULFormControlAccessibleWrap.cpp \
|
||||
nsXULTreeAccessibleWrap.cpp \
|
||||
$(NULL)
|
||||
#endif
|
||||
|
@ -96,11 +91,11 @@ EXPORTS = \
|
|||
nsAccessNodeWrap.h \
|
||||
nsAccessibleWrap.h \
|
||||
nsDocAccessibleWrap.h \
|
||||
nsHTMLFormControlAccessibleWrap.h \
|
||||
nsRootAccessibleWrap.h \
|
||||
nsTextAccessibleWrap.h \
|
||||
nsXULMenuAccessibleWrap.h \
|
||||
nsXULTreeAccessibleWrap.h \
|
||||
nsAccessibleText.h \
|
||||
$(NULL)
|
||||
|
||||
# we want to force the creation of a static lib.
|
||||
|
|
|
@ -274,6 +274,10 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
|
|||
{
|
||||
*aOutAccessible = nsnull;
|
||||
|
||||
if (HasRole(this, ROLE_TEXT_LEAF)) {
|
||||
// We don't create ATK objects for nsIAccessible plain text leaves
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mMaiAtkObject) {
|
||||
GType type = GetMaiAtkType(CreateMaiInterfaces());
|
||||
NS_ENSURE_TRUE(type, NS_ERROR_FAILURE);
|
||||
|
@ -320,22 +324,20 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
|
|||
PRUint32 accRole;
|
||||
GetRole(&accRole);
|
||||
|
||||
if (accRole != nsIAccessible::ROLE_HTML_CONTAINER) {
|
||||
//nsIAccessibleText
|
||||
nsCOMPtr<nsIAccessibleText> accessInterfaceText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleText),
|
||||
getter_AddRefs(accessInterfaceText));
|
||||
if (accessInterfaceText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
|
||||
}
|
||||
//nsIAccessibleText
|
||||
nsCOMPtr<nsIAccessibleText> accessInterfaceText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleText),
|
||||
getter_AddRefs(accessInterfaceText));
|
||||
if (accessInterfaceText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
|
||||
}
|
||||
|
||||
//nsIAccessibleEditableText
|
||||
nsCOMPtr<nsIAccessibleEditableText> accessInterfaceEditableText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
||||
getter_AddRefs(accessInterfaceEditableText));
|
||||
if (accessInterfaceEditableText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
|
||||
}
|
||||
//nsIAccessibleEditableText
|
||||
nsCOMPtr<nsIAccessibleEditableText> accessInterfaceEditableText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
||||
getter_AddRefs(accessInterfaceEditableText));
|
||||
if (accessInterfaceEditableText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
|
||||
}
|
||||
|
||||
//nsIAccessibleSelection
|
||||
|
@ -533,10 +535,12 @@ nsAccessibleWrap::TranslateStates(PRUint32 aState, PRUint32 aExtState, void *aAt
|
|||
atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
|
||||
}
|
||||
|
||||
#ifdef USE_ATK_STATE_INVALID_ENTRY
|
||||
if (aState & nsIAccessible::STATE_INVALID)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_INVALID);
|
||||
atk_state_set_add_state (state_set, ATK_STATE_INVALID_ENTRY);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef USE_ATK_STATE_DEFAULT
|
||||
if (aState & nsIAccessible::STATE_DEFAULT)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_DEFAULT);
|
||||
#endif
|
||||
|
@ -546,8 +550,23 @@ nsAccessibleWrap::TranslateStates(PRUint32 aState, PRUint32 aExtState, void *aAt
|
|||
atk_state_set_add_state (state_set, ATK_STATE_REQUIRED);
|
||||
#endif
|
||||
|
||||
#ifdef USE_ATK_STATE_VISITED
|
||||
if (aState & nsIAccessible::STATE_TRAVERSED)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_VISITED);
|
||||
#endif
|
||||
|
||||
#ifdef USE_ATK_STATE_ANIMATED
|
||||
if (aState & nsIAccessible::STATE_ANIMATED)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_ANIMATED);
|
||||
#endif
|
||||
|
||||
// The following state is
|
||||
// Extended state flags (for now non-MSAA, for Java and Gnome/ATK support)
|
||||
#ifdef USE_ATK_STATE_SELECTABLE_TEXT
|
||||
if (aExtState & nsIAccessible::EXT_STATE_SELECTABLE_TEXT)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE_TEXT);
|
||||
#endif
|
||||
|
||||
if (aExtState & nsIAccessible::EXT_STATE_ACTIVE)
|
||||
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
|
||||
|
||||
|
@ -800,6 +819,9 @@ getRoleCB(AtkObject *aAtkObj)
|
|||
}
|
||||
accRole = linkRole;
|
||||
}
|
||||
else if (accRole == nsIAccessible::ROLE_TEXT_CONTAINER) {
|
||||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#ifndef USE_ATK_ROLE_AUTOCOMPLETE
|
||||
else if (accRole == nsIAccessible::ROLE_AUTOCOMPLETE) {
|
||||
accRole = ATK_ROLE_COMBO_BOX;
|
||||
|
@ -810,9 +832,29 @@ getRoleCB(AtkObject *aAtkObj)
|
|||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_CAPTION
|
||||
else if (accRole == nsIAccessible::ROLE_CAPTION) {
|
||||
accRole = ATK_ROLE_LABEL;
|
||||
#ifndef USE_ATK_ROLE_FORM
|
||||
else if (accRole == nsIAccessible::ROLE_FORM) {
|
||||
accRole = ATK_ROLE_PANEL;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_HEADING
|
||||
else if (accRole == nsIAccessible::ROLE_HEADING) {
|
||||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_SECTION
|
||||
else if (accRole == nsIAccessible::ROLE_SECTION) {
|
||||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_PARAGRAPH
|
||||
else if (accRole == nsIAccessible::ROLE_PARAGRAPH) {
|
||||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_DOCUMENT_FRAME
|
||||
else if (accRole == nsIAccessible::ROLE_DOCUMENT) {
|
||||
accRole = ATK_ROLE_HTML_CONTAINER;
|
||||
}
|
||||
#endif
|
||||
aAtkObj->role = NS_STATIC_CAST(AtkRole, accRole);
|
||||
|
@ -850,20 +892,50 @@ getChildCountCB(AtkObject *aAtkObj)
|
|||
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
|
||||
|
||||
PRInt32 count = 0;
|
||||
accWrap->GetChildCount(&count);
|
||||
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);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIAccessibleText> accText;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText), getter_AddRefs(accText));
|
||||
if (!accText) { // Accessible text that is not a HyperText has no children
|
||||
accWrap->GetChildCount(&count);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
AtkObject *
|
||||
refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
||||
{
|
||||
// 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;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAccessible> accChild;
|
||||
rv = accWrap->GetChildAt(aChildIndex, getter_AddRefs(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;
|
||||
rv = hyperText->GetLink(aChildIndex, getter_AddRefs(hyperLink));
|
||||
accChild = do_QueryInterface(hyperLink);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIAccessibleText> accText;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText), getter_AddRefs(accText));
|
||||
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;
|
||||
|
|
|
@ -71,26 +71,26 @@
|
|||
#define USE_ATK_ROLE_CAPTION
|
||||
#define USE_ATK_ROLE_ENTRY
|
||||
#define USE_ATK_ROLE_CHART // XXX not currently used
|
||||
#define USE_ATK_ROLE_DOCUMENT_FRAME // XXX not currently used
|
||||
#define USE_ATK_ROLE_HEADING // XXX not currently used
|
||||
#define USE_ATK_ROLE_PAGE // XXX not currently used
|
||||
#define USE_ATK_ROLE_SECTION // XXX not currently used
|
||||
#define USE_ATK_ROLE_DOCUMENT_FRAME
|
||||
#define USE_ATK_ROLE_HEADING
|
||||
#define USE_ATK_ROLE_PAGE
|
||||
#define USE_ATK_ROLE_SECTION
|
||||
#define USE_ATK_ROLE_REDUNDANT_OBJECT // XXX not currently used
|
||||
#define USE_ATK_OBJECT_ATTRIBUTES // XXX not currently used
|
||||
#define USE_ATK_STATE_INVALID_ENTRY // XXX not currently used
|
||||
#define USE_ATK_STATE_INVALID_ENTRY
|
||||
// When should we use ROLE_AUTCOMPLETE vs. STATE_SUPPORTS_AUTOCOMPLETION?
|
||||
#define USE_ATK_STATE_SUPPORTS_AUTOCOMPLETION // XXX not currently used
|
||||
#define USE_ATK_STATE_SELECTABLE_TEXT // XXX not currently used
|
||||
#define USE_ATK_DOCUMENT // XXX not currently used
|
||||
#define USE_ATK_STATE_SELECTABLE_TEXT
|
||||
#endif
|
||||
|
||||
// ATK 1.12.0 or later
|
||||
#if ATK_MAJOR_VERSION >=2 || \
|
||||
(ATK_MAJOR_VERSION == 1 && ATK_MINOR_VERSION >= 12)
|
||||
#define USE_ATK_VALUE_MINIMUMINCREMENT // XXX not currently used
|
||||
#define USE_ATK_STATE_DEFAULT // XXX not currently used
|
||||
#define USE_ATK_STATE_VISITED // XXX not currently used
|
||||
#define USE_ATK_STATE_ANIMATED // XXX not currently used
|
||||
#define USE_ATK_ROLE_FORM // XXX not currently used
|
||||
#define USE_ATK_VALUE_MINIMUMINCREMENT
|
||||
#define USE_ATK_STATE_DEFAULT
|
||||
#define USE_ATK_STATE_VISITED
|
||||
#define USE_ATK_STATE_ANIMATED
|
||||
#define USE_ATK_ROLE_FORM
|
||||
#define USE_ATK_DESCRIPTION_RELATIONS
|
||||
#endif
|
||||
|
||||
|
@ -139,4 +139,6 @@ private:
|
|||
PRUint16 CreateMaiInterfaces(void);
|
||||
};
|
||||
|
||||
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
|
||||
|
||||
#endif /* __NS_ACCESSIBLE_WRAP_H__ */
|
||||
|
|
|
@ -76,7 +76,7 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsDocAccessibleWrap, nsDocAccessible, nsIAccessible
|
|||
|
||||
nsDocAccessibleWrap::nsDocAccessibleWrap(nsIDOMNode *aDOMNode,
|
||||
nsIWeakReference *aShell):
|
||||
nsDocAccessible(aDOMNode, aShell), nsAccessibleEditableText(aDOMNode)
|
||||
nsDocAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -513,32 +513,6 @@ TranslateAState(PRUint32 aState, PRUint32 aExtState)
|
|||
return ATK_STATE_INVALID;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::Shutdown()
|
||||
{
|
||||
nsAccessibleEditableText::ShutdownEditor();
|
||||
return nsDocAccessible::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::GetRole(PRUint32 *_retval)
|
||||
{
|
||||
PRBool isEditable;
|
||||
GetIsEditable(&isEditable);
|
||||
|
||||
if (isEditable)
|
||||
*_retval = ROLE_TEXT;
|
||||
else
|
||||
*_retval = ROLE_HTML_CONTAINER;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocAccessibleWrap::CheckForEditor()
|
||||
{
|
||||
nsDocAccessible::CheckForEditor();
|
||||
if (mEditor)
|
||||
SetEditor(mEditor); // set editor for nsAccessibleEditableText
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::FireDocLoadingEvent(PRBool aIsFinished)
|
||||
{
|
||||
if (!mDocument || !mWeakShell)
|
||||
|
|
|
@ -47,10 +47,8 @@
|
|||
#define _nsDocAccessibleWrap_H_
|
||||
|
||||
#include "nsDocAccessible.h"
|
||||
#include "nsAccessibleText.h"
|
||||
|
||||
class nsDocAccessibleWrap: public nsDocAccessible,
|
||||
public nsAccessibleEditableText
|
||||
class nsDocAccessibleWrap: public nsDocAccessible
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
@ -60,11 +58,6 @@ public:
|
|||
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible,
|
||||
void* aData);
|
||||
NS_IMETHOD FireDocLoadingEvent(PRBool isFinished);
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD GetRole(PRUint32 *aAccRole);
|
||||
|
||||
protected:
|
||||
void CheckForEditor();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,57 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kyle Yuan (kyle.yuan@sun.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 _nsHTMLFormControlAccessibleWrap_H_
|
||||
#define _nsHTMLFormControlAccessibleWrap_H_
|
||||
|
||||
#include "nsHTMLFormControlAccessible.h"
|
||||
#include "nsAccessibleText.h"
|
||||
|
||||
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
|
||||
|
||||
class nsHTMLTextFieldAccessibleWrap : public nsHTMLTextFieldAccessible,
|
||||
public nsAccessibleEditableText
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTextFieldAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD Shutdown();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,254 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gilbert Fang (gilbert.fang@sun.com)
|
||||
* Kyle Yuan (kyle.yuan@sun.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 "nsHTMLLinkAccessibleWrap.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsArrayUtils.h"
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLLinkAccessibleWrap Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLLinkAccessibleWrap, nsHTMLLinkAccessible, nsIAccessibleHyperLink)
|
||||
|
||||
nsHTMLLinkAccessibleWrap::nsHTMLLinkAccessibleWrap(nsIDOMNode* aDomNode, nsIArray* aTextNodes, nsIWeakReference* aShell, nsIFrame *aFrame):
|
||||
nsHTMLLinkAccessible(aDomNode, aShell, aFrame)
|
||||
{
|
||||
mTextNodes = aTextNodes;
|
||||
}
|
||||
|
||||
//-------------------------- nsIAccessibleHyperLink -------------------------
|
||||
/* readonly attribute long anchors; */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::GetAnchors(PRInt32 *aAnchors)
|
||||
{
|
||||
if (!mIsLink)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aAnchors = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long startIndex; */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::GetStartIndex(PRInt32 *aStartIndex)
|
||||
{
|
||||
PRInt32 endIndex;
|
||||
return GetLinkOffset(aStartIndex, &endIndex);
|
||||
}
|
||||
|
||||
/* readonly attribute long endIndex; */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::GetEndIndex(PRInt32 *aEndIndex)
|
||||
{
|
||||
PRInt32 startIndex;
|
||||
return GetLinkOffset(&startIndex, aEndIndex);
|
||||
}
|
||||
|
||||
/* nsIURI getURI (in long i); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::GetURI(PRInt32 i, nsIURI **aURI)
|
||||
{
|
||||
//I do not know why we have to return a nsIURI instead of
|
||||
//nsILink or just a string of url. Anyway, maybe nsIURI is
|
||||
//more powerful for the future.
|
||||
*aURI = nsnull;
|
||||
|
||||
if (!mIsLink)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(mActionContent));
|
||||
if (link) {
|
||||
return link->GetHrefURI(aURI);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* nsIAccessible getObject (in long i); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::GetObject(PRInt32 aIndex,
|
||||
nsIAccessible **aAccessible)
|
||||
{
|
||||
if (0 != aIndex)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return QueryInterface(NS_GET_IID(nsIAccessible), (void **)aAccessible);
|
||||
}
|
||||
|
||||
/* boolean isValid (); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::IsValid(PRBool *aIsValid)
|
||||
{
|
||||
// I have not found the cause which makes this attribute false.
|
||||
*aIsValid = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isSelected (); */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessibleWrap::IsSelected(PRBool *aIsSelected)
|
||||
{
|
||||
*aIsSelected = (gLastFocusedNode == mDOMNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLLinkAccessibleWrap::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
|
||||
{
|
||||
NS_ENSURE_TRUE(mTextNodes, NS_ERROR_FAILURE);
|
||||
|
||||
if (!mIsLink)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsILink> currentLink(do_QueryInterface(mActionContent));
|
||||
NS_ENSURE_TRUE(currentLink, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 index, count = 0;
|
||||
PRUint32 totalLength = 0, textLength = 0;
|
||||
|
||||
mTextNodes->GetLength(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextNodes, index));
|
||||
nsCOMPtr<nsIDOMText> domText(do_QueryInterface(domNode));
|
||||
if (domText) {
|
||||
domText->GetLength(&textLength);
|
||||
totalLength += textLength;
|
||||
}
|
||||
|
||||
// text node maybe a child (or grandchild, ...) of a link node
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
nsCOMPtr<nsILink> link = nsnull;
|
||||
domNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
while (parentNode) {
|
||||
link = do_QueryInterface(parentNode);
|
||||
if (link)
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> temp = parentNode;
|
||||
temp->GetParentNode(getter_AddRefs(parentNode));
|
||||
}
|
||||
|
||||
if (link == currentLink) {
|
||||
*aEndOffset = totalLength;
|
||||
*aStartOffset = totalLength - textLength;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLImageMapAccessible Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageMapAccessible, nsHTMLImageAccessible, nsIAccessibleHyperLink)
|
||||
|
||||
nsHTMLImageMapAccessible::nsHTMLImageMapAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLImageAccessible(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
/* readonly attribute long anchors; */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::GetAnchors(PRInt32 *aAnchors)
|
||||
{
|
||||
return GetChildCount(aAnchors);
|
||||
}
|
||||
|
||||
/* readonly attribute long startIndex; */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::GetStartIndex(PRInt32 *aStartIndex)
|
||||
{
|
||||
//should not be supported in image map hyperlink
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute long endIndex; */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::GetEndIndex(PRInt32 *aEndIndex)
|
||||
{
|
||||
//should not be supported in image map hyperlink
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIURI getURI (in long i); */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
{
|
||||
*aURI = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> mapAreas;
|
||||
mMapElement->GetAreas(getter_AddRefs(mapAreas));
|
||||
if (!mapAreas)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
mapAreas->Item(aIndex,getter_AddRefs(domNode));
|
||||
if (!domNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (content) {
|
||||
nsCOMPtr<nsIURI> baseURI = content->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIDOMElement> area(do_QueryInterface(domNode));
|
||||
nsAutoString hrefValue;
|
||||
if (NS_SUCCEEDED(area->GetAttribute(NS_LITERAL_STRING("href"), hrefValue))) {
|
||||
return NS_NewURI(aURI, hrefValue, nsnull, baseURI);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* nsIAccessible getObject (in long i); */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::GetObject(PRInt32 aIndex,
|
||||
nsIAccessible **aAccessible)
|
||||
{
|
||||
*aAccessible = nsnull;
|
||||
nsCOMPtr<nsIAccessible> areaAccessible;
|
||||
nsresult rv = GetChildAt(aIndex, getter_AddRefs(areaAccessible));
|
||||
areaAccessible.swap(*aAccessible);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* boolean isValid (); */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::IsValid(PRBool *aIsValid)
|
||||
{
|
||||
*aIsValid = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isSelected (); */
|
||||
NS_IMETHODIMP nsHTMLImageMapAccessible::IsSelected(PRBool *aIsSelected)
|
||||
{
|
||||
*aIsSelected = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,71 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gilbert Fang (gilbert.fang@sun.com)
|
||||
* Kyle Yuan (kyle.yuan@sun.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 _nsHTMLLinkAccessibleWrap_H_
|
||||
#define _nsHTMLLinkAccessibleWrap_H_
|
||||
|
||||
#include "nsHTMLImageAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsIAccessibleHyperLink.h"
|
||||
#include "nsIMutableArray.h"
|
||||
|
||||
class nsHTMLLinkAccessibleWrap : public nsHTMLLinkAccessible,
|
||||
public nsIAccessibleHyperLink
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEHYPERLINK
|
||||
|
||||
nsHTMLLinkAccessibleWrap(nsIDOMNode* aDomNode, nsIArray* aTextNodes, nsIWeakReference* aShell, nsIFrame *aFrame);
|
||||
private:
|
||||
nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);
|
||||
nsCOMPtr<nsIArray> mTextNodes;
|
||||
};
|
||||
|
||||
class nsHTMLImageMapAccessible : public nsHTMLImageAccessible,
|
||||
public nsIAccessibleHyperLink
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEHYPERLINK
|
||||
|
||||
nsHTMLImageMapAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,604 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 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 Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2002 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Pete Zha (pete.zha@sun.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kyle Yuan (kyle.yuan@sun.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsHTMLTableAccessibleWrap.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLTableCaptionElem.h"
|
||||
#include "nsIDOMHTMLTableCellElement.h"
|
||||
#include "nsIDOMHTMLTableElement.h"
|
||||
#include "nsIDOMHTMLTableRowElement.h"
|
||||
#include "nsIDOMHTMLTableSectionElem.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLTableCellAccessibleWrap Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsHTMLTableCellAccessibleWrap, nsHTMLTableCellAccessible, nsIAccessibleText, nsIAccessibleHyperText)
|
||||
|
||||
nsHTMLTableCellAccessibleWrap::nsHTMLTableCellAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLTableCellAccessible(aDomNode, aShell), nsAccessibleHyperText(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLTableCellAccessibleWrap::Shutdown()
|
||||
{
|
||||
nsAccessibleHyperText::Shutdown();
|
||||
return nsHTMLTableCellAccessible::Shutdown();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLTableAccessibleWrap Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTableAccessibleWrap, nsHTMLTableAccessible, nsIAccessibleTable)
|
||||
|
||||
nsHTMLTableAccessibleWrap::nsHTMLTableAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHTMLTableAccessible(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
*aCaption = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption;
|
||||
rv = table->GetCaption(getter_AddRefs(caption));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> captionNode(do_QueryInterface(caption));
|
||||
NS_ENSURE_TRUE(captionNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
accService->GetCachedAccessible(captionNode, mWeakShell, aCaption);
|
||||
if (*aCaption)
|
||||
return NS_OK;
|
||||
|
||||
return accService->CreateHTMLTableCaptionAccessible(captionNode, aCaption);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::SetCaption(nsIAccessible *aCaption)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aCaption));
|
||||
NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
rv = accessNode->GetDOMNode(getter_AddRefs(domNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> newDOMNode;
|
||||
rv = domNode->CloneNode(PR_TRUE, getter_AddRefs(newDOMNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement>
|
||||
captionElement(do_QueryInterface(newDOMNode));
|
||||
NS_ENSURE_TRUE(captionElement, NS_ERROR_FAILURE);
|
||||
|
||||
return table->SetCaption(captionElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetSummary(nsAString &aSummary)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
return table->GetSummary(aSummary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::SetSummary(const nsAString &aSummary)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
return table->SetSummary(aSummary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumns(PRInt32 *aColumns)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 rows;
|
||||
return tableLayout->GetTableSize(rows, *aColumns);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
rv = table->GetTHead(getter_AddRefs(section));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accHead;
|
||||
nsCOMPtr<nsIDOMNode> sectionNode(do_QueryInterface(section));
|
||||
if (sectionNode) {
|
||||
rv = accService->GetCachedAccessible(sectionNode, mWeakShell,
|
||||
getter_AddRefs(accHead));
|
||||
}
|
||||
|
||||
if (!accHead) {
|
||||
rv = accService->CreateHTMLTableHeadAccessible(section,
|
||||
getter_AddRefs(accHead));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibleTable> accTableHead(do_QueryInterface(accHead));
|
||||
NS_ENSURE_TRUE(accTableHead, NS_ERROR_FAILURE);
|
||||
|
||||
*aColumnHeader = accTableHead;
|
||||
NS_IF_ADDREF(*aColumnHeader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRows(PRInt32 *aRows)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 columns;
|
||||
return tableLayout->GetTableSize(*aRows, columns);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRowHeader(nsIAccessibleTable **aRowHeader)
|
||||
{
|
||||
// Can not implement because there is no row header in html table
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetSelectedColumns(PRUint32 *aNumColumns,
|
||||
PRInt32 **aColumns)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columnCount;
|
||||
rv = GetColumns(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool *states = new PRBool[columnCount];
|
||||
NS_ENSURE_TRUE(states, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aNumColumns = 0;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < columnCount; index++) {
|
||||
rv = IsColumnSelected(index, &states[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (states[index]) {
|
||||
(*aNumColumns)++;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 *outArray = (PRInt32 *)nsMemory::Alloc((*aNumColumns) * sizeof(PRInt32));
|
||||
if (!outArray) {
|
||||
delete []states;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRInt32 curr = 0;
|
||||
for (index = 0; index < columnCount; index++) {
|
||||
if (states[index]) {
|
||||
outArray[curr++] = index;
|
||||
}
|
||||
}
|
||||
|
||||
delete []states;
|
||||
*aColumns = outArray;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetSelectedRows(PRUint32 *aNumRows, PRInt32 **aRows)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 rowCount;
|
||||
rv = GetRows(&rowCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool *states = new PRBool[rowCount];
|
||||
NS_ENSURE_TRUE(states, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aNumRows = 0;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < rowCount; index++) {
|
||||
rv = IsRowSelected(index, &states[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (states[index]) {
|
||||
(*aNumRows)++;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 *outArray = (PRInt32 *)nsMemory::Alloc((*aNumRows) * sizeof(PRInt32));
|
||||
if (!outArray) {
|
||||
delete []states;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRInt32 curr = 0;
|
||||
for (index = 0; index < rowCount; index++) {
|
||||
if (states[index]) {
|
||||
outArray[curr++] = index;
|
||||
}
|
||||
}
|
||||
|
||||
delete []states;
|
||||
*aRows = outArray;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
nsIAccessible **aTableCellAccessible)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> cellElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(cellElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
return accService->GetAccessibleInWeakShell(cellElement, mWeakShell,
|
||||
aTableCellAccessible);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetIndexAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aRow * columns + aColumn;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aIndex % columns;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRowAtIndex(PRInt32 aIndex, PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aIndex / columns;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(domElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCellElement> cell(do_QueryInterface(domElement));
|
||||
NS_ENSURE_TRUE(cell, NS_ERROR_FAILURE);
|
||||
|
||||
return cell->GetColSpan(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRowExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(domElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCellElement> cell(do_QueryInterface(domElement));
|
||||
NS_ENSURE_TRUE(cell, NS_ERROR_FAILURE);
|
||||
|
||||
return cell->GetRowSpan(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetColumnDescription(PRInt32 aColumn, nsAString &_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::GetRowDescription(PRInt32 aRow, nsAString &_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::IsColumnSelected(PRInt32 aColumn, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 rows;
|
||||
rv = GetRows(&rows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 index = 0; index < rows; index++) {
|
||||
rv = IsCellSelected(index, aColumn, _retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!*_retval) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::IsRowSelected(PRInt32 aRow, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 index = 0; index < columns; index++) {
|
||||
rv = IsCellSelected(aRow, index, _retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!*_retval) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessibleWrap::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
PRInt32 startRowIndex = 0, startColIndex = 0,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
|
||||
return tableLayout->GetCellDataAt(aRow, aColumn,
|
||||
*getter_AddRefs(domElement),
|
||||
startRowIndex, startColIndex, rowSpan,
|
||||
colSpan, actualRowSpan, actualColSpan,
|
||||
*_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessibleWrap::GetTableNode(nsIDOMNode **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
if (table) {
|
||||
*_retval = table;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section(do_QueryInterface(mDOMNode));
|
||||
if (section) {
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = section->GetParentNode(getter_AddRefs(parent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = parent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessibleWrap::GetTableLayout(nsITableLayout **aLayoutObject)
|
||||
{
|
||||
*aLayoutObject = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tableNode;
|
||||
rv = GetTableNode(getter_AddRefs(tableNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(tableNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
nsIPresShell *presShell = content->GetDocument()->GetShellAt(0);
|
||||
|
||||
nsCOMPtr<nsISupports> layoutObject;
|
||||
rv = presShell->GetLayoutObjectFor(content, getter_AddRefs(layoutObject));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(layoutObject, aLayoutObject);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessibleWrap::GetCellAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell)
|
||||
{
|
||||
PRInt32 startRowIndex = 0, startColIndex = 0,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
PRBool isSelected;
|
||||
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return tableLayout->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
||||
startRowIndex, startColIndex,
|
||||
rowSpan, colSpan,
|
||||
actualRowSpan, actualColSpan,
|
||||
isSelected);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLTableHeadAccessible Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableHeadAccessible, nsHTMLTableAccessibleWrap)
|
||||
|
||||
nsHTMLTableHeadAccessible::nsHTMLTableHeadAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell):
|
||||
nsHTMLTableAccessibleWrap(aDomNode, aShell)
|
||||
{
|
||||
Init(); // Make sure this generated accessible of the table is cached
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetRole(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = ROLE_COLUMNHEADER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::SetCaption(nsIAccessible *aCaption)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetSummary(nsAString &aSummary)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::SetSummary(const nsAString &aSummary)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetRows(PRInt32 *aRows)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> head(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(head, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
rv = head->GetRows(getter_AddRefs(rows));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rows->GetLength((PRUint32 *)aRows);
|
||||
}
|
|
@ -1,96 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pete Zha (pete.zha@sun.com)
|
||||
* Kyle Yuan (kyle.yuan@sun.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 _nsHTMLTableAccessibleWrap_H_
|
||||
#define _nsHTMLTableAccessibleWrap_H_
|
||||
|
||||
#include "nsAccessibleHyperText.h"
|
||||
#include "nsHTMLTableAccessible.h"
|
||||
#include "nsIAccessibleTable.h"
|
||||
|
||||
class nsITableLayout;
|
||||
|
||||
class nsHTMLTableCellAccessibleWrap : public nsHTMLTableCellAccessible,
|
||||
public nsAccessibleHyperText
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTableCellAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD Shutdown();
|
||||
};
|
||||
|
||||
class nsHTMLTableAccessibleWrap : public nsHTMLTableAccessible,
|
||||
public nsIAccessibleTable
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLETABLE
|
||||
|
||||
nsHTMLTableAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
|
||||
protected:
|
||||
nsresult GetTableNode(nsIDOMNode **_retval);
|
||||
nsresult GetTableLayout(nsITableLayout **aLayoutObject);
|
||||
nsresult GetCellAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell);
|
||||
};
|
||||
|
||||
class nsHTMLTableHeadAccessible : public nsHTMLTableAccessibleWrap
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTableHeadAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell);
|
||||
|
||||
/* nsIAccessible */
|
||||
NS_IMETHOD GetRole(PRUint32 *aResult);
|
||||
|
||||
/* nsIAccessibleTable */
|
||||
NS_IMETHOD GetCaption(nsIAccessible **aCaption);
|
||||
NS_IMETHOD SetCaption(nsIAccessible *aCaption);
|
||||
NS_IMETHOD GetSummary(nsAString &aSummary);
|
||||
NS_IMETHOD SetSummary(const nsAString &aSummary);
|
||||
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
|
||||
NS_IMETHOD GetRows(PRInt32 *aRows);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -244,16 +244,17 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
|
|||
getter_AddRefs(accText));
|
||||
NS_ENSURE_TRUE(accText, nsnull);
|
||||
|
||||
nsCOMPtr<nsISupports> attrSet;
|
||||
nsCOMPtr<nsIAccessible> accessibleWithAttrs;
|
||||
PRInt32 startOffset = 0, endOffset = 0;
|
||||
nsresult rv = accText->GetAttributeRange(aOffset,
|
||||
&startOffset, &endOffset,
|
||||
getter_AddRefs(attrSet));
|
||||
getter_AddRefs(accessibleWithAttrs));
|
||||
*aStartOffset = startOffset;
|
||||
*aEndOffset = endOffset;
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
/* what to do with the nsISupports ? ??? */
|
||||
// XXX Turn accessibleWithAttrs into AtkAttributeSet by getting CSS for it
|
||||
// Look at nsAccessNodeWrap::get_computedStyle() for MSAA implementation
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define _nsTextAccessibleWrap_H_
|
||||
|
||||
#include "nsTextAccessible.h"
|
||||
#include "nsAccessibleText.h"
|
||||
|
||||
typedef class nsTextAccessible nsTextAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -70,9 +70,12 @@ ACCESSIBILITY_ATOM(headerContentLanguage, "content-language")
|
|||
|
||||
// Alphabetical list of frame types
|
||||
ACCESSIBILITY_ATOM(blockFrame, "BlockFrame")
|
||||
ACCESSIBILITY_ATOM(inlineBlockFrame, "InlineBlockFrame")
|
||||
ACCESSIBILITY_ATOM(inlineFrame, "InlineFrame")
|
||||
ACCESSIBILITY_ATOM(objectFrame, "ObjectFrame")
|
||||
ACCESSIBILITY_ATOM(textFrame, "TextFrame")
|
||||
ACCESSIBILITY_ATOM(tableCellFrame, "TableCellFrame")
|
||||
ACCESSIBILITY_ATOM(areaFrame, "AreaFrame")
|
||||
|
||||
// Alphabetical list of tag names
|
||||
ACCESSIBILITY_ATOM(a, "a")
|
||||
|
@ -85,6 +88,7 @@ ACCESSIBILITY_ATOM(body, "body")
|
|||
ACCESSIBILITY_ATOM(caption, "caption")
|
||||
ACCESSIBILITY_ATOM(description, "description") // XUL
|
||||
ACCESSIBILITY_ATOM(dd, "dd")
|
||||
ACCESSIBILITY_ATOM(div, "div")
|
||||
ACCESSIBILITY_ATOM(dl, "dl")
|
||||
ACCESSIBILITY_ATOM(dt, "dt")
|
||||
ACCESSIBILITY_ATOM(form, "form")
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsHTMLSelectAccessible.h"
|
||||
#include "nsHTMLTableAccessible.h"
|
||||
#include "nsHTMLTextAccessible.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIAccessibleProvider.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
@ -98,11 +99,8 @@
|
|||
#endif
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
#include "nsHTMLBlockAccessible.h"
|
||||
#include "nsHTMLLinkAccessibleWrap.h"
|
||||
#include "nsHTMLFormControlAccessibleWrap.h"
|
||||
#include "nsHTMLTableAccessibleWrap.h"
|
||||
#include "nsXULFormControlAccessibleWrap.h"
|
||||
#endif
|
||||
|
||||
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
|
||||
|
@ -410,29 +408,6 @@ nsAccessibilityService::CreateHTMLAreaAccessible(nsIWeakReference *aShell, nsIDO
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLBlockAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
#else
|
||||
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 nsHTMLBlockAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
|
@ -496,10 +471,6 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsISupports *aFrame,
|
|||
else if (tag == nsAccessibilityAtoms::optgroup) {
|
||||
*aAccessible = new nsHTMLSelectOptGroupAccessible(aNode, aWeakShell);
|
||||
}
|
||||
else if (tag == nsAccessibilityAtoms::caption) {
|
||||
*aAccessible = new nsEnumRoleAccessible(aNode, aWeakShell, nsIAccessible::ROLE_CAPTION);
|
||||
}
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
else if (tag == nsAccessibilityAtoms::ul || tag == nsAccessibilityAtoms::ol) {
|
||||
*aAccessible = new nsHTMLListAccessible(aNode, aWeakShell);
|
||||
}
|
||||
|
@ -517,6 +488,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsISupports *aFrame,
|
|||
else if (tag == nsAccessibilityAtoms::abbr ||
|
||||
tag == nsAccessibilityAtoms::acronym ||
|
||||
tag == nsAccessibilityAtoms::blockquote ||
|
||||
tag == nsAccessibilityAtoms::caption ||
|
||||
tag == nsAccessibilityAtoms::dd ||
|
||||
tag == nsAccessibilityAtoms::dl ||
|
||||
tag == nsAccessibilityAtoms::dt ||
|
||||
|
@ -531,14 +503,11 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsISupports *aFrame,
|
|||
tag == nsAccessibilityAtoms::tbody ||
|
||||
tag == nsAccessibilityAtoms::tfoot ||
|
||||
tag == nsAccessibilityAtoms::thead ||
|
||||
#else
|
||||
else if (
|
||||
#endif
|
||||
content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::tabindex) ||
|
||||
// The role from a <body> or doc element is already exposed in nsDocAccessible
|
||||
(tag != nsAccessibilityAtoms::body && content->GetParent() &&
|
||||
!aRole.IsEmpty())) {
|
||||
*aAccessible = new nsAccessibleWrap(aNode, aWeakShell);
|
||||
*aAccessible = new nsHyperTextAccessible(aNode, aWeakShell);
|
||||
}
|
||||
NS_IF_ADDREF(*aAccessible);
|
||||
return NS_OK;
|
||||
|
@ -567,6 +536,24 @@ nsAccessibilityService::CreateHTMLLIAccessible(nsISupports *aFrame,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHyperTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
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 nsHyperTextAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
|
@ -821,28 +808,6 @@ nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccess
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLTableCaptionAccessible(nsIDOMNode *aDOMNode, nsIAccessible **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDOMNode);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
rv = GetShellFromNode(aDOMNode, getter_AddRefs(weakShell));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsHTMLTableCaptionAccessible* accTableCaption =
|
||||
new nsHTMLTableCaptionAccessible(aDOMNode, weakShell);
|
||||
|
||||
NS_ENSURE_TRUE(accTableCaption, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*_retval = NS_STATIC_CAST(nsIAccessible *, accTableCaption);
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLTableHeadAccessible(nsIDOMNode *aDOMNode, nsIAccessible **_retval)
|
||||
{
|
||||
|
@ -891,6 +856,8 @@ nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAc
|
|||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
|
@ -898,31 +865,8 @@ nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessi
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = nsnull;
|
||||
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
// XXX Don't create ATK objects for these
|
||||
*_retval = new nsHTMLTextAccessible(node, weakShell, frame);
|
||||
#else
|
||||
// In ATK, we are only creating the accessible object for the text frame that is the FIRST
|
||||
// text frame in its block.
|
||||
// A depth-first traversal from its nearest parent block frame will produce a frame sequence like
|
||||
// TTTBTTBTT... (B for block frame, T for text frame), so every T frame which is the immediate
|
||||
// sibling of B frame will be the FIRST text frame.
|
||||
nsIFrame* parentFrame = nsAccessible::GetParentBlockFrame(frame);
|
||||
if (! parentFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(weakShell));
|
||||
nsIFrame* childFrame = parentFrame->GetFirstChild(nsnull);
|
||||
PRInt32 index = 0;
|
||||
nsIFrame* firstTextFrame = nsnull;
|
||||
PRBool ret = nsAccessible::FindTextFrame(index, presShell->GetPresContext(),
|
||||
childFrame, &firstTextFrame, frame);
|
||||
if (!ret || index != 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = new nsHTMLBlockAccessible(node, weakShell);
|
||||
#endif //MOZ_ACCESSIBILITY_ATK
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -940,7 +884,7 @@ nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAc
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTextFieldAccessibleWrap(node, weakShell);
|
||||
*_retval = new nsHTMLTextFieldAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -955,7 +899,7 @@ nsAccessibilityService::CreateXULTextBoxAccessible(nsIDOMNode *aNode, nsIAccessi
|
|||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
*_retval = new nsXULTextFieldAccessibleWrap(aNode, weakShell);
|
||||
*_retval = new nsXULTextFieldAccessible(aNode, weakShell);
|
||||
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -155,6 +155,18 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
}
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) {
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIAccessibleHyperText> hyperTextParent(do_QueryInterface(parent));
|
||||
if (hyperTextParent) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIAccessibleHyperLink*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return nsAccessNode::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
@ -564,6 +576,18 @@ NS_IMETHODIMP nsAccessible::GetChildAt(PRInt32 aChildNum, nsIAccessible **aChild
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAccessible *nsAccessible::NextChild(nsCOMPtr<nsIAccessible>& aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> nextChild;
|
||||
if (!aAccessible) {
|
||||
GetFirstChild(getter_AddRefs(nextChild));
|
||||
}
|
||||
else {
|
||||
aAccessible->GetNextSibling(getter_AddRefs(nextChild));
|
||||
}
|
||||
return (aAccessible = nextChild);
|
||||
}
|
||||
|
||||
void nsAccessible::CacheChildren(PRBool aWalkAnonContent)
|
||||
{
|
||||
if (!mWeakShell) {
|
||||
|
@ -767,18 +791,10 @@ NS_IMETHODIMP nsAccessible::GetState(PRUint32 *aState)
|
|||
*aState |= STATE_UNAVAILABLE;
|
||||
}
|
||||
else if (content->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
if (!content->HasAttr(kNameSpaceID_XHTML2_Unofficial,
|
||||
nsAccessibilityAtoms::role)) {
|
||||
// Default state for element accessible is focusable unless role is manually set
|
||||
// Subclasses of nsAccessible will clear focusable state if necessary
|
||||
nsIFrame *frame = GetFrame();
|
||||
if (frame && frame->IsFocusable()) {
|
||||
*aState |= STATE_FOCUSABLE;
|
||||
}
|
||||
else {
|
||||
nsIFrame *frame = GetFrame();
|
||||
if (frame && frame->IsFocusable()) {
|
||||
*aState |= STATE_FOCUSABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gLastFocusedNode == mDOMNode) {
|
||||
*aState |= STATE_FOCUSED;
|
||||
|
@ -826,8 +842,6 @@ NS_IMETHODIMP nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
|
|||
NS_IMETHODIMP nsAccessible::GetChildAtPoint(PRInt32 tx, PRInt32 ty, nsIAccessible **aAccessible)
|
||||
{
|
||||
*aAccessible = nsnull;
|
||||
PRInt32 numChildren; // Make sure all children cached first
|
||||
GetChildCount(&numChildren);
|
||||
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
|
@ -835,13 +849,38 @@ NS_IMETHODIMP nsAccessible::GetChildAtPoint(PRInt32 tx, PRInt32 ty, nsIAccessibl
|
|||
PRInt32 x, y, w, h;
|
||||
PRUint32 state;
|
||||
|
||||
nsCOMPtr<nsIAccessible> childAtPoint;
|
||||
while (child) {
|
||||
child->GetBounds(&x, &y, &w, &h);
|
||||
if (tx >= x && tx < x + w && ty >= y && ty < y + h) {
|
||||
child->GetFinalState(&state);
|
||||
if ((state & (STATE_OFFSCREEN|STATE_INVISIBLE)) == 0) { // Don't walk into offscreen items
|
||||
NS_ADDREF(*aAccessible = child);
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(child));
|
||||
if (accessNode) {
|
||||
nsIFrame *frame = accessNode->GetFrame();
|
||||
if (!frame) {
|
||||
child->GetFinalState(&state);
|
||||
// Some case accessibles don't have a frame; examples are
|
||||
// tree items or combo box dropdown markers. For these cases
|
||||
// just ensure that the returned accessible is visible.
|
||||
if ((state & (STATE_OFFSCREEN|STATE_INVISIBLE)) == 0) {
|
||||
// Don't walk into offscreen or invisible items
|
||||
NS_IF_ADDREF(*aAccessible = child);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If there are multiple accessibles the contain the point
|
||||
// and they overlap then pick the one with a frame that contains the point
|
||||
// For example, A point that's in block #2 is also in block #1, but we want to return #2:
|
||||
// [[block #1 is long wrapped text that continues to
|
||||
// another line]] [[here is a shorter block #2]]
|
||||
while (frame) {
|
||||
if (frame->GetScreenRectExternal().Contains(tx, ty)) {
|
||||
childAtPoint = child;
|
||||
break; // Definitely in this accessible, since one of its frame matches the point
|
||||
}
|
||||
frame = frame->GetNextContinuation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> next;
|
||||
|
@ -849,6 +888,10 @@ NS_IMETHODIMP nsAccessible::GetChildAtPoint(PRInt32 tx, PRInt32 ty, nsIAccessibl
|
|||
child = next;
|
||||
}
|
||||
|
||||
if (childAtPoint) {
|
||||
NS_ADDREF(*aAccessible = childAtPoint);
|
||||
return NS_OK;
|
||||
}
|
||||
GetState(&state);
|
||||
GetBounds(&x, &y, &w, &h);
|
||||
if ((state & (STATE_OFFSCREEN|STATE_INVISIBLE)) == 0 &&
|
||||
|
@ -1618,11 +1661,11 @@ nsRoleMapEntry nsAccessible::gWAIRoleMap[] =
|
|||
{"combobox", ROLE_COMBOBOX, eNameLabelOrTitle, eNoValue, eNoReqStates,
|
||||
{"readonly", BOOL_STATE, STATE_READONLY},
|
||||
{"multiselect", BOOL_STATE, STATE_MULTISELECTABLE | STATE_EXTSELECTABLE}, END_ENTRY},
|
||||
{"description", ROLE_STATICTEXT, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"description", ROLE_TEXT_CONTAINER, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"dialog", ROLE_DIALOG, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"document", ROLE_DOCUMENT, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"icon", ROLE_ICON, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"label", ROLE_STATICTEXT, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"label", ROLE_LABEL, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"list", ROLE_LIST, eNameLabelOrTitle, eNoValue, eNoReqStates,
|
||||
{"readonly", BOOL_STATE, STATE_READONLY},
|
||||
{"multiselect", BOOL_STATE, STATE_MULTISELECTABLE | STATE_EXTSELECTABLE}, END_ENTRY},
|
||||
|
@ -2168,6 +2211,12 @@ NS_IMETHODIMP nsAccessible::GetExtState(PRUint32 *aExtState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetIsEditable(PRBool *aIsEditable)
|
||||
{
|
||||
*aIsEditable = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
|
||||
NS_IMETHODIMP nsAccessible::GetNativeInterface(void **aOutAccessible)
|
||||
{
|
||||
|
@ -2405,111 +2454,100 @@ NS_IMETHODIMP nsAccessible::SelectAllSelection(PRBool *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
// static helper functions
|
||||
nsresult nsAccessible::GetParentBlockNode(nsIPresShell *aPresShell, nsIDOMNode *aCurrentNode, nsIDOMNode **aBlockNode)
|
||||
// nsIAccessibleHyperLink
|
||||
// Because of new-atk design, any embedded object in text can implement
|
||||
// nsIAccessibleHyperLink, which helps determine where it is located
|
||||
// within containing text
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetAnchors(PRInt32 *aAnchors)
|
||||
{
|
||||
*aBlockNode = nsnull;
|
||||
*aAnchors = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentNode));
|
||||
if (! content)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_IMETHODIMP nsAccessible::GetStartIndex(PRInt32 *aStartIndex)
|
||||
{
|
||||
*aStartIndex = 0;
|
||||
PRInt32 endIndex;
|
||||
return GetLinkOffset(aStartIndex, &endIndex);
|
||||
}
|
||||
|
||||
nsIFrame *frame = aPresShell->GetPrimaryFrameFor(content);
|
||||
if (! frame)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_IMETHODIMP nsAccessible::GetEndIndex(PRInt32 *aEndIndex)
|
||||
{
|
||||
*aEndIndex = 0;
|
||||
PRInt32 startIndex;
|
||||
return GetLinkOffset(&startIndex, aEndIndex);
|
||||
}
|
||||
|
||||
nsIFrame *parentFrame = GetParentBlockFrame(frame);
|
||||
if (! parentFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPresContext *presContext = aPresShell->GetPresContext();
|
||||
nsIAtom* frameType = nsnull;
|
||||
while (frame && (frameType = frame->GetType()) != nsAccessibilityAtoms::textFrame) {
|
||||
frame = frame->GetFirstChild(nsnull);
|
||||
}
|
||||
if (! frame || frameType != nsAccessibilityAtoms::textFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 index = 0;
|
||||
nsIFrame *firstTextFrame = nsnull;
|
||||
FindTextFrame(index, presContext, parentFrame->GetFirstChild(nsnull),
|
||||
&firstTextFrame, frame);
|
||||
if (firstTextFrame) {
|
||||
nsIContent *content = firstTextFrame->GetContent();
|
||||
|
||||
if (content) {
|
||||
CallQueryInterface(content, aBlockNode);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
//XXX, why?
|
||||
}
|
||||
NS_IMETHODIMP nsAccessible::GetURI(PRInt32 i, nsIURI **aURI)
|
||||
{
|
||||
*aURI = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIFrame* nsAccessible::GetParentBlockFrame(nsIFrame *aFrame)
|
||||
NS_IMETHODIMP nsAccessible::GetObject(PRInt32 aIndex,
|
||||
nsIAccessible **aAccessible)
|
||||
{
|
||||
if (! aFrame)
|
||||
return nsnull;
|
||||
|
||||
nsIFrame* frame = aFrame;
|
||||
while (frame && frame->GetType() != nsAccessibilityAtoms::blockFrame) {
|
||||
nsIFrame* parentFrame = frame->GetParent();
|
||||
frame = parentFrame;
|
||||
if (aIndex != 0) {
|
||||
*aAccessible = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return frame;
|
||||
*aAccessible = this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsAccessible::FindTextFrame(PRInt32 &index, nsPresContext *aPresContext, nsIFrame *aCurFrame,
|
||||
nsIFrame **aFirstTextFrame, const nsIFrame *aTextFrame)
|
||||
// Do a depth-first traversal to find the given text frame(aTextFrame)'s index of the block frame(aCurFrame)
|
||||
// it belongs to, also return the first text frame within the same block.
|
||||
// Parameters:
|
||||
// index [in/out] - the current index - finally, it will be the aTextFrame's index in its block;
|
||||
// aCurFrame [in] - the current frame - its initial value is the first child frame of the block frame;
|
||||
// aFirstTextFrame [out] - the first text frame which is within the same block with aTextFrame;
|
||||
// aTextFrame [in] - the text frame we are looking for;
|
||||
// Return:
|
||||
// PR_TRUE - the aTextFrame was found in its block frame;
|
||||
// PR_FALSE - the aTextFrame was NOT found in its block frame;
|
||||
// nsIAccessibleHyperLink::IsValid()
|
||||
NS_IMETHODIMP nsAccessible::IsValid(PRBool *aIsValid)
|
||||
{
|
||||
while (aCurFrame) {
|
||||
PRUint32 state;
|
||||
GetFinalState(&state);
|
||||
*aIsValid = (state & STATE_INVALID) != 0;
|
||||
// XXX In order to implement this we would need to follow every link
|
||||
// Perhaps we can get information about invalid links from the cache
|
||||
// In the mean time authors can use role="wairole:link" aaa:invalid="true"
|
||||
// to force it for links they internally know to be invalid
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aCurFrame == aTextFrame) {
|
||||
if (index == 0)
|
||||
*aFirstTextFrame = aCurFrame;
|
||||
// we got it, stop traversing
|
||||
return PR_TRUE;
|
||||
NS_IMETHODIMP nsAccessible::IsSelected(PRBool *aIsSelected)
|
||||
{
|
||||
*aIsSelected = (gLastFocusedNode == mDOMNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
|
||||
{
|
||||
*aStartOffset = *aEndOffset = 0;
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
if (!parent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
PRInt32 characterCount = 0;
|
||||
|
||||
while (NextChild(accessible)) {
|
||||
if (Role(accessible) == ROLE_TEXT_LEAF) {
|
||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(accessible));
|
||||
nsIFrame *frame = accessNode->GetFrame();
|
||||
if (frame) {
|
||||
nsITextContent *textContent = NS_STATIC_CAST(nsITextContent*, frame->GetContent());
|
||||
NS_ASSERTION(textContent, "No text content for a ROLE_TEXT?");
|
||||
characterCount += textContent->TextLength();
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* frameType = aCurFrame->GetType();
|
||||
if (frameType == nsAccessibilityAtoms::blockFrame) {
|
||||
// every block frame will reset the index
|
||||
index = 0;
|
||||
else if (accessible == this) {
|
||||
*aStartOffset = characterCount;
|
||||
*aEndOffset = characterCount + 1;
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
if (frameType == nsAccessibilityAtoms::textFrame) {
|
||||
nsRect frameRect = aCurFrame->GetRect();
|
||||
// skip the empty frame
|
||||
if (! frameRect.IsEmpty()) {
|
||||
if (index == 0)
|
||||
*aFirstTextFrame = aCurFrame;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// we won't expand the tree under a block frame.
|
||||
if (FindTextFrame(index, aPresContext, aCurFrame->GetFirstChild(nsnull),
|
||||
aFirstTextFrame, aTextFrame))
|
||||
return PR_TRUE;
|
||||
++ characterCount;
|
||||
}
|
||||
|
||||
nsIFrame* siblingFrame = aCurFrame->GetNextSibling();
|
||||
aCurFrame = siblingFrame;
|
||||
}
|
||||
return PR_FALSE;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif //MOZ_ACCESSIBILITY_ATK
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsPIAccessible.h"
|
||||
#include "nsIAccessibleHyperLink.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsIAccessibleValue.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
@ -115,6 +116,7 @@ struct nsRoleMapEntry
|
|||
class nsAccessible : public nsAccessNodeWrap,
|
||||
public nsIAccessible,
|
||||
public nsPIAccessible,
|
||||
public nsIAccessibleHyperLink,
|
||||
public nsIAccessibleSelectable,
|
||||
public nsIAccessibleValue
|
||||
{
|
||||
|
@ -130,6 +132,7 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLE
|
||||
NS_DECL_NSPIACCESSIBLE
|
||||
NS_DECL_NSIACCESSIBLEHYPERLINK
|
||||
NS_DECL_NSIACCESSIBLESELECTABLE
|
||||
NS_DECL_NSIACCESSIBLEVALUE
|
||||
|
||||
|
@ -140,8 +143,6 @@ public:
|
|||
NS_IMETHOD GetState(PRUint32 *aState); // Must support GetFinalState()
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
static nsresult GetParentBlockNode(nsIPresShell *aPresShell, nsIDOMNode *aCurrentNode, nsIDOMNode **aBlockNode);
|
||||
static nsIFrame* GetParentBlockFrame(nsIFrame *aFrame);
|
||||
static PRBool FindTextFrame(PRInt32 &index, nsPresContext *aPresContext, nsIFrame *aCurFrame,
|
||||
nsIFrame **aFirstTextFrame, const nsIFrame *aTextFrame);
|
||||
#endif
|
||||
|
@ -180,12 +181,19 @@ protected:
|
|||
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
|
||||
static nsresult GetTranslatedString(const nsAString& aKey, nsAString& aStringOut);
|
||||
nsresult AppendFlatStringFromSubtreeRecurse(nsIContent *aContent, nsAString *aFlatString);
|
||||
|
||||
// Helpers for dealing with children
|
||||
virtual void CacheChildren(PRBool aWalkAnonContent);
|
||||
nsIAccessible *NextChild(nsCOMPtr<nsIAccessible>& aAccessible);
|
||||
already_AddRefed<nsIAccessible> GetNextWithState(nsIAccessible *aStart, PRUint32 matchState);
|
||||
|
||||
// Selection helpers
|
||||
already_AddRefed<nsIAccessible> GetNextWithState(nsIAccessible *aStart, PRUint32 matchState);
|
||||
static already_AddRefed<nsIAccessible> GetMultiSelectFor(nsIDOMNode *aNode);
|
||||
|
||||
// Hyperlink helpers
|
||||
virtual nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);
|
||||
static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role; aAcc->GetRole(&role); return role; }
|
||||
|
||||
// For accessibles that have actions
|
||||
static void DoCommandCallback(nsITimer *aTimer, void *aClosure);
|
||||
nsresult DoCommand(nsIContent *aContent = nsnull);
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
@ -50,77 +51,6 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
// ------------
|
||||
// nsBlockAccessible
|
||||
// ------------
|
||||
|
||||
nsBlockAccessible::nsBlockAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):nsAccessibleWrap(aNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsBlockAccessible, nsAccessible)
|
||||
|
||||
/* nsIAccessible accGetAt (in long x, in long y); */
|
||||
NS_IMETHODIMP nsBlockAccessible::GetChildAtPoint(PRInt32 tx, PRInt32 ty,
|
||||
nsIAccessible **aChildAtPoint)
|
||||
{
|
||||
*aChildAtPoint = nsnull;
|
||||
nsCOMPtr<nsIAccessible> childAtPoint;
|
||||
|
||||
// We're going to find the child that contains coordinates (tx,ty)
|
||||
PRInt32 x,y,w,h;
|
||||
GetBounds(&x,&y,&w,&h); // Get bounds for this accessible
|
||||
if (tx >= x && tx < x + w && ty >= y && ty < y + h)
|
||||
{
|
||||
// It's within this nsIAccessible, let's drill down
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
nsCOMPtr<nsIAccessible> next;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
PRInt32 cx,cy,cw,ch; // Child bounds
|
||||
|
||||
while(child) {
|
||||
child->GetBounds(&cx,&cy,&cw,&ch);
|
||||
|
||||
// if there are multiple accessibles the contain the point
|
||||
// and they overlap then pick the one with a frame that contans the point
|
||||
|
||||
// For example, A point that's in block #2 is also in block #1, but we want to return #2:
|
||||
// [[block #1 is long wrapped text that continues to
|
||||
// another line]] [[here is a shorter block #2]]
|
||||
|
||||
if (tx >= cx && tx < cx + cw && ty >= cy && ty < cy + ch)
|
||||
{
|
||||
// See whether one of the frames for this accessible
|
||||
// contains this screen point
|
||||
if (!childAtPoint) {
|
||||
// Default in case accessible doesn't have a frame such as
|
||||
// tree items or combo box dropdown markers
|
||||
childAtPoint = child;
|
||||
}
|
||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(child));
|
||||
if (accessNode) {
|
||||
nsIFrame *frame = accessNode->GetFrame();
|
||||
while (frame) {
|
||||
if (frame->GetScreenRectExternal().Contains(tx, ty)) {
|
||||
childAtPoint = child;
|
||||
break; // Definitely in this accessible, since one of its frame matches the point
|
||||
}
|
||||
frame = frame->GetNextContinuation();
|
||||
}
|
||||
}
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(next));
|
||||
child = next;
|
||||
}
|
||||
|
||||
*aChildAtPoint = childAtPoint ? childAtPoint : this;
|
||||
NS_ADDREF(*aChildAtPoint);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------
|
||||
// nsLeafAccessible
|
||||
//-------------
|
||||
|
@ -159,14 +89,14 @@ NS_IMETHODIMP nsLeafAccessible::GetChildCount(PRInt32 *_retval)
|
|||
//----------------
|
||||
|
||||
nsLinkableAccessible::nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
|
||||
nsAccessibleWrap(aNode, aShell),
|
||||
nsHyperTextAccessible(aNode, aShell),
|
||||
mActionContent(nsnull),
|
||||
mIsLink(PR_FALSE),
|
||||
mIsOnclick(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsLinkableAccessible, nsAccessible)
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsLinkableAccessible, nsHyperTextAccessible)
|
||||
|
||||
NS_IMETHODIMP nsLinkableAccessible::TakeFocus()
|
||||
{
|
||||
|
@ -180,7 +110,7 @@ NS_IMETHODIMP nsLinkableAccessible::TakeFocus()
|
|||
/* long GetState (); */
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetState(PRUint32 *aState)
|
||||
{
|
||||
nsAccessible::GetState(aState);
|
||||
nsHyperTextAccessible::GetState(aState);
|
||||
if (mIsLink) {
|
||||
*aState |= STATE_LINKED;
|
||||
nsCOMPtr<nsILink> link = do_QueryInterface(mActionContent);
|
||||
|
@ -208,7 +138,10 @@ NS_IMETHODIMP nsLinkableAccessible::GetState(PRUint32 *aState)
|
|||
*aState &= ~STATE_FOCUSABLE; // Links must have href or tabindex
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
|
||||
// XXX What if we're in a contenteditable container?
|
||||
// We may need to go up the parent chain unless a better API is found
|
||||
nsCOMPtr<nsIAccessible> docAccessible =
|
||||
do_QueryInterface(nsCOMPtr<nsIAccessibleDocument>(GetDocAccessible()));
|
||||
if (docAccessible) {
|
||||
PRBool isEditable;
|
||||
docAccessible->GetIsEditable(&isEditable);
|
||||
|
@ -314,16 +247,33 @@ void nsLinkableAccessible::CacheActionContent()
|
|||
}
|
||||
}
|
||||
|
||||
// nsIAccessibleHyperLink::GetURI()
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
{
|
||||
// XXX Also implement this for nsHTMLImageAccessible file names
|
||||
*aURI = nsnull;
|
||||
if (aIndex != 0 || !mIsLink || !SameCOMIdentity(mDOMNode, mActionContent)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(mActionContent));
|
||||
if (link) {
|
||||
return link->GetHrefURI(aURI);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLinkableAccessible::Init()
|
||||
{
|
||||
CacheActionContent();
|
||||
return nsAccessibleWrap::Init();
|
||||
return nsHyperTextAccessible::Init();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLinkableAccessible::Shutdown()
|
||||
{
|
||||
mActionContent = nsnull;
|
||||
return nsAccessibleWrap::Shutdown();
|
||||
return nsHyperTextAccessible::Shutdown();
|
||||
}
|
||||
|
||||
//---------------------
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define _nsBaseWidgetAccessible_H_
|
||||
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIDOMNode;
|
||||
|
@ -49,18 +50,6 @@ class nsIDOMNode;
|
|||
* classes for the different accessibility implementations of
|
||||
* the HTML and XUL widget sets. --jgaunt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Special Accessible that knows how to handle hit detection for flowing text
|
||||
*/
|
||||
class nsBlockAccessible : public nsAccessibleWrap
|
||||
{
|
||||
public:
|
||||
nsBlockAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_IMETHOD GetChildAtPoint(PRInt32 x, PRInt32 y, nsIAccessible **_retval);
|
||||
};
|
||||
|
||||
/**
|
||||
* Leaf version of DOM Accessible -- has no children
|
||||
*/
|
||||
|
@ -79,7 +68,7 @@ public:
|
|||
* It knows how to report the state of the link ( traveled or not )
|
||||
* and can activate ( click ) the link programmatically.
|
||||
*/
|
||||
class nsLinkableAccessible : public nsAccessibleWrap
|
||||
class nsLinkableAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
public:
|
||||
nsLinkableAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
@ -91,6 +80,7 @@ public:
|
|||
NS_IMETHOD GetValue(nsAString& _retval);
|
||||
NS_IMETHOD TakeFocus();
|
||||
NS_IMETHOD GetKeyboardShortcut(nsAString& _retval);
|
||||
NS_IMETHOD GetURI(PRInt32 i, nsIURI **aURI);
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Shutdown();
|
||||
|
||||
|
|
|
@ -46,17 +46,12 @@
|
|||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsTextAccessible.h"
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
#include "nsAccessibleText.h"
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsCaretAccessible, nsLeafAccessible, nsIAccessibleCaret, nsISelectionListener)
|
||||
|
||||
|
@ -129,11 +124,6 @@ NS_IMETHODIMP nsCaretAccessible::AttachNewSelectionListener(nsIDOMNode *aCurrent
|
|||
|
||||
NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, PRInt16 aReason)
|
||||
{
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
if (nsAccessibleText::gSuppressedNotifySelectionChanged)
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShellFor(mCurrentDOMNode);
|
||||
nsCOMPtr<nsISelection> domSel(do_QueryReferent(mDomSelectionWeak));
|
||||
if (!presShell || domSel != aSel)
|
||||
|
@ -183,15 +173,19 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns
|
|||
if (visible) {
|
||||
mRootAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_LOCATION_CHANGE, this, nsnull);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// XXX Needs to be rewritten to deal with NEW atk
|
||||
// May want to grab some of the code Ginn Chen put in bug 312093 for it
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
accService->GetAccessibleInShell(mCurrentDOMNode, presShell, getter_AddRefs(accessible));
|
||||
nsCOMPtr<nsIAccessibleDocument> docAcc(do_QueryInterface(accessible));
|
||||
if (docAcc) {
|
||||
PRBool isEditable;
|
||||
docAcc->GetIsEditable(&isEditable);
|
||||
if (!isEditable) { // this is not a composer window, find out the text accessible object
|
||||
if (accessible) {
|
||||
PRUint32 extState;
|
||||
accessible->GetExtState(&extState);
|
||||
if (0 == (extState & EXT_STATE_EDITABLE)) {
|
||||
// this is not a composer window, find out the text accessible object
|
||||
nsCOMPtr<nsIDOMNode> focusNode;
|
||||
domSel->GetFocusNode(getter_AddRefs(focusNode));
|
||||
if (!focusNode) {
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
@ -80,8 +79,8 @@
|
|||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
|
||||
nsBlockAccessible(aDOMNode, aShell), mWnd(nsnull),
|
||||
mEditor(nsnull), mScrollPositionChangedTicks(0), mIsContentLoaded(PR_FALSE)
|
||||
nsHyperTextAccessible(aDOMNode, aShell), mWnd(nsnull),
|
||||
mScrollPositionChangedTicks(0), mIsContentLoaded(PR_FALSE)
|
||||
{
|
||||
// Because of the way document loading happens, the new nsIWidget is created before
|
||||
// the old one is removed. Since it creates the nsDocAccessible, for a brief moment
|
||||
|
@ -130,10 +129,10 @@ NS_INTERFACE_MAP_BEGIN(nsDocAccessible)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsBlockAccessible)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsHyperTextAccessible)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDocAccessible, nsBlockAccessible)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDocAccessible, nsBlockAccessible)
|
||||
NS_IMPL_ADDREF_INHERITED(nsDocAccessible, nsHyperTextAccessible)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDocAccessible, nsHyperTextAccessible)
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::GetName(nsAString& aName)
|
||||
{
|
||||
|
@ -217,13 +216,13 @@ NS_IMETHODIMP nsDocAccessible::GetState(PRUint32 *aState)
|
|||
*aState |= STATE_INVISIBLE;
|
||||
}
|
||||
|
||||
PRBool isEditable;
|
||||
GetIsEditable(&isEditable);
|
||||
|
||||
if (!isEditable) {
|
||||
PRUint32 extState;
|
||||
GetExtState(&extState);
|
||||
if (0 == (extState & EXT_STATE_EDITABLE)) {
|
||||
// Use STATE_READONLY when we're not in an editor pane
|
||||
*aState |= STATE_READONLY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -352,6 +351,13 @@ NS_IMETHODIMP nsDocAccessible::GetDocument(nsIDOMDocument **aDOMDoc)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsDocAccessible::SetEditor(nsIEditor* aEditor)
|
||||
{
|
||||
mEditor = aEditor;
|
||||
if (mEditor)
|
||||
mEditor->AddEditActionListener(this);
|
||||
}
|
||||
|
||||
void nsDocAccessible::CheckForEditor()
|
||||
{
|
||||
if (mEditor) {
|
||||
|
@ -381,17 +387,6 @@ void nsDocAccessible::CheckForEditor()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::GetIsEditable(PRBool *aIsEditable)
|
||||
{
|
||||
*aIsEditable = PR_FALSE;
|
||||
if (mEditor) {
|
||||
PRUint32 flags;
|
||||
mEditor->GetFlags(&flags);
|
||||
*aIsEditable = (flags & nsIPlaintextEditor::eEditorReadonlyMask) == 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNode **aAccessNode)
|
||||
{
|
||||
GetCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode); // Addrefs for us
|
||||
|
@ -435,7 +430,7 @@ NS_IMETHODIMP nsDocAccessible::Init()
|
|||
|
||||
AddEventListeners();
|
||||
|
||||
nsresult rv = nsBlockAccessible::Init();
|
||||
nsresult rv = nsHyperTextAccessible::Init();
|
||||
|
||||
if (mRoleMapEntry && mRoleMapEntry->role != ROLE_DIALOG &&
|
||||
mRoleMapEntry->role != ROLE_APPLICATION &&
|
||||
|
@ -462,12 +457,15 @@ NS_IMETHODIMP nsDocAccessible::Shutdown()
|
|||
return NS_OK; // Already shutdown
|
||||
}
|
||||
|
||||
if (mEditor) {
|
||||
mEditor->RemoveEditActionListener(this);
|
||||
mEditor = nsnull;
|
||||
}
|
||||
|
||||
RemoveEventListeners();
|
||||
|
||||
mWeakShell = nsnull; // Avoid reentrancy
|
||||
|
||||
mEditor = nsnull;
|
||||
|
||||
if (mFireEventTimer) {
|
||||
mFireEventTimer->Cancel();
|
||||
mFireEventTimer = nsnull;
|
||||
|
@ -478,7 +476,7 @@ NS_IMETHODIMP nsDocAccessible::Shutdown()
|
|||
|
||||
mDocument = nsnull;
|
||||
|
||||
return nsBlockAccessible::Shutdown();
|
||||
return nsHyperTextAccessible::Shutdown();
|
||||
}
|
||||
|
||||
nsIFrame* nsDocAccessible::GetFrame()
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#ifndef _nsDocAccessible_H_
|
||||
#define _nsDocAccessible_H_
|
||||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsPIAccessibleDocument.h"
|
||||
#include "nsIAccessibleEvent.h"
|
||||
|
@ -57,7 +57,7 @@ class nsIScrollableView;
|
|||
|
||||
const PRUint32 kDefaultCacheSize = 256;
|
||||
|
||||
class nsDocAccessible : public nsBlockAccessible,
|
||||
class nsDocAccessible : public nsHyperTextAccessible,
|
||||
public nsIAccessibleDocument,
|
||||
public nsPIAccessibleDocument,
|
||||
public nsIDocumentObserver,
|
||||
|
@ -107,6 +107,9 @@ class nsDocAccessible : public nsBlockAccessible,
|
|||
void RefreshNodes(nsIDOMNode *aStartNode, PRUint32 aChangeEvent);
|
||||
static void ScrollTimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
virtual void CheckForEditor();
|
||||
virtual void SetEditor(nsIEditor *aEditor);
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { nsIEditor *editor = mEditor; NS_IF_ADDREF(editor); return editor; }
|
||||
|
||||
nsresult FireDelayedToolkitEvent(PRUint32 aEvent, nsIDOMNode *aDOMNode,
|
||||
void *aData, PRBool aAllowDupes = PR_FALSE);
|
||||
|
||||
|
@ -115,10 +118,10 @@ class nsDocAccessible : public nsBlockAccessible,
|
|||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsITimer> mScrollWatchTimer;
|
||||
nsCOMPtr<nsITimer> mFireEventTimer;
|
||||
nsCOMPtr<nsIEditor> mEditor; // Editor, if there is one
|
||||
PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
|
||||
PRPackedBool mIsContentLoaded;
|
||||
nsCOMArray<nsIAccessibleEvent> mEventsToFire;
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -523,35 +523,6 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
|||
|
||||
nsCOMPtr<nsIPresShell> eventShell = GetPresShellFor(targetNode);
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchorElement(do_QueryInterface(targetNode));
|
||||
// For ATK, check whether this link is for an image.
|
||||
// If so, fire event for the image.
|
||||
if (anchorElement) {
|
||||
nsCOMPtr<nsIDOMNode> childNode;
|
||||
if (NS_SUCCEEDED(targetNode->GetFirstChild(getter_AddRefs(childNode)))) {
|
||||
while (childNode) {
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> imgNode(do_QueryInterface(childNode));
|
||||
if (imgNode) {
|
||||
anchorElement = nsnull; // ignore the link
|
||||
targetNode = childNode; // only fire event for image
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
tmpNode.swap(childNode);
|
||||
tmpNode->GetNextSibling(getter_AddRefs(childNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (anchorElement) {
|
||||
nsCOMPtr<nsIDOMNode> blockNode;
|
||||
// For ATK, we don't create any individual object for hyperlink, use its parent who has block frame instead
|
||||
if (NS_SUCCEEDED(nsAccessible::GetParentBlockNode(eventShell, targetNode, getter_AddRefs(blockNode))))
|
||||
targetNode = blockNode;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!eventShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -801,19 +772,6 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
|||
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS,
|
||||
treeItemAccessible, nsnull);
|
||||
}
|
||||
else if (anchorElement) {
|
||||
nsCOMPtr<nsIAccessibleHyperText> hyperText(do_QueryInterface(accessible));
|
||||
if (hyperText) {
|
||||
nsCOMPtr<nsIDOMNode> focusedNode(do_QueryInterface(anchorElement));
|
||||
NS_IF_RELEASE(gLastFocusedNode);
|
||||
gLastFocusedNode = focusedNode;
|
||||
NS_IF_ADDREF(gLastFocusedNode);
|
||||
|
||||
PRInt32 selectedLink;
|
||||
hyperText->GetSelectedLinkIndex(&selectedLink);
|
||||
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ATK_LINK_SELECTED, accessible, &selectedLink);
|
||||
}
|
||||
}
|
||||
else if (localName.EqualsIgnoreCase("radiogroup")) {
|
||||
// fire focus event for checked radio instead of radiogroup
|
||||
PRInt32 childCount = 0;
|
||||
|
|
|
@ -57,7 +57,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsTextAccessible, nsLinkableAccessible)
|
|||
*/
|
||||
NS_IMETHODIMP nsTextAccessible::GetRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_TEXT;
|
||||
*_retval = ROLE_TEXT_LEAF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ LIBXUL_LIBRARY = 1
|
|||
REQUIRES = content \
|
||||
docshell \
|
||||
dom \
|
||||
editor \
|
||||
gfx \
|
||||
imglib2 \
|
||||
intl \
|
||||
|
@ -57,6 +58,7 @@ REQUIRES = content \
|
|||
locale \
|
||||
necko \
|
||||
string \
|
||||
webshell \
|
||||
widget \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
|
@ -73,6 +75,11 @@ CPPSRCS = \
|
|||
nsHTMLSelectAccessible.cpp \
|
||||
nsHTMLTableAccessible.cpp \
|
||||
nsHTMLTextAccessible.cpp \
|
||||
nsHyperTextAccessible.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsHyperTextAccessible.h \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -1045,7 +1045,7 @@ NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetPreviousSibling(nsIAccessibl
|
|||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_STATICTEXT;
|
||||
*_retval = ROLE_ENTRY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableCellAccessible, nsBlockAccessible)
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableCellAccessible, nsHyperTextAccessible)
|
||||
|
||||
nsHTMLTableCellAccessible::nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsBlockAccessible(aDomNode, aShell)
|
||||
nsHyperTextAccessible(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,36 +62,10 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetState(PRUint32 *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsHTMLTableCaptionAccessible::nsHTMLTableCaptionAccessible
|
||||
(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsAccessibleWrap(aDomNode, aShell)
|
||||
{
|
||||
Init(); // Make sure this generated accessible of the table is cached
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableCaptionAccessible::GetState(PRUint32 *aResult)
|
||||
{
|
||||
nsAccessible::GetState(aResult);
|
||||
*aResult &= ~STATE_FOCUSABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableCaptionAccessible::GetValue(nsAString& aResult)
|
||||
{
|
||||
aResult.Truncate(); // Default name is blank
|
||||
|
||||
nsCOMPtr<nsIContent> captionContent(do_QueryInterface(mDOMNode));
|
||||
AppendFlatStringFromSubtree(captionContent, &aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableAccessible, nsBlockAccessible)
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableAccessible, nsHyperTextAccessible)
|
||||
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsBlockAccessible(aDomNode, aShell)
|
||||
nsHyperTextAccessible(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
|
||||
class nsHTMLTableCellAccessible : public nsBlockAccessible
|
||||
class nsHTMLTableCellAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
@ -51,15 +51,7 @@ public:
|
|||
NS_IMETHOD GetState(PRUint32 *aResult);
|
||||
};
|
||||
|
||||
class nsHTMLTableCaptionAccessible : public nsAccessibleWrap
|
||||
{
|
||||
public:
|
||||
nsHTMLTableCaptionAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetState(PRUint32 *aResult);
|
||||
NS_IMETHOD GetValue(nsAString& aResult);
|
||||
};
|
||||
|
||||
class nsHTMLTableAccessible : public nsBlockAccessible
|
||||
class nsHTMLTableAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
|
|
@ -101,13 +101,14 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetState(PRUint32 *aState)
|
|||
{
|
||||
nsTextAccessible::GetState(aState);
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
|
||||
nsCOMPtr<nsIAccessible> docAccessible =
|
||||
do_QueryInterface(nsCOMPtr<nsIAccessibleDocument>(GetDocAccessible()));
|
||||
if (docAccessible) {
|
||||
PRBool isEditable;
|
||||
docAccessible->GetIsEditable(&isEditable);
|
||||
if (!isEditable) {
|
||||
*aState |= STATE_READONLY;
|
||||
}
|
||||
PRUint32 extState;
|
||||
docAccessible->GetExtState(&extState);
|
||||
if (0 == (extState & EXT_STATE_EDITABLE)) {
|
||||
*aState |= STATE_READONLY; // Links not focusable in editor
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -156,7 +157,7 @@ NS_IMETHODIMP nsHTMLLabelAccessible::GetName(nsAString& aReturn)
|
|||
|
||||
NS_IMETHODIMP nsHTMLLabelAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
*aRole = ROLE_STATICTEXT;
|
||||
*aRole = ROLE_LABEL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -189,7 +190,7 @@ NS_IMETHODIMP nsHTMLLabelAccessible::GetChildCount(PRInt32 *aAccChildCount)
|
|||
|
||||
nsHTMLLIAccessible::nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
nsIFrame *aBulletFrame, const nsAString& aBulletText):
|
||||
nsBlockAccessible(aDOMNode, aShell)
|
||||
nsHyperTextAccessible(aDOMNode, aShell)
|
||||
{
|
||||
if (!aBulletText.IsEmpty()) {
|
||||
mBulletAccessible = new nsHTMLListBulletAccessible(mDOMNode, mWeakShell,
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
NS_IMETHOD GetState(PRUint32 *aState) { nsAccessibleWrap::GetState(aState); *aState &= ~STATE_FOCUSABLE; *aState |= STATE_READONLY; return NS_OK; }
|
||||
};
|
||||
|
||||
class nsHTMLLIAccessible : public nsBlockAccessible
|
||||
class nsHTMLLIAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,104 @@
|
|||
/* -*- 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 Developers of the Original Code are
|
||||
* Sun Microsystems and IBM Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ginn Chen (ginn.chen@sun.com)
|
||||
* Aaron Leventhal (aleventh@us.ibm.com)
|
||||
*
|
||||
* 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 _nsHyperTextAccessible_H_
|
||||
#define _nsHyperTextAccessible_H_
|
||||
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsIAccessibleText.h"
|
||||
#include "nsIAccessibleHyperText.h"
|
||||
#include "nsIAccessibleEditableText.h"
|
||||
#include "nsAccessibleEventData.h"
|
||||
#include "nsIEditActionListener.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };
|
||||
|
||||
// This character marks where in the text returned via nsIAccessibleText(),
|
||||
// that embedded object characters exist
|
||||
const PRUnichar kEmbeddedObjectChar = 0xfffc;
|
||||
|
||||
/**
|
||||
* Special Accessible that knows how contain both text and embedded objects
|
||||
*/
|
||||
class nsHyperTextAccessible : public nsAccessibleWrap,
|
||||
public nsIAccessibleText,
|
||||
public nsIAccessibleHyperText,
|
||||
public nsIAccessibleEditableText,
|
||||
public nsIEditActionListener
|
||||
{
|
||||
public:
|
||||
nsHyperTextAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLETEXT
|
||||
NS_DECL_NSIACCESSIBLEHYPERTEXT
|
||||
NS_DECL_NSIACCESSIBLEEDITABLETEXT
|
||||
NS_DECL_NSIEDITACTIONLISTENER
|
||||
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole);
|
||||
NS_IMETHOD GetExtState(PRUint32 *aState);
|
||||
|
||||
protected:
|
||||
PRBool IsHyperText();
|
||||
|
||||
nsresult GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset,
|
||||
nsISupports *aClosure, nsAString & aText);
|
||||
nsIFrame* GetStartPosAndText(PRInt32& aStartOffset, PRInt32 aEndOffset, nsAString &aText);
|
||||
|
||||
// Editor helpers, subclasses of nsHyperTextAccessible may have editor
|
||||
virtual void SetEditor(nsIEditor *aEditor) { return; }
|
||||
virtual void CheckForEditor() { return; } // Not implemented for conteditable yet
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { return nsnull; }
|
||||
|
||||
// Selection helpers
|
||||
nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
|
||||
nsresult GetSelectionRange(PRInt32 *aStartPos, PRInt32 *aEndPos);
|
||||
nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
|
||||
|
||||
// Event helpers
|
||||
nsresult FireTextChangeEvent(AtkTextChange *aTextData);
|
||||
|
||||
// Static helpers
|
||||
static nsresult DOMPointToOffset(nsISupports *aClosure, nsIDOMNode* aNode, PRInt32 aNodeOffset, PRInt32 *aResult);
|
||||
static nsresult OffsetToDOMPoint(nsISupports *aClosure, PRInt32 aOffset, nsIDOMNode** aResult, PRInt32* aPosition);
|
||||
static nsresult GetCurrentOffset(nsISupports *aClosure, nsISelection *aDomSel, PRInt32 *aOffset);
|
||||
};
|
||||
#endif // _nsHyperTextAccessible_H_
|
|
@ -54,10 +54,8 @@ class nsAccessibleWrap : public nsAccessible
|
|||
};
|
||||
|
||||
// Define unsupported wrap classes here
|
||||
typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -432,7 +432,7 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
|
|||
|
||||
// Begin check for extended roles that need to be mapped to something known
|
||||
if (role == ROLE_ENTRY || role == ROLE_PASSWORD_TEXT) {
|
||||
role = ROLE_TEXT;
|
||||
role = ROLE_TEXT_LEAF;
|
||||
}
|
||||
|
||||
// -- Try enumerated role
|
||||
|
|
|
@ -79,7 +79,6 @@ EXPORTS = \
|
|||
nsAccessibleWrap.h \
|
||||
nsDocAccessibleWrap.h \
|
||||
nsRootAccessibleWrap.h \
|
||||
nsHTMLFormControlAccessibleWrap.h \
|
||||
nsXULMenuAccessibleWrap.h \
|
||||
nsXULTreeAccessibleWrap.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -54,10 +54,8 @@ class nsAccessibleWrap : public nsAccessible
|
|||
};
|
||||
|
||||
// Define unsupported wrap classes here
|
||||
typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,7 @@ LIBXUL_LIBRARY = 1
|
|||
REQUIRES = content \
|
||||
docshell \
|
||||
dom \
|
||||
editor \
|
||||
gfx \
|
||||
intl \
|
||||
layout \
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
* For XUL descriptions and labels
|
||||
*/
|
||||
nsXULTextAccessible::nsXULTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsTextAccessibleWrap(aDomNode, aShell)
|
||||
nsHyperTextAccessible(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -42,17 +42,18 @@
|
|||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsTextAccessibleWrap.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
|
||||
class nsIWeakReference;
|
||||
|
||||
class nsXULTextAccessible : public nsTextAccessibleWrap
|
||||
class nsXULTextAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
|
||||
public:
|
||||
nsXULTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetName(nsAString& _retval);
|
||||
NS_IMETHOD GetState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_STATICTEXT; return NS_OK; }
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_LABEL; return NS_OK; }
|
||||
};
|
||||
|
||||
class nsXULTooltipAccessible : public nsLeafAccessible
|
||||
|
|
Загрузка…
Ссылка в новой задаче