wasm: Add DOM accessors functions through NativeInterface
Expose document and clientArea emscripten objects through NativeInterface. This is required by WebView implementation for wasm platform. Task-number: QTBUG-75183 Change-Id: I6f2f084a9dbceb80d2186c7395c008f268a91e39 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
This commit is contained in:
parent
a1f7fb73c2
commit
fb2fccc534
@ -371,6 +371,11 @@ qt_internal_extend_target(Gui CONDITION MACOS
|
||||
${FWAppKit}
|
||||
)
|
||||
|
||||
qt_internal_extend_target(Gui CONDITION WASM
|
||||
SOURCES
|
||||
platform/wasm/qwasmnativeinterface.cpp
|
||||
)
|
||||
|
||||
qt_internal_extend_target(Gui CONDITION APPLE
|
||||
SOURCES
|
||||
image/qimage_darwin.mm
|
||||
|
@ -41,6 +41,15 @@ public:
|
||||
|
||||
namespace QNativeInterface::Private {
|
||||
|
||||
#if defined(Q_OS_WASM) || defined(Q_QDOC)
|
||||
struct Q_GUI_EXPORT QWasmWindow
|
||||
{
|
||||
QT_DECLARE_NATIVE_INTERFACE(QWasmWindow, 1, QWindow)
|
||||
virtual emscripten::val document() const = 0;
|
||||
virtual emscripten::val clientArea() const = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(Q_QDOC)
|
||||
struct Q_GUI_EXPORT QCocoaWindow
|
||||
{
|
||||
|
@ -3065,6 +3065,10 @@ void *QWindow::resolveInterface(const char *name, int revision) const
|
||||
QT_NATIVE_INTERFACE_RETURN_IF(QWaylandWindow, platformWindow);
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WASM)
|
||||
QT_NATIVE_INTERFACE_RETURN_IF(QWasmWindow, platformWindow);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
17
src/gui/platform/wasm/qwasmnativeinterface.cpp
Normal file
17
src/gui/platform/wasm/qwasmnativeinterface.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <qpa/qplatformintegration.h>
|
||||
#include <qpa/qplatformwindow_p.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace QNativeInterface::Private;
|
||||
|
||||
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWasmWindow);
|
||||
|
||||
QT_END_NAMESPACE
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "qwasmintegration.h"
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <qpa/qplatformwindow_p.h>
|
||||
#include <emscripten/html5.h>
|
||||
#include "qwasmbackingstore.h"
|
||||
#include "qwasmscreen.h"
|
||||
@ -37,7 +38,7 @@ struct PointerEvent;
|
||||
class QWasmDeadKeySupport;
|
||||
struct WheelEvent;
|
||||
|
||||
class QWasmWindow final : public QPlatformWindow
|
||||
class QWasmWindow final : public QPlatformWindow, public QNativeInterface::Private::QWasmWindow
|
||||
{
|
||||
public:
|
||||
QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport, QWasmCompositor *compositor,
|
||||
@ -91,6 +92,10 @@ public:
|
||||
emscripten::val a11yContainer() const { return m_a11yContainer; }
|
||||
emscripten::val inputHandlerElement() const { return m_windowContents; }
|
||||
|
||||
// QNativeInterface::Private::QWasmWindow
|
||||
emscripten::val document() const override { return m_document; }
|
||||
emscripten::val clientArea() const override { return m_qtWindow; }
|
||||
|
||||
private:
|
||||
friend class QWasmScreen;
|
||||
static constexpr auto minSizeForRegularWindows = 100;
|
||||
|
Loading…
Reference in New Issue
Block a user