Revert "gpui: Fix overflow_hidden to support clip with border radius" (#37480)

This reverts commit 40199266b6.

The issue with the commit is: ContentMask<Pixels>::intersect is doing
intersection of corner radii which makes inner containers use the max
corner radius out of all the parents when it should be more complex to
correctly clip children (clip sorting..?)

Release Notes:

- N/A
This commit is contained in:
localcc
2025-09-03 19:52:47 +00:00
committed by GitHub
parent eedfc5be5a
commit bb2d833373
11 changed files with 130 additions and 446 deletions
+25 -53
View File
@@ -8,10 +8,10 @@
//! If all of your elements are the same height, see [`crate::UniformList`] for a simpler API
use crate::{
AnyElement, App, AvailableSpace, Bounds, ContentMask, Corners, DispatchPhase, Edges, Element,
EntityId, FocusHandle, GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId,
IntoElement, Overflow, Pixels, Point, ScrollDelta, ScrollWheelEvent, Size, Style,
StyleRefinement, Styled, Window, point, px, size,
AnyElement, App, AvailableSpace, Bounds, ContentMask, DispatchPhase, Edges, Element, EntityId,
FocusHandle, GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, IntoElement,
Overflow, Pixels, Point, ScrollDelta, ScrollWheelEvent, Size, Style, StyleRefinement, Styled,
Window, point, px, size,
};
use collections::VecDeque;
use refineable::Refineable as _;
@@ -705,7 +705,6 @@ impl StateInner {
&mut self,
bounds: Bounds<Pixels>,
padding: Edges<Pixels>,
corner_radii: Corners<Pixels>,
autoscroll: bool,
render_item: &mut RenderItemFn,
window: &mut Window,
@@ -729,15 +728,9 @@ impl StateInner {
let mut item_origin = bounds.origin + Point::new(px(0.), padding.top);
item_origin.y -= layout_response.scroll_top.offset_in_item;
for item in &mut layout_response.item_layouts {
window.with_content_mask(
Some(ContentMask {
bounds,
corner_radii,
}),
|window| {
item.element.prepaint_at(item_origin, window, cx);
},
);
window.with_content_mask(Some(ContentMask { bounds }), |window| {
item.element.prepaint_at(item_origin, window, cx);
});
if let Some(autoscroll_bounds) = window.take_autoscroll()
&& autoscroll
@@ -959,34 +952,19 @@ impl Element for List {
state.items = new_items;
}
let rem_size = window.rem_size();
let padding = style.padding.to_pixels(bounds.size.into(), rem_size);
let corner_radii = style.corner_radii.to_pixels(rem_size);
let layout = match state.prepaint_items(
bounds,
padding,
corner_radii,
true,
&mut self.render_item,
window,
cx,
) {
Ok(layout) => layout,
Err(autoscroll_request) => {
state.logical_scroll_top = Some(autoscroll_request);
state
.prepaint_items(
bounds,
padding,
corner_radii,
false,
&mut self.render_item,
window,
cx,
)
.unwrap()
}
};
let padding = style
.padding
.to_pixels(bounds.size.into(), window.rem_size());
let layout =
match state.prepaint_items(bounds, padding, true, &mut self.render_item, window, cx) {
Ok(layout) => layout,
Err(autoscroll_request) => {
state.logical_scroll_top = Some(autoscroll_request);
state
.prepaint_items(bounds, padding, false, &mut self.render_item, window, cx)
.unwrap()
}
};
state.last_layout_bounds = Some(bounds);
state.last_padding = Some(padding);
@@ -1004,17 +982,11 @@ impl Element for List {
cx: &mut App,
) {
let current_view = window.current_view();
window.with_content_mask(
Some(ContentMask {
bounds,
..Default::default()
}),
|window| {
for item in &mut prepaint.layout.item_layouts {
item.element.paint(window, cx);
}
},
);
window.with_content_mask(Some(ContentMask { bounds }), |window| {
for item in &mut prepaint.layout.item_layouts {
item.element.paint(window, cx);
}
});
let list_state = self.state.clone();
let height = bounds.size.height;
+1 -4
View File
@@ -411,10 +411,7 @@ impl Element for UniformList {
(self.render_items)(visible_range.clone(), window, cx)
};
let content_mask = ContentMask {
bounds,
..Default::default()
};
let content_mask = ContentMask { bounds };
window.with_content_mask(Some(content_mask), |window| {
for (mut item, ix) in items.into_iter().zip(visible_range.clone()) {
let item_origin = padded_bounds.origin