Skip to content

Truly independent web browser

LibWeb: Make style and layout helpers safe that only return FFI data

Andreas Kling2f14f0e8c29a
diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rs
index 8c7d4a658e6..41e23970b82 100644
--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs
@@ -2289,7 +2289,7 @@ unsafe fn publish_sampled_animation_overlay(
// whole, with the overlay over the same base.
None => {
// SAFETY: The base record stays live for the call.
- let base = unsafe { style_record_view(engine, input.style_record) };
+ let base = style_record_view(engine, input.style_record);
// SAFETY: Guaranteed by the caller, and the base's arrays are live.
unsafe {
publish_computed_groups(
@@ -2317,7 +2317,7 @@ unsafe fn publish_sampled_animation_overlay(
invalidation,
publication,
// SAFETY: The published record is live.
- view: unsafe { style_record_view(engine, publication.new_style_record) },
+ view: style_record_view(engine, publication.new_style_record),
rebuilt_every_group: rebuilt.every_group,
})
}
@@ -2353,12 +2353,8 @@ pub unsafe extern "C" fn style_engine_changed_style_groups(
}
/// Returns a synchronous borrowed view of a base or live animation-overlay record.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread, and its document's style engine
-/// must stay as it is for every read through the returned pointers.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_style_record_view(
+pub extern "C" fn style_engine_style_record_view(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
style_record: u64,
@@ -2367,7 +2363,7 @@ pub unsafe extern "C" fn style_engine_style_record_view(
return view;
}
// SAFETY: Guaranteed by the caller.
- let view = with_engine(read, host, |engine| unsafe { style_record_view(engine, style_record) });
+ let view = with_engine(read, host, |engine| style_record_view(engine, style_record));
if view.present {
host.engine_memo().views.set(style_record, view);
}
@@ -2375,10 +2371,7 @@ pub unsafe extern "C" fn style_engine_style_record_view(
}
/// [`style_engine_style_record_view`] on `engine`.
-///
-/// # Safety
-/// As for [`style_engine_style_record_view`], for the arguments after `engine`.
-pub unsafe fn style_record_view(engine: &mut StyleEngine, style_record: u64) -> FfiStyleRecordView {
+pub fn style_record_view(engine: &mut StyleEngine, style_record: u64) -> FfiStyleRecordView {
let view = engine.style_record_view(style_record);
match &view {
None => FfiStyleRecordView::missing(),
@@ -2398,11 +2391,8 @@ pub unsafe fn style_record_view(engine: &mut StyleEngine, style_record: u64) ->
}
/// Removes the retained computed-input assignment for one pseudo-element kind.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_remove_computed_pseudo(
+pub extern "C" fn style_engine_remove_computed_pseudo(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
@@ -2410,16 +2400,11 @@ pub unsafe extern "C" fn style_engine_remove_computed_pseudo(
) -> FfiStyleRecordDelta {
// SAFETY: Guaranteed by the caller.
// SAFETY: Guaranteed by the caller.
- with_engine(read, host, |engine| unsafe {
- remove_computed_pseudo(engine, node, pseudo_kind)
- })
+ with_engine(read, host, |engine| remove_computed_pseudo(engine, node, pseudo_kind))
}
/// [`style_engine_remove_computed_pseudo`] on `engine`.
-///
-/// # Safety
-/// As for [`style_engine_remove_computed_pseudo`], for the arguments after `engine`.
-pub unsafe fn remove_computed_pseudo(engine: &mut StyleEngine, node: u32, pseudo_kind: u8) -> FfiStyleRecordDelta {
+pub fn remove_computed_pseudo(engine: &mut StyleEngine, node: u32, pseudo_kind: u8) -> FfiStyleRecordDelta {
let Some(node) = StyleNodeID::from_raw(node) else {
return FfiStyleRecordDelta::default();
};
@@ -2691,11 +2676,8 @@ pub unsafe extern "C" fn style_engine_declared_only_record(
}
/// Settle the synthetic pseudo-element records of an element whose record the host just installed.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_settle_pseudo_records_after_host_record(
+pub extern "C" fn style_engine_settle_pseudo_records_after_host_record(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
@@ -2703,16 +2685,13 @@ pub unsafe extern "C" fn style_engine_settle_pseudo_records_after_host_record(
) -> FfiSettledPseudoRecords {
// SAFETY: Guaranteed by the caller.
// SAFETY: Guaranteed by the caller.
- with_engine(read, host, |engine| unsafe {
+ with_engine(read, host, |engine| {
settle_pseudo_records_after_host_record(engine, node, old_is_list_item)
})
}
/// [`style_engine_settle_pseudo_records_after_host_record`] on `engine`.
-///
-/// # Safety
-/// As for [`style_engine_settle_pseudo_records_after_host_record`], for the arguments after `engine`.
-pub unsafe fn settle_pseudo_records_after_host_record(
+pub fn settle_pseudo_records_after_host_record(
engine: &mut StyleEngine,
node: u32,
old_is_list_item: bool,
diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
index 7d85659c8e0..8479ec52c23 100644
--- a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
@@ -703,28 +703,20 @@ pub unsafe extern "C" fn style_engine_release_random_base_values(slot: *const c_
}
/// Answer a read of one element's style the host makes before the next style update.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_answer_record_demand(
+pub extern "C" fn style_engine_answer_record_demand(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
demand: FfiRecordDemand,
) -> FfiRecordDemandAnswer {
// SAFETY: Guaranteed by the caller.
- unsafe { ask_record_demand(host, read, node, RecordDemand::Element(demand)) }
+ ask_record_demand(host, read, node, RecordDemand::Element(demand))
}
/// Answer a read of one of an element's pseudo-elements the host makes before the next style update.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_answer_pseudo_element_record_demand(
+pub extern "C" fn style_engine_answer_pseudo_element_record_demand(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
@@ -732,13 +724,10 @@ pub unsafe extern "C" fn style_engine_answer_pseudo_element_record_demand(
pseudo_element: FfiDemandedPseudoElement,
) -> FfiRecordDemandAnswer {
// SAFETY: Guaranteed by the caller.
- unsafe { ask_record_demand(host, read, node, RecordDemand::PseudoElement(demand, pseudo_element)) }
+ ask_record_demand(host, read, node, RecordDemand::PseudoElement(demand, pseudo_element))
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
-unsafe fn ask_record_demand(
+fn ask_record_demand(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
diff --git a/Libraries/LibWeb/Rust/src/css/style/style_job.rs b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
index 6083c6315f5..8591e296a44 100644
--- a/Libraries/LibWeb/Rust/src/css/style/style_job.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
@@ -295,7 +295,7 @@ impl StyleJob {
.into_iter()
.filter_map(|record| {
// SAFETY: The view points into the record, which stays live while the rows name it.
- let view = unsafe { super::bridge::style_record_view(engine, record) };
+ let view = super::bridge::style_record_view(engine, record);
view.present.then(|| {
let environment = engine
.computed_group_sets
diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rs
index c944cdf60f7..ae72c6fb513 100644
--- a/Libraries/LibWeb/Rust/src/layout/commit.rs
+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs
@@ -85,7 +85,7 @@ impl CommitNotifications {
reset.tell(main_thread);
}
// SAFETY: Guaranteed by the caller.
- unsafe { host.deliver_commit_messages(main_thread, read, &self.messages) };
+ host.deliver_commit_messages(main_thread, read, &self.messages);
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 35fb56348b8..09ebaad4ace 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -952,11 +952,7 @@ impl FfiLayoutHostCallbacks {
}
/// Delivers `messages` to the document, in `read`.
- ///
- /// # Safety
- ///
- /// The document may re-enter the arena, so no arena borrow may be held across this call.
- pub(crate) unsafe fn deliver_commit_messages(
+ pub(crate) fn deliver_commit_messages(
&self,
_: &crate::stage::MainThread,
read: &crate::render_state::BegunRead,
@@ -970,11 +966,7 @@ impl FfiLayoutHostCallbacks {
}
/// Hands the document the scroll containers a build gave a style, in `read`.
- ///
- /// # Safety
- ///
- /// The document may re-enter the arena, so no arena borrow may be held across this call.
- pub(crate) unsafe fn take_built_scroll_containers(
+ pub(crate) fn take_built_scroll_containers(
&self,
_: &crate::stage::MainThread,
read: &crate::render_state::BegunRead,
diff --git a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
index 605f7440733..f9c346a9adc 100644
--- a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
+++ b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
@@ -67,16 +67,12 @@ pub extern "C" fn layout_row_identity_flags(host: &DocumentHost, id: NodeSlotId)
}
/// The layout node of the row `id` links to, made if nothing has asked for it yet, or null.
-///
-/// # Safety
-///
-/// As for [`layout_row_flags`].
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_link_shell(host: &DocumentHost, id: NodeSlotId, link: FfiNodeLink) -> *mut c_void {
+pub extern "C" fn layout_row_link_shell(host: &DocumentHost, id: NodeSlotId, link: FfiNodeLink) -> *mut c_void {
// SAFETY: Guaranteed by the caller.
let linked = rows(host, node_read()).link(id, link);
// SAFETY: As above.
- unsafe { shell_of(host, node_read(), (!linked.is_invalid()).then_some(linked)) }
+ shell_of(host, node_read(), (!linked.is_invalid()).then_some(linked))
}
#[unsafe(no_mangle)]
@@ -142,25 +138,17 @@ fn read_rows<R>(host: &DocumentHost, read: impl FnOnce(&PaintSource<'_>) -> R) -
}
/// The layout node of the live row `id`, made if nothing has asked for it yet, or null for none, spending `wait`.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
-unsafe fn shell_of(host: &DocumentHost, wait: impl RenderWait, id: Option<NodeSlotId>) -> *mut c_void {
+fn shell_of(host: &DocumentHost, wait: impl RenderWait, id: Option<NodeSlotId>) -> *mut c_void {
let Some(id) = id else {
return std::ptr::null_mut();
};
// SAFETY: Guaranteed by the caller.
- unsafe { bound_shell(host, wait, |_| Some(id)) }
+ bound_shell(host, wait, |_| Some(id))
}
/// The layout node of the live row `bound` finds among what each row is and the row each node is bound to, made if
/// nothing has asked for it yet, or null for none, spending `wait`: the identities are read once for both.
-///
-/// # Safety
-///
-/// As for [`shell_of`].
-unsafe fn bound_shell(
+fn bound_shell(
host: &DocumentHost,
wait: impl RenderWait,
bound: impl FnOnce(&RowIdentities) -> Option<NodeSlotId>,
@@ -179,17 +167,13 @@ unsafe fn bound_shell(
/// The layout node of the row the element or text node with `style_node` is bound to, made if nothing has asked for it
/// yet, or null if the node has no row.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_bound_shell(host: &DocumentHost, read: &BegunRead, style_node: u32) -> *mut c_void {
+pub extern "C" fn layout_row_bound_shell(host: &DocumentHost, read: &BegunRead, style_node: u32) -> *mut c_void {
let Some(style_node) = StyleNodeID::from_raw(style_node) else {
return std::ptr::null_mut();
};
// SAFETY: Guaranteed by the caller.
- unsafe { bound_shell(host, read, |identities| identities.bound_row(style_node)) }
+ bound_shell(host, read, |identities| identities.bound_row(style_node))
}
/// The content size of the committed box of the row the element with `style_node` is bound to, or none where the
@@ -220,12 +204,8 @@ pub extern "C" fn layout_row_bound_committed_content_size(
/// The layout node of the row the pseudo-element of kind `generated_for` on the element with `style_node` is bound to,
/// made if nothing has asked for it yet, or null.
-///
-/// # Safety
-///
-/// As for [`layout_row_bound_shell`].
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_bound_pseudo_element_shell(
+pub extern "C" fn layout_row_bound_pseudo_element_shell(
host: &DocumentHost,
read: &BegunRead,
style_node: u32,
@@ -235,7 +215,7 @@ pub unsafe extern "C" fn layout_row_bound_pseudo_element_shell(
return std::ptr::null_mut();
};
// SAFETY: Guaranteed by the caller.
- unsafe {
+ {
bound_shell(host, read, |identities| {
identities.bound_pseudo_element_row(style_node, generated_for)
})
@@ -243,14 +223,10 @@ pub unsafe extern "C" fn layout_row_bound_pseudo_element_shell(
}
/// The layout node of the viewport row the document is bound to, made if nothing has asked for it yet, or null.
-///
-/// # Safety
-///
-/// As for [`layout_row_bound_shell`].
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_bound_viewport_shell(host: &DocumentHost, read: &BegunRead) -> *mut c_void {
+pub extern "C" fn layout_row_bound_viewport_shell(host: &DocumentHost, read: &BegunRead) -> *mut c_void {
// SAFETY: Guaranteed by the caller.
- unsafe { bound_shell(host, read, RowIdentities::bound_viewport_row) }
+ bound_shell(host, read, RowIdentities::bound_viewport_row)
}
/// The read of the layout node the host holds, which the host lends the entries it calls about the node's document.
@@ -273,16 +249,12 @@ pub extern "C" fn layout_row_is_bound_to(host: &DocumentHost, id: NodeSlotId, st
}
/// The layout node of the box whose content box the row is laid out against, or null.
-///
-/// # Safety
-///
-/// As for [`layout_row_bound_shell`].
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_containing_block_shell_if_live(host: &DocumentHost, id: NodeSlotId) -> *mut c_void {
+pub extern "C" fn layout_row_containing_block_shell_if_live(host: &DocumentHost, id: NodeSlotId) -> *mut c_void {
// SAFETY: Guaranteed by the caller.
let containing_block = read_rows(host, |rows| rows.node_containing_block_if_live(id));
// SAFETY: As above.
- unsafe { shell_of(host, node_read(), containing_block) }
+ shell_of(host, node_read(), containing_block)
}
#[unsafe(no_mangle)]
@@ -319,12 +291,8 @@ pub extern "C" fn layout_row_any_ancestor_establishes_a_fixed_position_containin
}
/// The layout node of the row whose paintable row `slot` is, or null when the row has none.
-///
-/// # Safety
-///
-/// As for [`layout_row_bound_shell`].
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_paintable_layout_node_shell(
+pub extern "C" fn layout_row_paintable_layout_node_shell(
host: &DocumentHost,
read: &BegunRead,
slot: NodeSlotId,
@@ -332,7 +300,7 @@ pub unsafe extern "C" fn layout_row_paintable_layout_node_shell(
// SAFETY: Guaranteed by the caller.
let populated = rows(host, read).paintable.paintable_row_is_populated(slot);
// SAFETY: As above.
- unsafe { shell_of(host, read, populated.then_some(slot)) }
+ shell_of(host, read, populated.then_some(slot))
}
#[unsafe(no_mangle)]
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
index c6eb9cd65ea..6c42482ebd5 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
@@ -688,10 +688,7 @@ fn repaint(arena: &mut LayoutNodeArena, row: NodeSlotId, includes_hit_testing: b
}
}
-/// # Safety
-///
-/// `host` must be a live document host, on the document's thread.
-unsafe fn queue_marks(host: &DocumentHost, target: MarkedBox, marks: FfiBoxMarks) {
+fn queue_marks(host: &DocumentHost, target: MarkedBox, marks: FfiBoxMarks) {
if marks.is_empty() {
return;
}
@@ -700,24 +697,16 @@ unsafe fn queue_marks(host: &DocumentHost, target: MarkedBox, marks: FfiBoxMarks
}
/// Marks the box bound to the node with `style_node`, or the document's for 0.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on the document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_mark_node_box(host: &DocumentHost, style_node: u32, marks: FfiBoxMarks) {
+pub extern "C" fn render_state_mark_node_box(host: &DocumentHost, style_node: u32, marks: FfiBoxMarks) {
let target = MarkedBox::Node(StyleNodeID::from_raw(style_node));
// SAFETY: Guaranteed by the caller.
- unsafe { queue_marks(host, target, marks) };
+ queue_marks(host, target, marks);
}
/// Marks the box bound to the pseudo-element of kind `generated_for` on the element with `generator`.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on the document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_mark_pseudo_element_box(
+pub extern "C" fn render_state_mark_pseudo_element_box(
host: &DocumentHost,
generator: u32,
generated_for: u8,
@@ -731,19 +720,15 @@ pub unsafe extern "C" fn render_state_mark_pseudo_element_box(
generated_for,
};
// SAFETY: Guaranteed by the caller.
- unsafe { queue_marks(host, target, marks) };
+ queue_marks(host, target, marks);
}
/// Marks the box of the row `row`.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on the document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_mark_row_box(host: &DocumentHost, row: NodeSlotId, marks: FfiBoxMarks) {
+pub extern "C" fn render_state_mark_row_box(host: &DocumentHost, row: NodeSlotId, marks: FfiBoxMarks) {
let target = MarkedBox::Row(row);
// SAFETY: Guaranteed by the caller.
- unsafe { queue_marks(host, target, marks) };
+ queue_marks(host, target, marks);
}
#[cfg(test)]
diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout.rs b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
index 79a6efb8fd5..033f90a1f41 100644
--- a/Libraries/LibWeb/Rust/src/layout/update_layout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
@@ -800,7 +800,7 @@ impl LayoutRoundAnswer {
// SAFETY (for every call below): Guaranteed by the caller.
std::mem::take(&mut self.work).pay(main_thread);
if let Some((replaced_viewport, built)) = self.build.take() {
- unsafe {
+ {
layout_host.deliver_commit_messages(main_thread, read, &built.reports);
layout_host.take_built_scroll_containers(main_thread, read, &built.built_scroll_containers);
}
@@ -816,7 +816,7 @@ impl LayoutRoundAnswer {
if let Some(geometry_host) = document_host.host_tables().geometry_host.get() {
for (slot, offset) in self.clamped_scroll_offsets.drain(..) {
// SAFETY: The round clamped the offsets of rows it left live, whose layout nodes the host has now.
- unsafe { geometry_host.set_scroll_offset(main_thread, read, slot, offset.into()) };
+ geometry_host.set_scroll_offset(main_thread, read, slot, offset.into());
}
}
}
@@ -875,11 +875,7 @@ fn layout_update_host(document_host: &DocumentHost) -> FfiLayoutUpdateHostCallba
/// The first round of a rendering update's layout of `document_host`'s document, sealed for a frame to run beside the
/// host, where the document is active and `needs_round` says the round has something to do as of its facts.
-///
-/// # Safety
-///
-/// As for [`update_layout`].
-unsafe fn sealed_first_round(
+fn sealed_first_round(
main_thread: &MainThread,
document_host: &DocumentHost,
read: &BegunRead,
@@ -899,11 +895,7 @@ unsafe fn sealed_first_round(
/// Seals the first round of a rendering update's layout of `document_host`'s document, which the frame the update lets
/// fly next runs after its style.
-///
-/// # Safety
-///
-/// As for [`update_layout`].
-unsafe fn seal_first_round(
+fn seal_first_round(
main_thread: &MainThread,
document_host: &DocumentHost,
read: &BegunRead,
@@ -912,7 +904,7 @@ unsafe fn seal_first_round(
// A round is sealed for a document whose layout is up to date as well: the frame's style may leave it layout to
// do, which the round finds once the frame has applied the style.
// SAFETY: Guaranteed by the caller.
- if let Some(round) = unsafe { sealed_first_round(main_thread, document_host, read, inputs, |_| true) } {
+ if let Some(round) = sealed_first_round(main_thread, document_host, read, inputs, |_| true) {
document_host.seal_round(round);
}
}
@@ -920,11 +912,7 @@ unsafe fn seal_first_round(
/// Lets the first round of a rendering update's layout of `document_host`'s document fly beside the host, once the
/// host's style is up to date, where the layout is not and no round that flew with the style waits to be taken in. The
/// host's next layout update pays it first. Answers whether it flies.
-///
-/// # Safety
-///
-/// As for [`update_layout`].
-unsafe fn fly_first_round(
+fn fly_first_round(
main_thread: &MainThread,
document_host: &DocumentHost,
read: &BegunRead,
@@ -941,7 +929,7 @@ unsafe fn fly_first_round(
host.process_pending_list_item_renumbers(main_thread, read);
host.process_pending_top_layer_layout_changes(main_thread, read);
// SAFETY: Guaranteed by the caller.
- let round = unsafe {
+ let round = {
sealed_first_round(main_thread, document_host, read, inputs, |facts| {
!host_layout_is_up_to_date(document_host, read, facts)
})
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 eb689759cf0..4e662155d2c 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -336,7 +336,7 @@ pub unsafe extern "C" fn render_state_prepare_for_rendering(
if let Some(geometry_host) = host.host_tables().geometry_host.get() {
for (slot, offset) in prepared.clamped_scroll_offsets {
// SAFETY: The pass clamped the offsets of live rows, and the host holds no borrow of the arena.
- unsafe { geometry_host.set_scroll_offset(&main_thread, read, slot, offset.into()) };
+ geometry_host.set_scroll_offset(&main_thread, read, slot, offset.into());
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/host/mod.rs b/Libraries/LibWeb/Rust/src/painting/host/mod.rs
index bcf7ca7137b..3fc18cf3878 100644
--- a/Libraries/LibWeb/Rust/src/painting/host/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/host/mod.rs
@@ -49,12 +49,7 @@ pub struct FfiGeometryHostCallbacks {
impl FfiGeometryHostCallbacks {
/// Stores a scroll offset the overflow pass settled on, after the pass, in `read`.
- ///
- /// # Safety
- ///
- /// `slot` must name a live row. The host re-enters geometry queries and writes the store the
- /// offset lives in, so no mutable arena or cache borrow may be held across this call.
- pub(crate) unsafe fn set_scroll_offset(
+ pub(crate) fn set_scroll_offset(
&self,
_: &crate::stage::MainThread,
read: &crate::render_state::BegunRead,
diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rs
index 8d296ced667..671e3c6dd97 100644
--- a/Libraries/LibWeb/Rust/src/render_state.rs
+++ b/Libraries/LibWeb/Rust/src/render_state.rs
@@ -1075,7 +1075,7 @@ mod tests {
let test_host = TestHost::new();
let host = test_host.host();
// SAFETY: The host is live, on this thread.
- unsafe {
+ {
document_host_note_paint_preparation_is_current(host);
render_state_mark_node_box(host, 1, FfiBoxMarks::default());
}