mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:17:35 +00:00
LibWeb: Make URLSearchParams iterable
This uses the new support for the iterable IDL property.
This commit is contained in:
parent
14e99b9b68
commit
01417c82c5
7 changed files with 101 additions and 2 deletions
46
Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h
Normal file
46
Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "URLSearchParams.h"
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/URL/URLSearchParams.h>
|
||||
|
||||
namespace Web::URL {
|
||||
|
||||
class URLSearchParamsIterator : public Bindings::Wrappable
|
||||
, public RefCounted<URLSearchParamsIterator> {
|
||||
public:
|
||||
using WrapperType = Bindings::URLSearchParamsIteratorWrapper;
|
||||
|
||||
static NonnullRefPtr<URLSearchParamsIterator> create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return adopt_ref(*new URLSearchParamsIterator(url_search_params, iteration_kind));
|
||||
}
|
||||
|
||||
JS::Object* next();
|
||||
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
||||
private:
|
||||
explicit URLSearchParamsIterator(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
|
||||
: m_url_search_params(url_search_params)
|
||||
, m_iteration_kind(iteration_kind)
|
||||
{
|
||||
}
|
||||
|
||||
URLSearchParams const& m_url_search_params;
|
||||
JS::Object::PropertyKind m_iteration_kind;
|
||||
size_t m_index { 0 };
|
||||
};
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
URLSearchParamsIteratorWrapper* wrap(JS::GlobalObject&, URL::URLSearchParamsIterator&);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue