1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibWeb: Make URL, URLSearchParams & URLSearchParamsIterator GC-allocated

This commit is contained in:
Andreas Kling 2022-09-04 14:04:42 +02:00
parent 0dc2c27fa3
commit fe9c5395d4
11 changed files with 125 additions and 86 deletions

View file

@ -20,17 +20,14 @@ struct QueryParam {
String url_encode(Vector<QueryParam> const&, AK::URL::PercentEncodeSet);
Vector<QueryParam> url_decode(StringView);
class URLSearchParams : public Bindings::Wrappable
, public RefCounted<URLSearchParams> {
class URLSearchParams : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(URLSearchParams, Bindings::PlatformObject);
public:
using WrapperType = Bindings::URLSearchParamsWrapper;
static JS::NonnullGCPtr<URLSearchParams> create(HTML::Window&, Vector<QueryParam> list);
static DOM::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> create_with_global_object(HTML::Window&, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init);
static NonnullRefPtr<URLSearchParams> create(Vector<QueryParam> list)
{
return adopt_ref(*new URLSearchParams(move(list)));
}
static DOM::ExceptionOr<NonnullRefPtr<URLSearchParams>> create_with_global_object(HTML::Window&, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init);
virtual ~URLSearchParams() override;
void append(String const& name, String const& value);
void delete_(String const& name);
@ -50,19 +47,16 @@ private:
friend class URL;
friend class URLSearchParamsIterator;
explicit URLSearchParams(Vector<QueryParam> list)
: m_list(move(list)) {};
URLSearchParams(HTML::Window&, Vector<QueryParam> list);
virtual void visit_edges(Cell::Visitor&) override;
void update();
Vector<QueryParam> m_list;
WeakPtr<URL> m_url;
JS::GCPtr<URL> m_url;
};
}
namespace Web::Bindings {
URLSearchParamsWrapper* wrap(JS::Realm&, URL::URLSearchParams&);
}
WRAPPER_HACK(URLSearchParams, Web::URL)