Use is<>() / downcast<>() for Accessibility objects
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 19:08:40 +0000 (19:08 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 19:08:40 +0000 (19:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137286

Reviewed by Darin Adler.

Source/WebCore:

Use is<>() / downcast<>() for Accessibility objects and clean up the
surrounding code.

No new tests, no behavior change.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::focusedImageMapUIElement):
(WebCore::AXObjectCache::notificationPostTimerFired):
* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addTableCellChild):
(WebCore::AccessibilityARIAGrid::addChildren):
* accessibility/AccessibilityARIAGridCell.cpp:
(WebCore::AccessibilityARIAGridCell::parentTable):
(WebCore::AccessibilityARIAGridCell::rowIndexRange):
* accessibility/AccessibilityARIAGridRow.cpp:
(WebCore::AccessibilityARIAGridRow::disclosedRows):
(WebCore::AccessibilityARIAGridRow::disclosedByRow):
(WebCore::AccessibilityARIAGridRow::parentTable):
* accessibility/AccessibilityARIAGridRow.h:
* accessibility/AccessibilityImageMapLink.cpp:
(WebCore::AccessibilityImageMapLink::imageMapLinkRenderer):
* accessibility/AccessibilityImageMapLink.h:
* accessibility/AccessibilityList.h:
* accessibility/AccessibilityListBox.cpp:
(WebCore::AccessibilityListBox::setSelectedChildren):
(WebCore::AccessibilityListBox::selectedChildren):
(WebCore::AccessibilityListBox::listBoxOptionAccessibilityObject):
* accessibility/AccessibilityListBox.h:
* accessibility/AccessibilityListBoxOption.h:
* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::addChildren):
(WebCore::AccessibilityMenuList::didUpdateActiveOption):
* accessibility/AccessibilityMenuList.h:
* accessibility/AccessibilityMenuListOption.h:
* accessibility/AccessibilityMenuListPopup.cpp:
(WebCore::AccessibilityMenuListPopup::menuListOptionAccessibilityObject):
* accessibility/AccessibilityMenuListPopup.h:
* accessibility/AccessibilityMockObject.h:
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textUnderElement):
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityObject.cpp:
(WebCore::appendChildrenToArray):
(WebCore::AccessibilityObject::scrollViewAncestor):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::getDocumentLinks):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
(WebCore::AccessibilityRenderObject::addImageMapChildren):
(WebCore::AccessibilityRenderObject::addTextFieldChildren):
(WebCore::AccessibilityRenderObject::remoteSVGRootElement):
(WebCore::AccessibilityRenderObject::ariaSelectedRows):
* accessibility/AccessibilityRenderObject.h:
* accessibility/AccessibilitySVGRoot.h:
* accessibility/AccessibilityScrollView.cpp:
(WebCore::AccessibilityScrollView::addChildScrollbar):
* accessibility/AccessibilityScrollView.h:
* accessibility/AccessibilityScrollbar.h:
* accessibility/AccessibilitySlider.cpp:
(WebCore::AccessibilitySlider::addChildren):
* accessibility/AccessibilitySlider.h:
* accessibility/AccessibilitySpinButton.cpp:
(WebCore::AccessibilitySpinButton::addChildren):
(WebCore::AccessibilitySpinButtonPart::press):
* accessibility/AccessibilitySpinButton.h:
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::addChildren):
(WebCore::AccessibilityTable::addChildrenFromSection):
(WebCore::AccessibilityTable::headerContainer):
(WebCore::AccessibilityTable::columnHeaders):
(WebCore::AccessibilityTable::rowHeaders):
(WebCore::AccessibilityTable::cellForColumnAndRow):
* accessibility/AccessibilityTable.h:
Make isAccessibilityTable() public and mark as final so that callers
can benefit from tighter typing, as isAccessibilityTable() is
stricter than isTable(). isTable() indicates that the object is an
AccessibilityTable and is equivalent to is<AccessibilityTable>(object).
isAccessibilityTable() is equivalent to "isTable() && renderer()".

* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::parentTable):
* accessibility/AccessibilityTableCell.h:
* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::headerObject):
(WebCore::AccessibilityTableColumn::addChildren):
* accessibility/AccessibilityTableColumn.h:
* accessibility/AccessibilityTableHeaderContainer.cpp:
(WebCore::AccessibilityTableHeaderContainer::addChildren):
* accessibility/AccessibilityTableRow.cpp:
(WebCore::AccessibilityTableRow::parentTable):
(WebCore::AccessibilityTableRow::headerObject):
* accessibility/AccessibilityTableRow.h:
* accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
(webkitAccessibleSelectionClearSelection):
(webkitAccessibleSelectionSelectAllSelection):
* accessibility/atk/WebKitAccessibleInterfaceTable.cpp:
(core):
(cell):
(cellAtIndex):
(webkitAccessibleTableGetIndexAt):
(webkitAccessibleTableGetNColumns):
(webkitAccessibleTableGetNRows):
(webkitAccessibleTableGetColumnHeader):
(webkitAccessibleTableGetRowHeader):
* accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp:
(webkitAccessibleTableCellGetColumnHeaderCells):
(webkitAccessibleTableCellGetRowHeaderCells):
(webkitAccessibleTableCellGetColumnSpan):
(webkitAccessibleTableCellGetRowSpan):
(webkitAccessibleTableCellGetPosition):
* accessibility/ios/AccessibilityObjectIOS.mm:
(WebCore::AccessibilityObject::accessibilityPasswordFieldLength):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper convertPointToScreenSpace:]):
(-[WebAccessibilityObjectWrapper convertRectToScreenSpace:]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetElement):
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper convertPointToScreenSpace:]):
(-[WebAccessibilityObjectWrapper subrole]):
(-[WebAccessibilityObjectWrapper roleDescription]):
(-[WebAccessibilityObjectWrapper scrollViewParent]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[WebAccessibilityObjectWrapper accessibilityShowContextMenu]):
(-[WebAccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForAccessibilityProperties):
* rendering/RenderMenuList.cpp:
(RenderMenuList::didUpdateActiveOption):

Source/WebKit/win:

Use is<>() / downcast<>() for Accessibility objects.

* AccessibleBase.cpp:
(AccessibleBase::accSelect):
* AccessibleImage.cpp:
(AccessibleImage::name):

Source/WTF:

Remove the legacy TYPE_CASTS_BASE() macro now that it is no longer
used.

* wtf/Assertions.h:

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

54 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Assertions.h
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp
Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp
Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp
Source/WebCore/accessibility/AccessibilityARIAGridRow.h
Source/WebCore/accessibility/AccessibilityImageMapLink.cpp
Source/WebCore/accessibility/AccessibilityImageMapLink.h
Source/WebCore/accessibility/AccessibilityList.h
Source/WebCore/accessibility/AccessibilityListBox.cpp
Source/WebCore/accessibility/AccessibilityListBox.h
Source/WebCore/accessibility/AccessibilityListBoxOption.h
Source/WebCore/accessibility/AccessibilityMenuList.cpp
Source/WebCore/accessibility/AccessibilityMenuList.h
Source/WebCore/accessibility/AccessibilityMenuListOption.h
Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp
Source/WebCore/accessibility/AccessibilityMenuListPopup.h
Source/WebCore/accessibility/AccessibilityMockObject.h
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.h
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h
Source/WebCore/accessibility/AccessibilitySVGRoot.h
Source/WebCore/accessibility/AccessibilityScrollView.cpp
Source/WebCore/accessibility/AccessibilityScrollView.h
Source/WebCore/accessibility/AccessibilityScrollbar.h
Source/WebCore/accessibility/AccessibilitySlider.cpp
Source/WebCore/accessibility/AccessibilitySlider.h
Source/WebCore/accessibility/AccessibilitySpinButton.cpp
Source/WebCore/accessibility/AccessibilitySpinButton.h
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/AccessibilityTable.h
Source/WebCore/accessibility/AccessibilityTableCell.cpp
Source/WebCore/accessibility/AccessibilityTableCell.h
Source/WebCore/accessibility/AccessibilityTableColumn.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.h
Source/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp
Source/WebCore/accessibility/AccessibilityTableRow.cpp
Source/WebCore/accessibility/AccessibilityTableRow.h
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTable.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp
Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebKit/win/AccessibleBase.cpp
Source/WebKit/win/AccessibleImage.cpp
Source/WebKit/win/ChangeLog

index 4c62c50..70f7be8 100644 (file)
@@ -1,3 +1,15 @@
+2014-10-20  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for Accessibility objects
+        https://bugs.webkit.org/show_bug.cgi?id=137286
+
+        Reviewed by Darin Adler.
+
+        Remove the legacy TYPE_CASTS_BASE() macro now that it is no longer
+        used.
+
+        * wtf/Assertions.h:
+
 2014-10-18  Dan Bernstein  <mitz@apple.com>
 
         WorkQueue dispatches functions but isn’t a FunctionDispatcher
index 72be3d6..054750a 100644 (file)
@@ -382,32 +382,4 @@ static inline void UNREACHABLE_FOR_PLATFORM()
 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
 #endif
 
-/* TYPE CAST */
-
-// FIXME: This macro should be removed once the code base is ported to using
-// the new SPECIALIZE_TYPE_TRAITS_*() macro.
-#define TYPE_CASTS_BASE(ToClassName, argumentType, argumentName, pointerPredicate, referencePredicate) \
-inline ToClassName* to##ToClassName(argumentType* argumentName) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
-    return static_cast<ToClassName*>(argumentName); \
-} \
-inline const ToClassName* to##ToClassName(const argumentType* argumentName) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
-    return static_cast<const ToClassName*>(argumentName); \
-} \
-inline ToClassName& to##ToClassName(argumentType& argumentName) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
-    return static_cast<ToClassName&>(argumentName); \
-} \
-inline const ToClassName& to##ToClassName(const argumentType& argumentName) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
-    return static_cast<const ToClassName&>(argumentName); \
-} \
-void to##ToClassName(const ToClassName*); \
-void to##ToClassName(const ToClassName&);
-
 #endif /* WTF_Assertions_h */
index 1fd96d7..f251710 100644 (file)
@@ -1,3 +1,142 @@
+2014-10-20  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for Accessibility objects
+        https://bugs.webkit.org/show_bug.cgi?id=137286
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for Accessibility objects and clean up the
+        surrounding code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::focusedImageMapUIElement):
+        (WebCore::AXObjectCache::notificationPostTimerFired):
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addTableCellChild):
+        (WebCore::AccessibilityARIAGrid::addChildren):
+        * accessibility/AccessibilityARIAGridCell.cpp:
+        (WebCore::AccessibilityARIAGridCell::parentTable):
+        (WebCore::AccessibilityARIAGridCell::rowIndexRange):
+        * accessibility/AccessibilityARIAGridRow.cpp:
+        (WebCore::AccessibilityARIAGridRow::disclosedRows):
+        (WebCore::AccessibilityARIAGridRow::disclosedByRow):
+        (WebCore::AccessibilityARIAGridRow::parentTable):
+        * accessibility/AccessibilityARIAGridRow.h:
+        * accessibility/AccessibilityImageMapLink.cpp:
+        (WebCore::AccessibilityImageMapLink::imageMapLinkRenderer):
+        * accessibility/AccessibilityImageMapLink.h:
+        * accessibility/AccessibilityList.h:
+        * accessibility/AccessibilityListBox.cpp:
+        (WebCore::AccessibilityListBox::setSelectedChildren):
+        (WebCore::AccessibilityListBox::selectedChildren):
+        (WebCore::AccessibilityListBox::listBoxOptionAccessibilityObject):
+        * accessibility/AccessibilityListBox.h:
+        * accessibility/AccessibilityListBoxOption.h:
+        * accessibility/AccessibilityMenuList.cpp:
+        (WebCore::AccessibilityMenuList::addChildren):
+        (WebCore::AccessibilityMenuList::didUpdateActiveOption):
+        * accessibility/AccessibilityMenuList.h:
+        * accessibility/AccessibilityMenuListOption.h:
+        * accessibility/AccessibilityMenuListPopup.cpp:
+        (WebCore::AccessibilityMenuListPopup::menuListOptionAccessibilityObject):
+        * accessibility/AccessibilityMenuListPopup.h:
+        * accessibility/AccessibilityMockObject.h:
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::textUnderElement):
+        * accessibility/AccessibilityNodeObject.h:
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::appendChildrenToArray):
+        (WebCore::AccessibilityObject::scrollViewAncestor):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::getDocumentLinks):
+        (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
+        (WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
+        (WebCore::AccessibilityRenderObject::addImageMapChildren):
+        (WebCore::AccessibilityRenderObject::addTextFieldChildren):
+        (WebCore::AccessibilityRenderObject::remoteSVGRootElement):
+        (WebCore::AccessibilityRenderObject::ariaSelectedRows):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/AccessibilitySVGRoot.h:
+        * accessibility/AccessibilityScrollView.cpp:
+        (WebCore::AccessibilityScrollView::addChildScrollbar):
+        * accessibility/AccessibilityScrollView.h:
+        * accessibility/AccessibilityScrollbar.h:
+        * accessibility/AccessibilitySlider.cpp:
+        (WebCore::AccessibilitySlider::addChildren):
+        * accessibility/AccessibilitySlider.h:
+        * accessibility/AccessibilitySpinButton.cpp:
+        (WebCore::AccessibilitySpinButton::addChildren):
+        (WebCore::AccessibilitySpinButtonPart::press):
+        * accessibility/AccessibilitySpinButton.h:
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::addChildren):
+        (WebCore::AccessibilityTable::addChildrenFromSection):
+        (WebCore::AccessibilityTable::headerContainer):
+        (WebCore::AccessibilityTable::columnHeaders):
+        (WebCore::AccessibilityTable::rowHeaders):
+        (WebCore::AccessibilityTable::cellForColumnAndRow):
+        * accessibility/AccessibilityTable.h:
+        Make isAccessibilityTable() public and mark as final so that callers
+        can benefit from tighter typing, as isAccessibilityTable() is
+        stricter than isTable(). isTable() indicates that the object is an
+        AccessibilityTable and is equivalent to is<AccessibilityTable>(object).
+        isAccessibilityTable() is equivalent to "isTable() && renderer()".
+
+        * accessibility/AccessibilityTableCell.cpp:
+        (WebCore::AccessibilityTableCell::parentTable):
+        * accessibility/AccessibilityTableCell.h:
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObject):
+        (WebCore::AccessibilityTableColumn::addChildren):
+        * accessibility/AccessibilityTableColumn.h:
+        * accessibility/AccessibilityTableHeaderContainer.cpp:
+        (WebCore::AccessibilityTableHeaderContainer::addChildren):
+        * accessibility/AccessibilityTableRow.cpp:
+        (WebCore::AccessibilityTableRow::parentTable):
+        (WebCore::AccessibilityTableRow::headerObject):
+        * accessibility/AccessibilityTableRow.h:
+        * accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
+        (webkitAccessibleSelectionClearSelection):
+        (webkitAccessibleSelectionSelectAllSelection):
+        * accessibility/atk/WebKitAccessibleInterfaceTable.cpp:
+        (core):
+        (cell):
+        (cellAtIndex):
+        (webkitAccessibleTableGetIndexAt):
+        (webkitAccessibleTableGetNColumns):
+        (webkitAccessibleTableGetNRows):
+        (webkitAccessibleTableGetColumnHeader):
+        (webkitAccessibleTableGetRowHeader):
+        * accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp:
+        (webkitAccessibleTableCellGetColumnHeaderCells):
+        (webkitAccessibleTableCellGetRowHeaderCells):
+        (webkitAccessibleTableCellGetColumnSpan):
+        (webkitAccessibleTableCellGetRowSpan):
+        (webkitAccessibleTableCellGetPosition):
+        * accessibility/ios/AccessibilityObjectIOS.mm:
+        (WebCore::AccessibilityObject::accessibilityPasswordFieldLength):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper convertPointToScreenSpace:]):
+        (-[WebAccessibilityObjectWrapper convertRectToScreenSpace:]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetElement):
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+        (-[WebAccessibilityObjectWrapper convertPointToScreenSpace:]):
+        (-[WebAccessibilityObjectWrapper subrole]):
+        (-[WebAccessibilityObjectWrapper roleDescription]):
+        (-[WebAccessibilityObjectWrapper scrollViewParent]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        (-[WebAccessibilityObjectWrapper accessibilityShowContextMenu]):
+        (-[WebAccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForAccessibilityProperties):
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::didUpdateActiveOption):
+
 2014-10-20  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Generate all Inspector domains together in JavaScriptCore
index 16312b0..02452d5 100644 (file)
@@ -159,10 +159,10 @@ AccessibilityObject* AXObjectCache::focusedImageMapUIElement(HTMLAreaElement* ar
         return nullptr;
     
     for (const auto& child : axRenderImage->children()) {
-        if (!child->isImageMapLink())
+        if (!is<AccessibilityImageMapLink>(*child))
             continue;
         
-        if (toAccessibilityImageMapLink(child.get())->areaElement() == areaElement)
+        if (downcast<AccessibilityImageMapLink>(*child).areaElement() == areaElement)
             return child.get();
     }    
     
@@ -720,10 +720,8 @@ void AXObjectCache::notificationPostTimerFired(Timer<AXObjectCache>&)
 #ifndef NDEBUG
         // Make sure none of the render views are in the process of being layed out.
         // Notifications should only be sent after the renderer has finished
-        if (obj->isAccessibilityRenderObject()) {
-            AccessibilityRenderObject* renderObj = toAccessibilityRenderObject(obj);
-            RenderObject* renderer = renderObj->renderer();
-            if (renderer)
+        if (is<AccessibilityRenderObject>(*obj)) {
+            if (auto* renderer = downcast<AccessibilityRenderObject>(*obj).renderer())
                 ASSERT(!renderer->view().layoutState());
         }
 #endif
index 11e21f0..585fb07 100644 (file)
@@ -55,29 +55,29 @@ PassRefPtr<AccessibilityARIAGrid> AccessibilityARIAGrid::create(RenderObject* re
 
 bool AccessibilityARIAGrid::addTableCellChild(AccessibilityObject* child, HashSet<AccessibilityObject*>& appendedRows, unsigned& columnCount)
 {
-    if (!child || (!child->isTableRow() && child->ariaRoleAttribute() != RowRole))
+    if (!child || (!is<AccessibilityTableRow>(*child) && !is<AccessibilityARIAGridRow>(*child)))
         return false;
         
-    AccessibilityTableRow* row = toAccessibilityTableRow(child);
-    if (appendedRows.contains(row))
+    auto& row = downcast<AccessibilityTableRow>(*child);
+    if (appendedRows.contains(&row))
         return false;
         
     // store the maximum number of columns
-    unsigned rowCellCount = row->children().size();
+    unsigned rowCellCount = row.children().size();
     if (rowCellCount > columnCount)
         columnCount = rowCellCount;
     
-    row->setRowIndex((int)m_rows.size());        
-    m_rows.append(row);
+    row.setRowIndex((int)m_rows.size());
+    m_rows.append(&row);
 
     // Try adding the row if it's not ignoring accessibility,
     // otherwise add its children (the cells) as the grid's children.
-    if (!row->accessibilityIsIgnored())
-        m_children.append(row);
+    if (!row.accessibilityIsIgnored())
+        m_children.append(&row);
     else
-        m_children.appendVector(row->children());
+        m_children.appendVector(row.children());
 
-    appendedRows.add(row);
+    appendedRows.add(&row);
     return true;
 }
 
@@ -134,12 +134,12 @@ void AccessibilityARIAGrid::addChildren()
     
     // make the columns based on the number of columns in the first body
     for (unsigned i = 0; i < columnCount; ++i) {
-        AccessibilityTableColumn* column = toAccessibilityTableColumn(axCache->getOrCreate(ColumnRole));
-        column->setColumnIndex((int)i);
-        column->setParent(this);
-        m_columns.append(column);
-        if (!column->accessibilityIsIgnored())
-            m_children.append(column);
+        auto& column = downcast<AccessibilityTableColumn>(*axCache->getOrCreate(ColumnRole));
+        column.setColumnIndex(static_cast<int>(i));
+        column.setParent(this);
+        m_columns.append(&column);
+        if (!column.accessibilityIsIgnored())
+            m_children.append(&column);
     }
     
     AccessibilityObject* headerContainerObject = headerContainer();
index 58bed2b..d1dc939 100644 (file)
@@ -56,7 +56,7 @@ AccessibilityTable* AccessibilityARIAGridCell::parentTable() const
         return nullptr;
     
     if (parent->isAccessibilityTable())
-        return toAccessibilityTable(parent);
+        return downcast<AccessibilityTable>(parent);
 
     // It could happen that we hadn't reached the parent table yet (in
     // case objects for rows were not ignoring accessibility) so for
@@ -65,7 +65,7 @@ AccessibilityTable* AccessibilityARIAGridCell::parentTable() const
     if (!parent || !parent->isAccessibilityTable())
         return nullptr;
     
-    return toAccessibilityTable(parent);
+    return downcast<AccessibilityTable>(parent);
 }
     
 void AccessibilityARIAGridCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange)
@@ -74,13 +74,13 @@ void AccessibilityARIAGridCell::rowIndexRange(std::pair<unsigned, unsigned>& row
     if (!parent)
         return;
 
-    if (parent->isTableRow()) {
+    if (is<AccessibilityTableRow>(*parent)) {
         // We already got a table row, use its API.
-        rowRange.first = toAccessibilityTableRow(parent)->rowIndex();
+        rowRange.first = downcast<AccessibilityTableRow>(*parent).rowIndex();
     } else if (parent->isAccessibilityTable()) {
         // We reached the parent table, so we need to inspect its
         // children to determine the row index for the cell in it.
-        unsigned columnCount = toAccessibilityTable(parent)->columnCount();
+        unsigned columnCount = downcast<AccessibilityTable>(*parent).columnCount();
         if (!columnCount)
             return;
 
index 9dfa0be..092ca44 100644 (file)
@@ -73,7 +73,7 @@ void AccessibilityARIAGridRow::disclosedRows(AccessibilityChildrenVector& disclo
         return;
     
     unsigned level = hierarchicalLevel();
-    auto& allRows = toAccessibilityTable(parent)->rows();
+    auto& allRows = downcast<AccessibilityTable>(*parent).rows();
     int rowCount = allRows.size();
     for (int k = index + 1; k < rowCount; ++k) {
         AccessibilityObject* row = allRows[k].get();
@@ -100,7 +100,7 @@ AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const
     
     // Search for the previous row that matches the correct level.
     int index = rowIndex();
-    auto& allRows = toAccessibilityTable(parent)->rows();
+    auto& allRows = downcast<AccessibilityTable>(parent)->rows();
     int rowCount = allRows.size();
     if (index >= rowCount)
         return nullptr;
@@ -120,8 +120,8 @@ AccessibilityTable* AccessibilityARIAGridRow::parentTable() const
     // only have "row" elements, but if not, we still should handle it gracefully by finding the right table.
     for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
         // The parent table for an ARIA grid row should be an ARIA table.
-        if (parent->isTable() && parent->isAccessibilityTable() && toAccessibilityTable(parent)->isAriaTable())
-            return toAccessibilityTable(parent);
+        if (parent->isAccessibilityTable() && downcast<AccessibilityTable>(*parent).isAriaTable())
+            return downcast<AccessibilityTable>(parent);
     }
     
     return nullptr;
index 33ffa56..35e6d41 100644 (file)
@@ -53,8 +53,8 @@ private:
     virtual AccessibilityTable* parentTable() const override;
 }; 
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityARIAGridRow, isARIATreeGridRow())
-
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityARIAGridRow, isARIATreeGridRow())
+
 #endif // AccessibilityARIAGridRow_h
index ae957f0..9a9afb4 100644 (file)
@@ -140,8 +140,8 @@ RenderElement* AccessibilityImageMapLink::imageMapLinkRenderer() const
         return nullptr;
 
     RenderElement* renderer = nullptr;
-    if (m_parent && m_parent->isAccessibilityRenderObject())
-        renderer = downcast<RenderElement>(toAccessibilityRenderObject(m_parent)->renderer());
+    if (is<AccessibilityRenderObject>(m_parent))
+        renderer = downcast<RenderElement>(downcast<AccessibilityRenderObject>(*m_parent).renderer());
     else
         renderer = m_mapElement->renderer();
     
index 91f5ca6..52ecbfc 100644 (file)
@@ -80,9 +80,9 @@ private:
     virtual bool isImageMapLink() const override { return true; }
     virtual bool supportsPath() const override { return true; }
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityImageMapLink, isImageMapLink())
     
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityImageMapLink, isImageMapLink())
+
 #endif // AccessibilityImageMapLink_h
index 48bb2f6..f3efe49 100644 (file)
@@ -52,8 +52,8 @@ private:
     virtual AccessibilityRole determineAccessibilityRole() override;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityList, isList())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityList, isList())
+
 #endif // AccessibilityList_h
index 3561ee6..a360dd3 100644 (file)
@@ -92,16 +92,16 @@ void AccessibilityListBox::setSelectedChildren(const AccessibilityChildrenVector
     
     // disable any selected options
     for (const auto& child : m_children) {
-        AccessibilityListBoxOption* listBoxOption = toAccessibilityListBoxOption(child.get());
-        if (listBoxOption->isSelected())
-            listBoxOption->setSelected(false);
+        auto& listBoxOption = downcast<AccessibilityListBoxOption>(*child);
+        if (listBoxOption.isSelected())
+            listBoxOption.setSelected(false);
     }
     
     for (const auto& obj : children) {
         if (obj->roleValue() != ListBoxOptionRole)
             continue;
                 
-        toAccessibilityListBoxOption(obj.get())->setSelected(true);
+        downcast<AccessibilityListBoxOption>(*obj).setSelected(true);
     }
 }
     
@@ -113,7 +113,7 @@ void AccessibilityListBox::selectedChildren(AccessibilityChildrenVector& result)
         addChildren();
         
     for (const auto& child : m_children) {
-        if (toAccessibilityListBoxOption(child.get())->isSelected())
+        if (downcast<AccessibilityListBoxOption>(*child).isSelected())
             result.append(child.get());
     }    
 }
@@ -138,10 +138,10 @@ AccessibilityObject* AccessibilityListBox::listBoxOptionAccessibilityObject(HTML
     if (!element || element->hasTagName(hrTag))
         return nullptr;
     
-    AccessibilityObject* listBoxObject = m_renderer->document().axObjectCache()->getOrCreate(ListBoxOptionRole);
-    toAccessibilityListBoxOption(listBoxObject)->setHTMLElement(element);
+    AccessibilityObject& listBoxObject = *m_renderer->document().axObjectCache()->getOrCreate(ListBoxOptionRole);
+    downcast<AccessibilityListBoxOption>(listBoxObject).setHTMLElement(element);
     
-    return listBoxObject;
+    return &listBoxObject;
 }
     
 AccessibilityObject* AccessibilityListBox::elementAccessibilityHitTest(const IntPoint& point) const
index 261359d..f2166f4 100644 (file)
@@ -56,9 +56,9 @@ private:
     AccessibilityObject* listBoxOptionAccessibilityObject(HTMLElement*) const;
     virtual AccessibilityObject* elementAccessibilityHitTest(const IntPoint&) const override;
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityListBox, isListBox())
     
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityListBox, isListBox())
+
 #endif // AccessibilityListBox_h
index 060a607..8e22b43 100644 (file)
@@ -74,9 +74,9 @@ private:
     AccessibilityObject* listBoxOptionAccessibilityObject(HTMLElement*) const;
     virtual bool computeAccessibilityIsIgnored() const override;
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityListBoxOption, isListBoxOption())
     
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityListBoxOption, isListBoxOption())
+
 #endif // AccessibilityListBoxOption_h
index 6e2ce54..42de846 100644 (file)
@@ -66,7 +66,7 @@ void AccessibilityMenuList::addChildren()
     if (!list)
         return;
 
-    toAccessibilityMockObject(list)->setParent(this);
+    downcast<AccessibilityMockObject>(*list).setParent(this);
     if (list->accessibilityIsIgnored()) {
         cache->remove(list->axObjectID());
         return;
@@ -111,7 +111,7 @@ void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
     const auto& childObjects = children();
     if (!childObjects.isEmpty()) {
         ASSERT(childObjects.size() == 1);
-        ASSERT(childObjects[0]->isMenuListPopup());
+        ASSERT(is<AccessibilityMenuListPopup>(*childObjects[0]));
 
         // We might be calling this method in situations where the renderers for list items
         // associated to the menu list have not been created (e.g. they might be rendered
@@ -121,10 +121,8 @@ void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
         // You can reproduce the issue in the GTK+ port by removing this check and running
         // accessibility/insert-selected-option-into-select-causes-crash.html (will crash).
         int popupChildrenSize = static_cast<int>(childObjects[0]->children().size());
-        if (childObjects[0]->isMenuListPopup() && optionIndex >= 0 && optionIndex < popupChildrenSize) {
-            if (AccessibilityMenuListPopup* popup = toAccessibilityMenuListPopup(childObjects[0].get()))
-                popup->didUpdateActiveOption(optionIndex);
-        }
+        if (is<AccessibilityMenuListPopup>(*childObjects[0]) && optionIndex >= 0 && optionIndex < popupChildrenSize)
+            downcast<AccessibilityMenuListPopup>(*childObjects[0]).didUpdateActiveOption(optionIndex);
     }
 
     cache->postNotification(this, &document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
index 6cf4fd2..5b1b2d4 100644 (file)
@@ -55,8 +55,8 @@ private:
     virtual void childrenChanged() override;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityMenuList, isMenuList())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityMenuList, isMenuList())
+
 #endif // AccessibilityMenuList_h
index 6bee58b..5e383f7 100644 (file)
@@ -62,8 +62,8 @@ private:
     RefPtr<HTMLElement> m_element;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityMenuListOption, isMenuListOption())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityMenuListOption, isMenuListOption())
+
 #endif // AccessibilityMenuListOption_h
index 469afca..fe1bd34 100644 (file)
@@ -73,13 +73,10 @@ AccessibilityMenuListOption* AccessibilityMenuListPopup::menuListOptionAccessibi
     if (!is<HTMLOptionElement>(element) || !element->inRenderedDocument())
         return nullptr;
 
-    AccessibilityObject* object = document()->axObjectCache()->getOrCreate(MenuListOptionRole);
-    ASSERT_WITH_SECURITY_IMPLICATION(object->isMenuListOption());
+    auto& option = downcast<AccessibilityMenuListOption>(*document()->axObjectCache()->getOrCreate(MenuListOptionRole));
+    option.setElement(element);
 
-    AccessibilityMenuListOption* option = toAccessibilityMenuListOption(object);
-    option->setElement(element);
-
-    return option;
+    return &option;
 }
 
 bool AccessibilityMenuListPopup::press()
index a4b7d60..c156ace 100644 (file)
@@ -62,8 +62,8 @@ private:
     AccessibilityMenuListOption* menuListOptionAccessibilityObject(HTMLElement*) const;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityMenuListPopup, isMenuListPopup())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityMenuListPopup, isMenuListPopup())
+
 #endif // AccessibilityMenuListPopup_h
index e04fd7f..4b7bc46 100644 (file)
@@ -51,10 +51,10 @@ private:
     virtual bool isMockObject() const override { return true; }
 
     virtual bool computeAccessibilityIsIgnored() const override;
-}; 
+};
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityMockObject, isMockObject())
-    
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityMockObject, isMockObject())
+
 #endif // AccessibilityMockObject_h
index a8a4e6b..07966cf 100644 (file)
@@ -1669,9 +1669,9 @@ String AccessibilityNodeObject::textUnderElement(AccessibilityTextUnderElementMo
         if (!shouldUseAccessiblityObjectInnerText(child, mode))
             continue;
 
-        if (child->isAccessibilityNodeObject()) {
+        if (is<AccessibilityNodeObject>(*child)) {
             Vector<AccessibilityText> textOrder;
-            toAccessibilityNodeObject(child)->alternativeText(textOrder);
+            downcast<AccessibilityNodeObject>(*child).alternativeText(textOrder);
             if (textOrder.size() > 0 && textOrder[0].text.length()) {
                 appendNameToStringBuilder(builder, textOrder[0].text);
                 continue;
index 7ab2816..eb614a1 100644 (file)
@@ -207,8 +207,8 @@ private:
     bool usesAltTagForTextComputation() const;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityNodeObject, isAccessibilityNodeObject())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityNodeObject, isAccessibilityNodeObject())
+
 #endif // AccessibilityNodeObject_h
index e7c7d2c..2baf44a 100644 (file)
@@ -502,7 +502,7 @@ static void appendChildrenToArray(AccessibilityObject* object, bool isForward, A
 {
     // A table's children includes elements whose own children are also the table's children (due to the way the Mac exposes tables).
     // The rows from the table should be queried, since those are direct descendants of the table, and they contain content.
-    const auto& searchChildren = object->isAccessibilityTable() ? toAccessibilityTable(object)->rows() : object->children();
+    const auto& searchChildren = object->isAccessibilityTable() ? downcast<AccessibilityTable>(*object).rows() : object->children();
 
     size_t childrenSize = searchChildren.size();
 
@@ -1536,8 +1536,8 @@ void AccessibilityObject::updateBackingStore()
 ScrollView* AccessibilityObject::scrollViewAncestor() const
 {
     for (const AccessibilityObject* scrollParent = this; scrollParent; scrollParent = scrollParent->parentObject()) {
-        if (scrollParent->isAccessibilityScrollView())
-            return toAccessibilityScrollView(scrollParent)->scrollView();
+        if (is<AccessibilityScrollView>(*scrollParent))
+            return downcast<AccessibilityScrollView>(*scrollParent).scrollView();
     }
     
     return nullptr;
index b111901..0234bb3 100644 (file)
@@ -1005,9 +1005,11 @@ inline int AccessibilityObject::lineForPosition(const VisiblePosition&) const {
 inline void AccessibilityObject::updateBackingStore() { }
 #endif
 
-#define ACCESSIBILITY_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, AccessibilityObject, object, object->predicate, object.predicate)
-
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::AccessibilityObject& object) { return object.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // AccessibilityObject_h
index ca22ecc..3e35d5e 100644 (file)
@@ -1738,13 +1738,13 @@ void AccessibilityRenderObject::getDocumentLinks(AccessibilityChildrenVector& re
         } else {
             Node* parent = curr->parentNode();
             if (is<HTMLAreaElement>(*curr) && is<HTMLMapElement>(parent)) {
-                AccessibilityImageMapLink* areaObject = toAccessibilityImageMapLink(axObjectCache()->getOrCreate(ImageMapLinkRole));
+                auto& areaObject = downcast<AccessibilityImageMapLink>(*axObjectCache()->getOrCreate(ImageMapLinkRole));
                 HTMLMapElement& map = downcast<HTMLMapElement>(*parent);
-                areaObject->setHTMLAreaElement(downcast<HTMLAreaElement>(curr));
-                areaObject->setHTMLMapElement(&map);
-                areaObject->setParent(accessibilityParentForImageMap(&map));
+                areaObject.setHTMLAreaElement(downcast<HTMLAreaElement>(curr));
+                areaObject.setHTMLMapElement(&map);
+                areaObject.setParent(accessibilityParentForImageMap(&map));
 
-                result.append(areaObject);
+                result.append(&areaObject);
             }
         }
     }
@@ -2328,7 +2328,7 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
     if (!renderer()->frame().selection().isFocusedAndActive() || renderer()->document().focusedElement() != element)
         return;
 
-    if (toAccessibilityRenderObject(activeDescendant()) && shouldNotifyActiveDescendant())
+    if (activeDescendant() && shouldNotifyActiveDescendant())
         renderer()->document().axObjectCache()->postNotification(m_renderer, AXObjectCache::AXActiveDescendantChanged);
 }
 
@@ -2685,10 +2685,10 @@ bool AccessibilityRenderObject::inheritsPresentationalRole() const
         return false;
     
     for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) { 
-        if (!parent->isAccessibilityRenderObject())
+        if (!is<AccessibilityRenderObject>(*parent))
             continue;
         
-        Node* node = toAccessibilityRenderObject(parent)->node();
+        Node* node = downcast<AccessibilityRenderObject>(*parent).node();
         if (!is<Element>(node))
             continue;
         
@@ -2807,14 +2807,14 @@ void AccessibilityRenderObject::addImageMapChildren()
         // add an <area> element for this child if it has a link
         if (!area.isLink())
             continue;
-        AccessibilityImageMapLink* areaObject = toAccessibilityImageMapLink(axObjectCache()->getOrCreate(ImageMapLinkRole));
-        areaObject->setHTMLAreaElement(&area);
-        areaObject->setHTMLMapElement(map);
-        areaObject->setParent(this);
-        if (!areaObject->accessibilityIsIgnored())
-            m_children.append(areaObject);
+        auto& areaObject = downcast<AccessibilityImageMapLink>(*axObjectCache()->getOrCreate(ImageMapLinkRole));
+        areaObject.setHTMLAreaElement(&area);
+        areaObject.setHTMLMapElement(map);
+        areaObject.setParent(this);
+        if (!areaObject.accessibilityIsIgnored())
+            m_children.append(&areaObject);
         else
-            axObjectCache()->remove(areaObject->axObjectID());
+            axObjectCache()->remove(areaObject.axObjectID());
     }
 }
 
@@ -2837,10 +2837,11 @@ void AccessibilityRenderObject::addTextFieldChildren()
     if (!spinButtonElement || !spinButtonElement->isSpinButtonElement())
         return;
 
-    AccessibilitySpinButton* axSpinButton = toAccessibilitySpinButton(axObjectCache()->getOrCreate(SpinButtonRole));
-    axSpinButton->setSpinButtonElement(static_cast<SpinButtonElement*>(spinButtonElement));
-    axSpinButton->setParent(this);
-    m_children.append(axSpinButton);
+    auto& axSpinButton = downcast<AccessibilitySpinButton>(*axObjectCache()->getOrCreate(SpinButtonRole));
+    // FIXME: We should use is<>() / downcast<>() for SpinButtonElement.
+    axSpinButton.setSpinButtonElement(static_cast<SpinButtonElement*>(spinButtonElement));
+    axSpinButton.setParent(this);
+    m_children.append(&axSpinButton);
 }
     
 bool AccessibilityRenderObject::isSVGImage() const
@@ -2890,11 +2891,11 @@ AccessibilitySVGRoot* AccessibilityRenderObject::remoteSVGRootElement() const
 
     // In order to connect the AX hierarchy from the SVG root element from the loaded resource
     // the parent must be set, because there's no other way to get back to who created the image.
-    ASSERT(rootSVGObject && rootSVGObject->isAccessibilitySVGRoot());
-    if (!rootSVGObject->isAccessibilitySVGRoot())
+    ASSERT(rootSVGObject);
+    if (!is<AccessibilitySVGRoot>(*rootSVGObject))
         return nullptr;
     
-    return toAccessibilitySVGRoot(rootSVGObject);
+    return downcast<AccessibilitySVGRoot>(rootSVGObject);
 }
     
 void AccessibilityRenderObject::addRemoteSVGChildren()
@@ -3134,8 +3135,8 @@ void AccessibilityRenderObject::ariaSelectedRows(AccessibilityChildrenVector& re
         AccessibilityChildrenVector allRows;
         ariaTreeRows(allRows);
         rowsIteration(allRows);
-    } else if (isAccessibilityTable() && toAccessibilityTable(this)->supportsSelectedRows())
-        rowsIteration(toAccessibilityTable(this)->rows());
+    } else if (isAccessibilityTable() && downcast<AccessibilityTable>(*this).supportsSelectedRows())
+        rowsIteration(downcast<AccessibilityTable>(*this).rows());
 }
     
 void AccessibilityRenderObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& result)
index fa5d385..ed7be10 100644 (file)
@@ -338,8 +338,8 @@ private:
 #endif
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityRenderObject, isAccessibilityRenderObject())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityRenderObject, isAccessibilityRenderObject())
+
 #endif // AccessibilityRenderObject_h
index e8b8722..77eeb1b 100644 (file)
@@ -49,9 +49,9 @@ private:
     virtual AccessibilityObject* parentObject() const override;
     virtual bool isAccessibilitySVGRoot() const override { return true; }
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilitySVGRoot, isAccessibilitySVGRoot())
     
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilitySVGRoot, isAccessibilitySVGRoot())
+
 #endif // AccessibilitySVGRoot_h
index 8576dd6..c900098 100644 (file)
@@ -151,10 +151,10 @@ AccessibilityScrollbar* AccessibilityScrollView::addChildScrollbar(Scrollbar* sc
     if (!cache)
         return nullptr;
 
-    AccessibilityScrollbar* scrollBarObject = toAccessibilityScrollbar(cache->getOrCreate(scrollbar));
-    scrollBarObject->setParent(this);
-    m_children.append(scrollBarObject);
-    return scrollBarObject;
+    auto& scrollBarObject = downcast<AccessibilityScrollbar>(*cache->getOrCreate(scrollbar));
+    scrollBarObject.setParent(this);
+    m_children.append(&scrollBarObject);
+    return &scrollBarObject;
 }
         
 void AccessibilityScrollView::clearChildren()
index 56be1a0..89fdba9 100644 (file)
@@ -83,9 +83,9 @@ private:
     RefPtr<AccessibilityObject> m_verticalScrollbar;
     bool m_childrenDirty;
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityScrollView, isAccessibilityScrollView())
     
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityScrollView, isAccessibilityScrollView())
+
 #endif // AccessibilityScrollView_h
index a72796e..209fffd 100644 (file)
@@ -62,8 +62,8 @@ private:
     RefPtr<Scrollbar> m_scrollbar;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityScrollbar, isAccessibilityScrollbar())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityScrollbar, isAccessibilityScrollbar())
+
 #endif // AccessibilityScrollbar_h
index b5e346d..91aad3f 100644 (file)
@@ -84,15 +84,15 @@ void AccessibilitySlider::addChildren()
 
     AXObjectCache* cache = m_renderer->document().axObjectCache();
 
-    AccessibilitySliderThumb* thumb = toAccessibilitySliderThumb(cache->getOrCreate(SliderThumbRole));
-    thumb->setParent(this);
+    auto& thumb = downcast<AccessibilitySliderThumb>(*cache->getOrCreate(SliderThumbRole));
+    thumb.setParent(this);
 
     // Before actually adding the value indicator to the hierarchy,
     // allow the platform to make a final decision about it.
-    if (thumb->accessibilityIsIgnored())
-        cache->remove(thumb->axObjectID());
+    if (thumb.accessibilityIsIgnored())
+        cache->remove(thumb.axObjectID());
     else
-        m_children.append(thumb);
+        m_children.append(&thumb);
 }
 
 const AtomicString& AccessibilitySlider::getAttribute(const QualifiedName& attribute) const
index 5e9e7fd..2678e72 100644 (file)
@@ -84,8 +84,8 @@ private:
     virtual bool computeAccessibilityIsIgnored() const override;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilitySliderThumb, isSliderThumb())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilitySliderThumb, isSliderThumb())
+
 #endif // AccessibilitySlider_h
