Rename AccessibilityObject::matchedParent as Accessibility::findAncestor and re-imple...
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 19:59:21 +0000 (19:59 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 19:59:21 +0000 (19:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203654

Reviewed by Chris Fleizach.

No new tests necessary since this does not change functionality.

- Deleted AccessibilityObject::matchedParent and replaced with Accessibility::findAncestor.
- Accessibility::findAncestor is a template function that can be used with both AccessibilityObjects and AXIsolatedTreeNodes.
- Created the namespace Accessibility for implementation details that need not to be exposed to client code.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::helpText const):
(WebCore::AccessibilityNodeObject::textUnderElement const):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::parentObjectUnignored const):
(WebCore::AccessibilityObject::isDescendantOfRole const):
(WebCore::AccessibilityObject::ancestorAccessibilityScrollView const):
(WebCore::AccessibilityObject::headingElementForNode):
(WebCore::AccessibilityObject::isDescendantOfObject const):
(WebCore::AccessibilityObject::liveRegionAncestor const):
(WebCore::AccessibilityObject::isExpanded const):
(WebCore::AccessibilityObject::isAXHidden const):
(WebCore::AccessibilityObject::focusableAncestor):
(WebCore::AccessibilityObject::editableAncestor):
(WebCore::AccessibilityObject::radioGroupAncestor const):
(WebCore::AccessibilityObject::matchedParent): Deleted.
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
(WebCore::Accessibility::findAncestor):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::hasPopup const):
* accessibility/AccessibilitySVGElement.cpp:
(WebCore::AccessibilitySVGElement::computeAccessibilityIsIgnored const):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilityTreeAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityListAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityArticleAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityLandmarkAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityTableAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityIsInTableCell]):
(-[WebAccessibilityObjectWrapper _accessibilityFieldsetAncestor]):
(-[WebAccessibilityObjectWrapper _accessibilityFrameAncestor]):
(-[WebAccessibilityObjectWrapper tableCellParent]):
(-[WebAccessibilityObjectWrapper tableParent]):
(-[WebAccessibilityObjectWrapper accessibilityDatetimeValue]):
(-[WebAccessibilityObjectWrapper detailParentForSummaryObject:]):
(-[WebAccessibilityObjectWrapper detailParentForObject:]):
(-[WebAccessibilityObjectWrapper treeItemParentForObject:]):
(AXAttributeStringSetStyle):

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityObjectInterface.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilitySVGElement.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm

index bed0009..2fd8572 100644 (file)
@@ -1,3 +1,55 @@
+2019-10-31  Andres Gonzalez  <andresg_22@apple.com>
+
+        Rename AccessibilityObject::matchedParent as Accessibility::findAncestor and re-implement in a generic way so that can be used with both AccessibilityObjects and AXIsolatedTreeNodes.
+        https://bugs.webkit.org/show_bug.cgi?id=203654
+
+        Reviewed by Chris Fleizach.
+
+        No new tests necessary since this does not change functionality.
+
+        - Deleted AccessibilityObject::matchedParent and replaced with Accessibility::findAncestor.
+        - Accessibility::findAncestor is a template function that can be used with both AccessibilityObjects and AXIsolatedTreeNodes.
+        - Created the namespace Accessibility for implementation details that need not to be exposed to client code.
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::helpText const):
+        (WebCore::AccessibilityNodeObject::textUnderElement const):
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::parentObjectUnignored const):
+        (WebCore::AccessibilityObject::isDescendantOfRole const):
+        (WebCore::AccessibilityObject::ancestorAccessibilityScrollView const):
+        (WebCore::AccessibilityObject::headingElementForNode):
+        (WebCore::AccessibilityObject::isDescendantOfObject const):
+        (WebCore::AccessibilityObject::liveRegionAncestor const):
+        (WebCore::AccessibilityObject::isExpanded const):
+        (WebCore::AccessibilityObject::isAXHidden const):
+        (WebCore::AccessibilityObject::focusableAncestor):
+        (WebCore::AccessibilityObject::editableAncestor):
+        (WebCore::AccessibilityObject::radioGroupAncestor const):
+        (WebCore::AccessibilityObject::matchedParent): Deleted.
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        (WebCore::Accessibility::findAncestor):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::hasPopup const):
+        * accessibility/AccessibilitySVGElement.cpp:
+        (WebCore::AccessibilitySVGElement::computeAccessibilityIsIgnored const):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilityTreeAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityListAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityArticleAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityLandmarkAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityTableAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityIsInTableCell]):
+        (-[WebAccessibilityObjectWrapper _accessibilityFieldsetAncestor]):
+        (-[WebAccessibilityObjectWrapper _accessibilityFrameAncestor]):
+        (-[WebAccessibilityObjectWrapper tableCellParent]):
+        (-[WebAccessibilityObjectWrapper tableParent]):
+        (-[WebAccessibilityObjectWrapper accessibilityDatetimeValue]):
+        (-[WebAccessibilityObjectWrapper detailParentForSummaryObject:]):
+        (-[WebAccessibilityObjectWrapper detailParentForObject:]):
+        (-[WebAccessibilityObjectWrapper treeItemParentForObject:]):
+        (AXAttributeStringSetStyle):
+
 2019-10-31  Ryosuke Niwa  <rniwa@webkit.org>
 
         Integrate resize event with HTML5 event loop
index 0304ec7..61b7a4e 100644 (file)
@@ -1467,7 +1467,7 @@ void AccessibilityNodeObject::helpText(Vector<AccessibilityText>& textOrder) con
         auto matchFunc = [] (const AccessibilityObject& object) {
             return object.isFieldset() && !object.ariaDescribedByAttribute().isEmpty();
         };
-        if (const auto* parent = AccessibilityObject::matchedParent(*this, false, WTFMove(matchFunc)))
+        if (const auto* parent = Accessibility::findAncestor<AccessibilityObject>(*this, false, WTFMove(matchFunc)))
             textOrder.append(AccessibilityText(parent->ariaDescribedByAttribute(), AccessibilityTextSource::Summary));
     }
 
@@ -1770,7 +1770,7 @@ String AccessibilityNodeObject::textUnderElement(AccessibilityTextUnderElementMo
     if (is<Text>(node))
         return downcast<Text>(*node).wholeText();
 
-    bool isAriaVisible = AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+    bool isAriaVisible = Accessibility::findAncestor<AccessibilityObject>(*this, true, [] (const AccessibilityObject& object) {
         return equalLettersIgnoringASCIICase(object.getAttribute(aria_hiddenAttr), "false");
     }) != nullptr;
 
index a34a5f0..1ca81e4 100644 (file)
@@ -524,9 +524,9 @@ unsigned AccessibilityObject::blockquoteLevel() const
 
 AXCoreObject* AccessibilityObject::parentObjectUnignored() const
 {
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*this, false, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [] (const AccessibilityObject& object) {
         return !object.accessibilityIsIgnored();
-    }));
+    });
 }
 
 AccessibilityObject* AccessibilityObject::previousSiblingUnignored(int limit) const
@@ -620,7 +620,7 @@ AccessibilityObject* firstAccessibleObjectFromNode(const Node* node, const WTF::
 
 bool AccessibilityObject::isDescendantOfRole(AccessibilityRole role) const
 {
-    return AccessibilityObject::matchedParent(*this, false, [&role] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [&role] (const AccessibilityObject& object) {
         return object.roleValue() == role;
     }) != nullptr;
 }
@@ -1938,7 +1938,7 @@ void AccessibilityObject::updateBackingStore()
 
 const AccessibilityScrollView* AccessibilityObject::ancestorAccessibilityScrollView(bool includeSelf) const
 {
-    return downcast<AccessibilityScrollView>(AccessibilityObject::matchedParent(*this, includeSelf, [] (const auto& object) {
+    return downcast<AccessibilityScrollView>(Accessibility::findAncestor<AccessibilityObject>(*this, includeSelf, [] (const auto& object) {
         return is<AccessibilityScrollView>(object);
     }));
 }
@@ -2038,19 +2038,9 @@ AccessibilityObject* AccessibilityObject::headingElementForNode(Node* node)
 
     AccessibilityObject* axObject = renderObject->document().axObjectCache()->getOrCreate(renderObject);
 
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*axObject, true, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*axObject, true, [] (const AccessibilityObject& object) {
         return object.roleValue() == AccessibilityRole::Heading;
-    }));
-}
-
-const AccessibilityObject* AccessibilityObject::matchedParent(const AccessibilityObject& object, bool includeSelf, const WTF::Function<bool(const AccessibilityObject&)>& matches)
-{
-    const AccessibilityObject* parent = includeSelf ? &object : object.parentObject();
-    for (; parent; parent = parent->parentObject()) {
-        if (matches(*parent))
-            return parent;
-    }
-    return nullptr;
+    });
 }
 
 void AccessibilityObject::ariaTreeRows(AccessibilityChildrenVector& result)
@@ -2365,7 +2355,7 @@ bool AccessibilityObject::isDescendantOfObject(const AXCoreObject* axObject) con
     if (!axObject || !axObject->hasChildren())
         return false;
 
-    return AccessibilityObject::matchedParent(*this, false, [axObject] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [axObject] (const AccessibilityObject& object) {
         return &object == axObject;
     }) != nullptr;
 }
@@ -2739,9 +2729,9 @@ bool AccessibilityObject::isInsideLiveRegion(bool excludeIfOff) const
     
 AccessibilityObject* AccessibilityObject::liveRegionAncestor(bool excludeIfOff) const
 {
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*this, true, [excludeIfOff] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, true, [excludeIfOff] (const AccessibilityObject& object) {
         return object.supportsLiveRegion(excludeIfOff);
-    }));
+    });
 }
 
 bool AccessibilityObject::supportsARIAAttributes() const
@@ -2958,7 +2948,7 @@ bool AccessibilityObject::isExpanded() const
     
     // Summary element should use its details parent's expanded status.
     if (isSummary()) {
-        if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*this, false, [] (const AccessibilityObject& object) {
+        if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*this, false, [] (const AccessibilityObject& object) {
             return is<HTMLDetailsElement>(object.node());
         }))
             return parent->isExpanded();
@@ -3425,7 +3415,7 @@ bool AccessibilityObject::accessibilityIsIgnoredByDefault() const
 // http://www.w3.org/TR/wai-aria/terms#def_hidden
 bool AccessibilityObject::isAXHidden() const
 {
-    return AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, true, [] (const AccessibilityObject& object) {
         return equalLettersIgnoringASCIICase(object.getAttribute(aria_hiddenAttr), "true");
     }) != nullptr;
 }
@@ -3538,16 +3528,16 @@ void AccessibilityObject::setPreventKeyboardDOMEventDispatch(bool on)
 
 AccessibilityObject* AccessibilityObject::focusableAncestor()
 {
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, true, [] (const AccessibilityObject& object) {
         return object.canSetFocusAttribute();
-    }));
+    });
 }
 
 AccessibilityObject* AccessibilityObject::editableAncestor()
 {
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, true, [] (const AccessibilityObject& object) {
         return object.isTextControl();
-    }));
+    });
 }
 
 AccessibilityObject* AccessibilityObject::highestEditableAncestor()
@@ -3570,9 +3560,9 @@ AccessibilityObject* AccessibilityObject::highestEditableAncestor()
 
 AccessibilityObject* AccessibilityObject::radioGroupAncestor() const
 {
-    return const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*this, false, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [] (const AccessibilityObject& object) {
         return object.isRadioGroup();
-    }));
+    });
 }
 
 bool AccessibilityObject::isStyleFormatGroup() const
index 383ddec..c96f508 100644 (file)
@@ -761,7 +761,6 @@ public:
     AccessibilityObject* highestEditableAncestor() override;
 
     const AccessibilityScrollView* ancestorAccessibilityScrollView(bool includeSelf) const override;
-    static const AccessibilityObject* matchedParent(const AccessibilityObject&, bool includeSelf, const WTF::Function<bool(const AccessibilityObject&)>&);
 
     void clearIsIgnoredFromParentData() override { m_isIgnoredFromParentData = AccessibilityIsIgnoredFromParentData(); }
     void setIsIgnoredFromParentDataForChild(AXCoreObject*) override;
