Bug 1833854 - Part 1: Remove the unused JSGC_PRETENURE_GROUP_THRESHOLD GC parameter...
[gecko.git] / accessible / android / DocAccessibleWrap.cpp
blob9f661dd226c00a7489e03fe955f3dba2b618984c
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 #include "LocalAccessible-inl.h"
8 #include "AccAttributes.h"
9 #include "DocAccessibleChild.h"
10 #include "DocAccessibleWrap.h"
11 #include "nsIDocShell.h"
12 #include "nsIScrollableFrame.h"
13 #include "nsLayoutUtils.h"
14 #include "nsAccessibilityService.h"
15 #include "nsAccUtils.h"
16 #include "Pivot.h"
17 #include "SessionAccessibility.h"
18 #include "TraversalRule.h"
19 #include "mozilla/PresShell.h"
20 #include "mozilla/a11y/DocAccessiblePlatformExtChild.h"
22 using namespace mozilla;
23 using namespace mozilla::a11y;
25 #define UNIQUE_ID(acc) \
26 !acc || (acc->IsDoc() && acc->AsDoc()->IPCDoc()) \
27 ? 0 \
28 : reinterpret_cast<uint64_t>(acc->UniqueID())
30 ////////////////////////////////////////////////////////////////////////////////
31 // DocAccessibleWrap
32 ////////////////////////////////////////////////////////////////////////////////
34 DocAccessibleWrap::DocAccessibleWrap(Document* aDocument, PresShell* aPresShell)
35 : DocAccessible(aDocument, aPresShell) {
36 // We need an nsINode associated with this accessible to register it with the
37 // right SessionAccessibility instance. When the base AccessibleWrap
38 // constructor is called we don't have one yet because null is passed as the
39 // content node. So we do it here after a Document is associated with the
40 // accessible.
41 if (!IPCAccessibilityActive()) {
42 MonitorAutoLock mal(nsAccessibilityService::GetAndroidMonitor());
43 SessionAccessibility::RegisterAccessible(this);
47 DocAccessibleWrap::~DocAccessibleWrap() {}
49 void DocAccessibleWrap::Shutdown() {
50 // Unregister here before disconnecting from PresShell.
51 if (!IPCAccessibilityActive()) {
52 MonitorAutoLock mal(nsAccessibilityService::GetAndroidMonitor());
53 if (IsRoot()) {
54 SessionAccessibility::UnregisterAll(PresShellPtr());
55 } else {
56 SessionAccessibility::UnregisterAccessible(this);
59 DocAccessible::Shutdown();
62 DocAccessibleWrap* DocAccessibleWrap::GetTopLevelContentDoc(
63 AccessibleWrap* aAccessible) {
64 DocAccessibleWrap* doc =
65 static_cast<DocAccessibleWrap*>(aAccessible->Document());
66 while (doc && !doc->IsTopLevelContentDoc()) {
67 doc = static_cast<DocAccessibleWrap*>(doc->ParentDocument());
70 return doc;
73 bool DocAccessibleWrap::IsTopLevelContentDoc() {
74 DocAccessible* parentDoc = ParentDocument();
75 return DocumentNode()->IsContentDocument() &&
76 (!parentDoc || !parentDoc->DocumentNode()->IsContentDocument());
79 #undef UNIQUE_ID