From 359ada8a3f2ff03babe51e906bf22834aeeb0098 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:42:26 -0700 Subject: [PATCH] Preserve side-docked browser devtools layout on pane resize --- Sources/BrowserWindowPortal.swift | 6 +++--- Sources/Panels/BrowserPanelView.swift | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Sources/BrowserWindowPortal.swift b/Sources/BrowserWindowPortal.swift index 40007065..42e6c3c0 100644 --- a/Sources/BrowserWindowPortal.swift +++ b/Sources/BrowserWindowPortal.swift @@ -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 diff --git a/Sources/Panels/BrowserPanelView.swift b/Sources/Panels/BrowserPanelView.swift index c9130d59..16aeed0f 100644 --- a/Sources/Panels/BrowserPanelView.swift +++ b/Sources/Panels/BrowserPanelView.swift @@ -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