Make URL bar FR when creating new tab, make errors local to tabs only
This commit is contained in:
@@ -68,6 +68,7 @@ class BrowserView: UIView
|
||||
|
||||
convenience init() {
|
||||
self.init(frame: .zero)
|
||||
backgroundColor = .systemBackground
|
||||
|
||||
addSubview(titlebarView)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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?
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user