bug 1164976 - fire useful state change and caret move events for proxies r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Wed, 13 May 2015 14:21:23 -0400
changeset 274904 e5649b9714d1c08effc7dd8e10598c8fe931f0ea
parent 274903 661f089f73b53b4c5080188aa36a4d97469149c3
child 274905 c96edd3211223fa3c46ae15c0e2fa3e4aa523baa
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1164976
milestone41.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 1164976 - fire useful state change and caret move events for proxies r=davidb
accessible/atk/AccessibleWrap.cpp
accessible/base/EventQueue.cpp
accessible/base/Platform.h
accessible/ipc/DocAccessibleParent.cpp
accessible/ipc/DocAccessibleParent.h
accessible/ipc/PDocAccessible.ipdl
accessible/mac/Platform.mm
accessible/other/Platform.cpp
accessible/windows/msaa/Platform.cpp
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -1381,16 +1381,31 @@ a11y::ProxyEvent(ProxyAccessible* aTarge
   case nsIAccessibleEvent::EVENT_MENUPOPUP_END:
     atk_object_notify_state_change(wrapper, ATK_STATE_VISIBLE, false);
     atk_object_notify_state_change(wrapper, ATK_STATE_SHOWING, false);
     break;
   }
 }
 
 void
+a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget, uint64_t aState,
+                            bool aEnabled)
+{
+  MaiAtkObject* atkObj = MAI_ATK_OBJECT(GetWrapperFor(aTarget));
+  atkObj->FireStateChangeEvent(aState, aEnabled);
+}
+
+void
+a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
+{
+  AtkObject* wrapper = GetWrapperFor(aTarget);
+  g_signal_emit_by_name(wrapper, "text_caret_moved", aOffset);
+}
+
+void
 MaiAtkObject::FireStateChangeEvent(uint64_t aState, bool aEnabled)
 {
     int32_t stateIndex = AtkStateMap::GetStateIndexFor(aState);
     if (stateIndex >= 0) {
         NS_ASSERTION(gAtkStateMap[stateIndex].stateMapEntryType != kNoSuchState,
                      "No such state");
 
         if (gAtkStateMap[stateIndex].atkState != kNone) {
--- a/accessible/base/EventQueue.cpp
+++ b/accessible/base/EventQueue.cpp
@@ -497,16 +497,27 @@ EventQueue::SendIPCEvent(AccEvent* aEven
       break;
 
     case nsIAccessibleEvent::EVENT_REORDER:
       // reorder events on the application acc aren't necessary to tell the parent
       // about new top level documents.
       if (!aEvent->GetAccessible()->IsApplication())
         ipcDoc->SendEvent(id, aEvent->GetEventType());
       break;
+    case nsIAccessibleEvent::EVENT_STATE_CHANGE: {
+      AccStateChangeEvent* event = downcast_accEvent(aEvent);
+      ipcDoc->SendStateChangeEvent(id, event->GetState(),
+                                   event->IsStateEnabled());
+      break;
+    }
+    case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: {
+                                                       AccCaretMoveEvent* event = downcast_accEvent(aEvent);
+                                                       ipcDoc->SendEvent(id, event->GetCaretOffset());
+                                                       break;
+                                                     }
     default:
       ipcDoc->SendEvent(id, aEvent->GetEventType());
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // EventQueue: event queue
 
--- a/accessible/base/Platform.h
+++ b/accessible/base/Platform.h
@@ -62,11 +62,14 @@ void ProxyCreated(ProxyAccessible* aProx
  * disposed of and other action taken.
  */
 void ProxyDestroyed(ProxyAccessible*);
 
 /**
  * Callied when an event is fired on a proxied accessible.
  */
 void ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType);
+void ProxyStateChangeEvent(ProxyAccessible* aTarget, uint64_t aState,
+                           bool aEnabled);
+void ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset);
 } // namespace a11y
 } // namespace mozilla
 
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -122,16 +122,40 @@ DocAccessibleParent::RecvEvent(const uin
     return true;
   }
 
   ProxyEvent(proxy, aEventType);
   return true;
 }
 
 bool
