[ATK] Use a smart pointer for AccessibilityObject wrapper and remove GTK specific...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Apr 2019 07:35:24 +0000 (07:35 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Apr 2019 07:35:24 +0000 (07:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196593
<rdar://problem/49599153>

Reviewed by Michael Catanzaro.

Source/WebCore:

We have specific code for GTK to get/set the wrapper only because we don't use smart pointers. Also use
WebKitAccessible as AccessibilityObjectWrapper instead of generic AtkObject, to enforce wrappers to be
WebKitAccessible instances. This requires a few casts to AtkObject.

* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::setWrapper):
* accessibility/AccessibilityObjectInterface.h:
* accessibility/atk/AXObjectCacheAtk.cpp:
(WebCore::AXObjectCache::detachWrapper):
(WebCore::AXObjectCache::attachWrapper):
(WebCore::notifyChildrenSelectionChange):
(WebCore::AXObjectCache::postPlatformNotification):
(WebCore::AXObjectCache::nodeTextChangePlatformNotification):
(WebCore::AXObjectCache::frameLoadingEventPlatformNotification):
(WebCore::AXObjectCache::platformHandleFocusedUIElementChanged):
* accessibility/atk/AccessibilityObjectAtk.cpp:
* accessibility/atk/WebKitAccessibleInterfaceComponent.cpp:
(webkitAccessibleComponentRefAccessibleAtPoint):
* accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp:
(webkitAccessibleHypertextGetLink):
(webkitAccessibleHypertextGetNLinks):
* accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
(webkitAccessibleSelectionRefSelection):
* accessibility/atk/WebKitAccessibleInterfaceTable.cpp:
(webkitAccessibleTableRefAt):
(webkitAccessibleTableGetColumnHeader):
(webkitAccessibleTableGetRowHeader):
(webkitAccessibleTableGetCaption):
* accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp:
(convertToGPtrArray):
(webkitAccessibleTableCellGetTable):
* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(accessibilityObjectLength):
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(setAtkRelationSetFromCoreObject):
(atkParentOfRootObject):
(webkitAccessibleGetParent):
(webkitAccessibleRefChild):
(isTextWithCaret):
* editing/atk/FrameSelectionAtk.cpp:
(WebCore::emitTextSelectionChange):
(WebCore::maybeEmitTextFocusChange):

Source/WebKit:

* WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp:
(accessibilityRootObjectWrapper): Cast wrapper() as AtkObject.

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityObjectInterface.h
Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp
Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceComponent.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTable.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
Source/WebCore/editing/atk/FrameSelectionAtk.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp

index e511a7f..c8aaf95 100644 (file)
@@ -1,3 +1,54 @@
+2019-04-05  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [ATK] Use a smart pointer for AccessibilityObject wrapper and remove GTK specific code
+        https://bugs.webkit.org/show_bug.cgi?id=196593
+        <rdar://problem/49599153>
+
+        Reviewed by Michael Catanzaro.
+
+        We have specific code for GTK to get/set the wrapper only because we don't use smart pointers. Also use
+        WebKitAccessible as AccessibilityObjectWrapper instead of generic AtkObject, to enforce wrappers to be
+        WebKitAccessible instances. This requires a few casts to AtkObject.
+
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::setWrapper):
+        * accessibility/AccessibilityObjectInterface.h:
+        * accessibility/atk/AXObjectCacheAtk.cpp:
+        (WebCore::AXObjectCache::detachWrapper):
+        (WebCore::AXObjectCache::attachWrapper):
+        (WebCore::notifyChildrenSelectionChange):
+        (WebCore::AXObjectCache::postPlatformNotification):
+        (WebCore::AXObjectCache::nodeTextChangePlatformNotification):
+        (WebCore::AXObjectCache::frameLoadingEventPlatformNotification):
+        (WebCore::AXObjectCache::platformHandleFocusedUIElementChanged):
+        * accessibility/atk/AccessibilityObjectAtk.cpp:
+        * accessibility/atk/WebKitAccessibleInterfaceComponent.cpp:
+        (webkitAccessibleComponentRefAccessibleAtPoint):
+        * accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp:
+        (webkitAccessibleHypertextGetLink):
+        (webkitAccessibleHypertextGetNLinks):
+        * accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
+        (webkitAccessibleSelectionRefSelection):
+        * accessibility/atk/WebKitAccessibleInterfaceTable.cpp:
+        (webkitAccessibleTableRefAt):
+        (webkitAccessibleTableGetColumnHeader):
+        (webkitAccessibleTableGetRowHeader):
+        (webkitAccessibleTableGetCaption):
+        * accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp:
+        (convertToGPtrArray):
+        (webkitAccessibleTableCellGetTable):
+        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
+        (accessibilityObjectLength):
+        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
+        (setAtkRelationSetFromCoreObject):
+        (atkParentOfRootObject):
+        (webkitAccessibleGetParent):
+        (webkitAccessibleRefChild):
+        (isTextWithCaret):
+        * editing/atk/FrameSelectionAtk.cpp:
+        (WebCore::emitTextSelectionChange):
+        (WebCore::maybeEmitTextFocusChange):
+
 2019-04-04  Simon Fraser  <simon.fraser@apple.com>
 
         [iOS WK2] REGRESSION (r242687): Programmatic scroll of overflow scroll results in bad rendering
