Bug 1146665 - IPC Proxy for TableCell, r=tbsaunde
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 25 Mar 2015 16:14:28 +0200
changeset 266126 3702e7480713118515b0309ed65e0613332ce28c
parent 266125 2862e6b752de401637425e1ab32c44e9000a7630
child 266127 d92c07d1e6df5d28ef1668a2612ea2fc4d8d37f7
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)
reviewerstbsaunde
bugs1146665
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 1146665 - IPC Proxy for TableCell, r=tbsaunde
accessible/ipc/DocAccessibleChild.cpp
accessible/ipc/DocAccessibleChild.h
accessible/ipc/PDocAccessible.ipdl
accessible/ipc/ProxyAccessible.cpp
accessible/ipc/ProxyAccessible.h
--- a/accessible/ipc/DocAccessibleChild.cpp
+++ b/accessible/ipc/DocAccessibleChild.cpp
@@ -6,16 +6,18 @@
 
 #include "DocAccessibleChild.h"
 
 #include "Accessible-inl.h"
 #include "ProxyAccessible.h"
 #include "Relation.h"
 #include "HyperTextAccessible-inl.h"
 #include "ImageAccessible.h"
+#include "TableAccessible.h"
+#include "TableCellAccessible.h"
 #include "nsIPersistentProperties2.h"
 #include "nsISimpleEnumerator.h"
 
 namespace mozilla {
 namespace a11y {
 
 static uint32_t
 InterfacesFor(Accessible* aAcc)
@@ -68,16 +70,23 @@ DocAccessibleChild::IdToHyperTextAccessi
 
 ImageAccessible*
 DocAccessibleChild::IdToImageAccessible(const uint64_t& aID) const
 {
   Accessible* acc = IdToAccessible(aID);
   return (acc && acc->IsImage()) ? acc->AsImage() : nullptr;
 }
 
+TableCellAccessible*
+DocAccessibleChild::IdToTableCellAccessible(const uint64_t& aID) const
+{
+  Accessible* acc = IdToAccessible(aID);
+  return (acc && acc->IsTableCell()) ? acc->AsTableCell() : nullptr;
+}
+
 void
 DocAccessibleChild::ShowEvent(AccShowEvent* aShowEvent)
 {
   Accessible* parent = aShowEvent->Parent();
   uint64_t parentID = parent->IsDoc() ? 0 : reinterpret_cast<uint64_t>(parent->UniqueID());
   uint32_t idxInParent = aShowEvent->GetAccessible()->IndexInParent();
   nsTArray<AccessibleData> shownTree;
   ShowEventData data(parentID, idxInParent, shownTree);
@@ -777,10 +786,126 @@ DocAccessibleChild::RecvLinkIndexAtOffse
                                           const uint32_t& aOffset,
                                           int32_t* aIndex)
 {
   HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
   *aIndex = acc ? acc->LinkIndexAtOffset(aOffset) : -1;
   return true;
 }
 
+bool
+DocAccessibleChild::RecvTableOfACell(const uint64_t& aID,
+                                     uint64_t* aTableID,
+                                     bool* aOk)
+{
+  *aTableID = 0;
+  *aOk = false;
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    TableAccessible* table = acc->Table();
+    if (table) {
+      *aTableID = reinterpret_cast<uint64_t>(table->AsAccessible()->UniqueID());
+      *aOk = true;
+    }
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvColIdx(const uint64_t& aID,
+                               uint32_t* aIndex)
+{
+  *aIndex = 0;
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    *aIndex = acc->ColIdx();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvRowIdx(const uint64_t& aID,
+                               uint32_t* aIndex)
+{
+  *aIndex = 0;
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    *aIndex = acc->RowIdx();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvColExtent(const uint64_t& aID,
+                                  uint32_t* aExtent)
+{
+  *aExtent = 0;
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    *aExtent = acc->ColExtent();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvRowExtent(const uint64_t& aID,
+                                  uint32_t* aExtent)
+{
+  *aExtent = 0;
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    *aExtent = acc->RowExtent();
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvColHeaderCells(const uint64_t& aID,
+                                       nsTArray<uint64_t>* aCells)
+{
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    nsAutoTArray<Accessible*, 10> headerCells;
+    acc->ColHeaderCells(&headerCells);
+    aCells->SetCapacity(headerCells.Length());
+    for (uint32_t i = 0; i < headerCells.Length(); ++i) {
+      aCells->AppendElement(
+        reinterpret_cast<uint64_t>(headerCells[i]->UniqueID()));
+    }
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvRowHeaderCells(const uint64_t& aID,
+                                       nsTArray<uint64_t>* aCells)
+{
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  if (acc) {
+    nsAutoTArray<Accessible*, 10> headerCells;
+    acc->RowHeaderCells(&headerCells);
+    aCells->SetCapacity(headerCells.Length());
+    for (uint32_t i = 0; i < headerCells.Length(); ++i) {
+      aCells->AppendElement(
+        reinterpret_cast<uint64_t>(headerCells[i]->UniqueID()));
+    }
+  }
+
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvIsCellSelected(const uint64_t& aID,
+                                       bool* aSelected)
+{
+  TableCellAccessible* acc = IdToTableCellAccessible(aID);
+  *aSelected = acc && acc->Selected();
+  return true;
+}
+
 }
 }
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -219,22 +219,44 @@ public:
   virtual bool RecvLinkIndexOf(const uint64_t& aID,
                                const uint64_t& aLinkID,
                                int32_t* aIndex) override;
 
   virtual bool RecvLinkIndexAtOffset(const uint64_t& aID,
                                      const uint32_t& aOffset,
                                      int32_t* aIndex) override;
 
+  virtual bool RecvTableOfACell(const uint64_t& aID,
+                                uint64_t* aTableID,
+                                bool* aOk) override;
+
+  virtual bool RecvColIdx(const uint64_t& aID, uint32_t* aIndex) override;
+
+  virtual bool RecvRowIdx(const uint64_t& aID, uint32_t* aIndex) override;
+
+  virtual bool RecvColExtent(const uint64_t& aID, uint32_t* aExtent) override;
+
+  virtual bool RecvRowExtent(const uint64_t& aID, uint32_t* aExtent) override;
+
+  virtual bool RecvColHeaderCells(const uint64_t& aID,
+                                  nsTArray<uint64_t>* aCells) override;
+
+  virtual bool RecvRowHeaderCells(const uint64_t& aID,
+                                  nsTArray<uint64_t>* aCells) override;
+
+  virtual bool RecvIsCellSelected(const uint64_t& aID,
+                                  bool* aSelected) override;
+
 private:
 
   Accessible* IdToAccessible(const uint64_t& aID) const;
   Accessible* IdToAccessibleLink(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;
 
   bool PersistentPropertiesToArray(nsIPersistentProperties* aProps,
                                    nsTArray<Attribute>* aAttributes);
 
   DocAccessible* mDoc;
 };
 
 }
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -139,13 +139,21 @@ child:
   prio(high) sync AnchorCount(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
   prio(high) sync AnchorURIAt(uint64_t aID, uint32_t aIndex) returns(nsCString aURI, bool aOk);
   prio(high) sync AnchorAt(uint64_t aID, uint32_t aIndex) returns(uint64_t aIDOfAnchor, bool aOk);
 
   prio(high) sync LinkCount(uint64_t aID) returns(uint32_t aCount);
   prio(high) sync LinkAt(uint64_t aID, uint32_t aIndex) returns(uint64_t aIDOfLink, bool aOk);
   prio(high) sync LinkIndexOf(uint64_t aID, uint64_t aLinkID) returns(int32_t aIndex);
   prio(high) sync LinkIndexAtOffset(uint64_t aID, uint32_t aOffset) returns(int32_t aIndex);
-  
+
+  prio(high) sync TableOfACell(uint64_t aID) returns(uint64_t aTableID, bool aOk);
+  prio(high) sync ColIdx(uint64_t aID) returns(uint32_t aIndex);
+  prio(high) sync RowIdx(uint64_t aID) returns(uint32_t aIndex);
+  prio(high) sync ColExtent(uint64_t aID) returns(uint32_t aExtent);
+  prio(high) sync RowExtent(uint64_t aID) returns(uint32_t aExtent);
+  prio(high) sync ColHeaderCells(uint64_t aID) returns(uint64_t[] aCells);
+  prio(high) sync RowHeaderCells(uint64_t aID) returns(uint64_t[] aCells);
+  prio(high) sync IsCellSelected(uint64_t aID) returns(bool aSelected);
 };
 
 }
 }
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -457,10 +457,71 @@ ProxyAccessible::LinkIndexOf(ProxyAccess
 int32_t
 ProxyAccessible::LinkIndexAtOffset(uint32_t aOffset)
 {
   int32_t retVal = -1;
   unused << mDoc->SendLinkIndexAtOffset(mID, aOffset, &retVal);
   return retVal;
 }
 
+ProxyAccessible*
+ProxyAccessible::TableOfACell()
+{
+  uint64_t tableID = 0;
+  bool ok = false;
+  unused << mDoc->SendTableOfACell(mID, &tableID, &ok);
+  return ok ? mDoc->GetAccessible(tableID) : nullptr;
+}
+
+uint32_t
+ProxyAccessible::ColIdx()
+{
+  uint32_t index = 0;
+  unused << mDoc->SendColIdx(mID, &index);
+  return index;
+}
+
+uint32_t
+ProxyAccessible::RowIdx()
+{
+  uint32_t index = 0;
+  unused << mDoc->SendRowIdx(mID, &index);
+  return index;
+}
+
+uint32_t
+ProxyAccessible::ColExtent()
+{
+  uint32_t extent = 0;
+  unused << mDoc->SendColExtent(mID, &extent);
+  return extent;
+}
+
+uint32_t
+ProxyAccessible::RowExtent()
+{
+  uint32_t extent = 0;
+  unused << mDoc->SendRowExtent(mID, &extent);
+  return extent;
+}
+
+void
+ProxyAccessible::ColHeaderCells(nsTArray<uint64_t>* aCells)
+{
+  unused << mDoc->SendColHeaderCells(mID, aCells);
+}
+
+void
+ProxyAccessible::RowHeaderCells(nsTArray<uint64_t>* aCells)
+{
+  unused << mDoc->SendRowHeaderCells(mID, aCells);
+}
+
+bool
+ProxyAccessible::IsCellSelected()
+{
+  bool selected = false;
+  unused << mDoc->SendIsCellSelected(mID, &selected);
+  return selected;
+}
+
 }
 }
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -196,16 +196,32 @@ public:
   uint32_t LinkCount();
 
   ProxyAccessible* LinkAt(const uint32_t& aIndex);
 
   int32_t LinkIndexOf(ProxyAccessible* aLink);
 
   int32_t LinkIndexAtOffset(uint32_t aOffset);
 
+  ProxyAccessible* TableOfACell();
+
+  uint32_t ColIdx();
+
+  uint32_t RowIdx();
+
+  uint32_t ColExtent();
+
+  uint32_t RowExtent();
+
+  void ColHeaderCells(nsTArray<uint64_t>* aCells);
+
+  void RowHeaderCells(nsTArray<uint64_t>* aCells);
+
+  bool IsCellSelected();
+
   /**
    * 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.