6#include <Ultralight/CAPI/CAPI_DOMElement.h>
71 other.handle_ =
nullptr;
83 ulDestroyDOMElementList(handle_);
84 handle_ = other.handle_;
85 other.handle_ =
nullptr;
100 size_t length()
const {
return ulDOMElementListGetLength(handle_); }
122 return Element::Adopt(ulDOMElementListGetElement(handle_, index));
176 ULDOMElementList
raw()
const {
return handle_; }
184 ULDOMElementList handle = handle_;
190 explicit ElementList(ULDOMElementList handle) : handle_(handle) {}
193 ULDOMElementList handle_ =
nullptr;
197 detail::CString s(selectors);
204 return detail::EmptyHandleError();
205 detail::CString s(selectors);
206 detail::ErrorScope error;
207 ULDOMElementList result
208 = ulDOMElementQuerySelectorAll(
raw(), s.c_str(), error.out());
211 return Unexpected<Error>(error.TakeError());
215 ULDOMElementList result = ulDOMElementGetSelectedOptions(
raw());
220 ULDOMElementList result = ulDOMElementGetElements(
raw());
225 ULDOMElementList result = ulDOMElementGetChildren(
raw());
A handle to an element on a page.
Definition Element.h:142
static Element Adopt(ULDOMElement handle)
Wrap a C handle you own, taking ownership of it.
Definition Element.h:1987
ElementList querySelectorAll(std::string_view selectors) const
Find every element below this one that matches a CSS selector (querySelectorAll).
Definition ElementList.h:196
ElementList children() const
Get the element's child elements in order (children).
Definition ElementList.h:224
ULDOMElement raw() const
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMElement.h> functions.
Definition Element.h:2006
A forward iterator over the list's elements, so range-for works (for (dom::Element el : list)).
Definition ElementList.h:138
bool operator!=(const iterator &other) const
Definition ElementList.h:147
iterator(const ElementList *list, size_t index)
Definition ElementList.h:140
bool operator==(const iterator &other) const
Definition ElementList.h:148
iterator & operator++()
Definition ElementList.h:143
Element operator*() const
Definition ElementList.h:142
A fixed list of DOM elements returned by a query or an Element::children() call.
Definition ElementList.h:55
iterator begin() const
Definition ElementList.h:155
ElementList(const ElementList &)=delete
Element operator[](size_t index) const
Get the element at an index (the same as item()).
Definition ElementList.h:132
size_t size() const
Get the number of elements in the list (the same as length()).
Definition ElementList.h:107
static ElementList Adopt(ULDOMElementList handle)
Wrap a C handle you own, taking ownership of it.
Definition ElementList.h:168
~ElementList()
Destroy the list (elements you got from it aren't affected).
Definition ElementList.h:93
ULDOMElementList LeakRef()
Give up ownership of the C handle and return it.
Definition ElementList.h:183
bool empty() const
Whether or not the list has no elements (length() is 0).
Definition ElementList.h:112
ElementList(ULDOMElementList handle)
Definition ElementList.h:190
iterator end() const
Definition ElementList.h:156
size_t length() const
Get the number of elements in the list (length).
Definition ElementList.h:100
ElementList & operator=(const ElementList &)=delete
Element item(size_t index) const
Get the element at an index (item).
Definition ElementList.h:121
ElementList & operator=(ElementList &&other) noexcept
Move assignment (destroys the current list and other becomes empty).
Definition ElementList.h:81
ElementList()=default
Create an empty ElementList (length() is 0).
ULDOMElementList raw() const
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMElement.h> functions.
Definition ElementList.h:176
ElementList(ElementList &&other) noexcept
Move constructor (other becomes empty).
Definition ElementList.h:70
ElementList selectedOptions() const
Get the selected options in order (selectedOptions).
Definition ElementList.h:214
bool IsEmpty() const
Whether or not this Node is empty (it holds no handle).
Definition Node.h:216
Direct C++ access to modify page elements and handle events.
Expected< T, Error > Result
The result of a DOM operation that can fail (either a T or a dom::Error).
Definition Error.h:277
Root namespace for every public Ultralight type, function, and enumeration.
The type of dom::Checked.
Definition Error.h:282