@@ -239,59 +239,52 @@ class PreviewViewController: NSViewController, QLPreviewingController, WKNavigat
239239 }
240240 self . handler = handler
241241
242- if #available( macOS 11 , * ) {
243- // On BigSur 11.0.1 the entitlements on the extesion are ignored and webkit fail to render. Old WebView works.
244- let webView = WebView ( frame: previewRect)
245- webView. autoresizingMask = [ . height, . width]
246- webView. preferences. isJavaScriptEnabled = false
247- webView. preferences. allowsAirPlayForMediaPlayback = false
248- webView. preferences. arePlugInsEnabled = false
249-
250- if let v = settings [ SCSHSettings . Key. interactive] as? Bool , v {
251- webView. preferences. isJavaScriptEnabled = true
252- }
253-
254- self . view. addSubview ( webView)
255- webView. mainFrame. loadHTMLString ( html, baseURL: nil )
256- webView. frameLoadDelegate = self
257- } else {
258- let preferences = WKPreferences ( )
259- preferences. javaScriptEnabled = false
260- if let v = settings [ SCSHSettings . Key. interactive] as? Bool , v {
261- preferences. javaScriptEnabled = true
262- }
242+ let preferences = WKPreferences ( )
243+ preferences. javaScriptEnabled = false
244+ if let v = settings [ SCSHSettings . Key. interactive] as? Bool , v {
245+ preferences. javaScriptEnabled = true
246+ }
263247
264- // Create a configuration for the preferences
265- let configuration = WKWebViewConfiguration ( )
266- //configuration.preferences = preferences
267- configuration. allowsAirPlayForMediaPlayback = false
268- // configuration.userContentController.add(self, name: "jsHandler")
269-
270- let webView : WKWebView
271- if let v = settings [ SCSHSettings . Key. interactive] as? Bool , v {
272- webView = WKWebView ( frame: previewRect, configuration: configuration)
273- } else {
274- webView = StaticWebView ( frame: previewRect, configuration: configuration)
275- ( webView as! StaticWebView ) . fileUrl = self . fileUrl
276- }
277- webView. autoresizingMask = [ . height, . width]
278-
279- webView. wantsLayer = true
280- if #available( macOS 11 , * ) {
281- webView. layer? . borderWidth = 0
282- } else {
283- // Draw a border around the web view
284- webView. layer? . borderColor = NSColor . gridColor. cgColor
285- webView. layer? . borderWidth = 1
286- }
287-
288- webView. navigationDelegate = self
289- webView. uiDelegate = self
248+ // Create a configuration for the preferences
249+ let configuration = WKWebViewConfiguration ( )
250+ //configuration.preferences = preferences
251+ configuration. allowsAirPlayForMediaPlayback = false
252+ // configuration.userContentController.add(self, name: "jsHandler")
290253
254+ /* MARK: FIXME
255+ On Big Sur as far as I know, QuickLook extensions don't honor com.apple.security.network.client, so WebKit process immediately crash.
256+ To temporary fix add this entitlements exception
257+ com.apple.security.temporary-exception.mach-lookup.global-name:
258+ <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
259+ <array>
260+ <string>com.apple.nsurlsessiond</string>
261+ </array>
262+ */
291263
292- webView. loadHTMLString ( html, baseURL: nil )
293- self . view. addSubview ( webView)
264+ let webView : WKWebView
265+ if let v = settings [ SCSHSettings . Key. interactive] as? Bool , v {
266+ webView = WKWebView ( frame: previewRect, configuration: configuration)
267+ } else {
268+ webView = StaticWebView ( frame: previewRect, configuration: configuration)
269+ ( webView as! StaticWebView ) . fileUrl = self . fileUrl
294270 }
271+ webView. autoresizingMask = [ . height, . width]
272+
273+ webView. wantsLayer = true
274+ if #available( macOS 11 , * ) {
275+ webView. layer? . borderWidth = 0
276+ } else {
277+ // Draw a border around the web view
278+ webView. layer? . borderColor = NSColor . tertiaryLabelColor. cgColor
279+ webView. layer? . borderWidth = 1
280+ }
281+
282+ webView. navigationDelegate = self
283+ webView. uiDelegate = self
284+
285+
286+ webView. loadHTMLString ( html, baseURL: nil )
287+ self . view. addSubview ( webView)
295288 // handler(nil) // call the handler in the delegate method after complete rendering
296289 }
297290 }
@@ -368,20 +361,3 @@ extension PreviewViewController: WKScriptMessageHandler {
368361
369362extension PreviewViewController : WKUIDelegate {
370363}
371-
372- @available ( macOS, deprecated: 10.14 )
373- extension PreviewViewController : WebFrameLoadDelegate {
374- func webView( _ sender: WebView ! , didFinishLoadFor frame: WebFrame ! ) {
375- if let handler = self . handler {
376- handler ( nil )
377- }
378- self . handler = nil
379- }
380- func webView( _ sender: WebView ! , didFailLoadWithError error: Error ! , for frame: WebFrame ! ) {
381- if let handler = self . handler {
382- handler ( error)
383- }
384- self . handler = nil
385- }
386- }
387-
0 commit comments