diff --git a/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs b/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs index 1c52feae0355..6a733d488ddb 100644 --- a/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs +++ b/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs @@ -1301,6 +1301,21 @@ internal static void ArrangeElement(IntPtr htmlId, Rect rect, Rect? clipRect) } else { +#if NET7_0_OR_GREATER + var clipRectValue = clipRect ?? default; + + NativeMethods.ArrangeElement( + htmlId, + rect.Top, + rect.Left, + rect.Width, + rect.Height, + clipRect.HasValue, + clipRectValue.Top, + clipRectValue.Left, + clipRectValue.Bottom, + clipRectValue.Right); +#else var parms = new WindowManagerArrangeElementParams() { HtmlId = htmlId, @@ -1320,6 +1335,7 @@ internal static void ArrangeElement(IntPtr htmlId, Rect rect, Rect? clipRect) } TSInteropMarshaller.InvokeJS("Uno:arrangeElementNative", parms); +#endif } } @@ -1522,6 +1538,19 @@ internal enum HtmlPointerButtonUpdate #if NET7_0_OR_GREATER internal static partial class NativeMethods { + [JSImport("globalThis.Uno.UI.WindowManager.current.arrangeElementNativeFast")] + internal static partial void ArrangeElement( + IntPtr htmlId, + double top, + double left, + double width, + double height, + bool clip, + double clipTop, + double clipLeft, + double clipBottom, + double clipRight); + [JSImport("globalThis.Uno.UI.WindowManager.current.measureViewNativeFast")] internal static partial void MeasureView(IntPtr htmlId, double availableWidth, double availableHeight, bool measureContent, IntPtr pReturn); diff --git a/src/Uno.UI/ts/WindowManager.ts b/src/Uno.UI/ts/WindowManager.ts index a84185b765c8..1ac8829e7cae 100644 --- a/src/Uno.UI/ts/WindowManager.ts +++ b/src/Uno.UI/ts/WindowManager.ts @@ -712,25 +712,51 @@ namespace Uno.UI { public arrangeElementNative(pParams: number): boolean { const params = WindowManagerArrangeElementParams.unmarshal(pParams); - const element = this.getView(params.HtmlId); + + this.arrangeElementNativeFast( + params.HtmlId, + params.Top, + params.Left, + params.Width, + params.Height, + params.Clip, + params.ClipTop, + params.ClipLeft, + params.ClipBottom, + params.ClipRight); + + return true; + } + + public arrangeElementNativeFast( + htmlId: number, + top: number, + left: number, + width: number, + height: number, + clip: boolean, + clipTop: number, + clipLeft: number, + clipBottom: number, + clipRight: number) { + + const element = this.getView(htmlId); const style = element.style; style.position = "absolute"; - style.top = params.Top + "px"; - style.left = params.Left + "px"; - style.width = params.Width === NaN ? "auto" : params.Width + "px"; - style.height = params.Height === NaN ? "auto" : params.Height + "px"; + style.top = top + "px"; + style.left = left + "px"; + style.width = width === NaN ? "auto" : width + "px"; + style.height = height === NaN ? "auto" : height + "px"; - if (params.Clip) { - style.clip = `rect(${params.ClipTop}px, ${params.ClipRight}px, ${params.ClipBottom}px, ${params.ClipLeft}px)`; + if (clip) { + style.clip = `rect(${clipTop}px, ${clipRight}px, ${clipBottom}px, ${clipLeft}px)`; } else { style.clip = ""; } this.setAsArranged(element); - - return true; } private setAsArranged(element: HTMLElement | SVGElement) {