Skip to content

Truly independent web browser

LibWeb: Walk the children of a style value in one place

Andreas Kling998ed7cd9fac
diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rs
index f15ff391748..fd9039e446d 100644
--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs
@@ -22,10 +22,9 @@ use crate::css::style_value::{
BackgroundSizePayload, BorderImageSlicePayload, BorderRadiusPayload, BorderRadiusRectPayload, CalculatedPayload,
ColorFunctionPayload, ColorMixPayload, ColorSchemePayload, ConicGradientPayload, ContentPayload,
CounterDefinitionsPayload, CounterPayload, CounterStylePayload, CursorPayload, EasingPayload, FunctionPayload,
- GridTrackPlacementPayload, GridTrackSizeListPayload, ImagePayload, ImageSetPayload, LightDarkPayload,
- LinearGradientPayload, OpenTypeTaggedPayload, PositionPayload, RadialGradientPayload, RadialSizePayload,
- RandomValueSharingPayload, RatioPayload, RayPayload, RectPayload, ScrollbarColorPayload, ShadowPayload,
- ShorthandPayload, UrlPayload,
+ GridTrackPlacementPayload, GridTrackSizeListPayload, ImagePayload, ImageSetPayload, LinearGradientPayload,
+ OpenTypeTaggedPayload, PositionPayload, RadialGradientPayload, RadialSizePayload, RandomValueSharingPayload,
+ RatioPayload, RayPayload, RectPayload, ScrollbarColorPayload, ShadowPayload, ShorthandPayload, UrlPayload,
};
use crate::css::style_value_arc::StyleValueArc;
use ak::math;
@@ -1678,38 +1677,6 @@ pub(crate) fn container_relative_axes_read(unit_mask: u8, subject_inline_axis_is
}
pub(crate) fn collect_external_value_dependencies(value: &StyleValueData) -> ExternalValueDependencies {
- fn collect_optional(value: &RetainedStyleValueData, dependencies: &mut ExternalValueDependencies) {
- if let Some(value) = value.optional_data() {
- collect(value, dependencies);
- }
- }
-
- fn collect_values(values: &[&RetainedStyleValueData], dependencies: &mut ExternalValueDependencies) {
- for value in values {
- collect_optional(value, dependencies);
- }
- }
-
- fn collect_grid_entries(
- entries: &[crate::css::style_value::RetainedGridTrackEntry],
- dependencies: &mut ExternalValueDependencies,
- ) {
- for entry in entries {
- match entry.kind {
- GridTrackEntryKind::LineNames => {}
- GridTrackEntryKind::Size => collect(entry.size_value.data(), dependencies),
- GridTrackEntryKind::MinMax => {
- collect(entry.min_value.data(), dependencies);
- collect(entry.max_value.data(), dependencies);
- }
- GridTrackEntryKind::Repeat => {
- collect_grid_entries(entry.repeat_entries(), dependencies);
- collect_optional(&entry.repeat_count, dependencies);
- }
- }
- }
- }
-
fn collect_calculation(node: &crate::css::calc::CalcNode, dependencies: &mut ExternalValueDependencies) {
match node {
crate::css::calc::CalcNode::Numeric(crate::css::calc::CalcNumericValue::Length { unit, .. }) => {
@@ -1764,260 +1731,16 @@ pub(crate) fn collect_external_value_dependencies(value: &StyleValueData) -> Ext
let CalculatedPayload { rust_calculation, .. } = &**calculated_payload;
collect_calculation(rust_calculation.node(), dependencies);
}
- StyleValueData::Ratio(ratio_payload) => {
- let RatioPayload {
- numerator, denominator, ..
- } = &**ratio_payload;
- collect_values(&[numerator, denominator], dependencies);
- }
- StyleValueData::Edge { offset, .. } => collect_optional(offset, dependencies),
- StyleValueData::Anchor(_) | StyleValueData::AnchorSize(_) => {
- let (_, _, fallback_value) = value.anchor_name_and_fallback().unwrap();
- collect_optional(fallback_value, dependencies);
- }
- StyleValueData::Ray(ray_payload) => {
- let RayPayload { angle, position, .. } = &**ray_payload;
- collect_optional(angle, dependencies);
- collect_optional(position, dependencies);
- }
- StyleValueData::Function(function) => collect_optional(&function.value, dependencies),
- StyleValueData::OpenTypeTagged(open_type_tagged) => collect_optional(&open_type_tagged.value, dependencies),
- StyleValueData::GridTrackPlacement(grid_track_placement) => {
- collect_optional(&grid_track_placement.value, dependencies);
- }
- StyleValueData::OpacityValue { value } | StyleValueData::Filter { value, .. } => {
- collect_optional(value, dependencies);
- }
- StyleValueData::GridTrackSizeList(grid_track_size_list_payload) => {
- let GridTrackSizeListPayload { entries, .. } = &**grid_track_size_list_payload;
- collect_grid_entries(entries.as_slice(), dependencies);
- }
- StyleValueData::ColorFunction(color_function_payload) => {
- let ColorFunctionPayload {
- channel_0,
- channel_1,
- channel_2,
- alpha,
- origin_color,
- ..
- } = &**color_function_payload;
- collect_values(&[channel_0, channel_1, channel_2, alpha, origin_color], dependencies);
- }
- StyleValueData::BorderImageSlice(border_image_slice) => {
- let BorderImageSlicePayload {
- top,
- right,
- bottom,
- left,
- ..
- } = &**border_image_slice;
- collect_values(&[top, right, bottom, left], dependencies);
- }
- StyleValueData::Rect(rect_payload) => {
- let RectPayload {
- top,
- right,
- bottom,
- left,
- } = &**rect_payload;
- collect_values(&[top, right, bottom, left], dependencies);
- }
- StyleValueData::Content(content_payload) => {
- let ContentPayload { content, alt_text } = &**content_payload;
- collect(content.data(), dependencies);
- collect_optional(alt_text, dependencies);
- }
- StyleValueData::RadialSize(radial_size_payload) => {
- let RadialSizePayload { value_0, value_1, .. } = &**radial_size_payload;
- collect_values(&[value_0, value_1], dependencies);
- }
- StyleValueData::BasicShape { shape } => {
- let BasicShapeData {
- v0,
- v1,
- v2,
- v3,
- v4,
- points,
- ..
- } = shape.as_ref();
- collect_values(&[v0, v1, v2, v3, v4], dependencies);
- for point in points.as_slice() {
- for value in point.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::Counter(counter_payload) => {
- let CounterPayload { counter_style, .. } = &**counter_payload;
- collect(counter_style.data(), dependencies);
- }
StyleValueData::RandomValueSharing(random_value_sharing_payload) => {
- let RandomValueSharingPayload { fixed_value, .. } = &**random_value_sharing_payload;
dependencies.uses_random_function = true;
- if fixed_value.optional_data().is_some() {
- collect_optional(fixed_value, dependencies);
- } else {
- dependencies.has_unfixed_random_sharing = true;
- }
- }
- StyleValueData::Cursor(cursor_payload) => {
- let CursorPayload { image, x, y } = &**cursor_payload;
- collect(image.data(), dependencies);
- collect_values(&[x, y], dependencies);
- }
- StyleValueData::Easing(easing_payload) => {
- let EasingPayload {
- linear_stops,
- x1,
- y1,
- x2,
- y2,
- number_of_intervals,
- ..
- } = &**easing_payload;
- collect_values(&[x1, y1, x2, y2, number_of_intervals], dependencies);
- for stop in linear_stops.as_slice() {
- for value in stop.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::ImageSet(image_set_payload) => {
- let ImageSetPayload { options } = &**image_set_payload;
- dependencies.device_pixel_ratio_dependent = true;
- for option in options.as_slice() {
- for value in option.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::CounterDefinitions(counter_definitions_payload) => {
- let CounterDefinitionsPayload { counter_definitions } = &**counter_definitions_payload;
- for definition in counter_definitions.as_slice() {
- collect_optional(definition.value(), dependencies);
- }
- }
- StyleValueData::LinearGradient(linear_gradient_payload) => {
- let LinearGradientPayload {
- direction_value,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**linear_gradient_payload;
- collect_values(&[direction_value, color_interpolation_method], dependencies);
- for stop in color_stop_list.as_slice() {
- for value in stop.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::ConicGradient(conic_gradient_payload) => {
- let ConicGradientPayload {
- from_angle,
- position,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**conic_gradient_payload;
- collect_values(&[from_angle, position, color_interpolation_method], dependencies);
- for stop in color_stop_list.as_slice() {
- for value in stop.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::RadialGradient(radial_gradient_payload) => {
- let RadialGradientPayload {
- size,
- position,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**radial_gradient_payload;
- collect_values(&[size, position, color_interpolation_method], dependencies);
- for stop in color_stop_list.as_slice() {
- for value in stop.values() {
- collect_optional(value, dependencies);
- }
- }
- }
- StyleValueData::ColorMix(color_mix_payload) => {
- let ColorMixPayload {
- color_interpolation_method,
- colors,
- percentages,
- ..
- } = &**color_mix_payload;
- collect_values(&[color_interpolation_method], dependencies);
- collect_values(&colors.as_slice().iter().collect::<Vec<_>>(), dependencies);
- collect_values(&percentages.as_slice().iter().collect::<Vec<_>>(), dependencies);
- }
- StyleValueData::ContrastColor { color, .. } => collect(color.data(), dependencies),
- StyleValueData::LightDark(light_dark_payload) => {
- let LightDarkPayload { light, dark, .. } = &**light_dark_payload;
- dependencies.color_scheme_dependent = true;
- collect_values(&[light, dark], dependencies);
- }
- StyleValueData::Superellipse { parameter } => collect_optional(parameter, dependencies),
- StyleValueData::ScrollbarColor(scrollbar_color_payload) => {
- let ScrollbarColorPayload {
- thumb_color,
- track_color,
- } = &**scrollbar_color_payload;
- collect_values(&[thumb_color, track_color], dependencies);
- }
- StyleValueData::FontStyle { angle_value, .. } => collect_optional(angle_value, dependencies),
- StyleValueData::TextIndent { length_percentage, .. } => {
- collect_optional(length_percentage, dependencies);
- }
- StyleValueData::OverflowClipMargin { offset, .. } => collect_optional(offset, dependencies),
- StyleValueData::BackgroundSize(background_size_payload) => {
- let BackgroundSizePayload { size_x, size_y } = &**background_size_payload;
- collect_values(&[size_x, size_y], dependencies);
- }
- StyleValueData::Position(position_payload) => {
- let PositionPayload { edge_x, edge_y } = &**position_payload;
- collect_values(&[edge_x, edge_y], dependencies);
- }
- StyleValueData::Shadow(shadow_payload) => {
- let ShadowPayload {
- color,
- offset_x,
- offset_y,
- blur_radius,
- spread_distance,
- ..
- } = &**shadow_payload;
- collect_values(&[color, offset_x, offset_y, blur_radius, spread_distance], dependencies);
- }
- StyleValueData::Shorthand(_)
- | StyleValueData::ValueList { .. }
- | StyleValueData::Tuple { .. }
- | StyleValueData::Transformation(_) => {
- for value in value.child_values().unwrap().as_slice() {
- collect_optional(value, dependencies);
- }
- }
- StyleValueData::BorderRadiusRect(border_radius_rect_payload) => {
- let BorderRadiusRectPayload {
- top_left,
- top_right,
- bottom_right,
- bottom_left,
- } = &**border_radius_rect_payload;
- collect_values(&[top_left, top_right, bottom_right, bottom_left], dependencies);
- }
- StyleValueData::BorderRadius(border_radius_payload) => {
- let BorderRadiusPayload {
- horizontal_radius,
- vertical_radius,
- ..
- } = &**border_radius_payload;
- collect_values(&[horizontal_radius, vertical_radius], dependencies);
+ dependencies.has_unfixed_random_sharing |=
+ random_value_sharing_payload.fixed_value.optional_data().is_none();
}
+ StyleValueData::ImageSet(_) => dependencies.device_pixel_ratio_dependent = true,
+ StyleValueData::LightDark(_) => dependencies.color_scheme_dependent = true,
_ => {}
}
+ value.for_each_child(&mut |child| collect(child, dependencies));
}
let mut dependencies = ExternalValueDependencies::default();
@@ -2061,275 +1784,24 @@ pub(crate) fn random_caching_key(sharing: &StyleValueData) -> (&[u16], bool) {
}
/// Collects the element- or document-cached random sharing nodes reachable through the
-/// recursively absolutized style-value graph. Keep this aligned with new structural variants
-/// and with `absolutize::absolutize`.
+/// recursively absolutized style-value graph.
pub(crate) fn collect_unfixed_random_sharings_in_value(
value: &StyleValueData,
sharings: &mut Vec<*const StyleValueData>,
) {
- fn collect_optional(value: &RetainedStyleValueData, sharings: &mut Vec<*const StyleValueData>) {
- if let Some(value) = value.optional_data() {
- collect_unfixed_random_sharings_in_value(value, sharings);
- }
- }
-
- fn collect_list(values: &RetainedStyleValueDataList, sharings: &mut Vec<*const StyleValueData>) {
- for value in values.as_slice() {
- collect_optional(value, sharings);
- }
- }
-
- fn collect_grid_entries(
- entries: &[crate::css::style_value::RetainedGridTrackEntry],
- sharings: &mut Vec<*const StyleValueData>,
- ) {
- for entry in entries {
- match entry.kind {
- GridTrackEntryKind::LineNames => {}
- GridTrackEntryKind::Size => collect_optional(&entry.size_value, sharings),
- GridTrackEntryKind::MinMax => {
- collect_optional(&entry.min_value, sharings);
- collect_optional(&entry.max_value, sharings);
- }
- GridTrackEntryKind::Repeat => {
- collect_grid_entries(entry.repeat_entries(), sharings);
- collect_optional(&entry.repeat_count, sharings);
- }
- }
- }
- }
-
- let collect_values = |values: &[&RetainedStyleValueData], sharings: &mut Vec<*const StyleValueData>| {
- for value in values {
- collect_optional(value, sharings);
- }
- };
match value {
StyleValueData::Calculated(calculated_payload) => {
let CalculatedPayload { rust_calculation, .. } = &**calculated_payload;
crate::css::calc::collect_unfixed_random_sharings(rust_calculation.node(), sharings);
}
- StyleValueData::GridTrackSizeList(grid_track_size_list_payload) => {
- let GridTrackSizeListPayload { entries, .. } = &**grid_track_size_list_payload;
- collect_grid_entries(entries.as_slice(), sharings);
- }
- StyleValueData::Anchor(_) | StyleValueData::AnchorSize(_) => {
- let (_, _, fallback_value) = value.anchor_name_and_fallback().unwrap();
- collect_optional(fallback_value, sharings);
- }
- StyleValueData::RandomValueSharing(random_value_sharing_payload) => {
- let RandomValueSharingPayload { fixed_value, .. } = &**random_value_sharing_payload;
- match fixed_value.optional_data() {
- Some(fixed_value) => collect_unfixed_random_sharings_in_value(fixed_value, sharings),
- None => {
- if !sharings.contains(&std::ptr::from_ref(value)) {
- sharings.push(value);
- }
- }
- }
- }
- StyleValueData::Ratio(ratio_payload) => {
- let RatioPayload { numerator, denominator } = &**ratio_payload;
- collect_values(&[numerator, denominator], sharings);
- }
- StyleValueData::Edge { offset, .. } => collect_values(&[offset], sharings),
- StyleValueData::Ray(ray_payload) => {
- let RayPayload { angle, position, .. } = &**ray_payload;
- collect_values(&[angle, position], sharings);
- }
- StyleValueData::Function(function) => collect_values(&[&function.value], sharings),
- StyleValueData::OpenTypeTagged(open_type_tagged) => collect_values(&[&open_type_tagged.value], sharings),
- StyleValueData::GridTrackPlacement(grid_track_placement) => {
- collect_values(&[&grid_track_placement.value], sharings);
- }
- StyleValueData::OpacityValue { value } | StyleValueData::Filter { value, .. } => {
- collect_values(&[value], sharings);
- }
- StyleValueData::ColorFunction(color_function_payload) => {
- let ColorFunctionPayload {
- channel_0,
- channel_1,
- channel_2,
- alpha,
- origin_color,
- ..
- } = &**color_function_payload;
- collect_values(&[channel_0, channel_1, channel_2, alpha, origin_color], sharings);
- }
- StyleValueData::BorderImageSlice(border_image_slice) => collect_values(
- &[
- &border_image_slice.top,
- &border_image_slice.right,
- &border_image_slice.bottom,
- &border_image_slice.left,
- ],
- sharings,
- ),
- StyleValueData::Rect(rect) => collect_values(&[&rect.top, &rect.right, &rect.bottom, &rect.left], sharings),
- StyleValueData::Content(content_payload) => {
- let ContentPayload { content, alt_text } = &**content_payload;
- collect_values(&[content, alt_text], sharings);
- }
- StyleValueData::RadialSize(radial_size_payload) => {
- let RadialSizePayload { value_0, value_1, .. } = &**radial_size_payload;
- collect_values(&[value_0, value_1], sharings);
- }
- StyleValueData::BasicShape { shape } => {
- let BasicShapeData {
- v0,
- v1,
- v2,
- v3,
- v4,
- points,
- ..
- } = shape.as_ref();
- collect_values(&[v0, v1, v2, v3, v4], sharings);
- for point in points.as_slice() {
- collect_values(&point.values(), sharings);
- }
- }
- StyleValueData::Counter(counter_payload) => {
- let CounterPayload { counter_style, .. } = &**counter_payload;
- collect_values(&[counter_style], sharings);
- }
- StyleValueData::Cursor(cursor_payload) => {
- let CursorPayload { image, x, y } = &**cursor_payload;
- collect_values(&[image, x, y], sharings);
- }
- StyleValueData::Easing(easing_payload) => {
- let EasingPayload {
- linear_stops,
- x1,
- y1,
- x2,
- y2,
- number_of_intervals,
- ..
- } = &**easing_payload;
- collect_values(&[x1, y1, x2, y2, number_of_intervals], sharings);
- for stop in linear_stops.as_slice() {
- collect_values(&stop.values(), sharings);
- }
- }
- StyleValueData::ImageSet(image_set_payload) => {
- let ImageSetPayload { options } = &**image_set_payload;
- for option in options.as_slice() {
- collect_values(&option.values(), sharings);
- }
- }
- StyleValueData::CounterDefinitions(counter_definitions_payload) => {
- let CounterDefinitionsPayload { counter_definitions } = &**counter_definitions_payload;
- for definition in counter_definitions.as_slice() {
- collect_optional(definition.value(), sharings);
- }
- }
- StyleValueData::LinearGradient(linear_gradient_payload) => {
- let LinearGradientPayload {
- direction_value,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**linear_gradient_payload;
- collect_values(&[direction_value, color_interpolation_method], sharings);
- for stop in color_stop_list.as_slice() {
- collect_values(&stop.values(), sharings);
- }
- }
- StyleValueData::ConicGradient(conic_gradient_payload) => {
- let ConicGradientPayload {
- from_angle,
- position,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**conic_gradient_payload;
- collect_values(&[from_angle, position, color_interpolation_method], sharings);
- for stop in color_stop_list.as_slice() {
- collect_values(&stop.values(), sharings);
- }
- }
- StyleValueData::RadialGradient(radial_gradient_payload) => {
- let RadialGradientPayload {
- size,
- position,
- color_stop_list,
- color_interpolation_method,
- ..
- } = &**radial_gradient_payload;
- collect_values(&[size, position, color_interpolation_method], sharings);
- for stop in color_stop_list.as_slice() {
- collect_values(&stop.values(), sharings);
+ StyleValueData::RandomValueSharing(random_value_sharing_payload)
+ if random_value_sharing_payload.fixed_value.optional_data().is_none() =>
+ {
+ if !sharings.contains(&std::ptr::from_ref(value)) {
+ sharings.push(value);
}
}
- StyleValueData::ColorMix(color_mix_payload) => {
- let ColorMixPayload {
- color_interpolation_method,
- colors,
- percentages,
- ..
- } = &**color_mix_payload;
- collect_values(&[color_interpolation_method], sharings);
- collect_values(&colors.as_slice().iter().collect::<Vec<_>>(), sharings);
- collect_values(&percentages.as_slice().iter().collect::<Vec<_>>(), sharings);
- }
- StyleValueData::ContrastColor { color, .. } => collect_values(&[color], sharings),
- StyleValueData::LightDark(light_dark_payload) => {
- let LightDarkPayload { light, dark, .. } = &**light_dark_payload;
- collect_values(&[light, dark], sharings);
- }
- StyleValueData::Superellipse { parameter } => collect_values(&[parameter], sharings),
- StyleValueData::ScrollbarColor(scrollbar_color_payload) => {
- let ScrollbarColorPayload {
- thumb_color,
- track_color,
- } = &**scrollbar_color_payload;
- collect_values(&[thumb_color, track_color], sharings);
- }
- StyleValueData::FontStyle { angle_value, .. } => collect_values(&[angle_value], sharings),
- StyleValueData::TextIndent { length_percentage, .. } => collect_values(&[length_percentage], sharings),
- StyleValueData::OverflowClipMargin { offset, .. } => collect_values(&[offset], sharings),
- StyleValueData::BackgroundSize(background_size_payload) => {
- let BackgroundSizePayload { size_x, size_y } = &**background_size_payload;
- collect_values(&[size_x, size_y], sharings);
- }
- StyleValueData::Position(position_payload) => {
- let PositionPayload { edge_x, edge_y } = &**position_payload;
- collect_values(&[edge_x, edge_y], sharings);
- }
- StyleValueData::Shadow(shadow_payload) => {
- let ShadowPayload {
- color,
- offset_x,
- offset_y,
- blur_radius,
- spread_distance,
- ..
- } = &**shadow_payload;
- collect_values(&[color, offset_x, offset_y, blur_radius, spread_distance], sharings);
- }
- StyleValueData::Shorthand(_)
- | StyleValueData::ValueList { .. }
- | StyleValueData::Tuple { .. }
- | StyleValueData::Transformation(_) => collect_list(value.child_values().unwrap(), sharings),
- StyleValueData::BorderRadiusRect(border_radius_rect_payload) => {
- let BorderRadiusRectPayload {
- top_left,
- top_right,
- bottom_right,
- bottom_left,
- } = &**border_radius_rect_payload;
- collect_values(&[top_left, top_right, bottom_right, bottom_left], sharings);
- }
- StyleValueData::BorderRadius(border_radius_payload) => {
- let BorderRadiusPayload {
- horizontal_radius,
- vertical_radius,
- ..
- } = &**border_radius_payload;
- collect_values(&[horizontal_radius, vertical_radius], sharings);
- }
- _ => {}
+ _ => value.for_each_child(&mut |child| collect_unfixed_random_sharings_in_value(child, sharings)),
}
}
diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rs
index 71292f5c54f..f52fc9de077 100644
--- a/Libraries/LibWeb/Rust/src/css/style_value.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs
@@ -3235,6 +3235,142 @@ impl StyleValueData {
}
}
+ /// Calls `visit` with each value this one directly holds. The operands of a calculation are not
+ /// values: `CalcNode::for_each_child` walks those.
+ pub(crate) fn for_each_child(&self, visit: &mut impl FnMut(&Self)) {
+ fn grid_entries(entries: &[RetainedGridTrackEntry], values: &mut impl FnMut(&[&RetainedStyleValueData])) {
+ for entry in entries {
+ match entry.kind {
+ GridTrackEntryKind::LineNames => {}
+ GridTrackEntryKind::Size => values(&[&entry.size_value]),
+ GridTrackEntryKind::MinMax => values(&[&entry.min_value, &entry.max_value]),
+ GridTrackEntryKind::Repeat => {
+ grid_entries(entry.repeat_entries(), values);
+ values(&[&entry.repeat_count]);
+ }
+ }
+ }
+ }
+
+ let mut values = |children: &[&RetainedStyleValueData]| {
+ for child in children {
+ if let Some(child) = child.optional_data() {
+ visit(child);
+ }
+ }
+ };
+ match self {
+ Self::Ratio(ratio) => values(&[&ratio.numerator, &ratio.denominator]),
+ Self::Edge { offset, .. } | Self::OverflowClipMargin { offset, .. } => values(&[offset]),
+ Self::Anchor(_) | Self::AnchorSize(_) => values(&[self.anchor_name_and_fallback().unwrap().2]),
+ Self::RandomValueSharing(sharing) => values(&[&sharing.fixed_value]),
+ Self::Ray(ray) => values(&[&ray.angle, &ray.position]),
+ Self::Function(function) => values(&[&function.value]),
+ Self::OpenTypeTagged(open_type_tagged) => values(&[&open_type_tagged.value]),
+ Self::GridTrackPlacement(placement) => values(&[&placement.value]),
+ Self::OpacityValue { value } | Self::Filter { value, .. } => values(&[value]),
+ Self::GridTrackSizeList(list) => grid_entries(list.entries.as_slice(), &mut values),
+ Self::ColorFunction(color) => values(&[
+ &color.channel_0,
+ &color.channel_1,
+ &color.channel_2,
+ &color.alpha,
+ &color.origin_color,
+ ]),
+ Self::BorderImageSlice(slice) => values(&[&slice.top, &slice.right, &slice.bottom, &slice.left]),
+ Self::Rect(rect) => values(&[&rect.top, &rect.right, &rect.bottom, &rect.left]),
+ Self::Content(content) => values(&[&content.content, &content.alt_text]),
+ Self::RadialSize(size) => values(&[&size.value_0, &size.value_1]),
+ Self::BasicShape { shape } => {
+ let shape = shape.as_ref();
+ values(&[&shape.v0, &shape.v1, &shape.v2, &shape.v3, &shape.v4]);
+ for point in shape.points.as_slice() {
+ values(&point.values());
+ }
+ }
+ Self::Counter(counter) => values(&[&counter.counter_style]),
+ Self::Cursor(cursor) => values(&[&cursor.image, &cursor.x, &cursor.y]),
+ Self::Easing(easing) => {
+ values(&[
+ &easing.x1,
+ &easing.y1,
+ &easing.x2,
+ &easing.y2,
+ &easing.number_of_intervals,
+ ]);
+ for stop in easing.linear_stops.as_slice() {
+ values(&stop.values());
+ }
+ }
+ Self::ImageSet(image_set) => {
+ for option in image_set.options.as_slice() {
+ values(&option.values());
+ }
+ }
+ Self::CounterDefinitions(definitions) => {
+ for definition in definitions.counter_definitions.as_slice() {
+ values(&[definition.value()]);
+ }
+ }
+ Self::LinearGradient(gradient) => {
+ values(&[&gradient.direction_value, &gradient.color_interpolation_method]);
+ for stop in gradient.color_stop_list.as_slice() {
+ values(&stop.values());
+ }
+ }
+ Self::ConicGradient(gradient) => {
+ values(&[
+ &gradient.from_angle,
+ &gradient.position,
+ &gradient.color_interpolation_method,
+ ]);
+ for stop in gradient.color_stop_list.as_slice() {
+ values(&stop.values());
+ }
+ }
+ Self::RadialGradient(gradient) => {
+ values(&[&gradient.size, &gradient.position, &gradient.color_interpolation_method]);
+ for stop in gradient.color_stop_list.as_slice() {
+ values(&stop.values());
+ }
+ }
+ Self::ColorMix(mix) => {
+ values(&[&mix.color_interpolation_method]);
+ for color in mix.colors.as_slice() {
+ values(&[color]);
+ }
+ for percentage in mix.percentages.as_slice() {
+ values(&[percentage]);
+ }
+ }
+ Self::ContrastColor { color, .. } => values(&[color]),
+ Self::LightDark(light_dark) => values(&[&light_dark.light, &light_dark.dark]),
+ Self::Superellipse { parameter } => values(&[parameter]),
+ Self::ScrollbarColor(scrollbar) => values(&[&scrollbar.thumb_color, &scrollbar.track_color]),
+ Self::FontStyle { angle_value, .. } => values(&[angle_value]),
+ Self::TextIndent { length_percentage, .. } => values(&[length_percentage]),
+ Self::BackgroundSize(size) => values(&[&size.size_x, &size.size_y]),
+ Self::Position(position) => values(&[&position.edge_x, &position.edge_y]),
+ Self::Shadow(shadow) => values(&[
+ &shadow.color,
+ &shadow.offset_x,
+ &shadow.offset_y,
+ &shadow.blur_radius,
+ &shadow.spread_distance,
+ ]),
+ Self::Shorthand(_) | Self::ValueList { .. } | Self::Tuple { .. } | Self::Transformation(_) => {
+ for child in self.child_values().unwrap().as_slice() {
+ values(&[child]);
+ }
+ }
+ Self::BorderRadiusRect(rect) => {
+ values(&[&rect.top_left, &rect.top_right, &rect.bottom_right, &rect.bottom_left]);
+ }
+ Self::BorderRadius(radius) => values(&[&radius.horizontal_radius, &radius.vertical_radius]),
+ _ => {}
+ }
+ }
+
pub(crate) fn as_counter_style_system(&self) -> Option<&CounterStyleSystemPayload> {
match self {
Self::CounterStyleSystem(system) => Some(system),