Repository navigation
[Windows] Fix Border clipping for transformed content - #37424
Conversation
### Description of Change This pull request makes a minor update to the UI test pipeline configuration - Pipeline configuration simplification: * Removed the **duplicate** code that set the `$deviceType` variable and appended the `--skin` argument to the test command in `eng/pipelines/common/ui-tests-steps.yml`. The same code was already added at [line 133](https://github.com/dotnet/maui/blob/main/eng/pipelines/common/ui-tests-steps.yml#L133) as part of [PR #33409](#33409). The duplicate code was also added at [line 156](https://github.com/dotnet/maui/blob/main/eng/pipelines/common/ui-tests-steps.yml#L156) as part of [PR #31631](#31631).
Clip Border content through a stationary native host so child transforms do not transform the clip geometry. Preserve layout invalidation, explicit sizing, reconnect behavior, and custom handler activation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 37b8c9a3-5a3c-427e-8006-99c04b5dbd4d
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37424Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37424" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR fixes Windows Border clipping when the Border’s content is transformed (scale/rotation/translation) by moving the CompositionGeometricClip to a stationary native “clip host” visual so the clip aperture remains in Border coordinates rather than being transformed with the content.
Changes:
- Introduces a
ContentPanelClipHostinsideContentPaneland attaches the composition clip to that host instead of the content visual. - Updates the Windows
BorderHandlerto enable the clip host, routeCrossPlatformLayoutupdates to both panel and host, and clean up on disconnect/content changes. - Adds extensive Windows Border device test coverage for transforms, async image load rendering, runtime layout changes (FontSize/Padding), and handler/content lifecycle cases.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Records new protected override API entry for BorderHandler.DisconnectHandler(ContentPanel). |
| src/Core/src/Platform/Windows/LayoutPanel.cs | Removes special-case clip suppression so ClipsToBounds always applies a XAML rectangle clip. |
| src/Core/src/Platform/Windows/ContentPanel.cs | Adds clip-host panel, routes content into the host, and moves composition clip application to the host visual. |
| src/Core/src/Handlers/Border/BorderHandler.Windows.cs | Enables clip host and ensures content/layout are cleared and detached correctly (incl. disconnect). |
| src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs | Adds/updates device tests validating transformed clipping and layout invalidation scenarios. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
This comment has been minimized.
This comment has been minimized.
Clear stale clipping geometry for either non-positive dimension and remove the unnecessary DisconnectHandler override so the fix adds no public API surface. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ea69150-3ceb-40d9-959b-b4f509322d9b
There was a problem hiding this comment.
Review details
Suppressed comments (2)
src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs:314
ToBitmapreturns aCanvasBitmap(IDisposable). In the polling loop this allocates multiple bitmaps without disposing them, which can add unnecessary memory/handle pressure and flakiness on constrained CI VMs. Dispose each iteration.
while (renderedRedPixels == 0 && DateTime.UtcNow < timeout)
{
var bitmap = await handler.PlatformView.ToBitmap(MauiContext);
renderedRedPixels = CountRedPixels(bitmap);
src/Core/src/Platform/Windows/ContentPanel.cs:16
using Microsoft.UI.Xaml.Controls;appears unused in this file (no types from that namespace are referenced). Keeping it may trigger IDE0005/cleanup analyzers in builds that enforce unused-using removal.
using Microsoft.UI.Xaml.Controls;
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 5 findings
See inline comments for details.
kubaflo
left a comment
There was a problem hiding this comment.
Could you please check the ai's suggestions?
Route cross-platform measure invalidation directly to the stationary clip host instead of invalidating it during every layout pass. Refresh cached layout when handlers reconnect and add focused caching coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ea69150-3ceb-40d9-959b-b4f509322d9b
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Core/src/Platform/Windows/ContentPanel.cs:17
using Microsoft.UI.Xaml.Controls;appears unused in this file (no types from that namespace are referenced), which can trigger IDE0005/unnecessary-using analyzers in CI. Consider removing it.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Hosting;
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
…-clipping-windows
Clamp inset clip geometry when the stroke consumes the available size, preserve an empty rounded aperture, and let derived handlers observe hosted content before teardown. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ea69150-3ceb-40d9-959b-b4f509322d9b
Skill Validation Results
|
The pull request targets inflight/current, so merging main imported unrelated repository and workflow changes into the PR diff. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ea69150-3ceb-40d9-959b-b4f509322d9b
Preserve the stationary Windows Border clip host while integrating current layout, content reparenting, and SwipeControl base changes. Repair stale content ownership when views move between clip hosts or generic MauiPanel parents. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ea69150-3ceb-40d9-959b-b4f509322d9b
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 ## Root cause Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. ## Fix - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. ## Before / after video proof **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. ## Validation - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 ## Root cause Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. ## Fix - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. ## Before / after video proof **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. ## Validation - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 ## Root cause Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. ## Fix - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. ## Before / after video proof **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. ## Validation - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 ## Root cause Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. ## Fix - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. ## Before / after video proof **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. ## Validation - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 ## Root cause Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. ## Fix - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. ## Before / after video proof **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. ## Validation - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! Fixes #17523 Windows attached the Border's `CompositionGeometricClip` directly to the content visual while authoring the geometry in the parent `ContentPanel` coordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary. - Place Border content inside a Border-only stationary native clip host and attach the geometric clip to that host. - Route cross-platform measure invalidation to both native layers while preserving WinUI's cached subtree measure on unrelated parent layout passes. - Avoid re-entering measure from arrange when a layout owner changes; the normal invalidated measure pass remains authoritative. - Preserve the cross-platform arranged size through the native clip host, including detached and reconnected layout-owner transitions. - Cache stable composition and rectangular bounds clip geometry, rebuilding only when geometry inputs change. - Tear down layout owners, hosted content, stroke references, and cached clip state when the handler disconnects, after derived handler disconnect hooks have observed the intact platform view. - Safely ignore late invalidation after handler disconnect and synchronize direct or reconnect-driven layout-owner changes with the clip host. - Preserve current cross-parent content reparenting while clearing stale clip-host ownership when content moves Border → Border, Border → generic `MauiPanel`, or back again. - Handle zero-by-infinite WinUI measure constraints without invoking cross-platform layout. - Keep layout invalidation flowing for initial asynchronous image loads and runtime content-size, `FontSize`, and `Padding` changes without requiring an outer window resize. - Preserve explicit Border sizing, stroke/shadow behavior, nested layout clipping, content replacement, custom handler activation and mapper customization, shape removal, and accessibility behavior. - Clamp stroke-inset geometry to nonnegative dimensions and preserve an explicitly empty aperture when the stroke consumes all available content space, including rounded shapes. - Clear stale clipping geometry whenever either arranged dimension is non-positive. - Remove the obsolete nested `LayoutPanel` clip exception because the XAML rectangular clip and Border composition clip now live on separate visuals. - Update the three affected WinUI Image AspectFill baselines for the stationary clip host's one-pixel antialiased inner edge; image content remains pixel-identical. This is an implementation-only Windows fix; it adds no public APIs. **Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM:** transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes. https://github.com/user-attachments/assets/7cf6b0fc-c101-44df-ba5b-841131014708 **After — final reviewed PR gallery build using the exact `BorderResizeContent` source scenario:** the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content. https://github.com/user-attachments/assets/97a4429a-c32c-4c9f-9252-957b8f2c5e8f Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and **0 outside after the fix**. - Windows Border device tests: **38 passed, 0 failed, 0 skipped, 0 errors**. - Added coverage for scale, rotation, translation, combined transforms, shadows, nested layouts, initial asynchronous image rendering, runtime `FontSize` and `Padding`, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse. - Exact final `BorderResizeContent.xaml` gallery proof ran without resizing the window: - Image scale 1 → 4 changed 14,673 pixels inside the Border shapes and 0 outside. - Font size 40 → 120 changed 11,584 pixels inside the Border shapes and 0 outside. - All images rendered on initial load. - The repository's production `MagickNetVisualComparer` passes all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior. - Multiple independent MAUI expert, adversarial, and layout/performance reviews completed with no remaining actionable findings. @jstedfast, could you please test the PR artifacts against the original `BorderResizeContent` reproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly? Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Fixes #17523
Root cause
Windows attached the Border's
CompositionGeometricClipdirectly to the content visual while authoring the geometry in the parentContentPanelcoordinate space. Scale, rotation, and translation therefore transformed the clip together with the content instead of keeping the Border aperture stationary.Fix
MauiPanel, or back again.FontSize, andPaddingchanges without requiring an outer window resize.LayoutPanelclip exception because the XAML rectangular clip and Border composition clip now live on separate visuals.This is an implementation-only Windows fix; it adds no public APIs.
Before / after video proof
Before — issue author's attached reproduction, minimally retargeted to the current Windows TFM: transformed image content escapes the stationary ellipse, rounded rectangle, and triangle apertures as image scale changes.
issue-17523-before.mp4
After — final reviewed PR gallery build using the exact
BorderResizeContentsource scenario: the same scale interaction changes the image while each Border aperture remains stationary and correctly clips its content.issue-17523-after-final-review.mp4
Both recordings use a 1280×720 window. Pixel analysis of the recorded scale-4 frames detected transformed image pixels outside the three Border regions before the fix and 0 outside after the fix.
Validation
FontSizeandPadding, explicit sizing, content replacement, shape removal, disconnect/reconnect, derived disconnect ordering, teardown cleanup, direct layout-owner changes, derived handlers, clip ownership, cross-host and generic-parent reparenting, composition and bounds clip reuse, zero-by-infinite constraints, stroke-consuming zero-interior geometry, rounded empty apertures, cross-platform arranged-size propagation, automation, and layout-cache reuse.BorderResizeContent.xamlgallery proof ran without resizing the window:MagickNetVisualComparerpasses all three updated WinUI Image AspectFill snapshots at the default 0.005 RMS threshold. The accepted delta is confined to the one-pixel Border edge with zero changed pixels in the image interior.@jstedfast, could you please test the PR artifacts against the original
BorderResizeContentreproduction and confirm that initial rendering, transformed clipping, runtime font-size changes, and resizing now behave correctly?