Changeset 286059 in webkit
- Timestamp:
- Nov 19, 2021, 6:51:09 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/SourcesGTK.txt (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp (modified) (5 diffs)
-
Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h (modified) (5 diffs)
-
Source/WebCore/accessibility/atspi/AccessibilityObjectDocumentAtspi.cpp (added)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp (modified) (2 diffs)
-
Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286058 r286059 1 2021-11-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][a11y] Add implementation of document interface when building with ATSPI 4 https://bugs.webkit.org/show_bug.cgi?id=232755 5 6 Reviewed by Adrian Perez de Castro. 7 8 * SourcesGTK.txt: 9 * accessibility/atspi/AccessibilityObjectAtspi.cpp: 10 (WebCore::AccessibilityObjectAtspi::interfacesForObject): 11 (WebCore::AccessibilityObjectAtspi::path): 12 (WebCore::AccessibilityObjectAtspi::locale const): 13 (WebCore::AccessibilityObjectAtspi::buildInterfaces const): 14 * accessibility/atspi/AccessibilityObjectAtspi.h: 15 * accessibility/atspi/AccessibilityObjectDocumentAtspi.cpp: Added. 16 (WebCore::AccessibilityObjectAtspi::documentAttribute const): 17 (WebCore::AccessibilityObjectAtspi::documentAttributes const): 18 (WebCore::AccessibilityObjectAtspi::documentLocale const): 19 1 20 2021-11-19 Antti Koivisto <antti@apple.com> 2 21 -
trunk/Source/WebCore/SourcesGTK.txt
r286056 r286059 44 44 accessibility/atspi/AccessibilityObjectActionAtspi.cpp 45 45 accessibility/atspi/AccessibilityObjectComponentAtspi.cpp 46 accessibility/atspi/AccessibilityObjectDocumentAtspi.cpp 46 47 accessibility/atspi/AccessibilityObjectHyperlinkAtspi.cpp 47 48 accessibility/atspi/AccessibilityObjectHypertextAtspi.cpp -
trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp
r286056 r286059 91 91 if (coreObject.isLink() || (isRendererReplacedElement(renderer))) 92 92 interfaces.add(Interface::Hyperlink); 93 94 if (coreObject.roleValue() == AccessibilityRole::WebArea) 95 interfaces.add(Interface::Document); 93 96 94 97 return interfaces; … … 446 449 return g_variant_new_string(atspiObject->description().data()); 447 450 if (!g_strcmp0(propertyName, "Locale")) 448 return g_variant_new_string( setlocale(LC_MESSAGES, nullptr));451 return g_variant_new_string(atspiObject->locale().utf8().data()); 449 452 if (!g_strcmp0(propertyName, "AccessibleId")) 450 453 return g_variant_new_string(atspiObject->m_axObject ? String::number(atspiObject->m_axObject->objectID().toUInt64()).utf8().data() : ""); … … 486 489 if (m_interfaces.contains(Interface::Action)) 487 490 interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_action_interface), &s_actionFunctions }); 491 if (m_interfaces.contains(Interface::Document)) 492 interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_document_interface), &s_documentFunctions }); 488 493 m_path = atspiRoot->atspi().registerObject(*this, WTFMove(interfaces)); 489 494 } … … 694 699 695 700 return ""; 701 } 702 703 String AccessibilityObjectAtspi::locale() const 704 { 705 auto* axObject = isMainThread() ? m_coreObject : m_axObject; 706 return axObject ? axObject->language() : String(); 696 707 } 697 708 … … 1120 1131 if (m_interfaces.contains(Interface::Action)) 1121 1132 g_variant_builder_add(builder, "s", webkit_action_interface.name); 1133 if (m_interfaces.contains(Interface::Document)) 1134 g_variant_builder_add(builder, "s", webkit_document_interface.name); 1122 1135 } 1123 1136 -
trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h
r286056 r286059 50 50 Hyperlink = 1 << 4, 51 51 Hypertext = 1 << 5, 52 Action = 1 << 6 52 Action = 1 << 6, 53 Document = 1 << 7 53 54 }; 54 55 const OptionSet<Interface>& interfaces() const { return m_interfaces; } … … 75 76 WEBCORE_EXPORT CString name() const; 76 77 WEBCORE_EXPORT CString description() const; 78 WEBCORE_EXPORT String locale() const; 77 79 WEBCORE_EXPORT unsigned role() const; 78 80 WEBCORE_EXPORT unsigned childCount() const; … … 127 129 WEBCORE_EXPORT bool doAction() const; 128 130 131 WEBCORE_EXPORT String documentAttribute(const String&) const; 132 129 133 private: 130 134 explicit AccessibilityObjectAtspi(AXCoreObject*); … … 169 173 String actionKeyBinding() const; 170 174 175 HashMap<String, String> documentAttributes() const; 176 String documentLocale() const; 177 171 178 static OptionSet<Interface> interfacesForObject(AXCoreObject&); 172 179 … … 178 185 static GDBusInterfaceVTable s_hypertextFunctions; 179 186 static GDBusInterfaceVTable s_actionFunctions; 187 static GDBusInterfaceVTable s_documentFunctions; 180 188 181 189 AXCoreObject* m_axObject { nullptr }; -
trunk/Tools/ChangeLog
r286056 r286059 1 2021-11-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][a11y] Add implementation of document interface when building with ATSPI 4 https://bugs.webkit.org/show_bug.cgi?id=232755 5 6 Reviewed by Adrian Perez de Castro. 7 8 Add unit test for the document interface and WTR implementation. 9 10 * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp: 11 (testDocumentBasic): 12 (beforeAll): 13 * WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp: 14 (WTR::AccessibilityUIElement::language): 15 (WTR::AccessibilityUIElement::documentEncoding): 16 (WTR::AccessibilityUIElement::documentURI): 17 1 18 2021-11-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 19 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp
r286056 r286059 1940 1940 } 1941 1941 1942 static void testDocumentBasic(AccessibilityTest* test, gconstpointer) 1943 { 1944 test->showInWindow(800, 600); 1945 test->loadHtml( 1946 "<!doctype html>" 1947 "<html>" 1948 " <head>" 1949 " <meta http-equiv='content-language' content='en-us'/>" 1950 " <meta http-equiv='content-type' content='text/html; charset=UTF-8'/>" 1951 " <title>Document attributes</title>" 1952 " </head>" 1953 " <body>" 1954 " <p>This is a paragraph</p>" 1955 " <p lang='es'>Spanish</p>" 1956 " </body>" 1957 "</html>", 1958 "http://example.org"); 1959 test->waitUntilLoadFinished(); 1960 1961 auto testApp = test->findTestApplication(); 1962 g_assert_true(ATSPI_IS_ACCESSIBLE(testApp.get())); 1963 1964 auto documentWeb = test->findDocumentWeb(testApp.get()); 1965 g_assert_true(ATSPI_IS_DOCUMENT(documentWeb.get())); 1966 g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 2); 1967 1968 GUniquePtr<char> language(atspi_document_get_locale(ATSPI_DOCUMENT(documentWeb.get()), nullptr)); 1969 g_assert_cmpstr(language.get(), ==, "en-us"); 1970 // Elements with no language attribute inhewir the document one. 1971 auto p1 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr)); 1972 g_assert_true(ATSPI_IS_ACCESSIBLE(p1.get())); 1973 g_assert_cmpstr(atspi_accessible_get_object_locale(p1.get(), nullptr), ==, "en-us"); 1974 auto p2 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 1, nullptr)); 1975 g_assert_true(ATSPI_IS_ACCESSIBLE(p2.get())); 1976 g_assert_cmpstr(atspi_accessible_get_object_locale(p2.get(), nullptr), ==, "es"); 1977 1978 GRefPtr<GHashTable> attributes = adoptGRef(atspi_document_get_attributes(ATSPI_DOCUMENT(documentWeb.get()), nullptr)); 1979 g_assert_nonnull(attributes.get()); 1980 #if USE(ATSPI) 1981 g_assert_cmpuint(g_hash_table_size(attributes.get()), ==, 5); 1982 #else 1983 g_assert_cmpuint(g_hash_table_size(attributes.get()), ==, 3); 1984 #endif 1985 g_assert_cmpstr(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "DocType")), ==, "html"); 1986 GUniquePtr<char> value(atspi_document_get_document_attribute_value(ATSPI_DOCUMENT(documentWeb.get()), const_cast<char*>("DocType"), nullptr)); 1987 g_assert_cmpstr(value.get(), ==, "html"); 1988 g_assert_cmpstr(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "Encoding")), ==, "UTF-8"); 1989 value.reset(atspi_document_get_document_attribute_value(ATSPI_DOCUMENT(documentWeb.get()), const_cast<char*>("Encoding"), nullptr)); 1990 g_assert_cmpstr(value.get(), ==, "UTF-8"); 1991 g_assert_cmpstr(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "URI")), ==, "http://example.org/"); 1992 value.reset(atspi_document_get_document_attribute_value(ATSPI_DOCUMENT(documentWeb.get()), const_cast<char*>("URI"), nullptr)); 1993 g_assert_cmpstr(value.get(), ==, "http://example.org/"); 1994 #if USE(ATSPI) 1995 g_assert_cmpstr(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "MimeType")), ==, "text/html"); 1996 value.reset(atspi_document_get_document_attribute_value(ATSPI_DOCUMENT(documentWeb.get()), const_cast<char*>("MimeType"), nullptr)); 1997 g_assert_cmpstr(value.get(), ==, "text/html"); 1998 g_assert_cmpstr(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "Title")), ==, "Document attributes"); 1999 value.reset(atspi_document_get_document_attribute_value(ATSPI_DOCUMENT(documentWeb.get()), const_cast<char*>("Title"), nullptr)); 2000 g_assert_cmpstr(value.get(), ==, "Document attributes"); 2001 #endif 2002 } 2003 1942 2004 void beforeAll() 1943 2005 { … … 1964 2026 AccessibilityTest::add("WebKitAccessibility", "hypertext/basic", testHypertextBasic); 1965 2027 AccessibilityTest::add("WebKitAccessibility", "action/basic", testActionBasic); 2028 AccessibilityTest::add("WebKitAccessibility", "document/basic", testDocumentBasic); 1966 2029 } 1967 2030 -
trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp
r286056 r286059 685 685 JSRetainPtr<JSStringRef> AccessibilityUIElement::language() 686 686 { 687 return JSStringCreateWithCharacters(0, 0); 687 m_element->updateBackingStore(); 688 auto locale = m_element->locale(); 689 if (locale.isEmpty()) 690 return JSStringCreateWithCharacters(0, 0); 691 692 return OpaqueJSString::tryCreate(makeString("AXLanguage: ", locale)).leakRef(); 688 693 } 689 694 … … 1123 1128 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding() 1124 1129 { 1125 return JSStringCreateWithCharacters(0, 0); 1130 if (!m_element->interfaces().contains(WebCore::AccessibilityObjectAtspi::Interface::Document)) 1131 return JSStringCreateWithCharacters(0, 0); 1132 1133 return OpaqueJSString::tryCreate(m_element->documentAttribute("Encoding")).leakRef(); 1126 1134 } 1127 1135 1128 1136 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI() 1129 1137 { 1130 return JSStringCreateWithCharacters(0, 0); 1138 if (!m_element->interfaces().contains(WebCore::AccessibilityObjectAtspi::Interface::Document)) 1139 return JSStringCreateWithCharacters(0, 0); 1140 1141 return OpaqueJSString::tryCreate(m_element->documentAttribute("URI")).leakRef(); 1131 1142 } 1132 1143
Note:
See TracChangeset
for help on using the changeset viewer.