AXIsolatedObject support for table column objects.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2020 16:16:57 +0000 (16:16 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2020 16:16:57 +0000 (16:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208215

Reviewed by Chris Fleizach.

Covered by existing tests.

- AccessibilityTableColumn interface is now exposed through
AXCoreObject.
- Separated isTableColumn from isAccessibilityTableColumnInstance.
- This eliminates to need to downcast in the wrapper code, and hence
makes it possible that the same code works for both AccessibilityObjects
and AXIsolatedObjects.
- Completed the caching of table column properties in AXIsolatedObject.
- Some minor code cleanup.

* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addChildren): Removed unnecessary cast.
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::addChildren): Removed unnecessary cast.
(WebCore::AccessibilityTable::columnHeaders):
* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::columnHeader):
(WebCore::AccessibilityTableColumn::headerObject): Renamed columnHeader.
* accessibility/AccessibilityTableColumn.h:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::isAccessibilityTableColumnInstance const):
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityObjectInterface.h
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.h
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 7af206f..7baddc7 100644 (file)
@@ -1,3 +1,39 @@
+2020-02-26  Andres Gonzalez  <andresg_22@apple.com>
+
+        AXIsolatedObject support for table column objects.
+        https://bugs.webkit.org/show_bug.cgi?id=208215
+
+        Reviewed by Chris Fleizach.
+
+        Covered by existing tests.
+
+        - AccessibilityTableColumn interface is now exposed through
+        AXCoreObject.
+        - Separated isTableColumn from isAccessibilityTableColumnInstance.
+        - This eliminates to need to downcast in the wrapper code, and hence
+        makes it possible that the same code works for both AccessibilityObjects
+        and AXIsolatedObjects.
+        - Completed the caching of table column properties in AXIsolatedObject.
+        - Some minor code cleanup.
+
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addChildren): Removed unnecessary cast.
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::addChildren): Removed unnecessary cast.
+        (WebCore::AccessibilityTable::columnHeaders):
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::columnHeader):
+        (WebCore::AccessibilityTableColumn::headerObject): Renamed columnHeader.
+        * accessibility/AccessibilityTableColumn.h:
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        (WebCore::AXIsolatedObject::isAccessibilityTableColumnInstance const):
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2020-02-26  Youenn Fablet  <youenn@apple.com>
 
         Conversion between MediaSample and RemoteVideoSample should preserve the rotation information
