mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Add stub implementation of HTMLOptionsCollection
This is a subtype of `DOM::HTMLCollection` that only holds `HTMLOptionElement`s. In this stub implementation only `item`, `namedItem` and `length`, inherited from HTMLCollection, are exposed. This is good enough for applications that only read the collection.
This commit is contained in:
parent
6f4dde253f
commit
624527f15e
Notes:
sideshowbarker
2024-07-17 17:19:47 +09:00
Author: https://github.com/skyrising Commit: https://github.com/SerenityOS/serenity/commit/624527f15e Pull-request: https://github.com/SerenityOS/serenity/pull/13071
6 changed files with 67 additions and 0 deletions
|
@ -159,6 +159,8 @@
|
|||
#include <LibWeb/Bindings/HTMLOptGroupElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLOptionElementConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLOptionElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLOptionsCollectionConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLOptionsCollectionPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLOutputElementConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLOutputElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLParagraphElementConstructor.h>
|
||||
|
@ -407,6 +409,7 @@
|
|||
ADD_WINDOW_OBJECT_INTERFACE(HTMLOListElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLOptGroupElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLOptionElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLOptionsCollection) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLOutputElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLParagraphElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLParamElement) \
|
||||
|
|
|
@ -172,6 +172,7 @@ set(SOURCES
|
|||
HTML/HTMLObjectElement.cpp
|
||||
HTML/HTMLOptGroupElement.cpp
|
||||
HTML/HTMLOptionElement.cpp
|
||||
HTML/HTMLOptionsCollection.cpp
|
||||
HTML/HTMLOutputElement.cpp
|
||||
HTML/HTMLParagraphElement.cpp
|
||||
HTML/HTMLParamElement.cpp
|
||||
|
@ -522,6 +523,7 @@ libweb_js_wrapper(HTML/HTMLObjectElement)
|
|||
libweb_js_wrapper(HTML/HTMLOListElement)
|
||||
libweb_js_wrapper(HTML/HTMLOptGroupElement)
|
||||
libweb_js_wrapper(HTML/HTMLOptionElement)
|
||||
libweb_js_wrapper(HTML/HTMLOptionsCollection)
|
||||
libweb_js_wrapper(HTML/HTMLOutputElement)
|
||||
libweb_js_wrapper(HTML/HTMLParagraphElement)
|
||||
libweb_js_wrapper(HTML/HTMLParamElement)
|
||||
|
|
|
@ -199,6 +199,7 @@ class HTMLObjectElement;
|
|||
class HTMLOListElement;
|
||||
class HTMLOptGroupElement;
|
||||
class HTMLOptionElement;
|
||||
class HTMLOptionsCollection;
|
||||
class HTMLOutputElement;
|
||||
class HTMLParagraphElement;
|
||||
class HTMLParamElement;
|
||||
|
@ -446,6 +447,7 @@ class HTMLObjectElementWrapper;
|
|||
class HTMLOListElementWrapper;
|
||||
class HTMLOptGroupElementWrapper;
|
||||
class HTMLOptionElementWrapper;
|
||||
class HTMLOptionsCollectionWrapper;
|
||||
class HTMLOutputElementWrapper;
|
||||
class HTMLParagraphElementWrapper;
|
||||
class HTMLParamElementWrapper;
|
||||
|
|
16
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp
Normal file
16
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/HTMLOptionsCollection.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
|
||||
: DOM::HTMLCollection(root, move(filter))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
32
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h
Normal file
32
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class HTMLOptionsCollection final : public DOM::HTMLCollection {
|
||||
public:
|
||||
using WrapperType = Bindings::HTMLOptionsCollectionWrapper;
|
||||
|
||||
static NonnullRefPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
|
||||
{
|
||||
return adopt_ref(*new HTMLOptionsCollection(root, move(filter)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HTMLOptionsCollectionWrapper* wrap(JS::GlobalObject&, HTML::HTMLOptionsCollection&);
|
||||
|
||||
}
|
12
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.idl
Normal file
12
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.idl
Normal file
|
@ -0,0 +1,12 @@
|
|||
#import <DOM/HTMLCollection.idl>
|
||||
#import <HTML/HTMLOptionElement.idl>
|
||||
#import <HTML/HTMLOptGroupElement.idl>
|
||||
|
||||
[Exposed=Window]
|
||||
interface HTMLOptionsCollection : HTMLCollection {
|
||||
// [CEReactions] attribute unsigned long length; // shadows inherited length
|
||||
// [CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option);
|
||||
// [CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
||||
// [CEReactions] undefined remove(long index);
|
||||
// attribute long selectedIndex;
|
||||
};
|
Loading…
Reference in a new issue