Preserve side-docked browser devtools layout on pane resize

This commit is contained in:
Lawrence Chen 2026-03-10 20:42:26 -07:00
parent 0ca6569e00
commit 359ada8a3f
2 changed files with 6 additions and 7 deletions

View file

@ -1676,8 +1676,7 @@ final class WindowBrowserSlotView: NSView {
hostedWebView !== webView ||
!hostedWebViewConstraints.isEmpty ||
!webView.translatesAutoresizingMaskIntoConstraints ||
webView.autoresizingMask != [.width, .height] ||
!Self.rectApproximatelyEqual(webView.frame, bounds)
webView.autoresizingMask != [.width, .height]
guard needsFrameHosting else {
needsLayout = true
layoutSubtreeIfNeeded()
@ -1688,7 +1687,8 @@ final class WindowBrowserSlotView: NSView {
hostedWebViewConstraints = []
hostedWebView = webView
// Attached Web Inspector mutates the moved WKWebView's frame directly.
// Edge constraints fight side-docked resizing and cause visible churn.
// Re-pin only when hosting mode changes, not when WebKit resizes the page
// inside the slot for side-docked DevTools.
webView.translatesAutoresizingMaskIntoConstraints = true
webView.autoresizingMask = [.width, .height]
webView.frame = bounds

View file

@ -3786,8 +3786,7 @@ struct WebViewRepresentable: NSViewRepresentable {
hostedWebView !== webView ||
!hostedWebViewConstraints.isEmpty ||
!webView.translatesAutoresizingMaskIntoConstraints ||
webView.autoresizingMask != [.width, .height] ||
webView.frame != container.bounds
webView.autoresizingMask != [.width, .height]
guard needsFrameHosting else {
needsLayout = true
layoutSubtreeIfNeeded()
@ -3799,8 +3798,8 @@ struct WebViewRepresentable: NSViewRepresentable {
hostedWebView = webView
// WebKit's attached inspector does not reliably dock into a constraint-managed
// WKWebView hierarchy on macOS. Host the moved webview with autoresizing so
// the inspector can resize the content view in place.
// WKWebView hierarchy on macOS. Host the moved webview with autoresizing and
// keep WebKit-owned page frames intact when DevTools is side-docked.
webView.translatesAutoresizingMaskIntoConstraints = true
webView.autoresizingMask = [.width, .height]
webView.frame = container.bounds