Title: [285934] trunk/Source/WebCore
Revision
285934
Author
[email protected]
Date
2021-11-17 10:14:27 -0800 (Wed, 17 Nov 2021)

Log Message

AX: Use ObjectIdentifier for AXID
https://bugs.webkit.org/show_bug.cgi?id=233248

Patch by Carlos Garcia Campos <[email protected]> on 2021-11-17
Reviewed by Andres Gonzalez.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::setIsolatedTreeFocusedObject):
(WebCore::AXObjectCache::get):
(WebCore::AXObjectCache::cacheAndInitializeWrapper):
(WebCore::AXObjectCache::platformGenerateAXID const):
(WebCore::AXObjectCache::objectsForIDs const):
(WebCore::AXObjectCache::updateIsolatedTree):
* accessibility/AXObjectCache.h:
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
(WebCore::AXCoreObject::detach):
* accessibility/atspi/AccessibilityObjectAtspi.cpp:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::AXIsolatedObject):
(WebCore::AXIsolatedObject::associatedAXObject const):
(WebCore::AXIsolatedObject::detachFromParent):
(WebCore::AXIsolatedObject::isDetachedFromParent):
(WebCore::AXIsolatedObject::cellForColumnAndRow):
(WebCore::AXIsolatedObject::accessibilityHitTest const):
(WebCore::AXIsolatedObject::objectAttributeValue const):
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::nodeForID const):
(WebCore::AXIsolatedTree::idsForObjects const):
(WebCore::AXIsolatedTree::updateChildrenIDs):
(WebCore::AXIsolatedTree::generateSubtree):
(WebCore::AXIsolatedTree::createSubtree):
(WebCore::AXIsolatedTree::updateNode):
(WebCore::AXIsolatedTree::updateChildren):
(WebCore::AXIsolatedTree::removeSubtree):
(WebCore::AXIsolatedTree::applyPendingChanges):
* accessibility/isolatedtree/AXIsolatedTree.h:
(WebCore::AXIsolatedTree::WTF_GUARDED_BY_LOCK):
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase attachAXObject:]):
(-[WebAccessibilityObjectWrapperBase attachIsolatedObject:]):
(-[WebAccessibilityObjectWrapperBase detach]):
(-[WebAccessibilityObjectWrapperBase detachIsolatedObject:]):
* accessibility/win/AXObjectCacheWin.cpp:
(WebCore::AXObjectCache::platformGenerateAXID const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285933 => 285934)


--- trunk/Source/WebCore/ChangeLog	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/ChangeLog	2021-11-17 18:14:27 UTC (rev 285934)
@@ -1,3 +1,51 @@
+2021-11-17  Carlos Garcia Campos  <[email protected]>
+
+        AX: Use ObjectIdentifier for AXID
+        https://bugs.webkit.org/show_bug.cgi?id=233248
+
+        Reviewed by Andres Gonzalez.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::setIsolatedTreeFocusedObject):
+        (WebCore::AXObjectCache::get):
+        (WebCore::AXObjectCache::cacheAndInitializeWrapper):
+        (WebCore::AXObjectCache::platformGenerateAXID const):
+        (WebCore::AXObjectCache::objectsForIDs const):
+        (WebCore::AXObjectCache::updateIsolatedTree):
+        * accessibility/AXObjectCache.h:
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        (WebCore::AXCoreObject::detach):
+        * accessibility/atspi/AccessibilityObjectAtspi.cpp:
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::AXIsolatedObject):
+        (WebCore::AXIsolatedObject::associatedAXObject const):
+        (WebCore::AXIsolatedObject::detachFromParent):
+        (WebCore::AXIsolatedObject::isDetachedFromParent):
+        (WebCore::AXIsolatedObject::cellForColumnAndRow):
+        (WebCore::AXIsolatedObject::accessibilityHitTest const):
+        (WebCore::AXIsolatedObject::objectAttributeValue const):
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::nodeForID const):
+        (WebCore::AXIsolatedTree::idsForObjects const):
+        (WebCore::AXIsolatedTree::updateChildrenIDs):
+        (WebCore::AXIsolatedTree::generateSubtree):
+        (WebCore::AXIsolatedTree::createSubtree):
+        (WebCore::AXIsolatedTree::updateNode):
+        (WebCore::AXIsolatedTree::updateChildren):
+        (WebCore::AXIsolatedTree::removeSubtree):
+        (WebCore::AXIsolatedTree::applyPendingChanges):
+        * accessibility/isolatedtree/AXIsolatedTree.h:
+        (WebCore::AXIsolatedTree::WTF_GUARDED_BY_LOCK):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase attachAXObject:]):
+        (-[WebAccessibilityObjectWrapperBase attachIsolatedObject:]):
+        (-[WebAccessibilityObjectWrapperBase detach]):
+        (-[WebAccessibilityObjectWrapperBase detachIsolatedObject:]):
+        * accessibility/win/AXObjectCacheWin.cpp:
+        (WebCore::AXObjectCache::platformGenerateAXID const):
+
 2021-11-17  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Incorrect use of BreakWord with preferred width computation (it's a valid value for both WordBreak and OverflowWrap)

Modified: trunk/Source/WebCore/accessibility/AXLogger.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -502,7 +502,7 @@
     stream.dumpProperty("address", &object);
     stream.dumpProperty("wrapper", object.wrapper());
 
-    stream.dumpProperty("parentObject", parent ? parent->objectID() : 0);
+    stream.dumpProperty("parentObject", parent ? parent->objectID() : AXID());
 #if PLATFORM(COCOA)
     stream.dumpProperty("remoteParentObject", object.remoteParentObject());
 #endif

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -124,8 +124,6 @@
 
 using namespace HTMLNames;
 
-const AXID InvalidAXID = 0;
-
 // Post value change notifications for password fields or elements contained in password fields at a 40hz interval to thwart analysis of typing cadence
 static const Seconds accessibilityPasswordValueChangeNotificationInterval { 25_ms };
 static const Seconds accessibilityLiveRegionChangedNotificationInterval { 20_ms };
@@ -418,7 +416,7 @@
     auto* focus = getOrCreate(focusedNode);
 
     if (auto tree = AXIsolatedTree::treeForPageID(*m_pageID))
-        tree->setFocusedNodeID(focus ? focus->objectID() : InvalidAXID);
+        tree->setFocusedNodeID(focus ? focus->objectID() : AXID());
 }
 #endif
 
@@ -428,7 +426,7 @@
         return nullptr;
         
     AXID axID = m_widgetObjectMapping.get(widget);
-    ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
+    ASSERT(!axID.isHashTableDeletedValue());
     if (!axID)
         return nullptr;
     
@@ -441,7 +439,7 @@
         return nullptr;
     
     AXID axID = m_renderObjectMapping.get(renderer);
-    ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
+    ASSERT(!axID.isHashTableDeletedValue());
     if (!axID)
         return nullptr;
 
@@ -453,11 +451,11 @@
     if (!node)
         return nullptr;
 
-    AXID renderID = node->renderer() ? m_renderObjectMapping.get(node->renderer()) : 0;
-    ASSERT(!HashTraits<AXID>::isDeletedValue(renderID));
+    AXID renderID = node->renderer() ? m_renderObjectMapping.get(node->renderer()) : AXID();
+    ASSERT(!renderID.isHashTableDeletedValue());
 
     AXID nodeID = m_nodeObjectMapping.get(node);
-    ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID));
+    ASSERT(!nodeID.isHashTableDeletedValue());
 
     if (node->renderer() && nodeID && !renderID) {
         // This can happen if an AccessibilityNodeObject is created for a node that's not
@@ -611,7 +609,7 @@
 {
     ASSERT(newObject);
     AXID axID = getAXID(newObject);
-    ASSERT(axID != InvalidAXID);
+    ASSERT(axID.isValid());
 
     WTF::switchOn(domObject,
         [&axID, this] (RenderObject* typedValue) { m_renderObjectMapping.set(typedValue, axID); },
@@ -830,7 +828,7 @@
 void AXObjectCache::remove(AXID axID)
 {
     AXTRACE("AXObjectCache::remove");
-    AXLOG(makeString("AXID ", axID));
+    AXLOG(makeString("AXID ", axID.loggingString()));
 
     if (!axID)
         return;
@@ -895,16 +893,10 @@
 #if !PLATFORM(WIN)
 AXID AXObjectCache::platformGenerateAXID() const
 {
-    static AXID lastUsedID = 0;
-
-    // Generate a new ID.
-    AXID objID = lastUsedID;
+    AXID objID;
     do {
-        ++objID;
-    } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
-
-    lastUsedID = objID;
-
+        objID = AXID::generate();
+    } while (!objID.isValid() || m_idsInUse.contains(objID));
     return objID;
 }
 #endif
@@ -914,7 +906,7 @@
     ASSERT(isMainThread());
 
     return axIDs.map([this] (AXID axID) -> RefPtr<AXCoreObject> {
-        ASSERT(axID != InvalidAXID);
+        ASSERT(axID.isValid());
         return objectFromAXID(axID);
     });
 }
@@ -3272,7 +3264,7 @@
     AXLOG(std::make_pair(&object, notification));
     AXLOG(*this);
 
-    if (!m_pageID || object.objectID() == InvalidAXID) {
+    if (!m_pageID || !object.objectID().isValid()) {
         AXLOG("No pageID or objectID");
         return;
     }
@@ -3352,7 +3344,7 @@
     Vector<std::pair<RefPtr<AXCoreObject>, AXNotification>> filteredNotifications;
     for (const auto& notification : notifications) {
         AXLOG(notification);
-        if (!notification.first || notification.first->objectID() == InvalidAXID)
+        if (!notification.first || !notification.first->objectID().isValid())
             continue;
 
         switch (notification.second) {

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (285933 => 285934)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-11-17 18:14:27 UTC (rev 285934)
@@ -60,7 +60,7 @@
 class Widget;
 
 struct TextMarkerData {
-    AXID axID { 0 };
+    AXID axID;
 
     Node* node { nullptr };
     unsigned offset { 0 };

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (285933 => 285934)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2021-11-17 18:14:27 UTC (rev 285934)
@@ -828,7 +828,7 @@
     mutable bool m_childrenInitialized { false };
     AccessibilityRole m_role { AccessibilityRole::Unknown };
 private:
-    AXID m_id { 0 };
+    AXID m_id;
     OptionSet<AXAncestorFlag> m_ancestorFlags;
     AccessibilityObjectInclusion m_lastKnownIsIgnoredValue { AccessibilityObjectInclusion::DefaultBehavior };
 protected: // FIXME: Make the data members private.

Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (285933 => 285934)


--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2021-11-17 18:14:27 UTC (rev 285934)
@@ -36,6 +36,7 @@
 #include "Widget.h"
 #include <variant>
 #include <wtf/HashSet.h>
+#include <wtf/ObjectIdentifier.h>
 #include <wtf/RefCounted.h>
 
 #if PLATFORM(WIN)
@@ -93,8 +94,8 @@
 struct AccessibilityText;
 struct ScrollRectToVisibleOptions;
 
-using AXID = size_t;
-extern const AXID InvalidAXID;
+enum AXIDType { };
+using AXID = ObjectIdentifier<AXIDType>;
 
 enum class AXAncestorFlag : uint8_t {
     // When the flags aren't initialized, it means the object hasn't been inserted into the tree,
@@ -1582,7 +1583,7 @@
 {
     detachWrapper(detachmentType);
     detachRemoteParts(detachmentType);
-    setObjectID(InvalidAXID);
+    setObjectID({ });
 }
 
 #if ENABLE(ACCESSIBILITY)

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -439,7 +439,7 @@
         if (!g_strcmp0(propertyName, "Locale"))
             return g_variant_new_string(setlocale(LC_MESSAGES, nullptr));
         if (!g_strcmp0(propertyName, "AccessibleId"))
-            return g_variant_new_string(atspiObject->m_axObject ? String::number(atspiObject->m_axObject->objectID()).utf8().data() : "");
+            return g_variant_new_string(atspiObject->m_axObject ? String::number(atspiObject->m_axObject->objectID().toUInt64()).utf8().data() : "");
         if (!g_strcmp0(propertyName, "Parent"))
             return atspiObject->parentReference();
         if (!g_strcmp0(propertyName, "ChildCount"))

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -44,8 +44,8 @@
     , m_id(object.objectID())
 {
     ASSERT(isMainThread());
-    if (m_id != InvalidAXID)
-        initializeAttributeData(object, parentID == InvalidAXID);
+    if (m_id.isValid())
+        initializeAttributeData(object, !parentID.isValid());
     else {
         // Should never happen under normal circumstances.
         ASSERT_NOT_REACHED();
@@ -438,7 +438,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_id == InvalidAXID)
+    if (!m_id.isValid())
         return nullptr;
 
     if (auto* axObjectCache = this->axObjectCache()) {
@@ -529,7 +529,7 @@
 
 void AXIsolatedObject::detachFromParent()
 {
-    m_parentID = InvalidAXID;
+    m_parentID = { };
 }
 
 const AXCoreObject::AccessibilityChildrenVector& AXIsolatedObject::children(bool)
@@ -587,7 +587,7 @@
 
 bool AXIsolatedObject::isDetachedFromParent()
 {
-    if (parent() != InvalidAXID)
+    if (parent().isValid())
         return false;
 
     // Check whether this is the root node, in which case we should return false.
@@ -603,7 +603,7 @@
             if (auto cell = object->cellForColumnAndRow(columnIndex, rowIndex))
                 return cell->objectID();
         }
-        return InvalidAXID;
+        return { };
     });
 
     return tree()->nodeForID(cellID).get();
@@ -810,7 +810,7 @@
                 return axObject->objectID();
         }
 
-        return InvalidAXID;
+        return { };
     });
 
     return tree()->nodeForID(axID).get();
@@ -830,7 +830,7 @@
     auto value = m_propertyMap.get(propertyName);
     AXID nodeID = WTF::switchOn(value,
         [] (AXID& typedValue) -> AXID { return typedValue; },
-        [] (auto&) { return InvalidAXID; }
+        [] (auto&) { return AXID(); }
     );
 
     return tree()->nodeForID(nodeID).get();

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (285933 => 285934)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2021-11-17 18:14:27 UTC (rev 285934)
@@ -667,8 +667,8 @@
     String outerHTML() const override;
 
     RefPtr<AXIsolatedTree> m_cachedTree;
-    AXID m_parentID { InvalidAXID };
-    AXID m_id { InvalidAXID };
+    AXID m_parentID;
+    AXID m_id;
     Vector<AXID> m_childrenIDs;
     Vector<RefPtr<AXCoreObject>> m_children;
     AXPropertyMap m_propertyMap;

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -146,7 +146,7 @@
     if (m_usedOnAXThread && isMainThread())
         return nullptr;
 
-    return axID != InvalidAXID ? m_readerThreadNodeMap.get(axID) : nullptr;
+    return axID.isValid() ? m_readerThreadNodeMap.get(axID) : nullptr;
 }
 
 Vector<RefPtr<AXCoreObject>> AXIsolatedTree::objectsForIDs(const Vector<AXID>& axIDs) const
@@ -166,7 +166,7 @@
 Vector<AXID> AXIsolatedTree::idsForObjects(const Vector<RefPtr<AXCoreObject>>& objects) const
 {
     return objects.map([] (const RefPtr<AXCoreObject>& object) -> AXID {
-        return object ? object->objectID() : InvalidAXID;
+        return object ? object->objectID() : AXID();
     });
 }
 
@@ -175,7 +175,7 @@
     ASSERT(isMainThread());
     ASSERT(m_changeLogLock.isLocked());
 
-    if (axID != InvalidAXID) {
+    if (axID.isValid()) {
         m_nodeMap.set(axID, childrenIDs);
         m_pendingChildrenUpdates.append(std::make_pair(axID, WTFMove(childrenIDs)));
     }
@@ -186,14 +186,14 @@
     AXTRACE("AXIsolatedTree::generateSubtree");
     ASSERT(isMainThread());
 
-    if (axObject.objectID() == InvalidAXID)
+    if (!axObject.objectID().isValid())
         return;
 
-    auto object = createSubtree(axObject, axParent ? axParent->objectID() : InvalidAXID, attachWrapper);
+    auto object = createSubtree(axObject, axParent ? axParent->objectID() : AXID(), attachWrapper);
     Locker locker { m_changeLogLock };
     if (!axParent)
         setRootNode(object.ptr());
-    else if (axParent->objectID() != InvalidAXID) // Need to check for the objectID of axParent again because it may have been detached while traversing the tree.
+    else if (axParent->objectID().isValid()) // Need to check for the objectID of axParent again because it may have been detached while traversing the tree.
         updateChildrenIDs(axParent->objectID(), axParent->childrenIDs());
 }
 
@@ -203,7 +203,7 @@
     ASSERT(isMainThread());
 
     auto object = AXIsolatedObject::create(axObject, this, parentID);
-    if (object->objectID() == InvalidAXID) {
+    if (!object->objectID().isValid()) {
         // Either the axObject has an invalid ID or something else went terribly wrong. Don't bother doing anything else.
         ASSERT_NOT_REACHED();
         return object;
@@ -242,7 +242,7 @@
 
     AXID axID = axObject.objectID();
     auto* axParent = axObject.parentObject();
-    AXID parentID = axParent ? axParent->objectID() : InvalidAXID;
+    AXID parentID = axParent ? axParent->objectID() : AXID();
 
     auto newObject = AXIsolatedObject::create(axObject, this, parentID);
     newObject->m_childrenIDs = axObject.childrenIDs();
@@ -316,7 +316,7 @@
         }
         return false;
     });
-    if (!axAncestor || axAncestor->objectID() == InvalidAXID || iterator == m_nodeMap.end()) {
+    if (!axAncestor || !axAncestor->objectID().isValid() || iterator == m_nodeMap.end()) {
         // This update triggered before the isolated tree has been repopulated.
         // Return here since there is nothing to update.
         return;
@@ -365,7 +365,7 @@
     // Apply pending changes in case focus has changed and hasn't been updated.
     applyPendingChanges();
     Locker locker { m_changeLogLock };
-    AXLOG(makeString("focusedNodeID ", m_focusedNodeID));
+    AXLOG(makeString("focusedNodeID ", m_focusedNodeID.loggingString()));
     AXLOG("focused node:");
     AXLOG(nodeForID(m_focusedNodeID));
     return nodeForID(m_focusedNodeID);
@@ -392,7 +392,7 @@
 void AXIsolatedTree::setFocusedNodeID(AXID axID)
 {
     AXTRACE("AXIsolatedTree::setFocusedNodeID");
-    AXLOG(makeString("axID ", axID));
+    AXLOG(makeString("axID ", axID.loggingString()));
     ASSERT(isMainThread());
 
     Locker locker { m_changeLogLock };
@@ -406,7 +406,7 @@
 void AXIsolatedTree::removeNode(AXID axID)
 {
     AXTRACE("AXIsolatedTree::removeNode");
-    AXLOG(makeString("AXID ", axID));
+    AXLOG(makeString("AXID ", axID.loggingString()));
     ASSERT(isMainThread());
 
     m_nodeMap.remove(axID);
@@ -417,13 +417,13 @@
 void AXIsolatedTree::removeSubtree(AXID axID)
 {
     AXTRACE("AXIsolatedTree::removeSubtree");
-    AXLOG(makeString("Removing subtree for axID ", axID));
+    AXLOG(makeString("Removing subtree for axID ", axID.loggingString()));
     ASSERT(isMainThread());
 
     Vector<AXID> removals = { axID };
     while (removals.size()) {
         AXID axID = removals.takeLast();
-        if (axID == InvalidAXID)
+        if (!axID.isValid())
             continue;
 
         auto it = m_nodeMap.find(axID);
@@ -449,9 +449,9 @@
     Locker locker { m_changeLogLock };
 
     if (m_pendingFocusedNodeID != m_focusedNodeID) {
-        AXLOG(makeString("focusedNodeID ", m_focusedNodeID, " pendingFocusedNodeID ", m_pendingFocusedNodeID));
+        AXLOG(makeString("focusedNodeID ", m_focusedNodeID.loggingString(), " pendingFocusedNodeID ", m_pendingFocusedNodeID.loggingString()));
 
-        if (m_focusedNodeID != InvalidAXID) {
+        if (m_focusedNodeID.isValid()) {
             // Set the old focused object's IsFocused property to false.
             AXPropertyMap propertyMap;
             propertyMap.set(AXPropertyName::IsFocused, false);
@@ -462,7 +462,7 @@
 
     while (m_pendingNodeRemovals.size()) {
         auto axID = m_pendingNodeRemovals.takeLast();
-        AXLOG(makeString("removing axID ", axID));
+        AXLOG(makeString("removing axID ", axID.loggingString()));
         if (auto object = nodeForID(axID)) {
             object->detach(AccessibilityDetachmentType::ElementDestroyed);
             m_readerThreadNodeMap.remove(axID);
@@ -471,7 +471,7 @@
 
     while (m_pendingSubtreeRemovals.size()) {
         auto axID = m_pendingSubtreeRemovals.takeLast();
-        AXLOG(makeString("removing subtree axID ", axID));
+        AXLOG(makeString("removing subtree axID ", axID.loggingString()));
         if (auto object = nodeForID(axID)) {
             object->detach(AccessibilityDetachmentType::ElementDestroyed);
             m_pendingSubtreeRemovals.appendVector(object->m_childrenIDs);
@@ -481,8 +481,8 @@
 
     for (const auto& item : m_pendingAppends) {
         AXID axID = item.isolatedObject->objectID();
-        AXLOG(makeString("appending axID ", axID));
-        if (axID == InvalidAXID)
+        AXLOG(makeString("appending axID ", axID.loggingString()));
+        if (!axID.isValid())
             continue;
 
         auto& wrapper = item.wrapper ? item.wrapper : item.isolatedObject->wrapper();
@@ -518,7 +518,7 @@
     m_pendingAppends.clear();
 
     for (auto& update : m_pendingChildrenUpdates) {
-        AXLOG(makeString("updating children for axID ", update.first));
+        AXLOG(makeString("updating children for axID ", update.first.loggingString()));
         if (auto object = nodeForID(update.first))
             object->m_childrenIDs = WTFMove(update.second);
     }

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h (285933 => 285934)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h	2021-11-17 18:14:27 UTC (rev 285934)
@@ -323,7 +323,7 @@
 using AXPropertyMap = HashMap<AXPropertyName, AXPropertyValueVariant, IntHash<AXPropertyName>, WTF::StrongEnumHashTraits<AXPropertyName>>;
 
 struct AXPropertyChange {
-    AXID axID { InvalidAXID }; // ID of the object whose properties changed.
+    AXID axID; // ID of the object whose properties changed.
     AXPropertyMap properties; // Changed properties.
 };
 
@@ -407,8 +407,8 @@
     Vector<AXID> m_pendingNodeRemovals WTF_GUARDED_BY_LOCK(m_changeLogLock); // Nodes to be removed from the tree.
     Vector<AXID> m_pendingSubtreeRemovals WTF_GUARDED_BY_LOCK(m_changeLogLock); // Nodes whose subtrees are to be removed from the tree.
     Vector<std::pair<AXID, Vector<AXID>>> m_pendingChildrenUpdates WTF_GUARDED_BY_LOCK(m_changeLogLock);
-    AXID m_pendingFocusedNodeID WTF_GUARDED_BY_LOCK(m_changeLogLock) { InvalidAXID };
-    AXID m_focusedNodeID { InvalidAXID };
+    AXID m_pendingFocusedNodeID WTF_GUARDED_BY_LOCK(m_changeLogLock);
+    AXID m_focusedNodeID;
     Lock m_changeLogLock;
 };
 

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm (285933 => 285934)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm	2021-11-17 18:14:27 UTC (rev 285934)
@@ -290,9 +290,9 @@
 
 - (void)attachAXObject:(AXCoreObject*)axObject
 {
-    ASSERT(axObject && (_identifier == InvalidAXID || _identifier == axObject->objectID()));
+    ASSERT(axObject && (!_identifier.isValid() || _identifier == axObject->objectID()));
     m_axObject = axObject;
-    if (_identifier == InvalidAXID)
+    if (!_identifier.isValid())
         _identifier = m_axObject->objectID();
 }
 
@@ -299,9 +299,9 @@
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
 - (void)attachIsolatedObject:(AXCoreObject*)isolatedObject
 {
-    ASSERT(isolatedObject && (_identifier == InvalidAXID || _identifier == isolatedObject->objectID()));
+    ASSERT(isolatedObject && (!_identifier.isValid() || _identifier == isolatedObject->objectID()));
     m_isolatedObject = isolatedObject;
-    if (_identifier == InvalidAXID)
+    if (!_identifier.isValid())
         _identifier = m_isolatedObject->objectID();
 }
 #endif
@@ -309,7 +309,7 @@
 - (void)detach
 {
     ASSERT(isMainThread());
-    _identifier = InvalidAXID;
+    _identifier = { };
     m_axObject = nullptr;
 }
 
@@ -316,7 +316,7 @@
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
 - (void)detachIsolatedObject:(AccessibilityDetachmentType)detachmentType
 {
-    ASSERT_UNUSED(detachmentType, detachmentType == AccessibilityDetachmentType::ElementChanged ? _identifier != InvalidAXID && m_axObject : true);
+    ASSERT_UNUSED(detachmentType, detachmentType == AccessibilityDetachmentType::ElementChanged ? _identifier.isValid() && m_axObject : true);
     m_isolatedObject = nullptr;
 }
 #endif

Modified: trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp (285933 => 285934)


--- trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp	2021-11-17 17:50:26 UTC (rev 285933)
+++ trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp	2021-11-17 18:14:27 UTC (rev 285934)
@@ -120,7 +120,7 @@
     ASSERT(obj->objectID() >= 1);
     ASSERT(obj->objectID() <= std::numeric_limits<LONG>::max());
 
-    NotifyWinEvent(msaaEvent, page->chrome().platformPageClient(), OBJID_CLIENT, -static_cast<LONG>(obj->objectID()));
+    NotifyWinEvent(msaaEvent, page->chrome().platformPageClient(), OBJID_CLIENT, -static_cast<LONG>(obj->objectID().toUInt64()));
 }
 
 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&)
@@ -148,19 +148,19 @@
 
 AXID AXObjectCache::platformGenerateAXID() const
 {
-    static AXID lastUsedID = 0;
+    static LONG lastUsedID = 0;
 
     // Generate a new ID. Windows accessibility relies on a positive AXID,
     // ranging from 1 to LONG_MAX.
-    AXID objID = lastUsedID;
+    LONG currentID = lastUsedID;
+    AXID objID;
     do {
-        ++objID;
-        objID %= std::numeric_limits<LONG>::max();
-    } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
+        objID = makeObjectIdentifier<AXID>(++currentID);
+    } while (!objID.isValid() || m_idsInUse.contains(objID));
 
-    ASSERT(objID >= 1 && objID <= std::numeric_limits<LONG>::max());
+    ASSERT(objID.isValid() && objID.toUInt64() <= std::numeric_limits<LONG>::max());
 
-    lastUsedID = objID;
+    lastUsedID = currentID;
 
     return objID;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to