Truly independent web browser
LibWeb: Merge the retained list macros into one
Andreas Klingbb0fd1c0111b
diff --git a/Libraries/LibWeb/Rust/src/css/absolutize.rs b/Libraries/LibWeb/Rust/src/css/absolutize.rsindex 820cc957569..5f69446aeec 100644--- a/Libraries/LibWeb/Rust/src/css/absolutize.rs+++ b/Libraries/LibWeb/Rust/src/css/absolutize.rs@@ -970,9 +970,7 @@ fn absolutize_gradient(value: &StyleValueData, context: &AbsolutizationContext)second_position,));}- Some(crate::css::style_value::RetainedColorStopList::from_retained_elements(- stops,- ))+ Some(crate::css::style_value::RetainedColorStopList::from_vec(stops))};match value {StyleValueData::LinearGradient(linear_gradient_payload) => {@@ -1330,7 +1328,7 @@ fn absolutize_basic_shape(v3: v3.clone_retained(),v4: v4.clone_retained(),fill_rule: *fill_rule,- points: crate::css::style_value::RetainedShapePointList::from_retained_points(absolutized_points),+ points: crate::css::style_value::RetainedShapePointList::from_vec(absolutized_points),path: path.clone(),commands: commands.clone(),}),@@ -1474,7 +1472,7 @@ fn absolutize_easing(Some(Absolutized::Changed(retain_new(StyleValueData::Easing(StyleValueBox::new(EasingPayload {kind: *kind,- linear_stops: crate::css::style_value::RetainedLinearEasingStopList::from_retained_elements(stops),+ linear_stops: crate::css::style_value::RetainedLinearEasingStopList::from_vec(stops),x1,y1,x2,@@ -2228,9 +2226,7 @@ pub(crate) fn absolutize(value: &StyleValueData, context: &AbsolutizationContextrebuild!(changed,StyleValueData::ImageSet(StyleValueBox::new(ImageSetPayload {- options: crate::css::style_value::RetainedImageSetOptionList::from_retained_elements(- absolutized_options- ),+ options: crate::css::style_value::RetainedImageSetOptionList::from_vec(absolutized_options),})))}@@ -2245,9 +2241,7 @@ pub(crate) fn absolutize(value: &StyleValueData, context: &AbsolutizationContextrebuild!(changed,StyleValueData::CounterDefinitions(StyleValueBox::new(CounterDefinitionsPayload {- counter_definitions: crate::css::style_value::RetainedCounterDefinitionList::from_retained_elements(- definitions- ),+ counter_definitions: crate::css::style_value::RetainedCounterDefinitionList::from_vec(definitions),})))}diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex eac6287f2c1..2f1f06cc8e9 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -187,7 +187,7 @@ pub(crate) unsafe fn style_value_from_easing(descriptor: &FfiEasingDescriptor) -StyleValueArc::into_raw(StyleValueArc::new(StyleValueData::Easing(StyleValueBox::new(crate::css::style_value::EasingPayload {kind: descriptor.kind as u8,- linear_stops: RetainedLinearEasingStopList::from_retained_elements(stops),+ linear_stops: RetainedLinearEasingStopList::from_vec(stops),x1,y1,x2,@@ -1417,7 +1417,7 @@ fn retained_calculation(has_percentages_resolve_as: context.has_percentages_resolve_as,percentages_resolve_as: context.percentages_resolve_as,resolve_numbers_as_integers: context.resolve_numbers_as_integers,- accepted_ranges: context.accepted_ranges.clone_owned(),+ accepted_ranges: context.accepted_ranges.clone(),},))))}@@ -2640,7 +2640,7 @@ fn combine_legacy_rgb(}fn empty_shape_points() -> RetainedShapePointList {- RetainedShapePointList::from_retained_points(Vec::new())+ RetainedShapePointList::from_vec(Vec::new())}fn empty_retained_fly_string() -> CssString {@@ -2890,7 +2890,7 @@ fn interpolate_basic_shape(v3: empty(),v4: empty(),fill_rule: *from_fill_rule,- points: RetainedShapePointList::from_retained_points(points),+ points: RetainedShapePointList::from_vec(points),path: crate::css::css_path::CssPath::none(),commands: crate::css::style_value::ShapeCommands::default(),}),@@ -3007,9 +3007,9 @@ fn interpolate_shape_commands(v3: empty(),v4: empty(),fill_rule: from_fill_rule,- points: RetainedShapePointList::from_retained_points(points),+ points: RetainedShapePointList::from_vec(points),path: crate::css::css_path::CssPath::none(),- commands: crate::css::style_value::ShapeCommands::new(commands),+ commands: crate::css::style_value::ShapeCommands::from_vec(commands),}),})}@@ -3191,7 +3191,7 @@ fn composite_basic_shape(v3: empty(),v4: empty(),fill_rule: *underlying_fill_rule,- points: RetainedShapePointList::from_retained_points(points),+ points: RetainedShapePointList::from_vec(points),path: crate::css::css_path::CssPath::none(),commands: crate::css::style_value::ShapeCommands::default(),}),diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs b/Libraries/LibWeb/Rust/src/css/computed_value_types.rsindex 147f1447047..cde1c269445 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs@@ -946,11 +946,6 @@ pub struct RetainedComputedResolvedTransformList {pub length: usize,}-// SAFETY: The list owns its array, which is written once as the style group is built and only read after, like the-// style values its transforms name.-unsafe impl Send for RetainedComputedResolvedTransformList where ComputedResolvedTransform: Send {}-unsafe impl Sync for RetainedComputedResolvedTransformList where ComputedResolvedTransform: Sync {}-/// Layout of the computed transform properties.#[repr(C)]#[derive(Clone, PartialEq)]diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex 8b8d70f8414..d0ab65b1314 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -46,8 +46,8 @@ pub use crate::css::computed_value_types::{};use crate::css::computed_value_views::InlineLengthPercentage;use crate::css::retained_fly_string::{RetainedUtf16FlyString, RetainedUtf16FlyStringList};+use crate::css::style_value::retained_list;use crate::css::style_value::{RetainedStyleValueData, StyleValueData};-use crate::css::style_value::{retained_list_drop, retained_list_partial_eq};use crate::css::table_group_builder::group_index;impl ComputedStyleValueHandle {@@ -224,79 +224,15 @@ impl PartialEq for SurroundValues {&& self.padding == other.padding}}-impl RetainedTextDecorationLineList {- pub(crate) fn from_vec(values: Vec<u8>) -> Self {- let slice = values.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut u8;- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[u8] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-}--impl Clone for RetainedTextDecorationLineList {- fn clone(&self) -> Self {- Self::from_vec(self.as_slice().to_vec())- }-}--impl Drop for RetainedTextDecorationLineList {- fn drop(&mut self) {- if !self.pointer.is_null() {- drop(unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(self.pointer, self.length)) });- }- }-}--impl PartialEq for RetainedTextDecorationLineList {- fn eq(&self, other: &Self) -> bool {- self.as_slice() == other.as_slice()- }-}--macro_rules! impl_retained_computed_list {- ($list:ident, $element:ty) => {- impl $list {- pub(crate) fn from_vec(values: Vec<$element>) -> Self {- let slice = values.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut $element;- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[$element] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }- }-- impl Clone for $list {- fn clone(&self) -> Self {- Self::from_vec(self.as_slice().to_vec())- }- }-- retained_list_drop!($list);- retained_list_partial_eq!($list, $element);- };-}--impl_retained_computed_list!(RetainedComputedFilterOperationList, ComputedFilterOperation);-impl_retained_computed_list!(RetainedWillChangePropertyList, u16);-impl_retained_computed_list!(+retained_list!(RetainedTextDecorationLineList, u8);+retained_list!(RetainedComputedFilterOperationList, ComputedFilterOperation);+retained_list!(RetainedWillChangePropertyList, u16);+retained_list!(RetainedComputedShadowList,crate::css::computed_value_types::ComputedShadow);-impl_retained_computed_list!(RetainedComputedCursorList, ComputedCursor);-impl_retained_computed_list!(RetainedComputedSvgDashList, ComputedSvgDash);+retained_list!(RetainedComputedCursorList, ComputedCursor);+retained_list!(RetainedComputedSvgDashList, ComputedSvgDash);impl_computed_payload_clone_and_eq!(InheritedTextValues {text_justify,line_break,@@ -486,8 +422,8 @@ impl PartialEq for FontValues {&& self.font_size_value == other.font_size_value}}-impl_retained_computed_list!(RetainedPositionAreaList, u8);-impl_retained_computed_list!(RetainedPositionTryFallbackList, ComputedPositionTryFallback);+retained_list!(RetainedPositionAreaList, u8);+retained_list!(RetainedPositionTryFallbackList, ComputedPositionTryFallback);impl_computed_payload_clone_and_eq!(EffectsValues {opacity => paint_only,filter,@@ -518,67 +454,11 @@ impl_computed_payload_clone_and_eq!(InheritedUIValues {image_rendering,});-impl RetainedComputedResolvedTransformList {- pub(crate) fn from_vec(values: Vec<ComputedResolvedTransform>) -> Self {- let slice = values.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut ComputedResolvedTransform;- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[ComputedResolvedTransform] {- if self.pointer.is_null() {- return &[];- }- // SAFETY: A non-null pointer/length pair always comes from- // from_vec's boxed slice.- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-}--impl Clone for RetainedComputedResolvedTransformList {- fn clone(&self) -> Self {- Self::from_vec(self.as_slice().to_vec())- }-}--retained_list_drop!(RetainedComputedResolvedTransformList);-retained_list_partial_eq!(RetainedComputedResolvedTransformList, ComputedResolvedTransform);--macro_rules! impl_retained_grid_list {- ($list:ident, $element:ty) => {- impl $list {- pub(crate) fn from_vec(values: Vec<$element>) -> Self {- let slice = values.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut $element;- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[$element] {- if self.pointer.is_null() {- return &[];- }- // SAFETY: A non-null pointer/length pair always comes from- // from_vec's boxed slice.- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }- }-- impl Clone for $list {- fn clone(&self) -> Self {- Self::from_vec(self.as_slice().to_vec())- }- }-- retained_list_drop!($list);- retained_list_partial_eq!($list, $element);- };-}+retained_list!(RetainedComputedResolvedTransformList, ComputedResolvedTransform);-impl_retained_grid_list!(RetainedGridTrackEntryList, ComputedGridTrackEntry);-impl_retained_grid_list!(RetainedGridNameIndexList, u32);-impl_retained_grid_list!(RetainedGridAreaList, ComputedGridArea);+retained_list!(RetainedGridTrackEntryList, ComputedGridTrackEntry);+retained_list!(RetainedGridNameIndexList, u32);+retained_list!(RetainedGridAreaList, ComputedGridArea);const EMPTY_GRID_TRACK_LIST: ComputedGridTrackList = ComputedGridTrackList {is_subgrid: false,@@ -622,7 +502,7 @@ impl GridValues {fn initial() -> Self {Self {- names: RetainedUtf16FlyStringList::from_retained_strings(Vec::new()),+ names: RetainedUtf16FlyStringList::from_vec(Vec::new()),name_indices: RetainedGridNameIndexList::from_vec(Vec::new()),entries: RetainedGridTrackEntryList::from_vec(vec![Self::auto_track_entry(), Self::auto_track_entry()]),areas: RetainedGridAreaList::from_vec(Vec::new()),@@ -664,7 +544,7 @@ impl GridValues {let mut names: Vec<RetainedUtf16FlyString> = self.names.as_slice().to_vec();names.push(name.clone());let index = (names.len() - 1) as u32;- self.names = RetainedUtf16FlyStringList::from_retained_strings(names);+ self.names = RetainedUtf16FlyStringList::from_vec(names);index}}@@ -6173,7 +6053,7 @@ impl BoxValues {is_size_container: false,is_inline_size_container: false,is_scroll_state_container: false,- container_name: RetainedUtf16FlyStringList::from_retained_strings(Vec::new()),+ container_name: RetainedUtf16FlyStringList::from_vec(Vec::new()),}}}@@ -6300,9 +6180,9 @@ impl EffectsValues {impl AnchorValues {fn initial() -> Self {Self {- anchor_names: RetainedUtf16FlyStringList::from_retained_strings(Vec::new()),+ anchor_names: RetainedUtf16FlyStringList::from_vec(Vec::new()),anchor_scope_all: false,- anchor_scope_names: RetainedUtf16FlyStringList::from_retained_strings(Vec::new()),+ anchor_scope_names: RetainedUtf16FlyStringList::from_vec(Vec::new()),// PositionAnchor::Type::Normal.position_anchor_type: 0,position_anchor_name: RetainedUtf16FlyString::none(),@@ -6342,7 +6222,7 @@ impl InheritedUIValues {is_auto: true,},color_scheme: 0,- color_schemes: RetainedUtf16FlyStringList::from_retained_strings(Vec::new()),+ color_schemes: RetainedUtf16FlyStringList::from_vec(Vec::new()),image_rendering: crate::css::css_enums::image_rendering::AUTO,color_scheme_only: false,}diff --git a/Libraries/LibWeb/Rust/src/css/parser/fonts_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/fonts_parser.rsindex 30216089018..66bd35efe13 100644--- a/Libraries/LibWeb/Rust/src/css/parser/fonts_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/fonts_parser.rs@@ -555,10 +555,10 @@ fn parse_font_source(context: &ParseContext, values: &[ComponentValue]) -> Optiolocal_name: retained(local_name),url: RetainedString::from_ascii(String::new()),url_type: 0,- url_modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ url_modifiers: RetainedRequestUrlModifierList::from_vec(Vec::new()),has_format: false,format: crate::css::css_string::CssString::none(),- tech: RetainedByteList::from_bytes(Vec::new()),+ tech: RetainedByteList::from_vec(Vec::new()),})));}@@ -602,7 +602,7 @@ fn parse_font_source(context: &ParseContext, values: &[ComponentValue]) -> OptioSome(format) => CssString::from_utf16(&format),None => crate::css::css_string::CssString::none(),},- tech: RetainedByteList::from_bytes(tech),+ tech: RetainedByteList::from_vec(tech),})))}diff --git a/Libraries/LibWeb/Rust/src/css/parser/grid_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/grid_parser.rsindex 46fd85e3524..2e9c5cc9cd3 100644--- a/Libraries/LibWeb/Rust/src/css/parser/grid_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/grid_parser.rs@@ -845,7 +845,7 @@ fn grid_shorthand(property: u16, sub_properties: Vec<u16>, values: Vec<StyleValuParseOutcome::Parsed(StyleValueArc::new(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(sub_properties),+ sub_properties: RetainedPropertyIdList::from_vec(sub_properties),values: RetainedStyleValueDataList::from_retained_values(values.into_iter().map(RetainedStyleValueData::from_owned).collect(),),@@ -965,7 +965,7 @@ fn initial_grid_values() -> [StyleValueData; 6] {})],),StyleValueData::GridTemplateArea(StyleValueBox::new(GridTemplateAreaPayload {- grid_areas: RetainedGridAreaList::from_retained_elements(Vec::new()),+ grid_areas: RetainedGridAreaList::from_vec(Vec::new()),row_count: 0,column_count: 0,})),@@ -1312,7 +1312,7 @@ fn parse_grid_template_areas(_context: &ParseContext, values: &[ComponentValue])tokens.discard_whitespace();return tokens.is_empty().then(|| {StyleValueData::GridTemplateArea(StyleValueBox::new(GridTemplateAreaPayload {- grid_areas: RetainedGridAreaList::from_retained_elements(Vec::new()),+ grid_areas: RetainedGridAreaList::from_vec(Vec::new()),row_count: 0,column_count: 0,}))@@ -1378,7 +1378,7 @@ fn parse_grid_template_areas(_context: &ParseContext, values: &[ComponentValue])}Some(StyleValueData::GridTemplateArea(StyleValueBox::new(GridTemplateAreaPayload {- grid_areas: RetainedGridAreaList::from_retained_elements(areas),+ grid_areas: RetainedGridAreaList::from_vec(areas),row_count: rows.len(),column_count: column_count.unwrap_or(0),},diff --git a/Libraries/LibWeb/Rust/src/css/parser/images_gradients_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/images_gradients_parser.rsindex 09885df6b70..401ec34b70b 100644--- a/Libraries/LibWeb/Rust/src/css/parser/images_gradients_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/images_gradients_parser.rs@@ -75,7 +75,7 @@ fn image_from_string(string: &[u16]) -> Option<StyleValueData> {Some(StyleValueData::Image(StyleValueBox::new(ImagePayload {url: RetainedString::from_utf16(string)?,url_type: 0,- url_modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ url_modifiers: RetainedRequestUrlModifierList::from_vec(Vec::new()),resource_context: image_resource_context(),})))}@@ -142,7 +142,7 @@ fn parse_image_set(context: &ParseContext, property: u16, arguments: &[Component}(!options.is_empty()).then(|| {StyleValueData::ImageSet(StyleValueBox::new(ImageSetPayload {- options: RetainedImageSetOptionList::from_retained_elements(options),+ options: RetainedImageSetOptionList::from_vec(options),}))})}@@ -287,7 +287,7 @@ fn parse_color_stop_list(}stops.push(retained_color_stop(hint, stop)?);}- Some((RetainedColorStopList::from_retained_elements(stops), color_syntax_value))+ Some((RetainedColorStopList::from_vec(stops), color_syntax_value))}fn strip_ascii_prefix<'a>(value: &'a [u16], prefix: &[u8]) -> Option<&'a [u16]> {diff --git a/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rsindex 2296bb9e903..a936f0f7b4d 100644--- a/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs@@ -302,7 +302,7 @@ fn parse_background_position(}Some(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property_id::BACKGROUND_POSITION,- sub_properties: RetainedPropertyIdList::from_property_ids(vec![+ sub_properties: RetainedPropertyIdList::from_vec(vec![property_id::BACKGROUND_POSITION_X,property_id::BACKGROUND_POSITION_Y,]),@@ -514,7 +514,7 @@ fn parse_border_radius_shorthand(} = border_radius_rect_payload.into_inner();Some(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property_id::BORDER_RADIUS,- sub_properties: RetainedPropertyIdList::from_property_ids(vec![+ sub_properties: RetainedPropertyIdList::from_vec(vec![property_id::BORDER_TOP_LEFT_RADIUS,property_id::BORDER_TOP_RIGHT_RADIUS,property_id::BORDER_BOTTOM_RIGHT_RADIUS,@@ -626,7 +626,7 @@ fn positional_shorthand(property: u16, values: Vec<StyleValueData>) -> Option<St};Some(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(longhands.to_vec()),+ sub_properties: RetainedPropertyIdList::from_vec(longhands.to_vec()),values: RetainedStyleValueDataList::from_retained_values(expanded.into_iter().map(retained).collect()),})))}@@ -749,7 +749,7 @@ fn basic_shape(v3: values.remove(0),v4: values.remove(0),fill_rule,- points: RetainedShapePointList::from_retained_points(points),+ points: RetainedShapePointList::from_vec(points),path,commands: crate::css::style_value::ShapeCommands::default(),}),@@ -940,7 +940,7 @@ fn parse_circle_or_ellipse(v3: RetainedStyleValueData::none(),v4: RetainedStyleValueData::none(),fill_rule: 0,- points: RetainedShapePointList::from_retained_points(vec![]),+ points: RetainedShapePointList::from_vec(vec![]),path: CssPath::none(),commands: crate::css::style_value::ShapeCommands::default(),}),@@ -1330,9 +1330,9 @@ fn parse_shape(context: &ParseContext, property: u16, arguments: &[ComponentValuv3: RetainedStyleValueData::none(),v4: RetainedStyleValueData::none(),fill_rule,- points: RetainedShapePointList::from_retained_points(points),+ points: RetainedShapePointList::from_vec(points),path: CssPath::none(),- commands: ShapeCommands::new(commands),+ commands: ShapeCommands::from_vec(commands),}),})}diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rsindex 8059acb2498..4ad01a50ed4 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs@@ -656,7 +656,7 @@ fn parse_import_url(context: &ParseContext, value: &ComponentValue) -> Option<PaComponentKind::Token(ParserTokenKind::String(url)) => StyleValueData::Url(StyleValueBox::new(UrlPayload {url: RetainedString::from_utf16(url)?,url_type: 0,- modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ modifiers: RetainedRequestUrlModifierList::from_vec(Vec::new()),})),ComponentKind::Token(ParserTokenKind::Url(_)) => parse_url_value(context, value)?,ComponentKind::Function { name, .. } if equals_ascii_case_insensitive(name, b"url") => {diff --git a/Libraries/LibWeb/Rust/src/css/parser/transforms_effects_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/transforms_effects_parser.rsindex 413215b361d..30630bf966b 100644--- a/Libraries/LibWeb/Rust/src/css/parser/transforms_effects_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/transforms_effects_parser.rs@@ -366,7 +366,7 @@ fn easing(let [x1, y1, x2, y2] = coordinates.map(|value| value.map_or_else(RetainedStyleValueData::none, retained));StyleValueData::Easing(StyleValueBox::new(EasingPayload {kind,- linear_stops: RetainedLinearEasingStopList::from_retained_elements(linear_stops),+ linear_stops: RetainedLinearEasingStopList::from_vec(linear_stops),x1,y1,x2,diff --git a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rsindex d31fc4c3395..fcceb0e049c 100644--- a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs@@ -468,7 +468,7 @@ pub(crate) fn parse_url_value(context: &ParseContext, value: &ComponentValue) ->Some(StyleValueData::Url(StyleValueBox::new(UrlPayload {url: RetainedString::from_utf16(url)?,url_type,- modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(modifiers),+ modifiers: RetainedRequestUrlModifierList::from_vec(modifiers),})))}@@ -1727,7 +1727,7 @@ fn parse_contain_intrinsic_size_shorthand(ParseOutcome::Parsed(shared_style_value(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(longhands.to_vec()),+ sub_properties: RetainedPropertyIdList::from_vec(longhands.to_vec()),values: RetainedStyleValueDataList::from_retained_values(expanded.into_iter().map(RetainedStyleValueData::from_owned).collect(),),@@ -2958,7 +2958,7 @@ fn parse_color_scheme_property(_context: &ParseContext, values: &[ComponentValuereturn ParseOutcome::Parsed(shared_style_value(StyleValueData::ColorScheme(StyleValueBox::new(ColorSchemePayload {schemes: CssStringList::from_strings(Vec::new()),- scheme_codes: RetainedByteList::from_bytes(Vec::new()),+ scheme_codes: RetainedByteList::from_vec(Vec::new()),only: false,},))));@@ -2997,7 +2997,7 @@ fn parse_color_scheme_property(_context: &ParseContext, values: &[ComponentValueParseOutcome::Parsed(shared_style_value(StyleValueData::ColorScheme(StyleValueBox::new(ColorSchemePayload {schemes: CssStringList::from_strings(schemes),- scheme_codes: RetainedByteList::from_bytes(scheme_codes),+ scheme_codes: RetainedByteList::from_vec(scheme_codes),only,},))))@@ -3091,7 +3091,7 @@ fn parse_counter_definitions_property(}ParseOutcome::Parsed(shared_style_value(StyleValueData::CounterDefinitions(StyleValueBox::new(CounterDefinitionsPayload {- counter_definitions: RetainedCounterDefinitionList::from_retained_elements(definitions),+ counter_definitions: RetainedCounterDefinitionList::from_vec(definitions),}),)))}@@ -4027,7 +4027,7 @@ fn parse_positional_value_list_shorthand(ParseOutcome::Parsed(shared_style_value(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(longhands.to_vec()),+ sub_properties: RetainedPropertyIdList::from_vec(longhands.to_vec()),values: RetainedStyleValueDataList::from_retained_values(expanded.into_iter().map(RetainedStyleValueData::from_owned).collect(),),@@ -4093,7 +4093,7 @@ fn retained_shorthand_value() -> StyleValueData {StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(sub_properties),+ sub_properties: RetainedPropertyIdList::from_vec(sub_properties),values: RetainedStyleValueDataList::from_retained_values(values),}))}@@ -4216,9 +4216,7 @@ fn parse_unordered_shorthand(context: &ParseContext, property: u16, values: &[CoParseOutcome::Parsed(shared_style_value(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(- order.iter().map(|&index| longhands[index]).collect(),- ),+ sub_properties: RetainedPropertyIdList::from_vec(order.iter().map(|&index| longhands[index]).collect()),values: RetainedStyleValueDataList::from_retained_values(order.into_iter()diff --git a/Libraries/LibWeb/Rust/src/css/retained_fly_string.rs b/Libraries/LibWeb/Rust/src/css/retained_fly_string.rsindex 7fb5b464285..7a2224aeb55 100644--- a/Libraries/LibWeb/Rust/src/css/retained_fly_string.rs+++ b/Libraries/LibWeb/Rust/src/css/retained_fly_string.rs@@ -10,7 +10,7 @@//! module so the same struct layout is emitted into each header's namespace,//! the same arrangement `display.rs` uses for `FfiDisplay`.-use crate::css::style_value::retained_list_partial_eq;+use crate::css::style_value::retained_list;/// A retained `AK::Utf16FlyString` with the same one-word representation.#[repr(C)]pub struct RetainedUtf16FlyString {@@ -131,24 +131,6 @@ pub struct RetainedUtf16FlyStringList {}impl RetainedUtf16FlyStringList {- pub(crate) fn from_retained_strings(strings: Vec<RetainedUtf16FlyString>) -> Self {- let slice = strings.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedUtf16FlyString;- Self { pointer, length }- }-- pub(crate) fn clone_retained(&self) -> Self {- Self::from_retained_strings(self.as_slice().to_vec())- }-- pub(crate) fn as_slice(&self) -> &[RetainedUtf16FlyString] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-/// The list viewed as raw fly-string words; fly strings are interned, so/// equal raws mean equal strings.pub(crate) fn raws(&self) -> &[usize] {@@ -160,17 +142,4 @@ impl RetainedUtf16FlyStringList {}}-impl Clone for RetainedUtf16FlyStringList {- fn clone(&self) -> Self {- self.clone_retained()- }-}--impl Drop for RetainedUtf16FlyStringList {- fn drop(&mut self) {- if !self.pointer.is_null() {- drop(unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(self.pointer, self.length)) });- }- }-}-retained_list_partial_eq!(RetainedUtf16FlyStringList, RetainedUtf16FlyString);+retained_list!(RetainedUtf16FlyStringList, RetainedUtf16FlyString);diff --git a/Libraries/LibWeb/Rust/src/css/serialize/declarations.rs b/Libraries/LibWeb/Rust/src/css/serialize/declarations.rsindex 5669ca15ecd..99f88ec0d56 100644--- a/Libraries/LibWeb/Rust/src/css/serialize/declarations.rs+++ b/Libraries/LibWeb/Rust/src/css/serialize/declarations.rs@@ -74,7 +74,7 @@ fn serialize_a_css_declaration(list: &mut Vec<TextSink>, property: &StringUnits,fn shorthand_value(shorthand: u16, longhand_values: Vec<RetainedStyleValueData>) -> StyleValueArc {StyleValueArc::new(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: shorthand,- sub_properties: RetainedPropertyIdList::from_property_ids(longhands_for_shorthand(shorthand).to_vec()),+ sub_properties: RetainedPropertyIdList::from_vec(longhands_for_shorthand(shorthand).to_vec()),values: RetainedStyleValueDataList::from_retained_values(longhand_values),})))}diff --git a/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs b/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rsindex dc2d29708b3..2d8fd4de432 100644--- a/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs+++ b/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs@@ -224,7 +224,7 @@ pub(super) fn initial(property: u16) -> Cow<'static, StyleValueData> {if !longhands.is_empty() {return Cow::Owned(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property: property,- sub_properties: RetainedPropertyIdList::from_property_ids(longhands.to_vec()),+ sub_properties: RetainedPropertyIdList::from_vec(longhands.to_vec()),values: RetainedStyleValueDataList::from_retained_values(longhands.iter()diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rsindex 504826294df..b4ca410405a 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs@@ -417,7 +417,7 @@ mod tests {StyleValueData::Url(StyleValueBox::new(UrlPayload {url: RetainedString::from_ascii(url.to_owned()),url_type: 0,- modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ modifiers: RetainedRequestUrlModifierList::from_vec(Vec::new()),}))};let first = store(property_id::FILL, url_value());@@ -428,7 +428,7 @@ mod tests {StyleValueData::Image(StyleValueBox::new(ImagePayload {url: RetainedString::from_ascii("https://example.com/image.png".to_owned()),url_type: 0,- url_modifiers: RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ url_modifiers: RetainedRequestUrlModifierList::from_vec(Vec::new()),resource_context: ImageResourceContext {base_url: RetainedString::from_ascii(base_url.to_owned()),has_base_url: true,diff --git a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rsindex f0171713834..ee67d47c04a 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs@@ -50,7 +50,7 @@ fn url_dependencies_only_read_a_base_for_relative_urls() {let value = StyleValueData::Url(StyleValueBox::new(UrlPayload {url: crate::css::style_value::RetainedString::from_utf16(&url.encode_utf16().collect::<Vec<_>>()).unwrap(),url_type: 0,- modifiers: crate::css::style_value::RetainedRequestUrlModifierList::from_retained_modifiers(Vec::new()),+ modifiers: crate::css::style_value::RetainedRequestUrlModifierList::from_vec(Vec::new()),}));let dependencies = collect_external_value_dependencies(&value);assert_eq!(dependencies.needs_document_base_url, needs_base, "{url}");diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rsindex 948235fb805..19997d5320e 100644--- a/Libraries/LibWeb/Rust/src/css/style_value.rs+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs@@ -705,63 +705,70 @@ impl Clone for RetainedStyleValueDataList {}}-/// Implements `Drop` for a `Retained*List` struct: releases the Rust-owned boxed slice,-/// dropping each element (which releases the element's own retained references).-macro_rules! retained_list_drop {- ($list:ident) => {- impl Drop for $list {- fn drop(&mut self) {- if !self.pointer.is_null() {- drop(unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(self.pointer, self.length)) });- }- }- }- };-}-pub(crate) use retained_list_drop;--/// Implements the shared behavior for a `Retained*List` struct whose `from_raw` input is an-/// array of its own element type: `from_raw` copies `length` elements into a Rust-owned boxed-/// slice, assuming ownership of the elements' retained references, and `Drop` releases them.+/// Implements the shared behavior of a Rust-owned `{ pointer, length }` array of `$element`s:+/// building it from a `Vec`, reading it as a slice, and cloning, comparing and releasing it.macro_rules! retained_list {($list:ident, $element:ty) => {+ #[allow(dead_code, reason = "not every list is both built and read on the Rust side")]impl $list {- /// Takes ownership of the elements' retained references.- ///- /// # Safety- /// `elements` must point to `length` valid elements whose retained references this- /// list may assume ownership of.- unsafe fn from_raw(elements: *const $element, length: usize) -> Self {- let slice: Box<[$element]> = (0..length)- .map(|i| unsafe { std::ptr::read(elements.add(i)) })- .collect();+ pub(crate) fn from_vec(elements: Vec<$element>) -> Self {+ if elements.is_empty() {+ return Self {+ pointer: std::ptr::null_mut(),+ length: 0,+ };+ }+ let slice = elements.into_boxed_slice();let length = slice.len();let pointer = Box::into_raw(slice) as *mut $element;Self { pointer, length }}++ pub(crate) fn as_slice(&self) -> &[$element] {+ if self.pointer.is_null() {+ return &[];+ }+ // SAFETY: A non-null pointer and its length always come from a boxed slice.+ unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }+ }}- retained_list!($list, $element, native);- };- ($list:ident, $element:ty, native) => {- retained_list_drop!($list);+impl Clone for $list {fn clone(&self) -> Self {- if self.pointer.is_null() {- return Self {- pointer: std::ptr::null_mut(),- length: 0,- };+ Self::from_vec(self.as_slice().to_vec())+ }+ }++ impl PartialEq for $list {+ fn eq(&self, other: &Self) -> bool {+ self.as_slice() == other.as_slice()+ }+ }++ impl Drop for $list {+ fn drop(&mut self) {+ if !self.pointer.is_null() {+ drop(unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(self.pointer, self.length)) });}- let elements = unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- .to_vec()- .into_boxed_slice();- let length = elements.len();- let pointer = Box::into_raw(elements).cast::<$element>();- Self { pointer, length }}}++ // SAFETY: The list owns its boxed slice and only exposes shared access to its elements.+ unsafe impl Send for $list where $element: Send {}+ unsafe impl Sync for $list where $element: Sync {}};}+pub(crate) use retained_list;++/// Moves `length` elements out of `elements`, taking over the retained references they hold.+///+/// # Safety+/// `elements` must point to `length` valid elements whose references the caller may take over.+unsafe fn read_elements<T>(elements: *const T, length: usize) -> Vec<T> {+ (0..length)+ .map(|i| unsafe { std::ptr::read(elements.add(i)) })+ .collect()+}/// A Rust-owned array of C++ PropertyID values (`enum class PropertyID : u16`, opaque to Rust).#[repr(C)]@@ -772,22 +779,6 @@ pub struct RetainedPropertyIdList {retained_list!(RetainedPropertyIdList, u16);-impl RetainedPropertyIdList {- pub(crate) fn from_property_ids(property_ids: Vec<u16>) -> Self {- let slice = property_ids.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice).cast::<u16>();- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[u16] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-}-/// Shared native URL text, independent of host strings and the atom table.#[repr(C)]pub struct RetainedString {@@ -1047,16 +1038,9 @@ pub struct RetainedRequestUrlModifierList {}impl RetainedRequestUrlModifierList {- pub(crate) fn from_retained_modifiers(modifiers: Vec<RetainedRequestUrlModifier>) -> Self {- let slice = modifiers.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedRequestUrlModifier;- Self { pointer, length }- }-/// Copies and releases each modifier's leaked host string reference.unsafe fn from_raw(elements: *const FfiRequestUrlModifier, length: usize) -> Self {- let slice: Box<[RetainedRequestUrlModifier]> = (0..length)+ let modifiers: Vec<RetainedRequestUrlModifier> = (0..length).map(|i| {let element = unsafe { &*elements.add(i) };RetainedRequestUrlModifier {@@ -1066,22 +1050,11 @@ impl RetainedRequestUrlModifierList {}}).collect();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedRequestUrlModifier;- Self { pointer, length }+ Self::from_vec(modifiers)}}-retained_list_drop!(RetainedRequestUrlModifierList);--impl Clone for RetainedRequestUrlModifierList {- fn clone(&self) -> Self {- let slice = self.as_slice().to_vec().into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedRequestUrlModifier;- Self { pointer, length }- }-}+retained_list!(RetainedRequestUrlModifierList, RetainedRequestUrlModifier);/// A Rust-owned array of bytes, used for lists of C++ u8 enum values.#[repr(C)]@@ -1090,29 +1063,7 @@ pub struct RetainedByteList {length: usize,}-retained_list_drop!(RetainedByteList);--impl Clone for RetainedByteList {- fn clone(&self) -> Self {- Self::from_bytes(self.as_slice().to_vec())- }-}--impl RetainedByteList {- pub(crate) fn from_bytes(bytes: Vec<u8>) -> Self {- let slice = bytes.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice).cast::<u8>();- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[u8] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-}+retained_list!(RetainedByteList, u8);/// A retained counter definition: the counter name, the reversed flag and an optional retained/// value (null when absent).@@ -1169,17 +1120,11 @@ impl RetainedCounterDefinitionList {}}).collect();- Self::from_retained_elements(elements)+ Self::from_vec(elements)}}-retained_list_drop!(RetainedCounterDefinitionList);--impl Clone for RetainedCounterDefinitionList {- fn clone(&self) -> Self {- Self::from_retained_elements(self.as_slice().to_vec())- }-}+retained_list!(RetainedCounterDefinitionList, RetainedCounterDefinition);/// A retained image-set() option: the image, its resolution and an optional Rust-owned type string.#[repr(C)]@@ -1198,13 +1143,7 @@ pub struct RetainedImageSetOptionList {length: usize,}-retained_list_drop!(RetainedImageSetOptionList);--impl Clone for RetainedImageSetOptionList {- fn clone(&self) -> Self {- Self::from_retained_elements(self.as_slice().to_vec())- }-}+retained_list!(RetainedImageSetOptionList, RetainedImageSetOption);/// A retained gradient color stop: an optional transition hint, then an optional color,/// position and second position (each null when absent).@@ -1224,7 +1163,7 @@ pub struct RetainedColorStopList {length: usize,}-retained_list!(RetainedColorStopList, RetainedColorStop, native);+retained_list!(RetainedColorStopList, RetainedColorStop);impl RetainedCounterDefinition {pub(crate) fn value(&self) -> &RetainedStyleValueData {@@ -1287,22 +1226,6 @@ impl RetainedLinearEasingStop {}}-macro_rules! retained_list_as_slice {- ($list:ident, $element:ty) => {- impl $list {- pub(crate) fn as_slice(&self) -> &[$element] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }- }- };-}-retained_list_as_slice!(RetainedCounterDefinitionList, RetainedCounterDefinition);-retained_list_as_slice!(RetainedImageSetOptionList, RetainedImageSetOption);-retained_list_as_slice!(RetainedLinearEasingStopList, RetainedLinearEasingStop);-impl RetainedShapePoint {pub(crate) fn values(&self) -> [&RetainedStyleValueData; 2] {[&self.x, &self.y]@@ -1312,35 +1235,6 @@ impl RetainedShapePoint {Self { x, y }}}-retained_list_as_slice!(RetainedShapePointList, RetainedShapePoint);-retained_list_as_slice!(RetainedRequestUrlModifierList, RetainedRequestUrlModifier);-retained_list_as_slice!(RetainedGridAreaList, RetainedGridArea);--macro_rules! retained_list_from_vec {- ($list:ident, $element:ty) => {- impl $list {- pub(crate) fn from_retained_elements(elements: Vec<$element>) -> Self {- let slice = elements.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut $element;- Self { pointer, length }- }- }- };-}-retained_list_from_vec!(RetainedLinearEasingStopList, RetainedLinearEasingStop);-retained_list_from_vec!(RetainedImageSetOptionList, RetainedImageSetOption);-retained_list_from_vec!(RetainedCounterDefinitionList, RetainedCounterDefinition);-retained_list_from_vec!(RetainedColorStopList, RetainedColorStop);--impl RetainedShapePointList {- pub(crate) fn from_retained_points(points: Vec<RetainedShapePoint>) -> Self {- let slice = points.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedShapePoint;- Self { pointer, length }- }-}impl RetainedColorStop {pub(crate) fn transition_hint_value(&self) -> Option<&StyleValueData> {@@ -1384,15 +1278,6 @@ impl RetainedColorStop {}}-impl RetainedColorStopList {- pub(crate) fn as_slice(&self) -> &[RetainedColorStop] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-}-/// A retained named grid area: the retained area name and its grid line indices.#[repr(C)]#[derive(Clone, PartialEq)]@@ -1455,22 +1340,7 @@ pub struct RetainedGridAreaList {length: usize,}-impl RetainedGridAreaList {- pub(crate) fn from_retained_elements(elements: Vec<RetainedGridArea>) -> Self {- let slice = elements.into_boxed_slice();- let length = slice.len();- let pointer = Box::into_raw(slice) as *mut RetainedGridArea;- Self { pointer, length }- }-}--retained_list_drop!(RetainedGridAreaList);--impl Clone for RetainedGridAreaList {- fn clone(&self) -> Self {- Self::from_retained_elements(self.as_slice().to_vec())- }-}+retained_list!(RetainedGridAreaList, RetainedGridArea);/// A retained linear() easing stop: the output value and an optional input (null when absent).#[repr(C)]@@ -1497,7 +1367,7 @@ pub struct RetainedLinearEasingStopList {length: usize,}-retained_list!(RetainedLinearEasingStopList, RetainedLinearEasingStop, native);+retained_list!(RetainedLinearEasingStopList, RetainedLinearEasingStop);/// The kind of one grid track list entry.#[repr(u8)]@@ -1661,7 +1531,7 @@ pub struct RetainedShapePointList {length: usize,}-retained_list!(RetainedShapePointList, RetainedShapePoint, native);+retained_list!(RetainedShapePointList, RetainedShapePoint);/// An accepted numeric range for one value type (the C++ `enum class ValueType : u8`, opaque/// to Rust).@@ -1705,101 +1575,32 @@ impl RetainedNumericRangeList {}pub(crate) fn from_single_numeric_range(value_type: u8, min: f64, max: f64) -> Self {- let ranges = vec![RetainedNumericRangeByType { value_type, min, max }].into_boxed_slice();- let length = ranges.len();- let pointer = Box::into_raw(ranges) as *mut RetainedNumericRangeByType;- Self { pointer, length }+ Self::from_vec(vec![RetainedNumericRangeByType { value_type, min, max }])}pub(crate) fn from_numeric_ranges(ranges: impl IntoIterator<Item = (u8, f64, f64)>) -> Self {- let ranges = ranges- .into_iter()- .map(|(value_type, min, max)| RetainedNumericRangeByType { value_type, min, max })- .collect::<Vec<_>>();- if ranges.is_empty() {- return Self::empty();- }- let ranges = ranges.into_boxed_slice();- let length = ranges.len();- let pointer = Box::into_raw(ranges) as *mut RetainedNumericRangeByType;- Self { pointer, length }- }-- pub(crate) fn as_slice(&self) -> &[RetainedNumericRangeByType] {- if self.pointer.is_null() {- return &[];- }- unsafe { ak::slice_from_raw_parts(self.pointer, self.length) }- }-- pub(crate) fn clone_owned(&self) -> Self {- let ranges = self- .as_slice()- .iter()- .map(|range| RetainedNumericRangeByType {- value_type: range.value_type,- min: range.min,- max: range.max,- })- .collect::<Vec<_>>()- .into_boxed_slice();- let length = ranges.len();- let pointer = Box::into_raw(ranges) as *mut RetainedNumericRangeByType;- Self { pointer, length }+ Self::from_vec(+ ranges+ .into_iter()+ .map(|(value_type, min, max)| RetainedNumericRangeByType { value_type, min, max })+ .collect(),+ )}}-macro_rules! retained_list_partial_eq {- ($list:ty, $element:ty) => {- impl PartialEq for $list {- fn eq(&self, other: &Self) -> bool {- let as_slice = |list: &Self| -> &[$element] {- if list.pointer.is_null() {- &[]- } else {- unsafe { ak::slice_from_raw_parts(list.pointer.cast::<$element>(), list.length) }- }- };- as_slice(self) == as_slice(other)- }- }- };-}-pub(crate) use retained_list_partial_eq;+// SAFETY: The list owns its boxed slice and only exposes shared access to its elements.+unsafe impl Send for RetainedStyleValueDataList where RetainedStyleValueData: Send {}+unsafe impl Sync for RetainedStyleValueDataList where RetainedStyleValueData: Sync {}+// SAFETY: As above.+unsafe impl Send for RetainedGridTrackEntryList where RetainedGridTrackEntry: Send {}+unsafe impl Sync for RetainedGridTrackEntryList where RetainedGridTrackEntry: Sync {}-macro_rules! retained_list_send_sync {- ($list:ty, $element:ty) => {- // SAFETY: The list owns its boxed slice and only exposes shared access to its elements.- unsafe impl Send for $list where $element: Send {}- unsafe impl Sync for $list where $element: Sync {}- };+impl PartialEq for RetainedGridTrackEntryList {+ fn eq(&self, other: &Self) -> bool {+ self.as_slice() == other.as_slice()+ }}-retained_list_send_sync!(RetainedStyleValueDataList, RetainedStyleValueData);-retained_list_send_sync!(RetainedPropertyIdList, u16);-retained_list_send_sync!(RetainedRequestUrlModifierList, RetainedRequestUrlModifier);-retained_list_send_sync!(RetainedByteList, u8);-retained_list_send_sync!(RetainedCounterDefinitionList, RetainedCounterDefinition);-retained_list_send_sync!(RetainedImageSetOptionList, RetainedImageSetOption);-retained_list_send_sync!(RetainedColorStopList, RetainedColorStop);-retained_list_send_sync!(RetainedGridAreaList, RetainedGridArea);-retained_list_send_sync!(RetainedLinearEasingStopList, RetainedLinearEasingStop);-retained_list_send_sync!(RetainedGridTrackEntryList, RetainedGridTrackEntry);-retained_list_send_sync!(RetainedShapePointList, RetainedShapePoint);-retained_list_send_sync!(RetainedNumericRangeList, RetainedNumericRangeByType);--retained_list_partial_eq!(RetainedPropertyIdList, u16);-retained_list_partial_eq!(RetainedRequestUrlModifierList, RetainedRequestUrlModifier);-retained_list_partial_eq!(RetainedByteList, u8);-retained_list_partial_eq!(RetainedCounterDefinitionList, RetainedCounterDefinition);-retained_list_partial_eq!(RetainedImageSetOptionList, RetainedImageSetOption);-retained_list_partial_eq!(RetainedColorStopList, RetainedColorStop);-retained_list_partial_eq!(RetainedGridAreaList, RetainedGridArea);-retained_list_partial_eq!(RetainedLinearEasingStopList, RetainedLinearEasingStop);-retained_list_partial_eq!(RetainedGridTrackEntryList, RetainedGridTrackEntry);-retained_list_partial_eq!(RetainedShapePointList, RetainedShapePoint);-retained_list_partial_eq!(RetainedNumericRangeList, RetainedNumericRangeByType);-/// The shared leading fields of every color variant payload: the optional color type and the/// color syntax. Placing this first in each color payload lets C++ read it without knowing/// which color variant it has.@@ -1911,16 +1712,7 @@ pub struct ShapeCommands {length: usize,}-retained_list!(ShapeCommands, ShapeCommand, native);-retained_list_as_slice!(ShapeCommands, ShapeCommand);-retained_list_from_vec!(ShapeCommands, ShapeCommand);-retained_list_send_sync!(ShapeCommands, ShapeCommand);--impl ShapeCommands {- pub(crate) fn new(commands: Vec<ShapeCommand>) -> Self {- Self::from_retained_elements(commands)- }-}+retained_list!(ShapeCommands, ShapeCommand);impl Default for ShapeCommands {fn default() -> Self {@@ -1931,12 +1723,6 @@ impl Default for ShapeCommands {}}-impl PartialEq for ShapeCommands {- fn eq(&self, other: &Self) -> bool {- self.as_slice() == other.as_slice()- }-}-/// The box a [`StyleValueData`] variant too large to sit beside the tag keeps its payload in, laid/// out as one pointer C++ reads the payload through.#[repr(C)]@@ -4458,7 +4244,9 @@ pub unsafe extern "C" fn rust_style_value_create_shorthand(StyleValueArc::into_raw(StyleValueArc::new(StyleValueData::Shorthand(StyleValueBox::new(ShorthandPayload {shorthand_property,- sub_properties: unsafe { RetainedPropertyIdList::from_raw(sub_properties, sub_property_count) },+ sub_properties: RetainedPropertyIdList::from_vec(unsafe {+ read_elements(sub_properties, sub_property_count)+ }),values: unsafe { RetainedStyleValueDataList::from_retained_pointers(values, value_count) },},))))@@ -4609,7 +4397,9 @@ pub unsafe extern "C" fn rust_style_value_create_calculated(has_percentages_resolve_as,percentages_resolve_as,resolve_numbers_as_integers,- accepted_ranges: unsafe { RetainedNumericRangeList::from_raw(accepted_ranges, accepted_range_count) },+ accepted_ranges: RetainedNumericRangeList::from_vec(unsafe {+ read_elements(accepted_ranges, accepted_range_count)+ }),},))))}diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rsindex 30c648e4056..8dd8fd8b00a 100644--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs@@ -826,7 +826,7 @@ fn build_grid_group(values: &LonghandSource, parent: GroupShares<'_>) -> *constlet retained_slot = |property: u16| ComputedStyleValueHandle::from_retained(values.handle(property));let built = GridValues {- names: RetainedUtf16FlyStringList::from_retained_strings(arena.names),+ names: RetainedUtf16FlyStringList::from_vec(arena.names),name_indices: RetainedGridNameIndexList::from_vec(arena.name_indices),entries: RetainedGridTrackEntryList::from_vec(arena.entries),areas: RetainedGridAreaList::from_vec(arena.areas),@@ -2366,9 +2366,8 @@ fn build_inherited_ui_group(unreachable!("a computed color-scheme is a color-scheme value");};let ColorSchemePayload { schemes, only, .. } = &**color_scheme_payload;- let color_schemes = RetainedUtf16FlyStringList::from_retained_strings(- schemes.as_slice().iter().map(|name| name.to_fly_string()).collect(),- );+ let color_schemes =+ RetainedUtf16FlyStringList::from_vec(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,@@ -2991,9 +2990,9 @@ fn build_anchor_group(}let built = AnchorValues {- anchor_names: RetainedUtf16FlyStringList::from_retained_strings(anchor_names),+ anchor_names: RetainedUtf16FlyStringList::from_vec(anchor_names),anchor_scope_all,- anchor_scope_names: RetainedUtf16FlyStringList::from_retained_strings(anchor_scope_names),+ anchor_scope_names: RetainedUtf16FlyStringList::from_vec(anchor_scope_names),position_anchor_type,position_anchor_name,position_area: RetainedPositionAreaList::from_vec(position_area_keywords),@@ -3315,7 +3314,7 @@ fn build_box_group(is_size_container,is_inline_size_container,is_scroll_state_container,- container_name: RetainedUtf16FlyStringList::from_retained_strings(container_names),+ container_name: RetainedUtf16FlyStringList::from_vec(container_names),};crate::css::computed_values::rust_build_box_group(group_index::BOX, built, parent)}diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rsindex 6438fb511b5..2aec504ec92 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs@@ -99,7 +99,7 @@ fn containing_block_inset_shape(arena: &impl PaintRead, node: NodeSlotId) -> Ownv3: zero(),v4: RetainedStyleValueData::from_owned(radii),fill_rule: 0,- points: crate::css::style_value::RetainedShapePointList::from_retained_points(Vec::new()),+ points: crate::css::style_value::RetainedShapePointList::from_vec(Vec::new()),path: crate::css::css_path::CssPath::none(),commands: crate::css::style_value::ShapeCommands::default(),})