Diff
Modified: trunk/Source/WebCore/ChangeLog (282449 => 282450)
--- trunk/Source/WebCore/ChangeLog 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/ChangeLog 2021-09-15 13:44:21 UTC (rev 282450)
@@ -1,3 +1,37 @@
+2021-09-15 Carlos Garcia Campos <[email protected]>
+
+ AX: Move platform specific code for isolated tree mode to the platform files
+ https://bugs.webkit.org/show_bug.cgi?id=230301
+ <rdar://problem/83138024>
+
+ Reviewed by Adrian Perez de Castro.
+
+ Add missing ifdefs in the headers and move the mac specific code to mac files.
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::isolatedTreeRootObject):
+ (WebCore::AXObjectCache::clientSupportsIsolatedTree): Deleted.
+ (WebCore::AXObjectCache::isIsolatedTreeEnabled): Deleted.
+ (WebCore::AXObjectCache::initializeSecondaryAXThread): Deleted.
+ (WebCore::AXObjectCache::usedOnAXThread): Deleted.
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::initializeAttributeData):
+ (WebCore::AXIsolatedObject::children):
+ (WebCore::AXIsolatedObject::preventKeyboardDOMEventDispatch const): Deleted.
+ (WebCore::AXIsolatedObject::setPreventKeyboardDOMEventDispatch): Deleted.
+ (WebCore::AXIsolatedObject::convertRectToPlatformSpace const): Deleted.
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::initializePlatformProperties):
+ (WebCore::AXIsolatedObject::convertRectToPlatformSpace const):
+ (WebCore::AXIsolatedObject::preventKeyboardDOMEventDispatch const):
+ (WebCore::AXIsolatedObject::setPreventKeyboardDOMEventDispatch):
+ * accessibility/mac/AXObjectCacheMac.mm:
+ (WebCore::AXObjectCache::clientSupportsIsolatedTree):
+ (WebCore::AXObjectCache::isIsolatedTreeEnabled):
+ (WebCore::AXObjectCache::initializeSecondaryAXThread):
+ (WebCore::AXObjectCache::usedOnAXThread):
+
2021-09-15 Antti Koivisto <[email protected]>
[Layout][Integration] Remove unnecessary Run typedef
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (282449 => 282450)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2021-09-15 13:44:21 UTC (rev 282450)
@@ -112,13 +112,6 @@
#include "TextBoundaries.h"
#include "TextControlInnerElements.h"
#include "TextIterator.h"
-
-#if ENABLE(ACCESSIBILITY_ISOLATED_TREE) && PLATFORM(MAC)
-#include <pal/spi/cocoa/AccessibilitySupportSPI.h>
-#include <pal/spi/cocoa/AccessibilitySupportSoftLink.h>
-#include <pal/spi/mac/HIServicesSPI.h>
-#endif
-
#include <wtf/DataLog.h>
#include <wtf/SetForScope.h>
@@ -767,35 +760,6 @@
return newObj.get();
}
-#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-bool AXObjectCache::clientSupportsIsolatedTree()
-{
- auto client = _AXGetClientForCurrentRequestUntrusted();
- return client == kAXClientTypeVoiceOver
- || UNLIKELY(client == kAXClientTypeWebKitTesting);
-}
-
-bool AXObjectCache::isIsolatedTreeEnabled()
-{
- static std::atomic<bool> enabled { false };
- if (enabled)
- return true;
-
- if (!isMainThread()) {
- ASSERT(_AXUIElementRequestServicedBySecondaryAXThread());
- enabled = true;
- } else {
- enabled = RuntimeEnabledFeatures::sharedFeatures().isAccessibilityIsolatedTreeEnabled() // Used to turn off in apps other than Safari, e.g., Mail.
- && _AXSIsolatedTreeModeFunctionIsAvailable()
- && _AXSIsolatedTreeMode_Soft() != AXSIsolatedTreeModeOff // Used to switch via system defaults.
- && clientSupportsIsolatedTree();
- }
-
- return enabled;
-}
-
-#endif
-
AXCoreObject* AXObjectCache::rootObject()
{
if (!gAccessibilityEnabled)
@@ -810,15 +774,6 @@
}
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-
-void AXObjectCache::initializeSecondaryAXThread()
-{
- // Now that we have created our tree, initialize the secondary thread,
- // so future requests come in on the other thread.
- if (_AXSIsolatedTreeModeFunctionIsAvailable() && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread)
- _AXUIElementUseSecondaryAXThread(true);
-}
-
RefPtr<AXIsolatedTree> AXObjectCache::getOrCreateIsolatedTree() const
{
if (!m_pageID)
@@ -844,13 +799,6 @@
ASSERT_NOT_REACHED();
return nullptr;
}
-
-bool AXObjectCache::usedOnAXThread()
-{
- ASSERT(isIsolatedTreeEnabled());
- return _AXSIsolatedTreeModeFunctionIsAvailable()
- && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread;
-}
#endif
AccessibilityObject* AXObjectCache::rootObjectForFrame(Frame* frame)
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (282449 => 282450)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2021-09-15 13:44:21 UTC (rev 282450)
@@ -71,11 +71,8 @@
setProperty(AXPropertyName::ARIALandmarkRoleDescription, object.ariaLandmarkRoleDescription().isolatedCopy());
setProperty(AXPropertyName::AccessibilityDescription, object.accessibilityDescription().isolatedCopy());
setProperty(AXPropertyName::BoundingBoxRect, object.boundingBoxRect());
- setProperty(AXPropertyName::Description, object.descriptionAttributeValue().isolatedCopy());
setProperty(AXPropertyName::ElementRect, object.elementRect());
setProperty(AXPropertyName::HasARIAValueNow, object.hasARIAValueNow());
- setProperty(AXPropertyName::HasApplePDFAnnotationAttribute, object.hasApplePDFAnnotationAttribute());
- setProperty(AXPropertyName::HelpText, object.helpTextAttributeValue().isolatedCopy());
setProperty(AXPropertyName::IsAccessibilityIgnored, object.accessibilityIsIgnored());
setProperty(AXPropertyName::IsActiveDescendantOfFocusedContainer, object.isActiveDescendantOfFocusedContainer());
setProperty(AXPropertyName::IsAttachment, object.isAttachment());
@@ -137,11 +134,9 @@
setProperty(AXPropertyName::RoleDescription, object.roleDescription().isolatedCopy());
setProperty(AXPropertyName::RolePlatformString, object.rolePlatformString().isolatedCopy());
setProperty(AXPropertyName::RoleValue, static_cast<int>(object.roleValue()));
- setProperty(AXPropertyName::SpeechHint, object.speechHintAttributeValue().isolatedCopy());
setProperty(AXPropertyName::SupportsDatetimeAttribute, object.supportsDatetimeAttribute());
setProperty(AXPropertyName::SupportsRowCountChange, object.supportsRowCountChange());
setProperty(AXPropertyName::Title, object.title().isolatedCopy());
- setProperty(AXPropertyName::TitleAttributeValue, object.titleAttributeValue().isolatedCopy());
setProperty(AXPropertyName::DatetimeAttributeValue, object.datetimeAttributeValue().isolatedCopy());
setProperty(AXPropertyName::CanSetFocusAttribute, object.canSetFocusAttribute());
setProperty(AXPropertyName::CanSetTextRangeAttributes, object.canSetTextRangeAttributes());
@@ -209,9 +204,6 @@
setProperty(AXPropertyName::AutoCompleteValue, object.autoCompleteValue().isolatedCopy());
setProperty(AXPropertyName::SpeakAs, object.speakAsProperty());
setProperty(AXPropertyName::StringValue, object.stringValue().isolatedCopy());
-#if PLATFORM(MAC)
- setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
-#endif
setObjectProperty(AXPropertyName::FocusableAncestor, object.focusableAncestor());
setObjectProperty(AXPropertyName::EditableAncestor, object.editableAncestor());
setObjectProperty(AXPropertyName::HighestEditableAncestor, object.highestEditableAncestor());
@@ -411,7 +403,7 @@
setObjectVectorProperty(AXPropertyName::DocumentLinks, object.documentLinks());
}
- initializePlatformProperties(object);
+ initializePlatformProperties(object, isRoot);
}
AXCoreObject* AXIsolatedObject::associatedAXObject() const
@@ -514,8 +506,10 @@
const AXCoreObject::AccessibilityChildrenVector& AXIsolatedObject::children(bool)
{
+#if USE(APPLE_INTERNAL_SDK)
ASSERT(_AXSIsolatedTreeModeFunctionIsAvailable() && ((_AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread && !isMainThread())
|| (_AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeMainThread && isMainThread())));
+#endif
updateBackingStore();
m_children.clear();
m_children.reserveInitialCapacity(m_childrenIDs.size());
@@ -603,13 +597,6 @@
return String();
}
-bool AXIsolatedObject::preventKeyboardDOMEventDispatch() const
-{
- if (auto root = tree()->rootNode())
- return root->boolAttributeValue(AXPropertyName::PreventKeyboardDOMEventDispatch);
- return false;
-}
-
String AXIsolatedObject::documentEncoding() const
{
if (auto root = tree()->rootNode())
@@ -656,15 +643,6 @@
return objectAttributeValue(orientation == AccessibilityOrientation::Vertical ? AXPropertyName::VerticalScrollBar : AXPropertyName::HorizontalScrollBar);
}
-template<typename U>
-void AXIsolatedObject::performFunctionOnMainThread(U&& lambda) const
-{
- Accessibility::performFunctionOnMainThread([&lambda, this] () {
- if (auto* object = associatedAXObject())
- lambda(object);
- });
-}
-
void AXIsolatedObject::setARIAGrabbed(bool value)
{
performFunctionOnMainThread([&value](AXCoreObject* object) {
@@ -771,13 +749,6 @@
}
#endif
-void AXIsolatedObject::setPreventKeyboardDOMEventDispatch(bool value)
-{
- performFunctionOnMainThread([&value](AXCoreObject* object) {
- object->setPreventKeyboardDOMEventDispatch(value);
- });
-}
-
SRGBA<uint8_t> AXIsolatedObject::colorValue() const
{
return colorAttributeValue(AXPropertyName::ColorValue).toSRGBALossy<uint8_t>();
@@ -1167,15 +1138,6 @@
});
}
-FloatRect AXIsolatedObject::convertRectToPlatformSpace(const FloatRect& rect, AccessibilityConversionSpace space) const
-{
- return Accessibility::retrieveValueFromMainThread<FloatRect>([&rect, &space, this] () -> FloatRect {
- if (auto* axObject = associatedAXObject())
- return axObject->convertRectToPlatformSpace(rect, space);
- return { };
- });
-}
-
bool AXIsolatedObject::replaceTextInRange(const String& replacementText, const PlainTextRange& textRange)
{
return Accessibility::retrieveValueFromMainThread<bool>([&replacementText, &textRange, this] () -> bool {
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (282449 => 282450)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2021-09-15 13:44:21 UTC (rev 282450)
@@ -71,7 +71,7 @@
AXIsolatedObject(AXCoreObject&, AXIsolatedTree*, AXID parentID);
bool isAXIsolatedObjectInstance() const override { return true; }
void initializeAttributeData(AXCoreObject&, bool isRoot);
- void initializePlatformProperties(const AXCoreObject&);
+ void initializePlatformProperties(const AXCoreObject&, bool isRoot);
AXCoreObject* associatedAXObject() const;
void setProperty(AXPropertyName, AXPropertyValueVariant&&, bool shouldRemove = false);
@@ -100,7 +100,13 @@
void fillChildrenVectorForProperty(AXPropertyName, AccessibilityChildrenVector&) const;
void setMathscripts(AXPropertyName, AXCoreObject&);
void insertMathPairs(Vector<std::pair<AXID, AXID>>&, AccessibilityMathMultiscriptPairs&);
- template<typename U> void performFunctionOnMainThread(U&&) const;
+ template<typename U> void performFunctionOnMainThread(U&& lambda) const
+ {
+ Accessibility::performFunctionOnMainThread([&lambda, this]() {
+ if (auto* object = associatedAXObject())
+ lambda(object);
+ });
+ }
// Attribute retrieval overrides.
bool isHeading() const override { return boolAttributeValue(AXPropertyName::IsHeading); }
@@ -320,11 +326,13 @@
bool isAnonymousMathOperator() const override { return boolAttributeValue(AXPropertyName::IsAnonymousMathOperator); }
void mathPrescripts(AccessibilityMathMultiscriptPairs&) override;
void mathPostscripts(AccessibilityMathMultiscriptPairs&) override;
+#if PLATFORM(COCOA)
bool fileUploadButtonReturnsValueInTitle() const override { return boolAttributeValue(AXPropertyName::FileUploadButtonReturnsValueInTitle); }
String speechHintAttributeValue() const override { return stringAttributeValue(AXPropertyName::SpeechHint); }
String descriptionAttributeValue() const override { return stringAttributeValue(AXPropertyName::Description); }
String helpTextAttributeValue() const override { return stringAttributeValue(AXPropertyName::HelpText); }
String titleAttributeValue() const override { return stringAttributeValue(AXPropertyName::TitleAttributeValue); }
+#endif
#if PLATFORM(MAC)
bool caretBrowsingEnabled() const override { return boolAttributeValue(AXPropertyName::CaretBrowsingEnabled); }
#endif
@@ -369,7 +377,9 @@
uint64_t sessionID() const override;
String documentURI() const override;
String documentEncoding() const override;
+#if PLATFORM(COCOA)
bool preventKeyboardDOMEventDispatch() const override;
+#endif
// PlainTextRange support.
PlainTextRange selectedTextRange() const override;
@@ -444,7 +454,9 @@
#if PLATFORM(MAC)
void setCaretBrowsingEnabled(bool) override;
#endif
+#if PLATFORM(COCOA)
void setPreventKeyboardDOMEventDispatch(bool) override;
+#endif
String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const override;
std::optional<SimpleRange> misspellingRange(const SimpleRange&, AccessibilitySearchDirection) const override;
@@ -634,7 +646,9 @@
void overrideAttachmentParent(AXCoreObject* parent) override;
bool accessibilityIgnoreAttachment() const override;
AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const override;
+#if PLATFORM(COCOA)
bool hasApplePDFAnnotationAttribute() const override { return boolAttributeValue(AXPropertyName::HasApplePDFAnnotationAttribute); }
+#endif
const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const override;
AXCoreObject* webAreaObject() const override { return objectAttributeValue(AXPropertyName::WebArea); }
void setIsIgnoredFromParentData(AccessibilityIsIgnoredFromParentData&) override;
Modified: trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (282449 => 282450)
--- trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2021-09-15 13:44:21 UTC (rev 282450)
@@ -32,8 +32,18 @@
namespace WebCore {
-void AXIsolatedObject::initializePlatformProperties(const AXCoreObject& object)
+void AXIsolatedObject::initializePlatformProperties(const AXCoreObject& object, bool isRoot)
{
+ setProperty(AXPropertyName::Description, object.descriptionAttributeValue().isolatedCopy());
+ setProperty(AXPropertyName::HasApplePDFAnnotationAttribute, object.hasApplePDFAnnotationAttribute());
+ setProperty(AXPropertyName::HelpText, object.helpTextAttributeValue().isolatedCopy());
+ setProperty(AXPropertyName::SpeechHint, object.speechHintAttributeValue().isolatedCopy());
+ setProperty(AXPropertyName::TitleAttributeValue, object.titleAttributeValue().isolatedCopy());
+ setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
+
+ if (isRoot)
+ setProperty(AXPropertyName::PreventKeyboardDOMEventDispatch, object.preventKeyboardDOMEventDispatch());
+
if (object.isScrollView()) {
m_platformWidget = object.platformWidget();
m_remoteParent = object.remoteParentObject();
@@ -48,6 +58,15 @@
return is<AXIsolatedObject>(scrollView) ? downcast<AXIsolatedObject>(scrollView)->m_remoteParent.get() : nil;
}
+FloatRect AXIsolatedObject::convertRectToPlatformSpace(const FloatRect& rect, AccessibilityConversionSpace space) const
+{
+ return Accessibility::retrieveValueFromMainThread<FloatRect>([&rect, &space, this]() -> FloatRect {
+ if (auto* axObject = associatedAXObject())
+ return axObject->convertRectToPlatformSpace(rect, space);
+ return { };
+ });
+}
+
void AXIsolatedObject::attachPlatformWrapper(AccessibilityObjectWrapper* wrapper)
{
[wrapper attachIsolatedObject:this];
@@ -67,6 +86,20 @@
});
}
+bool AXIsolatedObject::preventKeyboardDOMEventDispatch() const
+{
+ if (auto root = tree()->rootNode())
+ return root->boolAttributeValue(AXPropertyName::PreventKeyboardDOMEventDispatch);
+ return false;
+}
+
+void AXIsolatedObject::setPreventKeyboardDOMEventDispatch(bool value)
+{
+ performFunctionOnMainThread([&value](AXCoreObject* object) {
+ object->setPreventKeyboardDOMEventDispatch(value);
+ });
+}
+
} // WebCore
#endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE) && PLATFORM(MAC)
Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (282449 => 282450)
--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm 2021-09-15 13:33:49 UTC (rev 282449)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm 2021-09-15 13:44:21 UTC (rev 282450)
@@ -32,10 +32,16 @@
#import "AccessibilityObject.h"
#import "AccessibilityTable.h"
#import "RenderObject.h"
+#import "RuntimeEnabledFeatures.h"
#import "WebAccessibilityObjectWrapperMac.h"
#import <pal/spi/cocoa/NSAccessibilitySPI.h>
#import <pal/spi/mac/HIServicesSPI.h>
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+#import <pal/spi/cocoa/AccessibilitySupportSPI.h>
+#import <pal/spi/cocoa/AccessibilitySupportSoftLink.h>
+#endif
+
#if USE(APPLE_INTERNAL_SDK)
#import <ApplicationServices/ApplicationServicesPriv.h>
#endif
@@ -600,6 +606,49 @@
{
}
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+bool AXObjectCache::clientSupportsIsolatedTree()
+{
+ auto client = _AXGetClientForCurrentRequestUntrusted();
+ return client == kAXClientTypeVoiceOver
+ || UNLIKELY(client == kAXClientTypeWebKitTesting);
+}
+
+bool AXObjectCache::isIsolatedTreeEnabled()
+{
+ static std::atomic<bool> enabled { false };
+ if (enabled)
+ return true;
+
+ if (!isMainThread()) {
+ ASSERT(_AXUIElementRequestServicedBySecondaryAXThread());
+ enabled = true;
+ } else {
+ enabled = RuntimeEnabledFeatures::sharedFeatures().isAccessibilityIsolatedTreeEnabled() // Used to turn off in apps other than Safari, e.g., Mail.
+ && _AXSIsolatedTreeModeFunctionIsAvailable()
+ && _AXSIsolatedTreeMode_Soft() != AXSIsolatedTreeModeOff // Used to switch via system defaults.
+ && clientSupportsIsolatedTree();
+ }
+
+ return enabled;
+}
+
+void AXObjectCache::initializeSecondaryAXThread()
+{
+ // Now that we have created our tree, initialize the secondary thread,
+ // so future requests come in on the other thread.
+ if (_AXSIsolatedTreeModeFunctionIsAvailable() && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread)
+ _AXUIElementUseSecondaryAXThread(true);
+}
+
+bool AXObjectCache::usedOnAXThread()
+{
+ ASSERT(isIsolatedTreeEnabled());
+ return _AXSIsolatedTreeModeFunctionIsAvailable()
+ && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread;
+}
+#endif
+
// TextMarker and TextMarkerRange funcstions.
// FIXME: TextMarker and TextMarkerRange should become classes wrapping the system objects.