index 932acb4..3ce9419 100644 (file)
@@ -82,15 +82,15 @@ void AccessibilitySpinButton::addChildren()
 {
     m_haveChildren = true;
     
-    AccessibilitySpinButtonPart* incrementor = toAccessibilitySpinButtonPart(axObjectCache()->getOrCreate(SpinButtonPartRole));
-    incrementor->setIsIncrementor(true);
-    incrementor->setParent(this);
-    m_children.append(incrementor);
+    auto& incrementor = downcast<AccessibilitySpinButtonPart>(*axObjectCache()->getOrCreate(SpinButtonPartRole));
+    incrementor.setIsIncrementor(true);
+    incrementor.setParent(this);
+    m_children.append(&incrementor);
 
-    AccessibilitySpinButtonPart* decrementor = toAccessibilitySpinButtonPart(axObjectCache()->getOrCreate(SpinButtonPartRole));
-    decrementor->setIsIncrementor(false);
-    decrementor->setParent(this);
-    m_children.append(decrementor);
+    auto& decrementor = downcast<AccessibilitySpinButtonPart>(*axObjectCache()->getOrCreate(SpinButtonPartRole));
+    decrementor.setIsIncrementor(false);
+    decrementor.setParent(this);
+    m_children.append(&decrementor);
 }
     
 void AccessibilitySpinButton::step(int amount)
@@ -132,14 +132,14 @@ LayoutRect AccessibilitySpinButtonPart::elementRect() const
 
 bool AccessibilitySpinButtonPart::press()
 {
-    if (!m_parent || !m_parent->isSpinButton())
+    if (!is<AccessibilitySpinButton>(m_parent))
         return false;
     
-    AccessibilitySpinButton* spinButton = toAccessibilitySpinButton(parentObject());
+    auto& spinButton = downcast<AccessibilitySpinButton>(*m_parent);
     if (m_isIncrementor)
-        spinButton->step(1);
+        spinButton.step(1);
     else
-        spinButton->step(-1);
+        spinButton.step(-1);
     
     return true;
 }
index be21ffe..8731942 100644 (file)
@@ -73,10 +73,10 @@ private:
     virtual bool isSpinButtonPart() const override { return true; }
     virtual LayoutRect elementRect() const override;
 };
-
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilitySpinButton, isNativeSpinButton())
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilitySpinButtonPart, isSpinButtonPart())
     
-} // namespace WebCore 
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilitySpinButton, isNativeSpinButton())
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilitySpinButtonPart, isSpinButtonPart())
 
 #endif // AccessibilitySpinButton_h
index 11ffd14..0b7be3a 100644 (file)
@@ -379,12 +379,12 @@ void AccessibilityTable::addChildren()
     // make the columns based on the number of columns in the first body
     unsigned length = maxColumnCount;
     for (unsigned i = 0; i < length; ++i) {
-        AccessibilityTableColumn* column = toAccessibilityTableColumn(axCache->getOrCreate(ColumnRole));
-        column->setColumnIndex((int)i);
-        column->setParent(this);
-        m_columns.append(column);
-        if (!column->accessibilityIsIgnored())
-            m_children.append(column);
+        auto& column = downcast<AccessibilityTableColumn>(*axCache->getOrCreate(ColumnRole));
+        column.setColumnIndex((int)i);
+        column.setParent(this);
+        m_columns.append(&column);
+        if (!column.accessibilityIsIgnored())
+            m_children.append(&column);
     }
     
     AccessibilityObject* headerContainerObject = headerContainer();
@@ -407,25 +407,25 @@ void AccessibilityTable::addChildrenFromSection(RenderTableSection* tableSection
         if (!renderRow)
             continue;
         
-        AccessibilityObject* rowObject = axCache->getOrCreate(renderRow);
-        if (!rowObject->isTableRow())
+        AccessibilityObject& rowObject = *axCache->getOrCreate(renderRow);
+        if (!is<AccessibilityTableRow>(rowObject))
             continue;
         
-        AccessibilityTableRow* row = toAccessibilityTableRow(rowObject);
+        auto& row = downcast<AccessibilityTableRow>(rowObject);
         // We need to check every cell for a new row, because cell spans
         // can cause us to miss rows if we just check the first column.
-        if (appendedRows.contains(row))
+        if (appendedRows.contains(&row))
             continue;
         
-        row->setRowIndex(static_cast<int>(m_rows.size()));
-        m_rows.append(row);
-        if (!row->accessibilityIsIgnored())
-            m_children.append(row);
+        row.setRowIndex(static_cast<int>(m_rows.size()));
+        m_rows.append(&row);
+        if (!row.accessibilityIsIgnored())
+            m_children.append(&row);
 #if PLATFORM(GTK) || PLATFORM(EFL)
         else
-            m_children.appendVector(row->children());
+            m_children.appendVector(row.children());
 #endif
-        appendedRows.add(row);
+        appendedRows.add(&row);
     }
     
     maxColumnCount = std::max(tableSection->numColumns(), maxColumnCount);
@@ -436,10 +436,10 @@ AccessibilityObject* AccessibilityTable::headerContainer()
     if (m_headerContainer)
         return m_headerContainer.get();
     
-    AccessibilityMockObject* tableHeader = toAccessibilityMockObject(axObjectCache()->getOrCreate(TableHeaderContainerRole));
-    tableHeader->setParent(this);
+    auto& tableHeader = downcast<AccessibilityMockObject>(*axObjectCache()->getOrCreate(TableHeaderContainerRole));
+    tableHeader.setParent(this);
 
-    m_headerContainer = tableHeader;
+    m_headerContainer = &tableHeader;
     return m_headerContainer.get();
 }
 
@@ -465,7 +465,7 @@ void AccessibilityTable::columnHeaders(AccessibilityChildrenVector& headers)
     updateChildrenIfNecessary();
     
     for (const auto& column : m_columns) {
-        if (AccessibilityObject* header = toAccessibilityTableColumn(column.get())->headerObject())
+        if (AccessibilityObject* header = downcast<AccessibilityTableColumn>(*column).headerObject())
             headers.append(header);
     }
 }
@@ -478,7 +478,7 @@ void AccessibilityTable::rowHeaders(AccessibilityChildrenVector& headers)
     updateChildrenIfNecessary();
     
     for (const auto& row : m_rows) {
-        if (AccessibilityObject* header = toAccessibilityTableRow(row.get())->headerObject())
+        if (AccessibilityObject* header = downcast<AccessibilityTableRow>(*row).headerObject())
             headers.append(header);
     }
 }
@@ -547,19 +547,19 @@ AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column,
         for (unsigned colIndexCounter = std::min(static_cast<unsigned>(children.size()), column + 1); colIndexCounter > 0; --colIndexCounter) {
             unsigned colIndex = colIndexCounter - 1;
             AccessibilityObject* child = children[colIndex].get();
-            ASSERT(child->isTableCell());
-            if (!child->isTableCell())
+            ASSERT(is<AccessibilityTableCell>(*child));
+            if (!is<AccessibilityTableCell>(*child))
                 continue;
             
             std::pair<unsigned, unsigned> columnRange;
             std::pair<unsigned, unsigned> rowRange;
-            AccessibilityTableCell* tableCellChild = toAccessibilityTableCell(child);
-            tableCellChild->columnIndexRange(columnRange);
-            tableCellChild->rowIndexRange(rowRange);
+            auto& tableCellChild = downcast<AccessibilityTableCell>(*child);
+            tableCellChild.columnIndexRange(columnRange);
+            tableCellChild.rowIndexRange(rowRange);
             
             if ((column >= columnRange.first && column < (columnRange.first + columnRange.second))
                 && (row >= rowRange.first && row < (rowRange.first + rowRange.second)))
-                return tableCellChild;
+                return &tableCellChild;
         }
     }
     
index 746d1db..b026f52 100644 (file)
@@ -75,6 +75,9 @@ public:
     // an object that contains, as children, all the objects that act as headers
     AccessibilityObject* headerContainer();
 
+    // isAccessibilityTable is whether it is exposed as an AccessibilityTable to the platform.
+    virtual bool isAccessibilityTable() const override final;
+
 protected:
     AccessibilityChildrenVector m_rows;
     AccessibilityChildrenVector m_columns;
@@ -86,8 +89,6 @@ protected:
 
     // isTable is whether it's an AccessibilityTable object.
     virtual bool isTable() const override { return true; }
-    // isAccessibilityTable is whether it is exposed as an AccessibilityTable to the platform.
-    virtual bool isAccessibilityTable() const override;
     // isDataTable is whether it is exposed as an AccessibilityTable because the heuristic
     // think this "looks" like a data-based table (instead of a table used for layout).
     virtual bool isDataTable() const override;
@@ -101,8 +102,8 @@ private:
     void addChildrenFromSection(RenderTableSection*, unsigned& maxColumnCount);
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTable, isTable())
-
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTable, isTable())
+
 #endif // AccessibilityTable_h
index c6cc866..6837be0 100644 (file)
@@ -89,9 +89,9 @@ AccessibilityTable* AccessibilityTableCell::parentTable() const
     // always be the case when AT clients access a table.
     // https://bugs.webkit.org/show_bug.cgi?id=42652
     AccessibilityObject* parentTable = axObjectCache()->get(downcast<RenderTableCell>(*m_renderer).table());
-    if (!parentTable || !parentTable->isTable())
+    if (!is<AccessibilityTable>(parentTable))
         return nullptr;
-    return toAccessibilityTable(parentTable);
+    return downcast<AccessibilityTable>(parentTable);
 }
     
 bool AccessibilityTableCell::isTableCell() const
index c7c73c3..3318682 100644 (file)
@@ -73,8 +73,8 @@ private:
     bool isTableCellInSameColGroup(AccessibilityTableCell*);
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTableCell, isTableCell())
-
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTableCell, isTableCell())
+
 #endif // AccessibilityTableCell_h
index 8e710e1..b02f9ef 100644 (file)
@@ -79,8 +79,8 @@ AccessibilityObject* AccessibilityTableColumn::headerObject()
     if (!m_parent->isAccessibilityTable())
         return nullptr;
     
-    AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
-    if (parentTable->isAriaTable()) {
+    auto& parentTable = downcast<AccessibilityTable>(*m_parent);
+    if (parentTable.isAriaTable()) {
         for (const auto& cell : children()) {
             if (cell->ariaRoleAttribute() == ColumnHeaderRole)
                 return cell.get();
@@ -173,11 +173,11 @@ void AccessibilityTableColumn::addChildren()
     if (!m_parent || !m_parent->isAccessibilityTable())
         return;
     
-    AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
-    int numRows = parentTable->rowCount();
+    AccessibilityTable& parentTable = downcast<AccessibilityTable>(*m_parent);
+    int numRows = parentTable.rowCount();
     
-    for (int i = 0; i < numRows; i++) {
-        AccessibilityTableCell* cell = parentTable->cellForColumnAndRow(m_columnIndex, i);
+    for (int i = 0; i < numRows; ++i) {
+        AccessibilityTableCell* cell = parentTable.cellForColumnAndRow(m_columnIndex, i);
         if (!cell)
             continue;
         
index e3cc516..af7ce3c 100644 (file)
@@ -66,8 +66,8 @@ private:
     virtual bool computeAccessibilityIsIgnored() const override;
 };
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTableColumn, isTableColumn())
-
 } // namespace WebCore 
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTableColumn, isTableColumn())
+
 #endif // AccessibilityTableColumn_h
index e4dd932..083bd98 100644 (file)
@@ -73,7 +73,7 @@ void AccessibilityTableHeaderContainer::addChildren()
     if (!m_parent || !m_parent->isAccessibilityTable())
         return;
     
-    toAccessibilityTable(m_parent)->columnHeaders(m_children);
+    downcast<AccessibilityTable>(*m_parent).columnHeaders(m_children);
     
     for (const auto& child : m_children)
         m_headerRect.unite(child->elementRect());
index 634d144..b1241d1 100644 (file)
@@ -106,8 +106,8 @@ AccessibilityTable* AccessibilityTableRow::parentTable() const
     for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
         // If this is a table object, but not an accessibility table, we should stop because we don't want to
         // choose another ancestor table as this row's table.
-        if (parent->isTable())
-            return parent->isAccessibilityTable() ? toAccessibilityTable(parent) : 0;
+        if (is<AccessibilityTable>(*parent))
+            return downcast<AccessibilityTable>(*parent).isAccessibilityTable() ? downcast<AccessibilityTable>(parent) : nullptr;
     }
     
     return nullptr;
@@ -124,10 +124,10 @@ AccessibilityObject* AccessibilityTableRow::headerObject()
     
     // check the first element in the row to see if it is a TH element
     AccessibilityObject* cell = rowChildren[0].get();
-    if (!cell->isTableCell())
+    if (!is<AccessibilityTableCell>(*cell))
         return nullptr;
     
-    RenderObject* cellRenderer = toAccessibilityTableCell(cell)->renderer();
+    RenderObject* cellRenderer = downcast<AccessibilityTableCell>(*cell).renderer();
     if (!cellRenderer)
         return nullptr;
     
index 67d5e2d..f1fe032 100644 (file)
@@ -64,10 +64,10 @@ private:
     
     virtual AccessibilityObject* observableObject() const override;
     virtual bool computeAccessibilityIsIgnored() const override;
-}; 
+};
 
-ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTableRow, isTableRow())
+} // namespace WebCore
 
-} // namespace WebCore 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityTableRow, isTableRow())
 
 #endif // AccessibilityTableRow_h
index 9e87f4f..0f79b00 100644 (file)
@@ -150,12 +150,12 @@ static gboolean webkitAccessibleSelectionClearSelection(AtkSelection* selection)
         return FALSE;
 
     AccessibilityObject::AccessibilityChildrenVector selectedItems;
-    if (coreSelection->isListBox() || coreSelection->isMenuList()) {
+    if (is<AccessibilityListBox>(*coreSelection)) {
         // Set the list of selected items to an empty list; then verify that it worked.
-        AccessibilityListBox* listBox = toAccessibilityListBox(coreSelection);
-        listBox->setSelectedChildren(selectedItems);
-        listBox->selectedChildren(selectedItems);
-        return !selectedItems.size();
+        auto& listBox = downcast<AccessibilityListBox>(*coreSelection);
+        listBox.setSelectedChildren(selectedItems);
+        listBox.selectedChildren(selectedItems);
+        return selectedItems.isEmpty();
     }
     return FALSE;
 }
@@ -246,12 +246,12 @@ static gboolean webkitAccessibleSelectionSelectAllSelection(AtkSelection* select
     if (!coreSelection || !coreSelection->isMultiSelectable())
         return FALSE;
 
-    if (coreSelection->isListBox()) {
+    if (is<AccessibilityListBox>(*coreSelection)) {
         const AccessibilityObject::AccessibilityChildrenVector& children = coreSelection->children();
-        AccessibilityListBox* listBox = toAccessibilityListBox(coreSelection);
-        listBox->setSelectedChildren(children);
+        AccessibilityListBox& listBox = downcast<AccessibilityListBox>(*coreSelection);
+        listBox.setSelectedChildren(children);
         AccessibilityObject::AccessibilityChildrenVector selectedItems;
-        listBox->selectedChildren(selectedItems);
+        listBox.selectedChildren(selectedItems);
         return selectedItems.size() == children.size();
     }
 
index 025ef08..d089a54 100644 (file)
@@ -50,7 +50,7 @@ using namespace WebCore;
 static AccessibilityObject* core(AtkTable* table)
 {
     if (!WEBKIT_IS_ACCESSIBLE(table))
-        return 0;
+        return nullptr;
 
     return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(table));
 }
@@ -58,9 +58,9 @@ static AccessibilityObject* core(AtkTable* table)
 static AccessibilityTableCell* cell(AtkTable* table, guint row, guint column)
 {
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject())
-        return toAccessibilityTable(accTable)->cellForColumnAndRow(column, row);
-    return 0;
+    if (is<AccessibilityTable>(*accTable))
+        return downcast<AccessibilityTable>(*accTable).cellForColumnAndRow(column, row);
+    return nullptr;
 }
 
 static gint cellIndex(AccessibilityTableCell* axCell, AccessibilityTable* axTable)
@@ -79,15 +79,13 @@ static gint cellIndex(AccessibilityTableCell* axCell, AccessibilityTable* axTabl
 static AccessibilityTableCell* cellAtIndex(AtkTable* table, gint index)
 {
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject()) {
+    if (is<AccessibilityTable>(*accTable)) {
         AccessibilityObject::AccessibilityChildrenVector allCells;
-        toAccessibilityTable(accTable)->cells(allCells);
-        if (0 <= index && static_cast<unsigned>(index) < allCells.size()) {
-            AccessibilityObject* accCell = allCells.at(index).get();
-            return toAccessibilityTableCell(accCell);
-        }
+        downcast<AccessibilityTable>(*accTable).cells(allCells);
+        if (0 <= index && static_cast<unsigned>(index) < allCells.size())
+            return downcast<AccessibilityTableCell>(allCells[index].get());
     }
-    return 0;
+    return nullptr;
 }
 
 static AtkObject* webkitAccessibleTableRefAt(AtkTable* table, gint row, gint column)
@@ -114,7 +112,7 @@ static gint webkitAccessibleTableGetIndexAt(AtkTable* table, gint row, gint colu
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(table), -1);
 
     AccessibilityTableCell* axCell = cell(table, row, column);
-    AccessibilityTable* axTable = toAccessibilityTable(core(table));
+    AccessibilityTable* axTable = downcast<AccessibilityTable>(core(table));
     return cellIndex(axCell, axTable);
 }
 
@@ -152,8 +150,8 @@ static gint webkitAccessibleTableGetNColumns(AtkTable* table)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(table), 0);
 
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject())
-        return toAccessibilityTable(accTable)->columnCount();
+    if (is<AccessibilityTable>(*accTable))
+        return downcast<AccessibilityTable>(*accTable).columnCount();
     return 0;
 }
 
@@ -163,8 +161,8 @@ static gint webkitAccessibleTableGetNRows(AtkTable* table)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(table), 0);
 
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject())
-        return toAccessibilityTable(accTable)->rowCount();
+    if (is<AccessibilityTable>(*accTable))
+        return downcast<AccessibilityTable>(*accTable).rowCount();
     return 0;
 }
 
@@ -202,18 +200,18 @@ static AtkObject* webkitAccessibleTableGetColumnHeader(AtkTable* table, gint col
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(table), 0);
 
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject()) {
+    if (is<AccessibilityTable>(*accTable)) {
         AccessibilityObject::AccessibilityChildrenVector columnHeaders;
-        toAccessibilityTable(accTable)->columnHeaders(columnHeaders);
+        downcast<AccessibilityTable>(*accTable).columnHeaders(columnHeaders);
 
         for (const auto& columnHeader : columnHeaders) {
             std::pair<unsigned, unsigned> columnRange;
-            toAccessibilityTableCell(columnHeader.get())->columnIndexRange(columnRange);
+            downcast<AccessibilityTableCell>(*columnHeader).columnIndexRange(columnRange);
             if (columnRange.first <= static_cast<unsigned>(column) && static_cast<unsigned>(column) < columnRange.first + columnRange.second)
                 return columnHeader->wrapper();
         }
     }
-    return 0;
+    return nullptr;
 }
 
 static AtkObject* webkitAccessibleTableGetRowHeader(AtkTable* table, gint row)
@@ -222,18 +220,18 @@ static AtkObject* webkitAccessibleTableGetRowHeader(AtkTable* table, gint row)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(table), 0);
 
     AccessibilityObject* accTable = core(table);
-    if (accTable->isAccessibilityRenderObject()) {
+    if (is<AccessibilityTable>(*accTable)) {
         AccessibilityObject::AccessibilityChildrenVector rowHeaders;
-        toAccessibilityTable(accTable)->rowHeaders(rowHeaders);
+        downcast<AccessibilityTable>(*accTable).rowHeaders(rowHeaders);
 
         for (const auto& rowHeader : rowHeaders) {
             std::pair<unsigned, unsigned> rowRange;
-            toAccessibilityTableCell(rowHeader.get())->rowIndexRange(rowRange);
+            downcast<AccessibilityTableCell>(*rowHeader).rowIndexRange(rowRange);
             if (rowRange.first <= static_cast<unsigned>(row) && static_cast<unsigned>(row) < rowRange.first + rowRange.second)
                 return rowHeader->wrapper();
         }
     }
-    return 0;
+    return nullptr;
 }
 
 static AtkObject* webkitAccessibleTableGetCaption(AtkTable* table)
index 4b8f0e8..3d1e962 100644 (file)
@@ -54,11 +54,11 @@ GPtrArray* webkitAccessibleTableCellGetColumnHeaderCells(AtkTableCell* cell)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(cell), nullptr);
 
     AccessibilityObject* axObject = core(cell);
-    if (!axObject || !axObject->isTableCell())
+    if (!is<AccessibilityTableCell>(axObject))
         return nullptr;
 
     AccessibilityObject::AccessibilityChildrenVector columnHeaders;
-    toAccessibilityTableCell(axObject)->columnHeaders(columnHeaders);
+    downcast<AccessibilityTableCell>(*axObject).columnHeaders(columnHeaders);
 
     return convertToGPtrArray(columnHeaders);
 }
@@ -69,11 +69,11 @@ GPtrArray* webkitAccessibleTableCellGetRowHeaderCells(AtkTableCell* cell)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(cell), nullptr);
 
     AccessibilityObject* axObject = core(cell);
-    if (!axObject || !axObject->isTableCell())
+    if (!is<AccessibilityTableCell>(axObject))
         return nullptr;
 
     AccessibilityObject::AccessibilityChildrenVector rowHeaders;
-    toAccessibilityTableCell(axObject)->rowHeaders(rowHeaders);
+    downcast<AccessibilityTableCell>(*axObject).rowHeaders(rowHeaders);
 
     return convertToGPtrArray(rowHeaders);
 }
@@ -84,11 +84,11 @@ gint webkitAccessibleTableCellGetColumnSpan(AtkTableCell* cell)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(cell), 0);
 
     AccessibilityObject* axObject = core(cell);
