AccessibleWrap.mm (1456B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "AccessibleWrap.h" 7 #include "LocalAccessible-inl.h" 8 9 #import "MUIAccessible.h" 10 #import "MUIRootAccessible.h" 11 12 using namespace mozilla::a11y; 13 14 //----------------------------------------------------- 15 // construction 16 //----------------------------------------------------- 17 AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) 18 : LocalAccessible(aContent, aDoc), 19 mNativeObject(nil), 20 mNativeInited(false) {} 21 22 void AccessibleWrap::Shutdown() { 23 // this ensures we will not try to re-create the native object. 24 mNativeInited = true; 25 26 // we really intend to access the member directly. 27 if (mNativeObject) { 28 [mNativeObject expire]; 29 [mNativeObject release]; 30 mNativeObject = nil; 31 } 32 33 LocalAccessible::Shutdown(); 34 } 35 36 id AccessibleWrap::GetNativeObject() { 37 if (!mNativeInited && !IsDefunct()) { 38 Class type = IsRoot() ? [MUIRootAccessible class] : [MUIAccessible class]; 39 mNativeObject = [[type alloc] initWithAccessible:this]; 40 } 41 42 mNativeInited = true; 43 44 return mNativeObject; 45 } 46 47 void AccessibleWrap::GetNativeInterface(void** aOutInterface) { 48 *aOutInterface = static_cast<void*>(GetNativeObject()); 49 }