⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286050 in webkit


Ignore:
Timestamp:
Nov 19, 2021, 12:51:53 AM (5 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK][a11y] Add implementation of hyperlink interface when building with ATSPI
https://bugs.webkit.org/show_bug.cgi?id=232707

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Add hyperlink implementation and make links be handled as replaced objects too, to ensure all hyperlinks are
handled the same way. That's consistent with chromium.

  • SourcesGTK.txt:
  • accessibility/atspi/AccessibilityObjectAtspi.cpp:

(WebCore::AccessibilityObjectAtspi::interfacesForObject):
(WebCore::AccessibilityObjectAtspi::path):
(WebCore::AccessibilityObjectAtspi::buildInterfaces const):

  • accessibility/atspi/AccessibilityObjectAtspi.h:
  • accessibility/atspi/AccessibilityObjectHyperlinkAtspi.cpp: Added.

(WebCore::AccessibilityObjectAtspi::url const):
(WebCore::AccessibilityObjectAtspi::offsetInParent const):

  • accessibility/atspi/AccessibilityObjectTextAtspi.cpp:

(WebCore::AccessibilityObjectAtspi::characterOffset const):

  • editing/TextIterator.cpp:

(WebCore::isRendererReplacedElement):
(WebCore::TextIterator::handleReplacedElement):

Tools:

Add unit tests to check hyperlink interface and implement AccessibilityUIElement::url() in WTR.

  • TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:

(testTextReplacedObjects):
(testHyperlinkBasic):
(beforeAll):

  • WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:

(WTR::AccessibilityUIElement::url):

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286049 r286050  
     12021-11-19  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][a11y] Add implementation of hyperlink interface when building with ATSPI
     4        https://bugs.webkit.org/show_bug.cgi?id=232707
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Add hyperlink implementation and make links be handled as replaced objects too, to ensure all hyperlinks are
     9        handled the same way. That's consistent with chromium.
     10
     11        * SourcesGTK.txt:
     12        * accessibility/atspi/AccessibilityObjectAtspi.cpp:
     13        (WebCore::AccessibilityObjectAtspi::interfacesForObject):
     14        (WebCore::AccessibilityObjectAtspi::path):
     15        (WebCore::AccessibilityObjectAtspi::buildInterfaces const):
     16        * accessibility/atspi/AccessibilityObjectAtspi.h:
     17        * accessibility/atspi/AccessibilityObjectHyperlinkAtspi.cpp: Added.
     18        (WebCore::AccessibilityObjectAtspi::url const):
     19        (WebCore::AccessibilityObjectAtspi::offsetInParent const):
     20        * accessibility/atspi/AccessibilityObjectTextAtspi.cpp:
     21        (WebCore::AccessibilityObjectAtspi::characterOffset const):
     22        * editing/TextIterator.cpp:
     23        (WebCore::isRendererReplacedElement):
     24        (WebCore::TextIterator::handleReplacedElement):
     25
    1262021-11-18  Frédéric Wang  <fwang@igalia.com>
    227
  • trunk/Source/WebCore/SourcesGTK.txt

    r285997 r286050  
    4343accessibility/atspi/AccessibilityObjectAtspi.cpp
    4444accessibility/atspi/AccessibilityObjectComponentAtspi.cpp
     45accessibility/atspi/AccessibilityObjectHyperlinkAtspi.cpp
    4546accessibility/atspi/AccessibilityObjectTextAtspi.cpp
    4647accessibility/atspi/AccessibilityObjectValueAtspi.cpp
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp

    r285997 r286050  
    3131#include "RenderBlock.h"
    3232#include "RenderObject.h"
     33#include "TextIterator.h"
    3334#include <glib/gi18n-lib.h>
    3435#include <wtf/MainThread.h>
     
    8687    if (coreObject.supportsRangeValue())
    8788        interfaces.add(Interface::Value);
     89
     90    if (coreObject.isLink() || (isRendererReplacedElement(renderer)))
     91        interfaces.add(Interface::Hyperlink);
    8892
    8993    return interfaces;
     
    475479        if (m_interfaces.contains(Interface::Value))
    476480            interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_value_interface), &s_valueFunctions });
     481        if (m_interfaces.contains(Interface::Hyperlink))
     482            interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_hyperlink_interface), &s_hyperlinkFunctions });
    477483        m_path = atspiRoot->atspi().registerObject(*this, WTFMove(interfaces));
    478484    }
     
    10921098    if (m_interfaces.contains(Interface::Value))
    10931099        g_variant_builder_add(builder, "s", webkit_value_interface.name);
     1100    if (m_interfaces.contains(Interface::Hyperlink))
     1101        g_variant_builder_add(builder, "s", webkit_hyperlink_interface.name);
    10941102}
    10951103
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h

    r285997 r286050  
    4747        Component = 1 << 1,
    4848        Text = 1 << 2,
    49         Value = 1 << 3
     49        Value = 1 << 3,
     50        Hyperlink = 1 << 4
    5051    };
    5152    const OptionSet<Interface>& interfaces() const { return m_interfaces; }
     
    118119    void valueChanged(double);
    119120
     121    WEBCORE_EXPORT URL url() const;
     122
    120123private:
    121124    explicit AccessibilityObjectAtspi(AXCoreObject*);
     
    140143    CString textAtOffset(int, TextGranularity, int&, int&) const;
    141144    int characterAtOffset(int) const;
     145    std::optional<unsigned> characterOffset(UChar, int) const;
    142146    IntRect textExtents(int, int, uint32_t) const;
    143147    int offsetAtPoint(const IntPoint&, uint32_t) const;
     
    149153    bool scrollToPoint(int, int, uint32_t, int, int) const;
    150154
     155    unsigned offsetInParent() const;
     156
    151157    static OptionSet<Interface> interfacesForObject(AXCoreObject&);
    152158
     
    155161    static GDBusInterfaceVTable s_textFunctions;
    156162    static GDBusInterfaceVTable s_valueFunctions;
     163    static GDBusInterfaceVTable s_hyperlinkFunctions;
    157164
    158165    AXCoreObject* m_axObject { nullptr };
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp

    r285994 r286050  
    2222
    2323#if ENABLE(ACCESSIBILITY) && USE(ATSPI)
     24#include "AXObjectCache.h"
    2425#include "AccessibilityAtspiEnums.h"
     26#include "AccessibilityObject.h"
    2527#include "AccessibilityObjectInterface.h"
     28#include "AccessibilityRootAtspi.h"
    2629#include "Editing.h"
    2730#include "PlatformScreen.h"
     31#include "RenderLayer.h"
    2832#include "SurrogatePairAwareTextIterator.h"
    2933#include "TextIterator.h"
    3034#include "VisibleUnits.h"
     35#include <gio/gio.h>
    3136
    3237namespace WebCore {
     
    485490}
    486491
     492std::optional<unsigned> AccessibilityObjectAtspi::characterOffset(UChar character, int index) const
     493{
     494    auto utf16Text = text();
     495    unsigned start = 0;
     496    size_t offset;
     497    while ((offset = utf16Text.find(character, start)) != notFound) {
     498        start = offset + 1;
     499        if (!index)
     500            break;
     501        index--;
     502    }
     503
     504    if (offset == notFound)
     505        return std::nullopt;
     506
     507    auto mapping = offsetMapping(utf16Text);
     508    return UTF16OffsetToUTF8(mapping, offset);
     509}
     510
    487511IntRect AccessibilityObjectAtspi::boundsForRange(unsigned utf16Offset, unsigned length, uint32_t coordinateType) const
    488512{
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r285655 r286050  
    278278        if (equalLettersIgnoringASCIICase(element.attributeWithoutSynchronization(roleAttr), "img"))
    279279            return true;
     280#if USE(ATSPI)
     281        // Links are also replaced with object replacement character in ATSPI.
     282        if (element.isLink())
     283            return true;
     284#endif
    280285    }
    281286
     
    751756    m_hasEmitted = true;
    752757
    753     if (m_behaviors.contains(TextIteratorBehavior::EmitsObjectReplacementCharacters) && renderer.isReplaced()) {
     758    if (m_behaviors.contains(TextIteratorBehavior::EmitsObjectReplacementCharacters)) {
    754759        emitCharacter(objectReplacementCharacter, *m_node->parentNode(), m_node, 0, 1);
    755760        // Don't process subtrees for embedded objects. If the text there is required,
  • trunk/Tools/ChangeLog

    r286041 r286050  
     12021-11-19  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][a11y] Add implementation of hyperlink interface when building with ATSPI
     4        https://bugs.webkit.org/show_bug.cgi?id=232707
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Add unit tests to check hyperlink interface and implement AccessibilityUIElement::url() in WTR.
     9
     10        * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
     11        (testTextReplacedObjects):
     12        (testHyperlinkBasic):
     13        (beforeAll):
     14        * WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
     15        (WTR::AccessibilityUIElement::url):
     16
    1172021-11-18  Alex Christensen  <achristensen@webkit.org>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp

    r285997 r286050  
    15341534        "  <body>"
    15351535        "    <p>This is <button>button1</button> and <button>button2</button> in paragraph</p>"
     1536        "    <p>This is <a href='#'>link1</a> and <a href='#'>link2</a> in paragraph</p>"
    15361537        "  </body>"
    15371538        "</html>",
     
    15441545    auto documentWeb = test->findDocumentWeb(testApp.get());
    15451546    g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get()));
    1546     g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 1);
     1547    g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 2);
    15471548
    15481549    auto p = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr));
     
    16121613    g_assert_cmpint(startOffset, ==, 15);
    16131614    g_assert_cmpint(endOffset, ==, 28);
     1615
     1616    // Links are also replaced elements.
     1617    p = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 1, nullptr));
     1618    g_assert_true(ATSPI_IS_TEXT(p.get()));
     1619    g_assert_cmpint(atspi_text_get_character_count(ATSPI_TEXT(p.get()), nullptr), ==, 28);
     1620    text.reset(atspi_text_get_text(ATSPI_TEXT(p.get()), 0, -1, nullptr));
     1621    g_assert_cmpstr(text.get(), ==, "This is \357\277\274 and \357\277\274 in paragraph");
     1622    g_assert_cmpint(atspi_accessible_get_child_count(p.get(), nullptr), ==, 2);
     1623
     1624    auto link1 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 0, nullptr));
     1625    g_assert_true(ATSPI_IS_TEXT(link1.get()));
     1626    text.reset(atspi_text_get_text(ATSPI_TEXT(link1.get()), 0, -1, nullptr));
     1627    g_assert_cmpstr(text.get(), ==, "link1");
     1628
     1629    auto link2 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 1, nullptr));
     1630    g_assert_true(ATSPI_IS_TEXT(link2.get()));
     1631    text.reset(atspi_text_get_text(ATSPI_TEXT(link2.get()), 0, -1, nullptr));
     1632    g_assert_cmpstr(text.get(), ==, "link2");
    16141633#endif
    16151634}
     
    16661685}
    16671686
     1687static void testHyperlinkBasic(AccessibilityTest* test, gconstpointer)
     1688{
     1689    test->showInWindow(800, 600);
     1690    test->loadHtml(
     1691        "<html>"
     1692        "  <body>"
     1693        "    <a href='https://www.webkitgtk.org'>WebKitGTK</a>"
     1694        "    <div role='link'>Link</div>"
     1695        "    <p>This is <button>button1</button> and <button>button2</button> in a paragraph</p>"
     1696        "    <p>This is <a href='https://www.webkitgtk.org'>link1</a> and <a href='https://www.gnome.org'>link2</a> in paragraph</p>"
     1697        "  </body>"
     1698        "</html>",
     1699        nullptr);
     1700    test->waitUntilLoadFinished();
     1701
     1702    auto testApp = test->findTestApplication();
     1703    g_assert_true(ATSPI_IS_ACCESSIBLE(testApp.get()));
     1704
     1705    auto documentWeb = test->findDocumentWeb(testApp.get());
     1706    g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get()));
     1707    g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 4);
     1708
     1709    auto section = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr));
     1710    g_assert_true(ATSPI_IS_ACCESSIBLE(section.get()));
     1711    g_assert_cmpint(atspi_accessible_get_role(section.get(), nullptr), ==, ATSPI_ROLE_SECTION);
     1712    g_assert_cmpint(atspi_accessible_get_child_count(section.get(), nullptr), ==, 1);
     1713
     1714    auto a = adoptGRef(atspi_accessible_get_child_at_index(section.get(), 0, nullptr));
     1715    g_assert_true(ATSPI_IS_ACCESSIBLE(a.get()));
     1716    g_assert_cmpint(atspi_accessible_get_role(a.get(), nullptr), ==, ATSPI_ROLE_LINK);
     1717    auto link = adoptGRef(atspi_accessible_get_hyperlink(a.get()));
     1718    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1719    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1720    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1721    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 0);
     1722#if USE(ATSPI)
     1723    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1724#else
     1725    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 0);
     1726#endif
     1727    GUniquePtr<char> uri(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1728    g_assert_cmpstr(uri.get(), ==, "https://www.webkitgtk.org/");
     1729    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == a.get());
     1730
     1731    auto div = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 1, nullptr));
     1732    g_assert_true(ATSPI_IS_ACCESSIBLE(div.get()));
     1733    g_assert_cmpint(atspi_accessible_get_role(div.get(), nullptr), ==, ATSPI_ROLE_LINK);
     1734    link = adoptGRef(atspi_accessible_get_hyperlink(div.get()));
     1735    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1736    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1737    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1738#if USE(ATSPI)
     1739    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 0);
     1740    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1741#else
     1742    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 10);
     1743    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 14);
     1744#endif
     1745    uri.reset(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1746    g_assert_cmpstr(uri.get(), ==, "");
     1747    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == div.get());
     1748
     1749    auto p = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 2, nullptr));
     1750    g_assert_true(ATSPI_IS_ACCESSIBLE(p.get()));
     1751    g_assert_cmpint(atspi_accessible_get_child_count(p.get(), nullptr), ==, 2);
     1752    auto button1 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 0, nullptr));
     1753    g_assert_true(ATSPI_IS_ACCESSIBLE(button1.get()));
     1754    link = adoptGRef(atspi_accessible_get_hyperlink(button1.get()));
     1755    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1756    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1757    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1758    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 8);
     1759#if USE(ATSPI)
     1760    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 9);
     1761#else
     1762    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 16);
     1763#endif
     1764    uri.reset(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1765    g_assert_cmpstr(uri.get(), ==, "");
     1766    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == button1.get());
     1767    auto button2 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 1, nullptr));
     1768    g_assert_true(ATSPI_IS_ACCESSIBLE(button2.get()));
     1769    link = adoptGRef(atspi_accessible_get_hyperlink(button2.get()));
     1770    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1771    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1772    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1773#if USE(ATSPI)
     1774    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 14);
     1775    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 15);
     1776#else
     1777    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 21);
     1778    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 29);
     1779#endif
     1780    uri.reset(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1781    g_assert_cmpstr(uri.get(), ==, "");
     1782    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == button2.get());
     1783
     1784    p = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 3, nullptr));
     1785    g_assert_true(ATSPI_IS_ACCESSIBLE(p.get()));
     1786    g_assert_cmpint(atspi_accessible_get_child_count(p.get(), nullptr), ==, 2);
     1787    auto link1 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 0, nullptr));
     1788    g_assert_true(ATSPI_IS_ACCESSIBLE(link1.get()));
     1789    link = adoptGRef(atspi_accessible_get_hyperlink(link1.get()));
     1790    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1791    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1792    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1793    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 8);
     1794#if USE(ATSPI)
     1795    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 9);
     1796#else
     1797    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 13);
     1798#endif
     1799    uri.reset(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1800    g_assert_cmpstr(uri.get(), ==, "https://www.webkitgtk.org/");
     1801    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == link1.get());
     1802    auto link2 = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 1, nullptr));
     1803    g_assert_true(ATSPI_IS_ACCESSIBLE(link2.get()));
     1804    link = adoptGRef(atspi_accessible_get_hyperlink(link2.get()));
     1805    g_assert_true(ATSPI_IS_HYPERLINK(link.get()));
     1806    g_assert_cmpint(atspi_hyperlink_get_n_anchors(ATSPI_HYPERLINK(link.get()), nullptr), ==, 1);
     1807    g_assert_true(atspi_hyperlink_is_valid(ATSPI_HYPERLINK(link.get()), nullptr));
     1808#if USE(ATSPI)
     1809    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 14);
     1810    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 15);
     1811#else
     1812    g_assert_cmpint(atspi_hyperlink_get_start_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 18);
     1813    g_assert_cmpint(atspi_hyperlink_get_end_index(ATSPI_HYPERLINK(link.get()), nullptr), ==, 23);
     1814#endif
     1815    uri.reset(atspi_hyperlink_get_uri(ATSPI_HYPERLINK(link.get()), 0, nullptr));
     1816    g_assert_cmpstr(uri.get(), ==, "https://www.gnome.org/");
     1817    g_assert_true(atspi_hyperlink_get_object(ATSPI_HYPERLINK(link.get()), 0, nullptr) == link2.get());
     1818}
     1819
    16681820void beforeAll()
    16691821{
     
    16871839    AccessibilityTest::add("WebKitAccessibility", "text/replaced-objects", testTextReplacedObjects);
    16881840    AccessibilityTest::add("WebKitAccessibility", "value/basic", testValueBasic);
     1841    AccessibilityTest::add("WebKitAccessibility", "hyperlink/basic", testHyperlinkBasic);
    16891842}
    16901843
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp

    r285997 r286050  
    3535#include <WebCore/AccessibilityObjectAtspi.h>
    3636#include <WebKit/WKBundleFrame.h>
     37#include <wtf/URL.h>
    3738#include <wtf/text/CString.h>
    3839#include <wtf/text/StringBuilder.h>
     
    11291130JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
    11301131{
    1131     return JSStringCreateWithCharacters(0, 0);
     1132    if (!m_element->interfaces().contains(WebCore::AccessibilityObjectAtspi::Interface::Hyperlink))
     1133        return JSStringCreateWithCharacters(0, 0);
     1134
     1135    m_element->updateBackingStore();
     1136    auto axURL = m_element->url();
     1137    if (axURL.isNull())
     1138        return JSStringCreateWithUTF8CString("AXURL: (null)");
     1139
     1140    if (axURL.isLocalFile()) {
     1141        // Do not expose absolute paths.
     1142        auto path = axURL.fileSystemPath();
     1143        auto index = path.find("LayoutTests");
     1144        if (index != notFound)
     1145            path = path.substring(index);
     1146        return OpaqueJSString::tryCreate(makeString("AXURL: ", path)).leakRef();
     1147    }
     1148
     1149    return OpaqueJSString::tryCreate(makeString("AXURL: ", axURL.string())).leakRef();
    11321150}
    11331151
Note: See TracChangeset for help on using the changeset viewer.