-    if (!axObject || !axObject->isTableCell())
+    if (!is<AccessibilityTableCell>(axObject))
         return 0;
 
     std::pair<unsigned, unsigned> columnRange;
-    toAccessibilityTableCell(axObject)->columnIndexRange(columnRange);
+    downcast<AccessibilityTableCell>(*axObject).columnIndexRange(columnRange);
 
     return columnRange.second;
 }
@@ -99,11 +99,11 @@ gint webkitAccessibleTableCellGetRowSpan(AtkTableCell* cell)
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(cell), 0);
 
     AccessibilityObject* axObject = core(cell);
-    if (!axObject || !axObject->isTableCell())
+    if (!is<AccessibilityTableCell>(axObject))
         return 0;
 
     std::pair<unsigned, unsigned> rowRange;
-    toAccessibilityTableCell(axObject)->rowIndexRange(rowRange);
+    downcast<AccessibilityTableCell>(*axObject).rowIndexRange(rowRange);
 
     return rowRange.second;
 }
@@ -114,16 +114,16 @@ gboolean webkitAccessibleTableCellGetPosition(AtkTableCell* cell, gint* row, gin
     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(cell), false);
 
     AccessibilityObject* axObject = core(cell);
-    if (!axObject || !axObject->isTableCell())
+    if (!is<AccessibilityTableCell>(axObject))
         return false;
 
     std::pair<unsigned, unsigned> columnRowRange;
     if (row) {
-        toAccessibilityTableCell(axObject)->rowIndexRange(columnRowRange);
+        downcast<AccessibilityTableCell>(*axObject).rowIndexRange(columnRowRange);
         *row = columnRowRange.first;
     }
     if (column) {
-        toAccessibilityTableCell(axObject)->columnIndexRange(columnRowRange);
+        downcast<AccessibilityTableCell>(*axObject).columnIndexRange(columnRowRange);
         *column = columnRowRange.first;
     }
 
index 1c9b939..3bb8769 100644 (file)
@@ -62,9 +62,9 @@ int AccessibilityObject::accessibilityPasswordFieldLength()
 {
     if (!isPasswordField())
         return 0;
-    RenderObject* renderObject = toAccessibilityRenderObject(this)->renderer();
+    RenderObject* renderObject = downcast<AccessibilityRenderObject>(*this).renderer();
     
-    if (!renderObject || !renderObject->node() || !renderObject->node()->isHTMLElement())
+    if (!renderObject || !is<HTMLInputElement>(renderObject->node()))
         return false;
     
     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*renderObject->node());
