Bug 1132485 - IPC proxy for GetText*Offset, r=tbsaunde
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 12 Feb 2015 22:56:13 +0200
changeset 228901 2076dbcf6bcc3360050849a053cd39ed1d096ee9
parent 228900 6947464c0fb8d0132fdbd291c3e98200dcd61194
child 228902 baf1a5507fd6655ccd84cac4d5d7e83f3a1bdf2e
push id55543
push useropettay@mozilla.com
push dateThu, 12 Feb 2015 23:13:14 +0000
treeherdermozilla-inbound@2076dbcf6bcc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1132485
milestone38.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 1132485 - IPC proxy for GetText*Offset, 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
@@ -165,10 +165,65 @@ DocAccessibleChild::RecvTextSubstring(co
   HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
   if (!acc) {
     return true;
   }
 
   acc->TextSubstring(aStartOffset, aEndOffset, *aText);
   return true;
 }
+
+bool
+DocAccessibleChild::RecvGetTextAfterOffset(const uint64_t& aID,
+                                           const int32_t& aOffset,
+                                           const AccessibleTextBoundary& aBoundaryType,
+                                           nsString* aText,
+                                           int32_t* aStartOffset,
+                                           int32_t* aEndOffset)
+{
+  *aStartOffset = 0;
+  *aEndOffset = 0;
+  HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
+  if (acc) {
+    acc->TextAfterOffset(aOffset, aBoundaryType,
+                         aStartOffset, aEndOffset, *aText);
+  }
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvGetTextAtOffset(const uint64_t& aID,
+                                        const int32_t& aOffset,
+                                        const AccessibleTextBoundary& aBoundaryType,
+                                        nsString* aText,
+                                        int32_t* aStartOffset,
+                                        int32_t* aEndOffset)
+{
+  *aStartOffset = 0;
+  *aEndOffset = 0;
+  HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
+  if (acc) {
+    acc->TextAtOffset(aOffset, aBoundaryType,
+                      aStartOffset, aEndOffset, *aText);
+  }
+  return true;
+}
+
+bool
+DocAccessibleChild::RecvGetTextBeforeOffset(const uint64_t& aID,
+                                            const int32_t& aOffset,
+                                            const AccessibleTextBoundary& aBoundaryType,
+                                            nsString* aText,
+                                            int32_t* aStartOffset,
+                                            int32_t* aEndOffset)
+{
+  *aStartOffset = 0;
+  *aEndOffset = 0;
+  HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
+  if (acc) {
+    acc->TextBeforeOffset(aOffset, aBoundaryType,
+                          aStartOffset, aEndOffset, *aText);
+  }
+  return true;
+}
+
 }
 }
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -57,16 +57,32 @@ public:
   virtual bool RecvDescription(const uint64_t& aID, nsString* aDesc) MOZ_OVERRIDE;
 
   virtual bool RecvAttributes(const uint64_t& aID, nsTArray<Attribute> *aAttributes) MOZ_OVERRIDE;
   virtual bool RecvTextSubstring(const uint64_t& aID,
                                  const int32_t& aStartOffset,
                                  const int32_t& aEndOffset, nsString* aText)
     MOZ_OVERRIDE;
 
+  virtual bool RecvGetTextAfterOffset(const uint64_t& aID,
+                                      const int32_t& aOffset,
+                                      const AccessibleTextBoundary& aBoundaryType,
+                                      nsString* aText, int32_t* aStartOffset,
+                                      int32_t* aEndOffset) MOZ_OVERRIDE;
+  virtual bool RecvGetTextAtOffset(const uint64_t& aID,
+                                   const int32_t& aOffset,
+                                   const AccessibleTextBoundary& aBoundaryType,
+                                   nsString* aText, int32_t* aStartOffset,
+                                   int32_t* aEndOffset) MOZ_OVERRIDE;
+  virtual bool RecvGetTextBeforeOffset(const uint64_t& aID,
+                                       const int32_t& aOffset,
+                                       const AccessibleTextBoundary& aBoundaryType,
+                                       nsString* aText, int32_t* aStartOffset,
+                                       int32_t* aEndOffset) MOZ_OVERRIDE;
+
 private:
   DocAccessible* mDoc;
 };
 
 }
 }
 
 #endif
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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 protocol PContent;
 
