summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Demos/WebView/WebContentClient.cpp16
-rw-r--r--Demos/WebView/WebContentClient.h2
-rw-r--r--Demos/WebView/WebContentView.cpp12
-rw-r--r--Demos/WebView/WebContentView.h3
-rw-r--r--Demos/WebView/main.cpp15
-rw-r--r--Services/WebContent/PageHost.cpp10
-rw-r--r--Services/WebContent/PageHost.h2
-rw-r--r--Services/WebContent/WebContentClient.ipc2
8 files changed, 61 insertions, 1 deletions
diff --git a/Demos/WebView/WebContentClient.cpp b/Demos/WebView/WebContentClient.cpp
index 7d799c9c2c..3835c3ebbb 100644
--- a/Demos/WebView/WebContentClient.cpp
+++ b/Demos/WebView/WebContentClient.cpp
@@ -98,3 +98,19 @@ void WebContentClient::handle(const Messages::WebContentClient::DidRequestScroll
#endif
m_view.notify_server_did_request_scroll_into_view({}, message.rect());
}
+
+void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& message)
+{
+#ifdef DEBUG_SPAM
+ dbg() << "handle: WebContentClient::DidHoverLink! url=" << message.url();
+#endif
+ m_view.notify_server_did_hover_link({}, message.url());
+}
+
+void WebContentClient::handle(const Messages::WebContentClient::DidUnhoverLink&)
+{
+#ifdef DEBUG_SPAM
+ dbg() << "handle: WebContentClient::DidUnhoverLink!";
+#endif
+ m_view.notify_server_did_unhover_link({});
+}
diff --git a/Demos/WebView/WebContentClient.h b/Demos/WebView/WebContentClient.h
index f7aaa6ddf5..7f51a53861 100644
--- a/Demos/WebView/WebContentClient.h
+++ b/Demos/WebView/WebContentClient.h
@@ -51,6 +51,8 @@ private:
virtual void handle(const Messages::WebContentClient::DidLayout&) override;
virtual void handle(const Messages::WebContentClient::DidChangeTitle&) override;
virtual void handle(const Messages::WebContentClient::DidRequestScrollIntoView&) override;
+ virtual void handle(const Messages::WebContentClient::DidHoverLink&) override;
+ virtual void handle(const Messages::WebContentClient::DidUnhoverLink&) override;
WebContentView& m_view;
};
diff --git a/Demos/WebView/WebContentView.cpp b/Demos/WebView/WebContentView.cpp
index 490ecfad18..90630c6c5d 100644
--- a/Demos/WebView/WebContentView.cpp
+++ b/Demos/WebView/WebContentView.cpp
@@ -125,6 +125,18 @@ void WebContentView::notify_server_did_request_scroll_into_view(Badge<WebContent
scroll_into_view(rect, true, true);
}
+void WebContentView::notify_server_did_hover_link(Badge<WebContentClient>, const URL& url)
+{
+ if (on_link_hover)
+ on_link_hover(url);
+}
+
+void WebContentView::notify_server_did_unhover_link(Badge<WebContentClient>)
+{
+ if (on_link_hover)
+ on_link_hover({});
+}
+
void WebContentView::did_scroll()
{
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
diff --git a/Demos/WebView/WebContentView.h b/Demos/WebView/WebContentView.h
index 4d448dd956..87a7d2fab1 100644
--- a/Demos/WebView/WebContentView.h
+++ b/Demos/WebView/WebContentView.h
@@ -40,6 +40,7 @@ public:
void load(const URL&);
Function<void(const String&)> on_title_change;
+ Function<void(const URL&)> on_link_hover;
void notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size);
void notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id);
@@ -47,6 +48,8 @@ public:
void notify_server_did_change_selection(Badge<WebContentClient>);
void notify_server_did_change_title(Badge<WebContentClient>, const String&);
void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect&);
+ void notify_server_did_hover_link(Badge<WebContentClient>, const URL&);
+ void notify_server_did_unhover_link(Badge<WebContentClient>);
private:
WebContentView();
diff --git a/Demos/WebView/main.cpp b/Demos/WebView/main.cpp
index 3ea4563068..3d6446bb98 100644
--- a/Demos/WebView/main.cpp
+++ b/Demos/WebView/main.cpp
@@ -27,6 +27,8 @@
#include "WebContentView.h"
#include <AK/URL.h>
#include <LibGUI/Application.h>
+#include <LibGUI/BoxLayout.h>
+#include <LibGUI/StatusBar.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
@@ -34,7 +36,11 @@ int main(int argc, char** argv)
{
auto app = GUI::Application::construct(argc, argv);
auto window = GUI::Window::construct();
- auto& view = window->set_main_widget<WebContentView>();
+ auto& main_widget = window->set_main_widget<GUI::Widget>();
+ main_widget.set_fill_with_background_color(true);
+ main_widget.set_layout<GUI::VerticalBoxLayout>();
+ auto& view = main_widget.add<WebContentView>();
+ auto& statusbar = main_widget.add<GUI::StatusBar>();
window->set_title("WebView");
window->set_rect(100, 100, 640, 480);
window->show();
@@ -43,6 +49,13 @@ int main(int argc, char** argv)
window->set_title(String::format("%s - WebView", title.characters()));
};
+ view.on_link_hover = [&](auto& url) {
+ if (url.is_valid())
+ statusbar.set_text(url.to_string());
+ else
+ statusbar.set_text("");
+ };
+
view.load("file:///res/html/misc/welcome.html");
return app->exec();
diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp
index d72a4bc945..7f35aea60d 100644
--- a/Services/WebContent/PageHost.cpp
+++ b/Services/WebContent/PageHost.cpp
@@ -134,4 +134,14 @@ void PageHost::page_did_request_scroll_into_view(const Gfx::IntRect& rect)
m_client.post_message(Messages::WebContentClient::DidRequestScrollIntoView(rect));
}
+void PageHost::page_did_hover_link(const URL& url)
+{
+ m_client.post_message(Messages::WebContentClient::DidHoverLink(url));
+}
+
+void PageHost::page_did_unhover_link()
+{
+ m_client.post_message(Messages::WebContentClient::DidUnhoverLink());
+}
+
}
diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h
index 14b2e41b2f..eef6d5918e 100644
--- a/Services/WebContent/PageHost.h
+++ b/Services/WebContent/PageHost.h
@@ -56,6 +56,8 @@ private:
virtual void page_did_layout() override;
virtual void page_did_change_title(const String&) override;
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
+ virtual void page_did_hover_link(const URL&) override;
+ virtual void page_did_unhover_link() override;
explicit PageHost(ClientConnection&);
diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc
index 8ea47bf9f0..906978a6f4 100644
--- a/Services/WebContent/WebContentClient.ipc
+++ b/Services/WebContent/WebContentClient.ipc
@@ -7,4 +7,6 @@ endpoint WebContentClient = 90
DidLayout(Gfx::IntSize content_size) =|
DidChangeTitle(String title) =|
DidRequestScrollIntoView(Gfx::IntRect rect) =|
+ DidHoverLink(URL url) =|
+ DidUnhoverLink() =|
}