XULAlertAccessible.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include "XULAlertAccessible.h"
  6. #include "Accessible-inl.h"
  7. #include "Role.h"
  8. #include "States.h"
  9. using namespace mozilla::a11y;
  10. ////////////////////////////////////////////////////////////////////////////////
  11. // XULAlertAccessible
  12. ////////////////////////////////////////////////////////////////////////////////
  13. XULAlertAccessible::
  14. XULAlertAccessible(nsIContent* aContent, DocAccessible* aDoc) :
  15. AccessibleWrap(aContent, aDoc)
  16. {
  17. mGenericTypes |= eAlert;
  18. }
  19. XULAlertAccessible::~XULAlertAccessible()
  20. {
  21. }
  22. NS_IMPL_ISUPPORTS_INHERITED0(XULAlertAccessible, Accessible)
  23. role
  24. XULAlertAccessible::NativeRole()
  25. {
  26. return roles::ALERT;
  27. }
  28. uint64_t
  29. XULAlertAccessible::NativeState()
  30. {
  31. return Accessible::NativeState() | states::ALERT;
  32. }
  33. ENameValueFlag
  34. XULAlertAccessible::Name(nsString& aName)
  35. {
  36. // Screen readers need to read contents of alert, not the accessible name.
  37. // If we have both some screen readers will read the alert twice.
  38. aName.Truncate();
  39. return eNameOK;
  40. }
  41. ////////////////////////////////////////////////////////////////////////////////
  42. // Widgets
  43. bool
  44. XULAlertAccessible::IsWidget() const
  45. {
  46. return true;
  47. }
  48. Accessible*
  49. XULAlertAccessible::ContainerWidget() const
  50. {
  51. // If a part of colorpicker widget.
  52. if (mParent && mParent->IsMenuButton())
  53. return mParent;
  54. return nullptr;
  55. }