Skip to content

Truly independent web browser

LibCompositing: Move display list properties out of DisplayList

Aliaksandr Kalenik305216d1bc32
diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.cpp b/Libraries/LibCompositing/DisplayList/DisplayList.cpp
index 54c99a22758..130836ffc43 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayList.cpp
+++ b/Libraries/LibCompositing/DisplayList/DisplayList.cpp
@@ -62,7 +62,7 @@ NonnullRefPtr<DisplayList> DisplayList::share_rust_recording(void const* lent_co
return adopt_rust_storage(RustFFI::display_list_storage_share_recorded(lent_commands, lent_visual_context_tree));
}
-NonnullRefPtr<DisplayList> DisplayList::adopt_received_storage(Properties properties, void const* storage)
+NonnullRefPtr<DisplayList> DisplayList::adopt_received_storage(DisplayListProperties properties, void const* storage)
{
return adopt_ref(*new DisplayList(properties.compatible_visual_context_tree_structural_epoch, properties.id, storage, properties.surface_clear_color, properties.root_group_color, {}));
}
@@ -147,7 +147,7 @@ ErrorOr<Core::AnonymousBuffer> DisplayList::copy_to_shared_buffer() const
return buffer;
}
-ErrorOr<NonnullRefPtr<DisplayList>> DisplayList::create_from_shared_buffer(Properties properties, Core::AnonymousBuffer shared_tape_buffer, u64 tape_size, u64 run_count)
+ErrorOr<NonnullRefPtr<DisplayList>> DisplayList::create_from_shared_buffer(DisplayListProperties properties, Core::AnonymousBuffer shared_tape_buffer, u64 tape_size, u64 run_count)
{
ReadonlyBytes packed;
if (shared_tape_buffer.is_valid()) {
@@ -162,7 +162,7 @@ ErrorOr<NonnullRefPtr<DisplayList>> DisplayList::create_from_shared_buffer(Prope
return adopt_received_storage(move(properties), storage);
}
-DisplayList::Properties DisplayList::properties() const
+DisplayListProperties DisplayList::properties() const
{
return {
.id = m_id,
@@ -210,7 +210,7 @@ ErrorOr<void> encode(Encoder& encoder, NonnullRefPtr<Compositing::DisplayList> c
template<>
ErrorOr<NonnullRefPtr<Compositing::DisplayList>> decode(Decoder& decoder)
{
- auto properties = TRY(decoder.decode<Compositing::DisplayList::Properties>());
+ auto properties = TRY(decoder.decode<Compositing::DisplayListProperties>());
auto tape_size = TRY(decoder.decode_size());
auto run_count = TRY(decoder.decode_size());
auto const* storage = TRY(Compositing::receive_display_list_tape(tape_size, run_count, [&](Bytes tape, Bytes run_bytes) -> ErrorOr<void> {
diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.h b/Libraries/LibCompositing/DisplayList/DisplayList.h
index f4324a04997..aabc53b9733 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayList.h
+++ b/Libraries/LibCompositing/DisplayList/DisplayList.h
@@ -15,6 +15,7 @@
#include <AK/NonnullRefPtr.h>
#include <AK/Span.h>
#include <LibCompositing/DisplayList/DisplayListCommand.h>
+#include <LibCompositing/DisplayList/DisplayListProperties.h>
#include <LibCompositing/Export.h>
#include <LibCompositing/Forward.h>
#include <LibCompositing/Types.h>
@@ -35,30 +36,6 @@ struct FfiRasterPainter;
class COMPOSITING_API DisplayList : public AtomicRefCounted<DisplayList> {
public:
~DisplayList();
- struct AsyncScrollingMetadata {
- // The document whose viewport this is, which the compositor names when it pans the visual viewport of a page
- // that has no scroll node.
- Optional<Web::UniqueNodeID> document_id;
- Gfx::IntRect viewport_rect;
- u64 wheel_event_listener_state_generation { 0 };
- bool has_blocking_wheel_event_listeners { false };
- bool has_blocking_wheel_event_region_covering_viewport { false };
- // Whether the viewport keeps the scrolls along an axis from the document it is nested in. A viewport with
- // nothing to scroll has no scroll node to carry its overscroll-behavior.
- bool viewport_keeps_horizontal_scrolls { false };
- bool viewport_keeps_vertical_scrolls { false };
- // Converts the compositor's device pixel offsets to the CSS pixels the snap geometry is in.
- double device_pixels_per_css_pixel { 1.0 };
- Compositing::KeyboardScrollState keyboard_scroll_state {};
- };
-
- // What travels alongside the tape of a list for whatever plays the list.
- struct Properties {
- u64 id { 0 };
- u64 compatible_visual_context_tree_structural_epoch { 0 };
- Optional<Gfx::Color> surface_clear_color;
- Gfx::Color root_group_color { Gfx::Color::Transparent };
- };
// An empty list, recorded against a visual context tree with no node but the visual viewport.
static NonnullRefPtr<DisplayList> create_empty();
@@ -77,9 +54,9 @@ public:
ErrorOr<Core::AnonymousBuffer> copy_to_shared_buffer() const;
// The receiver's side: copies the tape and the run table out of the buffer, which the sender can still
// write to, and checks the copies. Fails when the sizes do not fit the buffer or the tape is malformed.
- static ErrorOr<NonnullRefPtr<DisplayList>> create_from_shared_buffer(Properties, Core::AnonymousBuffer, u64 tape_size, u64 run_count);
+ static ErrorOr<NonnullRefPtr<DisplayList>> create_from_shared_buffer(DisplayListProperties, Core::AnonymousBuffer, u64 tape_size, u64 run_count);
- Properties properties() const;
+ DisplayListProperties properties() const;
u64 compatible_visual_context_tree_structural_epoch() const { return m_compatible_visual_context_tree_structural_epoch; }
u64 id() const { return m_id; }
@@ -124,7 +101,7 @@ public:
private:
// Takes over the storage of a tape that came from another process and passed its checks.
- static NonnullRefPtr<DisplayList> adopt_received_storage(Properties, void const* storage);
+ static NonnullRefPtr<DisplayList> adopt_received_storage(DisplayListProperties, void const* storage);
DisplayList(u64 compatible_visual_context_tree_structural_epoch, u64 id, void const* storage, Optional<Gfx::Color> surface_clear_color, Gfx::Color root_group_color, Optional<AsyncScrollingMetadata>);
@@ -154,5 +131,3 @@ template<>
COMPOSITING_API ErrorOr<NonnullRefPtr<Compositing::DisplayList>> decode(Decoder&);
}
-
-#include <LibCompositing/DisplayList/DisplayListPropertiesCodecs.h>
diff --git a/Libraries/LibCompositing/DisplayList/DisplayListProperties.h b/Libraries/LibCompositing/DisplayList/DisplayListProperties.h
new file mode 100644
index 00000000000..3ab7390c2eb
--- /dev/null
+++ b/Libraries/LibCompositing/DisplayList/DisplayListProperties.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Optional.h>
+#include <AK/Types.h>
+#include <LibCompositing/Types.h>
+#include <LibGfx/Color.h>
+#include <LibGfx/Rect.h>
+
+namespace Compositing {
+
+// What a display list of a document's viewport is stamped with for async scrolling.
+struct AsyncScrollingMetadata {
+ // The document whose viewport this is, which the compositor names when it pans the visual viewport of a page that
+ // has no scroll node.
+ Optional<Web::UniqueNodeID> document_id;
+ Gfx::IntRect viewport_rect;
+ u64 wheel_event_listener_state_generation { 0 };
+ bool has_blocking_wheel_event_listeners { false };
+ bool has_blocking_wheel_event_region_covering_viewport { false };
+ // Whether the viewport keeps the scrolls along an axis from the document it is nested in. A viewport with nothing to
+ // scroll has no scroll node to carry its overscroll-behavior.
+ bool viewport_keeps_horizontal_scrolls { false };
+ bool viewport_keeps_vertical_scrolls { false };
+ // Converts the compositor's device pixel offsets to the CSS pixels the snap geometry is in.
+ double device_pixels_per_css_pixel { 1.0 };
+ Compositing::KeyboardScrollState keyboard_scroll_state {};
+};
+
+// What travels alongside the tape of a display list for whatever plays the list.
+struct DisplayListProperties {
+ u64 id { 0 };
+ u64 compatible_visual_context_tree_structural_epoch { 0 };
+ Optional<Gfx::Color> surface_clear_color;
+ Gfx::Color root_group_color { Gfx::Color::Transparent };
+};
+
+}
+
+#include <LibCompositing/DisplayList/DisplayListPropertiesCodecs.h>
diff --git a/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc b/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc
index 16e29980be2..9f09c05853a 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc
+++ b/Libraries/LibCompositing/DisplayList/DisplayListProperties.ipc
@@ -5,10 +5,10 @@
// 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>
+#include <LibCompositing/DisplayList/DisplayListProperties.h>
[ExistingCpp]
-struct Compositing::DisplayList::AsyncScrollingMetadata {
+struct Compositing::AsyncScrollingMetadata {
Optional<Web::UniqueNodeID> document_id;
Gfx::IntRect viewport_rect;
u64 wheel_event_listener_state_generation;
@@ -21,7 +21,7 @@ struct Compositing::DisplayList::AsyncScrollingMetadata {
}
[ExistingCpp]
-struct Compositing::DisplayList::Properties {
+struct Compositing::DisplayListProperties {
u64 id;
u64 compatible_visual_context_tree_structural_epoch;
Optional<Gfx::Color> surface_clear_color;
diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rs
index 17614de8e4a..141d17e426f 100644
--- a/Libraries/LibCompositing/Rust/src/ffi.rs
+++ b/Libraries/LibCompositing/Rust/src/ffi.rs
@@ -211,7 +211,7 @@ pub struct FfiDisplayList<'a> {
pub storage: *const c_void,
pub id: u64,
pub compatible_visual_context_tree_structural_epoch: u64,
- /// A `Compositing::DisplayList::AsyncScrollingMetadata`, or none.
+ /// A `Compositing::AsyncScrollingMetadata`, or none.
pub async_scrolling_metadata: EncodedValue<'a>,
pub has_surface_clear_color: bool,
pub surface_clear_color: libgfx_rust::Color,
diff --git a/Libraries/LibCompositing/Rust/src/ipc_types.rs b/Libraries/LibCompositing/Rust/src/ipc_types.rs
index b8f359d53ff..a4898f4ebfd 100644
--- a/Libraries/LibCompositing/Rust/src/ipc_types.rs
+++ b/Libraries/LibCompositing/Rust/src/ipc_types.rs
@@ -156,7 +156,7 @@ impl Decode for Core_AnonymousBuffer {
/// A display list that another one nests, with the tree it was recorded against.
#[derive(Clone)]
pub struct NestedDisplayListResource {
- pub properties: Compositing_DisplayList_Properties,
+ pub properties: Compositing_DisplayListProperties,
pub storage: Arc<DisplayListStorage>,
pub tree: Arc<VisualContextTree>,
}
@@ -235,7 +235,7 @@ impl Decode for Compositing_DisplayListResourceTransaction {
let display_list_count = decoder.decode_size()?;
let mut display_lists = Vec::new();
for _ in 0..display_list_count {
- let properties: Compositing_DisplayList_Properties = decoder.decode()?;
+ let properties: Compositing_DisplayListProperties = decoder.decode()?;
let tape_size = decoder.decode_size()?;
let run_count = decoder.decode_size()?;
let packed_size =
diff --git a/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs b/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
index 940bbab4e21..b569f391550 100644
--- a/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
+++ b/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
@@ -14,7 +14,7 @@ use crate::display_list::summary::{for_each_compositor_metadata, for_each_indexe
use libgfx_rust::{Color, IntRect};
use std::sync::Arc;
-pub use crate::ipc_types::Compositing_DisplayList_AsyncScrollingMetadata as AsyncScrollingMetadata;
+pub use crate::ipc_types::Compositing_AsyncScrollingMetadata as AsyncScrollingMetadata;
pub struct DisplayList {
// One strong reference to the Rust storage, which owns the tape.
diff --git a/Libraries/LibCompositing/Scrolling/RecordedDisplayListScrolling.cpp b/Libraries/LibCompositing/Scrolling/RecordedDisplayListScrolling.cpp
index 71f652f96c5..438b342ec7c 100644
--- a/Libraries/LibCompositing/Scrolling/RecordedDisplayListScrolling.cpp
+++ b/Libraries/LibCompositing/Scrolling/RecordedDisplayListScrolling.cpp
@@ -11,7 +11,7 @@
namespace Compositing {
-using EncodedAsyncScrollingMetadata = IPC::Encoded<Optional<DisplayList::AsyncScrollingMetadata>>;
+using EncodedAsyncScrollingMetadata = IPC::Encoded<Optional<AsyncScrollingMetadata>>;
static void receive_json(void* receiver, ReadonlyBytes bytes)
{
diff --git a/Libraries/LibWeb/Painting/DisplayListRecording.h b/Libraries/LibWeb/Painting/DisplayListRecording.h
index 39a97a555b3..37b52183653 100644
--- a/Libraries/LibWeb/Painting/DisplayListRecording.h
+++ b/Libraries/LibWeb/Painting/DisplayListRecording.h
@@ -47,7 +47,7 @@ struct DisplayListRecording {
bool in_flight { false };
// What its display list is stamped with for async scrolling, sealed where the recording began, and the display list
// it copied paint commands from then, which it publishes again where it recorded the same.
- Optional<Compositing::DisplayList::AsyncScrollingMetadata> async_scrolling_metadata;
+ Optional<Compositing::AsyncScrollingMetadata> async_scrolling_metadata;
RefPtr<Compositing::DisplayList> paint_command_cache_source;
};
diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
index b89c14ffa4d..222ad362aba 100644
--- a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
@@ -622,7 +622,7 @@ Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRe
inputs.background_color = document.background_color(read);
}
inputs.has_navigable_container_with_composited_context = reconcile_navigable_container_paint_facts(read, document);
- Optional<Compositing::DisplayList::AsyncScrollingMetadata> async_scrolling_metadata;
+ Optional<Compositing::AsyncScrollingMetadata> async_scrolling_metadata;
if (auto navigable = document.navigable()) {
bool viewport_keeps_horizontal_scrolls = false;
bool viewport_keeps_vertical_scrolls = false;
@@ -630,7 +630,7 @@ Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRe
viewport_keeps_horizontal_scrolls = Painting::box_ending_scroll_chain(*viewport_box, 1, 0) == viewport_box;
viewport_keeps_vertical_scrolls = Painting::box_ending_scroll_chain(*viewport_box, 0, 1) == viewport_box;
}
- async_scrolling_metadata = Compositing::DisplayList::AsyncScrollingMetadata {
+ async_scrolling_metadata = Compositing::AsyncScrollingMetadata {
.document_id = document.unique_id(),
.viewport_rect = device_viewport_rect.to_type<int>(),
.wheel_event_listener_state_generation = navigable->page().wheel_event_listener_state_generation(),
diff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipc
index 83455f7af32..fef20f4ebda 100644
--- a/Services/Compositor/CompositorWebContentServer.ipc
+++ b/Services/Compositor/CompositorWebContentServer.ipc
@@ -1,7 +1,7 @@
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <LibCompositing/DisplayList/Canvas2DCommandStream.h>
-#include <LibCompositing/DisplayList/DisplayList.h>
+#include <LibCompositing/DisplayList/DisplayListProperties.h>
#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>
#include <LibCompositing/Forward.h>
#include <LibCompositing/Types.h>
@@ -43,7 +43,7 @@ endpoint CompositorWebContentServer
// The fonts and image frames that a display list or a visual context tree draws go ahead of it, in
// update_display_list_resources, and the resource transaction that comes with it holds none. Rust encoded the scroll
// state.
- [RustReceiver] update_display_list(Web::CompositorContextId context_id, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayList::Properties display_list_properties, Optional<Compositing::DisplayList::AsyncScrollingMetadata> async_scrolling_metadata, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state) =|
+ [RustReceiver] update_display_list(Web::CompositorContextId context_id, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, Optional<Compositing::AsyncScrollingMetadata> async_scrolling_metadata, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state) =|
update_display_list_resources(Web::CompositorContextId context_id, Compositing::DisplayListResourceTransaction resource_transaction) =|
[RustReceiver] update_visual_context_tree(Web::CompositorContextId context_id, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|
[RustReceiver] update_scroll_state(Web::CompositorContextId context_id, ByteBuffer scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|
@@ -67,7 +67,7 @@ endpoint CompositorWebContentServer
// A display list is rasterized into the target bitmap with the fonts, image frames and video sinks staged for it under
// a token that the next rasterize_display_list names, and with the display lists it nests, which come with it.
stage_rasterization(u64 token, Compositing::DisplayListResourceTransaction resources, Gfx::ShareableBitmap target_bitmap) =|
- [RustReceiver] rasterize_display_list(u64 token, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayList::Properties display_list_properties, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction nested_display_lists) => (bool success)
+ [RustReceiver] rasterize_display_list(u64 token, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction nested_display_lists) => (bool success)
create_webgl_context(Compositing::WebGL::WebGLVersion webgl_version, Gfx::IntSize size, bool depth, bool stencil, bool antialias) => (bool success, Compositing::CanvasId canvas_id, Vector<String> supported_extensions)
webgl_set_command_buffer(Compositing::CanvasId canvas_id, Core::AnonymousBuffer command_buffer) =|