/r/WebKit
/r/WebKit
Hey everyone, I'm trying to figure out how to determine which WebKit GitHub tags or commits are included in a specific Safari release. Is there a clear way to track which WebKit changes made it into different versions of Safari? Any tips or resources would be appreciated! Thanks!
I am creating a macOS WebKit based browser in Swift and when I load a game such as EaglerCraft or FNF in the browser, it does not accept keyboard input. However, JavaScript keyDown works, and input into text boxes works. So, why do games not work with input?
I am on macOS Sequoia 15.2, and Xcode 16.2
Below is my code:
import SwiftUI
import WebKit
class CustomWKWebView: WKWebView {
override var acceptsFirstResponder: Bool {
return true
}
override func keyDown(with event: NSEvent) {
super.keyDown(with: event) // Pass the event to the web content
}
override func keyUp(with event: NSEvent) {
super.keyUp(with: event) // Pass the event to the web content
}
}
struct WebView: NSViewRepresentable {
u/Binding var currentURL: String
u/Binding var pageTitle: String
class KeyPressHandlerView: NSView {
override var acceptsFirstResponder: Bool {
return true
}
override func keyDown(with event: NSEvent) {
super.keyDown(with: event) // Propagate the event
}
}
func makeNSView(context: Context) -> WKWebView {
let webView = CustomWKWebView() // Use the custom subclass
// Configure WKWebView
webView.configuration.preferences.setValue(true, forKey: "acceleratedDrawingEnabled")
webView.configuration.websiteDataStore = WKWebsiteDataStore.default()
webView.configuration.processPool = WKProcessPool()
webView.configuration.preferences.setValue(true, forKey: "fullScreenEnabled")
webView.allowsMagnification = true
webView.allowsBackForwardNavigationGestures = true
webView.customUserAgent = "MyCustomUserAgent/1.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36"
// Enable smooth scrolling and accelerated rendering if available
if webView.configuration.preferences.responds(to: Selector(("scrollAnimatorEnabled"))) {
webView.configuration.preferences.setValue(true, forKey: "scrollAnimatorEnabled")
}
// Set navigation and UI delegation
webView.navigationDelegate = context.coordinator
webView.uiDelegate = context.coordinator as? WKUIDelegate
// Assign the created WKWebView to the shared instance
WebViewController.shared.webView = webView
return webView
}
func updateNSView(_ nsView: WKWebView, context: Context) {
if let url = URL(string: currentURL), url != nsView.url {
nsView.load(URLRequest(url: url))
}
}
func makeCoordinator() -> Coordinator {
Coordinator(currentURL: $currentURL, pageTitle: $pageTitle)
}
class Coordinator: NSObject, WKNavigationDelegate, WKUIDelegate {
u/Binding var currentURL: String
u/Binding var pageTitle: String
init(currentURL: Binding<String>, pageTitle: Binding<String>) {
_currentURL = currentURL
_pageTitle = pageTitle
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
currentURL = webView.url?.absoluteString ?? currentURL
pageTitle = webView.title ?? "Untitled"
}
}
}
struct ContentView: View {
u/State private var currentURL = "https://www.google.com"
u/State private var pageTitle = "Google"
u/State private var inputURL = ""
u/State private var webView: WKWebView? = nil // Reference to the WKWebView instance
u/State private var titleBarColor = Color.blue // Title bar color
u/State private var showColorPicker = false // Toggle color picker visibility
init() {
// Load the saved color from UserDefaults
if let savedColor = UserDefaults.standard.color(forKey: "titleBarColor") {
_titleBarColor = State(initialValue: savedColor)
}
}
var body: some View {
VStack(spacing: 0) {
// Title Bar with URL Entry and Reload Button
// Title Bar with URL Entry and Reload Button
HStack {
TextField("Enter URL", text: $inputURL, onCommit: {
loadURL()
})
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding(.leading)
.foregroundColor(.black) // Force the text color to black
Button("Reload") {
WebViewController.shared.webView?.reload() // Reload the current page
}
.padding(.trailing)
Button("Customize Color") {
showColorPicker.toggle()
}
.padding(.trailing)
}
.padding()
.background(titleBarColor)
.foregroundColor(.white)
// Color Picker
if showColorPicker {
ColorPicker("Select Title Bar Color", selection: $titleBarColor)
.padding()
.background(Color.white)
.onChange(of: titleBarColor) { newColor in
saveColor(newColor) // Save the updated color
}
}
// WebView
WebView(currentURL: $currentURL, pageTitle: $pageTitle)
.onAppear { webView = WebViewController.shared.webView } // Set the webView instance
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onAppear {
webView?.becomeFirstResponder() // Ensure keyboard focus
}
Spacer()
}
.edgesIgnoringSafeArea(.bottom)
.onAppear {
inputURL = currentURL
}
.onChange(of: currentURL) { newURL in
inputURL = newURL
}
.onKeyDown { event in
// Detect Cmd+R for reload
if event.modifierFlags.contains(.command) && event.keyCode == 15 { // Cmd+R
reloadPage()
}
}
}
private func loadURL() {
if let formattedURL = formattedURL(inputURL) {
currentURL = formattedURL.absoluteString
webView?.load(URLRequest(url: formattedURL))
}
}
private func reloadPage() {
webView?.reload()
}
private func formattedURL(_ urlString: String) -> URL? {
if urlString.lowercased().hasPrefix("http://") || urlString.lowercased().hasPrefix("https://") {
return URL(string: urlString)
} else {
return URL(string: "https://\(urlString)")
}
}
private func saveColor(_ color: Color) {
UserDefaults.standard.setColor(color, forKey: "titleBarColor")
}
}
// WebViewController to manage WKWebView instance
class WebViewController {
static let shared = WebViewController()
var webView: WKWebView?
private init() {
webView = WKWebView()
}
}
// Extension for handling key events
extension View {
func onKeyDown(perform action: u/escaping (NSEvent) -> Void) -> some View {
KeyEventHandler(perform: action).background(self)
}
}
struct KeyEventHandler: NSViewRepresentable {
var perform: (NSEvent) -> Void
func makeNSView(context: Context) -> NSView {
let view = KeyPressHandlerView()
view.onKeyDown = perform
return view
}
func updateNSView(_ nsView: NSView, context: Context) {}
}
class KeyPressHandlerView: NSView {
var onKeyDown: ((NSEvent) -> Void)?
override func keyDown(with event: NSEvent) {
onKeyDown?(event)
}
override var acceptsFirstResponder: Bool {
true
}
}
// Extension to save and load Color in UserDefaults
extension UserDefaults {
func setColor(_ color: Color, forKey key: String) {
guard let nsColor = NSColor(color) else { return }
if let colorData = try? NSKeyedArchiver.archivedData(withRootObject: nsColor, requiringSecureCoding: false) {
set(colorData, forKey: key)
}
}
func color(forKey key: String) -> Color? {
guard let colorData = data(forKey: key),
let nsColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(colorData) as? NSColor else {
return nil
}
return Color(nsColor)
}
}
extension NSColor {
convenience init?(_ color: Color) {
guard let cgColor = color.cgColor else { return nil }
self.init(cgColor: cgColor)
}
}
I have tried giving elevated permissions, and I also tried to change some onKeyDown things, but so far nothing has worked.
Many thanks and happy new year!
I use a webkitgtk browser called Epiphany that only supports ad blocking through webkit content blocker json files. I was wondering if anyone here know of any repositories or urls serving these files?
Just curious how powerful it is
Hi everyone, I'm using Linux, and currently trying to build a cross-platform application that takes input from a stylus on a Wacom tablet. Specifically, I really need to get the stylus pressure. I decided to use Tauri, which unless I'm gravely mistaken is based on WebKit, at least on Linux.
I tried using the pressure
property of PointerEvent
, but it always seems to be equal to 0. On the other hand, I can get the X and Y coordinates of my pointer just fine.
I tried to see if the issue came from WebKit by visiting https://pressurejs.com/ using Epiphany, a WebKit-based browser, and indeed my stylus' pressure does not have an impact on the animations. On the other hand, the animations react to stylus pressure when I visit the webpage using Firefox.
I also tried using the webkitForce
property of MouseEvent
, instead of pressure
from PointerEvent
, to no avail.
So I have the following questions; any help on any one of those would be appreciated:
pressure
is not valid in WebKit, even though this table indicates that it has been compatible with all considered browsers for a long time?webkitForce
is not valid in WebKit, even though... it has "WebKit" in the name?I am still a little fuzzy on the specifics of how WebKit interacts with webkitgtk, GTK, Tauri and the wry library, so sorry if my post is confused. If this is not a WebKit issue, but an issue in one of those other projects, please let me know.
Thank you for any help!
Is there an easy way (perhaps in WebKit) to search for a given word on the displayed web page?
In my app, I have a long help page written in HTML, displayed using Webkit (MacOS 12.6). I would like to be able to quickly search for particular keywords.
Some quick googling brings up lots of links about how to do an "on page" search within Safari (Cmd-F) but almost nothing about how to create such functionality myself. Or am I googling in the wrong direction?
Device : IPHONE 13 (MLPH3ZD/A)
Version : IOS 16.6
here are the 2 lines that appear within the instagram setting tab:
Version : 303:1.0.8.111
Branch Type : local
My account has a strange behavior. It behaves differently than what it used to.
Conclusion : I still look for diverse point of views regarding what I evoked previously. I am determined to get rid of the spiderweb trap my previous digital marketing departement put me into, to expose myself to diverse marketing stimuli. I have rights as a human being for the protection of my data and the malicious use of my person as an object for brand exposures.
Thank you for staying until the end,
A sympathic large boy õ¿õ¬
Hi, I know this sub isn't that active, but I figured there is not a better place to post this.
I was trying to build WebKit from source for the past few days now. And every time I get this (look at the end of the post) error, I tried re-cloning the git repository but it didn't help.
I am using macOS 10.13.6 High Sierra with Xcode version 10, which I guess could be the problem since they're kind of outdated, but the WebKit readme says this version is supported.
I tried both command line and Xcode build but they all fail.
Here is the output that the command line build gives (I edited my user's name if you don't mind):
Build settings from command line:
ARCHS = x86_64
OBJROOT = /Users/{user}/Development/WebKit/WebKitBuild
SDKROOT = macosx
SHARED_PRECOMPS_DIR = /Users/{user}/Development/WebKit/WebKitBuild/PrecompiledHeaders
SYMROOT = /Users/{user}/Development/WebKit/WebKitBuild
2022-09-06 18:23:46.904 xcodebuild[18922:324757] NOTE: Referenced project PAL was written by a newer Xcode version (52) -- temporarily downgrading it (without modifying project file)
note: Using new build system
note: Planning build
note: Constructing build description
Build system information
warning: WebKitTestRunner isn't code signed but requires entitlements. It is not possible to add entitlements to a binary without signing it. (in target 'WebKitTestRunner')
Build system information
warning: TestWebKitAPI isn't code signed but requires entitlements. It is not possible to add entitlements to a binary without signing it. (in target 'TestWebKitAPI')
Build system information
warning: Skipping duplicate build file in Compile Sources build phase: /Users/{user}/Development/WebKit/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (in target 'JSCLLIntSettingsExtractor')
Build system information
warning: Skipping duplicate build file in Compile Sources build phase: /Users/{user}/Development/WebKit/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (in target 'JSCLLIntOffsetsExtractor')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'DumpRenderTree (Library)')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target '
DumpRenderTree.app
')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'LayoutTestHelper')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'DumpRenderTree')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'WebKitTestRunnerInjectedBundle')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'WebKitTestRunnerApp')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'WebKitTestRunner (Library)')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'WebKitTestRunner')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'MiniBrowser')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'WebProcessPlugIn')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestIPC')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'InjectedBundleTestWebKitAPI')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestWebKitAPILibrary')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestWTFLibrary')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestWebKitAPI')
Build system information
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestWTF')
Build system information
warning: missing creator for mutated node: ('/Users/{user}/Development/WebKit/WebKitBuild/Debug/DumpRenderTree.app/Contents/MacOS/DumpRenderTree') (in target '
DumpRenderTree.app
')
Build system information
warning: duplicate output file '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/CoreUISPI.h' on task: CpHeader /Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/mac/CoreUISPI.h /Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/CoreUISPI.h (in target 'PAL')
Build system information
warning: duplicate output file '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/SystemPreviewSPI.h' on task: CpHeader /Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h /Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/SystemPreviewSPI.h (in target 'PAL')
Build system information
warning: duplicate output file '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/wtf/SoftLinking.h' on task: CpHeader /Users/{user}/Development/WebKit/Source/WTF/wtf/cocoa/SoftLinking.h /Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/wtf/SoftLinking.h (in target 'WTF')
Build system information
error: Multiple commands produce '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/wtf/SoftLinking.h':
1) Target 'WTF' (project 'WTF') has copy command from '/Users/{user}/Development/WebKit/Source/WTF/wtf/SoftLinking.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/wtf/SoftLinking.h'
2) Target 'WTF' (project 'WTF') has copy command from '/Users/{user}/Development/WebKit/Source/WTF/wtf/cocoa/SoftLinking.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/wtf/SoftLinking.h'
Build system information
error: Multiple commands produce '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/SystemPreviewSPI.h':
1) Target 'PAL' (project 'PAL') has copy command from '/Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/SystemPreviewSPI.h'
2) Target 'PAL' (project 'PAL') has copy command from '/Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/SystemPreviewSPI.h'
Build system information
error: Multiple commands produce '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/CoreUISPI.h':
1) Target 'PAL' (project 'PAL') has copy command from '/Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/ios/CoreUISPI.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/CoreUISPI.h'
2) Target 'PAL' (project 'PAL') has copy command from '/Users/{user}/Development/WebKit/Source/WebCore/PAL/pal/spi/mac/CoreUISPI.h' to '/Users/{user}/Development/WebKit/WebKitBuild/Debug/usr/local/include/pal/CoreUISPI.h'
** BUILD FAILED **
Where does WebKit store the data (Browse History, etc) on Epiphany? Im trying to erase everything by code.
Submit email to form on https://iptv.fish
"URL is not valid or contains user credentials."
I'm using fetch natively in the browser and for some reason it thinks the email address is a credential.
https://github.com/WebKit/webkit/blob/main/Source/WebCore/Modules/fetch/FetchRequest.cpp#L166
If you're on linux you can test with Epiphany browser. or iOS/safari
edit: I discovered I had a space in my endpoint url. lol weird ass fucking bug, works fine in chrome/firefox -- safari don't likey spaces
Hi. I Wana develop a pure c++ application and embed WebKit inside it.
What's the latest version of WebKit that supports windows xp?
I can't seem to find information on what version of webkit is used in a particular version of webkitGTK. Is there a chart somewhere that has a version correspondence list?
It seems like a shame that WebKit isn't available on Windows anymore, because it's great for designing and developing various unique kinds of browsers, while Google's Blink is heavily designed around developing Chromium-style browsers. Also, the lack of such a browser for Windows means that web developers that want to test against WebKit have to use MacOS or Linux, which doesn't seem like an ideal situation. This seems like it constrains the creativity and options of browser developers, in addition to making things harder than they have to be for web designers that are using Windows.
So, I'm looking to use WebKit.NET, and I saw in the API [documentation] (http://webkitdotnet.sourceforge.net/docs/) that there are methods like getElementById, which I've seen JavaScript use often.
Are these methods there because thay're used by the JavaScript engine, or do they exist in the JavaScript engine because those are the methods that WebKit exposes?
Also, is there an event model, could I subscribe to the click event of a div, for example?