Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WPE] Introduce USE(ATK) #26110

Merged
merged 1 commit into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions Source/WebKit/PlatformWPE.cmake
Expand Up @@ -418,21 +418,29 @@ list(APPEND WebKit_PRIVATE_INCLUDE_DIRECTORIES
)

list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
${GIO_UNIX_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
)

list(APPEND WebKit_LIBRARIES
ATK::Bridge
WPE::libwpe
${ATK_LIBRARIES}
${GLIB_LIBRARIES}
${GLIB_GMODULE_LIBRARIES}
${LIBSOUP_LIBRARIES}
)

if (USE_ATK)
list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
)

list(APPEND WebKit_LIBRARIES
ATK::Bridge
${ATK_LIBRARIES}
)
endif ()

if (USE_CAIRO)
list(APPEND WebKit_LIBRARIES
Cairo::Cairo
Expand Down
Expand Up @@ -20,7 +20,7 @@
#include "config.h"
#include "WebKitWebViewAccessible.h"

#if !USE(GTK4)
#if USE(ATK)

#include <wtf/glib/WTFGType.h>

Expand Down Expand Up @@ -113,4 +113,4 @@ void webkitWebViewAccessibleSetWebView(WebKitWebViewAccessible* accessible, gpoi
atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_DEFUNCT, FALSE);
}

#endif // !USE(GTK4)
#endif // USE(ATK)
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/API/glib/WebKitWebViewAccessible.h
Expand Up @@ -19,7 +19,7 @@

#pragma once

#if !USE(GTK4)
#if USE(ATK)

#include <atk/atk.h>

Expand Down Expand Up @@ -53,4 +53,4 @@ void webkitWebViewAccessibleSetWebView(WebKitWebViewAccessible*, gpointer);

G_END_DECLS

#endif // !USE(GTK4)
#endif // USE(ATK)
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp
Expand Up @@ -40,7 +40,10 @@
#include <WebCore/Cursor.h>
#include <WebCore/DOMPasteAccess.h>
#include <WebCore/NotImplemented.h>

#if USE(ATK)
#include <atk/atk.h>
#endif

namespace WebKit {

Expand Down Expand Up @@ -435,10 +438,12 @@ void PageClientImpl::requestDOMPasteAccess(WebCore::DOMPasteAccessCategory, cons
completionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
}

#if USE(ATK)
AtkObject* PageClientImpl::accessible()
{
return ATK_OBJECT(m_view.accessible());
}
#endif

void PageClientImpl::didChangeWebPageID() const
{
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/PageClientImpl.h
Expand Up @@ -62,7 +62,9 @@ class PageClientImpl final : public PageClient
WPEView* wpeView() const;
#endif

#if USE(ATK)
AtkObject* accessible();
#endif

void sendMessageToWebView(UserMessage&&, CompletionHandler<void(UserMessage&&)>&&);
void setInputMethodState(std::optional<InputMethodState>&&);
Expand Down
9 changes: 9 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/WPEWebView.cpp
Expand Up @@ -297,8 +297,13 @@ View::View(struct wpe_view_backend* backend, WPEDisplay* display, const API::Pag
// get_accessible
[](void* data) -> void*
{
#if USE(ATK)
auto& view = *reinterpret_cast<View*>(data);
return view.accessible();
#else
UNUSED_PARAM(data);
return nullptr;
#endif
},
// set_device_scale_factor
[](void* data, float scale)
Expand Down Expand Up @@ -510,8 +515,10 @@ View::~View()
m_backingStore = nullptr;
#endif

#if USE(ATK)
if (m_accessible)
webkitWebViewAccessibleSetWebView(m_accessible.get(), nullptr);
#endif
}

void View::setClient(std::unique_ptr<API::ViewClient>&& client)
Expand Down Expand Up @@ -742,12 +749,14 @@ bool View::setFullScreen(bool fullScreenState)
};
#endif

#if USE(ATK)
WebKitWebViewAccessible* View::accessible() const
{
if (!m_accessible)
m_accessible = webkitWebViewAccessibleNew(const_cast<View*>(this));
return m_accessible.get();
}
#endif

#if ENABLE(GAMEPAD)
WebKit::WebPageProxy* View::platformWebPageProxyForGamepadInput()
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/WPEWebView.h
Expand Up @@ -129,7 +129,9 @@ class View : public API::ObjectImpl<API::Object::Type::View> {
bool setFullScreen(bool);
#endif

#if USE(ATK)
WebKitWebViewAccessible* accessible() const;
#endif

#if ENABLE(TOUCH_EVENTS)
WebKit::TouchGestureController& touchGestureController() const { return *m_touchGestureController; }
Expand Down Expand Up @@ -194,7 +196,9 @@ class View : public API::ObjectImpl<API::Object::Type::View> {
#endif
#endif

#if USE(ATK)
mutable GRefPtr<WebKitWebViewAccessible> m_accessible;
#endif

bool m_horizontalScrollActive { false };
bool m_verticalScrollActive { false };
Expand Down
7 changes: 7 additions & 0 deletions Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp
Expand Up @@ -30,7 +30,10 @@
#include "InputMethodState.h"
#include "PageClientImpl.h"
#include <WebCore/PlatformEvent.h>

#if USE(ATK)
#include <atk/atk.h>
#endif

#if ENABLE(WPE_PLATFORM)
#include <wpe/wpe-platform.h>
Expand Down Expand Up @@ -65,9 +68,13 @@ WPEView* WebPageProxy::wpeView() const

void WebPageProxy::bindAccessibilityTree(const String& plugID)
{
#if USE(ATK)
auto* accessible = static_cast<PageClientImpl&>(pageClient()).accessible();
atk_socket_embed(ATK_SOCKET(accessible), const_cast<char*>(plugID.utf8().data()));
atk_object_notify_state_change(accessible, ATK_STATE_TRANSIENT, FALSE);
#else
UNUSED_PARAM(plugID);
#endif
}

void WebPageProxy::didUpdateEditorState(const EditorState&, const EditorState& newEditorState)
Expand Down
4 changes: 4 additions & 0 deletions Source/cmake/OptionsGTK.cmake
Expand Up @@ -256,6 +256,10 @@ if (NOT EXISTS "${TOOLS_DIR}/glib/apply-build-revision-to-files.py")
set(BUILD_REVISION "tarball")
endif ()

if (NOT USE_GTK4)
SET_AND_EXPOSE_TO_BUILD(USE_ATK 1)
endif ()

SET_AND_EXPOSE_TO_BUILD(USE_ATSPI 1)
SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTK_UNIX_PRINT_FOUND})
SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)
Expand Down
14 changes: 12 additions & 2 deletions Source/cmake/OptionsWPE.cmake
Expand Up @@ -11,8 +11,6 @@ endif ()

set(USER_AGENT_BRANDING "" CACHE STRING "Branding to add to user agent string")

find_package(ATK 2.16.0 REQUIRED)
find_package(ATKBridge REQUIRED)
find_package(HarfBuzz 1.4.2 REQUIRED COMPONENTS ICU)
find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
find_package(JPEG REQUIRED)
Expand Down Expand Up @@ -97,6 +95,7 @@ WEBKIT_OPTION_DEFINE(ENABLE_WPE_PLATFORM_HEADLESS "Whether to enable support for
WEBKIT_OPTION_DEFINE(ENABLE_WPE_PLATFORM_WAYLAND "Whether to enable support for Wayland platform" PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC ${ENABLE_DEVELOPER_MODE})
WEBKIT_OPTION_DEFINE(ENABLE_WPE_1_1_API "Whether to build WPE 1.1 instead of WPE 2.0" PUBLIC OFF)
WEBKIT_OPTION_DEFINE(USE_ATK "Whether to enable usage of ATK." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_GBM "Whether to enable usage of GBM." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBBACKTRACE "Whether to enable usage of libbacktrace." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBDRM "Whether to enable usage of libdrm." PUBLIC ON)
Expand Down Expand Up @@ -211,6 +210,17 @@ set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "Absolute path to
set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "Absolute path to executable installation directory")
set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/wpe-webkit-${WPE_API_VERSION}" CACHE PATH "Absolute path to install executables executed by the library")

if (USE_ATK)
find_package(ATK 2.16.0)
if (NOT ATK_FOUND)
message(FATAL_ERROR "atk is required for USE_ATK")
endif ()
find_package(ATKBridge)
if (NOT ATKBridge_FOUND)
message(FATAL_ERROR "atk-bridge is required for USE_ATK")
endif ()
endif ()

if (ENABLE_GAMEPAD AND (NOT (WPE_VERSION VERSION_GREATER_EQUAL 1.13.90)))
message(FATAL_ERROR "libwpe>=1.13.90 is required for ENABLE_GAMEPAD")
endif ()
Expand Down
12 changes: 10 additions & 2 deletions Tools/MiniBrowser/wpe/CMakeLists.txt
Expand Up @@ -11,18 +11,26 @@ set(MiniBrowser_PRIVATE_INCLUDE_DIRECTORIES
)

set(MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
)

set(MiniBrowser_PRIVATE_LIBRARIES
${ATK_LIBRARIES}
${JavaScriptCore_LIBRARY_NAME}
WebKit::WPEToolingBackends
WebKit::WebKit
)

if (USE_ATK)
list(APPEND MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
)

list(APPEND MiniBrowser_PRIVATE_LIBRARIES
${ATK_LIBRARIES}
)
endif ()

if (ENABLE_WPE_PLATFORM)
list(APPEND MiniBrowser_PRIVATE_INCLUDE_DIRECTORIES
${WPEPlatform_DERIVED_SOURCES_DIR}
Expand Down
7 changes: 6 additions & 1 deletion Tools/MiniBrowser/wpe/main.cpp
Expand Up @@ -28,10 +28,13 @@
#include "BuildRevision.h"
#include <WPEToolingBackends/HeadlessViewBackend.h>
#include <WPEToolingBackends/WindowViewBackend.h>
#include <atk/atk.h>
#include <memory>
#include <wpe/webkit.h>

#if USE_ATK
#include <atk/atk.h>
#endif

#if !USE_GSTREAMER_FULL && (ENABLE_WEB_AUDIO || ENABLE_VIDEO)
#include <gst/gst.h>
#endif
Expand Down Expand Up @@ -414,9 +417,11 @@ static void activate(GApplication* application, WPEToolingBackends::ViewBackend*

if (backend) {
backend->setInputClient(std::make_unique<InputClient>(application, webView));
#if USE_ATK
auto* accessible = wpe_view_backend_dispatch_get_accessible(backend->backend());
if (ATK_IS_OBJECT(accessible))
backend->setAccessibleChild(ATK_OBJECT(accessible));
#endif
}

#if ENABLE_WPE_PLATFORM
Expand Down
32 changes: 24 additions & 8 deletions Tools/wpe/backends/PlatformWPE.cmake
Expand Up @@ -13,35 +13,52 @@ list(APPEND WPEToolingBackends_SOURCES
${WPEToolingBackends_DERIVED_SOURCES_DIR}/xdg-shell-protocol.c
${WPEToolingBackends_DERIVED_SOURCES_DIR}/xdg-shell-unstable-v6-protocol.c

atk/ViewBackendAtk.cpp
atk/WebKitAccessibleApplication.cpp

fdo/HeadlessViewBackendFdo.cpp
fdo/WindowViewBackend.cpp
)

list(APPEND WPEToolingBackends_PRIVATE_INCLUDE_DIRECTORIES
${TOOLS_DIR}/wpe/backends/atk
${TOOLS_DIR}/wpe/backends/fdo
)

list(APPEND WPEToolingBackends_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${LIBEPOXY_INCLUDE_DIRS}
)

list(APPEND WPEToolingBackends_LIBRARIES
WPE::FDO
${ATK_LIBRARIES}
${GLIB_GOBJECT_LIBRARIES}
${GLIB_LIBRARIES}
${LIBEPOXY_LIBRARIES}
${LIBXKBCOMMON_LIBRARIES}
${WAYLAND_LIBRARIES}
)

list(APPEND WPEToolingBackends_DEFINITIONS USE_GLIB=1 USE_ATK=1)
list(APPEND WPEToolingBackends_DEFINITIONS USE_GLIB=1)

if (USE_ATK)
list(APPEND WPEToolingBackends_SOURCES
atk/ViewBackendAtk.cpp
atk/WebKitAccessibleApplication.cpp
)

list(APPEND WPEToolingBackends_PRIVATE_INCLUDE_DIRECTORIES
${TOOLS_DIR}/wpe/backends/atk
)

list(APPEND WPEToolingBackends_SYSTEM_INCLUDE_DIRECTORIES
${ATK_INCLUDE_DIRS}
)

list(APPEND WPEToolingBackends_LIBRARIES
ATK::Bridge
${ATK_LIBRARIES}
)

list(APPEND WPEToolingBackends_DEFINITIONS USE_ATK=1)
endif ()

list(APPEND WPEToolingBackends_PRIVATE_DEFINITIONS ${LIBEPOXY_DEFINITIONS})

add_custom_command(
Expand Down Expand Up @@ -76,4 +93,3 @@ list(APPEND WPEToolingBackends_PRIVATE_DEFINITIONS WPE_BACKEND="libWPEBackend-fd
list(APPEND WPEToolingBackends_PRIVATE_DEFINITIONS
GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40
)
list(APPEND WPEToolingBackends_LIBRARIES ATK::Bridge)
14 changes: 14 additions & 0 deletions Tools/wpe/backends/ViewBackend.cpp
Expand Up @@ -85,4 +85,18 @@ void ViewBackend::dispatchInputTouchEvent(struct wpe_input_touch_event* event)
wpe_view_backend_dispatch_touch_event(backend(), event);
}

#if ((defined(USE_GLIB) && USE_GLIB) && !(defined(USE_ATK) && USE_ATK))
void ViewBackend::initializeAccessibility()
{
}

void ViewBackend::updateAccessibilityState(uint32_t)
{
}

void ViewBackend::notifyAccessibilityKeyEventListeners(struct wpe_input_keyboard_event*)
{
}
#endif

} // namespace WPEToolingBackends
4 changes: 4 additions & 0 deletions Tools/wpe/backends/atk/ViewBackendAtk.cpp
Expand Up @@ -25,6 +25,8 @@

#include "ViewBackend.h"

#if defined(USE_ATK) && USE_ATK

#include "WebKitAccessibleApplication.h"
#include <atk-bridge.h>
#include <atk/atk.h>
Expand Down Expand Up @@ -182,3 +184,5 @@ void ViewBackend::setAccessibleChild(AtkObject* child)
}

} // namespace WPEToolingBackends

#endif
4 changes: 4 additions & 0 deletions Tools/wpe/backends/atk/WebKitAccessibleApplication.cpp
Expand Up @@ -25,6 +25,8 @@

#include "WebKitAccessibleApplication.h"

#if defined(USE_ATK) && USE_ATK

struct _WebKitAccessibleApplicationPrivate {
AtkObject* child;
};
Expand Down Expand Up @@ -116,3 +118,5 @@ void webkitAccessibleApplicationSetChild(WebKitAccessibleApplication* accessible
g_signal_emit_by_name(accessible, "children-changed::add", 0, child);
}
}

#endif