Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwasmdom.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qwasmdom.h"
5
6#include <QMimeData>
7#include <QtCore/qpoint.h>
8#include <QtCore/qrect.h>
9#include <QtGui/qimage.h>
10#include <private/qstdweb_p.h>
11
12#include <utility>
13
15
16namespace dom {
17
18void syncCSSClassWith(emscripten::val element, std::string cssClassName, bool flag)
19{
20 if (flag) {
21 element["classList"].call<void>("add", emscripten::val(std::move(cssClassName)));
22 return;
23 }
24
25 element["classList"].call<void>("remove", emscripten::val(std::move(cssClassName)));
26}
27
28QPointF mapPoint(emscripten::val source, emscripten::val target, const QPointF &point)
29{
30 const auto sourceBoundingRect =
31 QRectF::fromDOMRect(source.call<emscripten::val>("getBoundingClientRect"));
32 const auto targetBoundingRect =
33 QRectF::fromDOMRect(target.call<emscripten::val>("getBoundingClientRect"));
34
35 const auto offset = sourceBoundingRect.topLeft() - targetBoundingRect.topLeft();
36 return point + offset;
37}
38
39} // namespace dom
40
\inmodule QtCore\reentrant
Definition qpoint.h:214
Combined button and popup list for selecting options.
void syncCSSClassWith(emscripten::val element, std::string cssClassName, bool flag)
Definition qwasmdom.cpp:18
QPointF mapPoint(emscripten::val source, emscripten::val target, const QPointF &point)
Definition qwasmdom.cpp:28
GLenum target
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source