AccessibleWrap.h (2594B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef __NS_ACCESSIBLE_WRAP_H__ 8 #define __NS_ACCESSIBLE_WRAP_H__ 9 10 #include "nsCOMPtr.h" 11 #include "LocalAccessible.h" 12 13 struct _AtkObject; 14 typedef struct _AtkObject AtkObject; 15 16 enum AtkProperty { 17 PROP_0, // gobject convention 18 PROP_NAME, 19 PROP_DESCRIPTION, 20 PROP_PARENT, // ancestry has changed 21 PROP_ROLE, 22 PROP_LAYER, 23 PROP_MDI_ZORDER, 24 PROP_TABLE_CAPTION, 25 PROP_TABLE_COLUMN_DESCRIPTION, 26 PROP_TABLE_COLUMN_HEADER, 27 PROP_TABLE_ROW_DESCRIPTION, 28 PROP_TABLE_ROW_HEADER, 29 PROP_TABLE_SUMMARY, 30 PROP_LAST // gobject convention 31 }; 32 33 struct AtkPropertyChange { 34 int32_t type; // property type as listed above 35 void* oldvalue; 36 void* newvalue; 37 }; 38 39 namespace mozilla { 40 namespace a11y { 41 42 class MaiHyperlink; 43 44 /** 45 * Atk specific functionality for an accessibility tree node that originated in 46 * mDoc's content process. 47 * 48 * AccessibleWrap, and its descendents in atk directory provide the 49 * implementation of AtkObject. 50 */ 51 class AccessibleWrap : public LocalAccessible { 52 public: 53 AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc); 54 virtual ~AccessibleWrap(); 55 void ShutdownAtkObject(); 56 57 virtual void Shutdown() override; 58 59 // return the atk object for this AccessibleWrap 60 virtual void GetNativeInterface(void** aOutAccessible) override; 61 62 AtkObject* GetAtkObject(void); 63 static AtkObject* GetAtkObject(LocalAccessible* aAccessible); 64 65 bool IsValidObject(); 66 67 /** 68 * ATK has a bunch of getters that expect a borrowed reference to raw char* 69 * pointers. To simulate this, we have a method that uses a static nsCString 70 * return a temporary buffer that gets wiped on the next call. 71 */ 72 static const char* ReturnString(nsAString& aString); 73 74 static void GetKeyBinding(Accessible* aAccessible, nsAString& aResult); 75 76 static Accessible* GetColumnHeader(TableAccessible* aAccessible, 77 int32_t aColIdx); 78 static Accessible* GetRowHeader(TableAccessible* aAccessible, 79 int32_t aRowIdx); 80 81 protected: 82 nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject* aObject); 83 nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject* aObject); 84 85 AtkObject* mAtkObject; 86 }; 87 88 } // namespace a11y 89 } // namespace mozilla 90 91 #endif /* __NS_ACCESSIBLE_WRAP_H__ */