xpcAccessibleValue.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "xpcAccessibleGeneric.h"
  6. #include "Accessible.h"
  7. using namespace mozilla;
  8. using namespace mozilla::a11y;
  9. NS_IMETHODIMP
  10. xpcAccessibleValue::GetMaximumValue(double* aValue)
  11. {
  12. NS_ENSURE_ARG_POINTER(aValue);
  13. *aValue = 0;
  14. if (Intl().IsNull())
  15. return NS_ERROR_FAILURE;
  16. if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
  17. return NS_ERROR_FAILURE;
  18. double value;
  19. if (Intl().IsAccessible()) {
  20. value = Intl().AsAccessible()->MaxValue();
  21. } else {
  22. value = Intl().AsProxy()->MaxValue();
  23. }
  24. if (!IsNaN(value))
  25. *aValue = value;
  26. return NS_OK;
  27. }
  28. NS_IMETHODIMP
  29. xpcAccessibleValue::GetMinimumValue(double* aValue)
  30. {
  31. NS_ENSURE_ARG_POINTER(aValue);
  32. *aValue = 0;
  33. if (Intl().IsNull())
  34. return NS_ERROR_FAILURE;
  35. if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
  36. return NS_ERROR_FAILURE;
  37. double value;
  38. if (Intl().IsAccessible()) {
  39. value = Intl().AsAccessible()->MinValue();
  40. } else {
  41. value = Intl().AsProxy()->MinValue();
  42. }
  43. if (!IsNaN(value))
  44. *aValue = value;
  45. return NS_OK;
  46. }
  47. NS_IMETHODIMP
  48. xpcAccessibleValue::GetCurrentValue(double* aValue)
  49. {
  50. NS_ENSURE_ARG_POINTER(aValue);
  51. *aValue = 0;
  52. if (Intl().IsNull())
  53. return NS_ERROR_FAILURE;
  54. if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
  55. return NS_ERROR_FAILURE;
  56. double value;
  57. if (Intl().IsAccessible()) {
  58. value = Intl().AsAccessible()->CurValue();
  59. } else {
  60. value = Intl().AsProxy()->CurValue();
  61. }
  62. if (!IsNaN(value))
  63. *aValue = value;
  64. return NS_OK;
  65. }
  66. NS_IMETHODIMP
  67. xpcAccessibleValue::SetCurrentValue(double aValue)
  68. {
  69. if (Intl().IsNull())
  70. return NS_ERROR_FAILURE;
  71. if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
  72. return NS_ERROR_FAILURE;
  73. if (Intl().IsAccessible()) {
  74. Intl().AsAccessible()->SetCurValue(aValue);
  75. } else {
  76. Intl().AsProxy()->SetCurValue(aValue);
  77. }
  78. return NS_OK;
  79. }
  80. NS_IMETHODIMP
  81. xpcAccessibleValue::GetMinimumIncrement(double* aValue)
  82. {
  83. NS_ENSURE_ARG_POINTER(aValue);
  84. *aValue = 0;
  85. if (Intl().IsNull())
  86. return NS_ERROR_FAILURE;
  87. if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
  88. return NS_ERROR_FAILURE;
  89. double value;
  90. if (Intl().IsAccessible()) {
  91. value = Intl().AsAccessible()->Step();
  92. } else {
  93. #if defined(XP_WIN)
  94. return NS_ERROR_NOT_IMPLEMENTED;
  95. #else
  96. value = Intl().AsProxy()->Step();
  97. #endif
  98. }
  99. if (!IsNaN(value))
  100. *aValue = value;
  101. return NS_OK;
  102. }