Title: [257739] trunk
Revision
257739
Author
[email protected]
Date
2020-03-02 14:50:30 -0800 (Mon, 02 Mar 2020)

Log Message

Fix for LayoutTests/accessibility/mac/search-text/search-text.html in IsolatedTree mode.
https://bugs.webkit.org/show_bug.cgi?id=208434

Reviewed by Chris Fleizach.

Source/WebCore:

Covered by LayoutTests/accessibility/mac/search-text/search-text.html

- Updates IsolatedTree for AXSelectedTextChanged notifications.
- Exposes webAreaObject through the AXCoreObject interface.
- AXIsolatedObject implementation for hasApplePDFAnnotationAttribute,
webAreaObject and stringForRange.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::postTextStateChangeNotification):
(WebCore::AXObjectCache::updateIsolatedTree):
(WebCore::AXObjectCache::rootWebArea):
* accessibility/AXObjectCache.h:
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isLoaded const):
(WebCore::AccessibilityRenderObject::accessKey const):
* accessibility/AccessibilityScrollView.h:
* accessibility/ios/AXObjectCacheIOS.mm:
(WebCore::AXObjectCache::postTextStateChangePlatformNotification):
(WebCore::AXObjectCache::postTextReplacementPlatformNotification):
(WebCore::AXObjectCache::postTextReplacementPlatformNotificationForTextControl):
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::stringForRange const):
(WebCore::AXIsolatedObject::hasApplePDFAnnotationAttribute const): Deleted.
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::removeNode):
(WebCore::AXIsolatedTree::applyPendingChanges):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postTextStateChangePlatformNotification):
(WebCore::addTextMarkerFor):
(WebCore::textReplacementChangeDictionary):
(WebCore::postUserInfoForChanges):
(WebCore::AXObjectCache::postTextReplacementPlatformNotification):
(WebCore::AXObjectCache::postTextReplacementPlatformNotificationForTextControl):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper textMarkerRangeFromVisiblePositions:endPosition:]):
(-[WebAccessibilityObjectWrapper associatedPluginParent]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):

Tools:

* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AccessibilityController::AccessibilityController): Initializes m_useAXThread.
(WTR::AccessibilityController::rootElement): No need to set m_useAXThread here since it is initialize in the constructor.
* WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
(WTR::AccessibilityController::accessibleElementById): Same as above.

LayoutTests:

* accessibility/mac/aria-expanded-notifications.html:
With this change, we now get the FocusChanged notification when the
script sets focus to a tree item.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (257738 => 257739)


--- trunk/LayoutTests/ChangeLog	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/LayoutTests/ChangeLog	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1,3 +1,14 @@
+2020-03-02  Andres Gonzalez  <[email protected]>
+
+        Fix for LayoutTests/accessibility/mac/search-text/search-text.html in IsolatedTree mode.
+        https://bugs.webkit.org/show_bug.cgi?id=208434
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/aria-expanded-notifications.html:
+        With this change, we now get the FocusChanged notification when the
+        script sets focus to a tree item.
+
 2020-03-02  Jason Lawrence  <[email protected]>
 
         [ Mac wk2 ] tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler.html is flaky failing.

Modified: trunk/LayoutTests/accessibility/mac/aria-expanded-notifications.html (257738 => 257739)


--- trunk/LayoutTests/accessibility/mac/aria-expanded-notifications.html	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/LayoutTests/accessibility/mac/aria-expanded-notifications.html	2020-03-02 22:50:30 UTC (rev 257739)
@@ -30,7 +30,9 @@
     var notifyName = 0;
     // The order of notifications should be Row Count, Row Collapsed, Row Count, Row Expanded
     function notifyCallback(element, notification) {  
-        if (notification == "AXLoadComplete" || notification == "AXLayoutComplete")
+        if (notification == "AXLoadComplete"
+            || notification == "AXLayoutComplete"
+            || notification == "AXFocusChanged")
             return;
         notifyName = notification;
         if (notifyCount == 0)

Modified: trunk/Source/WebCore/ChangeLog (257738 => 257739)


--- trunk/Source/WebCore/ChangeLog	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/ChangeLog	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1,3 +1,53 @@
+2020-03-02  Andres Gonzalez  <[email protected]>
+
+        Fix for LayoutTests/accessibility/mac/search-text/search-text.html in IsolatedTree mode.
+        https://bugs.webkit.org/show_bug.cgi?id=208434
+
+        Reviewed by Chris Fleizach.
+
+        Covered by LayoutTests/accessibility/mac/search-text/search-text.html
+
+        - Updates IsolatedTree for AXSelectedTextChanged notifications.
+        - Exposes webAreaObject through the AXCoreObject interface.
+        - AXIsolatedObject implementation for hasApplePDFAnnotationAttribute,
+        webAreaObject and stringForRange.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::postTextStateChangeNotification):
+        (WebCore::AXObjectCache::updateIsolatedTree):
+        (WebCore::AXObjectCache::rootWebArea):
+        * accessibility/AXObjectCache.h:
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isLoaded const):
+        (WebCore::AccessibilityRenderObject::accessKey const):
+        * accessibility/AccessibilityScrollView.h:
+        * accessibility/ios/AXObjectCacheIOS.mm:
+        (WebCore::AXObjectCache::postTextStateChangePlatformNotification):
+        (WebCore::AXObjectCache::postTextReplacementPlatformNotification):
+        (WebCore::AXObjectCache::postTextReplacementPlatformNotificationForTextControl):
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        (WebCore::AXIsolatedObject::stringForRange const):
+        (WebCore::AXIsolatedObject::hasApplePDFAnnotationAttribute const): Deleted.
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::removeNode):
+        (WebCore::AXIsolatedTree::applyPendingChanges):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postTextStateChangePlatformNotification):
+        (WebCore::addTextMarkerFor):
+        (WebCore::textReplacementChangeDictionary):
+        (WebCore::postUserInfoForChanges):
+        (WebCore::AXObjectCache::postTextReplacementPlatformNotification):
+        (WebCore::AXObjectCache::postTextReplacementPlatformNotificationForTextControl):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper textMarkerRangeFromVisiblePositions:endPosition:]):
+        (-[WebAccessibilityObjectWrapper associatedPluginParent]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+
 2020-03-02  Wenson Hsieh  <[email protected]>
 
         Make Path::Path(const Path&) and Path::operator=(const Path&) cheap

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1364,6 +1364,10 @@
         }
     }
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    updateIsolatedTree(object, AXSelectedTextChanged);
+#endif
+
     postTextStateChangeNotification(object, intent, selection);
 #else
     postTextStateChangeNotification(node, intent, selection);
