RootAccessible.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #ifndef mozilla_a11y_RootAccessible_h__
  6. #define mozilla_a11y_RootAccessible_h__
  7. #include "HyperTextAccessible.h"
  8. #include "DocAccessibleWrap.h"
  9. #include "nsIDOMEventListener.h"
  10. class nsIDocument;
  11. namespace mozilla {
  12. namespace a11y {
  13. class RootAccessible : public DocAccessibleWrap,
  14. public nsIDOMEventListener
  15. {
  16. NS_DECL_ISUPPORTS_INHERITED
  17. public:
  18. RootAccessible(nsIDocument* aDocument, nsIPresShell* aPresShell);
  19. // nsIDOMEventListener
  20. NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
  21. // Accessible
  22. virtual void Shutdown() override;
  23. virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) override;
  24. virtual Relation RelationByType(RelationType aType) override;
  25. virtual mozilla::a11y::role NativeRole() override;
  26. virtual uint64_t NativeState() override;
  27. // RootAccessible
  28. /**
  29. * Notify that the sub document presshell was activated.
  30. */
  31. virtual void DocumentActivated(DocAccessible* aDocument);
  32. /**
  33. * Return the primary remote top level document if any.
  34. */
  35. ProxyAccessible* GetPrimaryRemoteTopLevelContentDoc() const;
  36. protected:
  37. virtual ~RootAccessible();
  38. /**
  39. * Add/remove DOM event listeners.
  40. */
  41. virtual nsresult AddEventListeners() override;
  42. virtual nsresult RemoveEventListeners() override;
  43. /**
  44. * Process the DOM event.
  45. */
  46. void ProcessDOMEvent(nsIDOMEvent* aEvent);
  47. /**
  48. * Process "popupshown" event. Used by HandleEvent().
  49. */
  50. void HandlePopupShownEvent(Accessible* aAccessible);
  51. /*
  52. * Process "popuphiding" event. Used by HandleEvent().
  53. */
  54. void HandlePopupHidingEvent(nsINode* aNode);
  55. #ifdef MOZ_XUL
  56. void HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
  57. XULTreeAccessible* aAccessible);
  58. void HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
  59. XULTreeAccessible* aAccessible);
  60. uint32_t GetChromeFlags();
  61. #endif
  62. };
  63. inline RootAccessible*
  64. Accessible::AsRoot()
  65. {
  66. return IsRoot() ? static_cast<mozilla::a11y::RootAccessible*>(this) : nullptr;
  67. }
  68. } // namespace a11y
  69. } // namespace mozilla
  70. #endif