diff --git a/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs b/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs index 860a49b9b48c..1de561f6ef4a 100644 --- a/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs @@ -15,6 +15,7 @@ using System.Runtime.InteropServices.JavaScript; using Microsoft.UI.Xaml.Controls; +using System.Xml.Linq; namespace Uno.UI.Xaml { @@ -517,14 +518,8 @@ private struct WindowManagerRegisterEventOnViewParams internal static Rect GetBBox(IntPtr htmlId) { - var parms = new WindowManagerGetBBoxParams - { - HtmlId = htmlId - }; - - var ret = (WindowManagerGetBBoxReturn)TSInteropMarshaller.InvokeJS("Uno:getBBoxNative", parms, typeof(WindowManagerGetBBoxReturn)); - - return new Rect(ret.X, ret.Y, ret.Width, ret.Height); + var ret = NativeMethods.GetBBox(htmlId); + return new Rect(ret[0], ret[1], ret[2], ret[3]); } [TSInteropMessage] @@ -890,6 +885,9 @@ internal static partial void ArrangeElement( [JSImport("globalThis.Uno.UI.WindowManager.current.setUnsetCssClasses")] internal static partial void SetUnsetCssClasses(IntPtr htmlId, string[] cssClassesToSet, string[] cssClassesToUnset); + + [JSImport("globalThis.Uno.UI.WindowManager.current.getBBox")] + internal static partial double[] GetBBox(IntPtr htmlId); } } } diff --git a/src/Uno.UI/ts/WindowManager.ts b/src/Uno.UI/ts/WindowManager.ts index ebf2ed9409a1..c39687471958 100644 --- a/src/Uno.UI/ts/WindowManager.ts +++ b/src/Uno.UI/ts/WindowManager.ts @@ -984,24 +984,7 @@ namespace Uno.UI { delete this.allActiveElementsById[elementId]; } - public getBBoxNative(pParams: number, pReturn: number): boolean { - - const params = WindowManagerGetBBoxParams.unmarshal(pParams); - - const bbox = this.getBBoxInternal(params.HtmlId); - - const ret = new WindowManagerGetBBoxReturn(); - ret.X = bbox.x; - ret.Y = bbox.y; - ret.Width = bbox.width; - ret.Height = bbox.height; - - ret.marshal(pReturn); - - return true; - } - - private getBBoxInternal(elementId: number): any { + public getBBox(elementId: number): any { const element = this.getView(elementId) as SVGGraphicsElement; let unconnectedRoot: HTMLElement | SVGGraphicsElement = null; @@ -1028,12 +1011,17 @@ namespace Uno.UI { this.containerElement.appendChild(unconnectedRoot); } - return element.getBBox(); + let bbox = element.getBBox(); + + return [ + bbox.x, + bbox.y, + bbox.width, + bbox.height]; } finally { cleanupUnconnectedRoot(this.containerElement); } - } public setSvgElementRect(pParams: number): boolean {