Bug 1140534 - IPC Proxy for offsetAtPoint, r=tbsaunde
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sun, 08 Mar 2015 14:05:55 +0200
changeset 262757 3d6cd86c1791e3eaed69d7b2b290b42080f99c3c
parent 262756 d5f0d1845eccc192bb1731a9402933a72eb2bdef
child 262761 d5beb5eb843344e7b9952d56cac0ab9ed5e2577e
child 262774 c3f8fae88426c58614e9d5aa1182f773ea897115
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
bugs1140534
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 1140534 - IPC Proxy for offsetAtPoint, r=tbsaunde
accessible/atk/nsMaiInterfaceText.cpp
accessible/ipc/DocAccessibleChild.cpp
accessible/ipc/DocAccessibleChild.h
accessible/ipc/PDocAccessible.ipdl
accessible/ipc/ProxyAccessible.cpp
accessible/ipc/ProxyAccessible.h
--- a/accessible/atk/nsMaiInterfaceText.cpp
+++ b/accessible/atk/nsMaiInterfaceText.cpp
@@ -424,28 +424,38 @@ getCharacterCountCB(AtkText *aText)
 }
 
 static gint
 getOffsetAtPointCB(AtkText *aText,
                    gint aX, gint aY,
                    AtkCoordType aCoords)
 {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
-  if (!accWrap)
-    return -1;
+  if (accWrap) {
+    HyperTextAccessible* text = accWrap->AsHyperText();
+    if (!text || !text->IsTextRole()) {
+      return -1;
+    }
 
-  HyperTextAccessible* text = accWrap->AsHyperText();
-  if (!text || !text->IsTextRole())
-    return -1;
+    return static_cast<gint>(
+      text->OffsetAtPoint(aX, aY,
+                          (aCoords == ATK_XY_SCREEN ?
+                           nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
+                           nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
+  }
 
-  return static_cast<gint>(
-    text->OffsetAtPoint(aX, aY,
-                        (aCoords == ATK_XY_SCREEN ?
-                         nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
-                         nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
+  if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
+    return static_cast<gint>(
+      proxy->OffsetAtPoint(aX, aY,
+                           (aCoords == ATK_XY_SCREEN ?
+                            nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
+                            nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
+  }
+
+  return -1;
 }
 
 static gint
 getTextSelectionCountCB(AtkText *aText)
 {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
   if (accWrap) {
     HyperTextAccessible* text = accWrap->AsHyperText();
--- a/accessible/ipc/DocAccessibleChild.cpp
+++ b/accessible/ipc/DocAccessibleChild.cpp
@@ -387,10 +387,25 @@ DocAccessibleChild::RecvCharBounds(const
   HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
   if (acc && acc->IsTextRole()) {
     *aRetVal = acc->CharBounds(aOffset, aCoordType);
   }
 
   return true;
 }
 
+bool
+DocAccessibleChild::RecvOffsetAtPoint(const uint64_t& aID,
+                                      const int32_t& aX,
+                                      const int32_t& aY,
+                                      const uint32_t& aCoordType,
+                                      int32_t* aRetVal)
+{
+  *aRetVal = -1;
+  HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
+  if (acc && acc->IsTextRole()) {
+    *aRetVal = acc->OffsetAtPoint(aX, aY, aCoordType);
+  }
+  return true;
+}
+
 }
 }
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -116,16 +116,22 @@ public:
                               const int32_t& aEndOffset,
                               const uint32_t& aCoordType,
                               nsIntRect* aRetVal) MOZ_OVERRIDE;
 
   virtual bool RecvCharBounds(const uint64_t& aID,
                               const int32_t& aOffset,
                               const uint32_t& aCoordType,
                               nsIntRect* aRetVal) MOZ_OVERRIDE;
+
+  virtual bool RecvOffsetAtPoint(const uint64_t& aID,
+                                 const int32_t& aX,
+                                 const int32_t& aY,
+                                 const uint32_t& aCoordType,
+                                 int32_t* aRetVal) MOZ_OVERRIDE;
 private:
   bool PersistentPropertiesToArray(nsIPersistentProperties* aProps,
                                    nsTArray<Attribute>* aAttributes);
 
   DocAccessible* mDoc;
 };
 
 }
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -86,12 +86,15 @@ child:
     returns(Attribute[] aAttributes, int32_t aStartOffset, int32_t aEndOffset);
   prio(high) sync DefaultTextAttributes(uint64_t aID) returns(Attribute[] aAttributes);
 
   prio(high) sync TextBounds(uint64_t aID, int32_t aStartOffset, int32_t aEndOffset,
                              uint32_t aCoordType)
     returns(nsIntRect aRetVal);
   prio(high) sync CharBounds(uint64_t aID, int32_t aOffset, uint32_t aCoordType)
     returns(nsIntRect aRetVal);
+
+  prio(high) sync OffsetAtPoint(uint64_t aID, int32_t aX, int32_t aY, uint32_t aCoordType)
+    returns(int32_t aRetVal);
 };
 
 }
 }
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -257,10 +257,18 @@ nsIntRect
 ProxyAccessible::CharBounds(int32_t aOffset, uint32_t aCoordType)
 {
   nsIntRect rect;
   unused <<
     mDoc->SendCharBounds(mID, aOffset, aCoordType, &rect);
   return rect;
 }
 
+int32_t
+ProxyAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
+{
+  int32_t retVal = -1;
+  unused << mDoc->SendOffsetAtPoint(mID, aX, aY, aCoordType, &retVal);
+  return retVal;
+}
+
 }
 }
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -133,16 +133,18 @@ public:
                       int32_t* aEndOffset);
   void DefaultTextAttributes(nsTArray<Attribute>* aAttrs);
 
   nsIntRect TextBounds(int32_t aStartOffset, int32_t aEndOffset,
                        uint32_t aCoordType);
 
   nsIntRect CharBounds(int32_t aOffset, uint32_t aCoordType);
 
+  int32_t OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType);
+
   /**
    * 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.