Skip to content
Permalink
Browse files
AX: Make AccessibilityObjectInterface::contents return-by-value inste…
…ad of return-by-out-parameter

https://bugs.webkit.org/show_bug.cgi?id=231289

Patch by Tyler Wilcock <tyler_w@apple.com> on 2021-10-06
Reviewed by Darin Adler.

Make AccessibilityObjectInterface::contents return-by-value instead of
return-by-out-parameter as this is more ergonomic.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::contents):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::contents):
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

Canonical link: https://commits.webkit.org/242618@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
twilco authored and webkit-commit-queue committed Oct 6, 2021
1 parent d2ecbfe commit 102333cae39a453014b55f762d66e091f59c6a1c
Showing 7 changed files with 46 additions and 17 deletions.
@@ -1,3 +1,24 @@
2021-10-06 Tyler Wilcock <tyler_w@apple.com>

AX: Make AccessibilityObjectInterface::contents return-by-value instead of return-by-out-parameter
https://bugs.webkit.org/show_bug.cgi?id=231289

Reviewed by Darin Adler.

Make AccessibilityObjectInterface::contents return-by-value instead of
return-by-out-parameter as this is more ergonomic.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::contents):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::contents):
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

2021-10-06 Sihui Liu <sihui_liu@apple.com>

Add support for FileSystemSyncAccessHandle
@@ -3150,18 +3150,24 @@ IntRect AccessibilityObject::scrollVisibleContentRect() const
return IntRect();
}

void AccessibilityObject::contents(AccessibilityChildrenVector& result)
AXCoreObject::AccessibilityChildrenVector AccessibilityObject::contents()
{
if (isTabList())
tabChildren(result);
else if (isScrollView()) {
if (isTabList()) {
AccessibilityChildrenVector tabs;
tabChildren(tabs);
return tabs;
}

if (isScrollView()) {
// A scroll view's contents are everything except the scroll bars.
AccessibilityChildrenVector nonScrollbarChildren;
for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling()) {
for (auto* child = firstChild(); child; child = child->nextSibling()) {
if (child && !child->isScrollbar())
result.append(child);
nonScrollbarChildren.append(child);
}
return nonScrollbarChildren;
}
return { };
}

IntSize AccessibilityObject::scrollContentsSize() const
@@ -640,7 +640,7 @@ class AccessibilityObject : public AXCoreObject {

bool scrollByPage(ScrollByPageDirection) const override;
IntPoint scrollPosition() const override;
void contents(AccessibilityChildrenVector&) override;
AccessibilityChildrenVector contents() override;
IntSize scrollContentsSize() const override;
IntRect scrollVisibleContentRect() const override;
void scrollToMakeVisible(const ScrollRectToVisibleOptions&) const override;
@@ -1374,7 +1374,7 @@ class AXCoreObject : public ThreadSafeRefCounted<AXCoreObject> {
enum class ScrollByPageDirection { Up, Down, Left, Right };
virtual bool scrollByPage(ScrollByPageDirection) const = 0;
virtual IntPoint scrollPosition() const = 0;
virtual void contents(AccessibilityChildrenVector&) = 0;
virtual AccessibilityChildrenVector contents() = 0;
virtual IntSize scrollContentsSize() const = 0;
virtual IntRect scrollVisibleContentRect() const = 0;
virtual void scrollToMakeVisible(const ScrollRectToVisibleOptions&) const = 0;
@@ -298,9 +298,7 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
if (object.isImage())
setProperty(AXPropertyName::EmbeddedImageDescription, object.embeddedImageDescription().isolatedCopy());

AccessibilityChildrenVector contents;
object.contents(contents);
setObjectVectorProperty(AXPropertyName::Contents, contents);
setObjectVectorProperty(AXPropertyName::Contents, object.contents());

AccessibilityChildrenVector visibleChildren;
object.visibleChildren(visibleChildren);
@@ -560,6 +558,13 @@ void AXIsolatedObject::setSelectedChildren(const AccessibilityChildrenVector& se
});
}

AXCoreObject::AccessibilityChildrenVector AXIsolatedObject::contents()
{
AccessibilityChildrenVector result;
fillChildrenVectorForProperty(AXPropertyName::Contents, result);
return result;
}

bool AXIsolatedObject::isDetachedFromParent()
{
if (parent() != InvalidAXID)
@@ -348,7 +348,7 @@ class AXIsolatedObject final : public AXCoreObject {
void setSelectedChildren(const AccessibilityChildrenVector&) override;
void visibleChildren(AccessibilityChildrenVector& children) override { fillChildrenVectorForProperty(AXPropertyName::VisibleChildren, children); }
void tabChildren(AccessibilityChildrenVector& children) override { fillChildrenVectorForProperty(AXPropertyName::TabChildren, children); }
void contents(AccessibilityChildrenVector& children) override { fillChildrenVectorForProperty(AXPropertyName::Contents, children); }
AccessibilityChildrenVector contents() override;
bool hasARIAValueNow() const override { return boolAttributeValue(AXPropertyName::HasARIAValueNow); }
String tagName() const override { return stringAttributeValue(AXPropertyName::TagName); }
const AccessibilityChildrenVector& children(bool updateChildrenIfNeeded = true) override;
@@ -2380,11 +2380,8 @@ - (id)accessibilityAttributeValue:(NSString*)attributeName
}
}

if ([attributeName isEqualToString:NSAccessibilityContentsAttribute]) {
AccessibilityObject::AccessibilityChildrenVector contents;
backingObject->contents(contents);
return convertToNSArray(contents);
}
if ([attributeName isEqualToString:NSAccessibilityContentsAttribute])
return convertToNSArray(backingObject->contents());

if (backingObject->isTable() && backingObject->isExposable()) {
if ([attributeName isEqualToString:NSAccessibilityRowsAttribute])

0 comments on commit 102333c

Please sign in to comment.