Skip to content

Commit

Permalink
AX: Pre-size AXIsolatedObject::m_propertyMap to avoid unnecessary Has…
Browse files Browse the repository at this point in the history
…hTable reallocations

https://bugs.webkit.org/show_bug.cgi?id=249873
rdar://problem/103687278

Reviewed by Chris Fleizach.

Use reserveInitialCapacity to give AXIsolatedObject::m_propertyMap an
initial size to help avoid unnecessary HashTable reallocations. These
HashTable reallocations showed up in `sample`s when using VoiceOver on
popular websites.

This patch also removes AXPropertyName::TagName since it's not used on
the Mac platform for any AX-client facing functionality (and Mac is the
only platform that enables isolated tree mode).

* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::AXIsolatedObject):
(WebCore::AXIsolatedObject::initializeProperties):
(WebCore::AXIsolatedObject::tagName const):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:

Canonical link: https://commits.webkit.org/258328@main
  • Loading branch information
twilco committed Dec 25, 2022
1 parent af7823b commit 98a2838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Expand Up @@ -50,6 +50,12 @@ AXIsolatedObject::AXIsolatedObject(const Ref<AXCoreObject>& axObject, AXIsolated
m_parentID = axParent ? axParent->objectID() : AXID();

auto isRoot = !axParent && axObject->isScrollView() ? IsRoot::Yes : IsRoot::No;

// Every object will have at least this many properties. We can shrink this number
// to some estimated average once we implement sparse property storage (i.e. only storing
// a property if it's not the default value for its type).
m_propertyMap.reserveInitialCapacity(126);

initializeProperties(axObject, isRoot);
}

Expand Down Expand Up @@ -178,7 +184,6 @@ void AXIsolatedObject::initializeProperties(const Ref<AXCoreObject>& coreObject,
setProperty(AXPropertyName::Orientation, static_cast<int>(object.orientation()));
setProperty(AXPropertyName::HierarchicalLevel, object.hierarchicalLevel());
setProperty(AXPropertyName::Language, object.language().isolatedCopy());
setProperty(AXPropertyName::TagName, object.tagName().string().isolatedCopy());
setProperty(AXPropertyName::SupportsLiveRegion, object.supportsLiveRegion());
setProperty(AXPropertyName::IsInsideLiveRegion, object.isInsideLiveRegion());
setProperty(AXPropertyName::LiveRegionStatus, object.liveRegionStatus().isolatedCopy());
Expand Down Expand Up @@ -1171,6 +1176,12 @@ bool AXIsolatedObject::performDefaultAction()
return false;
}

AtomString AXIsolatedObject::tagName() const
{
ASSERT_NOT_REACHED();
return AtomString();
}

bool AXIsolatedObject::isAccessibilityNodeObject() const
{
ASSERT_NOT_REACHED();
Expand Down
Expand Up @@ -325,7 +325,7 @@ class AXIsolatedObject final : public AXCoreObject {
void tabChildren(AccessibilityChildrenVector& children) override { fillChildrenVectorForProperty(AXPropertyName::TabChildren, children); }
AccessibilityChildrenVector contents() override;
bool hasARIAValueNow() const override { return boolAttributeValue(AXPropertyName::HasARIAValueNow); }
AtomString tagName() const override { return AtomString { stringAttributeValue(AXPropertyName::TagName) }; }
AtomString tagName() const override;
const AccessibilityChildrenVector& children(bool updateChildrenIfNeeded = true) override;
void updateChildrenIfNecessary() override;
bool isDetachedFromParent() override;
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
Expand Up @@ -253,7 +253,6 @@ enum class AXPropertyName : uint16_t {
SupportsSetSize,
TabChildren,
TableLevel,
TagName,
TextLength,
Title,
TitleAttributeValue,
Expand Down

0 comments on commit 98a2838

Please sign in to comment.