Skip to content

Truly independent web browser

LibWebCommon: Generate the IPC codecs of device pixel geometry

Andreas Kling90b2873f63f4
diff --git a/Libraries/LibWebCommon/CMakeLists.txt b/Libraries/LibWebCommon/CMakeLists.txt
index a351d041e55..bcb1b3aaeae 100644
--- a/Libraries/LibWebCommon/CMakeLists.txt
+++ b/Libraries/LibWebCommon/CMakeLists.txt
@@ -101,6 +101,8 @@ invoke_py_generator(
"${LADYBIRD_SOURCE_DIR}/Meta/Utils/utils.py"
)
+compile_ipc(PixelUnits.ipc PixelUnitsCodecs.h)
+
# NB: The protocols between the UI process and the processes it hosts web content in only use LibWebCommon types, so
# both sides generate their endpoints from here.
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Services/WebContent)
diff --git a/Libraries/LibWebCommon/PixelUnits.cpp b/Libraries/LibWebCommon/PixelUnits.cpp
index fff0226f45b..81e829f8299 100644
--- a/Libraries/LibWebCommon/PixelUnits.cpp
+++ b/Libraries/LibWebCommon/PixelUnits.cpp
@@ -31,52 +31,4 @@ ErrorOr<Web::CSSPixelPoint> decode(Decoder& decoder)
return Web::CSSPixelPoint { Web::CSSPixels::from_raw(x), Web::CSSPixels::from_raw(y) };
}
-template<>
-ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelPoint const& value)
-{
- TRY(encoder.encode(value.x()));
- TRY(encoder.encode(value.y()));
- return {};
-}
-
-template<>
-ErrorOr<Web::DevicePixelPoint> decode(Decoder& decoder)
-{
- auto x = TRY(decoder.decode<Web::DevicePixels>());
- auto y = TRY(decoder.decode<Web::DevicePixels>());
- return Web::DevicePixelPoint { x, y };
-}
-
-template<>
-ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelSize const& value)
-{
- TRY(encoder.encode(value.width()));
- TRY(encoder.encode(value.height()));
- return {};
-}
-
-template<>
-ErrorOr<Web::DevicePixelSize> decode(Decoder& decoder)
-{
- auto width = TRY(decoder.decode<Web::DevicePixels>());
- auto height = TRY(decoder.decode<Web::DevicePixels>());
- return Web::DevicePixelSize { width, height };
-}
-
-template<>
-ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelRect const& value)
-{
- TRY(encoder.encode(value.location()));
- TRY(encoder.encode(value.size()));
- return {};
-}
-
-template<>
-ErrorOr<Web::DevicePixelRect> decode(Decoder& decoder)
-{
- auto location = TRY(decoder.decode<Web::DevicePixelPoint>());
- auto size = TRY(decoder.decode<Web::DevicePixelSize>());
- return Web::DevicePixelRect { location, size };
-}
-
}
diff --git a/Libraries/LibWebCommon/PixelUnits.h b/Libraries/LibWebCommon/PixelUnits.h
index 33ae85672d8..fc9423ff088 100644
--- a/Libraries/LibWebCommon/PixelUnits.h
+++ b/Libraries/LibWebCommon/PixelUnits.h
@@ -561,19 +561,6 @@ WEBCOMMON_API ErrorOr<void> encode(Encoder& encoder, Web::CSSPixelPoint const& v
template<>
WEBCOMMON_API ErrorOr<Web::CSSPixelPoint> decode(Decoder& decoder);
-template<>
-WEBCOMMON_API ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelPoint const& value);
-template<>
-WEBCOMMON_API ErrorOr<Web::DevicePixelPoint> decode(Decoder& decoder);
-
-template<>
-WEBCOMMON_API ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelSize const& value);
-template<>
-WEBCOMMON_API ErrorOr<Web::DevicePixelSize> decode(Decoder& decoder);
-
-template<>
-WEBCOMMON_API ErrorOr<void> encode(Encoder& encoder, Web::DevicePixelRect const& value);
-template<>
-WEBCOMMON_API ErrorOr<Web::DevicePixelRect> decode(Decoder& decoder);
-
}
+
+#include <LibWebCommon/PixelUnitsCodecs.h>
diff --git a/Libraries/LibWebCommon/PixelUnits.ipc b/Libraries/LibWebCommon/PixelUnits.ipc
new file mode 100644
index 00000000000..99f9711707f
--- /dev/null
+++ b/Libraries/LibWebCommon/PixelUnits.ipc
@@ -0,0 +1,23 @@
+// Copyright (c) 2026-present, the Ladybird developers.
+
+#include <LibWebCommon/PixelUnits.h>
+
+[ExistingCpp, Accessors]
+struct Web::DevicePixelPoint {
+ Web::DevicePixels x;
+ Web::DevicePixels y;
+}
+
+[ExistingCpp, Accessors]
+struct Web::DevicePixelSize {
+ Web::DevicePixels width;
+ Web::DevicePixels height;
+}
+
+[ExistingCpp, Accessors]
+struct Web::DevicePixelRect {
+ Web::DevicePixels x;
+ Web::DevicePixels y;
+ Web::DevicePixels width;
+ Web::DevicePixels height;
+}