Truly independent web browser
LibCompositing+LibWeb: Use out parameters for non-trivial returns
Zaggy1024cfbacf90b2ab
diff --git a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cppindex 4da7bb7bda9..e3f706dd209 100644--- a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp+++ b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp@@ -110,7 +110,9 @@ size_t AccumulatedVisualContextTree::live_node_count() constTransformWithOrigin AccumulatedVisualContextTree::visual_viewport_transform() const{- return Compositing::RustFFI::visual_context_tree_visual_viewport_transform(m_rust_tree);+ TransformWithOrigin transform;+ Compositing::RustFFI::visual_context_tree_visual_viewport_transform(m_rust_tree, &transform);+ return transform;}AccumulatedVisualContextTree AccumulatedVisualContextTree::with_visual_viewport_transform(TransformWithOrigin const& transform) const@@ -187,19 +189,25 @@ Optional<Gfx::FloatPoint> AccumulatedVisualContextTree::transform_point_for_hit_Gfx::FloatPoint AccumulatedVisualContextTree::inverse_transform_point(SpatialNodeIndex index, Gfx::FloatPoint screen_point) const{- return Compositing::RustFFI::visual_context_tree_inverse_transform_point(m_rust_tree, index, screen_point);+ Gfx::FloatPoint point;+ Compositing::RustFFI::visual_context_tree_inverse_transform_point(m_rust_tree, index, screen_point, &point);+ return point;}Gfx::FloatRect AccumulatedVisualContextTree::transform_rect_to_viewport(SpatialNodeIndex index, Gfx::FloatRect const& source_rect, ScrollStateSnapshot const& scroll_state, IncludeVisualViewportTransform include_visual_viewport_transform) const{auto scroll_offsets = scroll_state.device_offsets();- return Compositing::RustFFI::visual_context_tree_transform_rect_to_viewport(m_rust_tree, index, source_rect, scroll_offsets.data(), scroll_offsets.size(), include_visual_viewport_transform == IncludeVisualViewportTransform::Yes);+ Gfx::FloatRect rect;+ Compositing::RustFFI::visual_context_tree_transform_rect_to_viewport(m_rust_tree, index, source_rect, scroll_offsets.data(), scroll_offsets.size(), include_visual_viewport_transform == IncludeVisualViewportTransform::Yes, &rect);+ return rect;}Gfx::FloatPoint AccumulatedVisualContextTree::cumulative_scroll_chain_offset(SpatialNodeIndex index, ScrollStateSnapshot const& scroll_state) const{auto scroll_offsets = scroll_state.device_offsets();- return Compositing::RustFFI::visual_context_tree_cumulative_scroll_chain_offset(m_rust_tree, index, scroll_offsets.data(), scroll_offsets.size());+ Gfx::FloatPoint offset;+ Compositing::RustFFI::visual_context_tree_cumulative_scroll_chain_offset(m_rust_tree, index, scroll_offsets.data(), scroll_offsets.size(), &offset);+ return offset;}Gfx::FloatMatrix4x4 AccumulatedVisualContextTree::accumulated_matrix(SpatialNodeIndex index, ScrollStateSnapshot const& scroll_state, IncludeVisualViewportTransform include_visual_viewport_transform) constdiff --git a/Libraries/LibCompositing/Rust/build.rs b/Libraries/LibCompositing/Rust/build.rsindex 34f38a242f3..91e6df5805f 100644--- a/Libraries/LibCompositing/Rust/build.rs+++ b/Libraries/LibCompositing/Rust/build.rs@@ -74,11 +74,6 @@ fn expose_css_pixel_types_as_web_types(config: &mut cbindgen::Config) {config.export.rename.insert(rust_name.to_string(), cpp_name.to_string());}config.includes.push("LibWebCommon/PixelUnits.h".to_string());- config.after_includes = Some(- "#if defined(__clang__)\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n#endif"- .to_string(),- );- config.trailer = Some("#if defined(__clang__)\n#pragma clang diagnostic pop\n#endif".to_string());}// The types the C++ side defines itself, which the generated header refers to by their C++ names.diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rsindex 61823e819bb..bef0472bba3 100644--- a/Libraries/LibCompositing/Rust/src/ffi.rs+++ b/Libraries/LibCompositing/Rust/src/ffi.rs@@ -337,8 +337,9 @@ pub unsafe extern "C" fn visual_context_tree_inverse_transform_point(tree: *const c_void,spatial: SpatialNodeIndex,screen_point: libgfx_rust::FloatPoint,-) -> libgfx_rust::FloatPoint {- unsafe { tree_from_handle(tree) }.inverse_transform_point(spatial, screen_point)+ out: &mut libgfx_rust::FloatPoint,+) {+ *out = unsafe { tree_from_handle(tree) }.inverse_transform_point(spatial, screen_point);}fn include_visual_viewport_transform_from(include: bool) -> crate::visual_context::IncludeVisualViewportTransform {@@ -360,16 +361,17 @@ pub unsafe extern "C" fn visual_context_tree_transform_rect_to_viewport(scroll_offsets: *const libgfx_rust::FloatPoint,scroll_offsets_len: usize,include_visual_viewport_transform: bool,-) -> libgfx_rust::FloatRect {+ out: &mut libgfx_rust::FloatRect,+) {let tree = unsafe { tree_from_handle(tree) };// SAFETY: The caller guarantees the offsets address `scroll_offsets_len` points.let scroll_offsets = unsafe { ffi_slice(scroll_offsets, scroll_offsets_len) };- tree.transform_rect_to_viewport(+ *out = tree.transform_rect_to_viewport(spatial,rect,scroll_offsets,include_visual_viewport_transform_from(include_visual_viewport_transform),- )+ );}/// # Safety@@ -381,11 +383,12 @@ pub unsafe extern "C" fn visual_context_tree_cumulative_scroll_chain_offset(spatial: SpatialNodeIndex,scroll_offsets: *const libgfx_rust::FloatPoint,scroll_offsets_len: usize,-) -> libgfx_rust::FloatPoint {+ out: &mut libgfx_rust::FloatPoint,+) {let tree = unsafe { tree_from_handle(tree) };// SAFETY: The caller guarantees the offsets address `scroll_offsets_len` points.let scroll_offsets = unsafe { ffi_slice(scroll_offsets, scroll_offsets_len) };- tree.cumulative_scroll_chain_offset(spatial, scroll_offsets)+ *out = tree.cumulative_scroll_chain_offset(spatial, scroll_offsets);}/// # Safety@@ -440,17 +443,18 @@ pub unsafe extern "C" fn visual_context_tree_resolve_sticky_offsets(#[unsafe(no_mangle)]pub unsafe extern "C" fn visual_context_tree_visual_viewport_transform(tree: *const c_void,-) -> crate::host::FfiVisualViewportTransform {+ out: &mut crate::host::FfiVisualViewportTransform,+) {let tree = unsafe { tree_from_handle(tree) };let crate::visual_context::SpatialData::Transform(transform) =&tree.spatial_nodes[crate::display_list::commands::VISUAL_VIEWPORT_NODE_INDEX.0 as usize].dataelse {unreachable!("the visual viewport node is a transform");};- crate::host::FfiVisualViewportTransform {+ *out = crate::host::FfiVisualViewportTransform {matrix: transform.matrix,origin: transform.origin,- }+ };}/// # Safetydiff --git a/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Libraries/LibWeb/DOM/AccessibilityTreeNode.cppindex a7f6914f00c..6d98fb1d7dd 100644--- a/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp+++ b/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp@@ -627,8 +627,9 @@ void AccessibilityTreeNode::serialize_tree_as_node_data(Vector<WebView::Accessibauto line_rect_at_offset = [&](size_t offset) -> Optional<CSSPixelRect> {if (!layout)return {};- auto result = Layout::RustFFI::layout_script_text_caret_rect_in_dom_range(- layout->document_host(), Layout::Node::slot_id(layout), offset);+ Layout::RustFFI::FfiOptionalCssPixelRect result;+ Layout::RustFFI::layout_script_text_caret_rect_in_dom_range(+ layout->document_host(), Layout::Node::slot_id(layout), offset, &result);if (!result.has_value)return {};return result.rect;diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex 7ca2007d54e..0923470426f 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -6645,11 +6645,13 @@ static CSSPixelRect compute_intersection(Layout::BegunRead const& read, GC::Ref<scroll_margin[3].to_px(clip_rect.width()));return clip_rect;};- return Layout::RustFFI::layout_script_intersection_observer_intersection_rect(+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_intersection_observer_intersection_rect(document.layout_node_arena().host(), Layout::Node::slot_id(target->layout_node(read)), target_rect,Layout::Node::slot_id(root_layout_box), root_bounds,Painting::rect_to_viewport_transform(document, visual_context_tree),- const_cast<Vector<CSS::LengthPercentage>*>(&scroll_margin), inflate_scroll_container_clip_rect_by_scroll_margin);+ const_cast<Vector<CSS::LengthPercentage>*>(&scroll_margin), inflate_scroll_container_clip_rect_by_scroll_margin, &rect);+ return rect;}// https://www.w3.org/TR/intersection-observer/#run-the-update-intersection-observations-steps@@ -7893,8 +7895,10 @@ void Document::update_compositor_animations(Layout::BegunRead const& read)auto viewport_bounds = CSSPixelRect { { 0, 0 }, viewport_rect().size() };auto rect_to_viewport_transform = Painting::rect_to_viewport_transform(*this, *visual_context_tree);auto bounds_in_viewport = [&](Layout::Node const& node) -> CSSPixelRect {- return Layout::RustFFI::layout_script_bounding_client_rect(- node.document_host(), Layout::Node::slot_id(&node), rect_to_viewport_transform);+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_bounding_client_rect(+ node.document_host(), Layout::Node::slot_id(&node), rect_to_viewport_transform, &rect);+ return rect;};HashTable<Layout::Node const*> containing_blocks;for (auto const* container = layout_node->containing_block(); container; container = container->containing_block())@@ -10077,8 +10081,9 @@ Optional<CSSPixelRect> Document::current_caret_rect()};if (is<DOM::Text>(dom_node)) {- auto result = Layout::RustFFI::layout_script_text_caret_rect_in_dom_range(- layout_node->document_host(), Layout::Node::slot_id(layout_node), position->offset());+ Layout::RustFFI::FfiOptionalCssPixelRect result;+ Layout::RustFFI::layout_script_text_caret_rect_in_dom_range(+ layout_node->document_host(), Layout::Node::slot_id(layout_node), position->offset(), &result);if (result.has_value)return to_viewport_rect(result.rect);}diff --git a/Libraries/LibWeb/Painting/BoxViews.cpp b/Libraries/LibWeb/Painting/BoxViews.cppindex 81ffb49ac70..f5f953c9049 100644--- a/Libraries/LibWeb/Painting/BoxViews.cpp+++ b/Libraries/LibWeb/Painting/BoxViews.cpp@@ -86,17 +86,23 @@ static PixelBox pixel_box_from_ffi(Layout::RustFFI::FfiPixelBox const& box)CSSPixelRect absolute_rect(Layout::Node const& node){- return Layout::RustFFI::layout_script_paintable_absolute_rect(node.document_host(), committed_row_slot(node));+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_paintable_absolute_rect(node.document_host(), committed_row_slot(node), &rect);+ return rect;}CSSPixelRect absolute_padding_box_rect(Layout::Node const& node){- return Layout::RustFFI::layout_script_paintable_absolute_padding_box_rect(node.document_host(), committed_row_slot(node));+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_paintable_absolute_padding_box_rect(node.document_host(), committed_row_slot(node), &rect);+ return rect;}CSSPixelRect absolute_border_box_rect(Layout::Node const& node){- return Layout::RustFFI::layout_script_paintable_absolute_border_box_rect(node.document_host(), committed_row_slot(node));+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_paintable_absolute_border_box_rect(node.document_host(), committed_row_slot(node), &rect);+ return rect;}CSSPixelPoint absolute_position(Layout::Node const& node)@@ -106,7 +112,9 @@ CSSPixelPoint absolute_position(Layout::Node const& node)CSSPixelSize content_size(Layout::Node const& node){- return Layout::RustFFI::layout_script_paintable_content_size(node.document_host(), committed_row_slot(node));+ CSSPixelSize size;+ Layout::RustFFI::layout_script_paintable_content_size(node.document_host(), committed_row_slot(node), &size);+ return size;}CSSPixels content_width(Layout::Node const& node)@@ -121,7 +129,8 @@ CSSPixels content_height(Layout::Node const& node)BoxModelMetrics box_model(Layout::Node const& node){- auto metrics = Layout::RustFFI::layout_script_paintable_box_model(node.document_host(), committed_row_slot(node));+ Layout::RustFFI::FfiBoxModelMetrics metrics;+ Layout::RustFFI::layout_script_paintable_box_model(node.document_host(), committed_row_slot(node), &metrics);return {.margin = pixel_box_from_ffi(metrics.margin),.padding = pixel_box_from_ffi(metrics.padding),@@ -144,13 +153,15 @@ CSSPixels border_box_height(Layout::Node const& node)bool has_scrollable_overflow(Layout::Node const& node){- auto overflow = Layout::RustFFI::render_state_paintable_scrollable_overflow(node.document_host(), committed_row_slot(node));+ Layout::RustFFI::FfiOptionalOverflowData overflow;+ Layout::RustFFI::render_state_paintable_scrollable_overflow(node.document_host(), committed_row_slot(node), &overflow);return overflow.has_value && overflow.value.has_scrollable_overflow;}Optional<CSSPixelRect> scrollable_overflow_rect(Layout::Node const& node){- auto overflow = Layout::RustFFI::render_state_paintable_scrollable_overflow(node.document_host(), committed_row_slot(node));+ Layout::RustFFI::FfiOptionalOverflowData overflow;+ Layout::RustFFI::render_state_paintable_scrollable_overflow(node.document_host(), committed_row_slot(node), &overflow);if (!overflow.has_value)return {};return overflow.value.rect;@@ -293,7 +304,9 @@ Vector<Layout::RustFFI::FfiSvgTextCharacterCell> svg_text_character_cells(LayoutCSSPixelSize svg_viewport_size(Layout::Node const& node){- return Layout::RustFFI::render_state_paintable_svg_viewport_size(node.document_host(), committed_row_slot(node));+ CSSPixelSize size;+ Layout::RustFFI::render_state_paintable_svg_viewport_size(node.document_host(), committed_row_slot(node), &size);+ return size;}Optional<Gfx::AffineTransform> svg_viewport_transform(Layout::Node const& node)@@ -326,7 +339,8 @@ CSSPixelPoint box_type_agnostic_position(Layout::Node const& node)if (!row.has_value())return {};if (is_inline_paintable(node)) {- auto result = Layout::RustFFI::render_state_inline_paintable_first_piece_position(node.document_host(), committed_row_slot(node));+ Layout::RustFFI::FfiOptionalCssPixelPoint result;+ Layout::RustFFI::render_state_inline_paintable_first_piece_position(node.document_host(), committed_row_slot(node), &result);if (result.has_value)return { result.x, result.y };}@@ -361,8 +375,9 @@ static Optional<Layout::RustFFI::FfiCaretRectResult> caret_at_atomic_child(Layouauto* child_layout_node = child ? child->unsafe_layout_node(read) : nullptr;if (!child_layout_node || !child_layout_node->is_atomic_inline())return {};- auto result = Layout::RustFFI::layout_script_atomic_inline_caret_rect_for_position(- layout_node.document_host(), Layout::Node::slot_id(child_layout_node), child_offset < offset);+ Layout::RustFFI::FfiCaretRectResult result;+ Layout::RustFFI::layout_script_atomic_inline_caret_rect_for_position(+ layout_node.document_host(), Layout::Node::slot_id(child_layout_node), child_offset < offset, &result);if (!result.found)return {};return result;@@ -402,8 +417,9 @@ CSSPixelRect caret_rect_for_child_offset(Layout::BegunRead const& read, Layout::auto const* layout_node = text ? text->unsafe_layout_node(read) : nullptr;if (!layout_node)return {};- auto result = Layout::RustFFI::layout_script_text_caret_rect_for_position(- block.document_host(), Layout::Node::slot_id(layout_node), text_offset, true);+ Layout::RustFFI::FfiCaretRectResult result;+ Layout::RustFFI::layout_script_text_caret_rect_for_position(+ block.document_host(), Layout::Node::slot_id(layout_node), text_offset, true, &result);if (result.found)return result.rect;return {};@@ -501,9 +517,10 @@ Layout::RustFFI::FfiCaretPaint resolve_document_caret_paint(Layout::BegunRead coif (!text_layout_node)return caret;auto* host = text_layout_node->document_host();- auto result = Layout::RustFFI::layout_script_text_caret_rect_for_position(+ Layout::RustFFI::FfiCaretRectResult result;+ Layout::RustFFI::layout_script_text_caret_rect_for_position(host, Layout::Node::slot_id(text_layout_node), cursor_position->offset(),- cursor_position->affinity() == TextAffinity::Downstream);+ cursor_position->affinity() == TextAffinity::Downstream, &result);if (result.found) {auto const* style_source = static_cast<Layout::NodeWithStyle const*>(text_layout_node->node_arena().node_if_live(read, result.style_source));if (style_source && layout_node_is_visible(*style_source))@@ -514,8 +531,9 @@ Layout::RustFFI::FfiCaretPaint resolve_document_caret_paint(Layout::BegunRead cofor (auto const* block = text_layout_node->parent(); block; block = block->parent()) {if (!has_committed_box(*block) || !is_visible(*block))continue;- auto empty_line = Layout::RustFFI::layout_script_paintable_empty_line_caret_rect(- host, committed_row_slot(*block), Layout::Node::slot_id(text_layout_node), cursor_position->offset());+ Layout::RustFFI::FfiEmptyLineCaretRect empty_line;+ Layout::RustFFI::layout_script_paintable_empty_line_caret_rect(+ host, committed_row_slot(*block), Layout::Node::slot_id(text_layout_node), cursor_position->offset(), &empty_line);if (!empty_line.has_value)continue;auto const* style_source = static_cast<Layout::NodeWithStyle const*>(text_layout_node->node_arena().node_if_live(read, empty_line.style_source));@@ -608,7 +626,9 @@ Layout::RustFFI::FfiFocusedAreaOutline resolve_focused_area_outline(Layout::BeguCSSPixelRect transform_reference_box(Layout::Node const& node){- return Layout::RustFFI::render_state_paintable_transform_reference_box(node.document_host(), committed_row_slot(node));+ CSSPixelRect rect;+ Layout::RustFFI::render_state_paintable_transform_reference_box(node.document_host(), committed_row_slot(node), &rect);+ return rect;}CSSPixelRect transform_rect_to_viewport(Layout::Node const& node, CSSPixelRect const& rect, Compositing::AccumulatedVisualContextTree::IncludeVisualViewportTransform include_visual_viewport_transform)@@ -810,7 +830,9 @@ Vector<CSSPixelRect> client_rects(Layout::Node const& node, Layout::RustFFI::FfiCSSPixelRect bounding_client_rect(Layout::Node const& node, Layout::RustFFI::FfiRectToViewportTransform const& rect_to_viewport_transform){- return Layout::RustFFI::layout_script_bounding_client_rect(node.document_host(), committed_row_slot(node), rect_to_viewport_transform);+ CSSPixelRect rect;+ Layout::RustFFI::layout_script_bounding_client_rect(node.document_host(), committed_row_slot(node), rect_to_viewport_transform, &rect);+ return rect;}CSSPixelPoint cumulative_scroll_compensation(Layout::Node const& node)diff --git a/Libraries/LibWeb/Painting/ChromeWidget.cpp b/Libraries/LibWeb/Painting/ChromeWidget.cppindex 9b9143da030..bcb9837e228 100644--- a/Libraries/LibWeb/Painting/ChromeWidget.cpp+++ b/Libraries/LibWeb/Painting/ChromeWidget.cpp@@ -114,10 +114,11 @@ Optional<ScrollbarData> compute_scrollbar_data(Layout::Node const& node, ScrollDauto own_offset = scroll_state_snapshot->device_offset_for_index(own_scroll_node_index(node));device_scroll_offset = direction == ScrollDirection::Horizontal ? -own_offset.x() : -own_offset.y();}- auto result = Layout::RustFFI::layout_row_paintable_compute_scrollbar_data(+ Layout::RustFFI::FfiOptionalScrollbarData result;+ Layout::RustFFI::layout_row_paintable_compute_scrollbar_data(node.document_host(), committed_row_slot(node), static_cast<Layout::RustFFI::ScrollDirection>(direction),metrics, scrollbar_sizing == ScrollbarSizing::Enlarged, scroll_state_snapshot, device_scroll_offset,- node.document().page().client().device_pixels_per_css_pixel());+ node.document().page().client().device_pixels_per_css_pixel(), &result);if (!result.has_value)return {};return ScrollbarData {diff --git a/Libraries/LibWeb/Painting/HitTestDisplayList.cpp b/Libraries/LibWeb/Painting/HitTestDisplayList.cppindex fdef87b404b..01cd710393f 100644--- a/Libraries/LibWeb/Painting/HitTestDisplayList.cpp+++ b/Libraries/LibWeb/Painting/HitTestDisplayList.cpp@@ -62,7 +62,9 @@ bool HitTestDisplayList::is_current() constHitTestDisplayList::Item HitTestDisplayList::item(Layout::BegunRead const& read, size_t index) const{- return { index, Layout::RustFFI::layout_hit_test_item_facts(m_arena->host(), &read, index) };+ Layout::RustFFI::FfiHitTestItemExport facts;+ Layout::RustFFI::layout_hit_test_item_facts(m_arena->host(), &read, index, &facts);+ return { index, facts };}Optional<CSSPixelPoint> HitTestDisplayList::local_point_for_visual_context(Compositing::ContextRef context, CSSPixelPoint point, HitTestQuery const& query) const@@ -149,7 +151,9 @@ Optional<HitTestDisplayList::TopmostItem> HitTestDisplayList::topmost_item_from(Optional<HitTestDisplayList::TopmostItem> HitTestDisplayList::find_topmost_item(Layout::BegunRead const& read, CSSPixelPoint point, HitTestQuery const& query) const{QueryContext context { &query, m_arena->document() };- return topmost_item_from(Layout::RustFFI::layout_hit_test_find_topmost_item(m_arena->host(), &read, context.callbacks(), point));+ Layout::RustFFI::FfiTopmostItem item;+ Layout::RustFFI::layout_hit_test_find_topmost_item(m_arena->host(), &read, context.callbacks(), point, &item);+ return topmost_item_from(item);}Vector<size_t> HitTestDisplayList::hit_item_indices_topmost_first(Layout::BegunRead const& read, CSSPixelPoint point, HitTestQuery const& query) const@@ -308,7 +312,9 @@ Optional<CaretPosition> HitTestDisplayList::caret_position_at_line_edge(Layout::return {};CaretPositionQueryContext context { node, offset };auto type = edge == CaretLineEdge::Start ? CaretPositionType::Before : CaretPositionType::After;- return caret_position_from(Layout::RustFFI::layout_hit_test_caret_at_line_edge(m_arena->host(), &read, context.query, offset, affinity == TextAffinity::Downstream, to_underlying(type)));+ Layout::RustFFI::FfiCaretAt caret_at;+ Layout::RustFFI::layout_hit_test_caret_at_line_edge(m_arena->host(), &read, context.query, offset, affinity == TextAffinity::Downstream, to_underlying(type), &caret_at);+ return caret_position_from(caret_at);}Optional<CaretPosition> HitTestDisplayList::caret_position_on_adjacent_line(Layout::BegunRead const& read, DOM::Node const& node, size_t offset, TextAffinity affinity, CaretLineDirection direction, CSSPixels inline_coordinate, DOM::Node const& scope) const@@ -317,7 +323,9 @@ Optional<CaretPosition> HitTestDisplayList::caret_position_on_adjacent_line(Layoreturn {};CaretPositionQueryContext position_context { node, offset };QueryContext context { nullptr, m_arena->document() };- return caret_position_from(Layout::RustFFI::layout_hit_test_caret_on_adjacent_line(m_arena->host(), &read, context.callbacks(), position_context.query, offset, affinity == TextAffinity::Downstream, direction == CaretLineDirection::Next ? 1 : 0, inline_coordinate.raw_value(), ffi_identity_of(&scope)));+ Layout::RustFFI::FfiCaretAt caret_at;+ Layout::RustFFI::layout_hit_test_caret_on_adjacent_line(m_arena->host(), &read, context.callbacks(), position_context.query, offset, affinity == TextAffinity::Downstream, direction == CaretLineDirection::Next ? 1 : 0, inline_coordinate.raw_value(), ffi_identity_of(&scope), &caret_at);+ return caret_position_from(caret_at);}Optional<CSSPixels> HitTestDisplayList::caret_line_block_coordinate(Layout::BegunRead const& read, DOM::Node const& node, size_t offset, TextAffinity affinity) const@@ -334,7 +342,9 @@ Optional<CSSPixels> HitTestDisplayList::caret_line_block_coordinate(Layout::BeguOptional<CaretPosition> HitTestDisplayList::caret_position_from_point(Layout::BegunRead const& read, CSSPixelPoint point, HitTestQuery const& query, CaretPositionMode mode, GC::Ptr<DOM::Node const> constraint_scope) const{QueryContext context { &query, m_arena->document() };- return caret_position_from(Layout::RustFFI::layout_hit_test_caret_position_from_point(m_arena->host(), &read, context.callbacks(), point, to_underlying(mode), ffi_identity_of(constraint_scope.ptr())));+ Layout::RustFFI::FfiCaretAt caret_at;+ Layout::RustFFI::layout_hit_test_caret_position_from_point(m_arena->host(), &read, context.callbacks(), point, to_underlying(mode), ffi_identity_of(constraint_scope.ptr()), &caret_at);+ return caret_position_from(caret_at);}Optional<HitTestResult> HitTestDisplayList::hit_test(Layout::BegunRead const& read, CSSPixelPoint point, HitTestQuery const& query) constdiff --git a/Libraries/LibWeb/Painting/Scrolling.cpp b/Libraries/LibWeb/Painting/Scrolling.cppindex 6dc0266d891..e1eb5fa723d 100644--- a/Libraries/LibWeb/Painting/Scrolling.cpp+++ b/Libraries/LibWeb/Painting/Scrolling.cpp@@ -24,17 +24,23 @@ CSSPixelPoint scroll_offset(Layout::Node const& node){if (!has_committed_box(node))return {};- return Layout::RustFFI::render_state_row_scroll_offset(node.document_host(), committed_row_slot(node));+ CSSPixelPoint offset;+ Layout::RustFFI::render_state_row_scroll_offset(node.document_host(), committed_row_slot(node), &offset);+ return offset;}CSSPixelPoint minimum_scroll_offset(Layout::Node const& node){- return Layout::RustFFI::layout_row_paintable_minimum_scroll_offset(node.document_host(), committed_row_slot(node));+ CSSPixelPoint offset;+ Layout::RustFFI::layout_row_paintable_minimum_scroll_offset(node.document_host(), committed_row_slot(node), &offset);+ return offset;}CSSPixelPoint maximum_scroll_offset(Layout::Node const& node){- return Layout::RustFFI::layout_row_paintable_maximum_scroll_offset(node.document_host(), committed_row_slot(node));+ CSSPixelPoint offset;+ Layout::RustFFI::layout_row_paintable_maximum_scroll_offset(node.document_host(), committed_row_slot(node), &offset);+ return offset;}CSSPixelPoint clamp_scroll_offset(Layout::Node const& node, CSSPixelPoint offset)@@ -61,7 +67,9 @@ CSSPixelRect scroll_snapport_rect(Layout::Node const& node, CSSPixelRect scrollp{if (!has_committed_box(node))return scrollport;- return Layout::RustFFI::layout_row_scroll_snapport_rect(node.document_host(), committed_row_slot(node), scrollport);+ CSSPixelRect rect;+ Layout::RustFFI::layout_row_scroll_snapport_rect(node.document_host(), committed_row_slot(node), scrollport, &rect);+ return rect;}WheelScrollableAxes wheel_scrollable_axes(Layout::Node const& node)diff --git a/Libraries/LibWeb/Rust/build.rs b/Libraries/LibWeb/Rust/build.rsindex b3a0bec4816..858d54fcfc6 100644--- a/Libraries/LibWeb/Rust/build.rs+++ b/Libraries/LibWeb/Rust/build.rs@@ -2202,11 +2202,6 @@ fn expose_css_pixel_types_as_web_types(config: &mut cbindgen::Config) {config.export.rename.insert(rust_name.to_string(), cpp_name.to_string());}config.includes.push("LibWebCommon/PixelUnits.h".to_string());- config.after_includes = Some(- "#if defined(__clang__)\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n#endif"- .to_string(),- );- config.trailer = Some("#if defined(__clang__)\n#pragma clang diagnostic pop\n#endif".to_string());}fn expose_shared_abi_types_as_cpp_types(config: &mut cbindgen::Config) {@@ -2721,8 +2716,7 @@ fn main() -> Result<(), Box<dyn Error>> {);computed_values_config.after_includes- .as_mut()- .unwrap()+ .get_or_insert_with(String::new).push_str("\nnamespace Web::CSS::Parser::ValueParserFFI { struct DeclarationBlockData; }");// An animation sample and plan read the document's style engine, which the document host reaches.declare_document_host_of_layout_header(&mut computed_values_config);diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 7652d1c0ecc..fb408f6cea4 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -5628,13 +5628,17 @@ pub unsafe extern "C" fn render_state_set_node_needs_compositor_animation_frame(////// `host` must be a live document host, on its document's thread.#[unsafe(no_mangle)]-pub unsafe extern "C" fn render_state_row_scroll_offset(host: &DocumentHost, slot: NodeSlotId) -> FfiCssPixelPoint {+pub unsafe extern "C" fn render_state_row_scroll_offset(+ host: &DocumentHost,+ slot: NodeSlotId,+ out: &mut FfiCssPixelPoint,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host, node_read(), slot, |arena, slot| {arena.row_scroll_offset(slot).into()})- }+ };}#[unsafe(no_mangle)]diff --git a/Libraries/LibWeb/Rust/src/layout/script_entries.rs b/Libraries/LibWeb/Rust/src/layout/script_entries.rsindex 3a4e854379a..2512268a7b0 100644--- a/Libraries/LibWeb/Rust/src/layout/script_entries.rs+++ b/Libraries/LibWeb/Rust/src/layout/script_entries.rs@@ -73,13 +73,14 @@ pub unsafe extern "C" fn layout_script_bounding_client_rect(host: &DocumentHost,layout_node: NodeSlotId,rect_to_viewport_transform: FfiRectToViewportTransform,-) -> FfiCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiCssPixelRect,+) {+ *out = read_rows(host, |arena| {let rect_to_viewport_transform =unsafe { crate::painting::ffi::rect_to_viewport_transform_from_ffi(&rect_to_viewport_transform) };crate::painting::client_rects::bounding_client_rect(arena, layout_node, rect_to_viewport_transform.as_ref()).into()- })+ });}/// # Safety@@ -122,8 +123,9 @@ pub unsafe extern "C" fn layout_script_intersection_observer_intersection_rect(*mut c_void,FfiCssPixelRect,) -> FfiCssPixelRect,-) -> FfiCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiCssPixelRect,+) {+ *out = read_rows(host, |arena| {let rect_to_viewport_transform =unsafe { crate::painting::ffi::rect_to_viewport_transform_from_ffi(&rect_to_viewport_transform) };crate::painting::intersection_observer::intersection_rect(@@ -139,7 +141,7 @@ pub unsafe extern "C" fn layout_script_intersection_observer_intersection_rect(},).into()- })+ });}/// # Safety@@ -227,8 +229,9 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_in_dom_range(host: &DocumentHost,primary: NodeSlotId,offset: usize,-) -> FfiOptionalCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiOptionalCssPixelRect,+) {+ *out = read_rows(host, |arena| {let paintable_rows = arena;let fragments = arena.text_fragments(primary);let node_slots = fragments.as_slice();@@ -242,7 +245,7 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_in_dom_range(rect: FfiCssPixelRect::default(),},}- })+ });}/// # Safety@@ -255,7 +258,8 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_for_position(primary: NodeSlotId,offset: usize,affinity_is_downstream: bool,-) -> FfiCaretRectResult {+ out: &mut FfiCaretRectResult,+) {let mut result = FfiCaretRectResult {found: false,rect: FfiCssPixelRect::default(),@@ -263,7 +267,7 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_for_position(owner_paintable: NodeSlotId::INVALID,nearest_self_painting_inline: NodeSlotId::INVALID,};- read_rows(host, |arena| {+ *out = read_rows(host, |arena| {let paintable_rows = arena;let fragments = arena.text_fragments(primary);let node_slots = fragments.as_slice();@@ -280,7 +284,7 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_for_position(crate::painting::fragment_ownership::nearest_self_painting_inline_box(paintable_rows, answer.node).unwrap_or(NodeSlotId::INVALID);result- })+ });}/// # Safety@@ -292,7 +296,8 @@ pub unsafe extern "C" fn layout_script_atomic_inline_caret_rect_for_position(host: &DocumentHost,primary: NodeSlotId,after: bool,-) -> FfiCaretRectResult {+ out: &mut FfiCaretRectResult,+) {let mut result = FfiCaretRectResult {found: false,rect: FfiCssPixelRect::default(),@@ -300,7 +305,7 @@ pub unsafe extern "C" fn layout_script_atomic_inline_caret_rect_for_position(owner_paintable: NodeSlotId::INVALID,nearest_self_painting_inline: NodeSlotId::INVALID,};- read_rows(host, |arena| {+ *out = read_rows(host, |arena| {let paintable_rows = arena;let Some(answer) = crate::painting::caret::caret_rect_for_atomic_inline(paintable_rows, primary, after) else {return result;@@ -313,7 +318,7 @@ pub unsafe extern "C" fn layout_script_atomic_inline_caret_rect_for_position(crate::painting::fragment_ownership::nearest_self_painting_inline_box(paintable_rows, answer.node).unwrap_or(NodeSlotId::INVALID);result- })+ });}/// # Safety@@ -326,13 +331,14 @@ pub unsafe extern "C" fn layout_script_paintable_empty_line_caret_rect(block: NodeSlotId,primary: NodeSlotId,offset: usize,-) -> FfiEmptyLineCaretRect {+ out: &mut FfiEmptyLineCaretRect,+) {let mut result = FfiEmptyLineCaretRect {has_value: false,rect: FfiCssPixelRect::default(),style_source: NodeSlotId::INVALID,};- read_rows(host, |arena| {+ *out = read_rows(host, |arena| {let paintable_rows = arena;if !paintable_rows.paintable_row_is_populated(block) {return result;@@ -355,7 +361,7 @@ pub unsafe extern "C" fn layout_script_paintable_empty_line_caret_rect(}}result- })+ });}/// # Safety@@ -365,10 +371,11 @@ pub unsafe extern "C" fn layout_script_paintable_empty_line_caret_rect(pub unsafe extern "C" fn layout_script_paintable_absolute_rect(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiCssPixelRect,+) {+ *out = read_rows(host, |arena| {crate::painting::paintable_geometry::absolute_rect_or_default(arena, slot).into()- })+ });}/// # Safety@@ -378,14 +385,15 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_rect(pub unsafe extern "C" fn layout_script_paintable_absolute_padding_box_rect(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiCssPixelRect,+) {+ *out = read_rows(host, |arena| {let paintable_rows = arena;if !paintable_rows.paintable_row_is_populated(slot) {return FfiCssPixelRect::default();}crate::painting::paintable_geometry::absolute_padding_box_rect(paintable_rows, slot).into()- })+ });}/// # Safety@@ -395,14 +403,15 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_padding_box_rect(pub unsafe extern "C" fn layout_script_paintable_absolute_border_box_rect(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelRect {- read_rows(host, |arena| {+ out: &mut FfiCssPixelRect,+) {+ *out = read_rows(host, |arena| {let paintable_rows = arena;if !paintable_rows.paintable_row_is_populated(slot) {return FfiCssPixelRect::default();}crate::painting::paintable_geometry::absolute_border_box_rect(paintable_rows, slot).into()- })+ });}/// # Safety@@ -414,8 +423,9 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_border_box_rect(pub unsafe extern "C" fn layout_script_paintable_box_model(host: &DocumentHost,slot: NodeSlotId,-) -> FfiBoxModelMetrics {- read_rows(host, |arena| {+ out: &mut FfiBoxModelMetrics,+) {+ *out = read_rows(host, |arena| {if !arena.paintable_row_is_populated(slot) {return FfiBoxModelMetrics::default();}@@ -425,7 +435,7 @@ pub unsafe extern "C" fn layout_script_paintable_box_model(border: crate::painting::paintable_geometry::committed_border(arena, slot),inset: crate::painting::paintable_geometry::committed_inset(arena, slot),}- })+ });}/// # Safety@@ -435,14 +445,15 @@ pub unsafe extern "C" fn layout_script_paintable_box_model(pub unsafe extern "C" fn layout_script_paintable_content_size(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelSize {- read_rows(host, |arena| {+ out: &mut FfiCssPixelSize,+) {+ *out = read_rows(host, |arena| {let paintable_rows = arena;if !paintable_rows.paintable_row_is_populated(slot) {return FfiCssPixelSize::default();}crate::painting::paintable_geometry::committed_content_size(paintable_rows, slot)- })+ });}/// Answers `read` of the layout arena of `host`'s document, spending the script call's forced read.diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rsindex 3a7e937cc73..40c592b6cf5 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs@@ -193,22 +193,24 @@ pub unsafe extern "C" fn document_host_set_geometry_host(pub unsafe extern "C" fn render_state_paintable_scrollable_overflow(host: &DocumentHost,slot: NodeSlotId,-) -> FfiOptionalOverflowData {+ out: &mut FfiOptionalOverflowData,+) {// The host reads the overflow from the rows it holds, where they were measured and still read as the arena.let known = host.read_known_rows(|rows, source| {rows.overflow_is_measured().then(|| FfiOptionalOverflowData::of(source, slot))});if let Some(Some(overflow)) = known {- return overflow;+ *out = overflow;+ return;}// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host, node_read(), slot, |arena, slot| {arena.measure_scrollable_overflow();FfiOptionalOverflowData::of(&arena.paintable_rows(), slot)})- }+ };}#[derive(Default)]@@ -246,9 +248,10 @@ pub struct FfiBoxModelMetrics {pub unsafe extern "C" fn render_state_paintable_svg_viewport_size(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelSize {+ out: &mut FfiCssPixelSize,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host, node_read(), slot, |arena, slot| {let paintable_rows = arena.paintable_rows();if !paintable_rows.paintable_row_is_populated(slot) {@@ -256,7 +259,7 @@ pub unsafe extern "C" fn render_state_paintable_svg_viewport_size(}crate::painting::paintable_geometry::committed_svg_viewport_size(&paintable_rows, slot)})- }+ };}#[repr(C)]@@ -318,19 +321,21 @@ pub unsafe extern "C" fn render_state_paintable_svg_element_transform(pub unsafe extern "C" fn render_state_paintable_transform_reference_box(host: &DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelRect {+ out: &mut FfiCssPixelRect,+) {fn reference_box(rows: &impl PaintRead, slot: NodeSlotId) -> FfiCssPixelRect {committed_transform_reference_box(rows, slot).map_or_else(FfiCssPixelRect::default, Into::into)}if let Some(rect) = host.read_rows_between_jobs(node_read(), |rows| reference_box(rows, slot)) {- return rect;+ *out = rect;+ return;}// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host, node_read(), slot, |arena, slot| {reference_box(&arena.paintable_rows(), slot)})- }+ };}/// The transform reference box of the box in `slot`, where the box was laid out.@@ -955,9 +960,10 @@ pub struct FfiOptionalCssPixelPoint {pub unsafe extern "C" fn render_state_inline_paintable_first_piece_position(host: &DocumentHost,inline_paintable: NodeSlotId,-) -> FfiOptionalCssPixelPoint {+ out: &mut FfiOptionalCssPixelPoint,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host, node_read(), inline_paintable, |arena, inline_paintable| {let mut result = FfiOptionalCssPixelPoint {has_value: false,@@ -986,7 +992,7 @@ pub unsafe extern "C" fn render_state_inline_paintable_first_piece_position(});result})- }+ };}#[repr(C)]@@ -1108,9 +1114,10 @@ pub unsafe extern "C" fn render_state_visual_line_caret_inline_coordinate(line_index: u32,primary: NodeSlotId,offset: usize,-) -> FfiOptionalCssPixels {+ out: &mut FfiOptionalCssPixels,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_arena(host,node_read(),@@ -1135,7 +1142,7 @@ pub unsafe extern "C" fn render_state_visual_line_caret_inline_coordinate(}},)- }+ };}/// # Safetydiff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rsindex 191a24ad6a0..49331aefa14 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs@@ -62,7 +62,8 @@ pub unsafe extern "C" fn layout_row_paintable_compute_scrollbar_data(has_device_scroll_offset: bool,device_scroll_offset: f32,device_pixels_per_css_pixel: f64,-) -> FfiOptionalScrollbarData {+ out: &mut FfiOptionalScrollbarData,+) {// SAFETY: Guaranteed by the caller.let data = unsafe {read_measured_rows(host, super::node_read(), |rows| {@@ -78,9 +79,10 @@ pub unsafe extern "C" fn layout_row_paintable_compute_scrollbar_data(})};let Some(data) = data else {- return FfiOptionalScrollbarData::default();+ *out = FfiOptionalScrollbarData::default();+ return;};- FfiOptionalScrollbarData {+ *out = FfiOptionalScrollbarData {has_value: true,value: FfiScrollbarData {gutter_rect: data.gutter_rect.into(),@@ -88,7 +90,7 @@ pub unsafe extern "C" fn layout_row_paintable_compute_scrollbar_data(track_rect: data.track_rect.into(),thumb_travel_to_scroll_ratio: data.thumb_travel_to_scroll_ratio.to_double(),},- }+ };}/// # Safety@@ -98,14 +100,15 @@ pub unsafe extern "C" fn layout_row_paintable_compute_scrollbar_data(pub unsafe extern "C" fn layout_row_paintable_minimum_scroll_offset(host: &crate::render_state::DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelPoint {+ out: &mut FfiCssPixelPoint,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::minimum_scroll_offset(rows, slot)})}- .into()+ .into();}/// # Safety@@ -115,14 +118,15 @@ pub unsafe extern "C" fn layout_row_paintable_minimum_scroll_offset(pub unsafe extern "C" fn layout_row_paintable_maximum_scroll_offset(host: &crate::render_state::DocumentHost,slot: NodeSlotId,-) -> FfiCssPixelPoint {+ out: &mut FfiCssPixelPoint,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::maximum_scroll_offset(rows, slot)})}- .into()+ .into();}/// # Safety@@ -176,14 +180,15 @@ pub unsafe extern "C" fn layout_row_scroll_snapport_rect(host: &crate::render_state::DocumentHost,snap_container: NodeSlotId,scrollport: FfiCssPixelRect,-) -> FfiCssPixelRect {+ out: &mut FfiCssPixelRect,+) {// SAFETY: Guaranteed by the caller.- unsafe {+ *out = unsafe {read_measured_rows(host, super::node_read(), |rows| {crate::painting::scroll_snap::scroll_snapport_rect(rows, snap_container, scrollport.into())})}- .into()+ .into();}/// # Safety@@ -1174,8 +1179,9 @@ pub unsafe extern "C" fn layout_hit_test_item_facts(host: &crate::render_state::DocumentHost,read: &crate::render_state::BegunRead,index: usize,-) -> crate::painting::host::FfiHitTestItemExport {- with_hit_test_list_items_only(host, read, None, |list, arena| {+ out: &mut crate::painting::host::FfiHitTestItemExport,+) {+ *out = with_hit_test_list_items_only(host, read, None, |list, arena| {let item = &list.items[index];assert!(arena.paintable_row_is_populated(item.paintable),@@ -1194,7 +1200,7 @@ pub unsafe extern "C" fn layout_hit_test_item_facts(context: item.context,})})- .expect("no hit-test list")+ .expect("no hit-test list");}/// # Safety@@ -1222,14 +1228,15 @@ pub unsafe extern "C" fn layout_hit_test_find_topmost_item(read: &crate::render_state::BegunRead,callbacks: crate::painting::host::FfiHitTestQueryCallbacks,point: FfiCssPixelPoint,-) -> crate::painting::host::FfiTopmostItem {- with_hit_test_list_spatial_indexes_and_visual_context_tree(+ out: &mut crate::painting::host::FfiTopmostItem,+) {+ *out = with_hit_test_list_spatial_indexes_and_visual_context_tree(host,read,false,Default::default(),|list, tree, arena| ffi_topmost(list.find_topmost_item(arena, tree, &callbacks, point.into())),- )+ );}/// # Safety@@ -1271,11 +1278,12 @@ pub unsafe extern "C" fn layout_hit_test_caret_position_from_point(point: FfiCssPixelPoint,mode: u8,constraint_scope: crate::painting::host::FfiNodeIdentity,-) -> FfiCaretAt {+ out: &mut FfiCaretAt,+) {// SAFETY: Guaranteed by the entry point's contract.let main_thread = unsafe { main_thread(host) };let mode = crate::painting::hit_test::caret::CaretPositionMode::from_u8(mode);- with_hit_test_list_spatial_indexes_and_visual_context_tree(host, read, true, None, |list, tree, arena| {+ *out = with_hit_test_list_spatial_indexes_and_visual_context_tree(host, read, true, None, |list, tree, arena| {list.caret_position_from_point(&main_thread,arena,@@ -1286,7 +1294,7 @@ pub unsafe extern "C" fn layout_hit_test_caret_position_from_point(constraint_scope,)})- .unwrap_or_else(FfiCaretAt::none)+ .unwrap_or_else(FfiCaretAt::none);}/// The caret position at the start (`edge` 1) or end (`edge` 2) of the painted line holding the position `query`@@ -1303,12 +1311,13 @@ pub unsafe extern "C" fn layout_hit_test_caret_at_line_edge(offset: usize,affinity_is_downstream: bool,edge: u8,-) -> FfiCaretAt {+ out: &mut FfiCaretAt,+) {let edge = crate::painting::hit_test::caret::CaretPositionType::from_u8(edge);- with_hit_test_list_and_caret_lines(host, read, None, |list, arena| {+ *out = with_hit_test_list_and_caret_lines(host, read, None, |list, arena| {list.caret_at_line_edge(arena, &query, offset, affinity_is_downstream, edge)})- .unwrap_or_else(FfiCaretAt::none)+ .unwrap_or_else(FfiCaretAt::none);}/// The caret position on the line visually after (`direction` 1) or before (`direction` 0) the line holding the@@ -1329,7 +1338,8 @@ pub unsafe extern "C" fn layout_hit_test_caret_on_adjacent_line(direction: u8,inline_coordinate: i32,scope: crate::painting::host::FfiNodeIdentity,-) -> FfiCaretAt {+ out: &mut FfiCaretAt,+) {let direction = if direction == 1 {crate::painting::hit_test::caret::CaretLineDirection::Next} else {@@ -1337,7 +1347,7 @@ pub unsafe extern "C" fn layout_hit_test_caret_on_adjacent_line(};// SAFETY: Guaranteed by the entry point's contract.let main_thread = unsafe { main_thread(host) };- with_hit_test_list_and_caret_lines(host, read, None, |list, arena| {+ *out = with_hit_test_list_and_caret_lines(host, read, None, |list, arena| {list.caret_on_adjacent_line(&main_thread,arena,@@ -1350,7 +1360,7 @@ pub unsafe extern "C" fn layout_hit_test_caret_on_adjacent_line(scope,)})- .unwrap_or_else(FfiCaretAt::none)+ .unwrap_or_else(FfiCaretAt::none);}/// The block-axis middle of the painted line holding the position `query` describes, if a line holds it.diff --git a/Libraries/LibWeb/VisualLines.cpp b/Libraries/LibWeb/VisualLines.cppindex f47ab750839..0e1babc2d14 100644--- a/Libraries/LibWeb/VisualLines.cpp+++ b/Libraries/LibWeb/VisualLines.cpp@@ -119,8 +119,9 @@ static Optional<CSSPixels> caret_inline_coordinate(Layout::BegunRead const& readauto const* layout_node = dom_node.layout_node(read);if (!layout_node)return {};- auto result = Layout::RustFFI::render_state_visual_line_caret_inline_coordinate(- layout_node->document_host(), line.owner_paintable, line.line_index, Layout::Node::slot_id(layout_node), offset);+ Layout::RustFFI::FfiOptionalCssPixels result;+ Layout::RustFFI::render_state_visual_line_caret_inline_coordinate(+ layout_node->document_host(), line.owner_paintable, line.line_index, Layout::Node::slot_id(layout_node), offset, &result);if (!result.has_value)return {};return result.value;