WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
272840
AX: AccessibilityMenuListOption should subclass AccessibilityNodeObject
https://bugs.webkit.org/show_bug.cgi?id=272840
Summary
AX: AccessibilityMenuListOption should subclass AccessibilityNodeObject
Tyler Wilcock
Reported
2024-04-17 11:34:29 PDT
It is a node object, and the fact that it doesn't subclass AccessibilityNodeObject means it's missing important overrides like accessibilityText.
Attachments
Patch
(8.65 KB, patch)
2024-04-17 11:37 PDT
,
Tyler Wilcock
no flags
Details
Formatted Diff
Diff
Patch
(8.65 KB, patch)
2024-04-17 14:28 PDT
,
Tyler Wilcock
no flags
Details
Formatted Diff
Diff
Patch
(8.65 KB, patch)
2024-04-17 19:13 PDT
,
Tyler Wilcock
cfleizach
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-04-17 11:34:42 PDT
<
rdar://problem/126634909
>
Tyler Wilcock
Comment 2
2024-04-17 11:37:52 PDT
Created
attachment 470964
[details]
Patch
Tyler Wilcock
Comment 3
2024-04-17 14:28:51 PDT
Created
attachment 470971
[details]
Patch
Andres Gonzalez
Comment 4
2024-04-17 18:38:11 PDT
(In reply to Tyler Wilcock from
comment #3
)
> Created
attachment 470971
[details]
> Patch
diff --git a/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp b/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp index e76d336b9639..8c752ba71482 100644 --- a/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp +++ b/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp @@ -38,7 +38,7 @@ namespace WebCore { using namespace HTMLNames; AccessibilityMenuListOption::AccessibilityMenuListOption(HTMLOptionElement& element) - : m_element(element) + : AccessibilityNodeObject(&element) , m_parent(nullptr) { } @@ -48,28 +48,30 @@ Ref<AccessibilityMenuListOption> AccessibilityMenuListOption::create(HTMLOptionE return adoptRef(*new AccessibilityMenuListOption(element)); } -Element* AccessibilityMenuListOption::actionElement() const +HTMLOptionElement* AccessibilityMenuListOption::optionElement() const { - return m_element.get(); + return downcast<HTMLOptionElement>(node()); } -Node* AccessibilityMenuListOption::node() const +Element* AccessibilityMenuListOption::actionElement() const { - return m_element.get(); + return downcast<Element>(node()); } - + bool AccessibilityMenuListOption::isEnabled() const { - return m_element && !m_element->ownElementDisabled(); + auto* optionElement = this->optionElement(); + return optionElement && !optionElement->ownElementDisabled(); } bool AccessibilityMenuListOption::isVisible() const { - if (!m_element) + WeakPtr optionElement = this->optionElement(); + if (!optionElement) return false; // In a single-option select with the popup collapsed, only the selected item is considered visible. - auto ownerSelectElement = m_element->document().axObjectCache()->getOrCreate(m_element->ownerSelectElement()); + auto ownerSelectElement = optionElement->document().axObjectCache()->getOrCreate(optionElement->ownerSelectElement()); AG: auto* ? return ownerSelectElement && (!ownerSelectElement->isOffScreen() || isSelected()); } @@ -81,7 +83,8 @@ bool AccessibilityMenuListOption::isOffScreen() const bool AccessibilityMenuListOption::isSelected() const { - return m_element && m_element->selected(); + auto* optionElement = this->optionElement(); + return optionElement && optionElement->selected(); } void AccessibilityMenuListOption::setSelected(bool selected) @@ -89,7 +92,8 @@ void AccessibilityMenuListOption::setSelected(bool selected) if (!canSetSelectedAttribute()) return; - m_element->setSelected(selected); + if (auto* optionElement = this->optionElement()) + optionElement->setSelected(selected); } bool AccessibilityMenuListOption::canSetSelectedAttribute() const @@ -104,23 +108,22 @@ bool AccessibilityMenuListOption::computeAccessibilityIsIgnored() const LayoutRect AccessibilityMenuListOption::elementRect() const { - AccessibilityObject* parent = parentObject(); + RefPtr parent = parentObject(); // Our parent should've been set to be a menu-list popup before this method is called. ASSERT(parent && parent->isMenuListPopup()); if (!parent) return boundingBoxRect(); - AccessibilityObject* grandparent = parent->parentObject(); - if (!grandparent) - return boundingBoxRect(); - ASSERT(grandparent->isMenuList()); + RefPtr grandparent = parent->parentObject(); + ASSERT(!grandparent || grandparent->isMenuList()); - return grandparent->elementRect(); + return grandparent ? grandparent->elementRect() : boundingBoxRect(); } String AccessibilityMenuListOption::stringValue() const { - return m_element ? m_element->label() : String(); + auto* optionElement = this->optionElement(); + return optionElement ? optionElement->label() : String(); } } // namespace WebCore
Tyler Wilcock
Comment 5
2024-04-17 19:13:26 PDT
Created
attachment 470976
[details]
Patch
EWS
Comment 6
2024-04-18 09:27:18 PDT
Committed
277680@main
(c87f99943fbe): <
https://commits.webkit.org/277680@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 470976
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug