mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Add stub for ValidityState
This fixes https://html5test.com/ as previously an exception was being thrown after trying to access this attribute which would then result in a popup about the test failing (and none of the test results being shown).
This commit is contained in:
parent
0ec0e92b10
commit
e0bbbc729b
Notes:
sideshowbarker
2024-07-17 03:25:24 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/e0bbbc729b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/113
9 changed files with 87 additions and 1 deletions
|
@ -448,6 +448,7 @@ set(SOURCES
|
||||||
HTML/WorkerGlobalScope.cpp
|
HTML/WorkerGlobalScope.cpp
|
||||||
HTML/WorkerLocation.cpp
|
HTML/WorkerLocation.cpp
|
||||||
HTML/WorkerNavigator.cpp
|
HTML/WorkerNavigator.cpp
|
||||||
|
HTML/ValidityState.cpp
|
||||||
HighResolutionTime/Performance.cpp
|
HighResolutionTime/Performance.cpp
|
||||||
HighResolutionTime/TimeOrigin.cpp
|
HighResolutionTime/TimeOrigin.cpp
|
||||||
Infra/Base64.cpp
|
Infra/Base64.cpp
|
||||||
|
|
|
@ -467,6 +467,7 @@ class TrackEvent;
|
||||||
struct TransferDataHolder;
|
struct TransferDataHolder;
|
||||||
class TraversableNavigable;
|
class TraversableNavigable;
|
||||||
class UserActivation;
|
class UserActivation;
|
||||||
|
class ValidityState;
|
||||||
class VideoTrack;
|
class VideoTrack;
|
||||||
class VideoTrackList;
|
class VideoTrackList;
|
||||||
class Window;
|
class Window;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <LibWeb/HTML/HTMLDivElement.h>
|
#include <LibWeb/HTML/HTMLDivElement.h>
|
||||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||||
|
#include <LibWeb/HTML/ValidityState.h>
|
||||||
#include <LibWeb/HTML/Numbers.h>
|
#include <LibWeb/HTML/Numbers.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||||
|
@ -82,6 +83,17 @@ void HTMLInputElement::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_image_request);
|
visitor.visit(m_image_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity
|
||||||
|
JS::NonnullGCPtr<ValidityState const> HTMLInputElement::validity() const
|
||||||
|
{
|
||||||
|
auto& vm = this->vm();
|
||||||
|
auto& realm = this->realm();
|
||||||
|
|
||||||
|
dbgln("FIXME: Implement validity attribute getter");
|
||||||
|
|
||||||
|
return vm.heap().allocate<ValidityState>(realm, realm);
|
||||||
|
}
|
||||||
|
|
||||||
JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||||
{
|
{
|
||||||
if (type_state() == TypeAttributeState::Hidden)
|
if (type_state() == TypeAttributeState::Hidden)
|
||||||
|
|
|
@ -174,6 +174,8 @@ public:
|
||||||
virtual void form_associated_element_was_removed(DOM::Node*) override;
|
virtual void form_associated_element_was_removed(DOM::Node*) override;
|
||||||
virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&) override;
|
virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&) override;
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<ValidityState const> validity() const;
|
||||||
|
|
||||||
// ^HTMLElement
|
// ^HTMLElement
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
||||||
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
|
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <HTML/HTMLElement.idl>
|
#import <HTML/HTMLElement.idl>
|
||||||
#import <HTML/HTMLFormElement.idl>
|
#import <HTML/HTMLFormElement.idl>
|
||||||
|
#import <HTML/ValidityState.idl>
|
||||||
#import <FileAPI/FileList.idl>
|
#import <FileAPI/FileList.idl>
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#htmlinputelement
|
// https://html.spec.whatwg.org/multipage/input.html#htmlinputelement
|
||||||
|
@ -48,7 +49,7 @@ interface HTMLInputElement : HTMLElement {
|
||||||
undefined stepDown(optional long n = 1);
|
undefined stepDown(optional long n = 1);
|
||||||
|
|
||||||
[FIXME] readonly attribute boolean willValidate;
|
[FIXME] readonly attribute boolean willValidate;
|
||||||
[FIXME] readonly attribute ValidityState validity;
|
readonly attribute ValidityState validity;
|
||||||
[FIXME] readonly attribute DOMString validationMessage;
|
[FIXME] readonly attribute DOMString validationMessage;
|
||||||
boolean checkValidity();
|
boolean checkValidity();
|
||||||
boolean reportValidity();
|
boolean reportValidity();
|
||||||
|
|
26
Userland/Libraries/LibWeb/HTML/ValidityState.cpp
Normal file
26
Userland/Libraries/LibWeb/HTML/ValidityState.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/HTML/ValidityState.h>
|
||||||
|
#include <LibWeb/Bindings/ValidityStatePrototype.h>
|
||||||
|
|
||||||
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
JS_DEFINE_ALLOCATOR(ValidityState);
|
||||||
|
|
||||||
|
ValidityState::ValidityState(JS::Realm& realm)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValidityState::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
Base::initialize(realm);
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(ValidityState);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
Userland/Libraries/LibWeb/HTML/ValidityState.h
Normal file
27
Userland/Libraries/LibWeb/HTML/ValidityState.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
|
||||||
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#validitystate
|
||||||
|
class ValidityState final : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(ValidityState, Bindings::PlatformObject);
|
||||||
|
JS_DECLARE_ALLOCATOR(ValidityState);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~ValidityState() override = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ValidityState(JS::Realm&);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
15
Userland/Libraries/LibWeb/HTML/ValidityState.idl
Normal file
15
Userland/Libraries/LibWeb/HTML/ValidityState.idl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#validitystate
|
||||||
|
[Exposed=Window]
|
||||||
|
interface ValidityState {
|
||||||
|
[FIXME] readonly attribute boolean valueMissing;
|
||||||
|
[FIXME] readonly attribute boolean typeMismatch;
|
||||||
|
[FIXME] readonly attribute boolean patternMismatch;
|
||||||
|
[FIXME] readonly attribute boolean tooLong;
|
||||||
|
[FIXME] readonly attribute boolean tooShort;
|
||||||
|
[FIXME] readonly attribute boolean rangeUnderflow;
|
||||||
|
[FIXME] readonly attribute boolean rangeOverflow;
|
||||||
|
[FIXME] readonly attribute boolean stepMismatch;
|
||||||
|
[FIXME] readonly attribute boolean badInput;
|
||||||
|
[FIXME] readonly attribute boolean customError;
|
||||||
|
[FIXME] readonly attribute boolean valid;
|
||||||
|
};
|
|
@ -210,6 +210,7 @@ libweb_js_bindings(HTML/TimeRanges)
|
||||||
libweb_js_bindings(HTML/ToggleEvent)
|
libweb_js_bindings(HTML/ToggleEvent)
|
||||||
libweb_js_bindings(HTML/TrackEvent)
|
libweb_js_bindings(HTML/TrackEvent)
|
||||||
libweb_js_bindings(HTML/UserActivation)
|
libweb_js_bindings(HTML/UserActivation)
|
||||||
|
libweb_js_bindings(HTML/ValidityState)
|
||||||
libweb_js_bindings(HTML/VideoTrack)
|
libweb_js_bindings(HTML/VideoTrack)
|
||||||
libweb_js_bindings(HTML/VideoTrackList)
|
libweb_js_bindings(HTML/VideoTrackList)
|
||||||
libweb_js_bindings(HTML/Window GLOBAL)
|
libweb_js_bindings(HTML/Window GLOBAL)
|
||||||
|
|
Loading…
Reference in a new issue