docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
DOMRect.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
#pragma once
6
7
namespace
ultralight
{
8
namespace
dom
{
9
10
///
11
/// A rectangle in CSS pixels, relative to the viewport (DOMRect).
12
///
13
/// The coordinates are in the same space as event client positions and
14
/// Document::elementFromPoint().
15
///
16
/// \parblock
17
/// @note For an element in a subframe, the viewport is that frame's own viewport.
18
/// \endparblock
19
///
20
/// \parblock
21
/// @note CSS pixels are device pixels divided by the View's device scale.
22
/// \endparblock
23
///
24
/// @see Element::getBoundingClientRect(), Range::getBoundingClientRect()
25
///
26
struct
DOMRect
{
27
double
x
= 0;
///< The horizontal position.
28
double
y
= 0;
///< The vertical position.
29
double
width
= 0;
///< The width (can be negative).
30
double
height
= 0;
///< The height (can be negative).
31
32
///
33
/// Get the left edge (left). This is `x` unless the width is negative.
34
///
35
double
left
()
const
{
return
width
>= 0 ?
x
:
x
+
width
; }
36
37
///
38
/// Get the top edge (top). This is `y` unless the height is negative.
39
///
40
double
top
()
const
{
return
height
>= 0 ?
y
:
y
+
height
; }
41
42
///
43
/// Get the right edge (right).
44
///
45
double
right
()
const
{
return
width
>= 0 ?
x
+
width
:
x
; }
46
47
///
48
/// Get the bottom edge (bottom).
49
///
50
double
bottom
()
const
{
return
height
>= 0 ?
y
+
height
:
y
; }
51
};
52
53
}
// namespace dom
54
}
// namespace ultralight
ultralight::dom
Direct C++ access to modify page elements and handle events.
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
ultralight::dom::DOMRect
A rectangle in CSS pixels, relative to the viewport (DOMRect).
Definition
DOMRect.h:26
ultralight::dom::DOMRect::top
double top() const
Get the top edge (top).
Definition
DOMRect.h:40
ultralight::dom::DOMRect::left
double left() const
Get the left edge (left).
Definition
DOMRect.h:35
ultralight::dom::DOMRect::bottom
double bottom() const
Get the bottom edge (bottom).
Definition
DOMRect.h:50
ultralight::dom::DOMRect::height
double height
The height (can be negative).
Definition
DOMRect.h:30
ultralight::dom::DOMRect::width
double width
The width (can be negative).
Definition
DOMRect.h:29
ultralight::dom::DOMRect::right
double right() const
Get the right edge (right).
Definition
DOMRect.h:45
ultralight::dom::DOMRect::y
double y
The vertical position.
Definition
DOMRect.h:28
ultralight::dom::DOMRect::x
double x
The horizontal position.
Definition
DOMRect.h:27
Ultralight
dom
DOMRect.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4