Bug 1147551 - IPC Proxy for min/cur/max values, r=davidb
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 27 Mar 2015 00:06:38 +0200
changeset 266372 1d65746a972d833dcbc5bc03ee27c66821ceff47
parent 266371 97e579a59306882610f5acd5368ee722c2b4ace4
child 266373 8833d0060bcaf000083cabea394c8a967168ffce
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1147551
milestone39.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 1147551 - IPC Proxy for min/cur/max values, r=davidb
accessible/atk/nsMaiInterfaceValue.cpp
accessible/ipc/DocAccessibleChild.cpp
accessible/ipc/DocAccessibleChild.h
accessible/ipc/PDocAccessible.ipdl
accessible/ipc/ProxyAccessible.cpp
accessible/ipc/ProxyAccessible.h
--- a/accessible/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/atk/nsMaiInterfaceValue.cpp
@@ -3,98 +3,123 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "InterfaceInitFuncs.h"
 
 #include "AccessibleWrap.h"
 #include "nsMai.h"
-
+#include "ProxyAccessible.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Likely.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 extern "C" {
 
 static void
 getCurrentValueCB(AtkValue *obj, GValue *value)
 {
+  ProxyAccessible* proxy = nullptr;
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
-  if (!accWrap)
-    return;
+  if (!accWrap) {
+    proxy = GetProxy(ATK_OBJECT(obj));
+    if (!proxy) {
+      return;
+    }
+  }
 
   memset (value,  0, sizeof (GValue));
-  double accValue = accWrap->CurValue();
+  double accValue = accWrap ? accWrap->CurValue() : proxy->CurValue();
   if (IsNaN(accValue))
     return;
 
   g_value_init (value, G_TYPE_DOUBLE);
   g_value_set_double (value, accValue);
 }
 
 static void
 getMaximumValueCB(AtkValue *obj, GValue *value)
 {
+  ProxyAccessible* proxy = nullptr;
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
-  if (!accWrap)
-    return;
+  if (!accWrap) {
+    proxy = GetProxy(ATK_OBJECT(obj));
+    if (!proxy) {
+      return;
+    }
+  }
 
   memset(value,  0, sizeof (GValue));
-  double accValue = accWrap->MaxValue();
+  double accValue = accWrap ? accWrap->MaxValue() : proxy->MaxValue();
   if (IsNaN(accValue))
     return;
 
   g_value_init(value, G_TYPE_DOUBLE);
   g_value_set_double(value, accValue);
 }
 
 static void
 getMinimumValueCB(AtkValue *obj, GValue *value)
 {
+  ProxyAccessible* proxy = nullptr;
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
-  if (!accWrap)
-    return;
+  if (!accWrap) {
+    proxy = GetProxy(ATK_OBJECT(obj));
+    if (!proxy) {
+      return;
+    }
+  }
 
   memset(value,  0, sizeof (GValue));
-  double accValue = accWrap->MinValue();
+  double accValue = accWrap ? accWrap->MinValue() : proxy->MinValue();
   if (IsNaN(accValue))
     return;
 
   g_value_init(value, G_TYPE_DOUBLE);
   g_value_set_double(value, accValue);
 }
 
 static void
 getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
 {
+  ProxyAccessible* proxy = nullptr;
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
-  if (!accWrap)
-    return;
+  if (!accWrap) {
+    proxy = GetProxy(ATK_OBJECT(obj));
+    if (!proxy) {
+      return;
+    }
+  }
 
   memset(minimumIncrement,  0, sizeof (GValue));
-  double accValue = accWrap->Step();
+  double accValue = accWrap ? accWrap->Step() : proxy->Step();
   if (IsNaN(accValue))
     accValue = 0; // zero if the minimum increment is undefined
 
   g_value_init(minimumIncrement, G_TYPE_DOUBLE);
   g_value_set_double(minimumIncrement, accValue);
 }
 
 static gboolean
 setCurrentValueCB(AtkValue *obj, const GValue *value)
 {
+  ProxyAccessible* proxy = nullptr;
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
-  if (!accWrap)
-    return FALSE;
+  if (!accWrap) {
+    proxy = GetProxy(ATK_OBJECT(obj));
+    if (!proxy) {
+      return FALSE;
+    }
+  }
 
   double accValue =g_value_get_double(value);
-  return accWrap->SetCurValue(accValue);
+  return accWrap ? accWrap->SetCurValue(accValue) : proxy->SetCurValue(accValue);
 }
 }
 
 void
 valueInterfaceInitCB(AtkValueIface* aIface)
 {
   NS_ASSERTION(aIface, "Invalid aIface");
   if (MOZ_UNLIKELY(!aIface))
--- a/accessible/ipc/DocAccessibleChild.cpp
+++ b/accessible/ipc/DocAccessibleChild.cpp
@@ -1512,10 +1512,76 @@ DocAccessibleChild::RecvKeyboardShortcut
     KeyBinding kb = acc->KeyboardShortcut();
     *aKey = kb.Key();
     *aModifierMask = kb.ModifierMask();
   }
 
   return true;
 }
 
+bool
+DocAccessibleChild::RecvCurValue(const uint64_t& aID,
+                                 double* aValue)
+{
+  *aValue = UnspecifiedNaN<double>();
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    *aValue = acc->CurValue();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvSetCurValue(const uint64_t& aID,
+                                    const double& aValue,
+                                    bool* aRetVal)
+{
+  *aRetVal = false;
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    *aRetVal = acc->SetCurValue(aValue);
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvMinValue(const uint64_t& aID,
+                                 double* aValue)
+{
+  *aValue = UnspecifiedNaN<double>();
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    *aValue = acc->MinValue();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvMaxValue(const uint64_t& aID,
+                                 double* aValue)
+{
+  *aValue = UnspecifiedNaN<double>();
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    *aValue = acc->MaxValue();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvStep(const uint64_t& aID,
+                             double* aStep)
+{
+  *aStep = UnspecifiedNaN<double>();
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    *aStep = acc->Step();
+  }
+
+  return true;
+}
+
 }
 }
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -369,16 +369,32 @@ public:
 
   virtual bool RecvAccessKey(const uint64_t& aID,
                              uint32_t* aKey,
                              uint32_t* aModifierMask) override;
 
   virtual bool RecvKeyboardShortcut(const uint64_t& aID,
                                     uint32_t* aKey,
                                     uint32_t* aModifierMask) override;
+
+  virtual bool RecvCurValue(const uint64_t& aID,
+                            double* aValue);
+
+  virtual bool RecvSetCurValue(const uint64_t& aID,
+                               const double& aValue,
+                               bool* aRetVal);
+
+  virtual bool RecvMinValue(const uint64_t& aID,
+                            double* aValue);
+
+  virtual bool RecvMaxValue(const uint64_t& aID,
+                            double* aValue);
+
+  virtual bool RecvStep(const uint64_t& aID,
+                        double* aStep);
 private:
 
   Accessible* IdToAccessible(const uint64_t& aID) const;
   Accessible* IdToAccessibleLink(const uint64_t& aID) const;
   Accessible* IdToAccessibleSelect(const uint64_t& aID) const;
   HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
   ImageAccessible* IdToImageAccessible(const uint64_t& aID) const;
   TableCellAccessible* IdToTableCellAccessible(const uint64_t& aID) const;
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -193,12 +193,18 @@ child:
   prio(high) sync UnselectAll(uint64_t aID) returns(bool aSuccess);
 
   prio(high) sync DoAction(uint64_t aID, uint8_t aIndex) returns(bool aSuccess);
   prio(high) sync ActionCount(uint64_t aID) returns(uint8_t aCount);
   prio(high) sync ActionDescriptionAt(uint64_t aID, uint8_t aIndex) returns(nsString aDescription);
   prio(high) sync ActionNameAt(uint64_t aID, uint8_t aIndex) returns(nsString aName);
   prio(high) sync AccessKey(uint64_t aID) returns(uint32_t aKey, uint32_t aModifierMask);
   prio(high) sync KeyboardShortcut(uint64_t aID) returns(uint32_t aKey, uint32_t aModifierMask);
+
+  prio(high) sync CurValue(uint64_t aID) returns(double aValue);
+  prio(high) sync SetCurValue(uint64_t aID, double aValue) returns(bool aRetVal);
+  prio(high) sync MinValue(uint64_t aID) returns(double aValue);
+  prio(high) sync MaxValue(uint64_t aID) returns(double aValue);
+  prio(high) sync Step(uint64_t aID) returns(double aStep);
 };
 
 }
 }
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -840,10 +840,50 @@ KeyBinding
 ProxyAccessible::KeyboardShortcut()
 {
   uint32_t key = 0;
   uint32_t modifierMask = 0;
   unused << mDoc->SendKeyboardShortcut(mID, &key, &modifierMask);
   return KeyBinding(key, modifierMask);
 }
 
+double
+ProxyAccessible::CurValue()
+{
+  double val = UnspecifiedNaN<double>();
+  unused << mDoc->SendCurValue(mID, &val);
+  return val;
+}
+
+bool
+ProxyAccessible::SetCurValue(double aValue)
+{
+  bool success = false;
+  unused << mDoc->SendSetCurValue(mID, aValue, &success);
+  return success;
+}
+
+double
+ProxyAccessible::MinValue()
+{
+  double val = UnspecifiedNaN<double>();
+  unused << mDoc->SendMinValue(mID, &val);
+  return val;
+}
+
+double
+ProxyAccessible::MaxValue()
+{
+  double val = UnspecifiedNaN<double>();
+  unused << mDoc->SendMaxValue(mID, &val);
+  return val;
+}
+
+double
+ProxyAccessible::Step()
+{
+  double step = UnspecifiedNaN<double>();
+  unused << mDoc->SendStep(mID, &step);
+  return step;
+}
+
 }
 }
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -259,16 +259,22 @@ public:
 
   bool DoAction(uint8_t aIndex);
   uint8_t ActionCount();
   void ActionDescriptionAt(uint8_t aIndex, nsString& aDescription);
   void ActionNameAt(uint8_t aIndex, nsString& aName);
   KeyBinding AccessKey();
   KeyBinding KeyboardShortcut();
 
+  double CurValue();
+  bool SetCurValue(double aValue);
+  double MinValue();
+  double MaxValue();
+  double Step();
+
   /**
    * Allow the platform to store a pointers worth of data on us.
    */
   uintptr_t GetWrapper() const { return mWrapper; }
   void SetWrapper(uintptr_t aWrapper) { mWrapper = aWrapper; }
 
   /*
    * Return the ID of the accessible being proxied.