index 2903de1..06d012a 100644 (file)
@@ -1077,4 +1077,29 @@ public:
     virtual void setIsIgnoredFromParentDataForChild(AXCoreObject*) = 0;
 };
 
+namespace Accessibility {
+
+template<typename T, typename F>
+T* findAncestor(const T& object, bool includeSelf, const F& matches)
+{
+    T* parent;
+    if (includeSelf)
+        parent = const_cast<T*>(&object);
+    else {
+        auto* parentPtr = object.parentObject();
+        if (!is<T>(parentPtr))
+            return nullptr;
+        parent = parentPtr;
+    }
+
+    for (; parent; parent = parent->parentObject()) {
+        if (matches(*parent))
+            return parent;
+    }
+
+    return nullptr;
+}
+
+} // namespace Accessibility
+
 } // namespace WebCore
index 7c0be74..89496bd 100644 (file)
@@ -1033,7 +1033,7 @@ bool AccessibilityRenderObject::hasTextAlternative() const
 bool AccessibilityRenderObject::hasPopup() const
 {
     // Return true if this has the aria-haspopup attribute, or if it has an ancestor of type link with the aria-haspopup attribute.
-    return AccessibilityObject::matchedParent(*this, true, [this] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*this, true, [this] (const AccessibilityObject& object) {
         return (this == &object) ? !equalLettersIgnoringASCIICase(object.popupValue(), "false")
             : object.isLink() && !equalLettersIgnoringASCIICase(object.popupValue(), "false");
     });
index b066886..c711439 100644 (file)
@@ -248,7 +248,7 @@ bool AccessibilitySVGElement::computeAccessibilityIsIgnored() const
     if (m_renderer->isSVGShape()) {
         if (canSetFocusAttribute() || element()->hasEventListeners())
             return false;
-        if (auto svgParent = AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+        if (auto* svgParent = Accessibility::findAncestor<AccessibilityObject>(*this, true, [] (const AccessibilityObject& object) {
             return object.hasAttributesRequiredForInclusion() || object.isAccessibilitySVGRoot();
         }))
             return !svgParent->hasAttributesRequiredForInclusion();
index 87bfb9e..98f9402 100644 (file)
@@ -555,7 +555,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
         return role == AccessibilityRole::Tree;
     };
     
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, WTFMove(matchFunc)))
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, WTFMove(matchFunc)))
         return parent->wrapper();
     return nil;
 }
@@ -567,14 +567,14 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
         return role == AccessibilityRole::List || role == AccessibilityRole::ListBox;
     };
     
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, WTFMove(matchFunc)))
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, WTFMove(matchFunc)))
         return parent->wrapper();
     return nil;
 }
 
 - (AccessibilityObjectWrapper*)_accessibilityArticleAncestor
 {
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, [] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [] (const AccessibilityObject& object) {
         return object.roleValue() == AccessibilityRole::DocumentArticle;
     }))
         return parent->wrapper();
@@ -583,7 +583,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
 
 - (AccessibilityObjectWrapper*)_accessibilityLandmarkAncestor
 {
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, [self] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [self] (const AccessibilityObject& object) {
         return [self _accessibilityIsLandmarkRole:object.roleValue()];
     }))
         return parent->wrapper();
@@ -592,7 +592,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
 
 - (AccessibilityObjectWrapper*)_accessibilityTableAncestor
 {
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, [] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [] (const AccessibilityObject& object) {
         return object.roleValue() == AccessibilityRole::Table;
     }))
         return parent->wrapper();
@@ -601,14 +601,14 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
 
 - (BOOL)_accessibilityIsInTableCell
 {
-    return AccessibilityObject::matchedParent(*m_object, false, [] (const AccessibilityObject& object) {
+    return Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [] (const AccessibilityObject& object) {
         return object.roleValue() == AccessibilityRole::Cell;
     }) != nullptr;
 }
 
 - (AccessibilityObjectWrapper*)_accessibilityFieldsetAncestor
 {
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*m_object, false, [] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [] (const AccessibilityObject& object) {
         return object.isFieldset();
     }))
         return parent->wrapper();