@@ -3139,6 +3143,7 @@
     switch (notification) {
     case AXCheckedStateChanged:
     case AXChildrenChanged:
+    case AXSelectedTextChanged:
     case AXValueChanged: {
         tree->removeSubtree(object->objectID());
         auto* parent = object->parentObject();
@@ -3239,12 +3244,12 @@
     return !requiresAriaHiddenFalse || ariaHiddenFalsePresent;
 }
 
-AccessibilityObject* AXObjectCache::rootWebArea()
+AXCoreObject* AXObjectCache::rootWebArea()
 {
     AXCoreObject* rootObject = this->rootObject();
     if (!rootObject || !rootObject->isAccessibilityScrollView())
         return nullptr;
-    return downcast<AccessibilityScrollView>(*rootObject).webAreaObject();
+    return rootObject->webAreaObject();
 }
 
 AXAttributeCacheEnabler::AXAttributeCacheEnabler(AXObjectCache* cache)

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -368,10 +368,10 @@
     void platformPerformDeferredCacheUpdate();
 
 #if PLATFORM(COCOA)
-    void postTextStateChangePlatformNotification(AccessibilityObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
+    void postTextStateChangePlatformNotification(AXCoreObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
     void postTextStateChangePlatformNotification(AccessibilityObject*, AXTextEditType, const String&, const VisiblePosition&);
-    void postTextReplacementPlatformNotificationForTextControl(AccessibilityObject*, const String& deletedText, const String& insertedText, HTMLTextFormControlElement&);
-    void postTextReplacementPlatformNotification(AccessibilityObject*, AXTextEditType, const String&, AXTextEditType, const String&, const VisiblePosition&);
+    void postTextReplacementPlatformNotificationForTextControl(AXCoreObject*, const String& deletedText, const String& insertedText, HTMLTextFormControlElement&);
+    void postTextReplacementPlatformNotification(AXCoreObject*, AXTextEditType, const String&, AXTextEditType, const String&, const VisiblePosition&);
 #else
     static AXTextChange textChangeForEditType(AXTextEditType);
     void nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&);
@@ -412,7 +412,7 @@
     bool shouldSkipBoundary(const CharacterOffset&, const CharacterOffset&);
 
 private:
-    AccessibilityObject* rootWebArea();
+    AXCoreObject* rootWebArea();
 
     static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);
     static AXCoreObject* focusedObject(Document&);

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -756,6 +756,7 @@
     AccessibilityObject* highestEditableAncestor() override;
 
     const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const override;
+    AccessibilityObject* webAreaObject() const override { return nullptr; }
 
     void clearIsIgnoredFromParentData() override { m_isIgnoredFromParentData = AccessibilityIsIgnoredFromParentData(); }
     void setIsIgnoredFromParentDataForChild(AXCoreObject*) override;

Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1160,6 +1160,7 @@
     virtual AXCoreObject* highestEditableAncestor() = 0;
 
     virtual const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const = 0;
+    virtual AXCoreObject* webAreaObject() const = 0;
 
     virtual void setIsIgnoredFromParentData(AccessibilityIsIgnoredFromParentData&) = 0;
     virtual void clearIsIgnoredFromParentData() = 0;

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1492,7 +1492,7 @@
 
 bool AccessibilityRenderObject::isLoaded() const
 {
-    return !m_renderer->document().parser();
+    return m_renderer ? !m_renderer->document().parser() : false;
 }
 
 double AccessibilityRenderObject::estimatedLoadingProgress() const
@@ -1572,9 +1572,13 @@
 
 String AccessibilityRenderObject::accessKey() const
 {
+    if (!m_renderer)
+        return String();
+
     Node* node = m_renderer->node();
     if (!is<Element>(node))
-        return nullAtom();
+        return String();
+
     return downcast<Element>(*node).attributeWithoutSynchronization(accesskeyAttr);
 }
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityScrollView.h (257738 => 257739)


--- trunk/Source/WebCore/accessibility/AccessibilityScrollView.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/AccessibilityScrollView.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -41,7 +41,7 @@
 
     virtual ~AccessibilityScrollView();
 
-    AccessibilityObject* webAreaObject() const;
+    AccessibilityObject* webAreaObject() const override;
 
 private:
     explicit AccessibilityScrollView(ScrollView*);
@@ -71,7 +71,7 @@
     LayoutRect elementRect() const override;
     AccessibilityObject* parentObject() const override;
     AccessibilityObject* parentObjectIfExists() const override;
-    
+
     AccessibilityObject* firstChild() const override { return webAreaObject(); }
     AccessibilityScrollbar* addChildScrollbar(Scrollbar*);
     void removeChildScrollbar(AccessibilityObject*);

Modified: trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm (257738 => 257739)


--- trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2020-03-02 22:50:30 UTC (rev 257739)
@@ -92,7 +92,7 @@
         [obj->wrapper() accessibilityPostedNotification:notificationString];
 }
 
-void AXObjectCache::postTextStateChangePlatformNotification(AccessibilityObject* object, const AXTextStateChangeIntent&, const VisibleSelection&)
+void AXObjectCache::postTextStateChangePlatformNotification(AXCoreObject* object, const AXTextStateChangeIntent&, const VisibleSelection&)
 {
     postPlatformNotification(object, AXSelectedTextChanged);
 }
@@ -102,12 +102,12 @@
     postPlatformNotification(object, AXValueChanged);
 }
 
-void AXObjectCache::postTextReplacementPlatformNotification(AccessibilityObject* object, AXTextEditType, const String&, AXTextEditType, const String&, const VisiblePosition&)
+void AXObjectCache::postTextReplacementPlatformNotification(AXCoreObject* object, AXTextEditType, const String&, AXTextEditType, const String&, const VisiblePosition&)
 {
     postPlatformNotification(object, AXValueChanged);
 }
 
-void AXObjectCache::postTextReplacementPlatformNotificationForTextControl(AccessibilityObject* object, const String&, const String&, HTMLTextFormControlElement&)
+void AXObjectCache::postTextReplacementPlatformNotificationForTextControl(AXCoreObject* object, const String&, const String&, HTMLTextFormControlElement&)
 {
     postPlatformNotification(object, AXValueChanged);
 }

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (257738 => 257739)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -59,6 +59,8 @@
     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());
