Truly independent web browser
LibWeb: Take FFI pointer parameters as references where possible
Andreas Kling8d0217037c2f
diff --git a/Libraries/LibWeb/Rust/src/css/animated_overlay.rs b/Libraries/LibWeb/Rust/src/css/animated_overlay.rsindex 1c2853836ea..ca8330146ca 100644--- a/Libraries/LibWeb/Rust/src/css/animated_overlay.rs+++ b/Libraries/LibWeb/Rust/src/css/animated_overlay.rs@@ -184,38 +184,26 @@ pub extern "C" fn rust_animated_overlay_create() -> *mut AnimatedOverlay {}))}-/// # Safety-/// `overlay` must be a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_animated_overlay_is_empty(overlay: *const AnimatedOverlay) -> bool {- unsafe { &*overlay }.is_empty()+pub extern "C" fn rust_animated_overlay_is_empty(overlay: &AnimatedOverlay) -> bool {+ overlay.is_empty()}/// Returns a new overlay holding retained copies of `overlay`'s entries.-///-/// # Safety-/// `overlay` must be a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_animated_overlay_clone(overlay: *const AnimatedOverlay) -> *mut AnimatedOverlay {- Box::into_raw(Box::new(unsafe { &*overlay }.clone()))+pub extern "C" fn rust_animated_overlay_clone(overlay: &AnimatedOverlay) -> *mut AnimatedOverlay {+ Box::into_raw(Box::new(overlay.clone()))}/// Returns a new overlay holding retained copies of `overlay`'s inherited entries.-///-/// # Safety-/// `overlay` must be a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_animated_overlay_clone_inherited(- overlay: *const AnimatedOverlay,-) -> *mut AnimatedOverlay {- Box::into_raw(Box::new(unsafe { &*overlay }.clone_inherited()))+pub extern "C" fn rust_animated_overlay_clone_inherited(overlay: &AnimatedOverlay) -> *mut AnimatedOverlay {+ Box::into_raw(Box::new(overlay.clone_inherited()))}-/// # Safety-/// `overlay` must be a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_animated_overlay_contains(overlay: *const AnimatedOverlay, property: u16) -> bool {- unsafe { &*overlay }.get(property).is_some()+pub extern "C" fn rust_animated_overlay_contains(overlay: &AnimatedOverlay, property: u16) -> bool {+ overlay.get(property).is_some()}/// # Safety@@ -252,26 +240,23 @@ pub unsafe extern "C" fn rust_animated_overlay_set(/// the overlay or a subsequent mutation.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_animated_overlay_entries(- overlay: *const AnimatedOverlay,+ overlay: &AnimatedOverlay,count: *mut usize,) -> *const FfiAnimatedOverlayEntry {- let entries = &unsafe { &*overlay }.entries;+ let entries = &overlay.entries;unsafe { *count = entries.len() };entries.as_ptr()}/// The overlay's effective value for a longhand under the overlay read rule,/// or null when the overlay holds no entry or the important base value wins.-///-/// # Safety-/// `overlay` must be a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_animated_overlay_effective_value(- overlay: *const AnimatedOverlay,+pub extern "C" fn rust_animated_overlay_effective_value(+ overlay: &AnimatedOverlay,property: u16,base_value_is_important: bool,) -> *const c_void {- unsafe { &*overlay }+ overlay.get(property).filter(|entry| overlay_wins(entry, base_value_is_important)).map_or(std::ptr::null(), FfiAnimatedOverlayEntry::value_pointer)diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex 409e55b5b08..a6f1cabc38e 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -180,11 +180,11 @@ pub(crate) unsafe fn style_value_from_easing(descriptor: &FfiEasingDescriptor) -/// descriptor kind is linear.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_evaluate_easing(- descriptor: *const FfiEasingDescriptor,+ descriptor: &FfiEasingDescriptor,input_progress: f64,before_flag: bool,) -> f64 {- evaluate_easing_descriptor(unsafe { &*descriptor }, input_progress, before_flag)+ evaluate_easing_descriptor(descriptor, input_progress, before_flag)}/// Describes the easing a computed timing function value names, appending a linear easing's@@ -7466,20 +7466,13 @@ pub(crate) unsafe fn evaluate_animations(computed: *const FfiComputedAnimationBa/// `StyleValueData` allocations.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_interpolate_scalar_style_value(- context: *const FfiAnimationContext,+ context: Option<&FfiAnimationContext>,property_id: u16,- from: *const StyleValueData,- to: *const StyleValueData,+ from: &StyleValueData,+ to: &StyleValueData,delta: f32,) -> FfiAnimationValueResult {- interpolate_value(- unsafe { context.as_ref() },- property_id,- unsafe { &*from },- unsafe { &*to },- delta,- )- .into_ffi()+ interpolate_value(context, property_id, from, to, delta).into_ffi()}/// Test-only bridge for exercising Rust-owned style value composition without constructing an@@ -7489,11 +7482,11 @@ pub unsafe extern "C" fn rust_interpolate_scalar_style_value(/// `underlying` and `animated` must point at live `StyleValueData` allocations.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_test_composite_style_value(- underlying: *const StyleValueData,- animated: *const StyleValueData,+ underlying: &StyleValueData,+ animated: &StyleValueData,operation: FfiCompositeOperation,) -> FfiAnimationValueResult {- composite_scalar_value(unsafe { &*underlying }, unsafe { &*animated }, operation).into_ffi()+ composite_scalar_value(underlying, animated, operation).into_ffi()}#[cfg(test)]diff --git a/Libraries/LibWeb/Rust/src/css/calc.rs b/Libraries/LibWeb/Rust/src/css/calc.rsindex 537c17db36d..26515068760 100644--- a/Libraries/LibWeb/Rust/src/css/calc.rs+++ b/Libraries/LibWeb/Rust/src/css/calc.rs@@ -529,12 +529,12 @@ pub enum FfiNumericTypeMatch {pub unsafe extern "C" fn rust_numeric_type_operate(operation: FfiNumericTypeOperation,first: *const FfiNumericType,- second: *const FfiNumericType,+ second: &FfiNumericType,) -> FfiNumericType {let first = unsafe { &*first }.to_calc();let result = match operation {- FfiNumericTypeOperation::Add => first.added_to(&unsafe { &*second }.to_calc()),- FfiNumericTypeOperation::Multiply => first.multiplied_by(&unsafe { &*second }.to_calc()),+ FfiNumericTypeOperation::Add => first.added_to(&second.to_calc()),+ FfiNumericTypeOperation::Multiply => first.multiplied_by(&second.to_calc()),FfiNumericTypeOperation::Invert => Some(first.inverted()),};FfiNumericType::from_calc(result)@@ -1178,23 +1178,20 @@ pub unsafe extern "C" fn rust_calc_node_retain(node: *const CalcNode) {/// `node` must be a valid calculation node pointer.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_calc_node_determine_type(- node: *const CalcNode,+ node: &CalcNode,has_percentages_resolve_as: bool,resolve_as_is_number: bool,resolve_as_base: u8,) -> FfiNumericType {let resolve_as = resolve_as_from_fields(has_percentages_resolve_as, resolve_as_is_number, resolve_as_base);let percentage_leaf_type = percentage_leaf_type_for(resolve_as);- FfiNumericType::from_calc(unsafe { &*node }.numeric_type(&percentage_leaf_type))+ FfiNumericType::from_calc(node.numeric_type(&percentage_leaf_type))}/// Whether any leaf of the calculation is a percentage.-///-/// # Safety-/// `node` must be a valid calculation node pointer.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_calc_node_contains_percentage(node: *const CalcNode) -> bool {- unsafe { &*node }.contains_percentage()+pub extern "C" fn rust_calc_node_contains_percentage(node: &CalcNode) -> bool {+ node.contains_percentage()}/// What percentages resolve against in the surrounding context.diff --git a/Libraries/LibWeb/Rust/src/css/computed_longhand_table.rs b/Libraries/LibWeb/Rust/src/css/computed_longhand_table.rsindex cae8369c7ce..d394125784a 100644--- a/Libraries/LibWeb/Rust/src/css/computed_longhand_table.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_longhand_table.rs@@ -1406,16 +1406,13 @@ pub unsafe extern "C" fn rust_computed_longhand_table_release(table: *mut Comput/// Creates a frozen copy of `table` with every inherited longhand value taken/// from `inherited_source`.-///-/// # Safety-/// Both pointers must name live, frozen tables.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_create_with_inherited_values(- table: *const ComputedLonghandTable,- inherited_source: *const ComputedLonghandTable,+pub extern "C" fn rust_computed_longhand_table_create_with_inherited_values(+ table: &ComputedLonghandTable,+ inherited_source: &ComputedLonghandTable,) -> *mut ComputedLonghandTable {- unsafe { &*table }- .with_inherited_values_from(unsafe { &*inherited_source })+ table+ .with_inherited_values_from(inherited_source).into_raw_shared().cast_mut()}@@ -1430,7 +1427,7 @@ pub unsafe extern "C" fn rust_computed_longhand_table_create_with_inherited_valu/// point at live `StyleValueData`.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_computed_longhand_table_set(- table: *mut ComputedLonghandTable,+ table: &mut ComputedLonghandTable,property_id: u16,data: *const c_void,source_slot: i64,@@ -1438,21 +1435,17 @@ pub unsafe extern "C" fn rust_computed_longhand_table_set(let value = unsafe {RetainedStyleValueData::from_retained_pointer(crate::css::style_value::retain_style_value(data.cast()))};- unsafe { &mut *table }.set(property_id, value, source_slot);+ table.set(property_id, value, source_slot);}/// Replaces the table's contents with `source`'s, for the C++ builder that/// starts from an existing style's property array.-///-/// # Safety-/// `table` must be a valid, unfrozen, uniquely owned table and `source` a-/// valid table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_copy_from(- table: *mut ComputedLonghandTable,- source: *const ComputedLonghandTable,+pub extern "C" fn rust_computed_longhand_table_copy_from(+ table: &mut ComputedLonghandTable,+ source: &ComputedLonghandTable,) {- unsafe { &mut *table }.copy_from(unsafe { &*source });+ table.copy_from(source);}/// Replaces the table's values with a complete borrowed value span, retaining@@ -1465,12 +1458,12 @@ pub unsafe extern "C" fn rust_computed_longhand_table_copy_from(/// live `StyleValueData`.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_computed_longhand_table_copy_from_values(- table: *mut ComputedLonghandTable,+ table: &mut ComputedLonghandTable,values: *const *const c_void,count: usize,) {let values = unsafe { std::slice::from_raw_parts(values, count) };- unsafe { &mut *table }.copy_from_values(values);+ table.copy_from_values(values);}/// Returns the table's value span: one borrowed data pointer per longhand,@@ -1489,48 +1482,32 @@ pub unsafe extern "C" fn rust_computed_longhand_table_values(}/// Whether two frozen tables have equal values and publication metadata.-///-/// # Safety-/// Both pointers must name live, frozen tables.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_tables_equal_for_publication(- first: *const ComputedLonghandTable,- second: *const ComputedLonghandTable,+pub extern "C" fn rust_computed_longhand_tables_equal_for_publication(+ first: &ComputedLonghandTable,+ second: &ComputedLonghandTable,) -> bool {- unsafe { &*first }.publication_equals(unsafe { &*second })+ first.publication_equals(second)}/// Makes the table immutable; every later store aborts. Only a frozen table/// may be shared through `rust_computed_longhand_table_retain`.-///-/// # Safety-/// `table` must be a valid, uniquely owned table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_freeze(table: *mut ComputedLonghandTable) {- unsafe { &mut *table }.freeze();+pub extern "C" fn rust_computed_longhand_table_freeze(table: &mut ComputedLonghandTable) {+ table.freeze();}/// The importance bitmap, in the C++ `FixedBitmap` byte layout. The pointer/// stays valid while the caller's table reference is live.-///-/// # Safety-/// `table` must be a valid table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_importance_bits(- table: *const ComputedLonghandTable,-) -> *const u8 {- unsafe { &*table }.important_bits.as_ptr()+pub extern "C" fn rust_computed_longhand_table_importance_bits(table: &ComputedLonghandTable) -> *const u8 {+ table.important_bits.as_ptr()}/// The inheritance bitmap, in the C++ `FixedBitmap` byte layout.-///-/// # Safety-/// `table` must be a valid table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_inheritance_bits(- table: *const ComputedLonghandTable,-) -> *const u8 {- unsafe { &*table }.inherited_bits.as_ptr()+pub extern "C" fn rust_computed_longhand_table_inheritance_bits(table: &ComputedLonghandTable) -> *const u8 {+ table.inherited_bits.as_ptr()}/// Replaces the whole importance and inheritance bitmaps, for the builder@@ -1557,12 +1534,9 @@ pub unsafe extern "C" fn rust_computed_longhand_table_load_flag_bitmaps(/// Resets the state a fresh drive must not inherit from the style its table/// was seeded from: the evaluated bits and the recorded inheritance-dependent/// specified values.-///-/// # Safety-/// `table` must be a valid, unfrozen, uniquely owned table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_clear_seeded_state(table: *mut ComputedLonghandTable) {- unsafe { &mut *table }.clear_seeded_state();+pub extern "C" fn rust_computed_longhand_table_clear_seeded_state(table: &mut ComputedLonghandTable) {+ table.clear_seeded_state();}/// Records (or replaces) a longhand's inheritance-dependent specified value,@@ -1573,26 +1547,22 @@ pub unsafe extern "C" fn rust_computed_longhand_table_clear_seeded_state(table:/// point at live style value data.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_computed_longhand_table_add_inheritance_dependent_value(- table: *mut ComputedLonghandTable,+ table: &mut ComputedLonghandTable,property_id: u16,value: *const c_void,) {let value = unsafe {RetainedStyleValueData::from_retained_pointer(crate::css::style_value::retain_style_value(value.cast()))};- unsafe { &mut *table }.add_inheritance_dependent_value(property_id, value);+ table.add_inheritance_dependent_value(property_id, value);}/// Returns the non-longhand computation state stored alongside the table.-///-/// # Safety-/// `table` must be a valid, uniquely owned table when the returned view is-/// mutated. The view remains valid for the lifetime of the table.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_metadata(- table: *mut ComputedLonghandTable,+pub extern "C" fn rust_computed_longhand_table_metadata(+ table: &mut ComputedLonghandTable,) -> *mut FfiComputedStyleMetadata {- &raw mut unsafe { &mut *table }.metadata+ &raw mut table.metadata}/// The recorded inheritance-dependent specified values as a borrowed span.@@ -1612,32 +1582,26 @@ pub unsafe extern "C" fn rust_computed_longhand_table_inheritance_dependent_valu}/// The non-inherited groups whose inheritance-dependent source values changed.-///-/// # Safety-/// Both pointers must name live computed longhand tables.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_non_inherited_inheritance_changes(- old: *const ComputedLonghandTable,- new: *const ComputedLonghandTable,+pub extern "C" fn rust_computed_longhand_table_non_inherited_inheritance_changes(+ old: &ComputedLonghandTable,+ new: &ComputedLonghandTable,) -> u32 {- unsafe { &*old }.non_inherited_inheritance_changes(unsafe { &*new })+ old.non_inherited_inheritance_changes(new)}/// The effective value for one longhand: the animated overlay under the/// overlay read rule (important base values override animated but not/// transitioned properties), then an unevaluated longhand's recorded/// currentcolor-dependent specified value, then the stored table slot.-///-/// # Safety-/// `table` must be a valid table and `overlay` null or a valid overlay.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_computed_longhand_table_effective_value(- table: *const ComputedLonghandTable,- overlay: *const AnimatedOverlay,+pub extern "C" fn rust_computed_longhand_table_effective_value(+ table: &ComputedLonghandTable,+ overlay: Option<&AnimatedOverlay>,property_id: u16,with_animations: bool,) -> FfiEffectiveLonghandValue {- unsafe { &*table }.effective_value(unsafe { overlay.as_ref() }, property_id, with_animations)+ table.effective_value(overlay, property_id, with_animations)}#[cfg(test)]diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rsindex 36631aa1078..bade1c65748 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs@@ -99,14 +99,7 @@ impl LengthPercentageRef<'_> {match self.value {StyleValueData::Length { .. } => false,StyleValueData::Percentage { .. } => true,- StyleValueData::Calculated { .. } => {- // SAFETY: The calculated style value outlives this borrowed- // view, and the root query takes no other state.- let root = unsafe { calc::calc_root_from_calculated(self.calculated_pointer()) };- assert!(!root.is_null());- // SAFETY: The root borrows the same retained calculation.- unsafe { calc::rust_calc_node_contains_percentage(root) }- }+ StyleValueData::Calculated { rust_calculation, .. } => rust_calculation.node().contains_percentage(),_ => unreachable!("computed length-percentage holds a non-length-percentage style value"),}}diff --git a/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/query_parser.rsindex 316ee4587d2..a3c01a4f48e 100644--- a/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs@@ -2882,8 +2882,8 @@ pub unsafe extern "C" fn css_query_unref(handle: *const FfiQueryHandle) {/// # Safety/// `handle` must point to a live supports-expression handle.#[unsafe(no_mangle)]-pub unsafe extern "C" fn css_query_evaluate_supports(handle: *const FfiQueryHandle) -> u8 {- unsafe { handle.as_ref() }+pub unsafe extern "C" fn css_query_evaluate_supports(handle: Option<&FfiQueryHandle>) -> u8 {+ handle.and_then(FfiQueryHandle::evaluate_supports).map_or(3, |result| result as u8)}@@ -3299,7 +3299,7 @@ mod tests {},};- assert_eq!(unsafe { css_query_evaluate_supports(std::ptr::null()) }, 3);- assert_eq!(unsafe { css_query_evaluate_supports(&raw const handle) }, 3);+ assert_eq!(unsafe { css_query_evaluate_supports(None) }, 3);+ assert_eq!(unsafe { css_query_evaluate_supports(Some(&handle)) }, 3);}}diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rsindex fba77920c5b..65ce56f0351 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs@@ -3739,15 +3739,12 @@ pub unsafe extern "C" fn rust_page_selector_list_serialize(}/// Retains a normalized declaration block from parsed block contents, ignoring rules.-///-/// # Safety-/// `parse` must be a live result of `rust_parse_css_block_syntax`.#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_css_syntax_parse_declaration_block(- parse: *const ParsedStyleSheet,+pub extern "C" fn rust_css_syntax_parse_declaration_block(+ parse: &ParsedStyleSheet,) -> *mut crate::css::declaration_block::DeclarationBlock {use crate::css::declaration_block::DeclarationBlock;- let parsed = unsafe { &*parse };+ let parsed = parse;let declarations = declaration_block_from_blocks(parsed.items.iter().filter_map(|item| match item {ParsedRuleChild::Declarations(list) => list.declaration_block.as_ref(),ParsedRuleChild::Rule(_) => None,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.rsindex 8ec5f588259..eca32568cb0 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@@ -549,15 +549,9 @@ fn import_preludes_outlive_the_worker_and_shared_sheet() {assert!(unlayered.layer.is_none());assert!(unlayered.supports.is_none());unsafe {- assert_eq!(- css_query_evaluate_supports(Arc::as_ptr(named.supports.as_ref().unwrap())),- 1- );- assert_eq!(- css_query_evaluate_supports(Arc::as_ptr(anonymous.supports.as_ref().unwrap())),- 0- );- assert_eq!(css_query_evaluate_supports(Arc::as_ptr(&supports)), 1);+ assert_eq!(css_query_evaluate_supports(named.supports.as_deref()), 1);+ assert_eq!(css_query_evaluate_supports(anonymous.supports.as_deref()), 0);+ assert_eq!(css_query_evaluate_supports(Some(&*supports)), 1);}assert_eq!(serialize_style_value_to_utf16(&named.url).unwrap(),@@ -829,7 +823,7 @@ fn independent_workers_read_the_same_immutable_graph() {1);assert_eq!(- css_query_evaluate_supports(Arc::as_ptr(sheet.rules[1].supports_condition.as_ref().unwrap())),+ css_query_evaluate_supports(sheet.rules[1].supports_condition.as_deref()),1);}diff --git a/Libraries/LibWeb/Rust/src/css/rule.rs b/Libraries/LibWeb/Rust/src/css/rule.rsindex f45e9bc8a4a..8c162365e72 100644--- a/Libraries/LibWeb/Rust/src/css/rule.rs+++ b/Libraries/LibWeb/Rust/src/css/rule.rs@@ -838,9 +838,9 @@ pub extern "C" fn rust_rule_containing_function(rule: &NativeRule) -> *const Natpub unsafe extern "C" fn rust_rule_set_selector_text(rule: &NativeRule,input: FfiUtf16View,- sheet_rules: *const NativeRuleList,+ sheet_rules: Option<&NativeRuleList>,) -> bool {- unsafe { input.units() }.is_some_and(|input| rule.set_selector_text(input, unsafe { sheet_rules.as_ref() }))+ unsafe { input.units() }.is_some_and(|input| rule.set_selector_text(input, sheet_rules))}#[unsafe(no_mangle)]diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex ccd792051b5..44f3689fb6b 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -394,14 +394,15 @@ pub(crate) fn absolutize_length(value: f64, unit: usize, context: &FfiLengthReso/// Absolutizes a length during style computation.////// # Safety-/// `context` must be a valid pointer.+/// `context.resolved_viewport_relative_length` must be null or point to a live flag, which the+/// absolutization may set.#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_absolutize_length(value: f64,unit: u8,- context: *const FfiLengthResolutionContext,+ context: &FfiLengthResolutionContext,) -> FfiAbsolutizedLength {- absolutize_length(value, unit as usize, unsafe { &*context })+ absolutize_length(value, unit as usize, context)}/// Result of computing a property that resolves to a number.@@ -2256,9 +2257,6 @@ fn value_contains_percentage(value: &StyleValueData) -> bool {/// inheritance-dependency decision; the property-agnostic parts/// (depends-on-current-color and computational independence) stay with the/// value's own operations.-///-/// # Safety-/// `value` must point at a valid StyleValueData.pub(crate) fn value_depends_on_inherited_info_for_property(value: &StyleValueData, property_id: u16) -> bool {use crate::css::property_metadata::property_id as prop;match property_id {@@ -7117,16 +7115,11 @@ fn finalize_animated_box_type(#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_finalize_animated_box_type(box_type: FfiBoxTypeTransformationInput,- longhand_table: *const ComputedLonghandTable,- animated_overlay: *mut AnimatedOverlay,- input_line_height_metrics: *const FfiInputLineHeightMetrics,+ longhand_table: &ComputedLonghandTable,+ animated_overlay: &mut AnimatedOverlay,+ input_line_height_metrics: Option<&FfiInputLineHeightMetrics>,) {- finalize_animated_box_type(- box_type,- unsafe { &*longhand_table },- unsafe { &mut *animated_overlay },- unsafe { input_line_height_metrics.as_ref() },- );+ finalize_animated_box_type(box_type, longhand_table, animated_overlay, input_line_height_metrics);}/// Computes the font-weight property from its absolutized value.diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rsindex 0cd603f4a17..3e8fd585254 100644--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs@@ -841,14 +841,7 @@ fn transform_number(data: &StyleValueData) -> f64 {fn value_contains_percentage(data: &StyleValueData) -> bool {match data {StyleValueData::Percentage { .. } => true,- StyleValueData::Calculated { .. } => {- // SAFETY: The calculated style value outlives the query.- unsafe {- let root = crate::css::calc::calc_root_from_calculated(std::ptr::from_ref(data).cast());- assert!(!root.is_null());- crate::css::calc::rust_calc_node_contains_percentage(root)- }- }+ StyleValueData::Calculated { rust_calculation, .. } => rust_calculation.node().contains_percentage(),_ => false,}}diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rsindex ecdc19aa6f6..def26381715 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs@@ -1421,11 +1421,11 @@ pub unsafe extern "C" fn compositor_animation_effect_reset(state: *mut c_void) {#[unsafe(no_mangle)]pub unsafe extern "C" fn compositor_animation_effect_only_translates_horizontally(request: *const crate::painting::host::FfiCompositorAnimationRequest,- host: *const crate::painting::host::FfiCompositorAnimationHost,+ host: &crate::painting::host::FfiCompositorAnimationHost,) -> bool {use crate::painting::visual_animation_builder::{Host, Request, effect_only_translates_horizontally};let request = unsafe { Request::new(&*request) };- effect_only_translates_horizontally(&request, &Host::new(unsafe { &*host }))+ effect_only_translates_horizontally(&request, &Host::new(host))}/// # Safety@@ -1434,11 +1434,11 @@ pub unsafe extern "C" fn compositor_animation_effect_only_translates_horizontall#[unsafe(no_mangle)]pub unsafe extern "C" fn compositor_animation_effect_transform_preserves_axes(request: *const crate::painting::host::FfiCompositorAnimationRequest,- host: *const crate::painting::host::FfiCompositorAnimationHost,+ host: &crate::painting::host::FfiCompositorAnimationHost,) -> bool {use crate::painting::visual_animation_builder::{Host, Request, effect_transform_preserves_axes};let request = unsafe { Request::new(&*request) };- effect_transform_preserves_axes(&request, &Host::new(unsafe { &*host }))+ effect_transform_preserves_axes(&request, &Host::new(host))}/// Starts an update pass: the effects publish into an empty document list.diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rsindex 6ea32b97e62..623830a6f81 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs@@ -1754,11 +1754,11 @@ pub extern "C" fn document_host_clock_lane_is_coming(host: &DocumentHost) -> boopub unsafe extern "C" fn document_host_inject_clock_tick(host: &DocumentHost,frame_time_nanoseconds: i64,- scroll_offset: *const FfiScrollOffset,+ scroll_offset: Option<&FfiScrollOffset>,) {settle_lanes_for_testing();// SAFETY: Guaranteed by the caller.- let scroll_offsets = unsafe { scroll_offset.as_ref() }.map_or(&[][..], std::slice::from_ref);+ let scroll_offsets = scroll_offset.map_or(&[][..], std::slice::from_ref);host.clock_ticks().tick(frame_time_nanoseconds, scroll_offsets);settle_lanes_for_testing();}