1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=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 mozilla_a11y_HandlerDataCleanup_h 8 #define mozilla_a11y_HandlerDataCleanup_h 9 10 #include <oleauto.h> 11 #include "HandlerData.h" 12 13 namespace mozilla { 14 namespace a11y { 15 ReleaseStaticIA2DataInterfaces(StaticIA2Data & aData)16inline void ReleaseStaticIA2DataInterfaces(StaticIA2Data& aData) { 17 // Only interfaces of the proxied object wrapped by this handler should be 18 // released here, never other objects! 19 // For example, if StaticIA2Data were to include accParent in future, 20 // that must not be released here. 21 if (aData.mIA2) { 22 aData.mIA2->Release(); 23 } 24 if (aData.mIAHypertext) { 25 aData.mIAHypertext->Release(); 26 } 27 if (aData.mIAHyperlink) { 28 aData.mIAHyperlink->Release(); 29 } 30 if (aData.mIATable) { 31 aData.mIATable->Release(); 32 } 33 if (aData.mIATable2) { 34 aData.mIATable2->Release(); 35 } 36 if (aData.mIATableCell) { 37 aData.mIATableCell->Release(); 38 } 39 } 40 41 inline void CleanupDynamicIA2Data(DynamicIA2Data& aData, bool aZero = true) { 42 ::VariantClear(&aData.mRole); 43 if (aData.mKeyboardShortcut) { 44 ::SysFreeString(aData.mKeyboardShortcut); 45 } 46 if (aData.mName) { 47 ::SysFreeString(aData.mName); 48 } 49 if (aData.mDescription) { 50 ::SysFreeString(aData.mDescription); 51 } 52 if (aData.mDefaultAction) { 53 ::SysFreeString(aData.mDefaultAction); 54 } 55 if (aData.mValue) { 56 ::SysFreeString(aData.mValue); 57 } 58 if (aData.mAttributes) { 59 ::SysFreeString(aData.mAttributes); 60 } 61 if (aData.mIA2Locale.language) { 62 ::SysFreeString(aData.mIA2Locale.language); 63 } 64 if (aData.mIA2Locale.country) { 65 ::SysFreeString(aData.mIA2Locale.country); 66 } 67 if (aData.mIA2Locale.variant) { 68 ::SysFreeString(aData.mIA2Locale.variant); 69 } 70 if (aZero) { 71 ZeroMemory(&aData, sizeof(DynamicIA2Data)); 72 } 73 } 74 75 } // namespace a11y 76 } // namespace mozilla 77 78 #endif // mozilla_a11y_HandlerDataCleanup_h 79