blob: 5c8fac59b0ec9fe18fa7c7ae349759bd28a88d6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright (C) 2022 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 <QtCore/qrect.h>
#include <emscripten/val.h>
#if !defined(Q_OS_WASM)
static_assert(false, "This is a wasm-only file.");
#endif // !defined(Q_OS_WASM)
QT_BEGIN_NAMESPACE
/*!
Converts the DOMRect (https://www.w3.org/TR/geometry-1/) \a domRect to QRectF. The behavior is
undefined if the provided parameter is not a DOMRect.
\since 6.5
\ingroup platform-type-conversions
\sa toDOMRect()
*/
QRectF QRectF::fromDOMRect(emscripten::val domRect)
{
Q_ASSERT_X(domRect["constructor"]["name"].as<std::string>() == "DOMRect", Q_FUNC_INFO,
"Passed object is not a DOMRect");
return QRectF(domRect["left"].as<qreal>(), domRect["top"].as<qreal>(),
domRect["width"].as<qreal>(), domRect["height"].as<qreal>());
}
/*!
Converts this object to a DOMRect (https://www.w3.org/TR/geometry-1/).
\since 6.5
\ingroup platform-type-conversions
\sa fromDOMRect()
*/
emscripten::val QRectF::toDOMRect() const
{
return emscripten::val::global("DOMRect").new_(left(), top(), width(), height());
}
QT_END_NAMESPACE
|