Skip to content

Truly independent web browser

LibCompositing+LibWeb+Compositor: Keep the presented tree in Rust

Aliaksandr Kalenikdcd6c3188380
diff --git a/Libraries/LibCompositing/Rust/src/ipc_types.rs b/Libraries/LibCompositing/Rust/src/ipc_types.rs
index 98645e3591c..b8f359d53ff 100644
--- a/Libraries/LibCompositing/Rust/src/ipc_types.rs
+++ b/Libraries/LibCompositing/Rust/src/ipc_types.rs
@@ -153,25 +153,6 @@ impl Decode for Core_AnonymousBuffer {
}
}
-/// `Compositing::AccumulatedVisualContextTree`, which goes as its serialized bytes.
-#[derive(Clone)]
-pub struct Compositing_AccumulatedVisualContextTree(pub Arc<VisualContextTree>);
-
-impl Encode for Compositing_AccumulatedVisualContextTree {
- fn encode(&self, encoder: &mut Encoder) -> Result<(), EncodeError> {
- encoder.encode(&self.0.to_bytes())
- }
-}
-
-impl Decode for Compositing_AccumulatedVisualContextTree {
- const MIN_ENCODED_SIZE: usize = <Vec<u8> as Decode>::MIN_ENCODED_SIZE;
-
- fn decode(decoder: &mut Decoder<'_>) -> Result<Self, DecodeError> {
- let bytes: Vec<u8> = decoder.decode()?;
- Ok(Self(Arc::new(VisualContextTree::from_bytes(&bytes)?)))
- }
-}
-
/// A display list that another one nests, with the tree it was recorded against.
#[derive(Clone)]
pub struct NestedDisplayListResource {
diff --git a/Libraries/LibWeb/Compositor/CompositorFrame.h b/Libraries/LibWeb/Compositor/CompositorFrame.h
index 0cf552e1896..fee6604e7d8 100644
--- a/Libraries/LibWeb/Compositor/CompositorFrame.h
+++ b/Libraries/LibWeb/Compositor/CompositorFrame.h
@@ -10,7 +10,6 @@
#include <AK/ByteBuffer.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
-#include <LibCompositing/DisplayList/AccumulatedVisualContext.h>
#include <LibCompositing/DisplayList/DisplayList.h>
#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>
#include <LibCompositing/Types.h>
@@ -27,17 +26,19 @@ namespace Web::Compositor {
struct CompositorFrame {
AK_ALLOC_WITH_KMALLOC;
- // A newly recorded display list, with the visual context tree, resources and scroll state it paints with.
+ // A newly recorded display list, with the visual context tree, serialized, resources and scroll state it paints
+ // with.
struct DisplayListUpdate {
NonnullRefPtr<Compositing::DisplayList> display_list;
- Compositing::AccumulatedVisualContextTree visual_context_tree;
+ ByteBuffer visual_context_tree;
Compositing::DisplayListResourceTransaction resource_transaction;
ByteBuffer encoded_scroll_state;
};
- // A new visual context tree for the installed display list, with its resources, scroll snapshot and keyboard scroll state.
+ // A new visual context tree, serialized, for the installed display list, with its resources, scroll snapshot and
+ // keyboard scroll state.
struct VisualContextTreeUpdate {
- Compositing::AccumulatedVisualContextTree visual_context_tree;
+ ByteBuffer visual_context_tree;
Compositing::DisplayListResourceTransaction resource_transaction;
ByteBuffer encoded_scroll_state;
Compositing::KeyboardScrollState keyboard_scroll_state;
diff --git a/Libraries/LibWeb/Compositor/NavigablePresenter.cpp b/Libraries/LibWeb/Compositor/NavigablePresenter.cpp
index 4f0a72b7084..890f781f3a0 100644
--- a/Libraries/LibWeb/Compositor/NavigablePresenter.cpp
+++ b/Libraries/LibWeb/Compositor/NavigablePresenter.cpp
@@ -6,6 +6,7 @@
#include <LibGfx/Font/Font.h>
#include <LibWeb/Compositor/NavigablePresenter.h>
+#include <LibWeb/Layout/LayoutRustFFI.h>
#include <LibWeb/Painting/PaintingRustBridge.h>
namespace Web::Compositor {
@@ -32,24 +33,24 @@ struct PresenterFFI {
sealed.published->referenced_resources = presenter.m_compositor_display_list_command_resources;
}
- static void present(NavigablePresenter& presenter, SealedPresentation& sealed, NonnullRefPtr<Compositing::DisplayList> display_list, ReadonlyBytes encoded_scroll_state, CompositorFrameSink* sink)
+ static void present(NavigablePresenter& presenter, SealedPresentation& sealed, NonnullRefPtr<Compositing::DisplayList> display_list, Layout::RustFFI::FfiPresentedVisualContextTree const& visual_context_tree, ReadonlyBytes encoded_scroll_state, CompositorFrameSink* sink)
{
MutexLocker locker(presenter.m_mutex);
if (is_stale(presenter, sealed))
return;
- auto frame = presenter.build_frame_beside_event_loop(sealed, move(display_list), encoded_scroll_state);
+ auto frame = presenter.build_frame_beside_event_loop(sealed, move(display_list), visual_context_tree, encoded_scroll_state);
frame.scroll_requests = move(sealed.scroll_requests);
note_presented(presenter, sealed, encoded_scroll_state);
if (sink)
sink->submit(move(frame));
}
- static void present_unrecorded(NavigablePresenter& presenter, SealedPresentation& sealed, ReadonlyBytes encoded_scroll_state, CompositorFrameSink* sink)
+ static void present_unrecorded(NavigablePresenter& presenter, SealedPresentation& sealed, Layout::RustFFI::FfiPresentedVisualContextTree const& visual_context_tree, ReadonlyBytes encoded_scroll_state, CompositorFrameSink* sink)
{
MutexLocker locker(presenter.m_mutex);
if (is_stale(presenter, sealed))
return;
- auto frame = presenter.build_frame(sealed, {}, encoded_scroll_state);
+ auto frame = presenter.build_frame(sealed, {}, visual_context_tree, encoded_scroll_state);
frame.scroll_requests = move(sealed.scroll_requests);
note_presented(presenter, sealed, encoded_scroll_state);
if (sink)
@@ -60,28 +61,36 @@ struct PresenterFFI {
void NavigablePresenter::forget_compositor_display_list()
{
MutexLocker locker(m_mutex);
- m_compositor_visual_context_tree.clear();
m_compositor_display_list_paint_config.clear();
m_compositor_display_list = nullptr;
m_compositor_display_list_resources = {};
m_compositor_display_list_command_resources = {};
}
-CompositorFrame NavigablePresenter::build_frame(SealedPresentation const& sealed, Optional<PublishedDisplayList> published, ReadonlyBytes encoded_scroll_state)
+CompositorFrame NavigablePresenter::build_frame(SealedPresentation const& sealed, Optional<PublishedDisplayList> published, Layout::RustFFI::FfiPresentedVisualContextTree const& visual_context_tree, ReadonlyBytes encoded_scroll_state)
{
// A recording downgraded to cache-read-only leaves the retained source and the cached ranges into it live, so the
// resources they reference must survive the pruning that follows. A recording that replaced the source references
// everything the new source does.
- auto resources_with = [&](Compositing::DisplayListResourceSet resources, Compositing::AccumulatedVisualContextTree const& visual_context_tree) {
+ auto resources_with = [&](Compositing::DisplayListResourceSet resources) {
if (!published.has_value() || !published->replaces_paint_command_cache_source)
resources.include(sealed.paint_command_cache_source_resources);
// The next frame a rendering update commits copies paint commands from the one it committed last, whatever a
// clock lane presented since.
if (sealed.presented_by == PresentedBy::Clock)
resources.include(m_committed_command_resources);
- resources.include(m_resource_storage.collect_referenced_resources(visual_context_tree));
+ for (auto image_frame_id : ReadonlySpan<u64> { visual_context_tree.filter_image_frame_ids, visual_context_tree.filter_image_frame_id_count })
+ resources.image_frames.set(Compositing::ImageFrameResourceId { image_frame_id }, AK::HashSetExistingEntryBehavior::Keep);
return resources;
};
+ auto serialized_visual_context_tree = [&] {
+ VERIFY(visual_context_tree.tree);
+ ByteBuffer bytes;
+ Layout::RustFFI::presented_visual_context_tree_serialize(&visual_context_tree, &bytes, [](void* sink, u8 const* data, size_t size) {
+ MUST(static_cast<ByteBuffer*>(sink)->try_append(data, size));
+ });
+ return bytes;
+ };
// Keyboard eligibility belongs to this publication, not to the cached paint commands. Refresh it even if recording
// was skipped or returned the same display list, and send it with the corresponding scroll state.
@@ -105,16 +114,14 @@ CompositorFrame NavigablePresenter::build_frame(SealedPresentation const& sealed
auto command_resources = published->display_list == sealed.paint_command_cache_source
? sealed.paint_command_cache_source_resources
: m_resource_storage.collect_referenced_resources(*published->display_list);
- auto const& visual_context_tree = sealed.visual_context_tree.value();
- auto resources = resources_with(command_resources, visual_context_tree);
+ auto resources = resources_with(command_resources);
frame.display_list_update = CompositorFrame::DisplayListUpdate {
.display_list = published->display_list,
- .visual_context_tree = visual_context_tree,
+ .visual_context_tree = serialized_visual_context_tree(),
.resource_transaction = m_resource_storage.create_transaction(m_compositor_display_list_resources, resources),
.encoded_scroll_state = MUST(ByteBuffer::copy(encoded_scroll_state)),
};
m_compositor_display_list_visual_context_tree_structural_epoch = published->display_list->compatible_visual_context_tree_structural_epoch();
- m_compositor_visual_context_tree = visual_context_tree;
m_resource_storage.retain_only(resources);
m_compositor_display_list = published->display_list;
m_compositor_display_list_command_resources = move(command_resources);
@@ -129,18 +136,16 @@ CompositorFrame NavigablePresenter::build_frame(SealedPresentation const& sealed
m_resource_storage.retain_only(m_compositor_display_list_resources);
}
if (sealed.sends_visual_context_tree) {
- auto const& visual_context_tree = sealed.visual_context_tree.value();
- VERIFY(sealed.visual_context_tree_mismatches_for_testing || visual_context_tree.structural_epoch() == m_compositor_display_list_visual_context_tree_structural_epoch);
- auto resources = resources_with(m_compositor_display_list_command_resources, visual_context_tree);
+ VERIFY(sealed.visual_context_tree_mismatches_for_testing || visual_context_tree.structural_epoch == m_compositor_display_list_visual_context_tree_structural_epoch);
+ auto resources = resources_with(m_compositor_display_list_command_resources);
frame.visual_context_tree_update = CompositorFrame::VisualContextTreeUpdate {
- .visual_context_tree = visual_context_tree,
+ .visual_context_tree = serialized_visual_context_tree(),
.resource_transaction = m_resource_storage.create_transaction(m_compositor_display_list_resources, resources),
.encoded_scroll_state = MUST(ByteBuffer::copy(encoded_scroll_state)),
.keyboard_scroll_state = move(keyboard_scroll_state),
};
m_resource_storage.retain_only(resources);
m_compositor_display_list_resources = move(resources);
- m_compositor_visual_context_tree = visual_context_tree;
} else {
frame.scroll_state_update = CompositorFrame::ScrollStateUpdate {
.encoded_scroll_state = MUST(ByteBuffer::copy(encoded_scroll_state)),
@@ -150,12 +155,12 @@ CompositorFrame NavigablePresenter::build_frame(SealedPresentation const& sealed
return frame;
}
-CompositorFrame NavigablePresenter::build_frame_beside_event_loop(SealedPresentation& sealed, NonnullRefPtr<Compositing::DisplayList> display_list, ReadonlyBytes encoded_scroll_state)
+CompositorFrame NavigablePresenter::build_frame_beside_event_loop(SealedPresentation& sealed, NonnullRefPtr<Compositing::DisplayList> display_list, Layout::RustFFI::FfiPresentedVisualContextTree const& visual_context_tree, ReadonlyBytes encoded_scroll_state)
{
bool const replaces_paint_command_cache_source = sealed.recording->cache_mode == Painting::PaintCommandCacheMode::ReadWrite
&& display_list != sealed.paint_command_cache_source;
PublishedDisplayList published { move(display_list), replaces_paint_command_cache_source, {} };
- auto frame = build_frame(sealed, published, encoded_scroll_state);
+ auto frame = build_frame(sealed, published, visual_context_tree, encoded_scroll_state);
if (replaces_paint_command_cache_source) {
sealed.paint_command_cache_source = published.display_list;
sealed.paint_command_cache_source_resources = m_compositor_display_list_command_resources;
@@ -173,16 +178,16 @@ OwnPtr<SealedPresentation> NavigablePresenter::seal_for_clock_lane(SealedPresent
RefPtr<Compositing::DisplayList> source = committed.paint_command_cache_source;
if (committed.published.has_value())
source = committed.published->display_list;
- if (!source || source != m_compositor_display_list || !m_compositor_visual_context_tree.has_value())
+ if (!source || source != m_compositor_display_list)
return nullptr;
auto sealed = make<SealedPresentation>();
sealed->paint_config = committed.paint_config;
- sealed->visual_context_tree = *m_compositor_visual_context_tree;
+ sealed->visual_context_tree_structural_epoch = m_compositor_display_list_visual_context_tree_structural_epoch;
sealed->keyboard_scroll_state = committed.keyboard_scroll_state;
sealed->paint_command_cache_source = m_compositor_display_list;
sealed->paint_command_cache_source_resources = m_compositor_display_list_command_resources;
sealed->recording = Painting::DisplayListRecording {
- .visual_context_tree = *m_compositor_visual_context_tree,
+ .visual_context_tree_structural_epoch = m_compositor_display_list_visual_context_tree_structural_epoch,
.surface_clear_color = m_compositor_display_list->surface_clear_color(),
.cache_mode = Painting::PaintCommandCacheMode::ReadOnly,
.in_flight = true,
@@ -218,18 +223,17 @@ extern "C" WEB_API void web_sealed_presentation_destroy(void* sealed)
delete static_cast<Web::Compositor::SealedPresentation*>(sealed);
}
-extern "C" WEB_API void web_sealed_presentation_take_visual_context_tree(void* sealed_pointer, void const* tree, bool tree_is_restructured)
+extern "C" WEB_API void web_sealed_presentation_take_visual_context_tree(void* sealed_pointer, u64 structural_epoch, bool tree_is_restructured)
{
auto& sealed = *static_cast<Web::Compositor::SealedPresentation*>(sealed_pointer);
- auto visual_context_tree = Compositing::AccumulatedVisualContextTree::adopt_rust_handle(tree);
// A tree of another structure takes a new display list recorded against it, and the scroll offsets of its own nodes,
// which what presents the frame holds. A frame that records nothing seals no tree, and takes the render state's: the
// compositor's display list was cut from a tree of its structure.
- if (!tree_is_restructured && sealed.visual_context_tree.has_value())
- VERIFY(visual_context_tree.structural_epoch() == sealed.visual_context_tree->structural_epoch());
+ if (!tree_is_restructured && sealed.visual_context_tree_structural_epoch.has_value())
+ VERIFY(structural_epoch == *sealed.visual_context_tree_structural_epoch);
if (sealed.recording.has_value())
- sealed.recording->visual_context_tree = visual_context_tree;
- sealed.visual_context_tree = move(visual_context_tree);
+ sealed.recording->visual_context_tree_structural_epoch = structural_epoch;
+ sealed.visual_context_tree_structural_epoch = structural_epoch;
// A frame whose display list is the one the compositor has takes the tree on its own.
sealed.sends_visual_context_tree = true;
}
@@ -268,17 +272,17 @@ extern "C" WEB_API void web_navigable_presenter_add_video_sink(void* presenter,
}
// Declared here, not in a header, so that no C++ presents a frame through them.
-extern "C" WEB_API void web_navigable_presenter_present(void* presenter, void* sealed, Web::Layout::RustFFI::FfiPresentedRecording const* presented, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink);
-extern "C" WEB_API void web_navigable_presenter_present_unrecorded(void* presenter, void* sealed, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink);
+extern "C" WEB_API void web_navigable_presenter_present(void* presenter, void* sealed, Web::Layout::RustFFI::FfiPresentedRecording const* presented, Web::Layout::RustFFI::FfiPresentedVisualContextTree const* visual_context_tree, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink);
+extern "C" WEB_API void web_navigable_presenter_present_unrecorded(void* presenter, void* sealed, Web::Layout::RustFFI::FfiPresentedVisualContextTree const* visual_context_tree, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink);
-extern "C" WEB_API void web_navigable_presenter_present_unrecorded(void* presenter, void* sealed, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink)
+extern "C" WEB_API void web_navigable_presenter_present_unrecorded(void* presenter, void* sealed, Web::Layout::RustFFI::FfiPresentedVisualContextTree const* visual_context_tree, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink)
{
- Web::Compositor::PresenterFFI::present_unrecorded(*static_cast<Web::Compositor::NavigablePresenter*>(presenter), *static_cast<Web::Compositor::SealedPresentation*>(sealed), { encoded_scroll_state, encoded_scroll_state_size }, static_cast<Web::Compositor::CompositorFrameSink*>(sink));
+ Web::Compositor::PresenterFFI::present_unrecorded(*static_cast<Web::Compositor::NavigablePresenter*>(presenter), *static_cast<Web::Compositor::SealedPresentation*>(sealed), *visual_context_tree, { encoded_scroll_state, encoded_scroll_state_size }, static_cast<Web::Compositor::CompositorFrameSink*>(sink));
}
-extern "C" WEB_API void web_navigable_presenter_present(void* presenter, void* sealed_pointer, Web::Layout::RustFFI::FfiPresentedRecording const* presented, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink)
+extern "C" WEB_API void web_navigable_presenter_present(void* presenter, void* sealed_pointer, Web::Layout::RustFFI::FfiPresentedRecording const* presented, Web::Layout::RustFFI::FfiPresentedVisualContextTree const* visual_context_tree, u8 const* encoded_scroll_state, size_t encoded_scroll_state_size, void* sink)
{
auto& sealed = *static_cast<Web::Compositor::SealedPresentation*>(sealed_pointer);
auto display_list = Web::Painting::display_list_of_published_recording(sealed.recording.value(), *presented);
- Web::Compositor::PresenterFFI::present(*static_cast<Web::Compositor::NavigablePresenter*>(presenter), sealed, move(display_list), { encoded_scroll_state, encoded_scroll_state_size }, static_cast<Web::Compositor::CompositorFrameSink*>(sink));
+ Web::Compositor::PresenterFFI::present(*static_cast<Web::Compositor::NavigablePresenter*>(presenter), sealed, move(display_list), *visual_context_tree, { encoded_scroll_state, encoded_scroll_state_size }, static_cast<Web::Compositor::CompositorFrameSink*>(sink));
}
diff --git a/Libraries/LibWeb/Compositor/NavigablePresenter.h b/Libraries/LibWeb/Compositor/NavigablePresenter.h
index a6832750936..0070249ec36 100644
--- a/Libraries/LibWeb/Compositor/NavigablePresenter.h
+++ b/Libraries/LibWeb/Compositor/NavigablePresenter.h
@@ -14,7 +14,6 @@
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <AK/RefPtr.h>
-#include <LibCompositing/DisplayList/AccumulatedVisualContext.h>
#include <LibCompositing/DisplayList/DisplayList.h>
#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>
#include <LibWeb/Compositor/CompositorFrame.h>
@@ -27,6 +26,7 @@
namespace Web::Layout::RustFFI {
struct FfiPresentedRecording;
+struct FfiPresentedVisualContextTree;
}
@@ -55,9 +55,10 @@ struct SealedPresentation {
// The recording's paint config.
HTML::PaintConfig paint_config;
- // The visual context tree a new display list is cut from, or the one the compositor's display list takes where the
- // document's tree changed since it took one. Only a frame that sends a tree seals one.
- Optional<Compositing::AccumulatedVisualContextTree> visual_context_tree;
+ // The structural epoch of the visual context tree a new display list is cut from, or of the one the compositor's
+ // display list takes where the document's tree changed since it took one. The tree itself stays with the Rust
+ // presentation, which lends it as the frame is presented.
+ Optional<u64> visual_context_tree_structural_epoch;
// Whether the document's tree changed since the compositor took one.
bool sends_visual_context_tree { false };
// Whether presenting the frame sent the compositor other scroll offsets than the frame presented before it, which the
@@ -151,13 +152,13 @@ private:
// Builds the frame that brings the compositor context `sealed` names up to date with `published`, the display list a
// recording just published, or with what changed for the one the compositor has where none was published, from what
- // `sealed` sealed, and the scroll state sealed beside it, which seeds the offsets of the boxes new to the compositor.
- // Reads no navigable or document.
- CompositorFrame build_frame(SealedPresentation const&, Optional<PublishedDisplayList>, ReadonlyBytes encoded_scroll_state);
+ // `sealed` sealed, the visual context tree the frame goes with, and the scroll state sealed beside it, which seeds
+ // the offsets of the boxes new to the compositor. Reads no navigable or document.
+ CompositorFrame build_frame(SealedPresentation const&, Optional<PublishedDisplayList>, Layout::RustFFI::FfiPresentedVisualContextTree const&, ReadonlyBytes encoded_scroll_state);
// Builds the frame `sealed` sealed, with `display_list`, the display list its recording published, beside the event
// loop, keeping what it published in the seal, which the next frame from the seal copies paint commands from.
- CompositorFrame build_frame_beside_event_loop(SealedPresentation&, NonnullRefPtr<Compositing::DisplayList>, ReadonlyBytes encoded_scroll_state);
+ CompositorFrame build_frame_beside_event_loop(SealedPresentation&, NonnullRefPtr<Compositing::DisplayList>, Layout::RustFFI::FfiPresentedVisualContextTree const&, ReadonlyBytes encoded_scroll_state);
NavigablePresenter() = default;
@@ -171,8 +172,6 @@ private:
Compositing::DisplayListResourceSet m_compositor_display_list_command_resources;
Optional<PresentedBy> m_last_frame_presented_by;
Optional<u64> m_last_keyboard_scroll_state_generation;
- // The visual context tree the compositor's display list goes with, which a clock lane's recordings are cut from.
- Optional<Compositing::AccumulatedVisualContextTree> m_compositor_visual_context_tree;
// The generation of the last frame a rendering update committed that the presenter presented.
u64 m_last_committed_generation { 0 };
// The scroll offsets the last frame the presenter presented sent the compositor.
@@ -196,7 +195,7 @@ extern "C" {
WEB_API void web_navigable_presenter_unref(void* presenter);
WEB_API void* web_navigable_presenter_seal_for_clock_lane(void* presenter, void const* committed);
WEB_API void web_sealed_presentation_destroy(void* sealed);
-WEB_API void web_sealed_presentation_take_visual_context_tree(void* sealed, void const* tree, bool tree_is_restructured);
+WEB_API void web_sealed_presentation_take_visual_context_tree(void* sealed, u64 structural_epoch, bool tree_is_restructured);
WEB_API void web_navigable_presenter_add_font(void* presenter, void const* font);
WEB_API void web_navigable_presenter_add_image_frame(void* presenter, void const* frame);
WEB_API void web_navigable_presenter_add_video_sink(void* presenter, u64 resource_id, u64 sink_handle);
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index 94d33d86410..bd0c5f05575 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -12116,7 +12116,9 @@ Optional<Painting::DisplayListRecording> Document::start_recording(Layout::Begun
cache_mode = Painting::PaintCommandCacheMode::ReadOnly;
auto& document_paint_state = paint_state();
- auto visual_context_tree = document_paint_state.visual_context_tree(*this);
+ // NB: Reading the epoch brings the visual context tree up to date, which the recording freezes. It does so before
+ // the inputs are gathered, as bringing the tree up to date can clamp scroll offsets.
+ auto visual_context_tree_structural_epoch = document_paint_state.visual_context_tree_structural_epoch(read);
Optional<Gfx::Color> surface_clear_color;
@@ -12146,7 +12148,7 @@ Optional<Painting::DisplayListRecording> Document::start_recording(Layout::Begun
if (config.should_show_caret_hit_test_debug_overlay)
overlay_inputs.caret_debug_rect = m_caret_hit_test_debug_rect;
- return Painting::start_rust_display_list_recording(read, *this, move(visual_context_tree), surface_clear_color, cache_mode, config, overlay_inputs, move(committed));
+ return Painting::start_rust_display_list_recording(read, *this, visual_context_tree_structural_epoch, surface_clear_color, cache_mode, config, overlay_inputs, move(committed));
}
RefPtr<Compositing::DisplayList> Document::finish_display_list_recording(Layout::BegunRead const& read, Painting::DisplayListRecording const& recording, Compositing::DisplayListResourceStorage& resource_storage, Painting::HitTestListStands hit_test_list_stands)
@@ -12167,7 +12169,7 @@ Painting::HitTestListAdoption Document::adopt_published_recording(Optional<Layou
m_hit_test_display_list = nullptr;
adoption = Painting::HitTestListAdoption::Dropped;
} else if (!m_hit_test_display_list || !m_hit_test_display_list->is_current()) {
- m_hit_test_display_list = Painting::HitTestDisplayList::create_from_rust_recording(*hit_test_list_read, recording.visual_context_tree.structural_epoch(), layout_node_arena(), *m_chrome_widget_registry);
+ m_hit_test_display_list = Painting::HitTestDisplayList::create_from_rust_recording(*hit_test_list_read, recording.visual_context_tree_structural_epoch, layout_node_arena(), *m_chrome_widget_registry);
adoption = Painting::HitTestListAdoption::TookNew;
}
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cpp
index b43aa50b82d..8505292a156 100644
--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp
+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp
@@ -7225,16 +7225,16 @@ Compositor::SealedPresentation LocalNavigable::seal_presentation(Layout::BegunRe
auto& paint_state = document.paint_state();
bool const sends_visual_context_tree = paint_state.take_visual_context_tree_compositor_update(read);
// A frame that records nothing takes the render state's tree as it is sampled.
- Optional<Compositing::AccumulatedVisualContextTree> visual_context_tree;
+ Optional<u64> visual_context_tree_structural_epoch;
if (records_display_list)
- visual_context_tree = paint_state.visual_context_tree(document);
+ visual_context_tree_structural_epoch = paint_state.visual_context_tree_structural_epoch(read);
// A keyboard scroll reads the layout, which one the host knows is stale leaves to the next frame that lays it out.
Optional<Compositing::KeyboardScrollState> keyboard_scroll_state;
if (is_top_level_traversable() && !document.layout_is_known_stale())
keyboard_scroll_state = page().take_keyboard_scroll_state_for_compositor(0);
return Compositor::SealedPresentation {
.paint_config = paint_config,
- .visual_context_tree = move(visual_context_tree),
+ .visual_context_tree_structural_epoch = visual_context_tree_structural_epoch,
.sends_visual_context_tree = sends_visual_context_tree,
.scroll_requests = take_unsent_scroll_requests(),
.keyboard_scroll_state = move(keyboard_scroll_state),
diff --git a/Libraries/LibWeb/Painting/DisplayListRecording.h b/Libraries/LibWeb/Painting/DisplayListRecording.h
index 1f21fc96839..39a97a555b3 100644
--- a/Libraries/LibWeb/Painting/DisplayListRecording.h
+++ b/Libraries/LibWeb/Painting/DisplayListRecording.h
@@ -9,7 +9,6 @@
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <AK/RefPtr.h>
-#include <LibCompositing/DisplayList/AccumulatedVisualContext.h>
#include <LibCompositing/DisplayList/DisplayList.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Painting/PaintableTypes.h>
@@ -41,7 +40,8 @@ inline Optional<Layout::BegunRead const&> hit_test_list_read(Layout::BegunRead c
// A recording of a document's display list, started from the document as it was then: done in step with the host, or
// in flight beside the event loop until the event loop takes it in. Its display list is made once it is published.
struct DisplayListRecording {
- Compositing::AccumulatedVisualContextTree visual_context_tree;
+ // The structural epoch of the visual context tree the recording records against, which stays with the render state.
+ u64 visual_context_tree_structural_epoch { 0 };
Optional<Gfx::Color> surface_clear_color;
PaintCommandCacheMode cache_mode;
bool in_flight { false };
diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.cpp b/Libraries/LibWeb/Painting/DocumentPaintState.cpp
index b7e166bde8b..7b4b2cda18e 100644
--- a/Libraries/LibWeb/Painting/DocumentPaintState.cpp
+++ b/Libraries/LibWeb/Painting/DocumentPaintState.cpp
@@ -36,12 +36,6 @@ bool DocumentPaintState::has_visual_context_tree(Layout::BegunRead const& read)
return Layout::RustFFI::render_state_has_visual_context_tree(m_layout_node_arena->host(), &read);
}
-Compositing::AccumulatedVisualContextTree DocumentPaintState::visual_context_tree(DOM::Document const& document) const
-{
- Layout::ForcedReadScope read { document };
- return Compositing::AccumulatedVisualContextTree::adopt_rust_handle(retain_rust_main_visual_context_tree(read, document));
-}
-
u64 DocumentPaintState::visual_context_tree_structural_epoch(Layout::BegunRead const& read) const
{
return Layout::RustFFI::render_state_visual_context_tree_structural_epoch(m_layout_node_arena->host(), &read);
diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.h b/Libraries/LibWeb/Painting/DocumentPaintState.h
index 8aa3c7763c0..50fe27bd0b5 100644
--- a/Libraries/LibWeb/Painting/DocumentPaintState.h
+++ b/Libraries/LibWeb/Painting/DocumentPaintState.h
@@ -11,7 +11,6 @@
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <AK/Vector.h>
-#include <LibCompositing/DisplayList/AccumulatedVisualContext.h>
#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>
#include <LibGC/Ptr.h>
#include <LibWeb/Export.h>
@@ -75,7 +74,6 @@ public:
void set_boxes_with_auto_content_visibility(Vector<Compositing::RustFFI::NodeSlotId> boxes) { m_boxes_with_auto_content_visibility = move(boxes); }
Vector<Compositing::RustFFI::NodeSlotId> const& boxes_with_auto_content_visibility() const { return m_boxes_with_auto_content_visibility; }
- Compositing::AccumulatedVisualContextTree visual_context_tree(DOM::Document const&) const;
u64 visual_context_tree_structural_epoch(Layout::BegunRead const& read) const;
void set_display_list_used_as_paint_command_cache_source(RefPtr<Compositing::DisplayList> display_list, Compositing::DisplayListResourceSet referenced_resources)
diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
index 7aa01a383a1..b420838f9d4 100644
--- a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
@@ -210,13 +210,6 @@ bool rust_background_color_can_be_compositor_animated(Layout::Node const& layout
layout_node.document_host(), committed_row_slot(layout_node));
}
-void const* retain_rust_main_visual_context_tree(Layout::BegunRead const& read, DOM::Document const& document)
-{
- auto const* tree = Layout::RustFFI::render_state_main_visual_context_tree_retain(document_host(document), &read);
- VERIFY(tree);
- return tree;
-}
-
Layout::RustFFI::FfiPhysicalOverflowDirections rust_physical_overflow_directions(Layout::Node const& box)
{
return Layout::RustFFI::render_state_physical_overflow_directions(box.document_host(), committed_row_slot(box));
@@ -473,7 +466,7 @@ void commit_unrecorded_frame(Layout::BegunRead const& read, DOM::Document& docum
Layout::RustFFI::render_state_commit_unrecorded_frame(document_host(document), &read, sends_visual_context_tree, rendering_update_timestamp(document), give_up(move(presentation)));
}
-Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRead const& read, DOM::Document& document, Compositing::AccumulatedVisualContextTree visual_context_tree, Optional<Gfx::Color> surface_clear_color, PaintCommandCacheMode cache_mode, HTML::PaintConfig const& config, InspectorOverlayInputs const& overlay_inputs, Optional<Compositor::FlightPresentation> committed)
+Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRead const& read, DOM::Document& document, u64 visual_context_tree_structural_epoch, Optional<Gfx::Color> surface_clear_color, PaintCommandCacheMode cache_mode, HTML::PaintConfig const& config, InspectorOverlayInputs const& overlay_inputs, Optional<Compositor::FlightPresentation> committed)
{
auto* host = document_host(document);
auto device_pixels_per_css_pixel = document.page().client().device_pixels_per_css_pixel();
@@ -650,7 +643,7 @@ Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRe
};
}
DisplayListRecording recording {
- .visual_context_tree = move(visual_context_tree),
+ .visual_context_tree_structural_epoch = visual_context_tree_structural_epoch,
.surface_clear_color = surface_clear_color,
.cache_mode = cache_mode,
.in_flight = false,
diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.h b/Libraries/LibWeb/Painting/PaintingRustBridge.h
index df565ba4cc3..989a0430a5c 100644
--- a/Libraries/LibWeb/Painting/PaintingRustBridge.h
+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.h
@@ -37,7 +37,6 @@ WEB_API void dump_layout_tree(StringBuilder&, Layout::Node const&, bool interact
WEB_API Compositing::RustFFI::FfiVisualContextTreeInputs visual_context_tree_inputs(DOM::Document&);
WEB_API bool rust_background_color_can_be_compositor_animated(Layout::Node const&);
-WEB_API void const* retain_rust_main_visual_context_tree(Layout::BegunRead const&, DOM::Document const&);
WEB_API Layout::RustFFI::FfiPhysicalOverflowDirections rust_physical_overflow_directions(Layout::Node const&);
WEB_API void register_geometry_host(Layout::NodeArena&);
WEB_API void rust_update_visual_viewport_transform(Layout::BegunRead const&, DOM::Document&);
@@ -59,11 +58,10 @@ struct InspectorOverlayInputs {
Optional<CSSPixelRect> caret_debug_rect;
};
-// Starts recording the document's viewport against `visual_context_tree`, unless it has no box to record. The recording
-// flies where `blocker` is none, and takes `flight`, if any, to present its frame with beside the event loop.
-// Records the document's viewport for the host to publish, or, given `committed`, the presentation of the navigable's
-// next frame, commits the frame to the render owner, which presents it beside the event loop.
-WEB_API Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRead const&, DOM::Document&, Compositing::AccumulatedVisualContextTree, Optional<Gfx::Color> surface_clear_color, PaintCommandCacheMode, HTML::PaintConfig const&, InspectorOverlayInputs const&, Optional<Compositor::FlightPresentation> committed = {});
+// Starts recording the document's viewport against its visual context tree, of the structural epoch given, unless it has
+// no box to record. Records the document's viewport for the host to publish, or, given `committed`, the presentation of
+// the navigable's next frame, commits the frame to the render owner, which presents it beside the event loop.
+WEB_API Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRead const&, DOM::Document&, u64 visual_context_tree_structural_epoch, Optional<Gfx::Color> surface_clear_color, PaintCommandCacheMode, HTML::PaintConfig const&, InspectorOverlayInputs const&, Optional<Compositor::FlightPresentation> committed = {});
// Commits the navigable's next frame, which keeps the display list the compositor has, to the render owner, which
// presents it with `presentation` beside the event loop.
WEB_API void commit_unrecorded_frame(Layout::BegunRead const&, DOM::Document&, Compositor::FlightPresentation presentation);
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index 7932109be69..ed6e2bfb343 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -474,6 +474,37 @@ impl Default for FfiPresentation {
}
}
+/// The visual context tree a presented frame goes with, which the presentation lends the presenter for the call: C++
+/// passes it only to the entry points of the compositing crate, and keeps none of it.
+#[repr(C)]
+pub struct FfiPresentedVisualContextTree {
+ /// The tree, or null where the frame goes with none.
+ pub tree: *const c_void,
+ pub structural_epoch: u64,
+ /// The image frames the filters and backdrop filters of the tree's effects draw.
+ pub filter_image_frame_ids: *const u64,
+ pub filter_image_frame_id_count: usize,
+}
+
+/// Serializes the tree a presentation lends, for the compositor.
+///
+/// # Safety
+///
+/// `tree` must be what a presentation lends for the call, naming a tree; `append` is called synchronously with `sink`.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn presented_visual_context_tree_serialize(
+ tree: &FfiPresentedVisualContextTree,
+ sink: *mut c_void,
+ append: unsafe extern "C" fn(*mut c_void, *const u8, usize),
+) {
+ assert!(!tree.tree.is_null());
+ // SAFETY: The presentation lends the tree for the call.
+ let tree = unsafe { &*tree.tree.cast::<crate::painting::visual_context::VisualContextTree>() };
+ let bytes = tree.to_bytes();
+ // SAFETY: The sink copies the bytes synchronously.
+ unsafe { append(sink, bytes.as_ptr(), bytes.len()) };
+}
+
/// What the host reads of a published recording, to build its display list from.
#[repr(C)]
pub struct FfiPresentedRecording {
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
index a46f125bc61..31bdc794d66 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -433,21 +433,6 @@ pub(crate) unsafe fn main_visual_context_tree(
})
}
-/// The visual context tree of `host`'s document, prepared up to date, retained for the caller.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_main_visual_context_tree_retain(
- host: &crate::render_state::DocumentHost,
- read: &crate::render_state::BegunRead,
-) -> *const c_void {
- // SAFETY: Guaranteed by the caller.
- unsafe { main_visual_context_tree(host, read) }
- .map_or(std::ptr::null(), |tree| std::sync::Arc::into_raw(tree).cast())
-}
-
/// Whether the scroll translations of the space `slot`'s box is painted in, in the visual context tree of `host`'s
/// document, prepared up to date, and the origins drawn in that space round to whole device pixels: no transform but
/// identities lies above it.
diff --git a/Libraries/LibWeb/Rust/src/painting/presentation.rs b/Libraries/LibWeb/Rust/src/painting/presentation.rs
index 4443d33529a..0de45312132 100644
--- a/Libraries/LibWeb/Rust/src/painting/presentation.rs
+++ b/Libraries/LibWeb/Rust/src/painting/presentation.rs
@@ -12,7 +12,7 @@
//! their presenter's owners presented them.
use crate::paint_stage::Presenting;
-use crate::painting::ffi::{FfiPresentation, FfiPresentedRecording};
+use crate::painting::ffi::{FfiPresentation, FfiPresentedRecording, FfiPresentedVisualContextTree};
use crate::painting::paint_passes::ClockTickVisualContexts;
use crate::painting::record::publish::RecordingResourceSink;
use crate::painting::visual_context::VisualContextTree;
@@ -27,7 +27,7 @@ unsafe extern "C" {
fn web_sealed_presentation_destroy(sealed: *mut c_void);
fn web_sealed_presentation_take_visual_context_tree(
sealed: *mut c_void,
- tree: *const c_void,
+ structural_epoch: u64,
tree_is_restructured: bool,
);
fn web_navigable_presenter_add_font(presenter: *mut c_void, font: *const c_void);
@@ -37,6 +37,7 @@ unsafe extern "C" {
presenter: *mut c_void,
sealed: *mut c_void,
presented: *const FfiPresentedRecording,
+ visual_context_tree: *const FfiPresentedVisualContextTree,
encoded_scroll_state: *const u8,
encoded_scroll_state_size: usize,
sink: *mut c_void,
@@ -44,6 +45,7 @@ unsafe extern "C" {
fn web_navigable_presenter_present_unrecorded(
presenter: *mut c_void,
sealed: *mut c_void,
+ visual_context_tree: *const FfiPresentedVisualContextTree,
encoded_scroll_state: *const u8,
encoded_scroll_state_size: usize,
sink: *mut c_void,
@@ -145,6 +147,39 @@ pub(crate) struct Presentation {
/// Where the document's boxes were scrolled to as the frame was sealed, which seeds the offsets of the boxes new to
/// the compositor, as the scroll logic of the compositor reads it.
encoded_scroll_state: Vec<u8>,
+ /// The visual context tree the frames presented from the seal take to the compositor where a clock tick's update
+ /// left one, or the render state's where a frame without a recording sends it. A frame with a recording goes with
+ /// the tree it was recorded against otherwise.
+ taken_visual_context_tree: Option<Arc<VisualContextTree>>,
+}
+
+/// A tree a presenter reads for the call it is lent to, with the ids it hands it.
+struct LentVisualContextTree<'a> {
+ tree: Option<&'a Arc<VisualContextTree>>,
+ filter_image_frame_ids: Vec<u64>,
+}
+
+impl<'a> LentVisualContextTree<'a> {
+ fn new(tree: Option<&'a Arc<VisualContextTree>>) -> Self {
+ let mut filter_image_frame_ids = Vec::new();
+ if let Some(tree) = tree {
+ tree.for_each_effects_filter_image_frame_id(&mut |id| filter_image_frame_ids.push(id));
+ }
+ Self {
+ tree,
+ filter_image_frame_ids,
+ }
+ }
+
+ /// What C++ reads of the tree, which borrows the ids: it lives no longer than this.
+ fn to_ffi(&self) -> FfiPresentedVisualContextTree {
+ FfiPresentedVisualContextTree {
+ tree: self.tree.map_or(std::ptr::null(), |tree| Arc::as_ptr(tree).cast()),
+ structural_epoch: self.tree.map_or(0, |tree| tree.structural_epoch),
+ filter_image_frame_ids: self.filter_image_frame_ids.as_ptr(),
+ filter_image_frame_id_count: self.filter_image_frame_ids.len(),
+ }
+ }
}
impl Presentation {
@@ -158,6 +193,7 @@ impl Presentation {
presenter: PresenterBox(NonNull::new(ffi.presenter)?),
sealed: SealedPresentationBox(NonNull::new(ffi.sealed)?),
encoded_scroll_state: scroll_state.to_encoded_bytes(),
+ taken_visual_context_tree: None,
})
}
@@ -173,6 +209,7 @@ impl Presentation {
presenter: PresenterBox(self.presenter.0),
sealed: SealedPresentationBox(sealed),
encoded_scroll_state: self.encoded_scroll_state.clone(),
+ taken_visual_context_tree: None,
})
}
@@ -201,14 +238,15 @@ impl Presentation {
if let Some(scroll_offsets) = restructured_scroll_offsets {
self.encoded_scroll_state = ScrollStateSnapshot::from_device_offsets(scroll_offsets).to_encoded_bytes();
}
- // SAFETY: The presentation owns the seal, which takes over the reference.
+ // SAFETY: The presentation owns the seal.
unsafe {
web_sealed_presentation_take_visual_context_tree(
self.sealed.0.as_ptr(),
- Arc::into_raw(tree).cast(),
+ tree.structural_epoch,
tree_is_restructured,
);
}
+ self.taken_visual_context_tree = Some(tree);
}
/// Presents the sealed frame without a recording: the display list the compositor has stands, with
@@ -224,12 +262,15 @@ impl Presentation {
restructured_scroll_offsets: None,
});
}
- // SAFETY: The presentation owns both objects, the presenter copies the scroll state, and the stage holds the
- // sink.
+ let lent_visual_context_tree = LentVisualContextTree::new(self.taken_visual_context_tree.as_ref());
+ let visual_context_tree = lent_visual_context_tree.to_ffi();
+ // SAFETY: The presentation owns both objects and the tree it lends, the presenter copies the scroll state and
+ // what it keeps of the tree, and the stage holds the sink.
unsafe {
web_navigable_presenter_present_unrecorded(
self.presenter.0.as_ptr(),
self.sealed.0.as_ptr(),
+ &raw const visual_context_tree,
self.encoded_scroll_state.as_ptr(),
self.encoded_scroll_state.len(),
presenting.sink(),
@@ -237,15 +278,30 @@ impl Presentation {
}
}
- /// Presents the sealed frame with the recording `presented` describes, whose resources the presenter took already.
- pub(crate) fn present(&mut self, presented: &FfiPresentedRecording, presenting: &mut Presenting) {
- // SAFETY: The presentation owns both objects, the recording's display list is live for the call, the presenter
- // copies the scroll state, and the stage holds the sink.
+ /// Presents the sealed frame with the recording that left `output`, whose resources the presenter took already. The
+ /// frame goes with the tree a clock tick's update left, or else the one the recording was recorded against: a
+ /// recording that repeats the display list it published before publishes that list again, which holds the tree of
+ /// the recording before.
+ pub(crate) fn present(&mut self, output: &crate::painting::record::RecordingOutput, presenting: &mut Presenting) {
+ let presented = FfiPresentedRecording::of_output(output);
+ let tree = self
+ .taken_visual_context_tree
+ .as_ref()
+ .or(output.visual_context_tree.as_ref());
+ debug_assert!(
+ tree.is_some_and(|tree| tree.structural_epoch == output.recorded_structural_epoch),
+ "a frame goes with a tree of the structure its recording was recorded against"
+ );
+ let lent_visual_context_tree = LentVisualContextTree::new(tree);
+ let visual_context_tree = lent_visual_context_tree.to_ffi();
+ // SAFETY: The presentation owns both objects and the tree it lends, the recording's display list is live for
+ // the call, the presenter copies the scroll state and what it keeps of the tree, and the stage holds the sink.
unsafe {
web_navigable_presenter_present(
self.presenter.0.as_ptr(),
self.sealed.0.as_ptr(),
- presented,
+ &raw const presented,
+ &raw const visual_context_tree,
self.encoded_scroll_state.as_ptr(),
self.encoded_scroll_state.len(),
presenting.sink(),
@@ -256,7 +312,7 @@ impl Presentation {
#[cfg(test)]
mod ffi_test_stubs {
- use super::FfiPresentedRecording;
+ use super::{FfiPresentedRecording, FfiPresentedVisualContextTree};
use std::ffi::c_void;
#[unsafe(no_mangle)]
@@ -271,7 +327,7 @@ mod ffi_test_stubs {
extern "C" fn web_sealed_presentation_destroy(_: *mut c_void) {}
#[unsafe(no_mangle)]
- extern "C" fn web_sealed_presentation_take_visual_context_tree(_: *mut c_void, _: *const c_void, _: bool) {}
+ extern "C" fn web_sealed_presentation_take_visual_context_tree(_: *mut c_void, _: u64, _: bool) {}
#[unsafe(no_mangle)]
extern "C" fn web_navigable_presenter_add_font(_: *mut c_void, _: *const c_void) {}
@@ -287,6 +343,7 @@ mod ffi_test_stubs {
_: *mut c_void,
_: *mut c_void,
_: *const FfiPresentedRecording,
+ _: *const FfiPresentedVisualContextTree,
_: *const u8,
_: usize,
_: *mut c_void,
@@ -297,6 +354,7 @@ mod ffi_test_stubs {
extern "C" fn web_navigable_presenter_present_unrecorded(
_: *mut c_void,
_: *mut c_void,
+ _: *const FfiPresentedVisualContextTree,
_: *const u8,
_: usize,
_: *mut c_void,
diff --git a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
index 988d02c0d8e..8343e2f3350 100644
--- a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
+++ b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
@@ -19,7 +19,7 @@
use crate::layout::node_data::NodeSlotId;
use crate::layout::{LayoutNodeArena, RowsVersion};
use crate::paint_stage::Presenting;
-use crate::painting::ffi::{FfiFlightBlocker, FfiPresentedRecording};
+use crate::painting::ffi::FfiFlightBlocker;
use crate::painting::hit_test::HitTestList;
use crate::painting::paint_read::PaintSource;
use crate::painting::paint_state::{PendingRecording, PendingRecordingTrace};
@@ -117,7 +117,7 @@ impl VectorImageFrame {
&mut presentation.presenter,
display_list_ids,
);
- presentation.present(&FfiPresentedRecording::of_output(&output), presenting);
+ presentation.present(&output, presenting);
let recorded = Recorded::Presented {
output: PresentedOutput::of(output),
publishes_recording,
@@ -535,7 +535,7 @@ pub(crate) fn present(
presenting: &mut Presenting,
) -> RecordingOutput {
let output = crate::painting::record::publish::publish_to_presenter(pending, recorder, &mut presentation.presenter);
- presentation.present(&FfiPresentedRecording::of_output(&output), presenting);
+ presentation.present(&output, presenting);
output
}
@@ -554,7 +554,7 @@ pub(crate) fn present_with_vector_images(
&mut presentation.presenter,
display_list_ids,
);
- presentation.present(&FfiPresentedRecording::of_output(&output), presenting);
+ presentation.present(&output, presenting);
output
}
diff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipc
index c6b246ee38c..4a340a4d9fb 100644
--- a/Services/Compositor/CompositorWebContentServer.ipc
+++ b/Services/Compositor/CompositorWebContentServer.ipc
@@ -44,9 +44,9 @@ 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, Compositing::AccumulatedVisualContextTree 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::DisplayList::Properties display_list_properties, Optional<Compositing::DisplayList::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, Compositing::AccumulatedVisualContextTree visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|
+ [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) =|
// Hands WebContent a range of canvas IDs it may name its own 2D contexts with, so creating one needs no round trip.
diff --git a/Services/Compositor/Rust/src/core/messages.rs b/Services/Compositor/Rust/src/core/messages.rs
index df8f6e55b00..31fb3ccf26a 100644
--- a/Services/Compositor/Rust/src/core/messages.rs
+++ b/Services/Compositor/Rust/src/core/messages.rs
@@ -230,11 +230,11 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {
}
};
let adopt_time = started_at.elapsed();
+ let tree = decode_visual_context_tree(&message.visual_context_tree)?;
if !self.context_is_owned_by_sender(message.context_id)? {
return Ok(());
}
let properties = message.display_list_properties;
- let tree = message.visual_context_tree.0;
if properties.compatible_visual_context_tree_structural_epoch != tree.structural_epoch {
let _ = writeln!(
std::io::stderr(),
@@ -297,12 +297,13 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {
if !scroll_state_snapshot.has_only_finite_offsets() {
return Err(unusable_scroll_state);
}
+ let tree = decode_visual_context_tree(&message.visual_context_tree)?;
if !self.context_is_owned_by_sender(message.context_id)? {
return Ok(());
}
let tree_was_replaced = self.core.update_visual_context_tree(
message.context_id,
- AccumulatedVisualContextTree::from_arc(message.visual_context_tree.0),
+ AccumulatedVisualContextTree::from_arc(tree),
scroll_state_snapshot,
message.keyboard_scroll_state,
self.now,