RootAccessible.h (2701B)
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 6 #ifndef mozilla_a11y_RootAccessible_h__ 7 #define mozilla_a11y_RootAccessible_h__ 8 9 #include "HyperTextAccessible.h" 10 #include "DocAccessibleWrap.h" 11 12 #include "nsIDOMEventListener.h" 13 14 namespace mozilla { 15 16 class PresShell; 17 18 namespace a11y { 19 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. 26 */ 27 class RootAccessible : public DocAccessibleWrap, public nsIDOMEventListener { 28 NS_DECL_ISUPPORTS_INHERITED 29 30 public: 31 RootAccessible(dom::Document* aDocument, PresShell* aPresShell); 32 33 // nsIDOMEventListener 34 NS_DECL_NSIDOMEVENTLISTENER 35 36 // LocalAccessible 37 virtual void Shutdown() override; 38 virtual mozilla::a11y::ENameValueFlag DirectName( 39 nsString& aName) const override; 40 virtual Relation RelationByType(RelationType aType) const override; 41 virtual uint64_t NativeState() const override; 42 43 // RootAccessible 44 45 /** 46 * Notify that the sub document presshell was activated. 47 */ 48 virtual void DocumentActivated(DocAccessible* aDocument); 49 50 /** 51 * Return the primary remote top level document if any. 52 */ 53 RemoteAccessible* GetPrimaryRemoteTopLevelContentDoc() const; 54 55 protected: 56 virtual ~RootAccessible(); 57 58 /** 59 * Add/remove DOM event listeners. 60 */ 61 virtual nsresult AddEventListeners() override; 62 virtual nsresult RemoveEventListeners() override; 63 64 /** 65 * Process the DOM event. 66 */ 67 void ProcessDOMEvent(dom::Event* aDOMEvent, nsINode* aTarget); 68 69 /** 70 * Process "popupshown" event. Used by HandleEvent(). 71 */ 72 void HandlePopupShownEvent(LocalAccessible* aAccessible); 73 74 /* 75 * Process "popuphiding" event. Used by HandleEvent(). 76 */ 77 void HandlePopupHidingEvent(nsINode* aNode); 78 79 void HandleTreeRowCountChangedEvent(dom::Event* aEvent, 80 XULTreeAccessible* aAccessible); 81 void HandleTreeInvalidatedEvent(dom::Event* aEvent, 82 XULTreeAccessible* aAccessible); 83 84 uint32_t GetChromeFlags() const; 85 }; 86 87 inline RootAccessible* LocalAccessible::AsRoot() { 88 return IsRoot() ? static_cast<mozilla::a11y::RootAccessible*>(this) : nullptr; 89 } 90 91 } // namespace a11y 92 } // namespace mozilla 93 94 #endif