Skip to content

Commit

Permalink
Merge r243863 - [ATK] Cleanup WebPageAccessibilityObjectAtk
Browse files Browse the repository at this point in the history
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):
  • Loading branch information
carlosgcampos committed May 9, 2019
1 parent 25c9bc6 commit 4ff3d26
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 118 deletions.
33 changes: 33 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,36 @@
2019-04-03 Carlos Garcia Campos <cgarcia@igalia.com>

[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 <cgarcia@igalia.com>

[ATK] Embed the AtkSocket as soon as we receive the plug ID
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/SourcesGTK.txt
Expand Up @@ -406,7 +406,7 @@ WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
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

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/WebProcess/WebPage/WebPage.h
Expand Up @@ -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

Expand Down Expand Up @@ -1593,7 +1593,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
#endif

#if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
GRefPtr<AtkObject> m_accessibilityObject;
#endif

#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 Igalia S.L.
* 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
Expand All @@ -24,7 +24,7 @@
*/

#include "config.h"
#include "WebPageAccessibilityObject.h"
#include "WebKitWebPageAccessibilityObject.h"

#if HAVE(ACCESSIBILITY)

Expand All @@ -33,117 +33,111 @@
#include <WebCore/Document.h>
#include <WebCore/Frame.h>
#include <WebCore/Page.h>
#include <wtf/glib/WTFGType.h>

using namespace WebKit;
using namespace WebCore;

G_DEFINE_TYPE(WebPageAccessibilityObject, web_page_accessibility_object, ATK_TYPE_PLUG)
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();

WebPageAccessibilityObject* accessible = WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject);
if (!accessible->m_page)
return 0;
auto* accessible = WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject);
if (!accessible->priv->page)
return nullptr;

Page* corePage = accessible->m_page->corePage();
Page* corePage = accessible->priv->page->corePage();
if (!corePage)
return 0;
return nullptr;

Frame& coreFrame = corePage->mainFrame();
if (!coreFrame.document())
return 0;
return nullptr;

AXObjectCache* cache = coreFrame.document()->axObjectCache();
if (!cache)
return nullptr;

AccessibilityObject* coreRootObject = cache->rootObject();
if (!coreRootObject)
return 0;
return nullptr;

AtkObject* rootObject = coreRootObject->wrapper();
if (!rootObject || !ATK_IS_OBJECT(rootObject))
return 0;
return nullptr;

return rootObject;
}

static void webPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data)
static void webkitWebPageAccessibilityObjectInitialize(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);
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);

WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject)->m_page = reinterpret_cast<WebPage*>(data);
WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject)->priv->page = reinterpret_cast<WebPage*>(data);
atk_object_set_role(atkObject, ATK_ROLE_FILLER);
}

static gint webPageAccessibilityObjectGetIndexInParent(AtkObject*)
static gint webkitWebPageAccessibilityObjectGetIndexInParent(AtkObject*)
{
// An AtkPlug is the only child an AtkSocket can have.
return 0;
}

static gint webPageAccessibilityObjectGetNChildren(AtkObject* atkObject)
static gint webkitWebPageAccessibilityObjectGetNChildren(AtkObject* atkObject)
{
AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
if (!rootObject)
return 0;

return 1;
return accessibilityRootObjectWrapper(atkObject) ? 1 : 0;
}

static AtkObject* webPageAccessibilityObjectRefChild(AtkObject* atkObject, gint index)
static AtkObject* webkitWebPageAccessibilityObjectRefChild(AtkObject* atkObject, gint index)
{
// It's supposed to have either one child or zero.
if (index && index != 1)
return 0;
return nullptr;

AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
if (!rootObject)
return 0;
return nullptr;

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)
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 = webPageAccessibilityObjectInitialize;
atkObjectClass->get_index_in_parent = webPageAccessibilityObjectGetIndexInParent;
atkObjectClass->get_n_children = webPageAccessibilityObjectGetNChildren;
atkObjectClass->ref_child = webPageAccessibilityObjectRefChild;
atkObjectClass->initialize = webkitWebPageAccessibilityObjectInitialize;
atkObjectClass->get_index_in_parent = webkitWebPageAccessibilityObjectGetIndexInParent;
atkObjectClass->get_n_children = webkitWebPageAccessibilityObjectGetNChildren;
atkObjectClass->ref_child = webkitWebPageAccessibilityObjectRefChild;
}

WebPageAccessibilityObject* webPageAccessibilityObjectNew(WebPage* page)
AtkObject* webkitWebPageAccessibilityObjectNew(WebPage* page)
{
AtkObject* object = ATK_OBJECT(g_object_new(WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, NULL));
AtkObject* object = ATK_OBJECT(g_object_new(WEBKIT_TYPE_WEB_PAGE_ACCESSIBILITY_OBJECT, nullptr));
atk_object_initialize(object, page);
return WEB_PAGE_ACCESSIBILITY_OBJECT(object);
return object;
}

void webPageAccessibilityObjectRefresh(WebPageAccessibilityObject* accessible)
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.
AtkObject* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible));
if (!rootObject)
return;
atk_object_set_parent(rootObject, ATK_OBJECT(accessible));
if (auto* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible)))
atk_object_set_parent(rootObject, ATK_OBJECT(accessible));
}

#endif
#endif // HAVE(ACCESSIBILITY)
@@ -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)
67 changes: 0 additions & 67 deletions Source/WebKit/WebProcess/WebPage/atk/WebPageAccessibilityObject.h

This file was deleted.

6 changes: 3 additions & 3 deletions Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -61,7 +61,7 @@ void WebPage::platformInitialize()
// 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
Expand Down Expand Up @@ -113,7 +113,7 @@ void WebPage::updateAccessibilityTree()
if (!m_accessibilityObject)
return;

webPageAccessibilityObjectRefresh(m_accessibilityObject.get());
webkitWebPageAccessibilityObjectRefresh(WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(m_accessibilityObject.get()));
}
#endif

Expand Down

0 comments on commit 4ff3d26

Please sign in to comment.