1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/xul/XULTreeGridAccessible.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,216 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_a11y_XULTreeGridAccessible_h__ 1.10 +#define mozilla_a11y_XULTreeGridAccessible_h__ 1.11 + 1.12 +#include "XULTreeAccessible.h" 1.13 +#include "TableAccessible.h" 1.14 +#include "TableCellAccessible.h" 1.15 +#include "xpcAccessibleTable.h" 1.16 +#include "xpcAccessibleTableCell.h" 1.17 + 1.18 +namespace mozilla { 1.19 +namespace a11y { 1.20 + 1.21 +/** 1.22 + * Represents accessible for XUL tree in the case when it has multiple columns. 1.23 + */ 1.24 +class XULTreeGridAccessible : public XULTreeAccessible, 1.25 + public xpcAccessibleTable, 1.26 + public nsIAccessibleTable, 1.27 + public TableAccessible 1.28 +{ 1.29 +public: 1.30 + XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc, 1.31 + nsTreeBodyFrame* aTreeFrame) : 1.32 + XULTreeAccessible(aContent, aDoc, aTreeFrame), xpcAccessibleTable(this) 1.33 + { mGenericTypes |= eTable; } 1.34 + 1.35 + // nsISupports 1.36 + NS_DECL_ISUPPORTS_INHERITED 1.37 + 1.38 + // nsIAccessibleTable 1.39 + NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::) 1.40 + 1.41 + // TableAccessible 1.42 + virtual uint32_t ColCount(); 1.43 + virtual uint32_t RowCount(); 1.44 + virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex); 1.45 + virtual void ColDescription(uint32_t aColIdx, nsString& aDescription); 1.46 + virtual bool IsColSelected(uint32_t aColIdx); 1.47 + virtual bool IsRowSelected(uint32_t aRowIdx); 1.48 + virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx); 1.49 + virtual uint32_t SelectedCellCount(); 1.50 + virtual uint32_t SelectedColCount(); 1.51 + virtual uint32_t SelectedRowCount(); 1.52 + virtual void SelectedCells(nsTArray<Accessible*>* aCells); 1.53 + virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells); 1.54 + virtual void SelectedColIndices(nsTArray<uint32_t>* aCols); 1.55 + virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows); 1.56 + virtual void SelectRow(uint32_t aRowIdx); 1.57 + virtual void UnselectRow(uint32_t aRowIdx); 1.58 + virtual Accessible* AsAccessible() { return this; } 1.59 + 1.60 + // Accessible 1.61 + virtual void Shutdown(); 1.62 + virtual TableAccessible* AsTable() { return this; } 1.63 + virtual a11y::role NativeRole(); 1.64 + 1.65 +protected: 1.66 + 1.67 + // XULTreeAccessible 1.68 + virtual already_AddRefed<Accessible> 1.69 + CreateTreeItemAccessible(int32_t aRow) const MOZ_OVERRIDE; 1.70 +}; 1.71 + 1.72 + 1.73 +/** 1.74 + * Represents accessible for XUL tree item in the case when XUL tree has 1.75 + * multiple columns. 1.76 + */ 1.77 +class XULTreeGridRowAccessible : public XULTreeItemAccessibleBase 1.78 +{ 1.79 +public: 1.80 + using Accessible::GetChildAt; 1.81 + 1.82 + XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc, 1.83 + Accessible* aParent, nsITreeBoxObject* aTree, 1.84 + nsITreeView* aTreeView, int32_t aRow); 1.85 + 1.86 + // nsISupports and cycle collection 1.87 + NS_DECL_ISUPPORTS_INHERITED 1.88 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridRowAccessible, 1.89 + XULTreeItemAccessibleBase) 1.90 + 1.91 + // Accessible 1.92 + virtual void Shutdown(); 1.93 + virtual a11y::role NativeRole(); 1.94 + virtual ENameValueFlag Name(nsString& aName); 1.95 + virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, 1.96 + EWhichChildAtPoint aWhichChild); 1.97 + 1.98 + virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE; 1.99 + virtual uint32_t ChildCount() const MOZ_OVERRIDE; 1.100 + 1.101 + // XULTreeItemAccessibleBase 1.102 + virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const MOZ_OVERRIDE; 1.103 + virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx); 1.104 + 1.105 +protected: 1.106 + 1.107 + // Accessible 1.108 + virtual void CacheChildren(); 1.109 + 1.110 + // XULTreeItemAccessibleBase 1.111 + mutable AccessibleHashtable mAccessibleCache; 1.112 +}; 1.113 + 1.114 + 1.115 +/** 1.116 + * Represents an accessible for XUL tree cell in the case when XUL tree has 1.117 + * multiple columns. 1.118 + */ 1.119 + 1.120 +#define XULTREEGRIDCELLACCESSIBLE_IMPL_CID \ 1.121 +{ /* 84588ad4-549c-4196-a932-4c5ca5de5dff */ \ 1.122 + 0x84588ad4, \ 1.123 + 0x549c, \ 1.124 + 0x4196, \ 1.125 + { 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff } \ 1.126 +} 1.127 + 1.128 +class XULTreeGridCellAccessible : public LeafAccessible, 1.129 + public nsIAccessibleTableCell, 1.130 + public TableCellAccessible, 1.131 + public xpcAccessibleTableCell 1.132 +{ 1.133 +public: 1.134 + 1.135 + XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc, 1.136 + XULTreeGridRowAccessible* aRowAcc, 1.137 + nsITreeBoxObject* aTree, nsITreeView* aTreeView, 1.138 + int32_t aRow, nsITreeColumn* aColumn); 1.139 + 1.140 + // nsISupports 1.141 + NS_DECL_ISUPPORTS_INHERITED 1.142 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible, 1.143 + LeafAccessible) 1.144 + 1.145 + // nsIAccessible 1.146 + 1.147 + NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY, 1.148 + int32_t* aWidth, int32_t* aHeight); 1.149 + 1.150 + NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName); 1.151 + NS_IMETHOD DoAction(uint8_t aIndex); 1.152 + 1.153 + // nsIAccessibleTableCell 1.154 + NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::) 1.155 + 1.156 + // Accessible 1.157 + virtual TableCellAccessible* AsTableCell() { return this; } 1.158 + virtual void Shutdown(); 1.159 + virtual ENameValueFlag Name(nsString& aName); 1.160 + virtual Accessible* FocusedChild(); 1.161 + virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE; 1.162 + virtual int32_t IndexInParent() const; 1.163 + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; 1.164 + virtual a11y::role NativeRole(); 1.165 + virtual uint64_t NativeState(); 1.166 + virtual uint64_t NativeInteractiveState() const; 1.167 + 1.168 + // ActionAccessible 1.169 + virtual uint8_t ActionCount(); 1.170 + 1.171 + // TableCellAccessible 1.172 + virtual TableAccessible* Table() const MOZ_OVERRIDE; 1.173 + virtual uint32_t ColIdx() const MOZ_OVERRIDE; 1.174 + virtual uint32_t RowIdx() const MOZ_OVERRIDE; 1.175 + virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) MOZ_OVERRIDE; 1.176 + virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE { } 1.177 + virtual bool Selected() MOZ_OVERRIDE; 1.178 + 1.179 + // XULTreeGridCellAccessible 1.180 + NS_DECLARE_STATIC_IID_ACCESSOR(XULTREEGRIDCELLACCESSIBLE_IMPL_CID) 1.181 + 1.182 + /** 1.183 + * Fire name or state change event if the accessible text or value has been 1.184 + * changed. 1.185 + * @return true if name has changed 1.186 + */ 1.187 + bool CellInvalidated(); 1.188 + 1.189 +protected: 1.190 + // Accessible 1.191 + virtual Accessible* GetSiblingAtOffset(int32_t aOffset, 1.192 + nsresult* aError = nullptr) const; 1.193 + virtual void DispatchClickEvent(nsIContent* aContent, uint32_t aActionIndex); 1.194 + 1.195 + // XULTreeGridCellAccessible 1.196 + 1.197 + /** 1.198 + * Return true if value of cell can be modified. 1.199 + */ 1.200 + bool IsEditable() const; 1.201 + 1.202 + enum { eAction_Click = 0 }; 1.203 + 1.204 + nsCOMPtr<nsITreeBoxObject> mTree; 1.205 + nsITreeView* mTreeView; 1.206 + 1.207 + int32_t mRow; 1.208 + nsCOMPtr<nsITreeColumn> mColumn; 1.209 + 1.210 + nsString mCachedTextEquiv; 1.211 +}; 1.212 + 1.213 +NS_DEFINE_STATIC_IID_ACCESSOR(XULTreeGridCellAccessible, 1.214 + XULTREEGRIDCELLACCESSIBLE_IMPL_CID) 1.215 + 1.216 +} // namespace a11y 1.217 +} // namespace mozilla 1.218 + 1.219 +#endif