Skip to content
Permalink
Browse files
AX: Move handling of AXContents from platform wrapper to AX core
https://bugs.webkit.org/show_bug.cgi?id=231231

Patch by Tyler Wilcock <tyler_w@apple.com> on 2021-10-05
Reviewed by Chris Fleizach.

No changed functionality.

Moved handling of the AXContents (NSAccessibilityContentsAttribute) from the
Mac wrapper accessibilityAttributeValue handler to AXCoreObject::contents.
This makes it possible to share this code across multiple platforms.

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

Canonical link: https://commits.webkit.org/242553@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
twilco authored and webkit-commit-queue committed Oct 6, 2021
1 parent 9af2f40 commit 70b96535bb2f1a7f1c0947dcf353170107df33a1
Showing 8 changed files with 49 additions and 28 deletions.
@@ -1,3 +1,27 @@
2021-10-05 Tyler Wilcock <tyler_w@apple.com>

AX: Move handling of AXContents from platform wrapper to AX core
https://bugs.webkit.org/show_bug.cgi?id=231231

Reviewed by Chris Fleizach.

No changed functionality.

Moved handling of the AXContents (NSAccessibilityContentsAttribute) from the
Mac wrapper accessibilityAttributeValue handler to AXCoreObject::contents.
This makes it possible to share this code across multiple platforms.

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

2021-10-05 John Wilander <wilander@apple.com>

PCM: Allow measurement of links in nested, cross-site iframes
@@ -3149,6 +3149,20 @@ IntRect AccessibilityObject::scrollVisibleContentRect() const

return IntRect();
}

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

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

bool scrollByPage(ScrollByPageDirection) const override;
IntPoint scrollPosition() const override;
void contents(AccessibilityChildrenVector&) override;
IntSize scrollContentsSize() const override;
IntRect scrollVisibleContentRect() const override;
void scrollToMakeVisible(const ScrollRectToVisibleOptions&) const override;
@@ -1374,6 +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 IntSize scrollContentsSize() const = 0;
virtual IntRect scrollVisibleContentRect() const = 0;
virtual void scrollToMakeVisible(const ScrollRectToVisibleOptions&) const = 0;
@@ -298,6 +298,10 @@ 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);

AccessibilityChildrenVector visibleChildren;
object.visibleChildren(visibleChildren);
setObjectVectorProperty(AXPropertyName::VisibleChildren, visibleChildren);
@@ -348,6 +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); }
bool hasARIAValueNow() const override { return boolAttributeValue(AXPropertyName::HasARIAValueNow); }
String tagName() const override { return stringAttributeValue(AXPropertyName::TagName); }
const AccessibilityChildrenVector& children(bool updateChildrenIfNeeded = true) override;
@@ -96,6 +96,7 @@ enum class AXPropertyName : uint16_t {
ColumnIndexRange,
ComputedLabel,
ComputedRoleString,
Contents,
CurrentState,
CurrentValue,
DatetimeAttributeValue,
@@ -2381,34 +2381,9 @@ - (id)accessibilityAttributeValue:(NSString*)attributeName
}

if ([attributeName isEqualToString:NSAccessibilityContentsAttribute]) {
// The contents of a tab list are all the children except the tabs.
if (backingObject->isTabList()) {
auto children = self.childrenVectorArray;
AccessibilityObject::AccessibilityChildrenVector tabs;
backingObject->tabChildren(tabs);
auto tabsChildren = convertToNSArray(tabs);

NSMutableArray *contents = [NSMutableArray array];
for (id childWrapper in children) {
if ([tabsChildren containsObject:childWrapper])
[contents addObject:childWrapper];
}
return contents;
}

if (backingObject->isScrollView()) {
// A scrollView's contents are everything except the scroll bars.
auto children = self.childrenVectorArray;
NSMutableArray *contents = [NSMutableArray array];

for (WebAccessibilityObjectWrapper *childWrapper in children) {
if (auto backingObject = [childWrapper axBackingObject]) {
if (!backingObject->isScrollbar())
[contents addObject:childWrapper];
}
}
return contents;
}
AccessibilityObject::AccessibilityChildrenVector contents;
backingObject->contents(contents);
return convertToNSArray(contents);
}

if (backingObject->isTable() && backingObject->isExposable()) {

0 comments on commit 70b9653

Please sign in to comment.