Title: [243928] trunk/Source
Revision
243928
Author
carlo...@webkit.org
Date
2019-04-05 00:35:24 -0700 (Fri, 05 Apr 2019)

Log Message

[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.

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (243927 => 243928)


--- trunk/Source/WebCore/ChangeLog	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/ChangeLog	2019-04-05 07:35:24 UTC (rev 243928)
@@ -1,3 +1,54 @@
+2019-04-05  Carlos Garcia Campos  <cgar...@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.fra...@apple.com>
 
         [iOS WK2] REGRESSION (r242687): Programmatic scroll of overflow scroll results in bad rendering

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (243927 => 243928)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2019-04-05 07:35:24 UTC (rev 243928)
@@ -47,6 +47,10 @@
 #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 @@
     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 @@
 #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

Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (243927 => 243928)


--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2019-04-05 07:35:24 UTC (rev 243928)
@@ -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

Modified: trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -38,7 +38,7 @@
 
 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::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 @@
         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 @@
     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 @@
 
 void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification)
 {
-    AtkObject* axObject = coreObject->wrapper();
+    auto* axObject = ATK_OBJECT(coreObject->wrapper());
     if (!axObject)
         return;
 
@@ -231,7 +230,7 @@
             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 @@
     if (!parentObject)
         return;
 
-    AtkObject* wrapper = parentObject->wrapper();
+    auto* wrapper = parentObject->wrapper();
     if (!wrapper || !ATK_IS_TEXT(wrapper))
         return;
 
@@ -349,7 +348,7 @@
     if (!object)
         return;
 
-    AtkObject* axObject = object->wrapper();
+    auto* axObject = ATK_OBJECT(object->wrapper());
     if (!axObject || !ATK_IS_DOCUMENT(axObject))
         return;
 
@@ -376,13 +375,15 @@
 {
     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);
     }
 }
 

Modified: trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -156,25 +156,6 @@
     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.

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceComponent.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceComponent.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceComponent.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -81,7 +81,7 @@
     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)

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -49,7 +49,7 @@
     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 @@
     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++;
         }

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -158,9 +158,9 @@
 
     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;

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTable.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTable.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTable.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -96,7 +96,7 @@
     if (!axCell)
         return 0;
 
-    AtkObject* cell = axCell->wrapper();
+    auto* cell = axCell->wrapper();
     if (!cell)
         return 0;
 
@@ -215,7 +215,7 @@
             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 @@
             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 @@
         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;

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceTableCell.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -34,7 +34,7 @@
 {
     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 @@
     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;
 

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -231,7 +231,7 @@
 
     // 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);

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp (243927 => 243928)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -181,24 +181,24 @@
     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.
@@ -205,7 +205,7 @@
     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);
@@ -212,7 +212,7 @@
     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);
@@ -219,7 +219,7 @@
     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);
@@ -226,7 +226,7 @@
     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);
@@ -233,7 +233,7 @@
     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);
@@ -240,7 +240,7 @@
     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);
@@ -247,7 +247,7 @@
     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);
@@ -254,7 +254,7 @@
     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);
@@ -261,7 +261,7 @@
     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,7 +269,7 @@
     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);
@@ -276,7 +276,7 @@
     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);
@@ -283,7 +283,7 @@
     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);
@@ -290,7 +290,7 @@
     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 @@
             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 @@
     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 @@
     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 @@
         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;
 

Modified: trunk/Source/WebCore/editing/atk/FrameSelectionAtk.cpp (243927 => 243928)


--- trunk/Source/WebCore/editing/atk/FrameSelectionAtk.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebCore/editing/atk/FrameSelectionAtk.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -35,7 +35,7 @@
 
 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 @@
     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);
         }
     }
 

Modified: trunk/Source/WebKit/ChangeLog (243927 => 243928)


--- trunk/Source/WebKit/ChangeLog	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebKit/ChangeLog	2019-04-05 07:35:24 UTC (rev 243928)
@@ -1,3 +1,14 @@
+2019-04-05  Carlos Garcia Campos  <cgar...@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.fra...@apple.com>
 
         Simple iframe scrolling test fails to get a composited scrolling frame in WebKitTestRunnerApp

Modified: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp (243927 => 243928)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	2019-04-05 06:42:05 UTC (rev 243927)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	2019-04-05 07:35:24 UTC (rev 243928)
@@ -69,11 +69,7 @@
     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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to