Title: [289427] trunk/Source/WebCore
- Revision
- 289427
- Author
- [email protected]
- Date
- 2022-02-08 14:14:18 -0800 (Tue, 08 Feb 2022)
Log Message
Initialize the AXIsolatedObject AccessibilityText property lazily.
https://bugs.webkit.org/show_bug.cgi?id=236276
<rdar://problem/88604453>
Reviewed by Chris Fleizach.
Computation of the AccessibilitytText property may be very expensive and
if performed during the creation of IsolatedObjects may cause crashes
since it may invoke textUnderElement while page layout is in progress.
For these reasons, we are computing and caching this property on first
request.
This patch is a sequel to https://bugs.webkit.org/show_bug.cgi?id=236115.
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::accessibilityText const):
(WebCore::AXIsolatedObject::getOrRetrievePropertyValue):
(WebCore::AXIsolatedObject::innerHTML const):
(WebCore::AXIsolatedObject::outerHTML const):
(WebCore::AXIsolatedObject::getOrRetrieveStringPropertyValue):
Replaced by getOrRetrievePropertyValue<String>.
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
(WebCore::AXIsolatedObject::descriptionAttributeValue const):
(WebCore::AXIsolatedObject::titleAttributeValue const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (289426 => 289427)
--- trunk/Source/WebCore/ChangeLog 2022-02-08 22:06:14 UTC (rev 289426)
+++ trunk/Source/WebCore/ChangeLog 2022-02-08 22:14:18 UTC (rev 289427)
@@ -1,3 +1,31 @@
+2022-02-08 Andres Gonzalez <[email protected]>
+
+ Initialize the AXIsolatedObject AccessibilityText property lazily.
+ https://bugs.webkit.org/show_bug.cgi?id=236276
+ <rdar://problem/88604453>
+
+ Reviewed by Chris Fleizach.
+
+ Computation of the AccessibilitytText property may be very expensive and
+ if performed during the creation of IsolatedObjects may cause crashes
+ since it may invoke textUnderElement while page layout is in progress.
+ For these reasons, we are computing and caching this property on first
+ request.
+ This patch is a sequel to https://bugs.webkit.org/show_bug.cgi?id=236115.
+
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::initializeAttributeData):
+ (WebCore::AXIsolatedObject::accessibilityText const):
+ (WebCore::AXIsolatedObject::getOrRetrievePropertyValue):
+ (WebCore::AXIsolatedObject::innerHTML const):
+ (WebCore::AXIsolatedObject::outerHTML const):
+ (WebCore::AXIsolatedObject::getOrRetrieveStringPropertyValue):
+ Replaced by getOrRetrievePropertyValue<String>.
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::descriptionAttributeValue const):
+ (WebCore::AXIsolatedObject::titleAttributeValue const):
+
2022-02-08 Antoine Quint <[email protected]>
[css-logical] [css-animations] changing "direction" or "writing-mode" should recompute keyframes
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (289426 => 289427)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-02-08 22:06:14 UTC (rev 289426)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-02-08 22:14:18 UTC (rev 289427)
@@ -344,16 +344,6 @@
object.ariaOwnsElements(ariaOwnsElements);
setObjectVectorProperty(AXPropertyName::ARIAOwnsElements, ariaOwnsElements);
- Vector<AccessibilityText> texts;
- object.accessibilityText(texts);
- Vector<AccessibilityText> isolatedTexts;
- isolatedTexts.reserveCapacity(texts.size());
- for (const auto& text : texts) {
- AccessibilityText isolatedText(text.text.isolatedCopy(), text.textSource);
- isolatedTexts.uncheckedAppend(isolatedText);
- }
- setProperty(AXPropertyName::AccessibilityText, isolatedTexts);
-
// Spin button support.
setObjectProperty(AXPropertyName::DecrementButton, object.decrementButton());
setObjectProperty(AXPropertyName::IncrementButton, object.incrementButton());
@@ -606,7 +596,7 @@
void AXIsolatedObject::accessibilityText(Vector<AccessibilityText>& texts) const
{
- texts = vectorAttributeValue<AccessibilityText>(AXPropertyName::AccessibilityText);
+ texts = const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<Vector<AccessibilityText>>(AXPropertyName::AccessibilityText);
}
void AXIsolatedObject::classList(Vector<String>& list) const
@@ -977,10 +967,19 @@
);
}
-String AXIsolatedObject::getOrRetrieveStringPropertyValue(AXPropertyName propertyName)
+template<typename T>
+T AXIsolatedObject::getOrRetrievePropertyValue(AXPropertyName propertyName)
{
+ auto typedValue = [&propertyName, this] () {
+ auto value = m_propertyMap.get(propertyName);
+ return WTF::switchOn(value,
+ [] (T& typedValue) -> T { return typedValue; },
+ [] (auto&) { return T(); }
+ );
+ };
+
if (m_propertyMap.contains(propertyName))
- return stringAttributeValue(propertyName);
+ return typedValue();
Accessibility::performFunctionOnMainThread([&propertyName, this] () {
auto* axObject = associatedAXObject();
@@ -987,21 +986,29 @@
if (!axObject)
return;
- String value;
+ AXPropertyValueVariant value;
switch (propertyName) {
#if PLATFORM(COCOA)
case AXPropertyName::Description:
- value = axObject->descriptionAttributeValue();
+ value = axObject->descriptionAttributeValue().isolatedCopy();
break;
case AXPropertyName::TitleAttributeValue:
- value = axObject->titleAttributeValue();
+ value = axObject->titleAttributeValue().isolatedCopy();
break;
#endif
+ case AXPropertyName::AccessibilityText: {
+ Vector<AccessibilityText> texts;
+ axObject->accessibilityText(texts);
+ value = texts.map([] (const auto& text) -> AccessibilityText {
+ return { text.text.isolatedCopy(), text.textSource };
+ });
+ break;
+ }
case AXPropertyName::InnerHTML:
- value = axObject->innerHTML();
+ value = axObject->innerHTML().isolatedCopy();
break;
case AXPropertyName::OuterHTML:
- value = axObject->outerHTML();
+ value = axObject->outerHTML().isolatedCopy();
break;
default:
break;
@@ -1008,10 +1015,10 @@
}
// Cache value so that there is no need to access the main thread in subsequent calls.
- setProperty(propertyName, value.isolatedCopy());
+ setProperty(propertyName, WTFMove(value));
});
- return stringAttributeValue(propertyName);
+ return typedValue();
}
void AXIsolatedObject::fillChildrenVectorForProperty(AXPropertyName propertyName, AccessibilityChildrenVector& children) const
@@ -2475,12 +2482,12 @@
String AXIsolatedObject::innerHTML() const
{
- return const_cast<AXIsolatedObject*>(this)->getOrRetrieveStringPropertyValue(AXPropertyName::InnerHTML);
+ return const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<String>(AXPropertyName::InnerHTML);
}
String AXIsolatedObject::outerHTML() const
{
- return const_cast<AXIsolatedObject*>(this)->getOrRetrieveStringPropertyValue(AXPropertyName::OuterHTML);
+ return const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<String>(AXPropertyName::OuterHTML);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (289426 => 289427)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2022-02-08 22:06:14 UTC (rev 289426)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2022-02-08 22:14:18 UTC (rev 289427)
@@ -101,7 +101,7 @@
// The following method performs a lazy caching of the given property.
// If the property is already in m_propertyMap, returns the existing value.
// If not, retrieves the property from the main thread and cache it for later use.
- String getOrRetrieveStringPropertyValue(AXPropertyName);
+ template<typename T> T getOrRetrievePropertyValue(AXPropertyName);
void fillChildrenVectorForProperty(AXPropertyName, AccessibilityChildrenVector&) const;
void setMathscripts(AXPropertyName, AXCoreObject&);
Modified: trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (289426 => 289427)
--- trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2022-02-08 22:06:14 UTC (rev 289426)
+++ trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2022-02-08 22:14:18 UTC (rev 289427)
@@ -105,12 +105,12 @@
String AXIsolatedObject::descriptionAttributeValue() const
{
- return const_cast<AXIsolatedObject*>(this)->getOrRetrieveStringPropertyValue(AXPropertyName::Description);
+ return const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<String>(AXPropertyName::Description);
}
String AXIsolatedObject::titleAttributeValue() const
{
- return const_cast<AXIsolatedObject*>(this)->getOrRetrieveStringPropertyValue(AXPropertyName::TitleAttributeValue);
+ return const_cast<AXIsolatedObject*>(this)->getOrRetrievePropertyValue<String>(AXPropertyName::TitleAttributeValue);
}
} // WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes