Skip to content

Commit

Permalink
Cherry-pick c11d33b. rdar://problem/104956200
Browse files Browse the repository at this point in the history
    AX: Object IDs should not be generated with AXTreeStore::generateNewID().
    https://bugs.webkit.org/show_bug.cgi?id=251577
    <rdar://problem/104956200>

    Reviewed by Chris Fleizach.

    In the patch for
        https://bugs.webkit.org/show_bug.cgi?id=249480
        <rdar://problem/103449294>

    I erroneously switched the generation of object IDS in the AXObjectCache to use AXTreeStore::generateNewID. This is wrong because generateNewID checks the presence of the ID against the IDs of AX trees and not against object IDs. This patch rectifies this by bringing back AXObjectCache::generateNewObjectID (new name).

    * Source/WebCore/accessibility/AXObjectCache.cpp:
    (WebCore::AXObjectCache::generateNewObjectID const):
    (WebCore::AXObjectCache::getAXID):
    * Source/WebCore/accessibility/AXObjectCache.h:
    (WebCore::AXObjectCache::objectForID const): No need to pass AXID by reference since it just wraps an unsgined.

    Canonical link: https://commits.webkit.org/259922@main

Canonical link: https://commits.webkit.org/259548.45@safari-7615.1.21.13-branch
  • Loading branch information
AndresGonzalezApple authored and rjepstein committed Feb 7, 2023
1 parent 5501af0 commit 7db0595
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Source/WebCore/accessibility/AXObjectCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,15 @@ void AXObjectCache::remove(Widget* view)
remove(m_widgetObjectMapping.take(view));
}

AXID AXObjectCache::generateNewObjectID() const
{
AXID axID;
do {
axID = AXID::generate();
} while (!axID.isValid() || m_idsInUse.contains(axID));
return axID;
}

Vector<RefPtr<AXCoreObject>> AXObjectCache::objectsForIDs(const Vector<AXID>& axIDs) const
{
ASSERT(isMainThread());
Expand All @@ -1002,7 +1011,7 @@ AXID AXObjectCache::getAXID(AccessibilityObject* object)
return objectID;
}

objectID = generateNewID();
objectID = generateNewObjectID();
m_idsInUse.add(objectID);
object->setObjectID(objectID);
return objectID;
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/accessibility/AXObjectCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class AXObjectCache : public CanMakeWeakPtr<AXObjectCache>
const Element* rootAXEditableElement(const Node*);
bool nodeIsTextControl(const Node*);

AccessibilityObject* objectForID(const AXID& id) const { return m_objects.get(id); }
AccessibilityObject* objectForID(const AXID id) const { return m_objects.get(id); }
Vector<RefPtr<AXCoreObject>> objectsForIDs(const Vector<AXID>&) const;

// Text marker utilities.
Expand Down Expand Up @@ -488,6 +488,7 @@ class AXObjectCache : public CanMakeWeakPtr<AXObjectCache>
static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);

AXID getAXID(AccessibilityObject*);
AXID generateNewObjectID() const;

void notificationPostTimerFired();

Expand Down

0 comments on commit 7db0595

Please sign in to comment.