2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2012-06-10 16:44:50 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_a11y_XULTreeAccessible_h__
|
|
|
|
#define mozilla_a11y_XULTreeAccessible_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsITreeBoxObject.h"
|
|
|
|
#include "nsITreeView.h"
|
|
|
|
#include "nsITreeColumns.h"
|
2012-06-10 16:44:50 -07:00
|
|
|
#include "XULListboxAccessible.h"
|
|
|
|
|
2012-11-19 12:36:05 -08:00
|
|
|
class nsTreeBodyFrame;
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
2012-06-08 03:28:27 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* A class the represents the XUL Tree widget.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t kMaxTreeColumns = 100;
|
|
|
|
const uint32_t kDefaultTreeCacheSize = 256;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
/**
|
|
|
|
* Accessible class for XUL tree element.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
class XULTreeAccessible : public AccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-05-28 18:18:45 -07:00
|
|
|
using Accessible::GetChildAt;
|
2010-08-18 19:14:50 -07:00
|
|
|
|
2012-11-19 12:36:05 -08:00
|
|
|
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
|
|
|
|
nsTreeBodyFrame* aTreeframe);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
// nsISupports and cycle collection
|
2009-06-29 08:38:17 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeAccessible, Accessible)
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2013-10-28 20:30:55 -07:00
|
|
|
virtual void Shutdown();
|
2012-04-09 02:48:41 -07:00
|
|
|
virtual void Value(nsString& aValue);
|
2012-06-10 16:44:50 -07:00
|
|
|
virtual a11y::role NativeRole();
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeState();
|
|
|
|
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
2012-05-28 18:18:45 -07:00
|
|
|
EWhichChildAtPoint aWhichChild);
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2014-01-24 19:08:17 -08:00
|
|
|
virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
|
|
|
|
virtual uint32_t ChildCount() const MOZ_OVERRIDE;
|
2013-10-19 11:19:50 -07:00
|
|
|
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2010-09-01 17:46:59 -07:00
|
|
|
// SelectAccessible
|
|
|
|
virtual already_AddRefed<nsIArray> SelectedItems();
|
2012-08-22 08:56:38 -07:00
|
|
|
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);
|
2010-09-01 17:46:59 -07:00
|
|
|
virtual bool SelectAll();
|
|
|
|
virtual bool UnselectAll();
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
|
|
|
virtual bool IsWidget() const;
|
|
|
|
virtual bool IsActiveWidget() const;
|
|
|
|
virtual bool AreItemsOperable() const;
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* CurrentItem();
|
|
|
|
virtual void SetCurrentItem(Accessible* aItem);
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* ContainerWidget() const;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTreeAccessible
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
2009-08-19 23:45:19 -07:00
|
|
|
* Return tree item accessible at the givem row. If accessible doesn't exist
|
|
|
|
* in the cache then create and cache it.
|
2009-06-29 08:38:17 -07:00
|
|
|
*
|
|
|
|
* @param aRow [in] the given row index
|
|
|
|
*/
|
2014-01-24 19:08:17 -08:00
|
|
|
Accessible* GetTreeItemAccessible(int32_t aRow) const;
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invalidates the number of cached treeitem accessibles.
|
|
|
|
*
|
|
|
|
* @param aRow [in] row index the invalidation starts from
|
|
|
|
* @param aCount [in] the number of treeitem accessibles to invalidate,
|
|
|
|
* the number sign specifies whether rows have been
|
|
|
|
* inserted (plus) or removed (minus)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void InvalidateCache(int32_t aRow, int32_t aCount);
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fires name change events for invalidated area of tree.
|
|
|
|
*
|
|
|
|
* @param aStartRow [in] row index invalidation starts from
|
|
|
|
* @param aEndRow [in] row index invalidation ends, -1 means last row index
|
|
|
|
* @param aStartCol [in] column index invalidation starts from
|
|
|
|
* @param aEndCol [in] column index invalidation ends, -1 mens last column
|
|
|
|
* index
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow,
|
|
|
|
int32_t aStartCol, int32_t aEndCol);
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invalidates children created for previous tree view.
|
|
|
|
*/
|
2012-04-02 04:31:10 -07:00
|
|
|
void TreeViewChanged(nsITreeView* aView);
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~XULTreeAccessible();
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
/**
|
|
|
|
* Creates tree item accessible for the given row index.
|
|
|
|
*/
|
2014-01-24 19:08:17 -08:00
|
|
|
virtual already_AddRefed<Accessible>
|
|
|
|
CreateTreeItemAccessible(int32_t aRow) const;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsITreeBoxObject> mTree;
|
2012-04-27 00:56:49 -07:00
|
|
|
nsITreeView* mTreeView;
|
2014-01-24 19:08:17 -08:00
|
|
|
mutable AccessibleHashtable mAccessibleCache;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2009-08-19 23:45:19 -07:00
|
|
|
* Base class for tree item accessibles.
|
2009-06-29 08:38:17 -07:00
|
|
|
*/
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
#define XULTREEITEMBASEACCESSIBLE_IMPL_CID \
|
2009-08-19 23:45:19 -07:00
|
|
|
{ /* 1ab79ae7-766a-443c-940b-b1e6b0831dfc */ \
|
|
|
|
0x1ab79ae7, \
|
|
|
|
0x766a, \
|
|
|
|
0x443c, \
|
|
|
|
{ 0x94, 0x0b, 0xb1, 0xe6, 0xb0, 0x83, 0x1d, 0xfc } \
|
2009-06-29 08:38:17 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
class XULTreeItemAccessibleBase : public AccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-05-28 18:18:45 -07:00
|
|
|
using Accessible::GetParent;
|
2010-08-18 19:14:50 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTreeItemAccessibleBase(nsIContent* aContent, DocAccessible* aDoc,
|
|
|
|
Accessible* aParent, nsITreeBoxObject* aTree,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsITreeView* aTreeView, int32_t aRow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-09 02:44:31 -07:00
|
|
|
// nsISupports and cycle collection
|
2009-06-29 08:38:17 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessibleBase,
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap)
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2008-02-08 04:55:57 -08:00
|
|
|
// nsIAccessible
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetBounds(int32_t *aX, int32_t *aY,
|
|
|
|
int32_t *aWidth, int32_t *aHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHOD SetSelected(bool aSelect);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHOD TakeFocus();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
|
|
|
NS_IMETHOD DoAction(uint8_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2013-10-28 20:30:55 -07:00
|
|
|
virtual void Shutdown();
|
2012-06-10 16:44:50 -07:00
|
|
|
virtual GroupPos GroupPosition();
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeState();
|
|
|
|
virtual uint64_t NativeInteractiveState() const;
|
|
|
|
virtual int32_t IndexInParent() const;
|
2013-10-19 11:19:50 -07:00
|
|
|
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* FocusedChild();
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint8_t ActionCount();
|
2011-06-05 12:35:43 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* ContainerWidget() const;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTreeItemAccessibleBase
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(XULTREEITEMBASEACCESSIBLE_IMPL_CID)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
/**
|
|
|
|
* Return row index associated with the accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetRowIndex() const { return mRow; }
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
/**
|
|
|
|
* Return cell accessible for the given column. If XUL tree accessible is not
|
|
|
|
* accessible table then return null.
|
|
|
|
*/
|
2014-01-24 19:08:17 -08:00
|
|
|
virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const
|
2012-07-30 07:20:58 -07:00
|
|
|
{ return nullptr; }
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
2009-08-19 23:45:19 -07:00
|
|
|
* Proccess row invalidation. Used to fires name change events.
|
2009-06-29 08:38:17 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) = 0;
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~XULTreeItemAccessibleBase();
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
enum { eAction_Click = 0, eAction_Expand = 1 };
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void DispatchClickEvent(nsIContent *aContent, uint32_t aActionIndex);
|
|
|
|
virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult *aError = nullptr) const;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTreeItemAccessibleBase
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the tree item accessible is expandable (contains subrows).
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsExpandable();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2011-06-09 02:09:05 -07:00
|
|
|
/**
|
|
|
|
* Return name for cell at the given column.
|
|
|
|
*/
|
|
|
|
void GetCellName(nsITreeColumn* aColumn, nsAString& aName);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsITreeBoxObject> mTree;
|
2012-04-27 00:56:49 -07:00
|
|
|
nsITreeView* mTreeView;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mRow;
|
2009-08-19 23:45:19 -07:00
|
|
|
};
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(XULTreeItemAccessibleBase,
|
|
|
|
XULTREEITEMBASEACCESSIBLE_IMPL_CID)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessible class for items for XUL tree.
|
|
|
|
*/
|
2012-06-10 16:44:50 -07:00
|
|
|
class XULTreeItemAccessible : public XULTreeItemAccessibleBase
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTreeItemAccessible(nsIContent* aContent, DocAccessible* aDoc,
|
|
|
|
Accessible* aParent, nsITreeBoxObject* aTree,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsITreeView* aTreeView, int32_t aRow);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2011-06-09 02:44:31 -07:00
|
|
|
// nsISupports and cycle collection
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessible,
|
|
|
|
XULTreeItemAccessibleBase)
|
2011-06-09 02:44:31 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2013-10-28 20:30:55 -07:00
|
|
|
virtual void Shutdown();
|
2012-06-10 16:44:50 -07:00
|
|
|
virtual ENameValueFlag Name(nsString& aName);
|
|
|
|
virtual a11y::role NativeRole();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTreeItemAccessibleBase
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~XULTreeItemAccessible();
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2009-12-10 11:12:19 -08:00
|
|
|
virtual void CacheChildren();
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTreeItemAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsITreeColumn> mColumn;
|
2008-02-08 04:55:57 -08:00
|
|
|
nsString mCachedName;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessible class for columns element of XUL tree.
|
|
|
|
*/
|
2012-06-10 16:44:50 -07:00
|
|
|
class XULTreeColumAccessible : public XULColumAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTreeColumAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
protected:
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult *aError = nullptr) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
|
2012-04-03 02:54:01 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible downcasting method
|
2012-04-03 02:54:01 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
inline XULTreeAccessible*
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible::AsXULTree()
|
2012-04-03 02:54:01 -07:00
|
|
|
{
|
2012-11-17 18:01:44 -08:00
|
|
|
return IsXULTree() ? static_cast<XULTreeAccessible*>(this) : nullptr;
|
2012-04-03 02:54:01 -07:00
|
|
|
}
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|