diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-20 10:56:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-20 10:56:36 +0100 |
commit | 25a8bd3a8ae2c548f5aa260f06d83a434119ab5b (patch) | |
tree | 746848fa0bb1dc3193dc93546d68639a360b50ea | |
parent | e017fe92e6be10a3793232f43973373baf443914 (diff) | |
download | serenity-25a8bd3a8ae2c548f5aa260f06d83a434119ab5b.zip |
LibWeb: Use the sandboxed ImageDecoder when creating image documents
An image document is the synthetic DOM::Document we create to wrap an
image when you open the URL of an image directly in a web view.
The path that creates these documents will now also call out to the
separate ImageDecoder process for the actual decoding work.
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/FrameLoader.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index b226b3054b..970d181a21 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -17,6 +17,7 @@ #include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/HTML/Parser/HTMLParser.h> +#include <LibWeb/ImageDecoding.h> #include <LibWeb/Loader/FrameLoader.h> #include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Page/Page.h> @@ -72,13 +73,14 @@ static bool build_text_document(DOM::Document& document, const ByteBuffer& data) return true; } -static bool build_image_document(DOM::Document& document, const ByteBuffer& data) +static bool build_image_document(DOM::Document& document, ByteBuffer const& data) { - auto image_decoder = Gfx::ImageDecoder::try_create(data.bytes()); - if (!image_decoder) + NonnullRefPtr decoder = image_decoder_client(); + auto image = decoder->decode_image(data); + if (!image.has_value() || image->frames.is_empty()) return false; - auto frame = image_decoder->frame(0); - auto bitmap = frame.image; + auto const& frame = image->frames[0]; + auto const& bitmap = frame.bitmap; if (!bitmap) return false; |