Truly independent web browser
LibWeb: Remove comments and blocks left over from unsafe removal
Andreas Kling2d90a1b69a46
diff --git a/Libraries/LibWeb/Rust/src/css/absolutize.rs b/Libraries/LibWeb/Rust/src/css/absolutize.rsindex e5e67bb1525..3746dbc846c 100644--- a/Libraries/LibWeb/Rust/src/css/absolutize.rs+++ b/Libraries/LibWeb/Rust/src/css/absolutize.rs@@ -255,9 +255,7 @@ pub(crate) enum Absolutized {}fn retain_new(value: StyleValueData) -> RetainedStyleValueData {- let pointer = RetainedStyleValueData::from_arc(Arc::new(value));- // SAFETY: The freshly leaked Arc reference is exactly one strong reference.- pointer+ RetainedStyleValueData::from_arc(Arc::new(value))}/// Absolutizes one retained child slot. Returns the child for the rebuilt parent, whether any@@ -307,7 +305,6 @@ fn currentcolor_keyword() -> StyleValueData {// ColorStyleValue.h: ColorSyntax::Legacy = 0, Modern = 1.fn retained_null() -> RetainedStyleValueData {- // SAFETY: null encodes an absent optional value.RetainedStyleValueData::none()}diff --git a/Libraries/LibWeb/Rust/src/css/color_resolution.rs b/Libraries/LibWeb/Rust/src/css/color_resolution.rsindex 4324b0aa914..f267946c85c 100644--- a/Libraries/LibWeb/Rust/src/css/color_resolution.rs+++ b/Libraries/LibWeb/Rust/src/css/color_resolution.rs@@ -882,13 +882,10 @@ pub(crate) fn resolve_alpha(style_value: &StyleValueData, input: &ColorResolutio// Shared-graph retained-value constructors, mirroring make_result() in color_interpolation.rs.fn retained_value(value: StyleValueData) -> RetainedStyleValueData {- let pointer = RetainedStyleValueData::from_arc(Arc::new(value));- // SAFETY: Arc::into_raw transfers exactly one strong reference.- pointer+ RetainedStyleValueData::from_arc(Arc::new(value))}fn retained_null() -> RetainedStyleValueData {- // SAFETY: null encodes an absent optional value.RetainedStyleValueData::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 3c33ef08508..70f8e981878 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@@ -548,11 +548,9 @@ fn import_preludes_outlive_the_worker_and_shared_sheet() {assert!(anonymous.layer.as_ref().unwrap().units().is_empty());assert!(unlayered.layer.is_none());assert!(unlayered.supports.is_none());- {- 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!(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(),utf16("url(\"a.css\")")diff --git a/Libraries/LibWeb/Rust/src/css/rule/compilation.rs b/Libraries/LibWeb/Rust/src/css/rule/compilation.rsindex 1a25ceb9fb8..f58d66667bd 100644--- a/Libraries/LibWeb/Rust/src/css/rule/compilation.rs+++ b/Libraries/LibWeb/Rust/src/css/rule/compilation.rs@@ -1350,7 +1350,6 @@ mod tests {prepare,)});- // SAFETY: The test host lives until the end of the test.let next = host.host().published_rules()diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rsindex 10143eb4fc4..ca82f822e87 100644--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs@@ -1227,7 +1227,6 @@ pub unsafe extern "C" fn style_engine_set_tree_scope_animation_keyframes(shadow_root_identity,row,};- // SAFETY: Guaranteed by the caller.super::engine_calls::queue(host, write);}@@ -1256,7 +1255,6 @@ pub unsafe extern "C" fn style_engine_note_custom_property_environment(inheritable,inheritable_store: retain(inheritable_store),};- // SAFETY: Guaranteed by the caller.super::engine_calls::queue(host, write);}@@ -1736,7 +1734,6 @@ pub unsafe extern "C" fn style_engine_set_element_inline_style_properties(// SAFETY: Guaranteed by the caller.let data = unsafe { block.cast::<DeclarationBlock>().as_ref() }.map(DeclarationBlock::data);let has_transitions = data.as_ref().is_some_and(|data| declares_transitions(&data.properties));- // SAFETY: Guaranteed by the caller.super::engine_calls::queue(host, super::engine_calls::EngineWrite::InlineStyle { node, data });has_transitions}@@ -1772,17 +1769,14 @@ pub unsafe extern "C" fn style_engine_set_element_presentational_hint_propertieshints.append_in_specified_order(unsafe { declaration_from_view(property) });}let has_transitions = declares_transitions(&hints.properties);- // SAFETY: Guaranteed by the caller.- {- super::engine_calls::queue(- host,- super::engine_calls::EngineWrite::PresentationalHints {- node,- kind,- properties: hints.properties.into_boxed_slice(),- },- );- }+ super::engine_calls::queue(+ host,+ super::engine_calls::EngineWrite::PresentationalHints {+ node,+ kind,+ properties: hints.properties.into_boxed_slice(),+ },+ );has_transitions}@@ -2290,7 +2284,6 @@ unsafe fn publish_sampled_animation_overlay(// A pseudo-element the engine holds no assignment for owns no overlay slot, so the record is published again// whole, with the overlay over the same base.None => {- // SAFETY: The base record stays live for the call.let base = style_record_view(engine, input.style_record);// SAFETY: Guaranteed by the caller, and the base's arrays are live.unsafe {@@ -2318,7 +2311,6 @@ unsafe fn publish_sampled_animation_overlay(Ok(FfiAnimationOverlayPublication {invalidation,publication,- // SAFETY: The published record is live.view: style_record_view(engine, publication.new_style_record),rebuilt_every_group: rebuilt.every_group,})@@ -2365,7 +2357,6 @@ pub extern "C" fn style_engine_style_record_view(if let Some(view) = super::engine_calls::known_style_record_view(host, style_record) {return view;}- // SAFETY: Guaranteed by the caller.let view = with_engine(read, host, |engine| style_record_view(engine, style_record));if view.present {host.engine_memo().views.set(style_record, view);@@ -2401,8 +2392,6 @@ pub extern "C" fn style_engine_remove_computed_pseudo(node: u32,pseudo_kind: u8,) -> FfiStyleRecordDelta {- // SAFETY: Guaranteed by the caller.- // SAFETY: Guaranteed by the caller.with_engine(read, host, |engine| remove_computed_pseudo(engine, node, pseudo_kind))}@@ -2686,8 +2675,6 @@ pub extern "C" fn style_engine_settle_pseudo_records_after_host_record(node: u32,old_is_list_item: bool,) -> FfiSettledPseudoRecords {- // SAFETY: Guaranteed by the caller.- // SAFETY: Guaranteed by the caller.with_engine(read, host, |engine| {settle_pseudo_records_after_host_record(engine, node, old_is_list_item)})diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rsindex 8479ec52c23..47c2e47ba06 100644--- a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs+++ b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs@@ -658,16 +658,13 @@ pub extern "C" fn style_engine_park_element_random_base_values(host: &DocumentHoreturn std::ptr::null();}let slot = ParkedBaseValues::default();- // SAFETY: Guaranteed by the caller.- {- queue(- host,- EngineWrite::ParkRandomBaseValues {- node,- slot: Arc::clone(&slot),- },- );- }+ queue(+ host,+ EngineWrite::ParkRandomBaseValues {+ node,+ slot: Arc::clone(&slot),+ },+ );Arc::into_raw(slot).cast()}@@ -710,7 +707,6 @@ pub extern "C" fn style_engine_answer_record_demand(node: u32,demand: FfiRecordDemand,) -> FfiRecordDemandAnswer {- // SAFETY: Guaranteed by the caller.ask_record_demand(host, read, node, RecordDemand::Element(demand))}@@ -723,7 +719,6 @@ pub extern "C" fn style_engine_answer_pseudo_element_record_demand(demand: FfiPseudoElementRecordDemand,pseudo_element: FfiDemandedPseudoElement,) -> FfiRecordDemandAnswer {- // SAFETY: Guaranteed by the caller.ask_record_demand(host, read, node, RecordDemand::PseudoElement(demand, pseudo_element))}diff --git a/Libraries/LibWeb/Rust/src/css/style/style_job.rs b/Libraries/LibWeb/Rust/src/css/style/style_job.rsindex 8591e296a44..9a8732c8a22 100644--- a/Libraries/LibWeb/Rust/src/css/style/style_job.rs+++ b/Libraries/LibWeb/Rust/src/css/style/style_job.rs@@ -294,7 +294,6 @@ impl StyleJob {let records = records.into_iter().filter_map(|record| {- // SAFETY: The view points into the record, which stays live while the rows name it.let view = super::bridge::style_record_view(engine, record);view.present.then(|| {let environment = enginediff --git a/Libraries/LibWeb/Rust/src/css/style_sheet.rs b/Libraries/LibWeb/Rust/src/css/style_sheet.rsindex 6794556080f..b6bd6d2ddb5 100644--- a/Libraries/LibWeb/Rust/src/css/style_sheet.rs+++ b/Libraries/LibWeb/Rust/src/css/style_sheet.rs@@ -526,7 +526,6 @@ pub unsafe extern "C" fn rust_style_sheet_evaluate_media_queries(let result = sheet.evaluate_media_queries(unsafe { environment.borrow() }, state, &mut |identity, holds| {conditions.push((identity, holds));});- // SAFETY: Guaranteed by the caller.write_rule_conditions(host, conditions);result}@@ -546,7 +545,6 @@ pub unsafe extern "C" fn rust_style_sheet_publish_conditions(sheet.visit_conditions(unsafe { environment.borrow() }, true, &mut |identity, holds| {conditions.push((identity, holds));});- // SAFETY: Guaranteed by the caller.write_rule_conditions(host, conditions);}diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rsindex 65e16d26683..e0a2d2d1b4a 100644--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs@@ -1286,27 +1286,25 @@ fn build_transform_group(let perspective_origin_x = position_offset(edge_x);let perspective_origin_y = position_offset(edge_y);- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::TRANSFORM,- &entries,- |payload: &mut TransformValues| {- payload.transformations = transform_list;- payload.resolved_transforms = RetainedComputedResolvedTransformList::from_vec(resolved);- payload.transform_origin_x = transform_origin_x;- payload.transform_origin_y = transform_origin_y;- payload.transform_origin_z = transform_origin_z;- payload.rotate = rotate;- payload.translate = translate;- payload.scale = scale;- payload.has_perspective = has_perspective;- payload.perspective_px = perspective_px;- payload.perspective_origin_x = perspective_origin_x;- payload.perspective_origin_y = perspective_origin_y;- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::TRANSFORM,+ &entries,+ |payload: &mut TransformValues| {+ payload.transformations = transform_list;+ payload.resolved_transforms = RetainedComputedResolvedTransformList::from_vec(resolved);+ payload.transform_origin_x = transform_origin_x;+ payload.transform_origin_y = transform_origin_y;+ payload.transform_origin_z = transform_origin_z;+ payload.rotate = rotate;+ payload.translate = translate;+ payload.scale = scale;+ payload.has_perspective = has_perspective;+ payload.perspective_px = perspective_px;+ payload.perspective_origin_x = perspective_origin_x;+ payload.perspective_origin_y = perspective_origin_y;+ },+ parent,+ )}/// The shared prefix of every color style value variant.@@ -1578,33 +1576,29 @@ fn build_effects_group(filter_list: backdrop_list,operations: RetainedComputedFilterOperationList::from_vec(backdrop_operations),};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::EFFECTS,- &entries,- |payload: &mut EffectsValues| {- payload.filter = filter;- payload.backdrop_filter = backdrop_filter;- payload.box_shadows = RetainedComputedShadowList::from_vec(shadows);- payload.clip_is_rect = clip_is_rect;- payload.clip_edges = clip_edges;- payload.opacity_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::OPACITY));- payload.filter_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::FILTER));- payload.backdrop_filter_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::BACKDROP_FILTER));- payload.mix_blend_mode_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::MIX_BLEND_MODE));- payload.isolation_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::ISOLATION));- payload.box_shadow_style_value =- ComputedStyleValueHandle::from_retained(values.handle(property_id::BOX_SHADOW));- payload.clip_style_value = ComputedStyleValueHandle::from_retained(values.handle(property_id::CLIP));- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::EFFECTS,+ &entries,+ |payload: &mut EffectsValues| {+ payload.filter = filter;+ payload.backdrop_filter = backdrop_filter;+ payload.box_shadows = RetainedComputedShadowList::from_vec(shadows);+ payload.clip_is_rect = clip_is_rect;+ payload.clip_edges = clip_edges;+ payload.opacity_style_value = ComputedStyleValueHandle::from_retained(values.handle(property_id::OPACITY));+ payload.filter_style_value = ComputedStyleValueHandle::from_retained(values.handle(property_id::FILTER));+ payload.backdrop_filter_style_value =+ ComputedStyleValueHandle::from_retained(values.handle(property_id::BACKDROP_FILTER));+ payload.mix_blend_mode_style_value =+ ComputedStyleValueHandle::from_retained(values.handle(property_id::MIX_BLEND_MODE));+ payload.isolation_style_value =+ ComputedStyleValueHandle::from_retained(values.handle(property_id::ISOLATION));+ payload.box_shadow_style_value =+ ComputedStyleValueHandle::from_retained(values.handle(property_id::BOX_SHADOW));+ payload.clip_style_value = ComputedStyleValueHandle::from_retained(values.handle(property_id::CLIP));+ },+ parent,+ )}// --- Border lowering -------------------------------------------------------@@ -1668,27 +1662,25 @@ fn build_background_group(.and_then(crate::css::css_enums::keyword_to_background_box).expect("a computed background-clip keyword maps to its enum");- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::BACKGROUND,- &entries,- |payload: &mut BackgroundValues| {- payload.background_color = background_color;- payload.background_color_style_value = retained(property_id::BACKGROUND_COLOR);- payload.background_color_clip = background_color_clip;- payload.background_image = retained(property_id::BACKGROUND_IMAGE);- payload.background_attachment = retained(property_id::BACKGROUND_ATTACHMENT);- payload.background_blend_mode = retained(property_id::BACKGROUND_BLEND_MODE);- payload.background_clip = retained(property_id::BACKGROUND_CLIP);- payload.background_origin = retained(property_id::BACKGROUND_ORIGIN);- payload.background_position_x = retained(property_id::BACKGROUND_POSITION_X);- payload.background_position_y = retained(property_id::BACKGROUND_POSITION_Y);- payload.background_repeat = retained(property_id::BACKGROUND_REPEAT);- payload.background_size = retained(property_id::BACKGROUND_SIZE);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::BACKGROUND,+ &entries,+ |payload: &mut BackgroundValues| {+ payload.background_color = background_color;+ payload.background_color_style_value = retained(property_id::BACKGROUND_COLOR);+ payload.background_color_clip = background_color_clip;+ payload.background_image = retained(property_id::BACKGROUND_IMAGE);+ payload.background_attachment = retained(property_id::BACKGROUND_ATTACHMENT);+ payload.background_blend_mode = retained(property_id::BACKGROUND_BLEND_MODE);+ payload.background_clip = retained(property_id::BACKGROUND_CLIP);+ payload.background_origin = retained(property_id::BACKGROUND_ORIGIN);+ payload.background_position_x = retained(property_id::BACKGROUND_POSITION_X);+ payload.background_position_y = retained(property_id::BACKGROUND_POSITION_Y);+ payload.background_repeat = retained(property_id::BACKGROUND_REPEAT);+ payload.background_size = retained(property_id::BACKGROUND_SIZE);+ },+ parent,+ )}/// Builds the mask group from retained canonical computed values.@@ -1702,25 +1694,23 @@ fn build_mask_group(return std::ptr::null();};let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::MASK,- &entries,- |payload: &mut MaskValues| {- payload.mask_image = retained(property_id::MASK_IMAGE);- payload.mask_type = retained(property_id::MASK_TYPE);- payload.clip_path = retained(property_id::CLIP_PATH);- payload.mask_mode = retained(property_id::MASK_MODE);- payload.mask_repeat = retained(property_id::MASK_REPEAT);- payload.mask_position = retained(property_id::MASK_POSITION);- payload.mask_clip = retained(property_id::MASK_CLIP);- payload.mask_origin = retained(property_id::MASK_ORIGIN);- payload.mask_size = retained(property_id::MASK_SIZE);- payload.mask_composite = retained(property_id::MASK_COMPOSITE);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::MASK,+ &entries,+ |payload: &mut MaskValues| {+ payload.mask_image = retained(property_id::MASK_IMAGE);+ payload.mask_type = retained(property_id::MASK_TYPE);+ payload.clip_path = retained(property_id::CLIP_PATH);+ payload.mask_mode = retained(property_id::MASK_MODE);+ payload.mask_repeat = retained(property_id::MASK_REPEAT);+ payload.mask_position = retained(property_id::MASK_POSITION);+ payload.mask_clip = retained(property_id::MASK_CLIP);+ payload.mask_origin = retained(property_id::MASK_ORIGIN);+ payload.mask_size = retained(property_id::MASK_SIZE);+ payload.mask_composite = retained(property_id::MASK_COMPOSITE);+ },+ parent,+ )}/// Builds the border group from layout-facing side facts and retained@@ -1778,69 +1768,67 @@ fn build_border_group(}};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::BORDER,- &entries,- |payload: &mut BorderValues| {- payload.border_left = side(- property_id::BORDER_LEFT_STYLE,- property_id::BORDER_LEFT_WIDTH,- property_id::BORDER_LEFT_COLOR,- );- payload.border_top = side(- property_id::BORDER_TOP_STYLE,- property_id::BORDER_TOP_WIDTH,- property_id::BORDER_TOP_COLOR,- );- payload.border_right = side(- property_id::BORDER_RIGHT_STYLE,- property_id::BORDER_RIGHT_WIDTH,- property_id::BORDER_RIGHT_COLOR,- );- payload.border_bottom = side(- property_id::BORDER_BOTTOM_STYLE,- property_id::BORDER_BOTTOM_WIDTH,- property_id::BORDER_BOTTOM_COLOR,- );- payload.border_left_color_style_value = retained(property_id::BORDER_LEFT_COLOR);- payload.border_top_color_style_value = retained(property_id::BORDER_TOP_COLOR);- payload.border_right_color_style_value = retained(property_id::BORDER_RIGHT_COLOR);- payload.border_bottom_color_style_value = retained(property_id::BORDER_BOTTOM_COLOR);- payload.border_left_computed_width = length_to_css_pixels(- values- .value(property_id::BORDER_LEFT_WIDTH)- .expect("border-left-width has a computed value"),- );- payload.border_top_computed_width = length_to_css_pixels(- values- .value(property_id::BORDER_TOP_WIDTH)- .expect("border-top-width has a computed value"),- );- payload.border_right_computed_width = length_to_css_pixels(- values- .value(property_id::BORDER_RIGHT_WIDTH)- .expect("border-right-width has a computed value"),- );- payload.border_bottom_computed_width = length_to_css_pixels(- values- .value(property_id::BORDER_BOTTOM_WIDTH)- .expect("border-bottom-width has a computed value"),- );- payload.border_bottom_left_radius = retained(property_id::BORDER_BOTTOM_LEFT_RADIUS);- payload.border_bottom_right_radius = retained(property_id::BORDER_BOTTOM_RIGHT_RADIUS);- payload.border_top_left_radius = retained(property_id::BORDER_TOP_LEFT_RADIUS);- payload.border_top_right_radius = retained(property_id::BORDER_TOP_RIGHT_RADIUS);- payload.has_noninitial_border_radii = has_noninitial_border_radii;- payload.border_image_source = retained(property_id::BORDER_IMAGE_SOURCE);- payload.border_image_slice = retained(property_id::BORDER_IMAGE_SLICE);- payload.border_image_width = retained(property_id::BORDER_IMAGE_WIDTH);- payload.border_image_outset = retained(property_id::BORDER_IMAGE_OUTSET);- payload.border_image_repeat = retained(property_id::BORDER_IMAGE_REPEAT);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::BORDER,+ &entries,+ |payload: &mut BorderValues| {+ payload.border_left = side(+ property_id::BORDER_LEFT_STYLE,+ property_id::BORDER_LEFT_WIDTH,+ property_id::BORDER_LEFT_COLOR,+ );+ payload.border_top = side(+ property_id::BORDER_TOP_STYLE,+ property_id::BORDER_TOP_WIDTH,+ property_id::BORDER_TOP_COLOR,+ );+ payload.border_right = side(+ property_id::BORDER_RIGHT_STYLE,+ property_id::BORDER_RIGHT_WIDTH,+ property_id::BORDER_RIGHT_COLOR,+ );+ payload.border_bottom = side(+ property_id::BORDER_BOTTOM_STYLE,+ property_id::BORDER_BOTTOM_WIDTH,+ property_id::BORDER_BOTTOM_COLOR,+ );+ payload.border_left_color_style_value = retained(property_id::BORDER_LEFT_COLOR);+ payload.border_top_color_style_value = retained(property_id::BORDER_TOP_COLOR);+ payload.border_right_color_style_value = retained(property_id::BORDER_RIGHT_COLOR);+ payload.border_bottom_color_style_value = retained(property_id::BORDER_BOTTOM_COLOR);+ payload.border_left_computed_width = length_to_css_pixels(+ values+ .value(property_id::BORDER_LEFT_WIDTH)+ .expect("border-left-width has a computed value"),+ );+ payload.border_top_computed_width = length_to_css_pixels(+ values+ .value(property_id::BORDER_TOP_WIDTH)+ .expect("border-top-width has a computed value"),+ );+ payload.border_right_computed_width = length_to_css_pixels(+ values+ .value(property_id::BORDER_RIGHT_WIDTH)+ .expect("border-right-width has a computed value"),+ );+ payload.border_bottom_computed_width = length_to_css_pixels(+ values+ .value(property_id::BORDER_BOTTOM_WIDTH)+ .expect("border-bottom-width has a computed value"),+ );+ payload.border_bottom_left_radius = retained(property_id::BORDER_BOTTOM_LEFT_RADIUS);+ payload.border_bottom_right_radius = retained(property_id::BORDER_BOTTOM_RIGHT_RADIUS);+ payload.border_top_left_radius = retained(property_id::BORDER_TOP_LEFT_RADIUS);+ payload.border_top_right_radius = retained(property_id::BORDER_TOP_RIGHT_RADIUS);+ payload.has_noninitial_border_radii = has_noninitial_border_radii;+ payload.border_image_source = retained(property_id::BORDER_IMAGE_SOURCE);+ payload.border_image_slice = retained(property_id::BORDER_IMAGE_SLICE);+ payload.border_image_width = retained(property_id::BORDER_IMAGE_WIDTH);+ payload.border_image_outset = retained(property_id::BORDER_IMAGE_OUTSET);+ payload.border_image_repeat = retained(property_id::BORDER_IMAGE_REPEAT);+ },+ parent,+ )}// --- SVG, list and content lowering -----------------------------------------@@ -1987,26 +1975,23 @@ fn build_inherited_svg_group(.and_then(keyword_of).and_then(crate::css::css_enums::keyword_to_baseline_metric);- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::INHERITED_SVG,- &entries,- |payload: &mut InheritedSVGValues| {- payload.fill = lower_svg_paint(values, property_id::FILL, input);- payload.stroke = lower_svg_paint(values, property_id::STROKE, input);- payload.stroke_dasharray = RetainedComputedSvgDashList::from_vec(dashes);- payload.stroke_dashoffset =- lower_svg_length_percentage_or_number(values, property_id::STROKE_DASHOFFSET);- payload.stroke_width = lower_svg_length_percentage_or_number(values, property_id::STROKE_WIDTH);- payload.paint_order = order;- payload.paint_order_serialization_length = serialization_length;- payload.paint_order_is_normal = is_normal;- payload.has_dominant_baseline = dominant_baseline.is_some();- payload.dominant_baseline = dominant_baseline.unwrap_or(0);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::INHERITED_SVG,+ &entries,+ |payload: &mut InheritedSVGValues| {+ payload.fill = lower_svg_paint(values, property_id::FILL, input);+ payload.stroke = lower_svg_paint(values, property_id::STROKE, input);+ payload.stroke_dasharray = RetainedComputedSvgDashList::from_vec(dashes);+ payload.stroke_dashoffset = lower_svg_length_percentage_or_number(values, property_id::STROKE_DASHOFFSET);+ payload.stroke_width = lower_svg_length_percentage_or_number(values, property_id::STROKE_WIDTH);+ payload.paint_order = order;+ payload.paint_order_serialization_length = serialization_length;+ payload.paint_order_is_normal = is_normal;+ payload.has_dominant_baseline = dominant_baseline.is_some();+ payload.dominant_baseline = dominant_baseline.unwrap_or(0);+ },+ parent,+ )}/// Builds the inherited list group from canonical values without leaving@@ -2025,24 +2010,22 @@ fn build_inherited_list_group(return std::ptr::null();};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::INHERITED_LIST,- &entries,- |payload: &mut InheritedListValues| {- let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));- payload.list_style_type = retained(property_id::LIST_STYLE_TYPE);- payload.list_style_position = values- .value(property_id::LIST_STYLE_POSITION)- .and_then(keyword_of)- .and_then(crate::css::css_enums::keyword_to_list_style_position)- .expect("a computed list-style-position maps to its enum");- payload.list_style_image = retained(property_id::LIST_STYLE_IMAGE);- payload.quotes = retained(property_id::QUOTES);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::INHERITED_LIST,+ &entries,+ |payload: &mut InheritedListValues| {+ let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));+ payload.list_style_type = retained(property_id::LIST_STYLE_TYPE);+ payload.list_style_position = values+ .value(property_id::LIST_STYLE_POSITION)+ .and_then(keyword_of)+ .and_then(crate::css::css_enums::keyword_to_list_style_position)+ .expect("a computed list-style-position maps to its enum");+ payload.list_style_image = retained(property_id::LIST_STYLE_IMAGE);+ payload.quotes = retained(property_id::QUOTES);+ },+ parent,+ )}/// Builds the content group from its canonical values without leaving Rust.@@ -2060,20 +2043,18 @@ fn build_content_group(return std::ptr::null();};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::CONTENT,- &entries,- |payload: &mut ContentValues| {- let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));- payload.content = retained(property_id::CONTENT);- payload.counter_increment = retained(property_id::COUNTER_INCREMENT);- payload.counter_reset = retained(property_id::COUNTER_RESET);- payload.counter_set = retained(property_id::COUNTER_SET);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::CONTENT,+ &entries,+ |payload: &mut ContentValues| {+ let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));+ payload.content = retained(property_id::CONTENT);+ payload.counter_increment = retained(property_id::COUNTER_INCREMENT);+ payload.counter_reset = retained(property_id::COUNTER_RESET);+ payload.counter_set = retained(property_id::COUNTER_SET);+ },+ parent,+ )}// --- Inherited UI, inherited text and misc lowering -------------------------@@ -2167,21 +2148,19 @@ fn build_inherited_ui_group(schemes.as_slice().iter().map(|name| name.to_fly_string()).collect(),);- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::INHERITED_UI,- &entries,- |payload: &mut InheritedUIValues| {- payload.caret_color = caret_color;- payload.accent_color = accent_color;- payload.cursor = RetainedComputedCursorList::from_vec(cursors);- payload.scrollbar_color = scrollbar_color;- payload.color_schemes = color_schemes;- payload.color_scheme_only = *only;- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::INHERITED_UI,+ &entries,+ |payload: &mut InheritedUIValues| {+ payload.caret_color = caret_color;+ payload.accent_color = accent_color;+ payload.cursor = RetainedComputedCursorList::from_vec(cursors);+ payload.scrollbar_color = scrollbar_color;+ payload.color_schemes = color_schemes;+ payload.color_scheme_only = *only;+ },+ parent,+ )}/// Resolves a computed length-percentage against the element's font size.@@ -2270,39 +2249,37 @@ fn build_inherited_text_group(font_relative_length_to_css_pixels(underline_offset_data, input)};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::INHERITED_TEXT,- &entries,- |payload: &mut InheritedTextValues| {- payload.text_shadow = RetainedComputedShadowList::from_vec(text_shadows);- payload.text_underline_position = ComputedTextUnderlinePosition {- horizontal: *horizontal,- vertical: *vertical,- };- payload.text_underline_offset = ComputedTextUnderlineOffset {- used_value: underline_offset_used,- is_auto: underline_offset_is_auto,- value: if underline_offset_is_auto {- ComputedStyleValueHandle::empty()- } else {- ComputedStyleValueHandle::from_retained(values.handle(property_id::TEXT_UNDERLINE_OFFSET))- },- };- payload.text_indent = ComputedTextIndent {- length_percentage: ComputedStyleValueHandle::from_retained(length_percentage),- each_line: *each_line,- hanging: *hanging,- };- payload.tab_size_is_number = tab_size_is_number;- payload.tab_size_number = tab_size_number;- payload.tab_size_length = CssPixels::from_raw(tab_size_px);- payload.word_spacing = word_spacing;- payload.letter_spacing = letter_spacing;- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::INHERITED_TEXT,+ &entries,+ |payload: &mut InheritedTextValues| {+ payload.text_shadow = RetainedComputedShadowList::from_vec(text_shadows);+ payload.text_underline_position = ComputedTextUnderlinePosition {+ horizontal: *horizontal,+ vertical: *vertical,+ };+ payload.text_underline_offset = ComputedTextUnderlineOffset {+ used_value: underline_offset_used,+ is_auto: underline_offset_is_auto,+ value: if underline_offset_is_auto {+ ComputedStyleValueHandle::empty()+ } else {+ ComputedStyleValueHandle::from_retained(values.handle(property_id::TEXT_UNDERLINE_OFFSET))+ },+ };+ payload.text_indent = ComputedTextIndent {+ length_percentage: ComputedStyleValueHandle::from_retained(length_percentage),+ each_line: *each_line,+ hanging: *hanging,+ };+ payload.tab_size_is_number = tab_size_is_number;+ payload.tab_size_number = tab_size_number;+ payload.tab_size_length = CssPixels::from_raw(tab_size_px);+ payload.word_spacing = word_spacing;+ payload.letter_spacing = letter_spacing;+ },+ parent,+ )}/// Builds the misc reset group entirely from Rust-owned canonical values.@@ -2460,54 +2437,52 @@ fn build_misc_reset_group(.expect("a computed outline-color resolves in the Rust color context"),);- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::MISC_RESET,- &entries,- |payload: &mut MiscResetValues| {- let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));- payload.outline_offset_style_value = retained(property_id::OUTLINE_OFFSET);- payload.outline_offset = outline_offset;- payload.scroll_margin = ComputedLengthBox::from_data(- values.handle(property_id::SCROLL_MARGIN_TOP),- values.handle(property_id::SCROLL_MARGIN_RIGHT),- values.handle(property_id::SCROLL_MARGIN_BOTTOM),- values.handle(property_id::SCROLL_MARGIN_LEFT),- false,- );- payload.scroll_padding = ComputedLengthBox::from_data(- values.handle(property_id::SCROLL_PADDING_TOP),- values.handle(property_id::SCROLL_PADDING_RIGHT),- values.handle(property_id::SCROLL_PADDING_BOTTOM),- values.handle(property_id::SCROLL_PADDING_LEFT),- true,- );- payload.overflow_clip_margin = ComputedOverflowClipMargin {- left: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_LEFT),- top: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_TOP),- right: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_RIGHT),- bottom: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_BOTTOM),- };- payload.appearance = normalized_appearance;- payload.computed_appearance = computed_appearance;- payload.column_height = ComputedSize::from_data(values.handle(property_id::COLUMN_HEIGHT));- payload.outline_color = outline_color;- payload.object_position_x = position_offset(edge_x);- payload.object_position_y = position_offset(edge_y);- payload.view_transition_name = retained(property_id::VIEW_TRANSITION_NAME);- payload.scroll_snap_align_block = scroll_snap_align_block;- payload.scroll_snap_align_inline = scroll_snap_align_inline;- payload.scroll_snap_axis = scroll_snap_axis;- payload.scroll_snap_strictness = scroll_snap_strictness;- payload.scrollbar_gutter = *scrollbar_gutter;- payload.shape_margin = retained(property_id::SHAPE_MARGIN);- payload.shape_outside = retained(property_id::SHAPE_OUTSIDE);- payload.will_change = retained(property_id::WILL_CHANGE);- payload.implicit_will_change = RetainedWillChangePropertyList::from_vec(implicit_will_change.to_vec());- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::MISC_RESET,+ &entries,+ |payload: &mut MiscResetValues| {+ let retained = |property| ComputedStyleValueHandle::from_retained(values.handle(property));+ payload.outline_offset_style_value = retained(property_id::OUTLINE_OFFSET);+ payload.outline_offset = outline_offset;+ payload.scroll_margin = ComputedLengthBox::from_data(+ values.handle(property_id::SCROLL_MARGIN_TOP),+ values.handle(property_id::SCROLL_MARGIN_RIGHT),+ values.handle(property_id::SCROLL_MARGIN_BOTTOM),+ values.handle(property_id::SCROLL_MARGIN_LEFT),+ false,+ );+ payload.scroll_padding = ComputedLengthBox::from_data(+ values.handle(property_id::SCROLL_PADDING_TOP),+ values.handle(property_id::SCROLL_PADDING_RIGHT),+ values.handle(property_id::SCROLL_PADDING_BOTTOM),+ values.handle(property_id::SCROLL_PADDING_LEFT),+ true,+ );+ payload.overflow_clip_margin = ComputedOverflowClipMargin {+ left: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_LEFT),+ top: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_TOP),+ right: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_RIGHT),+ bottom: overflow_clip_margin_side(property_id::OVERFLOW_CLIP_MARGIN_BOTTOM),+ };+ payload.appearance = normalized_appearance;+ payload.computed_appearance = computed_appearance;+ payload.column_height = ComputedSize::from_data(values.handle(property_id::COLUMN_HEIGHT));+ payload.outline_color = outline_color;+ payload.object_position_x = position_offset(edge_x);+ payload.object_position_y = position_offset(edge_y);+ payload.view_transition_name = retained(property_id::VIEW_TRANSITION_NAME);+ payload.scroll_snap_align_block = scroll_snap_align_block;+ payload.scroll_snap_align_inline = scroll_snap_align_inline;+ payload.scroll_snap_axis = scroll_snap_axis;+ payload.scroll_snap_strictness = scroll_snap_strictness;+ payload.scrollbar_gutter = *scrollbar_gutter;+ payload.shape_margin = retained(property_id::SHAPE_MARGIN);+ payload.shape_outside = retained(property_id::SHAPE_OUTSIDE);+ payload.will_change = retained(property_id::WILL_CHANGE);+ payload.implicit_will_change = RetainedWillChangePropertyList::from_vec(implicit_will_change.to_vec());+ },+ parent,+ )}/// The C++ StyleValueList::Separator::Comma discriminant, static-asserted in@@ -3169,39 +3144,36 @@ fn build_animation_group(};matches!(item.data(), StyleValueData::Time { value, .. } if *value == 0.0)};- {- crate::css::computed_values::build_group_payload_with_rust_fill(- group_index::ANIMATION,- &entries,- |payload: &mut AnimationValues| {- payload.animation_name = retained(property_id::ANIMATION_NAME);- payload.animation_composition = retained(property_id::ANIMATION_COMPOSITION);- payload.animation_delay = retained(property_id::ANIMATION_DELAY);- payload.animation_direction = retained(property_id::ANIMATION_DIRECTION);- payload.animation_duration = retained(property_id::ANIMATION_DURATION);- payload.animation_fill_mode = retained(property_id::ANIMATION_FILL_MODE);- payload.animation_iteration_count = retained(property_id::ANIMATION_ITERATION_COUNT);- payload.animation_play_state = retained(property_id::ANIMATION_PLAY_STATE);- payload.animation_timeline = retained(property_id::ANIMATION_TIMELINE);- payload.animation_timing_function = retained(property_id::ANIMATION_TIMING_FUNCTION);- payload.scroll_timeline_name = retained(property_id::SCROLL_TIMELINE_NAME);- payload.scroll_timeline_axis = retained(property_id::SCROLL_TIMELINE_AXIS);- payload.timeline_scope = retained(property_id::TIMELINE_SCOPE);- payload.view_timeline_name = retained(property_id::VIEW_TIMELINE_NAME);- payload.view_timeline_axis = retained(property_id::VIEW_TIMELINE_AXIS);- payload.view_timeline_inset = retained(property_id::VIEW_TIMELINE_INSET);- payload.transition_property = retained(property_id::TRANSITION_PROPERTY);- payload.transition_duration = retained(property_id::TRANSITION_DURATION);- payload.transition_timing_function = retained(property_id::TRANSITION_TIMING_FUNCTION);- payload.transition_delay = retained(property_id::TRANSITION_DELAY);- payload.transition_behavior = retained(property_id::TRANSITION_BEHAVIOR);- payload.transition_delay_and_duration_are_single_zero =- is_single_zero_time(property_id::TRANSITION_DELAY)- && is_single_zero_time(property_id::TRANSITION_DURATION);- },- parent,- )- }+ crate::css::computed_values::build_group_payload_with_rust_fill(+ group_index::ANIMATION,+ &entries,+ |payload: &mut AnimationValues| {+ payload.animation_name = retained(property_id::ANIMATION_NAME);+ payload.animation_composition = retained(property_id::ANIMATION_COMPOSITION);+ payload.animation_delay = retained(property_id::ANIMATION_DELAY);+ payload.animation_direction = retained(property_id::ANIMATION_DIRECTION);+ payload.animation_duration = retained(property_id::ANIMATION_DURATION);+ payload.animation_fill_mode = retained(property_id::ANIMATION_FILL_MODE);+ payload.animation_iteration_count = retained(property_id::ANIMATION_ITERATION_COUNT);+ payload.animation_play_state = retained(property_id::ANIMATION_PLAY_STATE);+ payload.animation_timeline = retained(property_id::ANIMATION_TIMELINE);+ payload.animation_timing_function = retained(property_id::ANIMATION_TIMING_FUNCTION);+ payload.scroll_timeline_name = retained(property_id::SCROLL_TIMELINE_NAME);+ payload.scroll_timeline_axis = retained(property_id::SCROLL_TIMELINE_AXIS);+ payload.timeline_scope = retained(property_id::TIMELINE_SCOPE);+ payload.view_timeline_name = retained(property_id::VIEW_TIMELINE_NAME);+ payload.view_timeline_axis = retained(property_id::VIEW_TIMELINE_AXIS);+ payload.view_timeline_inset = retained(property_id::VIEW_TIMELINE_INSET);+ payload.transition_property = retained(property_id::TRANSITION_PROPERTY);+ payload.transition_duration = retained(property_id::TRANSITION_DURATION);+ payload.transition_timing_function = retained(property_id::TRANSITION_TIMING_FUNCTION);+ payload.transition_delay = retained(property_id::TRANSITION_DELAY);+ payload.transition_behavior = retained(property_id::TRANSITION_BEHAVIOR);+ payload.transition_delay_and_duration_are_single_zero = is_single_zero_time(property_id::TRANSITION_DELAY)+ && is_single_zero_time(property_id::TRANSITION_DURATION);+ },+ parent,+ )}/// Rebuilds the font group from the table and the platform font inputs the engine resolved.diff --git a/Libraries/LibWeb/Rust/src/layout/box_removal.rs b/Libraries/LibWeb/Rust/src/layout/box_removal.rsindex e57431a19e0..82ba803591c 100644--- a/Libraries/LibWeb/Rust/src/layout/box_removal.rs+++ b/Libraries/LibWeb/Rust/src/layout/box_removal.rs@@ -305,13 +305,10 @@ pub unsafe extern "C" fn render_state_can_detach_box_in_place(let (Some(parent), Some(child)) = (StyleNodeID::from_raw(parent), StyleNodeID::from_raw(child)) else {return false;};- // SAFETY: Guaranteed by the caller.- {- super::shell_reads::read_arena(host, read, (parent, child, facts), |arena, (parent, child, facts)| {- let (parent_row, child_row) = (arena.bound_row(parent), arena.bound_row(child));- !parent_row.is_invalid()- && !child_row.is_invalid()- && arena.can_detach_box_in_place(parent, parent_row, child_row, &facts)- })- }+ super::shell_reads::read_arena(host, read, (parent, child, facts), |arena, (parent, child, facts)| {+ let (parent_row, child_row) = (arena.bound_row(parent), arena.bound_row(child));+ !parent_row.is_invalid()+ && !child_row.is_invalid()+ && arena.can_detach_box_in_place(parent, parent_row, child_row, &facts)+ })}diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rsindex ae72c6fb513..570da6c513f 100644--- a/Libraries/LibWeb/Rust/src/layout/commit.rs+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs@@ -84,7 +84,6 @@ impl CommitNotifications {for reset in self.row_resets {reset.tell(main_thread);}- // SAFETY: Guaranteed by the caller.host.deliver_commit_messages(main_thread, read, &self.messages);}}diff --git a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs b/Libraries/LibWeb/Rust/src/layout/layout_changes.rsindex 67346769acc..0f63e176704 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs@@ -445,16 +445,13 @@ pub extern "C" fn render_state_set_needs_layout_update(node: NodeSlotId,propagate_through_ancestors: bool,) {- // SAFETY: Guaranteed by the caller.- {- queue(- host,- LayoutChange::SetNeedsLayoutUpdate {- node,- propagate_through_ancestors,- },- );- }+ queue(+ host,+ LayoutChange::SetNeedsLayoutUpdate {+ node,+ propagate_through_ancestors,+ },+ );}/// Detaches what is left of the boxes of the `count` nodes `style_nodes` names as they leave the document (see@@ -480,7 +477,6 @@ pub unsafe extern "C" fn render_state_detach_remaining_rows_for_removal(#[unsafe(no_mangle)]pub extern "C" fn render_state_set_needs_full_layout_tree_update(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetNeedsFullLayoutTreeUpdate);}@@ -489,13 +485,11 @@ pub extern "C" fn render_state_reset_cached_intrinsic_sizes_of_self_and_ancestorhost: &DocumentHost,node: NodeSlotId,) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::ResetCachedIntrinsicSizesOfSelfAndAncestors { node });}#[unsafe(no_mangle)]pub extern "C" fn render_state_record_partial_relayout_escape(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::RecordPartialRelayoutEscape);}@@ -523,7 +517,6 @@ pub unsafe extern "C" fn render_state_style_node_changed(new,generated_for,};- // SAFETY: Guaranteed by the caller.queue(host, change);if let Some(new) = new {host.write_marks(super::tree_update_marks::LayoutTreeUpdateMarkWrite::Clear(new));@@ -553,7 +546,6 @@ pub unsafe extern "C" fn render_state_set_anchor_name_elements(anchor_name,elements: elements.iter().copied().filter_map(StyleNodeID::from_raw).collect(),};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -563,7 +555,6 @@ pub extern "C" fn render_state_set_element_scroll_offset(host: &DocumentHost, elreturn;};let offset = offset.into();- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetElementScrollOffset { element, offset });}@@ -582,7 +573,6 @@ pub extern "C" fn render_state_set_pseudo_element_scroll_offset(generated_for,offset: offset.into(),};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -591,7 +581,6 @@ pub extern "C" fn render_state_set_identity_in_focused_text_control(host: &Documlet Some(node) = StyleNodeID::from_raw(node) else {return;};- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetIdentityInFocusedTextControl { node, value });}@@ -623,7 +612,6 @@ pub unsafe extern "C" fn render_state_set_svg_attribute_facts(facts: Box::new(facts),points: points.into(),};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -646,19 +634,16 @@ pub extern "C" fn render_state_set_svg_style_references(element,references: [mask, clip_path, fill, stroke],};- // SAFETY: Guaranteed by the caller.queue(host, change);}#[unsafe(no_mangle)]pub extern "C" fn render_state_set_document_is_decoded_svg(host: &DocumentHost, is_decoded_svg: bool) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetDocumentIsDecodedSvg(is_decoded_svg));}#[unsafe(no_mangle)]pub extern "C" fn render_state_set_node_flag(host: &DocumentHost, node: NodeSlotId, flag: NodeFlag, value: bool) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetNodeFlag { node, flag, value });}@@ -672,19 +657,16 @@ pub extern "C" fn render_state_set_owned_image_natural_size(node,natural_size: natural_size.into(),};- // SAFETY: Guaranteed by the caller.queue(host, change);}#[unsafe(no_mangle)]pub extern "C" fn render_state_invalidate_searchable_text(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::InvalidateSearchableText);}#[unsafe(no_mangle)]pub extern "C" fn render_state_restamp_table_spans(host: &DocumentHost, node: NodeSlotId) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::RestampTableSpans { node });}diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 24d1f96b6f7..ed44a4abbb3 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -5576,7 +5576,6 @@ pub extern "C" fn render_state_content_counter_styles_changed(let Some(owner) = counter_owner(style_node, generated_for) else {return false;};- // SAFETY: Guaranteed by the caller.read_arena(host, read, owner, |arena, owner| {super::generated_content::content_counter_styles_changed(arena, owner)})@@ -5608,19 +5607,15 @@ pub extern "C" fn render_state_set_node_needs_compositor_animation_frame(kind: super::node_data::CompositorAnimationFrameKind,value: bool,) {- // SAFETY: Guaranteed by the caller.- {- queue(- host,- LayoutChange::SetNodeNeedsCompositorAnimationFrame { node: id, kind, value },- );- }+ queue(+ host,+ LayoutChange::SetNodeNeedsCompositorAnimationFrame { node: id, kind, value },+ );}/// What the row is scrolled to, as the document published it.#[unsafe(no_mangle)]pub extern "C" fn render_state_row_scroll_offset(host: &DocumentHost, slot: NodeSlotId, out: &mut FfiCssPixelPoint) {- // SAFETY: Guaranteed by the caller.*out = {read_arena(host, node_read(), slot, |arena, slot| {arena.row_scroll_offset(slot).into()@@ -5640,7 +5635,6 @@ pub unsafe extern "C" fn render_state_set_node_style(record: style_record,payloads: StylePayloadsRef::new(payloads.cast()),};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -5697,29 +5691,24 @@ pub extern "C" fn render_state_pin_bound_box_style_record_for_detachment(let Some(style_node) = StyleNodeID::from_raw(style_node) else {return;};- // SAFETY: Guaranteed by the caller.- {- queue(- host,- LayoutChange::PinBoundBoxStyleRecordForDetachment {- style_node,- generated_for,- },- );- }+ queue(+ host,+ LayoutChange::PinBoundBoxStyleRecordForDetachment {+ style_node,+ generated_for,+ },+ );}/// Pins the style record `record` for the host's readers of the row `slot`, until the host/// releases it or the row is freed.#[unsafe(no_mangle)]pub extern "C" fn render_state_pin_node_style_record_for_host(host: &DocumentHost, slot: NodeSlotId, record: u64) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::PinNodeStyleRecordForHost { node: slot, record });}#[unsafe(no_mangle)]pub extern "C" fn render_state_release_node_style_record_pin_for_host(host: &DocumentHost, slot: NodeSlotId) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::ReleaseNodeStyleRecordPinForHost { node: slot });}@@ -5742,18 +5731,14 @@ pub unsafe extern "C" fn render_state_set_box_presence_host(context: *mut c_void,callback: unsafe extern "C" fn(*mut c_void, u32, u8),) {- // SAFETY: Guaranteed by the caller.- {- queue(- host,- LayoutChange::SetBoxPresenceHost(Some(BoxPresenceHost(context, callback))),- );- }+ queue(+ host,+ LayoutChange::SetBoxPresenceHost(Some(BoxPresenceHost(context, callback))),+ );}#[unsafe(no_mangle)]pub extern "C" fn render_state_clear_box_presence_host(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::SetBoxPresenceHost(None));}@@ -5780,7 +5765,6 @@ pub unsafe extern "C" fn document_host_set_style_record_host_callbacks(#[unsafe(no_mangle)]pub extern "C" fn render_state_layout_pass_is_running(host: &DocumentHost) -> bool {- // SAFETY: Guaranteed by the caller.read_arena(host, node_read(), (), |arena, ()| arena.layout_pass_is_running())}@@ -5789,13 +5773,11 @@ pub extern "C" fn render_state_needs_full_layout_tree_update(host: &DocumentHost,read: &crate::render_state::BegunRead,) -> bool {- // SAFETY: Guaranteed by the caller.read_arena(host, read, (), |arena, ()| arena.needs_full_layout_tree_update())}#[unsafe(no_mangle)]pub extern "C" fn render_state_layout_root(host: &DocumentHost, read: &crate::render_state::BegunRead) -> NodeSlotId {- // SAFETY: Guaranteed by the caller.read_arena(host, read, (), |arena, ()| arena.layout_root())}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.rsindex 3c073d70126..71ed0c4704c 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@@ -49,7 +49,6 @@ mod tests {let shell = std::ptr::without_provenance_mut(8);host.host_tables().attach_shell(child, shell);let read = host.read_for_test();- // SAFETY: The host lives on this thread until the test host is dropped.assert_eq!(render_state_node_shell_if_live(host, read, child), shell);let sibling = FfiDetachedBoxSibling {@@ -71,7 +70,6 @@ mod tests {);}// A recording can still name the removed image. Resolving it must apply the removal before answering.- // SAFETY: As above; the entry point accepts a stale slot.let resolved = render_state_node_shell_if_live(host, read, child);let shell_was_destroyed = !host.host_tables().shells.borrow().contains_key(&child);host.run(ScriptForcedRead::for_test(), true, |state| {@@ -99,7 +97,6 @@ pub extern "C" fn render_state_node_shell_if_live(.shell_facts(id).map_or(std::ptr::null_mut(), |facts| host.host_tables().shell_of(facts));}- // SAFETY: Guaranteed by the caller.let facts = {read_arena(host, read, id, |arena, id| {let kind = arena.node_kind_if_live(id)?;@@ -189,11 +186,7 @@ pub unsafe extern "C" fn document_host_replace_image_observers(host.host_tables().replace_image_observers(slot, observers)}-/// # Safety-///-/// `host` must be a live document host, on its document's thread.#[unsafe(no_mangle)]-// SAFETY: Guaranteed by the caller.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/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rsindex bfa243074ea..09a9457b996 100644--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs@@ -1450,7 +1450,6 @@ pub unsafe extern "C" fn render_state_take_changed_document_svg_root_natural_sizread: &crate::render_state::BegunRead,natural_size: *mut crate::painting::host::FfiNaturalSize,) -> bool {- // SAFETY: Guaranteed by the caller.let changed = super::shell_reads::read_arena(host, read, (), |arena, ()| {arena.take_changed_document_svg_root_natural_size()});diff --git a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rsindex 0b88467ac14..8e20c2e1048 100644--- a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs+++ b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs@@ -772,7 +772,6 @@ pub extern "C" fn render_state_node_is_partial_relayout_boundary(host: &crate::render_state::DocumentHost,node: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.super::shell_reads::read_arena(host, node_read(), node, |arena, node| {arena.node_is_partial_relayout_boundary(node)})diff --git a/Libraries/LibWeb/Rust/src/layout/script_entries.rs b/Libraries/LibWeb/Rust/src/layout/script_entries.rsindex ecb92ff0077..cc49863d646 100644--- a/Libraries/LibWeb/Rust/src/layout/script_entries.rs+++ b/Libraries/LibWeb/Rust/src/layout/script_entries.rs@@ -33,7 +33,6 @@ const SCRIPT_ENTRY: ScriptEntry = ScriptEntry { _private: () };/// Answers `read` from the rows of `host`'s document as of every write the host made, spending the script call's/// forced read. Every entry here is called with a live document host, on its document's thread.fn read_rows<R>(host: &DocumentHost, read: impl FnOnce(&PaintSource<'_>) -> R) -> R {- // SAFETY: The host is live.host.read_rows(ScriptForcedRead::at_script_entry(&SCRIPT_ENTRY), false, read)}@@ -386,9 +385,6 @@ pub extern "C" fn layout_script_paintable_absolute_border_box_rect(});}-/// # Safety-///-/// `host` must be a live document host, on its document's thread.#[unsafe(no_mangle)]pub extern "C" fn layout_script_paintable_box_model(host: &DocumentHost,@@ -425,7 +421,6 @@ pub extern "C" fn layout_script_paintable_content_size(/// Answers `read` of the layout arena of `host`'s document, spending the script call's forced read.fn read_arena<R>(host: &DocumentHost, read: impl FnOnce(&mut crate::layout::LayoutNodeArena) -> R) -> R {- // SAFETY: Every entry here is called with a live document host, on its document's thread.host.ask(ScriptForcedRead::at_script_entry(&SCRIPT_ENTRY), |state| {read(state.arena_mut())})diff --git a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs b/Libraries/LibWeb/Rust/src/layout/shell_reads.rsindex f9c346a9adc..d7f7553bc10 100644--- a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs+++ b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs@@ -54,7 +54,6 @@ fn identities(host: &DocumentHost, wait: impl RenderWait) -> RowIdentities {#[unsafe(no_mangle)]pub extern "C" fn layout_row_flags(host: &DocumentHost, id: NodeSlotId) -> u32 {- // SAFETY: Guaranteed by the caller.rows(host, node_read()).flags(id)}@@ -62,22 +61,18 @@ pub extern "C" fn layout_row_flags(host: &DocumentHost, id: NodeSlotId) -> u32 {/// reads as unset.#[unsafe(no_mangle)]pub extern "C" fn layout_row_identity_flags(host: &DocumentHost, id: NodeSlotId) -> u32 {- // SAFETY: Guaranteed by the caller.identities(host, node_read()).identity_flags(id)}/// The layout node of the row `id` links to, made if nothing has asked for it yet, or null.#[unsafe(no_mangle)]pub extern "C" fn layout_row_link_shell(host: &DocumentHost, id: NodeSlotId, link: FfiNodeLink) -> *mut c_void {- // SAFETY: Guaranteed by the caller.let linked = rows(host, node_read()).link(id, link);- // SAFETY: As above.shell_of(host, node_read(), (!linked.is_invalid()).then_some(linked))}#[unsafe(no_mangle)]pub extern "C" fn layout_row_generated_for(host: &DocumentHost, id: NodeSlotId) -> u8 {- // SAFETY: Guaranteed by the caller.identities(host, node_read()).generated_for(id)}@@ -87,14 +82,12 @@ pub extern "C" fn layout_row_has_compositor_animation_frame(id: NodeSlotId,kind: CompositorAnimationFrameKind,) -> bool {- // SAFETY: Guaranteed by the caller.rows(host, node_read()).has_compositor_animation_frame(id, kind)}/// The style node of the row, or 0 for a row that is gone or carries none.#[unsafe(no_mangle)]pub extern "C" fn layout_row_style_node(host: &DocumentHost, id: NodeSlotId) -> u32 {- // SAFETY: Guaranteed by the caller.identities(host, node_read()).style_node(id).map_or(0, crate::css::style::tree::StyleNodeID::raw)@@ -102,7 +95,6 @@ pub extern "C" fn layout_row_style_node(host: &DocumentHost, id: NodeSlotId) ->#[unsafe(no_mangle)]pub extern "C" fn layout_row_style_record(host: &DocumentHost, id: NodeSlotId) -> u64 {- // SAFETY: Guaranteed by the caller.styles(host, id, node_read()).style_record(id)}@@ -110,25 +102,21 @@ pub extern "C" fn layout_row_style_record(host: &DocumentHost, id: NodeSlotId) -/// writes, and a job tells the layout node of.#[unsafe(no_mangle)]pub extern "C" fn layout_row_style_is_derived(host: &DocumentHost, id: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.styles(host, id, node_read()).style_is_derived(id)}#[unsafe(no_mangle)]pub extern "C" fn layout_row_style_payloads(host: &DocumentHost, id: NodeSlotId) -> *const c_void {- // SAFETY: Guaranteed by the caller.styles(host, id, node_read()).style_payloads(id).as_ptr().cast()}#[unsafe(no_mangle)]pub extern "C" fn layout_row_is_atomic_inline(host: &DocumentHost, id: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.rows(host, node_read()).is_atomic_inline(id)}#[unsafe(no_mangle)]pub extern "C" fn layout_row_is_fragmented_inline(host: &DocumentHost, id: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.rows(host, node_read()).is_fragmented_inline(id)}@@ -142,7 +130,6 @@ fn shell_of(host: &DocumentHost, wait: impl RenderWait, id: Option<NodeSlotId>)let Some(id) = id else {return std::ptr::null_mut();};- // SAFETY: Guaranteed by the caller.bound_shell(host, wait, |_| Some(id))}@@ -154,14 +141,13 @@ fn bound_shell(bound: impl FnOnce(&RowIdentities) -> Option<NodeSlotId>,) -> *mut c_void {let facts = {- // SAFETY: Guaranteed by the caller.let identities = identities(host, wait);bound(&identities).and_then(|id| identities.shell_facts(id))};let Some(facts) = facts else {return std::ptr::null_mut();};- // SAFETY: As above. The factory reads the rows again, through the shared host.+ // The factory reads the rows again, through the shared host.host.host_tables().shell_of(facts)}@@ -172,7 +158,6 @@ pub extern "C" fn layout_row_bound_shell(host: &DocumentHost, read: &BegunRead,let Some(style_node) = StyleNodeID::from_raw(style_node) else {return std::ptr::null_mut();};- // SAFETY: Guaranteed by the caller.bound_shell(host, read, |identities| identities.bound_row(style_node))}@@ -189,7 +174,6 @@ pub extern "C" fn layout_row_bound_committed_content_size(let Some(style_node) = StyleNodeID::from_raw(style_node) else {return false;};- // SAFETY: Guaranteed by the caller.let Some(row) = identities(host, read).bound_row(style_node) else {return false;};@@ -214,18 +198,14 @@ pub extern "C" fn layout_row_bound_pseudo_element_shell(let Some(style_node) = StyleNodeID::from_raw(style_node) else {return std::ptr::null_mut();};- // SAFETY: Guaranteed by the caller.- {- bound_shell(host, read, |identities| {- identities.bound_pseudo_element_row(style_node, generated_for)- })- }+ bound_shell(host, read, |identities| {+ identities.bound_pseudo_element_row(style_node, generated_for)+ })}/// The layout node of the viewport row the document is bound to, made if nothing has asked for it yet, or null.#[unsafe(no_mangle)]pub extern "C" fn layout_row_bound_viewport_shell(host: &DocumentHost, read: &BegunRead) -> *mut c_void {- // SAFETY: Guaranteed by the caller.bound_shell(host, read, RowIdentities::bound_viewport_row)}@@ -239,7 +219,6 @@ pub extern "C" fn layout_row_read_of_held_node(host: &DocumentHost) -> *const Be/// viewport row the document is bound to.#[unsafe(no_mangle)]pub extern "C" fn layout_row_is_bound_to(host: &DocumentHost, id: NodeSlotId, style_node: u32) -> bool {- // SAFETY: Guaranteed by the caller.let identities = identities(host, node_read());let bound = match StyleNodeID::from_raw(style_node) {Some(style_node) => identities.bound_row(style_node),@@ -251,9 +230,7 @@ pub extern "C" fn layout_row_is_bound_to(host: &DocumentHost, id: NodeSlotId, st/// The layout node of the box whose content box the row is laid out against, or null.#[unsafe(no_mangle)]pub extern "C" fn layout_row_containing_block_shell_if_live(host: &DocumentHost, id: NodeSlotId) -> *mut c_void {- // SAFETY: Guaranteed by the caller.let containing_block = read_rows(host, |rows| rows.node_containing_block_if_live(id));- // SAFETY: As above.shell_of(host, node_read(), containing_block)}@@ -262,7 +239,6 @@ pub extern "C" fn layout_row_establishes_an_absolute_positioning_containing_blochost: &DocumentHost,id: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {crate::painting::style_queries::establishes_positioning_containing_blocks(rows, id).0})@@ -273,7 +249,6 @@ pub extern "C" fn layout_row_establishes_a_fixed_positioning_containing_block(host: &DocumentHost,id: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {crate::painting::style_queries::establishes_positioning_containing_blocks(rows, id).1})@@ -284,7 +259,6 @@ pub extern "C" fn layout_row_any_ancestor_establishes_a_fixed_position_containinhost: &DocumentHost,id: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {crate::painting::style_queries::any_ancestor_establishes_a_fixed_position_containing_block(rows, id)})@@ -297,15 +271,12 @@ pub extern "C" fn layout_row_paintable_layout_node_shell(read: &BegunRead,slot: NodeSlotId,) -> *mut c_void {- // SAFETY: Guaranteed by the caller.let populated = rows(host, read).paintable.paintable_row_is_populated(slot);- // SAFETY: As above.shell_of(host, read, populated.then_some(slot))}#[unsafe(no_mangle)]pub extern "C" fn layout_row_paintable_is_positioned(host: &DocumentHost, slot: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {rows.paintable_row_is_populated(slot) && crate::painting::style_queries::is_positioned(rows, slot)})@@ -313,7 +284,6 @@ pub extern "C" fn layout_row_paintable_is_positioned(host: &DocumentHost, slot:#[unsafe(no_mangle)]pub extern "C" fn layout_row_paintable_has_child_paintables(host: &DocumentHost, slot: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {crate::painting::paint_order::first_paint_child(rows, slot).is_some()})@@ -321,7 +291,6 @@ pub extern "C" fn layout_row_paintable_has_child_paintables(host: &DocumentHost,#[unsafe(no_mangle)]pub extern "C" fn layout_row_paintable_is_chrome_mirrored(host: &DocumentHost, slot: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {crate::painting::chrome_geometry::is_chrome_mirrored(rows, slot)})@@ -329,7 +298,6 @@ pub extern "C" fn layout_row_paintable_is_chrome_mirrored(host: &DocumentHost, s#[unsafe(no_mangle)]pub extern "C" fn layout_row_has_css_transform(host: &DocumentHost, id: NodeSlotId) -> bool {- // SAFETY: Guaranteed by the caller.read_rows(host, |rows| {rows.node_style_if_live(id).is_some_and(|style| crate::painting::style_queries::has_css_transform(rows, id, style))diff --git a/Libraries/LibWeb/Rust/src/layout/trace.rs b/Libraries/LibWeb/Rust/src/layout/trace.rsindex 801cbf225fd..c2b4f4878f0 100644--- a/Libraries/LibWeb/Rust/src/layout/trace.rs+++ b/Libraries/LibWeb/Rust/src/layout/trace.rs@@ -202,7 +202,6 @@ pub(crate) fn name_layout_trace_owners(main_thread: &MainThread, read: &crate::rlet Some(describe) = host.host_tables().layout_trace_describe_node.get() else {return;};- // SAFETY: The host is live for the token's entry.let owners = super::shell_reads::read_arena(host, read, (), |arena, ()| arena.layout_trace.unnamed_owners(arena));if owners.is_empty() {return;@@ -218,7 +217,6 @@ pub(crate) fn name_layout_trace_owners(main_thread: &MainThread, read: &crate::r)}).collect();- // SAFETY: As above.super::layout_changes::queue(host, super::layout_changes::LayoutChange::NameLayoutTraceOwners(names));}@@ -249,7 +247,6 @@ impl LayoutNodeArena {#[unsafe(no_mangle)]pub extern "C" fn render_state_begin_layout_trace(host: &DocumentHost, describe_node: DescribeNode) {host.host_tables().layout_trace_describe_node.set(Some(describe_node));- // SAFETY: As above.super::layout_changes::queue(host, super::layout_changes::LayoutChange::BeginLayoutTrace);}@@ -264,7 +261,6 @@ pub unsafe extern "C" fn render_state_take_layout_trace(context: *mut c_void,append_text: AppendText,) {- // SAFETY: Guaranteed by the caller.let text = super::shell_reads::read_arena(host, read, (), |arena, ()| arena.layout_trace.take());unsafe { append_text(context, text.as_ptr(), text.len()) };}diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rsindex 6c42482ebd5..0c4fae4e571 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs@@ -208,21 +208,18 @@ fn write_marks(host: &DocumentHost, write: LayoutTreeUpdateMarkWrite) -> bool {/// Whether the node `style_node` names holds a layout tree update mark of its own.#[unsafe(no_mangle)]pub extern "C" fn render_state_needs_layout_tree_update(host: &DocumentHost, style_node: u32) -> bool {- // SAFETY: Guaranteed by the caller.read_marks(host, style_node, LayoutTreeUpdateMarks::needs)}/// Which narrower rebuilds the marks the node `style_node` names has collected still permit.#[unsafe(no_mangle)]pub extern "C" fn render_state_layout_tree_update_reuse_reasons(host: &DocumentHost, style_node: u32) -> u8 {- // SAFETY: Guaranteed by the caller.read_marks(host, style_node, LayoutTreeUpdateMarks::reuse_reasons)}/// Whether a flat-tree descendant of the node `style_node` names holds a layout tree update mark.#[unsafe(no_mangle)]pub extern "C" fn render_state_child_needs_layout_tree_update(host: &DocumentHost, style_node: u32) -> bool {- // SAFETY: Guaranteed by the caller.read_marks(host, style_node, LayoutTreeUpdateMarks::child_needs)}@@ -238,7 +235,6 @@ pub extern "C" fn render_state_merge_layout_tree_update_mark(let Some(style_node) = StyleNodeID::from_raw(style_node) else {return false;};- // SAFETY: Guaranteed by the caller.write_marks(host, LayoutTreeUpdateMarkWrite::Merge(style_node, value, reuse_reason))}@@ -253,7 +249,6 @@ pub extern "C" fn render_state_set_child_needs_layout_tree_update(let Some(style_node) = StyleNodeID::from_raw(style_node) else {return false;};- // SAFETY: Guaranteed by the caller.write_marks(host, LayoutTreeUpdateMarkWrite::SetChildNeeds(style_node, value))}@@ -264,7 +259,6 @@ pub extern "C" fn render_state_clear_layout_tree_update_marks(host: &DocumentHoslet Some(style_node) = StyleNodeID::from_raw(style_node) else {return;};- // SAFETY: Guaranteed by the caller.write_marks(host, LayoutTreeUpdateMarkWrite::Clear(style_node));}@@ -429,7 +423,6 @@ pub extern "C" fn render_state_apply_layout_tree_update_mark() {use super::layout_changes::{LayoutChange, queue};let node = StyleNodeID::from_raw(style_node);- // SAFETY: Guaranteed by the caller.queue(host, LayoutChange::ApplyLayoutTreeUpdateMark { node, mark });}@@ -692,7 +685,6 @@ fn queue_marks(host: &DocumentHost, target: MarkedBox, marks: FfiBoxMarks) {if marks.is_empty() {return;}- // SAFETY: Guaranteed by the caller.super::layout_changes::queue(host, super::layout_changes::LayoutChange::MarkBox { target, marks });}@@ -700,7 +692,6 @@ fn queue_marks(host: &DocumentHost, target: MarkedBox, marks: FfiBoxMarks) {#[unsafe(no_mangle)]pub extern "C" fn render_state_mark_node_box(host: &DocumentHost, style_node: u32, marks: FfiBoxMarks) {let target = MarkedBox::Node(StyleNodeID::from_raw(style_node));- // SAFETY: Guaranteed by the caller.queue_marks(host, target, marks);}@@ -719,7 +710,6 @@ pub extern "C" fn render_state_mark_pseudo_element_box(generator,generated_for,};- // SAFETY: Guaranteed by the caller.queue_marks(host, target, marks);}@@ -727,7 +717,6 @@ pub extern "C" fn render_state_mark_pseudo_element_box(#[unsafe(no_mangle)]pub extern "C" fn render_state_mark_row_box(host: &DocumentHost, row: NodeSlotId, marks: FfiBoxMarks) {let target = MarkedBox::Row(row);- // SAFETY: Guaranteed by the caller.queue_marks(host, target, marks);}diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout.rs b/Libraries/LibWeb/Rust/src/layout/update_layout.rsindex 033f90a1f41..fbc8809e4b8 100644--- a/Libraries/LibWeb/Rust/src/layout/update_layout.rs+++ b/Libraries/LibWeb/Rust/src/layout/update_layout.rs@@ -800,10 +800,8 @@ impl LayoutRoundAnswer {// SAFETY (for every call below): Guaranteed by the caller.std::mem::take(&mut self.work).pay(main_thread);if let Some((replaced_viewport, built)) = self.build.take() {- {- layout_host.deliver_commit_messages(main_thread, read, &built.reports);- layout_host.take_built_scroll_containers(main_thread, read, &built.built_scroll_containers);- }+ layout_host.deliver_commit_messages(main_thread, read, &built.reports);+ layout_host.take_built_scroll_containers(main_thread, read, &built.built_scroll_containers);host.finish_layout_tree_build(main_thread, read, replaced_viewport, built.outcome.viewport);}if self.commits.is_empty() {@@ -815,7 +813,6 @@ impl LayoutRoundAnswer {super::trace::name_layout_trace_owners(main_thread, read);if let Some(geometry_host) = document_host.host_tables().geometry_host.get() {for (slot, offset) in self.clamped_scroll_offsets.drain(..) {- // SAFETY: The round clamped the offsets of rows it left live, whose layout nodes the host has now.geometry_host.set_scroll_offset(main_thread, read, slot, offset.into());}}@@ -903,7 +900,6 @@ fn seal_first_round() {// A round is sealed for a document whose layout is up to date as well: the frame's style may leave it layout to// do, which the round finds once the frame has applied the style.- // SAFETY: Guaranteed by the caller.if let Some(round) = sealed_first_round(main_thread, document_host, read, inputs, |_| true) {document_host.seal_round(round);}@@ -928,7 +924,6 @@ fn fly_first_round(let host = layout_update_host(document_host);host.process_pending_list_item_renumbers(main_thread, read);host.process_pending_top_layer_layout_changes(main_thread, read);- // SAFETY: Guaranteed by the caller.let round = {sealed_first_round(main_thread, document_host, read, inputs, |facts| {!host_layout_is_up_to_date(document_host, read, facts)diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rsindex 7529e86e254..ca3db1fc334 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs@@ -122,7 +122,6 @@ pub extern "C" fn render_state_paintable_row(host: &DocumentHost, slot: NodeSlot.paintable_row_is_populated(slot).then(|| *rows.paintable.paintable_data(slot))});- // SAFETY: Guaranteed by the caller.let answer = known.unwrap_or_else(|| {read_arena(host, node_read(), slot, |arena, slot| {let paintable_rows = arena.paintable_rows();@@ -144,7 +143,6 @@ pub extern "C" fn render_state_has_paintable_row(host: &DocumentHost, slot: Nodeif let Some(populated) = host.known_paintable_row_is_populated(slot) {return populated;}- // SAFETY: Guaranteed by the caller.read_arena(host, node_read(), slot, |arena, slot| {arena.paintable_rows().paintable_row_is_populated(slot)})@@ -183,7 +181,6 @@ pub extern "C" fn render_state_paintable_scrollable_overflow(*out = overflow;return;}- // SAFETY: Guaranteed by the caller.*out = {read_arena(host, node_read(), slot, |arena, slot| {arena.measure_scrollable_overflow();@@ -226,7 +223,6 @@ pub extern "C" fn render_state_paintable_svg_viewport_size(slot: NodeSlotId,out: &mut FfiCssPixelSize,) {- // SAFETY: Guaranteed by the caller.*out = {read_arena(host, node_read(), slot, |arena, slot| {let paintable_rows = arena.paintable_rows();@@ -249,20 +245,17 @@ pub extern "C" fn render_state_paintable_svg_viewport_transform(host: &DocumentHost,slot: NodeSlotId,) -> FfiOptionalAffineTransform {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), slot, |arena, slot| {- let transform = if arena.paintable_row_is_populated(slot) {- crate::painting::paintable_geometry::committed_svg_viewport_transform(arena, slot)- } else {- None- };- FfiOptionalAffineTransform {- has_value: transform.is_some(),- transform: transform.unwrap_or_default(),- }- })- }+ read_arena(host, node_read(), slot, |arena, slot| {+ let transform = if arena.paintable_row_is_populated(slot) {+ crate::painting::paintable_geometry::committed_svg_viewport_transform(arena, slot)+ } else {+ None+ };+ FfiOptionalAffineTransform {+ has_value: transform.is_some(),+ transform: transform.unwrap_or_default(),+ }+ })}/// The transform an SVG element's box was laid out with: its own CSS transform reduced to 2D, with a <use> element's@@ -272,15 +265,12 @@ pub extern "C" fn render_state_paintable_svg_element_transform(host: &DocumentHost,slot: NodeSlotId,) -> svg_formatting_context::FfiAffineTransform {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), slot, |arena, slot| {- if !arena.paintable_row_is_populated(slot) {- return svg_formatting_context::FfiAffineTransform::default();- }- crate::painting::paintable_geometry::committed_svg_element_transform(arena, slot).unwrap_or_default()- })- }+ read_arena(host, node_read(), slot, |arena, slot| {+ if !arena.paintable_row_is_populated(slot) {+ return svg_formatting_context::FfiAffineTransform::default();+ }+ crate::painting::paintable_geometry::committed_svg_element_transform(arena, slot).unwrap_or_default()+ })}#[unsafe(no_mangle)]@@ -296,7 +286,6 @@ pub extern "C" fn render_state_paintable_transform_reference_box(*out = rect;return;}- // SAFETY: Guaranteed by the caller.*out = {read_arena(host, node_read(), slot, |arena, slot| {reference_box(&arena.paintable_rows(), slot)@@ -320,20 +309,17 @@ pub extern "C" fn render_state_physical_overflow_directions(host: &DocumentHost,paintable: NodeSlotId,) -> FfiPhysicalOverflowDirections {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), paintable, |arena, paintable| {- let directions = if arena.paintable_row_is_populated(paintable) {- crate::painting::scrollable_overflow::physical_overflow_directions(arena, paintable)- } else {- crate::painting::scrollable_overflow::PhysicalOverflowDirections::default()- };- FfiPhysicalOverflowDirections {- horizontal_axis_is_positive: directions.horizontal_axis_is_positive,- vertical_axis_is_positive: directions.vertical_axis_is_positive,- }- })- }+ read_arena(host, node_read(), paintable, |arena, paintable| {+ let directions = if arena.paintable_row_is_populated(paintable) {+ crate::painting::scrollable_overflow::physical_overflow_directions(arena, paintable)+ } else {+ crate::painting::scrollable_overflow::PhysicalOverflowDirections::default()+ };+ FfiPhysicalOverflowDirections {+ horizontal_axis_is_positive: directions.horizontal_axis_is_positive,+ vertical_axis_is_positive: directions.vertical_axis_is_positive,+ }+ })}#[unsafe(no_mangle)]@@ -341,7 +327,6 @@ pub extern "C" fn render_state_background_color_can_be_compositor_animated(host: &DocumentHost,slot: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.read_arena(host, node_read(), slot, |arena, slot| {crate::painting::record::paint::background_resolution::background_color_can_be_compositor_animated(&arena.paintable_rows(),@@ -357,17 +342,14 @@ pub extern "C" fn render_state_paintable_visual_context_node_count(slot: NodeSlotId,list: crate::painting::host::FfiVisualContextBoxNodeList,) -> usize {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), (slot, list), |arena, (slot, list)| {- use crate::painting::host::FfiVisualContextBoxNodeList;- arena.with_paintable_visual_context_node_handles(slot, |handles| match list {- FfiVisualContextBoxNodeList::SpatialNodes => handles.spatial.len(),- FfiVisualContextBoxNodeList::ClipNodes => handles.clip_handles().count(),- FfiVisualContextBoxNodeList::EffectNodes => handles.effects.len(),- })+ read_arena(host, node_read(), (slot, list), |arena, (slot, list)| {+ use crate::painting::host::FfiVisualContextBoxNodeList;+ arena.with_paintable_visual_context_node_handles(slot, |handles| match list {+ FfiVisualContextBoxNodeList::SpatialNodes => handles.spatial.len(),+ FfiVisualContextBoxNodeList::ClipNodes => handles.clip_handles().count(),+ FfiVisualContextBoxNodeList::EffectNodes => handles.effects.len(),})- }+ })}/// # Safety@@ -381,7 +363,6 @@ pub unsafe extern "C" fn render_state_paintable_visual_context_copy_node_indicesout: *mut u32,capacity: usize,) {- // SAFETY: Guaranteed by the caller.let indices = {read_arena(host, node_read(), (slot, list), |arena, (slot, list)| {use crate::painting::host::FfiVisualContextBoxNodeList;@@ -414,19 +395,16 @@ pub(super) fn apply_walk_assignments(/// holds none.#[unsafe(no_mangle)]pub extern "C" fn render_state_sticky_spatial_node_index(host: &DocumentHost, paintable: NodeSlotId) -> u32 {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), paintable, |arena, paintable| {- let paint_state = arena.paint_state().borrow();- paint_state- .visual_context- .scroll_state- .states()- .iter()- .find(|state| state.is_sticky && state.paintable == paintable)- .map_or(u32::MAX, |state| state.node_index.0)- })- }+ read_arena(host, node_read(), paintable, |arena, paintable| {+ let paint_state = arena.paint_state().borrow();+ paint_state+ .visual_context+ .scroll_state+ .states()+ .iter()+ .find(|state| state.is_sticky && state.paintable == paintable)+ .map_or(u32::MAX, |state| state.node_index.0)+ })}/// Marks the entry the event loop calls between two tasks to take a finished recording in.@@ -731,17 +709,14 @@ pub extern "C" fn render_state_paintable_computed_svg_path(host: &DocumentHost,paintable: NodeSlotId,) -> *const c_void {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), paintable, |arena, paintable| {- let paintable_rows = arena.paintable_rows();- if !paintable_rows.paintable_row_is_populated(paintable) {- return std::ptr::null();- }- crate::painting::paintable_geometry::committed_svg_path(&paintable_rows, paintable)- .map_or(std::ptr::null(), |path| path.as_raw())- })- }+ read_arena(host, node_read(), paintable, |arena, paintable| {+ let paintable_rows = arena.paintable_rows();+ if !paintable_rows.paintable_row_is_populated(paintable) {+ return std::ptr::null();+ }+ crate::painting::paintable_geometry::committed_svg_path(&paintable_rows, paintable)+ .map_or(std::ptr::null(), |path| path.as_raw())+ })}/// The glyph cells a text content element's box committed for its own characters, one per code@@ -757,26 +732,23 @@ pub extern "C" fn render_state_paintable_svg_text_character_cells(host: &DocumentHost,paintable: NodeSlotId,) -> FfiSvgTextCharacterCells {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), paintable, |arena, paintable| {- let none = FfiSvgTextCharacterCells {- cells: std::ptr::null(),- count: 0,- };- let paintable_rows = arena.paintable_rows();- if !paintable_rows.paintable_row_is_populated(paintable) {- return none;- }- match crate::painting::paintable_geometry::committed_svg_text_character_cells(&paintable_rows, paintable) {- Some(cells) => FfiSvgTextCharacterCells {- cells: cells.as_ptr(),- count: cells.len(),- },- None => none,- }- })- }+ read_arena(host, node_read(), paintable, |arena, paintable| {+ let none = FfiSvgTextCharacterCells {+ cells: std::ptr::null(),+ count: 0,+ };+ let paintable_rows = arena.paintable_rows();+ if !paintable_rows.paintable_row_is_populated(paintable) {+ return none;+ }+ match crate::painting::paintable_geometry::committed_svg_text_character_cells(&paintable_rows, paintable) {+ Some(cells) => FfiSvgTextCharacterCells {+ cells: cells.as_ptr(),+ count: cells.len(),+ },+ None => none,+ }+ })}#[repr(C)]@@ -828,7 +800,6 @@ pub extern "C" fn render_state_may_have_auto_content_visibility(if let Some(facts) = host.known_arena_facts() {return facts.may_have_auto_content_visibility;}- // SAFETY: Guaranteed by the caller.read_arena(host, read, (), |arena, ()| arena.may_have_auto_content_visibility())}@@ -843,7 +814,6 @@ pub unsafe extern "C" fn render_state_collect_boxes_with_auto_content_visibilitycontext: *mut c_void,push_box: unsafe extern "C" fn(*mut c_void, NodeSlotId),) {- // SAFETY: Guaranteed by the caller.let boxes = {read_arena(host, read, root, |arena, root| {let mut boxes = Vec::new();@@ -866,20 +836,17 @@ pub extern "C" fn render_state_inline_paintable_has_content_pieces(host: &DocumentHost,inline_paintable: NodeSlotId,) -> bool {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), inline_paintable, |arena, inline_paintable| {- let mut has_content = false;- with_inline_pieces(&arena.paintable_rows(), inline_paintable, |piece, _| {- if !piece.is_geometry_only_placeholder {- has_content = true;- return false;- }- true- });- has_content- })- }+ read_arena(host, node_read(), inline_paintable, |arena, inline_paintable| {+ let mut has_content = false;+ with_inline_pieces(&arena.paintable_rows(), inline_paintable, |piece, _| {+ if !piece.is_geometry_only_placeholder {+ has_content = true;+ return false;+ }+ true+ });+ has_content+ })}#[repr(C)]@@ -895,7 +862,6 @@ pub extern "C" fn render_state_inline_paintable_first_piece_position(inline_paintable: NodeSlotId,out: &mut FfiOptionalCssPixelPoint,) {- // SAFETY: Guaranteed by the caller.*out = {read_arena(host, node_read(), inline_paintable, |arena, inline_paintable| {let mut result = FfiOptionalCssPixelPoint {@@ -948,7 +914,6 @@ pub unsafe extern "C" fn render_state_text_visual_lines(context: *mut c_void,push: unsafe extern "C" fn(*mut c_void, FfiVisualLine),) {- // SAFETY: Guaranteed by the caller.let lines = {read_arena(host, node_read(), primary, |arena, primary| {let fragments = arena.text_fragments(primary);@@ -995,16 +960,13 @@ pub extern "C" fn render_state_text_has_rendered_text_before(primary: NodeSlotId,offset: usize,) -> bool {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), (primary, offset), |arena, (primary, offset)| {- let fragments = arena.text_fragments(primary);- let node_slots = fragments.as_slice();- has_rendered_text_matching(&arena.paintable_rows(), node_slots, |fragment| {- fragment.dom_start_offset_in_node < offset- })+ read_arena(host, node_read(), (primary, offset), |arena, (primary, offset)| {+ let fragments = arena.text_fragments(primary);+ let node_slots = fragments.as_slice();+ has_rendered_text_matching(&arena.paintable_rows(), node_slots, |fragment| {+ fragment.dom_start_offset_in_node < offset})- }+ })}#[unsafe(no_mangle)]@@ -1013,16 +975,13 @@ pub extern "C" fn render_state_text_has_rendered_text_after(primary: NodeSlotId,offset: usize,) -> bool {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), (primary, offset), |arena, (primary, offset)| {- let fragments = arena.text_fragments(primary);- let node_slots = fragments.as_slice();- has_rendered_text_matching(&arena.paintable_rows(), node_slots, |fragment| {- fragment.dom_end_offset_in_node > offset- })+ read_arena(host, node_read(), (primary, offset), |arena, (primary, offset)| {+ let fragments = arena.text_fragments(primary);+ let node_slots = fragments.as_slice();+ has_rendered_text_matching(&arena.paintable_rows(), node_slots, |fragment| {+ fragment.dom_end_offset_in_node > offset})- }+ })}#[repr(C)]@@ -1040,7 +999,6 @@ pub extern "C" fn render_state_visual_line_caret_inline_coordinate(offset: usize,out: &mut FfiOptionalCssPixels,) {- // SAFETY: Guaranteed by the caller.*out = {read_arena(host,@@ -1078,27 +1036,24 @@ pub extern "C" fn render_state_visual_line_offset_closest_to_inline_coordinate(inline_coordinate: CssPixels,fallback_offset: usize,) -> usize {- // SAFETY: Guaranteed by the caller.- {- read_arena(- host,- node_read(),- (owner_paintable, line_index, primary, inline_coordinate, fallback_offset),- |arena, (owner_paintable, line_index, primary, inline_coordinate, fallback_offset)| {- let paintable_rows = arena.paintable_rows();- let fragments = arena.text_fragments(primary);- let node_slots = fragments.as_slice();- crate::painting::visual_lines::offset_closest_to_inline_coordinate(- &paintable_rows,- owner_paintable,- line_index,- node_slots,- inline_coordinate,- )- .unwrap_or(fallback_offset)- },- )- }+ read_arena(+ host,+ node_read(),+ (owner_paintable, line_index, primary, inline_coordinate, fallback_offset),+ |arena, (owner_paintable, line_index, primary, inline_coordinate, fallback_offset)| {+ let paintable_rows = arena.paintable_rows();+ let fragments = arena.text_fragments(primary);+ let node_slots = fragments.as_slice();+ crate::painting::visual_lines::offset_closest_to_inline_coordinate(+ &paintable_rows,+ owner_paintable,+ line_index,+ node_slots,+ inline_coordinate,+ )+ .unwrap_or(fallback_offset)+ },+ )}#[repr(C)]@@ -1118,7 +1073,6 @@ pub unsafe extern "C" fn render_state_paintable_grid_layout_json(context: *mut c_void,consume: unsafe extern "C" fn(*mut c_void, *const u8, usize),) {- // SAFETY: Guaranteed by the caller.let data = {read_arena(host, node_read(), paintable, |arena, paintable| {if !arena.paintable_row_is_populated(paintable) {@@ -1146,7 +1100,6 @@ pub unsafe extern "C" fn render_state_paintable_flex_layout_json(document_context: *const c_void,resolve_node_id: unsafe extern "C" fn(*const c_void, u32) -> i64,) {- // SAFETY: Guaranteed by the caller.let data = {read_arena(host, node_read(), paintable, |arena, paintable| {if !arena.paintable_row_is_populated(paintable) {@@ -1171,25 +1124,21 @@ pub extern "C" fn render_state_paintable_used_grid_tracks(paintable: NodeSlotId,columns: bool,) -> *const c_void {- // SAFETY: Guaranteed by the caller.- {- read_arena(- host,- node_read(),- (paintable, columns),- |arena, (paintable, columns)| {- if !arena.paintable_row_is_populated(paintable) {- return std::ptr::null();- }- let Some(tracks) = crate::painting::paintable_geometry::committed_used_grid_tracks(arena, paintable)- else {- return std::ptr::null();- };- let list = if columns { &tracks.columns } else { &tracks.rows };- std::sync::Arc::into_raw(std::sync::Arc::new(list.style_value())).cast()- },- )- }+ read_arena(+ host,+ node_read(),+ (paintable, columns),+ |arena, (paintable, columns)| {+ if !arena.paintable_row_is_populated(paintable) {+ return std::ptr::null();+ }+ let Some(tracks) = crate::painting::paintable_geometry::committed_used_grid_tracks(arena, paintable) else {+ return std::ptr::null();+ };+ let list = if columns { &tracks.columns } else { &tracks.rows };+ std::sync::Arc::into_raw(std::sync::Arc::new(list.style_value())).cast()+ },+ )}#[unsafe(no_mangle)]@@ -1205,7 +1154,6 @@ pub extern "C" fn render_state_main_visual_context_tree_retain(if let Some(tree) = host.read_known_rows(|rows, _| retain(rows.visual_context_tree.as_ref())) {return tree;}- // SAFETY: Guaranteed by the caller.read_arena(host, read, (), |arena, ()| {retain(arena.paint_state().borrow().visual_context.tree.as_ref())})@@ -1216,13 +1164,10 @@ pub extern "C" fn render_state_has_visual_context_tree(host: &DocumentHost,read: &crate::render_state::BegunRead,) -> bool {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, read, (), |arena, ()| {- let paint_state = arena.paint_state().borrow();- paint_state.visual_context.tree.is_some()- })- }+ read_arena(host, read, (), |arena, ()| {+ let paint_state = arena.paint_state().borrow();+ paint_state.visual_context.tree.is_some()+ })}#[unsafe(no_mangle)]@@ -1235,7 +1180,6 @@ pub extern "C" fn render_state_visual_context_tree_structural_epoch(.as_ref().map_or(0, |tree| tree.structural_epoch)});- // SAFETY: Guaranteed by the caller.known.unwrap_or_else(|| {read_arena(host, read, (), |arena, ()| {let paint_state = arena.paint_state().borrow();@@ -1249,17 +1193,14 @@ pub extern "C" fn render_state_visual_context_tree_has_visual_animations(host: &DocumentHost,read: &crate::render_state::BegunRead,) -> bool {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, read, (), |arena, ()| {- let paint_state = arena.paint_state().borrow();- paint_state- .visual_context- .tree- .as_deref()- .is_some_and(|tree| tree.has_visual_animations())- })- }+ read_arena(host, read, (), |arena, ()| {+ let paint_state = arena.paint_state().borrow();+ paint_state+ .visual_context+ .tree+ .as_deref()+ .is_some_and(|tree| tree.has_visual_animations())+ })}/// Hands `push_keyframe_color` the keyframe colors of each background color animation the visual context tree runs on@@ -1345,18 +1286,15 @@ pub unsafe extern "C" fn compositor_animation_effect_build(let host = Host::new(unsafe { &*host });let layout_node = request.layout_node();state.build(&request, &host, |kind| {- // SAFETY: Guaranteed by the caller.- {- read_arena(- document_host,- node_read(),- (layout_node, kind),- |arena, (layout_node, kind)| {- let tree = arena.paint_state().borrow().visual_context.tree.clone();- arena.paintable_visual_animation_target_indices(layout_node, tree.as_deref(), kind)- },- )- }+ read_arena(+ document_host,+ node_read(),+ (layout_node, kind),+ |arena, (layout_node, kind)| {+ let tree = arena.paint_state().borrow().visual_context.tree.clone();+ arena.paintable_visual_animation_target_indices(layout_node, tree.as_deref(), kind)+ },+ )})}@@ -1503,7 +1441,6 @@ pub unsafe extern "C" fn layout_arena_paint_push_svg_filter_primitive(pub extern "C" fn render_state_note_svg_paint_resources_changed(host: &DocumentHost) -> bool {let enrolled = host.svg_paint_resources_may_be_enrolled();if enrolled {- // SAFETY: As above.queue(host, PaintChange::SvgPaintResourcesChanged);}enrolleddiff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rsindex 4e662155d2c..fa8ec0e784b 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs@@ -30,7 +30,6 @@ pub extern "C" fn layout_row_paintable_physical_resize_axes(host: &crate::render_state::DocumentHost,slot: NodeSlotId,) -> FfiPhysicalResizeAxes {- // SAFETY: Guaranteed by the caller.let axes = read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::physical_resize_axes(rows, slot)});@@ -52,7 +51,6 @@ pub extern "C" fn layout_row_paintable_compute_scrollbar_data(device_pixels_per_css_pixel: f64,out: &mut FfiOptionalScrollbarData,) {- // SAFETY: Guaranteed by the caller.let data = read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::ChromeGeometry { arena: rows, metrics }.compute_scrollbar_data(slot,@@ -85,7 +83,6 @@ pub extern "C" fn layout_row_paintable_minimum_scroll_offset(slot: NodeSlotId,out: &mut FfiCssPixelPoint,) {- // SAFETY: Guaranteed by the caller.*out = {read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::minimum_scroll_offset(rows, slot)@@ -100,7 +97,6 @@ pub extern "C" fn layout_row_paintable_maximum_scroll_offset(slot: NodeSlotId,out: &mut FfiCssPixelPoint,) {- // SAFETY: Guaranteed by the caller.*out = {read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::maximum_scroll_offset(rows, slot)@@ -114,7 +110,6 @@ pub extern "C" fn layout_row_paintable_wheel_scrollable_axes(host: &crate::render_state::DocumentHost,slot: NodeSlotId,) -> FfiPhysicalResizeAxes {- // SAFETY: Guaranteed by the caller.let axes = read_measured_rows(host, super::node_read(), |rows| {crate::painting::chrome_geometry::wheel_scrollable_axes(rows, slot)});@@ -133,7 +128,6 @@ pub unsafe extern "C" fn layout_row_snap_container_geometry(snap_container: NodeSlotId,out_geometry: *mut crate::painting::host::FfiSnapContainerGeometry,) -> bool {- // SAFETY: Guaranteed by the caller.let geometry = read_measured_rows(host, super::node_read(), |rows| {crate::painting::scroll_snap::snap_container_geometry(rows, snap_container)});@@ -152,7 +146,6 @@ pub extern "C" fn layout_row_scroll_snapport_rect(scrollport: FfiCssPixelRect,out: &mut FfiCssPixelRect,) {- // SAFETY: Guaranteed by the caller.*out = {read_measured_rows(host, super::node_read(), |rows| {crate::painting::scroll_snap::scroll_snapport_rect(rows, snap_container, scrollport.into())@@ -166,7 +159,6 @@ pub extern "C" fn layout_row_scroll_snap_axes(host: &crate::render_state::DocumentHost,snap_container: NodeSlotId,) -> crate::painting::host::FfiSnapAxes {- // SAFETY: Guaranteed by the caller.read_measured_rows(host, super::node_read(), |rows| {crate::painting::scroll_snap::snap_axes_of_scroll_container(rows, snap_container)})@@ -183,7 +175,6 @@ pub extern "C" fn render_state_scroll_target_for_text_position(scroll_block_axis: bool,offset_out: &mut FfiCssPixelPoint,) -> NodeSlotId {- // SAFETY: Guaranteed by the caller.let target = {read_arena(host,@@ -215,23 +206,20 @@ pub extern "C" fn render_state_scrolling_box_for_scroll_step(viewport: NodeSlotId,delta: FfiCssPixelPoint,) -> NodeSlotId {- // SAFETY: Guaranteed by the caller.- {- read_arena(- host,- super::node_read(),- (target, viewport, delta),- |arena, (target, viewport, delta)| {- arena.measure_scrollable_overflow();- crate::painting::scroll_chain::scrolling_box_for_scroll_step(- &arena.paintable_rows(),- target,- viewport,- delta.into(),- )- },- )- }+ read_arena(+ host,+ super::node_read(),+ (target, viewport, delta),+ |arena, (target, viewport, delta)| {+ arena.measure_scrollable_overflow();+ crate::painting::scroll_chain::scrolling_box_for_scroll_step(+ &arena.paintable_rows(),+ target,+ viewport,+ delta.into(),+ )+ },+ )}/// # Safety@@ -246,7 +234,6 @@ pub unsafe extern "C" fn render_state_for_each_wheel_scrollable_box_in_containincontext: *mut c_void,push_scrollable_box: unsafe extern "C" fn(*mut c_void, NodeSlotId, f64, f64),) {- // SAFETY: Guaranteed by the caller.let boxes = {read_arena(host,@@ -279,7 +266,6 @@ pub extern "C" fn render_state_box_ending_scroll_chain(delta_x: f64,delta_y: f64,) -> NodeSlotId {- // SAFETY: Guaranteed by the caller.read_arena(host,node_read(),@@ -295,16 +281,13 @@ pub extern "C" fn render_state_first_wheel_scrollable_box_in_containing_block_chhost: &crate::render_state::DocumentHost,start: NodeSlotId,) -> NodeSlotId {- // SAFETY: Guaranteed by the caller.- {- read_arena(host, node_read(), start, |arena, start| {- arena.measure_scrollable_overflow();- crate::painting::scroll_chain::first_wheel_scrollable_box_in_containing_block_chain(- &arena.paintable_rows(),- start,- )- })- }+ read_arena(host, node_read(), start, |arena, start| {+ arena.measure_scrollable_overflow();+ crate::painting::scroll_chain::first_wheel_scrollable_box_in_containing_block_chain(+ &arena.paintable_rows(),+ start,+ )+ })}/// Prepares the document of `host` for rendering, and stores the scroll offsets the new overflow moved out of range.@@ -335,7 +318,6 @@ pub unsafe extern "C" fn render_state_prepare_for_rendering(let main_thread = unsafe { main_thread(host) };if let Some(geometry_host) = host.host_tables().geometry_host.get() {for (slot, offset) in prepared.clamped_scroll_offsets {- // SAFETY: The pass clamped the offsets of live rows, and the host holds no borrow of the arena.geometry_host.set_scroll_offset(&main_thread, read, slot, offset.into());}}@@ -387,7 +369,6 @@ pub unsafe extern "C" fn compositor_animation_effect_publish_pending(// SAFETY: Guaranteed by the caller.let animations = unsafe { crate::painting::visual_animation_builder::effect_state_from_handle(state) }.publish_pending(reuse_retained_timing_anchors);- // SAFETY: As above.host.publish_compositor_animations(animations);}@@ -512,7 +493,6 @@ pub unsafe extern "C" fn render_state_for_each_snap_area(context: *mut c_void,push_snap_area: unsafe extern "C" fn(*mut c_void, *const crate::painting::host::FfiSnapAreaGeometry),) {- // SAFETY: Guaranteed by the caller.let areas = {read_arena(host, super::node_read(), snap_container, |arena, snap_container| {let mut areas = Vec::new();@@ -575,7 +555,6 @@ pub unsafe extern "C" fn render_state_take_recording_trace(let Some(pending) = host.recording().take_pending_recording_trace() else {return false;};- // SAFETY: As above.let recording = read_arena(host, read, (), |arena, ()| {arena.paint_state().borrow().last_recording.clone()});@@ -614,7 +593,6 @@ pub unsafe extern "C" fn render_state_for_each_subtree_fragment_rect(context: *mut c_void,consume: unsafe extern "C" fn(*mut c_void, NodeSlotId, FfiCssPixelRect),) {- // SAFETY: Guaranteed by the caller.let rects = {read_arena(host, super::node_read(), root, |arena, root| {let paintable_rows = arena.paintable_rows();@@ -690,7 +668,6 @@ pub unsafe extern "C" fn render_state_record_display_list(let frame_inputs = frame_inputs(host, viewport, &inputs, &recorder);// SAFETY: The host lends the input arrays and buffers for this call, and the inputs copy what they read of them.let inputs = unsafe { inputs.recording_inputs() };- // SAFETY: Guaranteed by the caller.let Some(frame) = read_arena(host,read,@@ -974,7 +951,6 @@ fn with_hit_test_list<R>(&crate::painting::paint_read::PaintSource<'_>,) -> R,) -> R {- // SAFETY: The host is live.let rows = host.fresh_measured_rows(read);let absolute_rects = std::cell::RefCell::default();let source = crate::painting::paint_read::PaintSource::over_rows(&rows.paintable, &absolute_rects);@@ -1085,7 +1061,6 @@ pub extern "C" fn layout_paintable_event_dispatch_target(read: &crate::render_state::BegunRead,slot: NodeSlotId,) -> crate::painting::host::FfiNodeIdentity {- // SAFETY: Guaranteed by the caller.read_measured_rows(host, read, |rows| {crate::painting::hit_test::resolve::event_dispatch_target_of_paintable(rows, slot)})diff --git a/Libraries/LibWeb/Rust/src/painting/layout_tree_dump.rs b/Libraries/LibWeb/Rust/src/painting/layout_tree_dump.rsindex 325ef9b3658..e235f151921 100644--- a/Libraries/LibWeb/Rust/src/painting/layout_tree_dump.rs+++ b/Libraries/LibWeb/Rust/src/painting/layout_tree_dump.rs@@ -74,14 +74,12 @@ impl FfiLayoutTreeDumpCallbacks {identifier_sink: &mut Vec<u8>,) {// The C++ host fills both sinks synchronously through the exported push function.- {- (self.describe_dom_node)(- self.document,- node,- (&raw mut *tag_name_sink).cast(),- (&raw mut *identifier_sink).cast(),- );- }+ (self.describe_dom_node)(+ self.document,+ node,+ (&raw mut *tag_name_sink).cast(),+ (&raw mut *identifier_sink).cast(),+ );}fn navigable_container_content_document(@@ -111,15 +109,13 @@ impl FfiLayoutTreeDumpCallbacks {// The C++ host re-enters the dump for the nested document's own arena and appends// into the output sink synchronously through the exported push function; no reference to// the output vector is alive across the call.- {- (self.dump_nested_layout_tree)(- self.context,- layout_root,- indent,- interactive,- (&raw mut *output).cast(),- );- }+ (self.dump_nested_layout_tree)(+ self.context,+ layout_root,+ indent,+ interactive,+ (&raw mut *output).cast(),+ );}fn append_text(&self, _: &MainThread, bytes: &[u8]) {diff --git a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs b/Libraries/LibWeb/Rust/src/painting/paint_changes.rsindex ff6f4913d45..d91d4c9204e 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs@@ -215,13 +215,11 @@ pub(crate) fn queue(host: &DocumentHost, change: PaintChange) {#[unsafe(no_mangle)]pub extern "C" fn render_state_set_viewport_scroll_offset(host: &DocumentHost, offset: FfiCssPixelPoint) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::SetViewportScrollOffset(offset.into()));}#[unsafe(no_mangle)]pub extern "C" fn render_state_invalidate_scroll_state(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::InvalidateScrollState);}@@ -250,13 +248,11 @@ pub unsafe extern "C" fn render_state_apply_selection(start_offset,end_offset,};- // SAFETY: Guaranteed by the caller.queue(host, change);}#[unsafe(no_mangle)]pub extern "C" fn render_state_clear_selection(host: &DocumentHost, viewport: NodeSlotId) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::ClearSelection { viewport });}@@ -291,7 +287,6 @@ pub unsafe extern "C" fn render_state_apply_search_text(ranges,entries,};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -302,7 +297,6 @@ pub extern "C" fn render_state_clear_search_text(host: &DocumentHost) {if !host.host_tables().shows_search_text.replace(false) {return;}- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::ClearSearchText);}@@ -325,7 +319,6 @@ pub extern "C" fn render_state_sync_highlight_pseudo_styles(search_text_current_style_record,],};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -341,7 +334,6 @@ pub extern "C" fn render_state_set_scrollbar_enlarged(direction,enlarged,};- // SAFETY: Guaranteed by the caller.queue(host, change);}@@ -381,12 +373,10 @@ pub unsafe extern "C" fn render_state_set_layer_image_paint_facts(rows_with_facts.insert(node);}drop(rows_with_facts);- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::SetLayerImagePaintFacts { node, entries });}fn queue_replaced_paint_facts(host: &DocumentHost, target: MarkedBox, facts: ReplacedPaintFacts) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::SetReplacedPaintFacts { target, facts });}@@ -394,7 +384,6 @@ fn queue_replaced_paint_facts(host: &DocumentHost, target: MarkedBox, facts: Rep/// applies them: the element may change beside a frame in flight, which holds the boxes.fn queue_element_paint_facts(host: &DocumentHost, element: u32, facts: ReplacedPaintFacts) {if let Some(element) = StyleNodeID::from_raw(element) {- // SAFETY: Guaranteed by the caller.queue_replaced_paint_facts(host, MarkedBox::Node(Some(element)), facts);}}@@ -405,7 +394,6 @@ pub extern "C" fn render_state_set_form_control_paint_facts(element: u32,facts: FfiFormControlPaintFacts,) {- // SAFETY: Guaranteed by the caller.queue_element_paint_facts(host, element, ReplacedPaintFacts::FormControl(facts));}@@ -413,7 +401,6 @@ pub extern "C" fn render_state_set_form_control_paint_facts(/// paints.#[unsafe(no_mangle)]pub extern "C" fn render_state_set_canvas_paint_facts(host: &DocumentHost, element: u32, facts: FfiCanvasPaintFacts) {- // SAFETY: Guaranteed by the caller.queue_element_paint_facts(host, element, ReplacedPaintFacts::Canvas(facts));}@@ -426,7 +413,6 @@ pub extern "C" fn render_state_set_navigable_container_paint_facts(facts: FfiNavigableContainerPaintFacts,) {let facts = ReplacedPaintFacts::NavigableContainer(facts);- // SAFETY: Guaranteed by the caller.queue_replaced_paint_facts(host, MarkedBox::Row(node), facts);}@@ -443,7 +429,6 @@ pub unsafe extern "C" fn render_state_set_replaced_image_paint_facts() {// SAFETY: Guaranteed by the caller.let facts = unsafe { ImagePaintFacts::from_ffi(&facts) };- // SAFETY: Guaranteed by the caller.queue_replaced_paint_facts(host, MarkedBox::Row(node), ReplacedPaintFacts::Image(facts));}@@ -461,7 +446,6 @@ pub unsafe extern "C" fn render_state_set_element_image_paint_facts() {// SAFETY: Guaranteed by the caller.let facts = unsafe { ImagePaintFacts::from_ffi(&facts) };- // SAFETY: Guaranteed by the caller.queue_element_paint_facts(host, element, ReplacedPaintFacts::Image(facts));}@@ -477,7 +461,6 @@ pub unsafe extern "C" fn render_state_set_video_paint_facts() {// SAFETY: Guaranteed by the caller.let facts = unsafe { VideoPaintFacts::from_ffi(&facts) };- // SAFETY: Guaranteed by the caller.queue_element_paint_facts(host, element, ReplacedPaintFacts::Video(facts));}@@ -512,7 +495,6 @@ pub unsafe extern "C" fn render_state_publish_image_map_areas(}}).collect();- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::PublishImageMapAreas { node, areas });}@@ -528,13 +510,11 @@ pub extern "C" fn render_state_note_visual_context_style_change(} else {VisualContextBoxDirtyKind::StyleValueChange};- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::NoteVisualContextBoxDirty { node, kind });}#[unsafe(no_mangle)]pub extern "C" fn render_state_invalidate_all_paint_caches(host: &DocumentHost) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::InvalidateAllPaintCaches);}@@ -543,12 +523,10 @@ pub extern "C" fn render_state_visual_context_request_full_rebuild(host: &DocumentHost,scope: crate::painting::visual_context::dirty::VisualContextUpdateScope,) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::RequestFullVisualContextRebuild(scope));}#[unsafe(no_mangle)]pub extern "C" fn render_state_set_recording_trace_enabled(host: &DocumentHost, enabled: bool) {- // SAFETY: Guaranteed by the caller.queue(host, PaintChange::SetRecordingTraceEnabled(enabled));}diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rsindex 671e3c6dd97..97c290df2f6 100644--- a/Libraries/LibWeb/Rust/src/render_state.rs+++ b/Libraries/LibWeb/Rust/src/render_state.rs@@ -1002,7 +1002,6 @@ mod tests {fn a_write_is_answered_with_what_it_owes_the_host() {use crate::layout::layout_changes::{LayoutWrite, write};let test_host = TestHost::new();- // SAFETY: The host lives as long as the test host.let host = test_host.host();// SAFETY: The arena lives as long as the host's render state, and the test reaches it only between jobs.let arena = unsafe { &mut *host.arena_for_test() };@@ -1027,7 +1026,6 @@ mod tests {document_host_note_paint_preparation_is_current, document_host_paint_preparation_is_current,};let test_host = TestHost::new();- // SAFETY: The host lives as long as the test host.let host = test_host.host();// SAFETY: The arena lives as long as the host's render state, and the test reaches it only between jobs.let arena = unsafe { &mut *host.arena_for_test() };@@ -1047,18 +1045,14 @@ mod tests {});};- // SAFETY: The host is live, on this thread.document_host_note_paint_preparation_is_current(host);measure();- // SAFETY: As above.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.document_host_note_paint_preparation_is_current(host);measure();- // SAFETY: As above.assert!(document_host_paint_preparation_is_current(host));arena@@ -1074,11 +1068,8 @@ mod tests {};let test_host = TestHost::new();let host = test_host.host();- // SAFETY: The host is live, on this thread.- {- document_host_note_paint_preparation_is_current(host);- render_state_mark_node_box(host, 1, FfiBoxMarks::default());- }+ document_host_note_paint_preparation_is_current(host);+ render_state_mark_node_box(host, 1, FfiBoxMarks::default());assert!(document_host_paint_preparation_is_current(host));}diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rsindex 88120d49f69..5d852ac9816 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs@@ -1752,7 +1752,6 @@ pub extern "C" fn document_host_inject_clock_tick(scroll_offset: Option<&FfiScrollOffset>,) {settle_lanes_for_testing();- // SAFETY: Guaranteed by the caller.let scroll_offsets = scroll_offset.map_or(&[][..], std::slice::from_ref);host.clock_ticks().tick(frame_time_nanoseconds, scroll_offsets);settle_lanes_for_testing();