mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibWeb: Update HTML image loading algorithm with null checks from spec
The spec has been updated to fix the missing null checks we found:
8f3d1fc6d1
This commit is contained in:
parent
2b89020b6c
commit
2e9b12d327
3 changed files with 29 additions and 31 deletions
|
@ -48,17 +48,21 @@ void ImageRequest::set_current_url(AK::URL url)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#abort-the-image-request
|
||||
void ImageRequest::abort(JS::Realm& realm)
|
||||
void abort_the_image_request(JS::Realm& realm, ImageRequest* image_request)
|
||||
{
|
||||
// 1. Forget image request's image data, if any.
|
||||
m_image_data = nullptr;
|
||||
// 1. If image request is null, then return.
|
||||
if (!image_request)
|
||||
return;
|
||||
|
||||
// 2. Abort any instance of the fetching algorithm for image request,
|
||||
// 2. Forget image request's image data, if any.
|
||||
image_request->set_image_data(nullptr);
|
||||
|
||||
// 3. Abort any instance of the fetching algorithm for image request,
|
||||
// discarding any pending tasks generated by that algorithm.
|
||||
if (m_fetch_controller)
|
||||
m_fetch_controller->abort(realm, {});
|
||||
if (auto fetch_controller = image_request->fetch_controller())
|
||||
fetch_controller->abort(realm, {});
|
||||
|
||||
m_fetch_controller = nullptr;
|
||||
image_request->set_fetch_controller(nullptr);
|
||||
}
|
||||
|
||||
RefPtr<DecodedImageData const> ImageRequest::image_data() const
|
||||
|
@ -92,6 +96,11 @@ void ImageRequest::prepare_for_presentation(HTMLImageElement&)
|
|||
// FIXME: 16. Update req's img element's presentation appropriately.
|
||||
}
|
||||
|
||||
JS::GCPtr<Fetch::Infrastructure::FetchController> ImageRequest::fetch_controller()
|
||||
{
|
||||
return m_fetch_controller.ptr();
|
||||
}
|
||||
|
||||
void ImageRequest::set_fetch_controller(JS::GCPtr<Fetch::Infrastructure::FetchController> fetch_controller)
|
||||
{
|
||||
m_fetch_controller = move(fetch_controller);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue