1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 02:13:56 +09:00

LibWeb: Pass link target to HtmlView's on_link_click callback

This commit is contained in:
Linus Groh 2020-04-24 13:04:10 +01:00 committed by Andreas Kling
parent 95b51e857d
commit 061205b3b3
Notes: sideshowbarker 2024-07-19 07:20:47 +09:00
5 changed files with 5 additions and 4 deletions

View file

@ -133,7 +133,7 @@ Tab::Tab()
update_bookmark_button(url.to_string());
};
m_html_widget->on_link_click = [this](auto& url) {
m_html_widget->on_link_click = [this](auto& url, auto&) {
if (url.starts_with("#")) {
m_html_widget->scroll_to_anchor(url.substring_view(1, url.length() - 1));
} else {

View file

@ -151,7 +151,7 @@ int main(int argc, char* argv[])
open_page(path);
};
html_view.on_link_click = [&](const String& href) {
html_view.on_link_click = [&](const String& href, auto&) {
char* current_path = strdup(history.current().characters());
char* dir_path = dirname(current_path);
char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);

View file

@ -36,6 +36,7 @@ public:
virtual ~HTMLAnchorElement() override;
String href() const { return attribute("href"); }
String target() const { return attribute("target"); }
};
template<>

View file

@ -238,7 +238,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
run_javascript_url(link->href());
} else {
if (on_link_click)
on_link_click(link->href());
on_link_click(link->href(), link->target());
}
} else {
if (event.button() == GUI::MouseButton::Left) {

View file

@ -57,7 +57,7 @@ public:
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
Function<void(const String&)> on_link_click;
Function<void(const String& href, const String& target)> on_link_click;
Function<void(const String&)> on_link_hover;
Function<void(const String&)> on_title_change;
Function<void(const URL&)> on_load_start;