Move off of internal SDK, copy webkit spis from opensource

This commit is contained in:
2025-04-11 18:27:59 -07:00
parent 177db26b69
commit 2f4b3c64fe
37 changed files with 2432 additions and 32 deletions

View File

@@ -779,11 +779,7 @@ extension BrowserViewController: UITextFieldDelegate
return false
}
override func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
true
}
func textFieldDidEndEditing(_ textField: UITextField) {
if !changingFocusToAutocompleteController {
autocompleteViewController.view.isHidden = true

View File

@@ -103,9 +103,16 @@ class DocumentControlItemView: UIControl
separatorView.isHidden = !drawsBottomSeparator
}
override func setTracking(_ tracking: Bool) {
super.setTracking(tracking)
highlightView.isHidden = !tracking
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
super.beginTracking(touch, with: event)
highlightView.isHidden = false
return true
}
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
super.endTracking(touch, with: event)
highlightView.isHidden = true
}
public func title(_ title: String) -> Self {

View File

@@ -41,7 +41,7 @@ class FindOnPageViewController: UIViewController, _WKFindDelegate
findOnPageView.textField.addAction(UIAction(handler: { [unowned self] _ in
self.findString = findOnPageView.textField.text
webView?._find(self.findString, options: self.findOptions, maxCount: Int(self.maxCount))
webView?._find(self.findString, options: self.findOptions, maxCount: UInt(self.maxCount))
}), for: .editingChanged)
findOnPageView.prevResultButton.addAction(UIAction(handler: { [unowned self] _ in
@@ -82,24 +82,20 @@ class FindOnPageViewController: UIViewController, _WKFindDelegate
@objc
override func findNext(_ sender: Any?) {
webView?._find(self.findString, options: self.findOptions, maxCount: Int(self.maxCount))
webView?._find(self.findString, options: self.findOptions, maxCount: UInt(self.maxCount))
}
@objc
override func findPrevious(_ sender: Any?) {
let options: _WKFindOptions = self.findOptions.union(.backwards)
webView?._find(self.findString, options: options, maxCount: Int(self.maxCount))
webView?._find(self.findString, options: options, maxCount: UInt(self.maxCount))
}
func _webView(_ webView: WKWebView!, didFailToFind string: String!) {
// ??
}
private func _webView(_ webView: WKWebView!, didCountMatches matches: UInt, for string: String!) {
// TODO: Update a label
}
private func _webView(_ webView: WKWebView!, didFindMatches matches: UInt, for string: String!, withMatch matchIndex: Int) {
internal func _webView(_ webView: WKWebView!, didFindMatches matches: UInt, for string: String!, withMatch matchIndex: Int) {
findOnPageView.nextResultButton.isEnabled = matches > 0
findOnPageView.prevResultButton.isEnabled = matches > 0
}

View File

@@ -6,7 +6,6 @@
//
import UIKit
import UIKit_Private.UIKeyCommand_Private
@objc
protocol ShortcutResponder: AnyObject {
@@ -170,14 +169,14 @@ public class KeyboardShortcuts {
modifiers: [.alternate], input: "x",
title: "Raise Script Policy Restriction",
action: #selector(ShortcutResponder.raiseScriptPolicyRestriction)
)._nonRepeatable(),
),
// Lower Script Policy Restriction
UIKeyCommand(
modifiers: [.alternate], input: "c",
title: "Lower Script Policy Restriction",
action: #selector(ShortcutResponder.lowerScriptPolicyRestriction)
)._nonRepeatable(),
),
])
].removeNulls()

View File

@@ -5,8 +5,9 @@
#import "SBRProcessBundleBridge.h"
#import "SBRScriptPolicy.h"
#import "WebKitDefines.h"
// SPI
#import <UIKit/UITextField_Private.h>
#import <WebKit/WKWebViewPrivate.h>
#import <WebKit/_WKFindDelegate.h>

View File

@@ -0,0 +1,19 @@
//
// WebKitDefines.h
// SBrowser
//
// Created by James Magahern on 4/11/25.
//
#ifndef WebKitDefines_h
#define WebKitDefines_h
#define WK_API_AVAILABLE(...)
#define WK_API_UNAVAILABLE(...)
#define WK_CLASS_AVAILABLE(...) __attribute__((visibility("default"))) WK_API_AVAILABLE(__VA_ARGS__)
#define WK_API_DEPRECATED(_message, ...) __attribute__((deprecated(_message)))
#define WK_API_DEPRECATED_WITH_REPLACEMENT(_replacement, ...) __attribute__((deprecated("use " #_replacement)))
#define WK_CLASS_DEPRECATED_WITH_REPLACEMENT(_replacement, ...) __attribute__((visibility("default"))) __attribute__((deprecated("use " #_replacement)))
#endif /* WebKitDefines_h */

View File

@@ -6,7 +6,6 @@
//
import UIKit
import QuartzCore_Private
class SecurityIndicatorView: UIView
{
@@ -70,7 +69,7 @@ class TitlebarView: UIView
addSubview(separatorView)
separatorView.backgroundColor = UIColor(white: 1.0, alpha: 0.20)
separatorView.layer.compositingFilter = kCAFilterPlusL
separatorView.layer.compositingFilter = "kCAFilterPlusL"
titleLabelView.textColor = .white
titleLabelView.layer.shadowColor = UIColor.black.cgColor

View File

@@ -183,7 +183,7 @@ class URLBar: ReliefButton
controlsView.autoresizingMask = []
controlsView.clearButton.addAction(.init(handler: { [textField] _ in
textField.clearText()
textField.text = ""
}), for: .primaryActionTriggered)
controlsView.autocorrectButton.addAction(.init(handler: { [unowned self] _ in

View File

@@ -33,14 +33,14 @@ extension CGRect
public func centeredY(inRect: CGRect) -> CGRect {
var rect = self
rect.origin.y = CGRound(inRect.origin.y + (inRect.height - rect.height) / 2.0)
rect.origin.y = (inRect.origin.y + (inRect.height - rect.height) / 2.0).rounded()
return rect
}
public func centeredX(inRect: CGRect) -> CGRect {
var rect = self
rect.origin.x = CGRound(inRect.origin.x + (inRect.width - rect.width) / 2.0)
rect.origin.x = (inRect.origin.x + (inRect.width - rect.width) / 2.0).rounded()
return rect
}