@@ -617,7 +617,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
 
 - (AccessibilityObjectWrapper*)_accessibilityFrameAncestor
 {
-    auto* parent = AccessibilityObject::matchedParent(*m_object, false, [] (const AccessibilityObject& object) {
+    auto* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, false, [] (const AccessibilityObject& object) {
         return object.isWebArea();
     });
     if (!parent)
@@ -1182,9 +1182,9 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
 - (AccessibilityTableCell*)tableCellParent
 {
     // Find if this element is in a table cell.
-    if (AccessibilityObject* parent = const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*m_object, true, [] (const AccessibilityObject& object) {
+    if (AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, true, [] (const AccessibilityObject& object) {
         return object.isTableCell();
-    })))
+    }))
         return static_cast<AccessibilityTableCell*>(parent);
     return nil;
 }
@@ -1192,9 +1192,9 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
 - (AccessibilityTable*)tableParent
 {
     // Find if the parent table for the table cell.
-    if (AccessibilityObject* parent = const_cast<AccessibilityObject*>(AccessibilityObject::matchedParent(*m_object, true, [] (const AccessibilityObject& object) {
+    if (AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, true, [] (const AccessibilityObject& object) {
         return is<AccessibilityTable>(object) && downcast<AccessibilityTable>(object).isExposableThroughAccessibility();
-    })))
+    }))
         return static_cast<AccessibilityTable*>(parent);
     return nil;
 }
@@ -1397,8 +1397,10 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
 {
     if (![self _prepareAccessibilityCall])
         return nil;
-    
-    if (auto parent = AccessibilityObject::matchedParent(*m_object, true, [] (const AccessibilityObject& object) { return object.supportsDatetimeAttribute(); }))
+
+    if (auto* parent = Accessibility::findAncestor<AccessibilityObject>(*m_object, true, [] (const AccessibilityObject& object) {
+        return object.supportsDatetimeAttribute();
+    }))
         return parent->datetimeAttributeValue();
 
     return nil;
@@ -1971,7 +1973,7 @@ static RenderObject* rendererForView(WAKView* view)
 {
     // Use this to check if an object is the child of a summary object.
     // And return the summary's parent, which is the expandable details object.
-    if (const AccessibilityObject* summary = AccessibilityObject::matchedParent(*object, true, [] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* summary = Accessibility::findAncestor<AccessibilityObject>(*object, true, [] (const AccessibilityObject& object) {
         return object.hasTagName(summaryTag);
     }))
         return summary->parentObject();
@@ -1981,7 +1983,7 @@ static RenderObject* rendererForView(WAKView* view)
 - (AccessibilityObject*)detailParentForObject:(AccessibilityObject*)object
 {
     // Use this to check if an object is inside a details object.
-    if (const AccessibilityObject* details = AccessibilityObject::matchedParent(*object, true, [] (const AccessibilityObject& object) {
+    if (const AccessibilityObject* details = Accessibility::findAncestor<AccessibilityObject>(*object, true, [] (const AccessibilityObject& object) {
         return object.hasTagName(detailsTag);
     }))
         return const_cast<AccessibilityObject*>(details);
@@ -1991,10 +1993,10 @@ static RenderObject* rendererForView(WAKView* view)
 - (AccessibilityObject*)treeItemParentForObject:(AccessibilityObject*)object
 {
     // Use this to check if an object is inside a treeitem object.
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*object, true, [] (const AccessibilityObject& object) {
+    if (AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*object, true, [] (const AccessibilityObject& object) {
         return object.roleValue() == AccessibilityRole::TreeItem;
     }))
-        return const_cast<AccessibilityObject*>(parent);
+        return parent;
     return nil;
 }
 
@@ -2208,8 +2210,8 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
     auto matchFunc = [] (const AccessibilityObject& object) {
         return object.node() && object.node()->hasTagName(codeTag);
     };
-    
-    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*axObject, true, WTFMove(matchFunc)))
+
+    if (const AccessibilityObject* parent = Accessibility::findAncestor<AccessibilityObject>(*axObject, true, WTFMove(matchFunc)))
         [attrString addAttribute:UIAccessibilityTextAttributeContext value:UIAccessibilityTextualContextSourceCode range:range];
 }