--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -5,21 +5,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AccessibleWrap.h"
#include "Accessible-inl.h"
#include "ApplicationAccessibleWrap.h"
#include "InterfaceInitFuncs.h"
#include "nsAccUtils.h"
-#include "nsIAccessibleRelation.h"
-#include "nsIAccessibleTable.h"
#include "ProxyAccessible.h"
#include "RootAccessible.h"
-#include "nsIAccessibleValue.h"
#include "nsMai.h"
#include "nsMaiHyperlink.h"
#include "nsString.h"
#include "nsAutoPtr.h"
#include "prprf.h"
#include "nsStateMap.h"
#include "mozilla/a11y/Platform.h"
#include "Relation.h"
@@ -300,68 +297,68 @@ AccessibleWrap::SetMaiHyperlink(MaiHyper
return; // Never set and we're shutting down
}
delete maiHyperlink;
g_object_set_qdata(G_OBJECT(mAtkObject), quark_mai_hyperlink,
aMaiHyperlink);
}
}
-NS_IMETHODIMP
+void
AccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
- *aOutAccessible = nullptr;
-
- if (!mAtkObject) {
- if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) {
- // We don't create ATK objects for node which has been shutdown, or
- // nsIAccessible plain text leaves
- return NS_ERROR_FAILURE;
- }
+ *aOutAccessible = nullptr;
- GType type = GetMaiAtkType(CreateMaiInterfaces());
- NS_ENSURE_TRUE(type, NS_ERROR_FAILURE);
- mAtkObject =
- reinterpret_cast<AtkObject *>
- (g_object_new(type, nullptr));
- NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
-
- atk_object_initialize(mAtkObject, this);
- mAtkObject->role = ATK_ROLE_INVALID;
- mAtkObject->layer = ATK_LAYER_INVALID;
+ if (!mAtkObject) {
+ if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) {
+ // We don't create ATK objects for node which has been shutdown or
+ // plain text leaves
+ return;
}
- *aOutAccessible = mAtkObject;
- return NS_OK;
+ GType type = GetMaiAtkType(CreateMaiInterfaces());
+ if (!type)
+ return;
+
+ mAtkObject = reinterpret_cast<AtkObject*>(g_object_new(type, nullptr));
+ if (!mAtkObject)
+ return;
+
+ atk_object_initialize(mAtkObject, this);
+ mAtkObject->role = ATK_ROLE_INVALID;
+ mAtkObject->layer = ATK_LAYER_INVALID;
+ }
+
+ *aOutAccessible = mAtkObject;
}
AtkObject *
AccessibleWrap::GetAtkObject(void)
{
void *atkObj = nullptr;
GetNativeInterface(&atkObj);
return static_cast<AtkObject *>(atkObj);
}
-// Get AtkObject from nsIAccessible interface
+// Get AtkObject from Accessible interface
/* static */
AtkObject *
-AccessibleWrap::GetAtkObject(nsIAccessible* acc)
+AccessibleWrap::GetAtkObject(Accessible* acc)
{
void *atkObjPtr = nullptr;
acc->GetNativeInterface(&atkObjPtr);
return atkObjPtr ? ATK_OBJECT(atkObjPtr) : nullptr;
}
/* private */
uint16_t
AccessibleWrap::CreateMaiInterfaces(void)
{
uint16_t interfacesBits = 0;
-
+
// The Component interface is supported by all accessibles.
interfacesBits |= 1 << MAI_INTERFACE_COMPONENT;
// Add Action interface if the action count is more than zero.
if (ActionCount() > 0)
interfacesBits |= 1 << MAI_INTERFACE_ACTION;
// Text, Editabletext, and Hypertext interface.
@@ -369,22 +366,18 @@ AccessibleWrap::CreateMaiInterfaces(void
if (hyperText && hyperText->IsTextRole()) {
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
if (!nsAccUtils::MustPrune(this))
interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
}
// Value interface.
- nsCOMPtr<nsIAccessibleValue> accessInterfaceValue;
- QueryInterface(NS_GET_IID(nsIAccessibleValue),
- getter_AddRefs(accessInterfaceValue));
- if (accessInterfaceValue) {
- interfacesBits |= 1 << MAI_INTERFACE_VALUE;
- }
+ if (HasNumericValue())
+ interfacesBits |= 1 << MAI_INTERFACE_VALUE;
// Document interface.
if (IsDoc())
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
if (IsImage())
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
@@ -677,17 +670,17 @@ getRoleCB(AtkObject *aAtkObj)
ProxyAccessible* proxy = GetProxy(aAtkObj);
if (!proxy)
return ATK_ROLE_INVALID;
role = proxy->Role();
} else {
#ifdef DEBUG
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
- "Does not support nsIAccessibleText when it should");
+ "Does not support Text interface when it should");
#endif
role = accWrap->Role();
}
#define ROLE(geckoRole, stringRole, atkRole, macRole, \
msaaRole, ia2Role, nameRule) \
case roles::geckoRole: \
@@ -842,20 +835,20 @@ refChildCB(AtkObject *aAtkObj, gint aChi
if (aAtkObj != childAtkObj->accessible_parent)
atk_object_set_parent(childAtkObj, aAtkObj);
return childAtkObj;
}
gint
-getIndexInParentCB(AtkObject *aAtkObj)
+getIndexInParentCB(AtkObject* aAtkObj)
{
- // We don't use nsIAccessible::GetIndexInParent() because
- // for ATK we don't want to include text leaf nodes as children
+ // We don't use Accessible::IndexInParent() because we don't include text
+ // leaf nodes as children in ATK.
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return -1;
}
Accessible* parent = accWrap->Parent();
if (!parent)
return -1; // No parent
@@ -1036,18 +1029,18 @@ AccessibleWrap::HandleAccEvent(AccEvent*
// which decides it would be fun to change the DOM and flush layout.
if (accessible->IsDefunct())
return NS_OK;
uint32_t type = aEvent->GetEventType();
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accessible);
- // We don't create ATK objects for nsIAccessible plain text leaves,
- // just return NS_OK in such case
+ // We don't create ATK objects for plain text leaves, just return NS_OK in
+ // such case.
if (!atkObj) {
NS_ASSERTION(type == nsIAccessibleEvent::EVENT_SHOW ||
type == nsIAccessibleEvent::EVENT_HIDE,
"Event other than SHOW and HIDE fired for plain text leaves");
return NS_OK;
}
AccessibleWrap* accWrap = GetAccessibleWrap(atkObj);
@@ -1078,25 +1071,24 @@ AccessibleWrap::HandleAccEvent(AccEvent*
{
nsAutoString newName;
accessible->Name(newName);
MaybeFireNameChange(atkObj, newName);
break;
}
- case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
- {
- nsCOMPtr<nsIAccessibleValue> value(do_QueryObject(accessible));
- if (value) { // Make sure this is a numeric value
- // Don't fire for MSAA string value changes (e.g. text editing)
- // ATK values are always numeric
- g_object_notify( (GObject*)atkObj, "accessible-value" );
- }
- } break;
+
+ case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
+ if (accessible->HasNumericValue()) {
+ // Make sure this is a numeric value. Don't fire for string value changes
+ // (e.g. text editing) ATK values are always numeric.
+ g_object_notify((GObject*)atkObj, "accessible-value");
+ }
+ break;
case nsIAccessibleEvent::EVENT_SELECTION:
case nsIAccessibleEvent::EVENT_SELECTION_ADD:
case nsIAccessibleEvent::EVENT_SELECTION_REMOVE:
{
// XXX: dupe events may be fired
AccSelChangeEvent* selChangeEvent = downcast_accEvent(aEvent);
g_signal_emit_by_name(AccessibleWrap::GetAtkObject(selChangeEvent->Widget()),
--- a/accessible/atk/AccessibleWrap.h
+++ b/accessible/atk/AccessibleWrap.h
@@ -50,24 +50,24 @@ class AccessibleWrap : public Accessible
public:
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
virtual ~AccessibleWrap();
void ShutdownAtkObject();
virtual void Shutdown();
// return the atk object for this AccessibleWrap
- NS_IMETHOD GetNativeInterface(void **aOutAccessible);
+ virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
virtual nsresult HandleAccEvent(AccEvent* aEvent);
AtkObject * GetAtkObject(void);
- static AtkObject * GetAtkObject(nsIAccessible * acc);
+ static AtkObject* GetAtkObject(Accessible* aAccessible);
bool IsValidObject();
-
+
// get/set the MaiHyperlink object for this AccessibleWrap
MaiHyperlink* GetMaiHyperlink(bool aCreate = true);
void SetMaiHyperlink(MaiHyperlink* aMaiHyperlink);
static const char * ReturnString(nsAString &aString) {
static nsCString returnedString;
returnedString = NS_ConvertUTF16toUTF8(aString);
return returnedString.get();
--- a/accessible/atk/ApplicationAccessibleWrap.cpp
+++ b/accessible/atk/ApplicationAccessibleWrap.cpp
@@ -84,34 +84,33 @@ ApplicationAccessibleWrap::Name(nsString
// ATK doesn't provide a way to obtain an application name (for example,
// Firefox or Thunderbird) like IA2 does. Thus let's return an application
// name as accessible name that was used to get a branding name (for example,
// Minefield aka nightly Firefox or Daily aka nightly Thunderbird).
AppName(aName);
return eNameOK;
}
-NS_IMETHODIMP
+void
ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
- *aOutAccessible = nullptr;
-
- if (!mAtkObject) {
- mAtkObject =
- reinterpret_cast<AtkObject *>
- (g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
- NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
+ *aOutAccessible = nullptr;
- atk_object_initialize(mAtkObject, this);
- mAtkObject->role = ATK_ROLE_INVALID;
- mAtkObject->layer = ATK_LAYER_INVALID;
- }
+ if (!mAtkObject) {
+ mAtkObject =
+ reinterpret_cast<AtkObject*>(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
+ if (!mAtkObject)
+ return;
- *aOutAccessible = mAtkObject;
- return NS_OK;
+ atk_object_initialize(mAtkObject, this);
+ mAtkObject->role = ATK_ROLE_INVALID;
+ mAtkObject->layer = ATK_LAYER_INVALID;
+ }
+
+ *aOutAccessible = mAtkObject;
}
struct AtkRootAccessibleAddedEvent {
AtkObject *app_accessible;
AtkObject *root_accessible;
uint32_t index;
};
--- a/accessible/atk/ApplicationAccessibleWrap.h
+++ b/accessible/atk/ApplicationAccessibleWrap.h
@@ -21,15 +21,15 @@ public:
// Accessible
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) MOZ_OVERRIDE;
virtual bool RemoveChild(Accessible* aChild);
/**
* Return the atk object for app root accessible.
*/
- NS_IMETHOD GetNativeInterface(void** aOutAccessible);
+ virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
};
} // namespace a11y
} // namespace mozilla
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */
--- a/accessible/atk/AtkSocketAccessible.cpp
+++ b/accessible/atk/AtkSocketAccessible.cpp
@@ -131,21 +131,20 @@ AtkSocketAccessible::AtkSocketAccessible
if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
!aPlugId.IsVoid()) {
AtkSocket* accSocket =
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
}
}
-NS_IMETHODIMP
+void
AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = mAtkObject;
- return NS_OK;
}
void
AtkSocketAccessible::Shutdown()
{
if (mAtkObject) {
if (MAI_IS_ATK_SOCKET(mAtkObject))
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
--- a/accessible/atk/AtkSocketAccessible.h
+++ b/accessible/atk/AtkSocketAccessible.h
@@ -42,16 +42,15 @@ public:
*/
static bool gCanEmbed;
AtkSocketAccessible(nsIContent* aContent, DocAccessible* aDoc,
const nsCString& aPlugId);
virtual void Shutdown();
- // nsIAccessible
- NS_IMETHODIMP GetNativeInterface(void** aOutAccessible);
+ virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/atk/nsMaiInterfaceAction.cpp
@@ -34,18 +34,17 @@ getActionCountCB(AtkAction *aAction)
static const gchar*
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (!accWrap)
return nullptr;
nsAutoString description;
- nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
- NS_ENSURE_SUCCESS(rv, nullptr);
+ accWrap->ActionDescriptionAt(aActionIndex, description);
return AccessibleWrap::ReturnString(description);
}
static const gchar*
getActionNameCB(AtkAction *aAction, gint aActionIndex)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (!accWrap)
--- a/accessible/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/atk/nsMaiInterfaceDocument.cpp
@@ -78,17 +78,17 @@ getDocumentAttributesCB(AtkDocument *aDo
// according to atkobject.h, AtkAttributeSet is a GSList
GSList* attributes = nullptr;
DocAccessible* document = accWrap->AsDoc();
nsAutoString aURL;
document->URL(aURL);
attributes = prependToList(attributes, kDocUrlName, aURL);
nsAutoString aW3CDocType;
- document->GetDocType(aW3CDocType);
+ document->DocType(aW3CDocType);
attributes = prependToList(attributes, kDocTypeName, aW3CDocType);
nsAutoString aMimeType;
document->MimeType(aMimeType);
attributes = prependToList(attributes, kMimeTypeName, aMimeType);
return attributes;
}
@@ -97,23 +97,21 @@ const gchar *
getDocumentAttributeValueCB(AtkDocument *aDocument,
const gchar *aAttrName)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (!accWrap || !accWrap->IsDoc())
return nullptr;
DocAccessible* document = accWrap->AsDoc();
- nsresult rv;
nsAutoString attrValue;
if (!strcasecmp(aAttrName, kDocTypeName))
- rv = document->GetDocType(attrValue);
+ document->DocType(attrValue);
else if (!strcasecmp(aAttrName, kDocUrlName))
document->URL(attrValue);
else if (!strcasecmp(aAttrName, kMimeTypeName))
document->MimeType(attrValue);
else
return nullptr;
- NS_ENSURE_SUCCESS(rv, nullptr);
return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
}
}
--- a/accessible/atk/nsMaiInterfaceImage.cpp
+++ b/accessible/atk/nsMaiInterfaceImage.cpp
@@ -26,36 +26,40 @@ getImagePositionCB(AtkImage* aImage, gin
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap || !accWrap->IsImage())
return;
ImageAccessible* image = accWrap->AsImage();
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
- // Returned in screen coordinates
- image->GetImagePosition(geckoCoordType, aAccX, aAccY);
+ nsIntPoint pos = image->Position(geckoCoordType);
+ *aAccX = pos.x;
+ *aAccY = pos.y;
}
static const gchar*
getImageDescriptionCB(AtkImage* aImage)
{
return getDescriptionCB(ATK_OBJECT(aImage));
}
static void
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap || !accWrap->IsImage())
return;
- accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
+ nsIntSize size = accWrap->AsImage()->Size();
+ *aAccWidth = size.width;
+ *aAccHeight = size.height;
}
-}
+
+} // extern "C"
void
imageInterfaceInitCB(AtkImageIface* aIface)
{
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
--- a/accessible/atk/nsStateMap.h
+++ b/accessible/atk/nsStateMap.h
@@ -3,35 +3,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <atk/atk.h>
#include "AccessibleWrap.h"
/******************************************************************************
-The following nsIAccessible states aren't translated, just ignored:
+The following accessible states aren't translated, just ignored:
STATE_READONLY: Supported indirectly via EXT_STATE_EDITABLE
STATE_HOTTRACKED: No ATK equivalent. No known use case.
The nsIAccessible state is not currently supported.
STATE_FLOATING: No ATK equivalent. No known use case.
The nsIAccessible state is not currently supported.
STATE_MOVEABLE: No ATK equivalent. No known use case.
The nsIAccessible state is not currently supported.
STATE_SELFVOICING: No ATK equivalent -- the object has self-TTS.
The nsIAccessible state is not currently supported.
STATE_LINKED: The object is formatted as a hyperlink. Supported via ATK_ROLE_LINK.
STATE_EXTSELECTABLE: Indicates that an object extends its selection.
This is supported via STATE_MULTISELECTABLE.
STATE_PROTECTED: The object is a password-protected edit control.
Supported via ATK_ROLE_PASSWORD_TEXT
STATE_HASPOPUP: Object displays a pop-up menu or window when invoked.
- No ATK equivalent. The nsIAccessible state is not currently supported.
- STATE_PINNED: The object is pinned, usually indicating it is fixed in place and has permanence.
- No ATK equivalent. The nsIAccessible state is not currently supported.
+ No ATK equivalent. The accessible state is not
+ currently supported.
+ STATE_PINNED: The object is pinned, usually indicating it is fixed in
+ place and has permanence. No ATK equivalent. The
+ accessible state is not currently supported.
The following ATK states are not supported:
ATK_STATE_ARMED: No clear use case, used briefly when button is activated
ATK_STATE_HAS_TOOLTIP: No clear use case, no IA2 equivalent
ATK_STATE_ICONIFIED: Mozilla does not have elements which are collapsable into icons
ATK_STATE_TRUNCATED: No clear use case. Indicates that an object's onscreen content is truncated,
e.g. a text value in a spreadsheet cell. No IA2 state.
******************************************************************************/
--- a/accessible/base/ARIAMap.cpp
+++ b/accessible/base/ARIAMap.cpp
@@ -25,22 +25,22 @@ static const uint32_t kGenericAccType =
/**
* This list of WAI-defined roles are currently hardcoded.
* Eventually we will most likely be loading an RDF resource that contains this information
* Using RDF will also allow for role extensibility. See bug 280138.
*
* Definition of nsRoleMapEntry contains comments explaining this table.
*
- * When no nsIAccessibleRole enum mapping exists for an ARIA role, the
- * role will be exposed via the object attribute "xml-roles".
- * In addition, in MSAA, the unmapped role will also be exposed as a BSTR string role.
+ * When no Role enum mapping exists for an ARIA role, the role will be exposed
+ * via the object attribute "xml-roles".
*
- * There are no nsIAccessibleRole enums for the following landmark roles:
- * banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs
+ * There are no Role enums for the following landmark roles:
+ * banner, contentinfo, main, navigation, note, search, secondary,
+ * seealso, breadcrumbs.
*/
static nsRoleMapEntry sWAIRoleMaps[] =
{
{ // alert
&nsGkAtoms::alert,
roles::ALERT,
kUseMapRole,
--- a/accessible/base/ARIAMap.h
+++ b/accessible/base/ARIAMap.h
@@ -16,27 +16,27 @@
#include "nsIContent.h"
class nsINode;
////////////////////////////////////////////////////////////////////////////////
// Value constants
/**
- * Used to define if role requires to expose nsIAccessibleValue.
+ * Used to define if role requires to expose Value interface.
*/
enum EValueRule
{
/**
- * nsIAccessibleValue isn't exposed.
+ * Value interface isn't exposed.
*/
eNoValue,
/**
- * nsIAccessibleValue is implemented, supports value, min and max from
+ * Value interface is implemented, supports value, min and max from
* aria-valuenow, aria-valuemin and aria-valuemax.
*/
eHasValueMinMax
};
////////////////////////////////////////////////////////////////////////////////
// Action constants
@@ -145,40 +145,40 @@ struct nsRoleMapEntry
* Return ARIA role.
*/
const nsDependentAtomString ARIARoleString() const
{ return nsDependentAtomString(*roleAtom); }
// ARIA role: string representation such as "button"
nsIAtom** roleAtom;
- // Role mapping rule: maps to this nsIAccessibleRole
+ // Role mapping rule: maps to enum Role
mozilla::a11y::role role;
-
+
// Role rule: whether to use mapped role or native semantics
bool roleRule;
-
- // Value mapping rule: how to compute nsIAccessible value
+
+ // Value mapping rule: how to compute accessible value
EValueRule valueRule;
- // Action mapping rule, how to expose nsIAccessible action
+ // Action mapping rule, how to expose accessible action
EActionRule actionRule;
// 'live' and 'container-live' object attributes mapping rule: how to expose
// these object attributes if ARIA 'live' attribute is missed.
ELiveAttrRule liveAttRule;
// Accessible types this role belongs to.
uint32_t accTypes;
- // Automatic state mapping rule: always include in nsIAccessibleStates
- uint64_t state; // or kNoReqStates if no nsIAccessibleStates are automatic for this role.
+ // Automatic state mapping rule: always include in states
+ uint64_t state; // or kNoReqStates if no default state for this role
- // ARIA properties supported for this role
- // (in other words, the aria-foo attribute to nsIAccessibleStates mapping rules)
+ // ARIA properties supported for this role (in other words, the aria-foo
+ // attribute to accessible states mapping rules).
// Currently you cannot have unlimited mappings, because
// a variable sized array would not allow the use of
// C++'s struct initialization feature.
mozilla::a11y::aria::EStateRule attributeMap1;
mozilla::a11y::aria::EStateRule attributeMap2;
mozilla::a11y::aria::EStateRule attributeMap3;
mozilla::a11y::aria::EStateRule attributeMap4;
};
--- a/accessible/base/AccEvent.cpp
+++ b/accessible/base/AccEvent.cpp
@@ -5,16 +5,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AccEvent.h"
#include "nsAccUtils.h"
#include "DocAccessible.h"
#include "xpcAccEvents.h"
#include "States.h"
+#include "xpcAccessibleDocument.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/dom/Selection.h"
using namespace mozilla;
using namespace mozilla::a11y;
static_assert(static_cast<bool>(eNoUserInput) == false &&
@@ -179,17 +180,17 @@ AccTableChangeEvent::
////////////////////////////////////////////////////////////////////////////////
// AccVCChangeEvent
////////////////////////////////////////////////////////////////////////////////
AccVCChangeEvent::
AccVCChangeEvent(Accessible* aAccessible,
- nsIAccessible* aOldAccessible,
+ Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
int16_t aReason, EIsFromUserInput aIsFromUserInput) :
AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
aIsFromUserInput),
mOldAccessible(aOldAccessible), mOldStart(aOldStart), mOldEnd(aOldEnd),
mReason(aReason)
{
}
@@ -205,60 +206,68 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
uint32_t type = aEvent->GetEventType();
uint32_t eventGroup = aEvent->GetEventGroups();
nsCOMPtr<nsIAccessibleEvent> xpEvent;
if (eventGroup & (1 << AccEvent::eStateChangeEvent)) {
AccStateChangeEvent* sc = downcast_accEvent(aEvent);
bool extra = false;
uint32_t state = nsAccUtils::To32States(sc->GetState(), &extra);
- xpEvent = new xpcAccStateChangeEvent(type, acc, doc, domNode, fromUser,
+ xpEvent = new xpcAccStateChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
+ domNode, fromUser,
state, extra, sc->IsStateEnabled());
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eTextChangeEvent)) {
AccTextChangeEvent* tc = downcast_accEvent(aEvent);
nsString text;
tc->GetModifiedText(text);
- xpEvent = new xpcAccTextChangeEvent(type, acc, doc, domNode, fromUser,
+ xpEvent = new xpcAccTextChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
+ domNode, fromUser,
tc->GetStartOffset(), tc->GetLength(),
tc->IsTextInserted(), text);
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eHideEvent)) {
AccHideEvent* hideEvent = downcast_accEvent(aEvent);
- xpEvent = new xpcAccHideEvent(type, acc, doc, domNode, fromUser,
- hideEvent->TargetParent(),
- hideEvent->TargetNextSibling(),
- hideEvent->TargetPrevSibling());
+ xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc),
+ domNode, fromUser,
+ ToXPC(hideEvent->TargetParent()),
+ ToXPC(hideEvent->TargetNextSibling()),
+ ToXPC(hideEvent->TargetPrevSibling()));
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eCaretMoveEvent)) {
AccCaretMoveEvent* cm = downcast_accEvent(aEvent);
- xpEvent = new xpcAccCaretMoveEvent(type, acc, doc, domNode, fromUser,
+ xpEvent = new xpcAccCaretMoveEvent(type, ToXPC(acc), ToXPCDocument(doc),
+ domNode, fromUser,
cm->GetCaretOffset());
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eVirtualCursorChangeEvent)) {
AccVCChangeEvent* vcc = downcast_accEvent(aEvent);
- xpEvent = new xpcAccVirtualCursorChangeEvent(type, acc, doc, domNode, fromUser,
- vcc->OldAccessible(),
+ xpEvent = new xpcAccVirtualCursorChangeEvent(type,
+ ToXPC(acc), ToXPCDocument(doc),
+ domNode, fromUser,
+ ToXPC(vcc->OldAccessible()),
vcc->OldStartOffset(),
vcc->OldEndOffset(),
vcc->Reason());
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eObjectAttrChangedEvent)) {
AccObjectAttrChangedEvent* oac = downcast_accEvent(aEvent);
- xpEvent = new xpcAccObjectAttributeChangedEvent(type, acc, doc, domNode,
+ xpEvent = new xpcAccObjectAttributeChangedEvent(type,
+ ToXPC(acc),
+ ToXPCDocument(doc), domNode,
fromUser,
oac->GetAttribute());
return xpEvent.forget();
}
- xpEvent = new xpcAccEvent(type, acc, doc, domNode, fromUser);
+ xpEvent = new xpcAccEvent(type, ToXPC(acc), ToXPCDocument(doc), domNode, fromUser);
return xpEvent.forget();
}
--- a/accessible/base/AccEvent.h
+++ b/accessible/base/AccEvent.h
@@ -70,17 +70,17 @@ public:
// eRemoveDupes : For repeat events, only the newest event in queue
// will be emitted.
eRemoveDupes,
// eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
eDoNotEmit
};
- // Initialize with an nsIAccessible
+ // Initialize with an accessible.
AccEvent(uint32_t aEventType, Accessible* aAccessible,
EIsFromUserInput aIsFromUserInput = eAutoDetect,
EEventRule aEventRule = eRemoveDupes);
// AccEvent
uint32_t GetEventType() const { return mEventType; }
EEventRule GetEventRule() const { return mEventRule; }
bool IsFromUserInput() const { return mIsFromUserInput; }
@@ -465,38 +465,38 @@ private:
/**
* Accessible virtual cursor change event.
*/
class AccVCChangeEvent : public AccEvent
{
public:
AccVCChangeEvent(Accessible* aAccessible,
- nsIAccessible* aOldAccessible,
+ Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
int16_t aReason,
EIsFromUserInput aIsFromUserInput = eFromUserInput);
virtual ~AccVCChangeEvent() { }
// AccEvent
static const EventGroup kEventGroup = eVirtualCursorChangeEvent;
virtual unsigned int GetEventGroups() const
{
return AccEvent::GetEventGroups() | (1U << eVirtualCursorChangeEvent);
}
// AccTableChangeEvent
- nsIAccessible* OldAccessible() const { return mOldAccessible; }
+ Accessible* OldAccessible() const { return mOldAccessible; }
int32_t OldStartOffset() const { return mOldStart; }
int32_t OldEndOffset() const { return mOldEnd; }
int32_t Reason() const { return mReason; }
private:
- nsRefPtr<nsIAccessible> mOldAccessible;
+ nsRefPtr<Accessible> mOldAccessible;
int32_t mOldStart;
int32_t mOldEnd;
int16_t mReason;
};
/**
* Accessible object attribute changed event.
*/
--- a/accessible/base/DocManager.cpp
+++ b/accessible/base/DocManager.cpp
@@ -6,16 +6,17 @@
#include "DocManager.h"
#include "ApplicationAccessible.h"
#include "ARIAMap.h"
#include "DocAccessible-inl.h"
#include "DocAccessibleChild.h"
#include "nsAccessibilityService.h"
#include "RootAccessibleWrap.h"
+#include "xpcAccessibleDocument.h"
#ifdef A11Y_LOG
#include "Logging.h"
#endif
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
#include "nsCURILoader.h"
@@ -35,17 +36,17 @@ using namespace mozilla;
using namespace mozilla::a11y;
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// DocManager
////////////////////////////////////////////////////////////////////////////////
DocManager::DocManager()
- : mDocAccessibleCache(2)
+ : mDocAccessibleCache(2), mXPCDocumentCache(0)
{
}
////////////////////////////////////////////////////////////////////////////////
// DocManager public
DocAccessible*
DocManager::GetDocAccessible(nsIDocument* aDocument)
@@ -70,16 +71,44 @@ DocManager::FindAccessibleInCache(nsINod
arg.mNode = aNode;
mDocAccessibleCache.EnumerateRead(SearchAccessibleInDocCache,
static_cast<void*>(&arg));
return arg.mAccessible;
}
+void
+DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
+ nsIDocument* aDOMDocument)
+{
+ xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
+ if (xpcDoc) {
+ xpcDoc->Shutdown();
+ mXPCDocumentCache.Remove(aDocument);
+ }
+
+ mDocAccessibleCache.Remove(aDOMDocument);
+ RemoveListeners(aDOMDocument);
+}
+
+xpcAccessibleDocument*
+DocManager::GetXPCDocument(DocAccessible* aDocument)
+{
+ if (!aDocument)
+ return nullptr;
+
+ xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
+ if (!xpcDoc) {
+ xpcDoc = new xpcAccessibleDocument(aDocument);
+ mXPCDocumentCache.Put(aDocument, xpcDoc);
+ }
+ return xpcDoc;
+}
+
#ifdef DEBUG
bool
DocManager::IsProcessingRefreshDriverNotification() const
{
bool isDocRefreshing = false;
mDocAccessibleCache.EnumerateRead(SearchIfDocIsRefreshing,
static_cast<void*>(&isDocRefreshing));
--- a/accessible/base/DocManager.h
+++ b/accessible/base/DocManager.h
@@ -12,16 +12,17 @@
#include "nsWeakReference.h"
#include "nsIPresShell.h"
namespace mozilla {
namespace a11y {
class Accessible;
class DocAccessible;
+class xpcAccessibleDocument;
class DocAccessibleParent;
/**
* Manage the document accessible life cycle.
*/
class DocManager : public nsIWebProgressListener,
public nsIDOMEventListener,
public nsSupportsWeakReference
@@ -55,21 +56,25 @@ public:
* Search through all document accessibles for an accessible with the given
* unique id.
*/
Accessible* FindAccessibleInCache(nsINode* aNode) const;
/**
* Called by document accessible when it gets shutdown.
*/
- inline void NotifyOfDocumentShutdown(nsIDocument* aDocument)
- {
- mDocAccessibleCache.Remove(aDocument);
- RemoveListeners(aDocument);
- }
+ void NotifyOfDocumentShutdown(DocAccessible* aDocument,
+ nsIDocument* aDOMDocument);
+
+ /**
+ * Return XPCOM accessible document.
+ */
+ xpcAccessibleDocument* GetXPCDocument(DocAccessible* aDocument);
+ xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const
+ { return mXPCDocumentCache.GetWeak(aDocument); }
/*
* Notification that a top level document in a content process has gone away.
*/
void RemoteDocShutdown(DocAccessibleParent* aDoc)
{
DebugOnly<bool> result = mRemoteDocuments.RemoveElement(aDoc);
MOZ_ASSERT(result, "Why didn't we find the document!");
@@ -125,19 +130,16 @@ private:
void AddListeners(nsIDocument *aDocument, bool aAddPageShowListener);
void RemoveListeners(nsIDocument* aDocument);
/**
* Create document or root accessible.
*/
DocAccessible* CreateDocOrRootAccessible(nsIDocument* aDocument);
- typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
- DocAccessibleHashtable;
-
/**
* Get first entry of the document accessible from cache.
*/
static PLDHashOperator
GetFirstEntryInDocCache(const nsIDocument* aKey,
DocAccessible* aDocAccessible,
void* aUserArg);
@@ -158,18 +160,24 @@ private:
void* aUserArg);
#ifdef DEBUG
static PLDHashOperator
SearchIfDocIsRefreshing(const nsIDocument* aKey,
DocAccessible* aDocAccessible, void* aUserArg);
#endif
+ typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
+ DocAccessibleHashtable;
DocAccessibleHashtable mDocAccessibleCache;
+ typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
+ XPCDocumentHashtable;
+ XPCDocumentHashtable mXPCDocumentCache;
+
/*
* The list of remote top level documents.
*/
nsTArray<DocAccessibleParent*> mRemoteDocuments;
};
/**
* Return the existing document accessible for the document if any.
--- a/accessible/base/nsAccCache.h
+++ b/accessible/base/nsAccCache.h
@@ -1,19 +1,17 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _nsAccCache_H_
#define _nsAccCache_H_
-#include "nsIAccessible.h"
-#include "nsRefPtrHashtable.h"
-#include "nsCycleCollectionParticipant.h"
+#include "xpcAccessibleDocument.h"
////////////////////////////////////////////////////////////////////////////////
// Accessible cache utils
////////////////////////////////////////////////////////////////////////////////
/**
* Shutdown and removes the accessible from cache.
*/
@@ -33,49 +31,9 @@ ClearCacheEntry(const void* aKey, nsRefP
*/
static void
ClearCache(mozilla::a11y::AccessibleHashtable& aCache)
{
aCache.Enumerate(ClearCacheEntry<mozilla::a11y::Accessible>, nullptr);
}
-/**
- * Traverse the accessible cache entry for cycle collector.
- */
-template <class T>
-static PLDHashOperator
-CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
- void *aUserArg)
-{
- nsCycleCollectionTraversalCallback *cb =
- static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
-
- NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "accessible cache entry");
-
- nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
- cb->NoteXPCOMChild(supports);
- return PL_DHASH_NEXT;
-}
-
-/**
- * Unlink the accessible cache for the cycle collector.
- */
-inline void
-ImplCycleCollectionUnlink(mozilla::a11y::AccessibleHashtable& aCache)
-{
- ClearCache(aCache);
-}
-
-/**
- * Traverse the accessible cache for cycle collector.
- */
-inline void
-ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
- mozilla::a11y::AccessibleHashtable& aCache,
- const char* aName,
- uint32_t aFlags = 0)
-{
- aCache.EnumerateRead(CycleCollectorTraverseCacheEntry<mozilla::a11y::Accessible>,
- &aCallback);
-}
-
#endif
--- a/accessible/base/nsAccUtils.cpp
+++ b/accessible/base/nsAccUtils.cpp
@@ -363,24 +363,17 @@ nsAccUtils::IsTextInterfaceSupportCorrec
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
Accessible* child = aAccessible->GetChildAt(childIdx);
if (!IsEmbeddedObject(child)) {
foundText = true;
break;
}
}
- if (foundText) {
- // found text child node
- nsCOMPtr<nsIAccessibleText> text = do_QueryObject(aAccessible);
- if (!text)
- return false;
- }
-
- return true;
+ return !foundText || aAccessible->IsHyperText();
}
#endif
uint32_t
nsAccUtils::TextLength(Accessible* aAccessible)
{
if (IsEmbeddedObject(aAccessible))
return 1;
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -30,16 +30,18 @@
#include "Role.h"
#ifdef MOZ_ACCESSIBILITY_ATK
#include "RootAccessibleWrap.h"
#endif
#include "States.h"
#include "Statistics.h"
#include "TextLeafAccessibleWrap.h"
#include "TreeWalker.h"
+#include "xpcAccessibleApplication.h"
+#include "xpcAccessibleDocument.h"
#ifdef MOZ_ACCESSIBILITY_ATK
#include "AtkSocketAccessible.h"
#endif
#ifdef XP_WIN
#include "mozilla/a11y/Compatibility.h"
#include "HTMLWin32ObjectAccessible.h"
@@ -132,16 +134,17 @@ MustBeAccessible(nsIContent* aContent, D
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService
////////////////////////////////////////////////////////////////////////////////
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nullptr;
ApplicationAccessible* nsAccessibilityService::gApplicationAccessible = nullptr;
+xpcAccessibleApplication* nsAccessibilityService::gXPCApplicationAccessible = nullptr;
bool nsAccessibilityService::gIsShutdown = true;
nsAccessibilityService::nsAccessibilityService() :
DocManager(), FocusManager()
{
}
nsAccessibilityService::~nsAccessibilityService()
@@ -551,18 +554,17 @@ nsAccessibilityService::RecreateAccessib
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleRetrieval
NS_IMETHODIMP
nsAccessibilityService::GetApplicationAccessible(nsIAccessible** aAccessibleApplication)
{
NS_ENSURE_ARG_POINTER(aAccessibleApplication);
- NS_IF_ADDREF(*aAccessibleApplication = ApplicationAcc());
-
+ NS_IF_ADDREF(*aAccessibleApplication = XPCApplicationAcc());
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
@@ -571,17 +573,17 @@ nsAccessibilityService::GetAccessibleFor
return NS_OK;
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
if (!node)
return NS_ERROR_INVALID_ARG;
DocAccessible* document = GetDocAccessible(node->OwnerDoc());
if (document)
- NS_IF_ADDREF(*aAccessible = document->GetAccessible(node));
+ NS_IF_ADDREF(*aAccessible = ToXPC(document->GetAccessible(node)));
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::GetStringRole(uint32_t aRole, nsAString& aString)
{
#define ROLE(geckoRole, stringRole, atkRole, \
@@ -775,29 +777,29 @@ nsAccessibilityService::GetAccessibleFro
// exist in the document cache.
Accessible* accessible = FindAccessibleInCache(node);
if (!accessible) {
nsCOMPtr<nsIDocument> document(do_QueryInterface(node));
if (document)
accessible = GetExistingDocAccessible(document);
}
- NS_IF_ADDREF(*aAccessible = accessible);
+ NS_IF_ADDREF(*aAccessible = ToXPC(accessible));
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateAccessiblePivot(nsIAccessible* aRoot,
nsIAccessiblePivot** aPivot)
{
NS_ENSURE_ARG_POINTER(aPivot);
NS_ENSURE_ARG(aRoot);
*aPivot = nullptr;
- nsRefPtr<Accessible> accessibleRoot(do_QueryObject(aRoot));
+ Accessible* accessibleRoot = aRoot->ToInternalAccessible();
NS_ENSURE_TRUE(accessibleRoot, NS_ERROR_INVALID_ARG);
nsAccessiblePivot* pivot = new nsAccessiblePivot(accessibleRoot);
NS_ADDREF(*aPivot = pivot);
return NS_OK;
}
@@ -1174,16 +1176,19 @@ nsAccessibilityService::Shutdown()
NS_ASSERTION(!gIsShutdown, "Accessibility was shutdown already");
gIsShutdown = true;
PlatformShutdown();
gApplicationAccessible->Shutdown();
NS_RELEASE(gApplicationAccessible);
gApplicationAccessible = nullptr;
+
+ NS_IF_RELEASE(gXPCApplicationAccessible);
+ gXPCApplicationAccessible = nullptr;
}
already_AddRefed<Accessible>
nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
DocAccessible* aDoc)
{
nsAutoString role;
for (const nsXBLBinding* binding = aContent->GetXBLBinding(); binding; binding = binding->GetBaseBinding()) {
@@ -1661,16 +1666,30 @@ nsAccessibilityService::RemoveNativeRoot
#ifdef MOZ_ACCESSIBILITY_ATK
ApplicationAccessible* applicationAcc = ApplicationAcc();
if (applicationAcc)
applicationAcc->RemoveChild(aAccessible);
#endif
}
+bool
+nsAccessibilityService::HasAccessible(nsIDOMNode* aDOMNode)
+{
+ nsCOMPtr<nsINode> node(do_QueryInterface(aDOMNode));
+ if (!node)
+ return false;
+
+ DocAccessible* document = GetDocAccessible(node->OwnerDoc());
+ if (!document)
+ return false;
+
+ return document->HasAccessible(node);
+}
+
////////////////////////////////////////////////////////////////////////////////
// NS_GetAccessibilityService
////////////////////////////////////////////////////////////////////////////////
/**
* Return accessibility service; creating one if necessary.
*/
nsresult
@@ -1755,16 +1774,29 @@ SelectionMgr()
}
ApplicationAccessible*
ApplicationAcc()
{
return nsAccessibilityService::gApplicationAccessible;
}
+xpcAccessibleApplication*
+XPCApplicationAcc()
+{
+ if (!nsAccessibilityService::gXPCApplicationAccessible &&
+ nsAccessibilityService::gApplicationAccessible) {
+ nsAccessibilityService::gXPCApplicationAccessible =
+ new xpcAccessibleApplication(nsAccessibilityService::gApplicationAccessible);
+ NS_ADDREF(nsAccessibilityService::gXPCApplicationAccessible);
+ }
+
+ return nsAccessibilityService::gXPCApplicationAccessible;
+}
+
EPlatformDisabledState
PlatformDisabledState()
{
static int disabledState = 0xff;
if (disabledState == 0xff) {
disabledState = Preferences::GetInt("accessibility.force_disabled", 0);
if (disabledState < ePlatformIsForceEnabled)
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -17,31 +17,33 @@
class nsImageFrame;
class nsPluginFrame;
class nsITreeView;
namespace mozilla {
namespace a11y {
class ApplicationAccessible;
+class xpcAccessibleApplication;
/**
* Return focus manager.
*/
FocusManager* FocusMgr();
/**
* Return selection manager.
*/
SelectionManager* SelectionMgr();
/**
* Returns the application accessible.
*/
ApplicationAccessible* ApplicationAcc();
+xpcAccessibleApplication* XPCApplicationAcc();
} // namespace a11y
} // namespace mozilla
class nsAccessibilityService MOZ_FINAL : public mozilla::a11y::DocManager,
public mozilla::a11y::FocusManager,
public mozilla::a11y::SelectionManager,
public nsIAccessibilityService,
@@ -68,16 +70,19 @@ public:
/**
* Adds/remove ATK root accessible for gtk+ native window to/from children
* of the application accessible.
*/
virtual Accessible* AddNativeRootAccessible(void* aAtkAccessible);
virtual void RemoveNativeRootAccessible(Accessible* aRootAccessible);
+ virtual bool HasAccessible(nsIDOMNode* aDOMNode) MOZ_OVERRIDE;
+
+ // nsAccesibilityService
/**
* Notification used to update the accessible tree when deck panel is
* switched.
*/
void DeckPanelSwitched(nsIPresShell* aPresShell, nsIContent* aDeckNode,
nsIFrame* aPrevBoxFrame, nsIFrame* aCurrentBoxFrame);
/**
@@ -210,26 +215,28 @@ private:
* Reference for accessibility service instance.
*/
static nsAccessibilityService* gAccessibilityService;
/**
* Reference for application accessible instance.
*/
static mozilla::a11y::ApplicationAccessible* gApplicationAccessible;
+ static mozilla::a11y::xpcAccessibleApplication* gXPCApplicationAccessible;
/**
* Indicates whether accessibility service was shutdown.
*/
static bool gIsShutdown;
friend nsAccessibilityService* GetAccService();
friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr();
friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc();
+ friend mozilla::a11y::xpcAccessibleApplication* mozilla::a11y::XPCApplicationAcc();
friend nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult);
};
/**
* Return the accessibility service instance. (Handy global function)
*/
inline nsAccessibilityService*
--- a/accessible/base/nsAccessiblePivot.cpp
+++ b/accessible/base/nsAccessiblePivot.cpp
@@ -4,16 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsAccessiblePivot.h"
#include "HyperTextAccessible.h"
#include "nsAccUtils.h"
#include "States.h"
+#include "xpcAccessibleDocument.h"
using namespace mozilla::a11y;
/**
* An object that stores a given traversal rule during the pivot movement.
*/
class RuleCache
@@ -65,75 +66,74 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAcces
////////////////////////////////////////////////////////////////////////////////
// nsIAccessiblePivot
NS_IMETHODIMP
nsAccessiblePivot::GetRoot(nsIAccessible** aRoot)
{
NS_ENSURE_ARG_POINTER(aRoot);
- NS_IF_ADDREF(*aRoot = mRoot);
+ NS_IF_ADDREF(*aRoot = ToXPC(mRoot));
return NS_OK;
}
NS_IMETHODIMP
nsAccessiblePivot::GetPosition(nsIAccessible** aPosition)
{
NS_ENSURE_ARG_POINTER(aPosition);
- NS_IF_ADDREF(*aPosition = mPosition);
+ NS_IF_ADDREF(*aPosition = ToXPC(mPosition));
return NS_OK;
}
NS_IMETHODIMP
nsAccessiblePivot::SetPosition(nsIAccessible* aPosition)
{
- nsRefPtr<Accessible> secondPosition;
+ nsRefPtr<Accessible> position = nullptr;
if (aPosition) {
- secondPosition = do_QueryObject(aPosition);
- if (!secondPosition || !IsDescendantOf(secondPosition, GetActiveRoot()))
+ position = aPosition->ToInternalAccessible();
+ if (!position || !IsDescendantOf(position, GetActiveRoot()))
return NS_ERROR_INVALID_ARG;
}
// Swap old position with new position, saves us an AddRef/Release.
- mPosition.swap(secondPosition);
+ mPosition.swap(position);
int32_t oldStart = mStartOffset, oldEnd = mEndOffset;
mStartOffset = mEndOffset = -1;
- NotifyOfPivotChange(secondPosition, oldStart, oldEnd,
+ NotifyOfPivotChange(position, oldStart, oldEnd,
nsIAccessiblePivot::REASON_NONE, false);
return NS_OK;
}
NS_IMETHODIMP
nsAccessiblePivot::GetModalRoot(nsIAccessible** aModalRoot)
{
NS_ENSURE_ARG_POINTER(aModalRoot);
- NS_IF_ADDREF(*aModalRoot = mModalRoot);
+ NS_IF_ADDREF(*aModalRoot = ToXPC(mModalRoot));
return NS_OK;
}
NS_IMETHODIMP
nsAccessiblePivot::SetModalRoot(nsIAccessible* aModalRoot)
{
- nsRefPtr<Accessible> modalRoot;
+ Accessible* modalRoot = nullptr;
if (aModalRoot) {
- modalRoot = do_QueryObject(aModalRoot);
+ modalRoot = aModalRoot->ToInternalAccessible();
if (!modalRoot || !IsDescendantOf(modalRoot, mRoot))
return NS_ERROR_INVALID_ARG;
}
- mModalRoot.swap(modalRoot);
-
+ mModalRoot = modalRoot;
return NS_OK;
}
NS_IMETHODIMP
nsAccessiblePivot::GetStartOffset(int32_t* aStartOffset)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
@@ -160,60 +160,58 @@ nsAccessiblePivot::SetTextRange(nsIAcces
NS_ENSURE_ARG(aTextAccessible);
// Check that start offset is smaller than end offset, and that if a value is
// smaller than 0, both should be -1.
NS_ENSURE_TRUE(aStartOffset <= aEndOffset &&
(aStartOffset >= 0 || (aStartOffset != -1 && aEndOffset != -1)),
NS_ERROR_INVALID_ARG);
- nsRefPtr<Accessible> acc(do_QueryObject(aTextAccessible));
- if (!acc)
- return NS_ERROR_INVALID_ARG;
+ nsCOMPtr<nsIAccessible> xpcAcc = do_QueryInterface(aTextAccessible);
+ NS_ENSURE_ARG(xpcAcc);
- HyperTextAccessible* newPosition = acc->AsHyperText();
- if (!newPosition || !IsDescendantOf(newPosition, GetActiveRoot()))
+ nsRefPtr<Accessible> acc = xpcAcc->ToInternalAccessible();
+ NS_ENSURE_ARG(acc);
+
+ HyperTextAccessible* position = acc->AsHyperText();
+ if (!position || !IsDescendantOf(position, GetActiveRoot()))
return NS_ERROR_INVALID_ARG;
// Make sure the given offsets don't exceed the character count.
- int32_t charCount = newPosition->CharacterCount();
-
- if (aEndOffset > charCount)
+ if (aEndOffset > static_cast<int32_t>(position->CharacterCount()))
return NS_ERROR_FAILURE;
int32_t oldStart = mStartOffset, oldEnd = mEndOffset;
mStartOffset = aStartOffset;
mEndOffset = aEndOffset;
- nsRefPtr<Accessible> oldPosition = mPosition.forget();
- mPosition = newPosition;
-
- NotifyOfPivotChange(oldPosition, oldStart, oldEnd,
+ mPosition.swap(acc);
+ NotifyOfPivotChange(acc, oldStart, oldEnd,
nsIAccessiblePivot::REASON_TEXT,
(aArgc > 0) ? aIsFromUserInput : true);
return NS_OK;
}
// Traversal functions
NS_IMETHODIMP
nsAccessiblePivot::MoveNext(nsIAccessibleTraversalRule* aRule,
nsIAccessible* aAnchor, bool aIncludeStart,
bool aIsFromUserInput, uint8_t aArgc, bool* aResult)
{
NS_ENSURE_ARG(aResult);
NS_ENSURE_ARG(aRule);
-
*aResult = false;
- Accessible* root = GetActiveRoot();
- nsRefPtr<Accessible> anchor =
- (aArgc > 0) ? do_QueryObject(aAnchor) : mPosition;
- if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, root)))
+ Accessible* anchor = mPosition;
+ if (aArgc > 0 && aAnchor)
+ anchor = aAnchor->ToInternalAccessible();
+
+ if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, GetActiveRoot())))
return NS_ERROR_NOT_IN_TREE;
nsresult rv = NS_OK;
Accessible* accessible =
SearchForward(anchor, aRule, (aArgc > 1) ? aIncludeStart : false, &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (accessible)
@@ -226,23 +224,23 @@ nsAccessiblePivot::MoveNext(nsIAccessibl
NS_IMETHODIMP
nsAccessiblePivot::MovePrevious(nsIAccessibleTraversalRule* aRule,
nsIAccessible* aAnchor,
bool aIncludeStart, bool aIsFromUserInput,
uint8_t aArgc, bool* aResult)
{
NS_ENSURE_ARG(aResult);
NS_ENSURE_ARG(aRule);
-
*aResult = false;
- Accessible* root = GetActiveRoot();
- nsRefPtr<Accessible> anchor =
- (aArgc > 0) ? do_QueryObject(aAnchor) : mPosition;
- if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, root)))
+ Accessible* anchor = mPosition;
+ if (aArgc > 0 && aAnchor)
+ anchor = aAnchor->ToInternalAccessible();
+
+ if (anchor && (anchor->IsDefunct() || !IsDescendantOf(anchor, GetActiveRoot())))
return NS_ERROR_NOT_IN_TREE;
nsresult rv = NS_OK;
Accessible* accessible =
SearchBackward(anchor, aRule, (aArgc > 1) ? aIncludeStart : false, &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (accessible)
@@ -850,20 +848,21 @@ bool
nsAccessiblePivot::NotifyOfPivotChange(Accessible* aOldPosition,
int32_t aOldStart, int32_t aOldEnd,
int16_t aReason, bool aIsFromUserInput)
{
if (aOldPosition == mPosition &&
aOldStart == mStartOffset && aOldEnd == mEndOffset)
return false;
+ nsCOMPtr<nsIAccessible> xpcOldPos = ToXPC(aOldPosition); // death grip
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> >::ForwardIterator iter(mObservers);
while (iter.HasMore()) {
nsIAccessiblePivotObserver* obs = iter.GetNext();
- obs->OnPivotChanged(this, aOldPosition, aOldStart, aOldEnd, aReason,
+ obs->OnPivotChanged(this, xpcOldPos, aOldStart, aOldEnd, aReason,
aIsFromUserInput);
}
return true;
}
nsresult
RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult)
@@ -920,10 +919,10 @@ RuleCache::ApplyFilter(Accessible* aAcce
matchesRole = mAcceptRoles[idx] == accessibleRole;
if (matchesRole)
break;
}
if (!matchesRole)
return NS_OK;
}
- return mRule->Match(aAccessible, aResult);
+ return mRule->Match(ToXPC(aAccessible), aResult);
}
--- a/accessible/generic/ARIAGridAccessible.cpp
+++ b/accessible/generic/ARIAGridAccessible.cpp
@@ -23,39 +23,24 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Constructor
ARIAGridAccessible::
ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
+ AccessibleWrap(aContent, aDoc)
{
}
-////////////////////////////////////////////////////////////////////////////////
-// nsISupports
-
-NS_IMPL_ISUPPORTS_INHERITED(ARIAGridAccessible,
- Accessible,
- nsIAccessibleTable)
+NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
-// Accessible
-
-void
-ARIAGridAccessible::Shutdown()
-{
- mTable = nullptr;
- AccessibleWrap::Shutdown();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// nsIAccessibleTable
+// Table
uint32_t
ARIAGridAccessible::ColCount()
{
AccIterator rowIter(this, filters::GetRow);
Accessible* row = rowIter.Next();
if (!row)
return 0;
@@ -400,38 +385,16 @@ ARIAGridAccessible::UnselectCol(uint32_t
if (cell)
SetARIASelected(cell, false);
}
}
////////////////////////////////////////////////////////////////////////////////
// Protected
-bool
-ARIAGridAccessible::IsValidRow(int32_t aRow)
-{
- if (aRow < 0)
- return false;
-
- int32_t rowCount = 0;
- GetRowCount(&rowCount);
- return aRow < rowCount;
-}
-
-bool
-ARIAGridAccessible::IsValidColumn(int32_t aColumn)
-{
- if (aColumn < 0)
- return false;
-
- int32_t colCount = 0;
- GetColumnCount(&colCount);
- return aColumn < colCount;
-}
-
Accessible*
ARIAGridAccessible::GetRowAt(int32_t aRow)
{
int32_t rowIdx = aRow;
AccIterator rowIter(this, filters::GetRow);
Accessible* row = rowIter.Next();
@@ -527,30 +490,25 @@ ARIAGridAccessible::SetARIASelected(Acce
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Constructor
ARIAGridCellAccessible::
ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
+ HyperTextAccessibleWrap(aContent, aDoc)
{
mGenericTypes |= eTableCell;
}
-////////////////////////////////////////////////////////////////////////////////
-// nsISupports
-
-NS_IMPL_ISUPPORTS_INHERITED(ARIAGridCellAccessible,
- HyperTextAccessible,
- nsIAccessibleTableCell)
+NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridCellAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
-// nsIAccessibleTableCell
+// TableCell
TableAccessible*
ARIAGridCellAccessible::Table() const
{
Accessible* table = TableFor(Row());
return table ? table->AsTable() : nullptr;
}
@@ -643,15 +601,8 @@ ARIAGridCellAccessible::NativeAttributes
int32_t rowIdx = RowIndexFor(thisRow);
nsAutoString stringIdx;
stringIdx.AppendInt(rowIdx * colCount + colIdx);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
return attributes.forget();
}
-
-void
-ARIAGridCellAccessible::Shutdown()
-{
- mTableCell = nullptr;
- HyperTextAccessibleWrap::Shutdown();
-}
--- a/accessible/generic/ARIAGridAccessible.h
+++ b/accessible/generic/ARIAGridAccessible.h
@@ -1,47 +1,36 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_A11Y_ARIAGridAccessible_h_
#define MOZILLA_A11Y_ARIAGridAccessible_h_
-#include "nsIAccessibleTable.h"
-
#include "HyperTextAccessibleWrap.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
-#include "xpcAccessibleTable.h"
-#include "xpcAccessibleTableCell.h"
namespace mozilla {
namespace a11y {
/**
* Accessible for ARIA grid and treegrid.
*/
class ARIAGridAccessible : public AccessibleWrap,
- public xpcAccessibleTable,
- public nsIAccessibleTable,
public TableAccessible
{
public:
ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc);
- // nsISupports
NS_DECL_ISUPPORTS_INHERITED
- // nsIAccessibleTable
- NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
-
// Accessible
virtual TableAccessible* AsTable() { return this; }
- virtual void Shutdown();
// TableAccessible
virtual uint32_t ColCount();
virtual uint32_t RowCount();
virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
virtual bool IsColSelected(uint32_t aColIdx);
virtual bool IsRowSelected(uint32_t aRowIdx);
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx);
@@ -57,26 +46,16 @@ public:
virtual void UnselectCol(uint32_t aColIdx);
virtual void UnselectRow(uint32_t aRowIdx);
virtual Accessible* AsAccessible() { return this; }
protected:
virtual ~ARIAGridAccessible() {}
/**
- * Return true if the given row index is valid.
- */
- bool IsValidRow(int32_t aRow);
-
- /**
- * Retrn true if the given column index is valid.
- */
- bool IsValidColumn(int32_t aColumn);
-
- /**
* Return row accessible at the given row index.
*/
Accessible* GetRowAt(int32_t aRow);
/**
* Return cell accessible at the given column index in the row.
*/
Accessible* GetCellInRowAt(Accessible* aRow, int32_t aColumn);
@@ -93,32 +72,25 @@ protected:
bool aNotify = true);
};
/**
* Accessible for ARIA gridcell and rowheader/columnheader.
*/
class ARIAGridCellAccessible : public HyperTextAccessibleWrap,
- public nsIAccessibleTableCell,
- public TableCellAccessible,
- public xpcAccessibleTableCell
+ public TableCellAccessible
{
public:
ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
- // nsISupports
NS_DECL_ISUPPORTS_INHERITED
- // nsIAccessibleTableCell
- NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
-
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
- virtual void Shutdown();
virtual void ApplyARIAState(uint64_t* aState) const;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
protected:
virtual ~ARIAGridCellAccessible() {}
/**
* Return a containing row.
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -89,24 +89,20 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// Accessible: nsISupports and cycle collection
NS_IMPL_CYCLE_COLLECTION(Accessible,
mContent, mParent, mChildren)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Accessible)
- NS_INTERFACE_MAP_ENTRY(nsIAccessible)
if (aIID.Equals(NS_GET_IID(Accessible)))
- foundInterface = static_cast<nsIAccessible*>(this);
+ foundInterface = this;
else
- NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleSelectable, IsSelect())
- NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleValue, HasNumericValue())
- NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperLink, IsLink())
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessible)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, Accessible)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(Accessible)
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(Accessible, LastRelease())
Accessible::Accessible(nsIContent* aContent, DocAccessible* aDoc) :
mContent(aContent), mDoc(aDoc),
mParent(nullptr), mIndexInParent(-1), mChildrenFlags(eChildrenUninitialized),
@@ -920,17 +916,17 @@ Accessible::NativeAttributes()
nsAutoString unused;
// We support values, so expose the string value as well, via the valuetext
// object attribute. We test for the value interface because we don't want
// to expose traditional Value() information such as URL's on links and
// documents, or text in an input.
if (HasNumericValue()) {
nsAutoString valuetext;
- GetValue(valuetext);
+ Value(valuetext);
attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext,
unused);
}
// Expose checkable object attribute if the accessible has checkable state
if (State() & states::CHECKABLE) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable,
NS_LITERAL_STRING("true"));
@@ -1713,20 +1709,19 @@ Accessible::RelationByType(RelationType
case RelationType::CONTAINING_APPLICATION:
return Relation(ApplicationAcc());
default:
return Relation();
}
}
-/* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
-NS_IMETHODIMP Accessible::GetNativeInterface(void **aOutAccessible)
+void
+Accessible::GetNativeInterface(void** aNativeAccessible)
{
- return NS_ERROR_NOT_IMPLEMENTED;
}
void
Accessible::DoCommand(nsIContent *aContent, uint32_t aActionIndex)
{
class Runnable MOZ_FINAL : public nsRunnable
{
public:
@@ -2199,29 +2194,23 @@ Accessible::AnchorURIAt(uint32_t aAnchor
NS_PRECONDITION(IsLink(), "AnchorURIAt is called on not hyper link!");
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// SelectAccessible
-already_AddRefed<nsIArray>
-Accessible::SelectedItems()
+void
+Accessible::SelectedItems(nsTArray<Accessible*>* aItems)
{
- nsCOMPtr<nsIMutableArray> selectedItems = do_CreateInstance(NS_ARRAY_CONTRACTID);
- if (!selectedItems)
- return nullptr;
-
AccIterator iter(this, filters::GetSelected);
- nsIAccessible* selected = nullptr;
+ Accessible* selected = nullptr;
while ((selected = iter.Next()))
- selectedItems->AppendElement(selected, false);
-
- return selectedItems.forget();
+ aItems->AppendElement(selected);
}
uint32_t
Accessible::SelectedItemCount()
{
uint32_t count = 0;
AccIterator iter(this, filters::GetSelected);
Accessible* selected = nullptr;
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -6,41 +6,37 @@
#ifndef _Accessible_H_
#define _Accessible_H_
#include "mozilla/a11y/AccTypes.h"
#include "mozilla/a11y/RelationType.h"
#include "mozilla/a11y/Role.h"
#include "mozilla/a11y/States.h"
-#include "xpcAccessible.h"
-#include "xpcAccessibleHyperLink.h"
-#include "nsIAccessibleStates.h"
-#include "xpcAccessibleSelectable.h"
-#include "xpcAccessibleValue.h"
-
#include "nsIContent.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsRefPtrHashtable.h"
struct nsRoleMapEntry;
struct nsRect;
class nsIFrame;
class nsIAtom;
struct nsIntRect;
+class nsIPersistentProperties;
class nsView;
namespace mozilla {
namespace a11y {
class Accessible;
class AccEvent;
class AccGroupInfo;
+class ApplicationAccessible;
class DocAccessible;
class EmbeddedObjCollector;
class HTMLImageMapAccessible;
class HTMLLIAccessible;
class HyperTextAccessible;
class ImageAccessible;
class KeyBinding;
class Relation;
@@ -118,32 +114,26 @@ typedef nsRefPtrHashtable<nsPtrHashKey<c
#define NS_ACCESSIBLE_IMPL_IID \
{ /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */ \
0x133c8bf4, \
0x4913, \
0x4355, \
{ 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad } \
}
-class Accessible : public xpcAccessible,
- public xpcAccessibleHyperLink,
- public xpcAccessibleSelectable,
- public xpcAccessibleValue
+class Accessible : public nsISupports
{
public:
Accessible(nsIContent* aContent, DocAccessible* aDoc);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
+ NS_DECL_CYCLE_COLLECTION_CLASS(Accessible)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
- // nsIAccessible
- NS_IMETHOD GetNativeInterface(void** aOutAccessible);
-
//////////////////////////////////////////////////////////////////////////////
// Public methods
/**
* Return the document accessible for this accessible.
*/
DocAccessible* Document() const { return mDoc; }
@@ -190,16 +180,21 @@ public:
virtual void Description(nsString& aDescription);
/**
* Get the value of this accessible.
*/
virtual void Value(nsString& aValue);
/**
+ * Get help string for the accessible.
+ */
+ void Help(nsString& aHelp) const { aHelp.Truncate(); }
+
+ /**
* Get the name of this accessible.
*
* Note: aName.IsVoid() when name was left empty by the author on purpose.
* aName.IsEmpty() when the author missed name, AT can try to repair a name.
*/
virtual ENameValueFlag Name(nsString& aName);
/**
@@ -529,16 +524,21 @@ public:
virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const;
/**
* Selects the accessible within its container if applicable.
*/
virtual void SetSelected(bool aSelect);
/**
+ * Extend selection to this accessible.
+ */
+ void ExtendSelection() { };
+
+ /**
* Select the accessible within its container.
*/
void TakeSelection();
/**
* Focus the accessible.
*/
virtual void TakeFocus();
@@ -548,26 +548,33 @@ public:
*/
void ScrollTo(uint32_t aHow) const;
/**
* Scroll the accessible to the given point.
*/
void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
+ /**
+ * Get a pointer to accessibility interface for this node, which is specific
+ * to the OS/accessibility toolkit we're running on.
+ */
+ virtual void GetNativeInterface(void** aNativeAccessible);
+
//////////////////////////////////////////////////////////////////////////////
// Downcasting and types
inline bool IsAbbreviation() const
{
return mContent->IsHTML() &&
(mContent->Tag() == nsGkAtoms::abbr || mContent->Tag() == nsGkAtoms::acronym);
}
bool IsApplication() const { return mType == eApplicationType; }
+ ApplicationAccessible* AsApplication();
bool IsAutoComplete() const { return HasGenericType(eAutoComplete); }
bool IsAutoCompletePopup() const
{ return HasGenericType(eAutoCompletePopup); }
bool IsButton() const { return HasGenericType(eButton); }
@@ -729,17 +736,17 @@ public:
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
//////////////////////////////////////////////////////////////////////////////
// SelectAccessible
/**
* Return an array of selected items.
*/
- virtual already_AddRefed<nsIArray> SelectedItems();
+ virtual void SelectedItems(nsTArray<Accessible*>* aItems);
/**
* Return the number of selected items.
*/
virtual uint32_t SelectedItemCount();
/**
* Return selected item at the given index.
--- a/accessible/generic/ApplicationAccessible.cpp
+++ b/accessible/generic/ApplicationAccessible.cpp
@@ -25,21 +25,17 @@ using namespace mozilla::a11y;
ApplicationAccessible::ApplicationAccessible() :
AccessibleWrap(nullptr, nullptr)
{
mType = eApplicationType;
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
}
-////////////////////////////////////////////////////////////////////////////////
-// nsISupports
-
-NS_IMPL_ISUPPORTS_INHERITED(ApplicationAccessible, Accessible,
- nsIAccessibleApplication)
+NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
ENameValueFlag
ApplicationAccessible::Name(nsString& aName)
{
aName.Truncate();
--- a/accessible/generic/ApplicationAccessible.h
+++ b/accessible/generic/ApplicationAccessible.h
@@ -4,17 +4,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_ApplicationAccessible_h__
#define mozilla_a11y_ApplicationAccessible_h__
#include "AccessibleWrap.h"
-#include "xpcAccessibleApplication.h"
#include "nsIMutableArray.h"
#include "nsIXULAppInfo.h"
namespace mozilla {
namespace a11y {
/**
@@ -22,24 +21,22 @@ namespace a11y {
* Only one instance of ApplicationAccessible exists for one Mozilla instance.
* And this one should be created when Mozilla Startup (if accessibility
* feature has been enabled) and destroyed when Mozilla Shutdown.
*
* All the accessibility objects for toplevel windows are direct children of
* the ApplicationAccessible instance.
*/
-class ApplicationAccessible : public AccessibleWrap,
- public xpcAccessibleApplication
+class ApplicationAccessible : public AccessibleWrap
{
public:
ApplicationAccessible();
- // nsISupports
NS_DECL_ISUPPORTS_INHERITED
// Accessible
virtual void Shutdown();
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
virtual GroupPos GroupPosition();
virtual ENameValueFlag Name(nsString& aName);
@@ -94,13 +91,19 @@ protected:
virtual void CacheChildren();
virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
nsresult *aError = nullptr) const;
private:
nsCOMPtr<nsIXULAppInfo> mAppInfo;
};
+inline ApplicationAccessible*
+Accessible::AsApplication()
+{
+ return IsApplication() ? static_cast<ApplicationAccessible*>(this) : nullptr;
+}
+
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/generic/BaseAccessibles.cpp
+++ b/accessible/generic/BaseAccessibles.cpp
@@ -164,18 +164,17 @@ LinkableAccessible::Shutdown()
////////////////////////////////////////////////////////////////////////////////
// LinkableAccessible: HyperLinkAccessible
already_AddRefed<nsIURI>
LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex)
{
if (mIsLink) {
- NS_ASSERTION(mActionAcc->IsLink(),
- "nsIAccessibleHyperLink isn't implemented.");
+ NS_ASSERTION(mActionAcc->IsLink(), "HyperLink isn't implemented.");
if (mActionAcc->IsLink())
return mActionAcc->AnchorURIAt(aAnchorIndex);
}
return nullptr;
}
--- a/accessible/generic/BaseAccessibles.h
+++ b/accessible/generic/BaseAccessibles.h
@@ -113,22 +113,25 @@ protected:
/**
* A wrapper accessible around native accessible to connect it with
* crossplatform accessible tree.
*/
class DummyAccessible : public AccessibleWrap
{
public:
- DummyAccessible() : AccessibleWrap(nullptr, nullptr) { }
- virtual ~DummyAccessible() { }
+ DummyAccessible(DocAccessible* aDocument = nullptr) :
+ AccessibleWrap(nullptr, aDocument) { }
virtual uint64_t NativeState() MOZ_OVERRIDE MOZ_FINAL;
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE MOZ_FINAL;
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE MOZ_FINAL;
virtual bool NativelyUnavailable() const MOZ_OVERRIDE MOZ_FINAL;
virtual void ApplyARIAState(uint64_t* aState) const MOZ_OVERRIDE MOZ_FINAL;
+
+protected:
+ virtual ~DummyAccessible() { }
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -11,16 +11,17 @@
#include "nsAccCache.h"
#include "nsAccessiblePivot.h"
#include "nsAccUtils.h"
#include "nsEventShell.h"
#include "nsTextEquivUtils.h"
#include "Role.h"
#include "RootAccessible.h"
#include "TreeWalker.h"
+#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsICommandManager.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsIDOMAttr.h"
#include "nsIDOMCharacterData.h"
#include "nsIDOMDocument.h"
@@ -71,17 +72,17 @@ static nsIAtom** kRelationAttrs[] =
static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);
////////////////////////////////////////////////////////////////////////////////
// Constructor/desctructor
DocAccessible::
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell) :
- HyperTextAccessibleWrap(aRootContent, this), xpcAccessibleDocument(),
+ HyperTextAccessibleWrap(aRootContent, this),
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessibleCache(kDefaultCacheLength),
mNodeToAccessibleMap(kDefaultCacheLength),
mDocumentNode(aDocument),
mScrollPositionChangedTicks(0),
mLoadState(eTreeConstructionPending), mDocFlags(0), mLoadEventType(0),
mVirtualCursor(nullptr),
mPresShell(aPresShell), mIPCDoc(nullptr)
@@ -123,43 +124,22 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChildDocuments)
tmp->mDependentIDsHash.Clear();
tmp->mNodeToAccessibleMap.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAccessibleCache)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAnchorJumpElm)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DocAccessible)
- NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIAccessiblePivotObserver)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleDocument)
- foundInterface = 0;
-
- nsresult status;
- if (!foundInterface) {
- // HTML document accessible must inherit from HyperTextAccessible to get
- // support text interfaces. XUL document accessible doesn't need this.
- // However at some point we may push <body> to implement the interfaces and
- // return DocAccessible to inherit from AccessibleWrap.
-
- status = IsHyperText() ?
- HyperTextAccessible::QueryInterface(aIID, (void**)&foundInterface) :
- Accessible::QueryInterface(aIID, (void**)&foundInterface);
- } else {
- NS_ADDREF(foundInterface);
- status = NS_OK;
- }
-
- *aInstancePtr = foundInterface;
- return status;
-}
+NS_INTERFACE_MAP_END_INHERITING(HyperTextAccessible)
NS_IMPL_ADDREF_INHERITED(DocAccessible, HyperTextAccessible)
NS_IMPL_RELEASE_INHERITED(DocAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
ENameValueFlag
@@ -495,17 +475,17 @@ DocAccessible::Shutdown()
// We're about to get rid of all of our children so there won't be anything
// to invalidate.
AutoTreeMutation mut(this, false);
ClearCache(mAccessibleCache);
}
HyperTextAccessibleWrap::Shutdown();
- GetAccService()->NotifyOfDocumentShutdown(kungFuDeathGripDoc);
+ GetAccService()->NotifyOfDocumentShutdown(this, kungFuDeathGripDoc);
}
nsIFrame*
DocAccessible::GetFrame() const
{
nsIFrame* root = nullptr;
if (mPresShell)
root = mPresShell->GetRootFrame();
@@ -685,19 +665,21 @@ DocAccessible::Observe(nsISupports* aSub
NS_IMETHODIMP
DocAccessible::OnPivotChanged(nsIAccessiblePivot* aPivot,
nsIAccessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
PivotMoveReason aReason,
bool aIsFromUserInput)
{
- nsRefPtr<AccEvent> event = new AccVCChangeEvent(
- this, aOldAccessible, aOldStart, aOldEnd, aReason,
- aIsFromUserInput ? eFromUserInput : eNoUserInput);
+ nsRefPtr<AccEvent> event =
+ new AccVCChangeEvent(
+ this, (aOldAccessible ? aOldAccessible->ToInternalAccessible() : nullptr),
+ aOldStart, aOldEnd, aReason,
+ aIsFromUserInput ? eFromUserInput : eNoUserInput);
nsEventShell::FireEvent(event);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIDocumentObserver
@@ -1260,16 +1242,21 @@ DocAccessible::UnbindFromDocument(Access
#endif
}
// Remove an accessible from node-to-accessible map if it exists there.
if (aAccessible->IsNodeMapEntry() &&
mNodeToAccessibleMap.Get(aAccessible->GetNode()) == aAccessible)
mNodeToAccessibleMap.Remove(aAccessible->GetNode());
+ // Update XPCOM part.
+ xpcAccessibleDocument* xpcDoc = GetAccService()->GetCachedXPCDocument(this);
+ if (xpcDoc)
+ xpcDoc->NotifyOfShutdown(aAccessible);
+
void* uniqueID = aAccessible->UniqueID();
NS_ASSERTION(!aAccessible->IsDefunct(), "Shutdown the shutdown accessible!");
aAccessible->Shutdown();
mAccessibleCache.Remove(uniqueID);
}
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_DocAccessible_h__
#define mozilla_a11y_DocAccessible_h__
-#include "xpcAccessibleDocument.h"
#include "nsIAccessiblePivot.h"
#include "AccEvent.h"
#include "HyperTextAccessibleWrap.h"
#include "nsClassHashtable.h"
#include "nsDataHashtable.h"
#include "nsIDocument.h"
@@ -34,28 +33,26 @@ namespace a11y {
class DocManager;
class NotificationController;
class DocAccessibleChild;
class RelatedAccIterator;
template<class Class, class Arg>
class TNotification;
class DocAccessible : public HyperTextAccessibleWrap,
- public xpcAccessibleDocument,
public nsIDocumentObserver,
public nsIObserver,
public nsIScrollPositionListener,
public nsSupportsWeakReference,
public nsIAccessiblePivotObserver
{
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocAccessible, Accessible)
NS_DECL_NSIOBSERVER
-
NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
public:
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell);
// nsIScrollPositionListener
--- a/accessible/generic/FormControlAccessible.cpp
+++ b/accessible/generic/FormControlAccessible.cpp
@@ -18,30 +18,16 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// ProgressMeterAccessible
////////////////////////////////////////////////////////////////////////////////
template class mozilla::a11y::ProgressMeterAccessible<1>;
template class mozilla::a11y::ProgressMeterAccessible<100>;
////////////////////////////////////////////////////////////////////////////////
-// nsISupports
-
-template<int Max>
-NS_IMPL_ADDREF_INHERITED(ProgressMeterAccessible<Max>, LeafAccessible)
-
-template<int Max>
-NS_IMPL_RELEASE_INHERITED(ProgressMeterAccessible<Max>, LeafAccessible)
-
-template<int Max>
-NS_IMPL_QUERY_INTERFACE_INHERITED(ProgressMeterAccessible<Max>,
- LeafAccessible,
- nsIAccessibleValue)
-
-////////////////////////////////////////////////////////////////////////////////
// Accessible
template<int Max>
role
ProgressMeterAccessible<Max>::NativeRole()
{
return roles::PROGRESSBAR;
}
@@ -68,17 +54,17 @@ ProgressMeterAccessible<Max>::NativeStat
template<int Max>
bool
ProgressMeterAccessible<Max>::IsWidget() const
{
return true;
}
////////////////////////////////////////////////////////////////////////////////
-// nsIAccessibleValue
+// ProgressMeterAccessible<Max>: Value
template<int Max>
void
ProgressMeterAccessible<Max>::Value(nsString& aValue)
{
LeafAccessible::Value(aValue);
if (!aValue.IsEmpty())
return;
--- a/accessible/generic/FormControlAccessible.h
+++ b/accessible/generic/FormControlAccessible.h
@@ -22,18 +22,16 @@ public:
LeafAccessible(aContent, aDoc)
{
// Ignore 'ValueChange' DOM event in lieu of @value attribute change
// notifications.
mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
mType = eProgressType;
}
- NS_DECL_ISUPPORTS_INHERITED
-
// Accessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
// Value
virtual double MaxValue() const MOZ_OVERRIDE;
virtual double MinValue() const MOZ_OVERRIDE;
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -43,29 +43,22 @@ using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// HyperTextAccessible
////////////////////////////////////////////////////////////////////////////////
HyperTextAccessible::
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
- AccessibleWrap(aNode, aDoc), xpcAccessibleHyperText()
+ AccessibleWrap(aNode, aDoc)
{
mGenericTypes |= eHyperText;
}
-nsresult
-HyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
- xpcAccessibleHyperText::QueryInterface(aIID, aInstancePtr);
- return *aInstancePtr ? NS_OK : Accessible::QueryInterface(aIID, aInstancePtr);
-}
-NS_IMPL_ADDREF_INHERITED(HyperTextAccessible, AccessibleWrap)
-NS_IMPL_RELEASE_INHERITED(HyperTextAccessible, AccessibleWrap)
+NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessible, Accessible)
role
HyperTextAccessible::NativeRole()
{
nsIAtom *tag = mContent->Tag();
if (tag == nsGkAtoms::dd)
return roles::DEFINITION;
@@ -644,22 +637,22 @@ HyperTextAccessible::TextBeforeOffset(in
return;
}
uint32_t adjustedOffset = convertedOffset;
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
switch (aBoundaryType) {
- case BOUNDARY_CHAR:
+ case nsIAccessibleText::BOUNDARY_CHAR:
if (convertedOffset != 0)
CharAt(convertedOffset - 1, aText, aStartOffset, aEndOffset);
break;
- case BOUNDARY_WORD_START: {
+ case nsIAccessibleText::BOUNDARY_WORD_START: {
// If the offset is a word start (except text length offset) then move
// backward to find a start offset (end offset is the given offset).
// Otherwise move backward twice to find both start and end offsets.
if (adjustedOffset == CharacterCount()) {
*aEndOffset = FindWordBoundary(adjustedOffset, eDirPrevious, eStartWord);
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
} else {
*aStartOffset = FindWordBoundary(adjustedOffset, eDirPrevious, eStartWord);
@@ -668,31 +661,31 @@ HyperTextAccessible::TextBeforeOffset(in
*aEndOffset = *aStartOffset;
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
}
}
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
}
- case BOUNDARY_WORD_END: {
+ case nsIAccessibleText::BOUNDARY_WORD_END: {
// Move word backward twice to find start and end offsets.
*aEndOffset = FindWordBoundary(convertedOffset, eDirPrevious, eEndWord);
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
}
- case BOUNDARY_LINE_START:
+ case nsIAccessibleText::BOUNDARY_LINE_START:
*aStartOffset = FindLineBoundary(adjustedOffset, ePrevLineBegin);
*aEndOffset = FindLineBoundary(adjustedOffset, eThisLineBegin);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_LINE_END: {
+ case nsIAccessibleText::BOUNDARY_LINE_END: {
*aEndOffset = FindLineBoundary(adjustedOffset, ePrevLineEnd);
int32_t tmpOffset = *aEndOffset;
// Adjust offset if line is wrapped.
if (*aEndOffset != 0 && !IsLineEndCharAt(*aEndOffset))
tmpOffset--;
*aStartOffset = FindLineBoundary(tmpOffset, ePrevLineEnd);
TextSubstring(*aStartOffset, *aEndOffset, aText);
@@ -712,53 +705,53 @@ HyperTextAccessible::TextAtOffset(int32_
uint32_t adjustedOffset = ConvertMagicOffset(aOffset);
if (adjustedOffset == std::numeric_limits<uint32_t>::max()) {
NS_ERROR("Wrong given offset!");
return;
}
switch (aBoundaryType) {
- case BOUNDARY_CHAR:
+ case nsIAccessibleText::BOUNDARY_CHAR:
// Return no char if caret is at the end of wrapped line (case of no line
// end character). Returning a next line char is confusing for AT.
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET && IsCaretAtEndOfLine())
*aStartOffset = *aEndOffset = adjustedOffset;
else
CharAt(adjustedOffset, aText, aStartOffset, aEndOffset);
break;
- case BOUNDARY_WORD_START:
+ case nsIAccessibleText::BOUNDARY_WORD_START:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
*aEndOffset = FindWordBoundary(adjustedOffset, eDirNext, eStartWord);
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_WORD_END:
+ case nsIAccessibleText::BOUNDARY_WORD_END:
// Ignore the spec and follow what WebKitGtk does because Orca expects it,
// i.e. return a next word at word end offset of the current word
// (WebKitGtk behavior) instead the current word (AKT spec).
*aEndOffset = FindWordBoundary(adjustedOffset, eDirNext, eEndWord);
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_LINE_START:
+ case nsIAccessibleText::BOUNDARY_LINE_START:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
*aStartOffset = FindLineBoundary(adjustedOffset, eThisLineBegin);
*aEndOffset = FindLineBoundary(adjustedOffset, eNextLineBegin);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_LINE_END:
+ case nsIAccessibleText::BOUNDARY_LINE_END:
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
// In contrast to word end boundary we follow the spec here.
*aStartOffset = FindLineBoundary(adjustedOffset, ePrevLineEnd);
*aEndOffset = FindLineBoundary(adjustedOffset, eThisLineEnd);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
@@ -780,33 +773,33 @@ HyperTextAccessible::TextAfterOffset(int
return;
}
uint32_t adjustedOffset = convertedOffset;
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
adjustedOffset = AdjustCaretOffset(adjustedOffset);
switch (aBoundaryType) {
- case BOUNDARY_CHAR:
+ case nsIAccessibleText::BOUNDARY_CHAR:
// If caret is at the end of wrapped line (case of no line end character)
// then char after the offset is a first char at next line.
if (adjustedOffset >= CharacterCount())
*aStartOffset = *aEndOffset = CharacterCount();
else
CharAt(adjustedOffset + 1, aText, aStartOffset, aEndOffset);
break;
- case BOUNDARY_WORD_START:
+ case nsIAccessibleText::BOUNDARY_WORD_START:
// Move word forward twice to find start and end offsets.
*aStartOffset = FindWordBoundary(adjustedOffset, eDirNext, eStartWord);
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_WORD_END:
+ case nsIAccessibleText::BOUNDARY_WORD_END:
// If the offset is a word end (except 0 offset) then move forward to find
// end offset (start offset is the given offset). Otherwise move forward
// twice to find both start and end offsets.
if (convertedOffset == 0) {
*aStartOffset = FindWordBoundary(convertedOffset, eDirNext, eEndWord);
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
} else {
*aEndOffset = FindWordBoundary(convertedOffset, eDirNext, eEndWord);
@@ -814,23 +807,23 @@ HyperTextAccessible::TextAfterOffset(int
if (*aStartOffset != static_cast<int32_t>(convertedOffset)) {
*aStartOffset = *aEndOffset;
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
}
}
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_LINE_START:
+ case nsIAccessibleText::BOUNDARY_LINE_START:
*aStartOffset = FindLineBoundary(adjustedOffset, eNextLineBegin);
*aEndOffset = FindLineBoundary(*aStartOffset, eNextLineBegin);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
- case BOUNDARY_LINE_END:
+ case nsIAccessibleText::BOUNDARY_LINE_END:
*aStartOffset = FindLineBoundary(adjustedOffset, eThisLineEnd);
*aEndOffset = FindLineBoundary(adjustedOffset, eNextLineEnd);
TextSubstring(*aStartOffset, *aEndOffset, aText);
break;
}
}
already_AddRefed<nsIPersistentProperties>
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -2,18 +2,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_HyperTextAccessible_h__
#define mozilla_a11y_HyperTextAccessible_h__
#include "AccessibleWrap.h"
+#include "nsIAccessibleText.h"
#include "nsIAccessibleTypes.h"
-#include "xpcAccessibleHyperText.h"
#include "nsDirection.h"
#include "WordMovementType.h"
#include "nsIFrame.h"
#include "nsISelectionController.h"
class nsFrameSelection;
class nsRange;
@@ -32,27 +32,26 @@ class TextRange;
struct DOMPoint {
DOMPoint() : node(nullptr), idx(0) { }
DOMPoint(nsINode* aNode, int32_t aIdx) : node(aNode), idx(aIdx) { }
nsINode* node;
int32_t idx;
};
-// This character marks where in the text returned via nsIAccessibleText(),
+// This character marks where in the text returned via Text interface,
// that embedded object characters exist
const char16_t kEmbeddedObjectChar = 0xfffc;
const char16_t kImaginaryEmbeddedObjectChar = ' ';
const char16_t kForcedNewLineChar = '\n';
/**
* Special Accessible that knows how contain both text and embedded objects
*/
-class HyperTextAccessible : public AccessibleWrap,
- public xpcAccessibleHyperText
+class HyperTextAccessible : public AccessibleWrap
{
public:
HyperTextAccessible(nsIContent* aContent, DocAccessible* aDoc);
NS_DECL_ISUPPORTS_INHERITED
// Accessible
virtual int32_t GetLevelInternal();
--- a/accessible/generic/ImageAccessible.cpp
+++ b/accessible/generic/ImageAccessible.cpp
@@ -34,19 +34,16 @@ ImageAccessible::
{
mType = eImageType;
}
ImageAccessible::~ImageAccessible()
{
}
-NS_IMPL_ISUPPORTS_INHERITED(ImageAccessible, Accessible,
- nsIAccessibleImage)
-
////////////////////////////////////////////////////////////////////////////////
// Accessible public
uint64_t
ImageAccessible::NativeState()
{
// The state is a bitfield, get our inherited state, then logically OR it with
// states::ANIMATED if this is an animated image.
@@ -95,17 +92,17 @@ ImageAccessible::NativeName(nsString& aN
role
ImageAccessible::NativeRole()
{
return roles::GRAPHIC;
}
////////////////////////////////////////////////////////////////////////////////
-// nsIAccessible
+// Accessible
uint8_t
ImageAccessible::ActionCount()
{
uint8_t actionCount = LinkableAccessible::ActionCount();
return HasLongDesc() ? actionCount + 1 : actionCount;
}
--- a/accessible/generic/ImageAccessible.h
+++ b/accessible/generic/ImageAccessible.h
@@ -2,37 +2,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_ImageAccessible_h__
#define mozilla_a11y_ImageAccessible_h__
#include "BaseAccessibles.h"
-#include "xpcAccessibleImage.h"
class nsGenericHTMLElement;
namespace mozilla {
namespace a11y {
/* Accessible for supporting images
* supports:
* - gets name, role
* - support basic state
*/
-class ImageAccessible : public LinkableAccessible,
- public xpcAccessibleImage
+class ImageAccessible : public LinkableAccessible
{
public:
ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
- // nsISupports
- NS_DECL_ISUPPORTS_INHERITED
-
// Accessible
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
// ActionAccessible
virtual uint8_t ActionCount() MOZ_OVERRIDE;
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
--- a/accessible/generic/RootAccessible.cpp
+++ b/accessible/generic/RootAccessible.cpp
@@ -20,17 +20,16 @@
#include "Role.h"
#include "States.h"
#ifdef MOZ_XUL
#include "XULTreeAccessible.h"
#endif
#include "mozilla/dom/Element.h"
-#include "nsIAccessibleRelation.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/EventTarget.h"
#include "nsIDOMCustomEvent.h"
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestorUtils.h"
@@ -48,17 +47,17 @@
using namespace mozilla;
using namespace mozilla::a11y;
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
-NS_IMPL_ISUPPORTS_INHERITED(RootAccessible, DocAccessible, nsIAccessibleDocument)
+NS_IMPL_ISUPPORTS_INHERITED0(RootAccessible, DocAccessible)
////////////////////////////////////////////////////////////////////////////////
// Constructor/destructor
RootAccessible::
RootAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell) :
DocAccessibleWrap(aDocument, aRootContent, aPresShell)
@@ -472,17 +471,16 @@ RootAccessible::Shutdown()
{
// Called manually or by Accessible::LastRelease()
if (!PresShell())
return; // Already shutdown
DocAccessibleWrap::Shutdown();
}
-// nsIAccessible method
Relation
RootAccessible::RelationByType(RelationType aType)
{
if (!mDocumentNode || aType != RelationType::EMBEDS)
return DocAccessibleWrap::RelationByType(aType);
nsIDOMWindow* rootWindow = mDocumentNode->GetWindow();
if (rootWindow) {
--- a/accessible/html/HTMLElementAccessibles.cpp
+++ b/accessible/html/HTMLElementAccessibles.cpp
@@ -2,17 +2,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLElementAccessibles.h"
#include "DocAccessible.h"
#include "nsAccUtils.h"
-#include "nsIAccessibleRelation.h"
#include "nsIPersistentProperties2.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "mozilla/dom/HTMLLabelElement.h"
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -10,17 +10,16 @@
#include "nsEventShell.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "nsContentList.h"
#include "mozilla/dom/HTMLInputElement.h"
-#include "nsIAccessibleRelation.h"
#include "nsIDOMNSEditableElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIEditor.h"
#include "nsIFormControl.h"
#include "nsIPersistentProperties2.h"
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h"
@@ -279,20 +278,18 @@ HTMLButtonAccessible::IsWidget() const
HTMLTextFieldAccessible::
HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc)
{
mType = eHTMLTextFieldType;
}
-NS_IMPL_ISUPPORTS_INHERITED(HTMLTextFieldAccessible,
- Accessible,
- nsIAccessibleText,
- nsIAccessibleEditableText)
+NS_IMPL_ISUPPORTS_INHERITED0(HTMLTextFieldAccessible,
+ HyperTextAccessible)
role
HTMLTextFieldAccessible::NativeRole()
{
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::password, eIgnoreCase)) {
return roles::PASSWORD_TEXT;
}
--- a/accessible/html/HTMLImageMapAccessible.cpp
+++ b/accessible/html/HTMLImageMapAccessible.cpp
@@ -170,27 +170,27 @@ HTMLAreaAccessible::
HTMLLinkAccessible(aContent, aDoc)
{
// Make HTML area DOM element not accessible. HTML image map accessible
// manages its tree itself.
mStateFlags |= eNotNodeMapEntry;
}
////////////////////////////////////////////////////////////////////////////////
-// HTMLAreaAccessible: nsIAccessible
+// HTMLAreaAccessible: Accessible
ENameValueFlag
HTMLAreaAccessible::NativeName(nsString& aName)
{
ENameValueFlag nameFlag = Accessible::NativeName(aName);
if (!aName.IsEmpty())
return nameFlag;
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
- GetValue(aName);
+ Value(aName);
return eNameOK;
}
void
HTMLAreaAccessible::Description(nsString& aDescription)
{
aDescription.Truncate();
--- a/accessible/html/HTMLLinkAccessible.cpp
+++ b/accessible/html/HTMLLinkAccessible.cpp
@@ -22,19 +22,17 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
HTMLLinkAccessible::
HTMLLinkAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc)
{
}
-// Expose nsIAccessibleHyperLink unconditionally
-NS_IMPL_ISUPPORTS_INHERITED(HTMLLinkAccessible, HyperTextAccessibleWrap,
- nsIAccessibleHyperLink)
+NS_IMPL_ISUPPORTS_INHERITED0(HTMLLinkAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessible
role
HTMLLinkAccessible::NativeRole()
{
return roles::LINK;
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -5,17 +5,16 @@
#include "HTMLSelectAccessible.h"
#include "Accessible-inl.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "DocAccessible.h"
#include "nsEventShell.h"
-#include "nsIAccessibleEvent.h"
#include "nsTextEquivUtils.h"
#include "Role.h"
#include "States.h"
#include "nsCOMPtr.h"
#include "mozilla/dom/HTMLOptionElement.h"
#include "nsIComboboxControlFrame.h"
#include "nsContainerFrame.h"
@@ -388,18 +387,17 @@ HTMLComboboxAccessible::CacheChildren()
if (!comboFrame)
return;
nsIFrame* listFrame = comboFrame->GetDropDown();
if (!listFrame)
return;
if (!mListAccessible) {
- mListAccessible =
- new HTMLComboboxListAccessible(mParent, mContent, mDoc);
+ mListAccessible = new HTMLComboboxListAccessible(mParent, mContent, mDoc);
// Initialize and put into cache.
Document()->BindToDocument(mListAccessible, nullptr);
}
if (AppendChild(mListAccessible)) {
// Cache combobox option accessibles so that we build complete accessible
// tree for combobox.
@@ -554,17 +552,17 @@ HTMLComboboxAccessible::SelectedOption()
}
////////////////////////////////////////////////////////////////////////////////
// HTMLComboboxListAccessible
////////////////////////////////////////////////////////////////////////////////
HTMLComboboxListAccessible::
- HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
+ HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
DocAccessible* aDoc) :
HTMLSelectListAccessible(aContent, aDoc)
{
mStateFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLComboboxAccessible: Accessible
--- a/accessible/html/HTMLSelectAccessible.h
+++ b/accessible/html/HTMLSelectAccessible.h
@@ -204,17 +204,17 @@ private:
* A class that represents the window that lives to the right
* of the drop down button inside the Select. This is the window
* that is made visible when the button is pressed.
*/
class HTMLComboboxListAccessible : public HTMLSelectListAccessible
{
public:
- HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
+ HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent,
DocAccessible* aDoc);
virtual ~HTMLComboboxListAccessible() {}
// Accessible
virtual nsIFrame* GetFrame() const;
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
--- a/accessible/html/HTMLTableAccessible.cpp
+++ b/accessible/html/HTMLTableAccessible.cpp
@@ -6,17 +6,16 @@
#include "HTMLTableAccessible.h"
#include "mozilla/DebugOnly.h"
#include "Accessible-inl.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "DocAccessible.h"
-#include "nsIAccessibleRelation.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "TreeWalker.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "nsIDOMElement.h"
@@ -42,38 +41,26 @@ using namespace mozilla::dom;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessible
////////////////////////////////////////////////////////////////////////////////
HTMLTableCellAccessible::
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
+ HyperTextAccessibleWrap(aContent, aDoc)
{
mGenericTypes |= eTableCell;
}
-////////////////////////////////////////////////////////////////////////////////
-// HTMLTableCellAccessible: nsISupports implementation
-
-NS_IMPL_ISUPPORTS_INHERITED(HTMLTableCellAccessible,
- HyperTextAccessible,
- nsIAccessibleTableCell)
+NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableCellAccessible, HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessible: Accessible implementation
-void
-HTMLTableCellAccessible::Shutdown()
-{
- mTableCell = nullptr;
- HyperTextAccessibleWrap::Shutdown();
-}
-
role
HTMLTableCellAccessible::NativeRole()
{
return roles::CELL;
}
uint64_t
HTMLTableCellAccessible::NativeState()
@@ -141,17 +128,17 @@ HTMLTableCellAccessible::NativeAttribute
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::axis, axisText);
if (!axisText.IsEmpty())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::axis, axisText);
return attributes.forget();
}
////////////////////////////////////////////////////////////////////////////////
-// HTMLTableCellAccessible: nsIAccessibleTableCell implementation
+// HTMLTableCellAccessible: TableCellAccessible implementation
TableAccessible*
HTMLTableCellAccessible::Table() const
{
Accessible* parent = const_cast<HTMLTableCellAccessible*>(this);
while ((parent = parent->Parent())) {
roles::Role role = parent->Role();
if (role == roles::TABLE || role == roles::TREE_TABLE)
@@ -356,30 +343,22 @@ HTMLTableRowAccessible::NativeRole()
{
return roles::ROW;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible
////////////////////////////////////////////////////////////////////////////////
-NS_IMPL_ISUPPORTS_INHERITED(HTMLTableAccessible, Accessible,
- nsIAccessibleTable)
+NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible: Accessible
void
-HTMLTableAccessible::Shutdown()
-{
- mTable = nullptr;
- AccessibleWrap::Shutdown();
-}
-
-void
HTMLTableAccessible::CacheChildren()
{
// Move caption accessible so that it's the first child. Check for the first
// caption only, because nsAccessibilityService ensures we don't create
// accessibles for the other captions, since only the first is actually
// visible.
TreeWalker walker(this, mContent);
@@ -439,30 +418,30 @@ HTMLTableAccessible::NativeAttributes()
attributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"),
NS_LITERAL_STRING("true"), unused);
}
return attributes.forget();
}
////////////////////////////////////////////////////////////////////////////////
-// HTMLTableAccessible: nsIAccessible implementation
+// HTMLTableAccessible: Accessible
Relation
HTMLTableAccessible::RelationByType(RelationType aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType == RelationType::LABELLED_BY)
rel.AppendTarget(Caption());
return rel;
}
////////////////////////////////////////////////////////////////////////////////
-// HTMLTableAccessible: nsIAccessibleTable implementation
+// HTMLTableAccessible: Table
Accessible*
HTMLTableAccessible::Caption() const
{
Accessible* child = mChildren.SafeElementAt(0, nullptr);
return child && child->Role() == roles::CAPTION ? child : nullptr;
}
@@ -1008,28 +987,27 @@ HTMLTableAccessible::IsProbablyLayoutTab
}
}
if (HasDescendant(NS_LITERAL_STRING("table"))) {
RETURN_LAYOUT_ANSWER(true, "Has a nested table within it");
}
// If only 1 column or only 1 row, it's for layout
- int32_t columns, rows;
- GetColumnCount(&columns);
- if (columns <=1) {
+ uint32_t colCount = ColCount();
+ if (colCount <=1) {
RETURN_LAYOUT_ANSWER(true, "Has only 1 column");
}
- GetRowCount(&rows);
- if (rows <=1) {
+ uint32_t rowCount = RowCount();
+ if (rowCount <=1) {
RETURN_LAYOUT_ANSWER(true, "Has only 1 row");
}
// Check for many columns
- if (columns >= 5) {
+ if (colCount >= 5) {
RETURN_LAYOUT_ANSWER(false, ">=5 columns");
}
// Now we know there are 2-4 columns and 2 or more rows
// Check to see if there are visible borders on the cells
// XXX currently, we just check the first cell -- do we really need to do more?
nsTableOuterFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
if (!tableFrame)
@@ -1062,18 +1040,18 @@ HTMLTableAccessible::IsProbablyLayoutTab
rowColor = rowFrame->StyleBackground()->mBackgroundColor;
if (childIdx > 0 && prevRowColor != rowColor)
RETURN_LAYOUT_ANSWER(false, "2 styles of row background color, non-bordered");
}
}
// Check for many rows
- const int32_t kMaxLayoutRows = 20;
- if (rows > kMaxLayoutRows) { // A ton of rows, this is probably for data
+ const uint32_t kMaxLayoutRows = 20;
+ if (rowCount > kMaxLayoutRows) { // A ton of rows, this is probably for data
RETURN_LAYOUT_ANSWER(false, ">= kMaxLayoutRows (20) and non-bordered");
}
// Check for very wide table.
nsIFrame* documentFrame = Document()->GetFrame();
nsSize documentSize = documentFrame->GetSize();
if (documentSize.width > 0) {
nsSize tableSize = GetFrame()->GetSize();
@@ -1082,17 +1060,17 @@ HTMLTableAccessible::IsProbablyLayoutTab
// 3-4 columns, no borders, not a lot of rows, and 95% of the doc's width
// Probably for layout
RETURN_LAYOUT_ANSWER(true,
"<= 4 columns, table width is 95% of document width");
}
}
// Two column rules
- if (rows * columns <= 10) {
+ if (rowCount * colCount <= 10) {
RETURN_LAYOUT_ANSWER(true, "2-4 columns, 10 cells or less, non-bordered");
}
if (HasDescendant(NS_LITERAL_STRING("embed")) ||
HasDescendant(NS_LITERAL_STRING("object")) ||
HasDescendant(NS_LITERAL_STRING("applet")) ||
HasDescendant(NS_LITERAL_STRING("iframe"))) {
RETURN_LAYOUT_ANSWER(true, "Has no borders, and has iframe, object, applet or iframe, typical of advertisements");
--- a/accessible/html/HTMLTableAccessible.h
+++ b/accessible/html/HTMLTableAccessible.h
@@ -2,48 +2,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_HTMLTableAccessible_h__
#define mozilla_a11y_HTMLTableAccessible_h__
#include "HyperTextAccessibleWrap.h"
-#include "nsIAccessibleTable.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
-#include "xpcAccessibleTable.h"
-#include "xpcAccessibleTableCell.h"
class nsITableLayout;
class nsITableCellLayout;
namespace mozilla {
namespace a11y {
/**
* HTML table cell accessible (html:td).
*/
class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
- public nsIAccessibleTableCell,
- public TableCellAccessible,
- public xpcAccessibleTableCell
+ public TableCellAccessible
{
public:
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
- // nsIAccessibleTableCell
- NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
-
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
- virtual void Shutdown();
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
// TableCellAccessible
virtual TableAccessible* Table() const MOZ_OVERRIDE;
virtual uint32_t ColIdx() const MOZ_OVERRIDE;
@@ -53,21 +44,16 @@ public:
virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
virtual bool Selected() MOZ_OVERRIDE;
protected:
virtual ~HTMLTableCellAccessible() {}
/**
- * Return host table accessible.
- */
- already_AddRefed<nsIAccessibleTable> GetTableAccessible();
-
- /**
* Return nsITableCellLayout of the table cell frame.
*/
nsITableCellLayout* GetCellLayout() const;
/**
* Return row and column indices of the cell.
*/
nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const;
@@ -115,33 +101,28 @@ protected:
*/
// To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
// This allow release trunk builds to be used by testers to refine the
// data vs. layout heuristic
// #define SHOW_LAYOUT_HEURISTIC
class HTMLTableAccessible : public AccessibleWrap,
- public xpcAccessibleTable,
- public nsIAccessibleTable,
public TableAccessible
{
public:
HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
+ AccessibleWrap(aContent, aDoc)
{
mType = eHTMLTableType;
mGenericTypes |= eTable;
}
NS_DECL_ISUPPORTS_INHERITED
- // nsIAccessible Table
- NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
-
// TableAccessible
virtual Accessible* Caption() const;
virtual void Summary(nsString& aSummary);
virtual uint32_t ColCount();
virtual uint32_t RowCount();
virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx);
virtual int32_t ColIndexAt(uint32_t aCellIdx);
@@ -163,17 +144,16 @@ public:
virtual void SelectCol(uint32_t aColIdx);
virtual void SelectRow(uint32_t aRowIdx);
virtual void UnselectCol(uint32_t aColIdx);
virtual void UnselectRow(uint32_t aRowIdx);
virtual bool IsProbablyLayoutTable();
virtual Accessible* AsAccessible() { return this; }
// Accessible
- virtual void Shutdown();
virtual TableAccessible* AsTable() { return this; }
virtual void Description(nsString& aDescription);
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
protected:
@@ -224,21 +204,21 @@ protected:
/**
* HTML caption accessible (html:caption).
*/
class HTMLCaptionAccessible : public HyperTextAccessibleWrap
{
public:
HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc) { }
- virtual ~HTMLCaptionAccessible() { }
-
- // nsIAccessible
// Accessible
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
+
+protected:
+ virtual ~HTMLCaptionAccessible() { }
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/interfaces/nsIAccessibilityService.h
+++ b/accessible/interfaces/nsIAccessibilityService.h
@@ -21,20 +21,20 @@ class Accessible;
} // namespace mozilla
class nsINode;
class nsIContent;
class nsIFrame;
class nsIPresShell;
class nsPluginFrame;
-// 10ff6dca-b219-4b64-9a4c-67a62b86edce
+// 0e7e6879-854b-4260-bc6e-525b5fb5cf34
#define NS_IACCESSIBILITYSERVICE_IID \
-{ 0x84dd9182, 0x6639, 0x4377, \
- { 0xa4, 0x13, 0xad, 0xe1, 0xae, 0x4e, 0x52, 0xdd } }
+{ 0x0e7e6879, 0x854b, 0x4260, \
+ { 0xbc, 0x6e, 0x52, 0x5b, 0x5f, 0xb5, 0xcf, 0x34 } }
class nsIAccessibilityService : public nsIAccessibleRetrieval
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IACCESSIBILITYSERVICE_IID)
/**
* Return root document accessible that is or contains a document accessible
@@ -59,16 +59,21 @@ public:
/**
* Fire accessible event of the given type for the given target.
*
* @param aEvent [in] accessible event type
* @param aTarget [in] target of accessible event
*/
virtual void FireAccessibleEvent(uint32_t aEvent,
mozilla::a11y::Accessible* aTarget) = 0;
+
+ /**
+ * Return true if the given DOM node has accessible object.
+ */
+ virtual bool HasAccessible(nsIDOMNode* aDOMNode) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIAccessibilityService,
NS_IACCESSIBILITYSERVICE_IID)
// for component registration
// {DE401C37-9A7F-4278-A6F8-3DE2833989EF}
#define NS_ACCESSIBILITY_SERVICE_CID \
--- a/accessible/interfaces/nsIAccessible.idl
+++ b/accessible/interfaces/nsIAccessible.idl
@@ -7,16 +7,24 @@
#include "nsIArray.idl"
interface nsIPersistentProperties;
interface nsIDOMCSSPrimitiveValue;
interface nsIDOMNode;
interface nsIAccessibleDocument;
interface nsIAccessibleRelation;
+%{C++
+namespace mozilla {
+namespace a11y {
+class Accessible;
+}
+}
+%}
+
/**
* A cross-platform interface that supports platform-specific
* accessibility APIs like MSAA and ATK. Contains the sum of what's needed
* to support IAccessible as well as ATK's generic accessibility objects.
* Can also be used by in-process accessibility clients to get information
* about objects in the accessible tree. The accessible tree is a subset of
* nodes in the DOM tree -- such as documents, focusable elements and text.
* Mozilla creates the implementations of nsIAccessible on demand.
@@ -161,17 +169,16 @@ interface nsIAccessible : nsISupports
* Returns grouping information. Used for tree items, list items, tab panel
* labels, radio buttons, etc. Also used for collectons of non-text objects.
*
* @param groupLevel - 1-based, similar to ARIA 'level' property
* @param similarItemsInGroup - 1-based, similar to ARIA 'setsize' property,
* inclusive of the current item
* @param positionInGroup - 1-based, similar to ARIA 'posinset' property
*/
- [binaryname(ScriptableGroupPosition)]
void groupPosition(out long aGroupLevel, out long aSimilarItemsInGroup,
out long aPositionInGroup);
/**
* Accessible child which contains the coordinate at (x, y) in screen pixels.
* If the point is in the current accessible but not in a child, the
* current accessible will be returned.
* If the point is in neither the current accessible or a child, then
@@ -193,17 +200,16 @@ interface nsIAccessible : nsISupports
* @param y screen's y coordinate
* @return the deepest accessible child containing the given point
*/
nsIAccessible getDeepestChildAtPoint(in long x, in long y);
/**
* Nth accessible child using zero-based index or last child if index less than zero
*/
- [binaryname(ScriptableGetChildAt)]
nsIAccessible getChildAt(in long aChildIndex);
/**
* Return accessible relation by the given relation type (see.
* constants defined in nsIAccessibleRelation).
*/
nsIAccessibleRelation getRelationByType(in unsigned long aRelationType);
@@ -216,40 +222,37 @@ interface nsIAccessible : nsISupports
* Return accessible's x and y coordinates relative to the screen and
* accessible's width and height.
*/
void getBounds(out long x, out long y, out long width, out long height);
/**
* Add or remove this accessible to the current selection
*/
- [binaryname(ScriptableSetSelected)]
void setSelected(in boolean isSelected);
/**
* Extend the current selection from its current accessible anchor node
* to this accessible
*/
void extendSelection();
/**
* Select this accessible node only
*/
- [binaryname(ScriptableTakeSelection)]
void takeSelection();
/**
* Focus this accessible node,
* The state STATE_FOCUSABLE indicates whether this node is normally focusable.
* It is the callers responsibility to determine whether this node is focusable.
* accTakeFocus on a node that is not normally focusable (such as a table),
- * will still set focus on that node, although normally that will not be visually
+ * will still set focus on that node, although normally that will not be visually
* indicated in most style sheets.
*/
- [binaryname(ScriptableTakeFocus)]
void takeFocus();
/**
* The number of accessible actions associated with this accessible
*/
readonly attribute uint8_t actionCount;
/**
@@ -261,40 +264,36 @@ interface nsIAccessible : nsISupports
* The description of the accessible action at the given zero-based index
*/
AString getActionDescription(in uint8_t aIndex);
/**
* Perform the accessible action at the given zero-based index
* Action number 0 is the default action
*/
- [binaryname(ScriptableDoAction)]
void doAction(in uint8_t index);
/**
* Makes an object visible on screen.
*
* @param scrollType - defines where the object should be placed on
* the screen (see nsIAccessibleScrollType for
* available constants).
*/
- [binaryname(ScriptableScrollTo)]
void scrollTo(in unsigned long aScrollType);
/**
* Moves the top left of an object to a specified location.
*
* @param coordinateType [in] - specifies whether the coordinates are relative to
* the screen or the parent object (for available
* constants refer to nsIAccessibleCoordinateType)
* @param x [in] - defines the x coordinate
* @param y [in] - defines the y coordinate
*/
- [binaryname(ScriptableScrollToPoint)]
void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
- /**
- * Get a pointer to accessibility interface for this node, which is specific
- * to the OS/accessibility toolkit we're running on.
- */
- [noscript] void getNativeInterface(out voidPtr aOutAccessible);
+ %{C++
+ virtual mozilla::a11y::Accessible* ToInternalAccessible() const = 0;
+ %}
+
};
--- a/accessible/interfaces/nsIAccessibleDocument.idl
+++ b/accessible/interfaces/nsIAccessibleDocument.idl
@@ -14,17 +14,17 @@ interface nsIDOMWindow;
* that wish to retrieve information about a document.
* When accessibility is turned on in Gecko,
* there is an nsIAccessibleDocument for each document
* whether it is XUL, HTML or whatever.
* You can QueryInterface to nsIAccessibleDocument from the nsIAccessible for
* the root node of a document or you can get one from
* nsIAccessible::GetDocument().
*/
-[scriptable, uuid(c80f6600-3210-4893-8f71-fde381ca39c9)]
+[scriptable, uuid(2be938df-0210-4609-9ece-26b197a517e5)]
interface nsIAccessibleDocument : nsISupports
{
/**
* The URL of the document
*/
readonly attribute AString URL;
/**
@@ -65,11 +65,10 @@ interface nsIAccessibleDocument : nsISup
/**
* The virtual cursor pivot this document manages.
*/
readonly attribute nsIAccessiblePivot virtualCursor;
/**
* Return the child document accessible at the given index.
*/
- [binaryname(ScriptableGetChildDocumentAt)]
nsIAccessibleDocument getChildDocumentAt(in unsigned long index);
};
--- a/accessible/interfaces/nsIAccessibleEditableText.idl
+++ b/accessible/interfaces/nsIAccessibleEditableText.idl
@@ -1,61 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
-[scriptable, uuid(93d0ba57-0d20-49d1-aede-8fde6699855d)]
+[scriptable, uuid(28915cca-3366-4034-ba1d-b7afb9b37639)]
interface nsIAccessibleEditableText : nsISupports
{
/**
* Replaces the text represented by this object by the given text.
*/
void setTextContents (in AString text);
/**
* Inserts text at the specified position.
*
* @param text - text that is inserted.
* @param position - index at which to insert the text.
*/
- [binaryname(ScriptableInsertText)]
void insertText(in AString text, in long position);
/**
* Copies the text range into the clipboard.
*
* @param startPos - start index of the text to moved into the clipboard.
* @param endPos - end index of the text to moved into the clipboard.
*/
- [binaryname(ScriptableCopyText)]
void copyText(in long startPos, in long endPos);
/**
* Deletes a range of text and copies it to the clipboard.
*
* @param startPos - start index of the text to be deleted.
* @param endOffset - end index of the text to be deleted.
*/
- [binaryname(ScriptableCutText)]
void cutText(in long startPos, in long endPos);
/**
* Deletes a range of text.
*
* @param startPos - start index of the text to be deleted.
* @param endPos - end index of the text to be deleted.
*/
- [binaryname(ScriptableDeleteText)]
void deleteText(in long startPos, in long endPos);
/**
* Pastes text from the clipboard.
*
* @param position - index at which to insert the text from the system
* clipboard into the text represented by this object.
*/
- [binaryname(ScriptablePasteText)]
void pasteText(in long position);
};
--- a/accessible/interfaces/nsIAccessibleSelectable.idl
+++ b/accessible/interfaces/nsIAccessibleSelectable.idl
@@ -6,17 +6,17 @@
#include "nsISupports.idl"
interface nsIAccessible;
interface nsIArray;
/**
* An accessibility interface for selectable widgets.
*/
-[scriptable, uuid(3e507fc4-4fcc-4223-a674-a095f591eba1)]
+[scriptable, uuid(8efb03d4-1354-4875-94cf-261336057626)]
interface nsIAccessibleSelectable : nsISupports
{
/**
* Return an nsIArray of selected items within the widget.
*/
readonly attribute nsIArray selectedItems;
/**
@@ -27,38 +27,33 @@ interface nsIAccessibleSelectable : nsIS
/**
* Return a nth selected item within the widget.
*/
nsIAccessible getSelectedItemAt(in unsigned long index);
/**
* Return true if the given item is selected.
*/
- [binaryname(ScriptableIsItemSelected)]
boolean isItemSelected(in unsigned long index);
/**
* Adds the specified item to the widget's selection.
*/
- [binaryname(ScriptableAddItemToSelection)]
void addItemToSelection(in unsigned long index);
/**
* Removes the specified item from the widget's selection.
*/
- [binaryname(ScriptableRemoveItemFromSelection)]
void removeItemFromSelection(in unsigned long index);
/**
* Select all items.
*
* @return false if the object does not accept multiple selection,
* otherwise true.
*/
- [binaryname(ScriptableSelectAll)]
boolean selectAll();
/**
* Unselect all items.
*/
- [binaryname(ScriptableUnselectAll)]
void unselectAll();
};
--- a/accessible/interfaces/nsIAccessibleText.idl
+++ b/accessible/interfaces/nsIAccessibleText.idl
@@ -8,17 +8,17 @@
typedef long AccessibleTextBoundary;
interface nsIAccessible;
interface nsIArray;
interface nsIPersistentProperties;
interface nsIAccessibleTextRange;
-[scriptable, uuid(88789f40-54c9-494a-846d-3acaaf4cf46a)]
+[scriptable, uuid(93ad2ca1-f12b-4ab9-a793-95d9fa9d1774)]
interface nsIAccessibleText : nsISupports
{
// In parameters for character offsets:
// -1 will be treated as the equal to the end of the text
// -2 will be treated as the caret position
const int32_t TEXT_OFFSET_END_OF_TEXT = -1;
const int32_t TEXT_OFFSET_CARET = -2;
@@ -29,17 +29,16 @@ interface nsIAccessibleText : nsISupport
const AccessibleTextBoundary BOUNDARY_SENTENCE_END = 4; // don't use, deprecated
const AccessibleTextBoundary BOUNDARY_LINE_START = 5;
const AccessibleTextBoundary BOUNDARY_LINE_END = 6;
/**
* The current current caret offset.
* If set < 0 then caret will be placed at the end of the text
*/
- [binaryname(ScriptableCaretOffset)]
attribute long caretOffset;
readonly attribute long characterCount;
readonly attribute long selectionCount;
/**
* String methods may need to return multibyte-encoded strings,
* since some locales can't be encoded using 16-bit chars.
@@ -166,33 +165,31 @@ interface nsIAccessibleText : nsISupport
*
* @param startIndex 0-based character offset
* @param endIndex 0-based character offset - the offset of the
* character just past the last character of the
* string
* @param scrollType defines how to scroll (see nsIAccessibleScrollType for
* available constants)
*/
- [binaryname(ScriptableScrollSubstringTo)]
void scrollSubstringTo(in long startIndex, in long endIndex,
in unsigned long scrollType);
/**
* Moves the top left of a substring to a specified location.
*
* @param startIndex 0-based character offset
* @param endIndex 0-based character offset - the offset of the
* character just past the last character of
* the string
* @param coordinateType specifies the coordinates origin (for available
* constants refer to nsIAccessibleCoordinateType)
* @param x defines the x coordinate
* @param y defines the y coordinate
*/
- [binaryname(ScriptableScrollSubstringToPoint)]
void scrollSubstringToPoint(in long startIndex, in long endIndex,
in unsigned long coordinateType,
in long x, in long y);
/**
* Return a range that encloses this text control or otherwise the document
* this text accessible belongs to.
*/
--- a/accessible/mac/AccessibleWrap.h
+++ b/accessible/mac/AccessibleWrap.h
@@ -27,22 +27,22 @@
namespace mozilla {
namespace a11y {
class AccessibleWrap : public Accessible
{
public: // construction, destruction
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
virtual ~AccessibleWrap();
-
+
/**
* Get the native Obj-C object (mozAccessible).
*/
- NS_IMETHOD GetNativeInterface (void** aOutAccessible);
-
+ virtual void GetNativeInterface(void** aOutAccessible) MOZ_OVERRIDE;
+
/**
* The objective-c |Class| type that this accessible's native object
* should be instantied with. used on runtime to determine the
* right type for this accessible's associated native object.
*/
virtual Class GetNativeType ();
virtual void Shutdown ();
--- a/accessible/mac/AccessibleWrap.mm
+++ b/accessible/mac/AccessibleWrap.mm
@@ -38,24 +38,20 @@ AccessibleWrap::GetNativeObject()
mNativeInited = true;
return mNativeObject;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
-NS_IMETHODIMP
-AccessibleWrap::GetNativeInterface (void **aOutInterface)
+void
+AccessibleWrap::GetNativeInterface(void** aOutInterface)
{
- NS_ENSURE_ARG_POINTER(aOutInterface);
-
*aOutInterface = static_cast<void*>(GetNativeObject());
-
- return *aOutInterface ? NS_OK : NS_ERROR_FAILURE;
}
// overridden in subclasses to create the right kind of object. by default we create a generic
// 'mozAccessible' node.
Class
AccessibleWrap::GetNativeType ()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
--- a/accessible/mac/mozAccessible.h
+++ b/accessible/mac/mozAccessible.h
@@ -19,17 +19,17 @@
*/
inline id <mozAccessible>
GetObjectOrRepresentedView(id <mozAccessible> aObject)
{
return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
}
inline mozAccessible*
-GetNativeFromGeckoAccessible(nsIAccessible* aAccessible)
+GetNativeFromGeckoAccessible(mozilla::a11y::Accessible* aAccessible)
{
mozAccessible* native = nil;
aAccessible->GetNativeInterface((void**)&native);
return native;
}
@interface mozAccessible : NSObject <mozAccessible>
{
@@ -44,17 +44,17 @@ GetNativeFromGeckoAccessible(nsIAccessib
NSMutableArray* mChildren;
/**
* Weak reference to the parent
*/
mozAccessible* mParent;
/**
- * The nsIAccessible role of our gecko accessible.
+ * The role of our gecko accessible.
*/
mozilla::a11y::role mRole;
}
// inits with the gecko owner.
- (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent;
// our accessible parent (AXParent)
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -6,17 +6,16 @@
#import "mozAccessible.h"
#import "MacUtils.h"
#import "mozView.h"
#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
-#include "nsIAccessibleText.h"
#include "nsIAccessibleEditableText.h"
#include "nsIPersistentProperties2.h"
#include "Relation.h"
#include "Role.h"
#include "RootAccessible.h"
#include "mozilla/Services.h"
#include "nsRect.h"
@@ -298,20 +297,20 @@ GetClosestInterestingAccessible(id anObj
return GetClosestInterestingAccessible(nativeParent);
}
// GetUnignoredParent() returns null when there is no unignored accessible all the way up to
// the root accessible. so we'll have to return whatever native accessible is above our root accessible
// (which might be the owning NSWindow in the application, for example).
//
// get the native root accessible, and tell it to return its first parent unignored accessible.
- RootAccessible* root = mGeckoAccessible->RootAccessible();
- id nativeParent = GetNativeFromGeckoAccessible(static_cast<nsIAccessible*>(root));
+ id nativeParent =
+ GetNativeFromGeckoAccessible(mGeckoAccessible->RootAccessible());
NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
-
+
return GetClosestInterestingAccessible(nativeParent);
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (BOOL)hasRepresentedView
{
return NO;
@@ -388,34 +387,33 @@ GetClosestInterestingAccessible(id anObj
- (NSValue*)size
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (!mGeckoAccessible)
return nil;
- int32_t x = 0, y = 0, width = 0, height = 0;
- mGeckoAccessible->GetBounds (&x, &y, &width, &height);
+ nsIntRect rect = mGeckoAccessible->Bounds();
CGFloat scaleFactor =
nsCocoaUtils::GetBackingScaleFactor([[NSScreen screens] objectAtIndex:0]);
- return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(width) / scaleFactor,
- static_cast<CGFloat>(height) / scaleFactor)];
+ return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(rect.width) / scaleFactor,
+ static_cast<CGFloat>(rect.height) / scaleFactor)];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (NSString*)role
{
if (!mGeckoAccessible)
return nil;
#ifdef DEBUG_A11Y
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
- "Does not support nsIAccessibleText when it should");
+ "Does not support Text when it should");
#endif
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
case roles::geckoRole: \
return macRole;
switch (mRole) {
#include "RoleMap.h"
@@ -528,17 +526,17 @@ GetClosestInterestingAccessible(id anObj
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (id)value
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString value;
- mGeckoAccessible->GetValue (value);
+ mGeckoAccessible->Value(value);
return value.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(value.BeginReading())
length:value.Length()];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (void)valueDidChange
{
@@ -573,17 +571,17 @@ GetClosestInterestingAccessible(id anObj
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (NSString*)help
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString helpText;
- mGeckoAccessible->GetHelp (helpText);
+ mGeckoAccessible->Help(helpText);
return helpText.IsEmpty() ? nil : [NSString stringWithCharacters:reinterpret_cast<const unichar*>(helpText.BeginReading())
length:helpText.Length()];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
// objc-style description (from NSObject); not to be confused with the accessible description above.
- (NSString*)description
--- a/accessible/mac/mozActionElements.mm
+++ b/accessible/mac/mozActionElements.mm
@@ -289,25 +289,24 @@ enum CheckboxValue {
/**
* Returns the selected tab (the mozAccessible)
*/
- (id)value
{
if (!mGeckoAccessible)
return nil;
-
+
Accessible* accessible = mGeckoAccessible->GetSelectedItem(0);
if (!accessible)
return nil;
mozAccessible* nativeAcc = nil;
- nsresult rv = accessible->GetNativeInterface((void**)&nativeAcc);
- NS_ENSURE_SUCCESS(rv, nil);
-
+ accessible->GetNativeInterface((void**)&nativeAcc);
+
return nativeAcc;
}
/**
* Return the mozAccessibles that are the tabs.
*/
- (id)tabs
{
--- a/accessible/mac/mozTextAccessible.h
+++ b/accessible/mac/mozTextAccessible.h
@@ -6,16 +6,15 @@
#import "HyperTextAccessible.h"
@interface mozTextAccessible : mozAccessible
{
// both of these are the same old mGeckoAccessible, but already
// QI'd for us, to the right type, for convenience.
mozilla::a11y::HyperTextAccessible* mGeckoTextAccessible; // strong
- nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
}
@end
@interface mozTextLeafAccessible : mozAccessible
{
}
@end
--- a/accessible/mac/mozTextAccessible.mm
+++ b/accessible/mac/mozTextAccessible.mm
@@ -54,17 +54,16 @@ ToNSString(id aValue)
@implementation mozTextAccessible
- (id)initWithAccessible:(AccessibleWrap*)accessible
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ((self = [super initWithAccessible:accessible])) {
mGeckoTextAccessible = accessible->AsHyperText();
- CallQueryInterface(accessible, &mGeckoEditableTextAccessible);
}
return self;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (BOOL)accessibilityIsIgnored
{
@@ -304,32 +303,31 @@ ToNSString(id aValue)
return nil;
}
- (void)expire
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mGeckoTextAccessible = nullptr;
- NS_IF_RELEASE(mGeckoEditableTextAccessible);
[super expire];
NS_OBJC_END_TRY_ABORT_BLOCK;
}
#pragma mark -
- (BOOL)isReadOnly
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
return YES;
-
- if (mGeckoEditableTextAccessible)
+
+ if (mGeckoTextAccessible)
return (mGeckoAccessible->State() & states::READONLY) == 0;
return NO;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
}
- (NSNumber*)caretLineNumber
@@ -339,20 +337,20 @@ ToNSString(id aValue)
return (lineNumber >= 0) ? [NSNumber numberWithInt:lineNumber] : nil;
}
- (void)setText:(NSString*)aNewString
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
- if (mGeckoEditableTextAccessible) {
+ if (mGeckoTextAccessible) {
nsString text;
nsCocoaUtils::GetStringForNSString(aNewString, text);
- mGeckoEditableTextAccessible->SetTextContents(text);
+ mGeckoTextAccessible->ReplaceText(text);
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (NSString*)text
{
if (!mGeckoAccessible || !mGeckoTextAccessible)
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -29,17 +29,16 @@ const nsIAccessibleDocument = Components
const nsIAccessibleApplication = Components.interfaces.nsIAccessibleApplication;
const nsIAccessibleText = Components.interfaces.nsIAccessibleText;
const nsIAccessibleEditableText = Components.interfaces.nsIAccessibleEditableText;
const nsIAccessibleHyperLink = Components.interfaces.nsIAccessibleHyperLink;
const nsIAccessibleHyperText = Components.interfaces.nsIAccessibleHyperText;
-const nsIAccessibleCursorable = Components.interfaces.nsIAccessibleCursorable;
const nsIAccessibleImage = Components.interfaces.nsIAccessibleImage;
const nsIAccessiblePivot = Components.interfaces.nsIAccessiblePivot;
const nsIAccessibleSelectable = Components.interfaces.nsIAccessibleSelectable;
const nsIAccessibleTable = Components.interfaces.nsIAccessibleTable;
const nsIAccessibleTableCell = Components.interfaces.nsIAccessibleTableCell;
const nsIAccessibleTraversalRule = Components.interfaces.nsIAccessibleTraversalRule;
const nsIAccessibleValue = Components.interfaces.nsIAccessibleValue;
@@ -168,17 +167,17 @@ function getNode(aAccOrNodeOrID, aDocume
return null;
if (aAccOrNodeOrID instanceof nsIDOMNode)
return aAccOrNodeOrID;
if (aAccOrNodeOrID instanceof nsIAccessible)
return aAccOrNodeOrID.DOMNode;
- node = (aDocument || document).getElementById(aAccOrNodeOrID);
+ var node = (aDocument || document).getElementById(aAccOrNodeOrID);
if (!node) {
ok(false, "Can't get DOM element for " + aAccOrNodeOrID);
return null;
}
return node;
}
--- a/accessible/windows/ia2/ia2AccessibleAction.cpp
+++ b/accessible/windows/ia2/ia2AccessibleAction.cpp
@@ -72,29 +72,25 @@ ia2AccessibleAction::doAction(long aActi
STDMETHODIMP
ia2AccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
{
A11Y_TRYBLOCK_BEGIN
if (!aDescription)
return E_INVALIDARG;
-
*aDescription = nullptr;
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
if (acc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsAutoString description;
uint8_t index = static_cast<uint8_t>(aActionIndex);
- nsresult rv = acc->GetActionDescription(index, description);
- if (NS_FAILED(rv))
- return GetHRESULT(rv);
-
+ acc->ActionDescriptionAt(index, description);
if (description.IsEmpty())
return S_FALSE;
*aDescription = ::SysAllocStringLen(description.get(),
description.Length());
return *aDescription ? S_OK : E_OUTOFMEMORY;
A11Y_TRYBLOCK_END
--- a/accessible/windows/ia2/ia2AccessibleEditableText.h
+++ b/accessible/windows/ia2/ia2AccessibleEditableText.h
@@ -4,17 +4,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _ACCESSIBLE_EDITABLETEXT_H
#define _ACCESSIBLE_EDITABLETEXT_H
#include "nsISupports.h"
-#include "nsIAccessibleEditableText.h"
#include "AccessibleEditableText.h"
namespace mozilla {
namespace a11y {
class ia2AccessibleEditableText: public IAccessibleEditableText
{
--- a/accessible/windows/ia2/ia2AccessibleImage.cpp
+++ b/accessible/windows/ia2/ia2AccessibleImage.cpp
@@ -50,20 +50,17 @@ ia2AccessibleImage::get_description(BSTR
*aDescription = nullptr;
ImageAccessibleWrap* acc = static_cast<ImageAccessibleWrap*>(this);
if (acc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsAutoString description;
- nsresult rv = acc->GetName(description);
- if (NS_FAILED(rv))
- return GetHRESULT(rv);
-
+ acc->Name(description);
if (description.IsEmpty())
return S_FALSE;
*aDescription = ::SysAllocStringLen(description.get(), description.Length());
return *aDescription ? S_OK : E_OUTOFMEMORY;
A11Y_TRYBLOCK_END
}
@@ -83,24 +80,20 @@ ia2AccessibleImage::get_imagePosition(en
ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this);
if (imageAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
- int32_t x = 0, y = 0;
- nsresult rv = imageAcc->GetImagePosition(geckoCoordType, &x, &y);
- if (NS_FAILED(rv))
- return GetHRESULT(rv);
-
- *aX = x;
- *aY = y;
+ nsIntPoint pos = imageAcc->Position(geckoCoordType);
+ *aX = pos.x;
+ *aY = pos.y;
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleImage::get_imageSize(long* aHeight, long* aWidth)
{
@@ -111,20 +104,16 @@ ia2AccessibleImage::get_imageSize(long*
*aHeight = 0;
*aWidth = 0;
ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this);
if (imageAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;
- int32_t width = 0, height = 0;
- nsresult rv = imageAcc->GetImageSize(&width, &height);
- if (NS_FAILED(rv))
- return GetHRESULT(rv);
-
- *aHeight = width;
- *aWidth = height;
+ nsIntSize size = imageAcc->Size();
+ *aHeight = size.width;
+ *aWidth = size.height;
return S_OK;
A11Y_TRYBLOCK_END
}
--- a/accessible/windows/ia2/ia2AccessibleRelation.cpp
+++ b/accessible/windows/ia2/ia2AccessibleRelation.cpp
@@ -3,17 +3,16 @@
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ia2AccessibleRelation.h"
#include "Relation.h"
-#include "nsIAccessibleRelation.h"
#include "nsID.h"
#include "AccessibleRelation_i.c"
using namespace mozilla::a11y;
ia2AccessibleRelation::ia2AccessibleRelation(RelationType aType, Relation* aRel) :
mType(aType)
--- a/accessible/windows/ia2/ia2AccessibleRelation.h
+++ b/accessible/windows/ia2/ia2AccessibleRelation.h
@@ -5,17 +5,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _NS_ACCESSIBLE_RELATION_WRAP_H
#define _NS_ACCESSIBLE_RELATION_WRAP_H
#include "Accessible.h"
#include "IUnknownImpl.h"
-#include "nsIAccessibleRelation.h"
#include <utility>
#include "nsTArray.h"
#include "AccessibleRelation.h"
namespace mozilla {
namespace a11y {
--- a/accessible/windows/ia2/ia2AccessibleTable.cpp
+++ b/accessible/windows/ia2/ia2AccessibleTable.cpp
@@ -414,18 +414,18 @@ ia2AccessibleTable::get_summary(IUnknown
{
A11Y_TRYBLOCK_BEGIN
if (!aAccessible)
return E_INVALIDARG;
// Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
// link an accessible object to specify a summary. There is closes method
- // in nsIAccessibleTable::summary to get a summary as a string which is not
- // mapped directly to IAccessible2.
+ // in Table::summary to get a summary as a string which is not mapped
+ // directly to IAccessible2.
*aAccessible = nullptr;
return S_FALSE;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
--- a/accessible/windows/ia2/ia2AccessibleText.h
+++ b/accessible/windows/ia2/ia2AccessibleText.h
@@ -4,17 +4,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _ACCESSIBLE_TEXT_H
#define _ACCESSIBLE_TEXT_H
#include "nsISupports.h"
-#include "nsIAccessibleText.h"
#include "AccessibleText.h"
namespace mozilla {
namespace a11y {
class ia2AccessibleText: public IAccessibleText
{
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -8,17 +8,16 @@
#include "Accessible-inl.h"
#include "Compatibility.h"
#include "DocAccessible-inl.h"
#include "EnumVariant.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "nsIAccessibleEvent.h"
-#include "nsIAccessibleRelation.h"
#include "nsWinUtils.h"
#include "ServiceProvider.h"
#include "Relation.h"
#include "Role.h"
#include "RootAccessible.h"
#include "sdnAccessible.h"
#include "States.h"
@@ -360,17 +359,17 @@ AccessibleWrap::get_accRole(
if (!xpAccessible)
return E_INVALIDARG;
if (xpAccessible->IsDefunct())
return CO_E_OBJNOTCONNECTED;
#ifdef DEBUG
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(xpAccessible),
- "Does not support nsIAccessibleText when it should");
+ "Does not support Text when it should");
#endif
a11y::role geckoRole = xpAccessible->Role();
uint32_t msaaRole = 0;
#define ROLE(_geckoRole, stringRole, atkRole, macRole, \
_msaaRole, ia2Role, nameRule) \
case roles::_geckoRole: \
@@ -583,22 +582,25 @@ AccessibleWrap::get_accFocus(
pvarChild->vt = VT_EMPTY; // No focus or focus is not a child
}
return S_OK;
A11Y_TRYBLOCK_END
}
-// This helper class implements IEnumVARIANT for a nsIArray containing nsIAccessible objects.
-
+/**
+ * This helper class implements IEnumVARIANT for a nsTArray containing
+ * accessible objects.
+ */
class AccessibleEnumerator MOZ_FINAL : public IEnumVARIANT
{
public:
- AccessibleEnumerator(nsIArray* aArray) : mArray(aArray), mCurIndex(0) { }
+ AccessibleEnumerator(const nsTArray<Accessible*>& aArray) :
+ mArray(aArray), mCurIndex(0) { }
AccessibleEnumerator(const AccessibleEnumerator& toCopy) :
mArray(toCopy.mArray), mCurIndex(toCopy.mCurIndex) { }
~AccessibleEnumerator() { }
// IUnknown
DECL_IUNKNOWN
// IEnumVARIANT
@@ -607,17 +609,17 @@ public:
STDMETHODIMP Reset()
{
mCurIndex = 0;
return S_OK;
}
STDMETHODIMP Clone(IEnumVARIANT FAR* FAR* ppenum);
private:
- nsCOMPtr<nsIArray> mArray;
+ nsTArray<Accessible*> mArray;
uint32_t mCurIndex;
};
STDMETHODIMP
AccessibleEnumerator::QueryInterface(REFIID iid, void ** ppvObject)
{
A11Y_TRYBLOCK_BEGIN
@@ -638,36 +640,29 @@ AccessibleEnumerator::QueryInterface(REF
A11Y_TRYBLOCK_END
}
STDMETHODIMP
AccessibleEnumerator::Next(unsigned long celt, VARIANT FAR* rgvar, unsigned long FAR* pceltFetched)
{
A11Y_TRYBLOCK_BEGIN
- uint32_t length = 0;
- mArray->GetLength(&length);
-
+ uint32_t length = mArray.Length();
HRESULT hr = S_OK;
// Can't get more elements than there are...
if (celt > length - mCurIndex) {
hr = S_FALSE;
celt = length - mCurIndex;
}
+ // Copy the elements of the array into rgvar.
for (uint32_t i = 0; i < celt; ++i, ++mCurIndex) {
- // Copy the elements of the array into rgvar
- nsCOMPtr<nsIAccessible> accel(do_QueryElementAt(mArray, mCurIndex));
- NS_ASSERTION(accel, "Invalid pointer in mArray");
-
- if (accel) {
- rgvar[i].vt = VT_DISPATCH;
- rgvar[i].pdispVal = AccessibleWrap::NativeAccessible(accel);
- }
+ rgvar[i].vt = VT_DISPATCH;
+ rgvar[i].pdispVal = AccessibleWrap::NativeAccessible(mArray[mCurIndex]);
}
if (pceltFetched)
*pceltFetched = celt;
return hr;
A11Y_TRYBLOCK_END
@@ -687,33 +682,32 @@ AccessibleEnumerator::Clone(IEnumVARIANT
A11Y_TRYBLOCK_END
}
STDMETHODIMP
AccessibleEnumerator::Skip(unsigned long celt)
{
A11Y_TRYBLOCK_BEGIN
- uint32_t length = 0;
- mArray->GetLength(&length);
+ uint32_t length = mArray.Length();
// Check if we can skip the requested number of elements
if (celt > length - mCurIndex) {
mCurIndex = length;
return S_FALSE;
}
mCurIndex += celt;
return S_OK;
A11Y_TRYBLOCK_END
}
/**
* This method is called when a client wants to know which children of a node
* are selected. Note that this method can only find selected children for
- * nsIAccessible object which implement SelectAccessible.
+ * accessible object which implement SelectAccessible.
*
* The VARIANT return value arguement is expected to either contain a single IAccessible
* or an IEnumVARIANT of IAccessibles. We return the IEnumVARIANT regardless of the number
* of children selected, unless there are none selected in which case we return an empty
* VARIANT.
*
* We get the selected options from the select's accessible object and wrap
* those in an AccessibleEnumerator which we then put in the return VARIANT.
@@ -732,28 +726,23 @@ AccessibleWrap::get_accSelection(VARIANT
VariantInit(pvarChildren);
pvarChildren->vt = VT_EMPTY;
if (IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (IsSelect()) {
- nsCOMPtr<nsIArray> selectedItems = SelectedItems();
- if (selectedItems) {
- // 1) Create and initialize the enumeration
- nsRefPtr<AccessibleEnumerator> pEnum =
- new AccessibleEnumerator(selectedItems);
+ nsAutoTArray<Accessible*, 10> selectedItems;
+ SelectedItems(&selectedItems);
- // 2) Put the enumerator in the VARIANT
- if (!pEnum)
- return E_OUTOFMEMORY;
- pvarChildren->vt = VT_UNKNOWN; // this must be VT_UNKNOWN for an IEnumVARIANT
- NS_ADDREF(pvarChildren->punkVal = pEnum);
- }
+ // 1) Create and initialize the enumeration
+ nsRefPtr<AccessibleEnumerator> pEnum = new AccessibleEnumerator(selectedItems);
+ pvarChildren->vt = VT_UNKNOWN; // this must be VT_UNKNOWN for an IEnumVARIANT
+ NS_ADDREF(pvarChildren->punkVal = pEnum);
}
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
AccessibleWrap::get_accDefaultAction(
@@ -1076,24 +1065,21 @@ AccessibleWrap::Invoke(DISPID dispIdMemb
if (!typeInfo)
return E_FAIL;
return typeInfo->Invoke(static_cast<IAccessible*>(this), dispIdMember,
wFlags, pDispParams, pVarResult, pExcepInfo,
puArgErr);
}
-
-// nsIAccessible method
-NS_IMETHODIMP
-AccessibleWrap::GetNativeInterface(void **aOutAccessible)
+void
+AccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = static_cast<IAccessible*>(this);
NS_ADDREF_THIS();
- return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible
nsresult
AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
@@ -1217,21 +1203,21 @@ AccessibleWrap::GetHWNDFor(Accessible* a
}
return static_cast<HWND>(document->GetNativeWindow());
}
return nullptr;
}
IDispatch*
-AccessibleWrap::NativeAccessible(nsIAccessible* aAccessible)
+AccessibleWrap::NativeAccessible(Accessible* aAccessible)
{
if (!aAccessible) {
- NS_WARNING("Not passing in an aAccessible");
- return nullptr;
+ NS_WARNING("Not passing in an aAccessible");
+ return nullptr;
}
IAccessible* msaaAccessible = nullptr;
aAccessible->GetNativeInterface(reinterpret_cast<void**>(&msaaAccessible));
return static_cast<IDispatch*>(msaaAccessible);
}
Accessible*
--- a/accessible/windows/msaa/AccessibleWrap.h
+++ b/accessible/windows/msaa/AccessibleWrap.h
@@ -165,19 +165,19 @@ public: // construction, destruction
*/
void UpdateSystemCaretFor(Accessible* aAccessible);
/**
* Find an accessible by the given child ID in cached documents.
*/
Accessible* GetXPAccessibleFor(const VARIANT& aVarChild);
- NS_IMETHOD GetNativeInterface(void **aOutAccessible);
+ virtual void GetNativeInterface(void **aOutAccessible) MOZ_OVERRIDE;
- static IDispatch *NativeAccessible(nsIAccessible *aXPAccessible);
+ static IDispatch* NativeAccessible(Accessible* aAccessible);
protected:
virtual ~AccessibleWrap() { }
/**
* Creates ITypeInfo for LIBID_Accessibility if it's needed and returns it.
*/
static ITypeInfo* GetTI(LCID lcid);
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp
+++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp
@@ -16,17 +16,17 @@ using namespace mozilla::a11y;
HTMLWin32ObjectOwnerAccessible::
HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
DocAccessible* aDoc, void* aHwnd) :
AccessibleWrap(aContent, aDoc), mHwnd(aHwnd)
{
// Our only child is a HTMLWin32ObjectAccessible object.
if (mHwnd)
- mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd);
+ mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd, aDoc);
}
////////////////////////////////////////////////////////////////////////////////
// HTMLWin32ObjectOwnerAccessible: Accessible implementation
void
HTMLWin32ObjectOwnerAccessible::Shutdown()
{
@@ -58,35 +58,35 @@ HTMLWin32ObjectOwnerAccessible::CacheChi
AppendChild(mNativeAccessible);
}
////////////////////////////////////////////////////////////////////////////////
// HTMLWin32ObjectAccessible
////////////////////////////////////////////////////////////////////////////////
-HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
- DummyAccessible()
+HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd,
+ DocAccessible* aDoc) :
+ DummyAccessible(aDoc)
{
mHwnd = aHwnd;
if (mHwnd) {
// The plugin is not windowless. In this situation we use
// use its inner child owned by the plugin so that we don't get
// in an infinite loop, where the WM_GETOBJECT's get forwarded
// back to us and create another HTMLWin32ObjectAccessible
HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
if (childWnd) {
mHwnd = childWnd;
}
}
}
-NS_IMETHODIMP
+void
HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
{
if (mHwnd) {
::AccessibleObjectFromWindow(static_cast<HWND>(mHwnd),
OBJID_WINDOW, IID_IAccessible,
aNativeAccessible);
}
- return NS_OK;
}
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.h
+++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.h
@@ -18,17 +18,17 @@ class HTMLWin32ObjectOwnerAccessible : p
public:
// This will own the HTMLWin32ObjectAccessible. We create this where the
// <object> or <embed> exists in the tree, so that get_accNextSibling() etc.
// will still point to Gecko accessible sibling content. This is necessary
// because the native plugin accessible doesn't know where it exists in the
// Mozilla tree, and returns null for previous and next sibling. This would
// have the effect of cutting off all content after the plugin.
HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
- DocAccessible* aDoc, void* aHwnd);
+ DocAccessible* aDoc, void* aHwnd);
virtual ~HTMLWin32ObjectOwnerAccessible() {}
// Accessible
virtual void Shutdown();
virtual mozilla::a11y::role NativeRole();
virtual bool NativelyUnavailable() const;
protected:
@@ -39,28 +39,28 @@ protected:
void* mHwnd;
nsRefPtr<Accessible> mNativeAccessible;
};
/**
* This class is used only internally, we never! send out an IAccessible linked
* back to this object. This class is used to represent a plugin object when
* referenced as a child or sibling of another Accessible node. We need only
- * a limited portion of the nsIAccessible interface implemented here. The
+ * a limited portion of the Accessible interface implemented here. The
* in depth accessible information will be returned by the actual IAccessible
* object returned by us in Accessible::NewAccessible() that gets the IAccessible
* from the windows system from the window handle.
*/
class HTMLWin32ObjectAccessible : public DummyAccessible
{
public:
- HTMLWin32ObjectAccessible(void* aHwnd);
+ HTMLWin32ObjectAccessible(void* aHwnd, DocAccessible* aDoc);
virtual ~HTMLWin32ObjectAccessible() {}
- NS_IMETHOD GetNativeInterface(void** aNativeAccessible) MOZ_OVERRIDE;
+ virtual void GetNativeInterface(void** aNativeAccessible) MOZ_OVERRIDE;
protected:
void* mHwnd;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/windows/msaa/XULMenuAccessibleWrap.cpp
+++ b/accessible/windows/msaa/XULMenuAccessibleWrap.cpp
@@ -16,21 +16,21 @@ XULMenuitemAccessibleWrap::
XULMenuitemAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
XULMenuitemAccessible(aContent, aDoc)
{
}
ENameValueFlag
XULMenuitemAccessibleWrap::Name(nsString& aName)
{
- // XXX This should be done in get_accName() so that nsIAccessible::GetName()]
+ // XXX This should be done in MSAA's get_accName() so that Accessible::Name()]
// provides the same results on all platforms
XULMenuitemAccessible::Name(aName);
if (aName.IsEmpty())
return eNameOK;
-
+
nsAutoString accel;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::acceltext, accel);
if (!accel.IsEmpty())
aName += NS_LITERAL_STRING("\t") + accel;
return eNameOK;
}
--- a/accessible/windows/sdn/sdnDocAccessible.cpp
+++ b/accessible/windows/sdn/sdnDocAccessible.cpp
@@ -72,20 +72,17 @@ sdnDocAccessible::get_mimeType(BSTR __RP
if (!aMimeType)
return E_INVALIDARG;
*aMimeType = nullptr;
if (mAccessible->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsAutoString mimeType;
- nsresult rv = mAccessible->GetMimeType(mimeType);
- if (NS_FAILED(rv))
- return E_FAIL;
-
+ mAccessible->MimeType(mimeType);
if (mimeType.IsEmpty())
return S_FALSE;
*aMimeType = ::SysAllocStringLen(mimeType.get(), mimeType.Length());
return *aMimeType ? S_OK : E_OUTOFMEMORY;
A11Y_TRYBLOCK_END
}
@@ -98,20 +95,17 @@ sdnDocAccessible::get_docType(BSTR __RPC
if (!aDocType)
return E_INVALIDARG;
*aDocType = nullptr;
if (mAccessible->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsAutoString docType;
- nsresult rv = mAccessible->GetDocType(docType);
- if (NS_FAILED(rv))
- return E_FAIL;
-
+ mAccessible->DocType(docType);
if (docType.IsEmpty())
return S_FALSE;
*aDocType = ::SysAllocStringLen(docType.get(), docType.Length());
return *aDocType ? S_OK : E_OUTOFMEMORY;
A11Y_TRYBLOCK_END
}
--- a/accessible/xpcom/moz.build
+++ b/accessible/xpcom/moz.build
@@ -1,28 +1,20 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-EXPORTS += [
- 'xpcAccessible.h',
- 'xpcAccessibleDocument.h',
- 'xpcAccessibleHyperLink.h',
- 'xpcAccessibleHyperText.h',
- 'xpcAccessibleSelectable.h',
- 'xpcAccessibleValue.h',
-]
-
UNIFIED_SOURCES += [
'nsAccessibleRelation.cpp',
'xpcAccessible.cpp',
'xpcAccessibleApplication.cpp',
'xpcAccessibleDocument.cpp',
+ 'xpcAccessibleGeneric.cpp',
'xpcAccessibleHyperLink.cpp',
'xpcAccessibleHyperText.cpp',
'xpcAccessibleImage.cpp',
'xpcAccessibleSelectable.cpp',
'xpcAccessibleTable.cpp',
'xpcAccessibleTableCell.cpp',
'xpcAccessibleTextRange.cpp',
'xpcAccessibleValue.cpp',
--- a/accessible/xpcom/nsAccessibleRelation.cpp
+++ b/accessible/xpcom/nsAccessibleRelation.cpp
@@ -2,30 +2,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsAccessibleRelation.h"
#include "Relation.h"
#include "Accessible.h"
+#include "xpcAccessibleDocument.h"
#include "nsArrayUtils.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
Relation* aRel) :
mType(aType)
{
mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
- nsIAccessible* targetAcc = nullptr;
+ Accessible* targetAcc = nullptr;
while ((targetAcc = aRel->Next()))
- mTargets->AppendElement(targetAcc, false);
+ mTargets->AppendElement(static_cast<nsIAccessible*>(ToXPC(targetAcc)), false);
}
nsAccessibleRelation::~nsAccessibleRelation()
{
}
// nsISupports
NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
--- a/accessible/xpcom/xpcAccessible.cpp
+++ b/accessible/xpcom/xpcAccessible.cpp
@@ -1,307 +1,311 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "xpcAccessible.h"
-
#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
#include "nsIAccessibleRole.h"
#include "nsAccessibleRelation.h"
#include "Relation.h"
#include "Role.h"
#include "RootAccessible.h"
+#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsIPersistentProperties2.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessible::GetParent(nsIAccessible** aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aParent = static_cast<Accessible*>(this)->Parent());
+ NS_IF_ADDREF(*aParent = ToXPC(Intl()->Parent()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
{
NS_ENSURE_ARG_POINTER(aNextSibling);
*aNextSibling = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
- NS_IF_ADDREF(*aNextSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(1, &rv));
+ NS_IF_ADDREF(*aNextSibling = ToXPC(Intl()->GetSiblingAtOffset(1, &rv)));
return rv;
}
NS_IMETHODIMP
xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
{
NS_ENSURE_ARG_POINTER(aPreviousSibling);
*aPreviousSibling = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
- NS_IF_ADDREF(*aPreviousSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(-1, &rv));
+ NS_IF_ADDREF(*aPreviousSibling = ToXPC(Intl()->GetSiblingAtOffset(-1, &rv)));
return rv;
}
NS_IMETHODIMP
xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
{
NS_ENSURE_ARG_POINTER(aFirstChild);
*aFirstChild = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aFirstChild = static_cast<Accessible*>(this)->FirstChild());
+ NS_IF_ADDREF(*aFirstChild = ToXPC(Intl()->FirstChild()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
{
NS_ENSURE_ARG_POINTER(aLastChild);
*aLastChild = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aLastChild = static_cast<Accessible*>(this)->LastChild());
+ NS_IF_ADDREF(*aLastChild = ToXPC(Intl()->LastChild()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetChildCount(int32_t* aChildCount)
{
NS_ENSURE_ARG_POINTER(aChildCount);
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aChildCount = static_cast<Accessible*>(this)->ChildCount();
+ *aChildCount = Intl()->ChildCount();
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableGetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
+xpcAccessible::GetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
// If child index is negative, then return last child.
// XXX: do we really need this?
if (aChildIndex < 0)
- aChildIndex = static_cast<Accessible*>(this)->ChildCount() - 1;
+ aChildIndex = Intl()->ChildCount() - 1;
- Accessible* child = static_cast<Accessible*>(this)->GetChildAt(aChildIndex);
+ Accessible* child = Intl()->GetChildAt(aChildIndex);
if (!child)
return NS_ERROR_INVALID_ARG;
- NS_ADDREF(*aChild = child);
+ NS_ADDREF(*aChild = ToXPC(child));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetChildren(nsIArray** aChildren)
{
NS_ENSURE_ARG_POINTER(aChildren);
*aChildren = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> children =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- uint32_t childCount = static_cast<Accessible*>(this)->ChildCount();
+ uint32_t childCount = Intl()->ChildCount();
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
- nsIAccessible* child = static_cast<Accessible*>(this)->GetChildAt(childIdx);
- children->AppendElement(child, false);
+ Accessible* child = Intl()->GetChildAt(childIdx);
+ children->AppendElement(static_cast<nsIAccessible*>(ToXPC(child)), false);
}
NS_ADDREF(*aChildren = children);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
{
NS_ENSURE_ARG_POINTER(aIndexInParent);
- *aIndexInParent = static_cast<Accessible*>(this)->IndexInParent();
+ *aIndexInParent = Intl()->IndexInParent();
return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
xpcAccessible::GetDOMNode(nsIDOMNode** aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nullptr;
- nsINode *node = static_cast<Accessible*>(this)->GetNode();
+ nsINode* node = Intl()->GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
- NS_IF_ADDREF(*aDocument = static_cast<Accessible*>(this)->Document());
+ NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->Document()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
- NS_IF_ADDREF(*aRootDocument = static_cast<Accessible*>(this)->RootAccessible());
+ NS_IF_ADDREF(*aRootDocument = ToXPCDocument(Intl()->RootAccessible()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetRole(uint32_t* aRole)
{
NS_ENSURE_ARG_POINTER(aRole);
*aRole = nsIAccessibleRole::ROLE_NOTHING;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aRole = static_cast<Accessible*>(this)->Role();
+ *aRole = Intl()->Role();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
{
NS_ENSURE_ARG_POINTER(aState);
- nsAccUtils::To32States(static_cast<Accessible*>(this)->State(),
- aState, aExtraState);
+ nsAccUtils::To32States(Intl()->State(), aState, aExtraState);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetName(nsAString& aName)
{
aName.Truncate();
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString name;
- static_cast<Accessible*>(this)->Name(name);
+ Intl()->Name(name);
aName.Assign(name);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetDescription(nsAString& aDescription)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString desc;
- static_cast<Accessible*>(this)->Description(desc);
+ Intl()->Description(desc);
aDescription.Assign(desc);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetLanguage(nsAString& aLanguage)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->Language(aLanguage);
+ Intl()->Language(aLanguage);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetValue(nsAString& aValue)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString value;
- static_cast<Accessible*>(this)->Value(value);
+ Intl()->Value(value);
aValue.Assign(value);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetHelp(nsAString& aHelp)
{
- return NS_ERROR_NOT_IMPLEMENTED;
+ if (!Intl())
+ return NS_ERROR_FAILURE;
+
+ nsAutoString help;
+ Intl()->Help(help);
+ aHelp.Assign(help);
+
+ return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetAccessKey(nsAString& aAccessKey)
{
aAccessKey.Truncate();
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->AccessKey().ToString(aAccessKey);
+ Intl()->AccessKey().ToString(aAccessKey);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
{
aKeyBinding.Truncate();
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->KeyboardShortcut().ToString(aKeyBinding);
+ Intl()->KeyboardShortcut().ToString(aKeyBinding);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIPersistentProperties> attributes =
- static_cast<Accessible*>(this)->Attributes();
+ nsCOMPtr<nsIPersistentProperties> attributes = Intl()->Attributes();
attributes.swap(*aAttributes);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight)
@@ -310,46 +314,46 @@ xpcAccessible::GetBounds(int32_t* aX, in
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsIntRect rect = static_cast<Accessible*>(this)->Bounds();
+ nsIntRect rect = Intl()->Bounds();
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;;
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableGroupPosition(int32_t* aGroupLevel,
- int32_t* aSimilarItemsInGroup,
- int32_t* aPositionInGroup)
+xpcAccessible::GroupPosition(int32_t* aGroupLevel,
+ int32_t* aSimilarItemsInGroup,
+ int32_t* aPositionInGroup)
{
NS_ENSURE_ARG_POINTER(aGroupLevel);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- GroupPos groupPos = static_cast<Accessible*>(this)->GroupPosition();
+ GroupPos groupPos = Intl()->GroupPosition();
*aGroupLevel = groupPos.level;
*aSimilarItemsInGroup = groupPos.setSize;
*aPositionInGroup = groupPos.posInSet;
return NS_OK;
}
@@ -357,31 +361,31 @@ NS_IMETHODIMP
xpcAccessible::GetRelationByType(uint32_t aType,
nsIAccessibleRelation** aRelation)
{
NS_ENSURE_ARG_POINTER(aRelation);
*aRelation = nullptr;
NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- Relation rel = static_cast<Accessible*>(this)->RelationByType(static_cast<RelationType>(aType));
+ Relation rel = Intl()->RelationByType(static_cast<RelationType>(aType));
NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
return *aRelation ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
xpcAccessible::GetRelations(nsIArray** aRelations)
{
NS_ENSURE_ARG_POINTER(aRelations);
*aRelations = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
static const uint32_t relationTypes[] = {
nsIAccessibleRelation::RELATION_LABELLED_BY,
nsIAccessibleRelation::RELATION_LABEL_FOR,
@@ -422,151 +426,152 @@ xpcAccessible::GetRelations(nsIArray** a
}
NS_IMETHODIMP
xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aChild = static_cast<Accessible*>(this)->FocusedChild());
+ NS_IF_ADDREF(*aChild = ToXPC(Intl()->FocusedChild()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
nsIAccessible** aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aAccessible =
- static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
- Accessible::eDirectChild));
+ ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
nsIAccessible** aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aAccessible =
- static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
- Accessible::eDeepestChild));
+ ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableSetSelected(bool aSelect)
+xpcAccessible::SetSelected(bool aSelect)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->SetSelected(aSelect);
+ Intl()->SetSelected(aSelect);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::ExtendSelection()
{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-xpcAccessible::ScriptableTakeSelection()
-{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->TakeSelection();
+ Intl()->ExtendSelection();
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableTakeFocus()
+xpcAccessible::TakeSelection()
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->TakeFocus();
+ Intl()->TakeSelection();
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::TakeFocus()
+{
+ if (!Intl())
+ return NS_ERROR_FAILURE;
+
+ Intl()->TakeFocus();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetActionCount(uint8_t* aActionCount)
{
NS_ENSURE_ARG_POINTER(aActionCount);
*aActionCount = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aActionCount = static_cast<Accessible*>(this)->ActionCount();
+ *aActionCount = Intl()->ActionCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
+ if (aIndex >= Intl()->ActionCount())
return NS_ERROR_INVALID_ARG;
- static_cast<Accessible*>(this)->ActionNameAt(aIndex, aName);
+ Intl()->ActionNameAt(aIndex, aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
+ if (aIndex >= Intl()->ActionCount())
return NS_ERROR_INVALID_ARG;
- static_cast<Accessible*>(this)->ActionDescriptionAt(aIndex, aDescription);
+ Intl()->ActionDescriptionAt(aIndex, aDescription);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableDoAction(uint8_t aIndex)
+xpcAccessible::DoAction(uint8_t aIndex)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- return static_cast<Accessible*>(this)->DoAction(aIndex) ?
+ return Intl()->DoAction(aIndex) ?
NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableScrollTo(uint32_t aHow)
+xpcAccessible::ScrollTo(uint32_t aHow)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->ScrollTo(aHow);
+ Intl()->ScrollTo(aHow);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessible::ScriptableScrollToPoint(uint32_t aCoordinateType,
- int32_t aX, int32_t aY)
+xpcAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY)
{
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<Accessible*>(this)->ScrollToPoint(aCoordinateType, aX, aY);
+ Intl()->ScrollToPoint(aCoordinateType, aX, aY);
return NS_OK;
-}
\ No newline at end of file
+}
--- a/accessible/xpcom/xpcAccessible.h
+++ b/accessible/xpcom/xpcAccessible.h
@@ -9,27 +9,33 @@
#include "nsIAccessible.h"
class nsIAccessible;
namespace mozilla {
namespace a11y {
+class Accessible;
+
+/**
+ * XPCOM nsIAccessible interface implementation, used by xpcAccessibleGeneric
+ * class.
+ */
class xpcAccessible : public nsIAccessible
{
public:
+ // nsIAccessible
NS_IMETHOD GetParent(nsIAccessible** aParent) MOZ_FINAL;
NS_IMETHOD GetNextSibling(nsIAccessible** aNextSibling) MOZ_FINAL;
NS_IMETHOD GetPreviousSibling(nsIAccessible** aPreviousSibling) MOZ_FINAL;
NS_IMETHOD GetFirstChild(nsIAccessible** aFirstChild) MOZ_FINAL;
NS_IMETHOD GetLastChild(nsIAccessible** aLastChild) MOZ_FINAL;
NS_IMETHOD GetChildCount(int32_t* aChildCount) MOZ_FINAL;
- NS_IMETHOD ScriptableGetChildAt(int32_t aChildIndex,
- nsIAccessible** aChild) MOZ_FINAL;
+ NS_IMETHOD GetChildAt(int32_t aChildIndex, nsIAccessible** aChild) MOZ_FINAL;
NS_IMETHOD GetChildren(nsIArray** aChildren) MOZ_FINAL;
NS_IMETHOD GetIndexInParent(int32_t* aIndexInParent) MOZ_FINAL;
NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode) MOZ_FINAL;
NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument) MOZ_FINAL;
NS_IMETHOD GetRole(uint32_t* aRole) MOZ_FINAL;
@@ -42,46 +48,48 @@ public:
NS_IMETHOD GetHelp(nsAString& aHelp) MOZ_FINAL;
NS_IMETHOD GetAccessKey(nsAString& aAccessKey) MOZ_FINAL;
NS_IMETHOD GetKeyboardShortcut(nsAString& aKeyBinding) MOZ_FINAL;
NS_IMETHOD GetAttributes(nsIPersistentProperties** aAttributes) MOZ_FINAL;
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
- NS_IMETHOD ScriptableGroupPosition(int32_t* aGroupLevel,
- int32_t* aSimilarItemsInGroup,
- int32_t* aPositionInGroup) MOZ_FINAL;
+ NS_IMETHOD GroupPosition(int32_t* aGroupLevel, int32_t* aSimilarItemsInGroup,
+ int32_t* aPositionInGroup) MOZ_FINAL;
NS_IMETHOD GetRelationByType(uint32_t aType,
nsIAccessibleRelation** aRelation) MOZ_FINAL;
NS_IMETHOD GetRelations(nsIArray** aRelations) MOZ_FINAL;
NS_IMETHOD GetFocusedChild(nsIAccessible** aChild) MOZ_FINAL;
NS_IMETHOD GetChildAtPoint(int32_t aX, int32_t aY,
nsIAccessible** aAccessible) MOZ_FINAL;
NS_IMETHOD GetDeepestChildAtPoint(int32_t aX, int32_t aY,
nsIAccessible** aAccessible) MOZ_FINAL;
- NS_IMETHOD ScriptableSetSelected(bool aSelect) MOZ_FINAL;
+ NS_IMETHOD SetSelected(bool aSelect) MOZ_FINAL;
NS_IMETHOD ExtendSelection() MOZ_FINAL;
- NS_IMETHOD ScriptableTakeSelection() MOZ_FINAL;
- NS_IMETHOD ScriptableTakeFocus() MOZ_FINAL;
+ NS_IMETHOD TakeSelection() MOZ_FINAL;
+ NS_IMETHOD TakeFocus() MOZ_FINAL;
NS_IMETHOD GetActionCount(uint8_t* aActionCount) MOZ_FINAL;
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription) MOZ_FINAL;
- NS_IMETHOD ScriptableDoAction(uint8_t aIndex) MOZ_FINAL;
+ NS_IMETHOD DoAction(uint8_t aIndex) MOZ_FINAL;
- NS_IMETHOD ScriptableScrollTo(uint32_t aHow) MOZ_FINAL;
- NS_IMETHOD ScriptableScrollToPoint(uint32_t aCoordinateType,
- int32_t aX, int32_t aY) MOZ_FINAL;
+ NS_IMETHOD ScrollTo(uint32_t aHow) MOZ_FINAL;
+ NS_IMETHOD ScrollToPoint(uint32_t aCoordinateType,
+ int32_t aX, int32_t aY) MOZ_FINAL;
+
+protected:
+ xpcAccessible() { }
+ virtual ~xpcAccessible() {}
private:
- xpcAccessible() { }
- friend class Accessible;
+ Accessible* Intl();
xpcAccessible(const xpcAccessible&) MOZ_DELETE;
xpcAccessible& operator =(const xpcAccessible&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/xpcom/xpcAccessibleApplication.cpp
+++ b/accessible/xpcom/xpcAccessibleApplication.cpp
@@ -5,55 +5,65 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleApplication.h"
#include "ApplicationAccessible.h"
using namespace mozilla::a11y;
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports
+
+NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleApplication,
+ xpcAccessibleGeneric,
+ nsIAccessibleApplication)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleApplication
+
NS_IMETHODIMP
xpcAccessibleApplication::GetAppName(nsAString& aName)
{
aName.Truncate();
- if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<ApplicationAccessible*>(this)->AppName(aName);
+ Intl()->AppName(aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetAppVersion(nsAString& aVersion)
{
aVersion.Truncate();
- if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<ApplicationAccessible*>(this)->AppVersion(aVersion);
+ Intl()->AppVersion(aVersion);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetPlatformName(nsAString& aName)
{
aName.Truncate();
- if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<ApplicationAccessible*>(this)->PlatformName(aName);
+ Intl()->PlatformName(aName);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleApplication::GetPlatformVersion(nsAString& aVersion)
{
aVersion.Truncate();
- if (static_cast<ApplicationAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<ApplicationAccessible*>(this)->PlatformVersion(aVersion);
+ Intl()->PlatformVersion(aVersion);
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleApplication.h
+++ b/accessible/xpcom/xpcAccessibleApplication.h
@@ -3,33 +3,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_xpcAccessibleApplication_h_
#define mozilla_a11y_xpcAccessibleApplication_h_
#include "nsIAccessibleApplication.h"
-
-class nsIAccessible;
+#include "ApplicationAccessible.h"
+#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
-class xpcAccessibleApplication : public nsIAccessibleApplication
+/**
+ * XPCOM wrapper around ApplicationAccessible class.
+ */
+class xpcAccessibleApplication : public xpcAccessibleGeneric,
+ public nsIAccessibleApplication
{
public:
+ xpcAccessibleApplication(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
+
+ NS_DECL_ISUPPORTS_INHERITED
+
+ // nsIAccessibleApplication
NS_IMETHOD GetAppName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetAppVersion(nsAString& aVersion) MOZ_FINAL;
NS_IMETHOD GetPlatformName(nsAString& aName) MOZ_FINAL;
NS_IMETHOD GetPlatformVersion(nsAString& aVersion) MOZ_FINAL;
+protected:
+ virtual ~xpcAccessibleApplication() {}
+
private:
- xpcAccessibleApplication() { }
- friend class ApplicationAccessible;
+ ApplicationAccessible* Intl() { return mIntl->AsApplication(); }
xpcAccessibleApplication(const xpcAccessibleApplication&) MOZ_DELETE;
xpcAccessibleApplication& operator =(const xpcAccessibleApplication&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/xpcom/xpcAccessibleDocument.cpp
+++ b/accessible/xpcom/xpcAccessibleDocument.cpp
@@ -1,135 +1,203 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleDocument.h"
+#include "xpcAccessibleImage.h"
+#include "xpcAccessibleTable.h"
+#include "xpcAccessibleTableCell.h"
#include "DocAccessible-inl.h"
#include "nsIDOMDocument.h"
using namespace mozilla::a11y;
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports and cycle collection
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(xpcAccessibleDocument)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(xpcAccessibleDocument,
+ xpcAccessibleGeneric)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCache)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(xpcAccessibleDocument,
+ xpcAccessibleGeneric)
+ tmp->mCache.Clear();
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(xpcAccessibleDocument)
+ NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
+NS_INTERFACE_MAP_END_INHERITING(xpcAccessibleHyperText)
+
+NS_IMPL_ADDREF_INHERITED(xpcAccessibleDocument, xpcAccessibleHyperText)
+NS_IMPL_RELEASE_INHERITED(xpcAccessibleDocument, xpcAccessibleHyperText)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleDocument
+
NS_IMETHODIMP
xpcAccessibleDocument::GetURL(nsAString& aURL)
{
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<DocAccessible*>(this)->URL(aURL);
+ Intl()->URL(aURL);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetTitle(nsAString& aTitle)
{
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString title;
- static_cast<DocAccessible*>(this)->Title(title);
+ Intl()->Title(title);
aTitle = title;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetMimeType(nsAString& aType)
{
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<DocAccessible*>(this)->MimeType(aType);
+ Intl()->MimeType(aType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetDocType(nsAString& aType)
{
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- static_cast<DocAccessible*>(this)->DocType(aType);
+ Intl()->DocType(aType);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetDOMDocument(nsIDOMDocument** aDOMDocument)
{
NS_ENSURE_ARG_POINTER(aDOMDocument);
*aDOMDocument = nullptr;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (static_cast<DocAccessible*>(this)->DocumentNode())
- CallQueryInterface(static_cast<DocAccessible*>(this)->DocumentNode(), aDOMDocument);
+ if (Intl()->DocumentNode())
+ CallQueryInterface(Intl()->DocumentNode(), aDOMDocument);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetWindow(nsIDOMWindow** aDOMWindow)
{
NS_ENSURE_ARG_POINTER(aDOMWindow);
*aDOMWindow = nullptr;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aDOMWindow = static_cast<DocAccessible*>(this)->DocumentNode()->GetWindow());
+ NS_IF_ADDREF(*aDOMWindow = Intl()->DocumentNode()->GetWindow());
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetParentDocument(nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->ParentDocument());
+ NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->ParentDocument()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetChildDocumentCount(uint32_t* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aCount = static_cast<DocAccessible*>(this)->ChildDocumentCount();
+ *aCount = Intl()->ChildDocumentCount();
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleDocument::ScriptableGetChildDocumentAt(uint32_t aIndex,
- nsIAccessibleDocument** aDocument)
+xpcAccessibleDocument::GetChildDocumentAt(uint32_t aIndex,
+ nsIAccessibleDocument** aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
*aDocument = nullptr;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aDocument = static_cast<DocAccessible*>(this)->GetChildDocumentAt(aIndex));
+ NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->GetChildDocumentAt(aIndex)));
return *aDocument ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
xpcAccessibleDocument::GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
{
NS_ENSURE_ARG_POINTER(aVirtualCursor);
*aVirtualCursor = nullptr;
- if (static_cast<DocAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_ADDREF(*aVirtualCursor = static_cast<DocAccessible*>(this)->VirtualCursor());
+ NS_ADDREF(*aVirtualCursor = Intl()->VirtualCursor());
return NS_OK;
}
+
+////////////////////////////////////////////////////////////////////////////////
+// xpcAccessibleDocument
+
+xpcAccessibleGeneric*
+xpcAccessibleDocument::GetAccessible(Accessible* aAccessible)
+{
+ if (ToXPCDocument(aAccessible->Document()) != this) {
+ NS_ERROR("This XPCOM document is not related with given internal accessible!");
+ return nullptr;
+ }
+
+ if (aAccessible->IsDoc())
+ return this;
+
+ xpcAccessibleGeneric* xpcAcc = mCache.GetWeak(aAccessible);
+ if (xpcAcc)
+ return xpcAcc;
+
+ if (aAccessible->IsImage())
+ xpcAcc = new xpcAccessibleImage(aAccessible);
+ else if (aAccessible->IsTable())
+ xpcAcc = new xpcAccessibleTable(aAccessible);
+ else if (aAccessible->IsTableCell())
+ xpcAcc = new xpcAccessibleTableCell(aAccessible);
+ else if (aAccessible->IsHyperText())
+ xpcAcc = new xpcAccessibleHyperText(aAccessible);
+ else
+ xpcAcc = new xpcAccessibleGeneric(aAccessible);
+
+ mCache.Put(aAccessible, xpcAcc);
+ return xpcAcc;
+}
+
+void
+xpcAccessibleDocument::Shutdown()
+{
+ mCache.Clear();
+ xpcAccessibleGeneric::Shutdown();
+}
--- a/accessible/xpcom/xpcAccessibleDocument.h
+++ b/accessible/xpcom/xpcAccessibleDocument.h
@@ -4,39 +4,109 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_xpcAccessibleDocument_h_
#define mozilla_a11y_xpcAccessibleDocument_h_
#include "nsIAccessibleDocument.h"
+#include "DocAccessible.h"
+#include "nsAccessibilityService.h"
+#include "xpcAccessibleApplication.h"
+#include "xpcAccessibleHyperText.h"
+
namespace mozilla {
namespace a11y {
-class xpcAccessibleDocument : public nsIAccessibleDocument
+/**
+ * XPCOM wrapper around DocAccessible class.
+ */
+class xpcAccessibleDocument : public xpcAccessibleHyperText,
+ public nsIAccessibleDocument
{
public:
+ xpcAccessibleDocument(DocAccessible* aIntl) :
+ xpcAccessibleHyperText(aIntl), mCache(kDefaultCacheLength) { }
+
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(xpcAccessibleDocument,
+ xpcAccessibleGeneric)
+
+ // nsIAccessibleDocument
NS_IMETHOD GetURL(nsAString& aURL) MOZ_FINAL;
NS_IMETHOD GetTitle(nsAString& aTitle) MOZ_FINAL;
NS_IMETHOD GetMimeType(nsAString& aType) MOZ_FINAL;
NS_IMETHOD GetDocType(nsAString& aType) MOZ_FINAL;
NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument) MOZ_FINAL;
NS_IMETHOD GetWindow(nsIDOMWindow** aDOMWindow) MOZ_FINAL;
NS_IMETHOD GetParentDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetChildDocumentCount(uint32_t* aCount) MOZ_FINAL;
- NS_IMETHOD ScriptableGetChildDocumentAt(uint32_t aIndex,
- nsIAccessibleDocument** aDocument) MOZ_FINAL;
+ NS_IMETHOD GetChildDocumentAt(uint32_t aIndex,
+ nsIAccessibleDocument** aDocument) MOZ_FINAL;
NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor) MOZ_FINAL;
+ /**
+ * Return XPCOM wrapper for the internal accessible.
+ */
+ xpcAccessibleGeneric* GetAccessible(Accessible* aAccessible);
+
+ virtual void Shutdown() MOZ_OVERRIDE;
+
+protected:
+ virtual ~xpcAccessibleDocument() {}
+
private:
+ DocAccessible* Intl() { return mIntl->AsDoc(); }
+
+ void NotifyOfShutdown(Accessible* aAccessible)
+ {
+ xpcAccessibleGeneric* xpcAcc = mCache.GetWeak(aAccessible);
+ if (xpcAcc)
+ xpcAcc->Shutdown();
+
+ mCache.Remove(aAccessible);
+ }
+
+ friend class DocManager;
friend class DocAccessible;
- xpcAccessibleDocument() { }
-
xpcAccessibleDocument(const xpcAccessibleDocument&) MOZ_DELETE;
xpcAccessibleDocument& operator =(const xpcAccessibleDocument&) MOZ_DELETE;
+
+ nsRefPtrHashtable<nsPtrHashKey<const Accessible>, xpcAccessibleGeneric> mCache;
};
+inline xpcAccessibleGeneric*
+ToXPC(Accessible* aAccessible)
+{
+ if (!aAccessible)
+ return nullptr;
+
+ if (aAccessible->IsApplication())
+ return XPCApplicationAcc();
+
+ xpcAccessibleDocument* xpcDoc =
+ GetAccService()->GetXPCDocument(aAccessible->Document());
+ return xpcDoc ? xpcDoc->GetAccessible(aAccessible) : nullptr;
+}
+
+inline xpcAccessibleHyperText*
+ToXPCText(HyperTextAccessible* aAccessible)
+{
+ if (!aAccessible)
+ return nullptr;
+
+ xpcAccessibleDocument* xpcDoc =
+ GetAccService()->GetXPCDocument(aAccessible->Document());
+ return static_cast<xpcAccessibleHyperText*>(xpcDoc->GetAccessible(aAccessible));
+}
+
+inline xpcAccessibleDocument*
+ToXPCDocument(DocAccessible* aAccessible)
+{
+ return GetAccService()->GetXPCDocument(aAccessible);
+}
+
} // namespace a11y
} // namespace mozilla
#endif
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessibleGeneric.cpp
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "xpcAccessibleGeneric.h"
+
+using namespace mozilla::a11y;
+
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports and cycle collection
+
+NS_IMPL_CYCLE_COLLECTION_0(xpcAccessibleGeneric)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(xpcAccessibleGeneric)
+ NS_INTERFACE_MAP_ENTRY(nsIAccessible)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleSelectable,
+ mSupportedIfaces & eSelectable)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleValue,
+ mSupportedIfaces & eValue)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperLink,
+ mSupportedIfaces & eHyperLink)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessible)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(xpcAccessibleGeneric)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(xpcAccessibleGeneric)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessible
+
+Accessible*
+xpcAccessibleGeneric::ToInternalAccessible() const
+{
+ return mIntl;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// xpcAccessibleGeneric
+
+void
+xpcAccessibleGeneric::Shutdown()
+{
+ mIntl = nullptr;
+}
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessibleGeneric.h
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_a11y_xpcAccessibleGeneric_h_
+#define mozilla_a11y_xpcAccessibleGeneric_h_
+
+#include "xpcAccessible.h"
+#include "xpcAccessibleHyperLink.h"
+#include "xpcAccessibleSelectable.h"
+#include "xpcAccessibleValue.h"
+
+#include "Accessible.h"
+
+namespace mozilla {
+namespace a11y {
+
+/**
+ * XPCOM wrapper around Accessible class.
+ */
+class xpcAccessibleGeneric : public xpcAccessible,
+ public xpcAccessibleHyperLink,
+ public xpcAccessibleSelectable,
+ public xpcAccessibleValue
+{
+public:
+ xpcAccessibleGeneric(Accessible* aInternal) :
+ mIntl(aInternal), mSupportedIfaces(0)
+ {
+ if (mIntl->IsSelect())
+ mSupportedIfaces |= eSelectable;
+ if (mIntl->HasNumericValue())
+ mSupportedIfaces |= eValue;
+ if (mIntl->IsLink())
+ mSupportedIfaces |= eHyperLink;
+ }
+
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(xpcAccessibleGeneric, nsIAccessible)
+
+ // nsIAccessible
+ virtual Accessible* ToInternalAccessible() const MOZ_FINAL;
+
+ // xpcAccessibleGeneric
+ virtual void Shutdown();
+
+protected:
+ virtual ~xpcAccessibleGeneric() {}
+
+ Accessible* mIntl;
+
+ enum {
+ eSelectable = 1 << 0,
+ eValue = 1 << 1,
+ eHyperLink = 1 << 2,
+ eText = 1 << 3
+ };
+ uint8_t mSupportedIfaces;
+
+private:
+ friend class Accessible;
+ friend class xpcAccessible;
+ friend class xpcAccessibleHyperLink;
+ friend class xpcAccessibleSelectable;
+ friend class xpcAccessibleValue;
+
+ xpcAccessibleGeneric(const xpcAccessibleGeneric&) MOZ_DELETE;
+ xpcAccessibleGeneric& operator =(const xpcAccessibleGeneric&) MOZ_DELETE;
+};
+
+inline Accessible*
+xpcAccessible::Intl()
+{
+ return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
+}
+
+inline Accessible*
+xpcAccessibleHyperLink::Intl()
+{
+ return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
+}
+
+inline Accessible*
+xpcAccessibleSelectable::Intl()
+{
+ return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
+}
+
+inline Accessible*
+xpcAccessibleValue::Intl()
+{
+ return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
+}
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/xpcom/xpcAccessibleHyperLink.cpp
+++ b/accessible/xpcom/xpcAccessibleHyperLink.cpp
@@ -1,97 +1,94 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "xpcAccessibleHyperLink.h"
-
#include "Accessible-inl.h"
+#include "xpcAccessibleDocument.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
{
NS_ENSURE_ARG_POINTER(aStartIndex);
*aStartIndex = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aStartIndex = static_cast<Accessible*>(this)->StartOffset();
+ *aStartIndex = Intl()->StartOffset();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
{
NS_ENSURE_ARG_POINTER(aEndIndex);
*aEndIndex = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aEndIndex = static_cast<Accessible*>(this)->EndOffset();
+ *aEndIndex = Intl()->EndOffset();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
{
NS_ENSURE_ARG_POINTER(aAnchorCount);
*aAnchorCount = 0;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aAnchorCount = static_cast<Accessible*>(this)->AnchorCount();
+ *aAnchorCount = Intl()->AnchorCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
- Accessible* thisAcc = static_cast<Accessible*>(this);
- if (thisAcc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
+ if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
return NS_ERROR_INVALID_ARG;
- nsRefPtr<nsIURI>(thisAcc->AnchorURIAt(aIndex)).forget(aURI);
+ nsRefPtr<nsIURI>(Intl()->AnchorURIAt(aIndex)).forget(aURI);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
- Accessible* thisAcc = static_cast<Accessible*>(this);
- if (thisAcc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
+ if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
return NS_ERROR_INVALID_ARG;
- NS_IF_ADDREF(*aAccessible = thisAcc->AnchorAt(aIndex));
+ NS_IF_ADDREF(*aAccessible = ToXPC(Intl()->AnchorAt(aIndex)));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperLink::GetValid(bool* aValid)
{
NS_ENSURE_ARG_POINTER(aValid);
*aValid = false;
- if (static_cast<Accessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aValid = static_cast<Accessible*>(this)->IsLinkValid();
+ *aValid = Intl()->IsLinkValid();
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleHyperLink.h
+++ b/accessible/xpcom/xpcAccessibleHyperLink.h
@@ -9,30 +9,39 @@
#include "nsIAccessibleHyperLink.h"
class nsIAccessible;
namespace mozilla {
namespace a11y {
+class Accessible;
+
+/**
+ * XPCOM nsIAccessibleHyperLink implementation, used by xpcAccessibleGeneric
+ * class.
+ */
class xpcAccessibleHyperLink : public nsIAccessibleHyperLink
{
public:
NS_IMETHOD GetAnchorCount(int32_t* aAnchorCount) MOZ_FINAL;
NS_IMETHOD GetStartIndex(int32_t* aStartIndex) MOZ_FINAL;
NS_IMETHOD GetEndIndex(int32_t* aEndIndex) MOZ_FINAL;
NS_IMETHOD GetURI(int32_t aIndex, nsIURI** aURI) MOZ_FINAL;
NS_IMETHOD GetAnchor(int32_t aIndex, nsIAccessible** aAccessible) MOZ_FINAL;
NS_IMETHOD GetValid(bool* aValid) MOZ_FINAL;
-private:
+protected:
xpcAccessibleHyperLink() { }
- friend class Accessible;
+ virtual ~xpcAccessibleHyperLink() {}
+private:
xpcAccessibleHyperLink(const xpcAccessibleHyperLink&) MOZ_DELETE;
xpcAccessibleHyperLink& operator =(const xpcAccessibleHyperLink&) MOZ_DELETE;
+
+ Accessible* Intl();
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/xpcom/xpcAccessibleHyperText.cpp
+++ b/accessible/xpcom/xpcAccessibleHyperText.cpp
@@ -1,210 +1,193 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleHyperText.h"
+#include "Accessible-inl.h"
#include "HyperTextAccessible-inl.h"
#include "TextRange.h"
+#include "xpcAccessibleDocument.h"
#include "xpcAccessibleTextRange.h"
#include "nsIPersistentProperties2.h"
#include "nsIMutableArray.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
-nsresult
-xpcAccessibleHyperText::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
- *aInstancePtr = nullptr;
-
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (!text->IsTextRole())
- return NS_ERROR_NO_INTERFACE;
+NS_INTERFACE_MAP_BEGIN(xpcAccessibleHyperText)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleText,
+ mSupportedIfaces & eText)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleEditableText,
+ mSupportedIfaces & eText)
+ NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperText,
+ mSupportedIfaces & eText)
+NS_INTERFACE_MAP_END_INHERITING(xpcAccessibleGeneric)
- if (aIID.Equals(NS_GET_IID(nsIAccessibleText)))
- *aInstancePtr = static_cast<nsIAccessibleText*>(text);
- else if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText)))
- *aInstancePtr = static_cast<nsIAccessibleEditableText*>(text);
- else if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText)))
- *aInstancePtr = static_cast<nsIAccessibleHyperText*>(text);
- else
- return NS_ERROR_NO_INTERFACE;
-
- NS_ADDREF(text);
- return NS_OK;
-}
+NS_IMPL_ADDREF_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
+NS_IMPL_RELEASE_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleText
NS_IMETHODIMP
xpcAccessibleHyperText::GetCharacterCount(int32_t* aCharacterCount)
{
NS_ENSURE_ARG_POINTER(aCharacterCount);
*aCharacterCount = 0;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aCharacterCount = text->CharacterCount();
+ *aCharacterCount = Intl()->CharacterCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetText(int32_t aStartOffset, int32_t aEndOffset,
nsAString& aText)
{
aText.Truncate();
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->TextSubstring(aStartOffset, aEndOffset, aText);
+ Intl()->TextSubstring(aStartOffset, aEndOffset, aText);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetTextBeforeOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset,
int32_t* aEndOffset,
nsAString& aText)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
NS_ENSURE_ARG_POINTER(aEndOffset);
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+ Intl()->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetTextAtOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset,
int32_t* aEndOffset, nsAString& aText)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
NS_ENSURE_ARG_POINTER(aEndOffset);
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+ Intl()->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetTextAfterOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset,
int32_t* aEndOffset, nsAString& aText)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
NS_ENSURE_ARG_POINTER(aEndOffset);
*aStartOffset = *aEndOffset = 0;
aText.Truncate();
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
+ Intl()->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetCharacterAtOffset(int32_t aOffset,
char16_t* aCharacter)
{
NS_ENSURE_ARG_POINTER(aCharacter);
*aCharacter = L'\0';
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aCharacter = text->CharAt(aOffset);
+ *aCharacter = Intl()->CharAt(aOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetTextAttributes(bool aIncludeDefAttrs,
int32_t aOffset,
int32_t* aStartOffset,
int32_t* aEndOffset,
nsIPersistentProperties** aAttributes)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
NS_ENSURE_ARG_POINTER(aEndOffset);
NS_ENSURE_ARG_POINTER(aAttributes);
*aStartOffset = *aEndOffset = 0;
*aAttributes = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> attrs =
- text->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
+ Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
attrs.swap(*aAttributes);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties** aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIPersistentProperties> attrs = text->DefaultTextAttributes();
+ nsCOMPtr<nsIPersistentProperties> attrs = Intl()->DefaultTextAttributes();
attrs.swap(*aAttributes);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetCharacterExtents(int32_t aOffset,
int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight,
uint32_t aCoordType)
{
NS_ENSURE_ARG_POINTER(aX);
NS_ENSURE_ARG_POINTER(aY);
NS_ENSURE_ARG_POINTER(aWidth);
NS_ENSURE_ARG_POINTER(aHeight);
*aX = *aY = *aWidth = *aHeight;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsIntRect rect = text->CharBounds(aOffset, aCoordType);
+ nsIntRect rect = Intl()->CharBounds(aOffset, aCoordType);
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset,
int32_t* aX, int32_t* aY,
@@ -212,407 +195,378 @@ xpcAccessibleHyperText::GetRangeExtents(
uint32_t aCoordType)
{
NS_ENSURE_ARG_POINTER(aX);
NS_ENSURE_ARG_POINTER(aY);
NS_ENSURE_ARG_POINTER(aWidth);
NS_ENSURE_ARG_POINTER(aHeight);
*aX = *aY = *aWidth = *aHeight = 0;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsIntRect rect = text->TextBounds(aStartOffset, aEndOffset, aCoordType);
+ nsIntRect rect = Intl()->TextBounds(aStartOffset, aEndOffset, aCoordType);
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetOffsetAtPoint(int32_t aX, int32_t aY,
uint32_t aCoordType, int32_t* aOffset)
{
NS_ENSURE_ARG_POINTER(aOffset);
*aOffset = -1;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aOffset = text->OffsetAtPoint(aX, aY, aCoordType);
+ *aOffset = Intl()->OffsetAtPoint(aX, aY, aCoordType);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::GetScriptableCaretOffset(int32_t* aCaretOffset)
+xpcAccessibleHyperText::GetCaretOffset(int32_t* aCaretOffset)
{
NS_ENSURE_ARG_POINTER(aCaretOffset);
*aCaretOffset = -1;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aCaretOffset = text->CaretOffset();
+ *aCaretOffset = Intl()->CaretOffset();
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::SetScriptableCaretOffset(int32_t aCaretOffset)
+xpcAccessibleHyperText::SetCaretOffset(int32_t aCaretOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->SetCaretOffset(aCaretOffset);
+ Intl()->SetCaretOffset(aCaretOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetSelectionCount(int32_t* aSelectionCount)
{
NS_ENSURE_ARG_POINTER(aSelectionCount);
*aSelectionCount = 0;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aSelectionCount = text->SelectionCount();
+ *aSelectionCount = Intl()->SelectionCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetSelectionBounds(int32_t aSelectionNum,
int32_t* aStartOffset,
int32_t* aEndOffset)
{
NS_ENSURE_ARG_POINTER(aStartOffset);
NS_ENSURE_ARG_POINTER(aEndOffset);
*aStartOffset = *aEndOffset = 0;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aSelectionNum < 0 || aSelectionNum >= text->SelectionCount())
+ if (aSelectionNum < 0 || aSelectionNum >= Intl()->SelectionCount())
return NS_ERROR_INVALID_ARG;
- text->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
+ Intl()->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::SetSelectionBounds(int32_t aSelectionNum,
int32_t aStartOffset,
int32_t aEndOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
if (aSelectionNum < 0 ||
- !text->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
+ !Intl()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
return NS_ERROR_INVALID_ARG;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::AddSelection(int32_t aStartOffset, int32_t aEndOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->AddToSelection(aStartOffset, aEndOffset);
+ Intl()->AddToSelection(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::RemoveSelection(int32_t aSelectionNum)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->RemoveFromSelection(aSelectionNum);
+ Intl()->RemoveFromSelection(aSelectionNum);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableScrollSubstringTo(int32_t aStartOffset,
- int32_t aEndOffset,
- uint32_t aScrollType)
+xpcAccessibleHyperText::ScrollSubstringTo(int32_t aStartOffset,
+ int32_t aEndOffset,
+ uint32_t aScrollType)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
+ Intl()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableScrollSubstringToPoint(int32_t aStartOffset,
- int32_t aEndOffset,
- uint32_t aCoordinateType,
- int32_t aX, int32_t aY)
+xpcAccessibleHyperText::ScrollSubstringToPoint(int32_t aStartOffset,
+ int32_t aEndOffset,
+ uint32_t aCoordinateType,
+ int32_t aX, int32_t aY)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
+ Intl()->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetEnclosingRange(nsIAccessibleTextRange** aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
- text->EnclosingRange(range->mRange);
+ Intl()->EnclosingRange(range->mRange);
NS_ASSERTION(range->mRange.IsValid(),
"Should always have an enclosing range!");
range.forget(aRange);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetSelectionRanges(nsIArray** aRanges)
{
NS_ENSURE_ARG_POINTER(aRanges);
*aRanges = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> xpcRanges =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoTArray<TextRange, 1> ranges;
- text->SelectionRanges(&ranges);
+ Intl()->SelectionRanges(&ranges);
uint32_t len = ranges.Length();
for (uint32_t idx = 0; idx < len; idx++)
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
false);
xpcRanges.forget(aRanges);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetVisibleRanges(nsIArray** aRanges)
{
NS_ENSURE_ARG_POINTER(aRanges);
*aRanges = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> xpcRanges =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<TextRange> ranges;
- text->VisibleRanges(&ranges);
+ Intl()->VisibleRanges(&ranges);
uint32_t len = ranges.Length();
for (uint32_t idx = 0; idx < len; idx++)
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
false);
xpcRanges.forget(aRanges);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetRangeByChild(nsIAccessible* aChild,
nsIAccessibleTextRange** aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsRefPtr<Accessible> child = do_QueryObject(aChild);
+ Accessible* child = aChild->ToInternalAccessible();
if (child) {
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
- text->RangeByChild(child, range->mRange);
+ Intl()->RangeByChild(child, range->mRange);
if (range->mRange.IsValid())
range.forget(aRange);
}
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetRangeAtPoint(int32_t aX, int32_t aY,
nsIAccessibleTextRange** aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
*aRange = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
- text->RangeAtPoint(aX, aY, range->mRange);
+ Intl()->RangeAtPoint(aX, aY, range->mRange);
if (range->mRange.IsValid())
range.forget(aRange);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleEditableText
NS_IMETHODIMP
xpcAccessibleHyperText::SetTextContents(const nsAString& aText)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->ReplaceText(aText);
+ Intl()->ReplaceText(aText);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableInsertText(const nsAString& aText,
- int32_t aOffset)
+xpcAccessibleHyperText::InsertText(const nsAString& aText, int32_t aOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->InsertText(aText, aOffset);
+ Intl()->InsertText(aText, aOffset);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableCopyText(int32_t aStartOffset,
- int32_t aEndOffset)
+xpcAccessibleHyperText::CopyText(int32_t aStartOffset, int32_t aEndOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->CopyText(aStartOffset, aEndOffset);
+ Intl()->CopyText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableCutText(int32_t aStartOffset,
- int32_t aEndOffset)
+xpcAccessibleHyperText::CutText(int32_t aStartOffset, int32_t aEndOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->CutText(aStartOffset, aEndOffset);
+ Intl()->CutText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptableDeleteText(int32_t aStartOffset,
- int32_t aEndOffset)
+xpcAccessibleHyperText::DeleteText(int32_t aStartOffset, int32_t aEndOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->DeleteText(aStartOffset, aEndOffset);
+ Intl()->DeleteText(aStartOffset, aEndOffset);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleHyperText::ScriptablePasteText(int32_t aOffset)
+xpcAccessibleHyperText::PasteText(int32_t aOffset)
{
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- text->PasteText(aOffset);
+ Intl()->PasteText(aOffset);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleHyperText
NS_IMETHODIMP
xpcAccessibleHyperText::GetLinkCount(int32_t* aLinkCount)
{
NS_ENSURE_ARG_POINTER(aLinkCount);
*aLinkCount = 0;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aLinkCount = text->LinkCount();
+ *aLinkCount = Intl()->LinkCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetLinkAt(int32_t aIndex, nsIAccessibleHyperLink** aLink)
{
NS_ENSURE_ARG_POINTER(aLink);
*aLink = nullptr;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsCOMPtr<nsIAccessibleHyperLink> link = text->LinkAt(aIndex);
- link.forget(aLink);
-
+ NS_IF_ADDREF(*aLink = ToXPC(Intl()->LinkAt(aIndex)));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetLinkIndex(nsIAccessibleHyperLink* aLink,
int32_t* aIndex)
{
NS_ENSURE_ARG_POINTER(aLink);
NS_ENSURE_ARG_POINTER(aIndex);
*aIndex = -1;
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsRefPtr<Accessible> link(do_QueryObject(aLink));
- *aIndex = text->LinkIndexOf(link);
+ nsCOMPtr<nsIAccessible> xpcLink(do_QueryInterface(aLink));
+ Accessible* link = xpcLink->ToInternalAccessible();
+ if (link)
+ *aIndex = Intl()->LinkIndexOf(link);
+
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleHyperText::GetLinkIndexAtOffset(int32_t aOffset,
int32_t* aLinkIndex)
{
NS_ENSURE_ARG_POINTER(aLinkIndex);
*aLinkIndex = -1; // API says this magic value means 'not found'
- HyperTextAccessible* text = static_cast<HyperTextAccessible*>(this);
- if (text->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aLinkIndex = text->LinkIndexAtOffset(aOffset);
+ *aLinkIndex = Intl()->LinkIndexAtOffset(aOffset);
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleHyperText.h
+++ b/accessible/xpcom/xpcAccessibleHyperText.h
@@ -6,33 +6,45 @@
#ifndef mozilla_a11y_xpcAccessibleHyperText_h_
#define mozilla_a11y_xpcAccessibleHyperText_h_
#include "nsIAccessibleText.h"
#include "nsIAccessibleHyperText.h"
#include "nsIAccessibleEditableText.h"
+#include "HyperTextAccessible.h"
+#include "xpcAccessibleGeneric.h"
+
namespace mozilla {
namespace a11y {
-class xpcAccessibleHyperText : public nsIAccessibleText,
+class xpcAccessibleHyperText : public xpcAccessibleGeneric,
+ public nsIAccessibleText,
public nsIAccessibleEditableText,
public nsIAccessibleHyperText
{
public:
- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
+ xpcAccessibleHyperText(Accessible* aIntl) : xpcAccessibleGeneric(aIntl)
+ {
+ if (mIntl->IsHyperText() && mIntl->AsHyperText()->IsTextRole())
+ mSupportedIfaces |= eText;
+ }
+
+ NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXT
NS_DECL_NSIACCESSIBLEHYPERTEXT
NS_DECL_NSIACCESSIBLEEDITABLETEXT
+protected:
+ virtual ~xpcAccessibleHyperText() {}
+
private:
- xpcAccessibleHyperText() { }
- friend class HyperTextAccessible;
+ HyperTextAccessible* Intl() { return mIntl->AsHyperText(); }
xpcAccessibleHyperText(const xpcAccessibleHyperText&) MOZ_DELETE;
xpcAccessibleHyperText& operator =(const xpcAccessibleHyperText&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/xpcom/xpcAccessibleImage.cpp
+++ b/accessible/xpcom/xpcAccessibleImage.cpp
@@ -5,40 +5,51 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleImage.h"
#include "ImageAccessible.h"
using namespace mozilla::a11y;
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports
+
+NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleImage,
+ xpcAccessibleGeneric,
+ nsIAccessibleImage)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleImage
+
NS_IMETHODIMP
-xpcAccessibleImage::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
+xpcAccessibleImage::GetImagePosition(uint32_t aCoordType,
+ int32_t* aX, int32_t* aY)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
- if (static_cast<ImageAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsIntPoint point = static_cast<ImageAccessible*>(this)->Position(aCoordType);
+ nsIntPoint point = Intl()->Position(aCoordType);
*aX = point.x; *aY = point.y;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleImage::GetImageSize(int32_t* aWidth, int32_t* aHeight)
{
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
- if (static_cast<ImageAccessible*>(this)->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsIntSize size = static_cast<ImageAccessible*>(this)->Size();
+ nsIntSize size = Intl()->Size();
*aWidth = size.width;
*aHeight = size.height;
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleImage.h
+++ b/accessible/xpcom/xpcAccessibleImage.h
@@ -4,30 +4,38 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_xpcAccessibleImage_h_
#define mozilla_a11y_xpcAccessibleImage_h_
#include "nsIAccessibleImage.h"
+#include "xpcAccessibleGeneric.h"
+
namespace mozilla {
namespace a11y {
-class xpcAccessibleImage : public nsIAccessibleImage
+class xpcAccessibleImage : public xpcAccessibleGeneric,
+ public nsIAccessibleImage
{
public:
+ xpcAccessibleImage(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
+
+ NS_DECL_ISUPPORTS_INHERITED
+
NS_IMETHOD GetImagePosition(uint32_t aCoordType,
int32_t* aX, int32_t* aY) MOZ_FINAL;
NS_IMETHOD GetImageSize(int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
+protected:
+ virtual ~xpcAccessibleImage() {}
+
private:
- friend class ImageAccessible;
-
- xpcAccessibleImage() { }
+ ImageAccessible* Intl() { return mIntl->AsImage(); }
xpcAccessibleImage(const xpcAccessibleImage&) MOZ_DELETE;
xpcAccessibleImage& operator =(const xpcAccessibleImage&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/xpcom/xpcAccessibleSelectable.cpp
+++ b/accessible/xpcom/xpcAccessibleSelectable.cpp
@@ -1,134 +1,134 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "xpcAccessibleSelectable.h"
+#include "Accessible-inl.h"
+#include "xpcAccessibleDocument.h"
-#include "Accessible-inl.h"
+#include "nsIMutableArray.h"
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems)
{
NS_ENSURE_ARG_POINTER(aSelectedItems);
*aSelectedItems = nullptr;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+
+ nsAutoTArray<Accessible*, 10> items;
+ Intl()->SelectedItems(&items);
- nsCOMPtr<nsIArray> items = acc->SelectedItems();
- if (items) {
- uint32_t length = 0;
- items->GetLength(&length);
- if (length)
- items.swap(*aSelectedItems);
- }
+ uint32_t itemCount = items.Length();
+ if (itemCount == 0)
+ return NS_OK;
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIMutableArray> xpcItems =
+ do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ for (uint32_t idx = 0; idx < itemCount; idx++)
+ xpcItems->AppendElement(static_cast<nsIAccessible*>(ToXPC(items[idx])), false);
+
+ NS_ADDREF(*aSelectedItems = xpcItems);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount)
{
NS_ENSURE_ARG_POINTER(aSelectionCount);
*aSelectionCount = 0;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- *aSelectionCount = acc->SelectedItemCount();
+ *aSelectionCount = Intl()->SelectedItemCount();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
nsIAccessible** aSelected)
{
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = nullptr;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- *aSelected = acc->GetSelectedItem(aIndex);
+ *aSelected = ToXPC(Intl()->GetSelectedItem(aIndex));
if (*aSelected) {
NS_ADDREF(*aSelected);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
-xpcAccessibleSelectable::ScriptableIsItemSelected(uint32_t aIndex,
- bool* aIsSelected)
+xpcAccessibleSelectable::IsItemSelected(uint32_t aIndex, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- *aIsSelected = acc->IsItemSelected(aIndex);
+ *aIsSelected = Intl()->IsItemSelected(aIndex);
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleSelectable::ScriptableAddItemToSelection(uint32_t aIndex)
+xpcAccessibleSelectable::AddItemToSelection(uint32_t aIndex)
{
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- return acc->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
+ return Intl()->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
-xpcAccessibleSelectable::ScriptableRemoveItemFromSelection(uint32_t aIndex)
+xpcAccessibleSelectable::RemoveItemFromSelection(uint32_t aIndex)
{
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- return acc->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
+ return Intl()->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
-xpcAccessibleSelectable::ScriptableSelectAll(bool* aIsMultiSelect)
+xpcAccessibleSelectable::SelectAll(bool* aIsMultiSelect)
{
NS_ENSURE_ARG_POINTER(aIsMultiSelect);
*aIsMultiSelect = false;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- *aIsMultiSelect = acc->SelectAll();
+ *aIsMultiSelect = Intl()->SelectAll();
return NS_OK;
}
NS_IMETHODIMP
-xpcAccessibleSelectable::ScriptableUnselectAll()
+xpcAccessibleSelectable::UnselectAll()
{
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+ NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
- acc->UnselectAll();
+ Intl()->UnselectAll();
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleSelectable.h
+++ b/accessible/xpcom/xpcAccessibleSelectable.h
@@ -10,32 +10,42 @@
#include "nsIAccessibleSelectable.h"
class nsIAccessible;
class nsIArray;
namespace mozilla {
namespace a11y {
+class Accessible;
+
+/**
+ * XPCOM nsIAccessibleSelectable inteface implementation, used by
+ * xpcAccessibleGeneric class.
+ */
class xpcAccessibleSelectable : public nsIAccessibleSelectable
{
public:
+ // nsIAccessibleSelectable
NS_IMETHOD GetSelectedItems(nsIArray** aSelectedItems) MOZ_FINAL;
NS_IMETHOD GetSelectedItemCount(uint32_t* aSelectedItemCount) MOZ_FINAL;
NS_IMETHOD GetSelectedItemAt(uint32_t aIndex, nsIAccessible** aItem) MOZ_FINAL;
- NS_IMETHOD ScriptableIsItemSelected(uint32_t aIndex, bool* aIsSelected) MOZ_FINAL;
- NS_IMETHOD ScriptableAddItemToSelection(uint32_t aIndex) MOZ_FINAL;
- NS_IMETHOD ScriptableRemoveItemFromSelection(uint32_t aIndex) MOZ_FINAL;
- NS_IMETHOD ScriptableSelectAll(bool* aIsMultiSelect) MOZ_FINAL;
- NS_IMETHOD ScriptableUnselectAll() MOZ_FINAL;
+ NS_IMETHOD IsItemSelected(uint32_t aIndex, bool* aIsSelected) MOZ_FINAL;
+ NS_IMETHOD AddItemToSelection(uint32_t aIndex) MOZ_FINAL;
+ NS_IMETHOD RemoveItemFromSelection(uint32_t aIndex) MOZ_FINAL;
+ NS_IMETHOD SelectAll(bool* aIsMultiSelect) MOZ_FINAL;
+ NS_IMETHOD UnselectAll() MOZ_FINAL;
+
+protected:
+ xpcAccessibleSelectable() { }
+ virtual ~xpcAccessibleSelectable() {}
private:
- xpcAccessibleSelectable() { }
- friend class Accessible;
-
xpcAccessibleSelectable(const xpcAccessibleSelectable&) MOZ_DELETE;
xpcAccessibleSelectable& operator =(const xpcAccessibleSelectable&) MOZ_DELETE;
+
+ Accessible* Intl();
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/xpcom/xpcAccessibleTable.cpp
+++ b/accessible/xpcom/xpcAccessibleTable.cpp
@@ -3,485 +3,491 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleTable.h"
#include "Accessible.h"
#include "TableAccessible.h"
+#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
static const uint32_t XPC_TABLE_DEFAULT_SIZE = 40;
-nsresult
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports
+
+NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTable,
+ xpcAccessibleGeneric,
+ nsIAccessibleTable)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleTable
+
+NS_IMETHODIMP
xpcAccessibleTable::GetCaption(nsIAccessible** aCaption)
{
NS_ENSURE_ARG_POINTER(aCaption);
*aCaption = nullptr;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- NS_IF_ADDREF(*aCaption = mTable->Caption());
+ NS_IF_ADDREF(*aCaption = ToXPC(Intl()->Caption()));
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetColumnCount(int32_t* aColumnCount)
{
NS_ENSURE_ARG_POINTER(aColumnCount);
*aColumnCount = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aColumnCount = mTable->ColCount();
+ *aColumnCount = Intl()->ColCount();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetRowCount(int32_t* aRowCount)
{
NS_ENSURE_ARG_POINTER(aRowCount);
*aRowCount = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aRowCount = mTable->RowCount();
+ *aRowCount = Intl()->RowCount();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetCellAt(int32_t aRowIdx, int32_t aColIdx,
nsIAccessible** aCell)
{
NS_ENSURE_ARG_POINTER(aCell);
*aCell = nullptr;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
- aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
+ aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- NS_IF_ADDREF(*aCell = mTable->CellAt(aRowIdx, aColIdx));
+ NS_IF_ADDREF(*aCell = ToXPC(Intl()->CellAt(aRowIdx, aColIdx)));
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetCellIndexAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aCellIdx)
{
NS_ENSURE_ARG_POINTER(aCellIdx);
*aCellIdx = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
- aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
+ aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aCellIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
+ *aCellIdx = Intl()->CellIndexAt(aRowIdx, aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetColumnExtentAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aColumnExtent)
{
NS_ENSURE_ARG_POINTER(aColumnExtent);
*aColumnExtent = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
- aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
+ aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aColumnExtent = mTable->ColExtentAt(aRowIdx, aColIdx);
+ *aColumnExtent = Intl()->ColExtentAt(aRowIdx, aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetRowExtentAt(int32_t aRowIdx, int32_t aColIdx,
int32_t* aRowExtent)
{
NS_ENSURE_ARG_POINTER(aRowExtent);
*aRowExtent = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
- aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
+ aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aRowExtent = mTable->RowExtentAt(aRowIdx, aColIdx);
+ *aRowExtent = Intl()->RowExtentAt(aRowIdx, aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetColumnDescription(int32_t aColIdx,
nsAString& aDescription)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
nsAutoString description;
- mTable->ColDescription(aColIdx, description);
+ Intl()->ColDescription(aColIdx, description);
aDescription.Assign(description);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetRowDescription(int32_t aRowIdx, nsAString& aDescription)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
nsAutoString description;
- mTable->RowDescription(aRowIdx, description);
+ Intl()->RowDescription(aRowIdx, description);
aDescription.Assign(description);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::IsColumnSelected(int32_t aColIdx, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aIsSelected = mTable->IsColSelected(aColIdx);
+ *aIsSelected = Intl()->IsColSelected(aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::IsRowSelected(int32_t aRowIdx, bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
- *aIsSelected = mTable->IsRowSelected(aRowIdx);
+ *aIsSelected = Intl()->IsRowSelected(aRowIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::IsCellSelected(int32_t aRowIdx, int32_t aColIdx,
bool* aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = false;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
- aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount() ||
+ aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
+ *aIsSelected = Intl()->IsCellSelected(aRowIdx, aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCellCount(uint32_t* aSelectedCellCount)
{
NS_ENSURE_ARG_POINTER(aSelectedCellCount);
*aSelectedCellCount = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aSelectedCellCount = mTable->SelectedCellCount();
+ *aSelectedCellCount = Intl()->SelectedCellCount();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedColumnCount(uint32_t* aSelectedColumnCount)
{
NS_ENSURE_ARG_POINTER(aSelectedColumnCount);
*aSelectedColumnCount = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aSelectedColumnCount = mTable->SelectedColCount();
+ *aSelectedColumnCount = Intl()->SelectedColCount();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedRowCount(uint32_t* aSelectedRowCount)
{
NS_ENSURE_ARG_POINTER(aSelectedRowCount);
*aSelectedRowCount = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aSelectedRowCount = mTable->SelectedRowCount();
+ *aSelectedRowCount = Intl()->SelectedRowCount();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCells(nsIArray** aSelectedCells)
{
NS_ENSURE_ARG_POINTER(aSelectedCells);
*aSelectedCells = nullptr;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- nsresult rv = NS_OK;
- nsCOMPtr<nsIMutableArray> selCells =
+ NS_IMETHODIMP rv = NS_OK;
+ nsCOMPtr<nsIMutableArray> selCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoTArray<Accessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
- mTable->SelectedCells(&cellsArray);
+ Intl()->SelectedCells(&cellsArray);
uint32_t totalCount = cellsArray.Length();
for (uint32_t idx = 0; idx < totalCount; idx++) {
Accessible* cell = cellsArray.ElementAt(idx);
- selCells -> AppendElement(static_cast<nsIAccessible*>(cell), false);
+ selCells->AppendElement(static_cast<nsIAccessible*>(ToXPC(cell)), false);
}
NS_ADDREF(*aSelectedCells = selCells);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCellIndices(uint32_t* aCellsArraySize,
int32_t** aCellsArray)
{
NS_ENSURE_ARG_POINTER(aCellsArraySize);
*aCellsArraySize = 0;
NS_ENSURE_ARG_POINTER(aCellsArray);
*aCellsArray = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> cellsArray;
- mTable->SelectedCellIndices(&cellsArray);
+ Intl()->SelectedCellIndices(&cellsArray);
*aCellsArraySize = cellsArray.Length();
*aCellsArray = static_cast<int32_t*>
(moz_xmalloc(*aCellsArraySize * sizeof(int32_t)));
memcpy(*aCellsArray, cellsArray.Elements(),
*aCellsArraySize * sizeof(int32_t));
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedColumnIndices(uint32_t* aColsArraySize,
int32_t** aColsArray)
{
NS_ENSURE_ARG_POINTER(aColsArraySize);
*aColsArraySize = 0;
NS_ENSURE_ARG_POINTER(aColsArray);
*aColsArray = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> colsArray;
- mTable->SelectedColIndices(&colsArray);
+ Intl()->SelectedColIndices(&colsArray);
*aColsArraySize = colsArray.Length();
*aColsArray = static_cast<int32_t*>
(moz_xmalloc(*aColsArraySize * sizeof(int32_t)));
memcpy(*aColsArray, colsArray.Elements(),
*aColsArraySize * sizeof(int32_t));
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSelectedRowIndices(uint32_t* aRowsArraySize,
int32_t** aRowsArray)
{
NS_ENSURE_ARG_POINTER(aRowsArraySize);
*aRowsArraySize = 0;
NS_ENSURE_ARG_POINTER(aRowsArray);
*aRowsArray = 0;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> rowsArray;
- mTable->SelectedRowIndices(&rowsArray);
+ Intl()->SelectedRowIndices(&rowsArray);
*aRowsArraySize = rowsArray.Length();
*aRowsArray = static_cast<int32_t*>
(moz_xmalloc(*aRowsArraySize * sizeof(int32_t)));
memcpy(*aRowsArray, rowsArray.Elements(),
*aRowsArraySize * sizeof(int32_t));
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetColumnIndexAt(int32_t aCellIdx, int32_t* aColIdx)
{
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aCellIdx < 0
- || static_cast<uint32_t>(aCellIdx)
- >= mTable->RowCount() * mTable->ColCount())
+ if (aCellIdx < 0 ||
+ static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aColIdx = mTable->ColIndexAt(aCellIdx);
+ *aColIdx = Intl()->ColIndexAt(aCellIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetRowIndexAt(int32_t aCellIdx, int32_t* aRowIdx)
{
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aCellIdx < 0
- || static_cast<uint32_t>(aCellIdx)
- >= mTable->RowCount() * mTable->ColCount())
+ if (aCellIdx < 0 ||
+ static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- *aRowIdx = mTable->RowIndexAt(aCellIdx);
+ *aRowIdx = Intl()->RowIndexAt(aCellIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetRowAndColumnIndicesAt(int32_t aCellIdx, int32_t* aRowIdx,
int32_t* aColIdx)
{
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aCellIdx < 0
- || static_cast<uint32_t>(aCellIdx)
- >= mTable->RowCount() * mTable->ColCount())
+ if (aCellIdx < 0 ||
+ static_cast<uint32_t>(aCellIdx) >= Intl()->RowCount() * Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- mTable->RowAndColIndicesAt(aCellIdx, aRowIdx, aColIdx);
- return NS_OK;
+ Intl()->RowAndColIndicesAt(aCellIdx, aRowIdx, aColIdx);
+ return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::GetSummary(nsAString& aSummary)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoString summary;
- mTable->Summary(summary);
+ Intl()->Summary(summary);
aSummary.Assign(summary);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::IsProbablyForLayout(bool* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = false;
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aResult = mTable->IsProbablyLayoutTable();
+ *aResult = Intl()->IsProbablyLayoutTable();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::SelectColumn(int32_t aColIdx)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- mTable->SelectCol(aColIdx);
+ Intl()->SelectCol(aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::SelectRow(int32_t aRowIdx)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
- mTable->SelectRow(aRowIdx);
+ Intl()->SelectRow(aRowIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::UnselectColumn(int32_t aColIdx)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+ if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount())
return NS_ERROR_INVALID_ARG;
- mTable->UnselectCol(aColIdx);
+ Intl()->UnselectCol(aColIdx);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTable::UnselectRow(int32_t aRowIdx)
{
- if (!mTable)
+ if (!Intl())
return NS_ERROR_FAILURE;
- if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+ if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount())
return NS_ERROR_INVALID_ARG;
- mTable->UnselectRow(aRowIdx);
+ Intl()->UnselectRow(aRowIdx);
return NS_OK;
}
-
-
--- a/accessible/xpcom/xpcAccessibleTable.h
+++ b/accessible/xpcom/xpcAccessibleTable.h
@@ -1,73 +1,78 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++ MOZ_FINAL; tab-width: 2 MOZ_FINAL; indent-tabs-mode: nil MOZ_FINAL; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
-#define MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
+#ifndef mozilla_a11y_xpcAccessibleTable_h_
+#define mozilla_a11y_xpcAccessibleTable_h_
-#include "nsAString.h"
-#include "nscore.h"
-
-class nsIAccessible;
-class nsIArray;
+#include "nsIAccessibleTable.h"
+#include "xpcAccessibleGeneric.h"
namespace mozilla {
namespace a11y {
-class TableAccessible;
-
-class xpcAccessibleTable
+/**
+ * XPCOM wrapper around TableAccessible class.
+ */
+class xpcAccessibleTable : public xpcAccessibleGeneric,
+ public nsIAccessibleTable
{
public:
- explicit xpcAccessibleTable(TableAccessible* aTable) :
- mTable(aTable)
- {
- }
+ xpcAccessibleTable(Accessible* aIntl) : xpcAccessibleGeneric(aIntl) { }
+
+ NS_DECL_ISUPPORTS_INHERITED
- nsresult GetCaption(nsIAccessible** aCaption);
- nsresult GetSummary(nsAString& aSummary);
- nsresult GetColumnCount(int32_t* aColumnCount);
- nsresult GetRowCount(int32_t* aRowCount);
- nsresult GetCellAt(int32_t aRowIndex, int32_t aColumnIndex,
- nsIAccessible** aCell);
- nsresult GetCellIndexAt(int32_t aRowIndex, int32_t aColumnIndex,
- int32_t* aCellIndex);
- nsresult GetColumnIndexAt(int32_t aCellIndex, int32_t* aColumnIndex);
- nsresult GetRowIndexAt(int32_t aCellIndex, int32_t* aRowIndex);
- nsresult GetRowAndColumnIndicesAt(int32_t aCellIndex, int32_t* aRowIndex,
- int32_t* aColumnIndex);
- nsresult GetColumnExtentAt(int32_t row, int32_t column,
- int32_t* aColumnExtent);
- nsresult GetRowExtentAt(int32_t row, int32_t column,
- int32_t* aRowExtent);
- nsresult GetColumnDescription(int32_t aColIdx, nsAString& aDescription);
- nsresult GetRowDescription(int32_t aRowIdx, nsAString& aDescription);
- nsresult IsColumnSelected(int32_t aColIdx, bool* _retval);
- nsresult IsRowSelected(int32_t aRowIdx, bool* _retval);
- nsresult IsCellSelected(int32_t aRowIdx, int32_t aColIdx, bool* _retval);
- nsresult GetSelectedCellCount(uint32_t* aSelectedCellCount);
- nsresult GetSelectedColumnCount(uint32_t* aSelectedColumnCount);
- nsresult GetSelectedRowCount(uint32_t* aSelectedRowCount);
- nsresult GetSelectedCells(nsIArray** aSelectedCell);
- nsresult GetSelectedCellIndices(uint32_t* aCellsArraySize,
- int32_t** aCellsArray);
- nsresult GetSelectedColumnIndices(uint32_t* aColsArraySize,
- int32_t** aColsArray);
- nsresult GetSelectedRowIndices(uint32_t* aRowsArraySize,
- int32_t** aRowsArray);
- nsresult SelectColumn(int32_t aColIdx);
- nsresult SelectRow(int32_t aRowIdx);
- nsresult UnselectColumn(int32_t aColIdx);
- nsresult UnselectRow(int32_t aRowIdx);
- nsresult IsProbablyForLayout(bool* aIsForLayout);
+ // nsIAccessibleTable
+ NS_IMETHOD GetCaption(nsIAccessible** aCaption) MOZ_FINAL;
+ NS_IMETHOD GetSummary(nsAString& aSummary) MOZ_FINAL;
+ NS_IMETHOD GetColumnCount(int32_t* aColumnCount) MOZ_FINAL;
+ NS_IMETHOD GetRowCount(int32_t* aRowCount) MOZ_FINAL;
+ NS_IMETHOD GetCellAt(int32_t aRowIndex, int32_t aColumnIndex,
+ nsIAccessible** aCell) MOZ_FINAL;
+ NS_IMETHOD GetCellIndexAt(int32_t aRowIndex, int32_t aColumnIndex,
+ int32_t* aCellIndex) MOZ_FINAL;
+ NS_IMETHOD GetColumnIndexAt(int32_t aCellIndex, int32_t* aColumnIndex) MOZ_FINAL;
+ NS_IMETHOD GetRowIndexAt(int32_t aCellIndex, int32_t* aRowIndex) MOZ_FINAL;
+ NS_IMETHOD GetRowAndColumnIndicesAt(int32_t aCellIndex, int32_t* aRowIndex,
+ int32_t* aColumnIndex) MOZ_FINAL;
+ NS_IMETHOD GetColumnExtentAt(int32_t row, int32_t column,
+ int32_t* aColumnExtent) MOZ_FINAL;
+ NS_IMETHOD GetRowExtentAt(int32_t row, int32_t column,
+ int32_t* aRowExtent) MOZ_FINAL;
+ NS_IMETHOD GetColumnDescription(int32_t aColIdx, nsAString& aDescription) MOZ_FINAL;
+ NS_IMETHOD GetRowDescription(int32_t aRowIdx, nsAString& aDescription) MOZ_FINAL;
+ NS_IMETHOD IsColumnSelected(int32_t aColIdx, bool* _retval) MOZ_FINAL;
+ NS_IMETHOD IsRowSelected(int32_t aRowIdx, bool* _retval) MOZ_FINAL;
+ NS_IMETHOD IsCellSelected(int32_t aRowIdx, int32_t aColIdx, bool* _retval) MOZ_FINAL;
+ NS_IMETHOD GetSelectedCellCount(uint32_t* aSelectedCellCount) MOZ_FINAL;
+ NS_IMETHOD GetSelectedColumnCount(uint32_t* aSelectedColumnCount) MOZ_FINAL;
+ NS_IMETHOD GetSelectedRowCount(uint32_t* aSelectedRowCount) MOZ_FINAL;
+ NS_IMETHOD GetSelectedCells(nsIArray** aSelectedCell) MOZ_FINAL;
+ NS_IMETHOD GetSelectedCellIndices(uint32_t* aCellsArraySize,
+ int32_t** aCellsArray) MOZ_FINAL;
+ NS_IMETHOD GetSelectedColumnIndices(uint32_t* aColsArraySize,
+ int32_t** aColsArray) MOZ_FINAL;
+ NS_IMETHOD GetSelectedRowIndices(uint32_t* aRowsArraySize,
+ int32_t** aRowsArray) MOZ_FINAL;
+ NS_IMETHOD SelectColumn(int32_t aColIdx) MOZ_FINAL;
+ NS_IMETHOD SelectRow(int32_t aRowIdx) MOZ_FINAL;
+ NS_IMETHOD UnselectColumn(int32_t aColIdx) MOZ_FINAL;
+ NS_IMETHOD UnselectRow(int32_t aRowIdx) MOZ_FINAL;
+ NS_IMETHOD IsProbablyForLayout(bool* aIsForLayout) MOZ_FINAL;
protected:
- mozilla::a11y::TableAccessible* mTable;
+ virtual ~xpcAccessibleTable() {}
+
+private:
+ TableAccessible* Intl() { return mIntl->AsTable(); }
+
+ xpcAccessibleTable(const xpcAccessibleTable&) MOZ_DELETE;
+ xpcAccessibleTable& operator =(const xpcAccessibleTable&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
-#endif // MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
+#endif // mozilla_a11y_xpcAccessibleTable_h_
--- a/accessible/xpcom/xpcAccessibleTableCell.cpp
+++ b/accessible/xpcom/xpcAccessibleTableCell.cpp
@@ -2,157 +2,160 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleTableCell.h"
#include "Accessible.h"
+#include "nsIAccessibleTable.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
-
-#include "nsIAccessibleTable.h"
+#include "xpcAccessibleDocument.h"
#include "nsComponentManagerUtils.h"
#include "nsIMutableArray.h"
using namespace mozilla;
using namespace mozilla::a11y;
-nsresult
+////////////////////////////////////////////////////////////////////////////////
+// nsISupports
+
+NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTableCell,
+ xpcAccessibleHyperText,
+ nsIAccessibleTableCell)
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleTableCell
+
+NS_IMETHODIMP
xpcAccessibleTableCell::GetTable(nsIAccessibleTable** aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nullptr;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- TableAccessible* table = mTableCell->Table();
+ TableAccessible* table = Intl()->Table();
if (!table)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> xpcTable =
- do_QueryInterface(static_cast<nsIAccessible*>(table->AsAccessible()));
+ do_QueryInterface(static_cast<nsIAccessible*>(ToXPC(table->AsAccessible())));
xpcTable.forget(aTable);
-
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnIndex(int32_t* aColIdx)
{
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aColIdx = mTableCell->ColIdx();
+ *aColIdx = Intl()->ColIdx();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetRowIndex(int32_t* aRowIdx)
{
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aRowIdx = mTableCell->RowIdx();
-
+ *aRowIdx = Intl()->RowIdx();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnExtent(int32_t* aExtent)
{
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aExtent = mTableCell->ColExtent();
-
+ *aExtent = Intl()->ColExtent();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetRowExtent(int32_t* aExtent)
{
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aExtent = mTableCell->RowExtent();
-
+ *aExtent = Intl()->RowExtent();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<Accessible*, 10> headerCells;
- mTableCell->ColHeaderCells(&headerCells);
+ Intl()->ColHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
- cells->
- AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
- false);
+ cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
+ false);
}
NS_ADDREF(*aHeaderCells = cells);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
nsAutoTArray<Accessible*, 10> headerCells;
- mTableCell->RowHeaderCells(&headerCells);
+ Intl()->RowHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
- cells->
- AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
- false);
+ cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
+ false);
}
NS_ADDREF(*aHeaderCells = cells);
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
xpcAccessibleTableCell::IsSelected(bool* aSelected)
{
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = false;
- if (!mTableCell)
+ if (!Intl())
return NS_ERROR_FAILURE;
- *aSelected = mTableCell->Selected();
-
+ *aSelected = Intl()->Selected();
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleTableCell.h
+++ b/accessible/xpcom/xpcAccessibleTableCell.h
@@ -2,48 +2,50 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_xpcom_xpcAccessibletableCell_h_
#define mozilla_a11y_xpcom_xpcAccessibletableCell_h_
-#include "nscore.h"
+#include "nsIAccessibleTable.h"
-class nsIAccessibleTable;
-class nsIArray;
+#include "xpcAccessibleHyperText.h"
namespace mozilla {
namespace a11y {
-class TableAccessible;
-class TableCellAccessible;
-
/**
- * This class provides an implementation of the nsIAccessibleTableCell
- * interface's methods.
+ * XPCOM wrapper around TableAccessibleCell class.
*/
-class xpcAccessibleTableCell
+class xpcAccessibleTableCell : public xpcAccessibleHyperText,
+ public nsIAccessibleTableCell
{
public:
- explicit xpcAccessibleTableCell(TableCellAccessible* aTableCell) :
- mTableCell(aTableCell)
- {
- }
+ xpcAccessibleTableCell(Accessible* aIntl) : xpcAccessibleHyperText(aIntl) { }
+
+ NS_DECL_ISUPPORTS_INHERITED
- nsresult GetTable(nsIAccessibleTable** aTable);
- nsresult GetColumnIndex(int32_t* aColIdx);
- nsresult GetRowIndex(int32_t* aRowIdx);
- nsresult GetColumnExtent(int32_t* aExtent);
- nsresult GetRowExtent(int32_t* aExtent);
- nsresult GetColumnHeaderCells(nsIArray** aHeaderCells);
- nsresult GetRowHeaderCells(nsIArray** aHeaderCells);
- nsresult IsSelected(bool* aSelected);
+ // nsIAccessibleTableCell
+ NS_IMETHOD GetTable(nsIAccessibleTable** aTable) MOZ_FINAL;
+ NS_IMETHOD GetColumnIndex(int32_t* aColIdx) MOZ_FINAL;
+ NS_IMETHOD GetRowIndex(int32_t* aRowIdx) MOZ_FINAL;
+ NS_IMETHOD GetColumnExtent(int32_t* aExtent) MOZ_FINAL;
+ NS_IMETHOD GetRowExtent(int32_t* aExtent) MOZ_FINAL;
+ NS_IMETHOD GetColumnHeaderCells(nsIArray** aHeaderCells) MOZ_FINAL;
+ NS_IMETHOD GetRowHeaderCells(nsIArray** aHeaderCells) MOZ_FINAL;
+ NS_IMETHOD IsSelected(bool* aSelected) MOZ_FINAL;
protected:
- mozilla::a11y::TableCellAccessible* mTableCell;
+ virtual ~xpcAccessibleTableCell() {}
+
+private:
+ TableCellAccessible* Intl() { return mIntl->AsTableCell(); }
+
+ xpcAccessibleTableCell(const xpcAccessibleTableCell&) MOZ_DELETE;
+ xpcAccessibleTableCell& operator =(const xpcAccessibleTableCell&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_xpcom_xpcAccessibletableCell_h_
--- a/accessible/xpcom/xpcAccessibleTextRange.cpp
+++ b/accessible/xpcom/xpcAccessibleTextRange.cpp
@@ -1,18 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "xpcAccessibleTextRange.h"
-#include "HyperTextAccessible.h"
#include "TextRange.h"
+#include "xpcAccessibleDocument.h"
+
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla;
using namespace mozilla::a11y;
// nsISupports and cycle collection
@@ -31,66 +32,66 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(xpcAcces
NS_IMPL_CYCLE_COLLECTING_RELEASE(xpcAccessibleTextRange)
// nsIAccessibleTextRange
NS_IMETHODIMP
xpcAccessibleTextRange::GetStartContainer(nsIAccessibleText** aAnchor)
{
NS_ENSURE_ARG_POINTER(aAnchor);
- NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessibleText*>(mRange.StartContainer()));
+ NS_IF_ADDREF(*aAnchor = ToXPCText(mRange.StartContainer()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::GetStartOffset(int32_t* aOffset)
{
NS_ENSURE_ARG_POINTER(aOffset);
*aOffset = mRange.StartOffset();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::GetEndContainer(nsIAccessibleText** aAnchor)
{
NS_ENSURE_ARG_POINTER(aAnchor);
- NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessibleText*>(mRange.EndContainer()));
+ NS_IF_ADDREF(*aAnchor = ToXPCText(mRange.EndContainer()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::GetEndOffset(int32_t* aOffset)
{
NS_ENSURE_ARG_POINTER(aOffset);
*aOffset = mRange.EndOffset();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::GetContainer(nsIAccessible** aContainer)
{
NS_ENSURE_ARG_POINTER(aContainer);
- NS_IF_ADDREF(*aContainer = static_cast<nsIAccessible*>(mRange.Container()));
+ NS_IF_ADDREF(*aContainer = ToXPC(mRange.Container()));
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::GetEmbeddedChildren(nsIArray** aList)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> xpcList =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<Accessible*> objects;
mRange.EmbeddedChildren(&objects);
uint32_t len = objects.Length();
for (uint32_t idx = 0; idx < len; idx++)
- xpcList->AppendElement(static_cast<nsIAccessible*>(objects[idx]), false);
+ xpcList->AppendElement(static_cast<nsIAccessible*>(ToXPC(objects[idx])), false);
xpcList.forget(aList);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTextRange::Compare(nsIAccessibleTextRange* aOtherRange,
--- a/accessible/xpcom/xpcAccessibleValue.cpp
+++ b/accessible/xpcom/xpcAccessibleValue.cpp
@@ -1,90 +1,85 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "xpcAccessibleValue.h"
+#include "xpcAccessibleGeneric.h"
#include "Accessible.h"
using namespace mozilla;
using namespace mozilla::a11y;
NS_IMETHODIMP
xpcAccessibleValue::GetMaximumValue(double* aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
- double value = acc->MaxValue();
+ double value = Intl()->MaxValue();
if (!IsNaN(value))
*aValue = value;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleValue::GetMinimumValue(double* aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
- double value = acc->MinValue();
+ double value = Intl()->MinValue();
if (!IsNaN(value))
*aValue = value;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleValue::GetCurrentValue(double* aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
- double value = acc->CurValue();
+ double value = Intl()->CurValue();
if (!IsNaN(value))
*aValue = value;
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleValue::SetCurrentValue(double aValue)
{
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
- acc->SetCurValue(aValue);
+ Intl()->SetCurValue(aValue);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleValue::GetMinimumIncrement(double* aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
- Accessible* acc = static_cast<Accessible*>(this);
- if (acc->IsDefunct())
+ if (Intl()->IsDefunct())
return NS_ERROR_FAILURE;
- double value = acc->Step();
+ double value = Intl()->Step();
if (!IsNaN(value))
*aValue = value;
return NS_OK;
}
--- a/accessible/xpcom/xpcAccessibleValue.h
+++ b/accessible/xpcom/xpcAccessibleValue.h
@@ -7,28 +7,37 @@
#ifndef mozilla_a11y_xpcAccessibleValue_h_
#define mozilla_a11y_xpcAccessibleValue_h_
#include "nsIAccessibleValue.h"
namespace mozilla {
namespace a11y {
+class Accessible;
+
+/**
+ * XPCOM nsIAccessibleValue interface implementation, used by
+ * xpcAccessibleGeneric class.
+ */
class xpcAccessibleValue : public nsIAccessibleValue
{
public:
NS_IMETHOD GetMaximumValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
NS_IMETHOD GetMinimumValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
NS_IMETHOD GetCurrentValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
NS_IMETHOD SetCurrentValue(double aValue) MOZ_FINAL MOZ_OVERRIDE;
NS_IMETHOD GetMinimumIncrement(double* aMinIncrement) MOZ_FINAL MOZ_OVERRIDE;
-private:
+protected:
xpcAccessibleValue() { }
- friend class Accessible;
+ virtual ~xpcAccessibleValue() {}
+
+private:
+ Accessible* Intl();
xpcAccessibleValue(const xpcAccessibleValue&) MOZ_DELETE;
xpcAccessibleValue& operator =(const xpcAccessibleValue&) MOZ_DELETE;
};
} // namespace a11y
} // namespace mozilla
--- a/accessible/xul/XULColorPickerAccessible.cpp
+++ b/accessible/xul/XULColorPickerAccessible.cpp
@@ -23,29 +23,26 @@ using namespace mozilla::a11y;
XULColorPickerTileAccessible::
XULColorPickerTileAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
}
////////////////////////////////////////////////////////////////////////////////
-// XULColorPickerTileAccessible: nsIAccessible
+// XULColorPickerTileAccessible: Accessible
void
XULColorPickerTileAccessible::Value(nsString& aValue)
{
aValue.Truncate();
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
}
-////////////////////////////////////////////////////////////////////////////////
-// XULColorPickerTileAccessible: Accessible
-
role
XULColorPickerTileAccessible::NativeRole()
{
return roles::PUSHBUTTON;
}
uint64_t
XULColorPickerTileAccessible::NativeState()
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -15,17 +15,16 @@
#include "Role.h"
#include "States.h"
#include "TextUpdater.h"
#ifdef A11Y_LOG
#include "Logging.h"
#endif
-#include "nsIAccessibleRelation.h"
#include "nsIDOMXULDescriptionElement.h"
#include "nsNameSpaceManager.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "nsTextBoxFrame.h"
using namespace mozilla::a11y;
@@ -183,22 +182,18 @@ XULLinkAccessible::
XULLabelAccessible(aContent, aDoc)
{
}
XULLinkAccessible::~XULLinkAccessible()
{
}
-// Expose nsIAccessibleHyperLink unconditionally
-NS_IMPL_ISUPPORTS_INHERITED(XULLinkAccessible, XULLabelAccessible,
- nsIAccessibleHyperLink)
-
////////////////////////////////////////////////////////////////////////////////
-// XULLinkAccessible. nsIAccessible
+// XULLinkAccessible: Accessible
void
XULLinkAccessible::Value(nsString& aValue)
{
aValue.Truncate();
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, aValue);
}
--- a/accessible/xul/XULElementAccessibles.h
+++ b/accessible/xul/XULElementAccessibles.h
@@ -80,18 +80,16 @@ public:
};
class XULLinkAccessible : public XULLabelAccessible
{
public:
XULLinkAccessible(nsIContent* aContent, DocAccessible* aDoc);
- NS_DECL_ISUPPORTS_INHERITED
-
// Accessible
virtual void Value(nsString& aValue);
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
// ActionAccessible
virtual uint8_t ActionCount() MOZ_OVERRIDE;
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
--- a/accessible/xul/XULListboxAccessible.cpp
+++ b/accessible/xul/XULListboxAccessible.cpp
@@ -94,69 +94,32 @@ XULColumnItemAccessible::DoAction(uint8_
}
////////////////////////////////////////////////////////////////////////////////
// XULListboxAccessible
////////////////////////////////////////////////////////////////////////////////
XULListboxAccessible::
XULListboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- XULSelectControlAccessible(aContent, aDoc), xpcAccessibleTable(this)
+ XULSelectControlAccessible(aContent, aDoc)
{
nsIContent* parentContent = mContent->GetFlattenedTreeParent();
if (parentContent) {
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
do_QueryInterface(parentContent);
if (autoCompletePopupElm)
mGenericTypes |= eAutoCompletePopup;
}
-}
-NS_IMPL_ADDREF_INHERITED(XULListboxAccessible, XULSelectControlAccessible)
-NS_IMPL_RELEASE_INHERITED(XULListboxAccessible, XULSelectControlAccessible)
-
-nsresult
-XULListboxAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
- nsresult rv = XULSelectControlAccessible::QueryInterface(aIID, aInstancePtr);
- if (*aInstancePtr)
- return rv;
-
- if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsMulticolumn()) {
- *aInstancePtr = static_cast<nsIAccessibleTable*>(this);
- NS_ADDREF_THIS();
- return NS_OK;
- }
-
- return NS_ERROR_NO_INTERFACE;
+ if (IsMulticolumn())
+ mGenericTypes |= eTable;
}
////////////////////////////////////////////////////////////////////////////////
-// Accessible
-
-void
-XULListboxAccessible::Shutdown()
-{
- mTable = nullptr;
- XULSelectControlAccessible::Shutdown();
-}
-
-bool
-XULListboxAccessible::IsMulticolumn()
-{
- int32_t numColumns = 0;
- nsresult rv = GetColumnCount(&numColumns);
- if (NS_FAILED(rv))
- return false;
-
- return numColumns > 1;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// XULListboxAccessible. nsIAccessible
+// XULListboxAccessible: Accessible
uint64_t
XULListboxAccessible::NativeState()
{
// As a XULListboxAccessible we can have the following states:
// FOCUSED, READONLY, FOCUSABLE
// Get focus status from base class
@@ -198,17 +161,17 @@ XULListboxAccessible::NativeRole()
do_QueryInterface(mContent->GetParent());
if (xulPopup)
return roles::COMBOBOX_LIST;
return IsMulticolumn() ? roles::TABLE : roles::LISTBOX;
}
////////////////////////////////////////////////////////////////////////////////
-// XULListboxAccessible. nsIAccessibleTable
+// XULListboxAccessible: Table
uint32_t
XULListboxAccessible::ColCount()
{
nsIContent* headContent = nullptr;
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
childContent = childContent->GetNextSibling()) {
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcols,
@@ -615,17 +578,17 @@ XULListitemAccessible::GetListAccessible
void
XULListitemAccessible::Description(nsString& aDesc)
{
AccessibleWrap::Description(aDesc);
}
////////////////////////////////////////////////////////////////////////////////
-// XULListitemAccessible. nsIAccessible
+// XULListitemAccessible: Accessible
/**
* If there is a Listcell as a child ( not anonymous ) use it, otherwise
* default to getting the name from GetXULName
*/
ENameValueFlag
XULListitemAccessible::NativeName(nsString& aName)
{
@@ -723,30 +686,29 @@ XULListitemAccessible::ContainerWidget()
////////////////////////////////////////////////////////////////////////////////
// XULListCellAccessible
////////////////////////////////////////////////////////////////////////////////
XULListCellAccessible::
XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
- HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
+ HyperTextAccessibleWrap(aContent, aDoc)
{
mGenericTypes |= eTableCell;
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
-NS_IMPL_ISUPPORTS_INHERITED(XULListCellAccessible,
- HyperTextAccessible,
- nsIAccessibleTableCell)
+NS_IMPL_ISUPPORTS_INHERITED0(XULListCellAccessible,
+ HyperTextAccessible)
////////////////////////////////////////////////////////////////////////////////
-// XULListCellAccessible: nsIAccessibleTableCell implementation
+// XULListCellAccessible: TableCell
TableAccessible*
XULListCellAccessible::Table() const
{
Accessible* thisRow = Parent();
if (!thisRow || thisRow->Role() != roles::ROW)
return nullptr;
@@ -839,23 +801,16 @@ XULListCellAccessible::Selected()
NS_ENSURE_TRUE(table, false); // we expect to be in a listbox (table)
return table->IsRowSelected(RowIdx());
}
////////////////////////////////////////////////////////////////////////////////
// XULListCellAccessible. Accessible implementation
-void
-XULListCellAccessible::Shutdown()
-{
- mTableCell = nullptr;
- HyperTextAccessibleWrap::Shutdown();
-}
-
role
XULListCellAccessible::NativeRole()
{
return roles::CELL;
}
already_AddRefed<nsIPersistentProperties>
XULListCellAccessible::NativeAttributes()
--- a/accessible/xul/XULListboxAccessible.h
+++ b/accessible/xul/XULListboxAccessible.h
@@ -2,17 +2,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_XULListboxAccessible_h__
#define mozilla_a11y_XULListboxAccessible_h__
#include "BaseAccessibles.h"
-#include "nsIAccessibleTable.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "xpcAccessibleTable.h"
#include "xpcAccessibleTableCell.h"
#include "XULMenuAccessible.h"
#include "XULSelectControlAccessible.h"
class nsIWeakReference;
@@ -54,28 +53,21 @@ public:
enum { eAction_Click = 0 };
};
/*
* A class the represents the XUL Listbox widget.
*/
class XULListboxAccessible : public XULSelectControlAccessible,
- public xpcAccessibleTable,
- public nsIAccessibleTable,
public TableAccessible
{
public:
XULListboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
- NS_DECL_ISUPPORTS_INHERITED
-
- // nsIAccessibleTable
- NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
-
// TableAccessible
virtual uint32_t ColCount();
virtual uint32_t RowCount();
virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
virtual bool IsColSelected(uint32_t aColIdx);
virtual bool IsRowSelected(uint32_t aRowIdx);
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx);
virtual uint32_t SelectedCellCount();
@@ -85,33 +77,32 @@ public:
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells);
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols);
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
virtual void SelectRow(uint32_t aRowIdx);
virtual void UnselectRow(uint32_t aRowIdx);
virtual Accessible* AsAccessible() { return this; }
// Accessible
- virtual void Shutdown();
virtual void Value(nsString& aValue);
virtual TableAccessible* AsTable() { return this; }
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
// Widgets
virtual bool IsWidget() const;
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual Accessible* ContainerWidget() const;
protected:
virtual ~XULListboxAccessible() {}
- bool IsMulticolumn();
+ bool IsMulticolumn() { return ColCount() > 1; }
};
/**
* Listitems -- used in listboxes
*/
class XULListitemAccessible : public XULMenuitemAccessible
{
public:
@@ -150,32 +141,26 @@ protected:
private:
bool mIsCheckbox;
};
/**
* Class represents xul:listcell.
*/
class XULListCellAccessible : public HyperTextAccessibleWrap,
- public nsIAccessibleTableCell,
- public TableCellAccessible,
- public xpcAccessibleTableCell
+ public TableCellAccessible
{
public:
XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
- // nsIAccessibleTableCell
- NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
-
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
- virtual void Shutdown();
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
virtual a11y::role NativeRole() MOZ_OVERRIDE;
// TableCellAccessible
virtual TableAccessible* Table() const MOZ_OVERRIDE;
virtual uint32_t ColIdx() const MOZ_OVERRIDE;
virtual uint32_t RowIdx() const MOZ_OVERRIDE;
virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) MOZ_OVERRIDE;
--- a/accessible/xul/XULSelectControlAccessible.cpp
+++ b/accessible/xul/XULSelectControlAccessible.cpp
@@ -43,52 +43,43 @@ XULSelectControlAccessible::Shutdown()
{
mSelectControl = nullptr;
AccessibleWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// XULSelectControlAccessible: SelectAccessible
-already_AddRefed<nsIArray>
-XULSelectControlAccessible::SelectedItems()
+void
+XULSelectControlAccessible::SelectedItems(nsTArray<Accessible*>* aItems)
{
- nsCOMPtr<nsIMutableArray> selectedItems =
- do_CreateInstance(NS_ARRAY_CONTRACTID);
- if (!selectedItems || !mDoc)
- return nullptr;
-
// For XUL multi-select control
nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
do_QueryInterface(mSelectControl);
if (xulMultiSelect) {
int32_t length = 0;
xulMultiSelect->GetSelectedCount(&length);
for (int32_t index = 0; index < length; index++) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
xulMultiSelect->MultiGetSelectedItem(index, getter_AddRefs(itemElm));
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
Accessible* item = mDoc->GetAccessible(itemNode);
if (item)
- selectedItems->AppendElement(static_cast<nsIAccessible*>(item),
- false);
+ aItems->AppendElement(item);
}
} else { // Single select?
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
mSelectControl->GetSelectedItem(getter_AddRefs(itemElm));
nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
if (itemNode) {
Accessible* item = mDoc->GetAccessible(itemNode);
if (item)
- selectedItems->AppendElement(static_cast<nsIAccessible*>(item),
- false);
+ aItems->AppendElement(item);
}
}
-
- return selectedItems.forget();
}
Accessible*
XULSelectControlAccessible::GetSelectedItem(uint32_t aIndex)
{
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
--- a/accessible/xul/XULSelectControlAccessible.h
+++ b/accessible/xul/XULSelectControlAccessible.h
@@ -21,17 +21,17 @@ class XULSelectControlAccessible : publi
public:
XULSelectControlAccessible(nsIContent* aContent, DocAccessible* aDoc);
virtual ~XULSelectControlAccessible() {}
// Accessible
virtual void Shutdown();
// SelectAccessible
- virtual already_AddRefed<nsIArray> SelectedItems();
+ virtual void SelectedItems(nsTArray<Accessible*>* aItems) MOZ_OVERRIDE;
virtual uint32_t SelectedItemCount();
virtual Accessible* GetSelectedItem(uint32_t aIndex);
virtual bool IsItemSelected(uint32_t aIndex);
virtual bool AddItemToSelection(uint32_t aIndex);
virtual bool RemoveItemFromSelection(uint32_t aIndex);
virtual bool SelectAll();
virtual bool UnselectAll();
--- a/accessible/xul/XULSliderAccessible.cpp
+++ b/accessible/xul/XULSliderAccessible.cpp
@@ -52,18 +52,16 @@ XULSliderAccessible::NativeInteractiveSt
bool
XULSliderAccessible::NativelyUnavailable() const
{
return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters);
}
-// nsIAccessible
-
void
XULSliderAccessible::Value(nsString& aValue)
{
GetSliderAttr(nsGkAtoms::curpos, aValue);
}
uint8_t
XULSliderAccessible::ActionCount()
--- a/accessible/xul/XULTabAccessible.cpp
+++ b/accessible/xul/XULTabAccessible.cpp
@@ -6,17 +6,16 @@
#include "XULTabAccessible.h"
#include "nsAccUtils.h"
#include "Relation.h"
#include "Role.h"
#include "States.h"
// NOTE: alphabetically ordered
-#include "nsIAccessibleRelation.h"
#include "nsIDocument.h"
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDOMXULRelatedElement.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
@@ -25,25 +24,24 @@ using namespace mozilla::a11y;
XULTabAccessible::
XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
}
////////////////////////////////////////////////////////////////////////////////
-// XULTabAccessible: nsIAccessible
+// XULTabAccessible: Accessible
uint8_t
XULTabAccessible::ActionCount()
{
return 1;
}
-/** Return the name of our only action */
void
XULTabAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
{
if (aIndex == eAction_Switch)
aName.AssignLiteral("switch");
}
bool
@@ -94,17 +92,16 @@ XULTabAccessible::NativeState()
uint64_t
XULTabAccessible::NativeInteractiveState() const
{
uint64_t state = Accessible::NativeInteractiveState();
return (state & states::UNAVAILABLE) ? state : state | states::SELECTABLE;
}
-// nsIAccessible
Relation
XULTabAccessible::RelationByType(RelationType aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType != RelationType::LABEL_FOR)
return rel;
// Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible.
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -243,45 +243,38 @@ XULTreeAccessible::CurrentItem()
}
void
XULTreeAccessible::SetCurrentItem(Accessible* aItem)
{
NS_ERROR("XULTreeAccessible::SetCurrentItem not implemented");
}
-already_AddRefed<nsIArray>
-XULTreeAccessible::SelectedItems()
+void
+XULTreeAccessible::SelectedItems(nsTArray<Accessible*>* aItems)
{
if (!mTreeView)
- return nullptr;
+ return;
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (!selection)
- return nullptr;
-
- nsCOMPtr<nsIMutableArray> selectedItems =
- do_CreateInstance(NS_ARRAY_CONTRACTID);
- if (!selectedItems)
- return nullptr;
+ return;
int32_t rangeCount = 0;
selection->GetRangeCount(&rangeCount);
for (int32_t rangeIdx = 0; rangeIdx < rangeCount; rangeIdx++) {
int32_t firstIdx = 0, lastIdx = -1;
selection->GetRangeAt(rangeIdx, &firstIdx, &lastIdx);
for (int32_t rowIdx = firstIdx; rowIdx <= lastIdx; rowIdx++) {
- nsIAccessible* item = GetTreeItemAccessible(rowIdx);
+ Accessible* item = GetTreeItemAccessible(rowIdx);
if (item)
- selectedItems->AppendElement(item, false);
+ aItems->AppendElement(item);
}
}
-
- return selectedItems.forget();
}
uint32_t
XULTreeAccessible::SelectedItemCount()
{
if (!mTreeView)
return 0;
@@ -720,17 +713,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(XULTr
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XULTreeItemAccessibleBase)
NS_INTERFACE_TABLE_INHERITED(XULTreeItemAccessibleBase,
XULTreeItemAccessibleBase)
NS_INTERFACE_TABLE_TAIL_INHERITING(Accessible)
NS_IMPL_ADDREF_INHERITED(XULTreeItemAccessibleBase, Accessible)
NS_IMPL_RELEASE_INHERITED(XULTreeItemAccessibleBase, Accessible)
////////////////////////////////////////////////////////////////////////////////
-// XULTreeItemAccessibleBase: nsIAccessible implementation
+// XULTreeItemAccessibleBase: Accessible
Accessible*
XULTreeItemAccessibleBase::FocusedChild()
{
return FocusMgr()->FocusedAccessible() == this ? this : nullptr;
}
nsIntRect
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -24,18 +24,16 @@ const uint32_t kDefaultTreeCacheLength =
/**
* Accessible class for XUL tree element.
*/
class XULTreeAccessible : public AccessibleWrap
{
public:
- using Accessible::GetChildAt;
-
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeframe);
// nsISupports and cycle collection
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeAccessible, Accessible)
// Accessible
@@ -46,17 +44,17 @@ public:
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild);
virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
virtual uint32_t ChildCount() const MOZ_OVERRIDE;
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
// SelectAccessible
- virtual already_AddRefed<nsIArray> SelectedItems();
+ virtual void SelectedItems(nsTArray<Accessible*>* aItems) MOZ_OVERRIDE;
virtual uint32_t SelectedItemCount();
virtual Accessible* GetSelectedItem(uint32_t aIndex);
virtual bool IsItemSelected(uint32_t aIndex);
virtual bool AddItemToSelection(uint32_t aIndex);
virtual bool RemoveItemFromSelection(uint32_t aIndex);
virtual bool SelectAll();
virtual bool UnselectAll();
@@ -130,18 +128,16 @@ protected:
0x766a, \
0x443c, \
{ 0x94, 0x0b, 0xb1, 0xe6, 0xb0, 0x83, 0x1d, 0xfc } \
}
class XULTreeItemAccessibleBase : public AccessibleWrap
{
public:
- using Accessible::GetParent;
-
XULTreeItemAccessibleBase(nsIContent* aContent, DocAccessible* aDoc,
Accessible* aParent, nsITreeBoxObject* aTree,
nsITreeView* aTreeView, int32_t aRow);
// nsISupports and cycle collection
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessibleBase,
AccessibleWrap)
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -22,24 +22,17 @@
using namespace mozilla::a11y;
XULTreeGridAccessible::~XULTreeGridAccessible()
{
}
////////////////////////////////////////////////////////////////////////////////
-// XULTreeGridAccessible: nsISupports implementation
-
-NS_IMPL_ISUPPORTS_INHERITED(XULTreeGridAccessible,
- XULTreeAccessible,
- nsIAccessibleTable)
-
-////////////////////////////////////////////////////////////////////////////////
-// XULTreeGridAccessible: nsIAccessibleTable implementation
+// XULTreeGridAccessible: Table
uint32_t
XULTreeGridAccessible::ColCount()
{
return nsCoreUtils::GetSensibleColumnCount(mTree);
}
uint32_t
@@ -119,17 +112,17 @@ XULTreeGridAccessible::SelectedRowIndice
uint32_t rowCount = RowCount();
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++)
if (IsRowSelected(rowIdx))
aRows->AppendElement(rowIdx);
}
Accessible*
XULTreeGridAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex)
-{
+{
Accessible* row = GetTreeItemAccessible(aRowIndex);
if (!row)
return nullptr;
nsCOMPtr<nsITreeColumn> column =
nsCoreUtils::GetSensibleColumnAt(mTree, aColumnIndex);
if (!column)
return nullptr;
@@ -207,23 +200,16 @@ XULTreeGridAccessible::UnselectRow(uint3
if (selection)
selection->ClearRange(aRowIdx, aRowIdx);
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridAccessible: Accessible implementation
-void
-XULTreeGridAccessible::Shutdown()
-{
- mTable = nullptr;
- XULTreeAccessible::Shutdown();
-}
-
role
XULTreeGridAccessible::NativeRole()
{
nsCOMPtr<nsITreeColumns> treeColumns;
mTree->GetColumns(getter_AddRefs(treeColumns));
if (!treeColumns) {
NS_ERROR("No treecolumns object for tree!");
return roles::NOTHING;
@@ -434,17 +420,17 @@ XULTreeGridRowAccessible::CacheChildren(
// XULTreeGridCellAccessible
////////////////////////////////////////////////////////////////////////////////
XULTreeGridCellAccessible::
XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree, nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn) :
- LeafAccessible(aContent, aDoc), xpcAccessibleTableCell(this), mTree(aTree),
+ LeafAccessible(aContent, aDoc), mTree(aTree),
mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
{
mParent = aRowAcc;
mStateFlags |= eSharedNode;
mGenericTypes |= eTableCell;
NS_ASSERTION(mTreeView, "mTreeView is null");
@@ -463,31 +449,23 @@ XULTreeGridCellAccessible::~XULTreeGridC
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridCellAccessible: nsISupports implementation
NS_IMPL_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible, LeafAccessible,
mTree, mColumn)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible)
NS_INTERFACE_TABLE_INHERITED(XULTreeGridCellAccessible,
- nsIAccessibleTableCell,
XULTreeGridCellAccessible)
NS_INTERFACE_TABLE_TAIL_INHERITING(LeafAccessible)
NS_IMPL_ADDREF_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
NS_IMPL_RELEASE_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
////////////////////////////////////////////////////////////////////////////////
-// XULTreeGridCellAccessible: nsIAccessible implementation
-
-void
-XULTreeGridCellAccessible::Shutdown()
-{
- mTableCell = nullptr;
- LeafAccessible::Shutdown();
-}
+// XULTreeGridCellAccessible: Accessible
Accessible*
XULTreeGridCellAccessible::FocusedChild()
{
return nullptr;
}
ENameValueFlag
@@ -602,17 +580,17 @@ XULTreeGridCellAccessible::DoAction(uint
DoCommand();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
-// XULTreeGridCellAccessible: nsIAccessibleTableCell implementation
+// XULTreeGridCellAccessible: TableCell
TableAccessible*
XULTreeGridCellAccessible::Table() const
{
Accessible* grandParent = mParent->Parent();
if (grandParent)
return grandParent->AsTable();
--- a/accessible/xul/XULTreeGridAccessible.h
+++ b/accessible/xul/XULTreeGridAccessible.h
@@ -14,32 +14,24 @@
namespace mozilla {
namespace a11y {
/**
* Represents accessible for XUL tree in the case when it has multiple columns.
*/
class XULTreeGridAccessible : public XULTreeAccessible,
- public xpcAccessibleTable,
- public nsIAccessibleTable,
public TableAccessible
{
public:
XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeFrame) :
- XULTreeAccessible(aContent, aDoc, aTreeFrame), xpcAccessibleTable(this)
+ XULTreeAccessible(aContent, aDoc, aTreeFrame)
{ mGenericTypes |= eTable; }
- // nsISupports
- NS_DECL_ISUPPORTS_INHERITED
-
- // nsIAccessibleTable
- NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
-
// TableAccessible
virtual uint32_t ColCount();
virtual uint32_t RowCount();
virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
virtual void ColDescription(uint32_t aColIdx, nsString& aDescription);
virtual bool IsColSelected(uint32_t aColIdx);
virtual bool IsRowSelected(uint32_t aRowIdx);
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx);
@@ -50,17 +42,16 @@ public:
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells);
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols);
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
virtual void SelectRow(uint32_t aRowIdx);
virtual void UnselectRow(uint32_t aRowIdx);
virtual Accessible* AsAccessible() { return this; }
// Accessible
- virtual void Shutdown();
virtual TableAccessible* AsTable() { return this; }
virtual a11y::role NativeRole() MOZ_OVERRIDE;
protected:
virtual ~XULTreeGridAccessible();
// XULTreeAccessible
virtual already_AddRefed<Accessible>
@@ -120,38 +111,32 @@ protected:
{ /* 84588ad4-549c-4196-a932-4c5ca5de5dff */ \
0x84588ad4, \
0x549c, \
0x4196, \
{ 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff } \
}
class XULTreeGridCellAccessible : public LeafAccessible,
- public nsIAccessibleTableCell,
- public TableCellAccessible,
- public xpcAccessibleTableCell
+ public TableCellAccessible
{
public:
XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree, nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible,
LeafAccessible)
- // nsIAccessibleTableCell
- NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
-
// Accessible
virtual TableCellAccessible* AsTableCell() { return this; }
- virtual void Shutdown();
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
virtual ENameValueFlag Name(nsString& aName);
virtual Accessible* FocusedChild();
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
virtual int32_t IndexInParent() const;
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
virtual a11y::role NativeRole() MOZ_OVERRIDE;
virtual uint64_t NativeState() MOZ_OVERRIDE;
--- a/layout/inspector/inDOMView.cpp
+++ b/layout/inspector/inDOMView.cpp
@@ -22,17 +22,16 @@
#include "nsIDocument.h"
#include "nsIServiceManager.h"
#include "nsITreeColumns.h"
#include "nsITreeBoxObject.h"
#include "mozilla/dom/Element.h"
#include "mozilla/Services.h"
#ifdef ACCESSIBILITY
-#include "nsIAccessible.h"
#include "nsIAccessibilityService.h"
#endif
using namespace mozilla;
////////////////////////////////////////////////////////////////////////
// inDOMViewNode
@@ -329,20 +328,17 @@ inDOMView::GetCellProperties(int32_t row
}
#ifdef ACCESSIBILITY
if (mShowAccessibleNodes) {
nsCOMPtr<nsIAccessibilityService> accService =
services::GetAccessibilityService();
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
- nsCOMPtr<nsIAccessible> accessible;
- nsresult rv =
- accService->GetAccessibleFor(node->node, getter_AddRefs(accessible));
- if (NS_SUCCEEDED(rv) && accessible)
+ if (accService->HasAccessible(node->node))
aProps.AppendLiteral(" ACCESSIBLE_NODE");
}
#endif
return NS_OK;
}
NS_IMETHODIMP
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2762,17 +2762,17 @@ nsChildView::GetDocumentAccessible()
CallQueryReferent(mAccessible.get(),
static_cast<a11y::Accessible**>(getter_AddRefs(ret)));
return ret.forget();
}
// need to fetch the accessible anew, because it has gone away.
// cache the accessible in our weak ptr
nsRefPtr<a11y::Accessible> acc = GetRootAccessible();
- mAccessible = do_GetWeakReference(static_cast<nsIAccessible *>(acc.get()));
+ mAccessible = do_GetWeakReference(acc.get());
return acc.forget();
}
#endif
// RectTextureImage implementation
RectTextureImage::~RectTextureImage()
--- a/widget/windows/winrt/UIAAccessibilityBridge.cpp
+++ b/widget/windows/winrt/UIAAccessibilityBridge.cpp
@@ -6,17 +6,16 @@
#if defined(ACCESSIBILITY)
#include "UIAAccessibilityBridge.h"
#include "MetroUtils.h"
#include <OAIdl.h>
#include "nsIAccessibleEvent.h"
-#include "nsIAccessibleEditableText.h"
#include "nsIPersistentProperties2.h"
// generated
#include "UIABridge.h"
#include <wrl/implements.h>
using namespace mozilla::a11y;
--- a/widget/windows/winrt/UIABridge.cpp
+++ b/widget/windows/winrt/UIABridge.cpp
@@ -138,52 +138,50 @@ UIABridge::SetFocusInternal(LONG_PTR aAc
HRESULT
UIABridge::ClearFocus()
{
LogFunction();
return S_OK;
}
static void
-DumpChildInfo(nsCOMPtr<nsIAccessible>& aChild)
+DumpChildInfo(nsRefPtr<Accessible>& aChild)
{
#ifdef DEBUG
if (!aChild) {
return;
}
nsString str;
aChild->GetName(str);
BridgeLog("name: %ls", str.BeginReading());
aChild->GetDescription(str);
BridgeLog("description: %ls", str.BeginReading());
#endif
}
static bool
-ChildHasFocus(nsCOMPtr<nsIAccessible>& aChild)
+ChildHasFocus(nsRefPtr<Accessible>& aChild)
{
- Accessible* access = (Accessible*)aChild.get();
BridgeLog("Focus element flags: editable:%d focusable:%d readonly:%d",
- ((access->NativeState() & mozilla::a11y::states::EDITABLE) > 0),
- ((access->NativeState() & mozilla::a11y::states::FOCUSABLE) > 0),
- ((access->NativeState() & mozilla::a11y::states::READONLY) > 0));
- return (((access->NativeState() & mozilla::a11y::states::EDITABLE) > 0) &&
- ((access->NativeState() & mozilla::a11y::states::READONLY) == 0));
+ ((aChild->NativeState() & mozilla::a11y::states::EDITABLE) > 0),
+ ((aChild->NativeState() & mozilla::a11y::states::FOCUSABLE) > 0),
+ ((aChild->NativeState() & mozilla::a11y::states::READONLY) > 0));
+ return (((aChild->NativeState() & mozilla::a11y::states::EDITABLE) > 0) &&
+ ((aChild->NativeState() & mozilla::a11y::states::READONLY) == 0));
}
HRESULT
UIABridge::FocusChangeEvent()
{
LogFunction();
if (!Connected()) {
return UIA_E_ELEMENTNOTAVAILABLE;
}
- nsCOMPtr<nsIAccessible> child;
- mAccessible->GetFocusedChild(getter_AddRefs(child));
+ nsRefPtr<Accessible> child = mAccessible->FocusedChild();
if (!child) {
return S_OK;
}
if (!ChildHasFocus(child)) {
ComPtr<IUIAElement> element;
gElement.As(&element);
if (!element) {
@@ -216,18 +214,17 @@ UIABridge::ElementProviderFromPoint(doub
HRESULT
UIABridge::GetFocus(IRawElementProviderFragment ** retVal)
{
LogFunction();
if (!Connected()) {
return UIA_E_ELEMENTNOTAVAILABLE;
}
- nsCOMPtr<nsIAccessible> child;
- nsresult rv = mAccessible->GetFocusedChild(getter_AddRefs(child));
+ nsRefPtr<Accessible> child = mAccessible->FocusedChild();
if (!child) {
BridgeLog("mAccessible->GetFocusedChild failed.");
return S_OK;
}
DumpChildInfo(child);
ComPtr<IUIAElement> element;
@@ -488,20 +485,20 @@ UIABridge::get_HostRawElementProvider(IR
// Element
HRESULT
UIATextElement::SetFocusInternal(LONG_PTR aAccessible)
{
LogFunction();
#if defined(ACCESSIBILITY)
NS_ASSERTION(mAccessItem, "Bad accessible pointer");
- if (mAccessItem == (nsIAccessible*)aAccessible) {
+ if (mAccessItem == (Accessible*)aAccessible) {
return E_UNEXPECTED;
}
- mAccessItem = (nsIAccessible*)aAccessible;
+ mAccessItem = (Accessible*)aAccessible;
return S_OK;
#endif
return E_FAIL;
}
HRESULT
UIATextElement::ClearFocus()
{
@@ -691,22 +688,21 @@ UIATextElement::GetPropertyValue(PROPERT
pRetVal->boolVal = VARIANT_TRUE;
pRetVal->vt = VT_BOOL;
break;
case UIA_LocalizedControlTypePropertyId:
case UIA_LabeledByPropertyId:
break;
- case UIA_HasKeyboardFocusPropertyId:
+ case UIA_HasKeyboardFocusPropertyId:
{
if (mAccessItem) {
uint32_t state, extraState;
- if (NS_SUCCEEDED(mAccessItem->GetState(&state, &extraState)) &&
- (state & nsIAccessibleStates::STATE_FOCUSED)) {
+ if (mAccessItem->NativeState() & mozilla::a11y::states::FOCUSED) {
pRetVal->vt = VT_BOOL;
pRetVal->boolVal = VARIANT_TRUE;
return S_OK;
}
}
pRetVal->vt = VT_BOOL;
pRetVal->boolVal = VARIANT_FALSE;
break;
--- a/widget/windows/winrt/UIABridgePrivate.h
+++ b/widget/windows/winrt/UIABridgePrivate.h
@@ -128,12 +128,12 @@ public:
IFACEMETHODIMP get_IsReadOnly(BOOL *pRetVal);
void SetIndexID(int id) {
mIndexID = id;
}
private:
int mIndexID;
- nsCOMPtr<nsIAccessible> mAccessItem;
+ nsRefPtr<Accessible> mAccessItem;
};
} } }