Skip to content

Commit

Permalink
allowsInlinePredictions is now available (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Jul 31, 2023
1 parent 2eac1c4 commit 8ea1972
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,25 @@ public extension WKWebViewConfiguration {
return false
}

// [macOS 14] WebKit hasn't yet exposed this as public, even it's documented
return responds(to: sel_getUid("setAllowsInlinePredictions:"))
#if compiler(>=5.9)
return true
#else
return responds(to: sel_getUid("setAllowsInlinePredictions:"))
#endif
}

func setAllowsInlinePredictions(_ allowsInlinePredictions: Bool) {
func setAllowsInlinePredictions(_ newValue: Bool) {
guard supportsInlinePredictions else {
return
}

// [macOS 14] WebKit hasn't yet exposed this as public, even it's documented
setValue(allowsInlinePredictions, forKey: "allowsInlinePredictions")
#if compiler(>=5.9)
if #available(macOS 14.0, *) {
allowsInlinePredictions = newValue
return
}
#endif

setValue(newValue, forKey: "allowsInlinePredictions")
}
}
9 changes: 5 additions & 4 deletions MarkEditMacTests/RuntimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ final class RuntimeTests: XCTestCase {
return
}

// [macOS 14] Remove after WebKit exposes this as public
let configuration = WKWebViewConfiguration()
configuration.setValue(true, forKey: "allowsInlinePredictions")
testExistenceOfSelector(object: configuration, selector: "setAllowsInlinePredictions:")
#if compiler(<5.9)
let configuration = WKWebViewConfiguration()
configuration.setValue(true, forKey: "allowsInlinePredictions")
testExistenceOfSelector(object: configuration, selector: "setAllowsInlinePredictions:")
#endif
}

func testExistenceOfDrawsBackground() {
Expand Down

0 comments on commit 8ea1972

Please sign in to comment.