Remove the no-longer-needed webview pool.

This commit is contained in:
Brent Simmons committed 2026-12-04 14:48:20 -08:00
1 parent 545b8ebb64
commit b7d2829bbb
7 files changed
+47 -214

No files matched your search

+41 -50
View File
@@ -36,8 +36,8 @@ final class WebViewController: UIViewController {
private var topShowBarsViewConstraint: NSLayoutConstraint!
private var bottomShowBarsViewConstraint: NSLayoutConstraint!
private var webView: PreloadedWebView? {
return view.subviews[0] as? PreloadedWebView
private var webView: ArticleWebView? {
return view.subviews[0] as? ArticleWebView
}
private var webViewProcessDidTerminate = false
@@ -498,7 +498,7 @@ extension WebViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
for (index, view) in view.subviews.enumerated() {
if index != 0, let oldWebView = view as? PreloadedWebView {
if index != 0, let oldWebView = view as? ArticleWebView {
oldWebView.removeFromSuperview()
}
}
@@ -678,55 +678,46 @@ private extension WebViewController {
}
webViewProcessDidTerminate = false
coordinator.webViewProvider.dequeueWebView { webView in
webView.ready {
// Add the webview
webView.translatesAutoresizingMaskIntoConstraints = false
self.view.insertSubview(webView, at: 0)
NSLayoutConstraint.activate([
self.view.leadingAnchor.constraint(equalTo: webView.leadingAnchor),
self.view.trailingAnchor.constraint(equalTo: webView.trailingAnchor),
self.view.topAnchor.constraint(equalTo: webView.topAnchor),
self.view.bottomAnchor.constraint(equalTo: webView.bottomAnchor)
])
// UISplitViewController reports the wrong size to WKWebView which can cause horizontal
// rubberbanding on the iPad. This interferes with our UIPageViewController preventing
// us from easily swiping between WKWebViews. This hack fixes that.
webView.scrollView.contentInset = UIEdgeInsets(top: 0, left: -1, bottom: 0, right: 0)
webView.scrollView.setZoomScale(1.0, animated: false)
self.view.setNeedsLayout()
self.view.layoutIfNeeded()
// Configure the webview
webView.navigationDelegate = self
webView.uiDelegate = self
webView.scrollView.delegate = self
self.configureContextMenuInteraction()
// Remove possible existing message handlers
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasClicked)
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasShown)
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.showFeedInspector)
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.mediaSourceURLs)
// Add handlers
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasClicked)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasShown)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.showFeedInspector)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.mediaSourceURLs)
self.renderPage(webView)
}
}
installWebView(ArticleWebView(articleIconSchemeHandler: articleIconSchemeHandler))
}
func renderPage(_ webView: PreloadedWebView?) {
func installWebView(_ webView: ArticleWebView) {
// Add the webview
webView.translatesAutoresizingMaskIntoConstraints = false
view.insertSubview(webView, at: 0)
NSLayoutConstraint.activate([
view.leadingAnchor.constraint(equalTo: webView.leadingAnchor),
view.trailingAnchor.constraint(equalTo: webView.trailingAnchor),
view.topAnchor.constraint(equalTo: webView.topAnchor),
view.bottomAnchor.constraint(equalTo: webView.bottomAnchor)
])
// UISplitViewController reports the wrong size to WKWebView which can cause horizontal
// rubberbanding on the iPad. This interferes with our UIPageViewController preventing
// us from easily swiping between WKWebViews. This hack fixes that.
webView.scrollView.contentInset = UIEdgeInsets(top: 0, left: -1, bottom: 0, right: 0)
webView.scrollView.setZoomScale(1.0, animated: false)
view.setNeedsLayout()
view.layoutIfNeeded()
// Configure the webview
webView.navigationDelegate = self
webView.uiDelegate = self
webView.scrollView.delegate = self
configureContextMenuInteraction()
// Add handlers
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasClicked)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasShown)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.showFeedInspector)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.mediaSourceURLs)
renderPage(webView)
}
func renderPage(_ webView: ArticleWebView?) {
guard let webView = webView else { return }
// Rendering during an element-fullscreen transition triggers a WebKit