mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibWeb: Move some classes from the DOM namespace to the HTML namespace
The following classes are in the HTML spec and thus belong in the HTML namespace: * BeforeUnloadEvent * HTMLFormControlsCollection * RadioNodeList
This commit is contained in:
parent
69f96122b6
commit
13b7355ec1
Notes:
github-actions[bot]
2024-11-02 15:17:36 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/13b7355ec10 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2123
22 changed files with 72 additions and 71 deletions
|
@ -8,7 +8,6 @@ source_set("DOM") {
|
|||
"AccessibilityTreeNode.cpp",
|
||||
"AdoptedStyleSheets.cpp",
|
||||
"Attr.cpp",
|
||||
"BeforeUnloadEvent.cpp",
|
||||
"CDATASection.cpp",
|
||||
"CharacterData.cpp",
|
||||
"Comment.cpp",
|
||||
|
@ -28,7 +27,6 @@ source_set("DOM") {
|
|||
"EventDispatcher.cpp",
|
||||
"EventTarget.cpp",
|
||||
"HTMLCollection.cpp",
|
||||
"HTMLFormControlsCollection.cpp",
|
||||
"IDLEventListener.cpp",
|
||||
"LiveNodeList.cpp",
|
||||
"MutationObserver.cpp",
|
||||
|
@ -44,7 +42,6 @@ source_set("DOM") {
|
|||
"Position.cpp",
|
||||
"ProcessingInstruction.cpp",
|
||||
"QualifiedName.cpp",
|
||||
"RadioNodeList.cpp",
|
||||
"Range.cpp",
|
||||
"ShadowRoot.cpp",
|
||||
"Slot.cpp",
|
||||
|
|
|
@ -18,6 +18,7 @@ source_set("HTML") {
|
|||
"AttributeNames.cpp",
|
||||
"AudioTrack.cpp",
|
||||
"AudioTrackList.cpp",
|
||||
"BeforeUnloadEvent.cpp",
|
||||
"BroadcastChannel.cpp",
|
||||
"BrowsingContext.cpp",
|
||||
"BrowsingContextGroup.cpp",
|
||||
|
@ -73,6 +74,7 @@ source_set("HTML") {
|
|||
"HTMLEmbedElement.cpp",
|
||||
"HTMLFieldSetElement.cpp",
|
||||
"HTMLFontElement.cpp",
|
||||
"HTMLFormControlsCollection.cpp",
|
||||
"HTMLFormElement.cpp",
|
||||
"HTMLFrameElement.cpp",
|
||||
"HTMLFrameSetElement.cpp",
|
||||
|
@ -163,6 +165,7 @@ source_set("HTML") {
|
|||
"PopStateEvent.cpp",
|
||||
"PotentialCORSRequest.cpp",
|
||||
"PromiseRejectionEvent.cpp",
|
||||
"RadioNodeList.cpp",
|
||||
"SelectItem.cpp",
|
||||
"SelectedFile.cpp",
|
||||
"ServiceWorker.cpp",
|
||||
|
|
|
@ -67,7 +67,6 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/DOM/AbortSignal.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/AbstractRange.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/Attr.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/BeforeUnloadEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/CDATASection.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/CharacterData.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/Comment.idl",
|
||||
|
@ -81,7 +80,6 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/DOM/Event.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/EventTarget.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/HTMLCollection.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/HTMLFormControlsCollection.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/MutationObserver.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/MutationRecord.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl",
|
||||
|
@ -90,7 +88,6 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/DOM/NodeIterator.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/NodeList.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/ProcessingInstruction.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/RadioNodeList.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/Range.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/ShadowRoot.idl",
|
||||
"//Userland/Libraries/LibWeb/DOM/StaticRange.idl",
|
||||
|
@ -120,6 +117,7 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/AudioTrack.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/AudioTrackList.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/BeforeUnloadEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/BroadcastChannel.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/CanvasGradient.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/CanvasPattern.idl",
|
||||
|
@ -161,6 +159,7 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFontElement.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFormControlsCollection.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFrameElement.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.idl",
|
||||
|
@ -237,6 +236,7 @@ standard_idl_files = [
|
|||
"//Userland/Libraries/LibWeb/HTML/PluginArray.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/PopStateEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/RadioNodeList.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/ServiceWorker.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.idl",
|
||||
"//Userland/Libraries/LibWeb/HTML/ServiceWorkerRegistration.idl",
|
||||
|
|
|
@ -164,7 +164,6 @@ set(SOURCES
|
|||
DOM/AccessibilityTreeNode.cpp
|
||||
DOM/AdoptedStyleSheets.cpp
|
||||
DOM/Attr.cpp
|
||||
DOM/BeforeUnloadEvent.cpp
|
||||
DOM/CDATASection.cpp
|
||||
DOM/CharacterData.cpp
|
||||
DOM/Comment.cpp
|
||||
|
@ -185,7 +184,6 @@ set(SOURCES
|
|||
DOM/EventDispatcher.cpp
|
||||
DOM/EventTarget.cpp
|
||||
DOM/HTMLCollection.cpp
|
||||
DOM/HTMLFormControlsCollection.cpp
|
||||
DOM/IDLEventListener.cpp
|
||||
DOM/LiveNodeList.cpp
|
||||
DOM/MutationObserver.cpp
|
||||
|
@ -201,7 +199,6 @@ set(SOURCES
|
|||
DOM/Position.cpp
|
||||
DOM/ProcessingInstruction.cpp
|
||||
DOM/QualifiedName.cpp
|
||||
DOM/RadioNodeList.cpp
|
||||
DOM/Range.cpp
|
||||
DOM/ShadowRoot.cpp
|
||||
DOM/Slot.cpp
|
||||
|
@ -274,6 +271,7 @@ set(SOURCES
|
|||
HTML/AttributeNames.cpp
|
||||
HTML/AudioTrack.cpp
|
||||
HTML/AudioTrackList.cpp
|
||||
HTML/BeforeUnloadEvent.cpp
|
||||
HTML/BroadcastChannel.cpp
|
||||
HTML/BrowsingContext.cpp
|
||||
HTML/BrowsingContextGroup.cpp
|
||||
|
@ -343,6 +341,7 @@ set(SOURCES
|
|||
HTML/HTMLEmbedElement.cpp
|
||||
HTML/HTMLFieldSetElement.cpp
|
||||
HTML/HTMLFontElement.cpp
|
||||
HTML/HTMLFormControlsCollection.cpp
|
||||
HTML/HTMLFormElement.cpp
|
||||
HTML/HTMLFrameElement.cpp
|
||||
HTML/HTMLFrameSetElement.cpp
|
||||
|
@ -439,6 +438,7 @@ set(SOURCES
|
|||
HTML/PluginArray.cpp
|
||||
HTML/PotentialCORSRequest.cpp
|
||||
HTML/PromiseRejectionEvent.cpp
|
||||
HTML/RadioNodeList.cpp
|
||||
HTML/Scripting/ClassicScript.cpp
|
||||
HTML/Scripting/Environments.cpp
|
||||
HTML/Scripting/EnvironmentSettingsSnapshot.cpp
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWeb/DOM/AdoptedStyleSheets.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/BeforeUnloadEvent.h>
|
||||
#include <LibWeb/DOM/CDATASection.h>
|
||||
#include <LibWeb/DOM/Comment.h>
|
||||
#include <LibWeb/DOM/CustomEvent.h>
|
||||
|
@ -69,6 +68,7 @@
|
|||
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||
#include <LibWeb/FileAPI/BlobURLStore.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/HTML/BeforeUnloadEvent.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/CustomElements/CustomElementDefinition.h>
|
||||
#include <LibWeb/HTML/CustomElements/CustomElementReactionNames.h>
|
||||
|
@ -1763,7 +1763,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(StringView i
|
|||
// 2. If interface is an ASCII case-insensitive match for any of the strings in the first column in the following table,
|
||||
// then set constructor to the interface in the second column on the same row as the matching string:
|
||||
if (Infra::is_ascii_case_insensitive_match(interface, "beforeunloadevent"sv)) {
|
||||
event = BeforeUnloadEvent::create(realm, FlyString {});
|
||||
event = HTML::BeforeUnloadEvent::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "compositionevent"sv)) {
|
||||
event = UIEvents::CompositionEvent::create(realm, String {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "customevent"sv)) {
|
||||
|
@ -5697,7 +5697,7 @@ Document::StepsToFireBeforeunloadResult Document::steps_to_fire_beforeunload(boo
|
|||
// using BeforeUnloadEvent, with the cancelable attribute initialized to true.
|
||||
auto& global_object = HTML::relevant_global_object(*this);
|
||||
auto& window = verify_cast<HTML::Window>(global_object);
|
||||
auto beforeunload_event = BeforeUnloadEvent::create(realm(), HTML::EventNames::beforeunload);
|
||||
auto beforeunload_event = HTML::BeforeUnloadEvent::create(realm(), HTML::EventNames::beforeunload);
|
||||
beforeunload_event->set_cancelable(true);
|
||||
auto event_firing_result = window.dispatch_event(*beforeunload_event);
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/DOM/BeforeUnloadEvent.h>
|
||||
#include <LibWeb/DOM/DOMEventListener.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/EventDispatcher.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/DOM/IDLEventListener.h>
|
||||
#include <LibWeb/HTML/BeforeUnloadEvent.h>
|
||||
#include <LibWeb/HTML/CloseWatcherManager.h>
|
||||
#include <LibWeb/HTML/ErrorEvent.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
|
@ -691,7 +691,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
auto return_value = *return_value_or_error.value();
|
||||
|
||||
// 5. Process return value as follows:
|
||||
if (is<BeforeUnloadEvent>(event) && event.type() == "beforeunload") {
|
||||
if (is<HTML::BeforeUnloadEvent>(event) && event.type() == "beforeunload") {
|
||||
// -> If event is a BeforeUnloadEvent object and event's type is "beforeunload"
|
||||
// If return value is not null, then:
|
||||
if (!return_value.is_nullish()) {
|
||||
|
@ -699,7 +699,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
event.set_cancelled(true);
|
||||
|
||||
// 2. If event's returnValue attribute's value is the empty string, then set event's returnValue attribute's value to return value.
|
||||
auto& before_unload_event = static_cast<BeforeUnloadEvent&>(event);
|
||||
auto& before_unload_event = static_cast<HTML::BeforeUnloadEvent&>(event);
|
||||
if (before_unload_event.return_value().is_empty())
|
||||
before_unload_event.set_return_value(TRY(return_value.to_string(vm())));
|
||||
}
|
||||
|
|
|
@ -254,7 +254,6 @@ class AbortSignal;
|
|||
class AbstractRange;
|
||||
class AccessibilityTreeNode;
|
||||
class Attr;
|
||||
class BeforeUnloadEvent;
|
||||
class CDATASection;
|
||||
class CharacterData;
|
||||
class Comment;
|
||||
|
@ -273,7 +272,6 @@ class Event;
|
|||
class EventHandler;
|
||||
class EventTarget;
|
||||
class HTMLCollection;
|
||||
class HTMLFormControlsCollection;
|
||||
class IDLEventListener;
|
||||
class LiveNodeList;
|
||||
class MutationObserver;
|
||||
|
@ -286,7 +284,6 @@ class NodeList;
|
|||
class ParentNode;
|
||||
class Position;
|
||||
class ProcessingInstruction;
|
||||
class RadioNodeList;
|
||||
class Range;
|
||||
class RegisteredObserver;
|
||||
class ShadowRoot;
|
||||
|
@ -378,6 +375,7 @@ namespace Web::HTML {
|
|||
class AnimationFrameCallbackDriver;
|
||||
class AudioTrack;
|
||||
class AudioTrackList;
|
||||
class BeforeUnloadEvent;
|
||||
class BroadcastChannel;
|
||||
class BrowsingContext;
|
||||
class BrowsingContextGroup;
|
||||
|
@ -426,6 +424,7 @@ class HTMLElement;
|
|||
class HTMLEmbedElement;
|
||||
class HTMLFieldSetElement;
|
||||
class HTMLFontElement;
|
||||
class HTMLFormControlsCollection;
|
||||
class HTMLFormElement;
|
||||
class HTMLFrameElement;
|
||||
class HTMLFrameSetElement;
|
||||
|
@ -507,6 +506,7 @@ class Path2D;
|
|||
class Plugin;
|
||||
class PluginArray;
|
||||
class PromiseRejectionEvent;
|
||||
class RadioNodeList;
|
||||
class SelectedFile;
|
||||
class ServiceWorkerContainer;
|
||||
class ServiceWorkerRegistration;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <LibWeb/Bindings/BeforeUnloadEventPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/BeforeUnloadEvent.h>
|
||||
#include <LibWeb/HTML/BeforeUnloadEvent.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BeforeUnloadEvent);
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
class BeforeUnloadEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(BeforeUnloadEvent, DOM::Event);
|
|
@ -8,20 +8,21 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
#include <LibWeb/DOM/HTMLFormControlsCollection.h>
|
||||
#include <LibWeb/DOM/ParentNode.h>
|
||||
#include <LibWeb/HTML/HTMLFormControlsCollection.h>
|
||||
#include <LibWeb/HTML/RadioNodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(HTMLFormControlsCollection);
|
||||
|
||||
JS::NonnullGCPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
|
||||
JS::NonnullGCPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(DOM::ParentNode& root, Scope scope, Function<bool(DOM::Element const&)> filter)
|
||||
{
|
||||
return root.heap().allocate<HTMLFormControlsCollection>(root.realm(), root, scope, move(filter));
|
||||
}
|
||||
|
||||
HTMLFormControlsCollection::HTMLFormControlsCollection(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
|
||||
: HTMLCollection(root, scope, move(filter))
|
||||
HTMLFormControlsCollection::HTMLFormControlsCollection(DOM::ParentNode& root, Scope scope, Function<bool(DOM::Element const&)> filter)
|
||||
: DOM::HTMLCollection(root, scope, move(filter))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,7 @@ void HTMLFormControlsCollection::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlformcontrolscollection-nameditem
|
||||
Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::named_item_or_radio_node_list(FlyString const& name) const
|
||||
Variant<Empty, DOM::Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::named_item_or_radio_node_list(FlyString const& name) const
|
||||
{
|
||||
// 1. If name is the empty string, return null and stop the algorithm.
|
||||
if (name.is_empty())
|
||||
|
@ -42,7 +43,7 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
|
|||
|
||||
// 2. If, at the time the method is called, there is exactly one node in the collection that has either an id attribute or a name attribute equal to name, then return that node and stop the algorithm.
|
||||
// 3. Otherwise, if there are no nodes in the collection that have either an id attribute or a name attribute equal to name, then return null and stop the algorithm.
|
||||
Element* matching_element = nullptr;
|
||||
DOM::Element* matching_element = nullptr;
|
||||
bool multiple_matching = false;
|
||||
|
||||
auto collection = collect_matching_elements();
|
||||
|
@ -67,11 +68,11 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
|
|||
// 4. Otherwise, create a new RadioNodeList object representing a live view of the HTMLFormControlsCollection object, further filtered so that the only nodes in the
|
||||
// RadioNodeList object are those that have either an id attribute or a name attribute equal to name. The nodes in the RadioNodeList object must be sorted in tree
|
||||
// order. Return that RadioNodeList object.
|
||||
return JS::make_handle(RadioNodeList::create(realm(), root(), LiveNodeList::Scope::Descendants, [name](Node const& node) {
|
||||
if (!is<Element>(node))
|
||||
return JS::make_handle(RadioNodeList::create(realm(), root(), DOM::LiveNodeList::Scope::Descendants, [name](auto const& node) {
|
||||
if (!is<DOM::Element>(node))
|
||||
return false;
|
||||
|
||||
auto const& element = verify_cast<Element>(node);
|
||||
auto const& element = verify_cast<DOM::Element>(node);
|
||||
return element.id() == name || element.name() == name;
|
||||
}));
|
||||
}
|
|
@ -7,20 +7,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
#include <LibWeb/DOM/RadioNodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
class HTMLFormControlsCollection : public HTMLCollection {
|
||||
WEB_PLATFORM_OBJECT(HTMLFormControlsCollection, HTMLCollection);
|
||||
class HTMLFormControlsCollection : public DOM::HTMLCollection {
|
||||
WEB_PLATFORM_OBJECT(HTMLFormControlsCollection, DOM::HTMLCollection);
|
||||
JS_DECLARE_ALLOCATOR(HTMLFormControlsCollection);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<HTMLFormControlsCollection> create(ParentNode& root, Scope, ESCAPING Function<bool(Element const&)> filter);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<HTMLFormControlsCollection> create(DOM::ParentNode& root, Scope, ESCAPING Function<bool(DOM::Element const&)> filter);
|
||||
|
||||
virtual ~HTMLFormControlsCollection() override;
|
||||
|
||||
Variant<Empty, Element*, JS::Handle<RadioNodeList>> named_item_or_radio_node_list(FlyString const& name) const;
|
||||
Variant<Empty, DOM::Element*, JS::Handle<RadioNodeList>> named_item_or_radio_node_list(FlyString const& name) const;
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
@ -28,7 +27,7 @@ protected:
|
|||
virtual JS::Value named_item_value(FlyString const& name) const final;
|
||||
|
||||
private:
|
||||
HTMLFormControlsCollection(ParentNode& root, Scope, ESCAPING Function<bool(Element const&)> filter);
|
||||
HTMLFormControlsCollection(DOM::ParentNode& root, Scope, ESCAPING Function<bool(DOM::Element const&)> filter);
|
||||
};
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#import <DOM/HTMLCollection.idl>
|
||||
#import <DOM/RadioNodeList.idl>
|
||||
#import <HTML/RadioNodeList.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#htmlformcontrolscollection
|
||||
[Exposed=Window]
|
|
@ -14,7 +14,6 @@
|
|||
#include <LibWeb/DOM/DOMTokenList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/HTMLFormControlsCollection.h>
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
|
@ -22,6 +21,7 @@
|
|||
#include <LibWeb/HTML/HTMLButtonElement.h>
|
||||
#include <LibWeb/HTML/HTMLDialogElement.h>
|
||||
#include <LibWeb/HTML/HTMLFieldSetElement.h>
|
||||
#include <LibWeb/HTML/HTMLFormControlsCollection.h>
|
||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
|
@ -29,6 +29,7 @@
|
|||
#include <LibWeb/HTML/HTMLOutputElement.h>
|
||||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||
#include <LibWeb/HTML/HTMLTextAreaElement.h>
|
||||
#include <LibWeb/HTML/RadioNodeList.h>
|
||||
#include <LibWeb/HTML/SubmitEvent.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
|
@ -516,11 +517,11 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const&
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-elements
|
||||
JS::NonnullGCPtr<DOM::HTMLFormControlsCollection> HTMLFormElement::elements() const
|
||||
JS::NonnullGCPtr<HTMLFormControlsCollection> HTMLFormElement::elements() const
|
||||
{
|
||||
if (!m_elements) {
|
||||
auto& root = verify_cast<ParentNode>(const_cast<HTMLFormElement*>(this)->root());
|
||||
m_elements = DOM::HTMLFormControlsCollection::create(root, DOM::HTMLCollection::Scope::Descendants, [this](Element const& element) {
|
||||
m_elements = HTMLFormControlsCollection::create(root, DOM::HTMLCollection::Scope::Descendants, [this](Element const& element) {
|
||||
return is_form_control(element, *this);
|
||||
});
|
||||
}
|
||||
|
@ -1021,7 +1022,7 @@ JS::Value HTMLFormElement::named_item_value(FlyString const& name) const
|
|||
// 1. Let candidates be a live RadioNodeList object containing all the listed elements, whose form owner is the form
|
||||
// element, that have either an id attribute or a name attribute equal to name, with the exception of input
|
||||
// elements whose type attribute is in the Image Button state, in tree order.
|
||||
auto candidates = DOM::RadioNodeList::create(realm, root, DOM::LiveNodeList::Scope::Descendants, [this, name](auto& node) -> bool {
|
||||
auto candidates = RadioNodeList::create(realm, root, DOM::LiveNodeList::Scope::Descendants, [this, name](auto& node) -> bool {
|
||||
if (!is<DOM::Element>(node))
|
||||
return false;
|
||||
auto const& element = static_cast<DOM::Element const&>(node);
|
||||
|
@ -1038,7 +1039,7 @@ JS::Value HTMLFormElement::named_item_value(FlyString const& name) const
|
|||
// whose form owner is the form element, that have either an id attribute or a name attribute equal to name,
|
||||
// in tree order.
|
||||
if (candidates->length() == 0) {
|
||||
candidates = DOM::RadioNodeList::create(realm, root, DOM::LiveNodeList::Scope::Descendants, [this, name](auto& node) -> bool {
|
||||
candidates = RadioNodeList::create(realm, root, DOM::LiveNodeList::Scope::Descendants, [this, name](auto& node) -> bool {
|
||||
if (!is<HTMLImageElement>(node))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
Vector<JS::NonnullGCPtr<DOM::Element>> get_submittable_elements();
|
||||
|
||||
JS::NonnullGCPtr<DOM::HTMLFormControlsCollection> elements() const;
|
||||
JS::NonnullGCPtr<HTMLFormControlsCollection> elements() const;
|
||||
unsigned length() const;
|
||||
|
||||
WebIDL::ExceptionOr<bool> check_validity();
|
||||
|
@ -136,7 +136,7 @@ private:
|
|||
};
|
||||
HashMap<FlyString, PastNameEntry> mutable m_past_names_map;
|
||||
|
||||
JS::GCPtr<DOM::HTMLFormControlsCollection> mutable m_elements;
|
||||
JS::GCPtr<HTMLFormControlsCollection> mutable m_elements;
|
||||
|
||||
bool m_constructing_entry_list { false };
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#import <DOM/HTMLFormControlsCollection.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
#import <HTML/HTMLFormControlsCollection.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#attr-form-autocomplete
|
||||
[MissingValueDefault=on, InvalidValueDefault=on]
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/RadioNodeListPrototype.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/RadioNodeList.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/HTML/RadioNodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(RadioNodeList);
|
||||
|
||||
JS::NonnullGCPtr<RadioNodeList> RadioNodeList::create(JS::Realm& realm, Node const& root, Scope scope, Function<bool(Node const&)> filter)
|
||||
JS::NonnullGCPtr<RadioNodeList> RadioNodeList::create(JS::Realm& realm, DOM::Node const& root, Scope scope, Function<bool(DOM::Node const&)> filter)
|
||||
{
|
||||
return realm.heap().allocate<RadioNodeList>(realm, realm, root, scope, move(filter));
|
||||
}
|
||||
|
||||
RadioNodeList::RadioNodeList(JS::Realm& realm, Node const& root, Scope scope, Function<bool(Node const&)> filter)
|
||||
: LiveNodeList(realm, root, scope, move(filter))
|
||||
RadioNodeList::RadioNodeList(JS::Realm& realm, DOM::Node const& root, Scope scope, Function<bool(DOM::Node const&)> filter)
|
||||
: DOM::LiveNodeList(realm, root, scope, move(filter))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,13 @@ void RadioNodeList::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(RadioNodeList);
|
||||
}
|
||||
|
||||
static HTML::HTMLInputElement const* radio_button(Node const& node)
|
||||
static HTMLInputElement const* radio_button(DOM::Node const& node)
|
||||
{
|
||||
if (!is<HTML::HTMLInputElement>(node))
|
||||
if (!is<HTMLInputElement>(node))
|
||||
return nullptr;
|
||||
|
||||
auto const& input_element = verify_cast<HTML::HTMLInputElement>(node);
|
||||
if (input_element.type_state() != HTML::HTMLInputElement::TypeAttributeState::RadioButton)
|
||||
auto const& input_element = verify_cast<HTMLInputElement>(node);
|
||||
if (input_element.type_state() != HTMLInputElement::TypeAttributeState::RadioButton)
|
||||
return nullptr;
|
||||
|
||||
return &input_element;
|
||||
|
@ -49,7 +49,7 @@ FlyString RadioNodeList::value() const
|
|||
{
|
||||
// 1. Let element be the first element in tree order represented by the RadioNodeList object that is an input element whose type
|
||||
// attribute is in the Radio Button state and whose checkedness is true. Otherwise, let it be null.
|
||||
auto* element = verify_cast<HTML::HTMLInputElement>(first_matching([](Node const& node) -> bool {
|
||||
auto* element = verify_cast<HTMLInputElement>(first_matching([](DOM::Node const& node) -> bool {
|
||||
auto const* button = radio_button(node);
|
||||
if (!button)
|
||||
return false;
|
||||
|
@ -63,23 +63,23 @@ FlyString RadioNodeList::value() const
|
|||
|
||||
// 3. If element is an element with no value attribute, return the string "on".
|
||||
// 4. Otherwise, return the value of element's value attribute.
|
||||
return element->get_attribute(HTML::AttributeNames::value).value_or("on"_string);
|
||||
return element->get_attribute(AttributeNames::value).value_or("on"_string);
|
||||
}
|
||||
|
||||
void RadioNodeList::set_value(FlyString const& value)
|
||||
{
|
||||
HTML::HTMLInputElement* element = nullptr;
|
||||
HTMLInputElement* element = nullptr;
|
||||
|
||||
// 1. If the new value is the string "on": let element be the first element in tree order represented by the RadioNodeList object
|
||||
// that is an input element whose type attribute is in the Radio Button state and whose value content attribute is either absent,
|
||||
// or present and equal to the new value, if any. If no such element exists, then instead let element be null.
|
||||
if (value == "on"sv) {
|
||||
element = verify_cast<HTML::HTMLInputElement>(first_matching([&value](auto const& node) {
|
||||
element = verify_cast<HTMLInputElement>(first_matching([&value](auto const& node) {
|
||||
auto const* button = radio_button(node);
|
||||
if (!button)
|
||||
return false;
|
||||
|
||||
auto const maybe_value = button->get_attribute(HTML::AttributeNames::value);
|
||||
auto const maybe_value = button->get_attribute(AttributeNames::value);
|
||||
return !maybe_value.has_value() || maybe_value.value() == value;
|
||||
}));
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ void RadioNodeList::set_value(FlyString const& value)
|
|||
// type attribute is in the Radio Button state and whose value content attribute is present and equal to the new value, if any. If
|
||||
// no such element exists, then instead let element be null.
|
||||
else {
|
||||
element = verify_cast<HTML::HTMLInputElement>(first_matching([&value](auto const& node) {
|
||||
element = verify_cast<HTMLInputElement>(first_matching([&value](auto const& node) {
|
||||
auto const* button = radio_button(node);
|
||||
if (!button)
|
||||
return false;
|
||||
|
||||
auto const maybe_value = button->get_attribute(HTML::AttributeNames::value);
|
||||
auto const maybe_value = button->get_attribute(AttributeNames::value);
|
||||
return maybe_value.has_value() && maybe_value.value() == value;
|
||||
}));
|
||||
}
|
|
@ -8,15 +8,15 @@
|
|||
|
||||
#include <LibWeb/DOM/LiveNodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#radionodelist
|
||||
class RadioNodeList : public LiveNodeList {
|
||||
WEB_PLATFORM_OBJECT(RadioNodeList, LiveNodeList);
|
||||
class RadioNodeList : public DOM::LiveNodeList {
|
||||
WEB_PLATFORM_OBJECT(RadioNodeList, DOM::LiveNodeList);
|
||||
JS_DECLARE_ALLOCATOR(RadioNodeList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<RadioNodeList> create(JS::Realm& realm, Node const& root, Scope scope, ESCAPING Function<bool(Node const&)> filter);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<RadioNodeList> create(JS::Realm& realm, DOM::Node const& root, Scope scope, ESCAPING Function<bool(DOM::Node const&)> filter);
|
||||
|
||||
virtual ~RadioNodeList() override;
|
||||
|
||||
|
@ -27,7 +27,7 @@ protected:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
private:
|
||||
explicit RadioNodeList(JS::Realm& realm, Node const& root, Scope scope, ESCAPING Function<bool(Node const&)> filter);
|
||||
explicit RadioNodeList(JS::Realm& realm, DOM::Node const& root, Scope scope, ESCAPING Function<bool(DOM::Node const&)> filter);
|
||||
};
|
||||
|
||||
}
|
|
@ -48,7 +48,6 @@ libweb_js_bindings(DOM/AbstractRange)
|
|||
libweb_js_bindings(DOM/Attr)
|
||||
libweb_js_bindings(DOM/AbortController)
|
||||
libweb_js_bindings(DOM/AbortSignal)
|
||||
libweb_js_bindings(DOM/BeforeUnloadEvent)
|
||||
libweb_js_bindings(DOM/CDATASection)
|
||||
libweb_js_bindings(DOM/CharacterData)
|
||||
libweb_js_bindings(DOM/Comment)
|
||||
|
@ -62,7 +61,6 @@ libweb_js_bindings(DOM/Element)
|
|||
libweb_js_bindings(DOM/Event)
|
||||
libweb_js_bindings(DOM/EventTarget)
|
||||
libweb_js_bindings(DOM/HTMLCollection)
|
||||
libweb_js_bindings(DOM/HTMLFormControlsCollection)
|
||||
libweb_js_bindings(DOM/MutationObserver)
|
||||
libweb_js_bindings(DOM/MutationRecord)
|
||||
libweb_js_bindings(DOM/NamedNodeMap)
|
||||
|
@ -71,7 +69,6 @@ libweb_js_bindings(DOM/NodeFilter)
|
|||
libweb_js_bindings(DOM/NodeIterator)
|
||||
libweb_js_bindings(DOM/NodeList)
|
||||
libweb_js_bindings(DOM/ProcessingInstruction)
|
||||
libweb_js_bindings(DOM/RadioNodeList)
|
||||
libweb_js_bindings(DOM/Range)
|
||||
libweb_js_bindings(DOM/ShadowRoot)
|
||||
libweb_js_bindings(DOM/StaticRange)
|
||||
|
@ -102,6 +99,7 @@ libweb_js_bindings(Geometry/DOMRectList)
|
|||
libweb_js_bindings(Geometry/DOMRectReadOnly)
|
||||
libweb_js_bindings(HTML/AudioTrack)
|
||||
libweb_js_bindings(HTML/AudioTrackList)
|
||||
libweb_js_bindings(HTML/BeforeUnloadEvent)
|
||||
libweb_js_bindings(HTML/BroadcastChannel)
|
||||
libweb_js_bindings(HTML/CanvasGradient)
|
||||
libweb_js_bindings(HTML/CanvasPattern)
|
||||
|
@ -144,6 +142,7 @@ libweb_js_bindings(HTML/HTMLElement)
|
|||
libweb_js_bindings(HTML/HTMLEmbedElement)
|
||||
libweb_js_bindings(HTML/HTMLFieldSetElement)
|
||||
libweb_js_bindings(HTML/HTMLFontElement)
|
||||
libweb_js_bindings(HTML/HTMLFormControlsCollection)
|
||||
libweb_js_bindings(HTML/HTMLFormElement)
|
||||
libweb_js_bindings(HTML/HTMLFrameElement)
|
||||
libweb_js_bindings(HTML/HTMLFrameSetElement)
|
||||
|
@ -219,6 +218,7 @@ libweb_js_bindings(HTML/Plugin)
|
|||
libweb_js_bindings(HTML/PluginArray)
|
||||
libweb_js_bindings(HTML/PopStateEvent)
|
||||
libweb_js_bindings(HTML/PromiseRejectionEvent)
|
||||
libweb_js_bindings(HTML/RadioNodeList)
|
||||
libweb_js_bindings(HTML/ServiceWorker)
|
||||
libweb_js_bindings(HTML/ServiceWorkerContainer)
|
||||
libweb_js_bindings(HTML/ServiceWorkerRegistration)
|
||||
|
|
Loading…
Reference in a new issue