Bug 1499209 - Send abbreviated source bundles with accessibility events. r=Jamie
☠☠ backed out by e1daa7729f92 ☠ ☠
authorEitan Isaacson <eitan@monotonous.org>
Fri, 19 Oct 2018 23:26:10 +0000
changeset 442231 c8d88737a20ef4975399bd8825f5519ac378d6c9
parent 442230 6a22bf58801fe225e7477e089817d84df2e736ec
child 442232 b1e0d0e6c3997c22ba94ad2582de72eb2f07166f
push id71405
push usereisaacson@mozilla.com
push dateFri, 19 Oct 2018 23:28:48 +0000
treeherderautoland@c8d88737a20e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1499209
milestone64.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 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,68 @@ AccessibleWrap::WrapperRangeInfo(double*
     *aStep = Step();
     return true;
   }
 
   return false;
 }
 
 mozilla::java::GeckoBundle::LocalRef
-AccessibleWrap::ToBundle()
+AccessibleWrap::ToBundle(bool aMinimal)
 {
   if (!Proxy() && 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;
+  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));
 }