mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
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.
This commit is contained in:
parent
347838a240
commit
0cacc52990
4 changed files with 12 additions and 5 deletions
|
@ -38,6 +38,7 @@ namespace Web::HTML {
|
|||
|
||||
HTMLImageElement::HTMLImageElement(DOM::Document& document, QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
, m_image_loader(*this)
|
||||
{
|
||||
m_image_loader.on_load = [this] {
|
||||
this->document().update_layout();
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Web::HTML {
|
|||
|
||||
HTMLObjectElement::HTMLObjectElement(DOM::Document& document, QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
, m_image_loader(*this)
|
||||
{
|
||||
m_image_loader.on_load = [this] {
|
||||
m_should_show_fallback_content = false;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Add table
Reference in a new issue