+using AccessibleTextBoundary from "nsIAccessibleText.h";
+
 namespace mozilla {
 namespace a11y {
 
 struct AccessibleData
 {
   uint64_t ID;
   uint32_t Role;
   uint32_t ChildrenCount;
@@ -41,19 +43,30 @@ parent:
    * Notify the parent process the document in the child process is firing an
    * event.
    */
   Event(uint64_t aID, uint32_t type);
   ShowEvent(ShowEventData data);
   HideEvent(uint64_t aRootID);
 
 child:
+  // Accessible
   prio(high) sync State(uint64_t aID) returns(uint64_t states);
   prio(high) sync Name(uint64_t aID) returns(nsString name);
   prio(high) sync Value(uint64_t aID) returns(nsString value);
   prio(high) sync Description(uint64_t aID) returns(nsString desc);
   prio(high) sync Attributes(uint64_t aID) returns(Attribute[] attributes);
+
+  // AccessibleText
+
+  // TextSubstring is getText in IDL.
   prio(high) sync TextSubstring(uint64_t aID, int32_t aStartOffset, int32_t
                                 aEndOffset) returns(nsString aText);
+  prio(high) sync GetTextAfterOffset(uint64_t aID, int32_t aOffset, AccessibleTextBoundary aBoundaryType)
+    returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
+  prio(high) sync GetTextAtOffset(uint64_t aID, int32_t aOffset, AccessibleTextBoundary aBoundaryType)
+    returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
+  prio(high) sync GetTextBeforeOffset(uint64_t aID, int32_t aOffset, AccessibleTextBoundary aBoundaryType)
+    returns(nsString aText, int32_t aStartOffset, int32_t aEndOffset);
 };
 
 }
 }
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -82,10 +82,41 @@ ProxyAccessible::Attributes(nsTArray<Att
 }
 
 void
 ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
                                nsString& aText) const
 {
   unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOfset, &aText);
 }
+
+void
+ProxyAccessible::GetTextAfterOffset(int32_t aOffset,
+                                    AccessibleTextBoundary aBoundaryType,
+                                    nsString& aText, int32_t* aStartOffset,
+                                    int32_t* aEndOffset)
+{
+  unused << mDoc->SendGetTextAfterOffset(mID, aOffset, aBoundaryType,
+                                         &aText, aStartOffset, aEndOffset);
+}
+
+void
+ProxyAccessible::GetTextAtOffset(int32_t aOffset,
+                                 AccessibleTextBoundary aBoundaryType,
+                                 nsString& aText, int32_t* aStartOffset,
+                                 int32_t* aEndOffset)
+{
+  unused << mDoc->SendGetTextAtOffset(mID, aOffset, aBoundaryType,
+                                      &aText, aStartOffset, aEndOffset);
+}
+
+void
+ProxyAccessible::GetTextBeforeOffset(int32_t aOffset,
+                                     AccessibleTextBoundary aBoundaryType,
+                                     nsString& aText, int32_t* aStartOffset,
+                                     int32_t* aEndOffset)
+{
+  unused << mDoc->SendGetTextBeforeOffset(mID, aOffset, aBoundaryType,
+                                          &aText, aStartOffset, aEndOffset);
+}
+
 }
 }
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -3,16 +3,17 @@
 /* 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/. */
 
 #ifndef mozilla_a11y_ProxyAccessible_h
 #define mozilla_a11y_ProxyAccessible_h
 
 #include "mozilla/a11y/Role.h"
+#include "nsIAccessibleText.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace a11y {
 
 class Attribute;
 class DocAccessibleParent;
@@ -85,16 +86,28 @@ public:
   void Attributes(nsTArray<Attribute> *aAttrs) const;
 
   /**
    * Get the text between the given offsets.
    */
   void TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
                      nsString& aText) const;
 
+  void GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
+                          nsString& aText, int32_t* aStartOffset,
+                          int32_t* aEndOffset);
+
+  void GetTextAtOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
+                       nsString& aText, int32_t* aStartOffset,
+                       int32_t* aEndOffset);
+
+  void GetTextBeforeOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
+                           nsString& aText, int32_t* aStartOffset,
+                           int32_t* aEndOffset);
+
   /**
    * 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.