diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-04-14 10:39:12 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-15 09:46:49 +0200 |
commit | 0cacc52990826369a8d4c816b5f6671682851041 (patch) | |
tree | 1c05ce07530073f974e45014430c804779434630 /Userland/Libraries/LibWeb/Loader | |
parent | 347838a24025601f2a2734f0457a6d9b7aedc002 (diff) | |
download | serenity-0cacc52990826369a8d4c816b5f6671682851041.zip |
LibWeb: Set Cookie header on <img> and <object> resource requests
This required passing a reference to the owning HTML*Element to
ImageLoader, the same way that CSSLoader has a reference to its owner.
Diffstat (limited to 'Userland/Libraries/LibWeb/Loader')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ImageLoader.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ImageLoader.h | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp b/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp index 4d049c8d5f..0fa0f481d1 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp @@ -27,21 +27,24 @@ #include <AK/Debug.h> #include <LibCore/Timer.h> #include <LibGfx/Bitmap.h> +#include <LibWeb/DOM/Document.h> +#include <LibWeb/DOM/Element.h> #include <LibWeb/Loader/ImageLoader.h> #include <LibWeb/Loader/ResourceLoader.h> namespace Web { -ImageLoader::ImageLoader() - : m_timer(Core::Timer::construct()) +ImageLoader::ImageLoader(DOM::Element& owner_element) + : m_owner_element(owner_element) + , m_timer(Core::Timer::construct()) { } void ImageLoader::load(const URL& url) { m_loading_state = LoadingState::Loading; - LoadRequest request; - request.set_url(url); + + auto request = LoadRequest::create_for_url_on_page(url, m_owner_element.document().page()); set_resource(ResourceLoader::the().load_resource(Resource::Type::Image, request)); } diff --git a/Userland/Libraries/LibWeb/Loader/ImageLoader.h b/Userland/Libraries/LibWeb/Loader/ImageLoader.h index 1297958366..f4872cdaa0 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ImageLoader.h @@ -34,7 +34,7 @@ namespace Web { class ImageLoader : public ImageResourceClient { public: - ImageLoader(); + ImageLoader(DOM::Element& owner_element); void load(const URL&); @@ -69,6 +69,8 @@ private: Failed, }; + DOM::Element& m_owner_element; + mutable bool m_visible_in_viewport { false }; size_t m_current_frame_index { 0 }; |