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