Skip to content

Commit

Permalink
Webview container removed in order to fix dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Mar 7, 2022
1 parent 680a4f8 commit 07999f5
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions DuckDuckGo/BrowserTab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ final class BrowserTabViewController: NSViewController {
@IBOutlet weak var hoverLabel: NSTextField!
@IBOutlet weak var hoverLabelContainer: NSView!
private weak var webView: WebView?
private weak var webViewContainer: NSView?

var tabViewModel: TabViewModel?
var clickPoint: NSPoint?
Expand Down Expand Up @@ -136,16 +135,13 @@ final class BrowserTabViewController: NSViewController {
show(tabContent: tabViewModel?.tab.content)
}

private func removeWebViewFromHierarchy(webView: WebView? = nil,
container: NSView? = nil) {
guard let webView = webView ?? self.webView,
let container = container ?? self.webViewContainer
private func removeWebViewFromHierarchy(webView: WebView? = nil) {
guard let webView = webView ?? self.webView
else { return }

// close fullscreenWindowController when closing tab in FullScreen mode
webView.fullscreenWindowController?.close()
webView.removeFromSuperview()
container.removeFromSuperview()
}

private func addWebViewToViewHierarchy(_ webView: WebView) {
Expand All @@ -157,12 +153,7 @@ final class BrowserTabViewController: NSViewController {

webView.frame = view.bounds
webView.autoresizingMask = [.width, .height]

let container = NSView(frame: view.bounds)
container.autoresizingMask = [.width, .height]
view.addSubview(container)
container.addSubview(webView)
self.webViewContainer = container
view.addSubview(webView)

// Make sure this is on top
view.addSubview(hoverLabelContainer)
Expand All @@ -189,11 +180,10 @@ final class BrowserTabViewController: NSViewController {
guard self.tabViewModel !== tabViewModel else { return }

let oldWebView = webView
let webViewContainer = webViewContainer
displayWebView(of: tabViewModel)
subscribeToUrl(of: tabViewModel)
self.tabViewModel = tabViewModel
removeWebViewFromHierarchy(webView: oldWebView, container: webViewContainer)
removeWebViewFromHierarchy(webView: oldWebView)
}

func subscribeToUrl(of tabViewModel: TabViewModel) {
Expand Down

0 comments on commit 07999f5

Please sign in to comment.