|
@@ -41,6 +41,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
41
|
41
|
{
|
42
|
42
|
UIColor * _savedBackgroundColor;
|
43
|
43
|
BOOL _savedHideKeyboardAccessoryView;
|
|
44
|
+ BOOL _savedKeyboardDisplayRequiresUserAction;
|
44
|
45
|
}
|
45
|
46
|
|
46
|
47
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
@@ -54,6 +55,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
54
|
55
|
_directionalLockEnabled = YES;
|
55
|
56
|
_automaticallyAdjustContentInsets = YES;
|
56
|
57
|
_contentInset = UIEdgeInsetsZero;
|
|
58
|
+ _savedKeyboardDisplayRequiresUserAction = YES;
|
57
|
59
|
}
|
58
|
60
|
|
59
|
61
|
// Workaround for a keyboard dismissal bug present in iOS 12
|
|
@@ -214,6 +216,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
214
|
216
|
|
215
|
217
|
[self addSubview:_webView];
|
216
|
218
|
[self setHideKeyboardAccessoryView: _savedHideKeyboardAccessoryView];
|
|
219
|
+ [self setKeyboardDisplayRequiresUserAction: _savedKeyboardDisplayRequiresUserAction];
|
217
|
220
|
[self visitSource];
|
218
|
221
|
}
|
219
|
222
|
}
|
|
@@ -364,6 +367,64 @@ static NSURLCredential* clientAuthenticationCredential;
|
364
|
367
|
}
|
365
|
368
|
}
|
366
|
369
|
|
|
370
|
+-(void)setKeyboardDisplayRequiresUserAction:(BOOL)keyboardDisplayRequiresUserAction
|
|
371
|
+{
|
|
372
|
+ if (_webView == nil) {
|
|
373
|
+ _savedKeyboardDisplayRequiresUserAction = keyboardDisplayRequiresUserAction;
|
|
374
|
+ return;
|
|
375
|
+ }
|
|
376
|
+
|
|
377
|
+ if (_savedKeyboardDisplayRequiresUserAction == true) {
|
|
378
|
+ return;
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+ UIView* subview;
|
|
382
|
+
|
|
383
|
+ for (UIView* view in _webView.scrollView.subviews) {
|
|
384
|
+ if([[view.class description] hasPrefix:@"WK"])
|
|
385
|
+ subview = view;
|
|
386
|
+ }
|
|
387
|
+
|
|
388
|
+ if(subview == nil) return;
|
|
389
|
+
|
|
390
|
+ Class class = subview.class;
|
|
391
|
+
|
|
392
|
+ NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
|
|
393
|
+ NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
|
|
394
|
+
|
|
395
|
+ Method method;
|
|
396
|
+ IMP override;
|
|
397
|
+
|
|
398
|
+ if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
|
|
399
|
+ // iOS 12.2.0 - Future
|
|
400
|
+ SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
|
|
401
|
+ method = class_getInstanceMethod(class, selector);
|
|
402
|
+ IMP original = method_getImplementation(method);
|
|
403
|
+ override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
|
|
404
|
+ ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
|
|
405
|
+ });
|
|
406
|
+ }
|
|
407
|
+ else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
|
|
408
|
+ // iOS 11.3.0 - 12.2.0
|
|
409
|
+ SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
|
|
410
|
+ method = class_getInstanceMethod(class, selector);
|
|
411
|
+ IMP original = method_getImplementation(method);
|
|
412
|
+ override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
|
|
413
|
+ ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
|
|
414
|
+ });
|
|
415
|
+ } else {
|
|
416
|
+ // iOS 9.0 - 11.3.0
|
|
417
|
+ SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
|
|
418
|
+ method = class_getInstanceMethod(class, selector);
|
|
419
|
+ IMP original = method_getImplementation(method);
|
|
420
|
+ override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
|
|
421
|
+ ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
|
|
422
|
+ });
|
|
423
|
+ }
|
|
424
|
+
|
|
425
|
+ method_setImplementation(method, override);
|
|
426
|
+}
|
|
427
|
+
|
367
|
428
|
-(void)setHideKeyboardAccessoryView:(BOOL)hideKeyboardAccessoryView
|
368
|
429
|
{
|
369
|
430
|
if (_webView == nil) {
|