[atk] Replace deprecated call to atk_document_get_locale() in DumpRenderTree
[WebKit-https.git] / Tools / DumpRenderTree / atk / AccessibilityUIElementAtk.cpp
index 2047b3e3f6a363b047231ae3aad7d2ffb5468a3a..67a993edd33dd5300956b1d430025e17d23c7dc6 100644 (file)
@@ -175,6 +175,15 @@ static inline gchar* replaceCharactersForResults(gchar* str)
     return g_strdup(uString.utf8().data());
 }
 
+static bool checkElementState(PlatformUIElement element, AtkStateType stateType)
+{
+    if (!ATK_IS_OBJECT(element))
+        return false;
+
+    GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(element)));
+    return atk_state_set_contains_state(stateSet.get(), stateType);
+}
+
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
     : m_element(element)
 {
@@ -423,21 +432,11 @@ JSStringRef AccessibilityUIElement::language()
     if (!m_element)
         return JSStringCreateWithCharacters(0, 0);
 
-    // In ATK, the document language is exposed as the document's locale.
-    if (atk_object_get_role(ATK_OBJECT(m_element)) == ATK_ROLE_DOCUMENT_FRAME)
-        return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atk_document_get_locale(ATK_DOCUMENT(m_element))));
-
-    // For all other objects, the language is exposed as an AtkText attribute.
-    if (!ATK_IS_TEXT(m_element))
+    const gchar* locale = atk_object_get_object_locale(ATK_OBJECT(m_element));
+    if (!locale)
         return JSStringCreateWithCharacters(0, 0);
 
-    for (GSList* textAttributes = atk_text_get_default_attributes(ATK_TEXT(m_element)); textAttributes; textAttributes = textAttributes->next) {
-        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(textAttributes->data);
-        if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE)))
-            return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atkAttribute->value));
-    }
-
-    return JSStringCreateWithCharacters(0, 0);
+    return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", locale));
 }
 
 double AccessibilityUIElement::x()
@@ -490,7 +489,19 @@ double AccessibilityUIElement::clickPointY()
 
 JSStringRef AccessibilityUIElement::orientation() const
 {
-    return 0;
+    if (!m_element || !ATK_IS_OBJECT(m_element))
+        return JSStringCreateWithCharacters(0, 0);
+
+    const char* axOrientation = 0;
+    if (checkElementState(m_element, ATK_STATE_HORIZONTAL))
+        axOrientation = "AXOrientation: AXHorizontalOrientation";
+    else if (checkElementState(m_element, ATK_STATE_VERTICAL))
+        axOrientation = "AXOrientation: AXVerticalOrientation";
+
+    if (!axOrientation)
+        return JSStringCreateWithCharacters(0, 0);
+
+    return JSStringCreateWithUTF8CString(axOrientation);
 }
 
 double AccessibilityUIElement::intValue() const
@@ -539,15 +550,6 @@ JSStringRef AccessibilityUIElement::valueDescription()
     return JSStringCreateWithCharacters(0, 0);
 }
 
-static bool checkElementState(PlatformUIElement element, AtkStateType stateType)
-{
-    if (!ATK_IS_OBJECT(element))
-        return false;
-
-    GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(element)));
-    return atk_state_set_contains_state(stateSet.get(), stateType);
-}
-
 bool AccessibilityUIElement::isEnabled()
 {
     return checkElementState(m_element, ATK_STATE_ENABLED);
@@ -761,7 +763,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
     return false;
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly)
 {
     // FIXME: implement
     return 0;