Skip to content

Commit

Permalink
AX: AXIsActiveDescendantOfFocusedContainer is exposed by the Accessib…
Browse files Browse the repository at this point in the history
…ilityObjectWrapperMac but not used

https://bugs.webkit.org/show_bug.cgi?id=244423
rdar://problem/99216969

Reviewed by Chris Fleizach.

Un-exposing this from the wrapper allows us to remove AXPropertyName::IsActiveDescendantOfFocusedContainer.
The function definition is now also moved from AXCoreObject to AccessibilityObject.

* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::selectedListItem):
* Source/WebCore/accessibility/AccessibilityObject.h:
* Source/WebCore/accessibility/AccessibilityObjectInterface.h:
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::ariaSelectedRows):
(WebCore::AccessibilityRenderObject::ariaListboxSelectedChildren):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeProperties):
(WebCore::AXIsolatedObject::selectedListItem): Deleted.
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp
Use the AccessibilityObject-cast object since isActiveDescendantOfFocusedContainer
is no longer a core method (because Mac doesn't need it, and ATSPI
doesn't seem to have an isolated object implementation).

Canonical link: https://commits.webkit.org/253874@main
  • Loading branch information
twilco committed Aug 28, 2022
1 parent 3f8075f commit 94ae1c1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
13 changes: 10 additions & 3 deletions Source/WebCore/accessibility/AccessibilityObject.cpp
Expand Up @@ -3961,11 +3961,18 @@ bool AccessibilityObject::isContainedByPasswordField() const
return is<HTMLInputElement>(element) && downcast<HTMLInputElement>(*element).isPasswordField();
}

AXCoreObject* AccessibilityObject::selectedListItem()
AccessibilityObject* AccessibilityObject::selectedListItem()
{
for (const auto& child : children()) {
if (child->isListItem() && (child->isSelected() || child->isActiveDescendantOfFocusedContainer()))
return child.get();
if (!child->isListItem())
continue;

auto* axObject = dynamicDowncast<AccessibilityObject>(child.get());
if (!axObject)
continue;

if (axObject->isSelected() || axObject->isActiveDescendantOfFocusedContainer())
return axObject;
}

return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/accessibility/AccessibilityObject.h
Expand Up @@ -299,15 +299,15 @@ class AccessibilityObject : public AXCoreObject, public CanMakeWeakPtr<Accessibi
float stepValueForRange() const override { return 0.0f; }
AXCoreObject* selectedRadioButton() override { return nullptr; }
AXCoreObject* selectedTabItem() override { return nullptr; }
AXCoreObject* selectedListItem() override;
AccessibilityObject* selectedListItem();
int layoutCount() const override { return 0; }
double loadingProgress() const override { return 0; }
WEBCORE_EXPORT static bool isARIAControl(AccessibilityRole);
bool supportsCheckedState() const override;

bool supportsARIARoleDescription() const;
bool supportsARIAOwns() const override { return false; }
bool isActiveDescendantOfFocusedContainer() const override;
bool isActiveDescendantOfFocusedContainer() const;

bool hasPopup() const override { return false; }
String popupValue() const override;
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/accessibility/AccessibilityObjectInterface.h
Expand Up @@ -1068,7 +1068,6 @@ class AXCoreObject : public ThreadSafeRefCounted<AXCoreObject> {
virtual float stepValueForRange() const = 0;
virtual AXCoreObject* selectedRadioButton() = 0;
virtual AXCoreObject* selectedTabItem() = 0;
virtual AXCoreObject* selectedListItem() = 0;
virtual int layoutCount() const = 0;
virtual double loadingProgress() const = 0;
virtual String brailleLabel() const = 0;
Expand All @@ -1078,7 +1077,6 @@ class AXCoreObject : public ThreadSafeRefCounted<AXCoreObject> {
virtual String extendedDescription() const = 0;

virtual bool supportsARIAOwns() const = 0;
virtual bool isActiveDescendantOfFocusedContainer() const = 0;

// Retrieval of related objects.
AccessibilityChildrenVector activeDescendantOfObjects() const { return relatedObjects(AXRelationType::ActiveDescendantOf); }
Expand Down
17 changes: 12 additions & 5 deletions Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Expand Up @@ -3272,7 +3272,11 @@ void AccessibilityRenderObject::ariaSelectedRows(AccessibilityChildrenVector& re

// Get all the rows.
auto rowsIteration = [&](const auto& rows) {
for (auto& row : rows) {
for (auto& rowCoreObject : rows) {
auto* row = dynamicDowncast<AccessibilityObject>(rowCoreObject.get());
if (!row)
continue;

if (row->isSelected() || row->isActiveDescendantOfFocusedContainer()) {
result.append(row);
if (!isMulti)
Expand All @@ -3297,10 +3301,13 @@ void AccessibilityRenderObject::ariaListboxSelectedChildren(AccessibilityChildre

for (const auto& child : children()) {
// Every child should have aria-role option, and if so, check for selected attribute/state.
if (child->ariaRoleAttribute() == AccessibilityRole::ListBoxOption && (child->isSelected() || child->isActiveDescendantOfFocusedContainer())) {
result.append(child);
if (!isMulti)
return;
if (child->ariaRoleAttribute() == AccessibilityRole::ListBoxOption) {
auto* childAxObject = dynamicDowncast<AccessibilityObject>(child.get());
if (childAxObject->isSelected() || childAxObject->isActiveDescendantOfFocusedContainer()) {
result.append(childAxObject);
if (!isMulti)
return;
}
}
}
}
Expand Down
Expand Up @@ -773,7 +773,7 @@ uint64_t AccessibilityObjectAtspi::state() const

if (m_coreObject->isFocused() && !m_coreObject->activeDescendant())
addState(Atspi::State::Focused);
else if (m_coreObject->isActiveDescendantOfFocusedContainer()) {
else if (liveObject->isActiveDescendantOfFocusedContainer()) {
addState(Atspi::State::Focusable);
addState(Atspi::State::Focused);
}
Expand Down
Expand Up @@ -86,7 +86,6 @@ void AXIsolatedObject::initializeProperties(Ref<AXCoreObject> coreObject, IsRoot
setProperty(AXPropertyName::AncestorFlags, object.computeAncestorFlagsWithTraversal());

setProperty(AXPropertyName::HasARIAValueNow, object.hasARIAValueNow());
setProperty(AXPropertyName::IsActiveDescendantOfFocusedContainer, object.isActiveDescendantOfFocusedContainer());
setProperty(AXPropertyName::IsAttachment, object.isAttachment());
setProperty(AXPropertyName::IsBusy, object.isBusy());
setProperty(AXPropertyName::IsButton, object.isButton());
Expand Down Expand Up @@ -1855,12 +1854,6 @@ float AXIsolatedObject::stepValueForRange() const
return 0;
}

AXCoreObject* AXIsolatedObject::selectedListItem()
{
ASSERT_NOT_REACHED();
return nullptr;
}

bool AXIsolatedObject::hasDatalist() const
{
ASSERT_NOT_REACHED();
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Expand Up @@ -229,7 +229,6 @@ class AXIsolatedObject final : public AXCoreObject {
int layoutCount() const override { return intAttributeValue(AXPropertyName::LayoutCount); }
double loadingProgress() const override { return tree()->loadingProgress(); }
bool supportsARIAOwns() const override { return boolAttributeValue(AXPropertyName::SupportsARIAOwns); }
bool isActiveDescendantOfFocusedContainer() const override { return boolAttributeValue(AXPropertyName::IsActiveDescendantOfFocusedContainer); }
bool hasPopup() const override { return boolAttributeValue(AXPropertyName::HasPopup); }
String popupValue() const override { return stringAttributeValue(AXPropertyName::PopupValue); }
bool pressedIsPresent() const override { return boolAttributeValue(AXPropertyName::PressedIsPresent); }
Expand Down Expand Up @@ -542,7 +541,6 @@ class AXIsolatedObject final : public AXCoreObject {
AccessibilityObjectInclusion defaultObjectInclusion() const override;
bool accessibilityIsIgnoredByDefault() const override;
float stepValueForRange() const override;
AXCoreObject* selectedListItem() override;

AccessibilityChildrenVector relatedObjects(AXRelationType) const override;

Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
Expand Up @@ -128,7 +128,6 @@ enum class AXPropertyName : uint16_t {
IncrementButton,
InnerHTML,
InvalidStatus,
IsActiveDescendantOfFocusedContainer,
IsAnonymousMathOperator,
IsGrabbed,
IsARIATreeGridRow,
Expand Down
Expand Up @@ -2606,9 +2606,6 @@ - (id)accessibilityAttributeValue:(NSString*)attributeName
if ([attributeName isEqualToString:@"AXReadOnlyValue"])
return backingObject->readOnlyValue();

if ([attributeName isEqualToString:@"AXIsActiveDescendantOfFocusedContainer"])
return [NSNumber numberWithBool:backingObject->isActiveDescendantOfFocusedContainer()];

if ([attributeName isEqualToString:AXHasDocumentRoleAncestorAttribute])
return [NSNumber numberWithBool:backingObject->hasDocumentRoleAncestor()];

Expand Down

0 comments on commit 94ae1c1

Please sign in to comment.