Title: [243863] trunk
Revision
243863
Author
[email protected]
Date
2019-04-03 22:52:44 -0700 (Wed, 03 Apr 2019)

Log Message

[ATK] Cleanup WebPageAccessibilityObjectAtk
https://bugs.webkit.org/show_bug.cgi?id=196537

Reviewed by Michael Catanzaro.

Source/WebKit:

Several changes and cleanups:

 - Add WebKit prefix so that style checker doesn't complain about GObject conventions.
 - Rename the header to remove the Atk prefix to match the cpp file and class name.
 - Use pragma once.
 - Use nullptr instead of 0.
 - Use WEBKIT_DEFINE_TYPE instead of G_DEFINE_TYPE.
 - Return generic AtkObject* from constructor.

* SourcesGTK.txt:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp: Renamed from Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp.
(accessibilityRootObjectWrapper):
(webkitWebPageAccessibilityObjectInitialize):
(webkitWebPageAccessibilityObjectGetIndexInParent):
(webkitWebPageAccessibilityObjectGetNChildren):
(webkitWebPageAccessibilityObjectRefChild):
(webkit_web_page_accessibility_object_class_init):
(webkitWebPageAccessibilityObjectNew):
(webkitWebPageAccessibilityObjectRefresh):
* WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h: Added.
* WebProcess/WebPage/atk/WebPageAccessibilityObject.h: Removed.
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::platformInitialize):
(WebKit::WebPage::updateAccessibilityTree):

Tools:

Also consider files under atk directories as exceptions for GObject conventions.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_identifier_name_in_declaration):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243862 => 243863)


--- trunk/Source/WebKit/ChangeLog	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/ChangeLog	2019-04-04 05:52:44 UTC (rev 243863)
@@ -1,5 +1,38 @@
 2019-04-03  Carlos Garcia Campos  <[email protected]>
 
+        [ATK] Cleanup WebPageAccessibilityObjectAtk
+        https://bugs.webkit.org/show_bug.cgi?id=196537
+
+        Reviewed by Michael Catanzaro.
+
+        Several changes and cleanups:
+
+         - Add WebKit prefix so that style checker doesn't complain about GObject conventions.
+         - Rename the header to remove the Atk prefix to match the cpp file and class name.
+         - Use pragma once.
+         - Use nullptr instead of 0.
+         - Use WEBKIT_DEFINE_TYPE instead of G_DEFINE_TYPE.
+         - Return generic AtkObject* from constructor.
+
+        * SourcesGTK.txt:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp: Renamed from Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp.
+        (accessibilityRootObjectWrapper):
+        (webkitWebPageAccessibilityObjectInitialize):
+        (webkitWebPageAccessibilityObjectGetIndexInParent):
+        (webkitWebPageAccessibilityObjectGetNChildren):
+        (webkitWebPageAccessibilityObjectRefChild):
+        (webkit_web_page_accessibility_object_class_init):
+        (webkitWebPageAccessibilityObjectNew):
+        (webkitWebPageAccessibilityObjectRefresh):
+        * WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h: Added.
+        * WebProcess/WebPage/atk/WebPageAccessibilityObject.h: Removed.
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::platformInitialize):
+        (WebKit::WebPage::updateAccessibilityTree):
+
+2019-04-03  Carlos Garcia Campos  <[email protected]>
+
         [ATK] Set ATK_STATE_TRANSIENT on the atk socket until it's embedded
         https://bugs.webkit.org/show_bug.cgi?id=196535
 

Modified: trunk/Source/WebKit/SourcesGTK.txt (243862 => 243863)


--- trunk/Source/WebKit/SourcesGTK.txt	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/SourcesGTK.txt	2019-04-04 05:52:44 UTC (rev 243863)
@@ -410,7 +410,7 @@
 WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
 WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
 
-WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp
+WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp
 
 WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (243862 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-04 05:52:44 UTC (rev 243863)
@@ -85,7 +85,7 @@
 #include <wtf/text/WTFString.h>
 
 #if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
-#include "WebPageAccessibilityObject.h"
+typedef struct _AtkObject AtkObject;
 #include <wtf/glib/GRefPtr.h>
 #endif
 
@@ -1634,7 +1634,7 @@
 #endif
 
 #if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
-    GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
+    GRefPtr<AtkObject> m_accessibilityObject;
 #endif
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)

