LibWebView: Generate hyperlinks for attributes that represent links

On the view-source page, generate anchor tags for any 'href' or 'src'
attribute value we come across. This handles both when the attribute
contains an absolute URL and a URL relative to the page.

This requires sending the document's base URL over IPC to resolve
relative URLs.
This commit is contained in:
Timothy Flynn 2024-10-18 17:20:15 -04:00 committed by Andreas Kling
commit 1aab7b51ea
Notes: github-actions[bot] 2024-10-20 06:50:51 +00:00
10 changed files with 60 additions and 26 deletions

View file

@ -261,11 +261,11 @@ void WebContentClient::did_request_media_context_menu(u64 page_id, Gfx::IntPoint
}
}
void WebContentClient::did_get_source(u64 page_id, URL::URL const& url, ByteString const& source)
void WebContentClient::did_get_source(u64 page_id, URL::URL const& url, URL::URL const& base_url, String const& source)
{
if (auto view = view_for_page_id(page_id); view.has_value()) {
if (view->on_received_source)
view->on_received_source(url, source);
view->on_received_source(url, base_url, source);
}
}
@ -720,11 +720,11 @@ void WebContentClient::inspector_did_request_style_sheet_source(u64 page_id, Web
}
}
void WebContentClient::did_request_style_sheet_source(u64 page_id, Web::CSS::StyleSheetIdentifier const& identifier, String const& source)
void WebContentClient::did_get_style_sheet_source(u64 page_id, Web::CSS::StyleSheetIdentifier const& identifier, URL::URL const& base_url, String const& source)
{
if (auto view = view_for_page_id(page_id); view.has_value()) {
if (view->on_received_style_sheet_source)
view->on_received_style_sheet_source(identifier, source);
view->on_received_style_sheet_source(identifier, base_url, source);
}
}