PlatformChild.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include "mozilla/a11y/PlatformChild.h"
  6. #include "mozilla/mscom/EnsureMTA.h"
  7. #include "mozilla/mscom/InterceptorLog.h"
  8. #include "Accessible2.h"
  9. #include "Accessible2_2.h"
  10. #include "AccessibleHypertext2.h"
  11. #include "AccessibleTableCell.h"
  12. #include "AccessibleHypertext2_i.c"
  13. namespace mozilla {
  14. namespace a11y {
  15. /**
  16. * Unfortunately the COM interceptor does not intrinsically handle array
  17. * outparams. Instead we manually define the relevant metadata here, and
  18. * register it in a call to mozilla::mscom::RegisterArrayData.
  19. * @see mozilla::mscom::ArrayData
  20. */
  21. static const mozilla::mscom::ArrayData sPlatformChildArrayData[] = {
  22. {IID_IEnumVARIANT, 3, 1, VT_DISPATCH, IID_IDispatch, 2},
  23. {IID_IAccessible2, 30, 1, VT_UNKNOWN | VT_BYREF, IID_IAccessibleRelation, 2},
  24. {IID_IAccessibleRelation, 7, 1, VT_UNKNOWN | VT_BYREF, IID_IUnknown, 2},
  25. {IID_IAccessible2_2, 48, 2, VT_UNKNOWN | VT_BYREF, IID_IUnknown, 3,
  26. mozilla::mscom::ArrayData::Flag::eAllocatedByServer},
  27. {IID_IAccessibleTableCell, 4, 0, VT_UNKNOWN | VT_BYREF, IID_IUnknown, 1,
  28. mozilla::mscom::ArrayData::Flag::eAllocatedByServer},
  29. {IID_IAccessibleTableCell, 7, 0, VT_UNKNOWN | VT_BYREF, IID_IUnknown, 1,
  30. mozilla::mscom::ArrayData::Flag::eAllocatedByServer},
  31. {IID_IAccessibleHypertext2, 25, 0, VT_UNKNOWN | VT_BYREF, IID_IUnknown, 1,
  32. mozilla::mscom::ArrayData::Flag::eAllocatedByServer}
  33. };
  34. // Type libraries are thread-neutral, so we can register those from any
  35. // apartment. OTOH, proxies must be registered from within the apartment where
  36. // we intend to instantiate them. Therefore RegisterProxy() must be called
  37. // via EnsureMTA.
  38. PlatformChild::PlatformChild()
  39. : mAccTypelib(mozilla::mscom::RegisterTypelib(L"oleacc.dll",
  40. mozilla::mscom::RegistrationFlags::eUseSystemDirectory))
  41. , mMiscTypelib(mozilla::mscom::RegisterTypelib(L"Accessible.tlb"))
  42. {
  43. mozilla::mscom::InterceptorLog::Init();
  44. mozilla::mscom::RegisterArrayData(sPlatformChildArrayData);
  45. UniquePtr<mozilla::mscom::RegisteredProxy> ia2Proxy;
  46. mozilla::mscom::EnsureMTA([&ia2Proxy]() -> void {
  47. ia2Proxy = Move(mozilla::mscom::RegisterProxy(L"ia2marshal.dll"));
  48. });
  49. mIA2Proxy = Move(ia2Proxy);
  50. }
  51. } // namespace a11y
  52. } // namespace mozilla