1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/mac/AccessibleWrap.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* -*- Mode: Objective-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 +/* For documentation of the accessibility architecture, 1.10 + * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html 1.11 + */ 1.12 + 1.13 +#ifndef _AccessibleWrap_H_ 1.14 +#define _AccessibleWrap_H_ 1.15 + 1.16 +#include <objc/objc.h> 1.17 + 1.18 +#include "Accessible.h" 1.19 +#include "States.h" 1.20 + 1.21 +#include "nsCOMPtr.h" 1.22 + 1.23 +#include "nsTArray.h" 1.24 +#include "nsAutoPtr.h" 1.25 + 1.26 +#if defined(__OBJC__) 1.27 +@class mozAccessible; 1.28 +#endif 1.29 + 1.30 +namespace mozilla { 1.31 +namespace a11y { 1.32 + 1.33 +class AccessibleWrap : public Accessible 1.34 +{ 1.35 +public: // construction, destruction 1.36 + AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc); 1.37 + virtual ~AccessibleWrap(); 1.38 + 1.39 + /** 1.40 + * Get the native Obj-C object (mozAccessible). 1.41 + */ 1.42 + NS_IMETHOD GetNativeInterface (void** aOutAccessible); 1.43 + 1.44 + /** 1.45 + * The objective-c |Class| type that this accessible's native object 1.46 + * should be instantied with. used on runtime to determine the 1.47 + * right type for this accessible's associated native object. 1.48 + */ 1.49 + virtual Class GetNativeType (); 1.50 + 1.51 + virtual void Shutdown (); 1.52 + virtual void InvalidateChildren(); 1.53 + 1.54 + virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) MOZ_OVERRIDE; 1.55 + virtual bool RemoveChild(Accessible* aAccessible); 1.56 + 1.57 + virtual nsresult HandleAccEvent(AccEvent* aEvent); 1.58 + 1.59 + /** 1.60 + * Ignored means that the accessible might still have children, but is not 1.61 + * displayed to the user. it also has no native accessible object represented 1.62 + * for it. 1.63 + */ 1.64 + bool IsIgnored(); 1.65 + 1.66 + inline bool HasPopup () 1.67 + { return (NativeState() & mozilla::a11y::states::HASPOPUP); } 1.68 + 1.69 + /** 1.70 + * Returns this accessible's all children, adhering to "flat" accessibles by 1.71 + * not returning their children. 1.72 + */ 1.73 + void GetUnignoredChildren(nsTArray<Accessible*>* aChildrenArray); 1.74 + Accessible* GetUnignoredParent() const; 1.75 + 1.76 +protected: 1.77 + 1.78 + /** 1.79 + * Return true if the parent doesn't have children to expose to AT. 1.80 + */ 1.81 + bool AncestorIsFlat(); 1.82 + 1.83 + /** 1.84 + * Get the native object. Create it if needed. 1.85 + */ 1.86 +#if defined(__OBJC__) 1.87 + mozAccessible* GetNativeObject(); 1.88 +#else 1.89 + id GetNativeObject(); 1.90 +#endif 1.91 + 1.92 +private: 1.93 + 1.94 + /** 1.95 + * Our native object. Private because its creation is done lazily. 1.96 + * Don't access it directly. Ever. Unless you are GetNativeObject() or 1.97 + * Shutdown() 1.98 + */ 1.99 +#if defined(__OBJC__) 1.100 + // if we are in Objective-C, we use the actual Obj-C class. 1.101 + mozAccessible* mNativeObject; 1.102 +#else 1.103 + id mNativeObject; 1.104 +#endif 1.105 + 1.106 + /** 1.107 + * We have created our native. This does not mean there is one. 1.108 + * This can never go back to false. 1.109 + * We need it because checking whether we need a native object cost time. 1.110 + */ 1.111 + bool mNativeInited; 1.112 +}; 1.113 + 1.114 +} // namespace a11y 1.115 +} // namespace mozilla 1.116 + 1.117 +#endif