index 003a049..cd96968 100644 (file)
 #include <wtf/RetainPtr.h>
 #endif
 
+#if PLATFORM(GTK)
+#include <wtf/glib/GRefPtr.h>
+#endif
+
 #if PLATFORM(COCOA)
 
 typedef struct _NSRange NSRange;
@@ -934,20 +938,12 @@ public:
     bool isAXHidden() const;
     bool isDOMHidden() const;
     bool isHidden() const { return isAXHidden() || isDOMHidden(); }
-    
+
 #if HAVE(ACCESSIBILITY)
-#if PLATFORM(GTK)
-    AccessibilityObjectWrapper* wrapper() const override;
-    void setWrapper(AccessibilityObjectWrapper*);
-#else
     AccessibilityObjectWrapper* wrapper() const override { return m_wrapper.get(); }
-    void setWrapper(AccessibilityObjectWrapper* wrapper) 
-    {
-        m_wrapper = wrapper;
-    }
+    void setWrapper(AccessibilityObjectWrapper* wrapper) { m_wrapper = wrapper; }
 #endif
-#endif
-    
+
 #if PLATFORM(COCOA)
     void overrideAttachmentParent(AccessibilityObject* parent);
 #else
@@ -1050,7 +1046,7 @@ protected:
 #elif PLATFORM(WIN)
     COMPtr<AccessibilityObjectWrapper> m_wrapper;
 #elif PLATFORM(GTK)
-    AtkObject* m_wrapper { nullptr };
+    GRefPtr<WebKitAccessible> m_wrapper;
 #elif PLATFORM(WPE)
     RefPtr<AccessibilityObjectWrapper> m_wrapper;
 #endif
index 35bf520..71fa8f0 100644 (file)
@@ -37,8 +37,8 @@
 OBJC_CLASS WebAccessibilityObjectWrapper;
 typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper;
 #elif PLATFORM(GTK)
-typedef struct _AtkObject AtkObject;
-typedef struct _AtkObject AccessibilityObjectWrapper;
+typedef struct _WebKitAccessible WebKitAccessible;
+typedef struct _WebKitAccessible AccessibilityObjectWrapper;
 #elif PLATFORM(WPE)
 class AccessibilityObjectWrapper : public RefCounted<AccessibilityObjectWrapper> { };
 #else
index 3ac0228..bb183d1 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 
 void AXObjectCache::detachWrapper(AccessibilityObject* obj, AccessibilityDetachmentType detachmentType)
 {
-    AtkObject* wrapper = obj->wrapper();
+    auto* wrapper = obj->wrapper();
     ASSERT(wrapper);
 
     // If an object is being detached NOT because of the AXObjectCache being destroyed,
@@ -66,9 +66,8 @@ void AXObjectCache::detachWrapper(AccessibilityObject* obj, AccessibilityDetachm
 
 void AXObjectCache::attachWrapper(AccessibilityObject* obj)
 {
-    AtkObject* atkObj = ATK_OBJECT(webkitAccessibleNew(obj));
-    obj->setWrapper(atkObj);
-    g_object_unref(atkObj);
+    GRefPtr<WebKitAccessible> wrapper = adoptGRef(webkitAccessibleNew(obj));
+    obj->setWrapper(wrapper.get());
 
     // If an object is being attached and we are not in the middle of a layout update, then
     // we should report ATs by emitting the children-changed::add signal from the parent.
@@ -94,12 +93,12 @@ void AXObjectCache::attachWrapper(AccessibilityObject* obj)
         return;
 
     // Look for the right object to emit the signal from.
-    AtkObject* atkParent = coreParent->wrapper();
+    auto* atkParent = coreParent->wrapper();
     if (!atkParent)
         return;
 
     size_t index = coreParent->children(false).find(obj);
-    g_signal_emit_by_name(atkParent, "children-changed::add", index != notFound ? index : -1, atkObj);
+    g_signal_emit_by_name(atkParent, "children-changed::add", index != notFound ? index : -1, wrapper.get());
 }
 
 static AccessibilityObject* getListObject(AccessibilityObject* object)
@@ -168,24 +167,24 @@ static void notifyChildrenSelectionChange(AccessibilityObject* object)
     if (oldListObject.get() != listObject)
         oldFocusedObject.get() = nullptr;
 
-    AtkObject* axItem = item ? item->wrapper() : nullptr;
-    AtkObject* axOldFocusedObject = oldFocusedObject.get() ? oldFocusedObject.get()->wrapper() : nullptr;
+    WebKitAccessible* axItem = item ? item->wrapper() : nullptr;
+    WebKitAccessible* axOldFocusedObject = oldFocusedObject.get() ? oldFocusedObject.get()->wrapper() : nullptr;
 
     // Old focused object just lost focus, so emit the events.
     if (axOldFocusedObject && axItem != axOldFocusedObject) {
         g_signal_emit_by_name(axOldFocusedObject, "focus-event", false);
-        atk_object_notify_state_change(axOldFocusedObject, ATK_STATE_FOCUSED, false);
+        atk_object_notify_state_change(ATK_OBJECT(axOldFocusedObject), ATK_STATE_FOCUSED, false);
     }
 
     // Emit needed events for the currently (un)selected item.
     if (axItem) {
         bool isSelected = item->isSelected();
-        atk_object_notify_state_change(axItem, ATK_STATE_SELECTED, isSelected);
+        atk_object_notify_state_change(ATK_OBJECT(axItem), ATK_STATE_SELECTED, isSelected);
         // When the selection changes in a collapsed widget such as a combo box
         // whose child menu is not showing, that collapsed widget retains focus.
         if (!object->isCollapsed()) {
             g_signal_emit_by_name(axItem, "focus-event", isSelected);
-            atk_object_notify_state_change(axItem, ATK_STATE_FOCUSED, isSelected);
+            atk_object_notify_state_change(ATK_OBJECT(axItem), ATK_STATE_FOCUSED, isSelected);
         }
     }
 
@@ -196,7 +195,7 @@ static void notifyChildrenSelectionChange(AccessibilityObject* object)
 
 void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification)
 {
-    AtkObject* axObject = coreObject->wrapper();
+    auto* axObject = ATK_OBJECT(coreObject->wrapper());
     if (!axObject)
         return;
 
@@ -231,7 +230,7 @@ void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AX
             atk_value_get_current_value(ATK_VALUE(axObject), &propertyValues.new_value);
 #endif
 
-            g_signal_emit_by_name(ATK_OBJECT(axObject), "property-change::accessible-value", &propertyValues, NULL);
+            g_signal_emit_by_name(axObject, "property-change::accessible-value", &propertyValues, NULL);
         }
         break;
 
@@ -299,7 +298,7 @@ void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject* obje
     if (!parentObject)
         return;
 
-    AtkObject* wrapper = parentObject->wrapper();
+    auto* wrapper = parentObject->wrapper();
     if (!wrapper || !ATK_IS_TEXT(wrapper))
         return;
 
@@ -349,7 +348,7 @@ void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject* o
     if (!object)
         return;
 
-    AtkObject* axObject = object->wrapper();
+    auto* axObject = ATK_OBJECT(object->wrapper());
     if (!axObject || !ATK_IS_DOCUMENT(axObject))
         return;
 
@@ -376,13 +375,15 @@ void AXObjectCache::platformHandleFocusedUIElementChanged(Node* oldFocusedNode,
 {
     RefPtr<AccessibilityObject> oldObject = getOrCreate(oldFocusedNode);
     if (oldObject) {
-        g_signal_emit_by_name(oldObject->wrapper(), "focus-event", false);
-        atk_object_notify_state_change(oldObject->wrapper(), ATK_STATE_FOCUSED, false);
+        auto* axObject = oldObject->wrapper();
+        g_signal_emit_by_name(axObject, "focus-event", false);
+        atk_object_notify_state_change(ATK_OBJECT(axObject), ATK_STATE_FOCUSED, false);
     }
     RefPtr<AccessibilityObject> newObject = getOrCreate(newFocusedNode);
     if (newObject) {
-        g_signal_emit_by_name(newObject->wrapper(), "focus-event", true);
-        atk_object_notify_state_change(newObject->wrapper(), ATK_STATE_FOCUSED, true);
+        auto* axObject = newObject->wrapper();
+        g_signal_emit_by_name(axObject, "focus-event", true);
+        atk_object_notify_state_change(ATK_OBJECT(axObject), ATK_STATE_FOCUSED, true);
     }
 }
 
index 5933a19..42b8ec2 100644 (file)
@@ -156,25 +156,6 @@ AccessibilityObjectInclusion AccessibilityObject::accessibilityPlatformIncludesO
     return AccessibilityObjectInclusion::DefaultBehavior;
 }
 
-AccessibilityObjectWrapper* AccessibilityObject::wrapper() const
-{
-    return m_wrapper;
-}
-
-void AccessibilityObject::setWrapper(AccessibilityObjectWrapper* wrapper)
-{
-    if (wrapper == m_wrapper)
-        return;
-
-    if (m_wrapper)
-        g_object_unref(m_wrapper);
-
-    m_wrapper = wrapper;
-
-    if (m_wrapper)
-        g_object_ref(m_wrapper);
-}
-
 bool AccessibilityObject::allowsTextRanges() const
 {
     // Check type for the AccessibilityObject.
index f6b754a..6984726 100644 (file)
@@ -81,7 +81,7 @@ static AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent* co
     if (!target)
         return 0;
     g_object_ref(target->wrapper());
-    return target->wrapper();
+    return ATK_OBJECT(target->wrapper());
 }
 
 static void webkitAccessibleComponentGetExtents(AtkComponent* component, gint* x, gint* y, gint* width, gint* height, AtkCoordType coordType)
index db60218..f12e3df 100644 (file)
@@ -49,7 +49,7 @@ static AtkHyperlink* webkitAccessibleHypertextGetLink(AtkHypertext* hypertext, g
     for (const auto& child : children) {
         AccessibilityObject* coreChild = child.get();
         if (!coreChild->accessibilityIsIgnored()) {
-            AtkObject* axObject = coreChild->wrapper();
+            auto* axObject = coreChild->wrapper();
             if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))
                 continue;
 
@@ -74,7 +74,7 @@ static gint webkitAccessibleHypertextGetNLinks(AtkHypertext* hypertext)
     for (const auto& child : children) {
         AccessibilityObject* coreChild = child.get();
         if (!coreChild->accessibilityIsIgnored()) {
-            AtkObject* axObject = coreChild->wrapper();
+            auto* axObject = coreChild->wrapper();
             if (axObject && ATK_IS_HYPERLINK_IMPL(axObject))
                 linksFound++;
         }
index ec7f8ca..5bfd925 100644 (file)
@@ -158,9 +158,9 @@ static AtkObject* webkitAccessibleSelectionRefSelection(AtkSelection* selection,
 
     AccessibilityObject* option = optionFromSelection(selection, index);
     if (option) {
-        AtkObject* child = option->wrapper();
+        auto* child = option->wrapper();
         g_object_ref(child);
-        return child;
+        return ATK_OBJECT(child);
     }
 
     return nullptr;
index d07d08a..2da34c9 100644 (file)
@@ -96,7 +96,7 @@ static AtkObject* webkitAccessibleTableRefAt(AtkTable* table, gint row, gint col
     if (!axCell)
         return 0;
 
-    AtkObject* cell = axCell->wrapper();
+    auto* cell = axCell->wrapper();
     if (!cell)
         return 0;
 
@@ -215,7 +215,7 @@ static AtkObject* webkitAccessibleTableGetColumnHeader(AtkTable* table, gint col
             std::pair<unsigned, unsigned> 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 ATK_OBJECT(columnHeader->wrapper());
         }
     }
     return nullptr;
@@ -235,7 +235,7 @@ static AtkObject* webkitAccessibleTableGetRowHeader(AtkTable* table, gint row)
             std::pair<unsigned, unsigned> 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 ATK_OBJECT(rowHeader->wrapper());
         }
     }
     return nullptr;
@@ -252,7 +252,7 @@ static AtkObject* webkitAccessibleTableGetCaption(AtkTable* table)
         if (is<HTMLTableElement>(node)) {
             auto caption = downcast<HTMLTableElement>(*node).caption();
             if (caption)
-                return AccessibilityObject::firstAccessibleObjectFromNode(caption->renderer()->element())->wrapper();
+                return ATK_OBJECT(AccessibilityObject::firstAccessibleObjectFromNode(caption->renderer()->element())->wrapper());
         }
     }
     return nullptr;
index 9d84822..623e3e1 100644 (file)
@@ -34,7 +34,7 @@ static GPtrArray* convertToGPtrArray(const AccessibilityObject::AccessibilityChi
 {
     GPtrArray* array = g_ptr_array_new();
     for (const auto& child : children) {
-        if (AtkObject* atkObject = child->wrapper())
+        if (auto* atkObject = child->wrapper())
             g_ptr_array_add(array, atkObject);
     }
     return array;
@@ -149,7 +149,7 @@ AtkObject* webkitAccessibleTableCellGetTable(AtkTableCell* cell)
     if (!axObject || !axObject->isTableCell())
         return nullptr;
 
-    AtkObject* table = atk_object_get_parent(axObject->wrapper());
+    auto* table = atk_object_get_parent(ATK_OBJECT(axObject->wrapper()));
     if (!table || !ATK_IS_TABLE(table))
         return nullptr;
 
index da402da..94453dc 100644 (file)
@@ -231,7 +231,7 @@ static guint accessibilityObjectLength(const AccessibilityObject* object)
 
     // For those objects implementing the AtkText interface we use the
     // well known API to always get the text in a consistent way
-    AtkObject* atkObj = ATK_OBJECT(object->wrapper());
+    auto* atkObj = ATK_OBJECT(object->wrapper());
     if (ATK_IS_TEXT(atkObj)) {
         GUniquePtr<gchar> text(webkitAccessibleTextGetText(ATK_TEXT(atkObj), 0, -1));
         return g_utf8_strlen(text.get(), -1);
index ed2943e..a1480a6 100644 (file)
@@ -181,87 +181,87 @@ static void setAtkRelationSetFromCoreObject(AccessibilityObject* coreObject, Atk
     removeAtkRelationByType(relationSet, ATK_RELATION_LABEL_FOR);
     if (coreObject->isControl()) {
         if (AccessibilityObject* label = coreObject->correspondingLabelForControlElement())
-            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, label->wrapper());
+            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(label->wrapper()));
     } else if (coreObject->isFieldset()) {
         if (AccessibilityObject* label = coreObject->titleUIElement())
-            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, label->wrapper());
+            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(label->wrapper()));
     } else if (coreObject->roleValue() == AccessibilityRole::Legend) {
         if (RenderBlock* renderFieldset = ancestorsOfType<RenderBlock>(*coreObject->renderer()).first()) {
             if (renderFieldset->isFieldset()) {
                 AccessibilityObject* fieldset = coreObject->axObjectCache()->getOrCreate(renderFieldset);
-                atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, fieldset->wrapper());
+                atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(fieldset->wrapper()));
             }
         }
     } else if (AccessibilityObject* control = coreObject->correspondingControlForLabelElement()) {
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, control->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(control->wrapper()));
     } else {
         AccessibilityObject::AccessibilityChildrenVector ariaLabelledByElements;
         coreObject->ariaLabelledByElements(ariaLabelledByElements);
         for (const auto& accessibilityObject : ariaLabelledByElements)
-            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, accessibilityObject->wrapper());
+            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(accessibilityObject->wrapper()));
     }
 
     // Elements referenced by aria-labelledby should have the label-for relation as per the ARIA AAM spec.
     AccessibilityObject::AccessibilityChildrenVector labels;
     coreObject->ariaLabelledByReferencingElements(labels);
     for (const auto& accessibilityObject : labels)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements with aria-flowto should have the flows-to relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_FLOWS_TO);
     AccessibilityObject::AccessibilityChildrenVector ariaFlowToElements;
     coreObject->ariaFlowToElements(ariaFlowToElements);
     for (const auto& accessibilityObject : ariaFlowToElements)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_TO, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_TO, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-flowto should have the flows-from relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_FLOWS_FROM);
     AccessibilityObject::AccessibilityChildrenVector flowFrom;
     coreObject->ariaFlowToReferencingElements(flowFrom);
     for (const auto& accessibilityObject : flowFrom)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_FROM, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_FROM, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements with aria-describedby should have the described-by relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_DESCRIBED_BY);
     AccessibilityObject::AccessibilityChildrenVector ariaDescribedByElements;
     coreObject->ariaDescribedByElements(ariaDescribedByElements);
     for (const auto& accessibilityObject : ariaDescribedByElements)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIBED_BY, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIBED_BY, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-describedby should have the description-for relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_DESCRIPTION_FOR);
     AccessibilityObject::AccessibilityChildrenVector describers;
     coreObject->ariaDescribedByReferencingElements(describers);
     for (const auto& accessibilityObject : describers)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIPTION_FOR, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIPTION_FOR, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements with aria-controls should have the controller-for relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_CONTROLLER_FOR);
     AccessibilityObject::AccessibilityChildrenVector ariaControls;
     coreObject->ariaControlsElements(ariaControls);
     for (const auto& accessibilityObject : ariaControls)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLER_FOR, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLER_FOR, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-controls should have the controlled-by relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_CONTROLLED_BY);
     AccessibilityObject::AccessibilityChildrenVector controllers;
     coreObject->ariaControlsReferencingElements(controllers);
     for (const auto& accessibilityObject : controllers)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLED_BY, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLED_BY, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements with aria-owns should have the node-parent-of relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_NODE_PARENT_OF);
     AccessibilityObject::AccessibilityChildrenVector ariaOwns;
     coreObject->ariaOwnsElements(ariaOwns);
     for (const auto& accessibilityObject : ariaOwns)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_PARENT_OF, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_PARENT_OF, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-owns should have the node-child-of relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_NODE_CHILD_OF);
     AccessibilityObject::AccessibilityChildrenVector owners;
     coreObject->ariaOwnsReferencingElements(owners);
     for (const auto& accessibilityObject : owners)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_CHILD_OF, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_CHILD_OF, ATK_OBJECT(accessibilityObject->wrapper()));
 
 #if ATK_CHECK_VERSION(2, 25, 2)
     // Elements with aria-details should have the details relation as per the ARIA AAM spec.
@@ -269,28 +269,28 @@ static void setAtkRelationSetFromCoreObject(AccessibilityObject* coreObject, Atk
     AccessibilityObject::AccessibilityChildrenVector ariaDetails;
     coreObject->ariaDetailsElements(ariaDetails);
     for (const auto& accessibilityObject : ariaDetails)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-details should have the details-for relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_DETAILS_FOR);
     AccessibilityObject::AccessibilityChildrenVector details;
     coreObject->ariaDetailsReferencingElements(details);
     for (const auto& accessibilityObject : details)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS_FOR, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS_FOR, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements with aria-errormessage should have the error-message relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_ERROR_MESSAGE);
     AccessibilityObject::AccessibilityChildrenVector ariaErrorMessage;
     coreObject->ariaErrorMessageElements(ariaErrorMessage);
     for (const auto& accessibilityObject : ariaErrorMessage)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_MESSAGE, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_MESSAGE, ATK_OBJECT(accessibilityObject->wrapper()));
 
     // Elements referenced by aria-errormessage should have the error-for relation as per the ARIA AAM spec.
     removeAtkRelationByType(relationSet, ATK_RELATION_ERROR_FOR);
     AccessibilityObject::AccessibilityChildrenVector errors;
     coreObject->ariaErrorMessageReferencingElements(errors);
     for (const auto& accessibilityObject : errors)
-        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_FOR, accessibilityObject->wrapper());
+        atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_FOR, ATK_OBJECT(accessibilityObject->wrapper()));
 #endif
 }
 
@@ -324,10 +324,7 @@ static AtkObject* atkParentOfRootObject(AtkObject* object)
             return 0;
     }
 
-    if (!coreParent)
-        return 0;
-
-    return coreParent->wrapper();
+    return coreParent ? ATK_OBJECT(coreParent->wrapper()) : nullptr;
 }
 
 static AtkObject* webkitAccessibleGetParent(AtkObject* object)
@@ -350,10 +347,7 @@ static AtkObject* webkitAccessibleGetParent(AtkObject* object)
     if (!coreParent && isRootObject(coreObject))
         return atkParentOfRootObject(object);
 
-    if (!coreParent)
-        return 0;
-
-    return coreParent->wrapper();
+    return coreParent ? ATK_OBJECT(coreParent->wrapper()) : nullptr;
 }
 
 static gint webkitAccessibleGetNChildren(AtkObject* object)
@@ -385,7 +379,7 @@ static AtkObject* webkitAccessibleRefChild(AtkObject* object, gint index)
     if (!coreChild)
         return 0;
 
-    AtkObject* child = coreChild->wrapper();
+    auto* child = ATK_OBJECT(coreChild->wrapper());
     atk_object_set_parent(child, object);
     g_object_ref(child);
 
@@ -914,8 +908,8 @@ static bool isTextWithCaret(AccessibilityObject* coreObject)
         return false;
 
     // Check text objects and paragraphs only.
-    AtkObject* axObject = coreObject->wrapper();
-    AtkRole role = axObject ? atk_object_get_role(axObject) : ATK_ROLE_INVALID;
+    auto* axObject = coreObject->wrapper();
+    AtkRole role = axObject ? atk_object_get_role(ATK_OBJECT(axObject)) : ATK_ROLE_INVALID;
     if (role != ATK_ROLE_TEXT && role != ATK_ROLE_PARAGRAPH)
         return false;
 
index 9b5f288..7ff1ca3 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 
 static void emitTextSelectionChange(AccessibilityObject* object, VisibleSelection selection, int offset)
 {
-    AtkObject* axObject = object->wrapper();
+    auto* axObject = object->wrapper();
     if (!axObject || !ATK_IS_TEXT(axObject))
         return;
 
@@ -65,17 +65,17 @@ static void maybeEmitTextFocusChange(RefPtr<AccessibilityObject>&& object)
     if (object && oldObject.get() && oldObject.get()->document() != object->document())
         oldObject.get() = nullptr;
 
-    AtkObject* axObject = object ? object->wrapper() : 0;
-    AtkObject* oldAxObject = oldObject.get() ? oldObject.get()->wrapper() : nullptr;
+    auto* axObject = object ? object->wrapper() : nullptr;
+    auto* oldAxObject = oldObject.get() ? oldObject.get()->wrapper() : nullptr;
 
     if (axObject != oldAxObject) {
         if (oldAxObject && ATK_IS_TEXT(oldAxObject)) {
-            g_signal_emit_by_name(oldAxObject, "focus-event", false);
-            atk_object_notify_state_change(oldAxObject, ATK_STATE_FOCUSED, false);
+            g_signal_emit_by_name(oldAxObject, "focus-event", FALSE);
+            atk_object_notify_state_change(ATK_OBJECT(oldAxObject), ATK_STATE_FOCUSED, FALSE);
         }
         if (axObject && ATK_IS_TEXT(axObject)) {
-            g_signal_emit_by_name(axObject, "focus-event", true);
-            atk_object_notify_state_change(axObject, ATK_STATE_FOCUSED, true);
+            g_signal_emit_by_name(axObject, "focus-event", TRUE);
+            atk_object_notify_state_change(ATK_OBJECT(axObject), ATK_STATE_FOCUSED, TRUE);
         }
     }
 
index 8d40730..5192849 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-05  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [ATK] Use a smart pointer for AccessibilityObject wrapper and remove GTK specific code
+        https://bugs.webkit.org/show_bug.cgi?id=196593
+        <rdar://problem/49599153>
+
+        Reviewed by Michael Catanzaro.
+
+        * WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp:
+        (accessibilityRootObjectWrapper): Cast wrapper() as AtkObject.
+
 2019-04-04  Simon Fraser  <simon.fraser@apple.com>
 
         Simple iframe scrolling test fails to get a composited scrolling frame in WebKitTestRunnerApp
index dba3f43..1f04c03 100644 (file)
@@ -69,11 +69,7 @@ static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject)
     if (!coreRootObject)
         return nullptr;
 
-    AtkObject* rootObject = coreRootObject->wrapper();
-    if (!rootObject || !ATK_IS_OBJECT(rootObject))
-        return nullptr;
-
-    return rootObject;
+    return ATK_OBJECT(coreRootObject->wrapper());
 }
 
 static void webkitWebPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data)