示例#1
0
JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
{
    if (!m_element || !ATK_IS_OBJECT(m_element.get()))
        return JSStringCreateWithCharacters(0, 0);

    GOwnPtr<gchar> attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element.get()))));
    return JSStringCreateWithUTF8CString(attributeData.get());
}
JSStringRef AccessibilityUIElement::allAttributes()
{
    if (!m_element)
        return JSStringCreateWithCharacters(0, 0);

    ASSERT(ATK_IS_OBJECT(m_element));
    return JSStringCreateWithUTF8CString(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
}
示例#3
0
static String getAtkAttributeSetAsString(AtkObject* accessible)
{
    StringBuilder builder;

    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
        GOwnPtr<gchar> attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL));
        builder.append(attributeData.get());
        if (attributes->next)
            builder.append(", ");
    }
    atk_attribute_set_free(attributeSet);

    return builder.toString();
}
JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
{
    if (!m_element)
        return JSStringCreateWithCharacters(0, 0);

    String atkAttributeName = coreAttributeToAtkAttribute(attribute);
    if (atkAttributeName.isEmpty())
        return JSStringCreateWithCharacters(0, 0);

    for (GSList* atkAttributes = atk_object_get_attributes(ATK_OBJECT(m_element)); atkAttributes; atkAttributes = atkAttributes->next) {
        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(atkAttributes->data);
        if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data()))
            return JSStringCreateWithUTF8CString(atkAttribute->value);
    }

    return JSStringCreateWithCharacters(0, 0);
}
示例#5
0
static String getAttributeSetValueForId(AtkObject* accessible, const char* id)
{
    const char* attributeValue = 0;
    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
        if (!strcmp(atkAttribute->name, id)) {
            attributeValue = atkAttribute->value;
            break;
        }
    }

    String atkAttributeValue = String::fromUTF8(attributeValue);
    atk_attribute_set_free(attributeSet);

    return atkAttributeValue;
}
示例#6
0
static dbus_bool_t
impl_get_Attributes (DBusMessageIter * iter, void *user_data)
{
  DBusMessageIter iter_variant;
  AtkObject *object = (AtkObject *) user_data;
  AtkAttributeSet *attributes;

  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);

  attributes = atk_object_get_attributes (object);

  dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "a{ss}", &iter_variant);
  spi_object_append_attribute_set (&iter_variant, attributes);
  dbus_message_iter_close_container (iter, &iter_variant);

  atk_attribute_set_free (attributes);

  return TRUE;
}
示例#7
0
static DBusMessage *
impl_GetAttributes (DBusConnection * bus,
                    DBusMessage * message, void *user_data)
{
  AtkObject *object = (AtkObject *) user_data;
  AtkAttributeSet *attributes;
  DBusMessage *reply = NULL;
  DBusMessageIter iter;

  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
                        droute_not_yet_handled_error (message));

  attributes = atk_object_get_attributes (object);

  reply = dbus_message_new_method_return (message);
  dbus_message_iter_init_append (reply, &iter);
  spi_object_append_attribute_set (&iter, attributes);

  atk_attribute_set_free (attributes);

  return reply;
}
示例#8
0
JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
{
    if (!m_element)
        return JSStringCreateWithCharacters(0, 0);

    String atkAttributeName = coreAttributeToAtkAttribute(attribute);
    if (atkAttributeName.isNull())
        return JSStringCreateWithCharacters(0, 0);

    GOwnPtr<gchar> attributeValue;
    GOwnPtr<GSList> objectAttributes(atk_object_get_attributes(ATK_OBJECT(m_element.get())));
    for (GSList* attributes =  objectAttributes.get(); attributes; attributes = attributes->next) {
        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
        if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data())) {
            attributeValue.set(g_strdup(atkAttribute->value));
            break;
        }
    }

    attributesClear(objectAttributes.get());

    return JSStringCreateWithUTF8CString(attributeValue.get());
}
AtkObject* AccessibilityController::childElementById(AtkObject* parent, const char* id)
{
    if (!ATK_IS_OBJECT(parent))
        return 0;

    AtkAttributeSet* attributeSet = atk_object_get_attributes(parent);
    for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
        if (!strcmp(attribute->name, "html-id")) {
            if (!strcmp(attribute->value, id))
                return parent;
            break;
        }
    }

    int childCount = atk_object_get_n_accessible_children(parent);
    for (int i = 0; i < childCount; i++) {
        AtkObject* result = childElementById(atk_object_ref_accessible_child(parent, i), id);
        if (ATK_IS_OBJECT(result))
            return result;
    }

    return 0;
}
示例#10
0
文件: accessible.c 项目: GNOME/at-spi
static Accessibility_AttributeSet* 
impl_accessibility_accessible_get_attributes (PortableServer_Servant servant,
					       CORBA_Environment     *ev)
{
    Accessibility_AttributeSet *retval;
    AtkAttributeSet *attributes = NULL;
    AtkAttribute *attr = NULL;
    gint n_attributes = 0;
    gint i;
    
    AtkObject *object = get_atkobject_from_servant (servant);
    gchar *concat_str;
    
    g_return_val_if_fail (object != NULL, NULL);
    attributes = atk_object_get_attributes (object);

    if (attributes)
      n_attributes = g_slist_length (attributes);
    
    retval = CORBA_sequence_CORBA_string__alloc ();
    retval->_length = retval->_maximum = n_attributes;
    retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (n_attributes);
    CORBA_sequence_set_release (retval, CORBA_TRUE);
    
    for (i = 0; i < n_attributes; ++i)
    {
	attr = g_slist_nth_data (attributes, i);
	concat_str = g_strconcat (attr->name, ":", attr->value, NULL);
	retval->_buffer[i] = CORBA_string_dup (concat_str);
	g_free (concat_str);
    }

    atk_attribute_set_free (attributes);
    
  return retval;
}
示例#11
0
JSStringRef AccessibilityUIElement::allAttributes()
{
    return JSStringCreateWithUTF8CString(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
}