From 0cacc52990826369a8d4c816b5f6671682851041 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 14 Apr 2021 10:39:12 -0400 Subject: LibWeb: Set Cookie header on and 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. --- Userland/Libraries/LibWeb/Loader/ImageLoader.cpp | 11 +++++++---- Userland/Libraries/LibWeb/Loader/ImageLoader.h | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'Userland/Libraries/LibWeb/Loader') 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 #include #include +#include +#include #include #include 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 }; -- cgit v1.2.3