mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 10:18:38 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
44
mobile/ios/Client/UIScrollViewSwizzled.swift
Normal file
44
mobile/ios/Client/UIScrollViewSwizzled.swift
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import Shared
|
||||
|
||||
// Workaround for bug 1417152, whereby NaN bounds are being set on the scrollview when viewing PDFs in the web view.
|
||||
// Is fixed in WebKit, remove this file when the fix arrives in iOS release.
|
||||
|
||||
private let swizzling: (UIScrollView.Type) -> Void = { obj in
|
||||
let originalSelector = #selector(setter: UIView.bounds)
|
||||
let swizzledSelector = #selector(obj.swizzle_setBounds(bounds:))
|
||||
let originalMethod = class_getInstanceMethod(obj, originalSelector)
|
||||
let swizzledMethod = class_getInstanceMethod(obj, swizzledSelector)
|
||||
method_exchangeImplementations(originalMethod, swizzledMethod)
|
||||
}
|
||||
|
||||
extension UIScrollView {
|
||||
open override class func initialize() {
|
||||
// make sure this isn't a subclass
|
||||
guard self == UIScrollView.self else {
|
||||
return
|
||||
}
|
||||
swizzling(self)
|
||||
}
|
||||
|
||||
func swizzle_setBounds(bounds: CGRect) {
|
||||
[bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height].forEach() { val in
|
||||
if val.isNaN || val.isInfinite {
|
||||
Sentry.shared.send(message: "Bad scrollview bounds detected [infinite/nan].")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
[bounds.size.width, bounds.size.height].forEach() { val in
|
||||
if val < 0 {
|
||||
Sentry.shared.send(message: "Bad scrollview bounds detected [negative size].")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
self.swizzle_setBounds(bounds: bounds)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue