Bug 1285643 - Make xpcAccessibleValue work with proxied accessibles. r=tbsaunde
authorMichael Li <michael.li11702@gmail.com>
Mon, 11 Jul 2016 14:26:00 -0400
changeset 346893 9e87f6e3d61fb5b8ac395db6c39db95cd803ab0d
parent 346892 480e54e0ae6c08919fc79dbb1922e19366b8c829
child 346894 4c831617214558923c68aa9e51f2d89cae4387a3
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1285643
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1285643 - Make xpcAccessibleValue work with proxied accessibles. r=tbsaunde
accessible/xpcom/xpcAccessibleGeneric.h
accessible/xpcom/xpcAccessibleValue.cpp
accessible/xpcom/xpcAccessibleValue.h
--- a/accessible/xpcom/xpcAccessibleGeneric.h
+++ b/accessible/xpcom/xpcAccessibleGeneric.h
@@ -93,18 +93,18 @@ xpcAccessibleHyperLink::Intl()
 }
 
 inline Accessible*
 xpcAccessibleSelectable::Intl()
 {
   return static_cast<xpcAccessibleGeneric*>(this)->mIntl.AsAccessible();
 }
 
-inline Accessible*
+inline AccessibleOrProxy
 xpcAccessibleValue::Intl()
 {
-  return static_cast<xpcAccessibleGeneric*>(this)->mIntl.AsAccessible();
+  return static_cast<xpcAccessibleGeneric*>(this)->mIntl;
 }
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/xpcom/xpcAccessibleValue.cpp
+++ b/accessible/xpcom/xpcAccessibleValue.cpp
@@ -11,75 +11,119 @@ using namespace mozilla;
 using namespace mozilla::a11y;
 
 NS_IMETHODIMP
 xpcAccessibleValue::GetMaximumValue(double* aValue)
 {
   NS_ENSURE_ARG_POINTER(aValue);
   *aValue = 0;
 
-  if (Intl()->IsDefunct())
+  if (Intl().IsNull())
+    return NS_ERROR_FAILURE;
+
+  if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
     return NS_ERROR_FAILURE;
 
-  double value = Intl()->MaxValue();
+  double value;
+  if (Intl().IsAccessible()) {
+    value = Intl().AsAccessible()->MaxValue();
+  } else { 
+    value = Intl().AsProxy()->MaxValue();
+  }
+
   if (!IsNaN(value))
     *aValue = value;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleValue::GetMinimumValue(double* aValue)
 {
   NS_ENSURE_ARG_POINTER(aValue);
   *aValue = 0;
 
-  if (Intl()->IsDefunct())
+  if (Intl().IsNull())
+    return NS_ERROR_FAILURE;
+
+  if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
     return NS_ERROR_FAILURE;
 
-  double value = Intl()->MinValue();
+  double value;
+  if (Intl().IsAccessible()) {
+    value = Intl().AsAccessible()->MinValue();
+  } else { 
+    value = Intl().AsProxy()->MinValue();
+  }
+
   if (!IsNaN(value))
     *aValue = value;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleValue::GetCurrentValue(double* aValue)
 {
   NS_ENSURE_ARG_POINTER(aValue);
   *aValue = 0;
 
-  if (Intl()->IsDefunct())
+  if (Intl().IsNull())
+    return NS_ERROR_FAILURE;
+
+  if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
     return NS_ERROR_FAILURE;
 
-  double value = Intl()->CurValue();
+  double value;
+  if (Intl().IsAccessible()) {
+    value = Intl().AsAccessible()->CurValue();
+  } else { 
+    value = Intl().AsProxy()->MinValue();
+  }
+
   if (!IsNaN(value))
     *aValue = value;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleValue::SetCurrentValue(double aValue)
 {
-  if (Intl()->IsDefunct())
+  if (Intl().IsNull())
+    return NS_ERROR_FAILURE;
+
+  if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
     return NS_ERROR_FAILURE;
 
-  Intl()->SetCurValue(aValue);
+  if (Intl().IsAccessible()) {
+    Intl().AsAccessible()->SetCurValue(aValue);
+  } else { 
+    Intl().AsProxy()->SetCurValue(aValue);
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleValue::GetMinimumIncrement(double* aValue)
 {
   NS_ENSURE_ARG_POINTER(aValue);
   *aValue = 0;
 
-  if (Intl()->IsDefunct())
+  if (Intl().IsNull())
+    return NS_ERROR_FAILURE;
+
+  if (Intl().IsAccessible() && Intl().AsAccessible()->IsDefunct())
     return NS_ERROR_FAILURE;
 
-  double value = Intl()->Step();
+  double value = Intl().AsAccessible()->Step();
+  if (Intl().IsAccessible()) {
+    value = Intl().AsAccessible()->Step();
+  } else { 
+    value = Intl().AsProxy()->Step();
+  }
+
   if (!IsNaN(value))
     *aValue = value;
 
   return NS_OK;
 }
--- a/accessible/xpcom/xpcAccessibleValue.h
+++ b/accessible/xpcom/xpcAccessibleValue.h
@@ -27,18 +27,17 @@ public:
   NS_IMETHOD SetCurrentValue(double aValue) final override;
   NS_IMETHOD GetMinimumIncrement(double* aMinIncrement) final override;
 
 protected:
   xpcAccessibleValue() { }
   virtual ~xpcAccessibleValue() {}
 
 private:
-  Accessible* Intl();
+  AccessibleOrProxy Intl();
 
   xpcAccessibleValue(const xpcAccessibleValue&) = delete;
   xpcAccessibleValue& operator =(const xpcAccessibleValue&) = delete;
 };
 
 } // namespace a11y
 } // namespace mozilla
-
 #endif