Bug 1790317 part 2: Change instances of UniqueID in LocalAccessible code to use ID. r=eeejay default tip
authorJames Teh <jteh@mozilla.com>
Tue, 04 Oct 2022 06:13:52 +0000
changeset 636821 8454bb0c09fe9d0072a2c817edc9f283cd4d7a03
parent 636820 5f61eac2117b85404a5078a9943320a9308e01b8
push id40285
push usernbeleuzu@mozilla.com
push dateTue, 04 Oct 2022 09:44:18 +0000
treeherdermozilla-central@8454bb0c09fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs1790317
milestone107.0a1
Bug 1790317 part 2: Change instances of UniqueID in LocalAccessible code to use ID. r=eeejay This doesn't update usage elsewhere in the code base, but it should be enough to ensure that this doesn't break anything. We can gradually update other cases in future. Differential Revision: https://phabricator.services.mozilla.com/D157082
accessible/generic/LocalAccessible.cpp
--- a/accessible/generic/LocalAccessible.cpp
+++ b/accessible/generic/LocalAccessible.cpp
@@ -853,20 +853,17 @@ nsresult LocalAccessible::HandleAccEvent
     DocAccessibleChild* ipcDoc = mDoc->IPCDoc();
     // If ipcDoc is null, we can't fire the event to the client. We shouldn't
     // have fired the event in the first place, since this makes events
     // inconsistent for local and remote documents. To avoid this, don't call
     // nsEventShell::FireEvent on a DocAccessible for which
     // HasLoadState(eTreeConstructed) is false.
     MOZ_ASSERT(ipcDoc);
     if (ipcDoc) {
-      uint64_t id = aEvent->GetAccessible()->IsDoc()
-                        ? 0
-                        : reinterpret_cast<uintptr_t>(
-                              aEvent->GetAccessible()->UniqueID());
+      uint64_t id = aEvent->GetAccessible()->ID();
 
       switch (aEvent->GetEventType()) {
         case nsIAccessibleEvent::EVENT_SHOW:
           ipcDoc->ShowEvent(downcast_accEvent(aEvent));
           break;
 
         case nsIAccessibleEvent::EVENT_HIDE:
           ipcDoc->SendHideEvent(id, aEvent->IsFromUserInput());
@@ -915,36 +912,30 @@ nsresult LocalAccessible::HandleAccEvent
 #endif
           );
           break;
         }
         case nsIAccessibleEvent::EVENT_SELECTION:
         case nsIAccessibleEvent::EVENT_SELECTION_ADD:
         case nsIAccessibleEvent::EVENT_SELECTION_REMOVE: {
           AccSelChangeEvent* selEvent = downcast_accEvent(aEvent);
-          uint64_t widgetID =
-              selEvent->Widget()->IsDoc()
-                  ? 0
-                  : reinterpret_cast<uintptr_t>(selEvent->Widget()->UniqueID());
-          ipcDoc->SendSelectionEvent(id, widgetID, aEvent->GetEventType());
+          ipcDoc->SendSelectionEvent(id, selEvent->Widget()->ID(),
+                                     aEvent->GetEventType());
           break;
         }
         case nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED: {
           AccVCChangeEvent* vcEvent = downcast_accEvent(aEvent);
           LocalAccessible* position = vcEvent->NewAccessible();
           LocalAccessible* oldPosition = vcEvent->OldAccessible();
           ipcDoc->SendVirtualCursorChangeEvent(
-              id,
-              oldPosition ? reinterpret_cast<uintptr_t>(oldPosition->UniqueID())
-                          : 0,
+              id, oldPosition ? oldPosition->ID() : 0,
               vcEvent->OldStartOffset(), vcEvent->OldEndOffset(),
-              position ? reinterpret_cast<uintptr_t>(position->UniqueID()) : 0,
-              vcEvent->NewStartOffset(), vcEvent->NewEndOffset(),
-              vcEvent->Reason(), vcEvent->BoundaryType(),
-              vcEvent->IsFromUserInput());
+              position ? position->ID() : 0, vcEvent->NewStartOffset(),
+              vcEvent->NewEndOffset(), vcEvent->Reason(),
+              vcEvent->BoundaryType(), vcEvent->IsFromUserInput());
           break;
         }
 #if defined(XP_WIN)
         case nsIAccessibleEvent::EVENT_FOCUS: {
           ipcDoc->SendFocusEvent(id);
           break;
         }
 #endif
@@ -980,24 +971,19 @@ nsresult LocalAccessible::HandleAccEvent
           AccTextSelChangeEvent* textSelChangeEvent = downcast_accEvent(aEvent);
           AutoTArray<TextRange, 1> ranges;
           textSelChangeEvent->SelectionRanges(&ranges);
           nsTArray<TextRangeData> textRangeData(ranges.Length());
           for (size_t i = 0; i < ranges.Length(); i++) {
             const TextRange& range = ranges.ElementAt(i);
             LocalAccessible* start = range.StartContainer()->AsLocal();
             LocalAccessible* end = range.EndContainer()->AsLocal();
-            textRangeData.AppendElement(TextRangeData(
-                start->IsDoc() && start->AsDoc()->IPCDoc()
-                    ? 0
-                    : reinterpret_cast<uint64_t>(start->UniqueID()),
-                end->IsDoc() && end->AsDoc()->IPCDoc()
-                    ? 0
-                    : reinterpret_cast<uint64_t>(end->UniqueID()),
-                range.StartOffset(), range.EndOffset()));
+            textRangeData.AppendElement(TextRangeData(start->ID(), end->ID(),
+                                                      range.StartOffset(),
+                                                      range.EndOffset()));
           }
           ipcDoc->SendTextSelectionChangeEvent(id, textRangeData);
           break;
         }
         case nsIAccessibleEvent::EVENT_DESCRIPTION_CHANGE:
         case nsIAccessibleEvent::EVENT_NAME_CHANGE: {
           SendCache(CacheDomain::NameAndDescription, CacheUpdateType::Update);
           ipcDoc->SendEvent(id, aEvent->GetEventType());
@@ -3115,18 +3101,17 @@ void LocalAccessible::SendCache(uint64_t
     // be possible if this is a DocAccessible.
     MOZ_ASSERT(IsDoc(), "Called on a non-DocAccessible but IPCDoc is null");
     return;
   }
 
   RefPtr<AccAttributes> fields =
       BundleFieldsForCache(aCacheDomain, aUpdateType);
   nsTArray<CacheData> data;
-  data.AppendElement(
-      CacheData(IsDoc() ? 0 : reinterpret_cast<uint64_t>(UniqueID()), fields));
+  data.AppendElement(CacheData(ID(), fields));
   ipcDoc->SendCache(aUpdateType, data, true);
 }
 
 already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
     uint64_t aCacheDomain, CacheUpdateType aUpdateType) {
   RefPtr<AccAttributes> fields = new AccAttributes();
 
   // Caching name for text leaf Accessibles is redundant, since their name is
@@ -3233,27 +3218,25 @@ already_AddRefed<AccAttributes> LocalAcc
         if (acc->IsImageMap()) {
           // Layout doesn't walk image maps, so we do that
           // manually here. We do this before adding the map itself
           // so the children come earlier in the hittesting order.
           for (uint32_t i = 0; i < acc->ChildCount(); i++) {
             LocalAccessible* child = acc->LocalChildAt(i);
             MOZ_ASSERT(child);
             if (inViewAccs.EnsureInserted(child)) {
-              viewportCache.AppendElement(
-                  child->IsDoc()
-                      ? 0
-                      : reinterpret_cast<uint64_t>(child->UniqueID()));
+              MOZ_ASSERT(!child->IsDoc());
+              viewportCache.AppendElement(child->ID());
             }
           }
         }
 
         if (inViewAccs.EnsureInserted(acc)) {
-          viewportCache.AppendElement(
-              acc->IsDoc() ? 0 : reinterpret_cast<uint64_t>(acc->UniqueID()));
+          MOZ_ASSERT(!acc->IsDoc());
+          viewportCache.AppendElement(acc->ID());
         }
       }
 
       if (viewportCache.Length()) {
         fields->SetAttribute(nsGkAtoms::viewport, std::move(viewportCache));
       }
     }
   }
@@ -3594,17 +3577,17 @@ already_AddRefed<AccAttributes> LocalAcc
         // We use an IDRefsIterator here instead of calling RelationByType
         // directly because we only want to cache explicit relations. Implicit
         // relations will be computed and stored separately in the parent
         // process.
         rel.AppendIter(new IDRefsIterator(mDoc, mContent, relAtom));
       }
 
       while (LocalAccessible* acc = rel.LocalNext()) {
-        ids.AppendElement(acc->IsDoc() ? 0 : acc->ID());
+        ids.AppendElement(acc->ID());
       }
       if (ids.Length()) {
         fields->SetAttribute(relAtom, std::move(ids));
       } else if (aUpdateType == CacheUpdateType::Update) {
         fields->SetAttribute(relAtom, DeleteEntry());
       }
     }
   }