From 24fdd76b54c8a6a516cab82734815ddb28f33383 Mon Sep 17 00:00:00 2001 From: Marceau TONELLI Date: Tue, 17 Dec 2024 18:32:55 +0100 Subject: [PATCH] Refactor FXIOS-10205 [Swiftlint] Resolve 2 implicitly_unwrapped_optional violations in WKEngineWebView (#23801) * Resolve warnings in WKEngineWebView * Fix mock implementation of WKEngineWebView --------- Co-authored-by: Marceau Tonelli --- BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift | 2 +- BrowserKit/Sources/WebEngine/WKWebview/WKEngineWebView.swift | 4 ++-- .../Tests/WebEngineTests/Mock/MockWKEngineWebView.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift index f48f6c274c46..c230a09c7793 100644 --- a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift +++ b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift @@ -132,7 +132,7 @@ class WKEngineSession: NSObject, } func scrollToTop() { - webView.engineScrollView.setContentOffset(CGPoint.zero, animated: true) + webView.engineScrollView?.setContentOffset(CGPoint.zero, animated: true) } func findInPage(text: String, function: FindInPageFunction) { diff --git a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineWebView.swift b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineWebView.swift index 90ffa009e734..b31c09c06744 100644 --- a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineWebView.swift +++ b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineWebView.swift @@ -24,7 +24,7 @@ protocol WKEngineWebView: UIView { var interactionState: Any? { get set } var url: URL? { get } var title: String? { get } - var engineScrollView: WKScrollView! { get } + var engineScrollView: WKScrollView? { get } var engineConfiguration: WKEngineConfiguration { get } var hasOnlySecureContent: Bool { get } @@ -132,7 +132,7 @@ extension WKEngineWebView { // TODO: FXIOS-7896 #17641 Handle WKEngineWebView ThemeApplicable // TODO: FXIOS-7897 #17642 Handle WKEngineWebView AccessoryViewProvider class DefaultWKEngineWebView: WKWebView, WKEngineWebView, MenuHelperWebViewInterface { - var engineScrollView: WKScrollView! + var engineScrollView: WKScrollView? var engineConfiguration: WKEngineConfiguration weak var delegate: WKEngineWebViewDelegate? diff --git a/BrowserKit/Tests/WebEngineTests/Mock/MockWKEngineWebView.swift b/BrowserKit/Tests/WebEngineTests/Mock/MockWKEngineWebView.swift index 3615cb311e0f..a2d81329152a 100644 --- a/BrowserKit/Tests/WebEngineTests/Mock/MockWKEngineWebView.swift +++ b/BrowserKit/Tests/WebEngineTests/Mock/MockWKEngineWebView.swift @@ -13,7 +13,7 @@ class MockWKEngineWebView: UIView, WKEngineWebView { var engineConfiguration: WKEngineConfiguration var interactionState: Any? - var engineScrollView: WKScrollView! = MockEngineScrollView() + var engineScrollView: WKScrollView? = MockEngineScrollView() var url: URL? var title: String? var hasOnlySecureContent = false