feat: improve epub reader controls and annotations

This commit is contained in:
shen
2026-07-12 12:23:10 +08:00
parent 063a493b18
commit 8ccb7157b2
36 changed files with 2959 additions and 2160 deletions
@@ -31,20 +31,33 @@ extension RDEPUBWebView: WKNavigationDelegate {
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
RDEPUBWebViewDebug.logNavigationEvent(debugScope, webView: webView, event: "didFinish", url: webView.url)
applyReaderPageMediaVisibility()
guard readerPageMediaNavigationDidFinish(navigation) else { return }
applyPresentation()
}
public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
RDEPUBWebViewDebug.logNavigationEvent(debugScope, webView: webView, event: "processTerminated", url: webView.url)
// WebKit may not complete an in-flight media suspension after its
// content process exits. Tearing down flushes the FIFO callbacks and
// lets the coordinator activate another page without deadlocking.
// Rebuild the page afterward so a cached/current page does not remain
// permanently blank after WebKit recovers its content process.
let publication = publication
let renderRequest = currentRenderRequest
teardownWebView()
if let publication, let renderRequest {
load(publication: publication, request: renderRequest)
}
}
public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
RDEPUBWebViewDebug.logNavigationEvent(debugScope, webView: webView, event: "didFail", url: webView.url, error: error)
readerPageMediaNavigationDidFail(navigation)
}
public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
RDEPUBWebViewDebug.logNavigationEvent(debugScope, webView: webView, event: "didFailProvisional", url: webView.url, error: error)
readerPageMediaNavigationDidFail(navigation)
}
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {