Fixed layout recursion warning by getting rid of bigSurOffsetFix hack, which no longer appears to be needed. Fix #4590.

This commit is contained in:
Brent Simmons
2025-04-20 21:36:50 -07:00
parent aa75efaa2e
commit 5f4533cc6b

View File

@@ -53,47 +53,6 @@ final class DetailWebView: WKWebView {
override func viewDidEndLiveResize() {
super.viewDidEndLiveResize()
evaluateJavaScript("document.body.style.overflow = 'visible';", completionHandler: nil)
bigSurOffsetFix()
}
override func setFrameSize(_ newSize: NSSize) {
super.setFrameSize(newSize)
if (!inLiveResize) {
bigSurOffsetFix()
}
}
private var inBigSurOffsetFix = false
private func bigSurOffsetFix() {
/*
On macOS 11, when a user exits full screen
or exits zoomed mode by disconnecting an external display
the webview's `origin.y` is offset by a sizeable amount.
This code adjusts the height of the window by -1pt/+1pt,
which puts the webview back in the correct place.
*/
if #available(macOS 11, *) {
guard var frame = window?.frame else {
return
}
guard !inBigSurOffsetFix else {
return
}
inBigSurOffsetFix = true
defer {
inBigSurOffsetFix = false
}
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1)
window!.setFrame(frame, display: false)
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height + 1)
window!.setFrame(frame, display: false)
}
}
}