DocAccessibleChildBase.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef mozilla_a11y_DocAccessibleChildBase_h
  6. #define mozilla_a11y_DocAccessibleChildBase_h
  7. #include "mozilla/a11y/DocAccessible.h"
  8. #include "mozilla/a11y/PDocAccessibleChild.h"
  9. #include "mozilla/Unused.h"
  10. #include "nsISupportsImpl.h"
  11. namespace mozilla {
  12. namespace a11y {
  13. class Accessible;
  14. class AccShowEvent;
  15. class DocAccessibleChildBase : public PDocAccessibleChild
  16. {
  17. public:
  18. explicit DocAccessibleChildBase(DocAccessible* aDoc)
  19. : mDoc(aDoc)
  20. {
  21. MOZ_COUNT_CTOR(DocAccessibleChildBase);
  22. }
  23. ~DocAccessibleChildBase()
  24. {
  25. // Shutdown() should have been called, but maybe it isn't if the process is
  26. // killed?
  27. MOZ_ASSERT(!mDoc);
  28. if (mDoc) {
  29. mDoc->SetIPCDoc(nullptr);
  30. }
  31. MOZ_COUNT_DTOR(DocAccessibleChildBase);
  32. }
  33. virtual void Shutdown()
  34. {
  35. DetachDocument();
  36. SendShutdown();
  37. }
  38. void ShowEvent(AccShowEvent* aShowEvent);
  39. virtual void ActorDestroy(ActorDestroyReason) override
  40. {
  41. if (!mDoc) {
  42. return;
  43. }
  44. mDoc->SetIPCDoc(nullptr);
  45. mDoc = nullptr;
  46. }
  47. protected:
  48. static uint32_t InterfacesFor(Accessible* aAcc);
  49. static void SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree);
  50. virtual void MaybeSendShowEvent(ShowEventData& aData, bool aFromUser)
  51. { Unused << SendShowEvent(aData, aFromUser); }
  52. void DetachDocument()
  53. {
  54. if (mDoc) {
  55. mDoc->SetIPCDoc(nullptr);
  56. mDoc = nullptr;
  57. }
  58. }
  59. DocAccessible* mDoc;
  60. };
  61. } // namespace a11y
  62. } // namespace mozilla
  63. #endif // mozilla_a11y_DocAccessibleChildBase_h