Implementation of AXIsolatedObject::isDescendantOfObject.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2020 19:29:34 +0000 (19:29 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2020 19:29:34 +0000 (19:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=207697

Reviewed by Chris Fleizach.

- Moved the implementation of AccessibilityObject::isDescendantOfObject
and isAncestorOfObject to the base class AXCoreObject.
- Implemented AXIsolatedObject::hasChildren by caching the value from
the associated AXObject. It is used in isDescendantOfObject.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isDescendantOfObject const): MOved to AXCoreObject.
(WebCore::AccessibilityObject::isAncestorOfObject const): Moved to AXCoreObject.
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
(WebCore::AXCoreObject::isDescendantOfObject const):
(WebCore::AXCoreObject::isAncestorOfObject const):
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData): Sets the HasChildren attribute.
(WebCore::AXIsolatedObject::hasChildren const): Deleted.
(WebCore::AXIsolatedObject::isDescendantOfObject const): Deleted.
(WebCore::AXIsolatedObject::isAncestorOfObject const): Deleted.
* accessibility/isolatedtree/AXIsolatedObject.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256631 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityObjectInterface.h
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h

index ba410fa..a039168 100644 (file)
@@ -1,5 +1,31 @@
 2020-02-14  Andres Gonzalez  <andresg_22@apple.com>
 
+        Implementation of AXIsolatedObject::isDescendantOfObject.
+        https://bugs.webkit.org/show_bug.cgi?id=207697
+
+        Reviewed by Chris Fleizach.
+
+        - Moved the implementation of AccessibilityObject::isDescendantOfObject
+        and isAncestorOfObject to the base class AXCoreObject.
+        - Implemented AXIsolatedObject::hasChildren by caching the value from
+        the associated AXObject. It is used in isDescendantOfObject.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isDescendantOfObject const): MOved to AXCoreObject.
+        (WebCore::AccessibilityObject::isAncestorOfObject const): Moved to AXCoreObject.
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        (WebCore::AXCoreObject::isDescendantOfObject const):
+        (WebCore::AXCoreObject::isAncestorOfObject const):
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData): Sets the HasChildren attribute.
+        (WebCore::AXIsolatedObject::hasChildren const): Deleted.
+        (WebCore::AXIsolatedObject::isDescendantOfObject const): Deleted.
+        (WebCore::AXIsolatedObject::isAncestorOfObject const): Deleted.
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+
+2020-02-14  Andres Gonzalez  <andresg_22@apple.com>
+
         When updating a subtree of the IsolatedTree, first remove the entire subtree, not just the subtree root.
         https://bugs.webkit.org/show_bug.cgi?id=207759
 
index b040e29..8314712 100644 (file)
@@ -2115,24 +2115,6 @@ AccessibilityOrientation AccessibilityObject::orientation() const
     return AccessibilityOrientation::Undefined;
 }    
 
-bool AccessibilityObject::isDescendantOfObject(const AXCoreObject* axObject) const
-{
-    if (!axObject || !axObject->hasChildren())
-        return false;
-
-    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [axObject] (const AccessibilityObject& object) {
-        return &object == axObject;
-    }) != nullptr;
-}
-
-bool AccessibilityObject::isAncestorOfObject(const AXCoreObject* axObject) const
-{
-    if (!axObject)
-        return false;
-
-    return this == axObject || axObject->isDescendantOfObject(this);
-}
-
 AccessibilityObject* AccessibilityObject::firstAnonymousBlockChild() const
 {
     for (AccessibilityObject* child = firstChild(); child; child = child->nextSibling()) {
index e91b2f4..03efbed 100644 (file)
@@ -484,8 +484,6 @@ public:
     AccessibilityObject* activeDescendant() const override { return nullptr; }
     void handleActiveDescendantChanged() override { }
     void handleAriaExpandedChanged() override { }
-    bool isDescendantOfObject(const AXCoreObject*) const override;
-    bool isAncestorOfObject(const AXCoreObject*) const override;
     AccessibilityObject* firstAnonymousBlockChild() const override;
 
     WEBCORE_EXPORT static AccessibilityRole ariaRoleToWebCoreRole(const String&);
index 81517ca..c15f8ef 100644 (file)
@@ -888,8 +888,8 @@ public:
     virtual AXCoreObject* activeDescendant() const = 0;
     virtual void handleActiveDescendantChanged() = 0;
     virtual void handleAriaExpandedChanged() = 0;
-    virtual bool isDescendantOfObject(const AXCoreObject*) const = 0;
-    virtual bool isAncestorOfObject(const AXCoreObject*) const = 0;
+    bool isDescendantOfObject(const AXCoreObject*) const;
+    bool isAncestorOfObject(const AXCoreObject*) const;
     virtual AXCoreObject* firstAnonymousBlockChild() const = 0;
 
     virtual bool hasAttribute(const QualifiedName&) const = 0;
@@ -1222,4 +1222,17 @@ template<typename T, typename U> inline T retrieveAutoreleasedValueFromMainThrea
 
 } // namespace Accessibility
 
+inline bool AXCoreObject::isDescendantOfObject(const AXCoreObject* axObject) const
+{
+    return axObject && axObject->hasChildren()
+        && Accessibility::findAncestor<AXCoreObject>(*this, false, [axObject] (const AXCoreObject& object) {
+            return &object == axObject;
+        }) != nullptr;
+}
+
+inline bool AXCoreObject::isAncestorOfObject(const AXCoreObject* axObject) const
+{
+    return axObject && (this == axObject || axObject->isDescendantOfObject(this));
+}
+
 } // namespace WebCore
index ce3bed4..bd61009 100644 (file)
@@ -155,6 +155,7 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::LayoutCount, object.layoutCount());
     setProperty(AXPropertyName::EstimatedLoadingProgress, object.estimatedLoadingProgress());
     setProperty(AXPropertyName::SupportsARIAOwns, object.supportsARIAOwns());
+    setProperty(AXPropertyName::HasChildren, object.hasChildren());
     setProperty(AXPropertyName::HasPopup, object.hasPopup());
     setProperty(AXPropertyName::PopupValue, object.popupValue());
     setProperty(AXPropertyName::PressedIsPresent, object.pressedIsPresent());
@@ -1573,12 +1574,6 @@ bool AXIsolatedObject::canHaveChildren() const
     return false;
 }
 
-bool AXIsolatedObject::hasChildren() const
-{
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
 void AXIsolatedObject::setNeedsToUpdateChildren()
 {
     ASSERT_NOT_REACHED();
@@ -1622,18 +1617,6 @@ void AXIsolatedObject::handleAriaExpandedChanged()
     ASSERT_NOT_REACHED();
 }
 
-bool AXIsolatedObject::isDescendantOfObject(const AXCoreObject*) const
-{
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
-bool AXIsolatedObject::isAncestorOfObject(const AXCoreObject*) const
-{
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
 AXCoreObject* AXIsolatedObject::firstAnonymousBlockChild() const
 {
     ASSERT_NOT_REACHED();
index ab815be..2f6d2dd 100644 (file)
@@ -132,6 +132,7 @@ private:
         FileUploadButtonReturnsValueInTitle,
         FocusableAncestor,
         HasARIAValueNow,
+        HasChildren,
         HasPopup,
         HeadingLevel,
         HelpText,
@@ -771,7 +772,7 @@ private:
     void insertChild(AXCoreObject*, unsigned) override;
     bool shouldIgnoreAttributeRole() const override;
     bool canHaveChildren() const override;
-    bool hasChildren() const override;
+    bool hasChildren() const override { return boolAttributeValue(AXPropertyName::HasChildren); }
     void setNeedsToUpdateChildren() override;
     void setNeedsToUpdateSubtree() override;
     void clearChildren() override;
@@ -781,8 +782,6 @@ private:
     AXCoreObject* activeDescendant() const override;
     void handleActiveDescendantChanged() override;
     void handleAriaExpandedChanged() override;
-    bool isDescendantOfObject(const AXCoreObject*) const override;
-    bool isAncestorOfObject(const AXCoreObject*) const override;
     AXCoreObject* firstAnonymousBlockChild() const override;
     bool hasAttribute(const QualifiedName&) const override;
     const AtomString& getAttribute(const QualifiedName&) const override;