@@ -327,13 +327,20 @@ public void ConfigureOpenElement(ElementDeclaration declaration)
327327 GenerateIdForAnonymousElement ( ref openLayoutElement ) ;
328328 }
329329
330+ // ClipContent adds to clip stack (without scroll behavior)
331+ if ( declaration . Layout . ClipContent )
332+ {
333+ OpenClipElementStack . Add ( ( int ) openLayoutElement . Id ) ;
334+ }
335+
330336 // Process scroll config
331337 if ( declaration . Scroll . IsScrollable )
332338 {
333339 int scrollIndex = ScrollElementConfigs . Add ( declaration . Scroll ) ;
334340 ElementConfigs . Add ( new ElementConfig { Type = ElementConfigType . Scroll , ConfigIndex = scrollIndex } ) ;
335341 openLayoutElement . ElementConfigsLength ++ ;
336- OpenClipElementStack . Add ( ( int ) openLayoutElement . Id ) ;
342+ if ( ! declaration . Layout . ClipContent ) // Avoid double-push
343+ OpenClipElementStack . Add ( ( int ) openLayoutElement . Id ) ;
337344
338345 // Find or create scroll container data
339346 bool found = false ;
@@ -384,6 +391,12 @@ public void CloseElement()
384391 bool elementHasScrollHorizontal = false ;
385392 bool elementHasScrollVertical = false ;
386393
394+ // Pop clip stack for ClipContent elements
395+ if ( layoutConfig . ClipContent )
396+ {
397+ OpenClipElementStack . Length -- ;
398+ }
399+
387400 // Check for scroll config
388401 for ( int i = 0 ; i < openLayoutElement . ElementConfigsLength ; i ++ )
389402 {
@@ -393,7 +406,8 @@ public void CloseElement()
393406 ref var scrollConfig = ref ScrollElementConfigs [ config . ConfigIndex ] ;
394407 elementHasScrollHorizontal = scrollConfig . Horizontal ;
395408 elementHasScrollVertical = scrollConfig . Vertical ;
396- OpenClipElementStack . Length -- ;
409+ if ( ! layoutConfig . ClipContent ) // Avoid double-pop
410+ OpenClipElementStack . Length -- ;
397411 break ;
398412 }
399413 }
@@ -1134,6 +1148,8 @@ private void GenerateRenderCommandsRecursive(int elementIndex, short zIndex, Bou
11341148 // Find configs
11351149 int sharedIndex = FindConfigIndex ( ref element , ElementConfigType . Shared ) ;
11361150 int scrollIndex = FindConfigIndex ( ref element , ElementConfigType . Scroll ) ;
1151+ ref var layoutConfig = ref LayoutConfigs [ element . LayoutConfigIndex ] ;
1152+ bool clipContent = layoutConfig . ClipContent ;
11371153
11381154 SharedElementConfig sharedConfig = sharedIndex >= 0 ? SharedElementConfigs [ sharedIndex ] : default ;
11391155
@@ -1154,28 +1170,34 @@ private void GenerateRenderCommandsRecursive(int elementIndex, short zIndex, Bou
11541170 } ) ;
11551171 }
11561172
1157- // Scissor start
1158- if ( scrollIndex >= 0 )
1173+ // Scissor start (for scroll containers or ClipContent elements)
1174+ bool needsScissor = scrollIndex >= 0 || clipContent ;
1175+ if ( needsScissor )
11591176 {
1160- ref var scrollConfig = ref ScrollElementConfigs [ scrollIndex ] ;
1177+ ScrollRenderData scrollData = default ;
1178+ if ( scrollIndex >= 0 )
1179+ {
1180+ ref var scrollConfig = ref ScrollElementConfigs [ scrollIndex ] ;
1181+ scrollData = new ScrollRenderData
1182+ {
1183+ Horizontal = scrollConfig . Horizontal ,
1184+ Vertical = scrollConfig . Vertical
1185+ } ;
1186+ }
11611187 RenderCommands . Add ( new RenderCommand
11621188 {
11631189 BoundingBox = boundingBox ,
11641190 CommandType = RenderCommandType . ScissorStart ,
11651191 Id = element . Id ,
11661192 ZIndex = zIndex ,
1167- Scroll = new ScrollRenderData
1168- {
1169- Horizontal = scrollConfig . Horizontal ,
1170- Vertical = scrollConfig . Vertical
1171- }
1193+ Scroll = scrollData
11721194 } ) ;
11731195 }
11741196
1175- // If this element is a scroll container , its bounding box clips children
1197+ // If this element clips children , its bounding box clips children
11761198 var childClip = clipBounds ;
11771199 bool childHasClip = hasClip ;
1178- if ( scrollIndex >= 0 )
1200+ if ( needsScissor )
11791201 {
11801202 childClip = boundingBox ;
11811203 childHasClip = true ;
@@ -1238,7 +1260,7 @@ private void GenerateRenderCommandsRecursive(int elementIndex, short zIndex, Bou
12381260 }
12391261
12401262 // Scissor end
1241- if ( scrollIndex >= 0 )
1263+ if ( needsScissor )
12421264 {
12431265 RenderCommands . Add ( new RenderCommand
12441266 {
0 commit comments