Copied: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp (from rev 243862, trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp) (0 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp	2019-04-04 05:52:44 UTC (rev 243863)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2012, 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebKitWebPageAccessibilityObject.h"
+
+#if HAVE(ACCESSIBILITY)
+
+#include "WebPage.h"
+#include <WebCore/AXObjectCache.h>
+#include <WebCore/Document.h>
+#include <WebCore/Frame.h>
+#include <WebCore/Page.h>
+#include <wtf/glib/WTFGType.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+struct _WebKitWebPageAccessibilityObjectPrivate {
+    WebPage* page;
+};
+
+WEBKIT_DEFINE_TYPE(WebKitWebPageAccessibilityObject, webkit_web_page_accessibility_object, ATK_TYPE_PLUG)
+
+static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject)
+{
+    if (!AXObjectCache::accessibilityEnabled())
+        AXObjectCache::enableAccessibility();
+
+    auto* accessible = WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject);
+    if (!accessible->priv->page)
+        return nullptr;
+
+    Page* corePage = accessible->priv->page->corePage();
+    if (!corePage)
+        return nullptr;
+
+    Frame& coreFrame = corePage->mainFrame();
+    if (!coreFrame.document())
+        return nullptr;
+
+    AXObjectCache* cache = coreFrame.document()->axObjectCache();
+    if (!cache)
+        return nullptr;
+
+    AccessibilityObject* coreRootObject = cache->rootObject();
+    if (!coreRootObject)
+        return nullptr;
+
+    AtkObject* rootObject = coreRootObject->wrapper();
+    if (!rootObject || !ATK_IS_OBJECT(rootObject))
+        return nullptr;
+
+    return rootObject;
+}
+
+static void webkitWebPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data)
+{
+    if (ATK_OBJECT_CLASS(webkit_web_page_accessibility_object_parent_class)->initialize)
+        ATK_OBJECT_CLASS(webkit_web_page_accessibility_object_parent_class)->initialize(atkObject, data);
+
+    WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject)->priv->page = reinterpret_cast<WebPage*>(data);
+    atk_object_set_role(atkObject, ATK_ROLE_FILLER);
+}
+
+static gint webkitWebPageAccessibilityObjectGetIndexInParent(AtkObject*)
+{
+    // An AtkPlug is the only child an AtkSocket can have.
+    return 0;
+}
+
+static gint webkitWebPageAccessibilityObjectGetNChildren(AtkObject* atkObject)
+{
+    return accessibilityRootObjectWrapper(atkObject) ? 1 : 0;
+}
+
+static AtkObject* webkitWebPageAccessibilityObjectRefChild(AtkObject* atkObject, gint index)
+{
+    // It's supposed to have either one child or zero.
+    if (index && index != 1)
+        return nullptr;
+
+    AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
+    if (!rootObject)
+        return nullptr;
+
+    atk_object_set_parent(rootObject, atkObject);
+    g_object_ref(rootObject);
+
+    return rootObject;
+}
+
+static void webkit_web_page_accessibility_object_class_init(WebKitWebPageAccessibilityObjectClass* klass)
+{
+    AtkObjectClass* atkObjectClass = ATK_OBJECT_CLASS(klass);
+    // No need to implement get_parent() here since this is a subclass
+    // of AtkPlug and all the logic related to that function will be
+    // implemented by the ATK bridge.
+    atkObjectClass->initialize = webkitWebPageAccessibilityObjectInitialize;
+    atkObjectClass->get_index_in_parent = webkitWebPageAccessibilityObjectGetIndexInParent;
+    atkObjectClass->get_n_children = webkitWebPageAccessibilityObjectGetNChildren;
+    atkObjectClass->ref_child = webkitWebPageAccessibilityObjectRefChild;
+}
+
+AtkObject* webkitWebPageAccessibilityObjectNew(WebPage* page)
+{
+    AtkObject* object = ATK_OBJECT(g_object_new(WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT, nullptr));
+    atk_object_initialize(object, page);
+    return object;
+}
+
+void webkitWebPageAccessibilityObjectRefresh(WebKitWebPageAccessibilityObject* accessible)
+{
+    // We just need to ensure that there's a connection in the ATK
+    // world between this accessibility object and the AtkObject of
+    // the accessibility object for the root of the DOM tree.
+    if (auto* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible)))
+        atk_object_set_parent(rootObject, ATK_OBJECT(accessible));
+}
+
+#endif // HAVE(ACCESSIBILITY)

