Truly independent web browser
LibCompositing+LibWebCommon: Declare compositor IPC types in .ipc files
Aliaksandr Kalenik48a643fd1b0a
diff --git a/Libraries/LibCompositing/CMakeLists.txt b/Libraries/LibCompositing/CMakeLists.txtindex fce33010437..d3e3b5499c9 100644--- a/Libraries/LibCompositing/CMakeLists.txt+++ b/Libraries/LibCompositing/CMakeLists.txt@@ -19,7 +19,6 @@ set(SOURCESScrolling/ScrollState.cppScrolling/SmoothScrollAnimation.cppScrolling/WheelGestureIdentity.cpp- Types.cppUIOverlays.cppVideo/VideoFrameHold.cppVideo/VideoFramePresentationPage.cpp@@ -38,6 +37,8 @@ compile_ipc(${LADYBIRD_SOURCE_DIR}/Services/Compositor/CompositorWebContentCliencompile_ipc(${LADYBIRD_SOURCE_DIR}/Services/Compositor/CompositorWebContentServer.ipc ${CMAKE_BINARY_DIR}/Services/Compositor/CompositorWebContentServerEndpoint.h)compile_ipc(${LADYBIRD_SOURCE_DIR}/Services/Compositor/RenderClockClient.ipc ${CMAKE_BINARY_DIR}/Services/Compositor/RenderClockClientEndpoint.h)compile_ipc(${LADYBIRD_SOURCE_DIR}/Services/Compositor/RenderClockServer.ipc ${CMAKE_BINARY_DIR}/Services/Compositor/RenderClockServerEndpoint.h)+compile_ipc(DisplayList/DisplayListProperties.ipc DisplayList/DisplayListPropertiesCodecs.h)+compile_ipc(Types.ipc TypesCodecs.h)compile_ipc(FontClient.ipc FontClientEndpoint.h)compile_ipc(FontServer.ipc FontServerEndpoint.h)diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.cpp b/Libraries/LibCompositing/DisplayList/DisplayList.cppindex 7403a0c8bc5..8e94472926d 100644--- a/Libraries/LibCompositing/DisplayList/DisplayList.cpp+++ b/Libraries/LibCompositing/DisplayList/DisplayList.cpp@@ -181,60 +181,6 @@ ErrorOr<void> validate_display_list_references_live_visual_context_nodes(Displaynamespace IPC {-template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::DisplayList::AsyncScrollingMetadata const& metadata)-{- TRY(encoder.encode(metadata.document_id));- TRY(encoder.encode(metadata.viewport_rect));- TRY(encoder.encode(metadata.wheel_event_listener_state_generation));- TRY(encoder.encode(metadata.has_blocking_wheel_event_listeners));- TRY(encoder.encode(metadata.has_blocking_wheel_event_region_covering_viewport));- TRY(encoder.encode(metadata.viewport_keeps_horizontal_scrolls));- TRY(encoder.encode(metadata.viewport_keeps_vertical_scrolls));- TRY(encoder.encode(metadata.device_pixels_per_css_pixel));- TRY(encoder.encode(metadata.keyboard_scroll_state));- return {};-}--template<>-ErrorOr<Compositing::DisplayList::AsyncScrollingMetadata> decode(Decoder& decoder)-{- return Compositing::DisplayList::AsyncScrollingMetadata {- .document_id = TRY(decoder.decode<Optional<Web::UniqueNodeID>>()),- .viewport_rect = TRY(decoder.decode<Gfx::IntRect>()),- .wheel_event_listener_state_generation = TRY(decoder.decode<u64>()),- .has_blocking_wheel_event_listeners = TRY(decoder.decode<bool>()),- .has_blocking_wheel_event_region_covering_viewport = TRY(decoder.decode<bool>()),- .viewport_keeps_horizontal_scrolls = TRY(decoder.decode<bool>()),- .viewport_keeps_vertical_scrolls = TRY(decoder.decode<bool>()),- .device_pixels_per_css_pixel = TRY(decoder.decode<double>()),- .keyboard_scroll_state = TRY(decoder.decode<Compositing::KeyboardScrollState>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::DisplayList::Properties const& properties)-{- TRY(encoder.encode(properties.id));- TRY(encoder.encode(properties.compatible_visual_context_tree_structural_epoch));- TRY(encoder.encode(properties.surface_clear_color));- TRY(encoder.encode(properties.root_group_color));- TRY(encoder.encode(properties.async_scrolling_metadata));- return {};-}--template<>-ErrorOr<Compositing::DisplayList::Properties> decode(Decoder& decoder)-{- return Compositing::DisplayList::Properties {- .id = TRY(decoder.decode<u64>()),- .compatible_visual_context_tree_structural_epoch = TRY(decoder.decode<u64>()),- .surface_clear_color = TRY(decoder.decode<Optional<Gfx::Color>>()),- .root_group_color = TRY(decoder.decode<Gfx::Color>()),- .async_scrolling_metadata = TRY(decoder.decode<Optional<Compositing::DisplayList::AsyncScrollingMetadata>>()),- };-}-template<>ErrorOr<void> encode(Encoder& encoder, Compositing::DisplayList const& display_list){diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.h b/Libraries/LibCompositing/DisplayList/DisplayList.hindex 04fefc20544..428ba7fdf7a 100644--- a/Libraries/LibCompositing/DisplayList/DisplayList.h+++ b/Libraries/LibCompositing/DisplayList/DisplayList.h@@ -143,16 +143,6 @@ COMPOSITING_API ErrorOr<void> validate_display_list_references_live_visual_contenamespace IPC {-template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::DisplayList::AsyncScrollingMetadata const&);-template<>-COMPOSITING_API ErrorOr<Compositing::DisplayList::AsyncScrollingMetadata> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::DisplayList::Properties const&);-template<>-COMPOSITING_API ErrorOr<Compositing::DisplayList::Properties> decode(Decoder&);-template<>COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::DisplayList const&);template<>@@ -161,3 +151,5 @@ template<>COMPOSITING_API ErrorOr<NonnullRefPtr<Compositing::DisplayList>> decode(Decoder&);}++#include <LibCompositing/DisplayList/DisplayListPropertiesCodecs.h>diff --git a/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc b/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipcnew file mode 100644index 00000000000..470b95c59ee--- /dev/null+++ b/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc@@ -0,0 +1,30 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++// NB: The IPC compiler cannot check that each struct here lists every field of its C++ type. A field left out+// here does not cross IPC.++#include <LibCompositing/DisplayList/DisplayList.h>++[ExistingCpp]+struct Compositing::DisplayList::AsyncScrollingMetadata {+ Optional<Web::UniqueNodeID> document_id;+ Gfx::IntRect viewport_rect;+ u64 wheel_event_listener_state_generation;+ bool has_blocking_wheel_event_listeners;+ bool has_blocking_wheel_event_region_covering_viewport;+ bool viewport_keeps_horizontal_scrolls;+ bool viewport_keeps_vertical_scrolls;+ double device_pixels_per_css_pixel;+ Compositing::KeyboardScrollState keyboard_scroll_state;+}++[ExistingCpp]+struct Compositing::DisplayList::Properties {+ u64 id;+ u64 compatible_visual_context_tree_structural_epoch;+ Optional<Gfx::Color> surface_clear_color;+ Gfx::Color root_group_color;+ Optional<Compositing::DisplayList::AsyncScrollingMetadata> async_scrolling_metadata;+}diff --git a/Libraries/LibCompositing/Types.cpp b/Libraries/LibCompositing/Types.cppdeleted file mode 100644index 2f2773e576b..00000000000--- a/Libraries/LibCompositing/Types.cpp+++ /dev/null@@ -1,331 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibCompositing/Types.h>-#include <LibIPC/Decoder.h>-#include <LibIPC/Encoder.h>--namespace IPC {--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::KeyboardScrollState const& state)-{- TRY(encoder.encode(state.generation));- TRY(encoder.encode(state.visual_context_tree_structural_epoch));- TRY(encoder.encode(state.target));- TRY(encoder.encode(state.page_scroll_distance));- TRY(encoder.encode(state.arrow_scroll_distance));- return {};-}--template<>-ErrorOr<Compositing::KeyboardScrollState> decode(Decoder& decoder)-{- return Compositing::KeyboardScrollState {- .generation = TRY(decoder.decode<u64>()),- .visual_context_tree_structural_epoch = TRY(decoder.decode<u64>()),- .target = TRY(decoder.decode<Optional<Web::AsyncScrollNodeStableID>>()),- .page_scroll_distance = TRY(decoder.decode<float>()),- .arrow_scroll_distance = TRY(decoder.decode<float>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::AsyncScrollOffset const& offset)-{- TRY(encoder.encode(offset.stable_node_id));- TRY(encoder.encode(offset.compositor_scroll_offset));- TRY(encoder.encode(offset.unadopted_scroll_delta));- TRY(encoder.encode(offset.last_relative_scroll_delta));- TRY(encoder.encode(offset.visual_viewport_scale));- TRY(encoder.encode(offset.applied_scroll_request_id));- TRY(encoder.encode(offset.user_input_scroll_count));- TRY(encoder.encode(offset.context_user_input_scroll_count));- return {};-}--template<>-ErrorOr<Compositing::AsyncScrollOffset> decode(Decoder& decoder)-{- return Compositing::AsyncScrollOffset {- .stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .compositor_scroll_offset = TRY(decoder.decode<Gfx::FloatPoint>()),- .unadopted_scroll_delta = TRY(decoder.decode<Gfx::FloatPoint>()),- .last_relative_scroll_delta = TRY(decoder.decode<Gfx::FloatPoint>()),- .visual_viewport_scale = TRY(decoder.decode<Optional<float>>()),- .applied_scroll_request_id = TRY(decoder.decode<u64>()),- .user_input_scroll_count = TRY(decoder.decode<u64>()),- .context_user_input_scroll_count = TRY(decoder.decode<u64>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::SnapAreaIdentity const& identity)-{- TRY(encoder.encode(identity.node_id));- TRY(encoder.encode(identity.pseudo_element_type));- return {};-}--template<>-ErrorOr<Compositing::SnapAreaIdentity> decode(Decoder& decoder)-{- return Compositing::SnapAreaIdentity {- .node_id = TRY(decoder.decode<Web::UniqueNodeID>()),- .pseudo_element_type = TRY(decoder.decode<u8>()),- };-}--// NB: CSS pixel points travel as their raw fixed-point values, so that a destination is exactly the one selected.-template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::SnapDestination const& destination)-{- TRY(encoder.encode(destination.position));- TRY(encoder.encode(destination.snapped_x));- TRY(encoder.encode(destination.snapped_y));- TRY(encoder.encode(destination.evaluated_x));- TRY(encoder.encode(destination.evaluated_y));- TRY(encoder.encode(destination.snapped_areas.x));- TRY(encoder.encode(destination.snapped_areas.y));- return {};-}--template<>-ErrorOr<Compositing::SnapDestination> decode(Decoder& decoder)-{- return Compositing::SnapDestination {- .position = TRY(decoder.decode<Web::CSSPixelPoint>()),- .snapped_x = TRY(decoder.decode<bool>()),- .snapped_y = TRY(decoder.decode<bool>()),- .evaluated_x = TRY(decoder.decode<bool>()),- .evaluated_y = TRY(decoder.decode<bool>()),- .snapped_areas = {- .x = TRY(decoder.decode<Vector<Compositing::SnapAreaIdentity>>()),- .y = TRY(decoder.decode<Vector<Compositing::SnapAreaIdentity>>()),- },- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::StartedUserScroll const& started_user_scroll)-{- TRY(encoder.encode(started_user_scroll.stable_node_id));- TRY(encoder.encode(started_user_scroll.operation_id));- TRY(encoder.encode(started_user_scroll.initial_scroll_offset));- TRY(encoder.encode(started_user_scroll.unsnapped_scroll_destination));- TRY(encoder.encode(started_user_scroll.relative_scroll_delta));- TRY(encoder.encode(started_user_scroll.selection));- TRY(encoder.encode(started_user_scroll.settles_gesture));- TRY(encoder.encode(started_user_scroll.is_absolute_scroll));- TRY(encoder.encode(started_user_scroll.animation_kind));- return {};-}--template<>-ErrorOr<Compositing::StartedUserScroll> decode(Decoder& decoder)-{- return Compositing::StartedUserScroll {- .stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .operation_id = TRY(decoder.decode<Compositing::AsyncScrollOperationID>()),- .initial_scroll_offset = TRY(decoder.decode<Web::CSSPixelPoint>()),- .unsnapped_scroll_destination = TRY(decoder.decode<Web::CSSPixelPoint>()),- .relative_scroll_delta = TRY(decoder.decode<Web::CSSPixelPoint>()),- .selection = TRY(decoder.decode<Compositing::SnapDestination>()),- .settles_gesture = TRY(decoder.decode<bool>()),- .is_absolute_scroll = TRY(decoder.decode<bool>()),- .animation_kind = TRY(decoder.decode<Optional<Compositing::ScrollAnimationKind>>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::AppliedScrollRequest const& applied_scroll_request)-{- TRY(encoder.encode(applied_scroll_request.stable_node_id));- TRY(encoder.encode(applied_scroll_request.request_id));- TRY(encoder.encode(applied_scroll_request.moved_the_box));- return {};-}--template<>-ErrorOr<Compositing::AppliedScrollRequest> decode(Decoder& decoder)-{- return Compositing::AppliedScrollRequest {- .stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .request_id = TRY(decoder.decode<u64>()),- .moved_the_box = TRY(decoder.decode<bool>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::PendingAsyncScrollUpdates const& updates)-{- TRY(encoder.encode(updates.document_id));- TRY(encoder.encode(updates.sequence));- TRY(encoder.encode(updates.scroll_offsets));- TRY(encoder.encode(updates.completed_operation_ids));- TRY(encoder.encode(updates.operation_ids_taken_over_by_user_input));- TRY(encoder.encode(updates.started_user_scrolls));- TRY(encoder.encode(updates.applied_scroll_requests));- TRY(encoder.encode(updates.boxes_in_user_scroll_gesture));- TRY(encoder.encode(updates.boxes_whose_user_scroll_gesture_ended));- TRY(encoder.encode(updates.wheel_latched_scroller));- return {};-}--template<>-ErrorOr<Compositing::PendingAsyncScrollUpdates> decode(Decoder& decoder)-{- return Compositing::PendingAsyncScrollUpdates {- .document_id = TRY(decoder.decode<Optional<Web::UniqueNodeID>>()),- .sequence = TRY(decoder.decode<u64>()),- .scroll_offsets = TRY(decoder.decode<Vector<Compositing::AsyncScrollOffset>>()),- .completed_operation_ids = TRY(decoder.decode<Vector<Compositing::AsyncScrollOperationID>>()),- .operation_ids_taken_over_by_user_input = TRY(decoder.decode<Vector<Compositing::AsyncScrollOperationID>>()),- .started_user_scrolls = TRY(decoder.decode<Vector<Compositing::StartedUserScroll>>()),- .applied_scroll_requests = TRY(decoder.decode<Vector<Compositing::AppliedScrollRequest>>()),- .boxes_in_user_scroll_gesture = TRY(decoder.decode<Vector<Web::AsyncScrollNodeStableID>>()),- .boxes_whose_user_scroll_gesture_ended = TRY(decoder.decode<Vector<Web::AsyncScrollNodeStableID>>()),- .wheel_latched_scroller = TRY(decoder.decode<Optional<Web::AsyncScrollNodeStableID>>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::RequestedRelativeScroll const& relative_scroll)-{- TRY(encoder.encode(relative_scroll.delta));- TRY(encoder.encode(relative_scroll.lower_bound));- TRY(encoder.encode(relative_scroll.upper_bound));- return {};-}--template<>-ErrorOr<Compositing::RequestedRelativeScroll> decode(Decoder& decoder)-{- return Compositing::RequestedRelativeScroll {- .delta = TRY(decoder.decode<Gfx::FloatPoint>()),- .lower_bound = TRY(decoder.decode<Gfx::FloatPoint>()),- .upper_bound = TRY(decoder.decode<Gfx::FloatPoint>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::RequestedSmoothScroll const& smooth_scroll)-{- TRY(encoder.encode(smooth_scroll.operation_id));- TRY(encoder.encode(smooth_scroll.destination_offset));- TRY(encoder.encode(smooth_scroll.destination_is_relative));- TRY(encoder.encode(smooth_scroll.relative_lower_bound));- TRY(encoder.encode(smooth_scroll.relative_upper_bound));- TRY(encoder.encode(smooth_scroll.animation_kind));- TRY(encoder.encode(smooth_scroll.initiator));- TRY(encoder.encode(smooth_scroll.retargets_operation));- TRY(encoder.encode(smooth_scroll.settled_user_input_scroll_count));- return {};-}--template<>-ErrorOr<Compositing::RequestedSmoothScroll> decode(Decoder& decoder)-{- Compositing::RequestedSmoothScroll smooth_scroll {- .operation_id = TRY(decoder.decode<Compositing::AsyncScrollOperationID>()),- .destination_offset = TRY(decoder.decode<Gfx::FloatPoint>()),- .destination_is_relative = TRY(decoder.decode<bool>()),- .relative_lower_bound = TRY(decoder.decode<Gfx::FloatPoint>()),- .relative_upper_bound = TRY(decoder.decode<Gfx::FloatPoint>()),- .animation_kind = TRY(decoder.decode<Compositing::ScrollAnimationKind>()),- .initiator = TRY(decoder.decode<Compositing::SmoothScrollInitiator>()),- .retargets_operation = TRY(decoder.decode<bool>()),- .settled_user_input_scroll_count = TRY(decoder.decode<Optional<u64>>()),- };- if (!(smooth_scroll.relative_lower_bound.x() <= smooth_scroll.relative_upper_bound.x() && smooth_scroll.relative_lower_bound.y() <= smooth_scroll.relative_upper_bound.y()))- return Error::from_string_literal("Smooth scroll with an empty range of relative destinations");- return smooth_scroll;-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::ScrollRequest const& request)-{- TRY(encoder.encode(request.stable_node_id));- TRY(encoder.encode(request.request_id));- TRY(encoder.encode(request.jump_offset));- TRY(encoder.encode(request.visual_viewport_scale));- TRY(encoder.encode(request.relative_scroll));- TRY(encoder.encode(request.relative_scroll_moves_visual_viewport_first));- TRY(encoder.encode(request.instant_scroll_is_for_user_input));- TRY(encoder.encode(request.smooth_scroll));- TRY(encoder.encode(request.takes_over_from_momentum));- return {};-}--template<>-ErrorOr<Compositing::ScrollRequest> decode(Decoder& decoder)-{- return Compositing::ScrollRequest {- .stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .request_id = TRY(decoder.decode<u64>()),- .jump_offset = TRY(decoder.decode<Optional<Gfx::FloatPoint>>()),- .visual_viewport_scale = TRY(decoder.decode<Optional<float>>()),- .relative_scroll = TRY(decoder.decode<Optional<Compositing::RequestedRelativeScroll>>()),- .relative_scroll_moves_visual_viewport_first = TRY(decoder.decode<bool>()),- .instant_scroll_is_for_user_input = TRY(decoder.decode<bool>()),- .smooth_scroll = TRY(decoder.decode<Optional<Compositing::RequestedSmoothScroll>>()),- .takes_over_from_momentum = TRY(decoder.decode<bool>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::WheelEventAnswer const& answer)-{- TRY(encoder.encode(answer.performed_default_action));- TRY(encoder.encode(answer.wheel_gesture_mark));- TRY(encoder.encode(answer.operation_id));- TRY(encoder.encode(answer.operation_context_id));- TRY(encoder.encode(answer.routing_decision));- TRY(encoder.encode(answer.routed_scroller));- return {};-}--template<>-ErrorOr<Compositing::WheelEventAnswer> decode(Decoder& decoder)-{- return Compositing::WheelEventAnswer {- .performed_default_action = TRY(decoder.decode<bool>()),- .wheel_gesture_mark = TRY(decoder.decode<Optional<Web::WheelGestureMark>>()),- .operation_id = TRY(decoder.decode<Optional<Compositing::AsyncScrollOperationID>>()),- .operation_context_id = TRY(decoder.decode<Optional<Web::CompositorContextId>>()),- .routing_decision = TRY(decoder.decode<Optional<Web::InputRoutingDecision>>()),- .routed_scroller = TRY(decoder.decode<Optional<Web::AsyncScrollNodeStableID>>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Compositing::WheelStepLetThrough const& step)-{- TRY(encoder.encode(step.document_id));- TRY(encoder.encode(step.wheel_gesture_mark));- TRY(encoder.encode(step.position));- TRY(encoder.encode(step.delta_in_css_pixels));- TRY(encoder.encode(step.wheel_delta_precision));- TRY(encoder.encode(step.scroll_gesture_phase));- TRY(encoder.encode(step.scroll_chain));- return {};-}--template<>-ErrorOr<Compositing::WheelStepLetThrough> decode(Decoder& decoder)-{- return Compositing::WheelStepLetThrough {- .document_id = TRY(decoder.decode<Web::UniqueNodeID>()),- .wheel_gesture_mark = TRY(decoder.decode<Web::WheelGestureMark>()),- .position = TRY(decoder.decode<Gfx::FloatPoint>()),- .delta_in_css_pixels = TRY(decoder.decode<Gfx::FloatPoint>()),- .wheel_delta_precision = TRY(decoder.decode<Web::WheelDeltaPrecision>()),- .scroll_gesture_phase = TRY(decoder.decode<Web::ScrollGesturePhase>()),- .scroll_chain = TRY(decoder.decode<Vector<Web::AsyncScrollNodeStableID>>()),- };-}--}diff --git a/Libraries/LibCompositing/Types.h b/Libraries/LibCompositing/Types.hindex 5c8d32072bb..56f3cc384db 100644--- a/Libraries/LibCompositing/Types.h+++ b/Libraries/LibCompositing/Types.h@@ -301,66 +301,4 @@ inline constexpr AK::Duration user_scroll_settle_delay = AK::Duration::from_mill}-namespace IPC {--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::KeyboardScrollState const&);-template<>-COMPOSITING_API ErrorOr<Compositing::KeyboardScrollState> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::AsyncScrollOffset const&);-template<>-COMPOSITING_API ErrorOr<Compositing::AsyncScrollOffset> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::SnapAreaIdentity const&);-template<>-COMPOSITING_API ErrorOr<Compositing::SnapAreaIdentity> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::SnapDestination const&);-template<>-COMPOSITING_API ErrorOr<Compositing::SnapDestination> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::StartedUserScroll const&);-template<>-COMPOSITING_API ErrorOr<Compositing::StartedUserScroll> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::AppliedScrollRequest const&);-template<>-COMPOSITING_API ErrorOr<Compositing::AppliedScrollRequest> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::PendingAsyncScrollUpdates const&);-template<>-COMPOSITING_API ErrorOr<Compositing::PendingAsyncScrollUpdates> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::RequestedRelativeScroll const&);-template<>-COMPOSITING_API ErrorOr<Compositing::RequestedRelativeScroll> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::RequestedSmoothScroll const&);-template<>-COMPOSITING_API ErrorOr<Compositing::RequestedSmoothScroll> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::ScrollRequest const&);-template<>-COMPOSITING_API ErrorOr<Compositing::ScrollRequest> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::WheelEventAnswer const&);-template<>-COMPOSITING_API ErrorOr<Compositing::WheelEventAnswer> decode(Decoder&);--template<>-COMPOSITING_API ErrorOr<void> encode(Encoder&, Compositing::WheelStepLetThrough const&);-template<>-COMPOSITING_API ErrorOr<Compositing::WheelStepLetThrough> decode(Decoder&);--}+#include <LibCompositing/TypesCodecs.h>diff --git a/Libraries/LibCompositing/Types.ipc b/Libraries/LibCompositing/Types.ipcnew file mode 100644index 00000000000..6cb0ed5e0d4--- /dev/null+++ b/Libraries/LibCompositing/Types.ipc@@ -0,0 +1,196 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++// NB: The IPC compiler cannot check that each struct here lists every field of its C++ type. A field left out+// here does not cross IPC.++#include <LibCompositing/Types.h>+#include <LibCompositing/WebGL/Types.h>++[ExistingCpp]+enum Compositing::WindowResizingInProgress : u8 {+ No,+ Yes,+}++[ExistingCpp]+enum Compositing::ContextVisibility : u8 {+ Visible,+ Hidden,+}++[ExistingCpp]+enum Compositing::AsyncScrollUpdateFreshness : u8 {+ Pushed,+ FromCompositor,+}++[ExistingCpp]+enum Compositing::ScrollAnimationKind : u8 {+ SmoothScroll,+ Wheel,+ Momentum,+}++[ExistingCpp]+enum Compositing::AsyncScrollOperationTracking : u8 {+ No,+ Yes,+}++[ExistingCpp]+enum Compositing::WheelEventRouting : u8 {+ BeforeDispatch,+ AfterDispatch,+}++[ExistingCpp]+enum Compositing::WheelStepDispatch : u8 {+ NotYetDispatched,+ DispatchedAndNotCanceled,+}++[ExistingCpp]+enum Compositing::SmoothScrollInitiator : u8 {+ Programmatic,+ UserInput,+}++[ExistingCpp]+enum Compositing::WebGL::WebGLVersion : u8 {+ WebGL1,+ WebGL2,+}++[ExistingCpp]+struct Compositing::KeyboardScrollState {+ u64 generation;+ u64 visual_context_tree_structural_epoch;+ Optional<Web::AsyncScrollNodeStableID> target;+ float page_scroll_distance;+ float arrow_scroll_distance;+}++[ExistingCpp]+struct Compositing::AsyncScrollOffset {+ Web::AsyncScrollNodeStableID stable_node_id;+ Gfx::FloatPoint compositor_scroll_offset;+ Gfx::FloatPoint unadopted_scroll_delta;+ Gfx::FloatPoint last_relative_scroll_delta;+ Optional<float> visual_viewport_scale;+ u64 applied_scroll_request_id;+ u64 user_input_scroll_count;+ u64 context_user_input_scroll_count;+}++[ExistingCpp]+struct Compositing::SnapAreaIdentity {+ Web::UniqueNodeID node_id;+ u8 pseudo_element_type;+}++[ExistingCpp]+struct Compositing::SnappedAreas {+ Vector<Compositing::SnapAreaIdentity> x;+ Vector<Compositing::SnapAreaIdentity> y;+}++// NB: CSS pixel points travel as their raw fixed-point values, so that a destination is exactly the one selected.+[ExistingCpp]+struct Compositing::SnapDestination {+ Web::CSSPixelPoint position;+ bool snapped_x;+ bool snapped_y;+ bool evaluated_x;+ bool evaluated_y;+ Compositing::SnappedAreas snapped_areas;+}++[ExistingCpp]+struct Compositing::StartedUserScroll {+ Web::AsyncScrollNodeStableID stable_node_id;+ u64 operation_id;+ Web::CSSPixelPoint initial_scroll_offset;+ Web::CSSPixelPoint unsnapped_scroll_destination;+ Web::CSSPixelPoint relative_scroll_delta;+ Compositing::SnapDestination selection;+ bool settles_gesture;+ bool is_absolute_scroll;+ Optional<Compositing::ScrollAnimationKind> animation_kind;+}++[ExistingCpp]+struct Compositing::AppliedScrollRequest {+ Web::AsyncScrollNodeStableID stable_node_id;+ u64 request_id;+ bool moved_the_box;+}++[ExistingCpp]+struct Compositing::PendingAsyncScrollUpdates {+ Optional<Web::UniqueNodeID> document_id;+ u64 sequence;+ Vector<Compositing::AsyncScrollOffset> scroll_offsets;+ Vector<u64> completed_operation_ids;+ Vector<u64> operation_ids_taken_over_by_user_input;+ Vector<Compositing::StartedUserScroll> started_user_scrolls;+ Vector<Compositing::AppliedScrollRequest> applied_scroll_requests;+ Vector<Web::AsyncScrollNodeStableID> boxes_in_user_scroll_gesture;+ Vector<Web::AsyncScrollNodeStableID> boxes_whose_user_scroll_gesture_ended;+ Optional<Web::AsyncScrollNodeStableID> wheel_latched_scroller;+}++[ExistingCpp]+struct Compositing::RequestedRelativeScroll {+ Gfx::FloatPoint delta;+ Gfx::FloatPoint lower_bound;+ Gfx::FloatPoint upper_bound;+}++[ExistingCpp]+struct Compositing::RequestedSmoothScroll {+ u64 operation_id;+ Gfx::FloatPoint destination_offset;+ bool destination_is_relative;+ Gfx::FloatPoint relative_lower_bound;+ Gfx::FloatPoint relative_upper_bound;+ Compositing::ScrollAnimationKind animation_kind;+ Compositing::SmoothScrollInitiator initiator;+ bool retargets_operation;+ Optional<u64> settled_user_input_scroll_count;+}++[ExistingCpp]+struct Compositing::ScrollRequest {+ Web::AsyncScrollNodeStableID stable_node_id;+ u64 request_id;+ Optional<Gfx::FloatPoint> jump_offset;+ Optional<float> visual_viewport_scale;+ Optional<Compositing::RequestedRelativeScroll> relative_scroll;+ bool relative_scroll_moves_visual_viewport_first;+ bool instant_scroll_is_for_user_input;+ Optional<Compositing::RequestedSmoothScroll> smooth_scroll;+ bool takes_over_from_momentum;+}++[ExistingCpp]+struct Compositing::WheelEventAnswer {+ bool performed_default_action;+ Optional<Web::WheelGestureMark> wheel_gesture_mark;+ Optional<u64> operation_id;+ Optional<Web::CompositorContextId> operation_context_id;+ Optional<Web::InputRoutingDecision> routing_decision;+ Optional<Web::AsyncScrollNodeStableID> routed_scroller;+}++[ExistingCpp]+struct Compositing::WheelStepLetThrough {+ Web::UniqueNodeID document_id;+ Web::WheelGestureMark wheel_gesture_mark;+ Gfx::FloatPoint position;+ Gfx::FloatPoint delta_in_css_pixels;+ Web::WheelDeltaPrecision wheel_delta_precision;+ Web::ScrollGesturePhase scroll_gesture_phase;+ Vector<Web::AsyncScrollNodeStableID> scroll_chain;+}diff --git a/Libraries/LibWebCommon/CMakeLists.txt b/Libraries/LibWebCommon/CMakeLists.txtindex aaa70cd25fd..8af450f1c48 100644--- a/Libraries/LibWebCommon/CMakeLists.txt+++ b/Libraries/LibWebCommon/CMakeLists.txt@@ -51,7 +51,6 @@ set(SOURCESLoader/SiteCompatibility.cppMimeSniff/MimeType.cppMimeSniff/Resource.cpp- Page/AsyncScrollNodeStableID.cppPage/DragEvent.cppPage/InputEvent.cppPage/InputRoutingDecision.cpp@@ -118,9 +117,14 @@ invoke_py_generator(compile_ipc(ContentSecurityPolicy/RemoteViolationDirective.ipc ContentSecurityPolicy/RemoteViolationDirectiveCodecs.h)compile_ipc(HTML/NavigationResponse.ipc HTML/NavigationResponseCodecs.h)compile_ipc(MixedContent/ProhibitsMixedSecurityContexts.ipc MixedContent/ProhibitsMixedSecurityContextsCodecs.h)+compile_ipc(Page/AsyncScrollNodeStableID.ipc Page/AsyncScrollNodeStableIDCodecs.h)compile_ipc(Page/InputEvent.ipc Page/InputEventCodecs.h)+compile_ipc(Page/InputRoutingDecision.ipc Page/InputRoutingDecisionCodecs.h)+compile_ipc(Page/InputTrace.ipc Page/InputTraceCodecs.h)compile_ipc(Page/TextEditingCommand.ipc Page/TextEditingCommandCodecs.h)compile_ipc(PixelUnits.ipc PixelUnitsCodecs.h)+compile_ipc(UIEvents/KeyCode.ipc UIEvents/KeyCodeCodecs.h)+compile_ipc(UIEvents/MouseButton.ipc UIEvents/MouseButtonCodecs.h)compile_ipc(UpgradeInsecureRequests/InsecureRequestsPolicy.ipc UpgradeInsecureRequests/InsecureRequestsPolicyCodecs.h)compile_ipc(WebView/AccessibilityNodeData.ipc WebView/AccessibilityNodeDataCodecs.h)compile_ipc(WebView/DictionaryLookup.ipc WebView/DictionaryLookupCodecs.h)diff --git a/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.cpp b/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.cppdeleted file mode 100644index 57bfecb790a..00000000000--- a/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.cpp+++ /dev/null@@ -1,85 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibIPC/Decoder.h>-#include <LibIPC/Encoder.h>-#include <LibWebCommon/Page/AsyncScrollNodeStableID.h>--namespace IPC {--template<>-ErrorOr<void> encode(Encoder& encoder, Web::AsyncScrollNodeStableID const& stable_node_id)-{- TRY(encoder.encode(stable_node_id.node_id));- TRY(encoder.encode(stable_node_id.kind));- TRY(encoder.encode(stable_node_id.pseudo_element_type));- return {};-}--template<>-ErrorOr<Web::AsyncScrollNodeStableID> decode(Decoder& decoder)-{- return Web::AsyncScrollNodeStableID {- .node_id = TRY(decoder.decode<Web::UniqueNodeID>()),- .kind = TRY(decoder.decode<Web::AsyncScrollNodeKind>()),- .pseudo_element_type = TRY(decoder.decode<u8>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Web::CompositorScrollOffset const& scroll_offset)-{- TRY(encoder.encode(scroll_offset.scroll_node));- TRY(encoder.encode(scroll_offset.offset));- return {};-}--template<>-ErrorOr<Web::CompositorScrollOffset> decode(Decoder& decoder)-{- return Web::CompositorScrollOffset {- .scroll_node = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .offset = TRY(decoder.decode<Web::CSSPixelPoint>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Web::ScrollbarDraggedByCompositor const& scrollbar)-{- TRY(encoder.encode(scrollbar.context_id));- TRY(encoder.encode(scrollbar.scroller_stable_node_id));- return {};-}--template<>-ErrorOr<Web::ScrollbarDraggedByCompositor> decode(Decoder& decoder)-{- return Web::ScrollbarDraggedByCompositor {- .context_id = TRY(decoder.decode<Web::CompositorContextId>()),- .scroller_stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- };-}--template<>-ErrorOr<void> encode(Encoder& encoder, Web::OverlayScrollbarVisibility const& visibility)-{- TRY(encoder.encode(visibility.scroller_stable_node_id));- TRY(encoder.encode(visibility.vertical));- TRY(encoder.encode(visibility.hidden));- return {};-}--template<>-ErrorOr<Web::OverlayScrollbarVisibility> decode(Decoder& decoder)-{- return Web::OverlayScrollbarVisibility {- .scroller_stable_node_id = TRY(decoder.decode<Web::AsyncScrollNodeStableID>()),- .vertical = TRY(decoder.decode<bool>()),- .hidden = TRY(decoder.decode<bool>()),- };-}--}diff --git a/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.h b/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.hindex 04580e5aef5..b04919adcf6 100644--- a/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.h+++ b/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.h@@ -72,26 +72,4 @@ struct AK::Traits<Web::AsyncScrollNodeStableID> : DefaultTraits<Web::AsyncScroll}};-namespace IPC {--template<>-WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::AsyncScrollNodeStableID const&);-template<>-WEBCOMMON_API ErrorOr<Web::AsyncScrollNodeStableID> decode(Decoder&);--template<>-WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::CompositorScrollOffset const&);-template<>-WEBCOMMON_API ErrorOr<Web::CompositorScrollOffset> decode(Decoder&);--template<>-WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::ScrollbarDraggedByCompositor const&);-template<>-WEBCOMMON_API ErrorOr<Web::ScrollbarDraggedByCompositor> decode(Decoder&);--template<>-WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::OverlayScrollbarVisibility const&);-template<>-WEBCOMMON_API ErrorOr<Web::OverlayScrollbarVisibility> decode(Decoder&);--}+#include <LibWebCommon/Page/AsyncScrollNodeStableIDCodecs.h>diff --git a/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.ipc b/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.ipcnew file mode 100644index 00000000000..123af619ac2--- /dev/null+++ b/Libraries/LibWebCommon/Page/AsyncScrollNodeStableID.ipc@@ -0,0 +1,42 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++// NB: The IPC compiler cannot check that each struct here lists every field of its C++ type. A field left out+// here does not cross IPC.++#include <LibWebCommon/Page/AsyncScrollNodeStableID.h>++[ExistingCpp, RustDerive=Hash]+enum Web::AsyncScrollNodeKind : u8 {+ Viewport,+ Element,+ PseudoElement,+ VisualViewport,+}++[ExistingCpp, RustDerive=Copy+Eq+Hash]+struct Web::AsyncScrollNodeStableID {+ Web::UniqueNodeID node_id;+ Web::AsyncScrollNodeKind kind;+ u8 pseudo_element_type;+}++[ExistingCpp, RustDerive=Copy]+struct Web::CompositorScrollOffset {+ Web::AsyncScrollNodeStableID scroll_node;+ Web::CSSPixelPoint offset;+}++[ExistingCpp, RustDerive=Copy+Eq+Hash]+struct Web::ScrollbarDraggedByCompositor {+ Web::CompositorContextId context_id;+ Web::AsyncScrollNodeStableID scroller_stable_node_id;+}++[ExistingCpp, RustDerive=Copy+Eq+Hash]+struct Web::OverlayScrollbarVisibility {+ Web::AsyncScrollNodeStableID scroller_stable_node_id;+ bool vertical;+ bool hidden;+}diff --git a/Libraries/LibWebCommon/Page/InputRoutingDecision.cpp b/Libraries/LibWebCommon/Page/InputRoutingDecision.cppindex 3d34d6a43a2..32ee0ca0ee2 100644--- a/Libraries/LibWebCommon/Page/InputRoutingDecision.cpp+++ b/Libraries/LibWebCommon/Page/InputRoutingDecision.cpp@@ -9,6 +9,26 @@namespace Web {+// NB: Rust has the decisions without their strings, and makes each string from the name.+static consteval bool is_kebab_case_of(StringView string, StringView name)+{+ size_t string_index = 0;+ for (size_t name_index = 0; name_index < name.length(); ++name_index) {+ auto character = name[name_index];+ auto is_upper_case = character >= 'A' && character <= 'Z';+ if (is_upper_case && name_index > 0 && (string_index >= string.length() || string[string_index++] != '-'))+ return false;+ auto lower_case_character = is_upper_case ? static_cast<char>(character - 'A' + 'a') : character;+ if (string_index >= string.length() || string[string_index++] != lower_case_character)+ return false;+ }+ return string_index == string.length();+}++#define __ENUMERATE_INPUT_ROUTING_DECISION(name, string) static_assert(is_kebab_case_of(string##sv, #name##sv));+ENUMERATE_INPUT_ROUTING_DECISIONS(__ENUMERATE_INPUT_ROUTING_DECISION)+#undef __ENUMERATE_INPUT_ROUTING_DECISION+StringView input_routing_decision_name(InputRoutingDecision decision){switch (decision) {diff --git a/Libraries/LibWebCommon/Page/InputRoutingDecision.h b/Libraries/LibWebCommon/Page/InputRoutingDecision.hindex e2ca5d2bbc9..0d4dadb39bd 100644--- a/Libraries/LibWebCommon/Page/InputRoutingDecision.h+++ b/Libraries/LibWebCommon/Page/InputRoutingDecision.h@@ -78,3 +78,5 @@ enum class InputRoutingDecision : u8 {WEBCOMMON_API StringView input_routing_decision_name(InputRoutingDecision);}++#include <LibWebCommon/Page/InputRoutingDecisionCodecs.h>diff --git a/Libraries/LibWebCommon/Page/InputRoutingDecision.ipc b/Libraries/LibWebCommon/Page/InputRoutingDecision.ipcnew file mode 100644index 00000000000..6057e042c81--- /dev/null+++ b/Libraries/LibWebCommon/Page/InputRoutingDecision.ipc@@ -0,0 +1,63 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++#include <LibWebCommon/Page/InputRoutingDecision.h>++[ExistingCpp, RustDerive=Hash]+enum Web::InputRoutingDecision : u8 {+ ContextNotPresenting,+ NoAsyncScrollingState,+ BlockingWheelEventListeners,+ NoScrollNode,+ StaleWheelEventListeners,+ StepOvertaken,+ GestureEndWithNothingToSnap,+ SnappedAtGestureEnd,+ HitTestTargetsOfAnotherVisualContextTree,+ BlockedByMainThreadRegion,+ BlockedByWheelEventRegion,+ NoScrollTarget,+ ScrollerInOtherDocument,+ StepWithoutDelta,+ PannedVisualViewport,+ Latched,+ LatchedOutermostScrollerToStretch,+ ContinuedLatch,+ HandedToNestedContext,+ NestedContextPassedStepOn,+ NestedContextUnavailable,+ NotOverAScrollbar,+ NotPrimaryButton,+ HoveringScrollbarPaintedByCompositor,+ HoveringScrollbarPaintedByDisplayList,+ BeganScrollbarDrag,+ ContinuedScrollbarDrag,+ EndedScrollbarDrag,+ NoScrollbarDrag,+ LeftDuringScrollbarDrag,+ GestureEndAbsorbedByFling,+ FlingStarted,+ MomentumInterrupted,+ NotDispatchedByCompositor,+ ConsumedByCompositor,+ ForwardedToPage,+ NoAnswerFromCompositor,+ CoalescedIntoLaterEvent,+ DroppedWithoutLocalRoot,+ DroppedOutdatedPointerMove,+ ForwardedToRemoteFrame,+ CompositorDisplayListOutdated,+ StepExceedsInputLeftToThePage,+ DefaultActionPerformedByCompositor,+ NoWheelTarget,+ HandedToNestedNavigable,+ DispatchedWheelEvent,+ PageCanceledWheelEvent,+ ScrollKeptByOverscrollBehavior,+ ScrollbarDragDrivenByCompositor,+ FinishedAccepted,+ FinishedHandled,+ FinishedCancelled,+ FinishedDropped,+}diff --git a/Libraries/LibWebCommon/Page/InputTrace.cpp b/Libraries/LibWebCommon/Page/InputTrace.cppindex 7bed8259de1..4a36cc1e669 100644--- a/Libraries/LibWebCommon/Page/InputTrace.cpp+++ b/Libraries/LibWebCommon/Page/InputTrace.cpp@@ -4,8 +4,6 @@* SPDX-License-Identifier: BSD-2-Clause*/-#include <LibIPC/Decoder.h>-#include <LibIPC/Encoder.h>#include <LibWebCommon/Page/InputTrace.h>namespace Web {@@ -41,30 +39,3 @@ Vector<InputTraceRecord> InputTraceRecorder::take()}}--namespace IPC {--template<>-ErrorOr<void> encode(Encoder& encoder, Web::InputTraceRecord const& record)-{- TRY(encoder.encode(record.input_event_id));- TRY(encoder.encode(record.stage));- TRY(encoder.encode(record.decision));- TRY(encoder.encode(record.scroller));- TRY(encoder.encode(record.dom_target));- return {};-}--template<>-ErrorOr<Web::InputTraceRecord> decode(Decoder& decoder)-{- return Web::InputTraceRecord {- .input_event_id = TRY(decoder.decode<u64>()),- .stage = TRY(decoder.decode<Web::InputTraceStage>()),- .decision = TRY(decoder.decode<Web::InputRoutingDecision>()),- .scroller = TRY(decoder.decode<Optional<Web::AsyncScrollNodeStableID>>()),- .dom_target = TRY(decoder.decode<Optional<Web::UniqueNodeID>>()),- };-}--}diff --git a/Libraries/LibWebCommon/Page/InputTrace.h b/Libraries/LibWebCommon/Page/InputTrace.hindex fdb0bf15f35..902207e48a0 100644--- a/Libraries/LibWebCommon/Page/InputTrace.h+++ b/Libraries/LibWebCommon/Page/InputTrace.h@@ -52,11 +52,4 @@ private:}-namespace IPC {--template<>-WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::InputTraceRecord const&);-template<>-WEBCOMMON_API ErrorOr<Web::InputTraceRecord> decode(Decoder&);--}+#include <LibWebCommon/Page/InputTraceCodecs.h>diff --git a/Libraries/LibWebCommon/Page/InputTrace.ipc b/Libraries/LibWebCommon/Page/InputTrace.ipcnew file mode 100644index 00000000000..d1797f844f2--- /dev/null+++ b/Libraries/LibWebCommon/Page/InputTrace.ipc@@ -0,0 +1,24 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++// NB: The IPC compiler cannot check that each struct here lists every field of its C++ type. A field left out+// here does not cross IPC.++#include <LibWebCommon/Page/InputTrace.h>++[ExistingCpp]+enum Web::InputTraceStage : u8 {+ Compositor,+ CompositorForMainThread,+ WebContent,+}++[ExistingCpp]+struct Web::InputTraceRecord {+ u64 input_event_id;+ Web::InputTraceStage stage;+ Web::InputRoutingDecision decision;+ Optional<Web::AsyncScrollNodeStableID> scroller;+ Optional<Web::UniqueNodeID> dom_target;+}diff --git a/Libraries/LibWebCommon/UIEvents/KeyCode.h b/Libraries/LibWebCommon/UIEvents/KeyCode.hindex 0b865540e35..b342f81a6d8 100644--- a/Libraries/LibWebCommon/UIEvents/KeyCode.h+++ b/Libraries/LibWebCommon/UIEvents/KeyCode.h@@ -283,3 +283,5 @@ inline KeyCode code_point_to_key_code(u32 code_point)}}++#include <LibWebCommon/UIEvents/KeyCodeCodecs.h>diff --git a/Libraries/LibWebCommon/UIEvents/KeyCode.ipc b/Libraries/LibWebCommon/UIEvents/KeyCode.ipcnew file mode 100644index 00000000000..582bdc5b2d2--- /dev/null+++ b/Libraries/LibWebCommon/UIEvents/KeyCode.ipc@@ -0,0 +1,158 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++#include <LibWebCommon/UIEvents/KeyCode.h>++[ExistingCpp]+enum Web::UIEvents::KeyCode : u8 {+ Key_Invalid = 0x00,+ Key_Backspace = 0x08,+ Key_Tab = 0x09,+ Key_Return = 0x0D,+ Key_LeftShift = 0x10,+ Key_RightShift = 0xB0,+ Key_LeftControl = 0x11,+ Key_RightControl = 0xB1,+ Key_LeftAlt = 0x12,+ Key_RightAlt = 0xB2,+ Key_AltGr = 0xE1,+ Key_PauseBreak = 0x13,+ Key_CapsLock = 0x14,+ Key_Escape = 0x1B,+ Key_Space = 0x20,+ Key_PageUp = 0x21,+ Key_PageDown = 0x22,+ Key_End = 0x23,+ Key_Home = 0x24,+ Key_Left = 0x25,+ Key_Up = 0x26,+ Key_Right = 0x27,+ Key_Down = 0x28,+ Key_PrintScreen = 0x2A,+ Key_SysRq = 0x2C,+ Key_Delete = 0x2E,+ Key_0 = 0x30,+ Key_1 = 0x31,+ Key_2 = 0x32,+ Key_3 = 0x33,+ Key_4 = 0x34,+ Key_5 = 0x35,+ Key_6 = 0x36,+ Key_7 = 0x37,+ Key_8 = 0x38,+ Key_9 = 0x39,+ Key_A = 0x41,+ Key_B = 0x42,+ Key_C = 0x43,+ Key_D = 0x44,+ Key_E = 0x45,+ Key_F = 0x46,+ Key_G = 0x47,+ Key_H = 0x48,+ Key_I = 0x49,+ Key_J = 0x4A,+ Key_K = 0x4B,+ Key_L = 0x4C,+ Key_M = 0x4D,+ Key_N = 0x4E,+ Key_O = 0x4F,+ Key_P = 0x50,+ Key_Q = 0x51,+ Key_R = 0x52,+ Key_S = 0x53,+ Key_T = 0x54,+ Key_U = 0x55,+ Key_V = 0x56,+ Key_W = 0x57,+ Key_X = 0x58,+ Key_Y = 0x59,+ Key_Z = 0x5A,+ Key_RightParen = 0x60,+ Key_ExclamationPoint = 0x61,+ Key_AtSign = 0x62,+ Key_Hashtag = 0x63,+ Key_Dollar = 0x64,+ Key_Percent = 0x65,+ Key_Circumflex = 0x66,+ Key_Ampersand = 0x67,+ Key_Asterisk = 0x68,+ Key_LeftParen = 0x69,+ Key_Plus = 0x6A,+ Key_Minus = 0x6B,+ Key_Slash = 0x6C,+ Key_Comma = 0x6D,+ Key_Period = 0x6E,+ Key_Colon = 0x6F,+ Key_F1 = 0x70,+ Key_F2 = 0x71,+ Key_F3 = 0x72,+ Key_F4 = 0x73,+ Key_F5 = 0x74,+ Key_F6 = 0x75,+ Key_F7 = 0x76,+ Key_F8 = 0x77,+ Key_F9 = 0x78,+ Key_F10 = 0x79,+ Key_F11 = 0x7A,+ Key_F12 = 0x7B,+ Key_DoubleQuote = 0x7C,+ Key_Apostrophe = 0x7D,+ Key_Insert = 0x7E,+ Key_Semicolon = 0x7F,+ Key_LessThan = 0x80,+ Key_Equal = 0x81,+ Key_GreaterThan = 0x82,+ Key_QuestionMark = 0x83,+ Key_LeftBracket = 0x84,+ Key_RightBracket = 0x85,+ Key_Backslash = 0x86,+ Key_Underscore = 0x87,+ Key_LeftBrace = 0x88,+ Key_RightBrace = 0x89,+ Key_Pipe = 0x8A,+ Key_Tilde = 0x8B,+ Key_Backtick = 0x8C,+ Key_NumLock = 0x90,+ Key_ScrollLock = 0x91,+ Key_LeftSuper = 0x92,+ Key_RightSuper = 0xAC,+ Key_BrowserSearch = 0x93,+ Key_BrowserFavorites = 0x94,+ Key_BrowserHome = 0x95,+ Key_PreviousTrack = 0x96,+ Key_BrowserBack = 0x97,+ Key_BrowserForward = 0x98,+ Key_BrowserRefresh = 0x99,+ Key_BrowserStop = 0x9A,+ Key_VolumeDown = 0x9B,+ Key_VolumeUp = 0x9C,+ Key_Wake = 0x9D,+ Key_Sleep = 0x9E,+ Key_NextTrack = 0x9F,+ Key_MediaSelect = 0xA0,+ Key_Email = 0xA1,+ Key_MyComputer = 0xA2,+ Key_Power = 0xA3,+ Key_Stop = 0xA4,+ Key_LeftGUI = 0xA5,+ Key_Mute = 0xA6,+ Key_RightGUI = 0xA7,+ Key_Calculator = 0xA8,+ Key_Apps = 0xA9,+ Key_PlayPause = 0xAA,+ Key_Menu = 0xAB,+}++// NB: Mod_PlatformCtrl and Mod_PlatformWordJump each name one of these, which one depends on the platform.+[ExistingCpp, Flags, RustDerive=Default+Hash]+enum Web::UIEvents::KeyModifier : u32 {+ Mod_None = 0x00,+ Mod_Alt = 0x01,+ Mod_Ctrl = 0x02,+ Mod_Shift = 0x04,+ Mod_Super = 0x08,+ Mod_Keypad = 0x10,+ Mod_Mask = 0x1F,+ Is_Press = 0x80,+}diff --git a/Libraries/LibWebCommon/UIEvents/MouseButton.h b/Libraries/LibWebCommon/UIEvents/MouseButton.hindex f0d85d62572..31f19c94a10 100644--- a/Libraries/LibWebCommon/UIEvents/MouseButton.h+++ b/Libraries/LibWebCommon/UIEvents/MouseButton.h@@ -61,3 +61,5 @@ constexpr MouseButton button_code_to_mouse_button(i16 button)}}++#include <LibWebCommon/UIEvents/MouseButtonCodecs.h>diff --git a/Libraries/LibWebCommon/UIEvents/MouseButton.ipc b/Libraries/LibWebCommon/UIEvents/MouseButton.ipcnew file mode 100644index 00000000000..b198643352c--- /dev/null+++ b/Libraries/LibWebCommon/UIEvents/MouseButton.ipc@@ -0,0 +1,15 @@+// Copyright (c) 2026-present, the Ladybird developers.+//+// SPDX-License-Identifier: BSD-2-Clause++#include <LibWebCommon/UIEvents/MouseButton.h>++[ExistingCpp, Flags, RustDerive=Default+Hash]+enum Web::UIEvents::MouseButton : u8 {+ None = 0,+ Primary = 1,+ Secondary = 2,+ Middle = 4,+ Backward = 8,+ Forward = 16,+}diff --git a/Services/Compositor/ConnectionFromWebContent.cpp b/Services/Compositor/ConnectionFromWebContent.cppindex 9c263e2e40f..5d7f727e239 100644--- a/Services/Compositor/ConnectionFromWebContent.cpp+++ b/Services/Compositor/ConnectionFromWebContent.cpp@@ -630,6 +630,8 @@ static bool is_valid_scroll_request(Compositing::ScrollRequest const& scroll_reqif (auto const& smooth_scroll = scroll_request.smooth_scroll; smooth_scroll.has_value()) {if (!is_finite(smooth_scroll->destination_offset))return false;+ if (!(smooth_scroll->relative_lower_bound.x() <= smooth_scroll->relative_upper_bound.x() && smooth_scroll->relative_lower_bound.y() <= smooth_scroll->relative_upper_bound.y()))+ return false;// WebContent names the compositor's own scrolls only to head them somewhere else.if (smooth_scroll->operation_id < Compositing::first_operation_id_the_main_thread_requests && !smooth_scroll->retargets_operation)return false;