index 5a2b34c..e14a471 100644 (file)
@@ -139,7 +139,7 @@ void AccessibilityARIAGrid::addChildren()
     // make the columns based on the number of columns in the first body
     for (unsigned i = 0; i < columnCount; ++i) {
         auto& column = downcast<AccessibilityTableColumn>(*axCache->getOrCreate(AccessibilityRole::Column));
-        column.setColumnIndex(static_cast<int>(i));
+        column.setColumnIndex(i);
         column.setParent(this);
         m_columns.append(&column);
         if (!column.accessibilityIsIgnored())
index dd04a07..bd49d3f 100644 (file)
@@ -116,6 +116,8 @@ public:
     bool isAccessibilityTableInstance() const override { return false; }
     bool isAccessibilityProgressIndicatorInstance() const override { return false; }
 
+    bool isAccessibilityTableColumnInstance() const override { return false; }
+
     bool isAttachmentElement() const override { return false; }
     bool isHeading() const override { return false; }
     bool isLink() const override { return false; }
@@ -170,7 +172,11 @@ public:
     int axRowCount() const override { return 0; }
 
     bool isTableRow() const override { return false; }
+
     bool isTableColumn() const override { return false; }
+    unsigned columnIndex() const override { return 0; }
+    AXCoreObject* columnHeader() override { return nullptr; }
+
     bool isTableCell() const override { return false; }
     bool isFieldset() const override { return false; }
     bool isGroup() const override { return false; }
index 3a79a10..1709fcf 100644 (file)
@@ -489,6 +489,7 @@ public:
     virtual bool isAccessibilitySVGRoot() const = 0;
     virtual bool isAccessibilitySVGElement() const = 0;
     virtual bool isAccessibilityTableInstance() const = 0;
+    virtual bool isAccessibilityTableColumnInstance() const = 0;
     virtual bool isAccessibilityProgressIndicatorInstance() const = 0;
 
     virtual bool isAttachmentElement() const = 0;
@@ -552,7 +553,12 @@ public:
     virtual int axRowCount() const = 0;
 
     virtual bool isTableRow() const = 0;
+
+    // Table column support.
     virtual bool isTableColumn() const = 0;
+    virtual unsigned columnIndex() const = 0;
+    virtual AXCoreObject* columnHeader() = 0;
+
     virtual bool isTableCell() const = 0;
 
     virtual bool isFieldset() const = 0;
index 225fc8e..1bce886 100644 (file)
@@ -418,7 +418,7 @@ void AccessibilityTable::addChildren()
     unsigned length = maxColumnCount;
     for (unsigned i = 0; i < length; ++i) {
         auto& column = downcast<AccessibilityTableColumn>(*axCache->getOrCreate(AccessibilityRole::Column));
-        column.setColumnIndex((int)i);
+        column.setColumnIndex(i);
         column.setParent(this);
         m_columns.append(&column);
         if (!column.accessibilityIsIgnored())
@@ -538,7 +538,7 @@ AXCoreObject::AccessibilityChildrenVector AccessibilityTable::columnHeaders()
     AccessibilityChildrenVector columnsCopy = m_columns;
 
     for (const auto& column : columnsCopy) {
-        if (AXCoreObject* header = downcast<AccessibilityTableColumn>(*column).headerObject())
+        if (auto* header = column->columnHeader())
             headers.append(header);
     }
 
index 03d2ec7..ec509fc 100644 (file)
@@ -69,21 +69,18 @@ LayoutRect AccessibilityTableColumn::elementRect() const
     return columnRect;
 }
 
-AXCoreObject* AccessibilityTableColumn::headerObject()
+AXCoreObject* AccessibilityTableColumn::columnHeader()
 {
-    if (!m_parent)
+    if (!m_parent || !is<AccessibilityTable>(*m_parent)
+        || !m_parent->isExposable())
         return nullptr;
-    
+
     RenderObject* renderer = m_parent->renderer();
     if (!renderer)
         return nullptr;
-    if (!is<AccessibilityTable>(*m_parent))
-        return nullptr;
 
     auto& parentTable = downcast<AccessibilityTable>(*m_parent);
-    if (!parentTable.isExposable())
-        return nullptr;
-    
+
     if (parentTable.isAriaTable()) {
         for (const auto& cell : children()) {
             if (cell->ariaRoleAttribute() == AccessibilityRole::ColumnHeader)
index 5697cc1..f32647a 100644 (file)
@@ -41,13 +41,13 @@ public:
     static Ref<AccessibilityTableColumn> create();
     virtual ~AccessibilityTableColumn();
 
-    AXCoreObject* headerObject();
+    AXCoreObject* columnHeader() override;
 
     AccessibilityRole roleValue() const override { return AccessibilityRole::Column; }
-    
-    void setColumnIndex(int columnIndex) { m_columnIndex = columnIndex; }
-    int columnIndex() const { return m_columnIndex; }    
-    
+
+    void setColumnIndex(unsigned columnIndex) { m_columnIndex = columnIndex; }
+    unsigned columnIndex() const override { return m_columnIndex; }
+
     void addChildren() override;
     void setParent(AccessibilityObject*) override;
     
@@ -60,9 +60,10 @@ private:
     bool computeAccessibilityIsIgnored() const override;
     bool isTableColumn() const override { return true; }
 
+    bool isAccessibilityTableColumnInstance() const final { return true; }
     unsigned m_columnIndex;
 };
 
 } // namespace WebCore 
 
-SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTableColumn, isTableColumn())
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTableColumn, isAccessibilityTableColumnInstance())
index 1d53925..a6b010a 100644 (file)
@@ -115,7 +115,6 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::IsSlider, object.isSlider());
     setProperty(AXPropertyName::IsStyleFormatGroup, object.isStyleFormatGroup());
     setProperty(AXPropertyName::IsTableCell, object.isTableCell());
-    setProperty(AXPropertyName::IsTableColumn, object.isTableColumn());
     setProperty(AXPropertyName::IsTableRow, object.isTableRow());
     setProperty(AXPropertyName::IsTextControl, object.isTextControl());
     setProperty(AXPropertyName::IsTree, object.isTree());
@@ -237,6 +236,12 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
         setProperty(AXPropertyName::AXRowCount, object.axRowCount());
     }
 
+    if (object.isTableColumn()) {
+        setProperty(AXPropertyName::IsTableColumn, object.isTableColumn());
+        setProperty(AXPropertyName::ColumnIndex, object.columnIndex());
+        setProperty(AXPropertyName::ColumnHeader, object.columnHeader());
+    }
+
     if (object.isTextControl())
         setProperty(AXPropertyName::TextLength, object.textLength());
 
@@ -937,6 +942,12 @@ bool AXIsolatedObject::isAccessibilityTableInstance() const
     return false;
 }
 
+bool AXIsolatedObject::isAccessibilityTableColumnInstance() const
+{
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 bool AXIsolatedObject::isAccessibilityProgressIndicatorInstance() const
 {
     ASSERT_NOT_REACHED();
index db0dd11..e7f2a5e 100644 (file)
@@ -120,7 +120,9 @@ private:
         ColorValue,
         Columns,
         ColumnCount,
+        ColumnHeader,
         ColumnHeaders,
+        ColumnIndex,
         ComputedLabel,
         ComputedRoleString,
         CurrentState,
@@ -399,7 +401,12 @@ private:
     int axRowCount() const override { return intAttributeValue(AXPropertyName::AXRowCount); }
 
     bool isTableRow() const override { return boolAttributeValue(AXPropertyName::IsTableRow); }
+
+    // Table column support.
     bool isTableColumn() const override { return boolAttributeValue(AXPropertyName::IsTableColumn); }
+    unsigned columnIndex() const override { return unsignedAttributeValue(AXPropertyName::ColumnIndex); }
+    AXCoreObject* columnHeader() override { return objectAttributeValue(AXPropertyName::ColumnHeader); }
+
     bool isTableCell() const override { return boolAttributeValue(AXPropertyName::IsTableCell); }
     bool isFieldset() const override { return boolAttributeValue(AXPropertyName::IsFieldset); }
     bool isGroup() const override { return boolAttributeValue(AXPropertyName::IsGroup); }
@@ -689,7 +696,9 @@ private:
     bool isAccessibilitySVGRoot() const override;
     bool isAccessibilitySVGElement() const override;
     bool isAccessibilityTableInstance() const override;
+    bool isAccessibilityTableColumnInstance() const override;
     bool isAccessibilityProgressIndicatorInstance() const override;
+
     bool isAttachmentElement() const override;
     bool isNativeImage() const override;
     bool isImageButton() const override;
index 562ab7b..3849949 100644 (file)
@@ -2743,21 +2743,18 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             return @(backingObject->axRowCount());
     }
 
-    if (is<AccessibilityTableColumn>(*backingObject)) {
-        auto& column = downcast<AccessibilityTableColumn>(*backingObject);
+    if (backingObject->isTableColumn()) {
         if ([attributeName isEqualToString:NSAccessibilityIndexAttribute])
-            return [NSNumber numberWithInt:column.columnIndex()];
+            return [NSNumber numberWithUnsignedInt:backingObject->columnIndex()];
 
         // rows attribute for a column is the list of all the elements in that column at each row
-        if ([attributeName isEqualToString:NSAccessibilityRowsAttribute] ||
-            [attributeName isEqualToString:NSAccessibilityVisibleRowsAttribute]) {
-            return convertToNSArray(column.children());
-        }
+        if ([attributeName isEqualToString:NSAccessibilityRowsAttribute]
+            || [attributeName isEqualToString:NSAccessibilityVisibleRowsAttribute])
+            return convertToNSArray(backingObject->children());
+
         if ([attributeName isEqualToString:NSAccessibilityHeaderAttribute]) {
-            AXCoreObject* header = column.headerObject();
-            if (!header)
-                return nil;
-            return header->wrapper();
+            auto* header = backingObject->columnHeader();
+            return header ? header->wrapper() : nil;
         }
     }