Added: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h (0 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h	2019-04-04 05:52:44 UTC (rev 243863)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012, 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if HAVE(ACCESSIBILITY)
+
+#include <atk/atk.h>
+
+namespace WebKit {
+class WebPage;
+}
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT              (webkit_web_page_accessibility_object_get_type())
+#define WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT, WebKitWebPageAccessibilityObject))
+#define WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT, WebKitWebPageAccessibilityObjectClass))
+#define WEBKIT_IS_WEB_PAGE_ACCESSIBILITY_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT))
+#define WEBKIT_IS_WEB_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT))
+#define WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT, WebKitWebPageAccessibilityObjectClass))
+
+typedef struct _WebKitWebPageAccessibilityObject WebKitWebPageAccessibilityObject;
+typedef struct _WebKitWebPageAccessibilityObjectClass WebKitWebPageAccessibilityObjectClass;
+typedef struct _WebKitWebPageAccessibilityObjectPrivate WebKitWebPageAccessibilityObjectPrivate;
+
+struct _WebKitWebPageAccessibilityObject {
+    AtkPlug parent;
+
+    WebKitWebPageAccessibilityObjectPrivate* priv;
+};
+
+struct _WebKitWebPageAccessibilityObjectClass {
+    AtkPlugClass parentClass;
+};
+
+GType webkit_web_page_accessibility_object_get_type();
+
+AtkObject* webkitWebPageAccessibilityObjectNew(WebKit::WebPage*);
+
+void webkitWebPageAccessibilityObjectRefresh(WebKitWebPageAccessibilityObject*);
+
+G_END_DECLS
+
+#endif // HAVE(ACCESSIBILITY)

Deleted: trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObject.h (243862 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObject.h	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObject.h	2019-04-04 05:52:44 UTC (rev 243863)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2012 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebPageAccessibilityObject_h
-#define WebPageAccessibilityObject_h
-
-#if HAVE(ACCESSIBILITY)
-
-#include <atk/atk.h>
-
-namespace WebKit {
-class WebPage;
-}
-
-G_BEGIN_DECLS
-
-#define WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT              (web_page_accessibility_object_get_type())
-#define WEB_PAGE_ACCESSIBILITY_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObject))
-#define WEB_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObjectClass))
-#define WEB_IS_PAGE_ACCESSIBILITY_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT))
-#define WEB_IS_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT))
-#define WEB_PAGE_ACCESSIBILITY_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObjectClass))
-
-typedef struct _WebPageAccessibilityObject WebPageAccessibilityObject;
-typedef struct _WebPageAccessibilityObjectClass WebPageAccessibilityObjectClass;
-
-struct _WebPageAccessibilityObject {
-    AtkPlug parent;
-    WebKit::WebPage* m_page;
-};
-
-struct _WebPageAccessibilityObjectClass {
-    AtkPlugClass parentClass;
-};
-
-GType web_page_accessibility_object_get_type();
-
-WebPageAccessibilityObject* webPageAccessibilityObjectNew(WebKit::WebPage*);
-
-void webPageAccessibilityObjectRefresh(WebPageAccessibilityObject*);
-
-G_END_DECLS
-
-#endif
-#endif // WebPageAccessibilityObject_h

Deleted: trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp (243862 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp	2019-04-04 05:52:44 UTC (rev 243863)
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebPageAccessibilityObject.h"
-
-#if HAVE(ACCESSIBILITY)
-
-#include "WebPage.h"
-#include <WebCore/AXObjectCache.h>
-#include <WebCore/Document.h>
-#include <WebCore/Frame.h>
-#include <WebCore/Page.h>
-
-using namespace WebKit;
-using namespace WebCore;
-
-G_DEFINE_TYPE(WebPageAccessibilityObject, web_page_accessibility_object, ATK_TYPE_PLUG)
-
-static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject)
-{
-    if (!AXObjectCache::accessibilityEnabled())
-        AXObjectCache::enableAccessibility();
-
-    WebPageAccessibilityObject* accessible = WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject);
-    if (!accessible->m_page)
-        return 0;
-
-    Page* corePage = accessible->m_page->corePage();
-    if (!corePage)
-        return 0;
-
-    Frame& coreFrame = corePage->mainFrame();
-    if (!coreFrame.document())
-        return 0;
-
-    AXObjectCache* cache = coreFrame.document()->axObjectCache();
-    if (!cache)
-        return nullptr;
-
-    AccessibilityObject* coreRootObject = cache->rootObject();
-    if (!coreRootObject)
-        return 0;
-
-    AtkObject* rootObject = coreRootObject->wrapper();
-    if (!rootObject || !ATK_IS_OBJECT(rootObject))
-        return 0;
-
-    return rootObject;
-}
-
-static void webPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data)
-{
-    if (ATK_OBJECT_CLASS(web_page_accessibility_object_parent_class)->initialize)
-        ATK_OBJECT_CLASS(web_page_accessibility_object_parent_class)->initialize(atkObject, data);
-
-    WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject)->m_page = reinterpret_cast<WebPage*>(data);
-    atk_object_set_role(atkObject, ATK_ROLE_FILLER);
-}
-
-static gint webPageAccessibilityObjectGetIndexInParent(AtkObject*)
-{
-    // An AtkPlug is the only child an AtkSocket can have.
-    return 0;
-}
-
-static gint webPageAccessibilityObjectGetNChildren(AtkObject* atkObject)
-{
-    AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
-    if (!rootObject)
-        return 0;
-
-    return 1;
-}
-
-static AtkObject* webPageAccessibilityObjectRefChild(AtkObject* atkObject, gint index)
-{
-    // It's supposed to have either one child or zero.
-    if (index && index != 1)
-        return 0;
-
-    AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
-    if (!rootObject)
-        return 0;
-
-    atk_object_set_parent(rootObject, atkObject);
-    g_object_ref(rootObject);
-
-    return rootObject;
-}
-
-static void web_page_accessibility_object_init(WebPageAccessibilityObject*)
-{
-}
-
-static void web_page_accessibility_object_class_init(WebPageAccessibilityObjectClass* klass)
-{
-    AtkObjectClass* atkObjectClass = ATK_OBJECT_CLASS(klass);
-
-    // No need to implement get_parent() here since this is a subclass
-    // of AtkPlug and all the logic related to that function will be
-    // implemented by the ATK bridge.
-    atkObjectClass->initialize = webPageAccessibilityObjectInitialize;
-    atkObjectClass->get_index_in_parent = webPageAccessibilityObjectGetIndexInParent;
-    atkObjectClass->get_n_children = webPageAccessibilityObjectGetNChildren;
-    atkObjectClass->ref_child = webPageAccessibilityObjectRefChild;
-}
-
-WebPageAccessibilityObject* webPageAccessibilityObjectNew(WebPage* page)
-{
-    AtkObject* object = ATK_OBJECT(g_object_new(WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, NULL));
-    atk_object_initialize(object, page);
-    return WEB_PAGE_ACCESSIBILITY_OBJECT(object);
-}
-
-void webPageAccessibilityObjectRefresh(WebPageAccessibilityObject* accessible)
-{
-    // We just need to ensure that there's a connection in the ATK
-    // world between this accessibility object and the AtkObject of
-    // the accessibility object for the root of the DOM tree.
-    AtkObject* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible));
-    if (!rootObject)
-        return;
-    atk_object_set_parent(rootObject, ATK_OBJECT(accessible));
-}
-
-#endif

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (243862 => 243863)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2019-04-04 05:52:44 UTC (rev 243863)
@@ -31,7 +31,7 @@
 #include "EditorState.h"
 #include "WebEvent.h"
 #include "WebFrame.h"
-#include "WebPageAccessibilityObject.h"
+#include "WebKitWebPageAccessibilityObject.h"
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
 #include <WebCore/BackForwardController.h>
@@ -61,7 +61,7 @@
     // entry point to the Web process, and send a message to the UI
     // process to connect the two worlds through the accessibility
     // object there specifically placed for that purpose (the socket).
-    m_accessibilityObject = adoptGRef(webPageAccessibilityObjectNew(this));
+    m_accessibilityObject = adoptGRef(webkitWebPageAccessibilityObjectNew(this));
     GUniquePtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get())));
     send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
 #endif
@@ -117,7 +117,7 @@
     if (!m_accessibilityObject)
         return;
 
-    webPageAccessibilityObjectRefresh(m_accessibilityObject.get());
+    webkitWebPageAccessibilityObjectRefresh(WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(m_accessibilityObject.get()));
 }
 #endif
 

Modified: trunk/Tools/ChangeLog (243862 => 243863)


--- trunk/Tools/ChangeLog	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Tools/ChangeLog	2019-04-04 05:52:44 UTC (rev 243863)
@@ -1,3 +1,15 @@
+2019-04-03  Carlos Garcia Campos  <[email protected]>
+
+        [ATK] Cleanup WebPageAccessibilityObjectAtk
+        https://bugs.webkit.org/show_bug.cgi?id=196537
+
+        Reviewed by Michael Catanzaro.
+
+        Also consider files under atk directories as exceptions for GObject conventions.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_identifier_name_in_declaration):
+
 2019-04-03  Fujii Hironori  <[email protected]>
 
         The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (243862 => 243863)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2019-04-04 05:51:37 UTC (rev 243862)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2019-04-04 05:52:44 UTC (rev 243863)
@@ -3585,7 +3585,7 @@
         if not file_state.is_objective_c_or_objective_cpp() and modified_identifier.find('_') >= 0:
             # Various exceptions to the rule: _javascript_ op codes functions, const_iterator.
             if (not (filename.find('_javascript_Core') >= 0 and (modified_identifier.find('op_') >= 0 or modified_identifier.find('intrinsic_') >= 0))
-                and not (('gtk' in filename or 'glib' in filename or 'wpe' in filename) and modified_identifier.startswith('webkit_'))
+                and not (('gtk' in filename or 'glib' in filename or 'wpe' in filename or 'atk' in filename) and modified_identifier.startswith('webkit_'))
                 and not modified_identifier.startswith('tst_')
                 and not modified_identifier.startswith('webkit_dom_object_')
                 and not modified_identifier.startswith('webkit_soup')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to