Implementation for AXIsolatedObject::nextSibling and previousSibling.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Sep 2020 18:52:36 +0000 (18:52 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Sep 2020 18:52:36 +0000 (18:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=216710

Reviewed by Chris Fleizach.

Implementation for AXIsolatedObject::previousSibling and nextSibling which
are invoked by VoiceOver in Safari Reader mode.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::previousSibling const):
- Fixed crash caused by dereferencing m_renderer->parent() which can be null.
- Added check for the AXObjectCache that can become null.
(WebCore::AccessibilityRenderObject::nextSibling const):
- Code style cleanup.
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
- Added caching of next/previousSiblling objects.
(WebCore::AXIsolatedObject::previousSibling const): Inlined in header..
(WebCore::AXIsolatedObject::nextSibling const): Inlined in header.
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/isolatedtree/AXIsolatedTree.h:

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h

index ed577aa..7484191 100644 (file)
@@ -1,3 +1,27 @@
+2020-09-19  Andres Gonzalez  <andresg_22@apple.com>
+
+        Implementation for AXIsolatedObject::nextSibling and previousSibling.
+        https://bugs.webkit.org/show_bug.cgi?id=216710
+
+        Reviewed by Chris Fleizach.
+
+        Implementation for AXIsolatedObject::previousSibling and nextSibling which
+        are invoked by VoiceOver in Safari Reader mode.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::previousSibling const):
+        - Fixed crash caused by dereferencing m_renderer->parent() which can be null.
+        - Added check for the AXObjectCache that can become null.
+        (WebCore::AccessibilityRenderObject::nextSibling const):
+        - Code style cleanup.
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        - Added caching of next/previousSiblling objects.
+        (WebCore::AXIsolatedObject::previousSibling const): Inlined in header..
+        (WebCore::AXIsolatedObject::nextSibling const): Inlined in header.
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        * accessibility/isolatedtree/AXIsolatedTree.h:
+
 2020-09-19  Sam Weinig  <weinig@apple.com>
 
         Performance and PerformanceNavigation interfaces are missing toJSON operations
index 8476867..e1e129f 100644 (file)
@@ -341,13 +341,16 @@ AccessibilityObject* AccessibilityRenderObject::previousSibling() const
 
     // Case 4: This node has no previous siblings, but its parent is an inline,
     // and is another node's inline continutation. Follow the continuation chain.
-    else if (is<RenderInline>(*m_renderer->parent()) && (startOfConts = startOfContinuations(*m_renderer->parent())))
+    else if (is<RenderInline>(m_renderer->parent()) && (startOfConts = startOfContinuations(*m_renderer->parent())))
         previousSibling = childBeforeConsideringContinuations(startOfConts, m_renderer->parent()->firstChild());
 
     if (!previousSibling)
         return nullptr;
-    
-    return axObjectCache()->getOrCreate(previousSibling);
+
+    if (auto* objectCache = axObjectCache())
+        return objectCache->getOrCreate(previousSibling);
+
+    return nullptr;
 }
 
 static inline bool lastChildHasContinuation(RenderElement& renderer)
@@ -410,13 +413,17 @@ AccessibilityObject* AccessibilityRenderObject::nextSibling() const
 
     if (!nextSibling)
         return nullptr;
-    
+
+    auto* objectCache = axObjectCache();
+    if (!objectCache)
+        return nullptr;
+
     // Make sure next sibling has the same parent.
-    AccessibilityObject* nextObj = axObjectCache()->getOrCreate(nextSibling);
-    if (nextObj && nextObj->parentObject() != this->parentObject())
+    auto* nextObject = objectCache->getOrCreate(nextSibling);
+    if (nextObject && nextObject->parentObject() != this->parentObject())
         return nullptr;
-    
-    return nextObj;
+
+    return nextObject;
 }
 
 static RenderBoxModelObject* nextContinuation(RenderObject& renderer)
index 3ecf1a6..8b02816 100644 (file)
@@ -206,7 +206,7 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::AutoCompleteValue, object.autoCompleteValue());
     setProperty(AXPropertyName::SpeakAs, object.speakAsProperty());
     setProperty(AXPropertyName::StringValue, object.stringValue().isolatedCopy());
-#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
     setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
 #endif
     setObjectProperty(AXPropertyName::FocusableAncestor, object.focusableAncestor());
@@ -229,7 +229,9 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::HasPlainText, object.hasPlainText());
     setProperty(AXPropertyName::HasUnderline, object.hasUnderline());
     setProperty(AXPropertyName::IsKeyboardFocusable, object.isKeyboardFocusable());
-    
+    setObjectProperty(AXPropertyName::NextSibling, object.nextSibling());
+    setObjectProperty(AXPropertyName::PreviousSibling, object.previousSibling());
+
     if (object.isTable()) {
         setProperty(AXPropertyName::IsTable, true);
         setProperty(AXPropertyName::IsExposable, object.isExposable());
@@ -1423,18 +1425,6 @@ AXCoreObject* AXIsolatedObject::lastChild() const
     return nullptr;
 }
 
-AXCoreObject* AXIsolatedObject::previousSibling() const
-{
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
-AXCoreObject* AXIsolatedObject::nextSibling() const
-{
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
 AXCoreObject* AXIsolatedObject::nextSiblingUnignored(int) const
 {
     ASSERT_NOT_REACHED();
index a6f62b6..952cce0 100644 (file)
@@ -541,8 +541,8 @@ private:
     AXCoreObject* elementAccessibilityHitTest(const IntPoint&) const override;
     AXCoreObject* firstChild() const override;
     AXCoreObject* lastChild() const override;
-    AXCoreObject* previousSibling() const override;
-    AXCoreObject* nextSibling() const override;
+    AXCoreObject* previousSibling() const override { return objectAttributeValue(AXPropertyName::PreviousSibling); }
+    AXCoreObject* nextSibling() const override { return objectAttributeValue(AXPropertyName::NextSibling); }
     AXCoreObject* nextSiblingUnignored(int limit) const override;
     AXCoreObject* previousSiblingUnignored(int limit) const override;
     AXCoreObject* parentObjectIfExists() const override;
index 2e3ba3a..518c41f 100644 (file)
@@ -247,10 +247,12 @@ enum class AXPropertyName : uint16_t {
     MathSuperscriptObject,
     MaxValueForRange,
     MinValueForRange,
+    NextSibling,
     Orientation,
     Path,
     PlaceholderValue,
     PressedIsPresent,
+    PreviousSibling,
     PopupValue,
     PosInSet,
     PreventKeyboardDOMEventDispatch,