index f45b096..6a41b97 100644 (file)
@@ -1114,8 +1114,8 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
         ScrollView* scrollView = nullptr;
         AccessibilityObject* parent = nullptr;
         for (parent = m_object->parentObject(); parent; parent = parent->parentObject()) {
-            if (parent->isAccessibilityScrollView()) {
-                scrollView = toAccessibilityScrollView(parent)->scrollView();
+            if (is<AccessibilityScrollView>(*parent)) {
+                scrollView = downcast<AccessibilityScrollView>(*parent).scrollView();
                 break;
             }
         }
@@ -1168,8 +1168,8 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
         ScrollView* scrollView = nullptr;
         AccessibilityObject* parent = nullptr;
         for (parent = m_object->parentObject(); parent; parent = parent->parentObject()) {
-            if (parent->isAccessibilityScrollView()) {
-                scrollView = toAccessibilityScrollView(parent)->scrollView();
+            if (is<AccessibilityScrollView>(*parent)) {
+                scrollView = downcast<AccessibilityScrollView>(*parent).scrollView();
                 break;
             }
         }
index 48b9aee..3f9dbd6 100644 (file)
@@ -994,10 +994,10 @@ static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, N
     if (!AXAttributedStringRangeIsValid(attrString, range))
         return;
     
-    if (object && object->isAccessibilityRenderObject()) {
+    if (is<AccessibilityRenderObject>(object)) {
         // make a serializable AX object
         
-        RenderObject* renderer = toAccessibilityRenderObject(object)->renderer();
+        RenderObject* renderer = downcast<AccessibilityRenderObject>(*object).renderer();
         if (!renderer)
             return;
         
@@ -1199,7 +1199,7 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, VisiblePosit
     if (m_object->supportsARIADropping())
         [additional addObject:NSAccessibilityDropEffectsAttribute];
     
-    if (m_object->isAccessibilityTable() && toAccessibilityTable(m_object)->supportsSelectedRows())
+    if (m_object->isAccessibilityTable() && downcast<AccessibilityTable>(*m_object).supportsSelectedRows())
         [additional addObject:NSAccessibilitySelectedRowsAttribute];
     
     if (m_object->supportsARIALiveRegion()) {
@@ -1752,8 +1752,8 @@ static NSMutableArray *convertStringsToNSArray(const Vector<String>& vector)
         ScrollView* scrollView = nullptr;
         AccessibilityObject* parent = nullptr;
         for (parent = m_object->parentObject(); parent; parent = parent->parentObject()) {
-            if (parent->isAccessibilityScrollView()) {
-                scrollView = toAccessibilityScrollView(parent)->scrollView();
+            if (is<AccessibilityScrollView>(*parent)) {
+                scrollView = downcast<AccessibilityScrollView>(*parent).scrollView();
                 break;
             }
         }
@@ -1992,8 +1992,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->roleValue() == HorizontalRuleRole)
         return NSAccessibilityContentSeparatorSubrole;
     
-    if (m_object->isSpinButtonPart()) {
-        if (toAccessibilitySpinButtonPart(m_object)->isIncrementor())
+    if (is<AccessibilitySpinButtonPart>(*m_object)) {
+        if (downcast<AccessibilitySpinButtonPart>(*m_object).isIncrementor())
             return NSAccessibilityIncrementArrowSubrole;
         
         return NSAccessibilityDecrementArrowSubrole;
@@ -2005,11 +2005,11 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->isTreeItem())
         return NSAccessibilityOutlineRowSubrole;
     
-    if (m_object->isList()) {
-        AccessibilityList* listObject = toAccessibilityList(m_object);
-        if (listObject->isUnorderedList() || listObject->isOrderedList())
+    if (is<AccessibilityList>(*m_object)) {
+        auto& listObject = downcast<AccessibilityList>(*m_object);
+        if (listObject.isUnorderedList() || listObject.isOrderedList())
             return NSAccessibilityContentListSubrole;
-        if (listObject->isDescriptionList()) {
+        if (listObject.isDescriptionList()) {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
             return NSAccessibilityDefinitionListSubrole;
 #else
@@ -2179,9 +2179,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     
     // Only returning for DL (not UL or OL) because description changed with HTML5 from 'definition list' to
     // superset 'description list' and does not return the same values in AX API on some OS versions. 
-    if (m_object->isList()) {
-        AccessibilityList* listObject = toAccessibilityList(m_object);
-        if (listObject->isDescriptionList())
+    if (is<AccessibilityList>(*m_object)) {
+        if (downcast<AccessibilityList>(*m_object).isDescriptionList())
             return AXDescriptionListText();
     }
     
@@ -2217,7 +2216,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
 
 - (id)scrollViewParent
 {
-    if (!m_object || !m_object->isAccessibilityScrollView())
+    if (!is<AccessibilityScrollView>(m_object))
         return nil;
     
     // If this scroll view provides it's parent object (because it's a sub-frame), then
@@ -2225,8 +2224,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->parentObject())
         return nil;
     
-    AccessibilityScrollView* scrollView = toAccessibilityScrollView(m_object);
-    ScrollView* scroll = scrollView->scrollView();
+    ScrollView* scroll = downcast<AccessibilityScrollView>(*m_object).scrollView();
     if (!scroll)
         return nil;
     
@@ -2333,7 +2331,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->isWebArea()) {
         if ([attributeName isEqualToString:@"AXLinkUIElements"]) {
             AccessibilityObject::AccessibilityChildrenVector links;
-            toAccessibilityRenderObject(m_object)->getDocumentLinks(links);
+            downcast<AccessibilityRenderObject>(*m_object).getDocumentLinks(links);
             return convertToNSArray(links);
         }
         if ([attributeName isEqualToString:@"AXLoaded"])
@@ -2392,11 +2390,11 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     }
 
     // Only native spin buttons have increment and decrement buttons.
-    if (m_object->isNativeSpinButton()) {
+    if (is<AccessibilitySpinButton>(*m_object)) {
         if ([attributeName isEqualToString:NSAccessibilityIncrementButtonAttribute])
-            return toAccessibilitySpinButton(m_object)->incrementButton()->wrapper();
+            return downcast<AccessibilitySpinButton>(*m_object).incrementButton()->wrapper();
         if ([attributeName isEqualToString:NSAccessibilityDecrementButtonAttribute])
-            return toAccessibilitySpinButton(m_object)->decrementButton()->wrapper();
+            return downcast<AccessibilitySpinButton>(*m_object).decrementButton()->wrapper();
     }
     
     if ([attributeName isEqualToString: @"AXVisited"])
@@ -2557,19 +2555,20 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     }
     
     if (m_object->isAccessibilityTable()) {
+        auto& table = downcast<AccessibilityTable>(*m_object);
         if ([attributeName isEqualToString:NSAccessibilityRowsAttribute])
-            return convertToNSArray(toAccessibilityTable(m_object)->rows());
+            return convertToNSArray(table.rows());
         
         if ([attributeName isEqualToString:NSAccessibilityVisibleRowsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector visibleRows;
-            toAccessibilityTable(m_object)->visibleRows(visibleRows);
+            table.visibleRows(visibleRows);
             return convertToNSArray(visibleRows);
         }
         
         // TODO: distinguish between visible and non-visible columns
         if ([attributeName isEqualToString:NSAccessibilityColumnsAttribute] ||
             [attributeName isEqualToString:NSAccessibilityVisibleColumnsAttribute]) {
-            return convertToNSArray(toAccessibilityTable(m_object)->columns());
+            return convertToNSArray(table.columns());
         }
         
         if ([attributeName isEqualToString:NSAccessibilitySelectedRowsAttribute]) {
@@ -2585,12 +2584,12 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         
         if ([attributeName isEqualToString:NSAccessibilityColumnHeaderUIElementsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector columnHeaders;
-            toAccessibilityTable(m_object)->columnHeaders(columnHeaders);
+            table.columnHeaders(columnHeaders);
             return convertToNSArray(columnHeaders);
         }
         
         if ([attributeName isEqualToString:NSAccessibilityHeaderAttribute]) {
-            AccessibilityObject* headerContainer = toAccessibilityTable(m_object)->headerContainer();
+            AccessibilityObject* headerContainer = table.headerContainer();
             if (headerContainer)
                 return headerContainer->wrapper();
             return nil;
@@ -2598,59 +2597,61 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         
         if ([attributeName isEqualToString:NSAccessibilityRowHeaderUIElementsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector rowHeaders;
-            toAccessibilityTable(m_object)->rowHeaders(rowHeaders);
+            table.rowHeaders(rowHeaders);
             return convertToNSArray(rowHeaders);
         }
         
         if ([attributeName isEqualToString:NSAccessibilityVisibleCellsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector cells;
-            toAccessibilityTable(m_object)->cells(cells);
+            table.cells(cells);
             return convertToNSArray(cells);
         }
         
         if ([attributeName isEqualToString:NSAccessibilityColumnCountAttribute])
-            return @(toAccessibilityTable(m_object)->columnCount());
+            return @(table.columnCount());
         
         if ([attributeName isEqualToString:NSAccessibilityRowCountAttribute])
-            return @(toAccessibilityTable(m_object)->rowCount());
+            return @(table.rowCount());
     }
     
-    if (m_object->isTableColumn()) {
+    if (is<AccessibilityTableColumn>(*m_object)) {
+        auto& column = downcast<AccessibilityTableColumn>(*m_object);
         if ([attributeName isEqualToString:NSAccessibilityIndexAttribute])
-            return [NSNumber numberWithInt:toAccessibilityTableColumn(m_object)->columnIndex()];
+            return [NSNumber numberWithInt:column.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(toAccessibilityTableColumn(m_object)->children());
+            return convertToNSArray(column.children());
         }
         if ([attributeName isEqualToString:NSAccessibilityHeaderAttribute]) {
-            AccessibilityObject* header = toAccessibilityTableColumn(m_object)->headerObject();
+            AccessibilityObject* header = column.headerObject();
             if (!header)
                 return nil;
             return header->wrapper();
         }
     }
     
-    if (m_object->isTableCell()) {
+    if (is<AccessibilityTableCell>(*m_object)) {
+        auto& cell = downcast<AccessibilityTableCell>(*m_object);
         if ([attributeName isEqualToString:NSAccessibilityRowIndexRangeAttribute]) {
             std::pair<unsigned, unsigned> rowRange;
-            toAccessibilityTableCell(m_object)->rowIndexRange(rowRange);
+            cell.rowIndexRange(rowRange);
             return [NSValue valueWithRange:NSMakeRange(rowRange.first, rowRange.second)];
         }
         if ([attributeName isEqualToString:NSAccessibilityColumnIndexRangeAttribute]) {
             std::pair<unsigned, unsigned> columnRange;
-            toAccessibilityTableCell(m_object)->columnIndexRange(columnRange);
+            cell.columnIndexRange(columnRange);
             return [NSValue valueWithRange:NSMakeRange(columnRange.first, columnRange.second)];
         }
         if ([attributeName isEqualToString:NSAccessibilityColumnHeaderUIElementsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector columnHeaders;
-            toAccessibilityTableCell(m_object)->columnHeaders(columnHeaders);
+            cell.columnHeaders(columnHeaders);
             return convertToNSArray(columnHeaders);
         }
         if ([attributeName isEqualToString:NSAccessibilityRowHeaderUIElementsAttribute]) {
             AccessibilityObject::AccessibilityChildrenVector rowHeaders;
-            toAccessibilityTableCell(m_object)->rowHeaders(rowHeaders);
+            cell.rowHeaders(rowHeaders);
             return convertToNSArray(rowHeaders);
         }
     }
@@ -2691,9 +2692,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             
             return nil;
         }
-        if (m_object->isTableRow()) {
+        if (is<AccessibilityTableRow>(*m_object)) {
             if ([attributeName isEqualToString:NSAccessibilityIndexAttribute])
-                return [NSNumber numberWithInt:toAccessibilityTableRow(m_object)->rowIndex()];
+                return [NSNumber numberWithInt:downcast<AccessibilityTableRow>(*m_object).rowIndex()];
         }
     }
     
@@ -2703,9 +2704,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             AccessibilityObject::AccessibilityChildrenVector rowsCopy;
             m_object->ariaTreeItemDisclosedRows(rowsCopy);
             return convertToNSArray(rowsCopy);
-        } else if (m_object->isARIATreeGridRow()) {
+        } else if (is<AccessibilityARIAGridRow>(*m_object)) {
             AccessibilityObject::AccessibilityChildrenVector rowsCopy;
-            toAccessibilityARIAGridRow(m_object)->disclosedRows(rowsCopy);
+            downcast<AccessibilityARIAGridRow>(*m_object).disclosedRows(rowsCopy);
             return convertToNSArray(rowsCopy);
         }
     }
@@ -2723,8 +2724,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
                 parent = parent->parentObject();
             }
             return nil;
-        } else if (m_object->isARIATreeGridRow()) {
-            AccessibilityObject* row = toAccessibilityARIAGridRow(m_object)->disclosedByRow();
+        } else if (is<AccessibilityARIAGridRow>(*m_object)) {
+            AccessibilityObject* row = downcast<AccessibilityARIAGridRow>(*m_object).disclosedByRow();
             if (!row)
                 return nil;
             return row->wrapper();
@@ -2769,7 +2770,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return [NSNumber numberWithBool:m_object->isSelected()];
     
     if ([attributeName isEqualToString: NSAccessibilityServesAsTitleForUIElementsAttribute] && m_object->isMenuButton()) {
-        AccessibilityObject* uiElement = toAccessibilityRenderObject(m_object)->menuForMenuButton();
+        AccessibilityObject* uiElement = downcast<AccessibilityRenderObject>(*m_object).menuForMenuButton();
         if (uiElement)
             return [NSArray arrayWithObject:uiElement->wrapper()];
     }
@@ -3197,8 +3198,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (frameView && !frameView->platformWidget()) {
         // Find the appropriate scroll view to use to convert the contents to the window.
         for (AccessibilityObject* parent = m_object->parentObject(); parent; parent = parent->parentObject()) {
-            if (parent->isAccessibilityScrollView()) {
-                ScrollView* scrollView = toAccessibilityScrollView(parent)->scrollView();
+            if (is<AccessibilityScrollView>(*parent)) {
+                ScrollView* scrollView = downcast<AccessibilityScrollView>(*parent).scrollView();
                 rect = scrollView->contentsToRootView(rect);
                 break;
             }
@@ -3299,7 +3300,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             return;
         AccessibilityObject::AccessibilityChildrenVector selectedChildren;
         convertToVector(array, selectedChildren);
-        toAccessibilityListBox(m_object)->setSelectedChildren(selectedChildren);
+        downcast<AccessibilityListBox>(*m_object).setSelectedChildren(selectedChildren);
     } else if (m_object->isTextControl()) {
         if ([attributeName isEqualToString: NSAccessibilitySelectedTextAttribute]) {
             m_object->setSelectedText(string);
@@ -3706,7 +3707,7 @@ static RenderObject* rendererForView(NSView* view)
         if ([attribute isEqualToString:NSAccessibilityCellForColumnAndRowParameterizedAttribute]) {
             if (array == nil || [array count] != 2)
                 return nil;
-            AccessibilityTableCell* cell = toAccessibilityTable(m_object)->cellForColumnAndRow([[array objectAtIndex:0] unsignedIntValue], [[array objectAtIndex:1] unsignedIntValue]);
+            AccessibilityTableCell* cell = downcast<AccessibilityTable>(*m_object).cellForColumnAndRow([[array objectAtIndex:0] unsignedIntValue], [[array objectAtIndex:1] unsignedIntValue]);
             if (!cell)
                 return nil;
             
index 5c3e094..496ebb4 100644 (file)
@@ -1580,8 +1580,8 @@ PassRefPtr<Inspector::Protocol::DOM::AccessibilityProperties> InspectorDOMAgent:
                     liveRegionStatus = Inspector::Protocol::DOM::AccessibilityProperties::LiveRegionStatus::Polite;
             }
 
-            if (axObject->isAccessibilityNodeObject())
-                mouseEventNode = toAccessibilityNodeObject(axObject)->mouseButtonListener(MouseButtonListenerResultFilter::IncludeBodyElement);
+            if (is<AccessibilityNodeObject>(*axObject))
+                mouseEventNode = downcast<AccessibilityNodeObject>(*axObject).mouseButtonListener(MouseButtonListenerResultFilter::IncludeBodyElement);
 
             if (axObject->supportsARIAOwns()) {
                 Vector<Element*> ownedElements;
index 484ffbf..44c8d2b 100644 (file)
@@ -437,7 +437,7 @@ void RenderMenuList::didUpdateActiveOption(int optionIndex)
         return;
 
     if (AXObjectCache* cache = document().existingAXObjectCache()) {
-        if (AccessibilityMenuList* menuList = toAccessibilityMenuList(cache->get(this)))
+        if (AccessibilityMenuList* menuList = downcast<AccessibilityMenuList>(cache->get(this)))
             menuList->didUpdateActiveOption(optionIndex);
     }
 }
index 96f9b75..589c308 100644 (file)
@@ -616,10 +616,10 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::accSelect(long selectionFlags, VARIANT
         return E_INVALIDARG;
 
     if (selectionFlags & SELFLAG_TAKESELECTION) {
-        if (parentObject->isListBox()) {
+        if (is<AccessibilityListBox>(*parentObject)) {
             Vector<RefPtr<AccessibilityObject> > selectedChildren(1);
             selectedChildren[0] = childObject;
-            toAccessibilityListBox(parentObject)->setSelectedChildren(selectedChildren);
+            downcast<AccessibilityListBox>(*parentObject).setSelectedChildren(selectedChildren);
         } else { // any element may be selectable by virtue of it having the aria-selected property
             ASSERT(!parentObject->isMultiSelectable());
             childObject->setSelected(true);
index fd5f5f6..eb64e3a 100644 (file)
@@ -41,16 +41,16 @@ AccessibleImage::AccessibleImage(AccessibilityObject* obj, HWND window)
 
 String AccessibleImage::name() const
 {
-    if (!m_object->isAccessibilityRenderObject())
+    if (!is<AccessibilityRenderObject>(*m_object))
         return AccessibleBase::name();
 
-    AccessibilityRenderObject* obj = toAccessibilityRenderObject(m_object);
+    AccessibilityRenderObject& obj = downcast<AccessibilityRenderObject>(*m_object);
 
-    String ariaLabel = obj->ariaLabeledByAttribute();
+    String ariaLabel = obj.ariaLabeledByAttribute();
     if (!ariaLabel.isEmpty())
         return ariaLabel;
 
-    const AtomicString& altText = obj->getAttribute(HTMLNames::altAttr);
+    const AtomicString& altText = obj.getAttribute(HTMLNames::altAttr);
     if (!altText.isEmpty())
         return altText;
 
index 193ba58..fa08081 100644 (file)
@@ -1,3 +1,17 @@
+2014-10-20  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for Accessibility objects
+        https://bugs.webkit.org/show_bug.cgi?id=137286
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for Accessibility objects.
+
+        * AccessibleBase.cpp:
+        (AccessibleBase::accSelect):
+        * AccessibleImage.cpp:
+        (AccessibleImage::name):
+
 2014-10-18  peavo@outlook.com  <peavo@outlook.com>
 
         [WinCairo] Repaint issues with accelerated compositing.