From d846808122c272b173f1f8f7169d78d1e29bd3c7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Jan 2021 17:22:35 +0100 Subject: [PATCH] LibWeb: Port the WebContent service to Core::AnonymousBuffer for themes --- Userland/Services/WebContent/ClientConnection.cpp | 9 ++------- Userland/Services/WebContent/PageHost.cpp | 6 +++--- Userland/Services/WebContent/WebContentServer.ipc | 2 +- Userland/Services/WebContent/main.cpp | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index 46b38f440b..2f5b44f95a 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -73,13 +73,8 @@ OwnPtr ClientConnection::handle(const void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemTheme& message) { - auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id()); - if (!shared_buffer) { - dbgln("WebContentServer::UpdateSystemTheme: SharedBuffer already gone! Ignoring :^)"); - return; - } - Gfx::set_system_theme(*shared_buffer); - auto impl = Gfx::PaletteImpl::create_with_shared_buffer(*shared_buffer); + Gfx::set_system_theme(message.theme_buffer()); + auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(message.theme_buffer()); m_page_host->set_palette_impl(*impl); } diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 11641235eb..c76f1b02cd 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -49,11 +49,11 @@ PageHost::~PageHost() void PageHost::setup_palette() { // FIXME: Get the proper palette from our peer somehow - auto buffer = SharedBuffer::create_with_size(sizeof(Gfx::SystemTheme)); - auto* theme = buffer->data(); + auto buffer = Core::AnonymousBuffer::create_with_size(sizeof(Gfx::SystemTheme)); + auto* theme = buffer.data(); theme->color[(int)Gfx::ColorRole::Window] = Color::Magenta; theme->color[(int)Gfx::ColorRole::WindowText] = Color::Cyan; - m_palette_impl = Gfx::PaletteImpl::create_with_shared_buffer(*buffer); + m_palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(buffer); } Gfx::Palette PageHost::palette() const diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 143650dab7..cb2ff26b85 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -2,7 +2,7 @@ endpoint WebContentServer = 89 { Greet(i32 client_pid) => (i32 client_id, i32 server_pid) - UpdateSystemTheme(i32 shbuf_id) =| + UpdateSystemTheme(Core::AnonymousBuffer theme_buffer) =| LoadURL(URL url) =| LoadHTML(String html, URL url) =| diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index 20b6f8daa0..65c79ced7b 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -32,7 +32,7 @@ int main(int, char**) { Core::EventLoop event_loop; - if (pledge("stdio sendfd shared_buffer accept unix rpath recvfd", nullptr) < 0) { + if (pledge("stdio recvfd sendfd shared_buffer accept unix rpath recvfd", nullptr) < 0) { perror("pledge"); return 1; }