Align displaced remote content origin through AppKit coordinate conversion (build 49)

这个提交包含在:
mac 于 2026-11-02 22:41:37 +08:00 提交
1 父节点 3ba2c0b823
当前提交 2688b22f99
6 个文件已更改
+52 -3

没有与搜索条件相匹配的文件

+13 -1
查看文件
@@ -264,7 +264,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
// Follow the supplied parent without changing the bridge's resize policy.
parent.postsFrameChangedNotifications=YES;parent.postsBoundsChangedNotifications=YES;
for(NSNotificationName name in @[NSViewFrameDidChangeNotification,NSViewBoundsDidChangeNotification])[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(remoteParentGeometryChanged:) name:name object:parent];
[parent addSubview:_root];[self layoutBrowser];[_root setNeedsDisplay:YES];
[parent addSubview:_root];DYBrowserGeometrySample(_root,@"before-content-origin-alignment");[self fitRemoteParent];
DYBrowserGeometrySample(_root,@"attached-before-sdk-reply");
// Attach synchronously: the SDK reads the first child before reply returns.
dispatch_async(dispatch_get_main_queue(),^{if(!_closed){[self configurePresentationWindow];DYBrowserGeometrySample(_root,@"after-sdk-reply");}});
@@ -273,6 +273,18 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
}
- (void)fitRemoteParent{
NSView *parent=_root.superview;if(_closed||!_remoteMode||!parent)return;
// A scaled-display ViewBridge service can hand us its top-level content
// view with a stale frame origin (observed: 789,521 in an 1800x1200 window).
// Matching only its bounds keeps our child correct inside a displaced
// container. Align that content origin using AppKit's coordinate APIs;
// leave the host's window, content size and bridge resize policy intact.
NSWindow *window=parent.window;
if(window&&parent==window.contentView&&parent.superview){
NSRect screenContent=[window contentRectForFrameRect:window.frame];
NSRect windowContent=[window convertRectFromScreen:screenContent];
NSPoint origin=[parent.superview convertPoint:windowContent.origin fromView:nil];
if(std::isfinite(origin.x)&&std::isfinite(origin.y)&&!NSEqualPoints(parent.frame.origin,origin))[parent setFrameOrigin:origin];
}
if(!NSEqualRects(_root.frame,parent.bounds))_root.frame=parent.bounds;
[self layoutBrowser];[_root setNeedsDisplay:YES];
}