Title: [244107] trunk
Revision
244107
Author
[email protected]
Date
2019-04-10 01:01:01 -0700 (Wed, 10 Apr 2019)

Log Message

[ATK] Defer the emision of AtkObject::children-changed signal after layout is done
https://bugs.webkit.org/show_bug.cgi?id=187948

Reviewed by Michael Catanzaro.

Source/WebCore:

The signal AtkObject::children-changed is emitted from AXObjectCache::attachWrapper() and
AXObjectCache::detachWrapper(). Both can be called in the middle of a layout, so we need to defer the emission
of the signal after the layout is done, to avoid other atk entry points from being called at that point, since
most of them update the backing store at the beginning.

Fixes: accessibility/children-changed-sends-notification.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::performDeferredCacheUpdate): Call platformPerformDeferredCacheUpdate().
* accessibility/AXObjectCache.h:
* accessibility/atk/AXObjectCacheAtk.cpp:
(WebCore::wrapperParent): Helper to get the AtkObject parent of a given WebKitAccessible.
(WebCore::AXObjectCache::detachWrapper): Add wrapper to m_deferredDetachedWrapperList.
(WebCore::AXObjectCache::attachWrapper): Add object to m_deferredAttachedWrapperObjectList.
(WebCore::AXObjectCache::platformPerformDeferredCacheUpdate): Emit AtkObject::children-changed::add for objects
in m_deferredAttachedWrapperObjectList and AtkObject::children-changed::remove for wrappers in m_deferredDetachedWrapperList.
* accessibility/ios/AXObjectCacheIOS.mm:
(WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
* accessibility/win/AXObjectCacheWin.cpp:
(WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
* accessibility/wpe/AXObjectCacheWPE.cpp:
(WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):

LayoutTests:

Remove expectations of accessibility/children-changed-sends-notification.html that passes now.

* platform/gtk/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (244106 => 244107)


--- trunk/LayoutTests/ChangeLog	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/LayoutTests/ChangeLog	2019-04-10 08:01:01 UTC (rev 244107)
@@ -1,5 +1,16 @@
 2019-04-10  Carlos Garcia Campos  <[email protected]>
 
+        [ATK] Defer the emision of AtkObject::children-changed signal after layout is done
+        https://bugs.webkit.org/show_bug.cgi?id=187948
+
+        Reviewed by Michael Catanzaro.
+
+        Remove expectations of accessibility/children-changed-sends-notification.html that passes now.
+
+        * platform/gtk/TestExpectations:
+
+2019-04-10  Carlos Garcia Campos  <[email protected]>
+
         [ATK] Test accessibility/insert-children-assert.html is crashing since added in r216980
         https://bugs.webkit.org/show_bug.cgi?id=172281
         <rdar://problem/37030990>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (244106 => 244107)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-04-10 08:01:01 UTC (rev 244107)
@@ -3212,7 +3212,6 @@
 webkit.org/b/160251 fast/text/font-kerning.html [ ImageOnlyFailure ]
 
 webkit.org/b/161583 accessibility/auto-fill-types.html [ Failure ]
-webkit.org/b/161584 accessibility/children-changed-sends-notification.html [ Failure Crash ]
 
 webkit.org/b/161587 css3/font-feature-settings-rendering.html [ ImageOnlyFailure ]
 webkit.org/b/161588 css3/font-variant-synthesis-jdaggett.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (244106 => 244107)


--- trunk/Source/WebCore/ChangeLog	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/ChangeLog	2019-04-10 08:01:01 UTC (rev 244107)
@@ -1,5 +1,37 @@
 2019-04-10  Carlos Garcia Campos  <[email protected]>
 
+        [ATK] Defer the emision of AtkObject::children-changed signal after layout is done
+        https://bugs.webkit.org/show_bug.cgi?id=187948
+
+        Reviewed by Michael Catanzaro.
+
+        The signal AtkObject::children-changed is emitted from AXObjectCache::attachWrapper() and
+        AXObjectCache::detachWrapper(). Both can be called in the middle of a layout, so we need to defer the emission
+        of the signal after the layout is done, to avoid other atk entry points from being called at that point, since
+        most of them update the backing store at the beginning.
+
+        Fixes: accessibility/children-changed-sends-notification.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::performDeferredCacheUpdate): Call platformPerformDeferredCacheUpdate().
+        * accessibility/AXObjectCache.h:
+        * accessibility/atk/AXObjectCacheAtk.cpp:
+        (WebCore::wrapperParent): Helper to get the AtkObject parent of a given WebKitAccessible.
+        (WebCore::AXObjectCache::detachWrapper): Add wrapper to m_deferredDetachedWrapperList.
+        (WebCore::AXObjectCache::attachWrapper): Add object to m_deferredAttachedWrapperObjectList.
+        (WebCore::AXObjectCache::platformPerformDeferredCacheUpdate): Emit AtkObject::children-changed::add for objects
+        in m_deferredAttachedWrapperObjectList and AtkObject::children-changed::remove for wrappers in m_deferredDetachedWrapperList.
+        * accessibility/ios/AXObjectCacheIOS.mm:
+        (WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
+        * accessibility/win/AXObjectCacheWin.cpp:
+        (WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
+        * accessibility/wpe/AXObjectCacheWPE.cpp:
+        (WebCore::AXObjectCache::platformPerformDeferredCacheUpdate):
+
+2019-04-10  Carlos Garcia Campos  <[email protected]>
+
         [ATK] Test accessibility/insert-children-assert.html is crashing since added in r216980
         https://bugs.webkit.org/show_bug.cgi?id=172281
         <rdar://problem/37030990>

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (244106 => 244107)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2019-04-10 08:01:01 UTC (rev 244107)
@@ -2919,6 +2919,8 @@
     for (auto& deferredFocusedChangeContext : m_deferredFocusedNodeChange)
         handleFocusedUIElementChanged(deferredFocusedChangeContext.first, deferredFocusedChangeContext.second);
     m_deferredFocusedNodeChange.clear();
+
+    platformPerformDeferredCacheUpdate();
 }
     
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (244106 => 244107)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2019-04-10 08:01:01 UTC (rev 244107)
@@ -40,6 +40,10 @@
 #include <wtf/ListHashSet.h>
 #include <wtf/RefPtr.h>
 
+#if PLATFORM(GTK)
+#include <wtf/glib/GRefPtr.h>
+#endif
+
 namespace WebCore {
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
@@ -355,6 +359,8 @@
     void postPlatformNotification(AccessibilityObject*, AXNotification);
     void platformHandleFocusedUIElementChanged(Node* oldFocusedNode, Node* newFocusedNode);
 
+    void platformPerformDeferredCacheUpdate();
+
 #if PLATFORM(COCOA)
     void postTextStateChangePlatformNotification(AccessibilityObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
     void postTextStateChangePlatformNotification(AccessibilityObject*, AXTextEditType, const String&, const VisiblePosition&);
@@ -476,6 +482,11 @@
     Vector<std::pair<Node*, Node*>> m_deferredFocusedNodeChange;
     bool m_isSynchronizingSelection { false };
     bool m_performingDeferredCacheUpdate { false };
+
+#if PLATFORM(GTK)
+    ListHashSet<RefPtr<AccessibilityObject>> m_deferredAttachedWrapperObjectList;
+    ListHashSet<GRefPtr<AccessibilityObjectWrapper>> m_deferredDetachedWrapperList;
+#endif
 };
 
 class AXAttributeCacheEnabler

Modified: trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp (244106 => 244107)


--- trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp	2019-04-10 08:01:01 UTC (rev 244107)
@@ -36,6 +36,18 @@
 
 namespace WebCore {
 
+static AtkObject* wrapperParent(WebKitAccessible* wrapper)
+{
+    // Look for the right object to emit the signal from, but using the implementation
+    // of atk_object_get_parent from AtkObject class (which uses a cached pointer if set)
+    // since the accessibility hierarchy in WebCore will no longer be navigable.
+    gpointer webkitAccessibleClass = g_type_class_peek_parent(WEBKIT_ACCESSIBLE_GET_CLASS(wrapper));
+    gpointer atkObjectClass = g_type_class_peek_parent(webkitAccessibleClass);
+    AtkObject* atkParent = ATK_OBJECT_CLASS(atkObjectClass)->get_parent(ATK_OBJECT(wrapper));
+    // We don't want to emit any signal from an object outside WebKit's world.
+    return WEBKIT_IS_ACCESSIBLE(atkParent) ? atkParent : nullptr;
+}
+
 void AXObjectCache::detachWrapper(AccessibilityObject* obj, AccessibilityDetachmentType detachmentType)
 {
     auto* wrapper = obj->wrapper();
@@ -43,24 +55,9 @@
 
     // If an object is being detached NOT because of the AXObjectCache being destroyed,
     // then it's being removed from the accessibility tree and we should emit a signal.
-    if (detachmentType != AccessibilityDetachmentType::CacheDestroyed) {
-        if (obj->document()) {
-            // Look for the right object to emit the signal from, but using the implementation
-            // of atk_object_get_parent from AtkObject class (which uses a cached pointer if set)
-            // since the accessibility hierarchy in WebCore will no longer be navigable.
-            gpointer webkitAccessibleClass = g_type_class_peek_parent(WEBKIT_ACCESSIBLE_GET_CLASS(wrapper));
-            gpointer atkObjectClass = g_type_class_peek_parent(webkitAccessibleClass);
-            AtkObject* atkParent = ATK_OBJECT_CLASS(atkObjectClass)->get_parent(ATK_OBJECT(wrapper));
+    if (detachmentType != AccessibilityDetachmentType::CacheDestroyed && obj->document() && wrapperParent(wrapper))
+        m_deferredDetachedWrapperList.add(wrapper);
 
-            // We don't want to emit any signal from an object outside WebKit's world.
-            if (WEBKIT_IS_ACCESSIBLE(atkParent)) {
-                // The accessibility hierarchy is already invalid, so the parent-children relationships
-                // in the AccessibilityObject tree are not there anymore, so we can't know the offset.
-                g_signal_emit_by_name(atkParent, "children-changed::remove", -1, wrapper);
-            }
-        }
-    }
-
     webkitAccessibleDetach(WEBKIT_ACCESSIBLE(wrapper));
 }
 
@@ -87,18 +84,39 @@
     if (!obj->renderer())
         return;
 
-    // Don't emit the signal for objects whose parents won't be exposed directly.
-    AccessibilityObject* coreParent = obj->parentObjectUnignored();
-    if (!coreParent || coreParent->accessibilityIsIgnoredByDefault())
-        return;
+    m_deferredAttachedWrapperObjectList.add(obj);
+}
 
-    // Look for the right object to emit the signal from.
-    auto* atkParent = coreParent->wrapper();
-    if (!atkParent)
-        return;
+void AXObjectCache::platformPerformDeferredCacheUpdate()
+{
+    for (auto& coreObject : m_deferredAttachedWrapperObjectList) {
+        auto* wrapper = coreObject->wrapper();
+        if (!wrapper)
+            continue;
 
-    size_t index = coreParent->children(false).find(obj);
-    g_signal_emit_by_name(atkParent, "children-changed::add", index != notFound ? index : -1, wrapper.get());
+        // Don't emit the signal for objects whose parents won't be exposed directly.
+        auto* coreParent = coreObject->parentObjectUnignored();
+        if (!coreParent || coreParent->accessibilityIsIgnoredByDefault())
+            continue;
+
+        // Look for the right object to emit the signal from.
+        auto* atkParent = coreParent->wrapper();
+        if (!atkParent)
+            continue;
+
+        size_t index = coreParent->children(false).find(coreObject);
+        g_signal_emit_by_name(atkParent, "children-changed::add", index != notFound ? index : -1, wrapper);
+    }
+    m_deferredAttachedWrapperObjectList.clear();
+
+    for (auto& wrapper : m_deferredDetachedWrapperList) {
+        if (auto* atkParent = wrapperParent(wrapper.get())) {
+            // The accessibility hierarchy is already invalid, so the parent-children relationships
+            // in the AccessibilityObject tree are not there anymore, so we can't know the offset.
+            g_signal_emit_by_name(atkParent, "children-changed::remove", -1, wrapper.get());
+        }
+    }
+    m_deferredDetachedWrapperList.clear();
 }
 
 static AccessibilityObject* getListObject(AccessibilityObject* object)

Modified: trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm (244106 => 244107)


--- trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2019-04-10 08:01:01 UTC (rev 244107)
@@ -135,7 +135,11 @@
 void AXObjectCache::handleScrolledToAnchor(const Node*)
 {
 }
-    
+
+void AXObjectCache::platformPerformDeferredCacheUpdate()
+{
 }
 
+}
+
 #endif // HAVE(ACCESSIBILITY) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (244106 => 244107)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2019-04-10 08:01:01 UTC (rev 244107)
@@ -547,6 +547,10 @@
 {
 }
 
+void AXObjectCache::platformPerformDeferredCacheUpdate()
+{
 }
 
+}
+
 #endif // HAVE(ACCESSIBILITY) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp (244106 => 244107)


--- trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp	2019-04-10 08:01:01 UTC (rev 244107)
@@ -183,4 +183,8 @@
     postPlatformNotification(focusedObject, AXFocusedUIElementChanged);
 }
 
+void AXObjectCache::platformPerformDeferredCacheUpdate()
+{
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/accessibility/wpe/AXObjectCacheWPE.cpp (244106 => 244107)


--- trunk/Source/WebCore/accessibility/wpe/AXObjectCacheWPE.cpp	2019-04-10 08:00:41 UTC (rev 244106)
+++ trunk/Source/WebCore/accessibility/wpe/AXObjectCacheWPE.cpp	2019-04-10 08:01:01 UTC (rev 244107)
@@ -60,6 +60,11 @@
     notImplemented();
 }
 
+void AXObjectCache::platformPerformDeferredCacheUpdate()
+{
+    notImplemented();
+}
+
 } // namespace WebCore
 
 #endif // HAVE(ACCESSIBILITY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to