<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[282450] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/282450">282450</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-09-15 06:44:21 -0700 (Wed, 15 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>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>

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2021-09-15
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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCachecpp">trunk/Source/WebCore/accessibility/AXObjectCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityisolatedtreeAXIsolatedObjectcpp">trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityisolatedtreeAXIsolatedObjecth">trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityisolatedtreemacAXIsolatedObjectMacmm">trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm</a></li>
<li><a href="#trunkSourceWebCoreaccessibilitymacAXObjectCacheMacmm">trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2021-09-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        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):
+
</ins><span class="cx"> 2021-09-15  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [Layout][Integration] Remove unnecessary Run typedef
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -112,13 +112,6 @@
</span><span class="cx"> #include "TextBoundaries.h"
</span><span class="cx"> #include "TextControlInnerElements.h"
</span><span class="cx"> #include "TextIterator.h"
</span><del>-
-#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
-
</del><span class="cx"> #include <wtf/DataLog.h>
</span><span class="cx"> #include <wtf/SetForScope.h>
</span><span class="cx"> 
</span><span class="lines">@@ -767,35 +760,6 @@
</span><span class="cx">     return newObj.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#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
-
</del><span class="cx"> AXCoreObject* AXObjectCache::rootObject()
</span><span class="cx"> {
</span><span class="cx">     if (!gAccessibilityEnabled)
</span><span class="lines">@@ -810,15 +774,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
</span><del>-
-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);
-}
-
</del><span class="cx"> RefPtr<AXIsolatedTree> AXObjectCache::getOrCreateIsolatedTree() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_pageID)
</span><span class="lines">@@ -844,13 +799,6 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><del>-
-bool AXObjectCache::usedOnAXThread()
-{
-    ASSERT(isIsolatedTreeEnabled());
-    return _AXSIsolatedTreeModeFunctionIsAvailable()
-        && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread;
-}
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> AccessibilityObject* AXObjectCache::rootObjectForFrame(Frame* frame)
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityisolatedtreeAXIsolatedObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -71,11 +71,8 @@
</span><span class="cx">     setProperty(AXPropertyName::ARIALandmarkRoleDescription, object.ariaLandmarkRoleDescription().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::AccessibilityDescription, object.accessibilityDescription().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::BoundingBoxRect, object.boundingBoxRect());
</span><del>-    setProperty(AXPropertyName::Description, object.descriptionAttributeValue().isolatedCopy());
</del><span class="cx">     setProperty(AXPropertyName::ElementRect, object.elementRect());
</span><span class="cx">     setProperty(AXPropertyName::HasARIAValueNow, object.hasARIAValueNow());
</span><del>-    setProperty(AXPropertyName::HasApplePDFAnnotationAttribute, object.hasApplePDFAnnotationAttribute());
-    setProperty(AXPropertyName::HelpText, object.helpTextAttributeValue().isolatedCopy());
</del><span class="cx">     setProperty(AXPropertyName::IsAccessibilityIgnored, object.accessibilityIsIgnored());
</span><span class="cx">     setProperty(AXPropertyName::IsActiveDescendantOfFocusedContainer, object.isActiveDescendantOfFocusedContainer());
</span><span class="cx">     setProperty(AXPropertyName::IsAttachment, object.isAttachment());
</span><span class="lines">@@ -137,11 +134,9 @@
</span><span class="cx">     setProperty(AXPropertyName::RoleDescription, object.roleDescription().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::RolePlatformString, object.rolePlatformString().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::RoleValue, static_cast<int>(object.roleValue()));
</span><del>-    setProperty(AXPropertyName::SpeechHint, object.speechHintAttributeValue().isolatedCopy());
</del><span class="cx">     setProperty(AXPropertyName::SupportsDatetimeAttribute, object.supportsDatetimeAttribute());
</span><span class="cx">     setProperty(AXPropertyName::SupportsRowCountChange, object.supportsRowCountChange());
</span><span class="cx">     setProperty(AXPropertyName::Title, object.title().isolatedCopy());
</span><del>-    setProperty(AXPropertyName::TitleAttributeValue, object.titleAttributeValue().isolatedCopy());
</del><span class="cx">     setProperty(AXPropertyName::DatetimeAttributeValue, object.datetimeAttributeValue().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::CanSetFocusAttribute, object.canSetFocusAttribute());
</span><span class="cx">     setProperty(AXPropertyName::CanSetTextRangeAttributes, object.canSetTextRangeAttributes());
</span><span class="lines">@@ -209,9 +204,6 @@
</span><span class="cx">     setProperty(AXPropertyName::AutoCompleteValue, object.autoCompleteValue().isolatedCopy());
</span><span class="cx">     setProperty(AXPropertyName::SpeakAs, object.speakAsProperty());
</span><span class="cx">     setProperty(AXPropertyName::StringValue, object.stringValue().isolatedCopy());
</span><del>-#if PLATFORM(MAC)
-    setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
-#endif
</del><span class="cx">     setObjectProperty(AXPropertyName::FocusableAncestor, object.focusableAncestor());
</span><span class="cx">     setObjectProperty(AXPropertyName::EditableAncestor, object.editableAncestor());
</span><span class="cx">     setObjectProperty(AXPropertyName::HighestEditableAncestor, object.highestEditableAncestor());
</span><span class="lines">@@ -411,7 +403,7 @@
</span><span class="cx">         setObjectVectorProperty(AXPropertyName::DocumentLinks, object.documentLinks());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    initializePlatformProperties(object);
</del><ins>+    initializePlatformProperties(object, isRoot);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> AXCoreObject* AXIsolatedObject::associatedAXObject() const
</span><span class="lines">@@ -514,8 +506,10 @@
</span><span class="cx"> 
</span><span class="cx"> const AXCoreObject::AccessibilityChildrenVector& AXIsolatedObject::children(bool)
</span><span class="cx"> {
</span><ins>+#if USE(APPLE_INTERNAL_SDK)
</ins><span class="cx">     ASSERT(_AXSIsolatedTreeModeFunctionIsAvailable() && ((_AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread && !isMainThread())
</span><span class="cx">         || (_AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeMainThread && isMainThread())));
</span><ins>+#endif
</ins><span class="cx">     updateBackingStore();
</span><span class="cx">     m_children.clear();
</span><span class="cx">     m_children.reserveInitialCapacity(m_childrenIDs.size());
</span><span class="lines">@@ -603,13 +597,6 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool AXIsolatedObject::preventKeyboardDOMEventDispatch() const
-{
-    if (auto root = tree()->rootNode())
-        return root->boolAttributeValue(AXPropertyName::PreventKeyboardDOMEventDispatch);
-    return false;
-}
-
</del><span class="cx"> String AXIsolatedObject::documentEncoding() const
</span><span class="cx"> {
</span><span class="cx">     if (auto root = tree()->rootNode())
</span><span class="lines">@@ -656,15 +643,6 @@
</span><span class="cx">     return objectAttributeValue(orientation == AccessibilityOrientation::Vertical ? AXPropertyName::VerticalScrollBar : AXPropertyName::HorizontalScrollBar);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template<typename U>
-void AXIsolatedObject::performFunctionOnMainThread(U&& lambda) const
-{
-    Accessibility::performFunctionOnMainThread([&lambda, this] () {
-        if (auto* object = associatedAXObject())
-            lambda(object);
-    });
-}
-
</del><span class="cx"> void AXIsolatedObject::setARIAGrabbed(bool value)
</span><span class="cx"> {
</span><span class="cx">     performFunctionOnMainThread([&value](AXCoreObject* object) {
</span><span class="lines">@@ -771,13 +749,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void AXIsolatedObject::setPreventKeyboardDOMEventDispatch(bool value)
-{
-    performFunctionOnMainThread([&value](AXCoreObject* object) {
-        object->setPreventKeyboardDOMEventDispatch(value);
-    });
-}
-
</del><span class="cx"> SRGBA<uint8_t> AXIsolatedObject::colorValue() const
</span><span class="cx"> {
</span><span class="cx">     return colorAttributeValue(AXPropertyName::ColorValue).toSRGBALossy<uint8_t>();
</span><span class="lines">@@ -1167,15 +1138,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-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 { };
-    });
-}
-
</del><span class="cx"> bool AXIsolatedObject::replaceTextInRange(const String& replacementText, const PlainTextRange& textRange)
</span><span class="cx"> {
</span><span class="cx">     return Accessibility::retrieveValueFromMainThread<bool>([&replacementText, &textRange, this] () -> bool {
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityisolatedtreeAXIsolatedObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">     AXIsolatedObject(AXCoreObject&, AXIsolatedTree*, AXID parentID);
</span><span class="cx">     bool isAXIsolatedObjectInstance() const override { return true; }
</span><span class="cx">     void initializeAttributeData(AXCoreObject&, bool isRoot);
</span><del>-    void initializePlatformProperties(const AXCoreObject&);
</del><ins>+    void initializePlatformProperties(const AXCoreObject&, bool isRoot);
</ins><span class="cx">     AXCoreObject* associatedAXObject() const;
</span><span class="cx"> 
</span><span class="cx">     void setProperty(AXPropertyName, AXPropertyValueVariant&&, bool shouldRemove = false);
</span><span class="lines">@@ -100,7 +100,13 @@
</span><span class="cx">     void fillChildrenVectorForProperty(AXPropertyName, AccessibilityChildrenVector&) const;
</span><span class="cx">     void setMathscripts(AXPropertyName, AXCoreObject&);
</span><span class="cx">     void insertMathPairs(Vector<std::pair<AXID, AXID>>&, AccessibilityMathMultiscriptPairs&);
</span><del>-    template<typename U> void performFunctionOnMainThread(U&&) const;
</del><ins>+    template<typename U> void performFunctionOnMainThread(U&& lambda) const
+    {
+        Accessibility::performFunctionOnMainThread([&lambda, this]() {
+            if (auto* object = associatedAXObject())
+                lambda(object);
+        });
+    }
</ins><span class="cx"> 
</span><span class="cx">     // Attribute retrieval overrides.
</span><span class="cx">     bool isHeading() const override { return boolAttributeValue(AXPropertyName::IsHeading); }
</span><span class="lines">@@ -320,11 +326,13 @@
</span><span class="cx">     bool isAnonymousMathOperator() const override { return boolAttributeValue(AXPropertyName::IsAnonymousMathOperator); }
</span><span class="cx">     void mathPrescripts(AccessibilityMathMultiscriptPairs&) override;
</span><span class="cx">     void mathPostscripts(AccessibilityMathMultiscriptPairs&) override;
</span><ins>+#if PLATFORM(COCOA)
</ins><span class="cx">     bool fileUploadButtonReturnsValueInTitle() const override { return boolAttributeValue(AXPropertyName::FileUploadButtonReturnsValueInTitle); }
</span><span class="cx">     String speechHintAttributeValue() const override { return stringAttributeValue(AXPropertyName::SpeechHint); }
</span><span class="cx">     String descriptionAttributeValue() const override { return stringAttributeValue(AXPropertyName::Description); }
</span><span class="cx">     String helpTextAttributeValue() const override { return stringAttributeValue(AXPropertyName::HelpText); }
</span><span class="cx">     String titleAttributeValue() const override { return stringAttributeValue(AXPropertyName::TitleAttributeValue); }
</span><ins>+#endif
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     bool caretBrowsingEnabled() const override { return boolAttributeValue(AXPropertyName::CaretBrowsingEnabled); }
</span><span class="cx"> #endif
</span><span class="lines">@@ -369,7 +377,9 @@
</span><span class="cx">     uint64_t sessionID() const override;
</span><span class="cx">     String documentURI() const override;
</span><span class="cx">     String documentEncoding() const override;
</span><ins>+#if PLATFORM(COCOA)
</ins><span class="cx">     bool preventKeyboardDOMEventDispatch() const override;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     // PlainTextRange support.
</span><span class="cx">     PlainTextRange selectedTextRange() const override;
</span><span class="lines">@@ -444,7 +454,9 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     void setCaretBrowsingEnabled(bool) override;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(COCOA)
</ins><span class="cx">     void setPreventKeyboardDOMEventDispatch(bool) override;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const override;
</span><span class="cx">     std::optional<SimpleRange> misspellingRange(const SimpleRange&, AccessibilitySearchDirection) const override;
</span><span class="lines">@@ -634,7 +646,9 @@
</span><span class="cx">     void overrideAttachmentParent(AXCoreObject* parent) override;
</span><span class="cx">     bool accessibilityIgnoreAttachment() const override;
</span><span class="cx">     AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const override;
</span><ins>+#if PLATFORM(COCOA)
</ins><span class="cx">     bool hasApplePDFAnnotationAttribute() const override { return boolAttributeValue(AXPropertyName::HasApplePDFAnnotationAttribute); }
</span><ins>+#endif
</ins><span class="cx">     const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const override;
</span><span class="cx">     AXCoreObject* webAreaObject() const override { return objectAttributeValue(AXPropertyName::WebArea); }
</span><span class="cx">     void setIsIgnoredFromParentData(AccessibilityIsIgnoredFromParentData&) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityisolatedtreemacAXIsolatedObjectMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -32,8 +32,18 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-void AXIsolatedObject::initializePlatformProperties(const AXCoreObject& object)
</del><ins>+void AXIsolatedObject::initializePlatformProperties(const AXCoreObject& object, bool isRoot)
</ins><span class="cx"> {
</span><ins>+    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());
+
</ins><span class="cx">     if (object.isScrollView()) {
</span><span class="cx">         m_platformWidget = object.platformWidget();
</span><span class="cx">         m_remoteParent = object.remoteParentObject();
</span><span class="lines">@@ -48,6 +58,15 @@
</span><span class="cx">     return is<AXIsolatedObject>(scrollView) ? downcast<AXIsolatedObject>(scrollView)->m_remoteParent.get() : nil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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 { };
+    });
+}
+
</ins><span class="cx"> void AXIsolatedObject::attachPlatformWrapper(AccessibilityObjectWrapper* wrapper)
</span><span class="cx"> {
</span><span class="cx">     [wrapper attachIsolatedObject:this];
</span><span class="lines">@@ -67,6 +86,20 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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);
+    });
+}
+
</ins><span class="cx"> } // WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE) && PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilitymacAXObjectCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (282449 => 282450)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -32,10 +32,16 @@
</span><span class="cx"> #import "AccessibilityObject.h"
</span><span class="cx"> #import "AccessibilityTable.h"
</span><span class="cx"> #import "RenderObject.h"
</span><ins>+#import "RuntimeEnabledFeatures.h"
</ins><span class="cx"> #import "WebAccessibilityObjectWrapperMac.h"
</span><span class="cx"> #import <pal/spi/cocoa/NSAccessibilitySPI.h>
</span><span class="cx"> #import <pal/spi/mac/HIServicesSPI.h>
</span><span class="cx"> 
</span><ins>+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+#import <pal/spi/cocoa/AccessibilitySupportSPI.h>
+#import <pal/spi/cocoa/AccessibilitySupportSoftLink.h>
+#endif
+
</ins><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> #import <ApplicationServices/ApplicationServicesPriv.h>
</span><span class="cx"> #endif
</span><span class="lines">@@ -600,6 +606,49 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#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
+
</ins><span class="cx"> // TextMarker and TextMarkerRange funcstions.
</span><span class="cx"> // FIXME: TextMarker and TextMarkerRange should become classes wrapping the system objects.
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>