diff --git a/Libraries/LibWeb/DOM/HTMLIFrameElement.cpp b/Libraries/LibWeb/DOM/HTMLIFrameElement.cpp index 012e4ed448..fcad0465de 100644 --- a/Libraries/LibWeb/DOM/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLIFrameElement.cpp @@ -79,7 +79,7 @@ void HTMLIFrameElement::load_src(const String& value) return; } - m_hosted_frame->loader().load(url); + m_hosted_frame->loader().load(url, FrameLoader::Type::IFrame); } const Document* HTMLIFrameElement::hosted_document() const diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index 53e658b088..4e4d335a8a 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -142,7 +142,7 @@ void Window::did_set_location_href(Badge, const String auto* frame = document().frame(); if (!frame) return; - frame->loader().load(new_href); + frame->loader().load(new_href, FrameLoader::Type::Navigation); } void Window::did_call_location_reload(Badge) @@ -150,7 +150,7 @@ void Window::did_call_location_reload(Badge) auto* frame = document().frame(); if (!frame) return; - frame->loader().load(document().url()); + frame->loader().load(document().url(), FrameLoader::Type::Reload); } } diff --git a/Libraries/LibWeb/Frame/EventHandler.cpp b/Libraries/LibWeb/Frame/EventHandler.cpp index c24636bad7..6c0e804848 100644 --- a/Libraries/LibWeb/Frame/EventHandler.cpp +++ b/Libraries/LibWeb/Frame/EventHandler.cpp @@ -141,7 +141,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt page_client.page_did_click_link(url, link->target(), modifiers); } else { // FIXME: Handle different targets! - m_frame.loader().load(url); + m_frame.loader().load(url, FrameLoader::Type::Navigation); } } } else if (button == GUI::MouseButton::Right) { diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp index 98b5141167..de63ba7ccb 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -137,7 +137,7 @@ RefPtr FrameLoader::create_document_from_mime_type(const ByteBuffer& d return nullptr; } -bool FrameLoader::load(const URL& url) +bool FrameLoader::load(const URL& url, Type type) { dbg() << "FrameLoader::load: " << url; @@ -150,9 +150,10 @@ bool FrameLoader::load(const URL& url) request.set_url(url); set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request)); - frame().page().client().page_did_start_loading(url); + if (type == Type::Navigation) + frame().page().client().page_did_start_loading(url); - if (url.protocol() != "file" && url.protocol() != "about") { + if (type != Type::IFrame && url.protocol() != "file" && url.protocol() != "about") { URL favicon_url; favicon_url.set_protocol(url.protocol()); favicon_url.set_host(url.host()); @@ -211,7 +212,7 @@ void FrameLoader::resource_did_load() // FIXME: Also check HTTP status code before redirecting auto location = resource()->response_headers().get("Location"); if (location.has_value()) { - load(location.value()); + load(location.value(), FrameLoader::Type::Navigation); return; } diff --git a/Libraries/LibWeb/Loader/FrameLoader.h b/Libraries/LibWeb/Loader/FrameLoader.h index 2cad2654c0..d883626c45 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.h +++ b/Libraries/LibWeb/Loader/FrameLoader.h @@ -35,10 +35,16 @@ namespace Web { class FrameLoader final : public ResourceClient { public: + enum class Type { + Navigation, + Reload, + IFrame, + }; + explicit FrameLoader(Frame&); ~FrameLoader(); - bool load(const URL&); + bool load(const URL&, Type); Frame& frame() { return m_frame; } const Frame& frame() const { return m_frame; } diff --git a/Libraries/LibWeb/Page.cpp b/Libraries/LibWeb/Page.cpp index e4f9bebd16..73c3eeeb2c 100644 --- a/Libraries/LibWeb/Page.cpp +++ b/Libraries/LibWeb/Page.cpp @@ -42,7 +42,7 @@ Page::~Page() void Page::load(const URL& url) { - main_frame().loader().load(url); + main_frame().loader().load(url, FrameLoader::Type::Navigation); } Gfx::Palette Page::palette() const diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 8b33f1d0ba..c4ea156190 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -160,6 +160,7 @@ String PageView::selected_text() const void PageView::page_did_layout() { + ASSERT(layout_root()); set_content_size(layout_root()->size().to_int_size()); } @@ -392,7 +393,7 @@ bool PageView::load(const URL& url) if (window()) window()->set_override_cursor(GUI::StandardCursor::None); - return page().main_frame().loader().load(url); + return page().main_frame().loader().load(url, FrameLoader::Type::Navigation); } const LayoutDocument* PageView::layout_root() const