Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / accessible / ipc / DocAccessibleChild.h
blobdef22c596b31e1b7f6f1c4dfaf0bb8d026f5711a
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/. */
7 #ifndef mozilla_a11y_DocAccessibleChild_h
8 #define mozilla_a11y_DocAccessibleChild_h
10 #include "mozilla/a11y/DocAccessible.h"
11 #include "mozilla/a11y/PDocAccessibleChild.h"
12 #include "mozilla/Unused.h"
13 #include "nsISupportsImpl.h"
15 namespace mozilla {
16 namespace a11y {
18 class LocalAccessible;
19 class AccShowEvent;
21 /**
22 * These objects handle content side communication for an accessible document,
23 * and their lifetime is the same as the document they represent.
25 class DocAccessibleChild : public PDocAccessibleChild {
26 public:
27 DocAccessibleChild(DocAccessible* aDoc, IProtocol* aManager) : mDoc(aDoc) {
28 MOZ_COUNT_CTOR(DocAccessibleChild);
29 SetManager(aManager);
32 ~DocAccessibleChild() {
33 // Shutdown() should have been called, but maybe it isn't if the process is
34 // killed?
35 MOZ_ASSERT(!mDoc);
36 if (mDoc) {
37 mDoc->SetIPCDoc(nullptr);
40 MOZ_COUNT_DTOR(DocAccessibleChild);
43 virtual void Shutdown() {
44 DetachDocument();
45 SendShutdown();
48 /**
49 * Serializes a shown tree and sends it to the chrome process.
51 void InsertIntoIpcTree(LocalAccessible* aChild, bool aSuppressShowEvent);
52 void ShowEvent(AccShowEvent* aShowEvent);
54 virtual void ActorDestroy(ActorDestroyReason) override {
55 if (!mDoc) {
56 return;
59 mDoc->SetIPCDoc(nullptr);
60 mDoc = nullptr;
63 virtual mozilla::ipc::IPCResult RecvTakeFocus(const uint64_t& aID) override;
65 MOZ_CAN_RUN_SCRIPT_BOUNDARY
66 virtual mozilla::ipc::IPCResult RecvScrollTo(
67 const uint64_t& aID, const uint32_t& aScrollType) override;
69 virtual mozilla::ipc::IPCResult RecvTakeSelection(
70 const uint64_t& aID) override;
71 virtual mozilla::ipc::IPCResult RecvSetSelected(const uint64_t& aID,
72 const bool& aSelect) override;
74 virtual mozilla::ipc::IPCResult RecvVerifyCache(
75 const uint64_t& aID, const uint64_t& aCacheDomain,
76 AccAttributes* aFields) override;
78 virtual mozilla::ipc::IPCResult RecvDoActionAsync(
79 const uint64_t& aID, const uint8_t& aIndex) override;
81 virtual mozilla::ipc::IPCResult RecvSetCaretOffset(
82 const uint64_t& aID, const int32_t& aOffset) override;
84 MOZ_CAN_RUN_SCRIPT_BOUNDARY
85 virtual mozilla::ipc::IPCResult RecvSetTextSelection(
86 const uint64_t& aStartID, const int32_t& aStartOffset,
87 const uint64_t& aEndID, const int32_t& aEndOffset,
88 const int32_t& aSelectionNum) override;
90 MOZ_CAN_RUN_SCRIPT_BOUNDARY
91 virtual mozilla::ipc::IPCResult RecvScrollTextLeafRangeIntoView(
92 const uint64_t& aStartID, const int32_t& aStartOffset,
93 const uint64_t& aEndID, const int32_t& aEndOffset,
94 const uint32_t& aScrollType) override;
96 virtual mozilla::ipc::IPCResult RecvRemoveTextSelection(
97 const uint64_t& aID, const int32_t& aSelectionNum) override;
99 virtual mozilla::ipc::IPCResult RecvSetCurValue(
100 const uint64_t& aID, const double& aValue) override;
102 virtual mozilla::ipc::IPCResult RecvReplaceText(
103 const uint64_t& aID, const nsAString& aText) override;
105 virtual mozilla::ipc::IPCResult RecvInsertText(
106 const uint64_t& aID, const nsAString& aText,
107 const int32_t& aPosition) override;
109 virtual mozilla::ipc::IPCResult RecvCopyText(const uint64_t& aID,
110 const int32_t& aStartPos,
111 const int32_t& aEndPos) override;
113 virtual mozilla::ipc::IPCResult RecvCutText(const uint64_t& aID,
114 const int32_t& aStartPos,
115 const int32_t& aEndPos) override;
117 virtual mozilla::ipc::IPCResult RecvDeleteText(
118 const uint64_t& aID, const int32_t& aStartPos,
119 const int32_t& aEndPos) override;
121 MOZ_CAN_RUN_SCRIPT_BOUNDARY
122 virtual mozilla::ipc::IPCResult RecvPasteText(
123 const uint64_t& aID, const int32_t& aPosition) override;
125 virtual mozilla::ipc::IPCResult RecvRestoreFocus() override;
127 virtual mozilla::ipc::IPCResult RecvScrollToPoint(const uint64_t& aID,
128 const uint32_t& aScrollType,
129 const int32_t& aX,
130 const int32_t& aY) override;
132 bool SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset,
133 const bool& aIsSelectionCollapsed,
134 const bool& aIsAtEndOfLine,
135 const int32_t& aGranularity);
136 bool SendFocusEvent(const uint64_t& aID);
138 #if !defined(XP_WIN)
139 virtual mozilla::ipc::IPCResult RecvAnnounce(
140 const uint64_t& aID, const nsAString& aAnnouncement,
141 const uint16_t& aPriority) override;
142 #endif // !defined(XP_WIN)
144 virtual mozilla::ipc::IPCResult RecvScrollSubstringToPoint(
145 const uint64_t& aID, const int32_t& aStartOffset,
146 const int32_t& aEndOffset, const uint32_t& aCoordinateType,
147 const int32_t& aX, const int32_t& aY) override;
149 private:
150 LayoutDeviceIntRect GetCaretRectFor(const uint64_t& aID);
152 protected:
153 static void FlattenTree(LocalAccessible* aRoot,
154 nsTArray<LocalAccessible*>& aTree);
156 static AccessibleData SerializeAcc(LocalAccessible* aAcc);
158 void DetachDocument() {
159 if (mDoc) {
160 mDoc->SetIPCDoc(nullptr);
161 mDoc = nullptr;
165 LocalAccessible* IdToAccessible(const uint64_t& aID) const;
166 HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
168 DocAccessible* mDoc;
170 friend void DocAccessible::DoInitialUpdate();
173 } // namespace a11y
174 } // namespace mozilla
176 #endif // mozilla_a11y_DocAccessibleChild_h