Skip to content

Commit

Permalink
AX: Cache AccessibilityText eagerly
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265056
rdar://118574320

Reviewed by Chris Fleizach.

We cache accessibilityText lazily at present. This patch eagerly caches
that value on the AX thread, preventing main thread hits.

* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeProperties):
(WebCore::AXIsolatedObject::accessibilityText const):

Canonical link: https://commits.webkit.org/271161@main
  • Loading branch information
hoffmanjoshua authored and twilco committed Nov 27, 2023
1 parent 07f2e6a commit 1cf46fb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,14 @@ void AXIsolatedObject::initializeProperties(const Ref<AccessibilityObject>& axOb
setMathscripts(AXPropertyName::MathPostscripts, object);
}

if (object.isScrollView() || object.isWebArea()) {
// For the ScrollView and WebArea objects, cache the AccessibilityText property eagerly to avoid hitting the main thread in getOrRetrievePropertyValue during the construction of the isolated tree.
Vector<AccessibilityText> texts;
object.accessibilityText(texts);
auto axTextValue = texts.map([] (const auto& text) -> AccessibilityText {
return { text.text.isolatedCopy(), text.textSource };
});
setProperty(AXPropertyName::AccessibilityText, axTextValue);
Vector<AccessibilityText> texts;
object.accessibilityText(texts);
auto axTextValue = texts.map([] (const auto& text) -> AccessibilityText {
return { text.text.isolatedCopy(), text.textSource };
});
setProperty(AXPropertyName::AccessibilityText, axTextValue);

if (object.isScrollView() || object.isWebArea()) {
if (object.isScrollView()) {
setObjectProperty(AXPropertyName::VerticalScrollBar, object.scrollBar(AccessibilityOrientation::Vertical));
setObjectProperty(AXPropertyName::HorizontalScrollBar, object.scrollBar(AccessibilityOrientation::Horizontal));
Expand Down Expand Up @@ -564,7 +563,7 @@ AXIsolatedObject* AXIsolatedObject::cellForColumnAndRow(unsigned columnIndex, un

void AXIsolatedObject::accessibilityText(Vector<AccessibilityText>& texts) const
{
texts = const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<Vector<AccessibilityText>>(AXPropertyName::AccessibilityText);
texts = vectorAttributeValue<AccessibilityText>(AXPropertyName::AccessibilityText);
}

void AXIsolatedObject::insertMathPairs(Vector<std::pair<AXID, AXID>>& isolatedPairs, AccessibilityMathMultiscriptPairs& pairs)
Expand Down

0 comments on commit 1cf46fb

Please sign in to comment.