Bug 1499209 - Send abbreviated source bundles with accessibility events. r=Jamie
☠☠ backed out by 889b103b4e31 ☠ ☠
authorEitan Isaacson <eitan@monotonous.org>
Tue, 16 Oct 2018 15:48:31 +0000
changeset 490381 7d3a598c12859f4bed3fc560bad3ae37af5f272a
parent 490380 89663382dd1e73388c69f7764b44baa9e20a33c2
child 490382 38c1fc84fcaf42dbbdf53f286a0878cbadb0dbaf
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersJamie
bugs1499209
milestone64.0a1
Bug 1499209 - Send abbreviated source bundles with accessibility events. r=Jamie Depends on D8778 Differential Revision: https://phabricator.services.mozilla.com/D8779
accessible/android/AccessibleWrap.cpp
accessible/android/AccessibleWrap.h
accessible/android/SessionAccessibility.cpp
--- a/accessible/android/AccessibleWrap.cpp
+++ b/accessible/android/AccessibleWrap.cpp
@@ -368,59 +368,69 @@ AccessibleWrap::WrapperRangeInfo(double*
     *aStep = Step();
     return true;
   }
 
   return false;
 }
 
 mozilla::java::GeckoBundle::LocalRef
-AccessibleWrap::ToBundle()
+AccessibleWrap::ToBundle(bool aMinimal)
 {
   if (IsDefunct()) {
     return nullptr;
   }
 
   GECKOBUNDLE_START(nodeInfo);
   GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
 
   AccessibleWrap* parent = WrapperParent();
   GECKOBUNDLE_PUT(nodeInfo, "parentId",
     java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
 
   role role = WrapperRole();
   uint64_t state = State();
   uint64_t flags = GetFlags(role, state);
   GECKOBUNDLE_PUT(nodeInfo, "flags", java::sdk::Integer::ValueOf(flags));
-
-  nsAutoString geckoRole;
-  nsAutoString roleDescription;
-  if (VirtualViewID() != kNoID) {
-    GetRoleDescription(role, geckoRole, roleDescription);
-  }
-
-  GECKOBUNDLE_PUT(
-    nodeInfo, "roleDescription", jni::StringParam(roleDescription));
-  GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
   GECKOBUNDLE_PUT(nodeInfo, "className", java::sdk::Integer::ValueOf(AndroidClass()));
 
   nsAutoString text;
   if (state & states::EDITABLE) {
     Value(text);
   }
 
   if (!text.IsEmpty()) {
     nsAutoString hint;
     Name(hint);
     GECKOBUNDLE_PUT(nodeInfo, "hint", jni::StringParam(hint));
   } else {
     Name(text);
   }
   GECKOBUNDLE_PUT(nodeInfo, "text", jni::StringParam(text));
 
+  if (aMinimal) {
+    GECKOBUNDLE_FINISH(nodeInfo);
+    return nodeInfo;
+  }
+
+  nsAutoString geckoRole;
+  nsAutoString roleDescription;
+  int32_t androidClass = java::SessionAccessibility::CLASSNAME_VIEW;
+  if (VirtualViewID() != kNoID) {
+    GetRoleDescription(role, geckoRole, roleDescription);
+  }
+
+  GECKOBUNDLE_PUT(
+    nodeInfo, "roleDescription", jni::StringParam(roleDescription));
+  GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
+
+  GECKOBUNDLE_PUT(
+    nodeInfo, "roleDescription", jni::StringParam(roleDescription));
+  GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
+
   nsAutoString viewIdResourceName;
   WrapperDOMNodeID(viewIdResourceName);
   if (!viewIdResourceName.IsEmpty()) {
     GECKOBUNDLE_PUT(
       nodeInfo, "viewIdResourceName", jni::StringParam(viewIdResourceName));
   }
 
   nsIntRect bounds = Bounds();
--- a/accessible/android/AccessibleWrap.h
+++ b/accessible/android/AccessibleWrap.h
@@ -26,17 +26,17 @@ public:
   int32_t VirtualViewID() const { return mID; }
 
   virtual void SetTextContents(const nsAString& aText);
 
   virtual void GetTextContents(nsAString& aText);
 
   virtual bool GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset);
 
-  mozilla::java::GeckoBundle::LocalRef ToBundle();
+  mozilla::java::GeckoBundle::LocalRef ToBundle(bool aMinimal = false);
 
   int32_t AndroidClass()
   {
     return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
                         : GetAndroidClass(WrapperRole());
   }
 
   static const int32_t kNoID = -1;
--- a/accessible/android/SessionAccessibility.cpp
+++ b/accessible/android/SessionAccessibility.cpp
@@ -146,40 +146,40 @@ SessionAccessibility::GetInstanceFor(Acc
   return nullptr;
 }
 
 void
 SessionAccessibility::SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible)
 {
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
   aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
 }
 
 void
 SessionAccessibility::SendHoverEnterEvent(AccessibleWrap* aAccessible)
 {
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_HOVER_ENTER,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
 {
   // Suppress focus events from about:blank pages.
   // This is important for tests.
   if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
     return;
   }
 
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_FOCUSED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
                                          int32_t aScrollX,
                                          int32_t aScrollY,
                                          int32_t aMaxScrollX,
                                          int32_t aMaxScrollY)