+DocAccessibleParent::RecvStateChangeEvent(const uint64_t& aID,
+                                          const uint64_t& aState,
+                                          const bool& aEnabled)
+{
+  ProxyAccessible* target = GetAccessible(aID);
+  if (!target)
+    return false;
+
+  ProxyStateChangeEvent(target, aState, aEnabled);
+  return true;
+}
+
+bool
+DocAccessibleParent::RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset)
+{
+  ProxyAccessible* proxy = GetAccessible(aID);
+  if (!proxy)
+    return false;
+
+  ProxyCaretMoveEvent(proxy, aOffset);
+  return true;
+}
+
+bool
 DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID)
 {
   auto childDoc = static_cast<DocAccessibleParent*>(aChildDoc);
   DebugOnly<bool> result = AddChildDoc(childDoc, aID, false);
   MOZ_ASSERT(result);
   return true;
 }
 
--- a/accessible/ipc/DocAccessibleParent.h
+++ b/accessible/ipc/DocAccessibleParent.h
@@ -39,16 +39,22 @@ public:
    * Called when a message from a document in a child process notifies the main
    * process it is firing an event.
    */
   virtual bool RecvEvent(const uint64_t& aID, const uint32_t& aType)
     override;
 
   virtual bool RecvShowEvent(const ShowEventData& aData) override;
   virtual bool RecvHideEvent(const uint64_t& aRootID) override;
+  virtual bool RecvStateChangeEvent(const uint64_t& aID,
+                                    const uint64_t& aState,
+                                    const bool& aEnabled) override final;
+
+  virtual bool RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset)
+    override final;
 
   virtual bool RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID) override;
   void Unbind()
   {
     mParent = nullptr;
     mParentDoc->mChildDocs.RemoveElement(this);
     mParentDoc = nullptr;
   }
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -51,16 +51,18 @@ 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);
+  StateChangeEvent(uint64_t aID, uint64_t aState, bool aEnabled);
+  CaretMoveEvent(uint64_t aID, int32_t aOffset);
 
   /*
    * Tell the parent document to bind the existing document as a new child
    * document.
    */
   BindChildDoc(PDocAccessible aChildDoc, uint64_t aID);
 
 child:
--- a/accessible/mac/Platform.mm
+++ b/accessible/mac/Platform.mm
@@ -42,16 +42,26 @@ void
 ProxyDestroyed(ProxyAccessible*)
 {
 }
 
 void
 ProxyEvent(ProxyAccessible*, uint32_t)
 {
 }
+
+void
+ProxyStateChangeEvent(ProxyAccessible*, uint64_t, bool)
+{
+}
+
+void
+ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
+{
+}
 }
 }
 
 @interface GeckoNSApplication(a11y)
 -(void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;
 @end
 
 @implementation GeckoNSApplication(a11y)
--- a/accessible/other/Platform.cpp
+++ b/accessible/other/Platform.cpp
@@ -28,8 +28,18 @@ void
 a11y::ProxyDestroyed(ProxyAccessible*)
 {
 }
 
 void
 a11y::ProxyEvent(ProxyAccessible*, uint32_t)
 {
 }
+
+void
+a11y::ProxyStateChangeEvent(ProxyAccessible*, uint64_t, bool)
+{
+}
+
+void
+a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
+{
+}
--- a/accessible/windows/msaa/Platform.cpp
+++ b/accessible/windows/msaa/Platform.cpp
@@ -53,8 +53,18 @@ a11y::ProxyDestroyed(ProxyAccessible* aP
   aProxy->SetWrapper(0);
   wrapper->Release();
 }
 
 void
 a11y::ProxyEvent(ProxyAccessible*, uint32_t)
 {
 }
+
+void
+a11y::ProxyStateChangeEvent(ProxyAccessible*, uint64_t, bool)
+{
+}
+
+void
+a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
+{
+}