Browse Source

LibWeb: Port the WebContent service to Core::AnonymousBuffer for themes

Andreas Kling 4 năm trước cách đây
mục cha
commit
d846808122

+ 2 - 7
Userland/Services/WebContent/ClientConnection.cpp

@@ -73,13 +73,8 @@ OwnPtr<Messages::WebContentServer::GreetResponse> 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);
 }
 

+ 3 - 3
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<Gfx::SystemTheme>();
+    auto buffer = Core::AnonymousBuffer::create_with_size(sizeof(Gfx::SystemTheme));
+    auto* theme = buffer.data<Gfx::SystemTheme>();
     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

+ 1 - 1
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) =|

+ 1 - 1
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;
     }