AtkAttributeSet *
    getDocumentAttributesCB(AtkDocument *aDocument)
    {
        AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
        if (!accWrap || !accWrap->IsDoc())
            return nullptr;

        // according to atkobject.h, AtkAttributeSet is a GSList
        GSList* attributes = nullptr;
        DocAccessible* document = accWrap->AsDoc();
        nsAutoString aURL;
        nsresult rv = document->GetURL(aURL);
        if (NS_SUCCEEDED(rv))
            attributes = prependToList(attributes, kDocUrlName, aURL);

        nsAutoString aW3CDocType;
        rv = document->GetDocType(aW3CDocType);
        if (NS_SUCCEEDED(rv))
            attributes = prependToList(attributes, kDocTypeName, aW3CDocType);

        nsAutoString aMimeType;
        rv = document->GetMimeType(aMimeType);
        if (NS_SUCCEEDED(rv))
            attributes = prependToList(attributes, kMimeTypeName, aMimeType);

        return attributes;
    }
Ejemplo n.º 2
0
AtkAttributeSet *
getDocumentAttributesCB(AtkDocument *aDocument)
{
  nsAutoString url;
  nsAutoString w3cDocType;
  nsAutoString mimeType;
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
  if (accWrap) {
    if (!accWrap->IsDoc()) {
      return nullptr;
    }

    DocAccessible* document = accWrap->AsDoc();
    document->URL(url);
    document->DocType(w3cDocType);
    document->MimeType(mimeType);
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) {
    proxy->URLDocTypeMimeType(url, w3cDocType, mimeType);
  } else {
    return nullptr;
  }

  // according to atkobject.h, AtkAttributeSet is a GSList
  GSList* attributes = nullptr;
  attributes = prependToList(attributes, kDocUrlName, url);
  attributes = prependToList(attributes, kDocTypeName, w3cDocType);
  attributes = prependToList(attributes, kMimeTypeName, mimeType);

  return attributes;
}
Ejemplo n.º 3
0
const gchar *
getDocumentAttributeValueCB(AtkDocument *aDocument,
                            const gchar *aAttrName)
{
  ProxyAccessible* proxy = nullptr;
  DocAccessible* document = nullptr;
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
  if (accWrap) {
    if (!accWrap->IsDoc()) {
      return nullptr;
    }

    document = accWrap->AsDoc();
  } else {
    proxy = GetProxy(ATK_OBJECT(aDocument));
    if (!proxy) {
      return nullptr;
    }
  }

  nsAutoString attrValue;
  if (!strcasecmp(aAttrName, kDocTypeName)) {
    if (document) {
      document->DocType(attrValue);
    } else {
      proxy->DocType(attrValue);
    }
  } else if (!strcasecmp(aAttrName, kDocUrlName)) {
    if (document) {
      document->URL(attrValue);
    } else {
      proxy->URL(attrValue);
    }
  } else if (!strcasecmp(aAttrName, kMimeTypeName)) {
    if (document) {
      document->MimeType(attrValue);
    } else {
      proxy->MimeType(attrValue);
    }
  } else {
    return nullptr;
  }

  return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
}
Ejemplo n.º 4
0
void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) {
  mFocusPath.Clear();
  if (IPCAccessibilityActive()) {
    DocAccessibleChild* ipcDoc = IPCDoc();
    nsTArray<BatchData> cacheData;
    for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
         acc = static_cast<AccessibleWrap*>(acc->Parent())) {
      auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc()
                     ? 0
                     : reinterpret_cast<uint64_t>(acc->UniqueID());
      nsAutoString name;
      acc->Name(name);
      nsAutoString textValue;
      acc->Value(textValue);
      nsAutoString nodeID;
      acc->WrapperDOMNodeID(nodeID);
      nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
      nsTArray<Attribute> attributes;
      nsAccUtils::PersistentPropertiesToArray(props, &attributes);
      cacheData.AppendElement(BatchData(
          acc->Document()->IPCDoc(), uid, acc->State(), acc->Bounds(),
          acc->ActionCount(), name, textValue, nodeID, acc->CurValue(),
          acc->MinValue(), acc->MaxValue(), acc->Step(), attributes));
      mFocusPath.Put(acc->UniqueID(), acc);
    }

    ipcDoc->SendBatch(eBatch_FocusPath, cacheData);
  } else if (SessionAccessibility* sessionAcc =
                 SessionAccessibility::GetInstanceFor(this)) {
    nsTArray<AccessibleWrap*> accessibles;
    for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
         acc = static_cast<AccessibleWrap*>(acc->Parent())) {
      accessibles.AppendElement(acc);
    }

    sessionAcc->ReplaceFocusPathCache(accessibles);
  }
}
    const gchar *
    getDocumentAttributeValueCB(AtkDocument *aDocument,
                                const gchar *aAttrName)
    {
        AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
        if (!accWrap || !accWrap->IsDoc())
            return nullptr;

        DocAccessible* document = accWrap->AsDoc();
        nsresult rv;
        nsAutoString attrValue;
        if (!strcasecmp(aAttrName, kDocTypeName))
            rv = document->GetDocType(attrValue);
        else if (!strcasecmp(aAttrName, kDocUrlName))
            rv = document->GetURL(attrValue);
        else if (!strcasecmp(aAttrName, kMimeTypeName))
            rv = document->GetMimeType(attrValue);
        else
            return nullptr;

        NS_ENSURE_SUCCESS(rv, nullptr);
        return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
    }