mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb: Rename SharedImageRequest to SharedResourceRequest
For the SVG <use> element, we want to support loading HTML documents that have a SVG element inside of it pointed to by the URL fragment. In this situation we would need to fetch and parse the entire document in SharedImageRequest (so that we can still cache the SVGs). Rename SharedImageRequest to SharedResourceRequest to make the class a little more generic for future usecases.
This commit is contained in:
parent
2fb5054603
commit
a342370dfb
Notes:
github-actions[bot]
2024-08-05 09:27:38 +00:00
Author: https://github.com/shannonbooth
Commit: a342370dfb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/873
Reviewed-by: https://github.com/tcl3
18 changed files with 92 additions and 92 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/HTML/DecodedImageData.h>
|
||||
#include <LibWeb/HTML/ImageRequest.h>
|
||||
#include <LibWeb/HTML/ListOfAvailableImages.h>
|
||||
#include <LibWeb/HTML/SharedResourceRequest.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/ImageCodecPlugin.h>
|
||||
#include <LibWeb/SVG/SVGDecodedImageData.h>
|
||||
|
@ -39,7 +40,7 @@ ImageRequest::~ImageRequest()
|
|||
void ImageRequest::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_shared_image_request);
|
||||
visitor.visit(m_shared_resource_request);
|
||||
visitor.visit(m_page);
|
||||
visitor.visit(m_image_data);
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ bool ImageRequest::is_available() const
|
|||
|
||||
bool ImageRequest::is_fetching() const
|
||||
{
|
||||
return m_shared_image_request && m_shared_image_request->is_fetching();
|
||||
return m_shared_resource_request && m_shared_resource_request->is_fetching();
|
||||
}
|
||||
|
||||
ImageRequest::State ImageRequest::state() const
|
||||
|
@ -75,7 +76,7 @@ void ImageRequest::set_current_url(JS::Realm& realm, URL::URL url)
|
|||
{
|
||||
m_current_url = move(url);
|
||||
if (m_current_url.is_valid())
|
||||
m_shared_image_request = SharedImageRequest::get_or_create(realm, m_page, m_current_url);
|
||||
m_shared_resource_request = SharedResourceRequest::get_or_create(realm, m_page, m_current_url);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#abort-the-image-request
|
||||
|
@ -90,7 +91,7 @@ void abort_the_image_request(JS::Realm&, ImageRequest* image_request)
|
|||
|
||||
// 3. Abort any instance of the fetching algorithm for image request,
|
||||
// discarding any pending tasks generated by that algorithm.
|
||||
// AD-HOC: We simply don't do this, since our SharedImageRequest may be used by someone else.
|
||||
// AD-HOC: We simply don't do this, since our SharedResourceRequest may be used by someone else.
|
||||
}
|
||||
|
||||
JS::GCPtr<DecodedImageData> ImageRequest::image_data() const
|
||||
|
@ -126,14 +127,14 @@ void ImageRequest::prepare_for_presentation(HTMLImageElement&)
|
|||
|
||||
void ImageRequest::fetch_image(JS::Realm& realm, JS::NonnullGCPtr<Fetch::Infrastructure::Request> request)
|
||||
{
|
||||
VERIFY(m_shared_image_request);
|
||||
m_shared_image_request->fetch_image(realm, request);
|
||||
VERIFY(m_shared_resource_request);
|
||||
m_shared_resource_request->fetch_resource(realm, request);
|
||||
}
|
||||
|
||||
void ImageRequest::add_callbacks(Function<void()> on_finish, Function<void()> on_fail)
|
||||
{
|
||||
VERIFY(m_shared_image_request);
|
||||
m_shared_image_request->add_callbacks(move(on_finish), move(on_fail));
|
||||
VERIFY(m_shared_resource_request);
|
||||
m_shared_resource_request->add_callbacks(move(on_finish), move(on_fail));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue