/* * Copyright (c) 2024, the Ladybird developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Web::HTML { struct ValidityStateFlags { bool value_missing = false; bool type_mismatch = false; bool pattern_mismatch = false; bool too_long = false; bool too_short = false; bool range_underflow = false; bool range_overflow = false; bool step_mismatch = false; bool bad_input = false; bool custom_error = false; bool has_one_or_more_true_values() const { return value_missing || type_mismatch || pattern_mismatch || too_long || too_short || range_underflow || range_overflow || step_mismatch || bad_input || custom_error; } }; // https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals class ElementInternals final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(ElementInternals, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(ElementInternals); public: static GC::Ref create(JS::Realm&, HTMLElement& target_element); GC::Ptr shadow_root() const; WebIDL::ExceptionOr set_form_value(Variant, String, GC::Root> value, Optional, String, GC::Root>> state); WebIDL::ExceptionOr> form() const; WebIDL::ExceptionOr set_validity(ValidityStateFlags const& flags, Optional message, Optional> anchor); WebIDL::ExceptionOr will_validate() const; WebIDL::ExceptionOr> validity() const; WebIDL::ExceptionOr validation_message() const; WebIDL::ExceptionOr check_validity() const; WebIDL::ExceptionOr report_validity() const; WebIDL::ExceptionOr> labels(); private: explicit ElementInternals(JS::Realm&, HTMLElement& target_element); virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor& visitor) override; // https://html.spec.whatwg.org/multipage/custom-elements.html#internals-target GC::Ref m_target_element; }; }