- Revision
- 261694
- Author
- andresg...@apple.com
- Date
- 2020-05-14 08:35:45 -0700 (Thu, 14 May 2020)
Log Message
AXIsolatedTree::updateChildren needs to apply pending changes before updating the given node.
https://bugs.webkit.org/show_bug.cgi?id=211790
Reviewed by Chris Fleizach.
Covered by multiple tests.
AXIsolatedTree::updateChildren may be fired for an isolated object that
is still in the pending changes list, and thus nodeForID would fail,
causing the isolated tree to not be updated. This patch calls
applyPendingChanges before updating the given node's children.
Additional logging was added including the logging of the AXObjectCache
object hierarchy.
* accessibility/AXLogger.cpp:
(WebCore::AXLogger::log):
(WebCore::operator<<):
* accessibility/AXLogger.h:
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::remove):
(WebCore::AXObjectCache::postNotification):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::updateIsolatedTree):
* accessibility/AXObjectCache.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNode):
(WebCore::AXIsolatedTree::updateSubtree):
(WebCore::AXIsolatedTree::updateChildren):
(WebCore::AXIsolatedTree::focusedNode):
(WebCore::AXIsolatedTree::removeNode):
(WebCore::AXIsolatedTree::removeSubtree):
(WebCore::AXIsolatedTree::applyPendingChanges):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (261693 => 261694)
--- trunk/Source/WebCore/ChangeLog 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/ChangeLog 2020-05-14 15:35:45 UTC (rev 261694)
@@ -1,5 +1,42 @@
2020-05-14 Andres Gonzalez <andresg...@apple.com>
+ AXIsolatedTree::updateChildren needs to apply pending changes before updating the given node.
+ https://bugs.webkit.org/show_bug.cgi?id=211790
+
+ Reviewed by Chris Fleizach.
+
+ Covered by multiple tests.
+
+ AXIsolatedTree::updateChildren may be fired for an isolated object that
+ is still in the pending changes list, and thus nodeForID would fail,
+ causing the isolated tree to not be updated. This patch calls
+ applyPendingChanges before updating the given node's children.
+ Additional logging was added including the logging of the AXObjectCache
+ object hierarchy.
+
+ * accessibility/AXLogger.cpp:
+ (WebCore::AXLogger::log):
+ (WebCore::operator<<):
+ * accessibility/AXLogger.h:
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::remove):
+ (WebCore::AXObjectCache::postNotification):
+ (WebCore::AXObjectCache::performDeferredCacheUpdate):
+ (WebCore::AXObjectCache::updateIsolatedTree):
+ * accessibility/AXObjectCache.h:
+ * accessibility/isolatedtree/AXIsolatedTree.cpp:
+ (WebCore::AXIsolatedTree::updateNode):
+ (WebCore::AXIsolatedTree::updateSubtree):
+ (WebCore::AXIsolatedTree::updateChildren):
+ (WebCore::AXIsolatedTree::focusedNode):
+ (WebCore::AXIsolatedTree::removeNode):
+ (WebCore::AXIsolatedTree::removeSubtree):
+ (WebCore::AXIsolatedTree::applyPendingChanges):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
+2020-05-14 Andres Gonzalez <andresg...@apple.com>
+
Fix for crash in LayoutTest in isolated tree mode.
https://bugs.webkit.org/show_bug.cgi?id=211894
Modified: trunk/Source/WebCore/accessibility/AXLogger.cpp (261693 => 261694)
--- trunk/Source/WebCore/accessibility/AXLogger.cpp 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/AXLogger.cpp 2020-05-14 15:35:45 UTC (rev 261694)
@@ -29,6 +29,7 @@
#include "config.h"
#include "AXLogger.h"
+#include "AXObjectCache.h"
#include "Logging.h"
#include <wtf/text/TextStream.h>
@@ -59,10 +60,15 @@
#endif
}
-void AXLogger::log(const AXCoreObject& object)
+void AXLogger::log(const RefPtr<AXCoreObject>& object)
{
TextStream stream(TextStream::LineMode::MultipleLine);
- stream << object;
+
+ if (object)
+ stream << *object;
+ else
+ stream << "null";
+
LOG(Accessibility, "%s", stream.release().utf8().data());
}
@@ -101,6 +107,13 @@
}
#endif
+void AXLogger::log(AXObjectCache& axObjectCache)
+{
+ TextStream stream(TextStream::LineMode::MultipleLine);
+ stream << axObjectCache;
+ LOG(Accessibility, "%s", stream.release().utf8().data());
+}
+
TextStream& operator<<(TextStream& stream, AccessibilityRole role)
{
switch (role) {
@@ -700,4 +713,17 @@
}
#endif
+TextStream& operator<<(TextStream& stream, AXObjectCache& axObjectCache)
+{
+ TextStream::GroupScope groupScope(stream);
+ stream << "AXObjectCache " << &axObjectCache;
+
+ if (auto* root = axObjectCache.get(axObjectCache.document().view()))
+ AXLogger::add(stream, root, true);
+ else
+ stream << "No root!";
+
+ return stream;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/accessibility/AXLogger.h (261693 => 261694)
--- trunk/Source/WebCore/accessibility/AXLogger.h 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/AXLogger.h 2020-05-14 15:35:45 UTC (rev 261694)
@@ -36,11 +36,12 @@
AXLogger(const String& methodName);
~AXLogger();
static void log(const String&);
- static void log(const AXCoreObject&);
+ static void log(const RefPtr<AXCoreObject>&);
static void log(const std::pair<RefPtr<AXCoreObject>, AXObjectCache::AXNotification>&);
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
static void log(AXIsolatedTree&);
#endif
+ static void log(AXObjectCache&);
static void add(TextStream&, const RefPtr<AXCoreObject>&, bool recursive = false);
private:
String m_methodName;
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (261693 => 261694)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2020-05-14 15:35:45 UTC (rev 261694)
@@ -833,6 +833,9 @@
void AXObjectCache::remove(AXID axID)
{
+ AXTRACE("AXObjectCache::remove");
+ AXLOG(makeString("AXID ", axID));
+
if (!axID)
return;
@@ -1120,6 +1123,9 @@
void AXObjectCache::postNotification(AXCoreObject* object, Document* document, AXNotification notification, PostTarget postTarget, PostType postType)
{
+ AXTRACE("AXObjectCache::postNotification");
+ AXLOG(std::make_pair(object, notification));
+
stopCachingComputedObjectAttributes();
if (object && postTarget == TargetObservableParent)
@@ -3037,6 +3043,7 @@
void AXObjectCache::performDeferredCacheUpdate()
{
+ AXTRACE("AXObjectCache::performDeferredCacheUpdate");
if (m_performingDeferredCacheUpdate)
return;
@@ -3113,6 +3120,8 @@
{
AXTRACE("AXObjectCache::updateIsolatedTree");
AXLOG(std::make_pair(&object, notification));
+ AXLOG(*this);
+
if (!m_pageID)
return;
@@ -3146,6 +3155,8 @@
void AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<AXCoreObject>, AXNotification>>& notifications)
{
AXTRACE("AXObjectCache::updateIsolatedTree");
+ AXLOG(*this);
+
if (!m_pageID)
return;
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (261693 => 261694)
--- trunk/Source/WebCore/accessibility/AXObjectCache.h 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h 2020-05-14 15:35:45 UTC (rev 261694)
@@ -143,6 +143,7 @@
class AXObjectCache {
WTF_MAKE_NONCOPYABLE(AXObjectCache); WTF_MAKE_FAST_ALLOCATED;
+ friend WTF::TextStream& operator<<(WTF::TextStream&, AXObjectCache&);
public:
explicit AXObjectCache(Document&);
~AXObjectCache();
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (261693 => 261694)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp 2020-05-14 15:35:45 UTC (rev 261694)
@@ -197,6 +197,7 @@
void AXIsolatedTree::updateNode(AXCoreObject& axObject)
{
AXTRACE("AXIsolatedTree::updateNode");
+ AXLOG(&axObject);
ASSERT(isMainThread());
AXID axID = axObject.objectID();
auto* axParent = axObject.parentObject();
@@ -218,6 +219,7 @@
void AXIsolatedTree::updateSubtree(AXCoreObject& axObject)
{
AXTRACE("AXIsolatedTree::updateSubtree");
+ AXLOG(&axObject);
ASSERT(isMainThread());
removeSubtree(axObject.objectID());
auto* axParent = axObject.parentObject();
@@ -228,15 +230,22 @@
void AXIsolatedTree::updateChildren(AXCoreObject& axObject)
{
AXTRACE("AXIsolatedTree::updateChildren");
+ AXLOG("For AXObject:");
+ AXLOG(&axObject);
ASSERT(isMainThread());
+
if (!axObject.document() || !axObject.document()->hasLivingRenderTree())
return;
AXID axObjectID = axObject.objectID();
+
+ applyPendingChanges();
LockHolder locker { m_changeLogLock };
auto object = nodeForID(axObjectID);
- if (!object)
+ if (!object) {
+ AXLOG("No associated isolated object!");
return; // nothing to update.
+ }
auto removals = object->m_childrenIDs;
locker.unlockEarly();
@@ -250,6 +259,8 @@
removals.remove(index);
else {
// This is a new child, add it to the tree.
+ AXLOG("Adding a new child for:");
+ AXLOG(axChildren[i]);
generateSubtree(*axChildren[i], axObjectID, true);
}
}
@@ -268,11 +279,13 @@
RefPtr<AXIsolatedObject> AXIsolatedTree::focusedNode()
{
- AXTRACE("AXIsolatedTree::focusedUIElement");
+ AXTRACE("AXIsolatedTree::focusedNode");
// Apply pending changes in case focus has changed and hasn't been updated.
applyPendingChanges();
LockHolder locker { m_changeLogLock };
AXLOG(makeString("focusedNodeID ", m_focusedNodeID));
+ AXLOG("focused node:");
+ AXLOG(nodeForID(m_focusedNodeID));
return nodeForID(m_focusedNodeID);
}
@@ -305,6 +318,8 @@
void AXIsolatedTree::removeNode(AXID axID)
{
AXTRACE("AXIsolatedTree::removeNode");
+ AXLOG(makeString("AXID ", axID));
+
LockHolder locker { m_changeLogLock };
m_pendingNodeRemovals.append(axID);
}
@@ -312,6 +327,7 @@
void AXIsolatedTree::removeSubtree(AXID axID)
{
AXTRACE("AXIsolatedTree::removeSubtree");
+ AXLOG(makeString("Removing subtree for axID ", axID));
LockHolder locker { m_changeLogLock };
m_pendingSubtreeRemovals.append(axID);
}
@@ -328,6 +344,7 @@
AXTRACE("AXIsolatedTree::applyPendingChanges");
LockHolder locker { m_changeLogLock };
+ AXLOG(makeString("focusedNodeID ", m_focusedNodeID, " pendingFocusedNodeID ", m_pendingFocusedNodeID));
m_focusedNodeID = m_pendingFocusedNodeID;
while (m_pendingNodeRemovals.size()) {
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (261693 => 261694)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-05-14 15:31:58 UTC (rev 261693)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-05-14 15:35:45 UTC (rev 261694)
@@ -2290,11 +2290,10 @@
{
AXTRACE(makeString("WebAccessibilityObjectWrapper accessibilityAttributeValue:", String(attributeName)));
auto* backingObject = self.updateObjectBackingStore;
- if (!backingObject) {
- AXLOG("No backingObject!!!");
+ AXLOG("backingObject");
+ AXLOG(backingObject);
+ if (!backingObject)
return nil;
- }
- AXLOG(*backingObject);
if (backingObject->isDetachedFromParent()) {
AXLOG("backingObject is detached from parent!!!");