Bug 1856666 - run snap tests as cron r=releng-reviewers,ahal
[gecko.git] / accessible / generic / RootAccessible.h
blobb1e7e42fdb40fc524b2ce88e847b36bd077173c4
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/. */
6 #ifndef mozilla_a11y_RootAccessible_h__
7 #define mozilla_a11y_RootAccessible_h__
9 #include "HyperTextAccessible.h"
10 #include "DocAccessibleWrap.h"
12 #include "nsIDOMEventListener.h"
14 namespace mozilla {
16 class PresShell;
18 namespace a11y {
20 /**
21 * The node at a root of the accessibility tree. This node originated in the
22 * current process. If this is the parent process, RootAccessible is the
23 * Accessible for the top-level window. If this is a content process,
24 * RootAccessible is a top-level content document in this process, which is
25 * either a tab document or an out-of-process iframe.
27 class RootAccessible : public DocAccessibleWrap, public nsIDOMEventListener {
28 NS_DECL_ISUPPORTS_INHERITED
30 public:
31 RootAccessible(dom::Document* aDocument, PresShell* aPresShell);
33 // nsIDOMEventListener
34 NS_DECL_NSIDOMEVENTLISTENER
36 // LocalAccessible
37 virtual void Shutdown() override;
38 virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) const override;
39 virtual Relation RelationByType(RelationType aType) const override;
40 virtual uint64_t NativeState() const override;
42 // RootAccessible
44 /**
45 * Notify that the sub document presshell was activated.
47 virtual void DocumentActivated(DocAccessible* aDocument);
49 /**
50 * Return the primary remote top level document if any.
52 RemoteAccessible* GetPrimaryRemoteTopLevelContentDoc() const;
54 protected:
55 virtual ~RootAccessible();
57 /**
58 * Add/remove DOM event listeners.
60 virtual nsresult AddEventListeners() override;
61 virtual nsresult RemoveEventListeners() override;
63 /**
64 * Process the DOM event.
66 void ProcessDOMEvent(dom::Event* aDOMEvent, nsINode* aTarget);
68 /**
69 * Process "popupshown" event. Used by HandleEvent().
71 void HandlePopupShownEvent(LocalAccessible* aAccessible);
74 * Process "popuphiding" event. Used by HandleEvent().
76 void HandlePopupHidingEvent(nsINode* aNode);
78 void HandleTreeRowCountChangedEvent(dom::Event* aEvent,
79 XULTreeAccessible* aAccessible);
80 void HandleTreeInvalidatedEvent(dom::Event* aEvent,
81 XULTreeAccessible* aAccessible);
83 uint32_t GetChromeFlags() const;
86 inline RootAccessible* LocalAccessible::AsRoot() {
87 return IsRoot() ? static_cast<mozilla::a11y::RootAccessible*>(this) : nullptr;
90 } // namespace a11y
91 } // namespace mozilla
93 #endif