JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute) { if (!ATK_IS_OBJECT(m_element.get())) return JSStringCreateWithCharacters(0, 0); String atkAttributeName = coreAttributeToAtkAttribute(attribute); // Try object attributes first. String attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, atkAttributeName); // Try text attributes if the requested one was not found and we have an AtkText object. if (attributeValue.isEmpty() && ATK_IS_TEXT(m_element.get())) attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), TextAttributeType, atkAttributeName); // Additional check to make sure that the exposure of the state ATK_STATE_INVALID_ENTRY // is consistent with the exposure of aria-invalid as a text attribute, if present. if (atkAttributeName == attributesMap[InvalidNameIndex][AtkDomain]) { bool isInvalidState = checkElementState(m_element.get(), ATK_STATE_INVALID_ENTRY); if (attributeValue.isEmpty()) return JSStringCreateWithUTF8CString(isInvalidState ? "true" : "false"); // If the text attribute was there, check that it's consistent with // what the state says or force the test to fail otherwise. bool isAriaInvalid = attributeValue != "false"; if (isInvalidState != isAriaInvalid) return JSStringCreateWithCharacters(0, 0); } return JSStringCreateWithUTF8CString(attributeValue.utf8().data()); }
double AccessibilityUIElement::intValue() const { if (!ATK_IS_OBJECT(m_element.get())) return 0; if (ATK_IS_VALUE(m_element.get())) { GValue value = G_VALUE_INIT; atk_value_get_current_value(ATK_VALUE(m_element.get()), &value); if (!G_VALUE_HOLDS_FLOAT(&value)) return 0; return g_value_get_float(&value); } // Consider headings as an special case when returning the "int value" of // an AccessibilityUIElement, so we can reuse some tests to check the level // both for HTML headings and objects with the aria-level attribute. if (atk_object_get_role(ATK_OBJECT(m_element.get())) == ATK_ROLE_HEADING) { String headingLevel = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, "level"); bool ok; double headingLevelValue = headingLevel.toDouble(&ok); if (ok) return headingLevelValue; } return 0; }
bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute) { if (!ATK_IS_OBJECT(m_element.get())) return false; String atkAttributeName = coreAttributeToAtkAttribute(attribute); if (atkAttributeName.isEmpty()) return false; // For now, an attribute is supported whether it's exposed as a object or a text attribute. String attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, atkAttributeName); if (attributeValue.isEmpty()) attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), TextAttributeType, atkAttributeName); return !attributeValue.isEmpty(); }
bool AccessibilityUIElement::hasPopup() const { if (!m_element || !ATK_IS_OBJECT(m_element)) return false; return equalIgnoringCase(getAttributeSetValueForId(ATK_OBJECT(m_element), "aria-haspopup"), "true"); }
bool AccessibilityUIElement::hasPopup() const { if (!ATK_IS_OBJECT(m_element.get())) return false; String hasPopupValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, "haspopup"); return equalIgnoringCase(hasPopupValue, "true"); }
JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute) { if (!m_element) return JSStringCreateWithCharacters(0, 0); String atkAttributeName = coreAttributeToAtkAttribute(attribute); if (atkAttributeName.isEmpty()) return JSStringCreateWithCharacters(0, 0); String attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element), atkAttributeName.utf8().data()); return JSStringCreateWithUTF8CString(attributeValue.utf8().data()); }