mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
LibWeb: Evict replaced Resource objects from cache
When a Resource is converted to an ImageResource, evict the original resource from cache. The original resource's data has been moved, so on a warm reload of a page, when that resource is loaded from cache, it would not have any data to actually show.
This commit is contained in:
parent
004f69b535
commit
20eb441cba
Notes:
sideshowbarker
2024-07-17 16:51:34 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/20eb441cba Pull-request: https://github.com/SerenityOS/serenity/pull/13217 Reviewed-by: https://github.com/alimpfard
|
@ -11,6 +11,7 @@
|
||||||
#include <LibTextCodec/Decoder.h>
|
#include <LibTextCodec/Decoder.h>
|
||||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||||
#include <LibWeb/Loader/Resource.h>
|
#include <LibWeb/Loader/Resource.h>
|
||||||
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ Resource::Resource(Type type, Resource& resource)
|
||||||
, m_response_headers(move(resource.m_response_headers))
|
, m_response_headers(move(resource.m_response_headers))
|
||||||
, m_status_code(move(resource.m_status_code))
|
, m_status_code(move(resource.m_status_code))
|
||||||
{
|
{
|
||||||
|
ResourceLoader::the().evict_from_cache(m_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource::~Resource() = default;
|
Resource::~Resource() = default;
|
||||||
|
|
|
@ -280,4 +280,10 @@ void ResourceLoader::clear_cache()
|
||||||
s_resource_cache.clear();
|
s_resource_cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceLoader::evict_from_cache(LoadRequest const& request)
|
||||||
|
{
|
||||||
|
dbgln_if(CACHE_DEBUG, "Removing resource {} from cache", request.url());
|
||||||
|
s_resource_cache.remove(request);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
void set_user_agent(const String& user_agent) { m_user_agent = user_agent; }
|
void set_user_agent(const String& user_agent) { m_user_agent = user_agent; }
|
||||||
|
|
||||||
void clear_cache();
|
void clear_cache();
|
||||||
|
void evict_from_cache(LoadRequest const&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResourceLoader(NonnullRefPtr<Protocol::RequestClient> protocol_client);
|
ResourceLoader(NonnullRefPtr<Protocol::RequestClient> protocol_client);
|
||||||
|
|
Loading…
Reference in a new issue