Merge pull request #3100 from greenbuffo/fix/2916
Expand workaround for macOS 11 WebView origin offset bug. Fixes #2916
This commit is contained in:
commit
fa0744ed2c
|
@ -53,7 +53,19 @@ final class DetailWebView: WKWebView {
|
||||||
override func viewDidEndLiveResize() {
|
override func viewDidEndLiveResize() {
|
||||||
super.viewDidEndLiveResize()
|
super.viewDidEndLiveResize()
|
||||||
evaluateJavaScript("document.body.style.overflow = 'visible';", completionHandler: nil)
|
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
|
On macOS 11, when a user exits full screen
|
||||||
or exits zoomed mode by disconnecting an external display
|
or exits zoomed mode by disconnecting an external display
|
||||||
|
@ -66,6 +78,17 @@ final class DetailWebView: WKWebView {
|
||||||
guard var frame = window?.frame else {
|
guard var frame = window?.frame else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard !inBigSurOffsetFix else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
inBigSurOffsetFix = true
|
||||||
|
|
||||||
|
defer {
|
||||||
|
inBigSurOffsetFix = false
|
||||||
|
}
|
||||||
|
|
||||||
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1)
|
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1)
|
||||||
window!.setFrame(frame, display: false)
|
window!.setFrame(frame, display: false)
|
||||||
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height + 1)
|
frame.size = NSSize(width: window!.frame.width, height: window!.frame.height + 1)
|
||||||
|
|
Loading…
Reference in New Issue