@@ -194,42 +194,42 @@ SessionAccessibility::SendScrollingEvent
   GECKOBUNDLE_START(eventInfo);
   GECKOBUNDLE_PUT(eventInfo, "scrollX", java::sdk::Integer::ValueOf(aScrollX));
   GECKOBUNDLE_PUT(eventInfo, "scrollY", java::sdk::Integer::ValueOf(aScrollY));
   GECKOBUNDLE_PUT(eventInfo, "maxScrollX", java::sdk::Integer::ValueOf(aMaxScrollX));
   GECKOBUNDLE_PUT(eventInfo, "maxScrollY", java::sdk::Integer::ValueOf(aMaxScrollY));
   GECKOBUNDLE_FINISH(eventInfo);
 
   mSessionAccessibility->SendEvent(
-    java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId,
-    eventInfo, aAccessible->ToBundle());
+    java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId, eventInfo,
+    aAccessible->ToBundle(true));
 
   SendWindowContentChangedEvent(aAccessible);
 }
 
 void
 SessionAccessibility::SendWindowContentChangedEvent(AccessibleWrap* aAccessible)
 {
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_WINDOW_CONTENT_CHANGED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
 {
   // Suppress window state changed events from about:blank pages.
   // This is important for tests.
   if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
     return;
   }
 
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_WINDOW_STATE_CHANGED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
                                                     int32_t aCaretOffset)
 {
   int32_t fromIndex = aCaretOffset;
   int32_t startSel = -1;
@@ -240,17 +240,17 @@ SessionAccessibility::SendTextSelectionC
 
   GECKOBUNDLE_START(eventInfo);
   GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(fromIndex));
   GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aCaretOffset));
   GECKOBUNDLE_FINISH(eventInfo);
 
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_SELECTION_CHANGED,
-    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
                                            const nsString& aStr,
                                            int32_t aStart,
                                            uint32_t aLen,
                                            bool aIsInsert,
@@ -274,17 +274,17 @@ SessionAccessibility::SendTextChangedEve
   GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
   GECKOBUNDLE_PUT(eventInfo, "beforeText", jni::StringParam(beforeText));
   GECKOBUNDLE_PUT(eventInfo, "addedCount", java::sdk::Integer::ValueOf(aIsInsert ? aLen : 0));
   GECKOBUNDLE_PUT(eventInfo, "removedCount", java::sdk::Integer::ValueOf(aIsInsert ? 0 : aLen));
   GECKOBUNDLE_FINISH(eventInfo);
 
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_CHANGED,
-    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
                                              int32_t aStartOffset,
                                              int32_t aEndOffset)
 {
   nsAutoString text;
@@ -294,26 +294,26 @@ SessionAccessibility::SendTextTraversedE
   GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
   GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(aStartOffset));
   GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aEndOffset));
   GECKOBUNDLE_FINISH(eventInfo);
 
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::
       TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
-    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), eventInfo, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible)
 {
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_CLICKED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }
 
 void
 SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible)
 {
   mSessionAccessibility->SendEvent(
     java::sdk::AccessibilityEvent::TYPE_VIEW_SELECTED,
-    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle());
+    aAccessible->VirtualViewID(), nullptr, aAccessible->ToBundle(true));
 }