Script origins control inline policy, all scripts allowed for tab
This commit is contained in:
@@ -37,31 +37,48 @@ class BrowserView: UIView
|
||||
addSubview(titlebarView)
|
||||
|
||||
keyboardWillShowObserver = NotificationCenter.default.publisher(for: UIWindow.keyboardWillShowNotification).sink { notification in
|
||||
if let keyboardFrame = notification.userInfo?[UIWindow.keyboardFrameEndUserInfoKey] as? CGRect {
|
||||
self.keyboardLayoutOffset = self.bounds.height - keyboardFrame.minY
|
||||
}
|
||||
self.adjustOffsetForKeyboardNotification(userInfo: notification.userInfo!)
|
||||
}
|
||||
|
||||
keyboardWillHideObserver = NotificationCenter.default.publisher(for: UIWindow.keyboardWillHideNotification).sink { notification in
|
||||
if let keyboardFrame = notification.userInfo?[UIWindow.keyboardFrameEndUserInfoKey] as? CGRect {
|
||||
self.keyboardLayoutOffset = self.bounds.height - keyboardFrame.minY
|
||||
}
|
||||
self.adjustOffsetForKeyboardNotification(userInfo: notification.userInfo!)
|
||||
}
|
||||
}
|
||||
|
||||
override func layoutSubviews()
|
||||
{
|
||||
private func adjustOffsetForKeyboardNotification(userInfo: [AnyHashable : Any]) {
|
||||
guard let keyboardEndFrame = userInfo[UIWindow.keyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||
guard let animationDuration = userInfo[UIWindow.keyboardAnimationDurationUserInfoKey] as? TimeInterval else { return }
|
||||
guard let animationCurve = userInfo[UIWindow.keyboardAnimationCurveUserInfoKey] as? Int else { return }
|
||||
|
||||
let animationOptions: UIView.AnimationOptions = { curve -> UIView.AnimationOptions in
|
||||
switch UIView.AnimationCurve(rawValue: curve) {
|
||||
case .easeIn: return .curveEaseIn
|
||||
case .easeOut: return .curveEaseOut
|
||||
case .easeInOut: return .curveEaseInOut
|
||||
default: return .init()
|
||||
}
|
||||
}(animationCurve)
|
||||
|
||||
self.keyboardLayoutOffset = bounds.height - keyboardEndFrame.minY
|
||||
UIView.animate(withDuration: animationDuration, delay: 0.0, options: animationOptions, animations: { self.layoutIfNeeded() }, completion: nil)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
webView?.frame = bounds
|
||||
|
||||
if let toolbarView = toolbarView {
|
||||
var toolbarSize = toolbarView.sizeThatFits(bounds.size)
|
||||
|
||||
var bottomOffset: CGFloat = 0.0
|
||||
if keyboardLayoutOffset == 0 {
|
||||
toolbarSize.height += safeAreaInsets.bottom
|
||||
} else if toolbarView.urlBar?.textField.isFirstResponder ?? false {
|
||||
bottomOffset = keyboardLayoutOffset
|
||||
}
|
||||
|
||||
toolbarView.bounds = CGRect(origin: .zero, size: toolbarSize)
|
||||
toolbarView.center = CGPoint(x: bounds.center.x, y: bounds.maxY - (toolbarView.bounds.height / 2) - keyboardLayoutOffset)
|
||||
toolbarView.center = CGPoint(x: bounds.center.x, y: bounds.maxY - (toolbarView.bounds.height / 2) - bottomOffset)
|
||||
}
|
||||
|
||||
bringSubviewToFront(titlebarView)
|
||||
@@ -77,7 +94,7 @@ class BrowserView: UIView
|
||||
var webViewContentInset = UIEdgeInsets()
|
||||
webViewContentInset.top = titlebarView.frame.height
|
||||
webViewContentInset.bottom = toolbarView?.frame.height ?? 0
|
||||
webView?.scrollView.contentInset = webViewContentInset
|
||||
webView?.scrollView.contentInset = webViewContentInset.subtracting(safeAreaInsets)
|
||||
webView?.scrollView.scrollIndicatorInsets = webViewContentInset
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user