1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
/* Cydia - iPhone UIKit Front-End for Debian APT
* Copyright (C) 2008-2015 Jay Freeman (saurik)
*/
/* GNU General Public License, Version 3 {{{ */
/*
* Cydia is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* Cydia is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cydia. If not, see <http://www.gnu.org/licenses/>.
**/
/* }}} */
#include "CyteKit/UCPlatform.h"
#include "CyteKit/dispatchEvent.h"
#include "CyteKit/WebView.h"
#include "Substrate.hpp"
#include "iPhonePrivate.h"
// CYWebPolicyDecision* {{{
@interface CYWebPolicyDecisionMediator : NSObject <
WebPolicyDecisionListener
> {
id<WebPolicyDecisionListener> listener_;
CYWebPolicyDecision decision_;
}
- (id) initWithListener:(id<WebPolicyDecisionListener>)listener;
- (CYWebPolicyDecision) decision;
- (bool) decided;
- (bool) decide;
@end
@implementation CYWebPolicyDecisionMediator
- (id) initWithListener:(id<WebPolicyDecisionListener>)listener {
if ((self = [super init]) != nil) {
listener_ = listener;
} return self;
}
- (CYWebPolicyDecision) decision {
return decision_;
}
- (bool) decided {
return decision_ != CYWebPolicyDecisionUnknown;
}
- (bool) decide {
switch (decision_) {
case CYWebPolicyDecisionUnknown:
default:
NSLog(@"CYWebPolicyDecisionUnknown");
return false;
case CYWebPolicyDecisionDownload: [listener_ download]; break;
case CYWebPolicyDecisionIgnore: [listener_ ignore]; break;
case CYWebPolicyDecisionUse: [listener_ use]; break;
}
return true;
}
- (void) download {
decision_ = CYWebPolicyDecisionDownload;
}
- (void) ignore {
decision_ = CYWebPolicyDecisionIgnore;
}
- (void) use {
decision_ = CYWebPolicyDecisionUse;
}
@end
// }}}
@implementation CyteWebView : UIWebView {
}
#if ShowInternals
#include "CyteKit/UCInternal.h"
#endif
- (id) initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame]) != nil) {
} return self;
}
- (void) dealloc {
if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) {
UIWebViewInternal *&_internal(MSHookIvar<UIWebViewInternal *>(self, "_internal"));
if (&_internal != NULL) {
UIWebViewWebViewDelegate *&webViewDelegate(MSHookIvar<UIWebViewWebViewDelegate *>(_internal, "webViewDelegate"));
if (&webViewDelegate != NULL)
[webViewDelegate _clearUIWebView];
}
}
[super dealloc];
}
- (NSString *) description {
return [NSString stringWithFormat:@"<%s: %p, %@>", class_getName([self class]), self, [[[self request] URL] absoluteString]];
}
- (id<CyteWebViewDelegate>) delegate {
return (id<CyteWebViewDelegate>) [super delegate];
}
- (void) setDelegate:(id<CyteWebViewDelegate>)delegate {
[super setDelegate:delegate];
}
/*- (WebView *) webView:(WebView *)view createWebViewWithRequest:(NSURLRequest *)request {
id<CyteWebViewDelegate> delegate([self delegate]);
WebView *created(nil);
if (created == nil && [delegate respondsToSelector:@selector(webView:createWebViewWithRequest:)])
created = [delegate webView:view createWebViewWithRequest:request];
if (created == nil && [UIWebView instancesRespondToSelector:@selector(webView:createWebViewWithRequest:)])
created = [super webView:view createWebViewWithRequest:request];
return created;
}*/
// webView:addMessageToConsole: (X.Xx) {{{
static void $UIWebViewWebViewDelegate$webView$addMessageToConsole$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSDictionary *message) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:addMessageToConsole:)])
[uiWebView webView:view addMessageToConsole:message];
}
- (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:addMessageToConsole:)])
[delegate webView:view addMessageToConsole:message];
if ([UIWebView instancesRespondToSelector:@selector(webView:addMessageToConsole:)])
[super webView:view addMessageToConsole:message];
}
// }}}
// webView:decidePolicyForNavigationAction:request:frame:decisionListener: (2.0+) {{{
- (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
id<CyteWebViewDelegate> delegate([self delegate]);
CYWebPolicyDecisionMediator *mediator([[[CYWebPolicyDecisionMediator alloc] initWithListener:listener] autorelease]);
if (![mediator decided] && [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)])
[delegate webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator];
if (![mediator decided] && [UIWebView instancesRespondToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)])
[super webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator];
if ([delegate respondsToSelector:@selector(webView:didDecidePolicy:forNavigationAction:request:frame:)])
[delegate webView:view didDecidePolicy:[mediator decision] forNavigationAction:action request:request frame:frame];
[mediator decide];
}
// }}}
// webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener: (3.0+) {{{
static void $UIWebViewWebViewDelegate$webView$decidePolicyForNewWindowAction$request$newFrameName$decisionListener$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSDictionary *action, NSURLRequest *request, NSString *frame, id<WebPolicyDecisionListener> listener) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:)])
[uiWebView webView:view decidePolicyForNewWindowAction:action request:request newFrameName:frame decisionListener:listener];
}
- (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
id<CyteWebViewDelegate> delegate([self delegate]);
CYWebPolicyDecisionMediator *mediator([[[CYWebPolicyDecisionMediator alloc] initWithListener:listener] autorelease]);
if (![mediator decided] && [delegate respondsToSelector:@selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:)])
[delegate webView:view decidePolicyForNewWindowAction:action request:request newFrameName:frame decisionListener:mediator];
if (![mediator decided] && [UIWebView instancesRespondToSelector:@selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:)])
[super webView:view decidePolicyForNewWindowAction:action request:request newFrameName:frame decisionListener:mediator];
[mediator decide];
}
// }}}
// webView:didClearWindowObject:forFrame: (3.2+) {{{
static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, WebScriptObject *window, WebFrame *frame) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
[uiWebView webView:view didClearWindowObject:window forFrame:frame];
}
- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
[delegate webView:view didClearWindowObject:window forFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didClearWindowObject:forFrame:)])
[super webView:view didClearWindowObject:window forFrame:frame];
}
// }}}
// webView:didCommitLoadForFrame: (3.0+) {{{
static void $UIWebViewWebViewDelegate$webView$didCommitLoadForFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, WebFrame *frame) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:didCommitLoadForFrame:)])
[uiWebView webView:view didCommitLoadForFrame:frame];
}
- (void) webView:(WebView *)view didCommitLoadForFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didCommitLoadForFrame:)])
[delegate webView:view didCommitLoadForFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didCommitLoadForFrame:)])
[super webView:view didCommitLoadForFrame:frame];
}
// }}}
// webView:didFailLoadWithError:forFrame: (2.0+) {{{
- (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
[delegate webView:view didFailLoadWithError:error forFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
[super webView:view didFailLoadWithError:error forFrame:frame];
}
// }}}
// webView:didFailProvisionalLoadWithError:forFrame: (2.0+) {{{
- (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didFailProvisionalLoadWithError:forFrame:)])
[delegate webView:view didFailProvisionalLoadWithError:error forFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didFailProvisionalLoadWithError:forFrame:)])
[super webView:view didFailProvisionalLoadWithError:error forFrame:frame];
}
// }}}
// webView:didFinishLoadForFrame: (2.0+) {{{
- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didFinishLoadForFrame:)])
[delegate webView:view didFinishLoadForFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didFinishLoadForFrame:)])
[super webView:view didFinishLoadForFrame:frame];
}
// }}}
// webView:didReceiveTitle:forFrame: (3.2+) {{{
static void $UIWebViewWebViewDelegate$webView$didReceiveTitle$forFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSString *title, WebFrame *frame) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:didReceiveTitle:forFrame:)])
[uiWebView webView:view didReceiveTitle:title forFrame:frame];
}
- (void) webView:(WebView *)view didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didReceiveTitle:forFrame:)])
[delegate webView:view didReceiveTitle:title forFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didReceiveTitle:forFrame:)])
[super webView:view didReceiveTitle:title forFrame:frame];
}
// }}}
// webView:didStartProvisionalLoadForFrame: (2.0+) {{{
- (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webView:didStartProvisionalLoadForFrame:)])
[delegate webView:view didStartProvisionalLoadForFrame:frame];
if ([UIWebView instancesRespondToSelector:@selector(webView:didStartProvisionalLoadForFrame:)])
[super webView:view didStartProvisionalLoadForFrame:frame];
}
// }}}
// webView:resource:didCancelAuthenticationChallenge:fromDataSource: {{{
- (void) webView:(WebView *)view resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView respondsToSelector:@selector(webView:resource:didCancelAuthenticationChallenge:fromDataSource:)])
[super webView:view resource:identifier didCancelAuthenticationChallenge:challenge fromDataSource:source];
if ([delegate respondsToSelector:@selector(webView:resource:didCancelAuthenticationChallenge:fromDataSource:)])
[delegate webView:view resource:identifier didCancelAuthenticationChallenge:challenge fromDataSource:source];
}
// }}}
// webView:resource:didReceiveAuthenticationChallenge:fromDataSource: {{{
- (void) webView:(WebView *)view resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView respondsToSelector:@selector(webView:resource:didReceiveAuthenticationChallenge:fromDataSource:)])
[super webView:view resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
if ([delegate respondsToSelector:@selector(webView:resource:didReceiveAuthenticationChallenge:fromDataSource:)])
[delegate webView:view resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
}
// }}}
// webView:resource:willSendRequest:redirectResponse:fromDataSource: (3.2+) {{{
static NSURLRequest *$UIWebViewWebViewDelegate$webView$resource$willSendRequest$redirectResponse$fromDataSource$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, id identifier, NSURLRequest *request, NSURLResponse *response, WebDataSource *source) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:)])
request = [uiWebView webView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
return request;
}
- (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:)])
request = [super webView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
if ([delegate respondsToSelector:@selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:)])
request = [delegate webView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
return request;
}
// }}}
// webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource: {{{
- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)])
request = [super webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
if ([delegate respondsToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)])
request = [delegate webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
return request;
}
// }}}
// webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame: (2.1+) {{{
- (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
[[self retain] autorelease];
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:)])
if (
![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptAlertPanelWithMessage:initiatedByFrame:)] ||
[delegate webView:view shouldRunJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame]
)
[super webView:view runJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame];
}
// }}}
// webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame: (2.1+) {{{
- (BOOL) webView:(WebView *)view runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
[[self retain] autorelease];
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:)])
if (
![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptConfirmPanelWithMessage:initiatedByFrame:)] ||
[delegate webView:view shouldRunJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame]
)
return [super webView:view runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame];
return NO;
}
// }}}
// webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame: (2.1+) {{{
- (NSString *) webView:(WebView *)view runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame {
[[self retain] autorelease];
id<CyteWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:)])
if (
![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:)] ||
[delegate webView:view shouldRunJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame]
)
return [super webView:view runJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame];
return nil;
}
// }}}
// webViewClose: (3.2+) {{{
static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view) {
UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
if ([uiWebView respondsToSelector:@selector(webViewClose:)])
[uiWebView webViewClose:view];
}
- (void) webViewClose:(WebView *)view {
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webViewClose:)])
[delegate webViewClose:view];
if ([UIWebView instancesRespondToSelector:@selector(webViewClose:)])
[super webViewClose:view];
}
// }}}
- (void) _updateViewSettings {
[super _updateViewSettings];
id<CyteWebViewDelegate> delegate([self delegate]);
if ([delegate respondsToSelector:@selector(webViewUpdateViewSettings:)])
[delegate webViewUpdateViewSettings:self];
}
- (void) dispatchEvent:(NSString *)event {
[[self _documentView] dispatchEvent:event];
}
- (void) reloadFromOrigin {
[[[self _documentView] webView] reloadFromOrigin:nil];
}
- (UIScrollView *) scrollView {
if ([self respondsToSelector:@selector(_scrollView)])
return [self _scrollView];
else if ([self respondsToSelector:@selector(_scroller)])
return (UIScrollView *) [self _scroller];
else return nil;
}
- (void) setNeedsLayout {
[super setNeedsLayout];
WebFrame *frame([[[self _documentView] webView] mainFrame]);
if ([frame respondsToSelector:@selector(setNeedsLayout)])
[frame setNeedsLayout];
}
- (NSURLRequest *) request {
WebFrame *frame([[[self _documentView] webView] mainFrame]);
return [([frame provisionalDataSource] ?: [frame dataSource]) request];
}
@end
static void $UIWebViewWebViewDelegate$_clearUIWebView(UIWebViewWebViewDelegate *self, SEL sel) {
MSHookIvar<UIWebView *>(self, "uiWebView") = nil;
}
static BOOL $WAKView$canBecomeFocused(id self) {
return true;
}
static id $WAKView$parentFocusEnvironment(id self) {
return nil;
}
__attribute__((__constructor__)) static void $() {
if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) {
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:addMessageToConsole:), (IMP) &$UIWebViewWebViewDelegate$webView$addMessageToConsole$, "v16@0:4@8@12");
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:), (IMP) &$UIWebViewWebViewDelegate$webView$decidePolicyForNewWindowAction$request$newFrameName$decisionListener$, "v28@0:4@8@12@16@20@24");
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didClearWindowObject:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$, "v20@0:4@8@12@16");
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didCommitLoadForFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didCommitLoadForFrame$, "v16@0:4@8@12");
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didReceiveTitle:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didReceiveTitle$forFrame$, "v20@0:4@8@12@16");
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:), (IMP) &$UIWebViewWebViewDelegate$webView$resource$willSendRequest$redirectResponse$fromDataSource$, "@28@0:4@8@12@16@20@24");
class_addMethod($UIWebViewWebViewDelegate, @selector(webViewClose:), (IMP) &$UIWebViewWebViewDelegate$webViewClose$, "v12@0:4@8");
class_addMethod($UIWebViewWebViewDelegate, @selector(_clearUIWebView), (IMP) &$UIWebViewWebViewDelegate$_clearUIWebView, "v8@0:4");
}
if (Class $WAKView = objc_getClass("WAKView")) {
// iOS13 Crashes calling this for unknown reasons when Accessibility->Keyboards->Full Keybaord Access is enabled
class_addMethod($WAKView, @selector(canBecomeFocused), (IMP) &$WAKView$canBecomeFocused, "c@");
class_addMethod($WAKView, @selector(parentFocusEnvironment), (IMP) &$WAKView$parentFocusEnvironment, "@@");
}
}
@implementation UIWebDocumentView (Cydia)
- (void) _setScrollerOffset:(CGPoint)offset {
UIScroller *scroller([self _scroller]);
CGSize size([scroller contentSize]);
CGSize bounds([scroller bounds].size);
CGPoint max;
max.x = size.width - bounds.width;
max.y = size.height - bounds.height;
// wtf Apple?!
if (max.x < 0)
max.x = 0;
if (max.y < 0)
max.y = 0;
offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
[scroller setOffset:offset];
}
@end
|