Keep hidden portal sync from stealing devtools host
This commit is contained in:
parent
d881c29105
commit
6f8f5a6ac0
1 changed files with 20 additions and 5 deletions
|
|
@ -2752,7 +2752,18 @@ final class WindowBrowserPortal: NSObject {
|
|||
hostView.addSubview(containerView, positioned: .above, relativeTo: nil)
|
||||
refreshReasons.append("syncAttachContainer")
|
||||
}
|
||||
if webView.superview !== containerView {
|
||||
let shouldPreserveExternalHostForHiddenEntry =
|
||||
!entry.visibleInUI &&
|
||||
webView.superview !== containerView
|
||||
if shouldPreserveExternalHostForHiddenEntry {
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"browser.portal.reparent.skip web=\(browserPortalDebugToken(webView)) " +
|
||||
"reason=hiddenEntryExternalHost super=\(browserPortalDebugToken(webView.superview)) " +
|
||||
"container=\(browserPortalDebugToken(containerView))"
|
||||
)
|
||||
#endif
|
||||
} else if webView.superview !== containerView {
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"browser.portal.reparent web=\(browserPortalDebugToken(webView)) " +
|
||||
|
|
@ -2943,15 +2954,16 @@ final class WindowBrowserPortal: NSObject {
|
|||
refreshReasons.append("bounds")
|
||||
}
|
||||
|
||||
let containerOwnsWebView = webView.superview === containerView
|
||||
let containerBounds = containerView.bounds
|
||||
let preNormalizeWebFrame = webView.frame
|
||||
let preNormalizeWebFrame = containerOwnsWebView ? webView.frame : .zero
|
||||
let inspectorHeightFromInsets = max(0, containerBounds.height - preNormalizeWebFrame.height)
|
||||
let inspectorHeightFromOverflow = max(0, preNormalizeWebFrame.maxY - containerBounds.maxY)
|
||||
let inspectorHeightApprox = max(inspectorHeightFromInsets, inspectorHeightFromOverflow)
|
||||
#if DEBUG
|
||||
let inspectorSubviews = Self.inspectorSubviewCount(in: containerView)
|
||||
#endif
|
||||
if Self.frameExtendsOutsideBounds(preNormalizeWebFrame, bounds: containerBounds) {
|
||||
if containerOwnsWebView && Self.frameExtendsOutsideBounds(preNormalizeWebFrame, bounds: containerBounds) {
|
||||
let oldWebFrame = preNormalizeWebFrame
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
|
|
@ -3010,14 +3022,16 @@ final class WindowBrowserPortal: NSObject {
|
|||
if transientRecoveryReason == nil {
|
||||
resetTransientRecoveryRetryIfNeeded(forWebViewId: webViewId, entry: &entry)
|
||||
}
|
||||
if !shouldHide, !refreshReasons.isEmpty {
|
||||
if !shouldHide, containerOwnsWebView, !refreshReasons.isEmpty {
|
||||
refreshHostedWebViewPresentation(
|
||||
webView,
|
||||
in: containerView,
|
||||
reason: "\(source):" + refreshReasons.joined(separator: ",")
|
||||
)
|
||||
}
|
||||
hostView.reapplyHostedInspectorDividerIfNeeded(in: containerView, reason: "portal.sync")
|
||||
if containerOwnsWebView {
|
||||
hostView.reapplyHostedInspectorDividerIfNeeded(in: containerView, reason: "portal.sync")
|
||||
}
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"browser.portal.sync.result web=\(browserPortalDebugToken(webView)) source=\(source) " +
|
||||
|
|
@ -3027,6 +3041,7 @@ final class WindowBrowserPortal: NSObject {
|
|||
"old=\(browserPortalDebugFrame(oldFrame)) raw=\(browserPortalDebugFrame(frameInHost)) " +
|
||||
"target=\(browserPortalDebugFrame(targetFrame)) hide=\(shouldHide ? 1 : 0) " +
|
||||
"entryVisible=\(entry.visibleInUI ? 1 : 0) " +
|
||||
"containerOwnsWeb=\(containerOwnsWebView ? 1 : 0) " +
|
||||
"containerHidden=\(containerView.isHidden ? 1 : 0) webHidden=\(webView.isHidden ? 1 : 0) " +
|
||||
"containerBounds=\(browserPortalDebugFrame(containerView.bounds)) " +
|
||||
"preWebFrame=\(browserPortalDebugFrame(preNormalizeWebFrame)) " +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue