Skip to content

Truly independent web browser

LibWeb: Make FFI exports safe when their bodies need no unsafe

Andreas Kling8b51ccd773e3
diff --git a/Libraries/LibWeb/Rust/src/css/css_path.rs b/Libraries/LibWeb/Rust/src/css/css_path.rs
index b289e64104b..7149437ebd6 100644
--- a/Libraries/LibWeb/Rust/src/css/css_path.rs
+++ b/Libraries/LibWeb/Rust/src/css/css_path.rs
@@ -92,10 +92,8 @@ impl std::fmt::Debug for CssPath {
}
}
-/// # Safety
-/// `path` must be a live, nonempty CSS path. The caller owns the returned Gfx::Path.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_css_path_to_gfx_path(path: &CssPath) -> *mut std::ffi::c_void {
+pub extern "C" fn rust_css_path_to_gfx_path(path: &CssPath) -> *mut std::ffi::c_void {
path.to_gfx_path().into_raw()
}
diff --git a/Libraries/LibWeb/Rust/src/css/declaration_block.rs b/Libraries/LibWeb/Rust/src/css/declaration_block.rs
index 923c7fcc33d..aef5760bbdc 100644
--- a/Libraries/LibWeb/Rust/src/css/declaration_block.rs
+++ b/Libraries/LibWeb/Rust/src/css/declaration_block.rs
@@ -477,7 +477,7 @@ pub unsafe extern "C" fn rust_declaration_block_create(
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_declaration_block_share(block: &DeclarationBlock) -> *mut DeclarationBlock {
+pub extern "C" fn rust_declaration_block_share(block: &DeclarationBlock) -> *mut DeclarationBlock {
Box::into_raw(Box::new(DeclarationBlock::new(block.data())))
}
@@ -597,7 +597,7 @@ pub unsafe extern "C" fn rust_declaration_block_set_custom(
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_declaration_block_remove(block: &mut DeclarationBlock, property_id: u16) -> bool {
+pub extern "C" fn rust_declaration_block_remove(block: &mut DeclarationBlock, property_id: u16) -> bool {
block.remove(property_id)
}
@@ -622,7 +622,7 @@ pub unsafe extern "C" fn rust_declaration_block_remove_custom(
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_declaration_block_external_memory_size(block: &DeclarationBlock) -> usize {
+pub extern "C" fn rust_declaration_block_external_memory_size(block: &DeclarationBlock) -> usize {
let data = block.data();
let mut size = size_of::<DeclarationBlock>().saturating_add(data.external_memory_size());
if matches!(*block.state.borrow(), DeclarationBlockState::Mutable(_)) {
@@ -687,8 +687,8 @@ mod tests {
let original = DeclarationBlock::new(data.clone());
let mut fork = unsafe { Box::from_raw(rust_declaration_block_share(&original)) };
let expected = rust_declaration_data_dependencies(&data);
- assert!(unsafe { rust_declaration_block_remove(&mut fork, property_id::WIDTH) });
- assert!(unsafe { rust_declaration_block_remove(&mut fork, property_id::ANIMATION_NAME) });
+ assert!(rust_declaration_block_remove(&mut fork, property_id::WIDTH));
+ assert!(rust_declaration_block_remove(&mut fork, property_id::ANIMATION_NAME));
let mut retained = unsafe { Box::from_raw(rust_declaration_block_retain(&fork)) };
let owners = DECLARATION_OWNER_ALLOCATIONS.with(|count| count.get());
assert_eq!(
@@ -737,16 +737,16 @@ mod tests {
assert_eq!(borrowed.custom_properties.len(), 1);
assert!(!unsafe { rust_declaration_block_is_empty(block) });
assert_eq!(rust_declaration_block_revision(block), 0);
- assert!(unsafe { rust_declaration_block_external_memory_size(block) } > 0);
+ assert!(rust_declaration_block_external_memory_size(block) > 0);
let mut fork = unsafe { Box::from_raw(rust_declaration_block_share(block)) };
- assert!(!unsafe { rust_declaration_block_remove(&mut fork, property_id::HEIGHT) });
+ assert!(!rust_declaration_block_remove(&mut fork, property_id::HEIGHT));
assert!(matches!(*block.state.borrow(), DeclarationBlockState::Immutable(_)));
assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Immutable(_)));
assert!(Arc::ptr_eq(&snapshot, &fork.data()));
let mut retained = unsafe { Box::from_raw(rust_declaration_block_retain(block)) };
assert!(Rc::ptr_eq(&block.owner(), &retained.owner()));
- assert!(unsafe { rust_declaration_block_remove(&mut retained, property_id::WIDTH) });
+ assert!(rust_declaration_block_remove(&mut retained, property_id::WIDTH));
assert!(block.data().properties.is_empty());
assert_eq!(rust_declaration_block_revision(block), 1);
// A different handle's mutation cannot invalidate a pinned snapshot.
@@ -761,7 +761,7 @@ mod tests {
assert_eq!(rust_declaration_block_revision(block), 2);
assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Immutable(_)));
drop(rules);
- assert!(unsafe { rust_declaration_block_remove(&mut fork, property_id::WIDTH) });
+ assert!(rust_declaration_block_remove(&mut fork, property_id::WIDTH));
assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Mutable(_)));
assert!(fork.data().properties.is_empty());
assert_eq!(retained.data().properties.len(), 1);
diff --git a/Libraries/LibWeb/Rust/src/css/function_signature.rs b/Libraries/LibWeb/Rust/src/css/function_signature.rs
index 338954cf30a..37cacceeee1 100644
--- a/Libraries/LibWeb/Rust/src/css/function_signature.rs
+++ b/Libraries/LibWeb/Rust/src/css/function_signature.rs
@@ -43,7 +43,7 @@ pub struct FfiFunctionParameterView {
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_function_signature_view(signature: &FunctionSignature) -> FfiFunctionSignatureView {
+pub extern "C" fn rust_function_signature_view(signature: &FunctionSignature) -> FfiFunctionSignatureView {
let name = signature.name.units();
FfiFunctionSignatureView {
name: FfiUtf16View {
@@ -57,7 +57,7 @@ pub unsafe extern "C" fn rust_function_signature_view(signature: &FunctionSignat
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_function_signature_parameter(
+pub extern "C" fn rust_function_signature_parameter(
signature: &FunctionSignature,
index: usize,
) -> FfiFunctionParameterView {
diff --git a/Libraries/LibWeb/Rust/src/css/media_list.rs b/Libraries/LibWeb/Rust/src/css/media_list.rs
index fb0d7a224b6..11667d3aafb 100644
--- a/Libraries/LibWeb/Rust/src/css/media_list.rs
+++ b/Libraries/LibWeb/Rust/src/css/media_list.rs
@@ -104,12 +104,12 @@ pub extern "C" fn rust_media_list_create() -> *mut MediaList {
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_media_list_retain(list: &MediaList) -> *mut MediaList {
+pub extern "C" fn rust_media_list_retain(list: &MediaList) -> *mut MediaList {
Box::into_raw(Box::new(list.clone()))
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_media_list_share(list: &MediaList) -> *mut MediaList {
+pub extern "C" fn rust_media_list_share(list: &MediaList) -> *mut MediaList {
Box::into_raw(Box::new(list.share()))
}
@@ -121,7 +121,7 @@ pub unsafe extern "C" fn rust_media_list_free(list: *mut MediaList) {
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_media_list_length(list: &MediaList) -> usize {
+pub extern "C" fn rust_media_list_length(list: &MediaList) -> usize {
list.owner.borrow().data.queries.len()
}
@@ -218,12 +218,12 @@ pub unsafe extern "C" fn rust_media_list_item(
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_media_list_matches(list: &MediaList) -> bool {
+pub extern "C" fn rust_media_list_matches(list: &MediaList) -> bool {
list.matches()
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_media_list_item_matches(list: &MediaList, index: usize) -> bool {
+pub extern "C" fn rust_media_list_item_matches(list: &MediaList, index: usize) -> bool {
list.owner.borrow().matches[index]
}
diff --git a/Libraries/LibWeb/Rust/src/css/namespace_rule.rs b/Libraries/LibWeb/Rust/src/css/namespace_rule.rs
index c2274748f9e..7c021206b2f 100644
--- a/Libraries/LibWeb/Rust/src/css/namespace_rule.rs
+++ b/Libraries/LibWeb/Rust/src/css/namespace_rule.rs
@@ -18,7 +18,7 @@ const _: () = {
};
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_namespace_rule_prefix(rule: &NamespaceRuleData) -> FfiUtf16View {
+pub extern "C" fn rust_namespace_rule_prefix(rule: &NamespaceRuleData) -> FfiUtf16View {
let units = rule.prefix.units();
FfiUtf16View {
ascii: std::ptr::null(),
@@ -28,7 +28,7 @@ pub unsafe extern "C" fn rust_namespace_rule_prefix(rule: &NamespaceRuleData) ->
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_namespace_rule_uri(rule: &NamespaceRuleData) -> FfiUtf16View {
+pub extern "C" fn rust_namespace_rule_uri(rule: &NamespaceRuleData) -> FfiUtf16View {
let units = rule.uri.units();
FfiUtf16View {
ascii: std::ptr::null(),
diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs
index d89b6357508..8ec5f588259 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs
@@ -1139,7 +1139,7 @@ fn declaration_mutation_does_not_change_cached_or_nested_shared_blocks() {
let shared = DeclarationBlock::new(original);
assert_eq!(changed.data().properties.len(), 5);
assert_eq!(changed.data().custom_properties.len(), 1);
- unsafe { assert!(rust_declaration_block_remove(&mut changed, property_id::MARGIN_LEFT)) };
+ assert!(rust_declaration_block_remove(&mut changed, property_id::MARGIN_LEFT));
assert_eq!(shared.data().properties.len(), 5);
}
diff --git a/Libraries/LibWeb/Rust/src/css/property_rule.rs b/Libraries/LibWeb/Rust/src/css/property_rule.rs
index fa1af447486..b73e6e01d35 100644
--- a/Libraries/LibWeb/Rust/src/css/property_rule.rs
+++ b/Libraries/LibWeb/Rust/src/css/property_rule.rs
@@ -34,7 +34,7 @@ pub struct FfiPropertyRuleView {
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_property_rule_view(rule: &PropertyRuleData) -> FfiPropertyRuleView {
+pub extern "C" fn rust_property_rule_view(rule: &PropertyRuleData) -> FfiPropertyRuleView {
let name = rule.name.units();
let syntax_source = rule.syntax_source.units();
FfiPropertyRuleView {
diff --git a/Libraries/LibWeb/Rust/src/css/rule/compilation.rs b/Libraries/LibWeb/Rust/src/css/rule/compilation.rs
index 2a795ed01ff..855a98a4b44 100644
--- a/Libraries/LibWeb/Rust/src/css/rule/compilation.rs
+++ b/Libraries/LibWeb/Rust/src/css/rule/compilation.rs
@@ -1273,7 +1273,7 @@ mod tests {
drop(parsed_child);
let child = loaded_child.unwrap();
let host = crate::render_state::TestHost::new();
- let add_sheet = |host: &crate::render_state::TestHost| unsafe {
+ let add_sheet = |host: &crate::render_state::TestHost| {
crate::css::style::rule_writes::style_engine_add_sheet(
host.host(),
1,
diff --git a/Libraries/LibWeb/Rust/src/css/scope_selectors.rs b/Libraries/LibWeb/Rust/src/css/scope_selectors.rs
index c005d4a4236..fc8bb7cd0fe 100644
--- a/Libraries/LibWeb/Rust/src/css/scope_selectors.rs
+++ b/Libraries/LibWeb/Rust/src/css/scope_selectors.rs
@@ -33,11 +33,11 @@ pub unsafe extern "C" fn rust_scope_selectors_release(selectors: *const ScopeSel
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_scope_selectors_start(selectors: &ScopeSelectors) -> *const c_void {
+pub extern "C" fn rust_scope_selectors_start(selectors: &ScopeSelectors) -> *const c_void {
selectors.start.as_ref().map_or(std::ptr::null(), Arc::as_ptr).cast()
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_scope_selectors_end(selectors: &ScopeSelectors) -> *const c_void {
+pub extern "C" fn rust_scope_selectors_end(selectors: &ScopeSelectors) -> *const c_void {
selectors.end.as_ref().map_or(std::ptr::null(), Arc::as_ptr).cast()
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rs
index ff809a43062..1326bb6608e 100644
--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs
@@ -1281,11 +1281,8 @@ pub unsafe fn note_custom_property_environment(
/// The environment a child inherits from one the engine resolved: itself, unless a registration
/// keeps some of its custom properties from inheriting.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_inheritable_custom_property_environment(
+pub extern "C" fn style_engine_inheritable_custom_property_environment(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
identity: u64,
@@ -2053,12 +2050,8 @@ pub enum FfiNodeRecordReads {
/// Computes what moving an element from one final style record to another damages, from the
/// records and the facts the engine holds of the element. The counter styles its box was built
/// with are the host's to compare.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread, and both style records must
-/// remain pinned or assigned.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_element_record_damage(
+pub extern "C" fn style_engine_element_record_damage(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
@@ -2076,12 +2069,8 @@ pub unsafe extern "C" fn style_engine_element_record_damage(
/// Computes what moving one of an element's pseudo-elements from one final style record to another
/// damages, where either record can be zero. `counter_styles_changed` is the host's comparison of
/// the counter styles the pseudo-element's box was built with.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread, and every nonzero style record
-/// must remain pinned or assigned.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_pseudo_element_record_damage(
+pub extern "C" fn style_engine_pseudo_element_record_damage(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
@@ -2778,11 +2767,8 @@ pub struct FfiNativeRuleTarget {
}
/// Issue a new identity for changed declaration contents, independently of CSSOM wrappers.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_next_declaration_block_version(host: &DocumentHost) -> u32 {
+pub extern "C" fn style_engine_next_declaration_block_version(host: &DocumentHost) -> u32 {
host.next_declaration_block_version()
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
index 76788850ea6..b2eb6c735e2 100644
--- a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs
@@ -536,20 +536,14 @@ pub unsafe extern "C" fn style_engine_stage_element_declaration_delta(
}
/// Whether the host staged deltas it has not submitted yet.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_has_staged_input(host: &DocumentHost) -> bool {
+pub extern "C" fn style_engine_has_staged_input(host: &DocumentHost) -> bool {
!host.engine_memo().staged_input.borrow().is_empty()
}
/// Submits the deltas the host staged as one batch, which the engine applies in order with the host's other writes.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_submit_staged_input(host: &DocumentHost) {
+pub extern "C" fn style_engine_submit_staged_input(host: &DocumentHost) {
let staged = std::mem::take(&mut *host.engine_memo().staged_input.borrow_mut());
if !staged.is_empty() {
host.queue_change(ArenaChange::Engine(EngineWrite::ApplyTransaction(Box::new(staged))));
@@ -616,12 +610,8 @@ pub(crate) fn with_engine_and_arena<R>(
}
/// The custom-property environment an element holds, or null.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_element_custom_property_data(host: &DocumentHost, node: u32) -> *const c_void {
+pub extern "C" fn style_engine_element_custom_property_data(host: &DocumentHost, node: u32) -> *const c_void {
let Some(node) = StyleNodeID::from_raw(node) else {
return std::ptr::null();
};
@@ -629,12 +619,8 @@ pub unsafe extern "C" fn style_engine_element_custom_property_data(host: &Docume
}
/// The custom-property environment one of an element's synthetic pseudo-elements holds, or null.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_pseudo_element_custom_property_data(
+pub extern "C" fn style_engine_pseudo_element_custom_property_data(
host: &DocumentHost,
node: u32,
pseudo: u8,
@@ -646,12 +632,8 @@ pub unsafe extern "C" fn style_engine_pseudo_element_custom_property_data(
}
/// Which of an element's synthetic pseudo-elements hold a custom-property environment, as a bit set by kind.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_pseudo_elements_with_custom_property_data(host: &DocumentHost, node: u32) -> u64 {
+pub extern "C" fn style_engine_pseudo_elements_with_custom_property_data(host: &DocumentHost, node: u32) -> u64 {
let Some(node) = StyleNodeID::from_raw(node) else {
return 0;
};
@@ -791,12 +773,8 @@ unsafe fn ask_record_demand(
}
/// What a style record's values depend on.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_style_record_dependency_flags(
+pub extern "C" fn style_engine_style_record_dependency_flags(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
style_record: u64,
@@ -821,12 +799,8 @@ pub unsafe extern "C" fn style_engine_style_record_dependency_flags(
}
/// The identity of the custom-property environment a style record was computed in, or 0.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_style_record_custom_property_environment(
+pub extern "C" fn style_engine_style_record_custom_property_environment(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
style_record: u64,
@@ -1218,12 +1192,8 @@ pub(crate) fn known_style_record_view(
/// The before-change style the current style stabilization epoch decides the transitions of `node`'s element, or of
/// one of its pseudo-elements, against, or 0 before a pass has recorded one. The host knows it without asking: it
/// follows every baseline it records in the engine.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_transition_baseline(host: &DocumentHost, node: u32, pseudo_kind: u8) -> u64 {
+pub extern "C" fn style_engine_transition_baseline(host: &DocumentHost, node: u32, pseudo_kind: u8) -> u64 {
let Some(node) = StyleNodeID::from_raw(node) else {
return 0;
};
@@ -1232,12 +1202,8 @@ pub unsafe extern "C" fn style_engine_transition_baseline(host: &DocumentHost, n
/// Whether the engine has a style transaction pending, which the host knows without asking where it wrote nothing
/// since its last job.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_has_pending_transaction(host: &DocumentHost, read: &BegunRead) -> bool {
+pub extern "C" fn style_engine_has_pending_transaction(host: &DocumentHost, read: &BegunRead) -> bool {
match host.known_engine_facts() {
Some(facts) => facts.has_pending_style_transaction,
None => with_engine(read, host, |engine| engine.has_pending_transaction()),
@@ -1246,12 +1212,8 @@ pub unsafe extern "C" fn style_engine_has_pending_transaction(host: &DocumentHos
/// Whether the engine defers any element style input, which the host knows without asking where it wrote nothing since
/// its last job.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_has_deferred_element_style_inputs(host: &DocumentHost, read: &BegunRead) -> bool {
+pub extern "C" fn style_engine_has_deferred_element_style_inputs(host: &DocumentHost, read: &BegunRead) -> bool {
match host.known_engine_facts() {
Some(facts) => facts.has_deferred_element_style_inputs,
None => with_engine(read, host, |engine| engine.has_deferred_element_style_inputs()),
@@ -1273,16 +1235,8 @@ pub(crate) fn has_deferred_element_style_input(host: &DocumentHost, read: &Begun
/// The synthetic pseudo-elements `node` has rules for, as a C++ record's pseudo-style mask, or no bits when the engine
/// holds no answer for the node. The host knows it without asking for an element whose row it composes in the
/// transaction it took last, which answered it beside the row.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_published_pseudo_style_mask(
- host: &DocumentHost,
- read: &BegunRead,
- node: u32,
-) -> u64 {
+pub extern "C" fn style_engine_published_pseudo_style_mask(host: &DocumentHost, read: &BegunRead, node: u32) -> u64 {
host.transaction_pseudo_styles(node).map_or_else(
|| {
with_engine(read, host, |engine| {
@@ -1295,23 +1249,15 @@ pub unsafe extern "C" fn style_engine_published_pseudo_style_mask(
/// The synthetic pseudo-elements `node` has rules for that settling its pseudo-elements over the composition of its
/// record leaves alone, where the style transaction the host drains composes its row on the host, and none otherwise.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_inert_pseudo_kinds(host: &DocumentHost, node: u32) -> u64 {
+pub extern "C" fn style_engine_inert_pseudo_kinds(host: &DocumentHost, node: u32) -> u64 {
host.transaction_pseudo_styles(node).map_or(0, |styles| styles.inert)
}
/// Whether a size container waits for layout to be evaluated, which the host knows without asking where it wrote
/// nothing since its last job.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_has_size_containers_needing_evaluation_after_layout(
+pub extern "C" fn style_engine_has_size_containers_needing_evaluation_after_layout(
host: &DocumentHost,
read: &BegunRead,
) -> bool {
@@ -1363,12 +1309,8 @@ pub(crate) fn absorb_element_style_input(
}
/// Notes that the host rewrote the declarations of `node`, which a batch of reactions being applied reads.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_note_element_declarations_changed(host: &DocumentHost, node: u32) {
+pub extern "C" fn style_engine_note_element_declarations_changed(host: &DocumentHost, node: u32) {
if let Some(node) = StyleNodeID::from_raw(node) {
host.engine_memo().note_declarations_changed(node);
}
@@ -1405,12 +1347,8 @@ impl<T: Copy> Memo<T> {
}
/// The engine's id of the native rule `identity` names, plus one, or 0 for none.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_native_rule_id(
+pub extern "C" fn style_engine_native_rule_id(
host: &DocumentHost,
read: &crate::render_state::BegunRead,
identity: u64,
diff --git a/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs b/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs
index d8b07b4d4ff..eed2f95311b 100644
--- a/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs
@@ -116,11 +116,8 @@ pub unsafe extern "C" fn document_host_intern_atom(host: &DocumentHost, raw: usi
/// How many times the engine reclaimed atoms the host interned, which tells apart what the host keyed by the atoms
/// before and after.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_atom_generation(host: &DocumentHost) -> u64 {
+pub extern "C" fn document_host_atom_generation(host: &DocumentHost) -> u64 {
host.engine_memo().atoms.borrow().generation
}
@@ -267,11 +264,8 @@ pub unsafe extern "C" fn document_host_intern_attribute_value(host: &DocumentHos
/// Whether the host knows that nothing reads what the values of the attribute name `name` spell, which spares it the
/// value's text.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_attribute_value_text_is_known_unread(host: &DocumentHost, name: u32) -> bool {
+pub extern "C" fn document_host_attribute_value_text_is_known_unread(host: &DocumentHost, name: u32) -> bool {
value_text_is_known_unread(host, StyleAtomID(name))
}
@@ -310,11 +304,8 @@ fn value_text_is_known_unread(host: &DocumentHost, name: StyleAtomID) -> bool {
/// Whether the host knows that nothing of the engine reads the attribute name `name`: no selector tests it, by `name` or
/// the other forms the host published with it, and no `attr()` reads it, by its local name if it has one. Where it does
/// not know, the host hands the engine each change to the attribute.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_attribute_is_known_unread(host: &DocumentHost, name: u32) -> bool {
+pub extern "C" fn document_host_attribute_is_known_unread(host: &DocumentHost, name: u32) -> bool {
let atoms = host.engine_memo().atoms.borrow();
let Some(PublishedAttributeName {
forms,
@@ -330,11 +321,8 @@ pub unsafe extern "C" fn document_host_attribute_is_known_unread(host: &Document
/// Whether the engine's requirements of attribute value text moved since the host last asked, which makes the host ask
/// again about the names it knew nothing read.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_refresh_attribute_value_text_requirements(
+pub extern "C" fn document_host_refresh_attribute_value_text_requirements(
host: &DocumentHost,
read: &BegunRead,
) -> bool {
diff --git a/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs b/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
index 1947ecac6f6..456ed206f42 100644
--- a/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
@@ -960,12 +960,8 @@ impl StyleEngine {
/// Takes the element the style node `target` names, or none for 0, as the element the hover of `host`'s document
/// targets, as the events of a mouse move hover it, and stages the move of the engine's hover to it for the input the
/// host submits next, where it moves. Answers whether it does.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_request_hover(host: &crate::render_state::DocumentHost, target: u32) -> bool {
+pub extern "C" fn style_engine_request_hover(host: &crate::render_state::DocumentHost, target: u32) -> bool {
let target = StyleNodeID::from_raw(target);
let moves = host.request_hover(target);
if moves {
diff --git a/Libraries/LibWeb/Rust/src/css/style/rule_writes.rs b/Libraries/LibWeb/Rust/src/css/style/rule_writes.rs
index aa2c55e22fc..7a9e3406d65 100644
--- a/Libraries/LibWeb/Rust/src/css/style/rule_writes.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/rule_writes.rs
@@ -388,11 +388,8 @@ pub(crate) fn publish_native_rule_declarations(
}
/// Adds a sheet to the document's style engine, which cascades in `origin`, and answers the number the host gave it.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_add_sheet(
+pub extern "C" fn style_engine_add_sheet(
host: &crate::render_state::DocumentHost,
object: u32,
origin: FfiCascadeOrigin,
@@ -403,14 +400,8 @@ pub unsafe extern "C" fn style_engine_add_sheet(
}
/// Begins to replace the rules of the sheet `sheet`, whose rules the host compiles again, or none.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_begin_sheet_rules_replacement(
- host: &crate::render_state::DocumentHost,
- sheet: u32,
-) {
+pub extern "C" fn style_engine_begin_sheet_rules_replacement(host: &crate::render_state::DocumentHost, sheet: u32) {
host.published_rules().forget(sheet);
host.write_rules(RuleWrite::BeginSheetRulesReplacement(sheet));
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/style_job.rs b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
index 7d3f4b3a5e4..6083c6315f5 100644
--- a/Libraries/LibWeb/Rust/src/css/style/style_job.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
@@ -405,12 +405,8 @@ pub unsafe extern "C" fn style_engine_let_style_transaction_fly(
/// Takes in the style transaction of `host`'s document that the host let fly, waiting for it to land, for the host to
/// drain its reactions against the inputs it was sealed with. What the host wrote beside the transaction reaches the
/// render state only once style_engine_end_flown_style_drain() ends the drain: it is the next transaction's.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, that let a style transaction fly.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_take_flown_style_transaction(
+pub extern "C" fn style_engine_take_flown_style_transaction(
host: &DocumentHost,
read: &BegunRead,
) -> FfiStyleTransactionView {
@@ -421,24 +417,16 @@ pub unsafe extern "C" fn style_engine_take_flown_style_transaction(
/// Ends the drain of the style transaction of `host`'s document that flew, behind which the writes the host made beside
/// it reach the render state.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, that drains a style transaction that flew.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_end_flown_style_drain(host: &DocumentHost) {
+pub extern "C" fn style_engine_end_flown_style_drain(host: &DocumentHost) {
host.engine_memo().beside_flown_transaction.borrow_mut().clear();
host.end_style_drain();
}
/// Notes that the element `node` names arrived, moved or retired beside the style transaction of `host`'s document that
/// flew, which knows nothing of that, until the drain of its reactions ends.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_note_style_node_beside_flown_transaction(host: &DocumentHost, node: u32) {
+pub extern "C" fn style_engine_note_style_node_beside_flown_transaction(host: &DocumentHost, node: u32) {
if let Some(node) = StyleNodeID::from_raw(node) {
host.engine_memo().beside_flown_transaction.borrow_mut().insert(node);
}
@@ -446,39 +434,23 @@ pub unsafe extern "C" fn style_engine_note_style_node_beside_flown_transaction(h
/// Whether the element `node` names arrived, moved or retired beside the style transaction of `host`'s document that
/// flew.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_style_node_is_beside_flown_transaction(host: &DocumentHost, node: u32) -> bool {
+pub extern "C" fn style_engine_style_node_is_beside_flown_transaction(host: &DocumentHost, node: u32) -> bool {
StyleNodeID::from_raw(node).is_some_and(|node| host.engine_memo().beside_flown_transaction.borrow().contains(&node))
}
/// Whether the frame whose style transaction `host`'s document drains applied the element `style_node` names its record
/// `style_record` ahead of the host, and marked the relayout the move asks for: the host's install of the row marks none
/// then.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_frame_marked_relayout(
- host: &DocumentHost,
- style_node: u32,
- style_record: u64,
-) -> bool {
+pub extern "C" fn style_engine_frame_marked_relayout(host: &DocumentHost, style_node: u32, style_record: u64) -> bool {
StyleNodeID::from_raw(style_node).is_some_and(|style_node| host.frame_marked_relayout(style_node, style_record))
}
/// Whether the style transaction of `host`'s document the host let fly still flies; one that has landed is taken in.
/// The event loop asks between two tasks, so this never waits.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, and the event loop must call this between two tasks.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_engine_style_transaction_flies(host: &DocumentHost) -> bool {
+pub extern "C" fn style_engine_style_transaction_flies(host: &DocumentHost) -> bool {
let boundary = TaskBoundary::at_event_loop_entry(&TAKES_FINISHED_STYLE_IN);
host.frame_still_flies(&boundary)
}
diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rs
index b06cbd379bf..ccd792051b5 100644
--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs
@@ -6585,11 +6585,8 @@ pub(crate) fn rust_box_type_transformation_input(
/// samples over the record the engine holds for it: the same input the engine drives the record
/// against, read from the element's published facts and its parent's record. A target the engine
/// does not know is transformed with no facts and no parent display.
-///
-/// # Safety
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_animated_box_type_transformation_input(
+pub extern "C" fn rust_animated_box_type_transformation_input(
host: &crate::render_state::DocumentHost,
read: &crate::render_state::BegunRead,
node: u32,
diff --git a/Libraries/LibWeb/Rust/src/css/style_sheet.rs b/Libraries/LibWeb/Rust/src/css/style_sheet.rs
index 9eaa7b24f42..316f6f10766 100644
--- a/Libraries/LibWeb/Rust/src/css/style_sheet.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_sheet.rs
@@ -770,7 +770,7 @@ mod tests {
rust_rule_list_remove(&first.rules, 0);
set_media(&first, "print, screen");
assert_eq!(rust_rule_list_count(&second.rules), 2);
- assert_eq!(unsafe { rust_media_list_length(&second.media) }, 1);
+ assert_eq!(rust_media_list_length(&second.media), 1);
assert_eq!(rust_rule_list_count(&sheet(&parsed).rules), 2);
drop(parsed);
@@ -780,7 +780,7 @@ mod tests {
let media = retained.media.clone();
drop(retained);
assert_eq!(rust_rule_list_count(&rules), 1);
- assert_eq!(unsafe { rust_media_list_length(&media) }, 2);
+ assert_eq!(rust_media_list_length(&media), 2);
}
fn layer_names(sheet: &NativeStyleSheet) -> Vec<Vec<u16>> {
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index fb408f6cea4..fb4496e708e 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -5849,7 +5849,7 @@ fn known_layout_is_up_to_date(
}
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_layout_is_up_to_date(host: &DocumentHost, document_style_node: u32) -> bool {
+pub extern "C" fn render_state_layout_is_up_to_date(host: &DocumentHost, document_style_node: u32) -> bool {
// A frame in flight, or a round that flew and is not paid yet, brings layout the host waits for. The document's
// layout tree update marks are the frame's, so they are read only once no frame holds them.
let Some(here) = host.layout_waits_for_no_frame() else {
@@ -5871,12 +5871,8 @@ pub unsafe extern "C" fn render_state_layout_is_up_to_date(host: &DocumentHost,
/// Whether the host knows, without asking, that the layout of `host`'s document is not up to date: a frame brings
/// layout it waits for, or what it knows of the render state says so.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_layout_is_known_stale(host: &DocumentHost, document_style_node: u32) -> bool {
+pub extern "C" fn render_state_layout_is_known_stale(host: &DocumentHost, document_style_node: u32) -> bool {
let Some(here) = host.layout_waits_for_no_frame() else {
return true;
};
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
index 08a2916ca3b..e3c095f34f0 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
@@ -172,11 +172,8 @@ pub unsafe extern "C" fn document_host_set_owned_image_provider(
host.host_tables().set_owned_image_provider(slot, provider);
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_owned_image_provider(host: &DocumentHost, slot: NodeSlotId) -> *mut c_void {
+pub extern "C" fn document_host_owned_image_provider(host: &DocumentHost, slot: NodeSlotId) -> *mut c_void {
host.host_tables().owned_image_provider(slot)
}
@@ -201,7 +198,7 @@ pub unsafe extern "C" fn document_host_replace_image_observers(
/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
// SAFETY: Guaranteed by the caller.
-pub unsafe extern "C" fn document_host_image_observers(host: &DocumentHost, slot: NodeSlotId) -> *mut c_void {
+pub extern "C" fn document_host_image_observers(host: &DocumentHost, slot: NodeSlotId) -> *mut c_void {
host.host_tables().image_observers(slot)
}
diff --git a/Libraries/LibWeb/Rust/src/layout/script_entries.rs b/Libraries/LibWeb/Rust/src/layout/script_entries.rs
index 2512268a7b0..ecb92ff0077 100644
--- a/Libraries/LibWeb/Rust/src/layout/script_entries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/script_entries.rs
@@ -144,11 +144,8 @@ pub unsafe extern "C" fn layout_script_intersection_observer_intersection_rect(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_can_compute_client_rects_without_visual_context_update(
+pub extern "C" fn layout_script_can_compute_client_rects_without_visual_context_update(
host: &DocumentHost,
layout_node: NodeSlotId,
viewport_scroll_offset_is_zero: bool,
@@ -220,12 +217,8 @@ pub unsafe extern "C" fn layout_script_text_range_rects(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, used on the document
-/// thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_text_caret_rect_in_dom_range(
+pub extern "C" fn layout_script_text_caret_rect_in_dom_range(
host: &DocumentHost,
primary: NodeSlotId,
offset: usize,
@@ -248,12 +241,8 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_in_dom_range(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, used on the document
-/// thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_text_caret_rect_for_position(
+pub extern "C" fn layout_script_text_caret_rect_for_position(
host: &DocumentHost,
primary: NodeSlotId,
offset: usize,
@@ -287,12 +276,8 @@ pub unsafe extern "C" fn layout_script_text_caret_rect_for_position(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, used on the document
-/// thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_atomic_inline_caret_rect_for_position(
+pub extern "C" fn layout_script_atomic_inline_caret_rect_for_position(
host: &DocumentHost,
primary: NodeSlotId,
after: bool,
@@ -321,12 +306,8 @@ pub unsafe extern "C" fn layout_script_atomic_inline_caret_rect_for_position(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, used on the document
-/// thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_empty_line_caret_rect(
+pub extern "C" fn layout_script_paintable_empty_line_caret_rect(
host: &DocumentHost,
block: NodeSlotId,
primary: NodeSlotId,
@@ -364,11 +345,8 @@ pub unsafe extern "C" fn layout_script_paintable_empty_line_caret_rect(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_absolute_rect(
+pub extern "C" fn layout_script_paintable_absolute_rect(
host: &DocumentHost,
slot: NodeSlotId,
out: &mut FfiCssPixelRect,
@@ -378,11 +356,8 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_rect(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_absolute_padding_box_rect(
+pub extern "C" fn layout_script_paintable_absolute_padding_box_rect(
host: &DocumentHost,
slot: NodeSlotId,
out: &mut FfiCssPixelRect,
@@ -396,11 +371,8 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_padding_box_rect(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_absolute_border_box_rect(
+pub extern "C" fn layout_script_paintable_absolute_border_box_rect(
host: &DocumentHost,
slot: NodeSlotId,
out: &mut FfiCssPixelRect,
@@ -414,13 +386,11 @@ pub unsafe extern "C" fn layout_script_paintable_absolute_border_box_rect(
});
}
-/// # Safety
-///
/// # Safety
///
/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_box_model(
+pub extern "C" fn layout_script_paintable_box_model(
host: &DocumentHost,
slot: NodeSlotId,
out: &mut FfiBoxModelMetrics,
@@ -438,11 +408,8 @@ pub unsafe extern "C" fn layout_script_paintable_box_model(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_paintable_content_size(
+pub extern "C" fn layout_script_paintable_content_size(
host: &DocumentHost,
slot: NodeSlotId,
out: &mut FfiCssPixelSize,
@@ -509,12 +476,8 @@ pub unsafe extern "C" fn layout_script_rendered_text(
/// The text the pseudo-element of kind `generated_for` on the element `style_node` resolved its generated content to
/// when its box was built, as a raw `AK::Utf16String` representation for which the caller takes one reference.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_script_generated_content_accessible_text(
+pub extern "C" fn layout_script_generated_content_accessible_text(
host: &DocumentHost,
style_node: u32,
generated_for: u8,
diff --git a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
index 640d2fad6fe..08df8534a3b 100644
--- a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
+++ b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
@@ -314,12 +314,8 @@ pub unsafe extern "C" fn layout_row_bound_viewport_shell(host: &DocumentHost, re
}
/// The read of the layout node the host holds, which the host lends the entries it calls about the node's document.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, of a layout node the host holds.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_read_of_held_node(host: &DocumentHost) -> *const BegunRead {
+pub extern "C" fn layout_row_read_of_held_node(host: &DocumentHost) -> *const BegunRead {
host.begun_read_of_held_node(node_read())
}
@@ -473,12 +469,8 @@ pub unsafe extern "C" fn layout_row_has_css_transform(host: &DocumentHost, id: N
/// The characters the generated text row `id` renders, as a raw `AK::Utf16String` representation for which the caller
/// takes one reference.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, and `id` a live generated text row.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_row_generated_text(host: &DocumentHost, id: NodeSlotId) -> usize {
+pub extern "C" fn layout_row_generated_text(host: &DocumentHost, id: NodeSlotId) -> usize {
let text = host.ask(node_read(), |state| {
state
.arena_mut()
diff --git a/Libraries/LibWeb/Rust/src/layout/text_queries.rs b/Libraries/LibWeb/Rust/src/layout/text_queries.rs
index 045c778d25c..6a5026aba71 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_queries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_queries.rs
@@ -442,13 +442,8 @@ pub(crate) fn find_matching_text(
/// The DOM range of the word at `dom_offset` in the text the rows of the text node whose primary row is `primary`
/// render, which input reads in `read` as it selects the word at a point.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, and the primary and its fragments live text rows
-/// with styled parents.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_text_word_range(
+pub extern "C" fn layout_text_word_range(
host: &crate::render_state::DocumentHost,
primary: NodeSlotId,
dom_offset: usize,
diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout.rs b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
index 6fe4065bfde..7162597ae3f 100644
--- a/Libraries/LibWeb/Rust/src/layout/update_layout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
@@ -1152,30 +1152,20 @@ pub unsafe extern "C" fn document_host_set_layout_update_host_callbacks(
host.host_tables().layout_update_host.set(Some(callbacks));
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, with no layout update running. A document runs
-/// one layout update at a time; a nested request is a caller bug.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_begin_update_layout(host: &DocumentHost) {
+pub extern "C" fn document_host_begin_update_layout(host: &DocumentHost) {
let running = &host.host_tables().update_layout_running;
assert!(!running.replace(true), "a layout update is already running");
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, with a layout update running.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_end_update_layout(host: &DocumentHost) {
+pub extern "C" fn document_host_end_update_layout(host: &DocumentHost) {
let running = &host.host_tables().update_layout_running;
assert!(running.replace(false), "no layout update is running");
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_update_layout_is_running(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_update_layout_is_running(host: &DocumentHost) -> bool {
host.host_tables().update_layout_running.get()
}
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index 40c592b6cf5..e1a4e58965b 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -1401,11 +1401,8 @@ pub unsafe extern "C" fn render_state_background_color_animation_keyframe_colors
}
}
-/// # Safety
-///
-/// The returned handle is owned by the caller until `compositor_animation_effect_state_destroy`.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn compositor_animation_effect_state_create() -> *mut c_void {
+pub extern "C" fn compositor_animation_effect_state_create() -> *mut c_void {
Box::into_raw(Box::new(
crate::painting::visual_animation_builder::CompositorAnimationEffectState::default(),
))
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 49331aefa14..3a89e95568a 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -423,12 +423,8 @@ pub unsafe extern "C" fn render_state_update_visual_viewport_transform(
}
/// Starts an update pass of the compositor animations of `host`'s document, with none published.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_begin_compositor_animation_update(host: &crate::render_state::DocumentHost) {
+pub extern "C" fn render_state_begin_compositor_animation_update(host: &crate::render_state::DocumentHost) {
host.begin_compositor_animation_update();
}
@@ -453,12 +449,8 @@ pub unsafe extern "C" fn compositor_animation_effect_publish_pending(
/// Ends the current update pass of the compositor animations of `host`'s document, and gives the visual context tree
/// what its effects published where `publish_pending`, or none.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_publish_compositor_animations(
+pub extern "C" fn render_state_publish_compositor_animations(
host: &crate::render_state::DocumentHost,
read: &crate::render_state::BegunRead,
publish_pending: bool,
@@ -1142,11 +1134,8 @@ pub unsafe extern "C" fn layout_hit_test_visit_chrome_widgets(
});
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_hit_test_list_generation(host: &crate::render_state::DocumentHost) -> u64 {
+pub extern "C" fn layout_hit_test_list_generation(host: &crate::render_state::DocumentHost) -> u64 {
let mut recording = host.recording();
recording.hit_test_list().as_ref().map_or(0, |list| list.generation)
}
@@ -1170,12 +1159,8 @@ pub unsafe extern "C" fn layout_paintable_event_dispatch_target(
}
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread;
-/// `index` in range.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_hit_test_item_facts(
+pub extern "C" fn layout_hit_test_item_facts(
host: &crate::render_state::DocumentHost,
read: &crate::render_state::BegunRead,
index: usize,
@@ -1203,12 +1188,8 @@ pub unsafe extern "C" fn layout_hit_test_item_facts(
.expect("no hit-test list");
}
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread;
-/// `item_index` must be in range for the current hit-test list.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_hit_test_resolve_hit(
+pub extern "C" fn layout_hit_test_resolve_hit(
host: &crate::render_state::DocumentHost,
read: &crate::render_state::BegunRead,
item_index: usize,
@@ -1390,12 +1371,8 @@ pub unsafe extern "C" fn layout_hit_test_caret_line_block_coordinate(
/// The style-tree identity of the first `<area>` of the image's map, in tree order, whose shape
/// covers the point. Zero when the image has no map, or when no shape covers the point.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn layout_image_map_area_for_point(
+pub extern "C" fn layout_image_map_area_for_point(
host: &crate::render_state::DocumentHost,
slot: NodeSlotId,
x: f32,
diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rs
index 15fb1953ded..8d296ced667 100644
--- a/Libraries/LibWeb/Rust/src/render_state.rs
+++ b/Libraries/LibWeb/Rust/src/render_state.rs
@@ -1048,18 +1048,18 @@ mod tests {
};
// SAFETY: The host is live, on this thread.
- unsafe { document_host_note_paint_preparation_is_current(host) };
+ document_host_note_paint_preparation_is_current(host);
measure();
// SAFETY: As above.
- assert!(!unsafe { document_host_paint_preparation_is_current(host) });
+ assert!(!document_host_paint_preparation_is_current(host));
assert!(arena.scrollable_overflow.scrollability_changed.get());
// A read that measures nothing leaves the preparation as it is.
// SAFETY: As above.
- unsafe { document_host_note_paint_preparation_is_current(host) };
+ document_host_note_paint_preparation_is_current(host);
measure();
// SAFETY: As above.
- assert!(unsafe { document_host_paint_preparation_is_current(host) });
+ assert!(document_host_paint_preparation_is_current(host));
arena
.free_subtree(viewport)
@@ -1079,7 +1079,7 @@ mod tests {
document_host_note_paint_preparation_is_current(host);
render_state_mark_node_box(host, 1, FfiBoxMarks::default());
}
- assert!(unsafe { document_host_paint_preparation_is_current(host) });
+ assert!(document_host_paint_preparation_is_current(host));
}
#[test]
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rs
index 78edabaaa11..6ea32b97e62 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs
@@ -1608,34 +1608,22 @@ pub unsafe extern "C" fn clock_ticks_release(ticks: *const ClockTicks) {
/// A reference to the ticks the render clock hands the lanes of `host`'s document, which the caller releases with
/// `clock_ticks_release`.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_clock_ticks(host: &DocumentHost) -> *const ClockTicks {
+pub extern "C" fn document_host_clock_ticks(host: &DocumentHost) -> *const ClockTicks {
Arc::into_raw(Arc::clone(host.clock_ticks()))
}
/// Drops the plan of the lane of the frame `host`'s document presented last, for the rendering update with the serial
/// number `update`, which leaves it none. The plan is the host's, so this reads nothing of the render state.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_drop_clock_plan(host: &DocumentHost, update: u64) {
+pub extern "C" fn document_host_drop_clock_plan(host: &DocumentHost, update: u64) {
host.seal_clock_plan(None, update);
}
/// Notes that script changed an animation of `host`'s document: the animations of the plans sealed before no longer
/// stand, and the lanes' hover goes on.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_note_animation_change(host: &DocumentHost) {
+pub extern "C" fn document_host_note_animation_change(host: &DocumentHost) {
host.clock_ticks().note_animation_change();
}
@@ -1646,50 +1634,30 @@ pub unsafe extern "C" fn document_host_note_animation_change(host: &DocumentHost
/// the update's serial number, which its plan seals with. `outer_input_event` is the input event id of the newest
/// pointer move the document around a same-process iframe's knows of, or 0: what the iframe's lanes did with an older
/// move is stale.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_take_clock_lanes_in(
- host: &DocumentHost,
- update: u64,
- outer_input_event: u64,
-) -> bool {
+pub extern "C" fn document_host_take_clock_lanes_in(host: &DocumentHost, update: u64, outer_input_event: u64) -> bool {
host.take_clock_lanes_in(update, outer_input_event)
}
/// Whether the lanes of `host`'s document may hover or run transitions beside the tasks: the last plan the host sealed for
/// them was one.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_may_have_lanes(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_may_have_lanes(host: &DocumentHost) -> bool {
host.may_have_lanes()
}
/// The input event id of the newest pointer move `host`'s document knows of, from a mouse event it handled or from the
/// compositor.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_newest_pointer_input_event(host: &DocumentHost) -> u64 {
+pub extern "C" fn document_host_newest_pointer_input_event(host: &DocumentHost) -> u64 {
host.newest_pointer_input_event()
}
/// Whether the lanes of `host`'s document wait for the rendering update that took them in to seal its plan, presenting
/// nothing until then, where they would present frames beside a task: they sample running animations, or the pointer
/// is over the document, which they hover as it moves.
-///
-/// # Safety
-///
-/// `host` must name a live document host.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_lanes_wait_for_the_update(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_lanes_wait_for_the_update(host: &DocumentHost) -> bool {
let ticks = host.clock_ticks();
host.lanes_wait_for_the_update()
&& (ticks.plan_animates() || ticks.newest_pointer().is_some_and(|pointer| pointer.position.is_some()))
@@ -1698,24 +1666,15 @@ pub unsafe extern "C" fn document_host_lanes_wait_for_the_update(host: &Document
/// Notes whether the event loop of `host`'s document begins a task or goes idle: beside an idle event loop the lanes
/// sample no animations, which its rendering updates run. Answers whether a task begins whose lanes sample the
/// animations of the last plan the host sealed, for the caller to tick them at once.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_note_event_loop_task(host: &DocumentHost, runs_task: bool) -> bool {
+pub extern "C" fn document_host_note_event_loop_task(host: &DocumentHost, runs_task: bool) -> bool {
host.note_event_loop_task(runs_task)
}
/// Takes the boundary events a hover kept by a rendering update owes, where the host handled no mouse move since, and
/// answers whether it owes any: `has_pointer` is set with `pointer_x`, `pointer_y` where the pointer was, in the
/// context's device pixels, and not where it left the context.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread, and the pointers
-/// must be valid for writes.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_take_hover_events_owed(
+pub extern "C" fn document_host_take_hover_events_owed(
host: &DocumentHost,
has_pointer: &mut bool,
pointer_x: &mut f32,
@@ -1740,12 +1699,8 @@ pub unsafe extern "C" fn document_host_take_hover_events_owed(
/// id `input_event_id`, as the rendering update handling it took the lanes in, and writes the style node id of the
/// element the lane hovered there to `target`, or 0 for none: that is the element the screen shows the hover on, which
/// the host's events hover in place of the one its own layout has under the pointer.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_lane_hover_target_for(
+pub extern "C" fn document_host_lane_hover_target_for(
host: &DocumentHost,
input_event_id: u64,
target: &mut u32,
@@ -1759,45 +1714,29 @@ pub unsafe extern "C" fn document_host_lane_hover_target_for(
/// Holds the lanes of `host`'s document for a recording of the host's own that adds to the resource storage they
/// present with, until `document_host_release_clock_lane`: they present nothing meanwhile.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_hold_clock_lane(host: &DocumentHost) {
+pub extern "C" fn document_host_hold_clock_lane(host: &DocumentHost) {
host.clock_ticks().hold();
}
/// Releases a hold of `document_host_hold_clock_lane`.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_release_clock_lane(host: &DocumentHost) {
+pub extern "C" fn document_host_release_clock_lane(host: &DocumentHost) {
host.clock_ticks().release();
}
/// What the lane of the frame `host`'s document presented last does, once the lane of a frame presented by then has
/// come together. For a test.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_clock_lane_state(host: &DocumentHost) -> FfiClockLaneState {
+pub extern "C" fn document_host_clock_lane_state(host: &DocumentHost) -> FfiClockLaneState {
settle_lanes_for_testing();
host.clock_ticks().lane_state()
}
/// Whether the lane of a frame `host`'s document sampled after the one it presented last has yet to come together, once
/// the lane of a frame presented by then has come together. For a test.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_clock_lane_is_coming(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_clock_lane_is_coming(host: &DocumentHost) -> bool {
settle_lanes_for_testing();
host.clock_ticks().published().awaits_lane
}
@@ -1867,12 +1806,8 @@ pub unsafe extern "C" fn document_host_presented_color(
/// Whether the mouse event with the input event id `input_event_id` is older than the newest pointer move `host`'s
/// document knows of, and notes the id of one that is not, which the host handles: an older event moves neither the
/// hover nor the pointer.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_mouse_event_is_outdated(host: &DocumentHost, input_event_id: u64) -> bool {
+pub extern "C" fn document_host_mouse_event_is_outdated(host: &DocumentHost, input_event_id: u64) -> bool {
let outdated = host.mouse_event_is_outdated(input_event_id);
if outdated && hover::logs_hover() {
eprintln!(
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
index 628eba27a5d..83209996aac 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
@@ -1444,12 +1444,8 @@ pub unsafe extern "C" fn clock_ticks_pointer_moved(
/// Hands the clock lanes of `host`'s document a pointer move to `x`, `y` in device pixels, as the compositor would,
/// beside the mouse event with the input event id `input_event_id`, or none for 0, which the next tick hovers. For a
/// test, whose clock ticks only where it injects them.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_move_pointer(
+pub extern "C" fn document_host_move_pointer(
host: &crate::render_state::DocumentHost,
x: f32,
y: f32,
@@ -1466,12 +1462,8 @@ pub unsafe extern "C" fn document_host_move_pointer(
/// Hands the clock lanes of `host`'s document a pointer move to `x`, `y` in device pixels, beside the mouse event with
/// the input event id `input_event_id`, or none for 0, ticks them at `frame_time_nanoseconds`, and waits until the
/// StyleLayout thread has run the tick and the Paint thread the recording of the frame it presents. For a test.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_inject_pointer(
+pub extern "C" fn document_host_inject_pointer(
host: &crate::render_state::DocumentHost,
x: f32,
y: f32,
diff --git a/Libraries/LibWeb/Rust/src/render_state/devtools.rs b/Libraries/LibWeb/Rust/src/render_state/devtools.rs
index c68699c19f4..f93dafc3676 100644
--- a/Libraries/LibWeb/Rust/src/render_state/devtools.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/devtools.rs
@@ -35,12 +35,8 @@ pub(crate) struct DevtoolsEntry {
const DEVTOOLS_ENTRY: DevtoolsEntry = DevtoolsEntry { _private: () };
/// Makes the render state of `host`'s document panic answering this call, which waits for it.
-///
-/// # Safety
-///
-/// `host` must come from `document_host_create` and not be destroyed yet, on the document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_panic_for_testing(host: &DocumentHost) {
+pub extern "C" fn render_state_panic_for_testing(host: &DocumentHost) {
host.run(ScriptForcedRead::at_script_entry(&DEVTOOLS_ENTRY), false, |_| {
panic!("the render state panicked for a test")
});
@@ -54,12 +50,8 @@ fn read_arena<R>(host: &DocumentHost, read: impl FnOnce(&LayoutNodeArena) -> R)
}
/// How many layout passes, tree builds and measurements the document's layout has run, and how many rows it holds.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_layout_counts(host: &DocumentHost) -> FfiLayoutCounts {
+pub extern "C" fn render_state_layout_counts(host: &DocumentHost) -> FfiLayoutCounts {
read_arena(host, |arena| {
let tree_builds = arena.layout_tree_build_stats();
FfiLayoutCounts {
@@ -78,12 +70,8 @@ pub unsafe extern "C" fn render_state_layout_counts(host: &DocumentHost) -> FfiL
}
/// How many rows of the layout subtree `root` heads carry a pre-order label no greater than the row before them.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_pre_order_label_violation_count(host: &DocumentHost, root: NodeSlotId) -> u64 {
+pub extern "C" fn render_state_pre_order_label_violation_count(host: &DocumentHost, root: NodeSlotId) -> u64 {
read_arena(host, |arena| {
if !arena.slot_is_live(root) {
return 0;
@@ -102,12 +90,8 @@ pub unsafe extern "C" fn render_state_pre_order_label_violation_count(host: &Doc
}
/// How many times paint preparation recalculated scrollable overflow, counting from zero again where `reset`.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_scrollable_overflow_recalculation_count(host: &DocumentHost, reset: bool) -> u64 {
+pub extern "C" fn render_state_scrollable_overflow_recalculation_count(host: &DocumentHost, reset: bool) -> u64 {
read_arena(host, |arena| {
let recalculations = &arena.scrollable_overflow.recalculations;
if reset {
@@ -119,12 +103,8 @@ pub unsafe extern "C" fn render_state_scrollable_overflow_recalculation_count(ho
}
/// How many boxes wait for their visual context to be updated.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_visual_context_pending_dirty_box_count(host: &DocumentHost) -> usize {
+pub extern "C" fn render_state_visual_context_pending_dirty_box_count(host: &DocumentHost) -> usize {
read_arena(host, |arena| {
arena.paint_state().borrow().visual_context.dirty_boxes.boxes.len()
})
@@ -153,11 +133,7 @@ pub unsafe extern "C" fn render_state_stacking_context_structure_verification_re
}
/// How many layout nodes the host made for the rows of its document.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_shell_count(host: &DocumentHost) -> u32 {
+pub extern "C" fn render_state_shell_count(host: &DocumentHost) -> u32 {
host.host_tables().shells.borrow().len() as u32
}
diff --git a/Libraries/LibWeb/Rust/src/render_state/document_host.rs b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
index ea5bad7142d..dff982aa1e2 100644
--- a/Libraries/LibWeb/Rust/src/render_state/document_host.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
@@ -1332,23 +1332,15 @@ impl Drop for TestHost {
/// Whether the paint and hit testing properties of `host`'s document were prepared from its render state as it is, so
/// that preparing them again would find nothing to do: the host noted them current as it began to prepare them, and
/// wrote nothing to the render state since, queued, in place or by a job.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_paint_preparation_is_current(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_paint_preparation_is_current(host: &DocumentHost) -> bool {
host.paint_preparation_is_current.get()
}
/// Notes that the paint and hit testing properties of `host`'s document are current, as the host begins to prepare them:
/// they stay current until the host writes to the render state.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_note_paint_preparation_is_current(host: &DocumentHost) {
+pub extern "C" fn document_host_note_paint_preparation_is_current(host: &DocumentHost) {
host.paint_preparation_is_current.set(true);
}
@@ -1362,13 +1354,8 @@ pub struct FfiReadScopeView {
/// What a scope of a read of the render state of `host`'s document reads of `host`, which stays where it is for as long
/// as `host` lives.
-///
-/// # Safety
-///
-/// `host` must come from [`document_host_create`] and not be destroyed yet, and what this answers is read on its
-/// document's thread only, until the host is destroyed.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_read_scope_view(host: &DocumentHost) -> FfiReadScopeView {
+pub extern "C" fn document_host_read_scope_view(host: &DocumentHost) -> FfiReadScopeView {
FfiReadScopeView {
waits_for_frame: host.waits_for_frame.as_ptr(),
read: std::ptr::from_ref(&host.begun_read),
@@ -1376,33 +1363,21 @@ pub unsafe extern "C" fn document_host_read_scope_view(host: &DocumentHost) -> F
}
/// Whether the frame of `host`'s document flies, where the host has not taken it in yet, whether or not it landed.
-///
-/// # Safety
-///
-/// `host` must come from [`document_host_create`] and not be destroyed yet, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_frame_flies(host: &DocumentHost) -> bool {
+pub extern "C" fn document_host_frame_flies(host: &DocumentHost) -> bool {
host.frame_flies()
}
/// Sets the writes `host` queued aside, for the host to read its document's render state as the frame that flew last
/// left it, until document_host_queue_writes_set_aside() queues them behind the writes it queued meanwhile.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread, with no writes set aside.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_set_writes_aside(host: &DocumentHost) {
+pub extern "C" fn document_host_set_writes_aside(host: &DocumentHost) {
host.set_writes_aside();
}
/// Queues the writes `host` set aside behind the writes it queued meanwhile.
-///
-/// # Safety
-///
-/// `host` must be a live document host, on its document's thread.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn document_host_queue_writes_set_aside(host: &DocumentHost) {
+pub extern "C" fn document_host_queue_writes_set_aside(host: &DocumentHost) {
host.queue_writes_set_aside();
}