bug 1278004 - support QIing proxied accessibles to nsIAccessibleValue r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Fri, 03 Jun 2016 19:21:16 -0400
changeset 300942 9ffa4bbcb60bc2931856fb6b617f6fecdb2d41fa
parent 300941 900bc410537b4a0097874205ceeef27787704035
child 300943 043f1fb11b321403ce5c759a40e50b420bcefeb3
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1278004
milestone50.0a1
bug 1278004 - support QIing proxied accessibles to nsIAccessibleValue r=davidb
accessible/ipc/DocAccessibleParent.cpp
accessible/ipc/ProxyAccessible.h
accessible/xpcom/xpcAccessibleDocument.cpp
accessible/xpcom/xpcAccessibleGeneric.h
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -100,17 +100,18 @@ DocAccessibleParent::AddSubtree(ProxyAcc
 
   if (mAccessibles.Contains(newChild.ID())) {
     NS_ERROR("ID already in use");
     return 0;
   }
 
   auto role = static_cast<a11y::role>(newChild.Role());
   ProxyAccessible* newProxy =
-    new ProxyAccessible(newChild.ID(), aParent, this, role);
+    new ProxyAccessible(newChild.ID(), aParent, this, role,
+                        newChild.Interfaces());
   aParent->AddChildAt(aIdxInParent, newProxy);
   mAccessibles.PutEntry(newChild.ID())->mProxy = newProxy;
   ProxyCreated(newProxy, newChild.Interfaces());
 
   uint32_t accessibles = 1;
   uint32_t kids = newChild.ChildrenCount();
   for (uint32_t i = 0; i < kids; i++) {
     uint32_t consumed = AddSubtree(newProxy, aNewTree, aIdx + accessibles, i);
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -19,24 +19,38 @@
 namespace mozilla {
 namespace a11y {
 
 class Accessible;
 class Attribute;
 class DocAccessibleParent;
 enum class RelationType;
 
+enum Interfaces
+{
+  HYPERTEXT = 1,
+  HYPERLINK = 1 << 1,
+  IMAGE = 1 << 2,
+  VALUE = 1 << 3,
+  TABLE = 1 << 4,
+  TABLECELL = 1 << 5,
+  DOCUMENT = 1 << 6,
+  SELECTION = 1 << 7,
+  ACTION = 1 << 8,
+};
+
 class ProxyAccessible
 {
 public:
 
   ProxyAccessible(uint64_t aID, ProxyAccessible* aParent,
-                  DocAccessibleParent* aDoc, role aRole) :
+                  DocAccessibleParent* aDoc, role aRole, uint32_t aInterfaces) :
      mParent(aParent), mDoc(aDoc), mWrapper(0), mID(aID), mRole(aRole),
-     mOuterDoc(false), mIsDoc(false)
+     mOuterDoc(false), mIsDoc(false),
+     mHasValue(aInterfaces & Interfaces::VALUE)
   {
     MOZ_COUNT_CTOR(ProxyAccessible);
   }
   ~ProxyAccessible()
   {
     MOZ_COUNT_DTOR(ProxyAccessible);
     MOZ_ASSERT(!mWrapper);
   }
@@ -401,41 +415,31 @@ public:
    * Return true if this proxy is a DocAccessibleParent.
    */
   bool IsDoc() const { return mIsDoc; }
   DocAccessibleParent* AsDoc() const { return IsDoc() ? mDoc : nullptr; }
 
 protected:
   explicit ProxyAccessible(DocAccessibleParent* aThisAsDoc) :
     mParent(nullptr), mDoc(aThisAsDoc), mWrapper(0), mID(0),
-    mRole(roles::DOCUMENT), mOuterDoc(false), mIsDoc(true)
+    mRole(roles::DOCUMENT), mOuterDoc(false), mIsDoc(true), mHasValue(false)
   { MOZ_COUNT_CTOR(ProxyAccessible); }
 
 protected:
   ProxyAccessible* mParent;
 
 private:
   nsTArray<ProxyAccessible*> mChildren;
   DocAccessibleParent* mDoc;
   uintptr_t mWrapper;
   uint64_t mID;
-  role mRole : 30;
+  role mRole : 29;
   bool mOuterDoc : 1;
-  const bool mIsDoc: 1;
-};
 
-enum Interfaces
-{
-  HYPERTEXT = 1,
-  HYPERLINK = 1 << 1,
-  IMAGE = 1 << 2,
-  VALUE = 1 << 3,
-  TABLE = 1 << 4,
-  TABLECELL = 1 << 5,
-  DOCUMENT = 1 << 6,
-  SELECTION = 1 << 7,
-  ACTION = 1 << 8,
+public:
+  const bool mIsDoc: 1;
+  const bool mHasValue: 1;
 };
 
 }
 }
 
 #endif
--- a/accessible/xpcom/xpcAccessibleDocument.cpp
+++ b/accessible/xpcom/xpcAccessibleDocument.cpp
@@ -208,17 +208,22 @@ xpcAccessibleDocument::GetXPCAccessible(
   }
 
   xpcAccessibleGeneric* acc = mCache.GetWeak(aProxy);
   if (acc) {
     return acc;
   }
 
   // XXX support exposing optional interfaces.
-  acc = new xpcAccessibleGeneric(aProxy, 0);
+  uint8_t interfaces = 0;
+  if (aProxy->mHasValue) {
+    interfaces |= eValue;
+  }
+
+  acc = new xpcAccessibleGeneric(aProxy, interfaces);
   mCache.Put(aProxy, acc);
 
   return acc;
 }
 
 void
 xpcAccessibleDocument::Shutdown()
 {
--- a/accessible/xpcom/xpcAccessibleGeneric.h
+++ b/accessible/xpcom/xpcAccessibleGeneric.h
@@ -33,29 +33,18 @@ public:
     if (aInternal->IsSelect())
       mSupportedIfaces |= eSelectable;
     if (aInternal->HasNumericValue())
       mSupportedIfaces |= eValue;
     if (aInternal->IsLink())
       mSupportedIfaces |= eHyperLink;
   }
 
-  xpcAccessibleGeneric(ProxyAccessible* aProxy, uint32_t aInterfaces) :
-    mIntl(aProxy), mSupportedIfaces(0)
-  {
-    if (aInterfaces & Interfaces::SELECTION) {
-      mSupportedIfaces |= eSelectable;
-    }
-      if (aInterfaces & Interfaces::VALUE) {
-        mSupportedIfaces |= eValue;
-      }
-      if (aInterfaces & Interfaces::HYPERLINK) {
-        mSupportedIfaces |= eHyperLink;
-      }
-    }
+  xpcAccessibleGeneric(ProxyAccessible* aProxy, uint8_t aInterfaces) :
+    mIntl(aProxy), mSupportedIfaces(aInterfaces) {}
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(xpcAccessibleGeneric, nsIAccessible)
 
   // nsIAccessible
   virtual Accessible* ToInternalAccessible() const final override;
 
   // xpcAccessibleGeneric