mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Add type for FrameLoader::load
This should enable to destinguish between IFrame, Reload and Navigation motivated loads in order to call the appropriate hooks. This change is motivated as loading the IFrame test page causes the IFrame url to be added to the history and shows up as the current browser location bar.
This commit is contained in:
parent
6105f063cb
commit
a5b8cc2d0b
Notes:
sideshowbarker
2024-07-19 05:01:01 +09:00
Author: https://github.com/kevmeyer Commit: https://github.com/SerenityOS/serenity/commit/a5b8cc2d0b7 Pull-request: https://github.com/SerenityOS/serenity/pull/2733 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
7 changed files with 19 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -142,7 +142,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, 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<Bindings::LocationObject>)
|
||||
|
@ -150,7 +150,7 @@ void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
|
|||
auto* frame = document().frame();
|
||||
if (!frame)
|
||||
return;
|
||||
frame->loader().load(document().url());
|
||||
frame->loader().load(document().url(), FrameLoader::Type::Reload);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -137,7 +137,7 @@ RefPtr<Document> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue