commit 3398ca7b86c8d28ba1b62277b7d81e91df2f4143
parent a40ec1a2eabf14d02bf1c9a06b91670223b98a34
Author: Eitan Isaacson <eitan@monotonous.org>
Date: Fri, 21 Nov 2025 05:05:04 +0000
Bug 2001492 - Add pref to control details relationship on anchored elements. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D273522
Diffstat:
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp
@@ -76,6 +76,7 @@
#include "mozilla/PresShell.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ScrollContainerFrame.h"
+#include "mozilla/StaticPrefs_accessibility.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_ui.h"
#include "mozilla/dom/Element.h"
@@ -2021,6 +2022,9 @@ LocalAccessible* LocalAccessible::GetPopoverTargetDetailsRelation() const {
LocalAccessible* LocalAccessible::GetAnchorPositionTargetDetailsRelation()
const {
+ if (!StaticPrefs::accessibility_anchorPositionedAsDetails_enabled()) {
+ return nullptr;
+ }
nsIFrame* positionedFrame = nsCoreUtils::GetPositionedFrameForAnchor(
mDoc->PresShellPtr(), GetFrame());
if (!positionedFrame) {
@@ -2436,7 +2440,8 @@ Relation LocalAccessible::RelationByType(RelationType aType) const {
// Check early if the accessible is a tooltip. If so, it can never be a
// valid target for an anchor's details relation.
- if (Role() != roles::TOOLTIP) {
+ if (StaticPrefs::accessibility_anchorPositionedAsDetails_enabled() &&
+ Role() != roles::TOOLTIP) {
if (const nsIFrame* anchorFrame =
nsCoreUtils::GetAnchorForPositionedFrame(mDoc->PresShellPtr(),
GetFrame())) {
diff --git a/accessible/tests/browser/relations/browser.toml b/accessible/tests/browser/relations/browser.toml
@@ -12,7 +12,8 @@ prefs = [
# Required for the eval in invokeContentTask in shared-head.js
"security.allow_eval_with_system_principal=true",
# Required for CSS positioning
- "layout.css.anchor-positioning.enabled=true"
+ "layout.css.anchor-positioning.enabled=true",
+ "accessibility.anchorPositionedAsDetails.enabled=true",
]
["browser_anchor_positioning.js"]
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -263,6 +263,13 @@
value: true
mirror: always
+# Whether to enable automatic details relationships for
+# anchor positioned content.
+- name: accessibility.anchorPositionedAsDetails.enabled
+ type: bool
+ value: false
+ mirror: always
+
# Whether to enable all accessibility cache domains on startup.
# * false: enable domains as needed
# * true: enable all domains regardless of need (cache everything)