Commit 7e16816a authored by James Teh's avatar James Teh
Browse files

Bug 1848991: Attach a RemoteAccessible to its parent before calling ProxyCreated. (ESR) a=RyanVM

This is what we did before the fix for bug 1779578.
Failure to do this meant that RemoteAccessible::IsLink() returned false even for a child of a HyperText Accessible, which meant the ATK object was created without the HyperLink interface.
This change requires that we move the handling of pending OOP child docs, since we can't add a child document until ProxyCreated has been called on the OuterDoc.

Original Revision: https://phabricator.services.mozilla.com/D186423

Depends on D192440

Differential Revision: https://phabricator.services.mozilla.com/D192441
parent 284e8a92
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -927,6 +927,8 @@ static uint16_t GetInterfacesForProxy(RemoteAccessible* aProxy) {
}

void a11y::ProxyCreated(RemoteAccessible* aProxy) {
  MOZ_ASSERT(aProxy->RemoteParent() || aProxy->IsDoc(),
             "Need parent to check for HyperLink interface");
  GType type = GetMaiAtkType(GetInterfacesForProxy(aProxy));
  NS_ASSERTION(type, "why don't we have a type!");

+20 −14
Original line number Diff line number Diff line
@@ -218,25 +218,11 @@ RemoteAccessible* DocAccessibleParent::CreateAcc(
                                  aAccData.Type(), aAccData.GenericTypes(),
                                  aAccData.RoleMapEntryIndex());
  mAccessibles.PutEntry(aAccData.ID())->mProxy = newProxy;
  ProxyCreated(newProxy);

  if (RefPtr<AccAttributes> fields = aAccData.CacheFields()) {
    newProxy->ApplyCache(CacheUpdateType::Initial, fields);
  }

  mPendingOOPChildDocs.RemoveIf([&](dom::BrowserBridgeParent* bridge) {
    MOZ_ASSERT(bridge->GetBrowserParent(),
               "Pending BrowserBridgeParent should be alive");
    if (bridge->GetEmbedderAccessibleId() != aAccData.ID()) {
      return false;
    }
    MOZ_ASSERT(bridge->GetEmbedderAccessibleDoc() == this);
    if (DocAccessibleParent* childDoc = bridge->GetDocAccessibleParent()) {
      AddChildDoc(childDoc, aAccData.ID(), false);
    }
    return true;
  });

  return newProxy;
}

@@ -245,9 +231,29 @@ void DocAccessibleParent::AttachChild(RemoteAccessible* aParent,
                                      RemoteAccessible* aChild) {
  aParent->AddChildAt(aIndex, aChild);
  aChild->SetParent(aParent);
  // ProxyCreated might have already been called if aChild is being moved.
  if (!aChild->GetWrapper()) {
    ProxyCreated(aChild);
  }
  if (aChild->IsTableCell()) {
    CachedTableAccessible::Invalidate(aChild);
  }
  if (aChild->IsOuterDoc()) {
    // We can only do this after ProxyCreated is called because it will fire an
    // event on aChild.
    mPendingOOPChildDocs.RemoveIf([&](dom::BrowserBridgeParent* bridge) {
      MOZ_ASSERT(bridge->GetBrowserParent(),
                 "Pending BrowserBridgeParent should be alive");
      if (bridge->GetEmbedderAccessibleId() != aChild->ID()) {
        return false;
      }
      MOZ_ASSERT(bridge->GetEmbedderAccessibleDoc() == this);
      if (DocAccessibleParent* childDoc = bridge->GetDocAccessibleParent()) {
        AddChildDoc(childDoc, aChild->ID(), false);
      }
      return true;
    });
  }
}

void DocAccessibleParent::ShutdownOrPrepareForMove(RemoteAccessible* aAcc) {