2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Author: Kyle Yuan (kyle.yuan@sun.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#ifndef __nsXULTreeAccessible_h__
|
|
|
|
#define __nsXULTreeAccessible_h__
|
|
|
|
|
|
|
|
#include "nsITreeBoxObject.h"
|
|
|
|
#include "nsITreeView.h"
|
|
|
|
#include "nsITreeColumns.h"
|
2009-09-10 18:07:56 -07:00
|
|
|
#include "nsXULListboxAccessible.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A class the represents the XUL Tree widget.
|
|
|
|
*/
|
2007-12-11 00:18:04 -08:00
|
|
|
const PRUint32 kMaxTreeColumns = 100;
|
2007-03-22 10:30:00 -07:00
|
|
|
const PRUint32 kDefaultTreeCacheSize = 256;
|
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
/**
|
|
|
|
* Accessible class for XUL tree element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NS_XULTREEACCESSIBLE_IMPL_CID \
|
|
|
|
{ /* 2692e149-6176-42ee-b8e1-2c44b04185e3 */ \
|
|
|
|
0x2692e149, \
|
|
|
|
0x6176, \
|
|
|
|
0x42ee, \
|
|
|
|
{ 0xb8, 0xe1, 0x2c, 0x44, 0xb0, 0x41, 0x85, 0xe3 } \
|
|
|
|
}
|
|
|
|
|
2010-09-01 17:46:59 -07:00
|
|
|
class nsXULTreeAccessible : public nsAccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-08-18 19:14:50 -07:00
|
|
|
using nsAccessible::GetChildCount;
|
|
|
|
using nsAccessible::GetChildAt;
|
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
nsXULTreeAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
|
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
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeAccessible,
|
|
|
|
nsAccessible)
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2008-11-03 19:37:46 -08:00
|
|
|
// nsIAccessible
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHOD GetValue(nsAString& aValue);
|
2008-09-17 06:11:39 -07:00
|
|
|
|
2008-10-31 20:58:07 -07:00
|
|
|
// nsAccessNode
|
2010-06-11 21:04:35 -07:00
|
|
|
virtual void Shutdown();
|
2008-10-31 20:58:07 -07:00
|
|
|
|
2008-11-03 19:37:46 -08:00
|
|
|
// nsAccessible
|
2012-01-11 19:07:35 -08:00
|
|
|
virtual mozilla::a11y::role NativeRole();
|
2011-04-09 16:38:06 -07:00
|
|
|
virtual PRUint64 NativeState();
|
2011-06-13 15:20:54 -07:00
|
|
|
virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,
|
|
|
|
EWhichChildAtPoint aWhichChild);
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2010-01-11 06:14:06 -08:00
|
|
|
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
|
2009-12-10 11:12:19 -08:00
|
|
|
virtual PRInt32 GetChildCount();
|
|
|
|
|
2010-09-01 17:46:59 -07:00
|
|
|
// SelectAccessible
|
|
|
|
virtual bool IsSelect();
|
|
|
|
virtual already_AddRefed<nsIArray> SelectedItems();
|
|
|
|
virtual PRUint32 SelectedItemCount();
|
|
|
|
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
|
|
|
|
virtual bool IsItemSelected(PRUint32 aIndex);
|
|
|
|
virtual bool AddItemToSelection(PRUint32 aIndex);
|
|
|
|
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
|
|
|
|
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;
|
|
|
|
virtual nsAccessible* CurrentItem();
|
2011-12-08 04:20:15 -08:00
|
|
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
virtual nsAccessible* ContainerWidget() const;
|
|
|
|
|
2008-11-03 19:37:46 -08:00
|
|
|
// nsXULTreeAccessible
|
2009-06-29 08:38:17 -07:00
|
|
|
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEACCESSIBLE_IMPL_CID)
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
|
*/
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessible* GetTreeItemAccessible(PRInt32 aRow);
|
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)
|
|
|
|
*/
|
|
|
|
void InvalidateCache(PRInt32 aRow, PRInt32 aCount);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
void TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow,
|
|
|
|
PRInt32 aStartCol, PRInt32 aEndCol);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
2009-08-19 23:45:19 -07:00
|
|
|
/**
|
|
|
|
* Creates tree item accessible for the given row index.
|
|
|
|
*/
|
2010-03-10 02:26:11 -08:00
|
|
|
virtual already_AddRefed<nsAccessible> CreateTreeItemAccessible(PRInt32 aRow);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsITreeBoxObject> mTree;
|
|
|
|
nsCOMPtr<nsITreeView> mTreeView;
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessibleHashtable mAccessibleCache;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeAccessible,
|
|
|
|
NS_XULTREEACCESSIBLE_IMPL_CID)
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
#define NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID \
|
|
|
|
{ /* 1ab79ae7-766a-443c-940b-b1e6b0831dfc */ \
|
|
|
|
0x1ab79ae7, \
|
|
|
|
0x766a, \
|
|
|
|
0x443c, \
|
|
|
|
{ 0x94, 0x0b, 0xb1, 0xe6, 0xb0, 0x83, 0x1d, 0xfc } \
|
2009-06-29 08:38:17 -07:00
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
class nsXULTreeItemAccessibleBase : public nsAccessibleWrap
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-08-18 19:14:50 -07:00
|
|
|
using nsAccessible::GetParent;
|
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
nsXULTreeItemAccessibleBase(nsIContent* aContent, nsDocAccessible* aDoc,
|
|
|
|
nsAccessible* aParent, nsITreeBoxObject* aTree,
|
|
|
|
nsITreeView* aTreeView, PRInt32 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
|
2011-06-09 02:44:31 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeItemAccessibleBase,
|
|
|
|
nsAccessibleWrap)
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2008-02-08 04:55:57 -08:00
|
|
|
// nsIAccessible
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
|
|
|
|
PRInt32 *aWidth, PRInt32 *aHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -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
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel,
|
|
|
|
PRInt32 *aSimilarItemsInGroup,
|
|
|
|
PRInt32 *aPositionInGroup);
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
|
|
|
|
NS_IMETHOD DoAction(PRUint8 aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-21 19:17:31 -08:00
|
|
|
// nsAccessNode
|
2010-06-11 21:04:35 -07:00
|
|
|
virtual void Shutdown();
|
2010-10-20 21:16:10 -07:00
|
|
|
virtual bool IsPrimaryForNode() const;
|
2007-12-21 19:17:31 -08:00
|
|
|
|
2008-11-03 19:37:46 -08:00
|
|
|
// nsAccessible
|
2011-04-09 16:38:06 -07:00
|
|
|
virtual PRUint64 NativeState();
|
2011-06-13 02:08:40 -07:00
|
|
|
virtual PRInt32 IndexInParent() const;
|
2011-08-09 18:44:00 -07:00
|
|
|
virtual Relation RelationByType(PRUint32 aType);
|
2011-07-15 15:58:49 -07:00
|
|
|
virtual nsAccessible* FocusedChild();
|
2008-11-03 19:37:46 -08:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
|
|
|
virtual PRUint8 ActionCount();
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Widgets
|
|
|
|
virtual nsAccessible* ContainerWidget() const;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
// nsXULTreeItemAccessibleBase
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID)
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
/**
|
|
|
|
* Return row index associated with the accessible.
|
|
|
|
*/
|
|
|
|
PRInt32 GetRowIndex() const { return mRow; }
|
|
|
|
|
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.
|
|
|
|
*/
|
2010-03-10 02:26:11 -08:00
|
|
|
virtual nsAccessible* GetCellAccessible(nsITreeColumn *aColumn)
|
|
|
|
{ return nsnull; }
|
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
|
|
|
*/
|
2009-08-19 23:45:19 -07:00
|
|
|
virtual void RowInvalidated(PRInt32 aStartColIdx, PRInt32 aEndColIdx) = 0;
|
2009-06-29 08:38:17 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2009-08-19 23:45:19 -07:00
|
|
|
enum { eAction_Click = 0, eAction_Expand = 1 };
|
|
|
|
|
|
|
|
// nsAccessible
|
|
|
|
virtual void DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex);
|
2010-03-10 02:26:11 -08:00
|
|
|
virtual nsAccessible* GetSiblingAtOffset(PRInt32 aOffset,
|
2011-06-06 19:23:13 -07:00
|
|
|
nsresult *aError = nsnull) const;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
// nsXULTreeItemAccessibleBase
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
nsCOMPtr<nsITreeView> mTreeView;
|
|
|
|
PRInt32 mRow;
|
2009-08-19 23:45:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeItemAccessibleBase,
|
|
|
|
NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessible class for items for XUL tree.
|
|
|
|
*/
|
|
|
|
class nsXULTreeItemAccessible : public nsXULTreeItemAccessibleBase
|
|
|
|
{
|
|
|
|
public:
|
2012-02-07 14:38:54 -08:00
|
|
|
nsXULTreeItemAccessible(nsIContent* aContent, nsDocAccessible* aDoc,
|
|
|
|
nsAccessible* aParent, nsITreeBoxObject* aTree,
|
|
|
|
nsITreeView* aTreeView, PRInt32 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
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeItemAccessible,
|
|
|
|
nsXULTreeItemAccessibleBase)
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHOD GetName(nsAString& aName);
|
|
|
|
|
|
|
|
// nsAccessNode
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool Init();
|
2010-06-11 21:04:35 -07:00
|
|
|
virtual void Shutdown();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
// nsAccessible
|
2012-01-11 19:07:35 -08:00
|
|
|
virtual mozilla::a11y::role NativeRole();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
// nsXULTreeItemAccessibleBase
|
|
|
|
virtual void RowInvalidated(PRInt32 aStartColIdx, PRInt32 aEndColIdx);
|
|
|
|
|
|
|
|
protected:
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
// nsAccessible
|
|
|
|
virtual void CacheChildren();
|
|
|
|
|
|
|
|
// nsXULTreeItemAccessible
|
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.
|
|
|
|
*/
|
2007-09-18 20:31:14 -07:00
|
|
|
class nsXULTreeColumnsAccessible : public nsXULColumnsAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-02-07 14:38:54 -08:00
|
|
|
nsXULTreeColumnsAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// nsAccessible
|
2010-03-10 02:26:11 -08:00
|
|
|
virtual nsAccessible* GetSiblingAtOffset(PRInt32 aOffset,
|
2011-06-06 19:23:13 -07:00
|
|
|
nsresult *aError = nsnull) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|