2024-06-09 15:13:38 +12:00
|
|
|
/*
|
2024-06-16 12:47:35 -04:00
|
|
|
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
2024-06-09 15:13:38 +12:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2025-02-17 20:44:26 +01:00
|
|
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
2024-06-09 15:13:38 +12:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#validitystate
|
|
|
|
class ValidityState final : public Bindings::PlatformObject {
|
2024-06-16 12:47:35 -04:00
|
|
|
WEB_PLATFORM_OBJECT(ValidityState, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(ValidityState);
|
2024-06-09 15:13:38 +12:00
|
|
|
|
|
|
|
public:
|
2025-02-17 20:44:26 +01:00
|
|
|
[[nodiscard]] static GC::Ref<ValidityState> create(JS::Realm&, FormAssociatedElement const&);
|
|
|
|
|
2024-06-16 12:47:35 -04:00
|
|
|
virtual ~ValidityState() override = default;
|
2024-06-09 15:13:38 +12:00
|
|
|
|
2025-02-17 20:44:26 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-valuemissing
|
|
|
|
bool value_missing() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-typemismatch
|
|
|
|
bool type_mismatch() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-patternmismatch
|
|
|
|
bool pattern_mismatch() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-toolong
|
|
|
|
bool too_long() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-tooshort
|
|
|
|
bool too_short() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-rangeunderflow
|
|
|
|
bool range_underflow() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-rangeoverflow
|
|
|
|
bool range_overflow() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-stepmismatch
|
|
|
|
bool step_mismatch() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-badinput
|
|
|
|
bool bad_input() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-customerror
|
|
|
|
bool custom_error() const;
|
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-validitystate-valid
|
|
|
|
bool valid() const;
|
|
|
|
|
2024-06-09 15:13:38 +12:00
|
|
|
private:
|
2025-02-17 20:44:26 +01:00
|
|
|
ValidityState(JS::Realm&, FormAssociatedElement const&);
|
2024-06-09 15:13:38 +12:00
|
|
|
|
2024-06-16 12:47:35 -04:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2025-02-17 20:44:26 +01:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
FormAssociatedElement const& m_control;
|
2024-06-09 15:13:38 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|