Skip to content

AX: An anchor element that has a click handler but no href should still be considered a link - #67035

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
twilco:eng/AX-An-anchor-element-that-has-a-click-handler-but-no-href-should-still-be-considered-a-link
Jun 12, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
twilco:eng/AX-An-anchor-element-that-has-a-click-handler-but-no-href-should-still-be-considered-a-link

Conversation

@twilco

@twilco twilco commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

2387eef

AX: An anchor element that has a click handler but no href should still be considered a link
https://bugs.webkit.org/show_bug.cgi?id=316929
rdar://179398579

Reviewed by Chris Fleizach.

As a markup repair, Chrome and Firefox expose an <a> with a click handler but
no href as a link. WebKit did not: Element::isLink() is only true for anchors
with an href, so a hrefless anchor with an onclick handler fell through role
determination to the generic Inline role and was ignored by the accessibility tree.

With this commit, we implement this markup repair.

* LayoutTests/accessibility/anchor-with-click-handler-is-link-expected.txt: Added.
* LayoutTests/accessibility/anchor-with-click-handler-is-link.html: Added.
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::isClickEvent):
(WebCore::AXObjectCache::onEventListenerAdded):
(WebCore::AXObjectCache::onEventListenerRemoved):
(WebCore::AXObjectCache::handleClickHandlerChanged):
(WebCore::AXObjectCache::handleAttributeChange):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const):

Canonical link: https://commits.webkit.org/315102@main

db647b7

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ✅ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ✅ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@twilco twilco self-assigned this Jun 12, 2026
@twilco twilco added the Accessibility For bugs related to accessibility. label Jun 12, 2026
@twilco twilco added the merge-queue Applied to send a pull request to merge-queue label Jun 12, 2026
…ll be considered a link

https://bugs.webkit.org/show_bug.cgi?id=316929
rdar://179398579

Reviewed by Chris Fleizach.

As a markup repair, Chrome and Firefox expose an <a> with a click handler but
no href as a link. WebKit did not: Element::isLink() is only true for anchors
with an href, so a hrefless anchor with an onclick handler fell through role
determination to the generic Inline role and was ignored by the accessibility tree.

With this commit, we implement this markup repair.

* LayoutTests/accessibility/anchor-with-click-handler-is-link-expected.txt: Added.
* LayoutTests/accessibility/anchor-with-click-handler-is-link.html: Added.
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::isClickEvent):
(WebCore::AXObjectCache::onEventListenerAdded):
(WebCore::AXObjectCache::onEventListenerRemoved):
(WebCore::AXObjectCache::handleClickHandlerChanged):
(WebCore::AXObjectCache::handleAttributeChange):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const):

Canonical link: https://commits.webkit.org/315102@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/AX-An-anchor-element-that-has-a-click-handler-but-no-href-should-still-be-considered-a-link branch from db647b7 to 2387eef Compare June 12, 2026 15:33
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 315102@main (2387eef): https://commits.webkit.org/315102@main

Reviewed commits have been landed. Closing PR #67035 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 2387eef into WebKit:main Jun 12, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accessibility For bugs related to accessibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants