LibDevTools+LibWebView: Implement getting document style sheets

This commit is contained in:
Timothy Flynn 2025-03-11 17:14:54 -04:00 committed by Tim Flynn
parent cf601a49bb
commit 0b86bcfba7
Notes: github-actions[bot] 2025-03-13 20:57:24 +00:00
10 changed files with 274 additions and 6 deletions

View file

@ -603,6 +603,51 @@ void Application::remove_dom_node(DevTools::TabDescription const& description, W
});
}
void Application::retrieve_style_sheets(DevTools::TabDescription const& description, OnStyleSheetsReceived on_complete) const
{
auto view = ViewImplementation::find_view_by_id(description.id);
if (!view.has_value()) {
on_complete(Error::from_string_literal("Unable to locate tab"));
return;
}
view->on_received_style_sheet_list = [&view = *view, on_complete = move(on_complete)](Vector<Web::CSS::StyleSheetIdentifier> style_sheets) {
view.on_received_style_sheet_list = nullptr;
on_complete(move(style_sheets));
};
view->list_style_sheets();
}
void Application::retrieve_style_sheet_source(DevTools::TabDescription const& description, Web::CSS::StyleSheetIdentifier const& style_sheet) const
{
auto view = ViewImplementation::find_view_by_id(description.id);
if (!view.has_value())
return;
view->request_style_sheet_source(style_sheet);
}
void Application::listen_for_style_sheet_sources(DevTools::TabDescription const& description, OnStyleSheetSourceReceived on_style_sheet_source_received) const
{
auto view = ViewImplementation::find_view_by_id(description.id);
if (!view.has_value())
return;
view->on_received_style_sheet_source = [&view = *view, on_style_sheet_source_received = move(on_style_sheet_source_received)](auto const& style_sheet, auto const&, auto const& source) {
on_style_sheet_source_received(style_sheet, source);
};
}
void Application::stop_listening_for_style_sheet_sources(DevTools::TabDescription const& description) const
{
auto view = ViewImplementation::find_view_by_id(description.id);
if (!view.has_value())
return;
view->on_received_style_sheet_source = nullptr;
}
void Application::evaluate_javascript(DevTools::TabDescription const& description, String const& script, OnScriptEvaluationComplete on_complete) const
{
auto view = ViewImplementation::find_view_by_id(description.id);