diff --git a/App/Browser View/BrowserView.swift b/App/Browser View/BrowserView.swift index b29a203..1564275 100644 --- a/App/Browser View/BrowserView.swift +++ b/App/Browser View/BrowserView.swift @@ -68,6 +68,7 @@ class BrowserView: UIView convenience init() { self.init(frame: .zero) + backgroundColor = .systemBackground addSubview(titlebarView) diff --git a/App/Browser View/BrowserViewController+WebKitDelegate.swift b/App/Browser View/BrowserViewController+WebKitDelegate.swift index d1c8d2e..0d43108 100644 --- a/App/Browser View/BrowserViewController+WebKitDelegate.swift +++ b/App/Browser View/BrowserViewController+WebKitDelegate.swift @@ -10,7 +10,7 @@ import WebKit extension BrowserViewController: WKNavigationDelegate, WKUIDelegate { func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { - loadError = nil + tab.loadError = nil // Check to make sure we have connected to the web content process if !tab.bridge.webContentProcessConnected { @@ -99,11 +99,15 @@ extension BrowserViewController: WKNavigationDelegate, WKUIDelegate } func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { - self.loadError = error + if webView == tab.webView { + tab.loadError = error + } } func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { - self.loadError = error + if webView == tab.webView { + tab.loadError = error + } } // MARK: WKUIDelegate diff --git a/App/Browser View/BrowserViewController.swift b/App/Browser View/BrowserViewController.swift index b4e76e6..656ca20 100644 --- a/App/Browser View/BrowserViewController.swift +++ b/App/Browser View/BrowserViewController.swift @@ -35,8 +35,6 @@ class BrowserViewController: UIViewController private var activeTabObservation: AnyCancellable? private var faviconObservation: AnyCancellable? - internal var loadError: Error? - internal var commandKeyHeld: Bool = false internal var windowButtonHeld: Bool { get { toolbarController.newTabButton.isTracking } @@ -142,9 +140,7 @@ class BrowserViewController: UIViewController if gestureRecognizer.state != .began { return } } - // Create new tab - let newTab = tabController.createNewTab(url: nil) - self.tab = newTab + self.createNewTab(withURL: nil) } if Self.longPressWindowButtonToMakeNewTab { @@ -159,7 +155,7 @@ class BrowserViewController: UIViewController // Error button toolbarController.urlBar.errorButton.addAction(UIAction(handler: { [unowned self] _ in - let alert = UIAlertController(title: "Error", message: self.loadError?.localizedDescription, preferredStyle: .actionSheet) + let alert = UIAlertController(title: "Error", message: self.tab.loadError?.localizedDescription, preferredStyle: .actionSheet) alert.popoverPresentationController?.sourceView = self.toolbarController.urlBar.errorButton alert.addAction(UIAlertAction(title: "Reload", style: .destructive, handler: { _ in @@ -354,7 +350,7 @@ class BrowserViewController: UIViewController } internal func updateLoadProgress(forWebView webView: WKWebView) { - if let loadError = loadError { + if let loadError = tab.loadError { toolbarController.urlBar.loadProgress = .error(error: loadError) } else if webView.estimatedProgress == 1.0 { toolbarController.urlBar.loadProgress = .complete @@ -437,6 +433,9 @@ class BrowserViewController: UIViewController // Enforce dark mode setting tab.bridge.darkModeEnabled = toolbarController.darkModeEnabled + + // Blur url bar, if applicable + toolbarController.urlBar.textField.resignFirstResponder() } override func viewWillAppear(_ animated: Bool) { @@ -472,6 +471,10 @@ class BrowserViewController: UIViewController public func createNewTab(withURL url: URL?) { let newTab = tabController.createNewTab(url: url) self.tab = newTab + + if url == nil { + self.toolbarController.urlBar.textField.becomeFirstResponder() + } } } diff --git a/App/Tabs/Tab.swift b/App/Tabs/Tab.swift index 815da62..52b94df 100644 --- a/App/Tabs/Tab.swift +++ b/App/Tabs/Tab.swift @@ -62,6 +62,8 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate public var identifier = UUID() @Published public var favicon: UIImage? + public var loadError: Error? + private var faviconHost: String? private var faviconRequest: AnyCancellable? diff --git a/App/Titlebar and URL Bar/URLBar.swift b/App/Titlebar and URL Bar/URLBar.swift index d20dc91..59500a3 100644 --- a/App/Titlebar and URL Bar/URLBar.swift +++ b/App/Titlebar and URL Bar/URLBar.swift @@ -71,7 +71,6 @@ class URLBar: ReliefButton textField.autocorrectionType = .no textField.autocapitalizationType = .none textField.font = .systemFont(ofSize: 14.0) - textField.clearingBehavior = .clearOnInsertionAndShowSelectionTint textField.clearButtonMode = .whileEditing textField.addAction(UIAction(handler: { [unowned self] _ in // Mask view visibility is affected by editing state.