Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=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_DocAccessibleChildBase_h
8 : #define mozilla_a11y_DocAccessibleChildBase_h
9 :
10 : #include "mozilla/a11y/DocAccessible.h"
11 : #include "mozilla/a11y/PDocAccessibleChild.h"
12 : #include "mozilla/Unused.h"
13 : #include "nsISupportsImpl.h"
14 :
15 : namespace mozilla {
16 : namespace a11y {
17 :
18 : class Accessible;
19 : class AccShowEvent;
20 :
21 : class DocAccessibleChildBase : public PDocAccessibleChild
22 : {
23 : public:
24 0 : explicit DocAccessibleChildBase(DocAccessible* aDoc)
25 0 : : mDoc(aDoc)
26 : {
27 0 : MOZ_COUNT_CTOR(DocAccessibleChildBase);
28 0 : }
29 :
30 0 : ~DocAccessibleChildBase()
31 0 : {
32 : // Shutdown() should have been called, but maybe it isn't if the process is
33 : // killed?
34 0 : MOZ_ASSERT(!mDoc);
35 0 : if (mDoc) {
36 0 : mDoc->SetIPCDoc(nullptr);
37 : }
38 :
39 0 : MOZ_COUNT_DTOR(DocAccessibleChildBase);
40 0 : }
41 :
42 0 : virtual void Shutdown()
43 : {
44 0 : DetachDocument();
45 0 : SendShutdown();
46 0 : }
47 :
48 : void ShowEvent(AccShowEvent* aShowEvent);
49 :
50 0 : virtual void ActorDestroy(ActorDestroyReason) override
51 : {
52 0 : if (!mDoc) {
53 0 : return;
54 : }
55 :
56 0 : mDoc->SetIPCDoc(nullptr);
57 0 : mDoc = nullptr;
58 : }
59 :
60 : protected:
61 : static uint32_t InterfacesFor(Accessible* aAcc);
62 : static void SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree);
63 :
64 0 : virtual void MaybeSendShowEvent(ShowEventData& aData, bool aFromUser)
65 0 : { Unused << SendShowEvent(aData, aFromUser); }
66 :
67 0 : void DetachDocument()
68 : {
69 0 : if (mDoc) {
70 0 : mDoc->SetIPCDoc(nullptr);
71 0 : mDoc = nullptr;
72 : }
73 0 : }
74 :
75 : DocAccessible* mDoc;
76 : };
77 :
78 : } // namespace a11y
79 : } // namespace mozilla
80 :
81 : #endif // mozilla_a11y_DocAccessibleChildBase_h
|