@@ -206,7 +208,6 @@
     setProperty(AXPropertyName::HierarchicalLevel, object.hierarchicalLevel());
     setProperty(AXPropertyName::Language, object.language());
     setProperty(AXPropertyName::CanHaveSelectedChildren, object.canHaveSelectedChildren());
-    setProperty(AXPropertyName::HasARIAValueNow, object.hasARIAValueNow());
     setProperty(AXPropertyName::TagName, object.tagName().isolatedCopy());
     setProperty(AXPropertyName::SupportsLiveRegion, object.supportsLiveRegion());
     setProperty(AXPropertyName::IsInsideLiveRegion, object.isInsideLiveRegion());
@@ -378,6 +379,7 @@
     }
     
     if (isRoot) {
+        setObjectProperty(AXPropertyName::WebArea, object.webAreaObject());
         setProperty(AXPropertyName::PreventKeyboardDOMEventDispatch, object.preventKeyboardDOMEventDispatch());
         setProperty(AXPropertyName::SessionID, object.sessionID());
         setProperty(AXPropertyName::DocumentURI, object.documentURI());
@@ -864,6 +866,15 @@
     }
 }
 
+String AXIsolatedObject::stringForRange(RefPtr<Range> range) const
+{
+    return Accessibility::retrieveValueFromMainThread<String>([&range, this] () -> String {
+        if (auto* object = associatedAXObject())
+            return object->stringForRange(range);
+        return String();
+    });
+}
+
 Vector<RefPtr<Range>> AXIsolatedObject::findTextRanges(AccessibilitySearchTextCriteria const& criteria) const
 {
     return Accessibility::retrieveValueFromMainThread<Vector<RefPtr<Range>>>([&criteria, this] () -> Vector<RefPtr<Range>> {
@@ -1870,12 +1881,6 @@
     return AccessibilityObjectInclusion::DefaultBehavior;
 }
 
-bool AXIsolatedObject::hasApplePDFAnnotationAttribute() const
-{
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
 const AccessibilityScrollView* AXIsolatedObject::ancestorAccessibilityScrollView(bool) const
 {
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (257738 => 257739)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -144,6 +144,7 @@
         FileUploadButtonReturnsValueInTitle,
         FocusableAncestor,
         HasARIAValueNow,
+        HasApplePDFAnnotationAttribute,
         HasChildren,
         HasPopup,
         HeaderContainer,
@@ -328,6 +329,7 @@
         VerticalScrollBar,
         VisibleChildren,
         VisibleRows,
+        WebArea,
     };
     
     typedef std::pair<AXID, AXID> AccessibilityIsolatedTreeMathMultiscriptPair;
@@ -643,7 +645,7 @@
     VisiblePositionRange visiblePositionRangeForRange(const PlainTextRange&) const override { return VisiblePositionRange(); }
     VisiblePositionRange lineRangeForPosition(const VisiblePosition&) const override { return VisiblePositionRange(); }
     RefPtr<Range> rangeForPlainTextRange(const PlainTextRange&) const override { return nullptr; }
-    String stringForRange(RefPtr<Range>) const override { return String(); }
+    String stringForRange(RefPtr<Range>) const override;
     IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const override { return IntRect(); }
     IntRect boundsForRange(const RefPtr<Range>) const override { return IntRect(); }
     int lengthForVisiblePositionRange(const VisiblePositionRange&) const override { return 0; }
@@ -875,8 +877,9 @@
     void overrideAttachmentParent(AXCoreObject* parent) override;
     bool accessibilityIgnoreAttachment() const override;
     AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const override;
-    bool hasApplePDFAnnotationAttribute() const override;
+    bool hasApplePDFAnnotationAttribute() const override { return boolAttributeValue(AXPropertyName::HasApplePDFAnnotationAttribute); }
     const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const override;
+    AXCoreObject* webAreaObject() const override { return objectAttributeValue(AXPropertyName::WebArea); }
     void setIsIgnoredFromParentData(AccessibilityIsIgnoredFromParentData&) override;
     void clearIsIgnoredFromParentData() override;
     void setIsIgnoredFromParentDataForChild(AXCoreObject*) override;

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (257738 => 257739)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -174,7 +174,6 @@
 void AXIsolatedTree::removeNode(AXID axID)
 {
     LockHolder locker { m_changeLogLock };
-    ASSERT(m_readerThreadNodeMap.contains(axID));
     m_pendingRemovals.append(axID);
 }
 
@@ -215,17 +214,24 @@
     m_pendingRemovals.clear();
 
     for (const auto& item : m_pendingAppends) {
-        ASSERT(!m_readerThreadNodeMap.contains(item.m_isolatedObject->objectID())
-            || item.m_isolatedObject->objectID() == m_rootNodeID);
+        AXID axID = item.m_isolatedObject->objectID();
 
-        if (item.m_wrapper)
-            item.m_isolatedObject->attachPlatformWrapper(item.m_wrapper);
+        if (m_readerThreadNodeMap.get(axID) != &item.m_isolatedObject.get()) {
+            // The new IsolatedObject is a replacement for an existing object
+            // as the result of an update. Thus detach the existing one before
+            // adding the new one.
+            if (auto object = nodeForID(axID))
+                object->detach(AccessibilityDetachmentType::ElementDestroyed);
+            m_readerThreadNodeMap.remove(axID);
+        }
 
-        m_readerThreadNodeMap.add(item.m_isolatedObject->objectID(), item.m_isolatedObject.get());
+        if (m_readerThreadNodeMap.add(axID, item.m_isolatedObject.get()) && item.m_wrapper)
+            m_readerThreadNodeMap.get(axID)->attachPlatformWrapper(item.m_wrapper);
+
         // The reference count of the just added IsolatedObject must be 2
         // because it is referenced by m_readerThreadNodeMap and m_pendingAppends.
         // When m_pendingAppends is cleared, the object will be held only by m_readerThreadNodeMap.
-        ASSERT(m_readerThreadNodeMap.get(item.m_isolatedObject->objectID())->refCount() == 2);
+        ASSERT(m_readerThreadNodeMap.get(axID)->refCount() == 2);
     }
     m_pendingAppends.clear();
 }

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (257738 => 257739)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2020-03-02 22:50:30 UTC (rev 257739)
@@ -364,7 +364,7 @@
     AXPostNotificationWithUserInfo(obj->wrapper(), macNotification, nil, skipSystemNotification);
 }
 
-void AXObjectCache::postTextStateChangePlatformNotification(AccessibilityObject* object, const AXTextStateChangeIntent& intent, const VisibleSelection& selection)
+void AXObjectCache::postTextStateChangePlatformNotification(AXCoreObject* object, const AXTextStateChangeIntent& intent, const VisibleSelection& selection)
 {
     if (!object)
         object = rootWebArea();
@@ -419,7 +419,7 @@
     [userInfo release];
 }
 
-static void addTextMarkerFor(NSMutableDictionary* change, AccessibilityObject& object, const VisiblePosition& position)
+static void addTextMarkerFor(NSMutableDictionary* change, AXCoreObject& object, const VisiblePosition& position)
 {
     if (position.isNull())
         return;
@@ -427,7 +427,7 @@
         [change setObject:textMarker forKey:NSAccessibilityTextChangeValueStartMarker];
 }
 
-static void addTextMarkerFor(NSMutableDictionary* change, AccessibilityObject& object, HTMLTextFormControlElement& textControl)
+static void addTextMarkerFor(NSMutableDictionary* change, AXCoreObject& object, HTMLTextFormControlElement& textControl)
 {
     if (id textMarker = [object.wrapper() textMarkerForFirstPositionInTextControl:textControl])
         [change setObject:textMarker forKey:NSAccessibilityTextChangeValueStartMarker];
@@ -434,7 +434,7 @@
 }
 
 template <typename TextMarkerTargetType>
-static NSDictionary *textReplacementChangeDictionary(AccessibilityObject& object, AXTextEditType type, const String& string, TextMarkerTargetType& markerTarget)
+static NSDictionary *textReplacementChangeDictionary(AXCoreObject& object, AXTextEditType type, const String& string, TextMarkerTargetType& markerTarget)
 {
     NSString *text = (NSString *)string;
     NSUInteger length = [text length];
@@ -459,7 +459,7 @@
     postTextReplacementPlatformNotification(object, AXTextEditTypeUnknown, emptyString(), type, text, position);
 }
 
-static void postUserInfoForChanges(AccessibilityObject& rootWebArea, AccessibilityObject& object, NSMutableArray* changes)
+static void postUserInfoForChanges(AXCoreObject& rootWebArea, AXCoreObject& object, NSMutableArray* changes)
 {
     NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] initWithCapacity:4];
     [userInfo setObject:@(platformChangeTypeForWebCoreChangeType(AXTextStateChangeTypeEdit)) forKey:NSAccessibilityTextStateChangeTypeKey];
@@ -476,7 +476,7 @@
     [userInfo release];
 }
 
-void AXObjectCache::postTextReplacementPlatformNotification(AccessibilityObject* object, AXTextEditType deletionType, const String& deletedText, AXTextEditType insertionType, const String& insertedText, const VisiblePosition& position)
+void AXObjectCache::postTextReplacementPlatformNotification(AXCoreObject* object, AXTextEditType deletionType, const String& deletedText, AXTextEditType insertionType, const String& insertedText, const VisiblePosition& position)
 {
     if (!object)
         object = rootWebArea();
@@ -493,7 +493,7 @@
     [changes release];
 }
 
-void AXObjectCache::postTextReplacementPlatformNotificationForTextControl(AccessibilityObject* object, const String& deletedText, const String& insertedText, HTMLTextFormControlElement& textControl)
+void AXObjectCache::postTextReplacementPlatformNotificationForTextControl(AXCoreObject* object, const String& deletedText, const String& insertedText, HTMLTextFormControlElement& textControl)
 {
     if (!object)
         object = rootWebArea();

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (257738 => 257739)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1334,7 +1334,11 @@
 
 - (id)textMarkerRangeFromVisiblePositions:(const VisiblePosition&)startPosition endPosition:(const VisiblePosition&)endPosition
 {
-    return textMarkerRangeFromVisiblePositions(self.axBackingObject->axObjectCache(), startPosition, endPosition);
+    auto* backingObject = self.updateObjectBackingStore;
+    if (!backingObject)
+        return nil;
+
+    return textMarkerRangeFromVisiblePositions(backingObject->axObjectCache(), startPosition, endPosition);
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -1955,17 +1959,18 @@
 - (id)associatedPluginParent
 {
     return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([protectedSelf = RetainPtr<WebAccessibilityObjectWrapper>(self)] () -> RetainPtr<id> {
-        if (!protectedSelf.get().axBackingObject || !protectedSelf.get().axBackingObject->hasApplePDFAnnotationAttribute())
+        auto* backingObject = protectedSelf.get().axBackingObject;
+        if (!backingObject || !backingObject->hasApplePDFAnnotationAttribute())
             return nil;
-    
-        if (!protectedSelf.get().axBackingObject->document()->isPluginDocument())
+
+        if (!backingObject->document()->isPluginDocument())
             return nil;
-        
-        Widget* pluginWidget = static_cast<PluginDocument*>(protectedSelf.get().axBackingObject->document())->pluginWidget();
+
+        Widget* pluginWidget = static_cast<PluginDocument*>(backingObject->document())->pluginWidget();
         if (!pluginWidget || !pluginWidget->isPluginViewBase())
             return nil;
-        
-        return static_cast<PluginViewBase*>(pluginWidget)->accessibilityAssociatedPluginParentForElement(protectedSelf.get().axBackingObject->element());
+
+        return static_cast<PluginViewBase*>(pluginWidget)->accessibilityAssociatedPluginParentForElement(backingObject->element());
     });
 }
 
@@ -3071,7 +3076,7 @@
     if ([attributeName isEqualToString:@"AXDRTSpeechAttribute"])
         return [self baseAccessibilitySpeechHint];
 
-    // Used by DRT to find an accessible node by its element id.
+    // Used by TestRunner and DRT AccessibilityController to find an accessible node by its element id.
     if ([attributeName isEqualToString:@"AXDRTElementIdAttribute"])
         return backingObject->identifierAttribute();
 
@@ -3987,8 +3992,11 @@
     }
 
     if ([attribute isEqualToString:@"AXStringForTextMarkerRange"]) {
-        RefPtr<Range> range = [self rangeForTextMarkerRange:textMarkerRange];
-        return backingObject->stringForRange(range);
+        return Accessibility::retrieveValueFromMainThread<String>([&textMarkerRange, protectedSelf = RetainPtr<WebAccessibilityObjectWrapper>(self)] () -> String {
+            RefPtr<Range> range = [protectedSelf rangeForTextMarkerRange:textMarkerRange];
+            auto* backingObject = protectedSelf.get().axBackingObject;
+            return backingObject ? backingObject->stringForRange(range) : String();
+        });
     }
 
     if ([attribute isEqualToString:@"AXTextMarkerForPosition"]) {

Modified: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp (257738 => 257739)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -55,10 +55,10 @@
 
 static AccessibilityObjectWrapper* rootWebAreaWrapper(AXCoreObject& rootObject)
 {
-    if (!rootObject.isAccessibilityScrollView())
+    if (!rootObject.isScrollView())
         return nullptr;
 
-    if (auto* webAreaObject = downcast<AccessibilityScrollView>(rootObject).webAreaObject())
+    if (auto* webAreaObject = rootObject.webAreaObject())
         return webAreaObject->wrapper();
 
     return nullptr;

Modified: trunk/Tools/ChangeLog (257738 => 257739)


--- trunk/Tools/ChangeLog	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Tools/ChangeLog	2020-03-02 22:50:30 UTC (rev 257739)
@@ -1,3 +1,16 @@
+2020-03-02  Andres Gonzalez  <[email protected]>
+
+        Fix for LayoutTests/accessibility/mac/search-text/search-text.html in IsolatedTree mode.
+        https://bugs.webkit.org/show_bug.cgi?id=208434
+
+        Reviewed by Chris Fleizach.
+
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
+        (WTR::AccessibilityController::AccessibilityController): Initializes m_useAXThread.
+        (WTR::AccessibilityController::rootElement): No need to set m_useAXThread here since it is initialize in the constructor.
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
+        (WTR::AccessibilityController::accessibleElementById): Same as above.
+
 2020-03-02  John Wilander  <[email protected]>
 
         ResourceLoadStatistics: Enable cookie blocking and the Storage Access API in ephemeral sessions

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp (257738 => 257739)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp	2020-03-02 22:50:30 UTC (rev 257739)
@@ -46,6 +46,9 @@
 
 AccessibilityController::AccessibilityController()
 {
+#if PLATFORM(COCOA)
+    m_useAXThread = WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page());
+#endif
 }
 
 AccessibilityController::~AccessibilityController()
@@ -78,11 +81,6 @@
     WKBundlePageRef page = InjectedBundle::singleton().page()->page();
     PlatformUIElement root = static_cast<PlatformUIElement>(WKAccessibilityRootObject(page));
 
-    // Now that we have a root and the isolated tree is generated, set
-    // m_useAXThread to true for next request to be handled in the secondary thread.
-    if (WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page()))
-        m_useAXThread = true;
-
     return AccessibilityUIElement::create(root);
 }
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h (257738 => 257739)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h	2020-03-02 22:50:30 UTC (rev 257739)
@@ -96,11 +96,6 @@
     // do not work for WebKitTestRunner since this is calling directly into
     // WebCore/accessibility via _javascript_ without going through HIServices.
     // Thus to simulate the behavior of HIServices, AccessibilityController is spawning a secondary thread to service the _javascript_ requests.
-    // The following flag allows to run the very first request in the main
-    // thread and all subsequent requests in the secondary thread. this is what
-    // the behavior would be if using HIServices.
-    // The first request has to be served in the main thread in order to build
-    // the AXIsolatedTree.
     bool m_useAXThread { false };
     BinarySemaphore m_semaphore;
 #endif

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm (257738 => 257739)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm	2020-03-02 22:26:17 UTC (rev 257738)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm	2020-03-02 22:50:30 UTC (rev 257739)
@@ -103,11 +103,6 @@
         root = static_cast<PlatformUIElement>(WKAccessibilityRootObject(page));
     });
 
-    // Now that we have a root and the isolated tree is generated, set
-    // m_useAXThread to true for next request to be handled in the secondary thread.
-    if (WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page()))
-        m_useAXThread = true;
-
     id result;
     executeOnAXThreadIfPossible([&root, &idAttribute, &result] {
         result = findAccessibleObjectById(root, [NSString stringWithJSStringRef:idAttribute]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to