mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWebView: Display each tab's title in the Task Manager
This allows us to more easily differentiate between WebContent processes in the Task Manager at a glance.
This commit is contained in:
parent
2fc52657b6
commit
2851c05dee
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/trflynn89
Commit: 2851c05dee
Pull-request: https://github.com/SerenityOS/serenity/pull/24074
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 15 additions and 1 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/Platform/ProcessInfo.h>
|
||||
|
||||
|
@ -34,6 +36,7 @@ struct ProcessInfo : public Core::Platform::ProcessInfo {
|
|||
}
|
||||
|
||||
ProcessType type { ProcessType::WebContent };
|
||||
Optional<String> title;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ String ProcessManager::generate_html()
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Name</th>
|
||||
<th>PID</th>
|
||||
<th>Memory Usage</th>
|
||||
<th>CPU %</th>
|
||||
|
@ -210,6 +210,8 @@ String ProcessManager::generate_html()
|
|||
builder.append("<tr>"sv);
|
||||
builder.append("<td>"sv);
|
||||
builder.append(WebView::process_name_from_type(process.type));
|
||||
if (process.title.has_value())
|
||||
builder.appendff(" - {}", *process.title);
|
||||
builder.append("</td>"sv);
|
||||
builder.append("<td>"sv);
|
||||
builder.append(MUST(String::number(process.pid)));
|
||||
|
|
|
@ -38,6 +38,7 @@ void WebContentClient::notify_process_information(WebView::ProcessHandle const&
|
|||
{
|
||||
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::NotifyProcessInformation! pid={}", handle.pid);
|
||||
ProcessManager::the().add_process(ProcessType::WebContent, handle.pid);
|
||||
m_process_handle = handle;
|
||||
}
|
||||
|
||||
void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitmap_id)
|
||||
|
@ -48,6 +49,9 @@ void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitm
|
|||
|
||||
void WebContentClient::did_start_loading(u64 page_id, URL::URL const& url, bool is_redirect)
|
||||
{
|
||||
if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid))
|
||||
process->title.clear();
|
||||
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
view->set_url({}, url);
|
||||
|
||||
|
@ -121,6 +125,9 @@ void WebContentClient::did_layout(u64 page_id, Gfx::IntSize content_size)
|
|||
|
||||
void WebContentClient::did_change_title(u64 page_id, ByteString const& title)
|
||||
{
|
||||
if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid))
|
||||
process->title = MUST(String::from_byte_string(title));
|
||||
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
if (!view->on_title_change)
|
||||
return;
|
||||
|
|
|
@ -115,6 +115,8 @@ private:
|
|||
|
||||
// FIXME: Does a HashMap holding references make sense?
|
||||
HashMap<u64, ViewImplementation*> m_views;
|
||||
|
||||
ProcessHandle m_process_handle;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue