LibWeb/HTML: Make HTMLImageRequests currentURL a String

This is the same type as what is spec'd. We cannot use a URL record
for this member as the spec in some scenarios will set and compare
the URL string to an invalid URL value, such as the empty string.

With implicit string constructors for the URL class removed
explicitly using URL::Parser::basic_parse makes the code look
quite silly in those places.
This commit is contained in:
Shannon Booth 2025-02-22 20:16:45 +13:00 committed by Tim Flynn
parent 9b7fb0850d
commit f857c6a6e6
Notes: github-actions[bot] 2025-03-04 21:26:48 +00:00
4 changed files with 30 additions and 34 deletions

View file

@ -6,6 +6,7 @@
#include <AK/HashTable.h>
#include <LibGfx/Bitmap.h>
#include <LibURL/Parser.h>
#include <LibWeb/Fetch/Fetching/Fetching.h>
#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
@ -67,16 +68,11 @@ void ImageRequest::set_state(State state)
m_state = state;
}
URL::URL const& ImageRequest::current_url() const
{
return m_current_url;
}
void ImageRequest::set_current_url(JS::Realm& realm, URL::URL url)
void ImageRequest::set_current_url(JS::Realm& realm, String url)
{
m_current_url = move(url);
if (m_current_url.is_valid())
m_shared_resource_request = SharedResourceRequest::get_or_create(realm, m_page, m_current_url);
if (auto url = URL::Parser::basic_parse(m_current_url); url.has_value())
m_shared_resource_request = SharedResourceRequest::get_or_create(realm, m_page, url.release_value());
}
// https://html.spec.whatwg.org/multipage/images.html#abort-the-image-request