@@ -18,14 +18,111 @@ Gets a handle to the `<body>` element of the document.
1818webcc::DOMElement get_body ();
1919```
2020
21+ ### ` get_active_element `
22+
23+ Gets a handle to the currently focused element (` document.activeElement ` ).
24+ Returns an invalid handle (` -1 ` ) if no active element exists.
25+
26+ ``` cpp
27+ webcc::DOMElement get_active_element ();
28+ ```
29+
2130### ` get_element_by_id `
2231
2332Gets a handle to an element by its ID.
33+ Returns an invalid handle (` -1 ` ) if the element does not exist.
2434
2535``` cpp
2636webcc::DOMElement get_element_by_id (webcc::string_view id);
2737```
2838
39+ ### `get_parent_node`
40+
41+ Gets the parent element of a node.
42+ Returns an invalid handle (`-1`) if the node has no parent element.
43+
44+ ```cpp
45+ webcc::DOMElement get_parent_node(webcc::DOMElement node_handle);
46+ ```
47+
48+ ### ` is_connected `
49+
50+ Returns true if the node is currently connected to the document.
51+
52+ ``` cpp
53+ bool is_connected (webcc::DOMElement node_handle);
54+ ```
55+
56+ ### `is_valid`
57+
58+ Returns true if the handle currently refers to a valid DOM element.
59+ This is useful for checking results of selector-based APIs which can return `-1`.
60+
61+ ```cpp
62+ bool is_valid(webcc::DOMElement handle);
63+ ```
64+
65+ ### ` contains `
66+
67+ Returns true if ` container ` contains ` other ` in the DOM tree.
68+
69+ ``` cpp
70+ bool contains (webcc::DOMElement container_handle, webcc::DOMElement other_handle);
71+ ```
72+
73+ ### `query_selector`
74+
75+ Queries a descendant element using a CSS selector.
76+ Returns an invalid handle (`-1`) if nothing matches.
77+
78+ ```cpp
79+ webcc::DOMElement query_selector(webcc::DOMElement root_handle, webcc::string_view selector);
80+ ```
81+
82+ ### ` closest `
83+
84+ Returns the closest ancestor (including the node itself) that matches a selector.
85+ Returns an invalid handle (` -1 ` ) if nothing matches.
86+
87+ ``` cpp
88+ webcc::DOMElement closest (webcc::DOMElement node_handle, webcc::string_view selector);
89+ ```
90+
91+ ### `query_selector_all_count`
92+
93+ Returns the number of matches for a CSS selector under `root`.
94+
95+ ```cpp
96+ int32_t query_selector_all_count(webcc::DOMElement root_handle, webcc::string_view selector);
97+ ```
98+
99+ ### ` query_selector_all_fill `
100+
101+ Fills a contiguous range of handles with the results of ` querySelectorAll ` .
102+ Use ` webcc::reserve_deferred_handles(count) ` to reserve ` [start, start+count) ` and then convert
103+ entries back to ` webcc::DOMElement ` via ` webcc::DOMElement(start + i) ` .
104+
105+ ``` cpp
106+ void query_selector_all_fill (webcc::DOMElement root_handle, webcc::string_view selector, int32_t start, int32_t count);
107+ ```
108+
109+ ### `child_element_count`
110+
111+ Returns the number of element children of `root`.
112+
113+ ```cpp
114+ int32_t child_element_count(webcc::DOMElement root_handle);
115+ ```
116+
117+ ### ` child_element_fill `
118+
119+ Fills a contiguous range of handles with the element children of ` root ` .
120+ Use ` webcc::reserve_deferred_handles(count) ` to reserve ` [start, start+count) ` .
121+
122+ ``` cpp
123+ void child_element_fill (webcc::DOMElement root_handle, int32_t start, int32_t count);
124+ ```
125+
29126### `create_element`
30127
31128Creates a new HTML element with the specified tag name.
@@ -180,3 +277,9 @@ inline int32_t next_deferred_handle() {
180277 return counter++;
181278}
182279```
280+
281+ To reserve a contiguous range (useful for fill-style APIs):
282+
283+ ``` cpp
284+ inline int32_t reserve_deferred_handles (int32_t count);
285+ ```
0 commit comments