Bug 379878. Fix crashes and accessible value interface support for XUL progress meter. r=ginn.chen
authoraaronleventhal@moonset.net
Wed, 09 May 2007 06:25:52 -0700
changeset 1313 2a241e08dcd923f45b59b0d85f9dbdac6d2852f0
parent 1312 0a1cecca4bc1d9866bd94e651f9caa59eed7e5cd
child 1314 956b2d44a6c7061af7dd3c3e030d9d1502dbd779
push idunknown
push userunknown
push dateunknown
reviewersginn.chen
bugs379878
milestone1.9a5pre
Bug 379878. Fix crashes and accessible value interface support for XUL progress meter. r=ginn.chen
accessible/src/atk/nsMaiInterfaceValue.cpp
accessible/src/xul/nsXULFormControlAccessible.cpp
--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
@@ -125,17 +125,17 @@ getMinimumIncrementCB(AtkValue *obj, GVa
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
                             getter_AddRefs(accValue));
     if (!accValue)
         return;
 
-    memset (accValue,  0, sizeof (GValue));
+    memset (minimumIncrement,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
         return;
     g_value_init (minimumIncrement, G_TYPE_DOUBLE);
     g_value_set_double (minimumIncrement, accDouble);
 }
 
 gboolean
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -476,21 +476,25 @@ nsXULProgressMeterAccessible::GetState(P
 
 NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& aValue)
 {
   aValue.Truncate();
   nsAccessible::GetValue(aValue);
   if (!aValue.IsEmpty()) {
     return NS_OK;
   }
-  nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
-  NS_ASSERTION(element, "No element for DOM node!");
-  element->GetAttribute(NS_LITERAL_STRING("value"), aValue);
-  if (!aValue.IsEmpty() && aValue.Last() != '%')
-    aValue.AppendLiteral("%");
+  nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
+  if (!content) {
+    return NS_ERROR_FAILURE;
+  }
+  content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, aValue);
+  if (aValue.IsEmpty()) {
+    aValue.AppendLiteral("0");  // Empty value for progress meter = 0%
+  }
+  aValue.AppendLiteral("%");
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
 {
   *aMaximumValue = 1; // 100% = 1;
   return NS_OK;
 }
@@ -504,18 +508,24 @@ NS_IMETHODIMP nsXULProgressMeterAccessib
 NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumIncrement(double *aMinimumIncrement)
 {
   *aMinimumIncrement = 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
 {
+  *aCurrentValue = 0;
   nsAutoString currentValue;
-  GetValue(currentValue);
+  nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
+  if (!content) {
+    return NS_ERROR_FAILURE;
+  }
+  content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, currentValue);
+
   PRInt32 error;
   *aCurrentValue = currentValue.ToFloat(&error) / 100;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULProgressMeterAccessible::SetCurrentValue(double aValue)
 {
   return NS_ERROR_FAILURE; // Progress meters are readonly!