From fe32c9c3bd41e9753a56b5edfa9ad71e94dd243d Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 14 Sep 2021 00:15:41 +0300 Subject: [PATCH] LibWeb: Add the URL::searchParams attribute --- Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp | 1 + Userland/Libraries/LibWeb/URL/URL.cpp | 5 +++++ Userland/Libraries/LibWeb/URL/URL.h | 2 ++ Userland/Libraries/LibWeb/URL/URL.idl | 2 +- Userland/Libraries/LibWeb/URL/URLSearchParams.h | 6 ++++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index f96383ca16..69b540352c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -1481,6 +1481,7 @@ void generate_prototype_implementation(IDL::Interface const& interface) #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index c790aad675..8e6ed49b85 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -75,4 +75,9 @@ DOM::ExceptionOr URL::set_href(String const& href) return {}; } +URLSearchParams const* URL::search_params() const +{ + return m_query; +} + } diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index 8b7588d748..7406aa86e8 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -31,6 +31,8 @@ public: String href() const; DOM::ExceptionOr set_href(String const&); + URLSearchParams const* search_params() const; + String to_json() const; void set_query(Badge, String query) { m_url.set_query(move(query)); } diff --git a/Userland/Libraries/LibWeb/URL/URL.idl b/Userland/Libraries/LibWeb/URL/URL.idl index 933b03a2c0..a32ea6e5e5 100644 --- a/Userland/Libraries/LibWeb/URL/URL.idl +++ b/Userland/Libraries/LibWeb/URL/URL.idl @@ -11,7 +11,7 @@ interface URL { // TODO: attribute USVString port; // TODO: attribute USVString pathname; // TODO: attribute USVString search; - // TODO: [SameObject] readonly attribute URLSearchParams searchParams; + [SameObject] readonly attribute URLSearchParams searchParams; // TODO: attribute USVString hash; USVString toJSON(); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index f5ca945851..f3547a9ba7 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -55,3 +55,9 @@ private: }; } + +namespace Web::Bindings { + +URLSearchParamsWrapper* wrap(JS::GlobalObject&, URL::URLSearchParams&); + +}