Repair local-host devtools reparent geometry
This commit is contained in:
parent
ad31fb435a
commit
5d82a29f45
1 changed files with 15 additions and 2 deletions
|
|
@ -4992,6 +4992,8 @@ struct WebViewRepresentable: NSViewRepresentable {
|
|||
return true
|
||||
}
|
||||
guard !relatedSubviews.isEmpty else { return }
|
||||
let preserveSlotLocalFrames = sourceSuperview is WindowBrowserSlotView
|
||||
let sourceSlotBoundsSize = sourceSuperview.bounds.size
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"browser.localHost.reparent.batch reason=\(reason) source=\(Self.objectID(sourceSuperview)) " +
|
||||
|
|
@ -5000,11 +5002,17 @@ struct WebViewRepresentable: NSViewRepresentable {
|
|||
)
|
||||
#endif
|
||||
for view in relatedSubviews {
|
||||
let frameInWindow = sourceSuperview.convert(view.frame, to: nil)
|
||||
let className = String(describing: type(of: view))
|
||||
let targetFrame: NSRect
|
||||
if preserveSlotLocalFrames {
|
||||
targetFrame = view.frame
|
||||
} else {
|
||||
let frameInWindow = sourceSuperview.convert(view.frame, to: nil)
|
||||
targetFrame = container.convert(frameInWindow, from: nil)
|
||||
}
|
||||
view.removeFromSuperview()
|
||||
container.addSubview(view, positioned: .above, relativeTo: nil)
|
||||
view.frame = container.convert(frameInWindow, from: nil)
|
||||
view.frame = targetFrame
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"browser.localHost.reparent.batch.item reason=\(reason) class=\(className) " +
|
||||
|
|
@ -5012,6 +5020,11 @@ struct WebViewRepresentable: NSViewRepresentable {
|
|||
)
|
||||
#endif
|
||||
}
|
||||
if preserveSlotLocalFrames, sourceSlotBoundsSize != container.bounds.size {
|
||||
container.resizeSubviews(withOldSize: sourceSlotBoundsSize)
|
||||
container.needsLayout = true
|
||||
container.layoutSubtreeIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
private static func installPortalAnchorView(_ anchorView: NSView, in host: NSView) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue