mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 22:14:58 +00:00

With this change, we now have ~1200 CellAllocators across both LibJS and LibWeb in a normal WebContent instance. This gives us a minimum heap size of 4.7 MiB in the scenario where we only have one cell allocated per type. Of course, in practice there will be many more of each type, so the effective overhead is quite a bit smaller than that in practice. I left a few types unconverted to this mechanism because I got tired of doing this. :^)
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/URL.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
|
|
|
namespace Web::URL {
|
|
|
|
struct QueryParam {
|
|
String name;
|
|
String value;
|
|
};
|
|
ErrorOr<String> url_encode(Vector<QueryParam> const&, StringView encoding = "UTF-8"sv);
|
|
ErrorOr<Vector<QueryParam>> url_decode(StringView);
|
|
|
|
class URLSearchParams : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(URLSearchParams, Bindings::PlatformObject);
|
|
JS_DECLARE_ALLOCATOR(URLSearchParams);
|
|
|
|
public:
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> create(JS::Realm&, Vector<QueryParam> list);
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> construct_impl(JS::Realm&, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init);
|
|
|
|
virtual ~URLSearchParams() override;
|
|
|
|
size_t size() const;
|
|
WebIDL::ExceptionOr<void> append(String const& name, String const& value);
|
|
WebIDL::ExceptionOr<void> delete_(String const& name);
|
|
Optional<String> get(String const& name);
|
|
WebIDL::ExceptionOr<Vector<String>> get_all(String const& name);
|
|
bool has(String const& name);
|
|
WebIDL::ExceptionOr<void> set(String const& name, String const& value);
|
|
|
|
WebIDL::ExceptionOr<void> sort();
|
|
|
|
WebIDL::ExceptionOr<String> to_string() const;
|
|
|
|
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(String const&, String const&)>;
|
|
JS::ThrowCompletionOr<void> for_each(ForEachCallback);
|
|
|
|
private:
|
|
friend class URL;
|
|
friend class URLSearchParamsIterator;
|
|
|
|
URLSearchParams(JS::Realm&, Vector<QueryParam> list);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
WebIDL::ExceptionOr<void> update();
|
|
|
|
Vector<QueryParam> m_list;
|
|
JS::GCPtr<URL> m_url;
|
|
};
|
|
|
|
}
|