7#pragma push_macro("None")
10#include <Ultralight/CAPI/CAPI_DOMElement.h>
11#include <Ultralight/CAPI/CAPI_DOMEvent.h>
20#include <Ultralight/dom/detail/Properties.h>
21#include <Ultralight/dom/detail/Receivers.h>
54inline Result<EventListener> CheckedDelegation(EventListener listener,
bool receiver_alive,
55 const AddEventListenerOptions& options,
56 std::string_view selector) {
57 if (listener.raw() || options.signal.aborted())
60 return Unexpected<Error>(Error::PageGone());
61 std::string message =
"'" + std::string(selector) +
"' is not a valid selector.";
63 error.out()->code = kULDOMErrorCode_SyntaxError;
64 error.out()->message = ulCreateStringUTF8(message.data(), message.size());
65 return Unexpected<Error>(error.TakeError());
267 detail::StringProp<detail::IdTag>
id;
278 detail::StringProp<detail::TitleTag>
title;
285 detail::BoolProp<detail::HiddenTag>
hidden;
306 detail::StringProp<detail::ValueTag>
value;
313 detail::StringProp<detail::NameTag>
name;
392 std::swap(
detail_.handle, other.detail_.handle);
411 detail::CString s(selectors);
412 return Element(ulDOMElementQuerySelector(
raw(), s.c_str(),
nullptr));
424 return detail::EmptyHandleError();
425 detail::CString s(selectors);
426 detail::ErrorScope error;
427 ULDOMElement result = ulDOMElementQuerySelector(
raw(), s.c_str(), error.out());
430 if (error.has_exception())
431 return Unexpected<Error>(error.TakeError());
469 bool matches(std::string_view selectors)
const {
470 detail::CString s(selectors);
471 return ulDOMElementMatches(
raw(), s.c_str(),
nullptr);
483 return detail::EmptyHandleError();
484 detail::CString s(selectors);
485 detail::ErrorScope error;
486 bool result = ulDOMElementMatches(
raw(), s.c_str(), error.out());
487 if (error.has_exception())
488 return Unexpected<Error>(error.TakeError());
504 detail::CString s(selectors);
505 return Element(ulDOMElementClosest(
raw(), s.c_str(),
nullptr));
517 return detail::EmptyHandleError();
518 detail::CString s(selectors);
519 detail::ErrorScope error;
520 ULDOMElement result = ulDOMElementClosest(
raw(), s.c_str(), error.out());
523 if (error.has_exception())
524 return Unexpected<Error>(error.TakeError());
541 detail::CString n(
name);
542 ULString s = ulDOMElementGetAttribute(
raw(), n.c_str());
545 return detail::TakeString(s);
554 detail::CString n(
name);
555 return ulDOMElementHasAttribute(
raw(), n.c_str());
569 detail::CString n(
name);
570 detail::CString v(new_value);
571 ulDOMElementSetAttribute(
raw(), n.c_str(), v.c_str(),
nullptr);
580 detail::CString n(
name);
581 ulDOMElementRemoveAttribute(
raw(), n.c_str());
593 detail::CString n(
name);
594 bool present =
false;
595 ulDOMElementToggleAttribute(
raw(), n.c_str(),
nullptr, &present,
nullptr);
610 detail::CString n(
name);
611 bool present =
false;
612 ulDOMElementToggleAttribute(
raw(), n.c_str(), &force, &present,
nullptr);
622 std::vector<std::string> names;
623 ULDOMStringList list = ulDOMElementGetAttributeNames(
raw());
626 size_t count = ulDOMStringListGetLength(list);
627 names.reserve(count);
628 for (
size_t i = 0; i < count; i++)
629 names.push_back(detail::TakeString(ulDOMStringListGetString(list, i)));
630 ulDestroyDOMStringList(list);
644 return ulDOMElementContains(
raw(), other.
raw());
677 return ulDOMElementAppendChild(
raw(), child.
raw(),
nullptr) ? child :
Element();
689 return detail::EmptyHandleError();
690 detail::ErrorScope error;
691 if (ulDOMElementAppendChild(
raw(), child.
raw(), error.out()))
693 return Unexpected<Error>(error.TakeError());
709 return ulDOMNodeAppendChild(
Node::raw(), child.
raw(),
nullptr) ? child :
Node();
721 return detail::EmptyHandleError();
722 detail::ErrorScope error;
723 if (ulDOMNodeAppendChild(
Node::raw(), child.
raw(), error.out()))
725 return Unexpected<Error>(error.TakeError());
766 template <
typename... T>
767 requires((detail::NodeOrString<T> && ...))
769 auto items = detail::NodeOrStringItems(std::forward<T>(nodes)...);
770 ulDOMElementAppend(
raw(), items.data(), items.size(),
nullptr);
782 template <
typename... T>
783 requires((detail::NodeOrString<T> && ...))
785 auto items = detail::NodeOrStringItems(std::forward<T>(nodes)...);
786 if (
IsEmpty() || detail::HasEmptyItem(items))
787 return detail::EmptyHandleError();
788 detail::ErrorScope error;
789 if (ulDOMElementAppend(
raw(), items.data(), items.size(), error.out()))
791 return Unexpected<Error>(error.TakeError());
805 template <
typename... T>
806 requires((detail::NodeOrString<T> && ...))
808 auto items = detail::NodeOrStringItems(std::forward<T>(nodes)...);
809 ulDOMElementPrepend(
raw(), items.data(), items.size(),
nullptr);
821 template <
typename... T>
822 requires((detail::NodeOrString<T> && ...))
824 auto items = detail::NodeOrStringItems(std::forward<T>(nodes)...);
825 if (
IsEmpty() || detail::HasEmptyItem(items))
826 return detail::EmptyHandleError();
827 detail::ErrorScope error;
828 if (ulDOMElementPrepend(
raw(), items.data(), items.size(), error.out()))
830 return Unexpected<Error>(error.TakeError());
845 template <
typename... T>
846 requires((detail::NodeOrString<T> && ...))
848 auto items = detail::NodeOrStringItems(std::forward<T>(new_children)...);
849 ulDOMElementReplaceChildren(
raw(), items.data(), items.size(),
nullptr);
865 template <
typename... T>
866 requires((detail::NodeOrString<T> && ...))
868 auto items = detail::NodeOrStringItems(std::forward<T>(new_children)...);
869 if (
IsEmpty() || detail::HasEmptyItem(items))
870 return detail::EmptyHandleError();
871 detail::ErrorScope error;
872 if (ulDOMElementReplaceChildren(
raw(), items.data(), items.size(), error.out()))
874 return Unexpected<Error>(error.TakeError());
889 return ulDOMElementInsertBefore(
raw(), child.
raw(), ref_child.
raw(),
nullptr) ? child
904 return detail::EmptyHandleError();
905 detail::ErrorScope error;
906 if (ulDOMElementInsertBefore(
raw(), child.
raw(),
907 ref_child.
raw(), error.out()))
909 return Unexpected<Error>(error.TakeError());
926 return ulDOMNodeInsertBefore(
Node::raw(), child.
raw(), ref_child.
raw(),
nullptr) ? child
941 return detail::EmptyHandleError();
942 detail::ErrorScope error;
943 if (ulDOMNodeInsertBefore(
Node::raw(), child.
raw(), ref_child.
raw(), error.out()))
945 return Unexpected<Error>(error.TakeError());
960 return ulDOMElementReplaceChild(
raw(), new_child.
raw(), old_child.
raw(),
nullptr)
976 return detail::EmptyHandleError();
977 detail::ErrorScope error;
978 if (ulDOMElementReplaceChild(
raw(), new_child.
raw(),
979 old_child.
raw(), error.out()))
981 return Unexpected<Error>(error.TakeError());
999 return ulDOMNodeReplaceChild(
Node::raw(), new_child.
raw(), old_child.
raw(),
nullptr)
1015 return detail::EmptyHandleError();
1016 detail::ErrorScope error;
1017 if (ulDOMNodeReplaceChild(
Node::raw(), new_child.
raw(), old_child.
raw(), error.out()))
1019 return Unexpected<Error>(error.TakeError());
1031 return ulDOMElementRemoveChild(
raw(), child.
raw(),
nullptr) ? child :
Element();
1043 return detail::EmptyHandleError();
1044 detail::ErrorScope error;
1045 if (ulDOMElementRemoveChild(
raw(), child.
raw(), error.out()))
1047 return Unexpected<Error>(error.TakeError());
1061 return ulDOMNodeRemoveChild(
Node::raw(), child.
raw(),
nullptr) ? child :
Node();
1073 return detail::EmptyHandleError();
1074 detail::ErrorScope error;
1075 if (ulDOMNodeRemoveChild(
Node::raw(), child.
raw(), error.out()))
1077 return Unexpected<Error>(error.TakeError());
1088 return Element(ulDOMElementCloneNode(
raw(), deep));
1104 detail::CString p(position);
1105 ulDOMElementInsertAdjacentHTML(
raw(), p.c_str(), html.data() ? html.data() :
"", html.size(),
1120 return detail::EmptyHandleError();
1121 detail::CString p(position);
1122 detail::ErrorScope error;
1123 if (ulDOMElementInsertAdjacentHTML(
raw(), p.c_str(),
1124 html.data() ? html.data() :
"", html.size(),
1127 return Unexpected<Error>(error.TakeError());
1143 detail::CString p(position);
1144 return Element(ulDOMElementInsertAdjacentElement(
raw(), p.c_str(), other.
raw(),
nullptr));
1159 return detail::EmptyHandleError();
1160 detail::CString p(position);
1161 detail::ErrorScope error;
1162 ULDOMElement result = ulDOMElementInsertAdjacentElement(
1163 raw(), p.c_str(), other.
raw(), error.out());
1166 if (error.has_exception())
1167 return Unexpected<Error>(error.TakeError());
1188 detail::CString p(position);
1189 ulDOMElementInsertAdjacentText(
raw(), p.c_str(), text.data() ? text.data() :
"", text.size(),
1205 return detail::EmptyHandleError();
1206 detail::CString p(position);
1207 detail::ErrorScope error;
1208 if (ulDOMElementInsertAdjacentText(
raw(), p.c_str(),
1209 text.data() ? text.data() :
"", text.size(),
1212 return Unexpected<Error>(error.TakeError());
1223 return detail::TakeString(ulDOMElementGetTagName(
raw()));
1239 return Element(ulDOMElementGetFirstElementChild(
raw()));
1248 return Element(ulDOMElementGetLastElementChild(
raw()));
1257 return Element(ulDOMElementGetNextElementSibling(
raw()));
1266 return Element(ulDOMElementGetPreviousElementSibling(
raw()));
1298 ULDOMRect r = ulDOMElementGetBoundingClientRect(
raw());
1299 return DOMRect { r.x, r.y, r.width, r.height };
1399 ulDOMElementScrollIntoView(
raw(), align_to_top);
1415 void scrollTo(
double x,
double y)
const { ulDOMElementScrollTo(
raw(), x, y); }
1426 void scrollBy(
double x,
double y)
const { ulDOMElementScrollBy(
raw(), x, y); }
1478 detail::CString t(type);
1479 return ulDOMElementDispatchEvent(
raw(), t.c_str(),
1480 detail::EventInitFlags(init),
nullptr);
1506 detail::CString t(type);
1507 detail::CString d(event_detail);
1508 return ulDOMElementDispatchCustomEvent(
raw(), t.c_str(),
1509 detail::EventInitFlags(init), d.c_str(),
1539 template <
typename F>
1542 using Fn = std::decay_t<F>;
1543 static_assert(detail::InvocableWithEvent<Fn> || std::is_invocable_v<Fn&>,
1544 "addEventListener takes a callable invocable with (dom::Event) or ()");
1545 detail::CString t(type);
1546 ULDOMEventCallback thunk = &detail::EventThunk<Fn>;
1547 ULUserDataDestroyCallback destroy = &detail::DeleteCallable<Fn>;
1548 return detail::AddListener<Fn>(std::forward<F>(callback), options,
1549 [&](
unsigned flags,
void* fn) {
1550 return ulDOMElementAddEventListener(
raw(), t.c_str(), flags,
1551 thunk, fn, destroy);
1567 template <
typename F>
1570 return addEventListener(type, std::forward<F>(callback), detail::ToOptions(flags));
1596 template <
typename C,
typename M>
1597 requires(std::is_class_v<C> && std::is_member_function_pointer_v<M>
1601 return addEventListener(type, detail::WrapBorrowedMember(receiver, method), options);
1622 template <
typename C,
typename M>
1623 requires(std::is_class_v<C> && std::is_member_function_pointer_v<M>
1624 && !LockableHolder<C>)
1627 return addEventListener(type, detail::WrapBorrowedMember(receiver, method), flags);
1648 template <
typename H,
typename M>
1652 return addEventListener(type, detail::WrapHolderMember(std::move(holder), method), options);
1670 template <
typename H,
typename M>
1671 requires(LockableHolder<H> && std::is_member_function_pointer_v<M>)
1674 return addEventListener(type, detail::WrapHolderMember(std::move(holder), method), flags);
1709 template <
typename F>
1712 using Fn = std::decay_t<F>;
1713 static_assert(detail::InvocableWithEvent<Fn, Element> || std::is_invocable_v<Fn&, Element>
1714 || std::is_invocable_v<Fn&>,
1715 "On takes a callable invocable with (dom::Event, dom::Element), "
1716 "(dom::Element), or ()");
1717 detail::CString sel(selector);
1718 detail::CString t(type);
1719 ULDOMDelegatedEventCallback thunk = &detail::DelegatedThunk<Fn>;
1720 ULUserDataDestroyCallback destroy = &detail::DeleteCallable<Fn>;
1721 return detail::AddListener<Fn>(std::forward<F>(callback), options,
1722 [&](
unsigned flags,
void* fn) {
1723 return ulDOMElementAddDelegatedEventListener(
1724 raw(), sel.c_str(), t.c_str(), flags, thunk, fn,
1744 template <
typename F>
1747 return On(selector, type, std::forward<F>(callback), detail::ToOptions(flags));
1766 template <
typename F>
1771 return detail::EmptyHandleError();
1772 return detail::CheckedDelegation(
On(selector, type, std::forward<F>(callback), options),
1773 IsAlive(), options, selector);
1789 template <
typename F>
1818 template <
typename C,
typename M>
1819 requires(std::is_class_v<C> && std::is_member_function_pointer_v<M>
1823 return On(selector, type, detail::WrapBorrowedMember(receiver, method), options);
1848 template <
typename C,
typename M>
1849 requires(std::is_class_v<C> && std::is_member_function_pointer_v<M>
1850 && !LockableHolder<C>)
1853 return On(selector, type, detail::WrapBorrowedMember(receiver, method), flags);
1878 template <
typename H,
typename M>
1882 return On(selector, type, detail::WrapHolderMember(std::move(holder), method), options);
1904 template <
typename H,
typename M>
1905 requires(LockableHolder<H> && std::is_member_function_pointer_v<M>)
1908 return On(selector, type, detail::WrapHolderMember(std::move(holder), method), flags);
1997 return Element(handle ? ulCreateDOMElementRef(handle) :
nullptr);
2006 ULDOMElement
raw()
const {
return reinterpret_cast<ULDOMElement
>(
detail_.handle); }
2019 :
Node(reinterpret_cast<ULDOMNode>(handle)) {}
2026 bool TagIs(
const char* upper_tag)
const {
2038static_assert(std::is_standard_layout_v<detail::StyleProxy>,
2039 "StyleProxy must stay standard-layout");
2040static_assert(!std::is_aggregate_v<Element>,
"Element must not be an aggregate");
2041static_assert(!std::is_aggregate_v<detail::StyleProxy>,
2042 "StyleProxy must not be an aggregate");
2043#if defined(__GNUC__)
2044#pragma GCC diagnostic push
2045#pragma GCC diagnostic ignored "-Winvalid-offsetof"
2047static_assert(offsetof(Element, style) ==
sizeof(Node),
2048 "the style proxy must stay the first member Element declares (directly "
2049 "after the Node base subobject)");
2050#if defined(__GNUC__)
2051#pragma GCC diagnostic pop
2103 ULDOMValidityState state;
2104 ulDOMElementGetValidity(element, &state);
2105 return ValidityState { state.value_missing, state.type_mismatch, state.pattern_mismatch,
2106 state.too_long, state.too_short, state.range_underflow,
2107 state.range_overflow, state.step_mismatch, state.bad_input,
2108 state.custom_error, state.valid };
2111inline const char* SelectionDirectionName(SelectionDirection direction) {
2112 switch (direction) {
2113 case SelectionDirection::Forward:
2115 case SelectionDirection::Backward:
2123 std::string name = TakeString(ulDOMElementGetSelectionDirection(h));
2124 if (name ==
"forward")
2125 return SelectionDirection::Forward;
2126 if (name ==
"backward")
2127 return SelectionDirection::Backward;
2128 return SelectionDirection::None;
2131inline void SelectionDirectionTag::Set(ULDOMElement h, SelectionDirection v) {
2132 ulDOMElementSetSelectionDirection(h, SelectionDirectionName(v),
nullptr);
2135inline ULDOMSelectionMode SelectionModeValue(SelectionMode mode) {
2137 case SelectionMode::Select:
2138 return kULDOMSelectionMode_Select;
2139 case SelectionMode::Start:
2140 return kULDOMSelectionMode_Start;
2141 case SelectionMode::End:
2142 return kULDOMSelectionMode_End;
2144 return kULDOMSelectionMode_Preserve;
2256 detail::StringProp<detail::InputTypeTag>
type;
2302 ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"", new_value.size(),
true,
2315 return detail::EmptyHandleError();
2316 detail::ErrorScope error;
2317 if (ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"",
2318 new_value.size(),
true, error.out()))
2320 return Unexpected<Error>(error.TakeError());
2364 ulDOMElementSetCustomValidity(
raw(), error.data() ? error.data() :
"", error.size());
2375 return detail::TakeString(ulDOMElementGetValidationMessage(
raw()));
2410 ulDOMElementSetSelectionRange(
raw(), detail::IndexArgument(start), detail::IndexArgument(end),
2411 detail::SelectionDirectionName(direction),
nullptr);
2435 return detail::EmptyHandleError();
2436 detail::ErrorScope error;
2437 if (ulDOMElementSetSelectionRange(
raw(), detail::IndexArgument(start),
2438 detail::IndexArgument(end),
2439 detail::SelectionDirectionName(direction), error.out()))
2441 return Unexpected<Error>(error.TakeError());
2454 ulDOMElementSetRangeText(
raw(), replacement.data() ? replacement.data() :
"",
2455 replacement.size(),
nullptr);
2467 return detail::EmptyHandleError();
2468 detail::ErrorScope error;
2469 if (ulDOMElementSetRangeText(
raw(), replacement.data() ? replacement.data() :
"",
2470 replacement.size(), error.out()))
2472 return Unexpected<Error>(error.TakeError());
2494 ulDOMElementSetRangeTextInRange(
raw(), replacement.data() ? replacement.data() :
"",
2495 replacement.size(), detail::IndexArgument(start),
2496 detail::IndexArgument(end), detail::SelectionModeValue(mode),
2522 return detail::EmptyHandleError();
2523 detail::ErrorScope error;
2524 if (ulDOMElementSetRangeTextInRange(
raw(), replacement.data() ? replacement.data() :
"",
2525 replacement.size(), detail::IndexArgument(start),
2526 detail::IndexArgument(end),
2527 detail::SelectionModeValue(mode), error.out()))
2529 return Unexpected<Error>(error.TakeError());
2632 ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"", new_value.size(),
true,
2644 return detail::EmptyHandleError();
2645 detail::ErrorScope error;
2646 if (ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"",
2647 new_value.size(),
true, error.out()))
2649 return Unexpected<Error>(error.TakeError());
2682 ulDOMElementSetCustomValidity(
raw(), error.data() ? error.data() :
"", error.size());
2692 return detail::TakeString(ulDOMElementGetValidationMessage(
raw()));
2721 ulDOMElementSetSelectionRange(
raw(), detail::IndexArgument(start), detail::IndexArgument(end),
2722 detail::SelectionDirectionName(direction),
nullptr);
2743 return detail::EmptyHandleError();
2744 detail::ErrorScope error;
2745 if (ulDOMElementSetSelectionRange(
raw(), detail::IndexArgument(start),
2746 detail::IndexArgument(end),
2747 detail::SelectionDirectionName(direction), error.out()))
2749 return Unexpected<Error>(error.TakeError());
2760 ulDOMElementSetRangeText(
raw(), replacement.data() ? replacement.data() :
"",
2761 replacement.size(),
nullptr);
2771 return detail::EmptyHandleError();
2772 detail::ErrorScope error;
2773 if (ulDOMElementSetRangeText(
raw(), replacement.data() ? replacement.data() :
"",
2774 replacement.size(), error.out()))
2776 return Unexpected<Error>(error.TakeError());
2797 ulDOMElementSetRangeTextInRange(
raw(), replacement.data() ? replacement.data() :
"",
2798 replacement.size(), detail::IndexArgument(start),
2799 detail::IndexArgument(end), detail::SelectionModeValue(mode),
2823 return detail::EmptyHandleError();
2824 detail::ErrorScope error;
2825 if (ulDOMElementSetRangeTextInRange(
raw(), replacement.data() ? replacement.data() :
"",
2826 replacement.size(), detail::IndexArgument(start),
2827 detail::IndexArgument(end),
2828 detail::SelectionModeValue(mode), error.out()))
2830 return Unexpected<Error>(error.TakeError());
2906 ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"", new_value.size(),
true,
2918 return detail::EmptyHandleError();
2919 detail::ErrorScope error;
2920 if (ulDOMElementSetValue(
raw(), new_value.data() ? new_value.data() :
"",
2921 new_value.size(),
true, error.out()))
2923 return Unexpected<Error>(error.TakeError());
2956 ulDOMElementSetCustomValidity(
raw(), error.data() ? error.data() :
"", error.size());
2966 return detail::TakeString(ulDOMElementGetValidationMessage(
raw()));
2982 size_t length()
const {
return ulDOMElementGetOptionCount(
raw()); }
3035 detail::StringProp<detail::OptionTextTag>
text;
3074 size_t index()
const {
return ulDOMElementGetIndex(
raw()); }
3165 return detail::EmptyHandleError();
3166 detail::ErrorScope error;
3167 if (ulDOMElementRequestSubmit(
raw(),
nullptr, error.out()))
3169 return Unexpected<Error>(error.TakeError());
3184 ulDOMElementRequestSubmit(
raw(), submitter.
raw(),
nullptr);
3196 return detail::EmptyHandleError();
3197 detail::ErrorScope error;
3198 if (ulDOMElementRequestSubmit(
raw(), submitter.
raw(), error.out()))
3200 return Unexpected<Error>(error.TakeError());
3235 detail::StringProp<detail::SrcTag>
src;
3303 detail::StringProp<detail::SrcTag>
src;
3309 detail::StringProp<detail::AltTag>
alt;
3360 detail::StringProp<detail::HrefTag>
href;
3461 return Node::Adopt(ulDOMEventGetTargetNode(borrowed_));
3485#include <Ultralight/dom/detail/PropertiesImpl.h>
3487#pragma pop_macro("None")
A container for assembling DOM nodes off the page.
Definition DocumentFragment.h:43
The root of a page's DOM tree in a View or frame.
Definition Document.h:106
A handle to an element on a page.
Definition Element.h:142
Element insertBefore(const Element &child, const Element &ref_child) const
Insert an element before one of this element's children (insertBefore).
Definition Element.h:888
Result< Node > replaceChild(const Node &new_child, const Node &old_child, Checked_t) const
Same as replaceChild() with Nodes, but returns a Result with the reason for a failure (eg,...
Definition Element.h:1012
EventListener addEventListener(std::string_view type, F &&callback, EventListenerFlags flags) const
Listen for an event on this element, with options as flags (eg, dom::Once | dom::Capture).
Definition Element.h:1568
int offsetWidth() const
Get the element's width in CSS pixels, including its padding and borders (offsetWidth).
Definition Element.h:1307
int scrollWidth() const
Get the width of the element's content in CSS pixels, including any part scrolled out of view (scroll...
Definition Element.h:1379
void prepend(T &&... nodes) const
Add nodes and strings to the start of this element, before its first child (prepend).
Definition Element.h:807
detail::StringProp< detail::TextContentTag > textContent
The text of this element and all its descendants (textContent).
Definition Element.h:216
Result< Element > insertAdjacentElement(std::string_view position, const Element &other, Checked_t) const
Same as insertAdjacentElement(), but returns a Result with the reason for a failure (eg,...
Definition Element.h:1156
Element appendChild(const Element &child) const
Add an element as the last child of this element (appendChild).
Definition Element.h:676
detail::StringProp< detail::ValueTag > value
The current value of a form control (value).
Definition Element.h:306
int clientHeight() const
Get the element's inner height in CSS pixels, including its padding but not its borders or scrollbar ...
Definition Element.h:1357
bool contains(const Element &other) const
Whether or not another element is this element or one of its descendants (contains).
Definition Element.h:643
EventListener addEventListener(std::string_view type, C &receiver, M method, EventListenerFlags flags) const
Listen by calling a member function on an object you keep alive, with options as flags.
Definition Element.h:1625
EventListener addEventListener(std::string_view type, H holder, M method, const AddEventListenerOptions &options={}) const
Listen by calling a member function through a smart pointer that's checked before each call.
Definition Element.h:1650
int offsetLeft() const
Get the distance from the element's left border edge to its offsetParent()'s left padding edge,...
Definition Element.h:1330
void scrollBy(double x, double y) const
Scroll the element's content by an offset (scrollBy).
Definition Element.h:1426
Element firstElementChild() const
Get the element's first child element (firstElementChild).
Definition Element.h:1238
Result< bool > matches(std::string_view selectors, Checked_t) const
Same as matches(), but returns a Result with the reason for a failure (eg, a SyntaxError for a malfor...
Definition Element.h:481
Result< EventListener > On(std::string_view selector, std::string_view type, F &&callback, Checked_t) const
Same as On() with default options, but returns a Result with the reason for a failure.
Definition Element.h:1790
detail::BoolProp< detail::DisabledTag > disabled
Whether or not the element has a disabled attribute (disabled).
Definition Element.h:329
void replaceChildren(T &&... new_children) const
Replace all of this element's children with nodes and strings (replaceChildren).
Definition Element.h:847
EventListener On(std::string_view selector, std::string_view type, C &receiver, M method, EventListenerFlags flags) const
Listen for an event on matching elements by calling a member function on an object you keep alive,...
Definition Element.h:1851
detail::BoolProp< detail::CheckedTag > checked
Whether or not a checkbox or radio button is checked (checked).
Definition Element.h:321
void scrollIntoView(bool align_to_top=true) const
Scroll the element's ancestors so the element is visible (scrollIntoView).
Definition Element.h:1398
detail::StringProp< detail::ClassNameTag > className
The element's class attribute as one string (className).
Definition Element.h:273
Element closest(std::string_view selectors) const
Find the closest ancestor that matches a CSS selector, starting with this element itself (closest).
Definition Element.h:503
bool toggleAttribute(std::string_view name) const
Toggle an attribute (toggleAttribute).
Definition Element.h:592
std::string tagName() const
Get the element's tag name (tagName).
Definition Element.h:1222
Result< void > insertAdjacentText(std::string_view position, std::string_view text, Checked_t) const
Same as insertAdjacentText(), but returns a Result with the reason for a failure (eg,...
Definition Element.h:1202
void insertAdjacentText(std::string_view position, std::string_view text) const
Insert text relative to this element (insertAdjacentText).
Definition Element.h:1187
void removeAttribute(std::string_view name) const
Remove an attribute (removeAttribute).
Definition Element.h:579
Node insertBefore(const Node &child, const Node &ref_child) const
Insert a node of any kind before one of this element's children (insertBefore).
Definition Element.h:925
EventListener addEventListener(std::string_view type, F &&callback, const AddEventListenerOptions &options={}) const
Listen for an event on this element (addEventListener).
Definition Element.h:1540
int clientWidth() const
Get the element's inner width in CSS pixels, including its padding but not its borders or scrollbar (...
Definition Element.h:1349
detail::IntProp< detail::TabIndexTag > tabIndex
The element's position in the keyboard focus order (tabIndex).
Definition Element.h:294
static Element FromBorrowed(ULDOMElement handle)
Wrap a C handle the library owns (eg, a callback argument), adding a reference.
Definition Element.h:1996
Element insertAdjacentElement(std::string_view position, const Element &other) const
Insert an element relative to this element (insertAdjacentElement).
Definition Element.h:1142
detail::StringProp< detail::NameTag > name
The element's name attribute (name).
Definition Element.h:313
detail::ValueProp< detail::ScrollTopTag > scrollTop
How far the element's content is scrolled down, in CSS pixels (scrollTop).
Definition Element.h:356
Element querySelector(std::string_view selectors) const
Find the first element below this one that matches a CSS selector (querySelector).
Definition Element.h:410
bool hasAttribute(std::string_view name) const
Whether or not the element has an attribute (hasAttribute).
Definition Element.h:553
Result< void > replaceChildren(Checked_t, T &&... new_children) const
Same as replaceChildren(), but returns a Result with the reason for a failure (eg,...
Definition Element.h:867
std::vector< std::string > getAttributeNames() const
Get the names of the element's attributes in order (getAttributeNames).
Definition Element.h:621
int offsetTop() const
Get the distance from the element's top border edge to its offsetParent()'s top padding edge,...
Definition Element.h:1322
EventListener On(std::string_view selector, std::string_view type, H holder, M method, EventListenerFlags flags) const
Listen for an event on matching elements by calling a member function through a smart pointer,...
Definition Element.h:1906
Node replaceChild(const Node &new_child, const Node &old_child) const
Replace one of this element's children, of any kind, with a node of any kind (replaceChild).
Definition Element.h:998
Element cloneNode(bool deep=false) const
Copy this element (cloneNode).
Definition Element.h:1087
Element previousElementSibling() const
Get the element's previous sibling element (previousElementSibling).
Definition Element.h:1265
DOMRect getBoundingClientRect() const
Get the element's bounding rectangle relative to the viewport (getBoundingClientRect).
Definition Element.h:1297
EventListener On(std::string_view selector, std::string_view type, H holder, M method, const AddEventListenerOptions &options={}) const
Listen for an event on matching elements by calling a member function through a smart pointer that's ...
Definition Element.h:1880
Result< void > insertAdjacentHTML(std::string_view position, std::string_view html, Checked_t) const
Same as insertAdjacentHTML(), but returns a Result with the reason for a failure (eg,...
Definition Element.h:1117
Document ownerDocument() const
Get the document this element belongs to (ownerDocument).
Definition Document.h:1026
int scrollHeight() const
Get the height of the element's content in CSS pixels, including any part scrolled out of view (scrol...
Definition Element.h:1387
HTMLIFrameElement AsIFrame() const
Get this element as an <iframe> (HTMLIFrameElement).
Definition Element.h:3423
static Element Adopt(ULDOMElement handle)
Wrap a C handle you own, taking ownership of it.
Definition Element.h:1987
Result< void > append(Checked_t, T &&... nodes) const
Same as append(), but returns a Result with the reason for a failure (eg, a HierarchyRequestError for...
Definition Element.h:784
Element(const Element &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:375
HTMLImageElement AsImage() const
Get this element as an <img> (HTMLImageElement).
Definition Element.h:3427
void focus() const
Give the element keyboard focus (focus).
Definition Element.h:1436
Result< Node > appendChild(const Node &child, Checked_t) const
Same as appendChild() with a Node, but returns a Result with the reason for a failure (eg,...
Definition Element.h:719
int offsetHeight() const
Get the element's height in CSS pixels, including its padding and borders (offsetHeight).
Definition Element.h:1314
ULDOMElement LeakRef()
Give up ownership of the C handle and return it.
Definition Element.h:2013
Result< EventListener > On(std::string_view selector, std::string_view type, F &&callback, const AddEventListenerOptions &options, Checked_t) const
Same as On(), but returns a Result with the reason for a failure (eg, a SyntaxError for a malformed s...
Definition Element.h:1767
Result< Element > insertBefore(const Element &child, const Element &ref_child, Checked_t) const
Same as insertBefore(), but returns a Result with the reason for a failure (eg, a NotFoundError when ...
Definition Element.h:901
Element(ULDOMElement handle)
Definition Element.h:2018
EventListener On(std::string_view selector, std::string_view type, F &&callback, EventListenerFlags flags) const
Listen for an event on matching elements, with options as flags (see the options overload).
Definition Element.h:1745
void blur() const
Remove keyboard focus from the element (blur).
Definition Element.h:1441
Result< Element > replaceChild(const Element &new_child, const Element &old_child, Checked_t) const
Same as replaceChild(), but returns a Result with the reason for a failure (eg, a NotFoundError when ...
Definition Element.h:973
HTMLFormElement AsForm() const
Get this element as a <form> (HTMLFormElement).
Definition Element.h:3419
size_t childElementCount() const
Get the number of the element's child elements (childElementCount).
Definition Element.h:1274
detail::BoolProp< detail::HiddenTag > hidden
Whether or not the element has a hidden attribute (hidden).
Definition Element.h:285
bool matches(std::string_view selectors) const
Whether or not this element matches a CSS selector (matches).
Definition Element.h:469
Result< Element > appendChild(const Element &child, Checked_t) const
Same as appendChild(), but returns a Result with the reason for a failure (eg, a HierarchyRequestErro...
Definition Element.h:687
HTMLOptionElement AsOption() const
Get this element as an <option> (HTMLOptionElement).
Definition Element.h:3410
Element nextElementSibling() const
Get the element's next sibling element (nextElementSibling).
Definition Element.h:1256
void click() const
Click the element (click).
Definition Element.h:1454
Result< Element > removeChild(const Element &child, Checked_t) const
Same as removeChild(), but returns a Result with the reason for a failure (eg, a NotFoundError when c...
Definition Element.h:1041
Node removeChild(const Node &child) const
Remove one of this element's children, of any kind (removeChild).
Definition Element.h:1060
bool dispatchEvent(std::string_view type, const EventInit &init={}) const
Dispatch a synthetic event to this element (dispatchEvent).
Definition Element.h:1477
ElementList querySelectorAll(std::string_view selectors) const
Find every element below this one that matches a CSS selector (querySelectorAll).
Definition ElementList.h:196
Result< void > prepend(Checked_t, T &&... nodes) const
Same as prepend(), but returns a Result with the reason for a failure (eg, a HierarchyRequestError fo...
Definition Element.h:823
HTMLSelectElement AsSelect() const
Get this element as a <select> (HTMLSelectElement).
Definition Element.h:3406
Element lastElementChild() const
Get the element's last child element (lastElementChild).
Definition Element.h:1247
Result< Node > removeChild(const Node &child, Checked_t) const
Same as removeChild() with a Node, but returns a Result with the reason for a failure (eg,...
Definition Element.h:1071
Node appendChild(const Node &child) const
Add a node of any kind as the last child of this element (appendChild).
Definition Element.h:708
detail::ValueProp< detail::SelectedIndexTag > selectedIndex
The index of the selected option in a <select> (selectedIndex), as a std::optional<size_t>.
Definition Element.h:344
HTMLTextAreaElement AsTextArea() const
Get this element as a <textarea> (HTMLTextAreaElement).
Definition Element.h:3402
EventListener addEventListener(std::string_view type, H holder, M method, EventListenerFlags flags) const
Listen by calling a member function through a smart pointer, with options as flags.
Definition Element.h:1672
Element replaceChild(const Element &new_child, const Element &old_child) const
Replace one of this element's children with another element (replaceChild).
Definition Element.h:959
detail::StringProp< detail::TitleTag > title
The element's title attribute (title).
Definition Element.h:278
EventListener On(std::string_view selector, std::string_view type, C &receiver, M method, const AddEventListenerOptions &options={}) const
Listen for an event on matching elements by calling a member function on an object you keep alive (se...
Definition Element.h:1821
Element & operator=(Element other) noexcept
Assignment (copies or moves).
Definition Element.h:391
Element()
Create an empty Element.
Definition Element.h:368
Result< Node > insertBefore(const Node &child, const Node &ref_child, Checked_t) const
Same as insertBefore() with Nodes, but returns a Result with the reason for a failure (eg,...
Definition Element.h:938
bool toggleAttribute(std::string_view name, bool force) const
Add or remove an attribute (toggleAttribute with force).
Definition Element.h:609
bool dispatchCustomEvent(std::string_view type, std::string_view event_detail, const EventInit &init={}) const
Dispatch a synthetic CustomEvent with a string payload to this element.
Definition Element.h:1504
Element(Element &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:382
Element removeChild(const Element &child) const
Remove one of this element's children (removeChild).
Definition Element.h:1030
int clientLeft() const
Get the width of the element's left border, in CSS pixels (clientLeft).
Definition Element.h:1371
void scrollTo(double x, double y) const
Scroll the element's content to a position (scrollTo).
Definition Element.h:1415
Element parentElement() const
Get the element's parent element (parentElement).
Definition Element.h:1231
ElementList children() const
Get the element's child elements in order (children).
Definition ElementList.h:224
detail::StringProp< detail::InnerTextTag > innerText
The element's text as it's rendered (innerText).
Definition Element.h:234
detail::StringProp< detail::InnerHTMLTag > innerHTML
The markup of the element's children (innerHTML).
Definition Element.h:250
HTMLAnchorElement AsAnchor() const
Get this element as an <a> (HTMLAnchorElement).
Definition Element.h:3431
EventListener addEventListener(std::string_view type, C &receiver, M method, const AddEventListenerOptions &options={}) const
Listen by calling a member function on an object you keep alive.
Definition Element.h:1599
Result< Element > closest(std::string_view selectors, Checked_t) const
Same as closest(), but returns a Result with the reason for a failure (eg, a SyntaxError for a malfor...
Definition Element.h:515
void insertAdjacentHTML(std::string_view position, std::string_view html) const
Parse markup and insert it relative to this element (insertAdjacentHTML).
Definition Element.h:1103
detail::StringProp< detail::IdTag > id
The element's id attribute (id).
Definition Element.h:267
std::optional< std::string > getAttribute(std::string_view name) const
Get an attribute's value (getAttribute).
Definition Element.h:540
ULDOMElement raw() const
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMElement.h> functions.
Definition Element.h:2006
detail::ClassListProxy classList
The element's classes (classList).
Definition Element.h:195
HTMLInputElement AsInput() const
Get this element as an <input> (HTMLInputElement).
Definition Element.h:3398
void append(T &&... nodes) const
Add nodes and strings to the end of this element, after its last child (append).
Definition Element.h:768
detail::StringProp< detail::OuterHTMLTag > outerHTML
The markup of the element and its children (outerHTML).
Definition Element.h:262
detail::DatasetProxy dataset
The element's data-* attributes by camelCase name (dataset).
Definition Element.h:209
EventListener On(std::string_view selector, std::string_view type, F &&callback, const AddEventListenerOptions &options={}) const
Listen for an event on the elements inside this one that match a CSS selector, including elements add...
Definition Element.h:1710
void setAttribute(std::string_view name, std::string_view new_value) const
Set an attribute's value (setAttribute).
Definition Element.h:568
Result< Element > querySelector(std::string_view selectors, Checked_t) const
Same as querySelector(), but returns a Result with the reason for a failure (eg, a SyntaxError for a ...
Definition Element.h:422
detail::ValueProp< detail::ScrollLeftTag > scrollLeft
How far the element's content is scrolled right, in CSS pixels (scrollLeft).
Definition Element.h:363
Element offsetParent() const
Get the element that offsetTop() and offsetLeft() measure from (offsetParent).
Definition Element.h:1341
detail::StyleProxy style
The element's inline style (style).
Definition Element.h:179
bool TagIs(const char *upper_tag) const
Whether or not this element's tag name is upper_tag.
Definition Element.h:2026
int clientTop() const
Get the width of the element's top border, in CSS pixels (clientTop).
Definition Element.h:1364
A fixed list of DOM elements returned by a query or an Element::children() call.
Definition ElementList.h:55
static Error PageGone()
Create a page-gone error (is_page_gone() returns true).
Definition Error.h:123
Node targetNode() const
Get the node the event was dispatched to (target).
Definition Element.h:3460
Element target() const
Get the element the event was dispatched to (target).
Definition Element.h:3456
Element currentTarget() const
Get the element whose listener is running (currentTarget).
Definition Element.h:3464
ULDOMEvent raw() const
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMEvent.h> functions.
Definition Event.h:268
A handle to a registered DOM event listener.
Definition EventListener.h:151
Element relatedTarget() const
Get the other element of the focus change (relatedTarget).
Definition Element.h:3472
An <a> element (HTMLAnchorElement).
Definition Element.h:3352
friend class Element
Definition Element.h:3394
HTMLAnchorElement(const HTMLAnchorElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:3372
detail::StringProp< detail::HrefTag > href
The URL the link points to (href).
Definition Element.h:3360
HTMLAnchorElement & operator=(HTMLAnchorElement other) noexcept
Assignment (copies or moves).
Definition Element.h:3388
HTMLAnchorElement(HTMLAnchorElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:3379
HTMLAnchorElement()
Create an empty HTMLAnchorElement.
Definition Element.h:3365
An <iframe> element (HTMLIFrameElement).
Definition Element.h:3224
friend class Element
Definition Element.h:3283
HTMLIFrameElement()
Create an empty HTMLIFrameElement.
Definition Element.h:3240
Document contentDocument() const
Get the document inside the frame (contentDocument).
Definition Document.h:1034
HTMLIFrameElement(HTMLIFrameElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:3254
HTMLIFrameElement(const HTMLIFrameElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:3247
detail::StringProp< detail::SrcTag > src
The URL of the page in the frame (src).
Definition Element.h:3235
HTMLIFrameElement & operator=(HTMLIFrameElement other) noexcept
Assignment (copies or moves).
Definition Element.h:3263
An <img> element (HTMLImageElement).
Definition Element.h:3292
friend class Element
Definition Element.h:3343
HTMLImageElement()
Create an empty HTMLImageElement.
Definition Element.h:3314
HTMLImageElement & operator=(HTMLImageElement other) noexcept
Assignment (copies or moves).
Definition Element.h:3337
HTMLImageElement(const HTMLImageElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:3321
HTMLImageElement(HTMLImageElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:3328
detail::StringProp< detail::SrcTag > src
The URL of the image (src).
Definition Element.h:3303
detail::StringProp< detail::AltTag > alt
The image's text alternative (alt), from its alt attribute.
Definition Element.h:3309
An <option> element (HTMLOptionElement).
Definition Element.h:3020
friend class Element
Definition Element.h:3077
friend class HTMLSelectElement
Definition Element.h:3078
detail::StringProp< detail::OptionTextTag > text
The option's text with whitespace collapsed (text).
Definition Element.h:3035
HTMLOptionElement & operator=(HTMLOptionElement other) noexcept
Assignment (copies or moves).
Definition Element.h:3063
HTMLOptionElement()
Create an empty HTMLOptionElement.
Definition Element.h:3040
size_t index() const
Get the option's position in its <select> (index).
Definition Element.h:3074
HTMLOptionElement(const HTMLOptionElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:3047
HTMLOptionElement(HTMLOptionElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:3054
detail::BoolProp< detail::OptionSelectedTag > selected
Whether or not the option is selected (selected).
Definition Element.h:3028
A <select> element (HTMLSelectElement).
Definition Element.h:2851
friend class Element
Definition Element.h:3007
HTMLSelectElement(HTMLSelectElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:2882
void SetValue(std::string_view new_value) const
Select the option with a value and fire input and change events, like a user choice.
Definition Element.h:2905
HTMLSelectElement()
Create an empty HTMLSelectElement.
Definition Element.h:2868
std::string validationMessage() const
Get the message that describes why the select is invalid (validationMessage).
Definition Element.h:2965
bool checkValidity() const
Check whether the select meets its constraints (checkValidity).
Definition Element.h:2939
HTMLOptionElement item(size_t index) const
Get an option by its position (item).
Definition Element.h:3414
HTMLSelectElement(const HTMLSelectElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:2875
ElementList selectedOptions() const
Get the selected options in order (selectedOptions).
Definition ElementList.h:214
ValidityState validity() const
Get how the select fails its constraints (validity).
Definition Element.h:2975
void setCustomValidity(std::string_view error) const
Set a custom validation error (setCustomValidity).
Definition Element.h:2955
size_t length() const
Get the number of options (length), including those inside an <optgroup>.
Definition Element.h:2982
Result< void > SetValue(std::string_view new_value, Checked_t) const
Same as SetValue(), but returns a Result with the reason for a failure.
Definition Element.h:2916
HTMLFormElement form() const
Get the form the select belongs to (form).
Definition Element.h:3444
detail::BoolProp< detail::RequiredTag > required
Whether or not the select has a required attribute (required).
Definition Element.h:2863
bool reportValidity() const
Check whether the select meets its constraints, and report a failure to the user (reportValidity).
Definition Element.h:2947
HTMLSelectElement & operator=(HTMLSelectElement other) noexcept
Assignment (copies or moves).
Definition Element.h:2891
A <textarea> element (HTMLTextAreaElement).
Definition Element.h:2544
friend class Element
Definition Element.h:2834
void SetValue(std::string_view new_value) const
Set the textarea's value and fire input and change events, like a user edit.
Definition Element.h:2631
detail::ValueProp< detail::SelectionStartTag > selectionStart
The offset where the selection starts (selectionStart).
Definition Element.h:2579
std::string validationMessage() const
Get the message that describes why the textarea is invalid (validationMessage).
Definition Element.h:2691
Result< void > setRangeText(std::string_view replacement, size_t start, size_t end, Checked_t) const
Same as setRangeText() with a range, but returns a Result with the reason for a failure (eg,...
Definition Element.h:2809
detail::StringProp< detail::PlaceholderTag > placeholder
The textarea's placeholder attribute (placeholder).
Definition Element.h:2558
bool checkValidity() const
Check whether the textarea meets its constraints (checkValidity).
Definition Element.h:2665
void setRangeText(std::string_view replacement) const
Replace the selected text (setRangeText).
Definition Element.h:2759
void setRangeText(std::string_view replacement, size_t start, size_t end, SelectionMode mode=SelectionMode::Preserve) const
Replace a range of the text (setRangeText with a range).
Definition Element.h:2795
ValidityState validity() const
Get how the textarea fails its constraints (validity).
Definition Element.h:2701
void setCustomValidity(std::string_view error) const
Set a custom validation error (setCustomValidity).
Definition Element.h:2681
Result< void > SetValue(std::string_view new_value, Checked_t) const
Same as SetValue(), but returns a Result with the reason for a failure.
Definition Element.h:2642
HTMLFormElement form() const
Get the form the textarea belongs to (form).
Definition Element.h:3440
Result< void > setSelectionRange(size_t start, size_t end, Checked_t) const
Same as setSelectionRange(), but returns a Result with the reason for a failure.
Definition Element.h:2730
detail::StringProp< detail::DefaultValueTag > defaultValue
The textarea's default value (defaultValue), which is the text between its tags.
Definition Element.h:2573
Result< void > setRangeText(std::string_view replacement, Checked_t) const
Same as setRangeText(), but returns a Result with the reason for a failure.
Definition Element.h:2769
detail::BoolProp< detail::ReadOnlyTag > readOnly
Whether or not the textarea has a readonly attribute (readOnly).
Definition Element.h:2564
detail::ValueProp< detail::SelectionEndTag > selectionEnd
The offset just past the end of the selection (selectionEnd).
Definition Element.h:2584
Result< void > setRangeText(std::string_view replacement, size_t start, size_t end, SelectionMode mode, Checked_t) const
Same as setRangeText() with a range and a mode, but returns a Result with the reason for a failure.
Definition Element.h:2820
detail::BoolProp< detail::RequiredTag > required
Whether or not the textarea has a required attribute (required).
Definition Element.h:2552
HTMLTextAreaElement(const HTMLTextAreaElement &other)
Copy constructor (both handles refer to the same element).
Definition Element.h:2602
Result< void > setSelectionRange(size_t start, size_t end, SelectionDirection direction, Checked_t) const
Same as setSelectionRange() with a direction, but returns a Result with the reason for a failure.
Definition Element.h:2740
bool reportValidity() const
Check whether the textarea meets its constraints, and report a failure to the user (reportValidity).
Definition Element.h:2673
HTMLTextAreaElement()
Create an empty HTMLTextAreaElement.
Definition Element.h:2595
void select() const
Select all of the text (select).
Definition Element.h:2706
detail::ValueProp< detail::SelectionDirectionTag > selectionDirection
The direction of the selection (selectionDirection).
Definition Element.h:2590
void setSelectionRange(size_t start, size_t end, SelectionDirection direction=SelectionDirection::None) const
Set the selection (setSelectionRange).
Definition Element.h:2719
HTMLTextAreaElement & operator=(HTMLTextAreaElement other) noexcept
Assignment (copies or moves).
Definition Element.h:2618
HTMLTextAreaElement(HTMLTextAreaElement &&other) noexcept
Move constructor (other becomes empty).
Definition Element.h:2609
Element relatedTarget() const
Get the other element of a mouse transition (relatedTarget).
Definition Element.h:3468
A reference to an item in the DOM tree.
Definition Node.h:147
detail::NodeStorage detail_
Internal storage (not part of the API).
Definition Node.h:166
Node()
Create an empty Node.
Definition Node.h:171
ULDOMNode LeakRef()
Give up ownership of the C handle and return it.
Definition Node.h:546
ULDOMNode raw() const
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMNode.h> functions.
Definition Node.h:539
static Node Adopt(ULDOMNode handle)
Wrap a C handle you own, taking ownership of it.
Definition Node.h:520
bool IsEmpty() const
Whether or not this Node is empty (it holds no handle).
Definition Node.h:216
bool IsAlive() const
Whether or not this Node is valid (it isn't empty and its page is still alive).
Definition Node.h:223
Element parentElement() const
Get the node's parent element (parentElement).
Definition Element.h:3448
Element AsElement() const
Get this node as an Element.
Definition Element.h:3452
Element submitter() const
Get the button that submitted the form (submitter).
Definition Element.h:3476
Whether or not the DOM API can hold an object through H (ignoring const and references),...
Definition Holders.h:41
Definition StringSTL.h:166
Direct C++ access to modify page elements and handle events.
constexpr Checked_t Checked
Pass to a DOM call to get a dom::Result holding the reason for a failure instead of an empty value.
Definition Error.h:299
EventListenerFlags
Options for adding an event listener, as flags (addEventListener() and On()).
Definition EventListener.h:41
SelectionDirection
The direction of a text control's selection (selectionDirection).
Definition Element.h:2057
@ Forward
The selection was made toward the end of the text.
Definition Element.h:2059
@ None
No direction.
Definition Element.h:2058
@ Backward
The selection was made toward the start of the text.
Definition Element.h:2060
SelectionMode
Where the selection goes after HTMLInputElement::setRangeText() replaces text (selectMode).
Definition Element.h:2066
@ Preserve
Keep the selection, adjusted for the edit.
Definition Element.h:2067
@ Select
Select the inserted text.
Definition Element.h:2068
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.
@ End
Definition Anchor.h:29
@ Start
Definition Anchor.h:29
@ None
Definition Anchor.h:36
Options for adding an event listener, like the web's options object for addEventListener().
Definition EventListener.h:526
The type of dom::Checked.
Definition Error.h:282
A rectangle in CSS pixels, relative to the viewport (DOMRect).
Definition DOMRect.h:26
Options for an event you dispatch yourself (the web's EventInit).
Definition Event.h:30
The ways a form control fails its constraints (ValidityState).
Definition Element.h:2085
bool patternMismatch
The value doesn't match the pattern attribute.
Definition Element.h:2088
bool valid
None of the above are true.
Definition Element.h:2096
bool valueMissing
A required control has no value.
Definition Element.h:2086
bool tooShort
The user made the value shorter than minlength.
Definition Element.h:2090
bool rangeOverflow
The value is greater than max.
Definition Element.h:2092
bool rangeUnderflow
The value is less than min.
Definition Element.h:2091
bool tooLong
The user made the value longer than maxlength.
Definition Element.h:2089
bool stepMismatch
The value doesn't fit the step attribute.
Definition Element.h:2093
bool badInput
The user entered something the control can't convert.
Definition Element.h:2094
bool customError
A custom error message is set.
Definition Element.h:2095
bool typeMismatch
The value doesn't fit the input type (eg, a bad email).
Definition Element.h:2087